/************************************************************************!
*
* ADOBE CONFIDENTIAL
* ___________________
*
* Copyright 2015-2020 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 i(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)i.d(n,o,function(t){return e[t]}.bind(null,o));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=64)}([function(e,t,i){var n=i(2),o=["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","WHITELISTED_DOMAINS","CLIENT_DESCRIPTION","DEVICE_ID","DEVICE_DESCRIPTION","APP_DESCRIPTION","DEFAULT_RENDITION_404_BACKOFF","LOCAL_SETTINGS"];function r(){this.name="config"}r.prototype.VERSION=1,r.prototype.MAX_ELEMENTS=1e4,r.prototype.MAX_REMOVED_ELEMENTS=2e3,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.SOURCE_REF_KEY=r.prototype.DL_PREFIX+"sourceRef",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.LINK_LOCAL_PATH_KEY=r.prototype.DL_PREFIX+"linklocalpath",r.prototype.REPRESENTATION_ORDER_KEY=r.prototype.DL_PREFIX+"representationOrder",r.prototype.RENDITION_TYPE_KEY=r.prototype.DL_PREFIX+"renditiontype",r.prototype.SHA_KEY=r.prototype.DL_PREFIX+"sha256",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_ENABLED=!1,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.MAX_RECOVERED_LIBRARIES=10,r.prototype.ELMO_LOCAL_LIBRARY_LIMIT=2e4,r.prototype.ELMO_SERVER_RECOVERED_LIMIT=100,r.prototype.ADOBE_AUTHENTICATED_DOMAINS=["stock.adobe.com","stock.stage.adobe.com","adobe.io","adobestock.com","fotolia.net"],r.prototype.WHITELISTED_DOMAINS=["cclibraries-defaults-cdn.adobe.com","cclibraries-defaults-cdn.stage.adobe.com"],r.prototype.DISALLOWED_DOMAINS={"cc-api-storage-stage.adobe.io":["stock.adobe.com"],"cc-api-storage.adobe.io":["stock.stage.adobe.com"]},r.prototype.SHA_CACHE={},r.prototype.DEFAULT_CONTENT_LOCATIONS=[],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=16,r.prototype.SHARED_LOCAL_STORAGE_MIN_CLIENT_VERSION=6,r.prototype.SHARED_LOCAL_STORAGE_MAX_CLIENT_VERSION=16,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.TOOLKIT_NAMESPACE="toolkit",r.prototype.TOOLKIT_ID_KEY="id",r.prototype.RELATIONSHIP_CHILD="child",r.prototype.TLS_DISCOVERY_PORT_RANGE=[45623,45625],r.prototype.TLS_DELAY_ON_DECLINE=500,r.prototype.TLS_DELAY_ON_READY=250,r.prototype.setParameter=function(e,t){if(-1===o.indexOf(e))throw new n(n.INVALID_PARAMETER,"Parameter not configurable");if("SYNC_POLICY"===e&&-1===this.VALID_SYNC_POLICIES.indexOf(t))throw new n(n.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,i){var n=i(35);function o(){this.uuid=i(49),this.fs=i(19),this.crypto=i(41),this.path=i(12),this.imageSize=i(70),this.yazl=i(54),this.yauzl=i(55),this._initDCX()}o.prototype._initDCX=function(){this.dcx=new n(this.fs,{preserveFileExtensions:!0,logCallback:e=>this._log&&this._log("DCX: "+e)})},o.prototype.uuid=function(){return this.uuid()},o.prototype.log=function(e){this._log&&this._log("CC Libraries: "+e)},o.prototype.getDisplayName=function(e){return this._getDisplayName?this._getDisplayName(e):e.name},o.prototype.hasFileSystem=function(){return void 0!==this.fs},o.prototype.setFileSystem=function(e){this.fs=e,this._initDCX()},o.prototype.hasRenditionGenerator=function(){return void 0!==this.renditionGenerator},o.prototype.setRenditionGenerator=function(e){this.renditionGenerator=e},o.prototype.getVulcanInterface=function(){if("undefined"!==typeof VulcanInterface)return VulcanInterface},o.prototype.getVulcanMessage=function(){if("undefined"!==typeof VulcanMessage)return VulcanMessage},o.prototype.hasCEPVulcan=function(){return void 0!==this.getVulcanInterface()&&void 0!==this.getVulcanMessage()},o.prototype.getNodeTunnelOptions=function(e){return this._getNodeTunnelOptions?this._getNodeTunnelOptions(e):{}},o.prototype.getPathSeparator=function(){return"/"},o.prototype.getFileNameFromPath=function(e){return-1===e.indexOf("/")&&-1!==e.indexOf("\\")&&(e=e.replace(/\\/g,"/")),e.split("/").pop()},Object.freeze(o),Object.seal(o.prototype),e.exports=new o},function(e,t){var i=["INVALID_PARAMETER","READ_ONLY","NOT_IMPLEMENTED","NOT_SUPPORTED","REQUIRES_FILESYSTEM","DELETED_LOCALLY"];function n(e,t,o,r){if(-1!==i.indexOf(e))if(Error.call(this),Error.captureStackTrace)Error.captureStackTrace(this,n);else{var a=new Error;a.name=this.name,this.stack=a.stack}this.code=e,this._message=t,this.message="["+e+"] "+t,this.libraryId=o,this.underlyingError=r}n.prototype=Object.create(Error.prototype),n.prototype.name="AdobeLibraryError",n.INVALID_PARAMETER="INVALID_PARAMETER",n.READ_ONLY="READ_ONLY",n.NOT_IMPLEMENTED="NOT_IMPLEMENTED",n.NOT_SUPPORTED="NOT_SUPPORTED",n.REQUIRES_FILESYSTEM="REQUIRES_FILESYSTEM",n.DELETED_LOCALLY="DELETED_LOCALLY",n.NOT_ALLOWED="NOT_ALLOWED",n.FILE_TOO_LARGE="FILE_TOO_LARGE",n.EXCEEDS_MAX_LIBRARY_SIZE="EXCEEDS_MAX_LIBRARY_SIZE",n.CORRUPTED_LIBRARY="CORRUPTED_LIBRARY",n.THUMBNAIL_NOT_AVAILABLE="THUMBNAIL_NOT_AVAILABLE",n.STALE_THUMBNAIL="STALE_THUMBNAIL",n.RENDITION_NOT_AVAILABLE="RENDITION_NOT_AVAILABLE",n.FS_ERROR="FS_ERROR",n.OUT_OF_SPACE="OUT_OF_SPACE",n.LOGGED_OUT="LOGGED_OUT",n.EXCEEDS_QUOTA="EXCEEDS_QUOTA",n.RETRYABLE_SERVER_ERROR="RETRYABLE_SERVER_ERROR",n.TRANSFER_ERROR="TRANSFER_ERROR",n.TRANSFER_ABORTED="TRANSFER_ABORTED",n.NETWORK_ERROR="NETWORK_ERROR",n.ACCESS_DENIED="ACCESS_DENIED",n.URL_VALIDATION_FAILED="URL_VALIDATION_FAILED",n.NO_COMPATIBLE_APP_FOUND="NO_COMPATIBLE_APP_FOUND",n.APP_LAUNCH_FAILED="APP_LAUNCH_FAILED",n.OPERATION_CANCELLED="OPERATION_CANCELLED",n.INVALID_DATA="INVALID_DATA",Object.freeze(n),Object.seal(n.prototype),e.exports=n},function(e,t,i){var n=i(19),o=i(39),r=i(1),a=i(0);var s,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,ANALYTICS_STATE_REQUEST_TIMEOUT:2e3,ANALYTICS_STATE_REQUEST_RETRY_INTERVAL:5e3,ANALYTICS_STATE_REQUEST_MAX_RETRIES:2,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,FONT_WATCH_DEBOUNCE:1e3,FONT_WATCH_ERROR_DEBOUNCE_MIN:1e4,FONT_WATCH_ERROR_DEBOUNCE_MAX:3e5,FONT_WATCH_RESET:50,CDN_CACHE_ROOT:"/v1/",CDN_CACHE_FILE:"contents.json",CDN_REFRESH_INTERVAL:864e5,CDN_RETRY_INTERVAL:18e5,REST_API_VERSION:5,REST_API_MIN_VERSION:2,REST_API_MAX_VERSION:5,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","application/vnd.adobe.element.component+dcx","application/vnd.adobe.element.audio+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",ACP_CS_HOST:"platform-cs-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",CC_LIBRARY_SERVICE_HOST:"ccx-melville-stage.adobe.io",SHA_CDN_HOST:"cclibraries-defaults-cdn.stage.adobe.com"},production:{LABEL:"Production",CLIENT_ID:"ProjectCentral16",CLIENT_SECRET:"1ba6923b-fc3d-4114-a506-f3bc5b34093a",STORAGE_HOST:"cc-api-storage.adobe.io",ACP_CS_HOST:"platform-cs.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",CC_LIBRARY_SERVICE_HOST:"libraries.adobe.io",SHA_CDN_HOST:"cclibraries-defaults-cdn.adobe.com"}};var d={SETTINGS_FILE_VERSION:c.SETTINGS_FILE_VERSION};function p(){var e=JSON.stringify(d,void 0,2);if(e===s)return!1;try{var t=c.SETTINGS_FILE+".TEMP_"+r.uuid();n.writeFileSync(c.ROOT_DIR+t,e),n.renameSync(c.ROOT_DIR+t,c.ROOT_DIR+c.SETTINGS_FILE),s=e}catch(e){}return!0}var h={};h._init=function(){if(h.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/",c.FONT_DIRS=[process.env.WINDIR.replace(/\\/g,"/")+"/Fonts",e+"/AppData/Roaming/Adobe/CoreSync/plugins/livetype/r"];var t=(process.env["ProgramFiles(x86)"]||process.env.PROGRAMFILES).replace(/\\/g,"/");c.CC_DIR=`${t}/Adobe/Adobe Creative Cloud/`,c.DEFAULT_CONTENT_LOCATIONS=[`${t}/Adobe/Adobe Photoshop CC 2020/Required/`],c.FIREFOX_DIR=e+"/AppData/Roaming/Mozilla/Firefox/Profiles"}else c.ROOT_DIR=process.env.HOME+"/Library/Application Support/",c.LOG_DIR=process.env.HOME+"/Library/Logs/CreativeCloud/Creative Cloud Libraries/",c.FONT_DIRS=["/System/Library/Fonts","/Library/Fonts",process.env.HOME+"/Library/Fonts",process.env.HOME+"/Library/Application Support/Adobe/CoreSync/plugins/livetype/.r"],c.CC_DIR="/Applications/Utilities/Adobe Creative Cloud/",c.DEFAULT_CONTENT_LOCATIONS=["/Applications/Adobe Photoshop 2020/Adobe Photoshop 2020/Contents/Required/"],c.FIREFOX_DIR=process.env.HOME+"/Library/Application Support/Firefox/Profiles";c.ROOT_DIR+="Adobe/Creative Cloud Libraries/LIBS/",function(){try{s=n.readFileSync(c.ROOT_DIR+c.SETTINGS_FILE,"utf8");var e=JSON.parse(s);d.SETTINGS_FILE_VERSION===e.SETTINGS_FILE_VERSION&&(d=e)}catch(e){}}(),function(){var e=!1;try{var t=n.readFileSync(c.CC_DIR+c.CC_SETTINGS_FILE,"utf8");new o.Parser({async:!1}).parseString(t,function(t,i){t||i.C3Config.config[0].namespace.forEach(t=>{t&&t.$&&t.$.name&&"accc.container"===t.$.name&&t.property.forEach(t=>{t&&t.$&&t.$.name&&"IMS_ENV"===t.$.name&&"STG"===t._&&(e=!0)})})})}catch(e){}return e}()&&(c.ENVIRONMENT="staging"),process.argv.forEach(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`),d.DISABLE_CERTIFICATE_CHECK&&(console.warn("Disabling Certificate Check"),process.env.NODE_TLS_REJECT_UNAUTHORIZED=0),"number"==typeof d.MAX_ELEMENTS&&(a.MAX_ELEMENTS=d.MAX_ELEMENTS)},h.isPlatformWindows=function(){return 0===process.platform.indexOf("win")},h.getValue=function(e){return void 0!==d[e]?d[e]:c[e]},h.setValue=function(e,t){return d[e]=t,p()},h.getEnvironment=function(){var e=h.getValue("ENVIRONMENT");return l[e]||l[c.ENVIRONMENT]},h._getValidWSSTokens=function(){const e=(new Date).getTime();return(d.WSS_TOKENS||[]).filter(t=>t.expiry>e)},h.addWSSToken=function(e){const t=h._getValidWSSTokens();return t.push({value:e,expiry:(new Date).getTime()+15768e6}),d.WSS_TOKENS=t,p()},h.isWSSTokenValid=function(e){return h._getValidWSSTokens().some(t=>t.value===e)},h._init(),e.exports=h},function(e,t){function i(e,t,n){if(Error.call(this),Error.captureStackTrace)Error.captureStackTrace(this,i);else{var o=new Error;o.name=this.name,this.stack=o.stack}this.code=e,this.message="["+e+"] "+t,this.underlyingError=n}i.prototype=Object.create(Error.prototype),i.prototype.name="AdobeDCXError",i.INVALID_JSON="INVALID_JSON",i.READ_ONLY="READ_ONLY",i.INVALID_PARAMS="",i.INVALID_DATA="INVALID_DATA",i.DUPLICATE_VALUE="DUPLICATE_VALUE",i.NO_LOCAL_STORAGE="NO_LOCAL_STORAGE",i.INVALID_STATE="INVALID_STATE",i.DELETED_COMPOSITE="DELETED_COMPOSITE",i.UNEXPECTED_RESPONSE="UNEXPECTED_RESPONSE",i.NETWORK_ERROR="NETWORK_ERROR",i.COMPONENT_DOWNLOAD_ERROR="COMPONENT_DOWNLOAD_ERROR",i.COMPONENT_UPLOAD_ERROR="COMPONENT_UPLOAD_ERROR",i.COMPONENT_MODIFIED_ERROR="COMPONENT_MODIFIED_ERROR",i.UPDATE_CONFLICT="UPDATE_CONFLICT",i.NO_COMPOSITE="NO_COMPOSITE",i.ALREADY_EXISTS="ALREADY_EXISTS",i.SERVICE_IS_INACTIVE="SERVICE_IS_INACTIVE",i.EXCEEDS_QUOTA="EXCEEDS_QUOTA",i.NOT_IMPLEMENTED="NOT_IMPLEMENTED",i.RETRYABLE_SERVER_ERROR="RETRYABLE_SERVER_ERROR",i.TIMED_OUT="TIMED_OUT",i.UNEXPECTED="UNEXPECTED",i.TERMINATED_INPUTSTREAM="TERMINATED_INPUTSTREAM",i.WRONG_ENDPOINT="WRONG_ENDPOINT",i.OUT_OF_SPACE="ENOSPC";var n={};n[i.SERVICE_IS_INACTIVE]=1,n[i.NOT_IMPLEMENTED]=1,n[i.EXCEEDS_QUOTA]=1,n[i.RETRYABLE_SERVER_ERROR]=1,n[i.TIMED_OUT]=1,n[i.TERMINATED_INPUTSTREAM]=1,n[i.WRONG_ENDPOINT]=1,n[i.OUT_OF_SPACE]=1,i.wrapError=function(e,t,o,r){if(!o||!n[o.code]){if(r){var a=r.statusCode;a>=500&&a<600&&(501===a?(e=i.NOT_IMPLEMENTED,t="Unimplemented request"):507===a?(e=i.EXCEEDS_QUOTA,t="Quota exceeded"):(e=i.RETRYABLE_SERVER_ERROR,t="Server error"))}o=new i(e,t,o)}return r&&(o.response=r),o},i.networkError=function(e,t,n){return i.wrapError(i.NETWORK_ERROR,e,t,n)},i.unexpectedResponse=function(e,t,n){return i.wrapError(i.UNEXPECTED_RESPONSE,e,t,n)},e.exports=i},function(e,t,i){const n=i(1),o=i(2);e.exports=class{constructor(e){this._restrictedTypes=e,this._listeners={}}_checkType(e){if(this._restrictedTypes&&!this._restrictedTypes.includes(e)){const t=`${e} is not allowed. Should be one of: [${this._restrictedTypes.join(", ")}]`;throw new o(o.INVALID_PARAMETER,t)}}add(e,t){this._checkType(e),this._listeners[e]=this._listeners[e]||[],this._listeners[e].push(t)}remove(e,t){this._checkType(e);const i=this._listeners[e],n=i?i.indexOf(t):-1;-1!==n&&i.splice(n,1)}removeAll(e){e?(this._checkType(e),delete this._listeners[e]):this._listeners={}}notify(e,t){this._checkType(e);const i=this._listeners[e];i&&i.slice().forEach(e=>{try{e.apply(void 0,t||[])}catch(e){n.log("Error in listener callback: "+(e?e.toString():"")),e&&e.stack&&n.log(e.stack)}})}hasListeners(e){return this._checkType(e),(this._listeners[e]||[]).length>0}forEach(e){const t=this._listeners;Object.keys(t).forEach(i=>{t[i].forEach(t=>e(i,t))})}}},function(e,t,i){var n,o=i(19),r=i(3),a=i(5),s=i(7),c=r.getValue("LOG_DIR")+"CC Library Process.log",l=r.getValue("LOG_DIR")+"CC Library Process (prev).log",d=!1,p=new a(["logWrite"]),h=!1;function _(e,t,i){o.exists(t,function(n){o.exists(e,function(r){r&&!n?o.rename(e,t,i):i(null)})})}function u(e){!function(e){if(h)e(null);else{h=!0;var t=r.getValue("LOG_DIR")+"log.txt";_(r.getValue("LOG_DIR")+"log_prev.txt",l,function(){_(t,c,e)})}}(function(){o.stat(c,function(t,i){!t&&i.size>r.getValue("MAX_LOG_SIZE")?o.rename(c,l,e):e(null)})})}var f={};f.log=function(){var e=Array.prototype.slice.call(arguments).join(": ");r.getValue("CONSOLE_LOGGING")&&console.log(e);var t=(new Date).toString()+" "+e+"\n";n?n+=t:(n=t,d||function e(){s.ensurePathExists(r.getValue("LOG_DIR"),function(t){if(t)return n=void 0,void console.error(t);u(function(t){if(t)return n=void 0,void console.error(t);var i=n;n=void 0,d=!0,o.appendFile(c,i,function(t){t&&console.error(t),d=!1,n&&e(),p.notify("logWrite")})})})}())},f.addLogWriteListener=function(e){p.add("logWrite",e)},f.removeLogWriteListener=function(e){p.remove("logWrite",e)},f._listenerManager=p,e.exports=f},function(e,t,i){var n=i(1),o=i(11),r=i(0),a=i(2),s=["bmp","cur","gif","ico","jpeg","jpg","png","psd","tiff","tif","webp","svg","dds"],c={},l=function(e){return e+".TEMP_"+n.uuid()};const d=function(e,...t){const i=n.fs,o=t.find(e=>"function"==typeof e),a=t.slice(0,t.indexOf(o)),s=t.indexOf(o)===t.length-1?0:t[t.length-1];i[e].apply(i,a.concat((t,...i)=>{t&&"EPERM"===t.code&&s<r.FS_MAX_RETRIES?setTimeout(function(){d(e,...a,o,s+1)},r.FS_RETRY_INTERVAL):o(t,...i)}))};c.ensurePathExists=function(e,t){var i=n.getPathSeparator(),o=n.fs;!function e(t,n,r){var a=n.slice(0,t).join(i),s=function(){t<n.length?e(t+1,n,r):r(null)};o.exists(a,function(e){e?s():o.mkdir(a,s)})}(2,e.replace(/\\/g,i).split(i),t)},c.copyFile=function(e,t,i){var o=n.fs;try{var r=l(t),a=o.createWriteStream(r),s=o.createReadStream(e),c=!1;s.on("end",function(){c||d("rename",r,t,i)}),s.on("error",function(e){c=!0,i(e)}),s.pipe(a)}catch(e){i(e)}},c.getAvailablePath=function(e,t,i,n=0){let o=t.lastIndexOf(".");o=-1===o?t.length:o;const r=t.substring(0,o),a=t.substring(o+1),s=`${n?` (${n})`:""}${a?`.${a}`:""}`,d=255-l("").length-s.length;let p=r.substr(0,d);p[p.length-1].charCodeAt(0)>=55296&&p[p.length-1].charCodeAt(0)<=56319&&(p=p.substr(0,p.length-1));const h=`${e}${p}${s}`;c.statFile(h,function(o){o&&o.underlyingError&&"ENOENT"===o.underlyingError.code?i(null,h):o?i(o):c.getAvailablePath(e,t,i,n+1)})},c.rename=function(e,t,i){d("rename",e,t,i)},c.deleteFile=function(e,t){d("unlink",e,t)},c.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)},c.getFileExtension=function(e){var t=e&&e.replace(/^.*[\\/]/,""),i=t?t.lastIndexOf("."):-1;if(-1!==i)return t.substr(i+1).toLowerCase()},c.recursiveDeleteDirectory=function(e,t){var i=n.getPathSeparator(),o=n.fs,r=function(e){e&&"ENOENT"===e.code&&(e=null),t&&t(e)};d("readdir",e,function(t,n){if(t)r(t);else if(n&&0!==n.length){var a=null,s=0;n.forEach(t=>{var n=e+i+t;d("readdir",n,function(e){e?o.unlink(n,l):c.recursiveDeleteDirectory(n,l)})})}else o.rmdir(e,r);function l(t){t&&"ENOENT"===t.code&&(t=null),a=a||t,++s===n.length&&(a?r(a):o.rmdir(e,r))}})},c.getUserDir=function(e){const t=n.getPathSeparator(),i=e.replace(/@/g,"_");return r.ROOT_DIR+t+i},c.moveLibrary=function(e,t,i){if(t!==e.id){var n=e._collection._getCompositeDir(t),o=e._getCompositeDir(),r=e._collection._getRenditionCacheDir(t),a=e._getRenditionCacheDir();c.rename(n,o,function(t){t?i(t):(e._dcxComposite.path=o,c.rename(r,a,e=>i(e&&"ENOENT"===e.code?null:e)))})}else i(null)},c.readLibraryDirectory=function(e,t){var i=e._getTempDir();c.recursiveDeleteDirectory(i,function(){var i=e._getCompositeDir();d("readdir",i,t)})},c.doesRootDirExist=function(e,t){var i=n.fs,o=e._getCompositeDir();i.exists(o,function(e){t(null,e)})},c.deleteLibraryFromDisk=function(e,t,i=(()=>void 0)){if(n.hasFileSystem()){var o=e._getCompositeDir(t),r=e._getRenditionCacheDir(t);c.recursiveDeleteDirectory(o,function(){c.recursiveDeleteDirectory(r,i)})}else i(null)},c.writeJSONData=function(e,t,i){const o=n.fs;return new Promise((r,a)=>{c.ensurePathExists(e,s=>{if(s)return void a(s);const c=e+n.getPathSeparator()+t,l=c+".TEMP_"+n.uuid();o.writeFile(l,JSON.stringify(i,void 0,2),"utf8",e=>{e?a(e):d("rename",l,c,e=>e?a(e):r(c))})})})},c.readJSONData=function(e){const t=n.fs;return new Promise((i,n)=>{t.readFile(e,"utf8",function(e,t){if(e)"ENOENT"===e.code?i():n(e);else try{const o=t&&JSON.parse(t);i("object"==typeof o?o:void 0)}catch(e){n(e)}})})},c.statFile=function(e,t){n.fs.stat(e,function(e,i){e?t(o.getFileSystemError(e,"unable to stat file")):t(null,i)})},c.checkFileSize=function(e,t){c.statFile(e,function(e,i){e?t(e):i&&i.size>r.MAX_COMPONENT_SIZE?t(new a(a.FILE_TOO_LARGE,"Exceeds maximum file size")):t(null)})},c.computeSHA=function(e){const t=n.fs,i=n.crypto;return new Promise((n,o)=>{const r=i.createHash("sha256");r.setEncoding("hex");const a=t.createReadStream(e);a.on("error",e=>o(e)),r.on("finish",()=>n(r.read())),a.pipe(r)})},c.getImageDimensions=function(e,t){var i=c.getFileExtension(e);!i||s.includes(i)?r.SHARED_LOCAL_STORAGE?n.storageInterface.getImageDimensions(e,t):n.imageSize(e,function(e,i){t(i)}):t()},Object.seal(c),e.exports=c},function(e,t,i){var n,o;n=i(49);var r={_setLogCallback:function(e){o=e},merge:function(e){var t,i;for(t=1;t<arguments.length;++t){var n=arguments[t];if("object"==typeof n)for(i in n)n.hasOwnProperty(i)&&(e[i]=n[i])}return e},parentDirectory:function(e){var t=e.split("/");return t.pop(),t.join("/")},filePathComponents:function(e){var t=e.split("/"),i=t.pop(),n=i.split("."),o=n.length>1?n.pop():null;return{directory:t.join("/"),fileName:i,baseName:n.join("."),extension:o}},appendPathElements:function(){var e,t=[],i=arguments.length;for(e=0;e<i;e++){var n=arguments[e];"string"==typeof n&&""!==n&&(0===e&&1!==n.length||"/"===n.charAt(0)&&(n=n.slice(1)),e!==i-1&&"/"===n.charAt(n.length-1)&&(n=n.slice(0,n.length-1)),t.push(n))}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 i=(t?e.slice(1):e).split("/");if(!i||0===i.length)return!1;var n,o=i.length;for(n=0;n<o;n++){if(i[n].length>255||!a.test(i[n]))return!1}if(t&&i.length>0){var r=i[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,i){e.on("data",i||s),e.on("end",t||s)},r.flatCopy=function(e){var t,i={},n=Object.keys(e),o=n.length;for(t=0;t<o;t++){var r=n[t];i[r]=e[r]}return i},r.deepCopy=function(e){return JSON.parse(JSON.stringify(e))},r.objectsEqual=function(e,t,i){var n,o,a={},s=Object.keys(e),c=s.length;for(o=0;o<c;o++){if(n=s[o],!i||!i[n]){var l=e[n],d=t[n],p=typeof l;if(p!==typeof d)return!1;if("object"===p){if(!r.objectsEqual(l,d,i))return!1}else if(l!==d)return!1}a[n]=!0}for(c=(s=Object.keys(t)).length,o=0;o<c;o++)if(!a[n=s[o]])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,i=r.parseURI(e),n=i.scheme,o=i.authority,a="https"===n?443:"http"===n?80:-1;return n&&o&&(t=(n+"://"+o).toLowerCase(),a>=0&&o.indexOf(":")<0&&(t=t+":"+a)),t},r.ensureRelativeHrefStartsWithSlash=function(e){if(e){var t=r.parseURI(e),i=t.scheme,n=t.authority;i||n||"/"!==e.charAt(0)&&(e="/"+e)}return e};var l=/^([^:]+):(.*)$/,d=/^\s+|\s+$/g;r.parseHeaders=function(e){var t,i,n,o={},r=e.split(/\r?\n/);for(t=0;t<r.length;++t){var a=r[t];if(a.length>0){var s=a.charCodeAt(0);if(!i||9!==s&&32!==s){var c=l.exec(a);c&&c.length>1&&(i=c[1].toLowerCase(),n=(n=c[2]||"").replace(d,""),o[i]?o[i]=o[i]+","+n:o[i]=n)}else o[i]=o[i]+" "+a.replace(d,"")}}return o},r.timeStamp=function(e){var t=(new Date).getTime();return e&&(t-=t%1e3),t},r.generateUuid=n,r.log=function(e){if("function"==typeof o)try{o(e)}catch(e){}},e.exports=r},function(e,t,i){var n=i(1),o=i(0),r=i(56),a=i(61),s=i(109),c=i(2),l=i(18),d=i(110),p=i(113),h=i(114),_=i(7),u=i(15),f=new s,m={};function E(e,t,i){var n=e+"/"+t,o=void 0!==m[n];return m[n]=m[n]||[],m[n].push(i),o}function g(e,t){var i;i=e===o.PUBLIC_USER_ID?f.getPublicLibraryCollection(t):f.getLibraryCollection(e,t);var n=e+"/"+t,r=m[n];r&&(delete m[n],r.forEach(function(e){e(null,i)}))}var y={configure:function(e,t){if(n.hasFileSystem()||void 0!==t.SHARED_LOCAL_STORAGE||(t.SHARED_LOCAL_STORAGE=!1),n.hasFileSystem()&&!t.ROOT_DIR&&!1===t.SHARED_LOCAL_STORAGE)throw new c(c.INVALID_PARAMETER,"Missing ROOT_DIR option");if(n.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(!n.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&&!n.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){o.setParameter(e,t[e])}),n.analytics=e.analytics,n.vulcanCall=e.vulcanCall,n._log=e.log,n._getDisplayName=e.getDisplayName,n._getNodeTunnelOptions=e.getNodeTunnelOptions,e.renditionGenerator&&n.setRenditionGenerator(e.renditionGenerator),n.storageInterface&&n.storageInterface.shutdown(),n.storageInterface=new d(f),n.log("Configure: "+(o.SHARED_LOCAL_STORAGE?"<shared local storage>":o.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);o.setParameter(e,t),n.storageInterface.updateConfiguration()},getOption:function(e){return o[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")}o.LOCAL_SETTINGS[e]=t,n.storageInterface.updateConfiguration()},getLocalSetting:function(e){return o.LOCAL_SETTINGS[e]},getSNISettings:function(){return{TLS_DISCOVERY_PORT_RANGE:o.TLS_DISCOVERY_PORT_RANGE,TLS_DELAY_ON_DECLINE:2*o.TLS_DELAY_ON_DECLINE,TLS_DELAY_ON_READY:2*o.TLS_DELAY_ON_READY}},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(!n.hasFileSystem())throw new c(c.REQUIRES_FILESYSTEM,"ROOT_DIR option only applies when you have a filesystem");return o.ROOT_DIR},getLocale:function(){return l.getLocale()},unloadLibraryCollection:function(e){if(o.SHARED_LOCAL_STORAGE)throw new c(c.NOT_SUPPORTED,"unloadLibraryCollection() not supported with shared local storage");e.stopPolling(),e._removeAllListeners(),e._abortPushOrPull(!0),f.removeLibraryCollection(e)},loadLibraryCollection:function(e,t){if("function"!=typeof e)if(o.SHARED_LOCAL_STORAGE)t(new c(c.NOT_SUPPORTED,"loadLibraryCollection() not supported with shared local storage"));else if(!n.hasFileSystem()||o.SHARED_LOCAL_STORAGE||o.ROOT_DIR)if(e=e||{},!n.hasFileSystem()||e.USER_ID)if(e.CLOUD_ID=e.CLOUD_ID||o.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 i=f.getLibraryCollection(e.USER_ID,e.CLOUD_ID,e.ROOT_COLLECTION),a=E(e.USER_ID,e.CLOUD_ID,t);if(!i||a){if(!a)if(i=new r(e),n.hasFileSystem())_.doesRootDirExist(i,function(e,t){i._load(function(){t||i._setInitialSyncState(!0),i.sync(function(){i._setInitialSyncState(!1)}),l()})});else if("all"===e.WAIT_FOR)i._setInitialSyncState(!0),i.sync(function(){i._setInitialSyncState(!1),l()});else if(u.validateLibraryId(e.WAIT_FOR,!1)){i._setInitialSyncState(!0,[e.WAIT_FOR]),i.sync(function(){i._setInitialSyncState(!1)});var s=function(){"syncing"===i.syncState&&"pending"===i._libraryIdMap[e.WAIT_FOR]||(i.removeChangeListener(s),i.removeSyncListener(s),l())};i.addChangeListener(s),i.addSyncListener(s)}else i._setInitialSyncState(!0),i.sync(function(){i._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(i),o.AUTO_START_POLLING&&i.startPolling(),g(e.USER_ID,e.CLOUD_ID)}},loadPublicLibraryCollection:function(e,t){if("function"!=typeof e)if(o.SHARED_LOCAL_STORAGE)t(new c(c.NOT_SUPPORTED,"loadPublicLibraryCollection() not supported with shared local storage"));else if(!n.hasFileSystem()||o.SHARED_LOCAL_STORAGE||o.ROOT_DIR)if((e=e||{}).CLOUD_ID=e.CLOUD_ID||o.DEFAULT_CLOUD_ID,e.STORAGE_HOSTNAME){var i=f.getPublicLibraryCollection(e.CLOUD_ID),r=E(o.PUBLIC_USER_ID,e.CLOUD_ID,t);!i||r?r||(i=new a(e),n.hasFileSystem()?i._load(function(){i.sync(),s()}):s()):g(o.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(i),o.AUTO_START_POLLING&&i.startPolling(),g(o.PUBLIC_USER_ID,e.CLOUD_ID)}},isConnected:function(){if(!o.SHARED_LOCAL_STORAGE)throw new c(c.NOT_SUPPORTED,"isConnected() is only applicable if using shared local storage");return n.storageInterface&&n.storageInterface.isConnected()},reconnect:function(){if(!o.SHARED_LOCAL_STORAGE)throw new c(c.NOT_SUPPORTED,"reconnect() is only applicable if using shared local storage");n.storageInterface&&n.storageInterface.reconnect()},disconnect:function(){if(!o.SHARED_LOCAL_STORAGE)throw new c(c.NOT_SUPPORTED,"disconnect() is only applicable if using shared local storage");n.storageInterface&&n.storageInterface.isConnected()&&n.storageInterface.shutdown()},getServiceInfo:function(){if(!o.SHARED_LOCAL_STORAGE)throw new c(c.NOT_SUPPORTED,"getServiceInfo() is only applicable if using shared local storage");return n.storageInterface&&n.storageInterface.getServiceInfo()},isSyncingEnabled:function(){if(o.SHARED_LOCAL_STORAGE){var e=y.getServiceInfo();return!(!e||!e.syncingEnabled)}return o.SYNCING_ENABLED},enableSyncing:function(){o.SHARED_LOCAL_STORAGE?n.storageInterface.setSyncEnabled(!0):(o.SYNCING_ENABLED=!0,y.getLoadedCollections().forEach(e=>e.sync()))},disableSyncing:function(){o.SHARED_LOCAL_STORAGE?n.storageInterface.setSyncEnabled(!1):(o.SYNCING_ENABLED=!1,y.getLoadedCollections().forEach(e=>e._abortPushOrPull()))},getLibraryById:function(e){var t;return y.getLoadedCollections().some(function(i){return t=i.getLibraryById(e)}),t},resolveElementReference:function(e){e=e||"";var t,i=new RegExp("cloud-asset://(.+)/([A-Za-z0-9-]+);node=([A-Za-z0-9-]+)"),n=e.match(i);if(n){var o=n[1],r=n[2],a=n[3];y.getLoadedCollections().every(function(e){if(o===e._syncManager.getElementRefDomainPath()){var i=e.getLibraryById(r);return i&&(t=i.getElementById(a)),!1}return!0})}return t},getAccessToken:function(e,t,i,r,a){o.SHARED_LOCAL_STORAGE?0!==f.getLoadedCollections().length?n.storageInterface.getAccessToken(e,t,i,r,a):a(new c(c.LOGGED_OUT,"User must be logged in to request an access token")):a(new c(c.NOT_SUPPORTED,"getAccessToken() is only supported with shared local storage"))}};y.errors=c,y.utils=p,y.analyticsUtils=h,Object.seal(y),e.exports=y},function(e,t){var i={constructStringFromTemplate:function(e,t){var i=e;return Object.keys(t).forEach(e=>{i=i.replace("{{"+e+"}}",t[e])}),i},parseLocalisationFile:function(e){var t,i,n,o,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(i=(t=s[a].split("="))[0].replace(/^\s\s*/,"").replace(/\s\s*$/,""),n=1===t.length?"":t[1];n.match(/\\$/)&&"\\"===n.match(/\\$/).toString();)n=n.substring(0,n.length-1),n+=s[++a].replace(/\s\s*$/,"");for(o=2;o<t.length;o++)n+="="+t[o];n=n.replace(/^\s\s*/,"").replace(/\s\s*$/,""),r[i]=n}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 i,n,o=e.split("."),r=t.split(".");for(i=0;i<o.length&&i<r.length;i++){if(n=parseInt(o[i],10)-parseInt(r[i],10),isNaN(n))return isNaN(parseInt(o[i],10))?1:-1;if(n>0)return-1;if(n<0)return 1}return(n=o.length-r.length)>0?-1:n<0?1:0},promisify:e=>(...t)=>new Promise((i,n)=>{e(...t,(e,t)=>e?n(e):i(t))})};Object.seal(i),e.exports=i},function(e,t,i){var n=i(4),o=i(2),r={getErrorStatusCode:function(e){if(e){var t=e.code===n.UNEXPECTED_RESPONSE&&e.response&&e.response.statusCode;return t||(e.underlyingError?r.getErrorStatusCode(e.underlyingError):void 0)}},getSyncError:function(e,t,i){if(e){if(e.code===o.TRANSFER_ABORTED)return e;var a=r.getErrorStatusCode(e);return e.code===n.SERVICE_IS_INACTIVE?new o(o.LOGGED_OUT,"no access token: call updateAccessToken() and try again",t,e):e.code===n.NETWORK_ERROR?new o(o.NETWORK_ERROR,"error connecting to server",t,e):e.code===n.EXCEEDS_QUOTA?new o(o.EXCEEDS_QUOTA,"push failed due to insufficient remaining quota",t,e):e.code===n.OUT_OF_SPACE?new o(o.OUT_OF_SPACE,"not enough disk space",t,e):e.code===n.NOT_IMPLEMENTED?new o(o.NOT_IMPLEMENTED,"tried to call an API not implemented on the server",t,e):e.code===n.RETRYABLE_SERVER_ERROR?new o(o.RETRYABLE_SERVER_ERROR,"intermittent server failure - can retry later",t,e):e.code===n.INVALID_DATA||e.code===n.INVALID_JSON?new o(o.CORRUPTED_LIBRARY,"unable to read manifest",t,e):a&&i&&i[a]?new o(i[a],"server returned "+a+"response",t,e):new o(o.TRANSFER_ERROR,"something went wrong during a push/pull operation",t,e)}},getCommitError:function(e,t,i){if(e){var r=i?" - "+i:"";return e.code===n.INVALID_DATA||e.code===n.INVALID_JSON?new o(o.CORRUPTED_LIBRARY,"unable to read manifest"+r,t,e):e.code===n.OUT_OF_SPACE?new o(o.OUT_OF_SPACE,"not enough disk space"+r,t,e):new o(o.FS_ERROR,"filesystem error"+r,t,e)}},getFileSystemError:function(e,t,i){if(e)return"ENOSPC"===e.code?new o(o.OUT_OF_SPACE,t,i,e):new o(o.FS_ERROR,t,i,e)},getSnapshotError:function(e,t,i){if(e)return e.code===n.INVALID_DATA||e.code===n.INVALID_PARAMS?new o(o.INVALID_DATA,i,t,e):r.getFileSystemError(e,i,t)},getErrorPriority:function(e){var t=[o.OPERATION_CANCELLED,o.EXCEEDS_MAX_LIBRARY_SIZE,o.THUMBNAIL_NOT_AVAILABLE,o.RENDITION_NOT_AVAILABLE,o.URL_VALIDATION_FAILED,o.CORRUPTED_LIBRARY,o.TRANSFER_ABORTED,o.TRANSFER_ERROR,o.NETWORK_ERROR,o.EXCEEDS_QUOTA,o.RETRYABLE_SERVER_ERROR,o.LOGGED_OUT,o.FILE_TOO_LARGE,o.INVALID_DATA,o.FS_ERROR,o.OUT_OF_SPACE,o.ACCESS_DENIED,o.NOT_ALLOWED,o.DELETED_LOCALLY,o.REQUIRES_FILESYSTEM,o.NOT_SUPPORTED,o.NOT_IMPLEMENTED,o.INVALID_PARAMETER,o.READ_ONLY],i=e&&e.code&&t.indexOf(e.code);return void 0!==i?i:-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(e=>{var i=e.component&&e.component.id,n=e.error,o=n&&n.message,r=n&&n.response&&n.response.statusCode;t+="\n    ["+i+"] "+o+(r?": "+r:"")}))),t},isErrorCode:function(e){return!!e&&(o.hasOwnProperty(e)&&o[e]===e)}};Object.seal(r),e.exports=r},function(e,t){e.exports=require("path")},function(e,t,i){var n,o,r=i(8);o=i(41);var a={canUseFileSystem:!1,_setFS:function(e){n=e,a.canUseFileSystem=!!e},ensureDirectoryExists:function(e,t){var i=function(e){e&&"EEXIST"===e.code?t():t(e)},o=function(o){if(o)t();else{var s=r.parentDirectory(e);s?a.ensureDirectoryExists(s,function(o){o?t(o):n.mkdir(e,i)}):n.mkdir(e,i)}};e?n.exists(e,o):o(!0)},getTempFilePathAt:function(e,t){var i=function(){var n=e+r.generateUuid();a.exists(n,function(e){e?i():t(n)})};i()},exists:function(e,t){n.exists(e,t)},deleteFile:function(e,t){n.unlink(e,function(e){e&&"ENOENT"!==e.code?t(e):t()})},readFile:function(e,t,i){n.readFile(e,t,i)},writeFile:function(e,t,i,o){var s=r.parentDirectory(e);a.ensureDirectoryExists(s,function(r){r?o(r):n.writeFile(e,t,i,o)})},writeFileAtomically:function(e,t,i,o){var s=r.parentDirectory(e);a.ensureDirectoryExists(s,function(r){r?o(r):a.getTempFilePathAt(s+"/",function(r){n.writeFile(r,t,i,function(t){t?o(t):n.rename(r,e,o)})})})},createWriteStream:function(e,t){return n.createWriteStream(e,t)},createReadStream:function(e,t){return n.createReadStream(e,t)},move:function(e,t,i,o){var s=r.parentDirectory(t);a.ensureDirectoryExists(s,function(r){if(r)o(r);else if(i){var a=(new Date).getTime()/1e3;n.utimes(e,a,a,function(i){i?o(i):n.rename(e,t,o)})}else n.rename(e,t,o)})},info:function(e,t){n.stat(e,t)},directoryListing:function(e,t){var i,o,r=[],a=function(a){n.stat(e+"/"+a,function(e,n){if(!e)try{r.push({name:a,info:n}),i--}catch(t){e=t}e?o||(o=e,t(e)):0===i&&t(void 0,r)})};n.readdir(e,function(e,n){if(!e)try{var o,r=n.length;for(i=r,o=0;o<r;o++)a(n[o])}catch(t){e=t}e?t(e):0===i&&t(void 0,[])})},deleteDirectory:function(e,t){var i,o,r=function(){try{n.rmdir(e,t)}catch(e){t(e)}},s=function(e){e&&!i&&(i=e),--o<1&&(i?t(i):r())},c=function(t){var i=e+"/"+t;n.unlink(i,function(e){try{e?a.deleteDirectory(i,function(e){s(e)}):s()}catch(e){s(e)}})};n.readdir(e,function(e,i){if(!e)try{var n,a=i.length;if(a<1)r();else for(o=a,n=0;n<a;n++)c(i[n])}catch(t){e=t}e&&t(e)})}};a.copyFile=function(e,t,i){var o=r.parentDirectory(t);a.ensureDirectoryExists(o,function(o){o?i(o):function(e,t,i){try{var o=t+r.generateUuid(),a=n.createWriteStream(o),s=n.createReadStream(e);s.on("end",function(){n.rename(o,t,i)}),s.on("error",function(e){i(e)}),s.pipe(a)}catch(e){i(e)}}(e,t,i)})},a.getMD5Hash=function(e,t){const i=o.createHash("md5").setEncoding("base64");try{const o=n.createReadStream(e);o.pipe(i).on("finish",()=>t(null,i.read())),o.on("error",e=>t(e))}catch(e){t(e)}},e.exports=a},function(e,t,i){var n,o,r=i(1),a=i(0);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 i=e.getPrimaryRepresentation();if(i){var n=function(e){var t=null;return e.getValues().forEach(e=>{"trackingdata"===e.key&&(t||(t={}),t[e.namespace]=e.value)}),t}(i);n&&(t.trackingData=JSON.stringify(n)),t.elementPrimaryType=i.type}return t}function l(e,t){if(!e)return{};var i=t?{}:s(e._library);return i.groupID=e.id,i.groupClassifierName=e.classifierName,i}function d(e){if(!e)return{};var t=c(e.element);return t.appCode=e.appCode,t.elementAction=e.id,t}function p(){return null!==r.analytics&&void 0!==r.analytics}var h={reportError:function(e){p()&&e&&r.analytics.reportError(e.code+(e.underlyingError?":"+e.underlyingError.code:""))},reportCreateLibrary:function(e){p()&&r.analytics.reportEvent("createLibrary",{libraryID:e.id})},reportDeleteLibrary:function(e){p()&&r.analytics.reportEvent("deleteLibrary",s(e))},reportExportLibrary:function(e,t){if(p()){var i=t?s(t):{};e&&(i.error=e.code),r.analytics.reportEvent("exportLibrary",i)}},reportImportLibrary:function(e,t){if(p()){var i=t?s(t):{};e&&(i.error=e.code),r.analytics.reportEvent("importLibrary",i)}},reportCreateElement:function(e){p()&&(n=e,o=Date.now(),r.analytics.reportEvent("createElement",c(e)))},reportUpdateElement:function(e,t){if(p()){if(e===n&&Date.now()-o<a.ANALYTICS_ELEMENT_UPDATE_THRESHOLD)return;n=e,o=Date.now();var i=c(e);i.updateType=t?"info":"representation",r.analytics.reportEvent("updateElement",i)}},_reportUpdateElementMetadata:function(e,t,i){if(p()){var n=c(e);n.updateType=t,i&&Object.assign(n,i),r.analytics.reportEvent("updateElementMetadata",n)}},reportSetOrderInGroup:function(e,t,i){var n=l(t,!0);n.elementOrderInGroup=e.getOrderInGroup(t),n.removeExistingGroups=i,this._reportUpdateElementMetadata(e,"order",n)},reportSetDescription:function(e){this._reportUpdateElementMetadata(e,"description")}};h.reportUseElement=function(e,t,i){if(p()){var n=function(e){if(!e)return{};var t=c(e._element);return t.representationType=e.type,t.representationId=e.id,t}(e);n.opType=t,n.details=i,r.analytics.reportEvent("useElement",n)}},h.reportCheckoutElement=function(e,t,i){if(p()){var n=c(e);n.opType=t,n.details=i,r.analytics.reportEvent("checkoutElement",n)}},h.reportDeleteElement=function(e,t){if(p()){var i=c(e);i.isPermanent=!!t,r.analytics.reportEvent("deleteElement",i)}},h.reportRestoreElement=function(e){p()&&r.analytics.reportEvent("restoreElement",c(e))},h.reportCopyElement=function(e,t){if(p()){n=e,o=Date.now();var i=c(e);i.oldLibraryID=t._library.id,i.oldElementID=t.id,r.analytics.reportEvent("copyElement",i)}},h.reportMoveElement=function(e,t){if(p()){n=e,o=Date.now();var i=c(e);i.oldLibraryID=t._library.id,i.oldElementID=t.id,r.analytics.reportEvent("moveElement",i)}},h.reportCreateGroup=function(e){p()&&r.analytics.reportEvent("createGroup",l(e))},h.reportUpdateGroup=function(e){if(p()){var t=l(e);t.updateType="name",r.analytics.reportEvent("updateGroup",t)}},h.reportUpdateGroupMetadata=function(e,t){if(p()){var i=l(e);i.updateType="order",i.groupOrder=t,r.analytics.reportEvent("updateGroupMetadata",i)}},h.reportDeleteGroup=function(e,t,i){if(p()){var n=l(e);n.includeContents=t,t&&(n.numberElementsInGroup=i),r.analytics.reportEvent("deleteGroup",n)}},h.reportCopyGroup=function(e,t,i,n){if(p()){var o=l(e);o.oldLibraryID=t._library.id,o.oldGroupID=t.id,o.includeContents=i,i&&(o.numberElementsInGroup=n),r.analytics.reportEvent("copyGroup",o)}},h.reportMoveGroup=function(e,t,i,n){if(p()){var o=l(e);o.oldLibraryID=t._library.id,o.oldGroupID=t.id,o.includeContents=i,i&&(o.numberElementsInGroup=n),r.analytics.reportEvent("moveGroup",o)}},h.reportCollisionElement=function(e){p()&&r.analytics.reportEvent("collisionLibrary",c(e))},h.reportCreateLink=function(e,t){if(p()){var i=c(e);i.opType=t,r.analytics.reportEvent("createLink",i)}},h.reportShareElementLink=function(e){p()&&r.analytics.reportEvent("shareElementLink",c(e))},h.reportShareLibraryLink=function(e){p()&&r.analytics.reportEvent("shareLibraryLink",s(e))},h.reportElementActionInvoked=function(e){p()&&r.analytics.reportEvent("elementActionInvoked",d(e))},h.reportElementActionSuccessful=function(e,t){if(p()){var i=d(e);i.appVersion=t&&t.version,i.appLaunchStatus=t?t.isAlreadyRunning?"Running":"Launched":"Unknown",r.analytics.reportEvent("elementActionSuccessful",i)}},h.reportElementActionFailed=function(e,t){if(p()){var i=d(e);i.error=t?t.code+":"+t.message:"",r.analytics.reportEvent("elementActionFailed",i)}},h.reportUnexpectedState=function(e,t){if(p()){var i=s(e);i.details=t,r.analytics.reportEvent("unexpectedState",i)}},h.reportRemoveMissingComponents=function(e,t,i){if(p()){var n={libraryID:e,numMissing:t.length,numFixed:i,componentErrors:[]};t.forEach(e=>{var t=e.error,i=t&&t.code,o=t&&t.response&&t.response.statusCode,r=(i||"UNKNOWN_ERROR")+(o?": "+o:"");n.componentErrors.push(r)}),r.analytics.reportEvent("removeMissingComponents",n)}},Object.seal(h),e.exports=h},function(e,t,i){var n=i(35),o=i(4),r=i(0),a=i(1),s=i(18),c=i(2),l=i(14),d=i(7);const p=i(10).promisify;var h={},_={};h.isCompatibleType=function(e,t){return e===t||e===_[t]},h.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},h.validateLibrary=function(e){return(e.current&&e.current.rootNode.getValue(r.VERSION_KEY))===r.VERSION},h.areManifestsEqual=function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;const i=JSON.parse(e),n=JSON.parse(t);delete i["manifest-format-version"],delete n["manifest-format-version"];try{if(JSON.stringify(i)===JSON.stringify(n))return!0}catch(e){}return!1},h.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},h.getCustomDCXData=function(e){var t=[];return e.getCustomKeys().forEach(i=>{var n=i.split("#"),o=n.length>=2;o&&n.forEach(e=>{""===e&&(o=!1)});var a=0===i.indexOf(r.DL_PREFIX);o&&!a&&t.push({namespace:n.shift(),key:n.join("#"),value:e.getValue(i)})}),t},h.copyCustomDCXData=function(e,t){h.getCustomDCXData(e).forEach(e=>{t.setValue(h.getDCXKey(e.namespace,e.key),e.value)}),[r.REPRESENTATION_ORDER_KEY,r.IS_PREFERRED_THUMBNAIL_KEY,r.SHA_KEY].forEach(i=>{var n=e.getValue(i);n&&t.setValue(i,n)})},h.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},h.checkEncoding=function(e,t,i){if(-1===t.indexOf(e)){var n=t.join(", ");return i(new c(c.INVALID_PARAMETER,"Unsupported encoding. Supported encodings are: "+n)),!1}return!0},h.sortRepresentations=function(e){if(e.length<2)return;let t=!0;for(;t;){t=!1;for(let i=1;i<e.length;i++){const n=e[i-1],o=e[i];o._getOrder()<n._getOrder()&&(e[i-1]=o,e[i]=n,t=!0)}}},h.removeMissingComponents=function(e,t){if(e&&t){var i=0,n=0;return t.forEach(t=>{var o=t.component,r=t.error;o&&r&&r.response&&404===r.response.statusCode&&(e.removeComponent(o),i++,a.log("Removed missing component: "+o.id+" from library "+e.compositeId)),o&&r&&"[UNEXPECTED_RESPONSE] Incorrect content length"===r.message&&(n++,a.log("Skipped length-mismatch component: "+o.id+" from library "+e.compositeId))}),a.log("Fixed "+i+" of "+t.length+" components that failed to download"),l.reportRemoveMissingComponents(e.compositeId,t,i),t.length===i+n?e:void 0}};const u=(e,t)=>{const i=e=>e.representations.find(e=>e.id===t),n=e.elements.find(i)||e.removedElements.find(i);return n&&i(n)},f={"model/vnd.adobe.dn+dcx":"model/vnd.adobe.dn+dcxucf","application/vnd.adobe.element.agc+dcx":"application/vnd.adobe.element.agc+json"};h.fixLocalComponents=function(e,t){if(e&&t){var i=0,n=[];t.forEach(t=>{var r=t.component,s=t.error;if(r&&s&&s.code===o.INVALID_STATE){var c=u(e,r.id);c?n.push(c):e._dcxBranch.removeComponent(r),i++,a.log(`Removed missing local component: ${r.id} from library ${e.id}`)}else if(r&&s&&f[r.type]){const t=u(e,r.id),n=f[r.type];t&&(t._getDCXElement().type=n,i++,a.log(`Fixed mime type of local component: ${r.id} from library ${e.id} (${n})`))}}),i>0&&(e._beginOperation(),n.forEach(e=>{e.element.removeRepresentation(e)}),e._endOperation()),a.log("Fixed "+i+" of "+t.length+" components that failed to upload")}},h.recoverReadOnlyEdits=function(e,t,i){var n=[];e.elements.forEach(e=>{var i=t&&t.getChildWithId(e.id);(i&&i.getValue(r.MODIFIED_KEY))!==e.modified&&n.push(e)});const o=[];if(n.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));const t=p(e.copyElement.bind(e));n.forEach(e=>o.push(t(e,c))),a.log("Recovering "+n.length+" elements from read-only library")}Promise.all(o).then(()=>i(null),e=>i(e))},h.ensureBranchDataValid=function(e){var t=[r.ELEMENTS_NAME,r.REMOVED_ELEMENTS_NAME],i=!1;return e.getChildrenOf().forEach(function(n){if(-1!==t.indexOf(n.name)){var o=n.name===r.REMOVED_ELEMENTS_NAME;e.getChildrenOf(n).forEach(e=>{var t=e.getValue(r.REMOVED_KEY);!o&&t?(e.removeValue(r.REMOVED_KEY),i=!0):o&&!t&&(e.setValue(r.REMOVED_KEY,(new Date).valueOf()),i=!0)})}}),i},h.collaborationStateToDCX=function(e){return"incoming"===e?n.COLLABORATION.SHARED_WITH_USER:"outgoing"===e?n.COLLABORATION.SHARED_BY_USER:n.COLLABORATION.PRIVATE},h.collaborationStateFromDCX=function(e){return e===n.COLLABORATION.SHARED_WITH_USER?"incoming":e===n.COLLABORATION.SHARED_BY_USER?"outgoing":void 0},h.getCompositeRenditionMap=function(e){var t=e.getComponentsOf(),i={};return t&&t.forEach(e=>{if("rendition"===e.relationship){var t=e.getValue(r.RENDITION_TYPE_KEY);t&&(i[t]=e)}}),i},h.recoverFromElmo=function(e,t,i){const n=a.fs,o=a.getPathSeparator(),s={},c=t.every(t=>{s[t]=!0;const i=e._getCompositeDir(t)+o+"manifest";try{const e=JSON.parse(n.readFileSync(i,"utf8")).children.find(e=>"elements"===e.name);if(!e.children||0===e.children.length)return!0}catch(e){}}),l=e._syncManager,p=e=>{if(e)return l.links.test(l.getCompositePath(e),i),void a.log("Failed to recover from ELMO: "+e);a.log("Successfully recovered from ELMO"),i()};if(!c)return p("has_data");const h=()=>{d.recursiveDeleteDirectory(e._getBaseDir(),e=>{p(e&&"local_delete")})};l.getServerComposites((e,t)=>{if(e)return p("sg_fetch");t.every(e=>s[e.name])&&t.length>=r.ELMO_LOCAL_LIBRARY_LIMIT?l.deleteAllServerComposites(e=>{if(e)return p("sg_delete");h()}):t.length<r.ELMO_SERVER_RECOVERED_LIMIT?h():p("out_of_sync")})},Object.seal(h),e.exports=h},function(e,t,i){var n=i(0),o=i(1);const r=i(10).promisify;var a={},s={"application/x-indesign":!0,"application/postscript":!0,"application/illustrator":!0,"application/pdf":!0,"application/vnd.adobe.psremix":!0,"application/vnd.adobe.pstouch":!0,"application/vnd.adobe.ideas":!0,"application/vnd.adobe.ase":!0,"image/jpeg":!0,"image/jpg":!0,"image/pjpeg":!0,"image/tiff":!0,"image/gif":!0,"image/bmp":!0,"image/x-ms-bmp":!0,"image/svg+xml":!0,"image/png":!0,"image/x-png":!0,"image/jp2":!0,"image/psd":!0,"image/vnd.adobe.photoshop":!0,"image/heic":!0,"application/photoshop":!0,"application/x-photoshop":!0,"image/raw":!0,"image/dng":!0,"image/x-adobe-dng":!0,"video/mp4":!0,"video/mpeg":!0,"video/x-ms-wmv":!0,"video/3gpp":!0,"video/3gpp2":!0,"video/quicktime":!0,"video/x-msvideo":!0,"video/x-flv":!0,"video/x-ms-asf":!0,"video/x-m4v":!0,"video/mp2t":!0,"application/mxf":!0,"application/x-shockwave-flash":!0,"application/vnd.adobe.brushes.brush+ucf":!0,"application/vnd.adobe.collage":!0,"application/vnd.adobe.proto":!0,"application/msword":!0,"application/msexcel":!0,"application/mspowerpoint":!0,"application/vnd.ms-publisher":!0,"application/vnd.openxmlformats-officedocument.wordprocessingml.document":!0,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":!0,"application/vnd.openxmlformats-officedocument.presentationml.presentation":!0,"application/vnd.adobe.charts+zip":!0,"text/plain":!0,"text/rtf":!0};a.canComputeRenditionFromMimeType=function(e){return!!s[e]},a.canComputeRendition=function(e){return!(void 0===e._dcxComponent||!a.canComputeRenditionFromMimeType(e.type))},a.shouldPrefetchFullRendition=function(e){var t=(n.FULL_RENDITION_CONFIG||{})[e.type];if(!t)return!1;var i=!1;return Object.keys(t).forEach(n=>{var o=t[n];if("IF_NO_MATCHING_REPRESENTATION"===o.condition&&o.types){var r=e.representations.every(function(e){return-1===o.types.indexOf(e.type)});i=i||r}}),i},a.shouldPrefetchExternalLink=function(e){if(!e.isExternalLink)return!1;var t=(n.EXTERNAL_LINK_PREFETCH||{})[e.element.type];return void 0===t||t},a.prefetchRenditionsForElement=function(e,t=(()=>void 0)){if(!o.hasFileSystem())return void t(null);var i=n.RENDITION_SIZES||{},s=i[e.type]||i["*"]||[];const c=r(e.getThumbnailPath.bind(e)),l=s.map(e=>c(e));a.shouldPrefetchFullRendition(e)&&l.push(c(void 0)),e._forEachRepresentation(function(e){if(a.shouldPrefetchExternalLink(e)){const t=r(e.getContentPath.bind(e));l.push(t())}else if(e.isExternalLink){const t=r(e.testExternalLink.bind(e));l.push(t())}}),Promise.all(l).catch(()=>void 0).then(()=>t(null))},a.prefetchRenditions=function(e,t=(()=>void 0)){if(!o.hasFileSystem())return void t(null);const i=r(a.prefetchRenditionsForElement);Promise.all(e.elements.map(e=>i(e))).then(()=>t(null))},a.addToRenditionSizeConfig=function(e){var t=n.RENDITION_SIZES,i=t["*"]||[];i=JSON.parse(JSON.stringify(i));var o=e["*"]||[];Object.keys(t).forEach(i=>{if(!e[i]){var n=t[i];o.forEach(e=>{-1===n.indexOf(e)&&n.push(e)}),t[i]=n}}),Object.keys(e).forEach(n=>{var o=t[n]||JSON.parse(JSON.stringify(i));e[n].forEach(e=>{-1===o.indexOf(e)&&o.push(e)}),t[n]=o}),n.setParameter("RENDITION_SIZES",t)},a.addToFullRenditionConfig=function(e){var t=n.FULL_RENDITION_CONFIG;Object.keys(e).forEach(i=>{var n=t[i]||{};e[i].forEach(e=>{e.id&&(n[e.id]=e)}),t[i]=n}),n.setParameter("FULL_RENDITION_CONFIG",t)},Object.seal(a),e.exports=a},function(e,t,i){var n=i(6),o=i(5),r=i(0);n.log("Vulcan","Loading Vulcan Library...");var a=i(121),s=new a.VulcanAdapter("LIBS","1.0.0"),c=new a.VulcanControlAdapter;n.log("Vulcan","Vulcan Library Successfully Loaded");var l=new o;s.addMessageListener(function(e,t,i,o){e=e.replace(r.VULCAN_PREFIX,""),l.hasListeners(e)&&(n.log("Vulcan","<- "+i+" "+o+": "+e),l.notify(e,[t,i,o]))});var d={sendMessage:function(e,t,i,o){var r=i?i+" "+(o||"*"):"BROADCAST";n.log("Vulcan","-> "+r+": "+e),s.sendMessage(e,t||"",i||"",o||"")},addListener:function(e,t){l.add(e,t)},removeListener:function(e,t){l.remove(e,t)},call:function(e,t){var i,o,r=!1,a=function(n,a){r||!1!==t(n,a)&&(r=!0,clearTimeout(i),l.remove(e.responseType,o))};o=function(e){a(null,e)},l.add(e.responseType,o),e.timeout&&(i=setTimeout(function(){n.log("Vulcan","Timed out on "+e.responseType),a("timeout")},e.timeout)),d.sendMessage(e.requestType,e.payload,e.targetId,e.targetVersion)}};d.isAppInstalled=c.isAppInstalled.bind(c),d.getSpecifiers=c.getSpecifiers.bind(c),d.getAppPath=c.getAppPath.bind(c),d.isAppRunning=c.isAppRunning.bind(c),d.getAppVersion=c.getAppVersion.bind(c),d.launchApp=c.launchApp.bind(c),e.exports=d},function(e,t,i){const n=i(1),o=i(10);let r={};const a="undefined"!==typeof LOCALE_ROOT;n.hasFileSystem()&&a||(r={cs_CZ:i(73),da_DK:i(74),de_DE:i(75),en_US:i(76),es_ES:i(77),es_MX:i(78),fi_FI:i(79),fr_CA:i(80),fr_FR:i(81),fr_MA:i(82),hu_HU:i(83),it_IT:i(84),ja_JP:i(85),ko_KR:i(86),nb_NO:i(87),nl_NL:i(88),pl_PL:i(89),pt_BR:i(90),ru_RU:i(91),sv_SE:i(92),tr_TR:i(93),uk_UA:i(94),zh_CN:i(95),zh_TW:i(96)});const s={photoshop:"LIBS_TOOLKIT_NAME_PHOTOSHOP",photoshop_swatches:"LIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES",photoshop_brushes:"LIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES",photoshop_gradients:"LIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS",photoshop_patterns:"LIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS",photoshop_styles:"LIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES",photoshop_shapes:"LIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES"};e.exports=new class{constructor(){this.setLocale()}_getLocaleData(e){if(!r[e]&&n.hasFileSystem()&&a)try{r[e]=n.fs.readFileSync(LOCALE_ROOT+e+"/messages.properties","utf8")}catch(e){}return r[e]}_normaliseLocale(e){const t=(e=e.replace("-","_")).split("_");return t[0]=t[0]&&t[0].toLowerCase(),t[1]=t[1]&&t[1].toUpperCase(),t.join("_")}setLocale(e=""){e=this._normaliseLocale(e),this._getLocaleData(e)||(e="en_US"),this._locale=e,this._strings=o.parseLocalisationFile(this._getLocaleData(e))}getLocale(){return this._locale}translate(e,t){let i=this._strings[e];return i&&t&&(i=o.constructStringFromTemplate(i,t)),i||e}getToolkitName(e){return this.translate(s[e]||"LIBS_TOOLKIT_NAME_DEFAULT")}}},function(e,t){e.exports=require("fs")},function(e,t){e.exports=class{constructor(){this._isLocked=!1,this._queue=[]}obtain(e){this._isLocked?this._queue.push(e):(this._isLocked=!0,e(null))}release(){if(this._queue.length>0){const e=this._queue.shift();setTimeout(()=>e(null))}else this._isLocked=!1}abortPendingOperations(e){const t=this._queue;this._queue=[],t.forEach(t=>t(e))}isLocked(){return this._isLocked}hasPendingRequest(){return this._queue.length>0}}},function(e,t,i){var n=i(0),o=i(2),r=i(8),a={getBackoffTicks:function(e){var t=n.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 i=parseInt(t,10);if(i)return Math.max(0,i);var o=Date.parse(t);if(o){var r=(new Date).valueOf();return Math.max(0,o-r)/1e3+Math.floor(Math.random()*n.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 i=t.indexOf(";");return i>0&&(t=t.substring(0,i)),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 i=e.indexOf("."+t);return-1!==i&&i===e.length-t.length-1})};a.isAdobeDomain=function(e){return!!e&&s(e,n.ADOBE_AUTHENTICATED_DOMAINS)},a.validateURL=function(e,t){if(!e)return new o(o.URL_VALIDATION_FAILED,"URL not specified");var i=r.parseURI(e);if("https"!==i.scheme)return new o(o.URL_VALIDATION_FAILED,"URL must be https://");if(!(a.isAdobeDomain(i.authority)||s(i.authority,n.WHITELISTED_DOMAINS)))return new o(o.URL_VALIDATION_FAILED,"URL domain not in whitelist");const c=t&&t._syncManager._storageHost,l=c&&n.DISALLOWED_DOMAINS[c];return s(i.authority,l||[])?new o(o.URL_VALIDATION_FAILED,"URL domain does not match IMS environment (stage-production mismatch)"):null},Object.seal(a),e.exports=a},function(e,t,i){var n=i(39),o={parseXML:function(e,t){var i;return new n.Parser({async:!1}).parseString(e,function(e,n){e?t&&t(e):i=n}),i}};const r={true:!0,false:!1};o.parseQueryString=function(e,t={}){const i={},n=e&&e.split("?");if(n[1]){n[1].split("&").forEach(e=>{const[n,o]=e.split("=");t.parseBooleans&&Object.keys(r).includes(o)?i[n]=r[o]:i[n]=o})}return i},o.stripProtocolPrefix=function(e){return["http://","https://"].forEach(t=>{e&&0===e.indexOf(t)&&(e=e.substring(t.length))}),e},e.exports=o},function(e,t,i){var n,o,r=i(6),a="Proxy",s={},c=new(i(5))(["change","error"]),l={},d=i(124)(function(e,t){r.log(a,t),0===e&&c.notify("error",[t])});function p(e,t){d.resolve(e,function(e,i){e?t(e):t(null,i&&i[0])})}function h(e,t){p(e,function(i,o){delete t.agent,t.agent=o&&o.agent,t.agent?r.log(a,"Setting proxy for "+e+": "+o.hostname+":"+o.port+(n?" with":" without")+" authentication"):r.log(a,"No proxy (direct connection) for "+e)})}function _(){Object.keys(s).forEach(e=>{h(e,s[e])})}d.setAuthenticationCallback(function(e,t){var i=l[e.proxy.host+e.proxy.port]||{};i.username===n&&i.password===o?t("No new credentials"):n?(i.username=n,i.password=o,t(null,i),l[e.proxy.host+e.proxy.port]=i):t("No credentials present")}),d.on("change",function(){r.log(a,"System proxy settings changed"),_(),c.notify("change",[!0])});var u={};u.isLocalhostProxied=d.isLocalhostProxiedUnderHttp,u.addListener=function(e,t){c.add(e,t)},u.removeListener=function(e,t){c.remove(e,t)},u.removeAllListeners=function(e){c.removeAll(e)},u.getProxyForURL=function(e,t){p(e,t)},u.getNodeTunnelOptionsForURL=function(e){if(!s[e]){var t={};s[e]=t,h(e,t)}return s[e]},u.setProxyCredentials=function(e,t){n===e&&o===t||(r.log(a,"Setting proxy username and password"),n=e,o=t,_(),c.notify("change",[!1]))},u.getProxyCredentials=function(){return{user:n,password:o}},u.getRootCA=function(e){d.getRootCA(e)},u.getOSLocale=function(){return d.getOSLocale()},e.exports=u},function(e,t,i){var n,o=i(25),r=i(128),a=i(3),s=i(6),c=i(23),l=i(32),d=i(9),p=i(0),h=i(1),_=i(37),u=function(){if(!n){var e={ENVIRONMENT:"Staging"===a.getEnvironment().LABEL?"stage":"prod",ANALYTICS_API_KEY:a.getEnvironment().CLIENT_ID,ANALYTICS_X_PRODUCT:"CCLibraryProcess/"+_.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"};(n=new r({getAccessToken(e){l.getAccessToken(e)},getAgent(e,t){var i=c.getNodeTunnelOptionsForURL(e);t(null,i&&i.agent)},log(e){s.log("Analytics",e)}},e)).enable(p.ANALYTICS_ENABLED)}return n},f=[];var m={_updateDefaults:function(e){var t=d.getLoadedCollections(),i={"event.guid":h.uuid(),"event.user_guid":l.getUserId(),"event.category":"Library-Process","event.type":"info","event.dts_end":(new Date).toISOString(),"event.cloud_id":t&&t.length>0?t[0].cloudId:"","source.client_id":a.getEnvironment().CLIENT_ID,"source.version":_.version,"source.platform":o.platform()};return Object.keys(e).forEach(t=>{-1===t.indexOf(".")?i["ccxlp."+t]=e[t]:i[t]=e[t]}),i},_postEvent:function(e,t,i){u().postEvent(e,i),t&&u().flush(!0)},_reset:function(){n=void 0},reportEvent:function(e,t,i,n){t=Object.assign({"event.type":"info","event.subtype":e},t||{}),t=m._updateDefaults(t),m._postEvent(t,i,n)}};m.reportError=function(e,t,i,n){var o=e+": "+(t||"");if(function(e){return-1===f.indexOf(e)&&(f.length===a.getValue("ANALYTICS_ERROR_HISTORY")&&f.shift(),f.push(e),!0)}(o)){var r={"event.type":"error","event.error_type":e,"event.error_desc":o};r=m._updateDefaults(r),m._postEvent(r,i,n)}else n&&n(null,0)},m.setEnabled=function(e){u().enable(e)},e.exports=m},function(e,t){e.exports=require("os")},function(e,t,i){var n=i(4),o=i(36),r=i(50),a=i(67),s=i(40).STATES,c=i(13),l=i(8),d={PRIVATE:void 0,SHARED_BY_USER:"sharedByUser",SHARED_WITH_USER:"sharedWithUser"};function p(e,t,i,n,r,a){r=l.ensureRelativeHrefStartsWithSlash(r),this._options=a||{},i?this._setPath(i):r?(this._href=r,e&&(this._name=e),t&&(this._type=t),n&&(this._id=n)):t&&(this._current=new o,e&&(this._current._data.name=e),this._current._data.type=t,n&&(this._current.compositeId=n)),this._autoRemoveUnusedLocalFiles=!0,this._options.xhrBaseBranchSupport&&(this._baseBranchData=void 0,this._pushedBranchData=void 0,this._pulledBranchData=void 0),this._collaborationType=d.PRIVATE}p.newCompositeAsCopyOf=function(e,t,i,r,a,s,c){var d=e._core;if(d||e.current&&(d=e.current._core),!d)throw new n(n.INVALID_PARAMS,"compositeBranchOrElement must be a branch, an element or a composite with a current branch.");var h=new p(void 0,void 0,void 0,void 0,void 0,c);return r&&(h.path=r),h._current=o._newBranchAsCopyOfCore(d,this._localStorage),h.id=a||l.generateUuid(),t&&(h.name=t),i&&(h.type=i),s&&(h.href=s),h},p.COLLABORATION=d,Object.defineProperties(p.prototype,{id:{get(){return this._current?this._current.compositeId:this._id},set(e){if("string"!=typeof e)throw new n(n.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 n(n.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 n(n.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 n(n.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!==d.PRIVATE&&e!==d.SHARED_BY_USER&&e!==d.SHARED_WITH_USER)throw new n(n.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 n(n.INVALID_PARAMS,"Invalid clientDataString: must be a string or undefined.");var t=this._options.maxClientDataLength||1024;if(e&&e.length>t)throw new n(n.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 n(n.INVALID_PARAMS,"Expecting a string.");this._setPath(e)}},isBound:{get(){return this._current&&this._current.isBound||!this._current&&this._href},set(){throw new n(n.READ_ONLY,"Cannot set the property isBound. Use resetIdentity or resetBinding instead.")}},hasLocalStorage:{get(){return this._localStorage},set(){throw new n(n.READ_ONLY,"Cannot set the property hasLocalStorage.")}},autoRemoveUnusedLocalFiles:{get(){if(!this._localStorage)throw new n(n.NO_LOCAL_STORAGE,"No local storage.");return this._autoRemoveUnusedLocalFiles},set(e){if(!this._localStorage)throw new n(n.NO_LOCAL_STORAGE,"No local storage.");this._autoRemoveUnusedLocalFiles=e}},clientDataStoragePath:{get(){if(!this._localStorage)throw new n(n.NO_LOCAL_STORAGE,"No local storage.");return this._localStorage.clientDataPath()},set(){throw new n(n.READ_ONLY,'Property "clientDataStoragePath" is read-only.')}},current:{get(){return this._current},set(){throw new n(n.READ_ONLY,'Property "current" is read-only.')}}}),p.prototype.loadCurrentFromLocalStorage=function(e){if(!this._localStorage)throw new n(n.NO_LOCAL_STORAGE,"No local storage.");var t=this;this._loadBranch(this._localStorage.currentManifestPath(),!1,function(i,n){if(!i&&n)try{t._current=n,t._currentBranchCommittedAtDate=l.timeStamp(!0)}catch(e){i=e}e(i,i?void 0:n)})},p.prototype.commitChanges=function(e){if(!this._localStorage)throw new n(n.NO_LOCAL_STORAGE,"No local storage.");if(!this._current)return e(new n(n.INVALID_STATE,"Current branch is not in memory."));var t=this;c.writeFileAtomically(this._localStorage.currentManifestPath(),this._current.localData,"utf8",function(i){if(!i)try{t._currentBranchCommittedAtDate=l.timeStamp(!0),t._current._isDirty=!1}catch(e){i=e}e(i)})},p.prototype.tempAssetPath=function(){if(!this._localStorage)throw new n(n.NO_LOCAL_STORAGE,"No local storage.");return this._localStorage.tempPathForComponent()},p.prototype.deleteTempFiles=function(e){if(!this._localStorage)throw new n(n.NO_LOCAL_STORAGE,"No local storage.");this._localStorage.deleteTempFiles(function(t){e&&e(t)})},p.prototype.removeUnusedLocalFiles=function(e){if(!this._localStorage)throw new n(n.NO_LOCAL_STORAGE,"No local storage.");this._localStorage.removeUnusedLocalFiles(this._currentBranchCommittedAtDate,e)},p.prototype.removeLocalFilesForComponentsWithIDs=function(e,t){if(!this._localStorage)throw new n(n.NO_LOCAL_STORAGE,"No local storage.");if(!e)throw new n(n.INVALID_PARAMS,"Param componentIds must not be nil.");var i=this,o=this._current;i._loadBranch(i._localStorage.currentManifestPath(),!0,function(r,a){r&&"ENOENT"!==r.code?t([r]):i.loadBaseBranch(function(r,l){if(r&&"ENOENT"!==r.code)t([r]);else{var d,p,h=[],_={};for(d=0;d<e.length;++d){var u=e[d],f=o.getComponentWithId(u),m=a?a.getComponentWithId(u):void 0,E=l?l.getComponentWithId(u):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 n(n.COMPONENT_MODIFIED_ERROR,"Cannot remove the file of a modified component.");g.componentId=u,h.push(g)}else f&&(p=o.assetOfComponent(f))&&(void 0===_[p]&&(_[p]=u),i._localStorage.removeComponentAsset(f,o._local()),o._setDirty(!0)),m&&(p=a.assetOfComponent(m))&&void 0===_[p]&&(_[p]=u),E&&(p=l.assetOfComponent(E))&&void 0===_[p]&&(_[p]=u)}var y=Object.keys(_),v=y.length;if(v>0){var A=function(e){c.deleteFile(e,function(i){i&&(i.componentId=_[e],h.push(i)),0===--v&&t(h.length>0?h:void 0)})};for(d=0;d<y.length;++d)A(y[d])}else t(h.length>0?h:void 0)}})})},p.prototype.removeLocalStorage=function(e){if(!this._localStorage)throw new n(n.NO_LOCAL_STORAGE,"No local storage.");if(!this._path)return e(new n(n.INVALID_STATE,"No path set."));c.deleteDirectory(this._path,e)},p.prototype.loadBaseBranch=function(e){if(!this._localStorage&&!this._baseBranchData)throw new n(n.NO_LOCAL_STORAGE,"No local storage.");if(this._localStorage)this._loadBranch(this._localStorage.currentBaseManifestPath(),!0,e);else{var t,i;try{i=new o(void 0,!0).parse(this._baseBranchData)}catch(e){t=e}e(t,i)}},p.prototype.loadPulledBranch=function(e){if(!this._localStorage)throw new n(n.NO_LOCAL_STORAGE,"No local storage.");this._loadBranch(this._localStorage.pulledManifestPath(),!1,e)},p.prototype.loadPushedBranch=function(e){if(!this._localStorage)throw new n(n.NO_LOCAL_STORAGE,"No local storage.");this._loadBranch(this._localStorage.pushedManifestPath(),!1,e)},p.prototype.resolvePullWithBranch=function(e,t){if(!e)throw new n(n.INVALID_PARAMS,"Need a branch.");if(e===this._current)throw new n(n.INVALID_PARAMS,"Cannot resolve current.");if(this._localStorage&&!t)throw new n(n.INVALID_PARAMS,"Need a callback function.");var i=this,o=function(){e.readOnly=!1,e._collaborationType=i.collaborationType,e._clientDataString=i.clientDataString,i._current=e};if(this._localStorage)i._localStorage.resolvePulledBranch(e,function(e){if(!e)try{o(),i._autoRemoveUnusedLocalFiles&&i._localStorage.removeUnusedLocalFiles(i._currentBranchCommittedAtDate,function(){})}catch(t){e=t}t(e,e?void 0:i._current)});else{if(this._options.xhrBaseBranchSupport&&(this._baseBranchData=this._pulledBranchData,this._pulledBranchData=void 0),o(),!t)return this._current;t(void 0,this._current)}},p.prototype.acceptPush=function(e){if(this._localStorage&&!e)throw new n(n.INVALID_PARAMS,"Need a callback function.");var t,i,o=this,a=function(n){if(!n)if(t)try{o._localStorage?(t.applyToBranch(i),o._localStorage.acceptPushedBranch(i,function(i){if(!i)try{t.applyToBranch(o._current,!0),o._autoRemoveUnusedLocalFiles&&o._localStorage.removeUnusedLocalFiles(o._currentBranchCommittedAtDate,function(){})}catch(e){i=e}e(i)})):(t.applyToBranch(o._current,!0),o._options.xhrBaseBranchSupport&&(o._baseBranchData=o._pushedBranchData,o._pushedBranchData=void 0),o._pushJournal=void 0,e&&e())}catch(e){n=e}else e&&e();if(n){if(!e)throw n;e(n)}};if(!this._localStorage)return t=this._pushJournal,a();var s,c=2;r.readJournal(o._localStorage.pushJournalPath(),o,!1,function(e,i){c--,s?a():(e?"ENOENT"!==e.code&&(s=new n(n.INVALID_STATE,"Failed to load push journal.",e)):t=i,c||a())}),this._loadBranch(this._localStorage.currentManifestPath(),!1,function(e,t){c--,s?a():(e?s=new n(n.INVALID_STATE,"Failed to load current manifest.",e):i=t,c||a())})},p.prototype.discardPulledBranch=function(e){if(!this._localStorage)throw new n(n.NO_LOCAL_STORAGE,"No local storage.");var t=this;this._localStorage.discardPulledBranch(function(i){if(!i){try{t._autoRemoveUnusedLocalFiles&&t._localStorage.removeUnusedLocalFiles(t._currentBranchCommittedAtDate,function(){})}catch(e){i=e}e(i)}i&&e(i)})},p.prototype.discardPushedBranch=function(e){if(!this._localStorage)throw new n(n.NO_LOCAL_STORAGE,"No local storage.");var t=this;this._localStorage.discardPushedBranch(function(i){if(!i){try{t._autoRemoveUnusedLocalFiles&&t._localStorage.removeUnusedLocalFiles(t._currentBranchCommittedAtDate,function(){})}catch(e){i=e}e(i)}i&&e(i)})},p.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())},p.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())},p.prototype._loadBranch=function(e,t,i){if("function"!=typeof i)throw new n(n.INVALID_PARAMS,'Param "callback" must be a function.');var r=this;c.exists(e,function(n){n?c.readFile(e,"utf8",function(n,a){var s;if(!n)try{(s=new o(void 0,t,e).parse(a))._localStorage=r._localStorage}catch(e){n=e}i(n,s)}):i()})},p.prototype._discardEveryBranchButCurrent=function(e){if(!this._localStorage)throw new n(n.NO_LOCAL_STORAGE,"No local storage.");var t,i=this,o=3,r=function(n){n&&!t&&(t=n),0===--o&&(!t&&i._autoRemoveUnusedLocalFiles&&i._localStorage.removeUnusedLocalFiles(i._currentBranchCommittedAtDate,function(){}),e(t))};this._localStorage.discardPushedBranch(r),this._localStorage.discardPulledBranch(r),this._localStorage.discardBaseBranch(r)},p.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=p},function(e,t){e.exports=require("https")},function(e,t){var i={},n={"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomsvc+xml":["atomsvc"],"application/ccxml+xml":["ccxml"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma"],"application/emma+xml":["emma"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/font-tdpfr":["pfr"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/hyperstudio":["stk"],"application/illustrator":["ai"],"application/illustrator-text":["ai"],"application/illustrator.template":["ait"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/java-archive":["jar"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js"],"application/json":["json"],"application/jsonml+json":["jsonml"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/photoshop":["psd"],"application/photoshop.large":["psb"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/prs.cww":["cww"],"application/pskc+xml":["pskcxml"],"application/rdf+xml":["rdf"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/vnd.3gpp.pic-bw-large":["plb"],"application/vnd.3gpp.pic-bw-small":["psb"],"application/vnd.3gpp.pic-bw-var":["pvb"],"application/vnd.3gpp2.tcap":["tcap"],"application/vnd.3m.post-it-notes":["pwn"],"application/vnd.accpac.simply.aso":["aso"],"application/vnd.accpac.simply.imp":["imp"],"application/vnd.acucobol":["acu"],"application/vnd.acucorp":["atc","acutc"],"application/vnd.adobe.ae.graphic+zip":["aegraphic","mogrt"],"application/vnd.adobe.air-application-installer-package+zip":["air"],"application/vnd.adobe.animate-xfl+zip":["fla","xfl"],"application/vnd.adobe.animate-oam+zip":["oam"],"application/vnd.adobe.animate-sym+zip":["sym"],"application/vnd.adobe.animate-swf+zip":["swa"],"application/vnd.adobe.characterstyle+json":["style"],"application/vnd.adobe.characterstyle+snippet":["idms"],"application/vnd.adobe.charts+zip":["zip"],"application/vnd.adobe.ch.puppet+zip":["puppet"],"application/vnd.adobe.color+json":["ase"],"application/vnd.adobe.colortheme+json":["ase"],"application/vnd.adobe.cube+txt":["cube"],"application/vnd.adobe.element.agc+json":["agc"],"application/vnd.adobe.formscentral.fcdt":["fcdt"],"application/vnd.adobe.fxp":["fxp","fxpl"],"application/vnd.adobe.ibl.light+zip":["zip"],"application/vnd.adobe.illustrator.template":["ait"],"application/vnd.adobe.indesign-idms":["idms"],"application/vnd.adobe.indesign-idms-text":["idms"],"application/vnd.adobe.indesign.template":["indt"],"application/vnd.adobe.layerstyle":["asl"],"application/vnd.adobe.look+xml":["look"],"application/vnd.adobe.graphic+json":["json"],"application/vnd.adobe.mdl.material+zip":["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.photoshop.template":["psdt"],"application/vnd.adobe.ppro.graphic+zip":["prgraphic","mogrt"],"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/aif":["aif"],"audio/basic":["au","snd"],"audio/m4a":["m4a"],"audio/midi":["mid","midi","kar","rmi"],"audio/mp4":["mp4a"],"audio/mpeg":["mpga","mp2","mp2a","m2a"],"audio/mpeg3":["mp3","m3a"],"audio/ogg":["oga","ogg","spx"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/webm":["weba"],"audio/x-aac":["aac"],"audio/x-aiff":["aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-wav":["wav"],"audio/xm":["xm"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/dng":["dng"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heif":["heif"],"image/ief":["ief"],"image/jpeg":["jpeg","jpg","jpe"],"image/jpg":["jpg"],"image/ktx":["ktx"],"image/png":["png"],"image/prs.btif":["btif"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/tiff":["tiff","tif"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.adobe.photoshop.template":["psdt"],"image/vnd.adobe.pattern+png":["png"],"image/vnd.adobe.shape+svg":["shape"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.dvb.subtitle":["sub"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/webp":["webp"],"image/x-3ds":["3ds"],"image/x-adobe-dng":["dng"],"image/x-adobe-photoshop-brush":["abr"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["ico"],"image/x-mrsid-image":["sid"],"image/x-pcx":["pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/rfc822":["eml","mime"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/vnd.adobe.dn+dcx":["dn"],"model/vnd.adobe.dn+dcxucf":["dn"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.vtu":["vtu"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["x3db","x3dbz"],"model/x3d+vrml":["x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"text/cache-manifest":["appcache"],"text/calendar":["ics","ifb"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in"],"text/prs.lines.tag":["dsc"],"text/richtext":["rtx"],"text/sgml":["sgml","sgm"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-fortran":["f","for","f77","f90"],"text/x-java-source":["java"],"text/x-opml":["opml"],"text/x-pascal":["p","pas"],"text/x-nfo":["nfo"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"video/3gpp":["3gp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/jpeg":["jpgv"],"video/jpm":["jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["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","wmv"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-quicktime":["mov"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]},o={};Object.keys(n).forEach(e=>{n[e].forEach(t=>{o[t]=o[t]||[],o[t].push(e)})}),i.getExtensions=function(e){return e?n[e.toLowerCase()]||function(e){var t=e.match(/application\/x-adobe-libraries-(.+)/);return t?[t[1]]:[]}(e.toLowerCase()):[]},i.getMimeTypes=function(e){return e?o[e.toLowerCase()]||function(e){return["application/x-adobe-libraries-"+e]}(e.toLowerCase()):[]},Object.seal(i),e.exports=i},function(e,t,i){var n=i(1),o=i(0),r=function(){return n.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=o.ELEMENT_ACTION_PRODUCT_MAP.types,e.types["application/vnd.adobe.element.image+dcx"]=t}o.ELEMENT_ACTION_PRODUCT_MAP=e}},formatElementActionMapForClient:function(e){return e<9?{types:o.ELEMENT_ACTION_PRODUCT_MAP.types["application/vnd.adobe.element.image+dcx"],products:o.ELEMENT_ACTION_PRODUCT_MAP.products,installedApps:o.ELEMENT_ACTION_PRODUCT_MAP.installedApps}:o.ELEMENT_ACTION_PRODUCT_MAP},supportsStringMessages:function(e){return e>=16}};Object.seal(s),e.exports=s},function(e,t){e.exports=require("fs-extra")},function(e,t){e.exports=require("child_process")},function(e,t,i){var n=i(3),o=i(6),r=i(2),a="IMS",s=["creative_cloud","cce_private"];o.log(a,"Loading IMS Library...");var c,l,d,p,h,_,u,f=n.getEnvironment(),m=i(120),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(e=>{try{e.apply(void 0,t)}catch(e){o.log(a,"Error in callback: "+e)}})}function A(){var e=m.createRefEx(f.IMS);return p&&p.name&&p.pass&&m.setProxyCredentialsInIMSLibSession(e,p.name,p.pass),e}var C,I=!1;try{!function(){var e=A();m.registerClientToGroup(e,f.CLIENT_ID,"AAM"),c=m.getDeviceID(e),o.log(a,"DeviceID: "+c),m.releaseRef(e)}(),I=!0,o.log(a,"IMS Library Successfully Loaded")}catch(e){o.log(a,"IMS Library Failed to Load: "+e)}var S={getDeviceId:function(){return c},getUserId:function(){if(!l&&I){var e,t,i=A();try{t=(e=m.fetchDefaultUserInfoForClientId(i,f.CLIENT_ID))?"Default User: "+e.Email+" ("+e.UserID+")":"No default user"}catch(e){t="Error fetching default user: "+e}m.releaseRef(i),t!==C&&o.log(a,t),C=t,(l=e&&e.UserID)&&(u=!0,this.getAccessToken(function(e,t,i){d=i&&i.serviceAccounts,u=!1;var n=g;g=[],v(n,[])}))}return l},clearUserId:function(){l=void 0,d=void 0,h=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(h&&Date.now()<h.expires){if(!(e&&h.response.access_token&&e===h.response.access_token))return void t(null,h.response.access_token,h.response);if(_&&Date.now()<_)return delete h.response.access_token,h.expires=_,void t(null);_=Date.now()+n.getValue("ACCESS_TOKEN_CACHE_DURATION")}if(E.push(t),!(E.length>1)){h=void 0;var i=A();o.log(a,"Started IMSLib.fetchAccessToken"),m.fetchAccessToken(i,f.CLIENT_ID,f.CLIENT_SECRET,l,"",n.getValue("SCOPES"),function(e,t){o.log(a,"Finished IMSLib.fetchAccessToken"),setTimeout(function(){m.releaseRef(i)});var c=function(e,t,i){var n=E;E=[],v(n,[e,t,i])};return e?(o.log(a,e),void c(null)):!t.error&&!y(s,t.serviceAccounts)||"ride_AdobeID_subs_actreq"===t.error?(o.log(a,"Services not provisioned"),void c(new r(r.ACCESS_DENIED,"services not provisioned"),void 0,t)):(t.error?o.log(a,"Unknown Error: "+t.error):o.log(a,"Successfully obtained access token"),h={response:t,expires:Date.now()+n.getValue("ACCESS_TOKEN_CACHE_DURATION")},void c(null,t.access_token,t))})}}else t(null,void 0)},getClientAccessToken:function(e,t,i,n,s){if(l&&e===l){var c=A();o.log(a,`Started IMSLib.fetchAccessToken for ${t}`),m.fetchAccessToken(c,t,i,l,"",n,function(e,i){if(o.log(a,`Finished IMSLib.fetchAccessToken for ${t}`),setTimeout(function(){m.releaseRef(c)}),e||i.error)return o.log(a,e||i.error),void s(new r(r.ACCESS_DENIED,"error obtaining access token from IMS"));const{access_token:n,expires_in:l}=i;s(null,{access_token:n,expires_in:l})})}else s(new r(r.ACCESS_DENIED,"user mismatch"))},hasEntitlement:function(e,t){var i=function(){var i=y([e],d);t(i)};u?g.push(i):i()},setProxyCredentials:function(e,t){p={name:e,pass:t}}};e.exports=S},function(e,t,i){const n=i(12),o=i(9),r=i(34),a=i(0),s=e=>e,c={modified_date:parseInt,size:parseInt,name:s},l={modified_date:e=>e.map(e=>parseInt(e)),owner:s},d=e=>{for(const[t,i]of Object.entries(e))t.includes("#")&&(e.custom_data||(e.custom_data={}),e.custom_data[t]=i,delete e[t])},p=e=>{const t=e.custom_data||{};for(const[i,n]of Object.entries(t))e[i]=n;delete e.custom_data},h=(e,t)=>{if(Array.isArray(e))e.forEach(e=>h(e,t));else if("object"==typeof e&&null!==e)for(const[i,n]of Object.entries(e))"representations"===i&&Array.isArray(n)?n.forEach(t):h(n,t)},_=(e,t,i,n)=>{let a,s,c,l=e.headers["if-match"];if(l){if(null===l.match(/"([0-9]+)"/g))return{error:r.INVALID_ETAG};l=parseInt(l.match(/([0-9]+)/g)[0])}if(!n){const i=e.params.libraryId||e.body&&e.body.filters&&e.body.filters.library_id;if(i){if(!(n=o.getLibraryById(i))||n.isDeletedFromServer)return{error:r.LIBRARY_NOT_FOUND};if(l&&l!==n.modified)return{error:r.INCORRECT_ETAG};if(t&&!n.isWritable)return{error:r.LIBRARY_NOT_WRITABLE}}}return!e.params.elementId||(a=n.getElementById(e.params.elementId))&&(i?a.removed:!a.removed)?e.params.representationId&&!(s=a.getRepresentationById(e.params.representationId))?{error:r.REPRESENTATION_NOT_FOUND}:e.params.groupId&&!(c=n.getGroupById(e.params.groupId))?{error:r.GROUP_NOT_FOUND}:{library:n,element:a,group:c,representation:s}:{error:r.ELEMENT_NOT_FOUND}},u=e=>{const t={id:e.id,type:e.type,children:e.children.map(u),relationship:e.relationship,content_length:e.contentLength,content_hash:e.contentHash,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},i=e.getCachedContentPath();i&&(t.path=n.normalize(i));const o=e.getValues();return o&&o.length>0&&(t.custom_data={},o.forEach(e=>t.custom_data[`${e.namespace}#${e.key}`]=e.value)),t},f=e=>e?Array.isArray(e)?e.reduce((e,t)=>e+f(t),0):e.elements?e.elements.reduce((e,t)=>e+f(t),0):e.representations?e.representations.reduce((e,t)=>e+(t.contentLength||0),0):0:0,m=(e,t,i,n)=>{const o={id:e.id,name:e.name,type:e.type,created_date:e.created,modified_date:e.modified,element_ref:e.getReference(),tags:e.tags};if(o.groups=e.getGroups(/.*/).map(t=>({id:t.id,classifier:t.classifierName,order:e.getOrderInGroup(t)})),o.representations=e.representations.map(u),i){const t=e.library;if(o.library={},o.library.id=t.id,o.library.name=t.name,t.collaboration){const e=t.collaboration.toLowerCase();o.library.collaboration={state:e},o.library.collaboration.role="outgoing"===e?"owner":t.isWritable?"editor":"viewer",o.library.ownership=e}else o.library.ownership=t.collection.isPublic?"public":"private"}if(n){const t=e.library._renditionCache.serializeElementCache(e,!0);Object.keys(t).length>0&&(o.thumbnail_cache=t)}t&&(o.size=f(e));const r=e.getValues();return r&&r.length>0&&(o.custom_data={},r.forEach(e=>o.custom_data[`${e.namespace}#${e.key}`]=e.value)),o},E={"application/vnd.adobe.element.color+dcx":e=>{const t=e.representations.map(e=>e.getValue("color","data")).find(e=>e&&"RGB"===e.mode);if(t)return{type:"application/vnd.adobe.element.color+dcx",rendition:{swatches:[[{alpha:t.alpha,mode:t.mode,type:t.type,value:t.value}]]}}},"application/vnd.adobe.element.colortheme+dcx":e=>{const t=e.getPrimaryRepresentation();return t&&{type:"application/vnd.adobe.element.colortheme+dcx",rendition:t.getValue("colortheme","data")}},default:e=>{const t=a.RENDITION_SIZES[e.type]||a.RENDITION_SIZES["*"],i=t&&e.getCachedThumbnailPath(Math.max(...t));if(i)return{type:"href",rendition:i}}},g=e=>{return(E[e.type]||E.default)(e)};e.exports={getRequestHandler:(e,t,i)=>(n,o)=>{let a=_(n,t,i),{library:s,element:c,group:l,representation:u,error:f}=a;if(f)return o.send(f);const m=(n.headers["x-client-version"]||1)<=2;m&&(e=>{h(e,d)})(n.body);const E=n.headers["user-agent"];E&&(n.params.appName=E);try{Promise.resolve(e(n.params,n.body,l||u||c||s)).then(e=>{m&&(e=>{h(e,p)})(e),o.send(e)}).catch(e=>{o.send(e)})}catch(e){o.send(r.getResponseError(e))}},getPollingRequestHandler:e=>(t,i)=>{if(!t.body)return i.send(r.NOTIFICATIONS_DATA_NOT_FOUND);const n=e(t.body,e=>{i.send(e)});n&&t.on("close",n)},getGroupResponseData:e=>{return{id:e.id,name:e.name,classifier:e.classifierName,order:e.order,created_date:e.created,modified_date:e.modified}},getElementResponseData:m,getLibraryResponseData:(e,t={})=>{const i={id:e.id,name:e.name,created_date:e.created,modified_date:e.modified,toolkit_id:e.toolkitId,details:{num_elements:e.elements.length,num_archived_elements:e.removedElements.length}};if(i.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||(i.default=!0),e.collaboration){const t=e.collaboration.toLowerCase();i.collaboration={state:t},i.collaboration.role="outgoing"===t?"owner":e.isWritable?"editor":"viewer",i.ownership=t}else i.ownership=e.collection.isPublic?"public":"private";t.includeElements&&(i.elements=e.elements.map(m)),t.includeSize&&(i.size=f(e)),t.includeRenditionGrid&&(i.rendition_grid=(e=>{if(0===e.elements.length)return null;const t=e.elements.concat().sort((e,t)=>t.modified-e.modified),i=e.elements.concat().sort((e,t)=>e.created-t.created);let n=i.find(e=>{const t=g(e);return t&&"href"===t.type});const o={};n&&(o.main=g(n));for(let e=0;e<i.length&&!o.main;e++)o.main=g(i[e])||null,n=o.main&&i[e];o.tiles=[];for(let e=0;e<t.length&&o.tiles.length<3;e++){if(t[e]===n)continue;const i=g(t[e]);i&&o.tiles.push(i)}return o})(e));const n=e.getValues();return n&&n.length>0&&(i.custom_data={},n.forEach(e=>i.custom_data[`${e.namespace}#${e.key}`]=e.value)),i},getPagedResponses:(e,t,i,n,o,r)=>{if(e.length<=n)return{pagedResults:e,isLastPage:!0};const a=o?r.findNextIndex(e,t,o,i):0;if(e.length<=a+n)return{pagedResults:e.slice(a),isLastPage:!0};let s=a+n-1;for(;e[s+1]&&e[s][t]===e[s+1][t];)s++;return{pagedResults:e.slice(a,s+1),isLastPage:e.length<=s+1,nextStartValue:e[s][t]}},getSortOrder:(e="")=>{const t=Object.keys(c);let[i,n]=e.split("-").reverse(),o=void 0===n;return t.includes(i)||(i=t[0],o=!1),{orderBy:i,isAscending:o}},updateCustomData:(e,t)=>{t.forEach(({namespace:t,key:i,value:n})=>{null!==n?e.setValue(t,i,n):e.removeValue(t,i)})},parseCustomData:e=>{const t=[];return e?Object.keys(e).every(i=>{const[n,o,...r]=i.split("#");return!!(!r.length&&n&&n.length&&o&&o.length&&n!==a.DL_NAMESPACE)&&(t.push({namespace:n,key:o,value:e[i]}),!0)})?t:void 0:t},parseFilterField:(e,t)=>l[e]&&l[e](t),parseSortField:(e,t)=>c[e]&&c[e](t),getRequestedModels:_,parsePlaceholder:e=>{let t=e.match(/\$([0-9]+)\.([A-Za-z][A-Za-z0-9]*)/);if(t){const[,e,i]=t;return{index:parseInt(e),property:i}}}}},function(e,t,i){const n=i(139),o=i(2),r={};r[o.ACCESS_DENIED]=n.ForbiddenError,r[o.DELETED_LOCALLY]=n.NotFoundError,r[o.FILE_TOO_LARGE]=n.RequestEntityTooLargeError,r[o.INVALID_DATA]=n.BadRequestError,r[o.INVALID_PARAMETER]=n.BadRequestError,r[o.LOGGED_OUT]=n.UnauthorizedError,r[o.NOT_ALLOWED]=n.ForbiddenError,r[o.NOT_IMPLEMENTED]=n.NotImplementedError,r[o.NOT_SUPPORTED]=n.NotAcceptableError,r[o.READ_ONLY]=n.ForbiddenError,r[o.RENDITION_NOT_AVAILABLE]=n.NotFoundError,r[o.OUT_OF_SPACE]=n.InsufficientStorageError,r[o.URL_VALIDATION_FAILED]=n.BadRequestError,r[o.THUMBNAIL_NOT_AVAILABLE]=n.NotFoundError;const a={BadRequest:n.BadRequestError,InternalServer:n.InternalServerError,NotFound:n.NotFoundError,InsufficientStorage:n.InsufficientStorageError,Forbidden:n.ForbiddenError,PreconditionFailed:n.PreconditionFailedError,NotImplemented:n.NotImplementedError};e.exports={COLLECTION_NOT_FOUND:new n.InternalServerError("Cannot find private collection"),LIBRARY_NAME_MISSING:new n.BadRequestError("Library name is missing"),LIBRARY_ID_MISSING:new n.BadRequestError("Library id is missing"),LIBRARY_URL_MISSING:new n.BadRequestError("Library URL is missing"),LIBRARY_NOT_FOUND:new n.NotFoundError("Cannot find library"),LIBRARY_NOT_WRITABLE:new n.ForbiddenError("Library is read-only"),LIBRARY_NOT_ENOUGH_SPACE:new n.InsufficientStorageError("Library does not have enough space for new elements"),ELEMENT_NOT_FOUND:new n.NotFoundError("Cannot find element"),ELEMENT_IDS_MISSING:new n.BadRequestError("Element ids are missing"),ELEMENT_DATA_MISSING:new n.BadRequestError("Element data is missing"),ELEMENT_TYPE_MISSING:new n.BadRequestError("Element type is missing"),ELEMENT_BODY_MISSING:new n.BadRequestError("Element name or representation data or tag data is needed"),ELEMENT_NAME_INVALID:new n.BadRequestError("Element name must be a string"),ELEMENT_TAGS_INVALID:new n.BadRequestError("Element tags must be an array of strings"),REPRESENTATION_DATA_MISSING:new n.BadRequestError("Representations are missing"),REPRESENTATION_NOT_FOUND:new n.NotFoundError("Cannot find representation"),REPRESENTATION_PATH_NOT_FOUND:new n.NotFoundError("Cannot find representation path"),REPRESENTATION_ID_NOT_RESOLVED:new n.BadRequestError("Representation id cannot be resolved"),REPRESENTATION_TYPE_MISSING:new n.BadRequestError("Representation type is missing"),REPRESENTATION_REL_MISSING:new n.BadRequestError("Representation relationship is missing"),REPRESENTATION_CHILDREN_INVALID:new n.BadRequestError("Representation children is invalid"),REPRESENTATION_REL_INVALID:new n.BadRequestError("Representation relationship is invalid"),REPRESENTATION_REL_PRIMARY_FOUND:new n.BadRequestError("Cannot have multiple primary representations"),REPRESENTATION_WIDTH_INVALID:new n.BadRequestError("Representation width is invalid"),REPRESENTATION_HEIGHT_INVALID:new n.BadRequestError("Representation height is invalid"),REPRESENTATION_CONTENT_LENGTH_INVALID:new n.BadRequestError("Representation content_length is invalid"),REPRESENTATION_CONTENT_LENGTH_UNEXPECTED:new n.BadRequestError("Representation content_length can only be used for an externally-linked representation"),REPRESENTATION_FULL_SIZE_INVALID:new n.BadRequestError("Representation is_full_size is invalid"),REPRESENTATION_SOURCE_MISSING:new n.BadRequestError("Representation source should have a URL or Path"),GROUP_NOT_FOUND:new n.NotFoundError("Cannot find group"),GROUP_NAME_MISSING:new n.BadRequestError("Group name is missing"),GROUP_ORDER_MISSING:new n.BadRequestError("Group order is missing"),GROUP_BODY_MISSING:new n.BadRequestError("Group name or order is needed"),NOTIFICATIONS_DATA_NOT_FOUND:new n.BadRequestError("Notification base data is missing"),EMPTY_SEARCH:new n.BadRequestError("Empty search query"),CONFLICTING_OWNERSHIP:new n.NotFoundError("Filters for ownership and library id conflict"),INVALID_MODIFIED_FILTER:new n.BadRequestError("Modified date filter is incorrectly formatted"),EMPTY_FILTERS:new n.BadRequestError("If a filter object is defined, it must have at least one property"),INCORRECT_LIMIT:new n.BadRequestError("Limit must be a positive integer"),INVALID_CUSTOM_DATA:new n.BadRequestError("Invalid custom data"),INVALID_GROUP_DATA:new n.BadRequestError("Invalid group data"),INVALID_UPDATE_REQUEST:new n.BadRequestError("Invalid Update Request"),INVALID_ETAG:new n.BadRequestError("Invalid eTag syntax. Missing double quotes"),INCORRECT_ETAG:new n.PreconditionFailedError("The if-match eTag does not match the library modified time"),INVALID_TRANSACTION_SYNTAX:new n.BadRequestError("Invalid syntax for batch request. Should be an Array of requests with a method, path, and optional body"),INVALID_TRANSACTION_PLACEHOLDER:new n.BadRequestError("Invalid placeholder in batch request"),INVALID_TRANSACTION_REQUEST:new n.BadRequestError("Request is invalid or not supported by the batch api"),NOT_IMPLEMENTED:new n.NotImplementedError("Not implemented yet"),getResponseError:(e,t)=>{let i="object"==typeof e?e.message:e;if(i=t?`${i}. ${t}`:i,e instanceof o){e=new(r[e.code]||n.InternalServerError)(i)}else if(e.code){if(e.message!==i){e=new(0,a[e.body&&e.body.code||e.code])(i)}}else e=new n.InternalServerError(i||e);return e}}},function(e,t,i){var n=i(26),o=i(51),r=i(68),a=i(69),s=i(52),c=i(8),l=i(4),d=i(13),p=i(53);function h(e,t){e&&d._setFS(e),this._compositeOptions=c.merge({},t),t&&t.logCallback&&c._setLogCallback(t.logCallback)}h.COLLABORATION={PRIVATE:n.COLLABORATION.PRIVATE,SHARED_BY_USER:n.COLLABORATION.SHARED_BY_USER,SHARED_WITH_USER:n.COLLABORATION.SHARED_WITH_USER},h.AdobeDCXError=l,h.FileContent=o.FileContent,h.StreamProvider=o.StreamProvider,h.prototype.newEmptyComposite=function(e,t,i,o){var r=new n(e,t,null,o,null,this._compositeOptions);return i&&(r.path=i),r},h.prototype.newCompositeFromLocalStorage=function(e,t){try{if("string"!=typeof e)throw new l(l.INVALID_PARAMS,"");var i=new n(null,null,e,null,null,this._compositeOptions);i.loadCurrentFromLocalStorage(function(e){t(e,e?void 0:i)}),i.deleteTempFiles()}catch(e){t(e)}},h.prototype.newCompositeWithHref=function(e,t,i,o,r){var a=new n(i,r,null,o,e,this._compositeOptions);return t&&(a.path=t),a},h.prototype.newCompositeAsCopyOf=function(e,t,i,o,r,a){return n.newCompositeAsCopyOf(e,t,i,o,r,a,this._compositeOptions)},h.prototype.createHTTPService=function(e){return new o(e)},h.prototype.createStorageSession=function(e,t){return new r(e,t)},h.prototype.createCommunitySession=function(e,t){return new a(e,t)},h.prototype.compositeXfer=s,h.prototype.snapshot=p,e.exports=h},function(e,t,i){var n=i(48),o=i(66),r=i(4),a=i(8),s=6;function c(e,t,i){if(e)e=this._setData(e,t);else{var o=a.generateUuid();e={"manifest-format-version":s,id:o},this.originalManifestFormatVersion=s,this._core=new n(e,this,t),this._data=e}this._pendingElements=[],this.manifestPath=i}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 i,n,o=t.components;if(o)for(n=o.length,i=0;i<n;i++)delete o[i].localStorageAssetId;var r=t.children;if(r)for(n=r.length,i=0;i<n;i++)e(r[i])}(e),t<6&&function e(t,i){i&&t.path&&delete t.path;var n,o=t.components;if("object"==typeof o)for(n=0;n<o.length;n++){var r=o[n];"number"==typeof r.version&&(r.version=r.version.toString())}var a=t.children;if("object"==typeof a)for(n=0;n<a.length;n++)e(a[n])}(e,!0)}}c._newBranchAsCopyOfCore=function(e,t){var i=new c(JSON.parse(JSON.stringify(e._data))),n=i._core;return i._localStorage=t,i._resetIdentity(function(i){var o=e.getComponentWithId(i.id);if(!o)throw new r(r.INVALID_STATE,"Could not find original component.");if("modified"===o.state||!o.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(o);if(!a)throw new r(r.INVALID_STATE,"Cannot determine the href of component id "+o.id);n._setSourceHrefOfComponent(a,i),t&&t.removeComponentAsset(i,n._local())}),i},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,i,n,o,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 i)throw new r(r.INVALID_PARAMS,"Element must have a path of type string");var s=this._core.addChild(e,n,o,a);try{s.path=i}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 i=this._core.replaceChild(e.rootNode,t.path);return this._deleteElement(e),i},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,i,n){return this._core.addChild(e,t,i,n)},c.prototype.removeChild=function(e){return this._core.removeChild(e)},c.prototype.moveChild=function(e,t,i){return this._core.moveChild(e,t,i)},c.prototype.copyChild=function(e,t,i,n,o,r){return this._core.copyChild(e,t,i,n,o,r)},c.prototype.replaceChild=function(e,t,i,n){return this._core.replaceChild(e,t,i,n)},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,i,n,o,r,a,s,c,l){return this._core.addComponent(e,t,i,n,o,r,a,s,c,l)},c.prototype.addComponentWithUploadResults=function(e,t,i,n,o){return this._core.addComponentWithUploadResults(e,t,i,n,o)},c.prototype.updateComponent=function(e,t,i,n){return this._core.updateComponent(e,t,i,n)},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,i,n,o){return this._core.copyComponent(e,t,i,n,o)},c.prototype.replaceComponent=function(e,t,i,n){return this._core.replaceComponent(e,t,i,n)},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 i=JSON.parse(JSON.stringify(e._data));i["manifest-format-version"]=this._data["manifest-format-version"],delete i.path,(t=new o(i,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 i=this._verify(e);if(null===i)return e["manifest-format-version"]=s,this._core=new n(e,this,t),this._data=e,this;throw i},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,i){return this._core._verifyIntegrity(e,t,i)},e.exports=c},function(e){e.exports={name:"cc-libraries-api-js",version:"3.7.4",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.27","fs-extra":"7.0.1",glob:"7.1.1",punycode:"2.1.1",uuid:"3.3.2","uuid-browser":"3.1.0",yauzl:"2.9.1",yazl:"2.4.3"},optionalDependencies:{"@ccx-public/ingest":"^3.5.0",bufferutil:"1.3.0",ffi:"2.2.0","font-manager":"git+ssh://git@git.corp.adobe.com:michsmit/font-manager.git#v0.3.7","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#v2.0.0","node-imslib":"git+ssh://git@git.corp.adobe.com:ProjectCentral/node-imslib.git#v1.2.7","node-thumbnailgenerator":"git+ssh://git@git.corp.adobe.com:ProjectCentral/node-ThumbnailGenerator.git#v2.0.3","node-vulcanjs":"git+ssh://git@git.corp.adobe.com:slade/VulcanJS.git#v1.2.6",node_ssl:"git+ssh://git@git.corp.adobe.com:ProjectCentral/node_ssl.git#v1.3.0","ps-node":"^0.1.6",ref:"1.3.5",restify:"7.2.0",ws:"6.1.2",xml2js:"0.4.17"},devDependencies:{"7zip":"0.0.6","@adobe/tessa-npm-plugin":"^1.0.1","@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.45","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.4.0","grunt-node-gyp":"3.1.0","ignore-loader":"^0.1.2","ink-docstrap":"1.3.2",istanbul:"0.4.5","jasmine-node":"1.14.5",jsftp:"2.1.3","markdown-toc":"^1.2.0",matchdep:"1.0.1",mkdirp:"0.5.1",mockery:"2.0.0",mustache:"2.3.0",nock:"9.0.14","node-fetch":"2.6.0","raw-loader":"^0.5.1",request:"2.87.0","request-promise-native":"^1.0.7",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",tessa:"tessa-npm-plugin update","tessa-plugin-pr":"tessa-npm-plugin check --errorOnNewVulnerability",start:"node server",debug:"node server.js --debug","generate-rest-docs-toc":"markdown-toc -i --maxdepth=4 './technical_specs/Server REST API.md'"},cepPanels:[{source:"https://artifactory.corp.adobe.com/artifactory/generic-cc-libraries-release/2.6.64/CCLibraries.zxp",destination:"CC_LIBRARIES_PANEL_EXTENSION_2_6_64"},{source:"https://artifactory.corp.adobe.com/artifactory/generic-cc-libraries-release/2.10.86/CCLibraries.zxp",destination:"CC_LIBRARIES_PANEL_EXTENSION_2_10_86"},{source:"https://artifactory.corp.adobe.com/artifactory/generic-cc-libraries-release/2.11.27/CCLibraries.zxp",destination:"CC_LIBRARIES_PANEL_EXTENSION_2_11_27"},{source:"https://artifactory.corp.adobe.com/artifactory/generic-cc-libraries-release/2.13.141/CCLibraries.zxp",destination:"CC_LIBRARIES_PANEL_EXTENSION_2_13_141"},{source:"https://artifactory.corp.adobe.com/artifactory/generic-cc-libraries-release/3.4.23/CCLibraries.zxp",destination:"CC_LIBRARIES_PANEL_EXTENSION_3_4_23"},{source:"https://artifactory.corp.adobe.com/artifactory/generic-cc-libraries-release/3.7.76/CCLibraries.zxp",destination:"CC_LIBRARIES_PANEL_EXTENSION_3_7_76"}],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:"5.0",certification:"Release Candidate",name:"ACCCx5_0_0_{{build}}",volume:"Creative Cloud",build:"^\\d+$"},{product:"ACCC",subproduct:"HDSetup",version:"4.9",certification:"Integration Ready",name:"HDSetup",volume:"Release"}]}},function(e,t){e.exports=require("ws")},function(e,t){e.exports=require("xml2js")},function(e,t,i){var n=i(4),o=i(8);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,i,n,o,r){this.id=e,this.etag=t,this.version=i,this.md5=n,this.length=o,this.type=r},Object.defineProperties(r.prototype,{id:{get(){return this._data.id},set(e){if(this._readOnly)throw new n(n.READ_ONLY,"This object is read-only.");if(this._owner)throw new n(n.READ_ONLY,"Cannot change the id of a component that is part of a branch or element.");if("string"!=typeof e||""===e)throw new n(n.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 n(n.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new n(n.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 n(n.READ_ONLY,"This object is read-only.");if("string"!=typeof e||""===e)throw new n(n.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 n(n.READ_ONLY,"This object is read-only.");if(!o.isValidPath(e))throw new n(n.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 n(n.READ_ONLY,"parentPath is read-only.")}},absolutePath:{get(){return this._data.path&&this._owner?o.appendPathElements(this._parentPath,this._data.path):void 0},set(){throw new n(n.READ_ONLY,"absolutePath is read-only.")}},relationship:{get(){return this._data.rel},set(e){if(this._readOnly)throw new n(n.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new n(n.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 n(n.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new n(n.INVALID_PARAMS,"Expecting a string.");if(!a.hasOwnProperty(e))throw new n(n.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 n(n.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new n(n.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 n(n.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new n(n.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 n(n.READ_ONLY,"This object is read-only.");if(void 0!==e&&"string"!=typeof e)throw new n(n.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 n(n.READ_ONLY,"This object is read-only.");if("number"!=typeof e&&void 0!==e)throw new n(n.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 n(n.READ_ONLY,"This object is read-only.");if("number"!=typeof e&&void 0!==e)throw new n(n.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 n(n.READ_ONLY,"This object is read-only.");if("number"!=typeof e&&void 0!==e)throw new n(n.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=[],i=Object.keys(this._data),n=i.length;for(e=0;e<n;e++){var o=i[e];s[o]||t.push(o)}return t},r.prototype.getValue=function(e){if("string"!=typeof e)throw new n(n.INVALID_PARAMS,'Param "key" must be a string');return this._data[e]},r.prototype.setValue=function(e,t){if(this._readOnly)throw new n(n.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new n(n.INVALID_PARAMS,'Param "key" must be a string');this._data[e]=t,this._setDirty()},r.prototype.removeValue=function(e){if(this._readOnly)throw new n(n.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new n(n.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 n(n.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 n(n.READ_ONLY,"This object is read-only.");if("object"!=typeof e)throw new n(n.INVALID_PARAMS,'Param "link" must be an object.');if("string"!=typeof t)throw new n(n.INVALID_PARAMS,'Param "relationship" must be a string');var i=this._data._links;i||(i=this._data._links={}),i[t]=e,this._setDirty()},r.prototype.removeLink=function(e){if(this._readOnly)throw new n(n.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new n(n.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 o.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 n(n.INVALID_DATA,"Component is missing an id of type string"):null},e.exports=r},function(e,t){e.exports=require("crypto")},function(e,t){e.exports=require("url")},function(e,t,i){var n=i(4),o=n.networkError,r=n.unexpectedResponse,a=i(8),s=a.merge,c=i(51),l=a.appendPathElements;function d(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=[]}d.FileContent=c.FileContent,d.StreamProvider=c.StreamProvider,Object.defineProperties(d.prototype,{maxRedirects:{get(){return this._maxRedirects},set(e){if("number"!=typeof e)throw new n(n.INVALID_PARAMS,"Expecting a number.");this._maxRedirects=Math.floor(e)}},authenticationWhitelist:{get(){return this._authenticationWhitelist},set(e){if(!Array.isArray(e))throw new n(n.INVALID_PARAMS,"Expecting an array.");this._authenticationWhitelist=e}}}),d.prototype.isValidHref=function(e){var t=a.endPointOf(e);return!t||t===this._endPoint},d.prototype.isDomainOnWhitelist=function(e){var t=a.parseURI(e).authority;if(!t||0===t.length)return!0;var i,n=t.length,o=this._authenticationWhitelist.length;for(i=0;i<o;i++){var r=this._authenticationWhitelist[i],s=r.length;if((n>s?t.slice(-s):t)===r)return!0}return!1},d.prototype.getAsset=function(e,t,i,c){if(!(e=this._resolveUrl(e)))return c(new n(n.WRONG_ENDPOINT,"Wrong endpoint: "+e));var l,d={};"string"==typeof t?d["If-None-Match"]=t:s(d,t);var p,h=this,_=0;function u(e,t){if(e)return c(o("Error downloading an asset",e,t));var i=t.statusCode;if(200===i)c(void 0,t);else if(304===i)c(void 0,t);else if(301===i||302===i||303===i||307===i)if(!h._service.handlesRedirects&&h.maxRedirects)if(_<h.maxRedirects){var n=t.headers.location;n?p(n):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=(p=function(t){var n={responseType:i};return t&&(_++,n.reuseRequestDesc=l,h.isDomainOnWhitelist(t)||(d.Authorization=null)),h._service.invoke("GET",t||e,d,void 0,n,u)})()).progress=a.noOp,l},d.prototype.getAssetAsType=function(e,t,i,n){return this.getAsset(e,i,t,function(e,t){if(e)return n(e);if(200===t.statusCode){var i=t.response||t.responseText;n(void 0,i,t.headers.etag,t)}else 304===t.statusCode?n(void 0,null,t.headers.etag,t):n(r("Unexpected response getting asset",e,t))})},d.prototype.abortAll=function(){this._service.abortAll()},d.prototype._resolveUrl=function(e){var t=a.endPointOf(e);if(t){if(t!==this._endPoint)return;return e}return l(this._server,e)},d.prototype._makeRelativeUrl=function(e){var t=a.endPointOf(e);if(t){if(t!==this._endPoint)return;var i=a.parseURI(e);(i.scheme||i.authority)&&(e=i.path,i.query&&(e+="?"+i.query),i.fragment&&(e+="#"+i.fragment))}return e},d.prototype._parseAsyncResponse=function(e){var t=e.responseText||e.response;if(!t)throw new n(n.INVALID_DATA,"No body data.");var i={},o=t.indexOf("\n");if(-1===o)throw new n(n.INVALID_DATA,"Could not find status line.");var r=t.slice(0,13===t.charCodeAt(o-1)?o-1:o).split(" ");if(i.statusCode=parseInt(r[1],10),!i.statusCode)throw new n(n.INVALID_DATA,"Could not find status code.");r.length>2&&(i.statusText=r[2]);var s=t.search(/\r?\n\r?\n/);-1===s&&(s=t.length);var c=t.slice(o+1,s);i.headers=a.parseHeaders(c);var l="\r"===t.charAt(s)?s+4:s+2;return i.response=t.slice(l),i},d.prototype._pollForAsyncResponse=function(e,t,i,n){var s=this,c=Date.now()+1e3*t,l={responseType:"text",reuseRequestDesc:i,noSoonerThen:c};a.log("asynchronous request - polling"),i=this._service.invoke("GET",e,void 0,void 0,l,function(t,c){if(t)return n(o("Error polling for an asynchronous reponse",t,c));var l=c.statusCode;if(202===l){a.log("asynchronous request - not yet ready");var d=c.headers["retry-after"];d&&(d=parseInt(d,10)),s._pollForAsyncResponse(e,d||s.DEFAULT_POLL_DELAY,i,n)}else if(200===l){a.log("asynchronous request - success");try{c=s._parseAsyncResponse(c)}catch(e){return n(r("Error parsing response body.",e,c))}200===(l=c.statusCode)||201===l||204===l?n(void 0,c):n(r("Unexpected response polling for an asynchronous response",t,c))}else a.log("asynchronous request - error"),n(r("Unexpected response polling for an asynchronous response",t,c))})},d.prototype._handle202Response=function(e,t,i,n){var o,a=e.responseText||e.response;try{o=JSON.parse(a)}catch(t){return n(r("Error parsing 202 response body.",t,e))}var s=o.href;if(!s)return n(r("202 response missing an href.",void 0,e));var c=e.headers["retry-after"];c=c?parseInt(c,10):i,this._pollForAsyncResponse(this._resolveUrl(s),c,t,n)},e.exports=d},function(e,t,i){var n=i(4),o=i(72),r=i(97),a=i(0),s=i(14),c=i(2),l=i(1),d=i(18),p=i(20),h=i(16),_=i(15),u=i(11),f=i(7),m=i(28),E=i(5),g=i(100);const y=i(10).promisify;function v(e,t,i){(this._collection=e,this._dcxComposite=t,this._dcxBranch=t.current,this._listenerManager=new E(["change"]),i?(this._publicId=i,this._writable=!1):this._writable=!0,this._filterCache={},this._renditionCache=new g(this),this._autoGCMode={},this._transactionCount=0,this._commitInProgress=!1,this._pendingCommit=!1,this._onCommitCallbacks=[],this._dcxLock=new p,this._networkLock=new p,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(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._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(e=>{var t=new r(this,e);this._addElementToFilter(t),this._elements.push(t)}),this._dcxRemovedElementsNode)&&(this._dcxBranch.getChildrenOf(this._dcxRemovedElementsNode).forEach(e=>{var t=new r(this,e);this._removedElements.push(t)}),this._sortRemovedElements());this._dcxGroupsNode&&this._dcxBranch.getChildrenOf(this._dcxGroupsNode).forEach(e=>{var t=new o(this,e);this._groups.push(t)});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(t=>{t._markDeletedLocally(e)}),this._groups.forEach(t=>{t._markDeletedLocally(e)}),e&&this._listenerManager.removeAll()},v.prototype._removeAllListeners=function(){this._listenerManager.removeAll(),this._elements.forEach(e=>{e._removeAllListeners()})},v.prototype._toJSON=function(){return{id:this.id,name:this.name,elements:this._elements.map(e=>e._toJSON()),renditionCache:this._renditionCache.serializeCache(),groups:this._groups.map(e=>e._toJSON())}},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._doCommit=function(e){const t=()=>{if(e&&!a.SHARED_LOCAL_STORAGE){if(this._deletedLocally)return;this._collection._clearSyncErrors(),this._push(),this._collection._resetPollBackoff()}},i=e=>{var i=this._onCommitCallbacks;this._onCommitCallbacks=[],i.forEach(t=>{t.waitForSuccess&&!e?this._onCommitCallbacks.push(t):this._waitForCommit(t.callback)}),t()};if(!l.hasFileSystem())return void i();if(this._commitInProgress)return void(this._pendingCommit=!0);this._commitInProgress=!0;const n=(e,t)=>{e&&(e=u.getCommitError(e,this.id,t)),this._collection._reportCommitError(e)};l.storageInterface.commitManifest(this,(t,o)=>{n(t,"Failed to write composite to disk"),this._commitInProgress=!1,this._pendingCommit?(this._pendingCommit=!1,0===this._transactionCount&&this._doCommit(e)):i(o)})},v.prototype._waitForCommit=function(e,t){this._commitInProgress||this._transactionCount>0?this._onCommitCallbacks.push({callback:e,waitForSuccess:t}):this._renditionCache._waitForCommit(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 i;this._beginOperation();try{i=e.call(t)}catch(e){throw this._transactionCount--,e}return this._endOperation(),i},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(t=>{e=e.concat(t._getMissingLocalComponents())}),e},v.prototype._gcLocalData=function(e){var t=[],i={},n=[];if(this._removedElements.forEach(e=>{e._shouldGCLocalData()&&(t.push(e),e._forEachRepresentation(function(e){var t=e._dcxComponent,o=e._getCurrentComponentPath();t&&o&&t.etag&&"modified"!==t.state?(i[o]=i[o]||[],i[o].push(t.id)):o&&n.push(o)}))}),0!==t.length){n.forEach(e=>{delete i[e]}),this._elements.forEach(e=>{e._forEachRepresentation(function(e){var t=e._getCurrentComponentPath();t&&delete i[t]})});var o=[];Object.keys(i).forEach(e=>{o.push.apply(o,i[e])}),t.forEach(e=>this._renditionCache.clearCache(e)),l.log("Removing local files for components: [ "+o.join(", ")+" ]"),this._dcxComposite.removeLocalFilesForComponentsWithIDs(o,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,i,n){if(!_.checkDeletedState(this,n)){var o=this._dcxCompositeRenditionMap[e],r=t&&l.getFileNameFromPath(t),s=f.getFileExtension(r),c=l.uuid()+"."+s;f.checkFileSize(t,s=>{s?n(s):l.storageInterface.notifyStartWrite(this,[],()=>{this._dcxBranch.addComponent(r,i,"rendition",c,t,!0,void 0,this._dcxBranch.rootNode,void 0,(t,i)=>{t?n(t):_.checkDeletedState(this,n)||(i.setValue(a.MODIFIED_KEY,(new Date).valueOf()),i.setValue(a.RENDITION_TYPE_KEY,e),o&&this._dcxBranch.removeComponent(o),this._dcxCompositeRenditionMap=_.getCompositeRenditionMap(this._dcxBranch),this._commit(),n(null))})})})}},v.prototype._setRendition=function(e,t,i,n,o){const r=l.fs;let a;const s=t=>{t?o(u.getCommitError(t,this.id,"error writing library rendition")):_.checkDeletedState(this,o)||this._setRenditionFromPath(e,a,n,o)};var c=this.collection._getTempDir();f.ensurePathExists(c,e=>{if(e)o(u.getCommitError(e,this.id,"error creating temp directory"));else if(!_.checkDeletedState(this,o)){var d=m.getExtensions(n)[0],p=l.uuid()+"."+d;a=c+l.getPathSeparator()+p,"buffer"===i?r.writeFile(a,t,s):r.writeFile(a,t,i,s)}})},v.prototype._setRenditionInBrowser=function(e,t,i,n){var o=this._dcxCompositeRenditionMap[e],r=this._collection._syncManager,s=l.uuid();r.uploadNewComponentForLibrary(t,s,i,"rendition",this,(t,i)=>{t?n(t):_.checkDeletedState(this,n)||(i.setValue(a.MODIFIED_KEY,(new Date).valueOf()),i.setValue(a.RENDITION_TYPE_KEY,e),o&&this._dcxBranch.removeComponent(o),this._dcxCompositeRenditionMap=_.getCompositeRenditionMap(this._dcxBranch),this._commit(),n(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 i=this._filterCache[t].indexOf(e);-1!==i&&this._filterCache[t].splice(i,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,i){var n=this._getGroupsNode(),r=this._dcxBranch.addChild(e,void 0,void 0,n);r.type=a.GROUP_TYPE,r.setValue(a.CLASSIFIER_KEY,i),r.setValue(a.ORDER_KEY,t);var s=new o(this,r);return s._updateCreatedTime(),this._groups.push(s),s},v.prototype._doRemoveGroup=function(e,t){var i=this._groups.indexOf(e);this._groups.splice(i,1),this.elements.slice().forEach(i=>{void 0!==i.getOrderInGroup(e)&&(i._doSetOrderInGroup(e,void 0,!0),t&&t(i))}),this._dcxBranch.removeChild(e._dcxNode),e._markDeletedLocally(!0)},v.prototype._getNumberOfElementsInGroup=function(e){if(e){var t=0;return this.elements.forEach(i=>{void 0!==i.getOrderInGroup(e)&&t++}),t}},v.prototype._doCopyGroup=function(e,t,i,n,o){var r=e.library!==t&&t._groups.every(function(t){return t.id!==e.id})?e.id:l.uuid();this._doCopyDCXGroup(e,t,i,n,r,o)},v.prototype._doCopyDCXGroup=function(e,t,i,n,r,a){t._beginOperation(),n&&this._beginOperation();const c=e=>{t._endOperation(),n&&this.endOperation(),a(e)};l.storageInterface.notifyStartWrite(t,[this],()=>{var l=t._getGroupsNode();t._dcxBranch.copyChild(e._dcxNode,l,void 0,r,r,(r,l)=>{if(_.checkDeletedState(this,a))return;if(r)return void c(r);var d=new o(t,l);t._groups.push(d);var p=()=>{_.checkDeletedState(this,a)||(t._endOperation(),n&&(this._doRemoveGroup(e),this.endOperation()),a(null,d))};if(!i)return void p();var h=this.elements.filter(t=>void 0!==t.getOrderInGroup(e));const u=y(this._doCopyElement.bind(this));Promise.all(h.map(e=>u(e,t,n))).then(t=>{h.forEach((i,n)=>{const o=i.getOrderInGroup(e),r=t[n];r._doSetOrderInGroup(d,o,!0),s.reportCopyElement(r,i)}),p()}).catch(c)})})},v.prototype._doCreateElement=function(e,t){var i=this._dcxBranch.addChild(e,void 0,void 0,this._dcxElementsNode);i.path=i.id,i.type=t;var n=new r(this,i);return n._updateCreatedTime(),this._elements.push(n),this._addElementToFilter(n),n},v.prototype._doRemoveElement=function(e,t){var i=this._elements.indexOf(e);-1!==i&&this._elements.splice(i,1),-1!==(i=this._removedElements.indexOf(e))&&this._removedElements.splice(i,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 i=this._elements.indexOf(e);-1!==i&&(this._ensureRemovedElementsSpace(),this._elements.splice(i,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 i=this._removedElements.indexOf(e);-1!==i&&(this._removedElements.splice(i,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,i,n,o){if(this._numActiveCopyNodeOperations<a.MAX_DCX_CONCURRENT_COPIES)return this._numActiveCopyNodeOperations++,void e.copyChild(t,i,void 0,n,n,(e,t)=>{this._numActiveCopyNodeOperations--,o(e,t),this._pendingCopyNodeOperations.length>0&&this._pendingCopyNodeOperations.shift()()});this._pendingCopyNodeOperations.push(()=>this._doCopyDCXNode(e,t,i,n,o))},v.prototype._doCopyDCXElement=function(e,t,i,n,o){t._beginOperation(),l.storageInterface.notifyStartWrite(t,[this],()=>{this._doCopyDCXNode(t._dcxBranch,e._dcxNode,t._dcxElementsNode,n,(n,a)=>{if(_.checkDeletedState(this,o))return;if(n)return t._endOperation(),void o(n);var s=new r(t,a);t._addElementToFilter(s),t._elements.push(s),s._stripObsoleteGroupsData();const c=()=>{_.checkDeletedState(this,o)||(t._endOperation(),i&&this._wrapOperation(()=>this._doRemoveElement(e,!0)),o(null,s))};l.hasFileSystem()?this._renditionCache.copyCache(e,s).then(c,c):c()})})},v.prototype._doCopyElement=function(e,t,i,n){if(t._elements.length>=a.MAX_ELEMENTS)n(new c(c.EXCEEDS_MAX_LIBRARY_SIZE,"Library cannot have more than "+a.MAX_ELEMENTS+" elements",this.id));else{var o=e.id;t._elements.every(function(e){return e.id!==o})&&t._removedElements.every(function(e){return e.id!==o})||(o=l.uuid()),this._doCopyDCXElement(e,t,i,o,n)}},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(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 i=this._getClientData();i[e]=t,this._dcxComposite.clientDataString=JSON.stringify(i)},v.prototype._setCollaboration=function(e){var t=e&&e.collaboration&&e.collaboration.toLowerCase(),i=e&&e.collaboration_role&&e.collaboration_role.toLowerCase(),n=this._getClientDataValue(a.DATA_COLLABORATION_ROLE);if(this.collaboration!==t||n!==i){var o=_.collaborationStateToDCX(t);this._dcxComposite.collaborationType=o,this._setClientDataValue(a.DATA_COLLABORATION_ROLE,i),this._commit(!0,!0),this._notifyChange(),this._revertLocalChangesIfNecessary()}},v.prototype._isDeletedError=function(e){var t=e&&(e.code===n.NO_COMPOSITE||e.code===n.DELETED_COMPOSITE),i=e&&e.code===n.UNEXPECTED_RESPONSE&&e.response&&401===e.response.statusCode;return t||this.collection.isPublic&&i},v.prototype._isAlreadyExistsError=function(e){var t=e&&e.code===n.ALREADY_EXISTS,i=e&&e.code===n.UNEXPECTED_RESPONSE&&e.response&&409===e.response.statusCode;return t||i},v.prototype._isReadOnlyError=function(e){if("incoming"!==this.collaboration)return!1;var t=!1;return!e||e.code!==n.COMPONENT_UPLOAD_ERROR&&e.code!==n.UNEXPECTED_RESPONSE||(e.code===n.UNEXPECTED_RESPONSE&&e.response&&403===e.response.statusCode&&(t=!0),e.code===n.COMPONENT_UPLOAD_ERROR&&Array.isArray(e.failedComponents)&&e.failedComponents.length>0&&(t=!0,e.failedComponents.forEach(e=>{e.error&&e.error.code===n.UNEXPECTED_RESPONSE&&e.error.response&&403===e.error.response.statusCode||(t=!1)}))),t},v.prototype._mergeAndSwitchToBranch=function(e,t,i){var n=void 0!==t,c=e.localData;const d=(t,d)=>{if(_.checkDeletedState(this,i))return;if(t)return void i(u.getCommitError(t,this.id));l.log("Starting merge "+(n?"(local)":"(remote)"));const p={},f=e=>p[e]=(p[e]||0)+1;d.name!==this.name&&(e.name=this.name);var m=e.rootNode.getValue(a.MODIFIED_KEY),E=Math.max(m||0,this.modified||0);d!==this._dcxBranch&&E&&m!==E&&e.rootNode.setValue(a.MODIFIED_KEY,E);const g=e=>{const t={};return _.getCustomDCXData(e.rootNode).forEach(e=>{t[e.namespace+"#"+e.key]=e.value}),t};let y={};const v=g(this._dcxBranch),A=g(d),C=g(e);Object.keys(v).forEach(e=>{y[e]=!0,JSON.stringify(v[e])!==JSON.stringify(A[e])&&(C[e]=v[e])}),Object.keys(C).forEach(e=>{y[e]||A[e]&&!v[e]&&delete C[e]});var I,S,L,O=_.getCompositeRenditionMap(e),R=_.getCompositeRenditionMap(d);Object.keys(this._dcxCompositeRenditionMap).forEach(t=>{var i=this._dcxCompositeRenditionMap[t],n=R[t],o=O[t];n&&i.id===n.id||(o?(i.getValue(a.MODIFIED_KEY)||0)>(o.getValue(a.MODIFIED_KEY)||0)&&(e.removeComponent(o),e.copyComponent(i,e.rootNode)):e.copyComponent(i,e.rootNode))}),Object.keys(R).forEach(t=>{var i=this._dcxCompositeRenditionMap[t],n=R[t],o=O[t];!i&&o&&o.id===n.id&&e.removeComponent(o)}),e.getChildrenOf().forEach(e=>{e.name===a.ELEMENTS_NAME&&(I=e),e.name===a.REMOVED_ELEMENTS_NAME&&(S=e),e.name===a.GROUPS_NAME&&(L=e)}),I||(I=e.addChild(a.ELEMENTS_NAME));var T=function(){S||(S=e.addChild(a.REMOVED_ELEMENTS_NAME))},N=[],D={},b=[];const P=(e,t,i,n)=>{var o=t.getValue(a.ORDER_KEY),r=i&&i.getValue(a.ORDER_KEY),s=n&&n.getValue(a.ORDER_KEY);if(s!==o)e._dcxNode.setValue(a.ORDER_KEY,o);else if(r!==s)return e.order!==r&&e._dcxNode.setValue(a.ORDER_KEY,r),!0;return!1};this._groups.forEach(t=>{var i=t.id,n=t._dcxNode,o=t.modified,r=e.getChildWithId(i),s=r&&r.getValue(a.MODIFIED_KEY),c=d&&d.getChildWithId(i),p=c&&c.getValue(a.MODIFIED_KEY);if(!p&&!s||p&&!s&&o!==p){f("g1: group created locally");var h=e.copyChild(n,(L||(L=e.addChild(a.GROUPS_NAME)),L),void 0,void 0,void 0);t._setDCXNode(h)}else p&&!s&&o===p?(f("g2: group deleted on server"),b.push(t)):p===o&&p===s?(f("g3: no changes to group modified time"),t._setDCXNode(r),P(t,n,r,c)&&N.push(t)):p===o&&p!==s?(f("g4: updated group on server"),t._setDCXNode(r),N.push(t),P(t,n,r,c)):p!==o&&p===s?(f("g5: updated group locally"),t._setDCXNode(e.replaceChild(n,void 0,void 0)),P(t,n,r,c)&&N.push(t)):p!==o&&p!==s?(f("g6: updated group locally and on server (conflict)"),t._setDCXNode(e.replaceChild(n,void 0,void 0)),P(t,n,r,c)&&N.push(t)):l.log("ERROR: unexpected group merge case: base="+p+", current="+o+", pulled="+s);D[i]=!0}),b.forEach(e=>this._doRemoveGroup(e));var w=[],x=[],k=[],M=[],V=[];const F=t=>{var i=t.id,o=t._dcxNode,c=t.modified,p=t.removed,h=e.getChildWithId(i),_=h&&h.getValue(a.MODIFIED_KEY),u=h&&h.getValue(a.REMOVED_KEY),m=d&&d.getChildWithId(i),E=m&&m.getValue(a.MODIFIED_KEY),g=m&&m.getValue(a.REMOVED_KEY);this._dcxBranch=e;const y=()=>p?(T(),S):I,v=()=>!p&&t.removed?(k.push(t),!0):!(!p||t.removed)&&(M.push(t),!0),A=()=>{var e=!1,i=o.getValue(a.DESCRIPTION_DATA_KEY)||{time:0},n=h&&h.getValue(a.DESCRIPTION_DATA_KEY)||{time:0},r=m&&m.getValue(a.DESCRIPTION_DATA_KEY)||{time:0};if(i.time!==r.time){var s=o.getValue(a.DESCRIPTION_KEY);t._dcxNode.setValue(a.DESCRIPTION_KEY,s),t._dcxNode.setValue(a.DESCRIPTION_DATA_KEY,i)}else n.time!==r.time&&(e=!0);var c=o.getValue(a.GROUPS_KEY)||{},l=h&&h.getValue(a.GROUPS_KEY)||{},d=m&&m.getValue(a.GROUPS_KEY)||{},p={};return Object.keys(c).forEach(t=>{var i=c[t],n=l[t],o=d[t];o&&i.order===o.order?n||(e=!0):p[t]=i}),Object.keys(l).forEach(t=>{var i=c[t],n=l[t],o=d[t];o&&!i||p[t]||(p[t]=n,o&&n.order===o.order||(e=!0))}),(Object.keys(p).length>0||Object.keys(l).length>0)&&JSON.stringify(l)!==JSON.stringify(p)&&t._dcxNode.setValue(a.GROUPS_KEY,p),e};if(!E&&!_||E&&!_&&c!==E){f("e1: created element locally");var C=e.copyChild(o,y(),void 0,void 0,void 0);t._setDCXNode(C,!0)}else if(E&&!_&&c===E)f("e2: deleted element on server"),x.push(t);else if(E===c&&E===_){f("e3: no changes to element modified time"),t._setDCXNode(h,!0),g!==p&&(g===u?p&&!u?(f("e3a: removed element locally"),T(),t._dcxNode=e.moveChild(t._dcxNode,void 0,S),t._updateTimestampOnRemove(p)):u&&!p&&(f("e3b: restored element locally"),t._dcxNode=e.moveChild(t._dcxNode,void 0,I),t._updateTimestampOnRestore()):p||(f("e3c: remove/restore element conflict - local restore wins"),t._dcxNode=e.moveChild(t._dcxNode,void 0,I),t._updateTimestampOnRestore()));var L=v(),O=A();(L||O)&&N.push(t),t._ensureRemovedDataValid(n&&!a.SHARED_LOCAL_STORAGE)}else if(E===c&&E!==_)f("e4: updated element on server"),t._setDCXNode(h,n),N.push(t),v(),A(),t._ensureModifiedDataValid(n&&!a.SHARED_LOCAL_STORAGE);else if(E!==c&&E===_){f("e5: updated element locally");var R=e.replaceChild(o,void 0,void 0);t._setDCXNode(R,!0),(p&&!u||u&&!p)&&(t._dcxNode=e.moveChild(t._dcxNode,void 0,y())),A()&&N.push(t)}else if(E!==c&&E!==_){f("e6: updated element locally and on server (conflict)"),t._setDCXNode(h),N.push(t),v(),t._ensureModifiedDataValid(n&&!a.SHARED_LOCAL_STORAGE);var b=l.uuid(),P=e.copyChild(o,y(),void 0,b,b),F=new r(this,P);if(w.push(F),D[F.id]=!0,l.hasFileSystem()){const e=e=>this._renditionCache.copyCache(t,F).then(e,e);V.push(e)}s.reportCollisionElement(t)}else l.log("ERROR: unexpected element merge case: base="+E+", current="+c+", pulled="+_);this._dcxBranch=this._dcxComposite.current,D[i]=!0};this._elements.forEach(F),this._removedElements.forEach(F);var U=e=>{e.removed?this._removedElements.push(e):(this._addElementToFilter(e),this._elements.push(e))};w.forEach(U),this._sortRemovedElements(),x.forEach(e=>this._doRemoveElement(e,!1)),k.forEach(e=>this._doMarkElementRemoved(e,!1)),M.forEach(e=>this._doRestoreElement(e,!1)),this._dcxBranch=e,this._dcxElementsNode=I,this._dcxRemovedElementsNode=S,this._dcxGroupsNode=L,this._dcxCompositeRenditionMap=_.getCompositeRenditionMap(e);const B=(t,i)=>{if(!D[t.id]){var s=t.getValue(a.MODIFIED_KEY),c=d&&d.getChildWithId(t.id),l=c&&c.getValue(a.MODIFIED_KEY);if(l&&s&&l===s)f(i?"g7: deleted group locally":"e7: deleted element locally"),e.removeChild(t);else if(f(i?"g8: created group on server":"e8: created element on server"),i){var p=new o(this,t);this._groups.push(p)}else{var h=new r(this,t);U(h),h._ensureCreatedDataValid(n&&!a.SHARED_LOCAL_STORAGE)}}};var H=this._dcxBranch.getChildrenOf(this._dcxElementsNode),Y=this._dcxRemovedElementsNode?this._dcxBranch.getChildrenOf(this._dcxRemovedElementsNode):[],G=this._dcxGroupsNode?this._dcxBranch.getChildrenOf(this._dcxGroupsNode):[];H.forEach(e=>B(e)),Y.forEach(e=>B(e)),G.forEach(e=>B(e,!0)),Object.keys(p).sort().forEach(e=>{const t=p[e];l.log(`Merge Case ${e} (${t})`)}),this._transactionCount++,Promise.all(V.map(e=>new Promise(t=>e(t)))).then(()=>{_.checkDeletedState(this,i)||(this._transactionCount--,l.storageInterface.resolvePullWithBranch(this,e,c,n,t=>{_.checkDeletedState(this,i)||(t?i(u.getCommitError(t,this.id)):(l.hasFileSystem()||(this._dcxBaseBranch=e.copy()),a.SHARED_LOCAL_STORAGE||n||h.prefetchRenditions(this),i(null),N.forEach(e=>e._listenerManager.notify("change")),this._notifyChange()))}))})};this._waitForCommit(()=>{_.checkDeletedState(this,i)||(t?d(null,t):"unmodified"===this._dcxBranch.compositeState?d(null,this._dcxBranch):this._loadBaseBranch(d))})},v.prototype._pull=function(e){if(this._dcxComposite.href&&this._dcxBranch.isBound)if(this._deletedFromServer)e(null,!1);else{var t=(t,i)=>{_.checkDeletedState(this,e)||(t&&this._collection._reportSyncError(t),this._setSyncState(),this._networkLock.release(),e(t,i))};this._networkLock.obtain(i=>{i?e(null):_.checkDeletedState(this,e)||(this._setSyncState("downloading"),this._collection._syncManager.pullLibrary(this,(i,n)=>{_.checkDeletedState(this,e)||(this._isDeletedError(i)?l.hasFileSystem()&&"modified"===this._dcxBranch.compositeState&&"incoming"!==this.collaboration?(this._doRebindToServer(!1,e),this._networkLock.release()):(this._deletedFromServer=!0,this._notifyChange(),t(null,!0)):i?t(u.getSyncError(i,this.id)):n?this._mergeAndSwitchToBranch(n,void 0,i=>{_.checkDeletedState(this,e)||t(i,!0)}):t(null,!1))}))})}else e(null,!1)},v.prototype._pushWithParameters=function(e,t){const i=(e,i)=>t&&t(null,i);if(!a.SYNCING_ENABLED)return void i(0,!1);if(this._collection._retryTimeoutId)return void i(0,!1);if(this._dcxBranch.isBound&&"modified"!==this._dcxBranch.compositeState)return void i(0,!1);if(this._deletedFromServer)return void i(0,!1);if(!this.isWritable)return void i(0,!1);if(this._pushPending)return void i(0,!1);const o=(e,n)=>{_.checkDeletedState(this,i)||(this._pushFailedDueToQuota=!1,e&&(this._collection._reportSyncError(e),e.code===c.EXCEEDS_QUOTA&&(this._pushFailedDueToQuota=!0)),this._setSyncState(),this._collection._syncManager.pullMissingComponents(this,()=>{_.checkDeletedState(this,t)||(this._networkLock.release(),h.prefetchRenditions(this),i(0,n))}))};this._pushPending=!0,this._networkLock.obtain(t=>{t?i(0,!1):this._waitForCommit(()=>{var t;_.checkDeletedState(this,i)||(this._pushPending=!1,l.hasFileSystem()||(t=this._dcxBranch.copy()),this._setSyncState("uploading"),this._collection._syncManager.pushLibrary(this,e,e=>{if(!_.checkDeletedState(this,i))if(this._isDeletedError(e))l.hasFileSystem()&&"modified"===this._dcxBranch.compositeState&&"incoming"!==this.collaboration?(this._doRebindToServer(!1,i),this._networkLock.release()):(this._deletedFromServer=!0,this._notifyChange(),o(null,!0));else{if(this._isAlreadyExistsError(e)){const t=d.translate("LIBS_RECOVERED_LIBRARY",{name:""}),n=this._collection._recoveredLibraryCount>a.MAX_RECOVERED_LIBRARIES;if(this._dcxComposite.name.endsWith(t)||n){const t=n?"count exceeded":"already recovered";return l.log(`Failed to recover library ${t}: ${this.id}`),void o(u.getSyncError(e,this.id))}return this._dcxComposite.name=d.translate("LIBS_RECOVERED_LIBRARY",{name:this._dcxComposite.name}),l.log(`Recovering library due to 409 error: ${this.id}`),this._collection._recoveredLibraryCount++,this._doRebindToServer(!0,i),void this._networkLock.release()}if(this._isReadOnlyError(e))return l.log("Push failed due to read only. Reverting: "+this.id),this._setClientDataValue(a.DATA_COLLABORATION_ROLE,"viewer"),void this._revertLocalChangesIfNecessary(function(e){o(e,!1)});if(e&&e.code===c.TRANSFER_ABORTED)o(null,!0);else{if(e&&e.code===n.UPDATE_CONFLICT){if(l.log("Push failed due to conflict: "+this.id),this._numUpdateConflicts++,this._numUpdateConflicts<=a.MAX_UPDATE_CONFLICTS)return this._sync(!1,i),void this._networkLock.release();s.reportUnexpectedState(this,"updateConflict"),l.log("Reached maximum number of update-conflict retries: "+this.id)}this._numUpdateConflicts=0,e&&e.code===n.COMPONENT_UPLOAD_ERROR&&(l.log("Push failed due to component upload failure: "+this.id),_.fixLocalComponents(this,e.failedComponents)),e?o(u.getSyncError(e,this.id)):l.storageInterface.acceptPush(this,e=>{_.checkDeletedState(this,i)||(e?o(u.getCommitError(e,this.id),!0):(l.hasFileSystem()||(this._dcxBaseBranch=t),o(null,!0)))})}}}))})})},v.prototype._loadBaseBranch=function(e){l.hasFileSystem()?this._dcxComposite.loadBaseBranch((t,i)=>{this._waitForCommit(()=>e(t,i))}):e(null,this._dcxBaseBranch)},v.prototype._revertLocalChangesIfNecessary=function(e=(()=>void 0)){this.isWritable||"modified"!==this._dcxBranch.compositeState?e(null):this._loadBaseBranch((t,i)=>{this._transactionCount++,_.recoverReadOnlyEdits(this,i,t=>{t&&l.log("Error recovering library changes: "+t),this._transactionCount--;var n=i.copy(),o=this.collaboration,r=this._getClientDataValue(a.DATA_COLLABORATION_ROLE);this._mergeAndSwitchToBranch(n,this._dcxBranch,t=>{if(t)l.log("Error Reverting: "+this.id),e(t);else{var i=_.collaborationStateToDCX(o);this._dcxComposite.collaborationType=i,this._setClientDataValue(a.DATA_COLLABORATION_ROLE,r),this._commit(!0,!0),this._waitForCommit(()=>{this._notifyChange(),e(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){if(this._deletingFromServerInProgress||this._abortPushOrPull(),!this._dcxComposite.href)return void t(null);if(this._deletedFromServer)return void t(null);this._deletingFromServerInProgress=!0;const i=e=>{this._deletingFromServerInProgress=!1,this._setSyncState(),this._networkLock.release(),t(e)};this._networkLock.obtain(o=>{o?t(null):this._deletedFromDisk?i(null):(this._setSyncState("uploading"),this._dcxBranch.compositeState="pendingDelete",this._commit(!0,!0),this._waitForCommit(()=>{this._deletedFromDisk?i(null):this._collection._syncManager.pushDeletedLibrary(this,this.collaboration,e,t=>{t?this._isDeletedError(t)?(this._deletedFromServer=!0,t=null):(e||t.code!==n.UPDATE_CONFLICT)&&(t=u.getSyncError(t,this.id),this._collection._reportSyncError(t)):this._deletedFromServer=!0,i(t)})}))})},v.prototype._doRebindToServer=function(e,t){this._deletedFromServer=!1;var i=e||"incoming"===this.collaboration?"resetIdentity":"resetBinding",n=this.id;this._dcxComposite[i](e=>{_.checkDeletedState(this,t)||(e?t(e):(this._transactionCount++,this.id!==n&&(this._collection._libraryIdMap[this.id]=this,delete this._collection._libraryIdMap[n]),f.moveLibrary(this,n,e=>{_.checkDeletedState(this,t)||(this._transactionCount--,e?t(e):(this._collection._syncManager.prepareCompositeForPush(this._dcxComposite),this._setCollaboration(),this._commit(!1,!0),this._pushWithParameters(!0,t)))})))})},v.prototype._sync=function(e,t){const i=(e,i)=>{t&&this._waitForSyncToFinish(()=>t(e,i))};if(a.SHARED_LOCAL_STORAGE||!a.SYNCING_ENABLED)return void i(null,!1);if(this._collection._retryTimeoutId)return void i(null,!1);this._collection._clearSyncErrors(this.id);const n=(e,t)=>{_.checkDeletedState(this,i)||(e?i(e,t):this._push((e,n)=>{_.checkDeletedState(this,i)||i(e,t||n)}))};e?n(null,!1):this._pull(n)},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)}},toolkitId:{get(){return this.getValue(a.TOOLKIT_NAMESPACE,a.TOOLKIT_ID_KEY)},set(){throw new c(c.READ_ONLY,"toolkitId 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,i){if(i=i||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 n=this._doCreateGroup(e,t,i);return this._commit(),s.reportCreateGroup(n),n},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);let i=0;this._doRemoveGroup(e,e=>{t?(this.removeElement(e),i++):e._listenerManager.notify("change")}),this._commit(),s.reportDeleteGroup(e,t,i)},v.prototype.moveGroup=function(e,t,i,n){if(!_.checkDeletedState(this,n))if(this.isWritable)if(e)if(-1!==this._groups.indexOf(e))if(t)if(this!==t){var o;if(t.isWritable)return i&&(o=this._getNumberOfElementsInGroup(e)),this._doCopyGroup(e,t,i,!0,function(t,r){t?n(t):(s.reportMoveGroup(r,e,i,o),n(null,r))});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,"Group not in this library",this.id));else n(new c(c.INVALID_PARAMETER,"No group specified",this.id));else n(new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id))},v.prototype.copyGroup=function(e,t,i,n){if(!_.checkDeletedState(this,n))if(e)if(-1!==this._groups.indexOf(e))if(t){var o;if(t.isWritable)return i&&(o=this._getNumberOfElementsInGroup(e)),this._doCopyGroup(e,t,i,!1,function(t,r){t?n(t):(s.reportCopyGroup(r,e,i,o),n(null,r))});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,"Group not in this library",this.id));else n(new c(c.INVALID_PARAMETER,"No group specified",this.id))},v.prototype.createElement=function(e,t,i=!1){if(_.checkDeletedState(this),!this.isWritable)throw new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id);if(!(i=i&&t===a.COLOR_ELEMENT_TYPE)&&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(()=>{var i=this._doCreateElement(e,t);return s.reportCreateElement(i),i.beginOperation(),i})},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(()=>{for(;e._transactionCount>0;)e.endOperation();t?this._doRemoveElement(e,!0):this._doMarkElementRemoved(e,!0),s.reportDeleteElement(e,t)})},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(()=>{this._doRestoreElement(e,!0),s.reportRestoreElement(e)})},v.prototype.copyElement=function(e,t,i){if(!_.checkDeletedState(this,i))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,n){t?i(t):(s.reportCopyElement(n,e),i(null,n))});i(new c(c.NOT_ALLOWED,"you do not have write access to the destination library",t.id))}else i(new c(c.INVALID_PARAMETER,"No destination library specified",this.id));else i(new c(c.INVALID_PARAMETER,"Element not in this library",this.id));else i(new c(c.INVALID_PARAMETER,"No element specified",this.id))},v.prototype.moveElement=function(e,t,i){if(!_.checkDeletedState(this,i))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,n){t?i(t):(s.reportMoveElement(n,e),i(null,n))});i(new c(c.NOT_ALLOWED,"you do not have write access to the destination library",t.id))}else i(new c(c.INVALID_PARAMETER,"Move must have a different destination library",this.id));else i(new c(c.INVALID_PARAMETER,"No destination library specified",this.id));else i(new c(c.INVALID_PARAMETER,"Element not in this library",this.id));else i(new c(c.INVALID_PARAMETER,"No element specified",this.id));else i(new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id))},v.prototype.getValues=function(){return _.getCustomDCXData(this._dcxBranch.rootNode)},v.prototype.setValue=function(e,t,i){if(_.checkDeletedState(this),!this.isWritable)throw new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id);if(e===a.DL_NAMESPACE)throw new c(c.INVALID_PARAMETER,"Reserved namespace",this.id);var n,o=_.getDCXKey(e,t);try{n=JSON.parse(JSON.stringify(i))}catch(e){throw new c(c.INVALID_PARAMETER,"Value cannot be serialized to JSON",this.id)}this._dcxBranch.rootNode.setValue(o,n),this._commit()},v.prototype.getValue=function(e,t){if(e===a.DL_NAMESPACE)throw new c(c.INVALID_PARAMETER,"Reserved namespace",this.id);var i=_.getDCXKey(e,t);return this._dcxBranch.rootNode.getValue(i)},v.prototype.removeValue=function(e,t){if(e===a.DL_NAMESPACE)throw new c(c.INVALID_PARAMETER,"Reserved namespace",this.id);const i=_.getDCXKey(e,t);this._dcxBranch.rootNode.removeValue(i)},v.prototype.getRenditionPath=function(e,t){if(l.hasFileSystem()){if(!_.checkDeletedState(this,t)&&this._checkRenditionType(e,t)){var i=this._dcxCompositeRenditionMap[e];if(!i)return t(null);var n=this._dcxBranch.assetOfComponent(i);if(n)return t(null,n);this._networkLock.obtain(e=>{e?t(e):_.checkDeletedState(this,t)?this._networkLock.release():(this._setSyncState("downloading"),this._collection._syncManager.downloadComponent(this._dcxBranch,i,e=>{this._networkLock.release(),this._setSyncState(),e?t(u.getSyncError(e,this.id)):_.checkDeletedState(this,t)||(this._commit(!0,!0),t(null,this._dcxBranch.assetOfComponent(i)))}))})}}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 i=this.getRenditionURL(e);if(!i)return t(null);this._collection._syncManager.appendAccessTokenToURL(i,t)}},v.prototype.setRendition=function(e,t,i,n,o){if(!_.checkDeletedState(this,o)&&this._checkRenditionType(e,o))if(t)if(this.isWritable)if(l.hasFileSystem()){if(!_.checkEncoding(i,["utf8","ascii","base64","buffer"],o))return;this._setRendition(e,t,i,n,o)}else{if(void 0!==i)return void o(new c(c.INVALID_PARAMETER,"Encoding parameter not supported in-browser"));this._setRenditionInBrowser(e,t,n,o)}else o(new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id));else o(new c(c.INVALID_PARAMETER,"content must exist",this.id))},v.prototype.setRenditionFromPath=function(e,t,i,n){_.checkDeletedState(this,n)||this._checkRenditionType(e,n)&&("string"==typeof t?l.hasFileSystem()?this.isWritable?this._setRenditionFromPath(e,t,i,n):n(new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id)):n(new c(c.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this.id)):n(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(()=>{this._dcxBranch.removeComponent(t),this._dcxCompositeRenditionMap=_.getCompositeRenditionMap(this._dcxBranch),this._commit()})},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){const i=this.elements.find(t=>t.id===e);return i||t?i:this.removedElements.find(t=>t.id===e)},Object.freeze(v),Object.seal(v.prototype),e.exports=v},function(e,t,i){const n=i(1),o=i(7),r=i(11),a=i(10).promisify,s=(e,t)=>{const i=e[t].bind(e);return(...e)=>a(i)(...e).catch(e=>Promise.reject(r.getCommitError(e)))};e.exports={stat(e){const t=n.fs;return s(t,"stat")(e)},statSync(e){try{return n.fs.statSync(e)}catch(e){}},unlink(e){const t=n.fs;return s(t,"unlink")(e)},readdir(e){const t=n.fs;return s(t,"readdir")(e)},rename:(e,t)=>s(o,"rename")(e,t),copy:(e,t)=>s(o,"copyFile")(e,t),ensureDir:e=>s(o,"ensurePathExists")(e),remove(e){return this.stat(e).then(t=>t&&t.isDirectory()?s(o,"recursiveDeleteDirectory")(e):this.unlink(e))}}},function(e,t,i){const n=i(1);e.exports={join:(...e)=>e.join(n.getPathSeparator()),relative(e,t){const i=n.getPathSeparator(),o=e.replace(/\\/g,i).split(i),r=t.replace(/\\/g,i).split(i);for(;o[0]===r[0];)o.shift(),r.shift();return new Array(o.length).fill("..").concat(r).join(i)}}},function(e,t,i){var n=i(0),o=i(16),r={getStockData:function(e){return e&&e.getValue(n.STOCK_NAMESPACE,n.STOCK_DATA_KEY)},getStockDataForElement:function(e,t,i){var n=void 0===t?e.getPrimaryRepresentation():e.representations[t],a=r.getStockData(n);return a&&n.isExternalLink&&(o.shouldPrefetchExternalLink(n)&&!n.getCachedContentPath()||n.getCachedExternalLinkError())?r.getStockDataForElement(e,void 0===t?0:t+1,i||a.content_id):(!a&&i&&(a={content_id:i}),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===n.STOCK_STATE_PURCHASED)return String(t.license)}};e.exports=r},function(e,t,i){var n=i(4),o=i(65),r=i(40),a=i(13),s=i(8);function c(e,t,i){this._readOnly=i,this._owner=t,this._setData(e),this._localStorage=void 0}function l(e,t,i,o,r,a,c,l){var d=t._owner._core,p=e._owner._core,h=i&&e.id===t.id,_=p._getSourceHrefOfComponent(e),u=d.getComponentWithId(t.id),f=o&&(!u||!u.etag)&&"unmodified"===e.state,m=!h&&!_,E=m;if(r&&!u&&(_||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,h||(t.state="modified")),m){if(f){if(_=p._getHrefOfComponent(e),d._setSourceHrefOfComponent(_,t,c),!_&&E)throw new n(n.INVALID_STATE,"Failed to determine the source href of a component that does not have a local file.")}else if(E)throw new n(n.INVALID_STATE,"Could not use server-to-server copy for component "+e.id)}else d._setSourceHrefOfComponent(_,t,c);_&&(t.state="modified")}Object.defineProperties(c.prototype,{rootNode:{get(){return this.getChildWithAbsolutePath(o.ROOT_PATH)},set(){throw new n(n.READ_ONLY,'Property "rootNode" is read-only.')}},hasLocalStorage:{get(){return this._localStorage},set(){throw new n(n.READ_ONLY,"Cannot set the property hasLocalStorage.")}},isDirty:{get(){return this._isDirty},set(){throw new n(n.READ_ONLY,"Cannot set the property isDirty.")}},changeCount:{get(){return this._data.local&&this._data.local.change||0},set(){throw new n(n.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 o?t:void 0},c.prototype.getChildrenOf=function(e){if(!(e=e?this._allNodes[e.id]:this.rootNode))throw new n(n.INVALID_PARAMS,"Unknown node");var t,i=[],o=e._data.children;if(Array.isArray(o))for(t=0;t<o.length;t++){var r=o[t],a=this._allNodes[r.id];if(!a)throw new n(n.INVALID_DATA,"Node not in cache");i[i.length]=a}return i},c.prototype.addChild=function(e,t,i,r){if(this._readOnly)throw new n(n.READ_ONLY,"This object is read-only.");if(t=t||s.generateUuid(),this._allNodes[t])throw new n(n.DUPLICATE_VALUE,"Node already exists in branch.");if(i&&("number"!=typeof i||i%1!=0))throw new n(n.INVALID_PARAMS,'Param "index" must be an integer.');var a=r?this._allNodes[r.id]:this.rootNode;if(!a)throw new n(n.INVALID_PARAMS,"Unknown parent node.");var c=new o;c.id=t,e&&(c.name=e),c._parentPath=a.absolutePath||a._parentPath;var l=a._data.children;return l?(i>=0&&i<=l.length||(i=l.length),i===l.length?l[i]=c._data:l.splice(i,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 n(n.READ_ONLY,"This object is read-only.");if(!e)throw new n(n.INVALID_PARAMS,'Expecting param "node".');if(e.isRoot)throw new n(n.INVALID_PARAMS,"Cannot remove the root node.");var t=e.id;if(!t)throw new n(n.INVALID_PARAMS,'Param "node" must have an id.');var i=this._nodeDataOfParentOfNode(e);if(!i)throw new n(n.INVALID_PARAMS,"Node not found in this branch.");return i.parentNodeData.children.splice(i.index,1),0===i.parentNodeData.children.length&&delete i.parentNodeData.children,e=this._allNodes[t],this._removeNodeFromCachesRecursively(e._data),this._setDirty(),e},c.prototype.moveChild=function(e,t,i){if(this._readOnly)throw new n(n.READ_ONLY,"This object is read-only.");if(!e)throw new n(n.INVALID_PARAMS,'Expecting param "node".');if(e.isRoot)throw new n(n.INVALID_PARAMS,"Cannot move the root node.");if(t&&("number"!=typeof t||t%1!=0))throw new n(n.INVALID_PARAMS,'Param "index" must be an integer.');var o=e.id;if(!o)throw new n(n.INVALID_PARAMS,'Param "node" must have an id.');var r=this._nodeDataOfParentOfNode(e);if(e=this._allNodes[o],!r)throw new n(n.INVALID_PARAMS,"Node not found in this branch.");var a=i?this._allNodes[i.id]:this.rootNode;if(!a)throw new n(n.INVALID_PARAMS,"Unknown parent node.");if(this._nodeIdIsDescendantOf(a.id,e._data))throw new n(n.INVALID_PARAMS,"Must not create a cycle.");var s=r.parentNodeData.children.splice(r.index,1)[0];try{var c=a._data.children;c?(t>=0&&t<=c.length||(t=c.length),t===c.length?c[t]=s:c.splice(t,0,s)):a._data.children=[s]}catch(e){throw r.parentNodeData.children.splice(r.index,0,s),e}return 0===r.parentNodeData.children.length&&delete r.parentNodeData.children,this._setDirty(),this._allNodes[o]},c.prototype.copyChild=function(e,t,i,n,o,r){return this._copyChild(e,t,i,n,o,!1,r)},c.prototype.replaceChild=function(e,t,i,n){return this._copyChild(e,void 0,void 0,t,i||e.id,!0,n)},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 n(n.INVALID_PARAMS,"Unknown node");var t,i=[],o=e._data.components;if(Array.isArray(o))for(t=0;t<o.length;t++){var r=o[t],a=this._allComponents[r.id];if(!a)throw new n(n.INVALID_DATA,"Component not in cache");i[i.length]=a}return i},c.prototype.addComponent=function(e,t,i,o,a,c,l,d,p,h){var _=this._localStorage;if(!_)throw new n(n.NO_LOCAL_STORAGE,"No local storage. Use AdobeDCXCompositeXfer.uploadNewComponent() followed by addComponentWithUploadResults()");if("function"!=typeof h&&a)throw new n(n.INVALID_PARAMS,'Param "callback" must be a function.');if(this._readOnly)throw new n(n.READ_ONLY,"This object is read-only.");if(p&&"string"!=typeof p)throw new n(n.INVALID_PARAMS,'Param "id" must be of type string.');if(!a&&!l)throw new n(n.INVALID_PARAMS,"Must provide either source or sourceHref.");try{if(l){var u=this._getBranchOf(this).compositeHref;if(u){var f=s.endPointOf(u),m=s.endPointOf(l);if(f&&m&&f!==m)throw new n(n.WRONG_ENDPOINT,"Given source href has an invalid endpoint: "+m)}}var E=this._local();p=p||s.generateUuid();var g=new r;g.id=p,g.name=e,g.type=t,g.relationship=i,g.path=o,g.state="modified";var y=this,v=function(e){if(!e)try{if(p&&y._allComponents[p])throw new n(n.DUPLICATE_VALUE,'The "id" of a component must be unique.');var t=d?y._allNodes[d.id]:y.rootNode;if(!t)throw new n(n.INVALID_PARAMS,"Unknown parent node.");var i=y._normalizedAbsolutePathForItem(g,t);if(y._absolutePaths[i])throw new n(n.DUPLICATE_VALUE,"Duplicate absolute path: "+i);if(!s.isValidAbsolutePath(i))throw new n(n.INVALID_PARAMS,"Invalid absolute path: "+i);g._parentPath=t.absolutePath||t._parentPath;var o=t._data.components;o?o.push(g._data):t._data.components=[g._data],g._owner=y._owner,l&&y._setSourceHrefOfComponent(l,g),y._allComponents[g.id]=g,y._absolutePaths[i]=g,y._setDirty()}catch(t){_.removeComponentAsset(g,E),l&&y._setSourceHrefOfComponent(void 0,g),g=void 0,e=t}if(h)return h(e,g);if(e)throw e;return g};if(!a)return v();_.ingestComponentAsset(g,a,c,E,v)}catch(e){if(h)return h(e);throw e}},c.prototype.addComponentWithUploadResults=function(e,t,i,o,a){if(this._readOnly)throw new n(n.READ_ONLY,"This object is read-only.");if(a.compositeId!==this._owner.compositeId)throw new n(n.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 n(n.INVALID_PARAMS,"Param uploadResults must contain records of exactly one component upload.");if(this._localStorage)throw new n(n.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 n(n.DUPLICATE_VALUE,"Duplicate component id: "+l);var d=o?this._allNodes[o.id]:this.rootNode;if(!d)throw new n(n.INVALID_PARAMS,"Unknown parent node.");var p=new r;p.id=l,p.name=e,p.type=c.type,p.relationship=t,p.path=i,p.state="unmodified",p.etag=c.etag,p.length=c.length,p.version=c.version,p.md5=c.md5;var h=this._normalizedAbsolutePathForItem(p,d);if(this._absolutePaths[h])throw new n(n.DUPLICATE_VALUE,"Duplicate absolute path: "+h);p._parentPath=d.absolutePath||d._parentPath;var _=d._data.components;return _?_.push(p._data):d._data.components=[p._data],p._owner=this._owner,this._allComponents[l]=p,this._absolutePaths[h]=p,this._setDirty(),p},c.prototype.updateComponent=function(e,t,i,o){var r=this._localStorage;if(!r)throw new n(n.NO_LOCAL_STORAGE,"No local storage. Use AdobeDCXCompositeXfer.uploadComponent() to upload a new component asset and then call updateComponentWithUploadResults()");if("function"!=typeof o)throw new n(n.INVALID_PARAMS,'Param "callback" must be a function.');if(this._readOnly)throw new n(n.READ_ONLY,"This object is read-only.");if(!(e=this._allComponents[e.id]))throw new n(n.INVALID_PARAMS,"Unknown component.");try{var a=this;r.ingestComponentAsset(e,t,i,this._local(),function(t){if(!t)try{"modified"!==e.state?e.state="modified":a._setDirty(),a._setSourceHrefOfComponent(void 0,e)}catch(i){t=i,e=void 0}o(t,e)})}catch(e){o(e)}},c.prototype.updateComponentWithUploadResults=function(e,t){if(this._readOnly)throw new n(n.READ_ONLY,"This object is read-only.");if(!(e=this._allComponents[e.id]))throw new n(n.INVALID_PARAMS,"Unknown component.");if(this._localStorage)throw new n(n.INVALID_PARAMS,"This method is for in-browser use only. Use updateComponent() instead.");if(t.compositeId!==this._owner.compositeId)throw new n(n.INVALID_PARAMS,"Param uploadResults does not appear valid to be for this composite.");var i=t.records[e.id];if(!i)throw new n(n.INVALID_PARAMS,"Param uploadResults does not contain an upload record for the given component.");return e.etag=i.etag,e.version=i.version,e.md5=i.md5,e.length=i.length,e},c.prototype.removeComponent=function(e){if(this._readOnly)throw new n(n.READ_ONLY,"This object is read-only.");if(!e)throw new n(n.INVALID_PARAMS,'Expecting param "component".');var t=e.id;if(!t)throw new n(n.INVALID_PARAMS,'Param "component" must have an id.');var i=this._nodeDataOfParentOfComponent(e);if(!i)throw new n(n.INVALID_PARAMS,"Component not found in this branch.");return i.parentNodeData.components.splice(i.index,1),0===i.parentNodeData.components.length&&delete i.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 n(n.READ_ONLY,"This object is read-only.");if(!e)throw new n(n.INVALID_PARAMS,'Expecting param "component".');var i=e.id;if(!i)throw new n(n.INVALID_PARAMS,'Param "component" must have an id.');var o=this._nodeDataOfParentOfComponent(e);if(!o)throw new n(n.INVALID_PARAMS,"Component not found in this branch.");var r=t?this._allNodes[t.id]:this.rootNode;if(!r)throw new n(n.INVALID_PARAMS,"Unknown parent node.");var a=this._normalizedAbsolutePathForItem(e,r);if(this._absolutePaths[a])throw new n(n.DUPLICATE_VALUE,"Duplicate absolute path: "+a);var s=o.parentNodeData.components.splice(o.index,1)[0],c=r._data.components;return c?c.push(s):r._data.components=[s],0===o.parentNodeData.components.length&&delete o.parentNodeData.components,e=this._allComponents[i],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,i,n,o){return this._copyComponent(e,t,i,n,!1,o)},c.prototype.replaceComponent=function(e,t,i,n){return this._copyComponent(e,void 0,t,i||e.id,!0,n)},c.prototype.assetOfComponent=function(e,t){try{if(!this._localStorage)throw new n(n.NO_LOCAL_STORAGE,"No local storage.");if(!e)throw new n(n.INVALID_PARAMS,'Expecting param "component".');if(!e.id)throw new n(n.INVALID_PARAMS,'Param "component" must have an id.');var i=this._localStorage.componentAssetPath(e,this._local());if(!t)return i;a.exists(i,function(e){t(void 0,e?i:null)})}catch(e){if(!t)throw e;t(e)}},c.prototype._getHrefOfComponent=function(e){var t,i=this._getBranchOf(e).compositeHref;return i&&void 0!==e.version&&(t=s.appendPathElements(i,e.id),t+=";version="+e.version),t},c.prototype._setSourceHrefOfComponent=function(e,t,i){var n=t.id,o=this._componentSourceHrefLookup(!0,i);e?o[n]=e:o[n]&&delete o[n]},c.prototype._getSourceHrefOfComponent=function(e,t){var i=e.id,n=this._componentSourceHrefLookup(!1,t);if(n)return n[i]},c.prototype._copySourceHrefsFrom=function(e){var t=e._componentSourceHrefLookup(!1),i=this.allComponents(),n=i.length;if(n&&t){var o,r=this._componentSourceHrefLookup(!0);for(o=0;o<n;o++){var a=i[o].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),i=this._getBranchOf(e);return t._data.id===i._data.id&&(t.compositeHref===i.compositeHref&&this._localStorage===e._localStorage)},c.prototype._stringify=function(e,t){if(e){var i=this._data.local,n=null;try{delete this._data.local,n=JSON.stringify(this._data,void 0,t?2:void 0)}catch(e){throw e}finally{i&&(this._data.local=i)}return n}return JSON.stringify(this._data,void 0,t?2:void 0)},c.prototype._setData=function(e){var t=new o(e,this._readOnly,!0);t._owner=this._owner,t._parentPath="";var i={},a={},c={};a[t.id]=t,c[o.ROOT_PATH]=t;var l=this,d=function(e,t,i,a,c){var p,h,_,u=e.components;if(Array.isArray(u))for(p=0;p<u.length;p++){var f=u[p],m=new r(f,l._readOnly);if(t[m.id])throw new n(n.INVALID_DATA,"Duplicate component id: "+m.id);if(m._owner=l._owner,m._parentPath=c,a[_=l._normalizedAbsolutePathForItem(m)])throw new n(n.INVALID_DATA,"Duplicate absolute path: "+_);if(!s.isValidAbsolutePath(_))throw new n(n.INVALID_DATA,"Invalid absolute component path: "+_);t[m.id]=m,a[_]=m}var E=e.children;if(Array.isArray(E))for(p=0;p<E.length;p++){var g=E[p],y=new o(g,l._readOnly);if(i[y.id])throw new n(n.INVALID_DATA,"Duplicate node id: "+y.id);if(h=y.path,y._owner=l._owner,y._parentPath=c,h){if(a[_=l._normalizedAbsolutePathForItem(y)])throw new n(n.INVALID_DATA,"Duplicate absolute path: "+_);if(!s.isValidAbsolutePath(_))throw new n(n.INVALID_DATA,"Invalid node absolute path: "+_);a[_]=y}i[y.id]=y,d(g,t,i,a,y.path?s.appendPathElements(c,y.path):c)}};return d(e,i,a,c,o.ROOT_PATH),this._data=e,this._allComponents=i,this._allNodes=a,this._absolutePaths=c,this._isDirty=!1,this},c.prototype._removeNodeFromCachesRecursively=function(e){var t,i=e.components;if(Array.isArray(i))for(t=0;t<i.length;t++){var n=i[t].id,o=this._allComponents[n];delete this._allComponents[n],delete this._absolutePaths[this._normalizedAbsolutePathForItem(o)],o._owner=void 0,this._localStorage&&(this._localStorage.removeComponentAsset(o,this._local()),this._setSourceHrefOfComponent(void 0,o))}var r=e.children;if(Array.isArray(r))for(t=0;t<r.length;t++)this._removeNodeFromCachesRecursively(r[t]);var a=e.id,s=this._allNodes[a];delete this._allNodes[a],s.path&&delete this._absolutePaths[this._normalizedAbsolutePathForItem(s)],s._owner=void 0},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 n(n.READ_ONLY,"This object is read-only.");if(t||(t=e?this._local():this._data.local)){var i=t["componentS2SCopy#srcHref"];return!i&&e&&(i=t["componentS2SCopy#srcHref"]={}),i}},c.prototype._recursiveReset=function(e,t){var i,n=e.components;if(n)for(i=n.length-1;i>=0;i--){var o=n[i];"committedDelete"===o.state?(delete n[i],delete this._allComponents[o.id],delete o._owner,this._localStorage&&this._localStorage.removeComponentAsset(o,this._local()),this._setSourceHrefOfComponent(void 0,o,this._local())):(delete o.etag,delete o.version,delete o.length,delete o.md5,o.state="modified",t&&t(o))}var r=e.children;if(r)for(i=0;i<r.length;i++)this._recursiveReset(r[i],t)},c.prototype._nodeIdIsDescendantOf=function(e,t){var i,n=t.children;if(n)for(i=0;i<n.length;i++){var o=n[i];if(o.id===e||this._nodeIdIsDescendantOf(e,o))return!0}return!1},c.prototype._recursivelyGetAllComponentsOfChild=function(e,t){t=t||[];var i,n,o=e._data||e,r=o.components;if(r)for(n=r.length,i=0;i<n;i++)t[t.length]=this._allComponents[r[i].id];var a=o.children;if(a)for(n=a.length,i=0;i<n;i++)t=this._recursivelyGetAllComponentsOfChild(a[i],t);return t},c.prototype._nodeDataOfParentOfNode=function(e,t){t=t||this._data;var i,n=e._data.id,o=t.children;if(o)for(i=0;i<o.length;i++){var r=o[i];if(r.id===n)return{parentNodeData:t,index:i};var a=this._nodeDataOfParentOfNode(e,r);if(a)return a}return null},c.prototype._nodeDataOfParentOfComponent=function(e,t){t=t||this._data;var i,n=e._data.id,o=t.components;if(o)for(i=0;i<o.length;i++){if(o[i].id===n)return{parentNodeData:t,index:i}}var r=t.children;if(r)for(i=0;i<r.length;i++){var a=r[i],s=this._nodeDataOfParentOfComponent(e,a);if(s)return s}return null},c.prototype._determineAbsolutePathChangesRecursively=function(e,t,i){var n,o=e.components;if(o)for(n=0;n<o.length;n++){var r=o[n],a=this._allComponents[r.id];i.push({item:a,parentPath:t,absPath:s.appendPathElements(t,r.path)})}var c=e.children;if(c)for(n=0;n<c.length;n++){var l=c[n],d=this._allNodes[l.id],p=l.path,h=p?s.appendPathElements(t,p):t;i.push({item:d,parentPath:t,absPath:p?h:void 0}),this._determineAbsolutePathChangesRecursively(l,h,i)}},c.prototype._setPathOfNode=function(e,t){var i=t?s.appendPathElements(e.parentPath,t):e.parentPath,o=[{item:e,absPath:t?i:void 0}];this._determineAbsolutePathChangesRecursively(e._data,i,o);var r,a,c=s.flatCopy(this._absolutePaths);for(r=0;r<o.length;r++){var l=o[r].item;l._data.path&&delete c[this._normalizedAbsolutePathForItem(l)]}for(r=0;r<o.length;r++)if((a=o[r]).absPath){var d=a.absPath.toLowerCase();if(c[d])throw new n(n.DUPLICATE_VALUE,"Duplicate absolute path: "+d);if(!s.isValidAbsolutePath(d))throw new n(n.INVALID_PARAMS,"Invalid absolute path: "+d);c[d]=a.item}for(r=0;r<o.length;r++)(a=o[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 n(n.INVALID_PARAMS,"Unknown component.");var i=s.appendPathElements(e.parentPath,t).toLowerCase();if(this._absolutePaths[i])throw new n(n.DUPLICATE_VALUE,"Duplicate absolute path for component: "+i);if(!s.isValidAbsolutePath(i))throw new n(n.INVALID_PARAMS,"Invalid absolute path: "+i);delete this._absolutePaths[this._normalizedAbsolutePathForItem(e)],this._absolutePaths[i]=e,e._data.path=t},c.prototype._setDirty=function(e){if(!e){if("pending"===this._local().archivalState||"archived"===this._local().archivalState)throw new n(n.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,i=this._getBranchOf(e).compositeHref;if(t&&i){var n=s.endPointOf(t),o=s.endPointOf(i);if(n&&o&&n!==o)return!1}return!0},c.prototype._copyComponent=function(e,t,i,o,r,a){if(!e)throw new n(n.INVALID_PARAMS,'Expecting param "component".');if(a&&"function"!=typeof a)throw new n(n.INVALID_PARAMS,"Param callback must be a function.");var s=this,c=e._owner._core,d=this._isSameComposite(c),p=d||this._hasSameEndpoint(e),h=c._local(),_=this._localStorage,u=c._localStorage,f=_&&u;if(f&&!a&&!d)throw new n(n.INVALID_PARAMS,"Must pass a callback when copying between two different composites.");if(!f&&!p)throw new n(n.NO_LOCAL_STORAGE,"Cannot copy between two different endpoints without local storage.");var m=function(e,t,i){l(e,t,d,p,!o,f?_:void 0,i,h)},E=f?u.componentAssetPath(e,h):void 0;if(!a)return this._copyComponentModel(e,t,r,i,o,m);if(d||!E)try{a(void 0,this._copyComponentModel(e,t,r,i,o,m))}catch(e){a(e)}else{var g={};_.ingestComponentAsset(e,E,!0,g,function(n){if(n)a(n);else try{h=g,a(void 0,s._copyComponentModel(e,t,r,i,o,m))}catch(e){a(e)}})}},c.prototype._copyComponentModel=function(e,t,i,o,a,c){if(this._readOnly)throw new n(n.READ_ONLY,"This object is read-only.");if(!e)throw new n(n.INVALID_PARAMS,'Expecting param "component".');var l=e._owner,d=new r(JSON.parse(JSON.stringify(e._data)));o?(d.path=o,d.id=a||s.generateUuid()):a&&(d.id=a),d._owner=this._owner,e.id===d.id&&this._isSameComposite(l._core)||(d.state="modified",d.etag=void 0,d.version=void 0,d.md5=void 0,d.length=void 0);var p,h,_=this._allComponents[d.id];if(_&&!i)throw new n(n.DUPLICATE_VALUE,"Component already exists.");if(i&&!_)throw new n(n.INVALID_PARAMS,"Could not find existing component.");if(i){var u=this._nodeDataOfParentOfComponent(_);if(!u)throw new n(n.INVALID_PARAMS,"Parent node of existing component not found in this branch.");var f=u.parentNodeData.id;if(!(h=this._allNodes[f]))throw new n(n.INVALID_STATE,"Unknown parent node.");p=u.index}else if(!(h=t?this._allNodes[t.id]:this.rootNode))throw new n(n.INVALID_PARAMS,"Unknown parent node.");d._parentPath=h.absolutePath||h._parentPath;var m=this._normalizedAbsolutePathForItem(d),E=this._absolutePaths[m];if(E&&E!==_)throw new n(n.DUPLICATE_VALUE,"Duplicate absolute path: "+m);if(!s.isValidAbsolutePath(m))throw new n(n.INVALID_PARAMS,"Component path must be a valid path for a component.");var g=this._local();c&&c(e,d,g=s.deepCopy(g));var y=h._data.components;return i?y[p]=d._data:y?y.push(d._data):h._data.components=[d._data],this._data.local=g,this._allComponents[d.id]=d,this._absolutePaths[m]=d,this._setDirty(),d},c.prototype._copyChild=function(e,t,i,o,r,a,s){if(!e)throw new n(n.INVALID_PARAMS,'Expecting param "node".');var c=this,d=e._owner._core,p=this._isSameComposite(d),h=p||this._hasSameEndpoint(e),_=d._local(),u=this._localStorage,f=d._localStorage,m=u&&f,E=d._recursivelyGetAllComponentsOfChild(e);if(E.length>0){if(m&&!s&&!p)throw new n(n.INVALID_PARAMS,"Must pass a callback when copying between two different composites.");if(!m&&!h)throw new n(n.NO_LOCAL_STORAGE,"Cannot copy components between two different endpoints without local storage.")}var g=function(e,t,i){l(e,t,p,h,!0,m?u:void 0,i,_)};if(!s)return this._copyChildModel(e,t,i,a,o,r,g);var y=function(){s(void 0,c._copyChildModel(e,t,i,a,o,r,g))};if(0===E.length||p||!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{_=C,y()}catch(e){s(e)}};for(v=0;v<I;v++){var O=E[v],R=f.componentAssetPath(O,_);R&&(S++,u.ingestComponentAsset(O,R,!0,C,L))}if(0===S)try{y()}catch(e){s(e)}}},c.prototype._copyChildModel=function(e,t,i,a,c,l,d){if(this._readOnly)throw new n(n.READ_ONLY,"This object is read-only.");var p=e._owner,h=new o(JSON.parse(JSON.stringify(e._data)));c?(h.path=c,h.id=l||s.generateUuid()):l&&(h.id=l),h._owner=this._owner,e.isRoot&&(delete h._data.local,delete h._data["manifest-format-version"]);var _,u=this._allNodes[h.id];if(u&&!a)throw new n(n.DUPLICATE_VALUE,"Child node already exists.");if(a&&!u)throw new n(n.INVALID_PARAMS,"Could not find existing node to replace.");if(a){var f=this._nodeDataOfParentOfNode(u);if(!f)throw new n(n.INVALID_PARAMS,"Parent of existing node not found in this branch.");var m=f.parentNodeData.id;if(!(_=this._allNodes[m]))throw new n(n.INVALID_STATE,"Unknown parent node.");i=f.index}else if(!(_=t?this._allNodes[t.id]:this.rootNode))throw new n(n.INVALID_PARAMS,"Unknown parent node.");if(h._parentPath=_.absolutePath||_._parentPath,h.path){var E=this._normalizedAbsolutePathForItem(h),g=this._absolutePaths[E];if(g&&g!==u)throw new n(n.DUPLICATE_VALUE,"Duplicate absolute path: "+E);if(!s.isValidAbsolutePath(E))throw new n(n.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,i,n,o,r){var a,s;delete i[e.id],e.path&&delete o[t._normalizedAbsolutePathForItem(e)];var c=e._data.children;if(c)for(s=c.length,a=0;a<s;a++)I(i[c[a].id],t,i,n,o,r);var l=e._data.components;if(l)for(s=l.length,a=0;a<s;a++){var d=n[l[a].id];delete n[d.id],delete o[t._normalizedAbsolutePathForItem(d)],t._localStorage&&(t._localStorage.removeComponentAsset(d,r),t._setSourceHrefOfComponent(void 0,d,r))}};u&&I(u,this,y,v,A,C);var S=function(e,t,i,a,c,l,p,h){if(a[e.id])throw new n(n.DUPLICATE_VALUE,"Duplicate node id: "+e.id);var _;if(a[e.id]=e,e.path){if(l[_=t._core._normalizedAbsolutePathForItem(e)])throw new n(n.DUPLICATE_VALUE,"Duplicate absolute path: "+_);l[_]=e}var u,f,m=e._data.children;if(m)for(f=m.length,u=0;u<f;u++){var E=new o(m[u]);a[E.id]&&(E.id=s.generateUuid()),E._owner=t,E._parentPath=e.absolutePath||e._parentPath,S(E,t,i,a,c,l,p,h)}var g=e._data.components;if(g)for(f=g.length,u=0;u<f;u++){var y=new r(g[u]),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,d&&d(i.getComponentWithId(v),y,p),c[y.id])throw new n(n.DUPLICATE_VALUE,"Duplicate component id: "+y.id);if(c[y.id]=y,l[_=t._core._normalizedAbsolutePathForItem(y)])throw new n(n.DUPLICATE_VALUE,"Duplicate absolute path: "+_);l[_]=y}};if(S(h,this._owner,p,y,v,A,C,p._local()),a)_._data.children[i]=h._data;else{var L=_._data.children;L?(i>=0&&i<=L.length||(i=L.length),i===L.length?L[i]=h._data:L.splice(i,0,h._data)):_._data.children=[h._data]}return this._allNodes=y,this._allComponents=v,this._absolutePaths=A,this._data.local=C,this._setDirty(),h},c.prototype._verifyIntegrity=function(e,t,i){var r,a=this,c=[],l=!1,d=function(e){return c.push(new n(n.INVALID_STATE,e)),t&&(l||(t("Branch for composite "+a.rootNode.id+" has the following errors:"),l=!0),t("   "+e)),!1},p=function(e,t){return!!e||d(t)},h=[],_=function(e){(h.indexOf(e)<0||d("Item "+e.id+" encountered more than once"))&&h.push(e)},u=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];p("/"===y.charAt(0),"Absolute path "+y+" does not start with a slash.")}var v=function(e,t){var i,n,o=e.children;if(o)for(i=0;i<o.length;i++){var r=o[i],c=f[r.id];(c||d("Node "+r.id+" is not in cache."))&&(_(c),p(c._data===r,"Node "+c.id+" _data property incorrect."),delete f[c.id],c.path&&c._owner&&(n=a._normalizedAbsolutePathForItem(c),(m[n]||d("Absolute path of node "+c.id+" ("+n+") is not in cache."))&&delete m[n]),p(c._parentPath===t,"Parent path of node "+c.id+" should be "+t+" but is "+c._parentPath),p(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(i=0;i<l.length;i++){var h=l[i],E=u[h.id];(E||d("Component "+h.id+" is not in cache."))&&(_(E),p(E._data===h,"Component "+E.id+" _data property incorrect."),delete u[E.id],E._owner&&(n=a._normalizedAbsolutePathForItem(E),(m[n]||d("Absolute path "+n+" is not in cache."))&&delete m[n]),p(E._parentPath===t,"Parent path of component "+E.id+" should be "+t+" but is "+E._parentPath),p(E._owner===a._owner,"Component "+E.id+" _owner property is not correct."))}},A=m[o.ROOT_PATH];p(A,"Cannot find root node via path")&&(p(A.id===this._data.id,"Root node has correct id"),p(A.path===o.ROOT_PATH,"Root node has correct path"),p(""===A._parentPath,"Root node has correct parent path"),p(A._owner===this._owner,"Root node has correct owner"),p(A._data===this._data,"Root node has correct data"),p(f[A.id]===A,"Cannot find root node via id")&&delete f[A.id],delete m[o.ROOT_PATH]),v(this._data,o.ROOT_PATH);var C=Object.keys(u);for(r=0;r<C.length;r++)d("Component "+C[r]+" is in cache but could not be found.");for(C=Object.keys(f),r=0;r<C.length;r++)d("Node "+C[r]+" is in cache but could not be found.");for(C=Object.keys(m),r=0;r<C.length;r++)d("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++)p(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());p(O,"Component "+S+" does not have an entry in local storage mapping.")&&i&&p(i.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 T=this._allComponents[I[r]];T?p("modified"===T.state,"Component "+I[r]+" is in local source href mapping but has a state of "+T.state):p(!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,i){var n=i(4),o=i(13),r=3;function a(e,t,i){i?this._setData(i,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,i,n){o.readFile(e,"utf8",function(o,r){var s;if(o&&o.code&&i&&(o=void 0),!o)try{r=JSON.parse(r),s=new a(t,e,r)}catch(n){i?s=new a(t,e):o=n}n(o,o?void 0:s)})},Object.defineProperties(a.prototype,{compositeHref:{get(){return this._data["composite-href"]},set(){throw new n(n.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 n(n.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 n(n.READ_ONLY,"This property is read-only.")}}}),a.prototype.recordUploadedComponent=function(e,t,i,n,o,r,a){var s={etag:t,length:o,version:i,md5:n};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 i=t.timestamp;if(!i)return this.removeRecordForUploadedComponent(e);if(i=new Date(i),isNaN(i.getTime()))return this.removeRecordForUploadedComponent(e);if(Date.now()-i.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 n(n.INVALID_STATE,"Journal is not complete.");var i=e.isDirty;if(this.compositeHasBeenDeleted)e._data.state="committedDelete",e.manifestEtag=this.manifestEtag;else{this.compositeHasBeenArchived&&(e.compositeArchivalState="archived");var o,r="unmodified"!==e.compositeState&&this.changeCount!==e.changeCount,a=this.idsOfAllUploadedComponents(),s=a.length;for(o=0;o<s;o++){var c=a[o],l=e.getComponentWithId(c);if(l){var d=this.getRecordForUploadedComponent(l.id);l._data.etag=d.etag,l._data.length=d.length,l._data.version=d.version,l._data.md5=d.md5,d["source-href"]?e._core._getSourceHrefOfComponent(l)===d["source-href"]&&(l._data.state="unmodified",e._core._setSourceHrefOfComponent(void 0,l)):e.hasLocalStorage&&e._localStorage.componentAssetName(l,e._local())===d["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=i)},a.prototype.commitChanges=function(e){if(this._filePath){var t=this,i=function(e){t._needAnotherCommit=!1,t._commitInProgress=!0,t._waitingCallbacks=[],o.writeFileAtomically(t._filePath,JSON.stringify(t._data),"utf8",function(n){var o,r=e.length;for(o=0;o<r;o++)try{e[o](n)}catch(e){}t._needAnotherCommit?i(t._waitingCallbacks):t._commitInProgress=!1})};t._commitInProgress?(this._needAnotherCommit=!0,e&&this._waitingCallbacks.push(e)):i(e?[e]:[])}else e&&e()},a.prototype._setData=function(e,t){if(e["push-journal-format-version"]<=2){var i=e["uploaded-components"];if(i){var n,o=Object.keys(i),a=o.length;for(n=0;n<a;n++){var s=i[o[n]];"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 n(n.INVALID_DATA,"Wrong push journal format version."):e["composite-href"]!==t?new n(n.INVALID_DATA,"Composite and journal hrefs mismatch."):e["uploaded-components"]?null:new n(n.INVALID_DATA,"Missing component list.")},e.exports=a},function(e,t,i){var n,o,r,a=i(8),s=i(4),c=i(13);o=i(27),r=i(42);var l=a.merge;function d(e){this.filename=e}function p(){}function h(e){this._requestQueue=[],this._requestsOutstanding=[],this._rejectedAuths=[],this._authCallback=e,this._isActive=!0,this._waitingForAuthentication=!!e,this._currentAuthId=a.generateUuid(),this._https=o,this._XMLHttpRequest=n,this._handlesRedirects=void 0!==n,this._maxOutstanding=5}Object.defineProperties(h.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}}}),h.prototype._forceXhr=function(e,t){this._https=void 0,this._XMLHttpRequest=e||n,this._handlesRedirects=!t},h.FileContent=d,h.StreamProvider=p,h.prototype.setAdditionalHeaders=function(e){this._additionalHeaders=e||{}},h.prototype.setAdditionalNodeOptions=function(e){this._additionalNodeOptions=e},h.prototype.setApiKey=function(e){this._apiKey=e},h.prototype.setTimeout=function(e){this._timeout=e},h.prototype.setAuthToken=function(e){e?(this._authValue="Bearer "+e,this.resume()):(this._authValue=void 0,this._currentAuthId=a.generateUuid())},h.prototype.resume=function(){this._currentAuthId=a.generateUuid(),this._waitingForAuthentication=!1,this._checkQueue()},h.prototype.setRequestHooks=function(e,t){this._beforeHook=e,this._afterHook=t},h.prototype.invoke=function(e,t,i,n,o,r){var p=(o=o||{}).responseType;if(p instanceof d){if(!c.canUseFileSystem)throw new s(s.INVALID_PARAMS,"No filesystem access")}else if("buffer"===p){if("function"!=typeof Buffer)throw new s(s.INVALID_PARAMS,"No Buffer class")}else if("blob"===p){if("function"!=typeof Blob)throw new s(s.INVALID_PARAMS,"No Blob class")}else if(p&&"text"!==p&&"json"!==p&&"arraybuffer"!==p)throw new s(s.INVALID_PARAMS,"Unsupported response type");i=l({},i,this._additionalHeaders),this._apiKey&&(i["x-api-key"]=this._apiKey);var h={method:e,href:t,headers:i,callback:r,body:n,options:o},_=o.reuseRequestDesc;if(_){if(this._requestQueue.indexOf(_)>=0||this._requestsOutstanding.indexOf(_)>=0)throw new s(s.INVALID_PARAMS,"Request descriptor still in use.");h=a.merge(_,h)}return this._doRequest(h),h},h.prototype._doRequest=function(e){var t,i,n,o=this,h=0,_=[],u=e.body,f=e.options.responseType;function m(t,n){if(t)a.log("["+e.id+"] error: "+t);else{const t=(new Date).valueOf()-e.startTime;n.complete?a.log("["+e.id+"] success ("+t+"ms)"):a.log("["+e.id+"] success ("+t+"ms) but response is incomplete")}var r=o._requestsOutstanding.indexOf(e);r>=0&&o._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&&!o._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,n)),i&&i.end(),o._isActive&&o._checkQueue()}if(!this._isActive)return m(new s(s.SERVICE_IS_INACTIVE,"Network request in inactive state"));function E(t){t.pipe(n),t.on("error",function(t){m(new s(s.TERMINATED_INPUTSTREAM,"Input stream terminated abnormally",t)),o.abort(e)})}if(this._waitingForAuthentication||this._requestsOutstanding.length>=this._maxOutstanding||e.options.noSoonerThen)this._requestQueue.push(e),this._waitingForAuthentication||this._checkQueue();else{var g=e.headers;if(0!==e.href.indexOf("https:"))return m(new s(s.INVALID_PARAMS,"http not supported - network requests must use https"));if(null===g.Authorization?delete g.Authorization:this._authValue&&(g.Authorization=this._authValue),this._currentAuthId&&(e.authId=this._currentAuthId),this._beforeHook&&this._beforeHook(e),e.id=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),n=this._https.request(v,function(t){var n=!1,r=!1,l=!1;function p(){if(!r)return r=!0,i=void 0,m(void 0,t)}var h=o._requestsOutstanding.indexOf(e);if(h<0)o._checkQueue();else{e.response=t;var u=(new Date).valueOf()-e.startTime;if(a.log("["+e.id+"] "+t.statusCode+" ("+u+"ms)"),401===t.statusCode&&o._authCallback)o._requestsOutstanding.splice(h,1),o._requestQueue.unshift(e),o._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),!i&&e&&_.push(e)}),o._https&&f instanceof d&&(i=c.createWriteStream(f.filename),t.pipe(i),n=!0)):a.consumeStream(t),t.once("end",function(){l=!0;var i=o._requestsOutstanding.indexOf(e);if(!(i<0||(o._requestsOutstanding.splice(i,1),o._checkQueue(),n||r)))return r=!0,t.response=Buffer.concat(_),"arraybuffer"===f?t.response=new ArrayBuffer(t.response):"text"===f&&(t.response=t.response.toString()),m(void 0,t)});const h=()=>{if(!l&&!r)return r=!0,m(new s(s.NETWORK_ERROR,"incomplete response"))};t.once("close",h),t.once("aborted",()=>{t.complete||h()}),n&&(i.once("finish",p),i.once("close",p))}}}),e.clientRequest=n,n.once("error",m),n.once("abort",()=>m(new s(s.NETWORK_ERROR,"Request aborted"))),o._timeout&&n.setTimeout(o._timeout,function(){e.timedOut=!0,n.abort()}),e.bytesSent=0,e.bytesReported=0,n.once("end",function(){if(e.progress){var t=e.bytesSent-e.bytesReported;t>0&&(e.progress(t),e.bytesReported+=t)}});var A=n.write;if(n.write=function(t){var i=t&&t.length;return i&&(e.bytesSent+=i),A.call(n,t,function(){e.progress&&t&&(e.progress(i),e.bytesReported+=i)})},u instanceof d)E(c.createReadStream(u.filename));else if(u instanceof p){if(u.getStream)E(u.getStream());else u.getStreamAsync&&u.getStreamAsync(function(t,i){if(t)return m(new s(s.TERMINATED_INPUTSTREAM,"Error creating input stream",t)),void o.abort(e);E(i)})}else if(u instanceof Buffer)n.write(u),n.end();else if(u instanceof ArrayBuffer)n.write(new Buffer(new Int8Array(u))),n.end();else if("string"==typeof u)n.write(new Buffer(u,"utf8")),n.end();else{if(u)return m(new s(s.INVALID_PARAMS,"Invalid data type"));n.end()}this._afterHook&&this._afterHook(e,n)}else{if(u instanceof d)return c.canUseFileSystem?void c.readFile(u.filename,{},function(t,i){if(t)return m(t);e.body=i,o._doRequest(e)}):m(new s(s.INVALID_PARAMS,"Can't use FileContent without filesystem support"));var C;for(C in"function"==typeof Buffer&&u instanceof Buffer&&(e.body=u=new Int8Array(u)),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 d?"buffer":f),t.onreadystatechange=function(){var i=e.progress;if(i&&t.response){var n=t.response.length;i(n-h),h=n}if(4===t.readyState){if(0===t.status)return m(new s(s.UNEXPECTED,"XHR failure"));var r=o._requestsOutstanding.indexOf(e);if(r<0)o._checkQueue();else{var l=(new Date).valueOf()-e.startTime;if(a.log("["+e.id+"] "+t.status+" ("+l+"ms)"),o._requestsOutstanding.splice(r,1),401!==t.status||!o._authCallback){if(e.xhr=t,e.response=t,t.statusCode=t.status,t.headers=a.parseHeaders(t.getAllResponseHeaders()),f instanceof d){var p=t.response.response;return void c.writeFileAtomically(f.filename,p,void 0,function(e){return e?m(new s(s.UNEXPECTED,"Can't create file",e,t)):m(void 0,t)})}return i&&u&&i(u.length||u.size),m(void 0,t)}o._requestQueue.unshift(e),o._authFail(e),o._checkQueue()}}},g)g.hasOwnProperty(C)&&t.setRequestHeader(C,g[C]);e.xhr=t,o._timeout&&(t.timeout=o._timeout,t.ontimeout=function(){e.timedOut=!0,t.abort()}),u?t.send(u):t.send(),this._afterHook&&this._afterHook(e,t)}}},h.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)}},h.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"),i=e.callback;i&&(e.callback=void 0,i(t))}),void(this._checkQueueTimerId&&(clearTimeout(this._checkQueueTimerId),this._checkQueueTimerId=void 0,this._checkQueueTimerWhen=void 0))}for(var i,n=Date.now(),o=n+3e5,r=0;!(this._waitingForAuthentication||this._requestsOutstanding.length>=this._maxOutstanding||r>=this._requestQueue.length);){var a=this._requestQueue[r];(i=a.options.noSoonerThen||n)&&i>o&&(i=a.options.noSoonerThen=o),i<=n?(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,d=this._requestQueue.length;for(l=0;l<d;l++)(i=this._requestQueue[l].options.noSoonerThen)&&i>o&&(i=this._requestQueue[l].options.noSoonerThen=o),i&&(c=c&&c<i?c:i);if(c&&(!this._checkQueueTimerWhen||this._checkQueueTimerWhen>c)){this._checkQueueTimerId&&clearTimeout(this._checkQueueTimerId),this._checkQueueTimerWhen=c;var p=this;this._checkQueueTimerId=setTimeout(function(){p._checkQueueTimerWhen=void 0,p._checkQueueTimerId=void 0,p._checkQueue()},c-n)}}},h.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())};const _=e=>{const t=e&&e.callback;t&&(e.callback=void 0,t(new s(s.NETWORK_ERROR,"Request aborted")))};h.prototype.abortAllWithToken=function(e){if(e){for(let t=0;t<this._requestQueue.length;++t){const i=this._requestQueue[t];i.token===e&&(_(i),this._requestQueue.splice(t,1),--t)}for(let t=0;t<this._requestsOutstanding.length;++t)if(this._requestsOutstanding[t].token===e){const e=this._requestsOutstanding[t];this._requestsOutstanding.splice(t,1),--t,e.xhr&&e.xhr.abort(),e.clientRequest&&e.clientRequest.abort()}this._checkQueue()}},h.prototype.abortAll=function(){this._requestQueue.slice().forEach(_),this._requestQueue=[],this._requestsOutstanding.slice().forEach(e=>{e.xhr&&e.xhr.abort(),e.clientRequest&&e.clientRequest.abort()}),this._requestsOutstanding=[],this._checkQueue()},e.exports=h},function(e,t,i){var n,o,r=i(26),a=i(40),s=i(36),c=i(4),l=i(50),d=i(43),p=i(8),h=i(13),_=d.FileContent,u=a.STATES;function f(e,t,i){return c.wrapError(c.UNEXPECTED_RESPONSE,e,t,i)}function m(e,t,i){this._session=e,this._callback=t,this._cleanup=i,this._componentsPending=0,this.bytesTransfered=0,this.bytesTotal=0,this.onProgress=p.noOp;var n=this;this._reportProgress=function(e){if(e>0){n.bytesTransfered+=e;var t=n.onProgress;t&&t(n.bytesTransfered,n.bytesTotal)}}}m.prototype._callCallback=function(e,t){var i=this._callback;i&&(this._callback=void 0,i(e,t))},m.prototype._xferComplete=function(e,t){var i=this._cleanup;i?(this._cleanup=void 0,i(e,t)):this._callCallback(e,t)},m.prototype.abort=function(e){this._aborted||(this._aborted=!0,e||(this._callback=void 0,e=new Error("Aborted")),this._xferComplete(e),this._session._service.abortAllWithToken(this))};var E={};E.pullComposite=function(e,t,i){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",i)},E.pullMinimumComposite=function(e,t,i){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",i)},E.pullCompositeManifestOnly=function(e,t,i){return this._pullComposite(e,t,"none",i)},E.downloadComponents=function(e,t,i,n){var o=function e(t){return t._owner?e(t._owner):t}(t),r=new m(i,n);return r._referenceBranch=o,E._pullComponents(r,o,e||t.allComponents()),r},E.pushComposite=function(e,t,i,n){var o,r=e._localStorage;(o=new m(i,n,function(t,i){if(o._owner&&e.hasLocalStorage&&r.unregisterInMemoryBranchOrElement(o._owner),!e.hasLocalStorage){var n=o._journal;e._pushJournal=n.isEmpty?void 0:n}o._callCallback(t,i)}))._composite=e,o._overwriteExisting=t;var a=!e.isBound;if(o._compositeIsNew=a,e.hasLocalStorage)e._loadBranch(r.currentManifestPath(),!1,function(t,i){if(t)return o._xferComplete(t);o._owner=i,e._localStorage.registerInMemoryBranchOrElement(i),l.readJournal(r.pushJournalPath(),e,!0,function(t,i){if(t)return o._xferComplete(t);o._journal=i,E._pushComposite(e,o)})});else{if(!e.href)return o._xferComplete(new c(c.INVALID_STATE,"New composite has no href"));o._owner=e.current.copy(),o._journal=e._pushJournal||new l(e),E._pushComposite(e,o)}return o},E.remixComposite=function(e,t,i,n,o,r,a){var s=p.parseURI(i).path;if(!s||!n||s.split("/").pop()!==n)throw new c(c.INVALID_PARAMS,"Invalid combination of params targetHref ("+i+") and compositeId ("+n+")");var l=new m(r,a);return r.remixComposite(e,t,i,n,o,function(e){l._xferComplete(e,e?void 0:i)}).token=l,l},E.uploadNewComponent=function(e,t,i,o,a,s){if(i._localStorage)throw new c(c.INVALID_PARAMS,"For in-browser use only. Use composite.current.addComponent() to add a new component asset");return n(o||p.generateUuid(),t,!0,i.collaborationType===r.COLLABORATION.SHARED_WITH_USER,e,i.id,i.href,a,s)},E.uploadComponent=function(e,t,i,o,a){if(i._localStorage)throw new c(c.INVALID_PARAMS,"For in-browser use only. Use composite.current.updateComponent() to update a component asset");return n(e.id,e.type,!1,i.collaborationType===r.COLLABORATION.SHARED_WITH_USER,t,i.id,i.href,o,a)},E.copyAssetForNewComponent=function(e,t,i,n,a,s){if(i._localStorage)throw new c(c.INVALID_PARAMS,"For in-browser use only. Use composite.current.addComponent() to add a new component asset");return o(n||p.generateUuid(),t,!0,i.collaborationType===r.COLLABORATION.SHARED_WITH_USER,e,i.id,i.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,i,n){if("string"!=typeof e.href)throw new c(c.INVALID_STATE,"Composite must have an href");var o;var r=function(n,r){if(n)return o._xferComplete(n);var a;r?(a=r.manifestEtag,o._referenceBranch=r):e.current&&(a=e.current.manifestEtag,o._referenceBranch=e.current);var l=t.getCompositeManifest(e,a,function(t,n,a){if(t)return t.response&&404===t.response.statusCode?o._xferComplete(new c(c.NO_COMPOSITE,"Composite missing or deleted",t.underlyingError||t)):o._xferComplete(t);if(null===n&&!r)return o._xferComplete(void 0,null);var l;if(null!==n)try{if((l=(new s).parse(n))._localStorage=e._localStorage,l.compositeHref=e.href,l._collaborationType=e.collaborationType,l._clientDataString=e.clientDataString,l.manifestEtag=a,l.compositeState===u.committedDelete||l.compositeState===u.pendingDelete)return void o._session.deleteCompositeDirectory(e,function(e){return e?o._xferComplete(new c(c.DELETED_COMPOSITE,"Error deleting composite directory",e)):o._xferComplete(new c(c.DELETED_COMPOSITE,"Composite is deleted"))});o._referenceBranch&&l.hasLocalStorage&&l._updateLocalDataFromBranch(o._referenceBranch)}catch(e){return o._xferComplete(new c(c.INVALID_JSON,"Corrupted manifest",e))}else l=r;var d,p,h=l.allComponents();for(d=0;d<h.length;++d)(p=h[d]).state===u.pendingDelete||p.state===u.committedDelete?l.removeComponent(p):p.state=u.unmodified;h=void 0,"all"===i?h=l.allComponents():"min"===i&&(p=l.getComponentWithAbsolutePath("/META-INF/metadata.xml"))&&(h=[p]),h?E._pullComponents(o,l,h):o._xferComplete(void 0,l)});l&&(l.token=o,l.progress=o._reportProgress)};return(o=new m(t,n,function(t,i){if(t){var n=t.pulledBranch;n?(n.compositeState=u.unmodified,n.hasLocalStorage?h.writeFileAtomically(e._localStorage.pulledManifestPath(),t.pulledBranch.localData,"utf8",function(){o._callCallback(t)}):o._callCallback(t)):o._callCallback(t)}else{if(null===i)return o._callCallback(void 0,null);if(i.compositeState=u.unmodified,i.readOnly=!0,i.hasLocalStorage){var r=e._localStorage.pulledManifestPath();h.writeFileAtomically(r,i.localData,"utf8",function(e){if(e)return o._callCallback(e);i.manifestPath=r,i._isDirty=!1,o._callCallback(void 0,i)})}else e._options.xhrBaseBranchSupport&&(e._pulledBranchData=i.localData),o._callCallback(void 0,i)}}))._composite=e,e.hasLocalStorage?e.loadPulledBranch(r):r(),o},E._pullComponents=function(e,t,i){if(!t.hasLocalStorage)throw new c(c.INVALID_PARAMS,"No local storage.");var n,o=e._session;function r(n,o){if(e._componentsPending-=1,n&&(e.failedComponents=e.failedComponents||[],e.failedComponents.push({component:o,error:n})),0===e._componentsPending&&!e._aborted){var r=e.failedComponents;if(r){n=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){n=new c(l.code,l.message);break}}n.pulledBranch=t,n.failedComponents=r}t.readOnly&&t.manifestPath&&(!r||i.length>r.length)?h.writeFileAtomically(t.manifestPath,t.localData,"utf8",function(i){n=n||i,e._xferComplete(n,n?void 0:t)}):e._xferComplete(n,n?void 0:t)}}function a(t){if(!e._aborted){e.bytesTotal+=t.length||0;var i=t._owner._localStorage.tempPathForComponent(t),n=p.parentDirectory(i);h.ensureDirectoryExists(n,function(n){if(n)return e.abort(n);var a=E._pullComponent(t,i,o,r);a.progress=e._reportProgress,a.token=e})}}function s(e){t.assetOfComponent(e,function(t,i){"string"!=typeof i?a(e):r(void 0,e)})}for(e._componentsPending=i.length,n=0;n<i.length;++n){var l,d=i[n];if(e._referenceBranch){var _=e._referenceBranch.getComponentWithId(d.id);_&&(l=_.etag)}d.etag!==l?a(d):s(d)}0===e._componentsPending&&e._xferComplete(void 0,t)},E._pullComponent=function(e,t,i,n){var o=e._owner;if(!e._owner.hasLocalStorage)throw new c(c.INVALID_PARAMS,"No local storage. Use AdobeDCXCompositeXfer.pullCompositeManifestOnly() to pull down the composite without local storage.");return i.getComponent(e,new _(t),function(i,r){if(i)n(i,e);else if(200===r.statusCode){var a=Number(r.headers["content-length"]);e.length&&!isNaN(a)&&a!==e.length?n(new c(c.UNEXPECTED_RESPONSE,"Incorrect content length",i,r)):o._localStorage.ingestComponentAsset(e,t,!1,o._local(),function(t){n(t,e,r.headers.etag)})}else 304===r.statusCode?n(void 0,e,r.headers.etag):n(f("Unexpected response getting a component",i,r),e)})},E._pushComposite=function(e,t){if(!e.href)return t._xferComplete(new c(c.INVALID_STATE,"New composite has no href"));var i=t._owner,n=t._journal,o=t._compositeIsNew,a=t._overwriteExisting,s=t._session,l=i.changeCount,d=i.remoteData.length+50;if(t.bytesTotal=d,i.compositeState===u.committedDelete)return t._xferComplete(new c(c.DELETED_COMPOSITE,"Attempt to push a deleted composite"));if("archived"===i.compositeArchivalState)return t._xferComplete(new c(c.DELETED_COMPOSITE,"Attempt to push an archived composite"));var p="pending"===i.compositeArchivalState;if(p&&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(!o&&!p&&i.compositeState===u.unmodified)return t._xferComplete();if(i.compositeState===u.pendingDelete)return o&&!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,i){t._xferComplete(e,i)});function _(i,n){p?s.archiveCompositeDirectory(e,function(o){if(o)return n(o);i.compositeArchivalState="archived",t._journal.compositeHasBeenArchived=!0,t._journal.commitChanges(function(t){if(t)return n(t);e.hasLocalStorage?h.writeFileAtomically(e._localStorage.pushedManifestPath(),i.localData,"utf8",function(e){if(e)return n(e);n(void 0,i)}):n(void 0,i)})}):n(void 0,i)}function m(i){if(o)return t._xferComplete(i);var n=s.getCompositeManifestHref(e);s.headRequest(n,function(e,n){return e?t._xferComplete(e):404===n.statusCode?(i=new c(c.NO_COMPOSITE,"Composite does not exist; may have been deleted"),t._xferComplete(i)):t._xferComplete(i)})}!function(e,t,i,n,o){function r(e){e||(t.compositeHasBeenCreated=!0);var i,n=t._compositeCreationCallbacks,o=n.length;for(i=0;i<o;i++)try{n[i](e)}catch(e){}t._compositeCreationCallbacks=void 0}e.isBound||t.compositeHasBeenCreated?o():t._compositeCreationCallbacks?t._compositeCreationCallbacks.push(o):(t._compositeCreationCallbacks=[o],n.createCompositeDirectory(e,i,function(t,o){if(t){if(t.code!==c.ALREADY_EXISTS)return r(f("Unexpected response creating a composite directory",t,o));if(i)r();else{var a=n.getCompositeManifestHref(e);n.headRequest(a,function(e,t){return e?r(e):404!==t.statusCode?r(e=new c(c.ALREADY_EXISTS,"Composite already exists and overwriteExisting not specified")):void r()})}}else r()}))}(e,n,a,s,function(o){if(o)return t._xferComplete(o);E._pushComponents(t,i,function(){var r=t.failedComponents;if(r){o=new c(c.COMPONENT_UPLOAD_ERROR,"One or more components failed to upload.");var p,f=r.length;for(p=0;p<f;p++){var E=r[p].error;if(E.code===c.EXCEEDS_QUOTA){o=new c(E.code,E.message);break}}return o.failedComponents=r,m(o)}if(i.compositeState===u.modified){i.compositeState=u.unmodified,n.manifestEtag&&n.currentBranchEtag===i.manifestEtag&&(i.manifestEtag=n.manifestEtag);var g=i.remoteData;t.bytesTotal+=g.length,t.bytesTotal-=d;var y=s.updateManifest(i,g,a,function(o,r){if(o)return m(o);var a=r.headers.etag;n.manifestEtag=a,n.currentBranchEtag=i.manifestEtag,n.changeCount=l,n.commitChanges(function(o){if(o)return t._xferComplete(o);n.applyToBranch(i),i.compositeState=u.unmodified,e.hasLocalStorage?h.writeFileAtomically(e._localStorage.pushedManifestPath(),i.localData,"utf8",function(e){if(e)return t._xferComplete(e);i._isDirty=!1,_(i,function(e,i){t._xferComplete(e,i)})}):(e._options.xhrBaseBranchSupport&&(e._pushedBranchData=i.localData),_(i,function(e,i){t._xferComplete(e,i)}))})});y&&(y.progress=t._reportProgress,y.token=t)}else _(i,function(e,i){t._xferComplete(e,i)})})})},E._deleteComposite=function(e,t,i){var n=e._composite,o=e._owner,r=e._session;o.compositeState=u.committedDelete;var a=o.remoteData;e.bytesTotal=a.length,e._journal.manifestEtag&&e._journal.currentBranchEtag===o.manifestEtag&&(o.manifestEtag=e._journal.manifestEtag),r.updateManifest(o,a,t,function(t){if(t)return i(t);r.deleteCompositeDirectory(n,function(t){if(t)return i(t);e._journal.compositeHasBeenDeleted=!0,e._journal.commitChanges(function(e){if(e)return i(e);n.hasLocalStorage?h.writeFileAtomically(n._localStorage.pushedManifestPath(),o.localData,"utf8",function(e){if(e)return i(e);i(void 0,o)}):i(void 0,o)})})})},E._pushComponents=function(e,t,i){var n,o=t.allComponents(),a=e._composite,s=a._localStorage,l={},d=e._journal;function f(t,n,o){n?l[t.id]=n:delete l[t.id],o&&(e.failedComponents=e.failedComponents||[],e.failedComponents.push({component:t,error:o})),0===Object.keys(l).length&&d.commitChanges(i)}function m(t,i,n){f(t,"uploading"),h.info(i,function(o,s){if(o)return o=new c(c.INVALID_STATE,"Component asset missing",o),void f(t,null,o);var l=s.size,h=p.filePathComponents(i).fileName,m=d.getRecordForUploadedComponent(t.id);if(m&&m.length===l&&m["storage-name"]===h)return t.etag=m.etag,t.version=m.version,t.md5=m.md5,t.length=m.length,t.state=u.unmodified,void f(t,null);e.bytesTotal+=l;var E=e._session.uploadComponent(t,n,a.collaborationType===r.COLLABORATION.SHARED_WITH_USER,e,new _(i),function(e,i,n){if(!e){var o=i.headers.etag,r=i.headers["x-latest-version"],a=n.md5;o||(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=o,t.version=r,t.md5=a,t.length=l,t.state=u.unmodified,d.recordUploadedComponent(t.id,o,r,a,l,h),d.commitChanges())}f(t,null,e)});E&&(E.progress=e._reportProgress,E.token=e)})}function E(i,n,o){var l=d.getRecordForUploadedComponent(i.id);if(l&&l["source-href"]===n)return i.etag=l.etag,i.version=l.version,i.md5=l.md5,i.length=l.length,void(i.state=u.unmodified);f(i,"copying");var p=e._session.copyAssetToComponentId(i.id,i.type,e._composite.href,o,a.collaborationType===r.COLLABORATION.SHARED_WITH_USER,e,n,function(e,r,a){if(e){if(s){var l=s.componentAssetPath(i,t._local());if("string"==typeof l)return m(i,l,o)}}else{var p=r.headers.etag,h=r.headers["x-latest-version"],_=a.md5,E=a.size;p||(e=new c(c.UNEXPECTED_RESPONSE,"No etag")),h||(e=new c(c.UNEXPECTED_RESPONSE,"No version")),_||(e=new c(c.UNEXPECTED_RESPONSE,"No md5")),E||(e=new c(c.UNEXPECTED_RESPONSE,"No length")),e||(i.etag=p,i.version=h,i.md5=_,i.length=E,i.state=u.unmodified,d.recordUploadedComponent(i.id,p,h,_,E,void 0,n),d.commitChanges())}f(i,null,e)});p&&(p.progress=e._reportProgress,p.token=e)}for(n=0;n<o.length;++n){var g=o[n],y=g.state,v=!g.etag;if(y||(y=u.unmodified),v||y===u.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===u.unmodified?d.removeRecordForUploadedComponent(g.id):y!==u.committedDelete&&y!==u.pendingDelete||t.removeComponent(g)}0===Object.keys(l).length&&i()},n=function(e,t,i,n,o,r,s,l,d){if("function"!=typeof d)throw new c(c.INVALID_PARAMS,'Param "callback" must be a function.');var p=o.length||o.byteLength||o.size,h=new m(l,d);h.bytesTotal=p;var _=l.uploadAssetForComponentId(e,t,s,i,n,h,o,function(i,n,o){var s;if(!i)try{s=new a._UploadResults(r),p=p||_.bytesSent,s.records[e]=function(e,t,i,n,o){if("number"!=typeof t)throw new c(c.UNEXPECTED_RESPONSE,"No length");var r=n.headers.etag,s=n.headers["x-latest-version"],l=o.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,i)}(e,p,t,n,o)}catch(e){i=e,s=void 0}h._xferComplete(i,s)});return _&&(_.progress=h._reportProgress,_.token=h),h},o=function(e,t,i,n,o,r,s,l,d){if("function"!=typeof d)throw new c(c.INVALID_PARAMS,'Param "callback" must be a function.');var p=new m(l,d),h=l.copyAssetToComponentId(e,t,s,i,n,p,o,function(i,n,o){if(!p._aborted){var s;if(!i)try{(s=new a._UploadResults(r)).records[e]=function(e,t,i,n){var o=n.headers.etag,r=n.headers["x-latest-version"],s=t.md5,l=t.size;if("number"!=typeof l)throw new c(c.UNEXPECTED_RESPONSE,"No length");if(!o)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,o,r,s,l,i)}(e,o,t,n)}catch(e){i=e,s=void 0}d(i,s)}});return h&&(h.progress=p._reportProgress,h.token=p),p},e.exports=E},function(e,t,i){var n=i(26),o=i(36),r=i(4),a=i(8),s=i(13);let c,l;c=i(54),l=i(55);var d={isSnapshot:function(e,t){var i,n=!1,o=function(e,o){n||(n=!0,i&&i.isOpen&&i.close(),t(e,o))};l.open(e,{lazyEntries:!0},function(e,t){e?-1!==["EPERM","EACCES","ENOENT"].indexOf(e.code)?o(e):o(new r(r.INVALID_DATA,"Error while opening snapshot: "+e)):((i=t).on("entry",function(e){"mimetype"===e.fileName?i.openReadStream(e,function(e,t){if(e)o(e);else{var i=[];t.on("data",function(e){i.push(e)}),t.on("error",function(e){o(e)}),t.on("end",function(){var e=Buffer.concat(i).toString();e&&_(e,"dcxucf")?o(null,!0):o(null,!1)})}}):o(null,!1)}).on("error",function(e){o(e)}),i.readEntry())})},importSnapshot:function(e,t,i,o,r,a){return this.importSnapshotToDirectory(e,t,i,o,r,function(e,t){if(e)a(e);else try{var i=new n(null,null,t,null,null,null);i.loadCurrentFromLocalStorage(function(e){a(e,e?void 0:i)}),i.deleteTempFiles()}catch(e){a(e)}})}};d.importSnapshotToDirectory=function(e,t,i,n,c,d){var p,h,u,m,E=!1,g=0,y=0,v=0,A=!1,C=function(e,t){if(!A){if(A=!0,p&&p.isOpen&&p.close(),e)return t&&s.deleteDirectory(t),void d(e);d(e,t)}},I={},S={};return s.ensureDirectoryExists(t,function(d){d?C(d):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)):((p=l).on("entry",function(e){if(g++,y=0,v=0,f(e,n))if(1===g)"mimetype"===e.fileName?p.openReadStream(e,function(e,t){if(e)C(e);else{var i=[];t.on("data",function(e){i.push(e)}),t.on("error",function(e){C(e)}),t.on("end",function(){var e=Buffer.concat(i).toString();e&&_(e,"dcxucf")||C(new r(r.INVALID_DATA,"Bad mimetype")),p.readEntry()})}}):C(new r(r.INVALID_DATA,"Missing mimetype file"));else if(2===g)"manifest"===e.fileName?p.openReadStream(e,function(e,t){if(e)C(e);else{var i=[];t.on("data",function(e){i.push(e)}),t.on("error",function(e){C(e)}),t.on("end",function(){var e=Buffer.concat(i).toString();if(e){if(h=JSON.parse(e),(u=new o(h))._resetIdentity(),n){var t=u.getComponentWithAbsolutePath("/META-INF/metadata.xml");t&&u.removeComponent(t)}m=h.id,p.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 i=t+"/"+m+"/components";s.ensureDirectoryExists(i,function(t){t?C(t):p.openReadStream(e,function(t,n){if(t)C(t);else{var o=a.generateUuid(),r=e.fileName.split("/"),l=r[r.length-1].split(".");l&&(o=o+"."+l[l.length-1]),I["/"+e.fileName]=o,n.on("end",function(){p.readEntry()}),n.on("data",function(e){v+=e.length,function(){if(!E){var e=(g-1)/p.entryCount;y&&(e+=v/(y*p.entryCount)),c(Math.round(100*e))}}()}).on("error",function(e){C(e)}).pipe(s.createWriteStream(i+"/"+o))}})})}else C(new r(r.INVALID_DATA,"Missing manifest id"));else p.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=u.getComponentWithAbsolutePath(e);t&&(S[t.id]=I[e])}),h.local||(h.local={}),h.local["copyOnWrite#storageIds"]=S,i&&(h.local.compositeHref=i.endsWith("/")?i+h.id:i+"/"+h.id),m?s.ensureDirectoryExists(t+"/"+m,function(e){e?C(e):s.writeFile(t+"/"+m+"/manifest",JSON.stringify(h,void 0,2),function(e){e?C(e):C(null,t+"/"+m)})}):C(new r(r.INVALID_DATA,"Missing manifest id"))))}),p.readEntry())})}),function(){E||(E=!0,p&&p.close())}},d.exportSnapshot=function(e,t,i,n,o){var l,d,h=!1,u=function(e){if(!h){if(h=!0,e)return void s.deleteFile(d,()=>o(e));s.move(d,t,!1,e=>o(e||null))}};try{d=t.replace(/([^\\/]+)$/,"."+a.generateUuid()+"_$1"),l=s.createWriteStream(d)}catch(e){return void u(e)}var f,m=new c.ZipFile;if(e.type&&_(e.type,"dcx")){f=e.type+"ucf",m.addBuffer(new Buffer(f),"mimetype",{compress:!1});var E=p(e.current,i),y=JSON.stringify(E.manifest,void 0,2),v=E.lengths.total+y.length;m.addBuffer(new Buffer(y),"manifest",{compress:!0});var A=E.componentMap,C=!1,I=0;return E.components.map(function(t){return{id:t.id,path:A&&A[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 i=e.path+"/components/"+t.path;g(t.type)?m.addFile(i,t.absolutePath,{compress:!0}):m.addFile(i,t.absolutePath,{compress:!1})}),m.end(),m.on("error",function(){u(new r(r.INVALID_DATA,"Missing component file locally."))}),m.outputStream.on("error",function(e){u(C?new r(r.UNEXPECTED,"Export cancelled"):e)}).on("data",function(e){I+=e.length,C||n(Math.min(100,Math.round(100*I/v)))}).pipe(l).on("close",function(){u(C?new r(r.UNEXPECTED,"Export cancelled"):null)}).on("error",function(e){u(e)}),function(){C||(C=!0,m.outputStream.end())}}u(new r(r.INVALID_PARAMS,"Invalid composite type"))};var p=function(e,t){var i=JSON.parse(e.localData);t&&t(i);var n=h(i,i.local["copyOnWrite#storageIds"]||{});return delete i.local,delete i.manifestEtag,i.state="unmodified",{manifest:i,lengths:n.lengths,componentMap:n.componentMap,components:n.components}},h=function(e,t,i,n,o){return o=o||[],i=i||{},n=n||{total:0},e.components&&e.components.forEach(function(e){i[e.id]=t[e.id];var r=e.length||1e5;n[e.id]=r,n.total+=r,e.state="unmodified",delete e.version,delete e.md5,delete e.etag,o.push(e)}),e.children&&e.children.forEach(function(e){h(e,t,i,n,o)}),{lengths:n,componentMap:i,components:o}},_=function(e,t){var i=e.split("/");if(2===i.length){var n=i[1];if(n.length<t.length+2)return!1;if(n.substring(n.length-t.length)!==t)return!1;var o=n.length-(t.length+1);return"+"===n.charAt(o)}return!1},u=/^[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 i=e.fileName.split("/");if(i){var n=i[i.length-1];return!t&&"metadata.xml"===n||n.match(u)}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=d},function(e,t){e.exports=require("yazl")},function(e,t){e.exports=require("yauzl")},function(e,t,i){const n=i(4),o=i(57),r=i(44),a=i(1),s=i(0),c=i(107),l=i(108),d=i(14),p=i(2),h=i(18),_=i(7),u=i(11),f=i(59),m=i(10).promisify;e.exports=class extends o{constructor(e){super(e),this._bookmarkManager=new c(this),this._fontManager=new l(this)}_syncNewLibraries(e){this._loadingHint&&(e=e.slice()).sort((e,t)=>Number(this._loadingHint.includes(t.name))-Number(this._loadingHint.includes(e.name)));const t=(e=e.filter(e=>!this._doesLibraryExist(e.name))).map(e=>new Promise(t=>{this._syncNewLibrary(e.name,void 0,e,(e,i)=>{e&&this._reportSyncError(e),t(i)})}));return Promise.all(t).then(e=>e.some(e=>e))}_syncExistingLibraries(e,t){const i=[];return this._libraries.forEach(n=>{const o=e&&e[n.id];if(o&&(n._setCollaboration(o),n._deletedFromServer&&(n._deletedFromServer=!1,n._notifyChange())),t)return void((t[n.id]||o&&!o.isUnmodified)&&i.push(e=>n._sync(!1,e)));const r=!e||o&&o.isUnmodified;void 0===n.collaboration?i.push(e=>n._sync(r,e)):r?i.push(e=>{this._syncManager.hasCompositeChangedOnServer(n._dcxComposite,t=>{n._sync(!t,e)})}):i.push(e=>n._sync(!1,e))}),Promise.all(i.map(e=>new Promise(t=>{e((e,i)=>{e&&this._reportSyncError(e),t(i)})}))).then(e=>e.some(e=>e))}_handlePendingDeletes(){const e=this._pendingDeletes.map(e=>new Promise(t=>{e._deleteFromServer(!1,i=>i&&i.code===n.UPDATE_CONFLICT?(this._removeFromPendingDeletes(e),this._libraries.push(e),this._libraryIdMap[e.id]=e,e._markDeletedLocally(!1),this._updateSyncState(),this._notifyChange(!0),void t(!0)):i?(this._reportSyncError(i),void t(!1)):(this._removeFromPendingDeletes(e),e._deletedFromDisk=!0,void _.deleteLibraryFromDisk(this,e.id,e=>{e&&this._reportSyncError(e),t(!0)})))}));return Promise.all(e).then(e=>e.some(e=>e))}_removeFromPendingDeletes(e){const t=this._pendingDeletes.indexOf(e);-1!==t&&this._pendingDeletes.splice(t,1)}_dosync(e,t){this._clearSyncErrors(),this._syncManager.getServerComposites((i,n,o)=>{if(i)return i=u.getSyncError(i,void 0,{403:p.ACCESS_DENIED}),this._reportSyncError(i),void t(null,!1);const r=[];if(r.push(this._syncNewLibraries(n)),r.push(this._syncExistingLibraries(o,e)),r.push(this._handlePendingDeletes()),!e){const e=m(this._bookmarkManager.sync.bind(this._bookmarkManager))().catch(e=>this._reportSyncError(e)).then(()=>!1);r.push(e)}Promise.all(r).then(e=>t(null,e.some(e=>e)))})}_ensureDefaultLibrary(){const e="ok"===this.syncState&&!this.isInitialSyncInProgress&&s.SYNCING_ENABLED,t=this.libraries.some(e=>!e.isDeletedLocally&&!e.isDeletedFromServer);if(e&&!t){const e=h.translate("LIBS_DEFAULT_LIBRARY_NAME");a.log("Creating default library: "+e),this.createLibrary(e)}}_updateSyncState(){super._updateSyncState(),this._ensureDefaultLibrary()}_doRemoveLibrary(e,t=(()=>void 0)){const i=this._libraries.indexOf(e);-1!==i&&(this._libraries.splice(i,1),delete this._libraryIdMap[e.id]),e._removeAllListeners(),s.SHARED_LOCAL_STORAGE?(e._dcxBranch.compositeState="pendingDelete",e._commit(!1,!0),e._markDeletedLocally(!0),t(null)):(this._pendingDeletes.push(e),s.SYNCING_ENABLED?e._deleteFromServer(!0,i=>{e._markDeletedLocally(!0),i?t(null):(this._removeFromPendingDeletes(e),e._deletedFromDisk=!0,_.deleteLibraryFromDisk(this,e.id,t))}):(e._dcxBranch.compositeState="pendingDelete",e._commit(!0,!0),e._markDeletedLocally(!0),t(null))),this._notifyChange(!0)}_doImportLibrary(e,t,i){if(s.SHARED_LOCAL_STORAGE){const i=a.uuid();return a.storageInterface.importLibrary(this,e,i,t),this._addOperation(i,"import")}let n;const o=this._addOperation(i||a.uuid(),"import",void 0,()=>n&&n());return n=f.importLibrary(this,e,e=>o._updateProgress(e),(e,i)=>{o._updateProgress(100),this._removeOperation(o),t(e,i)}),o}get isPublic(){return!1}get bookmarks(){return this._bookmarkManager.getBookmarks()}get fontManager(){return this._fontManager}createLibrary(e){const t=a.uuid(),i=s.COMPOSITE_TYPE,n=this._getCompositeDir(t),o=a.dcx.newEmptyComposite(e,i,n,t);o.current.rootNode.setValue(s.VERSION_KEY,s.VERSION),this._syncManager.prepareCompositeForPush(o);const c=new r(this,o);return c._updateCreatedTime(),this._libraries.push(c),this._libraryIdMap[c.id]=c,this._notifyChange(!0),c._commit(!1,!0),d.reportCreateLibrary(c),c}removeLibrary(e,t){this._doRemoveLibrary(e,t),d.reportDeleteLibrary(e)}importLibrary(e,t){if("string"==typeof e){if(s.SHARED_LOCAL_STORAGE||a.hasFileSystem())return this._doImportLibrary(e,(e,i)=>{d.reportImportLibrary(e,i),t(e,i)});t(new p(p.REQUIRES_FILESYSTEM,"importLibrary only supported when you have a filesystem"))}else t(new p(p.INVALID_PARAMETER,"path must be a string"))}createBookmark(e,t,i){this._bookmarkManager.createBookmark(e,t,i)}removeBookmark(e,t){this._bookmarkManager.removeBookmark(e,t)}findBookmark(e){return this.bookmarks&&this.bookmarks.find(t=>t.url===e._dcxComposite.href)}syncBookmarks(e=(()=>void 0)){this._bookmarkManager.sync(e)}getDefaultLibrary(){return this.libraries.reduce((e,t)=>{const i=!e||(e.created||0)>(t.created||0);return"incoming"!==t.collaboration&&i?t:e},void 0)}getToolkitLibrary(e){const t=this._libraries.filter(t=>t.toolkitId===e);if(!t.length){const t=this.createLibrary(h.getToolkitName(e));return t.setValue(s.TOOLKIT_NAMESPACE,s.TOOLKIT_ID_KEY,e),t}return t.sort((e,t)=>e.created-t.created),t[0]}}},function(e,t,i){const n=i(4),o=i(44),r=i(1),a=i(0),s=i(101),c=i(14),l=i(2),d=i(105),p=i(7),h=i(15),_=i(11),u=i(21),f=i(16),m=i(59),E=i(5),g=i(106),y=i(10).promisify;e.exports=class{constructor(e){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 E(["change","deepchange","sync","operation","commitError"]),this._operations=[],g.connect(this),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._recoveredLibraryCount=0}_dispose(){g.disconnect(this)}_removeAllListeners(){this._listenerManager.removeAll(),this._libraries.forEach(e=>e._removeAllListeners())}_notifyChange(e){this._listenerManager.notify("deepchange"),e&&this._listenerManager.notify("change")}_loadLibrary(e,t){const i=this._getCompositeDir(e),n=i=>{r.log(`Load error: ${i}`),p.deleteLibraryFromDisk(this,e,()=>t(null))},a=i=>{const n=new o(this,i,this.isPublic&&e);"pendingDelete"===i.current.compositeState?(this._pendingDeletes.push(n),t(null)):(this._libraries.push(n),this._libraryIdMap[n.id]=n,n._renditionCache.load().then(t))};r.dcx.newCompositeFromLocalStorage(i,(t,i)=>t?n(`DCX error loading composite for ${e}`):i&&i.current?h.validateLibrary(i)?this.isPublic||i.id===e?void(i.href&&i.current.isBound?i.loadBaseBranch((t,o)=>{t||!o?n(`missing base branch for ${e} (even though bound to server)`):a(i)}):a(i)):n(`library id ${i.id} doesn't match folder on disk ${e}`):n(`failed validation for ${e}`):n(`composite/branch not loaded for ${e}`))}_load(e,t){this._loaded?e(null):(this._loaded=!0,p.readLibraryDirectory(this,(i,n)=>{if(i||!n)return void e(null);if(!t&&!this.isPublic&&n.length>=a.ELMO_LOCAL_LIBRARY_LIMIT)return void h.recoverFromElmo(this,n,()=>{this._loaded=!1,this._load(e,!0)});const o=[];if(n.forEach(e=>{if(h.validateLibraryId(e,this.isPublic)){const t=y(this._loadLibrary.bind(this))(e).catch(e=>this._reportCommitError(e));o.push(t)}}),o.push(this._externalLinkCache.load()),!this.isPublic){const e=y(this._bookmarkManager.load.bind(this._bookmarkManager))().catch(e=>this._reportCommitError(e));o.push(e)}Promise.all(o).then(()=>{r.log("Loaded "+this._libraries.length+" libraries and "+this._pendingDeletes.length+" pending deletes"),e(null)})}))}_doesLibraryExist(e){return this._libraryIdMap[e]||this._pendingDeletes.find(t=>t.id===e)}_syncNewLibrary(e,t,i,a){const s=t||this._syncManager.getCompositePath(e),c=r.hasFileSystem()&&this._getCompositeDir(e),d=r.dcx.newCompositeWithHref(s,c);this._libraryIdMap[e]="pending",this._updateSyncState();const p={id:e,_dcxComposite:d,collection:this};this._syncManager.pullLibrary(p,(t,r)=>{if(t||!r)return delete this._libraryIdMap[e],this._updateSyncState(),t=t?t.code===n.NO_COMPOSITE||t.code===n.DELETED_COMPOSITE?null:_.getSyncError(t,e):new l(l.NETWORK_ERROR,"No pulled branch"),void a(t,!0);d.resolvePullWithBranch(r,t=>{if(t||!this.isPublic&&d.id!==e)return delete this._libraryIdMap[e],this._updateSyncState(),t=t?_.getCommitError(t,e):new l(l.CORRUPTED_LIBRARY,"Library id does not match sync group id"),void a(t,!0);const n=new o(this,d,this.isPublic&&e);this._libraries.push(n),this._libraryIdMap[n.id]=n,this._updateSyncState(),n._setCollaboration(i),f.prefetchRenditions(n),this._notifyChange(!0),a(null,!0)})})}_reportSyncError(e){e&&(r.log("Sync error: "+_.errorToString(e)),this._syncErrors.push(e))}_clearSyncErrors(e){this._syncErrors=e?this._syncErrors.filter(t=>t.libraryId!==e):[]}_reportCommitError(e){this._lastCommitError=e,e&&(r.log("Commit error: "+_.errorToString(e)),this._listenerManager.notify("commitError",[e]))}_updateRetryState(){if(!this._retryTimeoutId&&"syncing"!==this._syncState){if("error"===this._syncState){const e=this.getPrimarySyncError();if(e&&e.code===l.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);const t=e.underlyingError&&e.underlyingError.response&&e.underlyingError.response.headers;let i=1e3*u.getRetryAfterHeader(t);return i>0?(this._numRetries=a.ERROR_RETRY_INTERVALS.length,r.log("Got Retry-After header")):i=1e3*a.ERROR_RETRY_INTERVALS[this._numRetries-1],r.log("Retrying after "+i+"ms"),this._retryTime=(new Date).valueOf()+i,void(this._retryTimeoutId=setTimeout(()=>{this._retryTimeoutId=void 0,this._retryTime=void 0,r.log("Starting retry"),this._syncWithParameters(!1)},i))}if(e&&e.code===l.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}}_setInitialSyncState(e,t){this._initialSyncInProgress=e,this._loadingHint=t,this._updateSyncState()}_resetPollBackoff(){this._backoffTicks=0,this._numBackoffs=0}_updateSyncState(){let e="syncing";this._initialSyncInProgress||Object.keys(this._libraryIdMap).some(e=>{const t=this._libraryIdMap[e];return"pending"===t||t._isSyncing()})||(this._syncErrors.length>0?(e="error",this._syncManager.clearSyncGroupCache(),c.reportError(this.getPrimarySyncError())):e="ok",this._syncProgressMap={},this._syncProgress=void 0);const t=this._syncState;this._syncState=e,this._updateRetryState(),t===e&&"error"!==this._syncState||this._listenerManager.notify("sync")}_updateProgress(e,t,i){i?this._syncProgressMap[e]={bytesLoaded:t||0,bytesTotal:i,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};let n=!1;const o=t||0,r=(i||0)>0?Math.max(0,Math.min(100,Math.round(o/i*100))):void 0;this._syncProgressMap[e].progress!==r&&(this._syncProgressMap[e].progress=r,n=!0);let a=0,s=0,c=0,l=0;const d=this._syncProgressMap;Object.keys(d).forEach(e=>{a++,d[e].bytesTotal>0&&s++,c+=d[e].bytesLoaded,l+=d[e].bytesTotal});const p=l>0?c*s/(l*a):0,h=Math.max(0,Math.min(100,Math.round(100*p)));(!this._syncProgress||this._syncProgress<h||100===this._syncProgress&&h<100)&&(this._syncProgress=h,n=!0),n&&this._listenerManager.notify("sync")}_updateExternalLinkDownloadProgress(e,t,i,n){const o=e.element.library.id+"."+e.element.id+"."+e.id;let r;i?(t=t||0,r=Math.max(0,Math.min(100,Math.round(t/i*100)))):n&&(r=-1),r!==this._externalLinkDownloadProgressMap[o]&&(void 0===r?delete this._externalLinkDownloadProgressMap[o]:this._externalLinkDownloadProgressMap[o]=r,this._listenerManager.notify("sync"))}_getExternalLinkDownloadProgress(e){const t=e.element.library.id+"."+e.element.id+"."+e.id;return this._externalLinkDownloadProgressMap[t]}_abortPushOrPull(e=!1){Object.keys(this._libraryIdMap).forEach(e=>{const t=this._libraryIdMap[e];"pending"===t?this._syncManager.abortPushOrPull(e):t._abortPushOrPull()}),this._pendingDeletes.forEach(e=>e._abortPushOrPull());const t=this._pendingSyncs;this._pendingSyncs=[],t.forEach(e=>e(new l(l.TRANSFER_ABORTED,"abort push or pull operation"))),e&&this._syncManager.abortAllDownloads()}_getBaseDir(){const e=r.getPathSeparator();return p.getUserDir(this._userId)+e+this._cloudId}_getLibraryDir(e,t){const i=r.getPathSeparator();let n=this._getBaseDir()+i+e;return t&&(n+=i+t),n}_getCompositeDir(e){return this._getLibraryDir("dcx",e)}_getTempDir(){const e=r.getPathSeparator();return this._getBaseDir()+e+".tmp"}_getRenditionCacheDir(e){return this._getLibraryDir("renditions",e)}_addOperation(e,t,i,n){const o=new d(this,e,t,i,n);return this._operations.push(o),this._operationIdMap[o.id]=o,this._notifyOperationChange(),o}_removeOperation(e){const t=this._operations.indexOf(e);-1!==t&&(this._operations.splice(t,1),delete this._operationIdMap[e.id]),this._notifyOperationChange()}_delayedRemoveOperation(e){this._removeOperationTimeout[e.id]||(this._removeOperationTimeout[e.id]=setTimeout(()=>{delete this._removeOperationTimeout[e.id],this._removeOperation(e)},a.REMOVE_OPERATION_TIMEOUT))}_updateOperation(e,t,i,n){this._operationIdMap[e]||this._addOperation(e,t,i),this._removeOperationTimeout[e]&&(clearTimeout(this._removeOperationTimeout[e]),delete this._removeOperationTimeout[e]),this._operationIdMap[e]._updateProgress(n)}_notifyOperationChange(){this._listenerManager.notify("operation")}_doExportLibrary(e,t,i,n){if(a.SHARED_LOCAL_STORAGE){const n=r.uuid();return r.storageInterface.exportLibrary(e,t,n,i),this._addOperation(n,"export",{libraryId:e.id})}let o;n=n||r.uuid(),e._setAutoGC("export_"+n,!1);const s=this._addOperation(n,"export",{libraryId:e.id},()=>o&&o());return o=m.exportLibrary(e,t,e=>s._updateProgress(e),t=>{s._updateProgress(100),this._removeOperation(s),e._setAutoGC("export_"+n,!0),i(t)}),s}_syncWithParameters(e,t,i,n){const o=()=>n&&n(null);if(a.SHARED_LOCAL_STORAGE)return r.storageInterface.sync(this),void o();a.SYNCING_ENABLED&&!this._retryTimeoutId?(e||this._resetPollBackoff(),this._syncing?this.isPolling?o():this._pendingSyncs.push(o):(new Date).valueOf()<this._lastSyncTime+a.MAX_SYNC_INTERVAL?t?o():setTimeout(()=>this._syncWithParameters(e,!0,i,o),a.MAX_SYNC_INTERVAL):(r.log("Start Sync: "+this.cloudId+(e?" [polling]":"")),this._syncing=!0,this._lastSyncTime=(new Date).valueOf(),this._dosync(i,(e,t)=>{if(this._syncing=!1,this._updateSyncState(),r.log("End Sync: "+this.cloudId),t&&this._resetPollBackoff(),this._pendingSyncs.length>0){const e=this._pendingSyncs;this._pendingSyncs=[],this.sync(()=>e.forEach(e=>e()))}o()}))):o()}get libraries(){return this._libraries}get commitError(){return this._lastCommitError}get syncState(){return this._syncState}get syncErrors(){return this._syncErrors}get syncProgress(){return this._syncProgress}get isInitialSyncInProgress(){return this._initialSyncInProgress}get isPolling(){return void 0!==this._pollTimerId}get isLoggedIn(){if(!a.SHARED_LOCAL_STORAGE)return this._syncManager.isLoggedIn()}get retryTime(){return"never"!==this._retryTime?this._retryTime:void 0}get userId(){return this._userId}get cloudId(){return this._cloudId}get cloudInfo(){return this._cloudInfo}get operations(){return this._operations}addChangeListener(e){this._listenerManager.add("change",e)}removeChangeListener(e){this._listenerManager.remove("change",e)}addDeepChangeListener(e){this._listenerManager.add("deepchange",e)}removeDeepChangeListener(e){this._listenerManager.remove("deepchange",e)}addOperationChangeListener(e){this._listenerManager.add("operation",e)}removeOperationChangeListener(e){this._listenerManager.remove("operation",e)}addSyncListener(e){this._listenerManager.add("sync",e)}removeSyncListener(e){this._listenerManager.remove("sync",e)}addCommitErrorListener(e){this._listenerManager.add("commitError",e)}removeCommitErrorListener(e){this._listenerManager.remove("commitError",e)}removeDeletedLibraries(e,t=(()=>void 0)){"function"==typeof e&&(t=e,e=void 0);const i=e&&e.exclude||[],n=e=>{const t=this._libraries.indexOf(e);return-1!==t&&(this._libraries.splice(t,1),delete this._libraryIdMap[e.id]),e._deletedFromDisk=!0,e._markDeletedLocally(!0),y(p.deleteLibraryFromDisk)(this,e.id)},o=this._libraries.filter(e=>e.isDeletedFromServer&&i.every(t=>e!==t)).map(e=>n(e)),r=e=>{o.length>0&&this._notifyChange(!0),t(e)};Promise.all(o).then(()=>r(null),r)}exportLibrary(e,t,i){if(-1!==this._libraries.indexOf(e))if("string"==typeof t)if(0===t.length||t[t.length-1].match(/\\|\//))i(new l(l.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,t=>{c.reportExportLibrary(t,e),i(t)});i(new l(l.REQUIRES_FILESYSTEM,"exportLibrary only supported when you have a filesystem"))}else i(new l(l.INVALID_PARAMETER,"path must be a string"));else i(new l(l.INVALID_PARAMETER,"library not in this collection"))}sync(e){this._syncWithParameters(!1,!1,void 0,e)}syncChanges(e,t){const i={};(e=e||[]).forEach(e=>i[e]=!0),this._syncWithParameters(!1,!1,i,t)}syncFull(e){this._syncManager.clearSyncGroupCache(),this._syncWithParameters(!1,!1,void 0,e)}getPrimarySyncError(){let e=this._syncErrors[0];return this._syncErrors.forEach(t=>{const i=_.getErrorPriority(t),n=_.getErrorPriority(e);i>n?e=t:i===n&&e.code===t.code&&e.libraryId!==t.libraryId&&(e=new l(e.code,"multiple errors (see libraryCollection.syncErrors)",void 0))}),e}getNewLibrarySyncProgress(){return this._newLibraryProgress?this._newLibraryProgress:Object.keys(this._libraryIdMap).filter(e=>"pending"===this._libraryIdMap[e]).map(e=>({id:e,progress:this._syncProgressMap[e]&&this._syncProgressMap[e].progress}))}startPolling(){if(a.SHARED_LOCAL_STORAGE)throw new l(l.NOT_SUPPORTED,"startPolling() not supported with shared local storage");if(!this.isPolling){const e=6e4*a.POLL_INTERVAL;this._pollTimerId=setInterval(()=>{"never"!==this._retryTime&&(this._backoffTicks>0?this._backoffTicks--:(0===this._backoffTicks&&(this._numBackoffs++,this._backoffTicks=u.getBackoffTicks(this._numBackoffs)),this._syncWithParameters(!0)))},e)}}stopPolling(){if(a.SHARED_LOCAL_STORAGE)throw new l(l.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)}getLibraryById(e){const t=this._libraryIdMap[e];if(t instanceof o)return t}updateAccessToken(e){if(a.SHARED_LOCAL_STORAGE)throw new l(l.NOT_SUPPORTED,"updateAccessToken() not supported with shared local storage");this._syncManager.updateAccessToken(e),r.log("defined")}getTempDir(e){if(!r.hasFileSystem())return void e(new l(l.REQUIRES_FILESYSTEM,"getTempDir only supported when you have a filesystem"));const t=this._getTempDir();p.ensurePathExists(t,i=>e(i,t))}copyFileToTempDir(e,t){this.getTempDir((i,n)=>{if(i)return void t(i);const o=p.getFileExtension(e),a=n+r.getPathSeparator()+r.uuid()+(o?"."+o:"");p.copyFile(e,a,e=>{e?p.deleteFile(a,()=>t(e)):t(null,a)})})}}},function(e,t,i){const n=i(45),o=i(46),r=i(1),a=i(0),s=i(20),c=i(7),l=i(11);e.exports=class{constructor(e){this._rootDir=e,this._cache={},this._pendingCacheItems={},this._lock=new s}load(){return this._loadingPromise||(this._loadingPromise=this._doTransaction(()=>this._load(),!1)),this._loadingPromise}save(){return this._doTransaction(()=>this._save())}_doTransaction(e,t=!0){const i=()=>this._lock.release();let n=new Promise(e=>this._lock.obtain(e)).then(e);return t&&(n=n.then(e=>this._save().then(()=>e))),n.then(i,i),n}_load(){return!r.hasFileSystem()||a.SHARED_LOCAL_STORAGE?Promise.resolve():c.readJSONData(o.join(this._rootDir,a.RENDITION_CACHE_FILE)).catch(()=>void 0).then(e=>{this._cache=e||{}})}_save(){return!r.hasFileSystem()||a.SHARED_LOCAL_STORAGE?Promise.resolve():c.writeJSONData(this._rootDir,a.RENDITION_CACHE_FILE,this._cache).then(()=>this._gcUnreferencedFiles())}_waitForCommit(e){if(!this._lock.isLocked())return e();this._doTransaction(e,!1)}_getCache(e){let t=this._cache;for(let i=0;t&&i<e.length;i++)t=t[e[i]];return t}_isErrorCode(e){return e&&l.isErrorCode(e)}_isPath(e){return e&&e!==a.RENDITION_CACHE_PLACEHOLDER&&!this._isErrorCode(e)}_getFilePath(e,t){if(!e)return;if(t&&!this._isPath(e))return e;const i=o.join(this._rootDir,e);return a.SHARED_LOCAL_STORAGE||n.statSync(i)?i:void 0}_setCacheEntry(e,t){let i=this._cache;for(let t=0;t<e.length-1;t++){const n=e[t];i=i[n]=i[n]||{}}const n=e[e.length-1];return void 0===t?delete i[n]:i[n]=t,t}_setCache(e,t,i){const a=c.getFileExtension(t)||"png",s=`${r.uuid()}.${a}`;return n.ensureDir(this._rootDir).then(()=>(this._pendingCacheItems[s]=!0,n[i?"rename":"copy"](t,o.join(this._rootDir,s)))).then(()=>(delete this._pendingCacheItems[s],this._setCacheEntry(e,s),o.join(this._rootDir,s))).catch(e=>(delete this._pendingCacheItems[s],Promise.reject(l.getCommitError(e,void 0,"unable to save cache to disk"))))}_iterate(e,t=this._cache,i=[]){Object.keys(t).forEach(n=>{"object"==typeof t[n]?this._iterate(e,t[n],i.concat(n)):e(i,t[n])})}_gcUnreferencedFiles(){const e={};return this._iterate((t,i)=>{e[i]=!0,delete this._pendingCacheItems[i]}),n.readdir(this._rootDir).then(t=>{const i=[];return t.forEach(t=>{const r=c.normaliseTempFileName(t);t===a.RENDITION_CACHE_FILE||e[t]||this._pendingCacheItems[r]||i.push(n.remove(o.join(this._rootDir,t)))}),Promise.all(i)})}}},function(e,t,i){const n=i(53),o=i(0),r=i(1),a=i(7),s=i(11),c=i(2),l={},d=/^[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,i,o)=>{let r,d;const p=(t,i)=>{if(d&&(t=new c(c.OPERATION_CANCELLED,"import cancelled")),t)return void o(t);r=void 0;const n=i.libraryId,l=i.extractPath,p=e._getCompositeDir(n),h=e=>{a.recursiveDeleteDirectory(l),a.recursiveDeleteDirectory(p),o(e)};a.rename(l,p,t=>{if(t)return h(s.getFileSystemError(t,"unable to move extracted zip after import"));e._loadLibrary(n,t=>{if(t)return h(t);const i=e.getLibraryById(n);if(!i)return h(new c(c.INVALID_DATA,"could not load library after import"));e._notifyChange(!0),i._push(),o(null,i)})})};return n.isSnapshot(t,(o,a)=>{if(o||d)return void p(o&&s.getSnapshotError(o,void 0,"error opening library archive"));const c=e._getTempDir();if(a){const o=e._syncManager.getSyncGroupPath();r=n.importSnapshot(t,c,o,!1,i,(e,t)=>{!e&&t?p(null,{libraryId:t.id,extractPath:t.path}):p(s.getSnapshotError(e,void 0,"cannot import the snapshot file"))})}else r=l._importNonSnapshotLibrary(e,t,c,i,p)}),()=>{d||(d=!0,r&&r())}}),l._importNonSnapshotLibrary=((e,t,i,n,l)=>{const p=r.getPathSeparator(),h=r.fs,_=r.yauzl;if(!_)return void l(new c(c.NOT_SUPPORTED,"yauzl (unzip) module not present"));const u=r.uuid(),f=i+r.getPathSeparator()+u,m=e._syncManager.getCompositePath(u);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:u,extractPath:f}))},S=f+p+"components";return a.ensurePathExists(S,e=>{e?I(s.getFileSystemError(e,"unable to create temp dir")):_.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(d))(e)?"data"!==e.fileName?(v=e.uncompressedSize,E.openReadStream(e,(t,i)=>{t?I(s.getFileSystemError(t,"error extracting zip file")):(i.on("end",()=>{E.readEntry()}),i.on("data",e=>{A+=e.length,(()=>{if(!g){let e=y/E.entryCount;v&&(e+=A/(v*E.entryCount)),n(Math.round(100*e))}})()}).on("error",e=>{I(s.getFileSystemError(e,"error extracting zip file"))}).pipe(h.createWriteStream(S+p+e.fileName)))})):E.openReadStream(e,(e,t)=>{if(e)return void I(s.getFileSystemError(e,"error reading zip file entry"));const i=[];t.on("data",e=>{i.push(e)}),t.on("error",e=>{I(s.getFileSystemError(e,"error extracting zip file"))}),t.on("end",()=>{const e=((e,t,i)=>{let n;try{n=JSON.parse(e)}catch(e){return null}if(!n||n.version!==o.EXPORT_VERSION)return null;const r=n.manifest,a=n.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:i,"copyOnWrite#storageIds":n.componentMap},{json:n,manifest:r})})(Buffer.concat(i).toString(),u,m);e&&e.manifest?h.writeFile(f+p+"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,i,r)=>{let a;const l=n.exportSnapshot(e._dcxComposite,t,e=>(delete e[`${o.TOOLKIT_NAMESPACE}#${o.TOOLKIT_ID_KEY}`],e.children=e.children.filter(e=>e.name!==o.REMOVED_ELEMENTS_NAME),e),i,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){e.exports=class{constructor(e,t){this._id=e,this._url=t}get id(){return this._id}get url(){return this._url}}},function(e,t,i){const n=i(57),o=i(2),r=i(0),a=i(1),s=i(7);e.exports=class extends n{constructor(e){e.IS_PUBLIC=!0,e.USER_ID=e.USER_ID||r.PUBLIC_USER_ID,super(e),this._newLibrariesLoading={}}_dosync(e,t){this._clearSyncErrors();const i=this._libraries.map(e=>new Promise(t=>{this._syncManager.hasCompositeChangedOnServer(e._dcxComposite,i=>{e._sync(!i,(e,i)=>{e&&this._reportSyncError(e),t(i)})})}));Promise.all(i).then(e=>t(null,e.some(e=>e)))}get isPublic(){return!0}canLoadLibrary(e){const t=new RegExp(this._syncManager.getSyncGroupPath()+"/(.+)");return!!e.match(t)}loadLibrary(e,t,i){const n=this.getLibraryById(e);if(n)return void i(null,n);if(t&&!this.canLoadLibrary(t))return void i(new o(o.INVALID_PARAMETER,"Invalid library url"));const s=this._newLibrariesLoading[e];if(s)return void s.push(i);this._newLibrariesLoading[e]=[i];const c=(t,i)=>{const n=this._newLibrariesLoading[e];delete this._newLibrariesLoading[e],n.forEach(e=>e(t,i))};r.SHARED_LOCAL_STORAGE?a.storageInterface.loadPublicLibrary(this,e,t,c):this._syncNewLibrary(e,t,void 0,t=>{if(t)return void c(t);const i=this.getLibraryById(e);i&&(i._loadedExternally=!0),c(null,i)})}unloadLibrary(e,t){const i=this._libraries.indexOf(e);-1!==i?(this._libraries.splice(i,1),delete this._libraryIdMap[e.id],e._markDeletedLocally(!0),r.SHARED_LOCAL_STORAGE?a.storageInterface.unloadPublicLibrary(e,t):(e._deletedFromDisk=!0,s.deleteLibraryFromDisk(this,e.id,t)),this._listenerManager.notify("change")):t(null)}}},function(e,t,i){const n=i(1),o=i(5),r=i(29),a=e=>`${e}_req`,s=e=>`${e}_res`,c=(e,t,i)=>`${e}#${t}#${i}`;e.exports=class{constructor(e,t){this._socket=e,this._version=t,this._listenerManager=new o,this._socketListenerManager=new o,this._pendingWriteState={},this._pendingWriteDependencyMap={},this._stringMap={},this._addSocketListener("message",e=>this._onMessage(e))}_onMessage(e){if(this._pendingStringId)return this._log(`RECEIVE STRING ${this._pendingStringId}`),this._stringMap[this._pendingStringId]=e,void delete this._pendingStringId;if(":"===e[0])return void(this._pendingStringId=e);const t=JSON.parse(e,(e,t)=>{if("manifest"===e&&this._stringMap[t]){const e=this._stringMap[t];return delete this._stringMap[t],e}return t});this._log(`RECEIVE ${t.type}`),this._listenerManager.notify(t.type,[t.data])}_addSocketListener(e,t){this._socketListenerManager.add(e,t),this._socket.addListener(e,t)}_removeSocketListeners(){this._socketListenerManager.forEach((e,t)=>this._socket.removeListener(e,t)),this._socketListenerManager.removeAll()}_log(e){this._logCallback&&this._logCallback(e)}setPendingWriteState(e,t,i){const n=c(e,t,i);this._pendingWriteState[n]=!0}setPendingWriteDependency(e,t,i,n,o,r){const a=c(e,t,i),s=c(n,o,r);a!==s&&(this._pendingWriteDependencyMap[a]=this._pendingWriteDependencyMap[a]||{},this._pendingWriteDependencyMap[a][s]={userId:n,cloudId:o,id:r})}clearPendingWriteState(e,t,i){var n=c(e,t,i),o=[];return Object.keys(this._pendingWriteDependencyMap[n]||{}).forEach(e=>{o.push(this._pendingWriteDependencyMap[n][e])}),delete this._pendingWriteState[n],delete this._pendingWriteDependencyMap[n],o}getPendingWriteState(e,t,i,n){const o=c(e,t,i);let r=!1;return!n&&this._pendingWriteState[o]&&(r=this._pendingWriteState[o]),Object.keys(this._pendingWriteDependencyMap).forEach(e=>{this._pendingWriteDependencyMap[e][o]&&(r=this._pendingWriteState[e]||r)}),r}setLogCallback(e){this._logCallback=e}addListener(e,t){this._listenerManager.add(e,t)}removeListener(e,t){this._listenerManager.remove(e,t)}send(e,t){try{this._log(`SEND ${e}`);const i=JSON.stringify({type:e,data:t},(e,t)=>{if("manifest"===e&&r.supportsStringMessages(this._version)){const e=":"+n.uuid();return this._log(`SEND STRING ${e}`),this._socket.send(e),this._socket.send(t),e}return t});this._socket.send(i)}catch(e){this._log(`ERROR ${e}`),this._socketListenerManager.notify("error",[e])}}addCallListener(e,t){this.addListener(a(e),i=>{const n=i.id;t(i.data,t=>{this.send(s(e),{id:n,data:t})})})}removeCallListener(e,t){this.removeListener(a(e),t)}call(e,t,i){const o=n.uuid(),r=t=>{t.id===o&&(this.removeListener(s(e),r),i(t.data))};this.addListener(s(e),r),this.send(a(e),{id:o,data:t})}onOpen(e){this._addSocketListener("open",e)}onClose(e){this._addSocketListener("close",e)}onError(e){this._addSocketListener("error",e)}shutdown(){this._addSocketListener("close",()=>{this._removeSocketListeners(),this._listenerManager.removeAll()});try{this._socket.close()}catch(e){}}}},function(e,t,i){var n=i(20),o={},r={obtainLock:function(e,t){o[e]||(o[e]=new n),o[e].obtain(t)},releaseLock:function(e){o[e]&&o[e].release()},isLocked:function(e){return!!o[e]&&o[e].isLocked()},hasPendingRequest:function(e){return!!o[e]&&o[e].hasPendingRequest()}};e.exports=r},function(e,t,i){global.LOCALE_ROOT=__dirname+"/locale/";const n=i(38),o=i(19),r=i(25);var a=i(3),s=i(6),c=i(71),l=i(115),d=i(117),p=i(118),h=i(22),_=i(63),u=i(47),f=i(119),m=i(123),E=i(32),g=i(127),y=i(129),v=i(130),A=i(131),C=i(24),I=i(23),S=i(132),L=i(133),O=i(134),R=i(135),T=i(136),N=i(147),D=i(149),b=i(9),P=i(2),w=i(0),x=i(1),k=i(18),M=i(150),V=i(15),F=i(11),U=i(16),B=i(7),H="Service",Y=!1;process.argv.forEach(e=>{"--test"===e&&(console.log("Testing CCLibrary Process..."),Y=!0)}),i(151).start(),l.clearTempFiles(a.getValue("ROOT_DIR")),Error.stackTraceLimit=1/0;var G=function(e){var t=0,i=function(){2===++t&&process.exit()},n=function(){s.removeLogWriteListener(n),i()};s.addLogWriteListener(n),s.log(H,"Uncaught exception: "+e+"\n"+e.stack),w.ANALYTICS_ENABLED?C.reportError("Uncaught",e+"\n"+e.stack,!0,i):i()};Y||process.on("uncaughtException",G);const j=[new n.Server({port:0,host:"127.0.0.1",verifyClient(e,t){if("file://"!==e.origin&&!e.origin.match(/http:\/\/localhost:[0-9]+$/))return s.log(H,"Rejected attempt to connect to websocket server from: "+e.origin),C.reportEvent("rejectedClientOrigin",{origin:e.origin}),void t(!1);t(!0)}}),new N];var W=new M;function q(e){_.isLocked(e.id)||(W.broadcast("librarychange",d.getLibraryData(e)),f.libraryChanged(e,!1))}function X(e){return e.isPublic?b.getLoadedPublicCollectionById(e.cloudId):b.getLoadedCollectionById(e.userId,e.cloudId)}function K(e,t){var i=X(e);return i&&i.getLibraryById(e[t||"id"])}function z(e,t,i){var n=K(e,i);return n&&n.getElementById(e[t||"element"])}function J(e){var t=z(e);return t&&t.getRepresentationById(e.representation)}var $,Q,Z=function(e,t){var i=K(e);i&&i._setAutoGC("client_writing",t)};function ee(e,t,i){var n=function(){var n=function(){c.validateBookmarks()};i?e.syncChanges(i,n):t?e.syncFull(n):e.sync(n)};e.isPublic||e.isLoggedIn?n():E.getAccessToken(function(t,i){!t&&i&&(e.updateAccessToken(i),n())})}function te(e){b.getLoadedCollections().forEach(t=>{e?t.isPublic||ee(t,!1,e):ee(t,!1)})}var ie=[],ne=function(){var e=[],t={};ie.forEach(i=>{X(i)?(e.push(i),t[i.userId+"/"+i.cloudId]=!0):function(e){W.broadcast("collectionremoved",e)}(i)}),b.getLoadedCollections().forEach(i=>{var n=i.isPublic?w.PUBLIC_USER_ID:i.userId;t[n+"/"+i.cloudId]||(e.push({isPublic:i.isPublic,userId:n,cloudId:i.cloudId}),function(e){W.broadcast("collectionadded",d.getCollectionData(e)),W.broadcast("syncstate",d.getSyncStateData(e))}(i))}),ie=e};b.addLoadedCollectionsListener(ne);var oe={};function re(e){var t=(e.isPublic?"":e.userId)+"/"+e.cloudId;oe[t]=oe[t]||{};var i=oe[t];e.libraries.forEach(e=>{i[e.id]||(i[e.id]=(()=>q(e)),e.addChangeListener(i[e.id]),q(e))}),Object.keys(i).forEach(t=>{e.getLibraryById(t)||(W.broadcast("librarydeleted",d.getDeletedLibraryData(e,t)),f.libraryDeleted(t),delete i[t])})}const ae=new R,se=e=>{b.getLoadedCollections().forEach(t=>{t.isPublic||(e&&t.fontManager._clearCache(),W.broadcast("fontcachechanged",{isPublic:t.isPublic,userId:t.userId,cloudId:t.cloudId}))})};ae.addChangeListener(()=>se(!1));var ce=0;function le(){const e=(e,t)=>{var i="client_"+ce++,n=h.parseQueryString(t.url),r=n.version||0,l="true"===n.diagnostics;s.log(H,i,"Client connected: "+(l?"diagnostic":"version="+r));var u=W.newChannel(e,r);u.onClose(function(){s.log(H,i,"Client disconnected")}),u.setLogCallback(function(e){s.log(H,i,e)});var m=!1;if(n.token&&(m=n.token===a.getValue("SERVICE_TOKEN")||a.isWSSTokenValid(n.token)),n.diagnostics||C.reportEvent("clientConnected",{clientId:i,clientVersion:r,numClients:W.numChannels(),hasToken:void 0!==n.token,isRejected:!m}),l)u.shutdown();else{var v=d.getEnvironmentData(r);if(m&&u.send("environmentinfo",v),v.updateRequired)return s.log(H,i,"Incompatible version. Update required: "+v.updateRequired),void u.shutdown();if(!m)return s.log(H,i,"Client validation failed"),void u.shutdown();u.addListener("configure",function(e){e.CLIENT_DESCRIPTION&&s.log(H,"Configure: "+e.CLIENT_DESCRIPTION);var t=!1,i=!1;if(e.RENDITION_SIZES&&(t=p.mergeRenditionSizes(e.RENDITION_SIZES)),e.FULL_RENDITION_CONFIG&&(i=p.mergeFullRenditionConfig(e.FULL_RENDITION_CONFIG)),(t||i)&&(p.triggerRenditionPrefetch(),f.collectionsLoaded()),e.LOCAL_SETTINGS){p.mergeLocalSettings(e.LOCAL_SETTINGS)&&W.broadcast("environmentinfo",d.getEnvironmentData(),u)}}),u.addListener("sync",function(e){var t=X(e);(function(e){var t=e&&e.getPrimarySyncError();return!!t&&t.code===P.ACCESS_DENIED})(t)||(t&&ee(t),y.ping())}),u.addListener("configuresync",function(e){g.configureFileSyncing(e.enable)}),u.addCallListener("commit",function(e,t){var i=X(e);_.obtainLock(e.id,function(){function n(){W.getPendingWriteState(e.userId,e.cloudId,e.id,u)||Z(e,!0)}function o(n,o){_.releaseLock(e.id);var r=i.getLibraryById(e.id),a={};if(n)(a=r?d.getLibraryData(r):a).success=!1,t(a);else{const n=(n,s)=>{o||(!function(e,t,i){var n=e.getLibraryById(t);n?W.broadcast("librarychange",d.getLibraryData(n),i):W.broadcast("librarydeleted",d.getDeletedLibraryData(e,t),i)}(i,e.id,u),r?f.libraryChanged(r,!0):f.libraryDeleted(e.id)),a.success=!0,a.renditions=n?[]:s,function(i){u.clearPendingWriteState(e.userId,e.cloudId,e.id).forEach(e=>{W.getPendingWriteState(e.userId,e.cloudId,e.id)||Z(e,!0)}),t(i)}(a)},s=e.renditions||[];r?r._renditionCache.applyRequestSetCache(s).then(e=>n(null,e),n).then(()=>U.prefetchRenditions(r)):n(null,new Array(s.length).fill(null))}}var r=i.getLibraryById(e.id);if(r){var a=d.getLibraryData(r);V.areManifestsEqual(a.manifest,e.current)?(s.log(H,"Commit skipped: nothing changed"),n(),o(null,!0)):V.areManifestsEqual(a.manifest,e.base)?(s.log(H,"Commit proceeding: fast-forward"),n(),x.storageInterface.updateExistingLibrary(i,r,e.current,e.base,void 0,o)):(s.log(H,"Commit fail: base mismatch"),o(!0))}else s.log(H,"Commit proceeding: creating new library"),n(),x.storageInterface.createNewLibrary(i,e.id,e.current,o)})}),u.addCallListener("getrenditionpath",function(e,t){var i=z(e);i?i.getThumbnailPath(e.size,function(e,i){t(i)}):t()}),u.addCallListener("startcomponentwrite",function(e,t){Z(e,!1),u.setPendingWriteState(e.userId,e.cloudId,e.id),(e.dependencies||[]).forEach(t=>{Z(t,!1),u.setPendingWriteDependency(e.userId,e.cloudId,e.id,t.userId,t.cloudId,t.id)}),t()}),u.addCallListener("loadpubliclibrary",function(e,t){var i=X(e);i&&i.isPublic?i.loadLibrary(e.id,e.url,function(){t()}):t()}),u.addCallListener("unloadpubliclibrary",function(e,t){var i=X(e),n=i&&i.getLibraryById(e.id);i&&i.isPublic&&n?i.unloadLibrary(n,function(){t()}):t()}),u.addCallListener("createBookmark",function(e,t){var i=X(e);i&&!i.isPublic?i.createBookmark(e.id,e.url,function(e,i){t({err:e&&d.prepareErrorForSerialization(e),bookmark:i})}):t()}),u.addCallListener("removeBookmark",function(e,t){var i,n=X(e);if(n&&!n.isPublic&&(n.bookmarks.forEach(t=>{t.id===e.id&&(i=t)}),i))return void n.removeBookmark(i,t);t()}),u.addCallListener("downloadfile",function(e,t){var i=X(e);i?i._syncManager.links.download(e.url,e.headers,e.tempDir,void 0,function(e,i,n,o){t({err:e&&d.prepareErrorForSerialization(e),tempFilePath:i,etag:n,responseHeaders:o&&o.headers})}):t({err:new P(P.INVALID_PARAMETER,"Library collection not found")})}),u.addCallListener("downloadexternallink",function(e,t){var i=J(e);i?i.getContentPath(function(e,i){t({err:e&&d.prepareErrorForSerialization(e),path:i})}):t({err:new P(P.INVALID_PARAMETER,"Representation not found")})}),u.addCallListener("testexternallink",function(e,t){var i=J(e);i?i.testExternalLink(function(e,i){t({err:e&&d.prepareErrorForSerialization(e),success:i})}):t({err:new P(P.INVALID_PARAMETER,"Representation not found")})}),u.addListener("clearcachedexternallink",function(e){var t=J(e);t&&t.isExternalLink&&t.clearCachedExternalLink()}),u.addCallListener("fscall",function(e,t){try{e.args.push(function(){var e=Array.prototype.slice.call(arguments);t(e)}),o[e.method].apply(o,e.args)}catch(e){t([e&&d.prepareErrorForSerialization(e)])}}),u.addCallListener("fspipe",function(e,t){try{var i=o.createReadStream(e.readStream.path,e.readStream.options),n=o.createWriteStream(e.writeStream.path,e.writeStream.options),r=!1,a=function(e){return function(){r||(r=!0,t({event:e,args:Array.prototype.slice.call(arguments)}))}};["end","error"].forEach(e=>i.on(e,a(e))),n.on("error",a("error")),i.pipe(n)}catch(e){t({event:"error",args:[e&&d.prepareErrorForSerialization(e)]})}}),u.addCallListener("performElementAction",function(e,t){s.log(H,"Recieved Element Action "+JSON.stringify(e));var i=z(e,"elementId","libraryId");S.launch({appCode:e.appCode,minVersion:e.minVersion,element:i,action:e.action},function(e,i){t({err:e,data:i})})}),u.addCallListener("importlibrary",function(e,t){var i=X(e);i?i._doImportLibrary(e.path,function(e,n){re(i),t({err:e&&d.prepareErrorForSerialization(e),libraryId:n&&n.id})},e.operationId):t({err:new P(P.INVALID_PARAMETER,"Library collection not found")})}),u.addCallListener("exportlibrary",function(e,t){var i=K(e);i?i.collection._doExportLibrary(i,e.path,function(e){t({err:e&&d.prepareErrorForSerialization(e)})},e.operationId):t({err:new P(P.INVALID_PARAMETER,"Library not found")})}),u.addListener("canceloperation",function(e){var t=X(e);t&&t._operationIdMap[e.operationId]&&t._operationIdMap[e.operationId].cancel()}),u.addCallListener("getImageDimensions",function(e,t){B.getImageDimensions(e,function(e){t({data:e})})}),u.addCallListener("getfontdata",function(e,t){var i=X(e);i&&i.fontManager?i.fontManager.getFontData(e.fontId,function(e,i){t({err:e&&d.prepareErrorForSerialization(e),data:i})}):t()}),u.addCallListener("getaccesstoken",function(e,t){E.getClientAccessToken(e.userId,e.clientId,e.clientSecret,e.scopes,function(e,i){t({err:e&&d.prepareErrorForSerialization(e),data:i})})}),u.addCallListener("computesha",function(e,t){B.computeSHA(e.path).then(e=>t({err:null,data:e}),e=>t({err:d.prepareErrorForSerialization(e)}))}),u.addCallListener("isfontavailable",function(e,t){ae.isFontAvailable(e.fontName,e.matchFamily).then(e=>t({data:e}))});var A=b.getLoadedCollections();0===A.length?u.send("clearcollections"):A.forEach(e=>{u.send("collectionadded",d.getCollectionData(e)),u.send("syncstate",d.getSyncStateData(e)),e.isPublic||u.send("bookmarkschanged",c.getCollectionBookmarksData(e))})}};j.forEach(t=>t.on("connection",e)),Ie.initialize(),a.setValue("SERVICE_PORT",j[0]._server.address().port),a.setValue("SERVICE_TOKEN",x.uuid()),s.log(H,"Version: "+d.getCodeVersion(!0)+" (protocol version = "+d.getAPIVersion()+")"),s.log(H,"Environment: "+a.getEnvironment().LABEL),s.log(H,"Root: "+a.getValue("ROOT_DIR")),s.log(H,"Listening on port: "+a.getValue("SERVICE_PORT")),m.sendStartupMessage(),C.reportEvent("processStarted",{apiVersion:d.getAPIVersion(),environment:a.getEnvironment().LABEL,osType:r.type(),osPlatform:r.platform(),osArch:r.arch(),osRelease:r.release(),osTotalMem:r.totalmem(),osFreeMem:r.freemem()})}var de=function(){S.updateInstallationMap(),W.broadcast("environmentinfo",d.getEnvironmentData())};g.addListener("installApplication",de),g.addListener("uninstallApplication",de),g.addListener("updateApplication",function(){S.updateInstallationMap(!0),de()});const pe=new D;pe.addChangeListener(()=>W.broadcast("environmentinfo",d.getEnvironmentData()));var he={};function _e(e){var t=e.userId+"/"+e.cloudId;if(he[t]=he[t]||{lastBroadcast:0},!he[t].pendingBroadcast){var i=a.getValue("SYNC_STATE_BROADCAST_THROTTLE"),n=(new Date).valueOf();if(n-he[t].lastBroadcast<i)he[t].pendingBroadcast=setTimeout(function(){delete he[t].pendingBroadcast,_e(e)},i);else{he[t].lastBroadcast=n;var o=d.getSyncStateData(e);if(W.broadcast("syncstate",o),"error"===e.syncState){var r=e.getPrimarySyncError();C.reportError("SyncError",F.errorToString(r))}}}}function ue(e){var t=d.getOperationsData(e);W.broadcast("operationschanged",t)}function fe(e,t){s.log(H,"Load public collection: "+JSON.stringify(e)),b.loadPublicLibraryCollection(e,function(e,i){if(e)return s.log(H,"Error loading public libraries: "+e),void G(e);i.startPolling(),i.addSyncListener(function(){re(i),_e(i)}),i.addOperationChangeListener(function(){ue(i)}),i.addChangeListener(function(){re(i)}),re(i),f.collectionsLoaded(),t()})}function me(e){s.log(H,"Load library collection: "+JSON.stringify(e)),b.loadLibraryCollection(e,function(t,i){if(t)return s.log(H,"Error loading libraries: "+t),void G(t);i.addSyncListener(function(){re(i),_e(i)}),i.addOperationChangeListener(function(){ue(i)}),re(i),f.collectionsLoaded(),function(e,t){const i=a.getEnvironment().PUBLIC_HOSTS.map(t=>new Promise(i=>{const n={getAccessToken:E.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?(n.CLOUD_ID=w.CP_CLOUD_ID+"_"+t.host,n.REQUIRES_COMMUNITY_SESSION=!0):n.CLOUD_ID=t.host,fe(n,i)}));Promise.all(i).then(t)}(e,function(){c.validateBookmarks(),c.sendBookmarksChanged(W),i.addChangeListener(function(){c.validateBookmarks(),c.sendBookmarksChanged(W)}),p.fixRenditions(b.getLoadedCollections())})})}function Ee(e,t,i){var n=E.getUserId();s.log(H,"Loading collection for active cloud: "+JSON.stringify(t));var o={getAccessToken:E.getAccessToken,USER_ID:n,STORAGE_HOSTNAME:a.getValue("STORAGE_HOST")||a.getEnvironment().STORAGE_HOST,COLLABORATION_HOSTNAME:a.getValue("COLLAB_HOST")||a.getEnvironment().COLLAB_HOST,CC_IMAGE_HOSTNAME:a.getValue("CC_IMAGE_HOST")||a.getEnvironment().CC_IMAGE_HOST,CC_IMAGE_X_HOSTNAME:a.getValue("CC_IMAGE_X_HOST")||a.getEnvironment().CC_IMAGE_X_HOST,TYPEKIT_HOSTNAME:a.getValue("TYPEKIT_HOST")||a.getEnvironment().TYPEKIT_HOST,CC_LIBRARY_SERVICE_HOSTNAME:a.getValue("CC_LIBRARY_SERVICE_HOST")||a.getEnvironment().CC_LIBRARY_SERVICE_HOST};if(e)s.log(H,"Error parsing cloud data: "+e);else{if(a.setValue("CLOUD_DATA_"+n,{activeCloud:t,numClouds:i}),!t)return o.CLOUD_INFO={switchingEnabled:i>1},void me(o);var r=t.features&&t.features.libraries,c=t.features&&t.features.files&&t.features.files.sync&&t.features.files.sync.uri,l=r&&r.storage&&r.storage.uri,d=r&&r.service&&r.service.uri,p=r&&r.view&&r.view.uri;if(!l)return s.log(H,"Unexpected cloud data: expected features.libraries.storage.uri to be defined"),void C.reportError("UnexpectedCloudData","expected features.libraries.storage.uri to be defined");if(!d)return s.log(H,"Unexpected cloud data: expected features.libraries.service.uri to be defined"),void C.reportError("UnexpectedCloudData","expected features.libraries.service.uri to be defined");o.CLOUD_ID=t.id,o.STORAGE_HOSTNAME=h.stripProtocolPrefix(l),o.COLLABORATION_HOSTNAME=h.stripProtocolPrefix(d),o.CLOUD_INFO={name:t.name,parameters:t.parameters,switchingEnabled:i>1,viewURI:h.stripProtocolPrefix(p),syncURI:c,useJumpToken:!1},me(o)}}const ge=e=>{w.ANALYTICS_ENABLED!==e&&(w.ANALYTICS_ENABLED=e,C.setEnabled(e),W.broadcast("environmentinfo",d.getEnvironmentData()))};var ye=!1;function ve(e,t,i,n){if(!ye){var o=E.getUserId();o?(ye=!0,ge(!!a.getValue(`ANALYTICS_ENABLED_${o}`)),g.getAnalyticsState(),e?Ee(t,i,n):E.hasEntitlement("cce_private",function(e){if(s.log(H,"cc_private entitlement: "+e),!0===e)A.getActiveCloud(function(e,t,i){Ee(e,t,i),C.reportEvent("getActiveCloud",{error:String(e),cloudId:t&&t.id,numClouds:i,cce_private:!0})});else if(!1===e)Ee(null),A.getActiveCloud(function(e,t,i){C.reportEvent("getActiveCloud",{error:String(e),cloudId:t&&t.id,numClouds:i,cce_private:!1})});else{var t=a.getValue("CLOUD_DATA_"+o);Ee(null,t&&t.activeCloud,t&&t.numClouds),C.reportEvent("getActiveCloud",{error:"UnknownEntitlement: could not determine cce_private entitlement",cloudId:t&&t.activeCloud&&t.activeCloud.id,numClouds:t&&t.numClouds})}})):E.clearUserId()}}function Ae(){b.getLoadedCollections().forEach(e=>{b.unloadLibraryCollection(e)}),oe={},ye=!1,ge(!1),f.collectionsUnloaded()}function Ce(e,t,i){E.setProxyCredentials(e,t),I.setProxyCredentials(e,t),i&&E.hasEntitlement("cce_private",function(e){void 0===e?(E.clearUserId(),E.getUserId(),Ae(),ve()):b.getLoadedCollections().forEach(e=>{"error"===e.syncState&&ee(e)})})}var Ie=new T;function Se(){var e="CCLibrary/"+d.getCodeVersion()+" "+r.platform()+"/"+r.arch()+"/"+r.release(),t={log:s.log,analytics:C,getNodeTunnelOptions:I.getNodeTunnelOptionsForURL,renditionGenerator:O.generate},i={ROOT_DIR:a.getValue("ROOT_DIR"),STORAGE_API_KEY:a.getEnvironment().CLIENT_ID,DEVICE_ID:E.getDeviceId(),DEVICE_DESCRIPTION:d.getDeviceDescription(),APP_DESCRIPTION:"LIBS-"+d.getCodeVersion(!0),USER_AGENT_HEADER:e,SHARED_LOCAL_STORAGE:!1,LOCAL_SETTINGS:a.getValue("LOCAL_SETTINGS")||{},RENDITION_SIZES:a.getValue("RENDITION_SIZES")||{},FULL_RENDITION_CONFIG:a.getValue("FULL_RENDITION_CONFIG")||{},EXTERNAL_LINK_PREFETCH:a.getValue("EXTERNAL_LINK_PREFETCH")||{},LOCALE:I.getOSLocale()};s.log(H,`locale: ${i.LOCALE}`);var n,o=a.getValue("WHITELISTED_DOMAINS");o&&(i.WHITELISTED_DOMAINS=o),b.configure(t,i),!1===a.getValue("SYNCING_ENABLED")&&(s.log(H,"Syncing disabled"),b.disableSyncing()),S.updateInstallationMap(),x.storageInterface.onAcceptPushedBranch(function(e){var t=-1!==b.getLoadedCollections().indexOf(e.collection),i=e.collection.getLibraryById(e.id)===e;t&&i&&q(e)}),x.storageInterface.onDownloadRendition(function(e){W.broadcast("renditioncachechange",d.getElementRenditionCacheData(e))}),A.addListener("cloudChange",function(e,t,i){var n=t?t.id:w.DEFAULT_CLOUD_ID;b.getLoadedCollections().some(function(e){return e.cloudId===n})?s.log(H,"Active cloud the same as already loaded"):(s.log(H,"Active cloud changed"),Ae(),ve(!0,e,t,i),C.reportEvent("cloudChange",{cloudId:n,numClouds:i}))});var c=!1;y.addListener("libraryChange",function(e){n?c=!0:(te(e),n=setTimeout(function(){c&&te(),n=null,c=!1},a.getValue("CORE_SYNC_NOTIFICATION_DEBOUNCE")))}),y.addListener("bookmarkChange",function(){b.getLoadedCollections().forEach(e=>{e.isPublic||e.syncBookmarks()})}),y.addListener("fileSyncState",function(e,t){!function(e,t){if($!==e){if(clearTimeout(Q),"normal"!==e){var i=a.getValue("CORE_SYNC_ANALYTICS_WAIT");Q=setTimeout(function(){C.reportEvent("fileSyncState",{state:e,isNotification:!!t,reportingDelay:i})},i)}$=e,b.isSyncingEnabled()&&"turned_off"===$?(s.log(H,"Syncing disabled"),a.setValue("SYNCING_ENABLED",!1),b.disableSyncing(),W.broadcast("environmentinfo",d.getEnvironmentData())):b.isSyncingEnabled()||"turned_off"===$||(s.log(H,"Syncing enabled"),a.setValue("SYNCING_ENABLED",!0),b.enableSyncing(),W.broadcast("environmentinfo",d.getEnvironmentData()),te())}}(e,t)}),g.addListener("signOut",function(){Ae(),E.clearUserId()}),g.addListener("signIn",function(){ve()}),g.addListener("proxySettingsChanged",function(e,t){Ce(e,t,!0)});function l(e,t,i,n){L.sendToast({title:k.translate("LIBS_OPEN_IN_TITLE"),message:k.translate(e),key:t,data:i,overridable:n})}function h(e,t){var i={"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&&(i["event.error_desc"]=t.error),t.element&&(i["event.cloud_id"]=t.element.library.collection.cloudId,i["content.id"]=u.getElementStockId(t.element),i["content.status"]=u.getElementStockLicense(t.element),i["content.type"]=t.element.getPrimaryRepresentation().type),C.reportEvent("Library-Process-Open-In",i)}function _(e,t){s.log(H,"Open Stock -  launch product "+e.elementRef),S.launch({appCode:e.appCode,minVersion:e.appVersion||"0",element:t,action:"openStock"},function(i,n){if(i)return s.log(H,"Open Stock - Error opening product "+i),l("LIBS_OPEN_IN_PRODUCT_LAUNCH_FAILED_"+e.appCode),void h("error",{launchInfo:e,error:"Launch product failed",productInfo:n,element:t});s.log(H,"Open Stock - Open request success"),h("useElement",{launchInfo:e,productInfo:n,element:t})})}g.addListener("analyticsStateChanged",e=>{const t=E.getUserId();t&&(a.setValue(`ANALYTICS_ENABLED_${t}`,e),ge(e))}),g.getProxyCredentials(function(e,t){Ce(e,t),ve(),setTimeout(le,100)}),L.addListener("clickNotification",function(e){"LAUNCH_CC"===e&&S.launch({appCode:"ADCS",waitForCompletion:!1},function(e){e?s.log(H,"Open Stock - Launch CC failed "+e):s.log(H,"Open Stock - Successfully launched CC from user click")})}),v.addListener("stock.open.request",function(e){if(s.log(H,"Open Stock - Recieved open request via ANS "+JSON.stringify(e)),e.state&&"new"!==e.state.toLowerCase())s.log(H,"Open Stock - Message state not new. Returning");else{v.setState({id:e.id,state:"received"});var t=e.payload;if(h("response",{launchInfo:t}),!t.protocolVersion||!t.elementRef||!t.appCode)return s.log(H,"Open Stock - ANS request corrupt "+JSON.stringify(e)),l("LIBS_OPEN_IN_DOWNLOAD_ERROR"),void h("error",{launchInfo:t,error:"ANS request corrupt"});if("1"!==t.protocolVersion.split(".")[0])return s.log(H,"Open Stock - Unsupported protocol version from ans message "+t.protocolVersion),l("LIBS_OPEN_IN_UNSUPPORTED_PROTOCOL","LAUNCH_CC"),void h("error",{launchInfo:t,error:"Unsupported protocol version from ans message"});if(!b.isSyncingEnabled())return s.log(H,"Open Stock - Sync Disabled."),l("LIBS_OPEN_IN_SYNC_DISABLED"),void h("error",{launchInfo:t,error:"Sync Disabled"});var i=S.appStatus({appCode:t.appCode,minVersion:t.appVersion||"0"});if("APP_NOT_INSTALLED"===i)return l("LIBS_OPEN_IN_NOT_INSTALLED_"+t.appCode,"LAUNCH_CC"),void h("notify",{launchInfo:t});if("NO_COMPATIBLE_VERSION"===i)return l("LIBS_OPEN_IN_NO_COMPATIBLE_VERSION_"+t.appCode,"LAUNCH_CC"),void h("notify",{launchInfo:t});l("LIBS_OPEN_IN_START_DOWNLOAD",null,null,!0),p.findElement(t.elementRef,function(e,i){if(e){s.log(H,"Open Stock - Error from find element "+e);var n="COLLECTION_NOT_FOUND"===e?"LIBS_OPEN_IN_COLLECTION_NOT_FOUND":"LIBS_OPEN_IN_DOWNLOAD_ERROR";return l(n),void h("error",{launchInfo:t,error:n})}s.log(H,"Open Stock -  downloading element "+t.elementRef),i.library.sync(function(e){if(e)return s.log(H,"Open Stock - Error downloading element "+e),l("LIBS_OPEN_IN_DOWNLOAD_ERROR"),void h("error",{launchInfo:t,error:"Download Failed"});U.prefetchRenditionsForElement(i,function(e){if(e)return s.log(H,"Open Stock - Error downloading element "+e),l("LIBS_OPEN_IN_DOWNLOAD_ERROR"),void h("error",{launchInfo:t,error:"Download Failed"});f.libraryChanged(i.library,!1),f.isSyncing()?(s.log(H,"Open Stock -  waiting for product bridge to update "+t.elementRef),f.addListener("syncEnd",function e(){f.isSyncing()||(f.removeListener("syncEnd",e),_(t,i))})):_(t,i)})})})}}),v.addListener("sharing.collaboration.updaterole",function(){b.getLoadedCollections().forEach(e=>{e.isPublic||ee(e,!0)})}),v.addListener("com.adobe.system.inform.typekit.generic.entitlementschanged",()=>se(!0)),I.addListener("change",function(e){e&&g.getProxyCredentials(function(e,t){Ce(e,t,!0)})}),I.addListener("error",function(e){C.reportError("ProxyResolverError",e)})}O.test(e=>{s.log("LOCAL_THUMBNAIL_GENERATOR",e?"Test Successful":"Test Failure")}),l.obtainProcessLock("lockfile",function(e){e||Y?I.getRootCA(function(e,t){if(t&&t.length>0){var n=i(27).globalAgent.options;n.ca=(n.ca||[]).concat(t)}if(Y)return console.log("Testing OK"),void process.exit(0);Se()}):process.exit(1)}),e.exports={shutdown:function(){j.forEach(e=>e.close()),g.removeAllListeners(),y.removeAllListeners(),v.removeAllListeners(),A.removeAllListeners(),I.removeAllListeners(),pe.removeAllListeners(),ae.removeAllListeners(),Ie.shutdown(),b.removeLoadedCollectionsListener(ne),x.storageInterface.removeOnAcceptPushedBranchListeners(),Ae()},loadPublicCollection:fe,unloadCollections:Ae,handleUncaughtException:G,waitForWSSInitialization:function(){return j[1].waitForInitialization()}}},function(e,t,i){var n=i(4),o=i(8);function r(e,t,i){e?this._setData(e):this._data={},this._readOnly=t,this._isRoot=i}r.ROOT_PATH="/",Object.defineProperties(r.prototype,{id:{get(){return this._data.id},set(e){if(this._readOnly)throw new n(n.READ_ONLY,"This object is read-only.");if(this._owner)throw new n(n.READ_ONLY,"Cannot change the id of a node that is part of a branch or element.");if("string"!=typeof e||""===e)throw new n(n.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 n(n.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new n(n.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 n(n.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new n(n.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 n(n.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new n(n.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 n(n.READ_ONLY,"This object is read-only.");if(this._isRoot)throw new n(n.READ_ONLY,"Cannot change the path of the root node.");if(e&&!o.isValidPath(e))throw new n(n.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 n(n.READ_ONLY,"parentPath is read-only.")}},absolutePath:{get(){var e=this.path;return this._isRoot?e:e&&this._owner?o.appendPathElements(this._parentPath,e):void 0},set(){throw new n(n.READ_ONLY,"absolutePath is read-only.")}},isRoot:{get(){return this._isRoot},set(){throw new n(n.READ_ONLY,"isRoot is read-only.")}}}),r.prototype.getLink=function(e){if("string"!=typeof e)throw new n(n.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 n(n.READ_ONLY,"This object is read-only.");if("object"!=typeof e)throw new n(n.INVALID_PARAMS,'Param "link" must be an object.');if("string"!=typeof t)throw new n(n.INVALID_PARAMS,'Param "relationship" must be a string');var i=this._data._links;i||(i=this._data._links={}),i[t]=e,this._setDirty()},r.prototype.removeLink=function(e){if(this._readOnly)throw new n(n.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new n(n.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=[],i=Object.keys(this._data),n=i.length;for(e=0;e<n;e++){var o=i[e];(this._isRoot?a[o]:s[o])||t.push(o)}return t},r.prototype.getValue=function(e){if("string"!=typeof e)throw new n(n.INVALID_PARAMS,'Param "key" must be a string');if("children"===e||"components"===e)throw new n(n.INVALID_PARAMS,"Illegal key");return this._data[e]},r.prototype.setValue=function(e,t){if(this._readOnly)throw new n(n.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new n(n.INVALID_PARAMS,'Param "key" must be a string');if("children"===e||"components"===e)throw new n(n.INVALID_PARAMS,"Illegal key");this._data[e]=t,this._setDirty()},r.prototype.removeValue=function(e){if(this._readOnly)throw new n(n.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new n(n.INVALID_PARAMS,'Param "key" must be a string');if("children"===e||"components"===e)throw new n(n.INVALID_PARAMS,"Illegal key");delete this._data[e],this._setDirty()},r.prototype.copy=function(){var e=null,t=this._data.children,i=this._data.components;try{t&&delete this._data.children,i&&delete this._data.components,e=new r(JSON.parse(JSON.stringify(this._data)))}finally{t&&(this._data.children=t),i&&(this._data.components=i)}return e},r.prototype.isEqualTo=function(e,t,i){return this._isEqual(this._data,e._data,o.merge({children:!0,components:!0},t),i)},r.prototype._isEqual=function(e,t,i,n){var r,a,s,c,l,d,p;if(!o.objectsEqual(e,t,i))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],d=null,p=0;p<c;p++)if(l.id===s[p].id){d=s[p];break}if(!d)return!1;if(!o.objectsEqual(l,d,n))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],i,n))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 n(n.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,i){var n=i(48),o=i(4),r=i(8);function a(e,t,i){(this._owner=t,e)?e=this._setData(e,i):(e={id:r.generateUuid()},this._core=new n(e,this,i),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 o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a string or undefined.");t.rootNode.name=e}},type:{get(){return this._core.rootNode.type},set(e){var t=this._core;if(t._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e||""===e)throw new o(o.INVALID_PARAMS,"Expecting a non-empty string.");t.rootNode.type=e}},compositeHref:{get(){return this._owner.compositeHref},set(){throw new o(o.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,i,n){return this._core.addChild(e,t,i,n)},a.prototype.removeChild=function(e){return this._core.removeChild(e)},a.prototype.moveChild=function(e,t,i){return this._core.moveChild(e,t,i)},a.prototype.copyChild=function(e,t,i,n,o,r){return this._core.copyChild(e,t,i,n,o,r)},a.prototype.allComponents=function(){return this._core.allComponents()},a.prototype.getComponentWithId=function(e){return this._core.getComponentWithId(e)},a.prototype.getComponentWithAbsolutePath=function(e){return this._core.getComponentWithAbsolutePath(e)},a.prototype.getComponentsOf=function(e){return this._core.getComponentsOf(e)},a.prototype.addComponent=function(e,t,i,n,o,r,a,s,c,l){return this._core.addComponent(e,t,i,n,o,r,a,s,c,l)},a.prototype.addComponentWithUploadResults=function(e,t,i,n,o){return this._core.addComponentWithUploadResults(e,t,i,n,o)},a.prototype.updateComponent=function(e,t,i,n){return this._core.updateComponent(e,t,i,n)},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,i,n,o){return this._core.copyComponent(e,t,i,n,o)},a.prototype.assetOfComponent=function(e,t){return this._core.assetOfComponent(e,t)},a.prototype.parse=function(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "data" must be a string');var t=null;try{t=JSON.parse(e)}catch(e){throw new o(o.INVALID_JSON,"Manifest could not be parsed. Underlying error: "+e.message)}return this._setData(t,this._core._readOnly)},a.prototype.copy=function(){return new a(JSON.parse(JSON.stringify(this._data)),this._owner)},a.prototype._updateLocalDataFromBranch=function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");if(!e._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage for source.");if(this._localStorage.compositePath!==e._localStorage.compositePath)throw new o(o.INVALID_PARAMS,"Branches must have same storage path.");this._core._localStorage.copyLocalStorageData(e,e._core._local(),this,this._core._local()),this._core._copySourceHrefsFrom(e._core)},a.prototype._verify=function(e){return"string"!=typeof e.id?new o(o.INVALID_DATA,"Element is missing an id of type string"):"string"!=typeof e.name?new o(o.INVALID_DATA,"Element is missing a name of type string"):"string"!=typeof e.type?new o(o.INVALID_DATA,"Element is missing a type of type string"):null},a.prototype._setData=function(e,t){var i=this._verify(e);if(null===i)return this._core=new n(e,this,t),this._data=e,this;throw i},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,i){return this._core._verifyIntegrity(e,t,i)},e.exports=a},function(e,t,i){var n=i(4),o=i(8),r=i(13);function a(e,t){if("string"!=typeof e||""===e)throw new n(n.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 n(n.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 i=this;r.writeFileAtomically(this.currentManifestPath(),e.localData,"utf8",function(e){e?(e.code!==n.OUT_OF_SPACE&&(e=new n(n.INVALID_STATE,"Could not write current manifest.",e)),t(e)):r.move(i.pulledManifestPath(),i.currentBaseManifestPath(),!1,function(e){e?t(new n(n.INVALID_STATE,"Could not move pull manifest.",e)):t()})})},a.prototype.acceptPushedBranch=function(e,t){var i=this;r.writeFileAtomically(this.currentManifestPath(),e.localData,"utf8",function(e){e?(e.code!==n.OUT_OF_SPACE&&(e=new n(n.INVALID_STATE,"Could not write current manifest.",e)),t(new n(n.INVALID_STATE,"Could not write current manifest.",e))):r.move(i.pushedManifestPath(),i.currentBaseManifestPath(),!1,function(e){e?t(new n(n.INVALID_STATE,"Could not move push manifest.",e)):i._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(i){i?e(i):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 n(n.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 n(n.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 i=t["copyOnWrite#storageIds"],n=i?i[e.id]:null;return n&&s.test(n)&&(n=null),n},a.prototype.componentAssetPath=function(e,t){var i=this.componentAssetName(e,t);return i?this._componentPathFromName(i):null},a.prototype.ingestComponentAsset=function(e,t,i,o,a){var s=this,c=this._newFileNameForComponent(e),l=this._componentPathFromName(c);this._inflightComponents.push(c);var d=function(t){if(!t)try{s._setComponentName(e,o,c)}catch(e){t=e}var i=s._inflightComponents.indexOf(c);i<0&&!t&&(t=new n(n.INVALID_STATE,"Could not find inflight component.")),s._inflightComponents.splice(i,1),a(t)};i?r.copyFile(t,l,d):r.move(t,l,!0,d)},a.prototype.removeComponentAsset=function(e,t){var i=t["copyOnWrite#storageIds"];i&&delete i[e.id]},a.prototype.componentIds=function(e){var t=e["copyOnWrite#storageIds"];return t?Object.keys(t):[]},a.prototype.copyLocalStorageData=function(e,t,i,n){var o,r=i.allComponents(),a=r.length,s=t["copyOnWrite#storageIds"];if(s){var c=n["copyOnWrite#storageIds"];for(c||(c=n["copyOnWrite#storageIds"]={}),o=0;o<a;o++){var l=r[o],d=l.id,p=e.getComponentWithId(d);if(p&&p.etag===l.etag){var h=s[d];h&&(c[d]=h)}}}},a.prototype.removeUnusedLocalFiles=function(e,t){var i,o,a,s,c,l=this,d=function(e){l._deleteComponentAsset(e,function(e){e&&!i&&(i=e),0===--c&&t(i)})},p=function(){try{var e,i=s.length,n=[];for(e=0;e<i;e++){var r=s[e].name,p=s[e].info;!o[r]&&p.mtime.getTime()<a&&l._inflightComponents.indexOf(r)<0&&n.push(r)}if((c=i=n.length)>0)for(e=0;e<i;e++)d(n[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(i)t(i);else{if(!e)try{if(r<1||!l)throw new n(n.INVALID_STATE,r<1?"No manifest found.":"Invalid time stamp");o=c,a=l}catch(t){e=t}e&&(i=e),s&&(i?t(i):p())}}),r.directoryListing(this._compositePath+"/components",function(e,n){if(i)t(i);else{if(!e)try{s=n}catch(t){e=t}e&&(i=e),o&&(i?t(i):p())}})},a.prototype.tempPathForComponent=function(){return this._compositePath+"/tmp/"+o.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,i,n){var o=t["copyOnWrite#storageIds"];if(o){var r=n["copyOnWrite#storageIds"];r||(r=n["copyOnWrite#storageIds"]={});var a=o[e];return a&&(r[i]=a),a}},a.prototype._componentPathFromName=function(e){return this._compositePath+"/components/"+e},a.prototype._newFileNameForComponent=function(e){var t=o.generateUuid();if(this._preserveFileExtensions){var i=e.path?o.filePathComponents(e.path).extension:null;i&&(t=t+"."+i)}return t},a.prototype._setComponentName=function(e,t,i){var n=t["copyOnWrite#storageIds"];n||(n=t["copyOnWrite#storageIds"]={}),n[e.id]=i},a.prototype._gatherComponentAssetNames=function(e,t,i){try{var n,a,s={},c=t||o.timeStamp(!0),l=e.length,d=l,p=0,h=function(e){if(e){e=e["copyOnWrite#storageIds"];var t,i=Object.keys(e);for(t=0;t<i.length;t++){var n=e[i[t]];s[n]=!0}}},_=function(e){r.exists(e,function(t){t?(p++,r.info(e,function(t,n){if(!t)try{var o=n.mtime.getTime();o<c&&(c=o),r.readFile(e,"utf8",function(e,t){if(d--,!e)try{t=JSON.parse(t),h(t.local)}catch(t){e=t}e&&!a&&(a=e),0===d&&i(a,p,s,c)})}catch(e){t=e}t&&(d--,a||(a=t),0===d&&i(a))})):0===--d&&i(a,p,s,c)})};for(n=0;n<l;n++)_(e[n]);for(l=this._inMemoryBranchesAndElements.length,n=0;n<l;n++)h(this._inMemoryBranchesAndElements[n]._local())}catch(e){i(e)}},a.prototype._deleteComponentAsset=function(e,t){r.deleteFile(this._componentPathFromName(e),t)},e.exports=a},function(e,t,i){var n=i(43),o=i(4),r=o.networkError,a=o.unexpectedResponse,s=i(26),c=i(8),l=i(13),d=c.appendPathElements,p="If-Match";function h(e,t){if(n.call(this,e,t),!this._endPoint)throw new o(o.INVALID_PARAMS,"Could not determine endpoint from: "+t);this.authenticationWhitelist=["adobe.com","adobe.io","fotolia.net"]}h.prototype=Object.create(n.prototype),h.prototype.name="AdobeStorageSession",h.FileContent=n.FileContent,h.StreamProvider=n.StreamProvider,h.prototype.getCollection=function(e,t,i){if(!(e=this._resolveUrl(e)))return i(new o(o.WRONG_ENDPOINT,"Wrong endpoint: "+e));var n;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,d){if(l)return i(r("Error retrieving a collection",l,d));if(200===d.statusCode){var p,h=d.responseText||d.response;try{p=JSON.parse(h)}catch(e){return(l=new o(o.INVALID_DATA,"Invalid JSON returned by server",e)).response=d,i(l)}n?n.children=n.children.concat(p.children):n=p;var _=d.headers["x-children-next-start"];if(_){var u=e+"&start="+_;c._service.invoke("GET",u,s,void 0,{responseType:"text"},t)}else i(void 0,n,d.headers.etag,d.headers)}else 304===d.statusCode?i(void 0,null,d.headers.etag,d.headers):i(a("Unexpected status code while getting a collection",void 0,d))})},h.prototype.pagedGetCollection=function(e,t,i,n,s,c,l,d){if(!(e=this._resolveUrl(e)))return d(new o(o.WRONG_ENDPOINT,"Wrong endpoint: "+e));e+=function(e,t,i,n){var o=[],r="";return t&&o.push("order="+t),e&&o.push("orderBy="+e),i&&o.push("start="+i),n&&o.push("limit="+n),o.length>0&&(r="?"+o.join("&")),r}(i,n,s,c);var p={};return t&&(p["If-None-Match"]=t),this._service.invoke("GET",e,p,void 0,{responseType:"text"},function(e,t){if(e)return d(r("Error retrieving a collection",e,t));if(200===t.statusCode){var i,n=t.responseText||t.response;try{i=JSON.parse(n)}catch(i){return(e=new o(o.INVALID_DATA,"Invalid JSON returned by server",i)).response=t,d(e)}l?l.children=l.children.concat(i.children):l=i,d(void 0,l,t.headers.etag,t.headers)}else 304===t.statusCode?d(void 0,null,t.headers.etag,t.headers):d(a("Unexpected status code while getting a collection",void 0,t))})},h.prototype.getComponent=function(e,t,i){var n=this.getComponentHref(e,e.version);return this.getAsset(n,void 0,t,i)},h.prototype.getRenditionOfComponent=function(e,t,i,n,o){var r=this.getComponentRenditionHref(e,e.version,i);return this.getAsset(r,{accept:t},n,o)},h.prototype.getSyncGroups=function(e,t){var i=d(this._server,"assets");return this.getCollection(i,e,t)},h.prototype.getSyncGroup=function(e,t,i){var n=d(this._server,"assets",e);return this.getCollection(n,t,i)},h.prototype.getCompositeManifest=function(e,t,i){var n=e.href;return n&&(n=this._resolveUrl(n)),n?(n=d(n,"manifest"),this.getAssetAsType(n,"text",t,i)):i(new o(o.WRONG_ENDPOINT,"Wrong endpoint: "+n))},h.prototype.headRequest=function(e,t){return this._service.invoke("HEAD",e,{},void 0,void 0,function(e,i){if(e)return t(e);t(e,i)})},h.prototype._checkForComponentAlreadyUploaded=function(e,t,i){if(!(l.canUseFileSystem&&e&&t&&t.filename))return i();l.getMD5Hash(t.filename,(t,n)=>{if(t)return i();this.headRequest(e,(e,t)=>{if(e)return i();const o=t&&t.statusCode,r=t&&t.headers["content-md5"];200!==o||r!==n?i():i(t,r)})})},h.prototype.remixComposite=function(e,t,i,n,o,r){var a={compositeId:n};o&&(a.creatorTool=o);var s={href:e};return t&&(s.authorization=t),this._invokeOperation("remix",s,{href:i},a,r)},h.prototype.createCompositeDirectory=function(e,t,i){var n=this,s=this._resolveUrl(e.href);if(!s)return i(new o(o.WRONG_ENDPOINT,"Wrong endpoint: "+s));function l(e,t,i){var a={"Content-Type":"application/vnd.adobe.directory+json","X-Update":"content"};t&&(a[p]="*"),n._service.invoke("PUT",s,a,void 0,void 0,function(e,t){return e?i(r("Error Creating composite directory",e,t)):409===t.statusCode?((e=new o(o.ALREADY_EXISTS,e)).response=t,i(e)):void i(void 0,t)})}l(0,t,function(e,o){if(e)return i(e);var d=o.statusCode;if(200===d||201===d)i(void 0,o);else if(404===d){var p=c.parentDirectory(s);n._service.invoke("PUT",p,{},void 0,void 0,function(e,n){if(e)return i(r("Error creating composite directory",e,n));var o=n.statusCode;200===o||201===o||409===o?l(0,t,function(e,t){if(e)return i(e);var n=t.statusCode;200===n||201===n?i(void 0,t):i(r("Error creating composite directory",e,t))}):i(a("Unexpected response creating composite directory",e,n))})}else i(a("Unexpected response creating composite directory",e,o))})},h.prototype.deleteCompositeDirectory=function(e,t){var i=this,n=this._resolveUrl(e.href);if(!n)return t(new o(o.WRONG_ENDPOINT,"Wrong endpoint: "+n));n+="?recursive=true&invocation_mode=sync,async";var s=this._service.invoke("DELETE",n,{"If-Match":"*"},void 0,void 0,function(e,n){if(e)return t(r("Error deleting composite directory",e,n));var o=n.statusCode;return 200===o||204===o||404===o?t(void 0,n):202===o?i._handle202Response(n,s,i.SYNC_ASYNC_DEFAULT_DELAY,t):void t(a("Unexpected response deleting composite directory",e,n))})},h.prototype.archiveCompositeDirectory=function(e,t){var i=this,n=this._makeRelativeUrl(e.href);if(!n)return t(new o(o.WRONG_ENDPOINT,"Wrong endpoint: "+e.href));var s={"Content-Type":"application/vnd.adobe.directory+json",Link:"<"+n+">;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,n){if(e)return t(r("Error archiving composite directory",e,n));var o=n.statusCode;return 200===o||204===o||404===o?t(void 0,n):202===o?i._handle202Response(n,l,i.SYNC_ASYNC_DEFAULT_DELAY,t):void t(a("Unexpected response archiving composite directory",e,n))})},h.prototype.leaveSharedComposite=function(e,t){if(e.collaborationType!==s.COLLABORATION.SHARED_WITH_USER)throw new o(o.INVALID_STATE,"Composite's collaboration type must be sharedWithUser.");return this.deleteCompositeDirectory(e,t)},h.prototype.uploadComponent=function(e,t,i,n,r,a){if(!e._owner||!e._owner.compositeHref)throw new o(o.INVALID_STATE,"Component must be part of a branch of a bound composite.");return this.uploadAssetForComponentId(e.id,e.type,e._owner.compositeHref,t,i,n,r,a)},h.prototype.uploadAssetForComponentId=function(e,t,i,n,s,c,l,d){const h=this._constructComponentHref(i,e);let _=h;s&&(_+="?intermediates=false");var u={};t&&(u["Content-Type"]=t);const f=(e,t)=>{e?delete u[p]:u[p]="*";var i=this._service.invoke("PUT",_,u,l,void 0,function(e,i){if(e)return t(r("Error uploading component",e,i));var n=i.statusCode;if(200===n||201===n||204===n){var s;try{s=JSON.parse(i.responseText||i.response)}catch(n){return(e=new o(o.INVALID_DATA,"Invalid JSON returned by server",n)).response=i,t(e,i,s)}t(void 0,i,s)}else 507===n?((e=new o(o.EXCEEDS_QUOTA,"Exceeds quota",e)).response=i,t(e)):((e=a("Unexpected response uploading component",e)).response=i,t(e))});return i.token=c,i};return f(n,(e,t,i)=>{if(e){if(!(t=e.response))return d(e);var o=t.statusCode;n||404!==o?!n||409!==o&&412!==o?d(e):this._checkForComponentAlreadyUploaded(h,l,(e,t)=>{e?d(null,e,{md5:t}):f(!1,d)}):f(!0,d)}else d(void 0,t,i)})},h.prototype.copyAssetToComponentId=function(e,t,i,n,s,c,l,d){var h=this._makeRelativeUrl(l);if(!h)return d(new o(o.WRONG_ENDPOINT,"Cannot copy asset: "+l));var _=this,u=this._constructComponentHref(i,e);u+="?invocation_mode=sync,async",s&&(u+="&intermediates=false");var f={};function m(e,t,i){e?delete f[p]:f[p]="*";var n=_._service.invoke("PUT",u,f,void 0,{responseType:"text"},function(e,o){if(e)return i(r("Error uploading component",e,o));var s=o.statusCode;200===s||201===s||204===s?i(void 0,o,t):202===s?_._handle202Response(o,n,_.SYNC_ASYNC_DEFAULT_DELAY,function(e,n){i(e,n,t)}):i(a("Unexpected response copying a component asset",e,o),o,t)});return n.token=c,n}t&&(f["Content-Type"]=t),f.Link="<"+h+">;rel=source";var E=function(e,t,i){var r;if(e){if(!(t=e.response))return d(e);var a=t.statusCode;i||404!==a&&409!==a&&412!==a?507===a?((e=new o(o.EXCEEDS_QUOTA,"Exceeds quota",e)).response=t,d(e)):d(e):m(!n,!0,E)}else{try{r=JSON.parse(t.responseText||t.response)}catch(i){return(e=new o(o.INVALID_DATA,"Invalid JSON returned by server",i)).response=t,d(e)}d(void 0,t,r)}};return m(n,!0,E)},h.prototype.updateManifest=function(e,t,i,n){var s=this.getBranchManifestHref(e),c={"Content-Type":"application/vnd.adobe.dcx-manifest+json"},l=e.manifestEtag;return i?c["If-Match"]="*":l&&(c["If-Match"]=l),this._service.invoke("PUT",s,c,t,void 0,function(e,t){if(e)return n(r("Error updating manifest",e,t));var s=t.statusCode;!t.headers.etag||200!==s&&201!==s&&204!==s?412===s||l&&!i&&409===s?((e=new o(o.UPDATE_CONFLICT,"Manifest has been changed")).response=t,n(e)):n(a("Unexpected response updating manifest",e,t)):n(void 0,t)})},h.prototype.getHrefForComposite=function(e,t){if(!e.type)throw new o(o.INVALID_STATE,"Composite needs a type");if(!e.id)throw new o(o.INVALID_STATE,"Composite needs an id");return e.href?e.href:this._resolveUrl(d("assets",t,e.id))},h.prototype.getHrefForCompositeWithId=function(e,t){return this._resolveUrl(d("assets",t,e))},h.prototype.getCompositeManifestHref=function(e){var t=this._resolveUrl(e.href);if(!t)throw new o(o.WRONG_ENDPOINT,"Wrong endpoint: "+t);return d(t,"manifest")},h.prototype.getBranchManifestHref=function(e){var t=this._resolveUrl(e.compositeHref);if(!t)throw new o(o.WRONG_ENDPOINT,"Wrong endpoint: "+t);return d(t,"manifest")},h.prototype.getComponentHref=function(e,t){var i,n=e._owner;if(!n||!n.compositeHref)throw new o(o.INVALID_STATE,"Component must be part of a branch of a bound composite.");return n._core&&(i=n._core._getSourceHrefOfComponent(e)),i||this._constructComponentHref(n.compositeHref,e.id,t)},h.prototype.getComponentRenditionHref=function(e,t,i){var n=e._owner;if(!n||!n.compositeHref)throw new o(o.INVALID_STATE,"Component must be part of a branch of a bound composite.");if(n._core&&n._core._getSourceHrefOfComponent(e))throw new o(o.INVALID_STATE,"Getting a rendition of a source href not implemented.");return this._constructComponentRenditionHref(n.compositeHref,e,t,i)},h.prototype._constructComponentHref=function(e,t,i){var n=d(this._resolveUrl(e),t);return n&&void 0!==i&&(n+=";version="+i),n},h.prototype._invokeOperation=function(e,t,i,n,s){var l=this,d=this._resolveUrl("/ops");d+="?invocation_mode=sync,async";var p={op:e,id:c.generateUuid(),target:i,source:t};n&&(p.value=n),c.log("[invoke operation]: "+JSON.stringify(p,void 0,2));var h=function(e,t){var i;if(e)return(t=e.response)?void(507===t.statusCode?((e=new o(o.EXCEEDS_QUOTA,"Exceeds quota",e)).response=t,s(e)):s(e)):s(e);try{i=JSON.parse(t.responseText||t.response)}catch(i){return(e=new o(o.INVALID_DATA,"Invalid JSON returned by server",i)).response=t,s(e)}if(i.error)return(e=new o(o.UNEXPECTED_RESPONSE,"Error in operation result: "+JSON.stringify(i.error,void 0,2))).response=t,s(e);s(void 0,t,i)},_=l._service.invoke("POST",d,{"Content-Type":"application/vnd.adobe.asset-operation+json"},JSON.stringify(p),{responseType:"text"},function(t,i){if(t)return h(r("Error invoking operation "+e,t,i));var n=i.statusCode;200===n||201===n||204===n?h(void 0,i):202===n?l._handle202Response(i,_,l.SYNC_ASYNC_DEFAULT_DELAY,function(e,t){h(e,t)}):h(a("Unexpected response for operation "+e,t,i),i)});return _},h.prototype._constructComponentRenditionHref=function(e,t,i,n){var o=d(this._constructComponentHref(e,t.id),":rendition");return o+=";size="+(n||"full"),void 0!==i&&(o+=";version="+i),o},e.exports=h},function(e,t,i){var n=i(43),o=i(4),r=i(8),a=r.appendPathElements;function s(e,t){if(n.call(this,e,t),!this._endPoint)throw new o(o.INVALID_PARAMS,"Could not determine endpoint from: "+t);this.authenticationWhitelist=["adobe.com","adobe.io","fotolia.net"]}s.prototype=Object.create(n.prototype),s.prototype.name="AdobeCommunitySession",s.FileContent=n.FileContent,s.StreamProvider=n.StreamProvider,s.prototype.getCompositeManifestHref=function(e){var t=this._resolveUrl(e.href);if(!t)throw new o(o.WRONG_ENDPOINT,"Wrong endpoint: "+t);return a(t,"manifest")},s.prototype.getComponent=function(e,t,i){var n=this.getComponentHref(e,e.version);return this.getAsset(n,void 0,t,i)},s.prototype.getRenditionOfComponent=function(e,t,i,n,o,r){var a=this.getComponentRenditionHref(e,e.version,t,i,n);return this.getAsset(a,{accept:t},o,r)},s.prototype.getCompositeManifest=function(e,t,i){var n=e.href;return n&&(n=this._resolveUrl(n)),n?(n=a(n,"manifest"),this.getAssetAsType(n,"text",t,i)):i(new o(o.WRONG_ENDPOINT,"Wrong endpoint: "+n))},s.prototype.headRequest=function(e,t){return this._service.invoke("HEAD",e,{},void 0,void 0,function(e,i){if(e)return t(e);t(e,i)})},s.prototype.getComponentHref=function(e,t){var i,n=e._owner;if(!n||!n.compositeHref)throw new o(o.INVALID_STATE,"Component must be part of a branch of a bound composite.");return n._core&&(i=n._core._getSourceHrefOfComponent(e)),i||this._constructComponentHref(n.compositeHref,e,t)},s.prototype.getComponentRenditionHref=function(e,t,i,n,r){var a=e._owner;if(!a||!a.compositeHref)throw new o(o.INVALID_STATE,"Component must be part of a branch of a bound composite.");if(a._core&&a._core._getSourceHrefOfComponent(e))throw new o(o.INVALID_STATE,"Getting a rendition of a source href not implemented.");return this._constructComponentRenditionHref(a.compositeHref,e,t,i,n,r)},s.prototype._constructComponentHref=function(e,t,i){var n=t.absolutePath.slice(1),o=a(this._resolveUrl(e),n);return o&&void 0!==i&&(this._hrefUsesContentApis(e)?o+="/version/"+i:o+="?version="+i),o};var c=/^\/?content\/2\/[^/]+\/[^/]+/,l=/^\/?api\/v2\/[^/]+\/assets\/[^/]+/,d={"image/jpeg":"jpg","image/png":"png"};s.prototype._constructComponentRenditionHref=function(e,t,i,n,a,s){var p,h,_=t.absolutePath.slice(1),u=r.parseURI(e).path;if("/content/2/"===u.slice(0,"/content/2/".length)){var f=d[n];if(!f)throw new o(o.INVALID_PARAMS,"Unsupported rendition media type: "+n);if(!((p=c.exec(u))&&p.length>0))throw new o(o.INVALID_PARAMS,"Failed to parse composite href: "+e);h=this._resolveUrl(r.appendPathElements(p[0],"rendition",_,"version",i,"format",f,"dimension",a,"size",String(s)))}else{if(!((p=l.exec(u))&&p.length>0))throw new o(o.INVALID_PARAMS,"Failed to parse composite href: "+e);h=this._resolveUrl(r.appendPathElements(p[0],"rendition",a,String(s),_)+"?version="+i)}return h},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,i){var n=i(9),o=i(6),r={getCollectionBookmarksData:function(e){var t=[];return e.bookmarks&&e.bookmarks.forEach(e=>{t.push({_id:e.id,_url:e.url})}),{isPublic:e.isPublic,userId:e.userId,cloudId:e.cloudId,bookmarks:t}},validateBookmarks:function(){var e=[];n.getLoadedCollections().forEach(t=>{t.isPublic||(e=e.concat(t.bookmarks))}),e.forEach(e=>{n.getLoadedCollections().forEach(t=>{t.isPublic&&!t.getLibraryById(e.id)&&t.canLoadLibrary(e.url)&&t.loadLibrary(e.id,e.url,function(t,i){t?o.log("BookmarkUtil","Error loading a public library: "+e.id+" url: "+e.url+" error: "+t):i&&delete i._loadedExternally})})}),n.getLoadedCollections().forEach(e=>{e.isPublic&&e.libraries.forEach(t=>{t._loadedExternally||(n.getLoadedCollections().some(function(e){return!e.isPublic&&e.findBookmark(t)})||e.unloadLibrary(t,function(e){e&&o.log("BookmarkUtil","Error unloading a public library: "+e)}))})})},sendBookmarksChanged:function(e){n.getLoadedCollections().forEach(t=>{t.isPublic||e.broadcast("bookmarkschanged",r.getCollectionBookmarksData(t))})}};e.exports=r},function(e,t,i){const n=i(0),o=i(2),r=i(14),a=i(15),s=i(5);e.exports=class{constructor(e,t){this._library=e,this._listenerManager=new s(["change"]),this._setDCXNode(t)}_setDCXNode(e){this._dcxNode=e,this._deletedLocally=!1}_getEventData(e){return this._dcxNode.getValue(n[e+"_DATA_KEY"])||{}}_getEventContext(e){const t=JSON.parse(JSON.stringify(this._getEventData(e)));return delete t.deviceId,delete t.userId,t}_isLocalEvent(e){const t=this._getEventData(e).deviceId;if(t&&n.DEVICE_ID)return t===n.DEVICE_ID}_markDeletedLocally(e){this._deletedLocally=e,e&&this._listenerManager.removeAll()}_commit(){this._updateModifiedTime(),this._library._commit(),this._listenerManager.notify("change"),r.reportUpdateGroup(this)}_commitMetadata(){this._library._commit(),this._listenerManager.notify("change")}_updateCreatedTime(){const e=(new Date).valueOf();this._dcxNode.setValue(n.CREATED_KEY,e),this._dcxNode.setValue(n.MODIFIED_KEY,e),this._setEventData("CREATED"),this._setEventData("MODIFIED")}_updateModifiedTime(){const e=(new Date).valueOf();this._dcxNode.setValue(n.MODIFIED_KEY,e),this._setEventData("MODIFIED")}_toJSON(){return{id:this.id,classifierName:this.classifierName,name:this.name,order:this.order}}toString(){return JSON.stringify(this._toJSON())}jasmineToString(){return this.toString()}_setEventData(e){if(!n.DEVICE_ID)return void this._clearEventData(e);const t={userId:this.library.collection.userId,deviceId:n.DEVICE_ID};n.DEVICE_DESCRIPTION&&(t.device=n.DEVICE_DESCRIPTION),n.APP_DESCRIPTION&&(t.app=n.APP_DESCRIPTION),this._dcxNode.setValue(n[e+"_DATA_KEY"],t)}_clearEventData(e){this._dcxNode.getValue(n[e+"_DATA_KEY"])&&this._dcxNode.removeValue(n[e+"_DATA_KEY"])}get id(){return this._dcxNode.id}get library(){return this._library}get name(){return this._dcxNode.name}set name(e){if(a.checkDeletedState(this),!this.isWritable)throw new o(o.NOT_ALLOWED,"you do not have write access to this library",this._library.id);this._dcxNode.name=e,this._commit()}get classifierName(){return this._dcxNode.getValue(n.CLASSIFIER_KEY)}get order(){return this._dcxNode.getValue(n.ORDER_KEY)}set order(e){if(!this.isWritable)throw new o(o.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if("string"!=typeof e)throw new o(o.INVALID_PARAMETER,"order must be a string",this._library.id);this._dcxNode.setValue(n.ORDER_KEY,e),this._commitMetadata(),r.reportUpdateGroupMetadata(this,e)}get isWritable(){return this._library.isWritable}get created(){return this._dcxNode.getValue(n.CREATED_KEY)}get createdBy(){return this._getEventData("CREATED").userId}get createdContext(){return this._getEventContext("CREATED")}get wasCreatedLocally(){return this._isLocalEvent("CREATED")}get modified(){return this._dcxNode.getValue(n.MODIFIED_KEY)}get modifiedBy(){return this._getEventData("MODIFIED").userId}get modifiedContext(){return this._getEventContext("MODIFIED")}get wasModifiedLocally(){return this._isLocalEvent("MODIFIED")}get isDeletedLocally(){return this._deletedLocally}addChangeListener(e){a.checkDeletedState(this),this._listenerManager.add("change",e)}removeChangeListener(e){this._listenerManager.remove("change",e)}}},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,i){var n=i(1),o=i(0),r=i(98),a=i(14),s=i(2),c=i(99),l=i(20),d=i(15),p=i(16),h=i(11),_=i(5);function u(e,t){this._library=e,this._renditionFetchLock=new l,this._listenerManager=new _(["change"]),this._transactionCount=0,this._setDCXNode(t,!0)}u.prototype._setDCXNode=function(e,t){var i={};this._representations&&this._representations.forEach(e=>{i[e.id]=e}),this._dcxNode=e,this._representations=[],this._deletedLocally=!1,this._library._dcxBranch.getChildrenOf(e).forEach(e=>{var t=i[e.id];t?(t._setDCXNode(e),delete i[e.id]):t=new r(this,e),this._representations.push(t)}),this._library._dcxBranch.getComponentsOf(e).forEach(e=>{var t=i[e.id];t?(t._setDCXComponent(e),delete i[e.id]):t=new r(this,void 0,e),this._representations.push(t)}),d.sortRepresentations(this._representations),t||this.library._renditionCache.clearCache(this),this._displayName=void 0},u.prototype._markDeletedLocally=function(e){this._deletedLocally=e,this._representations.forEach(t=>{t._markDeletedLocally(e)}),e&&this._listenerManager.removeAll()},u.prototype._removeAllListeners=function(){this._listenerManager.removeAll()},u.prototype._toJSON=function(){var e={id:this.id,name:this.name,type:this.type,description:this.description,representations:[]};return this._representations.forEach(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},u.prototype._addRepresentation=function(e,t){void 0!==t?this._representations.splice(t,0,e):this._representations.push(e)},u.prototype._removeRepresentation=function(e){var t=this._representations.indexOf(e);-1!==t&&this._representations.splice(t,1)},u.prototype._validateRelationship=function(e){if(-1===o.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)})},u.prototype._doCreateRepresentation=function(e,t,i){var n=this._library._dcxBranch.addChild(void 0,void 0,void 0,this._dcxNode);if(n.type=e,n.setValue(o.RELATIONSHIP_KEY,t),void 0===i){var a=this.representations[this.representations.length-1],s=Math.max(this.representations.length,a?a._getOrder()+1:0);n.setValue(o.REPRESENTATION_ORDER_KEY,s)}else n.setValue(o.REPRESENTATION_ORDER_KEY,i),this._representations.forEach((e,t)=>{if(t>=i){var n=e._getDCXElement(),r=n.getValue(o.REPRESENTATION_ORDER_KEY);void 0!==r&&n.setValue(o.REPRESENTATION_ORDER_KEY,r+1)}});var c=new r(this,n);return this._addRepresentation(c,i),c},u.prototype._getEventData=function(e,t){var i=!t&&{},n=this._dcxNode.getValue(o[e+"_DATA_KEY"])||i;if("CREATED"!==e&&"DESCRIPTION"!==e){var r=this._dcxNode.getValue(o[e+"_KEY"]);r&&r===n.time||(n=i)}return n},u.prototype._isLocalEvent=function(e){var t=this._getEventData(e).deviceId;if(t&&o.DEVICE_ID)return t===o.DEVICE_ID},u.prototype._getEventContext=function(e){var t=JSON.parse(JSON.stringify(this._getEventData(e)));return delete t.time,delete t.deviceId,delete t.userId,t},u.prototype._clearEventData=function(e){this._dcxNode.getValue(o[e+"_DATA_KEY"])&&this._dcxNode.removeValue(o[e+"_DATA_KEY"])},u.prototype._setEventData=function(e,t){if(o.DEVICE_ID){var i={userId:this.library.collection.userId,deviceId:o.DEVICE_ID};o.DEVICE_DESCRIPTION&&(i.device=o.DEVICE_DESCRIPTION),o.APP_DESCRIPTION&&(i.app=o.APP_DESCRIPTION),t&&(i.time=t),this._dcxNode.setValue(o[e+"_DATA_KEY"],i)}else this._clearEventData(e)},u.prototype._updateModifiedTime=function(){var e=(new Date).valueOf();this._dcxNode.setValue(o.MODIFIED_KEY,e),this._setEventData("MODIFIED",e)},u.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",e)},u.prototype._updateTimestampOnRemove=function(e){var t=e||(new Date).valueOf();this._dcxNode.setValue(o.REMOVED_KEY,t),this._setEventData("REMOVED",t)},u.prototype._updateTimestampOnRestore=function(){this._dcxNode.removeValue(o.REMOVED_KEY),this._clearEventData("REMOVED")},u.prototype._ensureRemovedDataValid=function(e){this.removed&&!this._getEventData("REMOVED",!0)?e?this._setEventData("REMOVED",this.removed):this._clearEventData("REMOVED"):this.removed||this._clearEventData("REMOVED")},u.prototype._ensureModifiedDataValid=function(e){this._getEventData("MODIFIED",!0)||(e?this._setEventData("MODIFIED",this.modified):this._clearEventData("MODIFIED")),this._ensureRemovedDataValid(e)},u.prototype._ensureCreatedDataValid=function(e){e&&!this._getEventData("CREATED",!0)&&this._setEventData("CREATED"),this._ensureModifiedDataValid(e)},u.prototype._commit=function(e){this._displayName=void 0,this._updateModifiedTime(),this._forEachRepresentation(e=>e._clearCachedExternalLink(!0)),this._listenerManager.notify("change"),this._library._commit(),a.reportUpdateElement(this,e)},u.prototype._commitMetadata=function(){this._listenerManager.notify("change"),this._library._commit()},u.prototype._wrapOperation=function(e,t){return this._library._wrapOperation(()=>{var i=this._library._wrapOperation(e,t);return this._updateModifiedTime(),this._listenerManager.notify("change"),i})},u.prototype._getMissingLocalComponents=function(){var e=[];return this._representations.forEach(t=>{e=e.concat(t._getMissingLocalComponents())}),e},u.prototype._forEachRepresentation=function(e,t=this.representations){t.forEach(t=>{e(t),this._forEachRepresentation(e,t.children)})},u.prototype._shouldGCLocalData=function(){var e=(new Date).valueOf();return this.removed&&e-this.removed>=o.REMOVED_ELEMENTS_CACHE_TIMEOUT},u.prototype.jasmineToString=function(){return this.toString()},u.prototype._stripObsoleteGroupsData=function(e){var t=this._dcxNode.getValue(o.GROUPS_KEY);if(t){var i=(e=e||o.DEFAULT_GROUP_CLASSIFIER)+"#",n=!1;Object.keys(t).forEach(e=>{if(e.startsWith(i)){var o=e.substring(i.length);this.library.getGroupById(o)||(delete t[e],n=!0)}}),n&&this._dcxNode.setValue(o.GROUPS_KEY,t)}},Object.defineProperties(u.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=n.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(o.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(o.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(o.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(o.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(o.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)}},sourceRef:{get(){return this._dcxNode.getValue(o.SOURCE_REF_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);if("string"!=typeof e||!e.startsWith("urn:"))throw new s(s.INVALID_PARAMETER,"sourceRef must be a string and a valid URN",this._library.id);this._dcxNode.setValue(o.SOURCE_REF_KEY,e),this._commit(!0)}}}),u.prototype.toString=function(){return JSON.stringify(this._toJSON())},u.prototype.addChangeListener=function(e){d.checkDeletedState(this),this._listenerManager.add("change",e)},u.prototype.removeChangeListener=function(e){this._listenerManager.remove("change",e)},u.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()},u.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)},u.prototype.createRepresentation=function(e,t,i,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);return this._wrapOperation(()=>{if(e===o.LINK_REPRESENTATION_TYPE)throw new s(s.INVALID_PARAMETER,"Cannot create external link representation directly - use setContentFromURL instead",this._library.id);if(void 0!==i&&(i<0||i>this._representations.length))throw new s(s.INVALID_PARAMETER,"Invalid index",this._library.id);this._validateRelationship(t);var r=this._doCreateRepresentation(e,t,i);return n||this.library._renditionCache.clearCache(this,!0),r})},u.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(()=>{this._removeRepresentation(e),e._dcxComponent?this._library._dcxBranch.removeComponent(e._dcxComponent):this._library._dcxBranch.removeChild(e._dcxNode),this.library._renditionCache.clearCache(this,!0),e._markDeletedLocally(!0)})},u.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(()=>{for(;this._representations[0];)this.removeRepresentation(this._representations[0])})},u.prototype.getPrimaryRepresentation=function(){var e;return this._representations.forEach(t=>{e||"primary"!==t.relationship||(e=t)}),e},u.prototype.getValue=function(e,t){if(e===o.DL_NAMESPACE)throw new s(s.INVALID_PARAMETER,"Reserved namespace",this._library.id);var i=d.getDCXKey(e,t);return this._dcxNode.getValue(i)},u.prototype.getValues=function(){return d.getCustomDCXData(this._dcxNode)},u.prototype.setValue=function(e,t,i){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===o.DL_NAMESPACE)throw new s(s.INVALID_PARAMETER,"Reserved namespace",this._library.id);var n,r=d.getDCXKey(e,t);try{n=JSON.parse(JSON.stringify(i))}catch(e){throw new s(s.INVALID_PARAMETER,"Value cannot be serialized to JSON",this._library.id)}this._dcxNode.setValue(r,n),this._commit()},u.prototype.removeValue=function(e,t){if(e===o.DL_NAMESPACE)throw new s(s.INVALID_PARAMETER,"Reserved namespace",this.id);const i=d.getDCXKey(e,t);this._dcxNode.removeValue(i)},u.prototype._getRenditionCandidate=function(e){var t,i,n,o,r,a,s,c=0;if("vector"===e&&this.supportsVectorThumbnail())return this.getPrimaryRepresentation();for(i=0;i<this._representations.length&&(n=this._representations[i],o=Math.max(n.width||0,n.height||0),r=n.isFullSize?Number.POSITIVE_INFINITY:o,a="primary"===n.relationship,s="rendition"===n.relationship,(!t||n.isPreferredThumbnail&&!t.isPreferredThumbnail||a&&"primary"!==t.relationship||s&&"primary"!==t.relationship&&"rendition"!==t.relationship||s&&"rendition"===t.relationship&&r>c)&&p.canComputeRendition(n)&&(t=n,c=r),!s||"image/png"!==n.type||!e||o!==e);i++);return t},u.prototype._setRenditionCache=function(e,t,i,o,r){this.library._renditionCache.setCache(this,e,t,i).then(e=>{o&&n.storageInterface.notifyDownloadRendition(this),r(null,e)},r)},u.prototype.getThumbnailURL=function(e,t){d.checkDeletedState(this,t)||this._library._waitForCommit(()=>{if(!d.checkDeletedState(this,t)){var i=this._getRenditionCandidate(e);if(i)this._library._collection._syncManager.renditions.getURL(i,e,t);else t(new s(s.THUMBNAIL_NOT_AVAILABLE,"no representation that can be converted into a thumbnail",this._library.id))}})},u.prototype.getAuthenticatedThumbnailURL=function(e,t){this.getThumbnailURL(e,function(e,i){e?t(e):this._library._collection._syncManager.appendAccessTokenToURL(i,t)}.bind(this))},u.prototype.getThumbnailPath=function(e,t){n.hasFileSystem()?d.checkDeletedState(this,t)||this._library._waitForCommit(()=>{if(d.checkDeletedState(this,t))return;if(o.SHARED_LOCAL_STORAGE)return void n.storageInterface.getRenditionPath(this,e,t);const i=(e,i)=>{this._renditionFetchLock.release(),t(e,i)};this._renditionFetchLock.obtain(()=>{if(!d.checkDeletedState(this,i)){var t=this.library._renditionCache.getCache(this,e);if(t)i(null,t);else{var o=this._getRenditionCandidate(e);if(o){if("rendition"===o.relationship&&"image/png"===o.type&&e&&Math.max(o.width||0,o.height||0)===e)return void o.getContentPath(i);var r=this._library._collection._syncManager,a=this.modified;const t=(t,n)=>{this.modified>a?i(new s(s.STALE_THUMBNAIL,"element changed before the rendition was received",this._library.id,t)):d.checkDeletedState(this,i)||(t?i(new s(s.THUMBNAIL_NOT_AVAILABLE,"error generating thumbnail",this._library.id,t)):this._setRenditionCache(e,n,!0,!0,i))};n.hasRenditionGenerator()&&e&&"vector"!==e?o.getContentPath(function(i,a){if(!i&&a){var s=o.element.library.collection._getTempDir()+n.getPathSeparator()+n.uuid()+".png";n.renditionGenerator(a,s,e,function(i){i?r.renditions.download(o,e,t):t(null,s)})}else r.renditions.download(o,e,t)}):r.renditions.download(o,e,t)}else i(new s(s.THUMBNAIL_NOT_AVAILABLE,"no representation that can be converted into a thumbnail",this._library.id))}}})}):t(new s(s.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this._library.id))},u.prototype.getCachedThumbnailPath=function(e){return this.library._renditionCache.getCache(this,e)},u.prototype.getThumbnailContent=function(e,t,i){const o=n.fs;n.hasFileSystem()?d.checkDeletedState(this,i)||d.checkEncoding(t,["utf8","ascii","base64","buffer"],i)&&this.getThumbnailPath(e,(e,n)=>{if(!e&&n){if(!d.checkDeletedState(this,i)){var r=(e,t)=>{e&&(e=h.getCommitError(e,this._library.id,"error reading content from disk")),i(e,t)};"buffer"===t?o.readFile(n,r):o.readFile(n,t,r)}}else i(e)}):i(new s(s.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this._library.id))},u.prototype.setThumbnailCache=function(e,t,i){"string"==typeof t?n.hasFileSystem()?d.checkDeletedState(this,i)||this._setRenditionCache(e,t,!1,!1,i):i(new s(s.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this._library.id)):i(new s(s.INVALID_PARAMETER,"path must be a string",this._library.id))},u.prototype.supportsVectorThumbnail=function(){const e=this.getPrimaryRepresentation();return!!e&&o.VECTOR_RENDITION_ELEMENT_TYPES.indexOf(e.type)>-1},u.prototype._getActions=function(e){var t=this.getPrimaryRepresentation();if(!t)return[];var i=o.ELEMENT_ACTION_PRODUCT_MAP,n=[];((i.types[this.type]||{})[t.type]||[]).forEach(t=>{!i.products[t]||e&&e!==i.products[t].action||n.push(new c(this,i.products[t]))});var r=n.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})},u.prototype.getActions=function(e){if(!o.SHARED_LOCAL_STORAGE)throw new s(s.NOT_SUPPORTED,"getActions() not supported without shared local storage");if(e&&-1===o.ELEMENT_ACTIONS.indexOf(e))throw new s(s.INVALID_PARAMETER,"Unknown id supplied. Potential ids are",o.ELEMENT_ACTIONS.join(", "));return this._getActions(e)},u.prototype.getGroups=function(e){e=e||o.DEFAULT_GROUP_CLASSIFIER;var t=this._dcxNode.getValue(o.GROUPS_KEY);if(!t)return[];var i=Object.keys(t);return this.library.getGroups(e).filter(e=>void 0!==this.getOrderInGroup(e)).sort(function(e,t){var n=i.indexOf(e.classifierName+"#"+e.id),o=i.indexOf(t.classifierName+"#"+t.id);return n===o?0:n<o?-1:1})},u.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(o.GROUPS_KEY)||{},i=e.classifierName+"#"+e.id;return t[i]&&t[i].order}},u.prototype._doSetOrderInGroup=function(e,t,i){var n=this._dcxNode.getValue(o.GROUPS_KEY)||{},r=e.classifierName+"#"+e.id;i&&Object.keys(n).forEach(t=>{t.startsWith(e.classifierName+"#")&&delete n[t]}),void 0===t&&n[r]&&delete n[r],void 0!==t&&(n[r]={order:t}),this._dcxNode.setValue(o.GROUPS_KEY,n)},u.prototype.setOrderInGroup=function(e,t,i){if(i=!1!==i,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,i),this._commitMetadata(),a.reportSetOrderInGroup(this,e,i)},u.prototype.getReference=function(){return"cloud-asset://"+this._library._collection._syncManager.getElementRefDomain()+this._library._collection._syncManager.getElementRefPath()+"/"+this._library.id+";node="+this.id},u.prototype.getRepresentationById=function(e){return this.representations.find(t=>t.id===e)},Object.freeze(u),Object.seal(u.prototype),e.exports=u},function(e,t,i){var n=i(1),o=i(0),r=i(2),a=i(20),s=i(28),c=i(15),l=i(7),d=i(11),p=i(21),h=i(16);function _(e,t,i){e instanceof _?this._parent=e:this._element=e,t?this._setDCXNode(t):this._setDCXComponent(i),this._lock=new a,this._pendingDownloadCallbacks=[]}_.prototype._setDCXNode=function(e){let t={};this._children&&this._children.forEach(e=>{t[e.id]=e}),this._dcxNode=e,delete this._dcxComponent,this._deletedLocally=!1,this._children=[],this.element.library._dcxBranch.getChildrenOf(e).forEach(e=>{let i=t[e.id];i?(i._setDCXNode(e),delete t[e.id]):i=new _(this,e),this._children.push(i)}),this.element.library._dcxBranch.getComponentsOf(e).forEach(e=>{let i=t[e.id];i?(i._setDCXComponent(e),delete t[e.id]):i=new _(this,void 0,e),this._children.push(i)})},_.prototype._setDCXComponent=function(e,t){this._dcxComponent=e,delete this._dcxNode,this._children=[],t||(this._deletedLocally=!1)},_.prototype._markDeletedLocally=function(e){this._deletedLocally=e},_.prototype._toJSON=function(){var e={id:this.id,type:this.type,relationship:this.relationship};return n.hasFileSystem()&&(e._componentPath=this._getComponentPath()),e},_.prototype._getOrder=function(){return this._getDCXElement().getValue(o.REPRESENTATION_ORDER_KEY)||0},_.prototype._setComponentInBrowser=function(e,t,i){this.element._library._collection._syncManager.uploadNewComponentForRepresentation(e,t,this,(e,t)=>{c.checkDeletedState(this,i)?i(e):e?i(e):(c.copyCustomDCXData(this._dcxNode,t),this.element._library._dcxBranch.removeChild(this._dcxNode),this._setDCXComponent(t,!0),this._commit(),i(null))})},_.prototype._setComponentFromPath=function(e,t,i,r){var a=e&&n.getFileNameFromPath(e),s=l.getFileExtension(a),d=this.id+"."+s;l.checkFileSize(e,s=>{s?r(s):l.getImageDimensions(e,s=>{n.storageInterface.notifyStartWrite(this.element._library,[],()=>{const n=this.element._library._dcxBranch,l=this._parent?this._parent._dcxNode:this._element._dcxNode;n.addComponent(a,this.type,this.relationship,d,e,i,void 0,l,this.id,(e,i)=>{c.checkDeletedState(this,r)||(e?r(e):(c.copyCustomDCXData(this._dcxNode,i),n.removeChild(this._dcxNode),this._setDCXComponent(i,!0),s&&(i.setValue("width",s.width),i.setValue("height",s.height)),t&&i.setValue(o.SHA_KEY,t),this._commit(),r(null)))})})})})},_.prototype._setComponent=function(e,t,i,o){const r=n.fs;let a;const p=e=>{c.checkDeletedState(this,o)||(e?o(d.getCommitError(e,this.element._library.id,"error writing representation contents")):this._setComponentFromPath(a,void 0,!1,o))};var h=this.element.library.collection._getTempDir();l.ensurePathExists(h,l=>{if(!c.checkDeletedState(this,o))if(l)o(d.getCommitError(l,this.element._library.id,"error creating temp directory"));else{if(!i){var _=s.getExtensions(this.type)[0];i=this.id+"."+_}a=h+n.getPathSeparator()+i,"buffer"===t?r.writeFile(a,e,p):r.writeFile(a,e,t,p)}})},_.prototype._getCurrentComponentPath=function(){if(this._dcxComponent)return this.element._library._dcxBranch.assetOfComponent(this._dcxComponent)},_.prototype._getComponentPath=function(e,t){if(!e)return this._getCurrentComponentPath();if(this.isExternalLink){return this.element.library.collection._externalLinkCache.getExternalLink(this).then(t=>e(null,t),e)}if(this._dcxComponent){var i=this._getCurrentComponentPath();if(i||t)e(null,i);else{var n=this.element._library;n._networkLock.obtain(t=>{t?e(t):c.checkDeletedState(this,e)?n._networkLock.release():(n._setSyncState("downloading"),n._collection._syncManager.downloadRepresentation(this,t=>{n._networkLock.release(),n._setSyncState(),c.checkDeletedState(this,e)||(t?e(d.getSyncError(t,this.element._library.id)):(n._commit(!0,!0),this._getComponentPath(e,!0)))}))})}}else{var o=this._getContentFromData();if(o){var r=this.element.library._renditionCache.getCache(this.element,this.id);r?e(null,r):this._generateContentDataFile(o,e)}else e(null)}},_.prototype._getContentFromData=function(){if(n.hasFileSystem()){var e=o.REPRESENTATION_CONTENT_VALUES[this.type];if(e&&e.contentFromData)return this.getValue(e.namespace,e.key)}},_.prototype._setExternalLink=function(e,t){if(this._dcxNode.setValue(o.LINK_TYPE_KEY,this._dcxNode.type),this._dcxNode.type=o.LINK_REPRESENTATION_TYPE,this._dcxNode.setValue(o.LINK_URL_KEY,e),t){t=t.replace(/\\/g,"/");const i=o.DEFAULT_CONTENT_LOCATIONS.find(e=>t.startsWith(e));if(i){const e=t.substring(i.length);this._dcxNode.setValue(o.LINK_LOCAL_PATH_KEY,e)}return this.element.library.collection._externalLinkCache.ensureExternalLinkCache(e,t)}return Promise.resolve()},_.prototype._clearCachedExternalLink=function(e){const t=this.element.library.collection._externalLinkCache;t&&this.isExternalLink&&(!e||t.getCachedError(this))&&(o.SHARED_LOCAL_STORAGE?n.storageInterface.clearCachedExternalLink(this):h.shouldPrefetchExternalLink(this)?t.getExternalLink(this,!0).catch(()=>void 0):t.testExternalLink(this,!0).catch(()=>void 0))},_.prototype._getLinkLocalPaths=function(){const e=this._dcxNode&&this._dcxNode.getValue(o.LINK_LOCAL_PATH_KEY);return e?o.DEFAULT_CONTENT_LOCATIONS.map(t=>`${t}${e}`):[]},_.prototype._setContentFromPath=function(e,t,i){const r=n=>{const r=n&&o.SHA_CACHE[n];if(r){this._dcxNode.setValue(o.SHA_KEY,n);const t=()=>{this._commit(),i(null)};this._setExternalLink(r,e).then(t,t)}else this._setComponentFromPath(e,n,t,i)};n.storageInterface.computeSHA(e).then(r,()=>r())},_.prototype._generateContentDataFile=function(e,t){const i=this.element.library.collection._getTempDir(),o=s.getExtensions(this.type)[0];l.writeJSONData(i,this.id+"."+o,e).then(e=>{this.element.setThumbnailCache(this.id,e,(e,i)=>{n.storageInterface.notifyDownloadRendition(this.element),t(e,i)})},e=>t(d.getCommitError(e)))},_.prototype._getDCXElement=function(){return this._dcxComponent||this._dcxNode},_.prototype._commit=function(){this.element._commit()},_.prototype._getMissingLocalComponents=function(){return n.hasFileSystem()&&this._dcxComponent&&!this._getCurrentComponentPath()?[this._dcxComponent]:[]},_.prototype.jasmineToString=function(){return this.toString()},Object.defineProperties(_.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._parent?this._parent.element:this._element},set(){throw new r(r.READ_ONLY,"element is a read-only property",this.element._library.id)}},children:{get(){return this._children},set(){throw new r(r.READ_ONLY,"children 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===o.LINK_REPRESENTATION_TYPE&&(e=this._getDCXElement().getValue(o.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._dcxComponent.getValue(o.RELATIONSHIP_KEY):this._dcxNode.getValue(o.RELATIONSHIP_KEY)||this._dcxNode.getValue("relationship")},set(e){if(this._parent)throw new r(r.NOT_ALLOWED,"you cannot set relationship on child representations",this.element._library.id);this.element._validateRelationship(e,this),this._dcxComponent?this._dcxComponent.relationship=e:this._dcxNode.setValue(o.RELATIONSHIP_KEY,e)}},width:{get(){return this._dcxComponent?this._dcxComponent.getValue("width"):this._dcxNode.getValue(o.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(o.WIDTH_KEY,e),this._commit()}},height:{get(){return this._dcxComponent?this._dcxComponent.getValue("height"):this._dcxNode.getValue(o.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(o.HEIGHT_KEY,e),this._commit()}},isFullSize:{get(){return this._getDCXElement().getValue(o.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(o.IS_FULL_SIZE_KEY,e),this._commit()}},isPreferredThumbnail:{get(){return this._getDCXElement().getValue(o.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(o.IS_PREFERRED_THUMBNAIL_KEY,e),this._commit()}},contentLength:{get(){if(this.isExternalLink)return this._dcxNode.getValue(o.LENGTH_KEY);if(this._dcxComponent){if(void 0===this._dcxComponent.length&&n.hasFileSystem()){var e=this._getCurrentComponentPath();try{var t=n.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(o.LENGTH_KEY,e),this._commit()}},contentHash:{get(){return this._getDCXElement().getValue(o.SHA_KEY)},set(){throw new r(r.READ_ONLY,"contentHash is a read-only property",this.element.library.id)}},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===o.LINK_REPRESENTATION_TYPE},set(){throw new r(r.READ_ONLY,"isExternalLink is a read-only property",this.element._library.id)}}}),_.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)},_.prototype.toString=function(){return JSON.stringify(this._toJSON())},_.prototype.getValue=function(e,t){if(e===o.DL_NAMESPACE)throw new r(r.INVALID_PARAMETER,"Reserved namespace",this.element._library.id);var i=c.getDCXKey(e,t);return this._getDCXElement().getValue(i)},_.prototype.getValues=function(){return c.getCustomDCXData(this._getDCXElement())},_.prototype.setValue=function(e,t,i){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===o.DL_NAMESPACE)throw new r(r.INVALID_PARAMETER,"Reserved namespace",this.element._library.id);var n,a=c.getDCXKey(e,t);try{n=JSON.parse(JSON.stringify(i))}catch(e){throw new r(r.INVALID_PARAMETER,"Value cannot be serialized to JSON",this.element._library.id)}this._getDCXElement().setValue(a,n),this._commit()},_.prototype.setContent=function(e,t,i,o){if(!c.checkDeletedState(this,o))if(this.isWritable)if(this._dcxComponent||this.isExternalLink)o(new r(r.INVALID_PARAMETER,"Cannot modify representation content once set",this.element._library.id));else if(n.hasFileSystem()){if(!c.checkEncoding(t,["utf8","ascii","base64","buffer"],o))return;this._setComponent(e,t,i,o)}else{if(void 0!==t)return void o(new r(r.INVALID_PARAMETER,"Encoding parameter not supported in-browser"));this._setComponentInBrowser(e,i,o)}else o(new r(r.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id))},_.prototype.setContentFromPath=function(e,t,i){"function"==typeof t&&(i=t,t=!1),n.hasFileSystem()?c.checkDeletedState(this,i)||(this.isWritable?this._dcxComponent||this.isExternalLink?i(new r(r.INVALID_PARAMETER,"Cannot modify representation content once set",this.element._library.id)):this._setContentFromPath(e,!t,i):i(new r(r.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id))):i(new r(r.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this.element._library.id))},_.prototype.setContentFromURL=function(e,t,i,o){if(n.hasFileSystem()||e){if(!c.checkDeletedState(this,o))if(this.isWritable)if("boolean"==typeof e)if(this._dcxComponent||this.isExternalLink)o(new r(r.INVALID_PARAMETER,"Cannot modify representation content once set",this.element._library.id));else{if(e)return this._setExternalLink(t),this._commit(),void o(null);var a=this.element.library.collection,h=a._getTempDir();n.storageInterface.downloadURL(a,t,i,h,(e,t,i,n)=>{if(e)o(d.getSyncError(e));else if(!c.checkDeletedState(this,o)){var r=p.getContentTypeHeader(n&&n.headers);if(r){var a=t+"."+s.getExtensions(r)[0];l.rename(t,a,e=>{e?o(d.getCommitError(e)):this._setComponentFromPath(a,void 0,!1,o)})}else this._setComponentFromPath(t,void 0,!1,o)}})}else o(new r(r.INVALID_PARAMETER,"Invalid createLink parameter: must be Boolean",this.element._library.id));else o(new r(r.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id))}else o(new r(r.NOT_IMPLEMENTED,"not yet implemented setContentFromURL without a filesystem",this.element._library.id))},_.prototype.getContentPath=function(e){n.hasFileSystem()?c.checkDeletedState(this,e)||this._getComponentPath(e):e(new r(r.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this.element._library.id))},_.prototype.getCachedContentPath=function(){if(!n.hasFileSystem())return;if(this.isExternalLink){return this.element.library.collection._externalLinkCache.getCachedPath(this)}if(this._dcxComponent)return this._getCurrentComponentPath()||void 0;return this._getContentFromData()&&this.element.library._renditionCache.getCache(this.element,this.id)||void 0},_.prototype.getContent=function(e,t){const i=n.fs;if(!c.checkDeletedState(this,t))if(n.hasFileSystem()){if(!c.checkEncoding(e,["utf8","ascii","base64","buffer"],t))return;this._getComponentPath((n,o)=>{if(n||!o)return void t(n);if(c.checkDeletedState(this,t))return;const r=(e,i)=>{e&&(e=d.getCommitError(e,this.element._library.id,"error reading content from disk")),t(e,i)};"buffer"===e?i.readFile(o,r):i.readFile(o,e,r)})}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)}},_.prototype.getContentURL=function(){return this.isExternalLink?this._dcxNode.getValue(o.LINK_URL_KEY):this._dcxComponent?this.element._library._collection._syncManager.getSharedCloudContentURL(this._dcxComponent):void 0},_.prototype.getAuthenticatedContentURL=function(e){var t=this.getContentURL();this.element._library._collection._syncManager.appendAccessTokenToURL(t,e)},_.prototype.createChild=function(e){if(!this._dcxNode)throw new r(r.NOT_ALLOWED,"can't create child on a component representation",this.element.library.id);const t=this.element.library._dcxBranch.addChild(void 0,void 0,void 0,this._dcxNode);t.type=e,t.setValue(o.RELATIONSHIP_KEY,o.RELATIONSHIP_CHILD);var i=new _(this,t);return this._children.push(i),this._commit(),i},_.prototype.removeChild=function(e){if(c.checkDeletedState(this),!this.isWritable)throw new r(r.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if(e._parent!==this)throw new r(r.INVALID_PARAMETER,"cannot remove a child that doesn't belong to this representation",this._library.id);e._dcxComponent?this.element.library._dcxBranch.removeComponent(e._dcxComponent):this.element.library._dcxBranch.removeChild(e._dcxNode);var t=this._children.indexOf(e);-1!==t&&this._children.splice(t,1),this._commit()},_.prototype.testExternalLink=function(e){this.isExternalLink&&this.getContentURL()?this.element.library.collection._externalLinkCache.testExternalLink(this).then(()=>e(null,!0),()=>e(null,!1)):e(new r(r.INVALID_PARAMETER,"Not an external link",this.element._library.id))},_.prototype.clearCachedExternalLink=function(){if(!this.isExternalLink||!this.getContentURL())throw new r(r.INVALID_PARAMETER,"Not an external link",this.element._library.id);this._clearCachedExternalLink()},_.prototype.getCachedExternalLinkError=function(){if(!this.isExternalLink||!this.getContentURL())return new r(r.INVALID_PARAMETER,"Not an external link",this.element._library.id);return this.element.library.collection._externalLinkCache.getCachedError(this)},_.prototype.getExternalLinkDownloadProgress=function(){if(this.isExternalLink)return this.element.library.collection._getExternalLinkDownloadProgress(this)},Object.freeze(_),Object.seal(_.prototype),e.exports=_},function(e,t,i){const n=i(2),o=i(10),r=i(0),a=i(1),s=i(14);e.exports=class{constructor(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(e=>e.code===t.appCode).map(e=>e.version).sort(o.compareVersions),this._invokable=this._installedVersions.length>0&&o.compareVersions(t.minVersion,this._installedVersions[0])>=0,Object.freeze(this._installedVersions)}get id(){return this._id}get element(){return this._element}get appCode(){return this._appCode}get appName(){return this._appName}get minAppVersion(){return this._minVersion}get installedVersions(){return this._installedVersions}get isCompatibleVersionInstalled(){return!!this._invokable}invoke(e=(()=>void 0)){this.isCompatibleVersionInstalled?(s.reportElementActionInvoked(this),a.storageInterface.sendElementAction(this,function(t,i){t?(t=-1!==["APP_NOT_INSTALLED","NO_COMPATIBLE_VERSION"].indexOf(t)?new n(n.NO_COMPATIBLE_APP_FOUND,"A compatible version of application is needed for this action:"+t):new n(n.APP_LAUNCH_FAILED,"Launching the app failed:"+t),s.reportElementActionFailed(this,t)):s.reportElementActionSuccessful(this,i),e(t,i)})):e(new n(n.NO_COMPATIBLE_APP_FOUND,"A compatible version of application is needed for this action",this._appCode))}}},function(e,t,i){const n=i(45),o=i(46),r=i(0),a=i(29),s=i(58),c="renditions";e.exports=class extends s{constructor(e){super(e._getRenditionCacheDir()),this._library=e,this._pendingSetCache=[]}getCache(e,t="full"){const i=this._getCache([c,e.id,t]);return this._getFilePath(i)}setCache(e,t="full",i,n=!1){return r.SHARED_LOCAL_STORAGE?this._requestSetCache(e.id,t,i):this._doTransaction(()=>this._setCache([c,e.id,t],i,n))}clearCache(e,t){const i=this._getCache([c,e.id]);return i?(t&&r.SHARED_LOCAL_STORAGE&&a.supportsClearRenditionCache()&&Object.keys(i).forEach(t=>this._requestSetCache(e.id,t,"CLEAR")),this._clearCache(e)):Promise.resolve()}copyCache(e,t){return r.SHARED_LOCAL_STORAGE?(this._copyCache(e,t),Promise.resolve()):this._doTransaction(()=>this._copyCache(e,t))}serializeCache(e=!1,t){const i={},n=n=>{i[n.id]=this.serializeElementCache(n,e,t)};return this._library.elements.forEach(n),this._library.removedElements.forEach(n),i}serializeElementCache(e,t=!1,i){const n=Object.assign({},this._cache[c]&&this._cache[c][e.id]||{});return t&&this._convertToAbsolutePaths(n),this._addExternalLinksToElementCache(n,e,t,i),n}replaceCache(e){this._cache={[c]:e}}replaceElementCache(e,t){this._cache[c]=this._cache[c]||{},this._cache[c][e.id]=t}checkAndInvalidateRenditions(e,t){const i=this._getCache([c,e.id])||{};let r;return Object.keys(i).some(a=>{if(!Number(a))return;const s=o.join(this._rootDir,i[a]),c=o&&n.statSync(s);return c&&c.size>t?(this.clearCache(e),r=`Invalidating rendition - ${e.id} ${e.name} dimension: ${a} size: ${c.size}`,!0):void 0}),r}doRequestSetCache(){return this._requestingSetCache=this._pendingSetCache,this._pendingSetCache=[],{data:this._requestingSetCache.map(({element:e,size:t,path:i})=>({element:e,size:t,path:i})),cancel:()=>{this._pendingSetCache=this._requestingSetCache.concat(this._pendingSetCache),delete this._requestingSetCache},complete:e=>this._completeRequestSetCache(e)}}applyRequestSetCache(e){return this._doTransaction(()=>this._applyRequestSetCache(e))}gc(){const e={},t=t=>{t._shouldGCLocalData()||(e[t.id]=!0)};this._library.elements.forEach(t),this._library.removedElements.forEach(t);const i=this._cache[c]||{};let n=!1;Object.keys(i).forEach(t=>{e[t]||(this._setCacheEntry([c,t]),n=!0)});const o=n?this.save():Promise.resolve(),r=this._library.collection._externalLinkCache;return o.then(()=>r&&r.gc())}_load(){return super._load().then(()=>{this.serializeCache(!0,!1)})}_gcUnreferencedFiles(){return this._library._dcxComposite.autoRemoveUnusedLocalFiles?super._gcUnreferencedFiles():Promise.resolve()}_copyCache(e,t){const i=t.library._renditionCache,n=this._getCache([c,e.id])||{},o=Object.keys(n).map(o=>{const a=this._getFilePath(n[o],!0);if(!a)return Promise.resolve();var s=e.getRepresentationById(o);if(s&&!t.getRepresentationById(o)){const i=e.representations.indexOf(s);i>=0&&i<t.representations.length&&(o=t.representations[i].id)}return this._isPath(a)?r.SHARED_LOCAL_STORAGE?i._requestSetCache(t.id,o,a):i._setCache([c,t.id,o],a):Promise.resolve(i._setCacheEntry([c,t.id,o],a))});return Promise.all(o)}_requestSetCache(e,t,i){return new Promise((n,o)=>{this._pendingSetCache=this._pendingSetCache.filter(i=>!(i.element===e&&i.size===t&&"CLEAR"===i.path)),this._pendingSetCache.push({element:e,size:t,path:i,callback:(e,t)=>e?o(e):n(t)})})}_applyRequestSetCache(e){const t=e.map(({element:e,size:t,path:i})=>"CLEAR"===i?(this._setCacheEntry([c,e,t]),Promise.resolve()):this._setCache([c,e,t],i));return Promise.all(t)}_completeRequestSetCache(e){const t={};return e.forEach((e,i)=>{const n=this._requestingSetCache[i],o=this._library.getElementById(n.element);if(n&&o&&e&&0===e.indexOf(this._rootDir)){const i=e.substring(this._rootDir.length+1);this._setCacheEntry([c,n.element,n.size],i),t[o.id]=o}n&&n.callback(null,e)}),delete this._requestingSetCache,Object.keys(t).map(e=>t[e])}_clearCache(e,t){const i=t?[c,e.id,t]:[c,e.id];return this._setCacheEntry(i),this.save()}_convertToAbsolutePaths(e){Object.keys(e).forEach(t=>{const i=e[t];e[t]=this._isPath(i)?o.join(this._rootDir,i):i})}_legacyGetCacheEntry(e){const t=this._getCache([c,e.element.id,e.id]);return this._getFilePath(t,!0)}_legacyClearCacheEntry(e){const t=[c,e.element.id,e.id];this._getCache(t)&&(this._setCacheEntry(t),this.save())}_addExternalLinksToElementCache(e,t,i=!1,n){e=e||{};const r=this._library.collection._externalLinkCache;t._forEachRepresentation(t=>{if(t.isExternalLink&&!e[t.id]){const a=r._getCacheEntry(t);a&&(e[t.id]=!i&&a.startsWith(r._rootDir)?o.relative(this._rootDir,a):a,r._notifyDownloadRendition(t,n))}})}}},function(e,t,i){var n=i(52),o=i(8),r=i(4),a=i(0),s=i(2),c=i(1),l=i(21),d=i(15),p=i(28);const h=i(102),_=i(103),u=i(104),f={"platform-cs.adobe.io":!0,"platform-cs-stage.adobe.io":!0};e.exports=class{constructor(e,t){this._collection=e,this._isPublic=t.IS_PUBLIC,this._storageHost=t.STORAGE_HOSTNAME,this._isACP=f[t.STORAGE_HOSTNAME],this._collaborationHost=t.COLLABORATION_HOSTNAME,this._ccLibraryHost=`https://${t.CC_LIBRARY_SERVICE_HOSTNAME}/api/v1`,this._apiKey=a.STORAGE_API_KEY,this._XHR=t.XHR,this._requiresCommunitySession=t.REQUIRES_COMMUNITY_SESSION,this._rootPath=t.ROOT_COLLECTION||"",this._rootPath||this._isPublic||(this._rootPath=o.appendPathElements(a.STORAGE_ASSETS_PATH,a.LIBRARY_SYNC_GROUP)),this._getAccessToken=t.getAccessToken,this._httpServices=[],this._storageService=this._createStorageSession(this.getStorageHost(),!0),this._storageServices={},this._renditionSync=new _(e=>this._getStorageSession(e),this.getStorageHost(),t),this._externalLinkSync=new h(e=>this._getStorageSession(e)),this._typekitSync=new u(e=>this._getStorageSession(e),t),this._lastSyncGroupState={},this._hasSetAuthToken=!1,this._authToken=void 0,this._inProgressSyncMap={},a.SHARED_LOCAL_STORAGE||this._isPublic||this._updateAuthToken()}get typekit(){return this._typekitSync}get renditions(){return this._renditionSync}get links(){return this._externalLinkSync}_getCommonRequestHeaders(){const e={};return a.USER_AGENT_HEADER&&(e["User-Agent"]=a.USER_AGENT_HEADER),e}_setAuthToken(e){this._hasSetAuthToken=!0,this._authToken=e,this._httpServices.forEach(t=>{e?(t.isActive=!0,t.setAuthToken(e)):t.isActive=!1})}_updateAuthToken(e=(()=>void 0)){this._getAccessToken(this._authToken,(t,i)=>{!t&&i?this._setAuthToken(i):(t&&t.code===s.ACCESS_DENIED&&(this._collection._reportSyncError(t),this._collection._updateSyncState()),this._setAuthToken()),e(null,i)})}_getAuthToken(e){this._hasSetAuthToken?e(null,this._authToken):this._updateAuthToken(e)}_authHandler(){this._updateAuthToken()}_createStorageSession(e,t){const i=this._isPublic&&e===this.getStorageHost();let n;if(t&&this._getAccessToken&&!i?(this._authToken||this._updateAuthToken(),(n=c.dcx.createHTTPService(this._authHandler.bind(this))).setAuthToken(this._authToken),this._httpServices.push(n)):n=c.dcx.createHTTPService(),n.setTimeout(a.NETWORK_TIMEOUT),n.setAdditionalNodeOptions(c.getNodeTunnelOptions(e)),(t||i)&&(n.setApiKey(this._apiKey),n.setAdditionalHeaders(this._getCommonRequestHeaders())),this._XHR&&n._forceXhr(this._XHR),e===this.getStorageHost()){if(this._requiresCommunitySession)return c.dcx.createCommunitySession(n,e);if(this._isACP)return c.dcx.createPlatformSession(n,e)}return c.dcx.createStorageSession(n,e)}_getStorageSession(e){var t=o.parseURI(e),i=t.scheme+"://"+t.authority,n=l.isAdobeDomain(t.authority);return this._storageServices[i]||(this._storageServices[i]=this._createStorageSession(i,n)),this._storageServices[i]}_isManifestOnly(){return"manifestOnly"===a.SYNC_POLICY||!c.hasFileSystem()}_pullCompositeComponents(e,t,i,o,r){if(this._isManifestOnly())r(null);else{var a=n.downloadComponents(e,t,this._storageService,r);this._inProgressSyncMap[o]=a,a.onProgress=function(e,t){0!==t&&i._updateProgress(o,e,t)}}}_pullComposite(e,t,i,o){this._inProgressSyncMap[i]=n.pullCompositeManifestOnly(e,this._storageService,(e,n)=>{if(!e&&n){var r=n.getComponentsOf();n.getChildrenOf().forEach(e=>{e.name===a.ELEMENTS_NAME&&n.getChildrenOf(e).forEach(e=>{r=r.concat(n.getComponentsOf(e))})}),this._pullCompositeComponents(r,n,t,i,e=>o(e,n))}else o(e,n)})}getServerComposites(e){var t=this._lastSyncGroupState.etag;this._storageService.getCollection(this.getSyncGroupPath(),t,(t,i,n,o)=>{if(t)t.response&&404===t.response.statusCode?e(null,[]):e(t);else{if(!i){var r=Math.max(a.DEFAULT_MAX_SYNC_INTERVAL,1e3*l.getRetryAfterHeader(o));return a.MAX_SYNC_INTERVAL=r,void e(null,[])}a.MAX_SYNC_INTERVAL=a.DEFAULT_MAX_SYNC_INTERVAL;var s=this._lastSyncGroupState.compositeEtags||{},c={},p=[],h={};(i.children||[]).forEach(e=>{e&&d.validateLibraryId(e.name,!1)&&(e.isUnmodified=e.etag&&s[e.name]===e.etag,p.push(e),h[e.name]=e,c[e.name]=e.etag)}),this._lastSyncGroupState={etag:n,compositeEtags:c},e(null,p,h)}})}deleteAllServerComposites(e){this._storageService.deleteCompositeDirectory({href:this.getSyncGroupPath()},e)}abortAllDownloads(){Object.keys(this._storageServices).map(e=>this._storageServices[e]).forEach(e=>e.abortAll())}clearSyncGroupCache(){this._lastSyncGroupState={}}doHeadRequest(e,t){let i;try{i=this._storageService.getCompositeManifestHref(e)}catch(e){return void t(e)}this._storageService.headRequest(i,t)}hasCompositeChangedOnServer(e,t){this.doHeadRequest(e,function(i,n){if(i)t(!0);else{var o=n&&n.headers&&n.headers.etag,r=e.current&&e.current.manifestEtag;t(o!==r)}})}downloadComponent(e,t,i){n.downloadComponents([t],e,this._storageService,i)}downloadRepresentation(e,t){var i=e._dcxComponent,n=e.element.library._dcxBranch;this.downloadComponent(n,i,t)}abortPushOrPull(e){this._inProgressSyncMap[e]&&(this._inProgressSyncMap[e].abort(new s(s.TRANSFER_ABORTED,"abort push or pull operation")),delete this._inProgressSyncMap[e])}pullLibrary(e,t){const i=e._dcxComposite,n=e.collection;let o=e.id;if(!o&&i.href){const e=i.href.split("/");o=e&&e[e.length-1]}c.log("Started pulling: "+o+(this._isManifestOnly()?" (manifest only)":""));var a=(new Date).valueOf();n._updateProgress(o),this._pullComposite(i,n,o,(e,s)=>{var l=(new Date).valueOf()-a;c.log("Finished pulling: "+o+(e?" ["+e.code+"]":"")+" duration="+l),delete this._inProgressSyncMap[o],n._updateProgress(o),s&&(s=s.copy(),d.ensureBranchDataValid(s)),e&&e.code===r.COMPONENT_DOWNLOAD_ERROR?this.doHeadRequest(i,(i,n)=>{if(!i&&n&&200===n.statusCode){var o=d.removeMissingComponents(e.pulledBranch.copy(),e.failedComponents);if(o)return void t(null,o)}t(e,s)}):t(e,s)})}pullMissingComponents(e,t){var i=e.id,n=e.collection,o=e._getMissingLocalComponents();if(this._isManifestOnly()||0===o.length)t(null);else{e._setSyncState("downloading"),c.log("Started pulling missing components: "+i);var r=(new Date).valueOf();n._updateProgress(i),this._pullCompositeComponents(o,e._dcxBranch,n,i,o=>{var a=(new Date).valueOf()-r;c.log("Finished pulling missing components: "+i+(o?" ["+o.code+"]":"")+" duration="+a),delete this._inProgressSyncMap[i],n._updateProgress(i),e._setSyncState(),o&&o.code===s.TRANSFER_ABORTED?t(null):t(o)})}}pushLibrary(e,t,i){const o=e._dcxComposite,r=e.collection,a=e.id;c.log("Started pushing: "+a);var s=(new Date).valueOf();r._updateProgress(a),this._inProgressSyncMap[a]=n.pushComposite(o,t,this._storageService,e=>{var t=(new Date).valueOf()-s;c.log("Finished pushing: "+a+(e?" ["+e.code+"]":"")+" duration="+t),delete this._inProgressSyncMap[a],r._updateProgress(a),i(e)}),this._inProgressSyncMap[a].onProgress=((e,t)=>{0!==t&&r._updateProgress(a,e,t)})}pushDeletedLibrary(e,t,i,n){const o=e._dcxComposite;if("incoming"===t)return c.log("Deleting incoming collaboration without pushing: "+o.id),void this._storageService.deleteCompositeDirectory(o,n);!o.current||o.current.isBound?(c.log("Pushing deleted composite: "+o.id),this.pushLibrary(e,i,t=>{if(t){if(t.code===r.UNEXPECTED_RESPONSE&&t.response&&404===t.response.statusCode)return void this._storageService.deleteCompositeDirectory(o,n);if(t.code===r.UPDATE_CONFLICT){var i=t;return void this.pullLibrary(e,e=>{e&&e.code===r.NO_COMPOSITE?this._storageService.deleteCompositeDirectory(o,n):e&&e.code===r.DELETED_COMPOSITE?n(null):n(e||i)})}}n(t)})):n(null)}getStorageHost(){return"https://"+this._storageHost}getSyncGroupPath(){return o.appendPathElements(this.getStorageHost(),this._rootPath)}getCompositePath(e){return o.appendPathElements(this.getSyncGroupPath(),e)}getComponentPath(e,t){return o.appendPathElements(this.getSyncGroupPath(),e,t)}getElementRefDomain(){return this._requiresCommunitySession?a.CP_CLOUD_ID:this._storageHost}getElementRefPath(){return a.STORAGE_ASSETS_PATH+a.LIBRARY_SYNC_GROUP}getElementRefDomainPath(){return this.getElementRefDomain()+this.getElementRefPath()}getCollaborationHost(){return"https://"+this._collaborationHost}getSharedCloudContentURL(e){return this._storageService.getComponentHref(e,e.version)}appendAccessTokenToURL(e,t){if(e){var i=this._apiKey;this._getAuthToken((n,o)=>{t(null,e+="?api_key="+i+(o?"&user_token="+o:""))})}else t(null,void 0)}getSharedCloudContent(e,t,i){var n=this._storageService.getComponentHref(e._dcxComponent,e._dcxComponent.version);this._storageService.getAssetAsType(n,t,{},function(e,t){e?i(e):i(null,t)})}prepareCompositeForPush(e){e.href=this.getCompositePath(e.id)}updateAccessToken(e){this._setAuthToken(e)}isLoggedIn(){return this._isPublic||this._httpServices[0].isActive}uploadNewComponentForRepresentation(e,t,i,o){var r=i._element._library._dcxComposite;n.uploadNewComponent(e,i.type,r,i.id,this._storageService,function(e,n){if(e)return void o(e);const a=t?t.lastIndexOf("."):-1,s=-1!==a&&t.substr(a+1).toLowerCase(),c=i.id+"."+s,l=i._parent?i._parent._dcxNode:i._element._dcxNode,d=r.current.addComponentWithUploadResults(t,i.relationship,c,l,n);o(null,d)})}uploadNewComponentForLibrary(e,t,i,o,r,a){var s=r._dcxComposite;n.uploadNewComponent(e,i,s,t,this._storageService,function(e,n){if(e)a(e);else{var r=p.getExtensions(i)[0],c=t+"."+r,l=s.current.addComponentWithUploadResults(c,o,c,s,n);a(null,l)}})}pushClientTokenInfo(e,t,i){this._getStorageSession(this._ccLibraryHost)._service.invoke("POST",`${this._ccLibraryHost}/client-tokens/${e}`,{"Content-Type":"application/json"},JSON.stringify({token:JSON.stringify(t),ttl:300}),null,(e,t)=>{if(e||201!==t.statusCode)return i(e||new Error("Failed to push client Token info to the server"));i(null,!0)})}}},function(e,t,i){const n=i(35),o=i(4),r=i(0),a=i(1),s=i(21),c=i(7);e.exports=class{constructor(e){this._getStorageSession=e}download(e,t,i,l,d,p=0){a.log("download external link: "+e);var h=this._getStorageSession(e),_=i+a.getPathSeparator()+a.uuid(),u=new n.FileContent(_);t=t||{},c.ensurePathExists(i,n=>{if(n)d(n);else{var c=h.getAssetAsType(e,u,t,(n,h,u,f)=>{if(c&&delete c.progress,n&&n.code===o.UNEXPECTED_RESPONSE){var m=n.response&&n.response.statusCode;if(a.log("download external link: Unexpected Response "+m+" from "+e),s.isRedirect(m)){var E=s.getLocationHeader(n.response.headers);if(E&&p<r.MAX_REDIRECT_FOLLOW)return a.log("download external link: Redirecting to "+E),void this.download(E,t,i,l,d,p+1);n.response.statusCode=404}}d(n,_,u,f)});if(c&&l){var f,m=0;c.progress=(e=>{m+=e,!f&&c.response&&c.response.headers&&(f=s.getContentLengthHeader(c.response.headers)),l(m,f||1)}),l(0,1)}}})}test(e,t,i=0){this._getStorageSession(e).headRequest(e,(n,o)=>{var c=o?o.statusCode:n;if(a.log("test external link: "+e+" -> "+c),o&&s.isRedirect(o.statusCode)){var l=s.getLocationHeader(o.headers);if(l&&i<r.MAX_HEAD_REDIRECT_FOLLOW)return a.log("test external link: Redirecting to "+l),void this.test(l,t,i+1);i>0&&(o.statusCode=404)}t(n,o)})}}},function(e,t,i){const n=i(35),o=i(0),r=i(1),a=i(21),s=i(11),c=i(7);e.exports=class{constructor(e,t,i){this._getStorageSession=e,this._imageHost=i.CC_IMAGE_HOSTNAME,this._imageXHost=i.CC_IMAGE_X_HOSTNAME,this._renditionStorageService=e(t,!0),this._requiresCommunitySession=i.REQUIRES_COMMUNITY_SESSION}_downloadRendition(e,t,i,a,c,l=0){if(e.isDeletedLocally||e.element.library.isDeletedFromServer)c("Error: representation deleted");else{var d=n=>this._downloadRendition(e,t,i,a,c,n);if(l>0&&"uploading"===e.element.library.syncState)setTimeout(()=>d(l),o.RENDITION_RETRY_INTERVAL);else{var p=i+r.getPathSeparator()+r.uuid()+".png",h=new n.FileContent(p);this._renditionStorageService.getAssetAsType(t,h,a,t=>{var i=t&&t.response&&t.response.headers,n=()=>c(t,p);if(404===s.getErrorStatusCode(t))return this._retry404IfNeeded(e,i,l,d,n);n()})}}}_retry404IfNeeded(e,t,i,n,s){var c=1e3*a.getRetryAfterHeader(t);if(o.RENDITION_RETRY_INTERVAL=Math.max(o.DEFAULT_RENDITION_RETRY_INTERVAL,c),o.RENDITION_404_BACKOFF=Math.max(o.DEFAULT_RENDITION_404_BACKOFF,c),i<o.RENDITION_MAX_RETRIES)return i++,r.log("404 fetching rendition: retrying ("+i+")"),void setTimeout(()=>n(i),o.RENDITION_RETRY_INTERVAL);r.log("404 fetching rendition: reached maximum retries"),r.log("Backing off rendition fetch of "+e.id+" for "+o.RENDITION_404_BACKOFF+"ms"),e._lastRendition404=(new Date).valueOf(),s()}_getImageServiceSVGRendition(e,t,i){var n=e.element,o="https://"+this._imageHost+"/createagc",a=this._getStorageSession(o),s={"Content-Type":"application/vnd.adobe.image-operation+json"},l={inputs:{application_file:{href:n.getReference()}},outputs:{agc:{disposition:"location"}}};if(e.isDeletedLocally||e.element.library.isDeletedFromServer)i("Error: representation deleted");else{var d=t=>this._getImageServiceSVGRendition(e,t,i);a._service.invoke("POST",o,s,JSON.stringify(l),{responseType:"text"},(p,h)=>{if(p||200!==h.statusCode){var _=function(){return i(p||"Image service call failed with: "+h.statusCode)};return h&&404===h.statusCode?this._retry404IfNeeded(e,h&&h.headers,t,d,_):void _()}var u;try{u=JSON.parse(h.response)}catch(e){return i(e)}if(u&&u.outputs&&u.outputs.agc&&u.outputs.agc.location)return o="https://"+this._imageXHost+"/agctosvg",a=this._getStorageSession(o),s={"Content-Type":"application/vnd.adobe.dwbedrockservice-operation+json"},l={inputs:{href:u.outputs.agc.location}},a._service.invoke("POST",o,s,JSON.stringify(l),{responseType:"text"},function(e,t){if(e||200!==t.statusCode)return i(e||"Image-x service call failed with: "+t.statusCode);var o=t.response,a=n.library.collection._getTempDir(),s=a+r.getPathSeparator()+r.uuid()+".svg";c.ensurePathExists(a,function(e){if(e)return i(e);r.fs.writeFile(s,o,function(e){if(e)return i(e);i(null,s)})})});i("Invalid image service response")})}}getURL(e,t,i){if(e._dcxComponent)try{i(null,this._requiresCommunitySession?this._renditionStorageService.getComponentRenditionHref(e._dcxComponent,e._dcxComponent.version,"image/png","width",t||"full"):this._renditionStorageService.getComponentRenditionHref(e._dcxComponent,e._dcxComponent.version,t||"full"))}catch(e){i(e)}else i("representation must be a component to generate a rendition")}download(e,t,i){if(e.element.library.isDeletedFromServer)return r.log("Error: Trying to fetch rendition from deleted library."),void i("Error: library deleted");if((new Date).valueOf()-(e._lastRendition404||0)<o.RENDITION_404_BACKOFF)i("Error: got 404 on last rendition attempt - backing off");else if("vector"===t&&e.element.supportsVectorThumbnail()){const t=()=>{"uploading"!==e.element.library.syncState?this._getImageServiceSVGRendition(e,0,i):setTimeout(t,o.RENDITION_RETRY_INTERVAL)};t()}else this.getURL(e,t,(t,n)=>{if(t)i(t);else{var o={Accept:"image/png"},r=e.element.library.collection._getTempDir();c.ensurePathExists(r,t=>{t?i(t):this._downloadRendition(e,n,r,o,i)})}})}}},function(e,t){e.exports=class{constructor(e,t){this._getStorageSession=e,this._typekitHost=t.TYPEKIT_HOSTNAME}getFontData(e,t){var i="https://"+this._typekitHost+"/v1/variations?include=trial,full,marketplace,purchased&include_marketplace_data=true&purpose=sync";this._getStorageSession(i)._service.invoke("POST",i,null,JSON.stringify(e),{responseType:"text"},function(e,i){if(e||200!==i.statusCode)return t(e||"Typekit service call failed with: "+i.statusCode);try{t(null,JSON.parse(i.response))}catch(e){t(e)}})}}},function(e,t,i){const n=i(1),o=i(0),r=i(5);e.exports=class{constructor(e,t,i,n,o){this._listenerManager=new r(["progress"]),this._collection=e,this._id=t,this._type=i,this._data=n,this._cancelCallback=o,this._progress=0}_updateProgress(e){this._progress!==e&&(this._progress=e,this._listenerManager.notify("progress",[this]),this._collection._notifyOperationChange())}get id(){return this._id}get type(){return this._type}get data(){return this._data}get progress(){return this._progress}addProgressListener(e){this._listenerManager.add("progress",e)}removeProgressListener(e){this._listenerManager.remove("progress",e)}cancel(){o.SHARED_LOCAL_STORAGE?n.storageInterface.cancelOperation(this._collection,this._id):this._cancelCallback&&this._cancelCallback()}}},function(e,t,i){const n=i(45),o=i(46),r=i(1),a=i(2),s=i(0),c=i(28),l=i(7),d=i(11),p=i(29),h=i(21),_=i(58),u="urls",f=(e,t,i,n)=>new Promise((o,a)=>{const s=(new Date).valueOf();r.log("Downloading from external URL: "+t),e._syncManager.links.download(t,{},i,n,(e,t,i,n)=>{r.log("Finished downloading from external URL: "+((new Date).valueOf()-s)+"ms"),e?a(e):o({tempFilePath:t,etag:i,response:n})})}),m=(e,t)=>new Promise(i=>{const n=(new Date).valueOf();r.log("HEAD request of external URL: "+t),r.storageInterface.testURL(e,t,function(e,t){r.log("Finished HEAD request of external URL: "+((new Date).valueOf()-n)+"ms"),i(t)})}),E={downloadExternalLink:e=>new Promise((t,i)=>{r.storageInterface.downloadExternalLink(e,(e,n)=>e?i(e):t(n))}),testExternalLink:e=>new Promise((t,i)=>{r.storageInterface.testExternalLink(e,(e,n)=>n?t():i())})},g={};class y extends _{static connect(e){const t=e.userId,i=g[t]=g[t]||new y(t);return i._connect(e),i}static disconnect(e){const t=e.userId;g[t]&&g[t]._disconnect(e)}constructor(e){super(o.join(l.getUserDir(e),"links")),this._userId=e,this._collections=[],this._pendingDownloads={},this._pendingTests={},this._referencedLinks={},this._sentNotifications={}}getCachedPath(e){const t=this._getCacheEntry(e);return this._isPath(t)?t:void 0}getCachedError(e){const t=h.validateURL(e.getContentURL(),this._privateCollection);if(t)return t;const i=this._getCacheEntry(e);return this._isErrorCode(i)?new a(i,"Broken link, or access denied"):null}getExternalLink(e,t=!1){const i=e.getContentURL(),n=h.validateURL(i,this._privateCollection);if(n)return Promise.reject(n);if(t)e.element.library._renditionCache._legacyClearCacheEntry(e),this._setCacheEntry([u,i]);else{const t=this._getCacheEntry(e);if(this._isPath(t))return Promise.resolve(t);if(this._isErrorCode(t))return Promise.reject(new a(t,"Broken link, or access denied"))}if(s.SHARED_LOCAL_STORAGE)return E.downloadExternalLink(e);if(!this._pendingDownloads[i]){const t=()=>{this._notifyDownloadFinished(this._pendingDownloads[i]);const t=e.element;t.supportsVectorThumbnail()&&t.library._renditionCache._clearCache(t,"vector"),delete this._pendingDownloads[i]};this._pendingDownloads[i]={promise:this._doGetExternalLink(e),representations:[]},this._pendingDownloads[i].promise.then(t,t)}return this._pendingDownloads[i].representations.push(e),this._pendingDownloads[i].promise}testExternalLink(e,t=!1){const i=e.getContentURL();if(h.validateURL(i,this._privateCollection))return Promise.reject();if(t)e.element.library._renditionCache._legacyClearCacheEntry(e),this._setCacheEntry([u,i]);else{const t=this._getCacheEntry(e);if(t)return this._isErrorCode(t)?Promise.reject():Promise.resolve()}if(s.SHARED_LOCAL_STORAGE&&p.supportsTestExternalLink())return E.testExternalLink(e);if(!this._pendingTests[i]){const e=this._getOnDownloadProgressCallback("_pendingTests",i),t=()=>{this._notifyDownloadFinished(this._pendingTests[i]),e(),delete this._pendingTests[i]};this._pendingTests[i]={promise:this._doTest(i),representations:[]},e(0,1),this._pendingTests[i].promise.then(t,t)}return this._pendingTests[i].representations.push(e),this._pendingTests[i].promise}ensureExternalLinkCache(e,t){const i=this._getCache([u,e]);return this._getFilePath(i)?Promise.resolve():this._doTransaction(()=>this._setCache([u,e],t))}gc(){const e={};this._collections.forEach(t=>{t.libraries.forEach(t=>{Object.assign(e,this._getReferences(t))})});const t=this._cache[u]||{};let i=!1;return Object.keys(t).forEach(t=>{e[t]||(this._setCacheEntry([u,t]),i=!0)}),i?this.save():Promise.resolve()}get _privateCollection(){return this._collections.find(e=>!e.isPublic)}_connect(e){this._collections.push(e),e._externalLinkCache=this}_disconnect(e){const t=this._collections.indexOf(e);-1!==t&&this._collections.splice(t,1),0===this._collections.length&&delete g[this._userId]}_getCacheEntry(e){const t=e.element.library._renditionCache._legacyGetCacheEntry(e);if(t)return t;const i=e.getContentURL(),n=this._getCache([u,i]);return this._getFilePath(n,!0)}_doGetExternalLink(e){const t=e.getContentURL(),i=e._getLinkLocalPaths().find(e=>n.statSync(e));return i?this._doTransaction(()=>this._setCache([u,t],i)):this._doDownload(t,e.type)}_doDownload(e,t){const i=this._getOnDownloadProgressCallback("_pendingDownloads",e),o=this._privateCollection._getTempDir();return f(this._privateCollection,e,o,i).then(({tempFilePath:o,response:r})=>{var a=h.getContentTypeHeader(r&&r.headers)||t,s=o+"."+(c.getExtensions(a)[0]||"data");const l=n.rename(o,s).then(()=>this._doTransaction(()=>this._setCache([u,e],s,!0)));return l.then(i,i),l}).catch(t=>{let n;var o=t&&t.response&&t.response.statusCode;return h.isUnrecoverableClientError(o)?(this._setCacheEntry([u,e],a.RENDITION_NOT_AVAILABLE),n=this.save().then(()=>Promise.reject(new a(a.RENDITION_NOT_AVAILABLE,"Broken link, or access denied")))):n=Promise.reject(d.getSyncError(t)),n.catch(()=>i(void 0,void 0,t)),n})}_doTest(e){return m(this._privateCollection,e).then(t=>{const i=t&&t.statusCode;let n;return h.isUnrecoverableClientError(i)?n=a.RENDITION_NOT_AVAILABLE:i&&i>=200&&i<400&&(n=s.RENDITION_CACHE_PLACEHOLDER),n?(this._setCacheEntry([u,e],n),this.save().then(()=>this._isErrorCode(n)?Promise.reject():Promise.resolve())):Promise.resolve()})}_getOnDownloadProgressCallback(e,t){return(i,n,o)=>{const r=this[e]&&this[e][t]&&this[e][t].representations;r&&r.forEach(e=>{e.element.library.collection._updateExternalLinkDownloadProgress(e,i,n,o)})}}_notifyDownloadFinished(e){e.representations.forEach(e=>this._notifyDownloadRendition(e,!0))}_notifyDownloadRendition(e,t){const i=`${e.element.library.id}.${e.element.id}.${e.id}`;!0!==t&&this._sentNotifications[i]||(this._sentNotifications[i]=!0,!1!==t&&r.storageInterface.notifyDownloadRendition(e.element))}_getReferences(e){if(this._referencedLinks[e.id]=this._referencedLinks[e.id]||{},this._referencedLinks[e.id].modified!==e.modified){this._referencedLinks[e.id].modified=e.modified,this._referencedLinks[e.id].urlMap={};const t=t=>{t._shouldGCLocalData()||t._forEachRepresentation(t=>{const i=t.isExternalLink&&t.getContentURL();i&&(this._referencedLinks[e.id].urlMap[i]=!0)})};e.elements.forEach(t),e.removedElements.forEach(t)}return this._referencedLinks[e.id].urlMap}}e.exports=y},function(e,t,i){const n=i(60),o=i(1),r=i(0),a=i(20),s=i(7),c=i(11),l=(e,t)=>e.find(e=>e.id===t),d=e=>e.map(e=>({id:e.id,url:e.url})),p=(e=[])=>e.map(e=>new n(e.id,e.url));e.exports=class{constructor(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._createStorageSession(e._syncManager.getCollaborationHost(),!0)._service,this._bookmarksURL=e._syncManager.getCollaborationHost()+r.BOOKMARKS_PATH}_getBookmarksDir(){return this._collection._getBaseDir()}_saveBookmarks(e){if(!o.hasFileSystem())return void e(null);const t={bookmarks:d(this._bookmarks),etag:this._bookmarksEtag};this._bookmarksBase&&(t.bookmarks_base=this._bookmarksBase),s.writeJSONData(this._getBookmarksDir(),r.BOOKMARKS_FILENAME,t).then(()=>e(null),t=>e(c.getCommitError(t,null,"bookmarks could not be saved")))}_loadBookmarks(e){if(!o.hasFileSystem())return void e(null);const t=this._getBookmarksDir()+o.getPathSeparator()+r.BOOKMARKS_FILENAME;s.readJSONData(t).then(t=>{t&&(this._bookmarks=p(t.bookmarks),this._bookmarksEtag=t.etag,this._bookmarksBase=t.bookmarks_base&&p(t.bookmarks_base)),e(null)},t=>e(c.getCommitError(t,null,"bookmarks could not be loaded")))}_pullBookmarks(e){o.log("Pulling bookmarks");const t={};this._bookmarksEtag&&(t["If-None-Match"]=this._bookmarksEtag),this._service.invoke("GET",this._bookmarksURL,t,void 0,{responseType:"text"},(t,i)=>{if(t)return e(t);if(200===i.statusCode)try{const t=JSON.parse(i.response);this._syncModified=!0,e(null,p(t.bookmarks),i.headers.etag)}catch(t){e("Cannot parse data: "+i.response)}else 304===i.statusCode||404===i.statusCode?e(null,void 0,i.headers.etag):e("Unexpected response getting bookmarks: "+i.statusCode)})}_mergeBookmarks(e,t){o.log("Merging bookmarks"),e&&(this._bookmarksBase&&(e.forEach(t=>{const i=l(this._bookmarks,t.id),n=l(this._bookmarksBase,t.id);!i&&n&&e.splice(e.indexOf(t),1)}),this._bookmarks.forEach(t=>{const i=l(e,t.id),n=l(this._bookmarksBase,t.id);i||n||e.push(t)})),this._bookmarks=e),this._bookmarksEtag=t}_pushBookmarks(e){o.log("Pushing bookmarks");const t={"Content-Type":"application/json"};this._bookmarksEtag&&(t["If-Match"]=this._bookmarksEtag);const i=JSON.stringify({bookmarks:d(this._bookmarks)});this._service.invoke("PUT",this._bookmarksURL,t,i,void 0,(t,i)=>{if(t)return e(t);const n=i.statusCode;!i.headers.etag||200!==n&&201!==n&&204!==n?409===n||412===n?this._pullBookmarks((t,i,n)=>{if(t)return e(t);this._mergeBookmarks(i,n),this._pushBookmarks(e)}):e("Unexpected response updating bookmarks: "+n):e(null,i.headers.etag)})}_commit(e){o.log("Commiting bookmarks"),this._lock.obtain(()=>{this._saveBookmarks(t=>{this._lock.release(),t?this._collection._reportCommitError(t):e&&this.sync(e=>e&&this._collection._reportSyncError(e))})})}_sync(e){this._bookmarksBase?this._pushBookmarks((t,i)=>{if(t)return e(t);this._bookmarksEtag=i,this._bookmarksBase=void 0,this._commit(),e(null)}):this._pullBookmarks((t,i,n)=>{if(t)return e(t);i&&(this._bookmarks=i,this._bookmarksEtag=n,this._bookmarksBase=void 0,this._commit()),e(null)})}_createBase(){this._bookmarksBase||(this._bookmarksBase=this._bookmarks.slice())}load(e){o.log("Loading bookmarks"),this._lock.obtain(()=>{this._loadBookmarks(t=>{this._lock.release(),e(t)})})}sync(e){o.log("Syncing bookmarks"),this._lock.obtain(()=>{this._syncModified=!1,this._sync(t=>{if(this._lock.release(),t)return t=c.getSyncError(t,null),e(t);e(null),this._syncModified&&this._collection._notifyChange(!0)})})}createBookmark(e,t,i){r.SHARED_LOCAL_STORAGE?o.storageInterface.createBookmark(this._collection,e,t,i):(o.log("Creating bookmark: "+e+" url: "+t),this._lock.obtain(()=>{let o=l(this._bookmarks,e),a=!1;o||(this._createBase(),o=new n(e,t),this._bookmarks.push(o),a=!0),this._lock.release(),i(null,o,a),a&&(this._commit(r.SYNCING_ENABLED),this._collection._notifyChange(!0))}))}removeBookmark(e,t){r.SHARED_LOCAL_STORAGE?o.storageInterface.removeBookmark(this._collection,e,t):(o.log("Removing bookmark: "+e.id+" url: "+e.id),this._lock.obtain(()=>{(e=l(this._bookmarks,e.id))&&(this._createBase(),this._bookmarks.splice(this._bookmarks.indexOf(e),1)),this._lock.release(),t(null),e&&(this._commit(r.SYNCING_ENABLED),this._collection._notifyChange(!0))}))}getBookmarks(){return this._bookmarks.slice()}}},function(e,t,i){const n=i(0),o=i(2),r=i(1),a=i(5);e.exports=class{constructor(e){this._collection=e,this._listenerManager=new a(["change"]),this._fontsCache={}}_clearCache(){this._fontsCache={},this._listenerManager.notify("change")}addChangeListener(e){this._listenerManager.add("change",e)}removeChangeListener(e){this._listenerManager.remove("change",e)}getFontData(e,t){const i=this._fontsCache[e];i?t(null,i):n.SHARED_LOCAL_STORAGE?r.storageInterface.getFontData(this._collection,e,(i,n)=>{n&&(this._fontsCache[e]=n),t(i,n)}):this._collection._syncManager.typekit.getFontData([e],(i,n)=>{if(i)return void t(new o(o.NETWORK_ERROR,"Error occurred while getting font data",null,i));const r=n&&n[0];this._fontsCache[e]=r,t(null,r)})}isSystemFontAvailable(e,t,i){if(!n.SHARED_LOCAL_STORAGE)return i(new o(o.NOT_SUPPORTED,"isSystemFontAvailable() is only supported with shared local storage"));r.storageInterface.isFontAvailable(e,t,i)}}},function(e,t,i){const n=i(5);e.exports=class{constructor(){this._collections=[],this._listenerManager=new n(["change"])}getLibraryCollection(e,t){return this._collections.find(i=>!i.isPublic&&i.userId===e&&i.cloudId===t)}getPublicLibraryCollection(e){return this._collections.find(t=>t.isPublic&&t.cloudId===e)}addLibraryCollection(e){this._collections.push(e),this._listenerManager.notify("change")}removeLibraryCollection(e){e._dispose();var t=this._collections.indexOf(e);-1!==t&&(this._collections.splice(t,1),this._listenerManager.notify("change"))}removeAllLibraryCollections(){this._collections.forEach(e=>e._dispose()),this._collections=[],this._listenerManager.notify("change")}getLoadedCollections(){return this._collections}addLoadedCollectionsListener(e){this._listenerManager.add("change",e)}removeLoadedCollectionsListener(e){this._listenerManager.remove("change",e)}}},function(e,t,i){var n=i(26),o=i(36),r=i(56),a=i(61),s=i(44),c=i(60),l=i(2),d=i(0),p=i(1),h=i(62),_=i(111),u=i(112),f=i(15),m=i(29),E=i(7);const g=i(10).promisify;function y(e){this._collectionManager=e,this._acceptPushedBranchListeners=[],this._downloadRenditionListeners=[],this._rootListeners=[],this._baseBranches={},this._portDiagnosis="UNKNOWN",this._logIndex=0,d.SHARED_LOCAL_STORAGE&&(this._connect(),this.fs=new u(this),p.hasFileSystem()||p.setFileSystem(this.fs))}var v=function(e){var t={};return t.isPublic=e.isPublic,t.userId=e.userId,t.cloudId=e.cloudId,t},A=function(e,t){var i=v(e.collection);return i[t||"id"]=e.id,i},C=function(e,t,i){var n=A(e.library,i);return n[t||"element"]=e.id,n},I=function(e){var t=C(e.element);return t.representation=e.id,t};y.prototype._getBase=function(e){var t=this._baseBranches[e];return t&&t.base},y.prototype._setBase=function(e,t){this._baseBranches[e]=this._baseBranches[e]||{},this._baseBranches[e].base=t},y.prototype._getLogIndex=function(){return this._logIndex++},y.prototype._getServicePort=function(e){var t=d.VULCAN_PREFIX+d.VULCAN_QUERY_REQUEST,i=d.VULCAN_PREFIX+d.VULCAN_QUERY_RESPONSE;function n(t){var i;try{i=JSON.parse(t)}catch(e){}i?e(null,i):e("NO_DATA")}if(p.vulcanCall)p.vulcanCall(t,"",i,n);else if(p.hasCEPVulcan()){var o,r=p.getVulcanInterface(),a=p.getVulcanMessage(),s=function(t){r.removeMessageListener(i,s),clearTimeout(o),t?n(r.getPayload(t)):e("NO_VULCAN_MESSAGE")};r.addMessageListener(i,s),o=setTimeout(s,d.VULCAN_QUERY_TIMEOUT);var c=new a(t);c.setPayload(""),r.dispatchMessage(c)}},y.prototype._connectToPort=function(e,t){const i=t&&t.port,n=t&&t.token,o=t&&t.domain;if(this._portDiagnosis=t?t.portdiagnosis:"UNKNOWN",this._connectionPort=i,!this._channel&&i&&"SIMPLE_HOSTNAME_GOING_TO_PROXY"!==this._portDiagnosis){try{var r=new _(i,n,o);this._channel=new h(r)}catch(e){}this._channel&&(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._isConnected=!0,this._sendConfiguration()}),this._channel.onClose(this._onDisconnect.bind(this)),this._channel.onError(this._onDisconnect.bind(this)))}},y.prototype._connect=function(){this._getServicePort(this._connectToPort.bind(this))},y.prototype.shutdown=function(){this._onDisconnect()},y.prototype._onDisconnect=function(){this._channel&&(this._channel.shutdown(),this._channel=void 0),this._isConnected=!1,this._collectionManager.removeAllLibraryCollections()},y.prototype._sendConfiguration=function(){this._channel.send("configure",{CLIENT_DESCRIPTION:d.CLIENT_DESCRIPTION,RENDITION_SIZES:d.RENDITION_SIZES,FULL_RENDITION_CONFIG:d.FULL_RENDITION_CONFIG,LOCAL_SETTINGS:d.LOCAL_SETTINGS})},y.prototype._onEnvironmentInfo=function(e){this._serviceInfo=e,e.whitelistedDomains&&(d.WHITELISTED_DOMAINS=e.whitelistedDomains),e.elementActionProductMap&&m.updateElementActionMap(e.elementActionProductMap),e.deviceId&&(d.DEVICE_ID=e.deviceId),e.deviceDescription&&(d.DEVICE_DESCRIPTION=e.deviceDescription),e.maxElements&&(d.MAX_ELEMENTS=e.maxElements),e.maxRemovedElements&&(d.MAX_REMOVED_ELEMENTS=e.maxRemovedElements),e.maxComponentSize&&(d.MAX_COMPONENT_SIZE=e.maxComponentSize),e.localSettings&&(d.LOCAL_SETTINGS=Object.assign(e.localSettings,d.LOCAL_SETTINGS)),e.shaCache&&(d.SHA_CACHE=e.shaCache),e.defaultContentLocations&&(d.DEFAULT_CONTENT_LOCATIONS=e.defaultContentLocations),e.analyticsEnabled&&(d.ANALYTICS_ENABLED=e.analyticsEnabled),this._collectionManager._collections.forEach(e=>{e._listenerManager.notify("sync")})},y.prototype._onCollectionAdded=function(e){var t;d.ROOT_DIR=e.rootDir;var 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};t=e.isPublic?new a(i):new r(i);const n=g(this.loadExistingLibrary.bind(this));Promise.all(e.libraries.map(e=>n(t,e.id,e.path,e.manifest,e.deletedFromServer,e.renditionCache))).then(()=>this._collectionManager.addLibraryCollection(t))},y.prototype._getLibraryCollection=function(e){return e.isPublic?this._collectionManager.getPublicLibraryCollection(e.cloudId):this._collectionManager.getLibraryCollection(e.userId,e.cloudId)},y.prototype._onCollectionRemoved=function(e){var t=this._getLibraryCollection(e);t&&this._collectionManager.removeLibraryCollection(t)},y.prototype._onClearCollections=function(){this._collectionManager.removeAllLibraryCollections()},y.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(e=>{t._syncErrors.push(new l(e.code,e.message,e.libraryId))}),e.libraryStates.forEach(e=>{var i=t.getLibraryById(e.id);i&&(i._syncState=e.state)}),t._listenerManager.notify("sync"))},y.prototype._onLibraryChange=function(e){var t=this._getLibraryCollection(e);if(t){var i=t.getLibraryById(e.id);i?(p.log("onLibraryChange: "+i.id),i._deletedFromServer!==e.deletedFromServer&&(i._deletedFromServer=e.deletedFromServer,i._notifyChange()),e.renditionCache=e.renditionCache||{},i._renditionCache.replaceCache(e.renditionCache),this.updateExistingLibrary(t,i,e.manifest,void 0,this._getBase(i.id),()=>{i._renditionCache.replaceCache(e.renditionCache)})):this.loadExistingLibrary(t,e.id,e.path,e.manifest,e.deletedFromServer,e.renditionCache)}},y.prototype._onRenditionCacheChange=function(e){var t=this._getLibraryCollection(e),i=t&&t.getLibraryById(e.id),n=i&&i.getElementById(e.elementId);n&&e.renditionCache&&(i._renditionCache.replaceElementCache(n,e.renditionCache),n._listenerManager.notify("change"))},y.prototype._onOperationsChanged=function(e){var t=this._getLibraryCollection(e),i={};e.operations.forEach(e=>{t._updateOperation(e.id,e.type,e.data,e.progress),i[e.id]=!0}),Object.keys(t._operationIdMap).forEach(e=>{i[e]||t._delayedRemoveOperation(t._operationIdMap[e])})},y.prototype._onLibraryDeleted=function(e){var t=this._getLibraryCollection(e);t&&this._deleteLibrary(t,e.id)},y.prototype._onBookmarksChanged=function(e){var t=this._getLibraryCollection(e);if(t&&e.bookmarks){var i=[];e.bookmarks.forEach(e=>{i.push(new c(e._id,e._url))}),t._bookmarkManager._bookmarks=i}},y.prototype._onFontCacheChanged=function(e){var t=this._getLibraryCollection(e);t&&t.fontManager&&t.fontManager._clearCache()},y.prototype.isConnected=function(){return this._isConnected},y.prototype.reconnect=function(){this._channel||this._connect()},y.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}},y.prototype.updateConfiguration=function(){d.SHARED_LOCAL_STORAGE&&this._channel&&this._isConnected&&this._sendConfiguration()},y.prototype.sync=function(e){this._channel.send("sync",v(e))},y.prototype.setSyncEnabled=function(e){this._channel.send("configuresync",{enable:e})},y.prototype.commitManifest=function(e,t){if(d.SHARED_LOCAL_STORAGE){const i=e._dcxBranch.localData,n=e._renditionCache.doRequestSetCache(),o=A(e);o.current=i,o.base=this._getBase(e.id),o.renditions=n.data,p.log("Start commit"),this._channel.call("commit",o,r=>{if(p.log("Finish commit: "+(r.success?"success":"fail")),r.success){if(p.log("Update base after commit"),this._setBase(e.id,i),r.renditions){n.complete(r.renditions).forEach(e=>e._listenerManager.notify("change"))}}else n.cancel(),e._waitForCommit(()=>{this.notifyStartWrite(e,[],()=>{e._deletedFromServer=r.deletedFromServer,this.updateExistingLibrary(e.collection,e,r.manifest,void 0,o.base,function(){e._commit(!0,!0)})})});t(null,r.success)})}else e._dcxLock.obtain(()=>{e._gcLocalData(()=>{e._dcxComposite.commitChanges(i=>{e._dcxLock.release(),e._renditionCache.gc(),t(i,!0)})})})},y.prototype.resolvePullWithBranch=function(e,t,i,n,o){p.log("resolvePullWithBranch"),d.SHARED_LOCAL_STORAGE?(e._dcxComposite._current=t,this._setBase(e.id,i),p.log("Finished resolvePullWithBranch: shared local storage"),o()):n?e._dcxLock.obtain(()=>{e._dcxComposite._current=t,e._dcxLock.release(),p.log("Finished resolvePullWithBranch: local merge"),o()}):e._dcxLock.obtain(()=>{e._dcxComposite.resolvePullWithBranch(t,(t,i)=>{e._dcxLock.release(),e._commit(!0,!0),e._waitForCommit(()=>{p.log("Finished resolvePullWithBranch: remote merge"),o(t,i)})})})},y.prototype.acceptPush=function(e,t){p.log("acceptPush"),e._dcxLock.obtain(()=>{e._dcxComposite.acceptPush(i=>{e._dcxLock.release(),p.log("Finished acceptPush"),this._acceptPushedBranchListeners.forEach(t=>t(e)),t(i)})})},y.prototype.onAcceptPushedBranch=function(e){this._acceptPushedBranchListeners.push(e)},y.prototype.removeOnAcceptPushedBranchListeners=function(){this._acceptPushedBranchListeners=[]},y.prototype._deleteLibrary=function(e,t){p.log("deleteLibrary");var i=e.getLibraryById(t);if(i){var n=e._libraries.indexOf(i);-1!==n&&(e._libraries.splice(n,1),delete e._libraryIdMap[i.id]),i._markDeletedLocally(!0),e._notifyChange(!0)}},y.prototype._loadBranch=function(e,t,i){var n;try{(n=new o(void 0,i).parse(t))._localStorage=e._localStorage}catch(e){}return n},y.prototype._addLibrary=function(e,t,i,o,r){i=i||e._getCompositeDir(t);var a=new n(null,null,i,null,null,{preserveFileExtensions:!0}),c=this._loadBranch(a,o,!1);if(c)if("pendingDelete"!==c.compositeState){a._current=c,this._setBase(t,o);var d=new s(e,a,e.isPublic&&t);e._libraries.push(d),e._libraryIdMap[d.id]=d,e._notifyChange(!0),r(null,d)}else r(null);else r(new l(l.CORRUPTED_LIBRARY,"Library corrupted in local storage",t))},y.prototype.createNewLibrary=function(e,t,i,n=(()=>void 0)){p.log("createNewLibrary"),this._addLibrary(e,t,void 0,i,function(e,t){!e&&t?(t._commit(!1,!0),t._waitForCommit(n)):n(e)})},y.prototype.loadExistingLibrary=function(e,t,i,n,o,r,a=(()=>void 0)){p.log("loadExistingLibrary"),this._addLibrary(e,t,void 0,n,function(e,t){!e&&t?(t._deletedFromServer=o,r&&t._renditionCache.replaceCache(r),a(null,t)):a(e)})},y.prototype.updateExistingLibrary=function(e,t,i,n,o,r=(()=>void 0)){var a="updateExistingLibrary["+this._getLogIndex()+"]: ";if(f.areManifestsEqual(t._dcxBranch.localData,i))return p.log(a+"already up-to-date"),void r();var s=this._loadBranch(t._dcxComposite,i,!1);if(p.log(a+"changes to update (state = "+(s&&s.compositeState)+")"),s){var c=f.ensureBranchDataValid(s);p.log(a+"fixed branch data: "+c),"pendingDelete"===s.compositeState?(e._doRemoveLibrary(t),r()):t._waitForCommit(()=>{if(n){if(!f.areManifestsEqual(t._dcxBranch.localData,n))return p.log(a+"Commit aborting: something changed and it's no longer a fast-forward"),void r(!0)}else n=this._getBase(t.id);if(o&&n!==o)return p.log(a+"Commit aborting: base manifest changed before we got chance to update!"),void r(!0);var e=this._loadBranch(t._dcxComposite,n,!0)||s;p.log(a+"base "+e.changeCount+" -> updated "+s.changeCount),t._mergeAndSwitchToBranch(s,e,function(){p.log(a+"finished merge"),d.SHARED_LOCAL_STORAGE?r(null):(t._commit(!1,!0),t._waitForCommit(r))})})}else r(new l(l.CORRUPTED_LIBRARY,"Invalid manifest",t.id))},y.prototype.getRenditionPath=function(e,t,i=(()=>void 0),n=0){var o=e.library._renditionCache.getCache(e,t||"full");if(o)i(null,o);else{var r=C(e);r.size=t,p.log("Get rendition path from CCLibrary process"),this._channel.call("getrenditionpath",r,o=>{if(!o&&n<d.LOCAL_RENDITION_MAX_RETRIES)return p.log("getrenditionpath: rendition not found"),void setTimeout(()=>this.getRenditionPath(e,t,i,n+1),d.LOCAL_RENDITION_RETRY_INTERVAL);i(null,o)})}},y.prototype.notifyDownloadRendition=function(e){this._downloadRenditionListeners.forEach(t=>{t(e)}),e._listenerManager.notify("change")},y.prototype.onDownloadRendition=function(e){this._downloadRenditionListeners.push(e)},y.prototype.removeOnDownloadRenditionListeners=function(){this._downloadRenditionCacheListeners=[]},y.prototype.notifyStartWrite=function(e,t,i=(()=>void 0)){if(d.SHARED_LOCAL_STORAGE){var n=A(e);n.dependencies=[],t.forEach(e=>{n.dependencies.push(A(e))}),this._channel.call("startcomponentwrite",n,function(){i(null)})}else i(null)},y.prototype.loadPublicLibrary=function(e,t,i,n=(()=>void 0)){var o=v(e);o.id=t,o.url=i,this._channel.call("loadpubliclibrary",o,function(){n(null)})},y.prototype.unloadPublicLibrary=function(e,t=(()=>void 0)){var i=A(e);this._channel.call("unloadpubliclibrary",i,function(){t(null)})},y.prototype.downloadURL=function(e,t,i,n,o){if(d.SHARED_LOCAL_STORAGE){var r=v(e);r.url=t,r.headers=i,r.tempDir=n,this._channel.call("downloadfile",r,function(e){o(e.err,e.tempFilePath,e.etag,{headers:e.responseHeaders})})}else e._syncManager.links.download(t,i,n,void 0,o)},y.prototype.testURL=function(e,t,i){d.SHARED_LOCAL_STORAGE?i(null):e._syncManager.links.test(t,i)},y.prototype.downloadExternalLink=function(e,t){p.log("Download external link from CCLibrary process"),this._channel.call("downloadexternallink",I(e),function(e){t(e.err,e.path)})},y.prototype.testExternalLink=function(e,t){p.log("Test external link via CCLibrary process"),this._channel.call("testexternallink",I(e),function(e){t(e.err,e.success)})},y.prototype.clearCachedExternalLink=function(e){p.log("Clear cached external link via CCLibrary process"),this._channel.send("clearcachedexternallink",I(e))},y.prototype.createBookmark=function(e,t,i,n=(()=>void 0)){var o=v(e);o.id=t,o.url=i,this._channel.call("createBookmark",o,function(e){var t=e&&e.err,i=e&&e.bookmark;i&&(i=new c(i._id,i._url)),n(t,i)})},y.prototype.removeBookmark=function(e,t,i=(()=>void 0)){var n=v(e);n.id=t.id,this._channel.call("removeBookmark",n,function(e){i(e)})},y.prototype.sendElementAction=function(e,t=(()=>void 0)){var i=C(e.element,"elementId","libraryId");i.appCode=e.appCode,i.minVersion=e.minAppVersion,i.action=e.id,this._channel.call("performElementAction",i,function(e){t(e.err,e.data)})},y.prototype.getImageDimensions=function(e,t){this._channel.call("getImageDimensions",e,function(e){t(e.data)})},y.prototype.importLibrary=function(e,t,i,n=(()=>void 0)){var o=v(e);o.path=t,o.operationId=i,this._channel.call("importlibrary",o,function(t){n(t.err,e.getLibraryById(t.libraryId))})},y.prototype.exportLibrary=function(e,t,i,n=(()=>void 0)){var o=A(e);o.path=t,o.operationId=i,this._channel.call("exportlibrary",o,function(e){n(e.err)})},y.prototype.cancelOperation=function(e,t){var i=v(e);i.operationId=t,this._channel.send("canceloperation",i)},y.prototype.getFontData=function(e,t,i=(()=>void 0)){var n=v(e);n.fontId=t,this._channel.call("getfontdata",n,function(e){i(e.err,e.data)})},y.prototype.isFontAvailable=function(e,t,i=(()=>void 0)){const n={fontName:e,matchFamily:t};this._channel.call("isfontavailable",n,({err:e,data:t})=>i(e,t))},y.prototype.getAccessToken=function(e,t,i,n,o=(()=>void 0)){const r={userId:e,clientId:t,clientSecret:i,scopes:n};this._channel.call("getaccesstoken",r,({err:e,data:t})=>o(e,t))},y.prototype.computeSHA=function(e){return d.SHARED_LOCAL_STORAGE?new Promise((t,i)=>{this._channel.call("computesha",{path:e},({err:e,data:n})=>e?i(e):t(n))}):E.computeSHA(e)},Object.freeze(y),Object.seal(y.prototype),e.exports=y},function(e,t,i){const n=i(0),o=i(5);e.exports=class{constructor(e,t,i){let r=i?`wss://${i}:${e}`:`ws://127.0.0.1:${e}`;r+=`/?version=${n.SHARED_LOCAL_STORAGE_VERSION}`,t&&(r+=`&token=${t}`),this._socket=new WebSocket(r),this._socket.onopen=(()=>this._listenerManager.notify("open")),this._socket.onclose=(()=>this._listenerManager.notify("close")),this._socket.onmessage=(e=>this._listenerManager.notify("message",[e.data])),this._socket.onerror=(e=>this._listenerManager.notify("error",[e])),this._listenerManager=new o(["open","close","message","error"])}send(e){this._socket.send(e)}addListener(e,t){this._listenerManager.add(e,t)}removeListener(e,t){this._listenerManager.remove(e,t)}close(){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()}}},function(e,t,i){var n=i(2),o={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 r(e){this._storageInterface=e}r.prototype._fsCall=function(e,t,i=(()=>void 0)){var n={method:e,args:t};this._storageInterface._channel.call("fscall",n,function(e){i.apply(null,e)})},r.prototype._pipeCall=function(e,t,i,n=(()=>void 0)){var o={readStream:{path:e,options:t},writeStream:i};this._storageInterface._channel.call("fspipe",o,n)},Object.keys(o).forEach(e=>{r.prototype[e]=o[e]?function(){var t,i=Array.prototype.slice.call(arguments);"function"==typeof i[i.length-1]&&(t=i.pop()),this._fsCall(e,i,t)}:function(){var t=new n(n.NOT_IMPLEMENTED,e+" is not implemented in shared local storage"),i=arguments[arguments.length-1];if("function"!=typeof i)throw t;i(t)}}),r.prototype.createReadStream=function(e){var t={on:function(e,i){t[e]=i}};return t.pipe=((i,n)=>{this._pipeCall(e,n,i,e=>{t[e.event]&&t[e.event].apply(null,e.args)})}),t},r.prototype.createWriteStream=function(e,t){return{path:e,options:t}},Object.freeze(r),Object.seal(r.prototype),e.exports=r},function(e,t,i){const n=i(1),o=i(28),r=i(16),a=i(7);e.exports=class{static mimeTypeToExtensions(e){return o.getExtensions(e)}static extensionToMimeTypes(e){return o.getMimeTypes(e)}static canGenerateRenditionFromMimeType(e){return r.canComputeRenditionFromMimeType(e)}static generateUuid(){return n.uuid()}static copyFile(e,t,i,o){if(i)return a.copyFile(e,t,o);const r=n.getFileNameFromPath(t);a.getAvailablePath(t.substring(0,t.indexOf(r)),r,(t,i)=>t?o(t):a.copyFile(e,i,o))}static getFileSize(e,t){a.statFile(e,(e,i)=>{t(e,i&&i.size)})}}},function(e,t,i){const n=i(14);e.exports=class{static reportUseElement(e,t,i){n.reportUseElement(e,t,i)}static reportCheckoutElement(e,t,i){n.reportCheckoutElement(e,t,i)}static reportCreateLink(e,t){n.reportCreateLink(e,t)}static reportShareElementLink(e){n.reportShareElementLink(e)}static reportShareLibraryLink(e){n.reportShareLibraryLink(e)}}},function(e,t,i){var n=i(30),o=i(116),r=i(3),a={obtainProcessLock:function(e,t){var i=r.getValue("ROOT_DIR");n.ensureDir(i,function(n){if(n)return console.error("Error: Could not create root directory: "+i),void t(!1);var r=o.openSync(i+"."+e,"w");o.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=n.readdirSync(e);t&&t.forEach(t=>{if(-1!==t.indexOf(".TEMP_"))try{n.unlinkSync(e+"/"+t)}catch(e){}})}catch(e){}}};e.exports=a},function(e,t){e.exports=require("fs-ext")},function(e,t,i){var n,o=i(25),r=i(31),a=i(3),s=i(0),c=i(29),l=i(37),d={};d.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._renditionCache.serializeCache()}},d.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.library._renditionCache.serializeElementCache(e)}},d.getDeletedLibraryData=function(e,t){return{isPublic:e.isPublic,userId:e.userId,cloudId:e.cloudId,id:t}},d.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(e=>{t.libraryStates.push({id:e.id,state:e._syncState})}),e._syncErrors.forEach(e=>{t.errors.push({code:e.code,message:e._message,libraryId:e.libraryId})}),t},d.prepareErrorForSerialization=function(e,t){return t=t||[e],Object.keys(e).forEach(i=>{if("underlyingError"===i&&e.underlyingError)-1===t.indexOf(e.underlyingError)?e.underlyingError=d.prepareErrorForSerialization(e.underlyingError,t.concat([e.underlyingError])):delete e.underlyingError;else try{JSON.stringify(e[i])}catch(t){delete e[i]}}),e},d.getCollectionData=function(e){var t={rootDir:s.ROOT_DIR,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(e=>{t.libraries.push(d.getLibraryData(e))}),t},d.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}},d.getAPIVersion=function(){return s.SHARED_LOCAL_STORAGE_VERSION},d.getCodeVersion=function(e){var t=l.version;return e&&(t+="-29"),t},d.getDeviceDescription=function(e){if(!n||e){var t,i=o.platform(),a={darwin:"mac",win32:"win",win64:"win"}[i]||i;if("darwin"===i)try{t=r.execSync("sw_vers -productVersion",{timeout:1e3}).toString().trim()}catch(e){}else t=o.release();n=a,t&&(n+="-"+t)}return n},d.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:d.getAPIVersion(),codeVersion:d.getCodeVersion(),buildNumber:"29",environment:a.getEnvironment().LABEL,syncingEnabled:s.SYNCING_ENABLED,analyticsEnabled:s.ANALYTICS_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,shaCache:s.SHA_CACHE,defaultContentLocations:s.DEFAULT_CONTENT_LOCATIONS}},e.exports=d},function(e,t,i){var n=i(3),o=i(6),r=i(9),a=i(16),s=i(0),c={mergeRenditionSizes:function(e){return a.addToRenditionSizeConfig(e),n.setValue("RENDITION_SIZES",s.RENDITION_SIZES)},mergeFullRenditionConfig:function(e){return a.addToFullRenditionConfig(e),n.setValue("FULL_RENDITION_CONFIG",s.FULL_RENDITION_CONFIG)},mergeLocalSettings:function(e){return Object.assign(s.LOCAL_SETTINGS,e),n.setValue("LOCAL_SETTINGS",s.LOCAL_SETTINGS)},triggerRenditionPrefetch:function(){r.getLoadedCollections().forEach(e=>{e.libraries.forEach(e=>{a.prefetchRenditions(e)})})},findElement:function(e,t){e=e||"";var i=new RegExp("cloud-asset://(.+)/([A-Za-z0-9-]+);node=([A-Za-z0-9-]+)"),n=e.match(i);if(n){var o,a,s,l=n[1],d=n[2],p=n[3];r.getLoadedCollections().every(function(e){return l!==e._syncManager.getElementRefDomainPath()||(o=e,(a=e.getLibraryById(d))&&(s=a.getElementById(p)),!1)}),s?t(null,s):0===r.getLoadedCollections().length?t("NO_COLLECTIONS_PRESENT"):o?a?a.sync(function(){(s=a.getElementById(p))?t(null,s):"error"===o.syncState?t("COLLECTION_SYNC_ERROR"):t("ELEMENT_NOT_FOUND")}):o.sync(function(){(a=o.getLibraryById(d))?c.findElement(e,t):"error"===o.syncState?t("COLLECTION_SYNC_ERROR"):t("LIBRARY_NOT_FOUND")}):t("COLLECTION_NOT_FOUND")}else t("UNPARSABLE_ELEMENT_REF")},fixRenditions:function(e){const t=e&&e.filter(e=>!e.isPublic)[0],i=t&&t.userId;if(!i)return;const r="VALIDATE_RENDITIONS_"+i;if(n.getValue(r))return;n.setValue(r,!0);const a=n.getValue("VALIDATE_RENDITIONS_SIZE_THRESHOLD");o.log("VALIDATE_RENDITIONS","Rendition invalidation check starting"),e.forEach(e=>{e.libraries.forEach(e=>{let t=!1;e.elements.forEach(i=>{const n=e._renditionCache.checkAndInvalidateRenditions(i,a);n&&(o.log("VALIDATE_RENDITIONS",n),t=!0)}),t&&(e._commit(!0,!0),e._notifyChange())})}),o.log("VALIDATE_RENDITIONS","Rendition invalidation check ending")}};e.exports=c},function(e,t,i){var n,o,r,a=i(32),s=i(3),c=i(6),l=i(63),d=i(17),p=i(9),h=i(47),_=i(122),u=i(0),f=i(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);d.sendMessage(o?u.VULCAN_LIBRARY_CHANGED_LOCAL_TYPE:u.VULCAN_LIBRARY_CHANGED_REMOTE_TYPE,e),v={},o=null}}function R(e,t,i){0!==Object.keys(v).length&&(v[e]||o!==i)&&O(),v[e]=t,o=i}function T(e,t,i){C(),c.log(m,"Saving lookup file"),e.userId=a.getUserId(),_.saveLookupMap(g,e,function(o){if(o)return c.log(m,o.toString()),n=null,void i();n=e,C(),r=setTimeout(function(){r=null,n=null,c.log(m,"Released lookup file")},s.getValue("PRODUCT_BRIDGE_INMEMORY_LIFETIME")),t?d.sendMessage(u.VULCAN_COLLECTIONS_LOADED_TYPE):L()||O(),c.log(m,"Lookup file saved"),c.log(m,"Lookup library count: "+Object.keys(n.libraries).length),i()})}function N(e){if(n)return e(n);c.log(m,"Reading lookup file"),_.readLookupMap(g,function(t,i){if(t)return c.log(m,t),void e(null);c.log(m,"Lookup file read"),e(n=i)})}function D(e,t,i){c.log(m,"Update Callback Received"),I(function(){N(function(n){if(!n)return S(),void A.collectionsLoaded();var o=e&&e.library,r=o&&n.libraries[o.id];if(r){var a=r.elements[e.id];if(a&&_.updateElementLookupData(a,t)){a.mod=_.getElementModifiedTime(e);var s={name:o.name,domain:o._collection._syncManager.getElementRefDomain(),path:o._collection._syncManager.getElementRefPath(),elements:{}};return s.elements[e.id]=a,R(o.id,s,i),void T(n,!1,function(){S()})}}L()||O(),S()})})}A.collectionsLoaded=function(){c.log(m,"Collections Loaded"),I(function(){v={},o=null;var e=p.getLoadedCollections(),t={elementTypes:s.getValue("PRODUCT_BRIDGE_ELEMENT_TYPES")||[],libraries:{}};e&&e.forEach(e=>{e.libraries.forEach(e=>{t.libraries[e.id]=_.buildLibraryLookupData(e,D)})}),T(t,!0,function(){S()})})},A.collectionsUnloaded=function(){c.log(m,"Collections Unloaded"),I(function(){!function(e){C(),c.log(m,"Deleting lookup file"),_.deleteLookupMap(g,function(t){t&&c.log(m,t.toString()),n=null,c.log(m,"Lookup file deleted"),e()})}(function(){d.sendMessage(u.VULCAN_COLLECTIONS_UNLOADED_TYPE),S()})})},A.libraryChanged=function(e,t){c.log(m,"Library Changed - "+(t?"Local":"Remote")+": "+e.id),I(function(){N(function(i){if(!i)return S(),void A.collectionsLoaded();var n,o=i.libraries[e.id],r=!1,a=function(e,i){D(e,i,t)};if(o){n={elements:{}},o.name!==e.name&&(o.name=e.name,r=!0);var s=[];e.elements.forEach(e=>{if(_.shouldIncludeInLookupData(e)){var t,i,c,l=o.elements[e.id];if(!(i=(i=!l||l.mod!==_.getElementModifiedTime(e))||!l||l.stockLicense!==h.getElementStockLicense(e)))l.reps.forEach(e=>{e.path||(c=c||[]).push(e.id)}),c&&(i=(t=_.buildElementLookupData(e,a)).reps.some(function(e){return e.path&&c.indexOf(e.id)>-1}));i&&(t=t||_.buildElementLookupData(e,a),n.elements[e.id]=t,o.elements[e.id]=t,r=!0),s.push(e.id)}}),Object.keys(o.elements).forEach(e=>{-1===s.indexOf(e)&&(n.elements[e]=null,delete o.elements[e],r=!0)})}else{var c=_.buildLibraryLookupData(e,a);n=c,i.libraries[e.id]=c,r=!0}if(!r)return L()||O(),void S();n.name=e.name,n.domain=e._collection._syncManager.getElementRefDomain(),n.path=e._collection._syncManager.getElementRefPath(),R(e.id,n,t),T(i,!1,function(){S()})})})},A.libraryDeleted=function(e){c.log(m,"Library Deleted: "+e),I(function(){O(),N(function(t){if(!t)return S(),void A.collectionsLoaded();delete t.libraries[e],T(t,!1,function(){S(),d.sendMessage(u.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,i){var n=i(19),o=i(3),r=i(47),a=i(1),s=i(16),c={normalizePath:function(e){return o.isPlatformWindows()&&e?e.replace(/\//g,"\\"):e},getElementModifiedTime:function(e){let t=!1;return e._forEachRepresentation(function(e){!e.isExternalLink||e.getCachedContentPath()||e.getCachedExternalLinkError()||(t=!0)}),t?e.modified-1:e.modified},updateElementLookupData:function(e,t){var i=!1;return Array.isArray(t.reps)&&t.reps.forEach(t=>{i=e.reps.some(function(i,n){if(i.id===t.id&&i.path!==t.path)return e.reps[n]=t,!0})||i}),void 0!==t.stockLicense&&t.stockLicense!==e.stockLicense&&(i=!0,e.stockLicense=t.stockLicense,null===e.stockLicense&&delete e.stockLicense),i},buildElementLookupData:function(e,t){var i=e.modified,n={name:e.name,type:o.getValue("PRODUCT_BRIDGE_ELEMENT_TYPES").indexOf(e.type),mod:c.getElementModifiedTime(e),reps:[]},a=r.getElementStockId(e),l=r.getElementStockLicense(e);if(a&&(n.stockId=a),l&&(n.stockLicense=l),e.wasModifiedLocally&&(n.local=!0),e.representations.forEach(o=>{var a=!o.isExternalLink||s.shouldPrefetchExternalLink(o);if(o.isCompatibleType(o.type)&&a){const a={id:o.id};"primary"===o.relationship?n.reps.unshift(a):n.reps.push(a);const s=o.getCachedContentPath(),d=o.isExternalLink&&o.getCachedExternalLinkError();if(s||d)return a.type=o.type,void(s&&(a.path=c.normalizePath(s)));o.getContentPath((a,s)=>{if(s){var d={reps:[{id:o.id,type:o.type,path:c.normalizePath(s)}]};(l=r.getElementStockLicense(e))&&(d.stockLicense=l),i===e.modified&&t(e,d)}else o.isExternalLink&&r.getElementStockLicense(e)!==n.stockLicense&&t(e,{stockLicense:r.getElementStockLicense(e)||null})})}else o.isCompatibleType(o.type)&&o.isExternalLink&&o.testExternalLink(function(){r.getElementStockLicense(e)!==n.stockLicense&&t(e,{stockLicense:r.getElementStockLicense(e)||null})})}),s.shouldPrefetchFullRendition(e)){n.reps.push({id:"FULL_RENDITION"});var d=!0;e.getThumbnailPath(void 0,function(o,r){if(r){var a={id:"FULL_RENDITION",type:"image/png",path:c.normalizePath(r)};d?c.updateElementLookupData(n,{reps:[a]}):i===e.modified&&t(e,{reps:[a]})}}),d=!1}return n},buildLibraryLookupData:function(e,t){var i={name:e.name,domain:e._collection._syncManager.getElementRefDomain(),path:e._collection._syncManager.getElementRefPath(),elements:{}};return e.elements.forEach(e=>{c.shouldIncludeInLookupData(e)&&(i.elements[e.id]=c.buildElementLookupData(e,t))}),i},saveLookupMap:function(e,t,i){var o=e+".TEMP_"+a.uuid();n.writeFile(o,JSON.stringify(t),function(t){t?i(t):n.rename(o,e,function(e){i(e)})})},readLookupMap:function(e,t){n.exists(e,function(i){i?n.readFile(e,"utf8",function(e,i){try{i=i&&JSON.parse(i)}catch(t){i=void 0,e=t}t(e,i)}):t(null)})},deleteLookupMap:function(e,t){n.exists(e,function(i){i?n.unlink(e,function(e){t(e)}):t(null)})},shouldIncludeInLookupData:function(e){return-1!==(o.getValue("PRODUCT_BRIDGE_ELEMENT_TYPES")||[]).indexOf(e.type)}};e.exports=c},function(e,t,i){var n,o=i(3),r=i(17),a=i(23),s=i(125),c=i(0);r.addListener(c.VULCAN_SHUTDOWN_REQUEST,function(){n?n():process.exit(0)}),r.addListener(c.VULCAN_QUERY_REQUEST,function(e,t,i){s.perform(function(e){var n={port:o.getValue("SERVICE_PORT"),token:o.getValue("SERVICE_TOKEN")};e&&(n.portdiagnosis=e),o.setValue("SERVICE_LAST_QUERY_TIME",(new Date).valueOf()),r.sendMessage(c.VULCAN_QUERY_RESPONSE,JSON.stringify(n),t,i)})}),r.addListener(c.VULCAN_PROXY_QUERY_REQUEST,function(e,t,i){var n={};try{n=JSON.parse(e)}catch(e){}var o={requestId:n.requestId};if(!n.url||"string"!=typeof n.url)return o.err="url parameter must be specified, and must be a string",void r.sendMessage(c.VULCAN_PROXY_QUERY_RESPONSE,JSON.stringify(o),t,i);a.getProxyForURL(n.url,function(e,n){if(e)o.err=e;else{var s=a.getProxyCredentials();o.proxyHost=n.hostname,o.proxyPort=n.port,o.proxyUser=s.user,o.proxyPassword=s.password}r.sendMessage(c.VULCAN_PROXY_QUERY_RESPONSE,JSON.stringify(o),t,i)})}),a.addListener("change",function(){r.sendMessage(c.VULCAN_PROXY_CHANGE_MESSAGE,"","","")});var l={setShutdownListener:function(e){n=e},sendStartupMessage:function(){r.sendMessage(c.VULCAN_STARTUP_MESSAGE,"","","")}};e.exports=l},function(e,t){e.exports=require("node-ProxyResolver")},function(e,t,i){var n=i(126),o=i(3),r=i(38),a=i(6),s=i(23),c=i(42),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 d(){return new Promise(function(e,t){var i=c.format({protocol:"ws",host:"localhost:"+o.getValue("SERVICE_PORT")+"/",slashes:!0,query:{diagnostics:!0,token:o.getValue("SERVICE_TOKEN")}}),n=new r(i,{origin:"file://"});n.on("error",function(e){t(l.COULD_NOT_CONNECT_SOCKET,e)}),n.on("open",function(){n.close(),e()})})}function p(){return new Promise(function(e,t){s.isLocalhostProxied(function(i,n){!0===n?t(l.SIMPLE_HOSTNAME_GOING_TO_PROXY):e()})})}e.exports.perform=function(e){new Promise(function(e,t){n.lookup("localhost",function(i,n){"127.0.0.1"!==n?(a.log("DIAGNOSTICS","Expected localhost to resolve to 127.0.0.1, but instead it resolved to "+n),t(l.DNS_RESOLUTION_FAILED,i,n)):e()})}).then(p).then(d).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,i){var n=i(17),o=i(6),r=i(22),a=i(3),s=i(24),c=i(23),l=i(5),d=i(1),p="Thor";function h(e,t){var i=null;if(e){var n=new RegExp("<"+t+"[^<>]*>([^<>]*)</"+t+">",""),o=e.match(n);i=o&&o[1]}return i}function _(e){return e.replace("{{uuid}}",d.uuid())}function u(e){const t=r.parseXML(e),i=t&&t["feature-response"]&&t["feature-response"]["feature-entry"];if(!i)return o.log(p,`Failed to parse user feature XML: ${e}`),!1;const n=i.find(e=>e&&e.$&&"com.adobe.oobe.acc.v1.piip.user.status"===e.$.id),a=n&&n.$&&n.$.state;return o.log(p,`Obtained analytics state from Thor: ${a}`),"OptedIn"===a}var f=new l(["signIn","signOut","proxySettingsChanged","installApplication","uninstallApplication","updateApplication","analyticsStateChanged"]);n.addListener("accc.localapps.panel.refresh.ssoevent",function(e){var t=h(e,"event_type");o.log(p,"ACCC Sign-on State: "+t),"signin_success"===t?f.notify("signIn"):"signout_success"===t&&f.notify("signOut")}),n.addListener("com.adobe.aam.AAMIMSStatus",function(e){var t=h(e,"Status");o.log(p,"AAM Sign-on State: "+t),"USER_AUTH_SUCCESS"===t&&f.notify("signIn")}),n.addListener("com.adobe.aam.AAMSIGNOUTStatus",function(){o.log(p,"AAM Sign-on State: signOut"),f.notify("signOut")}),n.addListener("any.accc.app.ProductDeploymentEvent",function(e){var t={productCode:function(e){var t=e;return"PHSP"===e&&(t="PHXS"),t}(h(e,"productCode")),productVersion:h(e,"productVersion"),productLanguage:h(e,"productLanguage"),countryCode:h(e,"countryCode"),subscriptionStatus:h(e,"subscriptionStatus")};switch(h(e,"eventType")){case"Install":f.notify("installApplication",[t]);break;case"Uninstall":f.notify("uninstallApplication",[t]);break;case"Update":f.notify("updateApplication",[t])}}),n.addListener("any.accc.app.ProxySettingsChanged",function(e){var t=h(e,"proxyuser"),i=h(e,"proxypassword");null!==t&&null!==i&&f.notify("proxySettingsChanged",[t,i])}),n.addListener("any.accc.app.UserContextData",e=>{const t=u(e);f.notify("analyticsStateChanged",[t])});var m={addListener:function(e,t){f.add(e,t)},removeListener:function(e,t){f.remove(e,t)},removeAllListeners:function(e){f.removeAll(e)},getProxyCredentials:function(e){c.getProxyForURL("https://adobe.com",function(t,i){if(i&&i.hostname){var o={requestType:"accc.app.ProxySettingsRequest",responseType:"accc.app.ProxySettingsResponse",payload:_('<?xml version="1.0" encoding="utf-8"?><request><type>accc.app.ProxySettingsRequest</type><request_id>{{uuid}}</request_id></request>'),targetId:"ADCS",targetVersion:"",timeout:a.getValue("PROXY_REQUEST_TIMEOUT")};n.call(o,function(t,i){if(t)return s.reportError("GetProxySettingsError","timed out getting proxy settings from Thor"),void e(null,null);var n=h(i,"proxyuser"),o=h(i,"proxypassword");s.reportEvent("getProxySettings",{isAuthenticatingProxy:!!n}),e(n,o)})}else e(null,null)})},configureFileSyncing:function(e,t=(()=>void 0)){var i=function(){var i={requestType:"accc.files.setFilesSyncStatusRequest",responseType:"adbproduct.files.setFilesSyncStatusResponse",payload:_(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:a.getValue("CONFIGURE_SYNC_TIMEOUT")};n.call(i,function(e){e&&s.reportError("ConfigureFileSyncError","timed out turning on/off file sync via Thor"),t(e)})};n.isAppRunning("creativecloud")?i():n.launchApp("creativecloud",!1,"--showwindow=false",function(){setTimeout(i,a.getValue("THOR_LAUNCH_WAIT"))})},getAnalyticsState:function(e=(()=>void 0),t=0){const i={requestType:"accc.app.UserContextDataRequest",responseType:"adbproduct.app.UserContextDataResponse",payload:_('<?xml version="1.0" encoding="utf-8"?><request><request-id>{{uuid}}</request-id></request>'),targetId:"ADCS",targetVersion:"",timeout:a.getValue("ANALYTICS_STATE_REQUEST_TIMEOUT")};n.call(i,(i,n)=>{if(i)return o.log(p,"Error getting analytics opt-in state from Thor"),void(t<a.getValue("ANALYTICS_STATE_REQUEST_MAX_RETRIES")?setTimeout(()=>m.getAnalyticsState(e,t+1),a.getValue("ANALYTICS_STATE_REQUEST_RETRY_INTERVAL")):e(!1));const s=r.parseXML(n),c=s&&s.response;if(!c)return o.log(p,`Invalid analytics opt-in state response from Thor: ${n}`),void e(!1);const l=c.error&&c.error[0];if(l)return l&&l.$&&"SignInPending"===l.$.id?o.log(p,"User sign in pending. Analytics flag not received yet."):o.log(p,`Error fetching analytics opt-in state: ${JSON.stringify(l)}`),void e(!1);const d=u(c.UserfeatureXML&&c.UserfeatureXML[0]);f.notify("analyticsStateChanged",[d]),e(d)})}};e.exports=m},function(e,t,i){"use strict";function n(e,t){var i=e.toString();if(i.length<t){var n=[];n.length=t-i.length+1,i=n.join("0")+i}return i}function o(e,t){return Object.getOwnPropertyNames(t).forEach(function(i){if("object"==typeof t[i])"object"!=typeof e[i]&&(e[i]={}),o(e[i],t[i]);else{var n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,n)}}),e}function r(e,t,i){e.forEach(function(e){setTimeout(function(){e(t,i)})})}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 i=this;e=e||{},t=t||{};var n=function(e){throw i._log(e),new Error("ERROR: "+e)};this._queuedEvents=[],this._queuedCallbacks=[],this._lastSendTime=0,this._isEnabled=!1,this._dependencies=o({},e),e.getAccessToken&&"function"==typeof e.getAccessToken||n("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]||n("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(),i=n(e.getMonth()+1,2),o=n(e.getDate(),2),r=n(e.getHours(),2),a=n(e.getMinutes(),2),s=n(e.getSeconds(),2),c=n(e.getMilliseconds(),3),l=e.getTimezoneOffset(),d=l<0?"+":"-",p=Math.floor(Math.abs(l)/60),h=Math.abs(l)%60;return t+"-"+i+"-"+o+"T"+r+":"+a+":"+s+"."+c+(d+n(p,2)+n(h,2))},l.prototype._updateDebounce=function(e){var t=e&&(e["retry-after"]||e["Retry-After"]),i=0;if(t){var n;try{n=parseInt(t,10)}catch(e){}if(n)i=Math.max(0,n);else{var o=Date.parse(t);if(o){var r=(new Date).valueOf();i=Math.max(0,o-r)/1e3+Math.floor(10*Math.random())}}}this._options.ANALYTICS_DEBOUNCE=Math.max(1e3*i,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 i=e;if(e&&e.length>t&&t>0){var n=e.length-t;i=e.slice(n,e.length)}return i}(this._queuedEvents,this._options.ANALYTICS_MAX_QUEUED_EVENTS)},l.prototype._sendAnalytics=function(e,t,n){var a=this;if(n=n||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 d=function(){var e=function(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)};return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()}(),p="["+d+"] ",h={events:this._sendingEvents},_=function(e){var t=a._queuedEvents?a._queuedEvents.length:0;if(a._sendingEvents){var i=a._sendingEvents.length;e?(a._requeueEvents(a._sendingEvents),a._log(p+"Error sending "+i+" events: "+e)):a._log(p+"Success sending "+i+" events: "+JSON.stringify(a._sendingEvents)),delete a._sendingEvents;var n=a._sendingCallbacks;delete a._sendingCallbacks,e?r(n,e):r(n,null,i)}t>0&&a._sendAnalytics()},u=function(e,t){if(a._updateDebounce(t),401===e&&0===n)return a._clearAccessToken(),a._requeueEvents(a._sendingEvents),delete a._sendingEvents,a._queuedCallbacks=a._sendingCallbacks.concat(a._queuedCallbacks),delete a._sendingCallbacks,a._log(p+"Access token is expired. Retry one more time."),void a._sendAnalytics(!0,void 0,n+1);200===e?_():_(new Error("Unexpected Response: "+e))};this._getAccessToken(function(e,t){if(!e||a._options.ALLOW_NO_TOKEN)if(t&&0!==t.length||a._options.ALLOW_NO_TOKEN){var n="https://"+a._getAnalyticsHost();if(a._log(p+"Sending analytics to "+n+"/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":d,"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(n,function(e,t){t&&t.agent?s.agent=t&&t.agent:o(s,t||{});var n=i(27).request(s,function(e){e&&function(e){var t=function(){};e.on("data",t),e.on("end",t)}(e);var t=e&&e.statusCode,i=e&&e.headers;u(t,i)});n.once("error",function(e){_(e)}),n.end(JSON.stringify(h))})}else{!function(e){var i=new XMLHttpRequest;i.onreadystatechange=function(){if(4===this.readyState){var e=i.getAllResponseHeaders();u(this.status,e)}},i.onerror=function(e){_(new Error(e))},i.open("POST",n+"/ingest",!0),i.setRequestHeader("x-api-key",a._options.ANALYTICS_API_KEY),i.setRequestHeader("x-user-region",a._options.ANALYTICS_USER_REGION),i.setRequestHeader("Content-Type","application/json"),t&&i.setRequestHeader("Authorization","Bearer "+t),i.setRequestHeader("X-Product",a._options.ANALYTICS_X_PRODUCT),i.setRequestHeader("X-Product-Location",a._options.ANALYTICS_X_PRODUCT_LOCATION),i.setRequestHeader("X-Request-Id",d),i.send(e)}(JSON.stringify(h))}}else _(new Error("No access token"));else _(e)})}}},l.prototype.enable=function(e){this._isEnabled=e,e&&this._sendAnalytics(!0)},l.prototype.postEvent=function(e,t,i){var n=i||{},o="event.dts_start",a="event.coll_dts",s=n.TIMESTAMP_PROPERTY_NAME||this._options.TIMESTAMP_PROPERTY_NAME,c=n.ANALYTICS_PROJECT||this._options.ANALYTICS_PROJECT,l=n.ANALYTICS_INGEST_TYPE||this._options.ANALYTICS_INGEST_TYPE;e[a]&&e[a]instanceof Date&&(e[a]=this._formatTimestamp(e[a])),e[o]&&e[o]instanceof Date&&(e[o]=this._formatTimestamp(e[o])),e[s]||(e[s]=this._formatTimestamp(new Date)),e[s]instanceof Date&&(e[s]=this._formatTimestamp(e[s]));var d={time:e[s],project:c,environment:this._getEnvironment(),ingesttype:l,data:e};e.simulate?(this._log("event sim:"+JSON.stringify(d)),t&&r([t],null,0)):(this._queueEvent(d),this._sendAnalytics(!1,t))},l.prototype.flush=function(e,t){this._sendAnalytics(e,t)},e.exports=l},function(e,t,i){var n,o,r,a=i(17),s=i(6),c=i(22),l=i(3),d=i(9),p=i(5),h=i(1),_=i(0),u={job:"files"},f={filterjob:"files",observe:{attrs:'type="sync.out.notify.job.status"'}},m={changemonitor:"cclibraries"},E={changemonitor:"cclibraries",pathprefix:[_.STORAGE_ASSETS_PATH+_.LIBRARY_SYNC_GROUP,_.BOOKMARKS_MONITOR_PATH]},g={filterchangemonitor:"cclibraries"},y=new RegExp(".*/([^/]+)/manifest$"),v=new RegExp(".*/([^/]+)$"),A=function(e){var t=c.parseXML(e,function(e){s.log("CoreSyncNotifications",e)}),i=t&&t.message||{};Object.keys(i).forEach(e=>{i[e]=i[e][0]});var n=i.events&&i.events.event;n&&(i.events=[],n.forEach(e=>{i.events.push(e.$)}));var o=i.errors&&i.errors.error;return o&&(delete i.errors,i.numErrors=o.length,i.firstError=o[0]&&o[0].$),i},C=function(e,t,i,n,o){o=o||0;var r=h.uuid(),c="sync.in.request."+t,d="sync.out.response."+t,p=JSON.parse(JSON.stringify(i));e&&(p.userid=e.userId,p.cloudid=function(e){return e===_.DEFAULT_CLOUD_ID?_.DEFAULT_CORESYNC_CLOUD_ID:e}(e.cloudId)),p.requestid=r,p.type=c;var u={requestType:c,responseType:d,payload:function(e){var t="";return Object.keys(e).forEach(i=>{var n=e[i];n.attrs?t+="<"+i+" "+n.attrs+" />":Array.isArray(n)?n.forEach(e=>{t+="<"+i+">"+e+"</"+i+">"}):t+="<"+i+">"+n+"</"+i+">"}),'<?xml version="1.0" encoding="utf-8"?><message>'+t+"</message>"}(p),targetId:"CORS",targetVersion:"",timeout:l.getValue("CORE_SYNC_REQUEST_TIMEOUT")};a.call(u,function(a,c){if(a)o<l.getValue("CORE_SYNC_NUM_RETRIES")?C(e,t,i,n,o+1):n(a);else{var d=A(c);if(!d||d.requestid!==r)return!1;s.log("CoreSyncNotifications",t+":\n"+JSON.stringify(d,void 0,2)),n(null,d)}})},I=new p(["libraryChange","bookmarkChange","fileSyncState"]),S={},L=!0,O=function(){o=void 0,n=void 0,S={}},R=function(e){return e.userId+"/"+e.cloudId},T=function(e,t){var i=!!t&&void 0===t.status;o=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),I.notify("fileSyncState",[o,i])},N=function(e,t){C(e,"changemonitor.enable",m,function(e,i){if(e)t(e);else{var n=i&&i.status;"success"===n?t(null):(s.log("CoreSyncNotifications","Error enabling changemonitor: "+n),t("enable_error"))}})},D=function(e,t){C(void 0,"observer.create",e,function(e,i){if(e)t(e);else{var n=i&&i.status;"success"===n?t(null,i.observerid):(s.log("CoreSyncNotifications","Error creating observer: "+n),t("create_error"))}})},b=function(e,t){!function(e,t){C(e,"changemonitor.getstatus",m,function(i,n){if(i)t(i);else{var o=n&&n.status;if("does_not_exist"===o){var r=Object.assign({},E);e.cloudId!==_.DEFAULT_CLOUD_ID&&(r.syncurl=e.syncurl),C(e,"changemonitor.create",r,function(i,n){i?t(i):"success"===(o=n&&n.status)?N(e,t):(s.log("CoreSyncNotifications","Error creating changemonitor: "+o),t("create_error"))})}else"success"===o?"active"===n.majorstate?t(null):N(e,t):(s.log("CoreSyncNotifications","Unexpected changemonitor status: "+o),t("status_error"))}})}(e,function(i){i?t(i):(e.isEnabled=!0,e.observerId?t(null):D(g,function(i,n){i?t(i):(e.observerId=n,t(null))}))})},P=function(e,t){!function(e,t){C(void 0,"observer.destroy",{observerid:e},function(e,i){if(e)t(e);else{var n=i&&i.status;"success"===n?t(null):(s.log("CoreSyncNotifications","Error destroying observer: "+n),t("destroy_error"))}})}(e.observerId,function(){delete e.observerId,function(e,t){C(e,"changemonitor.destroy",m,function(e,i){if(e)t(e);else{var n=i&&i.status;"success"===n?t(null):(s.log("CoreSyncNotifications","Error destroying changemonitor: "+n),t("destroy_error"))}})}(e,t)})},w=[],x=function(e=(()=>void 0),t=0){if(w.push(e),w.length>1)return;var i=function(e){var i=w;w=[],i.forEach(t=>{t(e)}),e?e&&!r&&t<l.getValue("CORE_SYNC_NUM_RETRIES")&&(r=setTimeout(function(){x(void 0,t+1)},l.getValue("CORE_SYNC_REQUEST_TIMEOUT"))):clearTimeout(r)};if(!L)return O(),void i(null);const a=[];if(Object.keys(S).forEach(e=>{var t=S[e];d.getLoadedCollectionById(t.userId,t.cloudId)||(delete S[e],a.push(e=>P(t,e)))}),d.getLoadedCollections().forEach(e=>{if(!e.isPublic){var t=R(e);if(S[t])S[t].isEnabled?"stopped"===S[t].state&&"normal"===o&&a.push(e=>b(S[t],e)):a.push(e=>b(S[t],e));else{var i={userId:e.userId,cloudId:e.cloudId,syncurl:e.cloudInfo&&e.cloudInfo.syncURI};a.push(e=>{b(i,function(n){n||(S[t]=i),e(n)})})}}}),!n){a.push(e=>{D(f,function(t,i){t?e(t):(n=i,e(null))})});var s=d.getLoadedCollections()[0];s&&a.push(e=>(function(e,t){C(e,"job.getstatus",u,function(e,i){T(e,i),t(e)})})(s,e))}Promise.all(a.map(e=>new Promise((t,i)=>e(e=>e?i(e):t())))).then(()=>i(null),i)};d.addLoadedCollectionsListener(x),a.addListener("sync.out.broadcast.app.startedup",function(){O(),L=!0,x()}),a.addListener("sync.out.broadcast.app.shuttingdown",function(){I.notify("fileSyncState",["shutdown",!0]),L=!1,x()}),a.addListener("sync.out.notify.job.status",function(e){var t=A(e);s.log("CoreSyncNotifications","sync.out.notify.job.status:\n"+JSON.stringify(t,void 0,2)),T(null,t),x()}),a.addListener("sync.out.notify.changemonitor.status",function(e){var t=A(e);s.log("CoreSyncNotifications","sync.out.notify.changemonitor.status:\n"+JSON.stringify(t,void 0,2));var i=R({userId:t.userid,cloudId:function(e){return e===_.DEFAULT_CORESYNC_CLOUD_ID?_.DEFAULT_CLOUD_ID:e}(t.cloudid)});S[i]&&(S[i].state=t.majorstate,"disabled"===t.majorstate&&(s.log("CoreSyncNotifications","Change monitor was disabled - need to re-enable"),S[i].isEnabled=!1,x()))}),a.addListener("sync.out.notify.changemonitor.pathevent",function(e){var t={},i=!1;const n=A(e).events||[],o={};n.forEach(e=>{e&&(o[e.type]=o[e.type]||0,o[e.type]++)});const r=Object.keys(o).map(e=>`${e}: ${o[e]}`).join(", ");s.log("CoreSyncNotifications",`sync.out.notify.changemonitor.pathevent: ${r||"no events"}`),n.forEach(e=>{if(e)if(e.path!==_.BOOKMARKS_MONITOR_PATH){var n=e.path&&e.path.match(y);if(n)t[n[1]]=!0;else{var o=e.path&&e.path.match(v);"deleted"===e.type&&"folder"===e.file_type&&o&&(t[o[1]]=!0)}}else i=!0});var a=Object.keys(t);a.length>0&&(s.log("CoreSyncNotifications","Report library change"),I.notify("libraryChange",[a])),i&&(s.log("CoreSyncNotifications","Report bookmark change"),I.notify("bookmarkChange",[]))});var k={addListener:function(e,t){I.add(e,t)},removeListener:function(e,t){I.remove(e,t)},removeAllListeners:function(e){I.removeAll(e)},ping:function(e){x(e)}};e.exports=k},function(e,t,i){var n=i(17),o=i(3),r=i(6),a=i(22),s=i(24),c=i(5),l=i(10),d=i(1),p={"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"]},h=function(){var e=[];return Object.keys(p).forEach(t=>{e=e.concat(p[t])}),e}(),_=new c(h),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]||[]};n.addListener("cclibraries.notification.ans",function(e){var t=u(e),i=t&&t["notifications-signal"],a=i&&i["notification-signal"];a&&a.forEach(e=>{var t=e.$&&e.$["sub-type"];if(r.log("ANS","Received notification: "+t),-1!==h.indexOf(t)){var i=[];m(e,"notification-info").forEach(e=>{var t=f(e,"notification-ids"),n=m(t,"notification-id");i=i.concat(n)}),function(e,t){var i=d.uuid(),a="";e.forEach(e=>{a+="<notification-id>"+e+"</notification-id>"});var c={NOTIFICATION_IDS:a,REQUEST_ID:i,REQUEST_NAMESPACE:"cclibraries.notification.ans.byID.data"},p={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:o.getValue("GET_NOTIFICATION_TIMEOUT")};n.call(p,function(e,n){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 o=[];if(n){var a=u(n),c=a&&a.notifications;if(f(c,"request-context")!==i)return!1;m(c,"notification").forEach(e=>{var t=f(e,"notification-id"),i=f(e,"payload");try{i=i&&JSON.parse(i)}catch(t){r.log("ANS","Failed to parse ANS payload: "+e.payload),s.reportError("ANS","Failed to parse ANS payload: "+e.payload)}o.push({id:t,payload:i,state:f(e,"state"),created:parseInt(f(e,"timestamp"),10),modified:parseInt(f(e,"modifiedTimeStamp"),10)})})}t(null,o)})}(i,function(e,i){e||i.forEach(e=>{_.notify(t,[e])})})}})});var E={};E.EVENTS=p,E.addListener=function(e,t){_.hasListeners(e)||function(e){var t;Object.keys(p).some(function(i){if(p[i].includes(e))return t=i,!0});var i={NOTIFICATION_TYPE:t,NOTIFICATION_SUB_TYPE:e,OBSERVER_NAMESPACE:"cclibraries.notification.ans"};n.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>',i),"ADCS","")}(e),_.add(e,t)},E.removeListener=function(e,t){_.remove(e,t)},E.removeAllListeners=function(e){_.removeAll(e)},E.setState=function(e){var t={NOTIFICATION_ID:e.id,STATE:e.state};n.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,i){var n=i(3),o=i(5),r=i(1),a=i(39),s=i(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,i){if(e)t("Error parsing XML response: "+e);else{var n=i&&i.response&&i.response.clouds&&i.response.clouds[0],o=(n=n||i&&i.message&&i.message.clouds&&i.message.clouds[0])&&n.$&&n.$.activeCloud,r=n&&n.$&&n.$.trueCloudCount&&parseInt(n.$.trueCloudCount,10),a=n&&n._;if(o){var s=[];if(a)try{var c=new Buffer(a,"base64");s=JSON.parse(c.toString())}catch(e){}t(null,s,o,r)}else t("Invalid response from any.app.GetActiveCloudResponse")}})}var d=new o(["cloudChange"]);s.addListener(c.Ipc.UpdateActiveCloud,function(e){l(e,function(e,t,i,n){var o;e?d.notify("cloudChange",[e]):(t.forEach(e=>{e.id===i&&(o=e)}),d.notify("cloudChange",[e,o,n]))})});var p={};p.getClouds=function(e){var t,i=setTimeout(function(){s.removeListener(c.Ipc.GetActiveCloudResponse,t),e("GetActiveCloud timed out after "+n.getValue("GET_ACTIVE_CLOUD_TIMEOUT")+"ms")},n.getValue("GET_ACTIVE_CLOUD_TIMEOUT"));t=function(n){clearTimeout(i),l(n,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")},p.getActiveCloud=function(e){p.getClouds(function(t,i,n,o){var r;t?e(t):(i.forEach(e=>{e.id===n&&(r=e)}),e(null,r,o))})},p.addListener=function(e,t){d.add(e,t)},p.removeListener=function(e,t){d.remove(e,t)},p.removeAllListeners=function(e){d.removeAll(e)},e.exports=p},function(e,t,i){var n=i(3),o=i(17),r=i(24),a=i(6),s=i(0),c=i(10),l=i(1),d=i(12),p="ProductLauncher",h=n.getValue("PRODUCT_LAUNCHER_SUPPORTED_PRODUCTS"),_={};function u(e,t){var i=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(),d=e.element.type+":"+(c&&c.type),h="Unexpectedly trying to ["+e.action+"] "+d+" in "+i.code;a.log(p,"Error: "+h),r.reportError("ElementActionConfigMismatch",h)}var _=null,u={elementRef:e.element.getReference(),requestID:l.uuid(),appCode:i.code,path:i.path,action:e.action};if(!1===e.waitForCompletion)return o.sendMessage(s.VULCAN_APP_SEND_ACTION_MESSAGE,JSON.stringify(u),i.code,i.version),void t(null,i);a.log(p,"Sending open request: ",JSON.stringify(u)),o.addListener(s.VULCAN_APP_ACTION_ACCEPTED_MESSAGE,f),o.sendMessage(s.VULCAN_APP_SEND_ACTION_MESSAGE,JSON.stringify(u),i.code,i.version),_=setTimeout(function(){o.removeListener(s.VULCAN_APP_ACTION_ACCEPTED_MESSAGE,f,i.code,i.version),t("APP_SEND_ACTION_FAILED")},n.getValue("SEND_ACTION_TIMEOUT"))}else t("NO_ACTION_SPECIFIED");else t(null,i);function f(e,n,r){a.log(p,"Recieved edit accept from :",n," ",r,": ",e),e===u.requestID?(clearTimeout(_),o.removeListener(s.VULCAN_APP_ACTION_ACCEPTED_MESSAGE,f,i.code,i.version),t(null,i)):a.log(p,"RequestID didn't match: Expected "+u.requestID+" to be "+e)}}function f(e){return e?e.isUnsupported?(a.log(p,"Unsupported version "+e.version),"NO_COMPATIBLE_VERSION"):"USABLE":(a.log(p,"App not installed "+e),"APP_NOT_INSTALLED")}_.getAppDetails=function(e){var t=[];return s.ELEMENT_ACTION_PRODUCT_MAP.installedApps.forEach(i=>{if(i.code===e.appCode){var n={};Object.assign(n,i),-1===c.compareVersions(e.minVersion||0,n.version)?n.isUnsupported=!0:n.isAlreadyRunning=o.isAppRunning(n.specifier),t.push(n)}}),t.sort(function(t,i){if(!1!==e.prioritizeRunning){if(t.isAlreadyRunning&&!i.isAlreadyRunning)return-1;if(i.isAlreadyRunning&&!t.isAlreadyRunning)return 1}return c.compareVersions(t.version,i.version)}),a.log(p,"Installed app details: "+JSON.stringify(t)),t[0]},_.appStatus=function(e){return f(_.getAppDetails(e))};var m={};_.launch=function(e,t){const i=_.getAppDetails(e),r=f(i);if(t=t||(()=>void 0),"USABLE"!==r)return void t(r);var c=i.specifier;if(e.specifierInfo=i,i.isAlreadyRunning||!1===e.waitForCompletion&&!e.element)return a.log(p,"Switching focus to app: "+c),void o.launchApp(c,!0,"",function(){u(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 h;function E(e,t,n){var r={};try{r=JSON.parse(e)}catch(i){return void a.log(p,"Unparsable payload received from "+t+" "+n,e)}d.normalize(r.path)===d.normalize(i.path)?(clearInterval(h),o.removeListener(s.VULCAN_APP_READY_MESSAGE,E),l(e=>u(e.options,e.callback))):a.log(p,"Received unknown app ready: "+e+" from "+t+" "+n+", specifier - "+JSON.stringify(i))}o.addListener(s.VULCAN_APP_READY_MESSAGE,E);const g=(e,t)=>{clearInterval(h),o.removeListener(s.VULCAN_APP_READY_MESSAGE,E),a.log(p,t),l(t=>t.callback(e))},y=(new Date).valueOf();h=setInterval(()=>{(new Date).valueOf()-y>n.getValue("LAUNCH_APP_TIMEOUT")?g("APP_LAUNCH_TIMEOUT","Launch app timed out: "+c):o.isAppRunning(c)||g("APP_LAUNCH_FAILED","App was killed before it finished launching: "+c)},n.getValue("LAUNCH_APP_POLL_INTERVAL")),a.log(p,"Launching app: "+c),o.launchApp(c,!0,"",(e,t)=>{(e||!0!==t)&&g("APP_LAUNCH_FAILED","Vulcan could not launch app: "+c+" "+e)})},_.updateInstallationMap=function(e){var t=o.getSpecifiers();a.log(p,"Recieved the list of installed apps: "+t.join(", "));var i={};(s.ELEMENT_ACTION_PRODUCT_MAP.installedApps||[]).forEach(e=>{i[e.specifier]=e});var n=[];return t.forEach(t=>{if(!i[t]||e){var r=t.split("-");if(2===r.length){var s=h[r[0]];if(!s)return;var c=o.getAppPath(t);if(!c)return void a.log(p,"No application path for specifier: "+t);var l=o.getAppVersion(t);if(!l)return void a.log(p,"No application version for specifier: "+t+" at "+c+" ("+l+")");n.push({specifier:t,code:s,version:l,path:d.normalize(c)})}else a.log(p,"Unexpected app specifier structure: "+t)}else n.push(i[t])}),s.ELEMENT_ACTION_PRODUCT_MAP.installedApps=n,a.log(p,"Updated installation map: ",JSON.stringify(n)),n},e.exports=_},function(e,t,i){var n=i(6),o=i(22),r=i(17),a=i(3),s=i(5),c=i(10),l=i(1),d={handlers:{}},p="accc.app.ShowNotificationRequest",h='<?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>',_=new s(["clickNotification"]);r.addListener("cclibrary.app.ShowNotificationResponse",function(e){var t,i,r,a,s=o.parseXML(e);try{r=s.response.requestid[0],a=s.response.context[0],t=(i=JSON.parse(a)).type}catch(t){n.log("Toast","Failed to parse, notification response "+e)}_.hasListeners("clickNotification")&&_.notify("clickNotification",[t,r,i.data])}),d.addListener=function(e,t){_.add(e,t)},d.removeListener=function(e,t){_.remove(e,t)};var u,f=[];d.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(!u)if(t)u=setTimeout(function(){u=void 0,e()},t);else if(0!==f.length){var i=f.shift(),n=c.constructStringFromTemplate(h,i);r.sendMessage(p,n,"ADCS",""),e(a.getValue("OS_TOAST_NOTIFICATIONS_BACKOFF"))}}(e.overridable?a.getValue("OS_TOAST_NOTIFICATIONS_DELAY"):0)},e.exports=d},function(e,t,i){var n,o,r=i(31),a=i(3),s=i(12),c=i(6),l=i(24),d=i(7),p=0,h={},_={_isEnabled:!0};_._scriptPath=s.join(__dirname,"localThumbnailsProcess.js"),_._startChildProcess=function(){n||(c.log("LocalThumbnails","Starting child process"),n=r.fork(_._scriptPath),process.on("exit",_._stopChildProcess),n.on("message",_._handleResponse),n.on("exit",_._handleExit))},_._stopChildProcess=function(e){n&&(c.log("LocalThumbnails","Stopping child process"),n.removeListener("message",_._handleResponse),n.removeListener("exit",_._handleExit),process.removeListener("exit",_._stopChildProcess),e||n.send({exit:!0}),n=void 0)},_._handleResponse=function(e){var t=h[e.id];if(delete h[e.id],t){0===Object.keys(h).length&&(o&&clearTimeout(o),o=setTimeout(function(){0===Object.keys(h).length&&_._stopChildProcess(),o=null},a.getValue("LOCAL_THUMBNAILS_SHUTDOWN_DELAY")));var i=" ("+((new Date).valueOf()-t.startTime)+"ms)";"__test__"===t.source?(c.log("LocalThumbnails","Testing: Success"+i),t.callback(e.err)):e.err?(c.log("LocalThumbnails","["+t.id+"] Error received: "+e.err+i),l.reportError("ThumbnailGeneratorError",e.err),t.callback(e.err)):(c.log("LocalThumbnails","["+t.id+"] Success"+i),t.callback(null,t.destination))}},_._handleExit=function(e,t){_._stopChildProcess(!0);var i=Object.keys(h);if(0!==i.length){var n="Unexpected exit: "+(null!==e?e:t);l.reportError("ThumbnailGeneratorError",n),i.forEach(e=>{var t=h[e];"__test__"===t.source?c.log("LocalThumbnails","Testing: Failed - "+n):c.log("LocalThumbnails","["+e+"] "+n),t.callback("unexpected_exit")}),h={}}},_.generate=function(e,t,i,o){if(_._isEnabled)if(e&&t){_._startChildProcess();var r={id:p++,startTime:(new Date).valueOf(),source:e,destination:t,size:i,callback:o};h[r.id]=r,"__test__"!==e&&c.log("LocalThumbnails","["+r.id+"] Requesting (size "+i+"): "+e),d.ensurePathExists(s.dirname(t),()=>{n.send({id:r.id,src:s.normalize(e),dest:s.normalize(t),size:i})})}else o("Missing source and/or destination path - source:"+e+"destination:"+t);else o("local_thumbnails_disabled")},_.test=function(e){_.generate("__test__","__test__",250,function(t){var i="unexpected_exit"!==t;_._isEnabled=i,e(i)})},e.exports=_},function(e,t,i){const n=i(19),o=i(12),r=i(31),a=i(24),s=i(5),c=i(3),l=i(6),d="SystemFonts";class p{constructor(e){this._scriptPath=e||p._scriptPath,this._listenerManager=new s(["change"]),this._fontWatchers=[],this._changeCount=0,this._fontWatchDebounce=c.getValue("FONT_WATCH_DEBOUNCE"),this._getFonts()}_getAvailableFonts(e){l.log(d,"Requesting fonts from font manager");let t=!1;const i=(i,n)=>{t||(i?(l.log(d,i),a.reportError(d,i),e([])):e(n),t=!0)},n=r.fork(this._scriptPath);n.on("message",e=>i(null,e)),n.on("exit",e=>i("Error, exiting with code: "+e))}_getFonts(e){return e&&delete this._fontCache,this._fontCache?Promise.resolve(this._fontCache):(this._fetchingPromise?e&&(this._pendingRefresh=!0):this._fetchingPromise=new Promise(e=>{const t=setInterval(()=>{if(this._pendingRefresh)return void(this._pendingRefresh=!1);const i=(new Date).valueOf();clearInterval(t),l.log(d,"Loading system fonts"),this._getAvailableFonts(t=>{const n=(new Date).valueOf()-i;if(delete this._fetchingPromise,t&&!this._pendingRefresh)this._fontWatchDebounce=c.getValue("FONT_WATCH_DEBOUNCE"),l.log(d,`Loaded ${t.length} fonts (${n}ms)`),this._fontCache=t,this._listenerManager.notify("change"),e(t);else{const i=t?"System fonts changed while loading":"Failed to load system fonts";if(this._pendingRefresh=!1,l.log(d,`${i} (${n}ms) - loading again`),!t){const e=c.getValue("FONT_WATCH_ERROR_DEBOUNCE_MIN"),t=c.getValue("FONT_WATCH_ERROR_DEBOUNCE_MAX");this._fontWatchDebounce=Math.max(e,Math.min(t,2*this._fontWatchDebounce))}e(this._getFonts())}})},this._fontWatchDebounce)}),this._fetchingPromise)}_onChange(e){l.log(d,`Font directory changed: ${e}`),this._getFonts(!0).then(()=>this._changeCount=0),this._changeCount++,this._changeCount>c.getValue("FONT_WATCH_RESET")&&(l.log(d,"Resetting font directory watchers"),this._ensureWatchers(!0),this._changeCount=0)}_ensureWatchers(e=!1){const t=this._listenerManager.hasListeners("change");t&&!e||(this._fontWatchers.forEach(e=>e&&e.close()),this._fontWatchers=[]),t&&c.getValue("FONT_DIRS").forEach((e,t)=>{if(this._fontWatchers[t])return;const i=()=>this._onChange(e),o=i=>{l.log(d,`Failed to watch font directory (${i&&i.code}): ${e}`),this._fontWatchers[t]=void 0,a.reportError(d,i&&i.code)};try{this._fontWatchers[t]=n.watch(e,{persistent:!1},i),l.log(d,`Watching font directory: ${e}`),this._fontWatchers[t].on("error",o)}catch(e){o(e)}})}isFontAvailable(e,t=!1){this._ensureWatchers();const i=t?"family":"postscriptName";return this._getFonts().then(t=>t.some(t=>t[i]===e))}addChangeListener(e){this._listenerManager.add("change",e),this._ensureWatchers()}removeChangeListener(e){this._listenerManager.remove("change",e),this._ensureWatchers()}removeAllListeners(){this._listenerManager.removeAll("change"),this._ensureWatchers()}}p._scriptPath=o.join(__dirname,"systemFontsProcess.js"),e.exports=p},function(e,t,i){const n=i(137),o=i(9),r=i(32),a=i(3),s=i(6),c=i(22),l=i(17),d=i(1),p=i(138),h=i(140),_=i(141),u=i(142);let f=i(143);const m="API",E="cclibraries.api.QueryRequest",g="cclibraries.api.QueryResponse";e.exports=class{initialize(e){return this._server?Promise.reject("API is already initialized"):(this._server=n.createServer({name:"CCLibraries REST API"}),this._batchHandlers={},this._server.use(n.plugins.bodyParser()),this._server.use(n.plugins.queryParser({mapParams:!0})),this._server.use((e,t,i)=>{let n=this._logRequest(e,t);if(t.header("x-request-id",n),t.header("x-env",a.getEnvironment().LABEL),t.header("access-control-allow-origin","*"),t.charSet("utf-8"),"OPTIONS"===e.method)return i();if((e.headers.token||e.query.token)!==this._serviceToken)return t.send(401);if(0===o.getLoadedCollections().length){const e=r.getUserId();return t.send(403,{userId:e})}i()}),this._optionsRoute=this._server.opts("*",(e,t)=>{t.header("access-control-allow-methods",e.header("access-control-request-method")),t.header("access-control-allow-headers",e.header("access-control-request-headers")),t.send(200)}),this._elementsRoute=new p(this),this._groupsRoute=new h(this),this._librariesRoute=new _(this),this._notificationsRoute=new u(this),this._searchRoute=new f(this),new Promise(t=>{this._server.listen(e||0,"127.0.0.1",()=>{s.log(m,`${this._server.name} listening at ${this._server.url}`),this._serviceHostname=this._server.url,this._serviceToken=d.uuid(),this._onConnectionHandler=this._connectionHandler.bind(this),l.addListener(E,this._onConnectionHandler),t()})}))}addBatchHandler(e,t,i,n,o){n=n||(()=>void 0),this._batchHandlers[e]=this._batchHandlers[e]||{};const r={params:{},routeInfo:{routeHandler:i,bodyValidator:n,isRemovedElement:o}},a=t.split("/").reduceRight((e,t)=>t.startsWith(":")?i=>(e.params[t.substr(1)]=i,e):{[t]:e},r);Object.assign(this._batchHandlers[e],a)}getBatchHandler(e,t,i,n,o){const[r,a]=t.split("?"),s=a?c.parseQueryString("?"+a,{parseBooleans:!0}):{};s.libraryId=o.id;const l=r.split("/").reduce((e,t)=>"function"==typeof e?e(t):e&&e[t],this._batchHandlers[e]);if(l)return{method:e,path:r,body:i,index:n,headers:[],params:Object.assign(s,l.params),_routeInfo:l.routeInfo}}_logRequest(e,t){const i=Date.now(),n=e.headers["x-request-id"]||d.uuid();return s.log(m,`[${n}] ${e.method.toUpperCase()} ${e.headers.host}${e.href()}`),t.on("finish",()=>{s.log(m,`[${n}] ${t.statusCode} (${Date.now()-i}ms)`)}),n}_connectionHandler(e,t,i){let n;s.log(m,`Client connected: ${t} - ${i}`);try{n=e&&JSON.parse(e)}catch(t){s.log(m,`Parse error, client message: ${e}`)}const o=n&&n.apiVersion,r={apiVersion:a.getValue("REST_API_VERSION"),apiMinVersion:a.getValue("REST_API_MIN_VERSION"),apiMaxVersion:a.getValue("REST_API_MAX_VERSION")};!o||o<r.apiMinVersion?r.updateRequired="client":o>r.apiMaxVersion?r.updateRequired="server":(r.serviceHostname=this._serviceHostname,r.serviceToken=this._serviceToken),l.sendMessage(g,JSON.stringify(r),t,i)}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._searchRoute.dispose(),this._searchRoute=void 0,this._server.rm(this._optionsRoute),this._optionsRoute=void 0,this._server.close(),this._server=void 0,l.removeListener(E,this._onConnectionHandler))}}},function(e,t){e.exports=require("restify")},function(e,t,i){const n=i(12),{getRequestHandler:o,getElementResponseData:r,updateCustomData:a,parseCustomData:s,parsePlaceholder:c}=i(33),l=i(34),d=i(9),p=i(0),h=i(14);e.exports=class{constructor(e){this._server=e._server,this._routes=[],this._batchHandlers=[],this._routes.push(this._server.get("/libraries/:libraryId/elements",o(this.getElements.bind(this)))),this._routes.push(this._server.post("/libraries/:libraryId/elements",o(this.createElement.bind(this),!0))),this._routes.push(this._server.get("/libraries/:libraryId/elements/:elementId",o(this.getElement.bind(this)))),this._routes.push(this._server.put("/libraries/:libraryId/elements/:elementId",o(this.updateElement.bind(this),!0))),this._routes.push(this._server.del("/libraries/:libraryId/elements/:elementId",o(this.removeElement.bind(this),!0))),this._routes.push(this._server.get("/libraries/:libraryId/elements/:elementId/representations/:representationId/path",o(this.getRepresentationPath.bind(this)))),this._routes.push(this._server.post("/libraries/:libraryId/elements/:elementId/representations/:representationId/report_usage",o(this.reportRepresentationUsage.bind(this),!1))),this._routes.push(this._server.get("/libraries/:libraryId/removed_elements",o(this.getRemovedElements.bind(this)))),this._routes.push(this._server.get("/libraries/:libraryId/removed_elements/:elementId",o(this.getElement.bind(this),null,!0))),this._routes.push(this._server.del("/libraries/:libraryId/removed_elements/:elementId",o(this.removeElement.bind(this),null,!0))),e.addBatchHandler("POST","elements",this.createElement.bind(this),this.validateElementData.bind(this)),e.addBatchHandler("PUT","elements/:elementId",this.updateElement.bind(this),this.validateElementData.bind(this)),e.addBatchHandler("DELETE","elements/:elementId",this.removeElement.bind(this)),e.addBatchHandler("DELETE","removed_elements/:elementId",this.removeElement.bind(this),void 0,!0)}_buildRepresentations(e,t){const i=[];if(e.representations.length>0){const i=t.filter(e=>e.id).map(e=>e.id);e.representations.slice().forEach(t=>{i.includes(t.id)||e.removeRepresentation(t)})}return t.forEach((t,n)=>{if(t.id){const i=e.getRepresentationById(t.id);return void(i&&i._getDCXElement().setValue(p.REPRESENTATION_ORDER_KEY,n))}const o=e.createRepresentation(t.type,t.relationship,n);this._buildRepresentation(o,t,i)}),Promise.all(i)}_buildRepresentation(e,t,i){t.source&&(t.source.path||t.source.url)&&i.push(new Promise((i,n)=>{t.source.path?e.setContentFromPath(t.source.path,t.source.moveFile,e=>{e?n(e):i()}):t.source.url&&e.setContentFromURL(!!t.source.createLink,t.source.url,t.source.headers,e=>{e?n(e):i()})}).then(()=>{void 0!==t.width&&(e.width=t.width),void 0!==t.height&&(e.height=t.height),void 0!==t.content_length&&(e.contentLength=t.content_length),void 0!==t.is_full_size&&(e.isFullSize=t.is_full_size)}));const n=s(t.custom_data);n?(a(e,n),(t.children||[]).forEach(t=>{const n=e.createChild(t.type);this._buildRepresentation(n,t,i)})):i.push(Promise.reject(l.INVALID_CUSTOM_DATA))}validateElementData(e,t,i,n){if(!e)return l.ELEMENT_DATA_MISSING;const o=e.tags,r=e.representations,a=s(e.custom_data),c=e.groups;if(!a)return l.INVALID_CUSTOM_DATA;if(i){if(!(0!==a.length||e.name||r||o||c))return l.ELEMENT_BODY_MISSING}else{if(!e.type)return l.ELEMENT_TYPE_MISSING;if((!e.force||e.type!==p.COLOR_ELEMENT_TYPE)&&t.elements.length>=p.MAX_ELEMENTS)return l.LIBRARY_NOT_ENOUGH_SPACE}if(e.name&&"string"!=typeof e.name)return l.ELEMENT_NAME_INVALID;if(o&&(!Array.isArray(o)||!o.every(e=>"string"==typeof e)))return l.ELEMENT_TAGS_INVALID;if(r||!i){if(!r||!Array.isArray(r)||0===r.length)return l.REPRESENTATION_DATA_MISSING;for(let e of r){let t;if(i&&e.id){if(!(t=i.getRepresentationById(e.id)))return l.REPRESENTATION_ID_NOT_RESOLVED}else{const t=this._validateRepresentationData(e);if(t)return t}}if(r.filter(e=>{const t=i&&i.getRepresentationById(e.id);return"primary"===(t?t.relationship:e.relationship)}).length>1)return l.REPRESENTATION_REL_PRIMARY_FOUND}return c?this._validateGroupsData(c,t,n):void 0}_validateGroupsData(e,t,i){const n=Array.isArray(e);if(!e||n&&0===e.length)return;const o=(e,n=p.DEFAULT_GROUP_CLASSIFIER)=>{for(let o=0;o<e.length;o++){const r=e[o];if(!r.id||"string"!=typeof r.order)return l.INVALID_GROUP_DATA;if(i&&c(r.id)){const e=i("groupId",r.id);if(e)return e}else{const e=t.getGroupById(r.id);if(!e)return l.GROUP_NOT_FOUND;if(e.classifierName!==n)return l.INVALID_GROUP_DATA}}};if(n)return o(e);if("object"!=typeof e)return l.INVALID_GROUP_DATA;let r=Object.keys(e);for(let t=0;t<r.length;t++){const i=r[t],n=o(e[i],i);if(n)return n}}_validateRepresentationData(e,t){if(!e.type)return l.REPRESENTATION_TYPE_MISSING;if(t){if(e.relationship)return l.REPRESENTATION_REL_INVALID}else{if(!e.relationship)return l.REPRESENTATION_REL_MISSING;if(!p.VALID_RELATIONS.includes(e.relationship))return l.REPRESENTATION_REL_INVALID}if(e.source&&!e.source.path&&!e.source.url)return l.REPRESENTATION_SOURCE_MISSING;if(void 0!==e.width&&"number"!=typeof e.width||e.width<0)return l.REPRESENTATION_WIDTH_INVALID;if(void 0!==e.height&&"number"!=typeof e.height||e.height<0)return l.REPRESENTATION_HEIGHT_INVALID;if(void 0!==e.content_length){if(!e.source.url||!e.source.createLink)return l.REPRESENTATION_CONTENT_LENGTH_UNEXPECTED;if("number"!=typeof e.content_length||e.content_length<0)return l.REPRESENTATION_CONTENT_LENGTH_INVALID}if(e.children){if(!Array.isArray(e.children))return l.REPRESENTATION_CHILDREN_INVALID;if(e.children.some(e=>this._validateRepresentationData(e,!0)))return l.REPRESENTATION_CHILDREN_INVALID}return void 0!==e.is_full_size&&"boolean"!=typeof e.is_full_size?l.REPRESENTATION_FULL_SIZE_INVALID:void 0}_updateElement(e,t){const i=e.tags,n=e.representations,o=s(e.custom_data),r=e.groups;if(e.name&&(t.name=e.name),i&&(t.tags=i),a(t,o),r){const e=(e,i=p.DEFAULT_GROUP_CLASSIFIER)=>{const n=t.getGroups(i);n.length>0&&t.setOrderInGroup(n[0],void 0),e.forEach(e=>{const i=t.library.getGroupById(e.id);t.setOrderInGroup(i,e.order,!1)})};Array.isArray(r)?e(r):Object.keys(r).forEach(t=>{e(r[t],t)})}if(n)return this._buildRepresentations(t,n)}createElement(e,t,i){if(t&&(t.self||t.source))return this.copyOrMoveElements(e,t,i);const n=this.validateElementData(t,i);if(n)return Promise.reject(n);const o=i.createElement(t.name,t.type,t.force);return Promise.resolve(this._updateElement(t,o,!0)).then(()=>(o.endOperation(),r(o))).catch(e=>(o.library.removeElement(o),Promise.reject(l.getResponseError(e))))}updateElement(e,t,i){const n=this.validateElementData(t,i.library,i);return n?Promise.reject(n):(i.beginOperation(),t.representations?Promise.resolve(this._updateElement(t,i)).then(()=>(i.endOperation(),r(i))).catch(e=>(i.endOperation(),Promise.reject(l.getResponseError(e)))):(this._updateElement(t,i),i.endOperation(),r(i)))}copyOrMoveElements(e,t,i){const n=!!t.self,o=t.self||t.source,a=o.id,s=o.elements;if(!a)return Promise.reject(l.LIBRARY_ID_MISSING);if(!s||!Array.isArray(s)||0===s.length)return Promise.reject(l.ELEMENT_IDS_MISSING);const c=d.getLibraryById(a);if(!c)return Promise.reject(l.LIBRARY_NOT_FOUND);if(n&&!c.isWritable)return Promise.reject(l.LIBRARY_NOT_WRITABLE);if(i.elements.length+s.length>p.MAX_ELEMENTS)return Promise.reject(l.LIBRARY_NOT_ENOUGH_SPACE);const h=s.map(e=>c.getElementById(e));if(h.some(e=>!e))return Promise.reject(l.ELEMENT_NOT_FOUND);i.beginOperation(),n&&c.beginOperation();const _=n?c.moveElement.bind(c):c.copyElement.bind(c),u=()=>{i.endOperation(),n&&c.endOperation()},f=[];return h.forEach(e=>{f.push(new Promise((t,n)=>{_(e,i,(e,i)=>{e?n(l.getResponseError(e)):t(i)})}))}),Promise.all(f).then(e=>(u(),{elements:e.map(r)})).catch(e=>(u(),Promise.reject(e)))}getElement(e,t,i){return r(i)}getElements(e,t,i){return{elements:i.elements.map(r)}}getRemovedElements(e,t,i){return{elements:i.removedElements.map(r)}}getRepresentationPath(e,t,i){return new Promise((e,t)=>{i.getContentPath((i,o)=>i?t(l.getResponseError(i)):o?void e({path:n.normalize(o)}):t(l.REPRESENTATION_PATH_NOT_FOUND))})}removeElement(e,t,i){i.library.removeElement(i,e.permanent||i.removed)}reportRepresentationUsage(e,t,i){const n=e.appName?{appName:e.appName}:{},o=t&&t.opType||"unknown";h.reportUseElement(i,o,n)}dispose(){this._routes.forEach(e=>this._server.rm(e))}}},function(e,t){e.exports=require("restify-errors")},function(e,t,i){const{getRequestHandler:n,getGroupResponseData:o}=i(33),r=i(34);e.exports=class{constructor(e){this._server=e._server,this._routes=[],this._routes.push(this._server.get("/libraries/:libraryId/groups",n(this.getGroups.bind(this)))),this._routes.push(this._server.post("/libraries/:libraryId/groups",n(this.createGroup.bind(this),!0))),this._routes.push(this._server.get("/libraries/:libraryId/groups/:groupId",n(this.getGroup.bind(this)))),this._routes.push(this._server.put("/libraries/:libraryId/groups/:groupId",n(this.updateGroup.bind(this),!0))),this._routes.push(this._server.del("/libraries/:libraryId/groups/:groupId",n(this.removeGroup.bind(this),!0))),e.addBatchHandler("POST","groups",this.createGroup.bind(this),this.validateCreateGroupBody.bind(this)),e.addBatchHandler("PUT","groups/:groupId",this.updateGroup.bind(this),this.validateUpdateGroupBody.bind(this)),e.addBatchHandler("DELETE","groups/:groupId",this.removeGroup.bind(this))}validateCreateGroupBody(e){const t=e&&e.name,i=e&&e.order;return t?i?void 0:r.GROUP_ORDER_MISSING:r.GROUP_NAME_MISSING}createGroup(e,t,i){const n=t&&t.name,r=t&&t.classifier,a=t&&t.order;let s=this.validateCreateGroupBody(t);if(s)return Promise.reject(s);const c=i.createGroup(n,a,r);return o(c)}removeGroup(e,t,i){i.library.removeGroup(i,e.include_contents)}getGroup(e,t,i){return o(i)}getGroups(e,t,i){const n={groups:[]},r=e.classifier||/.*/;return n.groups=i.getGroups(r).map(e=>o(e)),n}validateUpdateGroupBody(e){const t=e&&e.name,i=e&&e.order;return t||i?t&&"string"!=typeof t||i&&"string"!=typeof i?r.INVALID_GROUP_DATA:void 0:r.GROUP_BODY_MISSING}updateGroup(e,t,i){const n=t&&t.name,r=t&&t.order;let a=this.validateUpdateGroupBody(t);return a?Promise.reject(a):(i.library.beginOperation(),n&&(i.name=n),r&&(i.order=r),i.library.endOperation(),o(i))}dispose(){this._routes.forEach(e=>this._server.rm(e))}}},function(e,t,i){const{getRequestHandler:n,getLibraryResponseData:o,updateCustomData:r,parseCustomData:a,getRequestedModels:s,parsePlaceholder:c}=i(33),l=i(34),d=i(18),p=i(9),h=i(0),_=e=>{if(!e)return;const t=e=>e.some(e=>c(e.id));return Array.isArray(e)?t(e):Object.keys(e).some(i=>t(e[i]))},u=(e,t)=>{const i=void 0!==t&&`Issue at request index: ${t}`;return l.getResponseError(e,i)},f=(e,t)=>{const{routeHandler:i,isRemovedElement:n}=e._routeInfo,{element:o,group:r,representation:a,error:c}=s(e,!0,n,t);if(c)throw u(c,e.index);try{return i(e.params,e.body,r||a||o||t)}catch(t){throw u(t,e.index)}},m={elementId:"elements",groupId:"groups"},E=Object.keys(m);e.exports=class{constructor(e){this._apiServer=e,this._server=e._server,this._routes=[],this._routes.push(this._server.get("/libraries",n(this.getLibraries.bind(this)))),this._routes.push(this._server.post("/libraries",n(this.createLibrary.bind(this)))),this._routes.push(this._server.get("/libraries/:libraryId",n(this.getLibrary.bind(this)))),this._routes.push(this._server.put("/libraries/:libraryId",n(this.updateLibrary.bind(this),!0))),this._routes.push(this._server.del("/libraries/:libraryId",n(this.removeLibrary.bind(this)))),this._routes.push(this._server.patch("/libraries/:libraryId",n(this.batchUpdateLibrary.bind(this),!0))),e.addBatchHandler("PUT","",this.updateLibrary.bind(this),this.validateUpdateLibraryBody.bind(this))}createLibrary(e,t){if(t&&t.follow)return this.followLibrary(e,t);const i=a(t&&t.custom_data);if(!i)return Promise.reject(l.INVALID_CUSTOM_DATA);const n=i.find(e=>"toolkit"===e.namespace&&"id"===e.key),s=n&&d.getToolkitName(n.value)||t&&t.name||e&&e.name;if(!s)return Promise.reject(l.LIBRARY_NAME_MISSING);const c=p.getLoadedCollections().find(e=>!e.isPublic);if(!c)return Promise.reject(l.COLLECTION_NOT_FOUND);const h=c.createLibrary(s);return r(h,i),o(h)}followLibrary(e,t){const i=t&&t.id,n=t&&t.url;if(!i)return Promise.reject(l.LIBRARY_ID_MISSING);if(!n)return Promise.reject(l.LIBRARY_URL_MISSING);const o=p.getLoadedCollections().find(e=>!e.isPublic);return o?new Promise((e,t)=>{o._bookmarkManager.createBookmark(i,n,i=>{i?t(i):e()})}):Promise.reject(l.COLLECTION_NOT_FOUND)}getLibraries(){const e={libraries:[]};return p.getLoadedCollections().forEach(t=>{t.libraries.forEach(t=>{t.isDeletedFromServer||e.libraries.push(o(t))})}),e}getLibrary(e,t,i){return o(i,{includeElements:!0})}removeLibrary(e,t,i){i.collection.removeLibrary(i,()=>{})}validateUpdateLibraryBody(e){const t=e&&e.name,i=a(e&&e.custom_data);return i?0!==i.length||t?void 0:l.INVALID_UPDATE_REQUEST:l.INVALID_CUSTOM_DATA}updateLibrary(e,t,i){t=t||{},e&&e.name&&!t.name&&(t.name=e.name);const n=this.validateUpdateLibraryBody(t);if(n)return Promise.reject(n);const s=t.name;s&&(i.name=s);const c=a(t&&t.custom_data);return r(i,c),o(i)}validateBatchedRequests(e,t){const i=e.filter(e=>e&&"POST"===e.method&&"elements"===e.path).length;if(t.elements.length+i>h.MAX_ELEMENTS)return l.LIBRARY_NOT_ENOUGH_SPACE;for(let i=0;i<e.length;i++){const n=e[i];if(!n)return u(l.INVALID_TRANSACTION_REQUEST,i);const o="PUT"===n.method&&n.path.startsWith("elements/")&&n.body&&n.body.representations,r="POST"===n.method&&"elements"===n.path&&n.body&&(n.body.source||n.body.self);if(o||r)return u(l.NOT_IMPLEMENTED,i);const a=(t,n)=>{const{index:o,property:r}=c(n);let a=e[o];if(a=a&&a._originalRequest||a,o>i||"id"!==r||"POST"!==a.method||a.path!==m[t])return l.INVALID_TRANSACTION_PLACEHOLDER},{isRemovedElement:d,bodyValidator:p}=n._routeInfo;let h;const _=E.find(e=>n.params[e]&&c(n.params[e]));if(_){const e=a(_,n.params[_]);if(e)return u(e,i);h={}}else{const e=s(n,!0,d,t);if(h=e.element,e.error)return u(e.error,i)}const f=p(n.body,t,h,a);if(f)return u(f,i)}}batchUpdateLibrary(e,t,i){if(!Array.isArray(t)||0===t.length)return Promise.reject(l.INVALID_TRANSACTION_SYNTAX);const n=t.findIndex(e=>"object"!=typeof e||"string"!=typeof e.path||!e.method||e.body&&"object"!=typeof e.body);if(n>-1)return Promise.reject(u(l.INVALID_TRANSACTION_SYNTAX,n));const o=t.map((e,t)=>this._apiServer.getBatchHandler(e.method,e.path,e.body,t,i)),r=this.validateBatchedRequests(o,i);if(r)return Promise.reject(r);let a=!1;const s=[],d=e=>i.removeElement(i.getElementById(e),!0);i.beginOperation();const p=o.filter(e=>"POST"===e.method&&"elements"===e.path).map(e=>(_(e.body.groups)&&(o[e.index]=this._apiServer.getBatchHandler("PUT",`${e.path}/$${e.index}.id`,{groups:e.body.groups},e.index,i),delete e.body.groups,o[e.index]._originalRequest=e),Promise.resolve().then(()=>f(e,i)).then(t=>{a?d(t.id):(s.push(t.id),e.response=t)})));return Promise.all(p).then(()=>{const e=i.isDeletedFromServer&&l.LIBRARY_NOT_FOUND||!i.isWritable&&l.LIBRARY_NOT_WRITABLE||this.validateBatchedRequests(o,i);if(e)return Promise.reject(e);const t=e=>{const t=c(e),i=t&&o[t.index],n=i&&(i._originalRequest?i._originalRequest.response:i.response);return n?n[t.property]:e},n=e=>e.forEach(e=>e.id=t(e.id));return o.forEach(e=>{if(e.response)return;E.forEach(i=>e.params[i]&&(e.params[i]=t(e.params[i])));const o=e.body&&e.body.groups;o&&(Array.isArray(o)?n(o):Object.keys(o).forEach(e=>n(o[e]))),e.response=f(e,i)}),i.endOperation(),o.map(e=>e.response)}).catch(e=>(a=!0,Promise.all(p.map(e=>e.catch(()=>null))).then(()=>(s.forEach(d),i.endOperation(),Promise.reject(e)))))}dispose(){this._routes.forEach(e=>this._server.rm(e))}}},function(e,t,i){const{getPollingRequestHandler:n,getLibraryResponseData:o}=i(33),r=i(9);e.exports=class{constructor(e){this._server=e._server,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",n(this.handleLibraryNotifications.bind(this)))),this._routes.push(this._server.post("/notifications/libraries/sync",n(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(i=>{if("error"===i.syncState)return t=i.syncState,e=i.getPrimarySyncError(),!0;"syncing"===i.syncState&&(t=i.syncState)}),{state:t,error:e}}_getChangedLibrariesData(e,t){let i=Object.keys(t).length!==Object.keys(e).length;const n={};return Object.keys(t).forEach(a=>{const s=t[a];e[a]!==s?(n[a]=o(r.getLibraryById(a)),i=!0):n[a]=s}),i?n:void 0}_compareSyncStatusData(e,t){return!e||e.state!==t.state||e.error!==t.error}handleLibraryNotifications(e,t){const i=this._getLibrariesData(),n=this._getChangedLibrariesData(e,i);if(n)return void t(n);const o=i=>{const n=this._getChangedLibrariesData(e,i);if(n)return t(n),!0};return this._pendingLibraryChangeCallbacks.push(o),()=>{this._pendingLibraryChangeCallbacks.includes(o)&&this._pendingLibraryChangeCallbacks.splice(this._pendingLibraryChangeCallbacks.indexOf(o),1)}}handleSyncStatusNotifications(e,t){const i=this._getSyncStatusData();if(this._compareSyncStatusData(e,i))return void t(i);const n=i=>{if(this._compareSyncStatusData(e,i))return t(i)};return this._pendingSyncChangeCallbacks.push(n),()=>{this._pendingSyncChangeCallbacks.includes(n)&&this._pendingSyncChangeCallbacks.splice(this._pendingSyncChangeCallbacks.indexOf(n),1)}}dispose(){r.removeLoadedCollectionsListener(this._onCollectionsChanged),this._routes.forEach(e=>this._server.rm(e))}}},function(e,t,i){const{getRequestHandler:n,getElementResponseData:o,getLibraryResponseData:r,getPagedResponses:a,getSortOrder:s,parseFilterField:c,parseSortField:l}=i(33),d=i(34),p=i(9),{isSearchQueryEmpty:h,findMatchingElements:_,findMatchingLibraries:u,isValidModifiedFilter:f}=i(144),m=i(146),E=10;e.exports=class{constructor(e){this._server=e._server,this._routes=[],this._routes.push(this._server.post("/search",n(this.searchElements.bind(this)))),this._localizedSorter=new m,this._localizedSorter.init()}searchElements(e,t,i){let n=t.q;if(t.filters)for(let e in t.filters)t.filters[e]=c(e,t.filters[e]);if(h(n))return Promise.reject(d.EMPTY_SEARCH);if(t.filters&&0===Object.keys(t.filters).length)return Promise.reject(d.EMPTY_FILTERS);if(t.filters&&t.filters.modified_date&&!f(t.filters.modified_date))return Promise.reject(d.INVALID_MODIFIED_FILTER);if(t.limit<=0)return Promise.reject(d.INCORRECT_LIMIT);const m=t.filters&&t.filters.owner;let g;m&&(g=(e=>{const t=!e.collection.isPublic&&"outgoing"!==e.collaboration;return!!("owner"===m&&t||"shared"===m&&!t)}));let y=[];if(i){if(g&&!g(i))return Promise.reject(d.CONFLICTING_OWNERSHIP);y.push(i)}else p.getLoadedCollections().forEach(e=>{e.libraries.forEach(e=>{g&&!g(e)||y.push(e)})});const v=_(n,y,t.filters).map(e=>o(e,!0,!i,t.thumbnail_cache)),A=i?[]:u(n,y,t.filters).map(e=>r(e,{includeSize:!0,includeRenditionGrid:!0})),C=v.concat(A),{orderBy:I,isAscending:S}=s(t.order_by);C.length>0&&this._localizedSorter.sortResponses(C,I,S);const L=t.limit&&parseInt(t.limit)||E,O=l(I,t.start),{pagedResults:R,isLastPage:T,nextStartValue:N}=a(C,I,S,L,O,this._localizedSorter),D={},b={count:R.length,order_by:t.order_by};return R.length>0&&(b.start=R[0][I]),T||(b.next=N,D.next={uri:"/search",method:"POST",body:t},D.next.body.start=N,D.next.body.limit=L),Promise.resolve({results:R,_page:b,_links:D,_totalCount:C.length})}dispose(){this._routes.forEach(e=>this._server.rm(e))}}},function(e,t,i){const n=i(145),o="application/vnd.adobe.element.color+dcx",r="application/vnd.adobe.element.colortheme+dcx",a="application/vnd.adobe.element.characterstyle+dcx",s="application/vnd.adobe.element.paragraphstyle+dcx",c="application/vnd.adobe.element.text+dcx",l={};function d(e){if(!(e=e&&e.trim().toLowerCase()))return[];let t;return t=e.length>2&&'"'===e.charAt(0)&&'"'===e.charAt(e.length-1)?[e.substring(1,e.length-1)]:e.indexOf(" ")>-1?e.split(/[ ]+/):[e]}function p(e,t){if(!t)return!0;if(t.modified_date){const[i,n]=t.modified_date;if(i&&e.modified<i||n&&e.modified>n)return!1}return!0}function h(e,t){const i={[o]:_,[r]:u,[a]:f,[s]:f,[c]:m}[e.type];return i&&i(e,t)}function _(e,t){let i=y.getRGBColor(e);return(i=i&&y.colorDataToHexString(i).toLowerCase())&&i.includes(t)}function u(e,t){const i=E(e,"application/vnd.adobe.colortheme+json"),n=i&&i.getValue("colortheme","data");if(n&&Array.isArray(n.swatches))for(let e=0;e<n.swatches.length;e++){const i=n.swatches[e];if(y.colorDataToHexString(i).toLowerCase().includes(t))return!0}return!1}function f(e,t){const i=E(e,"application/vnd.adobe.characterstyle+json"),n=i&&i.getValue("characterstyle","data"),o=n&&n.fontFamily&&n.fontFamily.toLowerCase(),r=n&&n.adbeFont&&n.adbeFont.style&&n.adbeFont.style.toLowerCase(),a=n&&n.fontSize&&n.fontSize.value&&n.fontSize.value.toString().toLowerCase();return o&&o.includes(t)||r&&r.includes(t)||a&&a.includes(t)}function m(e,t){const i=E(e,"application/vnd.adobe.text+json"),n=i&&i.getValue("text","data");let o=0;for(let e=0;e<n.paragraphs.length&&!(o>=6e3);e++){const i=g(n.paragraphs[e].text,6e3-o).toLowerCase();if(i.includes(t))return!0;o+=i.length}return!1}function E(e,t){return e.representations.find(e=>e.type===t)}function g(e,t,i=!0){const o=i?"...":"";return e.length<=t?e:n.ucs2.encode(n.ucs2.decode(e).slice(0,t))+o}l.isSearchQueryEmpty=(e=>!(e=e&&e.trim().toLowerCase()&&function(e){if('"'===e.charAt(0)&&'"'===e.charAt(e.length-1))return e.substring(1,e.length-1);return e}(e))),l.findMatchingElements=((e,t,i)=>{if(!t||!Array.isArray(t)||!e)return[];const n=d(e);if(0===n.length)return[];let o=[];return t.forEach(e=>{e.elements.forEach(e=>{p(e,i)&&function(e,t){const i=e.name.toLowerCase(),n=e.description&&e.description.toLowerCase(),o=e.getGroups()[0],r=o&&o.name.toLowerCase(),a=function(e){let t;if(e.representations.find(e=>{if(t=e.getValue("adobestock","trackingdata"))return!0}),t)return String(t.content_id);return null}(e);let s=function(e){let t;return e.representations.some(e=>t=e.getValue("stock","query")),t}(e);s=s&&s.toLowerCase();for(let o=0;o<t.length;o++){const c=t[o],l=i.includes(c)||n&&n.includes(c)||r&&r.includes(c)||a&&a.includes(c)||s&&s.includes(c)||h(e,c);if(!l)return!1}return!0}(e,n)&&o.push(e)})}),o}),l.findMatchingLibraries=((e,t,i)=>{if(!t||!Array.isArray(t)||!e)return[];const n=d(e);if(0===n.length)return[];let o=[];return t.forEach(e=>{p(e,i)&&function(e,t){const i=e.name.toLowerCase();for(let e=0;e<t.length;e++){const n=t[e],o=i.includes(n);if(!o)return!1}return!0}(e,n)&&o.push(e)}),o}),l.isValidModifiedFilter=(e=>{if(!Array.isArray(e))return!1;const[t,i]=e;return!(!t&&!i||"number"!=typeof t&&null!==t||"number"!=typeof i&&null!==i||t&&i&&t>i)});const y={};y.getRGBColor=(e=>{if(!e||!e.representations)return;const t=e.representations;for(let e=0;e<t.length;e++){const i=t[e].getValue("color","data");if(i&&"RGB"===i.mode)return i}}),y.colorDataToHexString=(e=>{const t=Array.isArray(e)?function(e){return e.find(e=>"RGB"===e.mode)}(e):e;return t&&t.value?function(e,t,i){let n=function(e,t,i){return e<<16|t<<8|i}(e,t,i).toString(16);for(;n.length<6;)n="0"+n;return"#"+n}(Math.round(t.value.r),Math.round(t.value.g),Math.round(t.value.b)):""}),e.exports=l},function(e,t){e.exports=require("punycode")},function(e,t,i){const n=i(9);e.exports=class{init(e){e=e||n.getLocale().replace("_","-"),this._collator=new Intl.Collator(e,{numeric:!0})}_compare(e,t){return e===t?0:"string"==typeof e&&"string"==typeof t?this._collator.compare(e,t):e<t?-1:1}_sort(e,t,i){return e.sort((e,n)=>{const o=i?this._compare(t(e),t(n)):this._compare(t(n),t(e));if(0===o){if(e.element_ref&&!n.element_ref)return i?-1:1;if(!e.element_ref&&n.element_ref)return i?1:-1}return o})}findNextIndex(e,t,i,n){let o=-1;for(let r=0;r<e.length;r++)if(n?1===this._compare(e[r][t],i):-1===this._compare(e[r][t],i)){o=r;break}return o}sortResponses(e,t,i){return e&&t&&0!==e.length?"modified_date"===t?this.sortByModified(e,i):"name"===t?this.sortByName(e,i):"size"===t?this.sortBySize(e,i):void 0:e}sortByModified(e,t=!1){return this._sort(e,e=>e.modified_date,t)}sortByName(e,t=!0){return this._sort(e,e=>e.name,t)}sortBySize(e,t=!1){return this._sort(e,e=>e.size,t)}}},function(e,t,i){const n=i(27),o=i(6),r=i(148),a=i(30),s=i(12),c=i(41),l=i(3),d=i(38),p=i(18),h=i(9),_=i(1),u=i(0),f=i(32),m="TLS_SERVER",E="com",g="adobelocalhost",y=864e5,v=730,A=60,C="user.js",I='\n// Adobe Creative Cloud in Microsoft Office\nuser_pref("security.enterprise_roots.enabled", true);\n',S=()=>({sniPort:0,trustInProgress:!1,certificateIsTrusted:!1,delayOnDecline:u.TLS_DELAY_ON_DECLINE,delayOnReady:u.TLS_DELAY_ON_READY,tokens:l.getValue("WSS_TOKENS")||[],dataUploaded:{},dataUploadInProgress:{}});function L(e,t,i){return new Promise((r,a)=>{const s=n.createServer(e);s.on("listening",()=>{o.log(m,`${i} is up and running at port: ${s.address().port}`),r(s)}),s.on("error",e=>{o.log(m,`Failed to launch ${i} at port: ${t} with error: ${e}`),a(e)}),s.listen(t,"127.0.0.1")})}function O(e,t){return Math.floor((e.getTime()-t.getTime())/y)}e.exports=class{constructor(){this._config=S(),this._locationOfIdentity=s.join(l.getValue("ROOT_DIR"),"identity"),this._deviceID=l.getValue("SNI_SERVER_ID")||c.createHash("md5").update(_.uuid()).digest("hex"),l.setValue("SNI_SERVER_ID",this._deviceID)}on(e,t){return"connection"!==e||this._initializationPromise||(this._onConnection=t,this._initialize()),this}_isUserHashValid(e){const t=f.getUserId();return t&&c.createHash("md5").update(t).digest("hex")===e}_ensureIdentityExists(){return r.isSelfSignedIdentityPresent(this._locationOfIdentity,this._deviceID).then(e=>{o.log(m,`Identity is already present for ${this._deviceID}.adobelocalhost.com`);const t=new Date(e.validFrom),i=new Date(e.validTo),n=new Date,s=O(i,t),c=O(i,n);return s>v||c<A?(o.log(m,"Current Identity is invalid so removing it and creating a new one"),a.unlinkSync(e.key),a.unlinkSync(e.cert),a.unlinkSync(e.dCert),r.createSelfSignedIdentity(this._locationOfIdentity,this._deviceID,".adobelocalhost.com","Adobe Creative Cloud","1","730")):e}).catch(()=>(o.log(m,`Creating new identity for ${this._deviceID}.adobelocalhost.com`),a.ensureDirSync(this._locationOfIdentity),r.createSelfSignedIdentity(this._locationOfIdentity,this._deviceID,".adobelocalhost.com","Adobe Creative Cloud","1","730")))}_enableSystemCertificatesInFirefox(){const e=l.getValue("FIREFOX_DIR");let t;try{t=a.readdirSync(e)}catch(e){return void o.log(m,"Skipping Firefox setup - Firefox is not installed")}t.forEach(t=>{const i=s.join(e,t,C);try{const e=a.readFileSync(i,"utf8"),n="security.enterprise_roots.enabled";if(e.includes(`'${n}'`)||e.includes(`"${n}"`))return void o.log(m,`Skipping Firefox setup for profile ${t} - entry already present`)}catch(e){}try{a.appendFileSync(i,I,{encoding:"utf8"}),o.log(m,`Enabling system certificates for Firefox profile: ${t}`)}catch(e){o.log(m,`Failed to enable system certificates for Firefox profile: ${t}`)}})}_initiateCertificateTrustProcess(e){this._config.trustInProgress||(this._config.trustInProgress=!0,r.isCertificateTrusted(this._dCertificateLocation).then(e=>(this._config.certificateIsTrusted=e,this._config.certificateIsTrusted&&o.log(m,"Certificate is already trusted"),!e)).then(t=>!!t&&(o.log(m,"Starting the certificate trust process"),r.showDialog(p.translate("LIBS_PROCESS_CERTIFICATE_TRUST_DIALOG_TITLE"),p.translate("LIBS_PROCESS_CERTIFICATE_TRUST_DIALOG_MESSAGE"),p.translate("LIBS_PROCESS_OK_LABEL"),p.translate("LIBS_PROCESS_CANCEL_LABEL")).then(t=>t?r.addCertificateToTrustStore(this._dCertificateLocation,"Adobe Creative Cloud"):(function(e){const t=l.getValue("IDS_DECLINED_TO_TRUST_CERT")||{};t[e]=!0,l.setValue("IDS_DECLINED_TO_TRUST_CERT",t)}(e),Promise.reject(new Error("User declined to trust the certificate")))).then(()=>this._config.certificateIsTrusted=!0))).then(()=>this._enableSystemCertificatesInFirefox()).catch(e=>o.log(m,"Failed to trust the certificate: ",e)).then(()=>this._config.trustInProgress=!1))}_uploadServerData(e){if(this._config.dataUploadInProgress[e])return;const t=h.getLoadedCollections().find(e=>!e.isPublic);if(!t)return o.log(m,`Upload secret token info for ${e} failed as there is no private collection loaded`);const i=_.uuid();this._config.dataUploadInProgress[e]=!0,o.log(m,`Uploading secret token info for ${e} to the server`),t._syncManager.pushClientTokenInfo(e,{token:i,deviceID:this._deviceID,port:this.wssPort},t=>{o.log(m,`Upload secret token info for ${e} was ${t?"failure":"success"}`),l.addWSSToken(i),this._config.dataUploaded[e]=!t,this._config.dataUploadInProgress[e]=!1})}_sniCallback(e,t){const i=()=>t("error"),n=e.split(".",4);if(n.some(function(e){return!e})||n[2]!==g||n[3]!==E)return o.log(m,`serverName received is not as per the requirement: ${e}`),void setImmediate(i);if(!this._isUserHashValid(n[1]))return o.log(m,`userHash does not match: ${n[1]}`),void setImmediate(i);const r=n[0];return function(e){const t=l.getValue("IDS_DECLINED_TO_TRUST_CERT")||{};return Boolean(t[e])}(r)&&!this._config.certificateIsTrusted?(o.log(m,"user has declined to trust the certificate"),setTimeout(i,this._config.delayOnDecline)):this._config.certificateIsTrusted?this._config.dataUploaded[r]?void setTimeout(i,this._config.delayOnReady):(this._uploadServerData(r),setImmediate(i)):(this._initiateCertificateTrustProcess(r),setImmediate(i))}get sniPort(){return this._config.sniPort}get wssPort(){return l.getValue("WSS_PORT")||0}waitForInitialization(){return this._initializationPromise?this._initializationPromise:Promise.reject("TLSServer not yet initialized")}_initialize(){const e=u.TLS_DISCOVERY_PORT_RANGE,t=this.wssPort;let i,n;const r=this._sniCallback.bind(this);this._initializationPromise=this._ensureIdentityExists().then(t=>(i=a.readFileSync(t.cert),n=a.readFileSync(t.key),this._dCertificateLocation=t.dCert,function e(t,i,n,o,r){return o>r?Promise.reject(new Error("None of the ports in the specified range are available")):L({cert:t,key:i,SNICallback:n},o,"TLSDiscoveryServer").catch(()=>e(t,i,n,++o,r))}(i,n,r,e[0],e[1]))).then(e=>(this._sniServer=e,this._config.sniPort=e.address().port,L({cert:i,key:n},t,"wssUnderlyingServer"))).then(e=>{this._wssUnderlyingServer=e,l.setValue("WSS_PORT",e.address().port),this._wssServer=new d.Server({server:this._wssUnderlyingServer}),this._wssServer.on("connection",this._onConnection)}).catch(e=>(o.log(m,"Failed to launch tlsServer",e),Promise.reject(e)))}close(){this._sniServer&&this._sniServer.close(),this._wssServer&&this._wssServer.close(),this._wssUnderlyingServer&&this._wssUnderlyingServer.close(),this._sniServer=null,this._wssServer=null,this._wssUnderlyingServer=null,this._initializationPromise=null,this._config=S()}}},function(e,t){e.exports=require("node_ssl")},function(e,t,i){const n=i(42),o=i(27),r=i(5),a=i(0),s=i(3),c=i(23),l=i(6),d="CDN Cache";e.exports=class{constructor(){this._listenerManager=new r(["change"]),a.SHA_CACHE=s.getValue("SHA_CACHE")||{},s.getValue("CDN_REFRESH_INTERVAL")&&this._fetch()}get _cacheBaseURL(){return`https://${s.getEnvironment().SHA_CDN_HOST}${s.getValue("CDN_CACHE_ROOT")}`}_fetch(){const e=this._cacheBaseURL+s.getValue("CDN_CACHE_FILE");l.log(d,`Fetching SHA Cache from CDN: ${e}`);const t=Object.assign({},n.parse(e),c.getNodeTunnelOptionsForURL(e));o.get(t,e=>{const t=e&&e.statusCode;if(200!==t)return void this._onFetchError(`status code: ${t}`);let i="";e.on("data",e=>i+=e),e.on("end",()=>{let e;try{e=JSON.parse(i)}catch(e){return void this._onFetchError(e)}this._onFetchSuccess(e||{})})}).once("error",e=>this._onFetchError(e))}_onFetchSuccess(e){const t=this._cacheBaseURL;Object.keys(e).forEach(i=>{e[i]=`${t}${e[i]}`}),a.SHA_CACHE=e,s.setValue("SHA_CACHE",e),this._listenerManager.notify("change"),setTimeout(()=>this._fetch(),s.getValue("CDN_REFRESH_INTERVAL"))}_onFetchError(e){l.log(d,`Error fetching SHA Cache: ${e}`),setTimeout(()=>this._fetch(),s.getValue("CDN_RETRY_INTERVAL"))}addChangeListener(e){this._listenerManager.add("change",e)}removeChangeListener(e){this._listenerManager.remove("change",e)}removeAllListeners(){this._listenerManager.removeAll("change")}}},function(e,t,i){const n=i(62);e.exports=class{constructor(){this._channels=[]}newChannel(e,t){const i=new n(e,t);return this._channels.push(i),i.onClose(()=>{var e=this._channels.indexOf(i);-1!==e&&this._channels.splice(e,1),i.shutdown()}),i}numChannels(){return this._channels.length}broadcast(e,t,i){this._channels.forEach(n=>{i&&n===i||n.send(e,t)})}getPendingWriteState(e,t,i,n){var o=!1;return this._channels.forEach(r=>{o=o||r.getPendingWriteState(e,t,i,r===n)}),o}}},function(e,t){e.exports=require("idle-gc")}]);