/************************************************************************!
*
* ADOBE CONFIDENTIAL
* ___________________
*
* Copyright 2015-2019 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/!function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(o,i,function(t){return e[t]}.bind(null,i));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=64)}([function(e,t,n){var o=n(2),i=["ROOT_DIR","POLL_INTERVAL","RENDITION_SIZES","FULL_RENDITION_CONFIG","EXTERNAL_LINK_PREFETCH","LOCALE","STORAGE_API_KEY","USER_AGENT_HEADER","SYNC_POLICY","ELEMENT_TYPE_FILTERS","AUTO_START_POLLING","SHARED_LOCAL_STORAGE","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.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=15,r.prototype.SHARED_LOCAL_STORAGE_MIN_CLIENT_VERSION=6,r.prototype.SHARED_LOCAL_STORAGE_MAX_CLIENT_VERSION=15,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===i.indexOf(e))throw new o(o.INVALID_PARAMETER,"Parameter not configurable");if("SYNC_POLICY"===e&&-1===this.VALID_SYNC_POLICIES.indexOf(t))throw new o(o.INVALID_PARAMETER,"Invalid value for SYNC_POLICY");"POLL_INTERVAL"===e&&(t=Math.max(1,t)),this[e]=t},Object.freeze(r),Object.seal(r.prototype),e.exports=new r},function(e,t,n){var o=n(48);function i(){this.uuid=n(50),this.fs=n(20),this.crypto=n(41),this.path=n(14),this.imageSize=n(69),this.yazl=n(56),this.yauzl=n(57),this._initDCX()}i.prototype._initDCX=function(){var e=this;this.dcx=new o(this.fs,{preserveFileExtensions:!0,logCallback(t){e._log&&e._log("DCX: "+t)}})},i.prototype.uuid=function(){return this.uuid()},i.prototype.log=function(e){this._log&&this._log("CC Libraries: "+e)},i.prototype.getDisplayName=function(e){return this._getDisplayName?this._getDisplayName(e):e.name},i.prototype.hasFileSystem=function(){return void 0!==this.fs},i.prototype.setFileSystem=function(e){this.fs=e,this._initDCX()},i.prototype.hasRenditionGenerator=function(){return void 0!==this.renditionGenerator},i.prototype.setRenditionGenerator=function(e){this.renditionGenerator=e},i.prototype.getVulcanInterface=function(){if("undefined"!==typeof VulcanInterface)return VulcanInterface},i.prototype.getVulcanMessage=function(){if("undefined"!==typeof VulcanMessage)return VulcanMessage},i.prototype.hasCEPVulcan=function(){return void 0!==this.getVulcanInterface()&&void 0!==this.getVulcanMessage()},i.prototype.getNodeTunnelOptions=function(e){return this._getNodeTunnelOptions?this._getNodeTunnelOptions(e):{}},i.prototype.getPathSeparator=function(){return"/"},i.prototype.getFileNameFromPath=function(e){return-1===e.indexOf("/")&&-1!==e.indexOf("\\")&&(e=e.replace(/\\/g,"/")),e.split("/").pop()},Object.freeze(i),Object.seal(i.prototype),e.exports=new i},function(e,t){var n=["INVALID_PARAMETER","READ_ONLY","NOT_IMPLEMENTED","NOT_SUPPORTED","REQUIRES_FILESYSTEM","DELETED_LOCALLY"];function o(e,t,i,r){if(-1!==n.indexOf(e))if(Error.call(this),Error.captureStackTrace)Error.captureStackTrace(this,o);else{var a=new Error;a.name=this.name,this.stack=a.stack}this.code=e,this._message=t,this.message="["+e+"] "+t,this.libraryId=i,this.underlyingError=r}o.prototype=Object.create(Error.prototype),o.prototype.name="AdobeLibraryError",o.INVALID_PARAMETER="INVALID_PARAMETER",o.READ_ONLY="READ_ONLY",o.NOT_IMPLEMENTED="NOT_IMPLEMENTED",o.NOT_SUPPORTED="NOT_SUPPORTED",o.REQUIRES_FILESYSTEM="REQUIRES_FILESYSTEM",o.DELETED_LOCALLY="DELETED_LOCALLY",o.NOT_ALLOWED="NOT_ALLOWED",o.FILE_TOO_LARGE="FILE_TOO_LARGE",o.EXCEEDS_MAX_LIBRARY_SIZE="EXCEEDS_MAX_LIBRARY_SIZE",o.CORRUPTED_LIBRARY="CORRUPTED_LIBRARY",o.THUMBNAIL_NOT_AVAILABLE="THUMBNAIL_NOT_AVAILABLE",o.STALE_THUMBNAIL="STALE_THUMBNAIL",o.RENDITION_NOT_AVAILABLE="RENDITION_NOT_AVAILABLE",o.FS_ERROR="FS_ERROR",o.OUT_OF_SPACE="OUT_OF_SPACE",o.LOGGED_OUT="LOGGED_OUT",o.EXCEEDS_QUOTA="EXCEEDS_QUOTA",o.RETRYABLE_SERVER_ERROR="RETRYABLE_SERVER_ERROR",o.TRANSFER_ERROR="TRANSFER_ERROR",o.TRANSFER_ABORTED="TRANSFER_ABORTED",o.NETWORK_ERROR="NETWORK_ERROR",o.ACCESS_DENIED="ACCESS_DENIED",o.URL_VALIDATION_FAILED="URL_VALIDATION_FAILED",o.NO_COMPATIBLE_APP_FOUND="NO_COMPATIBLE_APP_FOUND",o.APP_LAUNCH_FAILED="APP_LAUNCH_FAILED",o.OPERATION_CANCELLED="OPERATION_CANCELLED",o.INVALID_DATA="INVALID_DATA",Object.freeze(o),Object.seal(o.prototype),e.exports=o},function(e,t,n){var o=n(20),i=n(39),r=n(1),a=n(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_RESET:50,CDN_CACHE_ROOT:"/v1/",CDN_CACHE_FILE:"contents.json",CDN_REFRESH_INTERVAL:864e5,CDN_RETRY_INTERVAL:18e5,REST_API_VERSION:3,REST_API_MIN_VERSION:2,REST_API_MAX_VERSION:3,PRODUCT_LAUNCHER_SUPPORTED_PRODUCTS:{illustrator:"ILST",photoshop:"PHXS",indesign:"IDSN",premierepro:"PPRO",aftereffects:"AEFT",flash:"FLPR",euclid:"ESHR",creativecloud:"ADCS"},PRODUCT_BRIDGE_ELEMENT_TYPES:["application/vnd.adobe.element.image+dcx","application/vnd.adobe.element.video+dcx","application/vnd.adobe.element.3d+dcx","application/vnd.adobe.element.template+dcx","application/vnd.adobe.element.text+dcx","application/vnd.adobe.element.animation+dcx"],PRODUCT_BRIDGE_INMEMORY_LIFETIME:6e5,EXTERNAL_LINK_PREFETCH:{"application/vnd.adobe.element.video+dcx":!1}},l={staging:{LABEL:"Staging",CLIENT_ID:"ProjectCentral16",CLIENT_SECRET:"5c597af3-e18a-41bc-8b65-82fd532e5f12",STORAGE_HOST:"cc-api-storage-stage.adobe.io",CCWEB_HOST:"assets-stage.adobecc.com",CCLIB_HOST:"cc-api-assets-stage.adobe.io",COLLAB_HOST:"cc-collab-stage.adobe.io",CC_IMAGE_HOST:"cc-api-image-stage.adobe.io",CC_IMAGE_X_HOST:"cc-api-image-x-stage.adobe.io",PUBLIC_HOSTS:[{host:"public-stage.adobecc.com"},{host:"drakozoxj1229.cloudfront.net",community_platform:!0},{host:"cdn-stage.cp.adobe.io",community_platform:!0}],TYPEKIT_HOST:"cctypekit-relstage.adobe.io",IMS:"ims-na1-stg1.adobelogin.com",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",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();o.writeFileSync(c.ROOT_DIR+t,e),o.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=o.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=o.readFileSync(c.CC_DIR+c.CC_SETTINGS_FILE,"utf8");new i.Parser({async:!1}).parseString(t,function(t,n){t||n.C3Config.config[0].namespace.forEach(function(t){t&&t.$&&t.$.name&&"accc.container"===t.$.name&&t.property.forEach(function(t){t&&t.$&&t.$.name&&"IMS_ENV"===t.$.name&&"STG"===t._&&(e=!0)})})})}catch(e){}return e}()&&(c.ENVIRONMENT="staging"),process.argv.forEach(function(e){"--debug"===e&&(c.CONSOLE_LOGGING=!0)}),c.CONSOLE_LOGGING||console.log(`Outputting logs to: ${c.LOG_DIR}\nTo view log messages on the console, use the --debug argument`),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 n(e,t,o){if(Error.call(this),Error.captureStackTrace)Error.captureStackTrace(this,n);else{var i=new Error;i.name=this.name,this.stack=i.stack}this.code=e,this.message="["+e+"] "+t,this.underlyingError=o}n.prototype=Object.create(Error.prototype),n.prototype.name="AdobeDCXError",n.INVALID_JSON="INVALID_JSON",n.READ_ONLY="READ_ONLY",n.INVALID_PARAMS="",n.INVALID_DATA="INVALID_DATA",n.DUPLICATE_VALUE="DUPLICATE_VALUE",n.NO_LOCAL_STORAGE="NO_LOCAL_STORAGE",n.INVALID_STATE="INVALID_STATE",n.DELETED_COMPOSITE="DELETED_COMPOSITE",n.UNEXPECTED_RESPONSE="UNEXPECTED_RESPONSE",n.NETWORK_ERROR="NETWORK_ERROR",n.COMPONENT_DOWNLOAD_ERROR="COMPONENT_DOWNLOAD_ERROR",n.COMPONENT_UPLOAD_ERROR="COMPONENT_UPLOAD_ERROR",n.COMPONENT_MODIFIED_ERROR="COMPONENT_MODIFIED_ERROR",n.UPDATE_CONFLICT="UPDATE_CONFLICT",n.NO_COMPOSITE="NO_COMPOSITE",n.ALREADY_EXISTS="ALREADY_EXISTS",n.SERVICE_IS_INACTIVE="SERVICE_IS_INACTIVE",n.EXCEEDS_QUOTA="EXCEEDS_QUOTA",n.NOT_IMPLEMENTED="NOT_IMPLEMENTED",n.RETRYABLE_SERVER_ERROR="RETRYABLE_SERVER_ERROR",n.TIMED_OUT="TIMED_OUT",n.UNEXPECTED="UNEXPECTED",n.TERMINATED_INPUTSTREAM="TERMINATED_INPUTSTREAM",n.WRONG_ENDPOINT="WRONG_ENDPOINT",n.OUT_OF_SPACE="ENOSPC";var o={};o[n.SERVICE_IS_INACTIVE]=1,o[n.NOT_IMPLEMENTED]=1,o[n.EXCEEDS_QUOTA]=1,o[n.RETRYABLE_SERVER_ERROR]=1,o[n.TIMED_OUT]=1,o[n.TERMINATED_INPUTSTREAM]=1,o[n.WRONG_ENDPOINT]=1,o[n.OUT_OF_SPACE]=1,n.wrapError=function(e,t,i,r){if(!i||!o[i.code]){if(r){var a=r.statusCode;a>=500&&a<600&&(501===a?(e=n.NOT_IMPLEMENTED,t="Unimplemented request"):507===a?(e=n.EXCEEDS_QUOTA,t="Quota exceeded"):(e=n.RETRYABLE_SERVER_ERROR,t="Server error"))}i=new n(e,t,i)}return r&&(i.response=r),i},n.networkError=function(e,t,o){return n.wrapError(n.NETWORK_ERROR,e,t,o)},n.unexpectedResponse=function(e,t,o){return n.wrapError(n.UNEXPECTED_RESPONSE,e,t,o)},e.exports=n},function(e,t,n){var o=n(1),i=n(2);function r(e){this._restrictedTypes=e,this._listeners={}}r.prototype._checkType=function(e){if(this._restrictedTypes&&-1===this._restrictedTypes.indexOf(e)){var t="["+this._restrictedTypes.join(", ")+"]";throw new i(i.INVALID_PARAMETER,e+" is not allowed. Should be one of: "+t)}},r.prototype.add=function(e,t){this._checkType(e),this._listeners[e]=this._listeners[e]||[],this._listeners[e].push(t)},r.prototype.remove=function(e,t){this._checkType(e);var n=this._listeners[e];if(n){var o=n.indexOf(t);-1!==o&&n.splice(o,1)}},r.prototype.removeAll=function(e){e?(this._checkType(e),delete this._listeners[e]):this._listeners={}},r.prototype.notify=function(e,t){this._checkType(e);var n=this._listeners[e];n&&n.slice(0).forEach(function(e){try{e.apply(void 0,t||[])}catch(e){o.log("Error in listener callback: "+(e?e.toString():"")),e&&e.stack&&o.log(e.stack)}})},r.prototype.hasListeners=function(e){this._checkType(e);var t=this._listeners[e];return!!(t&&t.length>0)},r.prototype.forEach=function(e){var t=this._listeners;Object.keys(t).forEach(function(n){t[n].forEach(function(t){e(n,t)})})},Object.freeze(r),Object.seal(r.prototype),e.exports=r},function(e,t,n){var o,i=n(20),r=n(3),a=n(5),s=n(8),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 u(e,t,n){i.exists(t,function(o){i.exists(e,function(r){r&&!o?i.rename(e,t,n):n(null)})})}function _(e){!function(e){if(h)e(null);else{h=!0;var t=r.getValue("LOG_DIR")+"log.txt";u(r.getValue("LOG_DIR")+"log_prev.txt",l,function(){u(t,c,e)})}}(function(){i.stat(c,function(t,n){!t&&n.size>r.getValue("MAX_LOG_SIZE")?i.rename(c,l,e):e(null)})})}var f={};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";o?o+=t:(o=t,d||function e(){s.ensurePathExists(r.getValue("LOG_DIR"),function(t){if(t)return o=void 0,void console.error(t);_(function(t){if(t)return o=void 0,void console.error(t);var n=o;o=void 0,d=!0,i.appendFile(c,n,function(t){t&&console.error(t),d=!1,o&&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,n){var o,i;o=n(50);var r={_setLogCallback:function(e){i=e},merge:function(e){var t,n;for(t=1;t<arguments.length;++t){var o=arguments[t];if("object"==typeof o)for(n in o)o.hasOwnProperty(n)&&(e[n]=o[n])}return e},parentDirectory:function(e){var t=e.split("/");return t.pop(),t.join("/")},filePathComponents:function(e){var t=e.split("/"),n=t.pop(),o=n.split("."),i=o.length>1?o.pop():null;return{directory:t.join("/"),fileName:n,baseName:o.join("."),extension:i}},appendPathElements:function(){var e,t=[],n=arguments.length;for(e=0;e<n;e++){var o=arguments[e];"string"==typeof o&&""!==o&&(0===e&&1!==o.length||"/"===o.charAt(0)&&(o=o.slice(1)),e!==n-1&&"/"===o.charAt(o.length-1)&&(o=o.slice(0,o.length-1)),t.push(o))}return t.join("/")}},a=/^[^\u0000-\u001F\u0022\u002A\u003A\u003C\u003E\u003F\u005C\u007F]*[^\u0000-\u001F\u0022\u002A\u002E\u003A\u003C\u003E\u003F\u005C\u007F]{1}$/;r.isValidPath=function(e,t){try{if(e.length>65535)return!1;var n=(t?e.slice(1):e).split("/");if(!n||0===n.length)return!1;var o,i=n.length;for(o=0;o<i;o++){if(n[o].length>255||!a.test(n[o]))return!1}if(t&&n.length>0){var r=n[0];if("manifest"===r||"mimetype"===r)return!1}return!0}catch(e){return!1}},r.isValidAbsolutePath=function(e){return r.isValidPath(e,!0)};var s=r.noOp=function(){};r.consumeStream=function(e,t,n){e.on("data",n||s),e.on("end",t||s)},r.flatCopy=function(e){var t,n={},o=Object.keys(e),i=o.length;for(t=0;t<i;t++){var r=o[t];n[r]=e[r]}return n},r.deepCopy=function(e){return JSON.parse(JSON.stringify(e))},r.objectsEqual=function(e,t,n){var o,i,a={},s=Object.keys(e),c=s.length;for(i=0;i<c;i++){if(o=s[i],!n||!n[o]){var l=e[o],d=t[o],p=typeof l;if(p!==typeof d)return!1;if("object"===p){if(!r.objectsEqual(l,d,n))return!1}else if(l!==d)return!1}a[o]=!0}for(c=(s=Object.keys(t)).length,i=0;i<c;i++)if(!a[o=s[i]])return!1;return!0};var c=new RegExp("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?");r.parseURI=function(e){var t=e.match(c);return{scheme:t[2],authority:t[4],path:t[5],query:t[7],fragment:t[9]}},r.endPointOf=function(e){var t,n=r.parseURI(e),o=n.scheme,i=n.authority,a="https"===o?443:"http"===o?80:-1;return o&&i&&(t=(o+"://"+i).toLowerCase(),a>=0&&i.indexOf(":")<0&&(t=t+":"+a)),t},r.ensureRelativeHrefStartsWithSlash=function(e){if(e){var t=r.parseURI(e),n=t.scheme,o=t.authority;n||o||"/"!==e.charAt(0)&&(e="/"+e)}return e};var l=/^([^:]+):(.*)$/,d=/^\s+|\s+$/g;r.parseHeaders=function(e){var t,n,o,i={},r=e.split(/\r?\n/);for(t=0;t<r.length;++t){var a=r[t];if(a.length>0){var s=a.charCodeAt(0);if(!n||9!==s&&32!==s){var c=l.exec(a);c&&c.length>1&&(n=c[1].toLowerCase(),o=(o=c[2]||"").replace(d,""),i[n]?i[n]=i[n]+","+o:i[n]=o)}else i[n]=i[n]+" "+a.replace(d,"")}}return i},r.timeStamp=function(e){var t=(new Date).getTime();return e&&(t-=t%1e3),t},r.generateUuid=o,r.log=function(e){if("function"==typeof i)try{i(e)}catch(e){}},e.exports=r},function(e,t,n){var o=n(1),i=n(9),r=n(11),a=n(0),s=n(2),c=["bmp","cur","gif","ico","jpeg","jpg","png","psd","tiff","tif","webp","svg","dds"],l={},d=function(e){return e+".TEMP_"+o.uuid()};const p=function(e,...t){const n=o.fs,i=t.find(e=>"function"==typeof e),r=t.slice(0,t.indexOf(i)),s=t.indexOf(i)===t.length-1?0:t[t.length-1];n[e].apply(n,r.concat((t,...n)=>{t&&"EPERM"===t.code&&s<a.FS_MAX_RETRIES?setTimeout(function(){p(e,...r,i,s+1)},a.FS_RETRY_INTERVAL):i(t,...n)}))};l.ensurePathExists=function(e,t){var n=o.getPathSeparator(),i=o.fs;!function e(t,o,r){var a=o.slice(0,t).join(n),s=function(){t<o.length?e(t+1,o,r):r(null)};i.exists(a,function(e){e?s():i.mkdir(a,s)})}(2,e.replace(/\\/g,n).split(n),t)},l.copyFile=function(e,t,n){var i=o.fs;try{var r=d(t),a=i.createWriteStream(r),s=i.createReadStream(e),c=!1;s.on("end",function(){c||p("rename",r,t,n)}),s.on("error",function(e){c=!0,n(e)}),s.pipe(a)}catch(e){n(e)}},l.getAvailablePath=function(e,t,n,o=0){let i=t.lastIndexOf(".");i=-1===i?t.length:i;const r=t.substring(0,i),a=t.substring(i+1),s=`${o?` (${o})`:""}${a?`.${a}`:""}`,c=255-d("").length-s.length;let p=r.substr(0,c);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}`;l.statFile(h,function(i){i&&i.underlyingError&&"ENOENT"===i.underlyingError.code?n(null,h):i?n(i):l.getAvailablePath(e,t,n,o+1)})},l.rename=function(e,t,n){p("rename",e,t,n)},l.deleteFile=function(e,t){p("unlink",e,t)},l.normaliseTempFileName=function(e){return function(e){var t=e.match(/(.*)\.TEMP_[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i);return t&&t[1]?t[1]:e}(e)},l.getFileExtension=function(e){var t=e&&e.replace(/^.*[\\/]/,""),n=t?t.lastIndexOf("."):-1;if(-1!==n)return t.substr(n+1).toLowerCase()},l.recursiveDeleteDirectory=function(e,t){var n=o.getPathSeparator(),i=o.fs,r=function(e){e&&"ENOENT"===e.code&&(e=null),t&&t(e)};p("readdir",e,function(t,o){if(t)r(t);else if(o&&0!==o.length){var a=null,s=0;o.forEach(function(t){var o=e+n+t;p("readdir",o,function(e){e?i.unlink(o,c):l.recursiveDeleteDirectory(o,c)})})}else i.rmdir(e,r);function c(t){t&&"ENOENT"===t.code&&(t=null),a=a||t,++s===o.length&&(a?r(a):i.rmdir(e,r))}})},l.getUserDir=function(e){const t=o.getPathSeparator(),n=e.replace(/@/g,"_");return a.ROOT_DIR+t+n},l.moveLibrary=function(e,t,n){if(t!==e.id){var o=e._collection._getCompositeDir(t),i=e._getCompositeDir(),r=e._collection._getRenditionCacheDir(t),a=e._getRenditionCacheDir();l.rename(o,i,function(t){t?n(t):(e._dcxComposite.path=i,l.rename(r,a,e=>n(e&&"ENOENT"===e.code?null:e)))})}else n(null)},l.readLibraryDirectory=function(e,t){var n=e._getTempDir();l.recursiveDeleteDirectory(n,function(){var n=e._getCompositeDir();p("readdir",n,t)})},l.doesRootDirExist=function(e,t){var n=o.fs,i=e._getCompositeDir();n.exists(i,function(e){t(null,e)})},l.deleteLibraryFromDisk=function(e,t,n){var r=i.wrapCallback(n);if(o.hasFileSystem()){var a=e._getCompositeDir(t),s=e._getRenditionCacheDir(t);l.recursiveDeleteDirectory(a,function(){l.recursiveDeleteDirectory(s,r)})}else r(null)},l.writeJSONData=function(e,t,n){const i=o.fs;return new Promise((r,a)=>{l.ensurePathExists(e,s=>{if(s)return void a(s);const c=e+o.getPathSeparator()+t,l=c+".TEMP_"+o.uuid();i.writeFile(l,JSON.stringify(n,void 0,2),"utf8",e=>{e?a(e):p("rename",l,c,e=>e?a(e):r(c))})})})},l.readJSONData=function(e){const t=o.fs;return new Promise((n,o)=>{t.readFile(e,"utf8",function(e,t){if(e)"ENOENT"===e.code?n():o(e);else try{const i=t&&JSON.parse(t);n("object"==typeof i?i:void 0)}catch(e){o(e)}})})},l.statFile=function(e,t){o.fs.stat(e,function(e,n){e?t(r.getFileSystemError(e,"unable to stat file")):t(null,n)})},l.checkFileSize=function(e,t){l.statFile(e,function(e,n){e?t(e):n&&n.size>a.MAX_COMPONENT_SIZE?t(new s(s.FILE_TOO_LARGE,"Exceeds maximum file size")):t(null)})},l.computeSHA=function(e){const t=o.fs,n=o.crypto;return new Promise((o,i)=>{const r=n.createHash("sha256");r.setEncoding("hex");const a=t.createReadStream(e);a.on("error",e=>i(e)),r.on("finish",()=>o(r.read())),a.pipe(r)})},l.getImageDimensions=function(e,t){var n=l.getFileExtension(e);!n||c.includes(n)?a.SHARED_LOCAL_STORAGE?o.storageInterface.getImageDimensions(e,t):o.imageSize(e,function(e,n){t(n)}):t()},Object.seal(l),e.exports=l},function(e,t){var n={wrapCallback:function(e){return function(){e&&e.apply(this,arguments)}},constructStringFromTemplate:function(e,t){var n=e;return Object.keys(t).forEach(function(e){n=n.replace("{{"+e+"}}",t[e])}),n},parseLocalisationFile:function(e){var t,n,o,i,r={},a=0,s=e.split(/\n/);for(a=0;a<s.length;a++)if(s[a]=s[a].replace(/^\s\s*/,"").replace(/\s\s*$/,""),s[a].length>0&&"#"!==s[a].match("^#")){for(n=(t=s[a].split("="))[0].replace(/^\s\s*/,"").replace(/\s\s*$/,""),o=1===t.length?"":t[1];o.match(/\\$/)&&"\\"===o.match(/\\$/).toString();)o=o.substring(0,o.length-1),o+=s[++a].replace(/\s\s*$/,"");for(i=2;i<t.length;i++)o+="="+t[i];o=o.replace(/^\s\s*/,"").replace(/\s\s*$/,""),r[n]=o}return r},compareVersions:function(e,t){if(e=(e||"0").toString().replace(/(\.0)*$/,"").replace(/[^.0-9]+/gim,"."),t=(t||"0").toString().replace(/(\.0)*$/,"").replace(/[^.0-9]+/gim,"."),(isNaN(parseInt(e,10))||parseInt(e,10)>250)&&(e="0"),(isNaN(parseInt(t,10))||parseInt(t,10)>250)&&(t="0"),e===t)return 0;var n,o,i=e.split("."),r=t.split(".");for(n=0;n<i.length&&n<r.length;n++){if(o=parseInt(i[n],10)-parseInt(r[n],10),isNaN(o))return isNaN(parseInt(i[n],10))?1:-1;if(o>0)return-1;if(o<0)return 1}return(o=i.length-r.length)>0?-1:o<0?1:0}};Object.seal(n),e.exports=n},function(e,t,n){var o=n(1),i=n(0),r=n(44),a=n(61),s=n(106),c=n(2),l=n(19),d=n(107),p=n(110),h=n(111),u=n(8),_=n(15),f=new s,m={};function E(e,t,n){var o=e+"/"+t,i=void 0!==m[o];return m[o]=m[o]||[],m[o].push(n),i}function g(e,t){var n;n=e===i.PUBLIC_USER_ID?f.getPublicLibraryCollection(t):f.getLibraryCollection(e,t);var o=e+"/"+t,r=m[o];r&&(delete m[o],r.forEach(function(e){e(null,n)}))}var y={configure:function(e,t){if(o.hasFileSystem()||void 0!==t.SHARED_LOCAL_STORAGE||(t.SHARED_LOCAL_STORAGE=!1),o.hasFileSystem()&&!t.ROOT_DIR&&!1===t.SHARED_LOCAL_STORAGE)throw new c(c.INVALID_PARAMETER,"Missing ROOT_DIR option");if(o.hasFileSystem()&&t.ROOT_DIR&&!1!==t.SHARED_LOCAL_STORAGE)throw new c(c.INVALID_PARAMETER,"ROOT_DIR option doesn't apply when using shared local storage");if(!o.hasFileSystem()&&t.ROOT_DIR)throw new c(c.REQUIRES_FILESYSTEM,"ROOT_DIR option only applies when you have a filesystem");if(!1===t.SHARED_LOCAL_STORAGE&&!t.STORAGE_API_KEY)throw new c(c.INVALID_PARAMETER,"Missing STORAGE_API_KEY option");if(!1===t.SHARED_LOCAL_STORAGE&&!t.DEVICE_ID)throw new c(c.INVALID_PARAMETER,"Missing DEVICE_ID option");if(!1!==t.SHARED_LOCAL_STORAGE&&!o.hasCEPVulcan()&&!e.vulcanCall)throw new c(c.INVALID_PARAMETER,"Shared local storage requires either the CEP VulcanInterface/VulcanMessage as globals, or for you to pass in the vulcanCall dependency");if(!t.APP_DESCRIPTION)throw new c(c.INVALID_PARAMETER,'Missing APP_DESCRIPTION option - should be a string of the form <name>-<version>, e.g. "PHXS-16.0".');if(t.ROOT_DIR)for(;-1!==["/","\\"].indexOf(t.ROOT_DIR.substr(-1));)t.ROOT_DIR=t.ROOT_DIR.slice(0,-1);t.LOCALE&&(l.setLocale(t.LOCALE),delete t.LOCALE),Object.keys(t).forEach(function(e){i.setParameter(e,t[e])}),o.analytics=e.analytics,o.vulcanCall=e.vulcanCall,o._log=e.log,o._getDisplayName=e.getDisplayName,o._getNodeTunnelOptions=e.getNodeTunnelOptions,e.renditionGenerator&&o.setRenditionGenerator(e.renditionGenerator),o.storageInterface&&o.storageInterface.shutdown(),o.storageInterface=new d(f),o.log("Configure: "+(i.SHARED_LOCAL_STORAGE?"<shared local storage>":i.ROOT_DIR))},setOption:function(e,t){if(-1!==["ROOT_DIR","SHARED_LOCAL_STORAGE","ELEMENT_TYPE_FILTERS","STORAGE_API_KEY"].indexOf(e))throw new c(c.INVALID_PARAMETER,"Cannot reconfigure "+e);i.setParameter(e,t),o.storageInterface.updateConfiguration()},getOption:function(e){return i[e]},setLocalSetting:function(e,t){if("string"!=typeof e)throw new c(c.INVALID_PARAMETER,"Key must be a string");try{JSON.stringify(t)}catch(e){throw new c(c.INVALID_PARAMETER,"Value must be serializable to JSON")}i.LOCAL_SETTINGS[e]=t,o.storageInterface.updateConfiguration()},getLocalSetting:function(e){return i.LOCAL_SETTINGS[e]},getSNISettings:function(){return{TLS_DISCOVERY_PORT_RANGE:i.TLS_DISCOVERY_PORT_RANGE,TLS_DELAY_ON_DECLINE:2*i.TLS_DELAY_ON_DECLINE,TLS_DELAY_ON_READY:2*i.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(!o.hasFileSystem())throw new c(c.REQUIRES_FILESYSTEM,"ROOT_DIR option only applies when you have a filesystem");return i.ROOT_DIR},getLocale:function(){return l.getLocale()},unloadLibraryCollection:function(e){if(i.SHARED_LOCAL_STORAGE)throw new c(c.NOT_SUPPORTED,"unloadLibraryCollection() not supported with shared local storage");e.stopPolling(),e._removeAllListeners(),f.removeLibraryCollection(e)},loadLibraryCollection:function(e,t){if("function"!=typeof e)if(i.SHARED_LOCAL_STORAGE)t(new c(c.NOT_SUPPORTED,"loadLibraryCollection() not supported with shared local storage"));else if(!o.hasFileSystem()||i.SHARED_LOCAL_STORAGE||i.ROOT_DIR)if(e=e||{},!o.hasFileSystem()||e.USER_ID)if(e.CLOUD_ID=e.CLOUD_ID||i.DEFAULT_CLOUD_ID,e.STORAGE_HOSTNAME)if(e.COLLABORATION_HOSTNAME)if(e.CC_IMAGE_HOSTNAME)if(e.CC_IMAGE_X_HOSTNAME)if(e.TYPEKIT_HOSTNAME){var n=f.getLibraryCollection(e.USER_ID,e.CLOUD_ID),a=E(e.USER_ID,e.CLOUD_ID,t);if(!n||a){if(!a)if(n=new r(e),o.hasFileSystem())u.doesRootDirExist(n,function(e,t){n._load(function(){t||n._setInitialSyncState(!0),n.sync(function(){n._setInitialSyncState(!1)}),l()})});else if("all"===e.WAIT_FOR)n._setInitialSyncState(!0),n.sync(function(){n._setInitialSyncState(!1),l()});else if(_.validateLibraryId(e.WAIT_FOR,!1)){n._setInitialSyncState(!0,[e.WAIT_FOR]),n.sync(function(){n._setInitialSyncState(!1)});var s=function(){"syncing"===n.syncState&&"pending"===n._libraryIdMap[e.WAIT_FOR]||(n.removeChangeListener(s),n.removeSyncListener(s),l())};n.addChangeListener(s),n.addSyncListener(s)}else n._setInitialSyncState(!0),n.sync(function(){n._setInitialSyncState(!1)}),l()}else g(e.USER_ID,e.CLOUD_ID)}else t(new c(c.INVALID_PARAMETER,"Missing TYPEKIT_HOSTNAME option"));else t(new c(c.INVALID_PARAMETER,"Missing CC_IMAGE_X_HOSTNAME option"));else t(new c(c.INVALID_PARAMETER,"Missing CC_IMAGE_HOSTNAME option"));else t(new c(c.INVALID_PARAMETER,"Missing COLLABORATION_HOSTNAME option"));else t(new c(c.INVALID_PARAMETER,"Missing STORAGE_HOSTNAME option"));else t(new c(c.INVALID_PARAMETER,"Missing USER_ID option"));else t(new c(c.INVALID_PARAMETER,"ROOT_DIR not configured. Make sure you call CCLibraries.configure()"));else(t=e)(new c(c.INVALID_PARAMETER,"options argument not specified"));function l(){f.addLibraryCollection(n),i.AUTO_START_POLLING&&n.startPolling(),g(e.USER_ID,e.CLOUD_ID)}},loadPublicLibraryCollection:function(e,t){if("function"!=typeof e)if(i.SHARED_LOCAL_STORAGE)t(new c(c.NOT_SUPPORTED,"loadPublicLibraryCollection() not supported with shared local storage"));else if(!o.hasFileSystem()||i.SHARED_LOCAL_STORAGE||i.ROOT_DIR)if((e=e||{}).CLOUD_ID=e.CLOUD_ID||i.DEFAULT_CLOUD_ID,e.STORAGE_HOSTNAME){var n=f.getPublicLibraryCollection(e.CLOUD_ID),r=E(i.PUBLIC_USER_ID,e.CLOUD_ID,t);!n||r?r||(n=new a(e),o.hasFileSystem()?n._load(function(){n.sync(),s()}):s()):g(i.PUBLIC_USER_ID,e.CLOUD_ID)}else t(new c(c.INVALID_PARAMETER,"Missing STORAGE_HOSTNAME option"));else t(new c(c.INVALID_PARAMETER,"ROOT_DIR not configured. Make sure you call CCLibraries.configure()"));else(t=e)(new c(c.INVALID_PARAMETER,"options argument not specified"));function s(){f.addLibraryCollection(n),i.AUTO_START_POLLING&&n.startPolling(),g(i.PUBLIC_USER_ID,e.CLOUD_ID)}},isConnected:function(){if(!i.SHARED_LOCAL_STORAGE)throw new c(c.NOT_SUPPORTED,"isConnected() is only applicable if using shared local storage");return o.storageInterface&&o.storageInterface.isConnected()},reconnect:function(){if(!i.SHARED_LOCAL_STORAGE)throw new c(c.NOT_SUPPORTED,"reconnect() is only applicable if using shared local storage");o.storageInterface&&o.storageInterface.reconnect()},disconnect:function(){if(!i.SHARED_LOCAL_STORAGE)throw new c(c.NOT_SUPPORTED,"disconnect() is only applicable if using shared local storage");o.storageInterface&&o.storageInterface.isConnected()&&o.storageInterface.shutdown()},getServiceInfo:function(){if(!i.SHARED_LOCAL_STORAGE)throw new c(c.NOT_SUPPORTED,"getServiceInfo() is only applicable if using shared local storage");return o.storageInterface&&o.storageInterface.getServiceInfo()},isSyncingEnabled:function(){if(i.SHARED_LOCAL_STORAGE){var e=y.getServiceInfo();return!(!e||!e.syncingEnabled)}return i.SYNCING_ENABLED},enableSyncing:function(){i.SHARED_LOCAL_STORAGE?o.storageInterface.setSyncEnabled(!0):(i.SYNCING_ENABLED=!0,y.getLoadedCollections().forEach(function(e){e.sync()}))},disableSyncing:function(){i.SHARED_LOCAL_STORAGE?o.storageInterface.setSyncEnabled(!1):i.SYNCING_ENABLED=!1},getLibraryById:function(e){var t;return y.getLoadedCollections().some(function(n){return t=n.getLibraryById(e)}),t},resolveElementReference:function(e){e=e||"";var t,n=new RegExp("cloud-asset://(.+)/([A-Za-z0-9-]+);node=([A-Za-z0-9-]+)"),o=e.match(n);if(o){var i=o[1],r=o[2],a=o[3];y.getLoadedCollections().every(function(e){if(i===e._syncManager.getElementRefDomainPath()){var n=e.getLibraryById(r);return n&&(t=n.getElementById(a)),!1}return!0})}return t},getAccessToken:function(e,t,n,r,a){i.SHARED_LOCAL_STORAGE?0!==f.getLoadedCollections().length?o.storageInterface.getAccessToken(e,t,n,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,n){var o=n(4),i=n(2),r={getErrorStatusCode:function(e){if(e){var t=e.code===o.UNEXPECTED_RESPONSE&&e.response&&e.response.statusCode;return t||(e.underlyingError?r.getErrorStatusCode(e.underlyingError):void 0)}},getSyncError:function(e,t,n){if(e){var a=r.getErrorStatusCode(e);return e.code===o.SERVICE_IS_INACTIVE?new i(i.LOGGED_OUT,"no access token: call updateAccessToken() and try again",t,e):e.code===o.NETWORK_ERROR?new i(i.NETWORK_ERROR,"error connecting to server",t,e):e.code===o.EXCEEDS_QUOTA?new i(i.EXCEEDS_QUOTA,"push failed due to insufficient remaining quota",t,e):e.code===o.OUT_OF_SPACE?new i(i.OUT_OF_SPACE,"not enough disk space",t,e):e.code===o.NOT_IMPLEMENTED?new i(i.NOT_IMPLEMENTED,"tried to call an API not implemented on the server",t,e):e.code===o.RETRYABLE_SERVER_ERROR?new i(i.RETRYABLE_SERVER_ERROR,"intermittent server failure - can retry later",t,e):e.code===o.INVALID_DATA||e.code===o.INVALID_JSON?new i(i.CORRUPTED_LIBRARY,"unable to read manifest",t,e):a&&n&&n[a]?new i(n[a],"server returned "+a+"response",t,e):new i(i.TRANSFER_ERROR,"something went wrong during a push/pull operation",t,e)}},getCommitError:function(e,t,n){if(e){var r=n?" - "+n:"";return e.code===o.INVALID_DATA||e.code===o.INVALID_JSON?new i(i.CORRUPTED_LIBRARY,"unable to read manifest"+r,t,e):e.code===o.OUT_OF_SPACE?new i(i.OUT_OF_SPACE,"not enough disk space"+r,t,e):new i(i.FS_ERROR,"filesystem error"+r,t,e)}},getFileSystemError:function(e,t,n){if(e)return"ENOSPC"===e.code?new i(i.OUT_OF_SPACE,t,n,e):new i(i.FS_ERROR,t,n,e)},getSnapshotError:function(e,t,n){if(e)return e.code===o.INVALID_DATA||e.code===o.INVALID_PARAMS?new i(i.INVALID_DATA,n,t,e):r.getFileSystemError(e,n,t)},getErrorPriority:function(e){var t=[i.OPERATION_CANCELLED,i.EXCEEDS_MAX_LIBRARY_SIZE,i.THUMBNAIL_NOT_AVAILABLE,i.RENDITION_NOT_AVAILABLE,i.URL_VALIDATION_FAILED,i.CORRUPTED_LIBRARY,i.TRANSFER_ABORTED,i.TRANSFER_ERROR,i.NETWORK_ERROR,i.EXCEEDS_QUOTA,i.RETRYABLE_SERVER_ERROR,i.LOGGED_OUT,i.FILE_TOO_LARGE,i.INVALID_DATA,i.FS_ERROR,i.OUT_OF_SPACE,i.ACCESS_DENIED,i.NOT_ALLOWED,i.DELETED_LOCALLY,i.REQUIRES_FILESYSTEM,i.NOT_SUPPORTED,i.NOT_IMPLEMENTED,i.INVALID_PARAMETER,i.READ_ONLY],n=e&&e.code&&t.indexOf(e.code);return void 0!==n?n:-1},errorToString:function(e){var t="";return e&&(e.message&&(t+=e.message),e.libraryId&&(t+=" library: "+e.libraryId),e.underlyingError?t+="\n<- "+r.errorToString(e.underlyingError):e.response&&e.response.statusCode&&(t+=": "+e.response.statusCode),e.failedComponents&&(t+="\n<- Failed Components:",e.failedComponents.forEach(function(e){var n=e.component&&e.component.id,o=e.error,i=o&&o.message,r=o&&o.response&&o.response.statusCode;t+="\n    ["+n+"] "+i+(r?": "+r:"")}))),t},isErrorCode:function(e){return!!e&&(i.hasOwnProperty(e)&&i[e]===e)}};Object.seal(r),e.exports=r},function(e,t,n){var o=n(2);function i(){this._operations=[],this._isRunning=!1}i.prototype.addOperation=function(e,t,n){if(this._isRunning)throw new o(o.INVALID_PARAMETER,"Cannot add operations after calling run()");this._operations.push({operation:e,argsArray:t||[],thisObject:n})},i.prototype.run=function(e,t){function n(t,n,o){e&&e(t,n,o)}if(this._isRunning)throw new o(o.INVALID_PARAMETER,"Cannot call run() more than once");this._isRunning=!0;var i=this._operations.length;0===i&&n(null,!1,[]);var r,a=0,s=!1,c=[],l=[];this._operations.forEach(function(e,d){e.argsArray.push(function(e,p){!function(e,d,p){if(e&&t&&t(e),!s){if(r=r||e,c[p])return s=!0,void n(new o(o.INVALID_PARAMETER,"Operation not valid: calls callback multiple times"));if(a++,l[p]=d,c[p]=!0,a===i){s=!0;var h=!!l.reduce(function(e,t){return e||t},!1);n(r||null,h,l)}}}(e,p,d)}),e.operation.apply(e.thisObject,e.argsArray)})},Object.freeze(i),Object.seal(i.prototype),e.exports=i},function(e,t,n){var o,i,r=n(7);i=n(41);var a={canUseFileSystem:!1,_setFS:function(e){o=e,a.canUseFileSystem=!!e},ensureDirectoryExists:function(e,t){var n=function(e){e&&"EEXIST"===e.code?t():t(e)},i=function(i){if(i)t();else{var s=r.parentDirectory(e);s?a.ensureDirectoryExists(s,function(i){i?t(i):o.mkdir(e,n)}):o.mkdir(e,n)}};e?o.exists(e,i):i(!0)},getTempFilePathAt:function(e,t){var n=function(){var o=e+r.generateUuid();a.exists(o,function(e){e?n():t(o)})};n()},exists:function(e,t){o.exists(e,t)},deleteFile:function(e,t){o.unlink(e,function(e){e&&"ENOENT"!==e.code?t(e):t()})},readFile:function(e,t,n){o.readFile(e,t,n)},writeFile:function(e,t,n,i){var s=r.parentDirectory(e);a.ensureDirectoryExists(s,function(r){r?i(r):o.writeFile(e,t,n,i)})},writeFileAtomically:function(e,t,n,i){var s=r.parentDirectory(e);a.ensureDirectoryExists(s,function(r){r?i(r):a.getTempFilePathAt(s+"/",function(r){o.writeFile(r,t,n,function(t){t?i(t):o.rename(r,e,i)})})})},createWriteStream:function(e,t){return o.createWriteStream(e,t)},createReadStream:function(e,t){return o.createReadStream(e,t)},move:function(e,t,n,i){var s=r.parentDirectory(t);a.ensureDirectoryExists(s,function(r){if(r)i(r);else if(n){var a=(new Date).getTime()/1e3;o.utimes(e,a,a,function(n){n?i(n):o.rename(e,t,i)})}else o.rename(e,t,i)})},info:function(e,t){o.stat(e,t)},directoryListing:function(e,t){var n,i,r=[],a=function(a){o.stat(e+"/"+a,function(e,o){if(!e)try{r.push({name:a,info:o}),n--}catch(t){e=t}e?i||(i=e,t(e)):0===n&&t(void 0,r)})};o.readdir(e,function(e,o){if(!e)try{var i,r=o.length;for(n=r,i=0;i<r;i++)a(o[i])}catch(t){e=t}e?t(e):0===n&&t(void 0,[])})},deleteDirectory:function(e,t){var n,i,r=function(){try{o.rmdir(e,t)}catch(e){t(e)}},s=function(e){e&&!n&&(n=e),--i<1&&(n?t(n):r())},c=function(t){var n=e+"/"+t;o.unlink(n,function(e){try{e?a.deleteDirectory(n,function(e){s(e)}):s()}catch(e){s(e)}})};o.readdir(e,function(e,n){if(!e)try{var o,a=n.length;if(a<1)r();else for(i=a,o=0;o<a;o++)c(n[o])}catch(t){e=t}e&&t(e)})}};a.copyFile=function(e,t,n){var i=r.parentDirectory(t);a.ensureDirectoryExists(i,function(i){i?n(i):function(e,t,n){try{var i=t+r.generateUuid(),a=o.createWriteStream(i),s=o.createReadStream(e);s.on("end",function(){o.rename(i,t,n)}),s.on("error",function(e){n(e)}),s.pipe(a)}catch(e){n(e)}}(e,t,n)})},a.getMD5Hash=function(e,t){const n=i.createHash("md5").setEncoding("base64");try{const i=o.createReadStream(e);i.pipe(n).on("finish",()=>t(null,n.read())),i.on("error",e=>t(e))}catch(e){t(e)}},e.exports=a},function(e,t){e.exports=require("path")},function(e,t,n){var o=n(48),i=n(4),r=n(0),a=n(1),s=n(19),c=n(2),l=n(18),d=n(12),p={},h={};p.isCompatibleType=function(e,t){return e===t||e===h[t]},p.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},p.validateLibrary=function(e){return(e.current&&e.current.rootNode.getValue(r.VERSION_KEY))===r.VERSION},p.areManifestsEqual=function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;const n=JSON.parse(e),o=JSON.parse(t);delete n["manifest-format-version"],delete o["manifest-format-version"];try{if(JSON.stringify(n)===JSON.stringify(o))return!0}catch(e){}return!1},p.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},p.getCustomDCXData=function(e){var t=[];return e.getCustomKeys().forEach(function(n){var o=n.split("#"),i=o.length>=2;i&&o.forEach(function(e){""===e&&(i=!1)});var a=0===n.indexOf(r.DL_PREFIX);i&&!a&&t.push({namespace:o.shift(),key:o.join("#"),value:e.getValue(n)})}),t},p.copyCustomDCXData=function(e,t){p.getCustomDCXData(e).forEach(function(e){t.setValue(p.getDCXKey(e.namespace,e.key),e.value)}),[r.REPRESENTATION_ORDER_KEY,r.IS_PREFERRED_THUMBNAIL_KEY,r.SHA_KEY].forEach(function(n){var o=e.getValue(n);o&&t.setValue(n,o)})},p.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},p.checkEncoding=function(e,t,n){if(-1===t.indexOf(e)){var o=t.join(", ");return n(new c(c.INVALID_PARAMETER,"Unsupported encoding. Supported encodings are: "+o)),!1}return!0},p.sortRepresentations=function(e){if(e.length<2)return;let t=!0;for(;t;){t=!1;for(let n=1;n<e.length;n++){const o=e[n-1],i=e[n];i._getOrder()<o._getOrder()&&(e[n-1]=i,e[n]=o,t=!0)}}},p.removeMissingComponents=function(e,t){if(e&&t){var n=0,o=0;return t.forEach(function(t){var i=t.component,r=t.error;i&&r&&r.response&&404===r.response.statusCode&&(e.removeComponent(i),n++,a.log("Removed missing component: "+i.id+" from library "+e.compositeId)),i&&r&&"[UNEXPECTED_RESPONSE] Incorrect content length"===r.message&&(o++,a.log("Skipped length-mismatch component: "+i.id+" from library "+e.compositeId))}),a.log("Fixed "+n+" of "+t.length+" components that failed to download"),l.reportRemoveMissingComponents(e.compositeId,t,n),t.length===n+o?e:void 0}};p.removeMissingLocalComponents=function(e,t){if(e&&t){var n=0,o=[];t.forEach(function(t){var r=t.component,s=t.error;if(r&&s&&s.code===i.INVALID_STATE){var c=function(e,t){var n;return e.elements.some(function(e){return e.representations.some(function(e){if(e.id===t)return n=e,!0})}),n}(e,r.id);c?o.push(c):e._dcxBranch.removeComponent(r),n++,a.log("Removed missing local component: "+r.id+" from library "+e.id)}}),n>0&&(e._beginOperation(),o.forEach(function(e){e.element.removeRepresentation(e)}),e._endOperation()),a.log("Fixed "+n+" of "+t.length+" components that failed to upload")}},p.recoverReadOnlyEdits=function(e,t,n){var o=[];e.elements.forEach(function(e){var n=t&&t.getChildWithId(e.id);(n&&n.getValue(r.MODIFIED_KEY))!==e.modified&&o.push(e)});var i=new d;if(o.length>0){var c,l=s.translate("LIBS_RECOVERED_LIBRARY",{name:e.name});e.collection.libraries.some(function(e){if(e.name===l&&e.isWritable&&"incoming"!==e.collaboration&&e.elements.length<r.MAX_ELEMENTS)return c=e,!0}),c||(c=e.collection.createLibrary(l)),o.forEach(function(t){i.addOperation(e.copyElement,[t,c],e)}),a.log("Recovering "+o.length+" elements from read-only library")}i.run(n)},p.ensureBranchDataValid=function(e){var t=[r.ELEMENTS_NAME,r.REMOVED_ELEMENTS_NAME],n=!1;return e.getChildrenOf().forEach(function(o){if(-1!==t.indexOf(o.name)){var i=o.name===r.REMOVED_ELEMENTS_NAME;e.getChildrenOf(o).forEach(function(e){var t=e.getValue(r.REMOVED_KEY);!i&&t?(e.removeValue(r.REMOVED_KEY),n=!0):i&&!t&&(e.setValue(r.REMOVED_KEY,(new Date).valueOf()),n=!0)})}}),n},p.collaborationStateToDCX=function(e){return"incoming"===e?o.COLLABORATION.SHARED_WITH_USER:"outgoing"===e?o.COLLABORATION.SHARED_BY_USER:o.COLLABORATION.PRIVATE},p.collaborationStateFromDCX=function(e){return e===o.COLLABORATION.SHARED_WITH_USER?"incoming":e===o.COLLABORATION.SHARED_BY_USER?"outgoing":void 0},p.getCompositeRenditionMap=function(e){var t=e.getComponentsOf(),n={};return t&&t.forEach(function(e){if("rendition"===e.relationship){var t=e.getValue(r.RENDITION_TYPE_KEY);t&&(n[t]=e)}}),n},Object.seal(p),e.exports=p},function(e,t,n){var o=n(0),i=n(1),r=n(12),a=n(9),s={},c={"application/x-indesign":!0,"application/postscript":!0,"application/illustrator":!0,"application/pdf":!0,"application/vnd.adobe.psremix":!0,"application/vnd.adobe.pstouch":!0,"application/vnd.adobe.ideas":!0,"application/vnd.adobe.ase":!0,"image/jpeg":!0,"image/jpg":!0,"image/pjpeg":!0,"image/tiff":!0,"image/gif":!0,"image/bmp":!0,"image/x-ms-bmp":!0,"image/svg+xml":!0,"image/png":!0,"image/x-png":!0,"image/jp2":!0,"image/psd":!0,"image/vnd.adobe.photoshop":!0,"application/photoshop":!0,"application/x-photoshop":!0,"image/raw":!0,"image/dng":!0,"image/x-adobe-dng":!0,"video/mp4":!0,"video/mpeg":!0,"video/x-ms-wmv":!0,"video/3gpp":!0,"video/3gpp2":!0,"video/quicktime":!0,"video/x-msvideo":!0,"video/x-flv":!0,"video/x-ms-asf":!0,"video/x-m4v":!0,"video/mp2t":!0,"application/mxf":!0,"application/x-shockwave-flash":!0,"application/vnd.adobe.brushes.brush+ucf":!0,"application/vnd.adobe.collage":!0,"application/vnd.adobe.proto":!0,"application/msword":!0,"application/msexcel":!0,"application/mspowerpoint":!0,"application/vnd.ms-publisher":!0,"application/vnd.openxmlformats-officedocument.wordprocessingml.document":!0,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":!0,"application/vnd.openxmlformats-officedocument.presentationml.presentation":!0,"application/vnd.adobe.charts+zip":!0,"text/plain":!0,"text/rtf":!0};s.canComputeRenditionFromMimeType=function(e){return!!c[e]},s.canComputeRendition=function(e){return!(void 0===e._dcxComponent||!s.canComputeRenditionFromMimeType(e.type))},s.shouldPrefetchFullRendition=function(e){var t=(o.FULL_RENDITION_CONFIG||{})[e.type];if(!t)return!1;var n=!1;return Object.keys(t).forEach(function(o){var i=t[o];if("IF_NO_MATCHING_REPRESENTATION"===i.condition&&i.types){var r=e.representations.every(function(e){return-1===i.types.indexOf(e.type)});n=n||r}}),n},s.shouldPrefetchExternalLink=function(e){if(!e.isExternalLink)return!1;var t=(o.EXTERNAL_LINK_PREFETCH||{})[e.element.type];return void 0===t||t},s.prefetchRenditionsForElement=function(e,t){var n=a.wrapCallback(t);if(i.hasFileSystem()){var c=new r,l=o.RENDITION_SIZES||{};(l[e.type]||l["*"]||[]).forEach(function(t){c.addOperation(e.getThumbnailPath,[t],e)}),s.shouldPrefetchFullRendition(e)&&c.addOperation(e.getThumbnailPath,[void 0],e),e._forEachRepresentation(function(e){s.shouldPrefetchExternalLink(e)?c.addOperation(e.getContentPath,[],e):e.isExternalLink&&c.addOperation(e.testExternalLink,[],e)}),c.run(n)}else n(null)},s.prefetchRenditions=function(e,t){var n=a.wrapCallback(t);if(i.hasFileSystem()){var o=new r;e.elements.forEach(function(e){o.addOperation(s.prefetchRenditionsForElement,[e],s)}),o.run(n)}else n(null)},s.addToRenditionSizeConfig=function(e){var t=o.RENDITION_SIZES,n=t["*"]||[];n=JSON.parse(JSON.stringify(n));var i=e["*"]||[];Object.keys(t).forEach(function(n){if(!e[n]){var o=t[n];i.forEach(function(e){-1===o.indexOf(e)&&o.push(e)}),t[n]=o}}),Object.keys(e).forEach(function(o){var i=t[o]||JSON.parse(JSON.stringify(n));e[o].forEach(function(e){-1===i.indexOf(e)&&i.push(e)}),t[o]=i}),o.setParameter("RENDITION_SIZES",t)},s.addToFullRenditionConfig=function(e){var t=o.FULL_RENDITION_CONFIG;Object.keys(e).forEach(function(n){var o=t[n]||{};e[n].forEach(function(e){e.id&&(o[e.id]=e)}),t[n]=o}),o.setParameter("FULL_RENDITION_CONFIG",t)},Object.seal(s),e.exports=s},function(e,t,n){var o=n(6),i=n(5),r=n(0);o.log("Vulcan","Loading Vulcan Library...");var a=n(118),s=new a.VulcanAdapter("LIBS","1.0.0"),c=new a.VulcanControlAdapter;o.log("Vulcan","Vulcan Library Successfully Loaded");var l=new i;s.addMessageListener(function(e,t,n,i){e=e.replace(r.VULCAN_PREFIX,""),l.hasListeners(e)&&(o.log("Vulcan","<- "+n+" "+i+": "+e),l.notify(e,[t,n,i]))});var d={sendMessage:function(e,t,n,i){var r=n?n+" "+(i||"*"):"BROADCAST";o.log("Vulcan","-> "+r+": "+e),s.sendMessage(e,t||"",n||"",i||"")},addListener:function(e,t){l.add(e,t)},removeListener:function(e,t){l.remove(e,t)},call:function(e,t){var n,i,r=!1,a=function(o,a){r||!1!==t(o,a)&&(r=!0,clearTimeout(n),l.remove(e.responseType,i))};i=function(e){a(null,e)},l.add(e.responseType,i),e.timeout&&(n=setTimeout(function(){o.log("Vulcan","Timed out on "+e.responseType),a("timeout")},e.timeout)),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,n){var o,i,r=n(1),a=n(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 n=e.getPrimaryRepresentation();if(n){var o=function(e){var t=null;return e.getValues().forEach(function(e){"trackingdata"===e.key&&(t||(t={}),t[e.namespace]=e.value)}),t}(n);o&&(t.trackingData=JSON.stringify(o)),t.elementPrimaryType=n.type}return t}function l(e,t){if(!e)return{};var n=t?{}:s(e._library);return n.groupID=e.id,n.groupClassifierName=e.classifierName,n}function 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 n=t?s(t):{};e&&(n.error=e.code),r.analytics.reportEvent("exportLibrary",n)}},reportImportLibrary:function(e,t){if(p()){var n=t?s(t):{};e&&(n.error=e.code),r.analytics.reportEvent("importLibrary",n)}},reportCreateElement:function(e){p()&&(o=e,i=Date.now(),r.analytics.reportEvent("createElement",c(e)))},reportUpdateElement:function(e,t){if(p()){if(e===o&&Date.now()-i<a.ANALYTICS_ELEMENT_UPDATE_THRESHOLD)return;o=e,i=Date.now();var n=c(e);n.updateType=t?"info":"representation",r.analytics.reportEvent("updateElement",n)}},_reportUpdateElementMetadata:function(e,t,n){if(p()){var o=c(e);o.updateType=t,n&&Object.assign(o,n),r.analytics.reportEvent("updateElementMetadata",o)}},reportSetOrderInGroup:function(e,t,n){var o=l(t,!0);o.elementOrderInGroup=e.getOrderInGroup(t),o.removeExistingGroups=n,this._reportUpdateElementMetadata(e,"order",o)},reportSetDescription:function(e){this._reportUpdateElementMetadata(e,"description")}};h.reportUseElement=function(e,t,n){if(p()){var o=function(e){if(!e)return{};var t=c(e._element);return t.representationType=e.type,t}(e);o.opType=t,o.details=n,r.analytics.reportEvent("useElement",o)}},h.reportCheckoutElement=function(e,t,n){if(p()){var o=c(e);o.opType=t,o.details=n,r.analytics.reportEvent("checkoutElement",o)}},h.reportDeleteElement=function(e,t){if(p()){var n=c(e);n.isPermanent=!!t,r.analytics.reportEvent("deleteElement",n)}},h.reportRestoreElement=function(e){p()&&r.analytics.reportEvent("restoreElement",c(e))},h.reportCopyElement=function(e,t){if(p()){o=e,i=Date.now();var n=c(e);n.oldLibraryID=t._library.id,n.oldElementID=t.id,r.analytics.reportEvent("copyElement",n)}},h.reportMoveElement=function(e,t){if(p()){o=e,i=Date.now();var n=c(e);n.oldLibraryID=t._library.id,n.oldElementID=t.id,r.analytics.reportEvent("moveElement",n)}},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 n=l(e);n.updateType="order",n.groupOrder=t,r.analytics.reportEvent("updateGroupMetadata",n)}},h.reportDeleteGroup=function(e,t,n){if(p()){var o=l(e);o.includeContents=t,t&&(o.numberElementsInGroup=n),r.analytics.reportEvent("deleteGroup",o)}},h.reportCopyGroup=function(e,t,n,o){if(p()){var i=l(e);i.oldLibraryID=t._library.id,i.oldGroupID=t.id,i.includeContents=n,n&&(i.numberElementsInGroup=o),r.analytics.reportEvent("copyGroup",i)}},h.reportMoveGroup=function(e,t,n,o){if(p()){var i=l(e);i.oldLibraryID=t._library.id,i.oldGroupID=t.id,i.includeContents=n,n&&(i.numberElementsInGroup=o),r.analytics.reportEvent("moveGroup",i)}},h.reportCollisionElement=function(e){p()&&r.analytics.reportEvent("collisionLibrary",c(e))},h.reportCreateLink=function(e,t){if(p()){var n=c(e);n.opType=t,r.analytics.reportEvent("createLink",n)}},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 n=d(e);n.appVersion=t&&t.version,n.appLaunchStatus=t?t.isAlreadyRunning?"Running":"Launched":"Unknown",r.analytics.reportEvent("elementActionSuccessful",n)}},h.reportElementActionFailed=function(e,t){if(p()){var n=d(e);n.error=t?t.code+":"+t.message:"",r.analytics.reportEvent("elementActionFailed",n)}},h.reportUnexpectedState=function(e,t){if(p()){var n=s(e);n.details=t,r.analytics.reportEvent("unexpectedState",n)}},h.reportRemoveMissingComponents=function(e,t,n){if(p()){var o={libraryID:e,numMissing:t.length,numFixed:n,componentErrors:[]};t.forEach(function(e){var t=e.error,n=t&&t.code,i=t&&t.response&&t.response.statusCode,r=(n||"UNKNOWN_ERROR")+(i?": "+i:"");o.componentErrors.push(r)}),r.analytics.reportEvent("removeMissingComponents",o)}},Object.seal(h),e.exports=h},function(e,t,n){var o=n(1),i=n(9),r={},a="undefined"!==typeof LOCALE_ROOT;function s(){this.setLocale()}o.hasFileSystem()&&a||(r={cs_CZ:n(72),da_DK:n(73),de_DE:n(74),en_US:n(75),es_ES:n(76),es_MX:n(77),fi_FI:n(78),fr_CA:n(79),fr_FR:n(80),fr_MA:n(81),hu_HU:n(82),it_IT:n(83),ja_JP:n(84),ko_KR:n(85),nb_NO:n(86),nl_NL:n(87),pl_PL:n(88),pt_BR:n(89),ru_RU:n(90),sv_SE:n(91),tr_TR:n(92),uk_UA:n(93),zh_CN:n(94),zh_TW:n(95)}),s.prototype._getLocaleData=function(e){if(!r[e]&&o.hasFileSystem()&&a)try{r[e]=o.fs.readFileSync(LOCALE_ROOT+e+"/messages.properties","utf8")}catch(e){}return r[e]},s.prototype._normaliseLocale=function(e){if(e){var t=(e=e.replace("-","_")).split("_");return t[0]=t[0]&&t[0].toLowerCase(),t[1]=t[1]&&t[1].toUpperCase(),t.join("_")}},s.prototype.setLocale=function(e){(e=this._normaliseLocale(e))&&this._getLocaleData(e)||(e="en_US"),this._locale=e,this._strings=i.parseLocalisationFile(this._getLocaleData(this._locale))},s.prototype.getLocale=function(){return this._locale},s.prototype.translate=function(e,t){var n=this._strings[e];return n&&t&&(n=i.constructStringFromTemplate(n,t)),n||e};const c={photoshop:"LIBS_TOOLKIT_NAME_PHOTOSHOP"};s.prototype.getToolkitName=function(e){return this.translate(c[e]||"LIBS_TOOLKIT_NAME_DEFAULT")},Object.freeze(s),Object.seal(s.prototype),e.exports=new s},function(e,t){e.exports=require("fs")},function(e,t){function n(){this._isLocked=!1,this._pendingContinuations=[]}n.prototype.obtain=function(e,t){this._isLocked?this._pendingContinuations.push({continuation:e,thisObject:t}):(this._isLocked=!0,e.apply(t,[null]))},n.prototype.release=function(){if(this._pendingContinuations.length>0){var e=this._pendingContinuations.shift();setTimeout(function(){e.continuation.apply(e.thisObject,[null])})}else this._isLocked=!1},n.prototype.abortPendingOperations=function(e){var t=this._pendingContinuations;this._pendingContinuations=[],t.forEach(function(t){t.continuation.apply(t.thisObject,[e])})},n.prototype.isLocked=function(){return this._isLocked},n.prototype.hasPendingRequest=function(){return this._pendingContinuations.length>0},Object.freeze(n),Object.seal(n.prototype),e.exports=n},function(e,t,n){var o,i,r=n(6),a="Proxy",s={},c=new(n(5))(["change","error"]),l={},d=n(121)(function(e,t){r.log(a,t),0===e&&c.notify("error",[t])});function p(e,t){d.resolve(e,function(e,n){e?t(e):t(null,n&&n[0])})}function h(e,t){p(e,function(n,i){delete t.agent,t.agent=i&&i.agent,t.agent?r.log(a,"Setting proxy for "+e+": "+i.hostname+":"+i.port+(o?" with":" without")+" authentication"):r.log(a,"No proxy (direct connection) for "+e)})}function u(){Object.keys(s).forEach(function(e){h(e,s[e])})}d.setAuthenticationCallback(function(e,t){var n=l[e.proxy.host+e.proxy.port]||{};n.username===o&&n.password===i?t("No new credentials"):o?(n.username=o,n.password=i,t(null,n),l[e.proxy.host+e.proxy.port]=n):t("No credentials present")}),d.on("change",function(){r.log(a,"System proxy settings changed"),u(),c.notify("change",[!0])});var _={};_.isLocalhostProxied=d.isLocalhostProxiedUnderHttp,_.addListener=function(e,t){c.add(e,t)},_.removeListener=function(e,t){c.remove(e,t)},_.removeAllListeners=function(e){c.removeAll(e)},_.getProxyForURL=function(e,t){p(e,t)},_.getNodeTunnelOptionsForURL=function(e){if(!s[e]){var t={};s[e]=t,h(e,t)}return s[e]},_.setProxyCredentials=function(e,t){o===e&&i===t||(r.log(a,"Setting proxy username and password"),o=e,i=t,u(),c.notify("change",[!1]))},_.getProxyCredentials=function(){return{user:o,password:i}},_.getRootCA=function(e){d.getRootCA(e)},_.getOSLocale=function(){return d.getOSLocale()},e.exports=_},function(e,t,n){var o,i=n(24),r=n(125),a=n(3),s=n(6),c=n(22),l=n(30),d=n(10),p=n(0),h=n(1),u=n(37),_=function(){if(!o){var e={ENVIRONMENT:"Staging"===a.getEnvironment().LABEL?"stage":"prod",ANALYTICS_API_KEY:a.getEnvironment().CLIENT_ID,ANALYTICS_X_PRODUCT:"CCLibraryProcess/"+u.version,ANALYTICS_PROJECT:a.getValue("ANALYTICS_PROJECT"),ANALYTICS_INGEST_TYPE:a.getValue("ANALYTICS_INGEST_TYPE"),ANALYTICS_MAX_QUEUED_EVENTS:a.getValue("MAX_QUEUED_ANALYTICS"),ANALYTICS_DEBOUNCE:a.getValue("ANALYTICS_DEBOUNCE"),ANALYTICS_USER_REGION:"US"};(o=new r({getAccessToken(e){l.getAccessToken(e)},getAgent(e,t){var n=c.getNodeTunnelOptionsForURL(e);t(null,n&&n.agent)},log(e){s.log("Analytics",e)}},e)).enable(p.ANALYTICS_ENABLED)}return o},f=[];var m={_updateDefaults:function(e){var t=d.getLoadedCollections(),n={"event.guid":h.uuid(),"event.user_guid":l.getUserId(),"event.category":"Library-Process","event.type":"info","event.dts_end":(new Date).valueOf(),"event.cloud_id":t&&t.length>0?t[0].cloudId:"","source.client_id":a.getEnvironment().CLIENT_ID,"source.version":u.version,"source.platform":i.platform()};return Object.keys(e).forEach(function(t){-1===t.indexOf(".")?n["ccxlp."+t]=e[t]:n[t]=e[t]}),n},_postEvent:function(e,t,n){_().postEvent(e,n),t&&_().flush(!0)},_reset:function(){o=void 0},reportEvent:function(e,t,n,o){t=Object.assign({"event.type":"info","event.subtype":e},t||{}),t=m._updateDefaults(t),m._postEvent(t,n,o)}};m.reportError=function(e,t,n,o){var i=e+": "+(t||"");if(function(e){return-1===f.indexOf(e)&&(f.length===a.getValue("ANALYTICS_ERROR_HISTORY")&&f.shift(),f.push(e),!0)}(i)){var r={"event.type":"error","event.error_type":e,"event.error_desc":i};r=m._updateDefaults(r),m._postEvent(r,n,o)}else o&&o(null,0)},m.setEnabled=function(e){_().enable(e)},e.exports=m},function(e,t){e.exports=require("os")},function(e,t,n){var o=n(4),i=n(33),r=n(51),a=n(67),s=n(40).STATES,c=n(13),l=n(7),d={PRIVATE:void 0,SHARED_BY_USER:"sharedByUser",SHARED_WITH_USER:"sharedWithUser"};function p(e,t,n,o,r,a){r=l.ensureRelativeHrefStartsWithSlash(r),this._options=a||{},n?this._setPath(n):r?(this._href=r,e&&(this._name=e),t&&(this._type=t),o&&(this._id=o)):t&&(this._current=new i,e&&(this._current._data.name=e),this._current._data.type=t,o&&(this._current.compositeId=o)),this._autoRemoveUnusedLocalFiles=!0,this._options.xhrBaseBranchSupport&&(this._baseBranchData=void 0,this._pushedBranchData=void 0,this._pulledBranchData=void 0),this._collaborationType=d.PRIVATE}p.newCompositeAsCopyOf=function(e,t,n,r,a,s,c){var d=e._core;if(d||e.current&&(d=e.current._core),!d)throw new o(o.INVALID_PARAMS,"compositeBranchOrElement must be a branch, an element or a composite with a current branch.");var h=new p(void 0,void 0,void 0,void 0,void 0,c);return r&&(h.path=r),h._current=i._newBranchAsCopyOfCore(d,this._localStorage),h.id=a||l.generateUuid(),t&&(h.name=t),n&&(h.type=n),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 o(o.INVALID_PARAMS,"Expecting a string.");this._current&&(this._current.compositeId=e),this._id=e}},name:{get(){return this._current?this._current.name:this._name},set(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,"Expecting a string.");this._current&&(this._current.name=e),this._name=e}},type:{get(){return this._current?this._current.type:this._type},set(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,"Expecting a string.");this._current&&(this._current.type=e),this._type=e}},href:{get(){return this._current?this._current.compositeHref:this._href},set(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,"Expecting a string.");e=l.ensureRelativeHrefStartsWithSlash(e),this._current&&(this._current.compositeHref=e),this._href=e}},collaborationType:{get(){return this._current?this._current._collaborationType:this._collaborationType},set(e){if(e!==d.PRIVATE&&e!==d.SHARED_BY_USER&&e!==d.SHARED_WITH_USER)throw new o(o.INVALID_PARAMS,"Invalid value: ."+e);this._current&&(this._current._collaborationType=e),this._collaborationType=e}},clientDataString:{get(){return this._current?this._current._clientDataString:this._clientDataString},set(e){if("string"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Invalid clientDataString: must be a string or undefined.");var t=this._options.maxClientDataLength||1024;if(e&&e.length>t)throw new o(o.INVALID_PARAMS,"Invalid clientDataString: cannot be greater than 1KB");this._current&&(this._current._clientDataString=e),this._clientDataString=e}},path:{get(){return this._path},set(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,"Expecting a string.");this._setPath(e)}},isBound:{get(){return this._current&&this._current.isBound||!this._current&&this._href},set(){throw new o(o.READ_ONLY,"Cannot set the property isBound. Use resetIdentity or resetBinding instead.")}},hasLocalStorage:{get(){return this._localStorage},set(){throw new o(o.READ_ONLY,"Cannot set the property hasLocalStorage.")}},autoRemoveUnusedLocalFiles:{get(){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");return this._autoRemoveUnusedLocalFiles},set(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");this._autoRemoveUnusedLocalFiles=e}},clientDataStoragePath:{get(){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");return this._localStorage.clientDataPath()},set(){throw new o(o.READ_ONLY,'Property "clientDataStoragePath" is read-only.')}},current:{get(){return this._current},set(){throw new o(o.READ_ONLY,'Property "current" is read-only.')}}}),p.prototype.loadCurrentFromLocalStorage=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");var t=this;this._loadBranch(this._localStorage.currentManifestPath(),!1,function(n,o){if(!n&&o)try{t._current=o,t._currentBranchCommittedAtDate=l.timeStamp(!0)}catch(e){n=e}e(n,n?void 0:o)})},p.prototype.commitChanges=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");if(!this._current)return e(new o(o.INVALID_STATE,"Current branch is not in memory."));var t=this;c.writeFileAtomically(this._localStorage.currentManifestPath(),this._current.localData,"utf8",function(n){if(!n)try{t._currentBranchCommittedAtDate=l.timeStamp(!0),t._current._isDirty=!1}catch(e){n=e}e(n)})},p.prototype.tempAssetPath=function(){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");return this._localStorage.tempPathForComponent()},p.prototype.deleteTempFiles=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");this._localStorage.deleteTempFiles(function(t){e&&e(t)})},p.prototype.removeUnusedLocalFiles=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");this._localStorage.removeUnusedLocalFiles(this._currentBranchCommittedAtDate,e)},p.prototype.removeLocalFilesForComponentsWithIDs=function(e,t){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");if(!e)throw new o(o.INVALID_PARAMS,"Param componentIds must not be nil.");var n=this,i=this._current;n._loadBranch(n._localStorage.currentManifestPath(),!0,function(r,a){r&&"ENOENT"!==r.code?t([r]):n.loadBaseBranch(function(r,l){if(r&&"ENOENT"!==r.code)t([r]);else{var d,p,h=[],u={};for(d=0;d<e.length;++d){var _=e[d],f=i.getComponentWithId(_),m=a?a.getComponentWithId(_):void 0,E=l?l.getComponentWithId(_):void 0;if(!(f&&"/META-INF/metadata.xml"===f.absolutePath||m&&"/META-INF/metadata.xml"===m.absolutePath||E&&"/META-INF/metadata.xml"===E.absolutePath))if(f&&f.state===s.modified||m&&m.state===s.modified){var g=new o(o.COMPONENT_MODIFIED_ERROR,"Cannot remove the file of a modified component.");g.componentId=_,h.push(g)}else f&&(p=i.assetOfComponent(f))&&(void 0===u[p]&&(u[p]=_),n._localStorage.removeComponentAsset(f,i._local()),i._setDirty(!0)),m&&(p=a.assetOfComponent(m))&&void 0===u[p]&&(u[p]=_),E&&(p=l.assetOfComponent(E))&&void 0===u[p]&&(u[p]=_)}var y=Object.keys(u),v=y.length;if(v>0){var A=function(e){c.deleteFile(e,function(n){n&&(n.componentId=u[e],h.push(n)),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 o(o.NO_LOCAL_STORAGE,"No local storage.");if(!this._path)return e(new o(o.INVALID_STATE,"No path set."));c.deleteDirectory(this._path,e)},p.prototype.loadBaseBranch=function(e){if(!this._localStorage&&!this._baseBranchData)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");if(this._localStorage)this._loadBranch(this._localStorage.currentBaseManifestPath(),!0,e);else{var t,n;try{n=new i(void 0,!0).parse(this._baseBranchData)}catch(e){t=e}e(t,n)}},p.prototype.loadPulledBranch=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");this._loadBranch(this._localStorage.pulledManifestPath(),!1,e)},p.prototype.loadPushedBranch=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");this._loadBranch(this._localStorage.pushedManifestPath(),!1,e)},p.prototype.resolvePullWithBranch=function(e,t){if(!e)throw new o(o.INVALID_PARAMS,"Need a branch.");if(e===this._current)throw new o(o.INVALID_PARAMS,"Cannot resolve current.");if(this._localStorage&&!t)throw new o(o.INVALID_PARAMS,"Need a callback function.");var n=this,i=function(){e.readOnly=!1,e._collaborationType=n.collaborationType,e._clientDataString=n.clientDataString,n._current=e};if(this._localStorage)n._localStorage.resolvePulledBranch(e,function(e){if(!e)try{i(),n._autoRemoveUnusedLocalFiles&&n._localStorage.removeUnusedLocalFiles(n._currentBranchCommittedAtDate,function(){})}catch(t){e=t}t(e,e?void 0:n._current)});else{if(this._options.xhrBaseBranchSupport&&(this._baseBranchData=this._pulledBranchData,this._pulledBranchData=void 0),i(),!t)return this._current;t(void 0,this._current)}},p.prototype.acceptPush=function(e){if(this._localStorage&&!e)throw new o(o.INVALID_PARAMS,"Need a callback function.");var t,n,i=this,a=function(o){if(!o)if(t)try{i._localStorage?(t.applyToBranch(n),i._localStorage.acceptPushedBranch(n,function(n){if(!n)try{t.applyToBranch(i._current,!0),i._autoRemoveUnusedLocalFiles&&i._localStorage.removeUnusedLocalFiles(i._currentBranchCommittedAtDate,function(){})}catch(e){n=e}e(n)})):(t.applyToBranch(i._current,!0),i._options.xhrBaseBranchSupport&&(i._baseBranchData=i._pushedBranchData,i._pushedBranchData=void 0),i._pushJournal=void 0,e&&e())}catch(e){o=e}else e&&e();if(o){if(!e)throw o;e(o)}};if(!this._localStorage)return t=this._pushJournal,a();var s,c=2;r.readJournal(i._localStorage.pushJournalPath(),i,!1,function(e,n){c--,s?a():(e?"ENOENT"!==e.code&&(s=new o(o.INVALID_STATE,"Failed to load push journal.",e)):t=n,c||a())}),this._loadBranch(this._localStorage.currentManifestPath(),!1,function(e,t){c--,s?a():(e?s=new o(o.INVALID_STATE,"Failed to load current manifest.",e):n=t,c||a())})},p.prototype.discardPulledBranch=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");var t=this;this._localStorage.discardPulledBranch(function(n){if(!n){try{t._autoRemoveUnusedLocalFiles&&t._localStorage.removeUnusedLocalFiles(t._currentBranchCommittedAtDate,function(){})}catch(e){n=e}e(n)}n&&e(n)})},p.prototype.discardPushedBranch=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");var t=this;this._localStorage.discardPushedBranch(function(n){if(!n){try{t._autoRemoveUnusedLocalFiles&&t._localStorage.removeUnusedLocalFiles(t._currentBranchCommittedAtDate,function(){})}catch(e){n=e}e(n)}n&&e(n)})},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,n){if("function"!=typeof n)throw new o(o.INVALID_PARAMS,'Param "callback" must be a function.');var r=this;c.exists(e,function(o){o?c.readFile(e,"utf8",function(o,a){var s;if(!o)try{(s=new i(void 0,t,e).parse(a))._localStorage=r._localStorage}catch(e){o=e}n(o,s)}):n()})},p.prototype._discardEveryBranchButCurrent=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");var t,n=this,i=3,r=function(o){o&&!t&&(t=o),0===--i&&(!t&&n._autoRemoveUnusedLocalFiles&&n._localStorage.removeUnusedLocalFiles(n._currentBranchCommittedAtDate,function(){}),e(t))};this._localStorage.discardPushedBranch(r),this._localStorage.discardPulledBranch(r),this._localStorage.discardBaseBranch(r)},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 n={},o={"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomsvc+xml":["atomsvc"],"application/ccxml+xml":["ccxml"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma"],"application/emma+xml":["emma"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/font-tdpfr":["pfr"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/hyperstudio":["stk"],"application/illustrator":["ai"],"application/illustrator-text":["ai"],"application/illustrator.template":["ait"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/java-archive":["jar"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js"],"application/json":["json"],"application/jsonml+json":["jsonml"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/photoshop":["psd"],"application/photoshop.large":["psb"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/prs.cww":["cww"],"application/pskc+xml":["pskcxml"],"application/rdf+xml":["rdf"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/vnd.3gpp.pic-bw-large":["plb"],"application/vnd.3gpp.pic-bw-small":["psb"],"application/vnd.3gpp.pic-bw-var":["pvb"],"application/vnd.3gpp2.tcap":["tcap"],"application/vnd.3m.post-it-notes":["pwn"],"application/vnd.accpac.simply.aso":["aso"],"application/vnd.accpac.simply.imp":["imp"],"application/vnd.acucobol":["acu"],"application/vnd.acucorp":["atc","acutc"],"application/vnd.adobe.air-application-installer-package+zip":["air"],"application/vnd.adobe.animate-xfl+zip":["fla","xfl"],"application/vnd.adobe.animate-oam+zip":["oam"],"application/vnd.adobe.animate-sym+zip":["sym"],"application/vnd.adobe.animate-swf+zip":["swa"],"application/vnd.adobe.characterstyle+json":["style"],"application/vnd.adobe.characterstyle+snippet":["idms"],"application/vnd.adobe.charts+zip":["zip"],"application/vnd.adobe.ch.puppet+zip":["puppet"],"application/vnd.adobe.color+json":["ase"],"application/vnd.adobe.colortheme+json":["ase"],"application/vnd.adobe.cube+txt":["cube"],"application/vnd.adobe.element.agc+dcx":["agc"],"application/vnd.adobe.formscentral.fcdt":["fcdt"],"application/vnd.adobe.fxp":["fxp","fxpl"],"application/vnd.adobe.ibl.light+zip":["zip"],"application/vnd.adobe.indesign-idms":["idms"],"application/vnd.adobe.indesign-idms-text":["idms"],"application/vnd.adobe.indesign.template":["indt"],"application/vnd.adobe.layerstyle":["asl"],"application/vnd.adobe.look+xml":["look"],"application/vnd.adobe.ppro.graphic+zip":["prgraphic"],"application/vnd.adobe.ae.graphic+zip":["aegraphic"],"application/vnd.adobe.graphic+json":["json"],"application/vnd.adobe.mdl.material+zip":["zip"],"application/vnd.adobe.muse-collection":["muse"],"application/vnd.adobe.obj.3d+zip":["zip"],"application/vnd.adobe.paragraphstyle+json":["style"],"application/vnd.adobe.paragraphstyle+snippet":["idms"],"application/vnd.adobe.ribbon.brush+zip":["brush"],"application/vnd.adobe.scatter.brush+zip":["brush"],"application/vnd.adobe.vector.brush+zip":["brush"],"application/vnd.adobe.text+json":["text-json"],"application/vnd.adobe.xdp+xml":["xdp"],"application/vnd.adobe.xfdf":["xfdf"],"application/vnd.ahead.space":["ahead"],"application/vnd.airzip.filesecure.azf":["azf"],"application/vnd.airzip.filesecure.azs":["azs"],"application/vnd.amazon.ebook":["azw"],"application/vnd.americandynamics.acc":["acc"],"application/vnd.amiga.ami":["ami"],"application/vnd.android.package-archive":["apk"],"application/vnd.anser-web-certificate-issue-initiation":["cii"],"application/vnd.anser-web-funds-transfer-initiation":["fti"],"application/vnd.antix.game-component":["atx"],"application/vnd.apple.installer+xml":["mpkg"],"application/vnd.apple.mpegurl":["m3u8"],"application/vnd.aristanetworks.swi":["swi"],"application/vnd.astraea-software.iota":["iota"],"application/vnd.audiograph":["aep"],"application/vnd.blueice.multipass":["mpm"],"application/vnd.bmi":["bmi"],"application/vnd.businessobjects":["rep"],"application/vnd.chemdraw+xml":["cdxml"],"application/vnd.chipnuts.karaoke-mmd":["mmd"],"application/vnd.cinderella":["cdy"],"application/vnd.claymore":["cla"],"application/vnd.cloanto.rp9":["rp9"],"application/vnd.clonk.c4group":["c4g","c4d","c4f","c4p","c4u"],"application/vnd.cluetrust.cartomobile-config":["c11amc"],"application/vnd.cluetrust.cartomobile-config-pkg":["c11amz"],"application/vnd.commonspace":["csp"],"application/vnd.contact.cmsg":["cdbcmsg"],"application/vnd.cosmocaller":["cmc"],"application/vnd.crick.clicker":["clkx"],"application/vnd.crick.clicker.keyboard":["clkk"],"application/vnd.crick.clicker.palette":["clkp"],"application/vnd.crick.clicker.template":["clkt"],"application/vnd.crick.clicker.wordbank":["clkw"],"application/vnd.criticaltools.wbs+xml":["wbs"],"application/vnd.ctc-posml":["pml"],"application/vnd.cups-ppd":["ppd"],"application/vnd.curl.car":["car"],"application/vnd.curl.pcurl":["pcurl"],"application/vnd.dart":["dart"],"application/vnd.data-vision.rdz":["rdz"],"application/vnd.dece.data":["uvf","uvvf","uvd","uvvd"],"application/vnd.dece.ttml+xml":["uvt","uvvt"],"application/vnd.dece.unspecified":["uvx","uvvx"],"application/vnd.dece.zip":["uvz","uvvz"],"application/vnd.denovo.fcselayout-link":["fe_launch"],"application/vnd.dna":["dna"],"application/vnd.dolby.mlp":["mlp"],"application/vnd.dpgraph":["dpg"],"application/vnd.dreamfactory":["dfac"],"application/vnd.ds-keypoint":["kpxx"],"application/vnd.dvb.ait":["ait"],"application/vnd.dvb.service":["svc"],"application/vnd.dynageo":["geo"],"application/vnd.ecowin.chart":["mag"],"application/vnd.enliven":["nml"],"application/vnd.epson.esf":["esf"],"application/vnd.epson.msf":["msf"],"application/vnd.epson.quickanime":["qam"],"application/vnd.epson.salt":["slt"],"application/vnd.epson.ssf":["ssf"],"application/vnd.eszigno3+xml":["es3","et3"],"application/vnd.ezpix-album":["ez2"],"application/vnd.ezpix-package":["ez3"],"application/vnd.fdf":["fdf"],"application/vnd.fdsn.mseed":["mseed"],"application/vnd.fdsn.seed":["seed","dataless"],"application/vnd.flographit":["gph"],"application/vnd.fluxtime.clip":["ftc"],"application/vnd.framemaker":["fm","frame","maker","book"],"application/vnd.frogans.fnc":["fnc"],"application/vnd.frogans.ltf":["ltf"],"application/vnd.fsc.weblaunch":["fsc"],"application/vnd.fujitsu.oasys":["oas"],"application/vnd.fujitsu.oasys2":["oa2"],"application/vnd.fujitsu.oasys3":["oa3"],"application/vnd.fujitsu.oasysgp":["fg5"],"application/vnd.fujitsu.oasysprs":["bh2"],"application/vnd.fujixerox.ddd":["ddd"],"application/vnd.fujixerox.docuworks":["xdw"],"application/vnd.fujixerox.docuworks.binder":["xbd"],"application/vnd.fuzzysheet":["fzs"],"application/vnd.genomatix.tuxedo":["txd"],"application/vnd.geogebra.file":["ggb"],"application/vnd.geogebra.tool":["ggt"],"application/vnd.geometry-explorer":["gex","gre"],"application/vnd.geonext":["gxt"],"application/vnd.geoplan":["g2w"],"application/vnd.geospace":["g3w"],"application/vnd.gmx":["gmx"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/vnd.grafeq":["gqf","gqs"],"application/vnd.groove-account":["gac"],"application/vnd.groove-help":["ghf"],"application/vnd.groove-identity-message":["gim"],"application/vnd.groove-injector":["grv"],"application/vnd.groove-tool-message":["gtm"],"application/vnd.groove-tool-template":["tpl"],"application/vnd.groove-vcard":["vcg"],"application/vnd.hal+xml":["hal"],"application/vnd.handheld-entertainment+xml":["zmm"],"application/vnd.hbci":["hbci"],"application/vnd.hhe.lesson-player":["les"],"application/vnd.hp-hpgl":["hpgl"],"application/vnd.hp-hpid":["hpid"],"application/vnd.hp-hps":["hps"],"application/vnd.hp-jlyt":["jlt"],"application/vnd.hp-pcl":["pcl"],"application/vnd.hp-pclxl":["pclxl"],"application/vnd.ibm.minipay":["mpy"],"application/vnd.ibm.modcap":["afp","listafp","list3820"],"application/vnd.ibm.rights-management":["irm"],"application/vnd.ibm.secure-container":["sc"],"application/vnd.iccprofile":["icc","icm"],"application/vnd.igloader":["igl"],"application/vnd.immervision-ivp":["ivp"],"application/vnd.immervision-ivu":["ivu"],"application/vnd.insors.igm":["igm"],"application/vnd.intercon.formnet":["xpw","xpx"],"application/vnd.intergeo":["i2g"],"application/vnd.intu.qbo":["qbo"],"application/vnd.intu.qfx":["qfx"],"application/vnd.ipunplugged.rcprofile":["rcprofile"],"application/vnd.irepository.package+xml":["irp"],"application/vnd.is-xpr":["xpr"],"application/vnd.isac.fcs":["fcs"],"application/vnd.jam":["jam"],"application/vnd.jcp.javame.midlet-rms":["rms"],"application/vnd.jisp":["jisp"],"application/vnd.joost.joda-archive":["joda"],"application/vnd.kahootz":["ktz","ktr"],"application/vnd.kde.karbon":["karbon"],"application/vnd.kde.kchart":["chrt"],"application/vnd.kde.kformula":["kfo"],"application/vnd.kde.kivio":["flw"],"application/vnd.kde.kontour":["kon"],"application/vnd.kde.kpresenter":["kpr","kpt"],"application/vnd.kde.kspread":["ksp"],"application/vnd.kde.kword":["kwd","kwt"],"application/vnd.kenameaapp":["htke"],"application/vnd.kidspiration":["kia"],"application/vnd.kinar":["kne","knp"],"application/vnd.koan":["skp","skd","skt","skm"],"application/vnd.kodak-descriptor":["sse"],"application/vnd.las.las+xml":["lasxml"],"application/vnd.llamagraphics.life-balance.desktop":["lbd"],"application/vnd.llamagraphics.life-balance.exchange+xml":["lbe"],"application/vnd.lotus-1-2-3":["123"],"application/vnd.lotus-approach":["apr"],"application/vnd.lotus-freelance":["pre"],"application/vnd.lotus-notes":["nsf"],"application/vnd.lotus-organizer":["org"],"application/vnd.lotus-screencam":["scm"],"application/vnd.lotus-wordpro":["lwp"],"application/vnd.macports.portpkg":["portpkg"],"application/vnd.mcd":["mcd"],"application/vnd.medcalcdata":["mc1"],"application/vnd.mediastation.cdkey":["cdkey"],"application/vnd.mfer":["mwf"],"application/vnd.mfmp":["mfm"],"application/vnd.micrografx.flo":["flo"],"application/vnd.micrografx.igx":["igx"],"application/vnd.mif":["mif"],"application/vnd.mobius.daf":["daf"],"application/vnd.mobius.dis":["dis"],"application/vnd.mobius.mbk":["mbk"],"application/vnd.mobius.mqy":["mqy"],"application/vnd.mobius.msl":["msl"],"application/vnd.mobius.plc":["plc"],"application/vnd.mobius.txf":["txf"],"application/vnd.mophun.application":["mpn"],"application/vnd.mophun.certificate":["mpc"],"application/vnd.mozilla.xul+xml":["xul"],"application/vnd.ms-artgalry":["cil"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.ms-excel":["xls","xlm","xla","xlc","xlt","xlw"],"application/vnd.ms-excel.addin.macroenabled.12":["xlam"],"application/vnd.ms-excel.sheet.binary.macroenabled.12":["xlsb"],"application/vnd.ms-excel.sheet.macroenabled.12":["xlsm"],"application/vnd.ms-excel.template.macroenabled.12":["xltm"],"application/vnd.ms-fontobject":["eot"],"application/vnd.ms-htmlhelp":["chm"],"application/vnd.ms-ims":["ims"],"application/vnd.ms-lrm":["lrm"],"application/vnd.ms-officetheme":["thmx"],"application/vnd.ms-pki.seccat":["cat"],"application/vnd.ms-pki.stl":["stl"],"application/vnd.ms-powerpoint":["ppt","pps","pot"],"application/vnd.ms-powerpoint.addin.macroenabled.12":["ppam"],"application/vnd.ms-powerpoint.presentation.macroenabled.12":["pptm"],"application/vnd.ms-powerpoint.slide.macroenabled.12":["sldm"],"application/vnd.ms-powerpoint.slideshow.macroenabled.12":["ppsm"],"application/vnd.ms-powerpoint.template.macroenabled.12":["potm"],"application/vnd.ms-project":["mpp","mpt"],"application/vnd.ms-word.document.macroenabled.12":["docm"],"application/vnd.ms-word.template.macroenabled.12":["dotm"],"application/vnd.ms-works":["wps","wks","wcm","wdb"],"application/vnd.ms-wpl":["wpl"],"application/vnd.ms-xpsdocument":["xps"],"application/vnd.mseq":["mseq"],"application/vnd.musician":["mus"],"application/vnd.muvee.style":["msty"],"application/vnd.mynfc":["taglet"],"application/vnd.neurolanguage.nlu":["nlu"],"application/vnd.nitf":["ntf","nitf"],"application/vnd.noblenet-directory":["nnd"],"application/vnd.noblenet-sealer":["nns"],"application/vnd.noblenet-web":["nnw"],"application/vnd.nokia.n-gage.data":["ngdat"],"application/vnd.nokia.radio-preset":["rpst"],"application/vnd.nokia.radio-presets":["rpss"],"application/vnd.novadigm.edm":["edm"],"application/vnd.novadigm.edx":["edx"],"application/vnd.novadigm.ext":["ext"],"application/vnd.oasis.opendocument.chart":["odc"],"application/vnd.oasis.opendocument.chart-template":["otc"],"application/vnd.oasis.opendocument.database":["odb"],"application/vnd.oasis.opendocument.formula":["odf"],"application/vnd.oasis.opendocument.formula-template":["odft"],"application/vnd.oasis.opendocument.graphics":["odg"],"application/vnd.oasis.opendocument.graphics-template":["otg"],"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/voicexml+xml":["vxml"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":["dmg"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["deb","udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-otf":["otf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-ttf":["ttf","ttc"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/font-woff":["woff"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-install-instructions":["install"],"application/x-iso9660-image":["iso"],"application/x-java-jnlp-file":["jnlp"],"application/x-latex":["latex"],"application/x-lzh-compressed":["lzh","lha"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdownload":["exe","dll","com","bat","msi"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["wmf","wmz","emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-nzb":["nzb"],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["rar"],"application/x-research-info-systems":["ris"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["obj"],"application/x-ustar":["ustar"],"application/x-wais-source":["src"],"application/x-x509-ca-cert":["der","crt"],"application/x-xfig":["fig"],"application/x-xliff+xml":["xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"application/xaml+xml":["xaml"],"application/xcap-diff+xml":["xdf"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xml":["xml","xsl"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/adpcm":["adp"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mp4":["mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/webm":["weba"],"audio/x-aac":["aac"],"audio/x-aiff":["aif","aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-wav":["wav"],"audio/xm":["xm"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/dng":["dng"],"image/g3fax":["g3"],"image/gif":["gif"],"image/ief":["ief"],"image/jpeg":["jpeg","jpg","jpe"],"image/jpg":["jpg"],"image/ktx":["ktx"],"image/png":["png"],"image/prs.btif":["btif"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/tiff":["tiff","tif"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.adobe.photoshop.template":["psdt"],"image/vnd.adobe.pattern+png":["png"],"image/vnd.adobe.shape+svg":["shape"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.dvb.subtitle":["sub"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/webp":["webp"],"image/x-3ds":["3ds"],"image/x-adobe-dng":["dng"],"image/x-adobe-photoshop-brush":["abr"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["ico"],"image/x-mrsid-image":["sid"],"image/x-pcx":["pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/rfc822":["eml","mime"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/vnd.adobe.dn+dcx":["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"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]},i={};Object.keys(o).forEach(function(e){o[e].forEach(function(t){i[t]=i[t]||[],i[t].push(e)})}),n.getExtensions=function(e){return e?o[e.toLowerCase()]||function(e){var t=e.match(/application\/x-adobe-libraries-(.+)/);return t?[t[1]]:[]}(e.toLowerCase()):[]},n.getMimeTypes=function(e){return e?i[e.toLowerCase()]||function(e){return["application/x-adobe-libraries-"+e]}(e.toLowerCase()):[]},Object.seal(n),e.exports=n},function(e,t){e.exports=require("fs-extra")},function(e,t,n){var o=n(39),i={parseXML:function(e,t){var n;return new o.Parser({async:!1}).parseString(e,function(e,o){e?t&&t(e):n=o}),n},parseQueryString:function(e){var t={},n=e&&e.split("?");n[1]&&n[1].split("&").forEach(function(e){var n=e.split("=");n[1]&&(t[n[0]]=n[1])});return t},stripProtocolPrefix:function(e){return["http://","https://"].forEach(function(t){e&&0===e.indexOf(t)&&(e=e.substring(t.length))}),e}};e.exports=i},function(e,t,n){var o=n(3),i=n(6),r=n(2),a="IMS",s=["creative_cloud","cce_private"];i.log(a,"Loading IMS Library...");var c,l,d,p,h,u,_,f=o.getEnvironment(),m=n(117),E=[],g=[];function y(e,t){if(t)return t.some(function(t){return-1!==e.indexOf(t.serviceCode)&&"CLOSED"!==t.serviceStatus})}function v(e,t){e.forEach(function(e){try{e.apply(void 0,t)}catch(e){i.log(a,"Error in callback: "+e)}})}function A(){var e=m.createRefEx(f.IMS);return p&&p.name&&p.pass&&m.setProxyCredentialsInIMSLibSession(e,p.name,p.pass),e}var C,S=!1;try{!function(){var e=A();m.registerClientToGroup(e,f.CLIENT_ID,"AAM"),c=m.getDeviceID(e),i.log(a,"DeviceID: "+c),m.releaseRef(e)}(),S=!0,i.log(a,"IMS Library Successfully Loaded")}catch(e){i.log(a,"IMS Library Failed to Load: "+e)}var I={getDeviceId:function(){return c},getUserId:function(){if(!l&&S){var e,t,n=A();try{t=(e=m.fetchDefaultUserInfoForClientId(n,f.CLIENT_ID))?"Default User: "+e.Email+" ("+e.UserID+")":"No default user"}catch(e){t="Error fetching default user: "+e}m.releaseRef(n),t!==C&&i.log(a,t),C=t,(l=e&&e.UserID)&&(_=!0,this.getAccessToken(function(e,t,n){d=n&&n.serviceAccounts,_=!1;var o=g;g=[],v(o,[])}))}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(u&&Date.now()<u)return delete h.response.access_token,h.expires=u,void t(null);u=Date.now()+o.getValue("ACCESS_TOKEN_CACHE_DURATION")}if(E.push(t),!(E.length>1)){h=void 0;var n=A();i.log(a,"Started IMSLib.fetchAccessToken"),m.fetchAccessToken(n,f.CLIENT_ID,f.CLIENT_SECRET,l,"",o.getValue("SCOPES"),function(e,t){i.log(a,"Finished IMSLib.fetchAccessToken"),setTimeout(function(){m.releaseRef(n)});var c=function(e,t,n){var o=E;E=[],v(o,[e,t,n])};return e?(i.log(a,e),void c(null)):!t.error&&!y(s,t.serviceAccounts)||"ride_AdobeID_subs_actreq"===t.error?(i.log(a,"Services not provisioned"),void c(new r(r.ACCESS_DENIED,"services not provisioned"),void 0,t)):(t.error?i.log(a,"Unknown Error: "+t.error):i.log(a,"Successfully obtained access token"),h={response:t,expires:Date.now()+o.getValue("ACCESS_TOKEN_CACHE_DURATION")},void c(null,t.access_token,t))})}}else t(null,void 0)},getClientAccessToken:function(e,t,n,o,s){if(l&&e===l){var c=A();i.log(a,`Started IMSLib.fetchAccessToken for ${t}`),m.fetchAccessToken(c,t,n,l,"",o,function(e,n){if(i.log(a,`Finished IMSLib.fetchAccessToken for ${t}`),setTimeout(function(){m.releaseRef(c)}),e||n.error)return i.log(a,e||n.error),void s(new r(r.ACCESS_DENIED,"error obtaining access token from IMS"));const{access_token:o,expires_in:l}=n;s(null,{access_token:o,expires_in:l})})}else s(new r(r.ACCESS_DENIED,"user mismatch"))},hasEntitlement:function(e,t){var n=function(){var n=y([e],d);t(n)};_?g.push(n):n()},setProxyCredentials:function(e,t){p={name:e,pass:t}}};e.exports=I},function(e,t,n){const o=n(14),i=n(10),r=n(32),a=n(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,n]of Object.entries(e))t.includes("#")&&(e.custom_data||(e.custom_data={}),e.custom_data[t]=n,delete e[t])},p=e=>{const t=e.custom_data||{};for(const[n,o]of Object.entries(t))e[n]=o;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[n,o]of Object.entries(e))"representations"===n&&Array.isArray(o)?o.forEach(t):h(o,t)},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},n=e.getCachedContentPath();n&&(t.path=o.normalize(n));const i=e.getValues();return i&&i.length>0&&(t.custom_data={},i.forEach(e=>t.custom_data[`${e.namespace}#${e.key}`]=e.value)),t},_=e=>e?Array.isArray(e)?e.reduce((e,t)=>e+_(t),0):e.elements?e.elements.reduce((e,t)=>e+_(t),0):e.representations?e.representations.reduce((e,t)=>e+(t.contentLength||0),0):0:0,f=(e,t,n,o)=>{const i={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(i.groups=e.getGroups(/.*/).map(t=>({id:t.id,classifier:t.classifierName,order:e.getOrderInGroup(t)})),i.representations=e.representations.map(u),n){const t=e.library;if(i.library={},i.library.id=t.id,i.library.name=t.name,t.collaboration){const e=t.collaboration.toLowerCase();i.library.collaboration={state:e},i.library.collaboration.role="outgoing"===e?"owner":t.isWritable?"editor":"viewer",i.library.ownership=e}else i.library.ownership=t.collection.isPublic?"public":"private"}if(o){const t=e.library._renditionCache.serializeElementCache(e,!0);Object.keys(t).length>0&&(i.thumbnail_cache=t)}t&&(i.size=_(e));const r=e.getValues();return r&&r.length>0&&(i.custom_data={},r.forEach(e=>i.custom_data[`${e.namespace}#${e.key}`]=e.value)),i};e.exports={getRequestHandler:(e,t,n)=>(o,a)=>{let s,c,l,u;const _=o.params.libraryId||o.body&&o.body.filters&&o.body.filters.library_id;if(_){if(!(s=i.getLibraryById(_))||s.isDeletedFromServer)return a.send(r.LIBRARY_NOT_FOUND);if(t&&!s.isWritable)return a.send(r.LIBRARY_NOT_WRITABLE)}if(o.params.elementId&&(!(c=s.getElementById(o.params.elementId))||(n?!c.removed:c.removed)))return a.send(r.ELEMENT_NOT_FOUND);if(o.params.representationId&&!(l=c.getRepresentationById(o.params.representationId)))return a.send(r.REPRESENTATION_NOT_FOUND);if(o.params.groupId&&!(u=s.getGroupById(o.params.groupId)))return a.send(r.GROUP_NOT_FOUND);const f=(o.headers["x-client-version"]||1)<=2;f&&(e=>{h(e,d)})(o.body);try{e(o.params,o.body,u||l||c||s).then(e=>{f&&(e=>{h(e,p)})(e),a.send(e)}).catch(e=>{a.send(e)})}catch(e){a.send(r.getResponseError(e))}},getPollingRequestHandler:e=>(t,n)=>{if(!t.body)return n.send(r.NOTIFICATIONS_DATA_NOT_FOUND);const o=e(t.body,e=>{n.send(e)});o&&t.on("close",o)},getGroupResponseData:e=>{return{id:e.id,name:e.name,classifier:e.classifierName,order:e.order,created_date:e.created,modified_date:e.modified}},getElementResponseData:f,getLibraryResponseData:(e,t,n)=>{const o={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(o.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||(o.default=!0),e.collaboration){const t=e.collaboration.toLowerCase();o.collaboration={state:t},o.collaboration.role="outgoing"===t?"owner":e.isWritable?"editor":"viewer",o.ownership=t}else o.ownership=e.collection.isPublic?"public":"private";t&&(o.elements=e.elements.map(f)),n&&(o.size=_(e));const i=e.getValues();return i&&i.length>0&&(o.custom_data={},i.forEach(e=>o.custom_data[`${e.namespace}#${e.key}`]=e.value)),o},getPagedResponses:(e,t,n,o,i,r)=>{if(e.length<=o)return{pagedResults:e,isLastPage:!0};const a=i?r.findNextIndex(e,t,i,n):0;if(e.length<=a+o)return{pagedResults:e.slice(a),isLastPage:!0};let s=a+o-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[n,o]=e.split("-").reverse(),i=void 0===o;return t.includes(n)||(n=t[0],i=!1),{orderBy:n,isAscending:i}},updateCustomData:(e,t)=>{t.forEach(({namespace:t,key:n,value:o})=>{null!==o?e.setValue(t,n,o):e.removeValue(t,n)})},parseCustomData:e=>{const t=[];return e?Object.keys(e).every(n=>{const[o,i,...r]=n.split("#");return!!(!r.length&&o&&o.length&&i&&i.length&&o!==a.DL_NAMESPACE)&&(t.push({namespace:o,key:i,value:e[n]}),!0)})?t:void 0:t},parseFilterField:(e,t)=>l[e]&&l[e](t),parseSortField:(e,t)=>c[e]&&c[e](t)}},function(e,t,n){const o=n(137),i=n(2),r={};r[i.ACCESS_DENIED]=o.ForbiddenError,r[i.DELETED_LOCALLY]=o.NotFoundError,r[i.FILE_TOO_LARGE]=o.RequestEntityTooLargeError,r[i.INVALID_DATA]=o.BadRequestError,r[i.INVALID_PARAMETER]=o.BadRequestError,r[i.LOGGED_OUT]=o.UnauthorizedError,r[i.NOT_ALLOWED]=o.ForbiddenError,r[i.NOT_IMPLEMENTED]=o.NotImplementedError,r[i.NOT_SUPPORTED]=o.NotAcceptableError,r[i.READ_ONLY]=o.ForbiddenError,r[i.RENDITION_NOT_AVAILABLE]=o.NotFoundError,r[i.OUT_OF_SPACE]=o.InsufficientStorageError,r[i.URL_VALIDATION_FAILED]=o.BadRequestError,r[i.THUMBNAIL_NOT_AVAILABLE]=o.NotFoundError,e.exports={COLLECTION_NOT_FOUND:new o.InternalServerError("Cannot find private collection"),LIBRARY_NAME_MISSING:new o.BadRequestError("Library name is missing"),LIBRARY_ID_MISSING:new o.BadRequestError("Library id is missing"),LIBRARY_URL_MISSING:new o.BadRequestError("Library URL is missing"),LIBRARY_NOT_FOUND:new o.NotFoundError("Cannot find library"),LIBRARY_NOT_WRITABLE:new o.ForbiddenError("Library is read-only"),LIBRARY_NOT_ENOUGH_SPACE:new o.InsufficientStorageError("Library does not have enough space for new elements"),ELEMENT_NOT_FOUND:new o.NotFoundError("Cannot find element"),ELEMENT_IDS_MISSING:new o.BadRequestError("Element ids are missing"),ELEMENT_DATA_MISSING:new o.BadRequestError("Element data is missing"),ELEMENT_TYPE_MISSING:new o.BadRequestError("Element type is missing"),ELEMENT_BODY_MISSING:new o.BadRequestError("Element name or representation data or tag data is needed"),ELEMENT_NAME_INVALID:new o.BadRequestError("Element name must be a string"),ELEMENT_TAGS_INVALID:new o.BadRequestError("Element tags must be an array of strings"),REPRESENTATION_DATA_MISSING:new o.BadRequestError("Representations are missing"),REPRESENTATION_NOT_FOUND:new o.NotFoundError("Cannot find representation"),REPRESENTATION_PATH_NOT_FOUND:new o.NotFoundError("Cannot find representation path"),REPRESENTATION_ID_NOT_RESOLVED:new o.BadRequestError("Representation id cannot be resolved"),REPRESENTATION_TYPE_MISSING:new o.BadRequestError("Representation type is missing"),REPRESENTATION_REL_MISSING:new o.BadRequestError("Representation relationship is missing"),REPRESENTATION_CHILDREN_INVALID:new o.BadRequestError("Representation children is invalid"),REPRESENTATION_REL_INVALID:new o.BadRequestError("Representation relationship is invalid"),REPRESENTATION_REL_PRIMARY_FOUND:new o.BadRequestError("Cannot have multiple primary representations"),REPRESENTATION_WIDTH_INVALID:new o.BadRequestError("Representation width is invalid"),REPRESENTATION_HEIGHT_INVALID:new o.BadRequestError("Representation height is invalid"),REPRESENTATION_CONTENT_LENGTH_INVALID:new o.BadRequestError("Representation content_length is invalid"),REPRESENTATION_CONTENT_LENGTH_UNEXPECTED:new o.BadRequestError("Representation content_length can only be used for an externally-linked representation"),REPRESENTATION_FULL_SIZE_INVALID:new o.BadRequestError("Representation is_full_size is invalid"),REPRESENTATION_SOURCE_MISSING:new o.BadRequestError("Representation source should have a URL or Path"),GROUP_NOT_FOUND:new o.NotFoundError("Cannot find group"),GROUP_NAME_MISSING:new o.BadRequestError("Group name is missing"),GROUP_ORDER_MISSING:new o.BadRequestError("Group order is missing"),GROUP_BODY_MISSING:new o.BadRequestError("Group name or order is needed"),NOTIFICATIONS_DATA_NOT_FOUND:new o.BadRequestError("Notification base data is missing"),EMPTY_SEARCH:new o.BadRequestError("Empty search query"),CONFLICTING_OWNERSHIP:new o.NotFoundError("Filters for ownership and library id conflict"),INVALID_MODIFIED_FILTER:new o.BadRequestError("Modified date filter is incorrectly formatted"),EMPTY_FILTERS:new o.BadRequestError("If a filter object is defined, it must have at least one property"),INCORRECT_LIMIT:new o.BadRequestError("Limit must be a positive integer"),INVALID_CUSTOM_DATA:new o.BadRequestError("Invalid custom data"),INVALID_UPDATE_REQUEST:new o.BadRequestError("Invalid Update Request"),getResponseError:e=>{if(e instanceof i){return new(r[e.code]||o.InternalServerError)(e.message)}return new o.InternalServerError(e&&e.message?e.message:e)}}},function(e,t,n){var o=n(49),i=n(66),r=n(4),a=n(7),s=6;function c(e,t,n){if(e)e=this._setData(e,t);else{var i=a.generateUuid();e={"manifest-format-version":s,id:i},this.originalManifestFormatVersion=s,this._core=new o(e,this,t),this._data=e}this._pendingElements=[],this.manifestPath=n}function l(e){var t=e["manifest-format-version"];if(t<s){if(t<4)throw new r(r.INVALID_DATA,"Encountered manifest format version "+e["manifest-format-version"]+". Format version conversion not yet implemented for that version.");t<5&&function e(t){var n,o,i=t.components;if(i)for(o=i.length,n=0;n<o;n++)delete i[n].localStorageAssetId;var r=t.children;if(r)for(o=r.length,n=0;n<o;n++)e(r[n])}(e),t<6&&function e(t,n){n&&t.path&&delete t.path;var o,i=t.components;if("object"==typeof i)for(o=0;o<i.length;o++){var r=i[o];"number"==typeof r.version&&(r.version=r.version.toString())}var a=t.children;if("object"==typeof a)for(o=0;o<a.length;o++)e(a[o])}(e,!0)}}c._newBranchAsCopyOfCore=function(e,t){var n=new c(JSON.parse(JSON.stringify(e._data))),o=n._core;return n._localStorage=t,n._resetIdentity(function(n){var i=e.getComponentWithId(n.id);if(!i)throw new r(r.INVALID_STATE,"Could not find original component.");if("modified"===i.state||!i.etag)throw new r(r.INVALID_STATE,"Cannot create a new composite from a branch that contains modified or unbound components.");var a=e._getHrefOfComponent(i);if(!a)throw new r(r.INVALID_STATE,"Cannot determine the href of component id "+i.id);o._setSourceHrefOfComponent(a,n),t&&t.removeComponentAsset(n,o._local())}),n},Object.defineProperties(c.prototype,{compositeId:{get(){return this._core.rootNode.id},set(e){var t=this._core;if(t._readOnly)throw new r(r.READ_ONLY,"This object is read-only.");if("string"!=typeof e||""===e)throw new r(r.INVALID_PARAMS,"Expecting a non-empty string.");if(t._allNodes[e])throw new r(r.DUPLICATE_VALUE,"There is already a node with the same id.");delete t._allNodes[this._data.id],this._data.id=e,t._allNodes[e]=this._core.rootNode,t._setDirty()}},rootNode:{get(){return this._core.rootNode},set(e){this._core.rootNode=e}},name:{get(){return this._core.rootNode.name},set(e){var t=this._core;if(t._readOnly)throw new r(r.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new r(r.INVALID_PARAMS,"Expecting a string or undefined.");t.rootNode.name=e}},type:{get(){return this._core.rootNode.type},set(e){var t=this._core;if(t._readOnly)throw new r(r.READ_ONLY,"This object is read-only.");if("string"!=typeof e||""===e)throw new r(r.INVALID_PARAMS,"Expecting a non-empty string.");t.rootNode.type=e}},compositeHref:{get(){return this._data.local?this._data.local.compositeHref:void 0},set(e){var t=this._core;if(t._readOnly)throw new r(r.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new r(r.INVALID_PARAMS,"Expecting a string or undefined.");t._local().compositeHref=a.ensureRelativeHrefStartsWithSlash(e),t._setDirty(!0)}},_collaborationType:{get(){return this._data.local?this._data.local.collaborationType:void 0},set(e){var t=this._core;if(t._readOnly)throw new r(r.READ_ONLY,"This object is read-only.");e?t._local().collaborationType=e:delete t._local().collaborationType,t._setDirty(!0)}},_clientDataString:{get(){return this._data.local?this._data.local.clientDataString:void 0},set(e){var t=this._core;if(t._readOnly)throw new r(r.READ_ONLY,"This object is read-only.");e?t._local().clientDataString=e:delete t._local().clientDataString,t._setDirty(!0)}},manifestEtag:{get(){return this._data.local?this._data.local.manifestEtag:void 0},set(e){var t=this._core;if(t._readOnly)throw new r(r.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new r(r.INVALID_PARAMS,"Expecting a string or undefined.");t._local().manifestEtag=e,t._setDirty(!0)}},compositeState:{get(){return this._data.state||"unmodified"},set(e){var t=this._core;if(t._readOnly)throw new r(r.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new r(r.INVALID_PARAMS,"Expecting a string.");if("unmodified"!==e&&"modified"!==e&&"pendingDelete"!==e&&"committedDelete"!==e)throw new r(r.INVALID_PARAMS,'State must be "modified", "unmodified", "pendingDelete", or "committedDelete".');if("pendingDelete"===e&&"committedDelete"===e&&("pending"===this.compositeArchivalState||"archived"===this.compositeArchivalState))throw new r(r.INVALID_STATE,"Cannot delete an archived composite.");this._data.state=e,t._setDirty(!0)}},compositeArchivalState:{get(){return this._core._local().archivalState||"active"},set(e){var t=this._core;if(t._readOnly)throw new r(r.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new r(r.INVALID_PARAMS,"Expecting a string.");if("pending"!==e&&"archived"!==e&&"active"!==e)throw new r(r.INVALID_PARAMS,'State must be "pending", "archived", or undefined.');if("archived"===this.compositeArchivalState)throw new r(r.INVALID_STATE,"Composite has already been archived.");if("active"!==e&&("pendingDelete"===this.compositeState||"committedDelete"===this.compositeState))throw new r(r.INVALID_STATE,"Cannot archive a deleted composite.");"active"===e?delete this._core._local().archivalState:this._core._local().archivalState=e,t._setDirty(!0)}},isBound:{get(){return this.manifestEtag&&this.compositeHref},set(){throw new r(r.READ_ONLY,"Cannot set the property isBound. Use resetIdentity instead.")}},_localStorage:{get(){return this._core._localStorage},set(e){this._core._localStorage=e}},hasLocalStorage:{get(){return this._core.hasLocalStorage},set(e){this._core.hasLocalStorage=e}},_isDirty:{get(){return this._core._isDirty},set(e){this._core._isDirty=e}},isDirty:{get(){return this._core.isDirty},set(e){this._core.isDirty=e}},localData:{get(){return this._core._stringify(!1,!0)},set(){throw new r(r.READ_ONLY,"Cannot set the property localData.")}},remoteData:{get(){return this._core._stringify(!0)},set(){throw new r(r.READ_ONLY,"Cannot set the property remoteData.")}},pendingElements:{get(){return this._pendingElements},set(){throw new r(r.READ_ONLY,"Cannot set the property pendingElements.")}},changeCount:{get(){return this._core.changeCount},set(e){this._core.changeCount=e}},readOnly:{get(){return this._core._readOnly},set(e){this._core._readOnly=e}}}),c.prototype.parse=function(e){if("string"!=typeof e)throw new r(r.INVALID_PARAMS,'Param "data" must be a string');var t=null;try{t=JSON.parse(e)}catch(e){throw new r(r.INVALID_JSON,"Manifest could not be parsed. Underlying error: "+e.message)}return this._setData(t,this._core._readOnly)},c.prototype.getElementWithId=function(e){return this._createElement(this._core.getChildWithId(e))},c.prototype.getElementWithAbsolutePath=function(e){return this._createElement(this._core.getChildWithAbsolutePath(e))},c.prototype.addElement=function(e,t,n,o,i,a){if("string"!=typeof e)throw new r(r.INVALID_PARAMS,"Element must have a name of type string");if("string"!=typeof t)throw new r(r.INVALID_PARAMS,"Element must have a type of type string");if("string"!=typeof n)throw new r(r.INVALID_PARAMS,"Element must have a path of type string");var s=this._core.addChild(e,o,i,a);try{s.path=n}catch(e){throw this._core.removeChild(s),e}return s._data.type=t,this._createElement(s)},c.prototype.updateElement=function(e){var t=this.getChildWithId(e.rootNode.id);if(!t)throw new r(r.INVALID_PARAMS,"Element does not exist in branch.");var n=this._core.replaceChild(e.rootNode,t.path);return this._deleteElement(e),n},c.prototype.abandonElement=function(e){this._deleteElement(e)},c.prototype.getChildWithId=function(e){return this._core.getChildWithId(e)},c.prototype.getChildWithAbsolutePath=function(e){return this._core.getChildWithAbsolutePath(e)},c.prototype.getChildrenOf=function(e){return this._core.getChildrenOf(e)},c.prototype.addChild=function(e,t,n,o){return this._core.addChild(e,t,n,o)},c.prototype.removeChild=function(e){return this._core.removeChild(e)},c.prototype.moveChild=function(e,t,n){return this._core.moveChild(e,t,n)},c.prototype.copyChild=function(e,t,n,o,i,r){return this._core.copyChild(e,t,n,o,i,r)},c.prototype.replaceChild=function(e,t,n,o){return this._core.replaceChild(e,t,n,o)},c.prototype.allComponents=function(){return this._core.allComponents()},c.prototype.getComponentWithId=function(e){return this._core.getComponentWithId(e)},c.prototype.getComponentWithAbsolutePath=function(e){return this._core.getComponentWithAbsolutePath(e)},c.prototype.getComponentsOf=function(e){return this._core.getComponentsOf(e)},c.prototype.addComponent=function(e,t,n,o,i,r,a,s,c,l){return this._core.addComponent(e,t,n,o,i,r,a,s,c,l)},c.prototype.addComponentWithUploadResults=function(e,t,n,o,i){return this._core.addComponentWithUploadResults(e,t,n,o,i)},c.prototype.updateComponent=function(e,t,n,o){return this._core.updateComponent(e,t,n,o)},c.prototype.updateComponentWithUploadResults=function(e,t){return this._core.updateComponentWithUploadResults(e,t)},c.prototype.removeComponent=function(e){return this._core.removeComponent(e)},c.prototype.moveComponent=function(e,t){return this._core.moveComponent(e,t)},c.prototype.copyComponent=function(e,t,n,o,i){return this._core.copyComponent(e,t,n,o,i)},c.prototype.replaceComponent=function(e,t,n,o){return this._core.replaceComponent(e,t,n,o)},c.prototype.assetOfComponent=function(e,t){return this._core.assetOfComponent(e,t)},c.prototype.copy=function(){var e=new c(JSON.parse(JSON.stringify(this._data)));return e._localStorage=this._localStorage,e},c.prototype._createElement=function(e){var t;if(e){var n=JSON.parse(JSON.stringify(e._data));n["manifest-format-version"]=this._data["manifest-format-version"],delete n.path,(t=new i(n,this,this._core._readOnly))&&this._localStorage&&(t._localStorage=this._localStorage,t._updateLocalDataFromBranch(this),this._localStorage.registerInMemoryBranchOrElement(t))}return t&&this._pendingElements.push(t),t},c.prototype._deleteElement=function(e){var t=this._pendingElements.indexOf(e);if(t<0)throw new r(r.INVALID_PARAMS,"Unknown element.");this._pendingElements.splice(t,1),this._localStorage&&this._localStorage.unregisterInMemoryBranchOrElement(e)},c.prototype._updateLocalDataFromBranch=function(e){if(this._readOnly)throw new r(r.READ_ONLY,"This object is read-only.");if(!this._localStorage)throw new r(r.NO_LOCAL_STORAGE,"No local storage.");if(!e._localStorage)throw new r(r.NO_LOCAL_STORAGE,"No local storage for source.");if(this._localStorage.compositePath!==e._localStorage.compositePath)throw new r(r.INVALID_PARAMS,"Branches must have same storage path.");this._core._localStorage.copyLocalStorageData(e,e._core._local(),this,this._core._local()),this._core._copySourceHrefsFrom(e._core)},c.prototype._verify=function(e){return"string"!=typeof e.id?new r(r.INVALID_DATA,"Manifest is missing an id of type string"):"string"!=typeof e.name?new r(r.INVALID_DATA,"Manifest is missing a name of type string"):"string"!=typeof e.type?new r(r.INVALID_DATA,"Manifest is missing a type of type string"):"number"!=typeof e["manifest-format-version"]?new r(r.INVALID_DATA,"Manifest is missing a manifest-format-version of type number"):null},c.prototype._setData=function(e,t){this.originalManifestFormatVersion=e["manifest-format-version"],l(e),e.local&&(e.local.version=2);var n=this._verify(e);if(null===n)return e["manifest-format-version"]=s,this._core=new o(e,this,t),this._data=e,this;throw n},c.prototype._reset=function(e,t){if(this._readOnly)throw new r(r.READ_ONLY,"This object is read-only.");this._data.local&&(delete this._data.local.manifestEtag,delete this._data.local.compositeHref),e||(this._data.id=a.generateUuid()),this._data.state="modified",this._core._recursiveReset(this._data,t),this._core._setDirty()},c.prototype._resetBinding=function(e){this._reset(!0,e)},c.prototype._resetIdentity=function(e){this._reset(!1,e)},c.prototype._local=function(){return this._core._local()},c.prototype._setDirty=function(e){this._core._setDirty(e)},c.prototype._setPathOfNode=function(e,t){this._core._setPathOfNode(e,t)},c.prototype._verifyIntegrity=function(e,t,n){return this._core._verifyIntegrity(e,t,n)},e.exports=c},function(e,t,n){var o=n(0),i=n(2),r=n(7),a={getBackoffTicks:function(e){var t=o.BACKOFF_INTERVALS;return t[Math.max(0,Math.min(e,t.length-1))]-1},getRetryAfterHeader:function(e){if(e){var t=e["retry-after"]||e["Retry-After"];if(t)try{var n=parseInt(t,10);if(n)return Math.max(0,n);var i=Date.parse(t);if(i){var r=(new Date).valueOf();return Math.max(0,i-r)/1e3+Math.floor(Math.random()*o.RETRY_RANDOM_SECONDS)}}catch(e){}}return 0},getLocationHeader:function(e){if(e){var t=e.location||e.Location;if(t)return t}},getContentTypeHeader:function(e){if(e){var t=e["content-type"]||e["Content-Type"];if(t){var n=t.indexOf(";");return n>0&&(t=t.substring(0,n)),t}}},getContentLengthHeader:function(e){if(e){var t=e["content-length"]||e["Content-Length"];return Number(t)||void 0}},isUnrecoverableClientError:function(e,t){return!!e&&(e>=400&&e<500&&(401!==e||!!t)&&407!==e&&408!==e)},isRedirect:function(e){return 301===e||302===e||303===e||307===e}},s=function(e,t){return t.some(function(t){if(e===t)return!0;var n=e.indexOf("."+t);return-1!==n&&n===e.length-t.length-1})};a.isAdobeDomain=function(e){return!!e&&s(e,o.ADOBE_AUTHENTICATED_DOMAINS)},a.validateURL=function(e,t){if(!e)return new i(i.URL_VALIDATION_FAILED,"URL not specified");var n=r.parseURI(e);if("https"!==n.scheme)return new i(i.URL_VALIDATION_FAILED,"URL must be https://");if(!(a.isAdobeDomain(n.authority)||s(n.authority,o.WHITELISTED_DOMAINS)))return new i(i.URL_VALIDATION_FAILED,"URL domain not in whitelist");const c=t&&t._syncManager._storageHost,l=c&&o.DISALLOWED_DOMAINS[c];return s(n.authority,l||[])?new i(i.URL_VALIDATION_FAILED,"URL domain does not match IMS environment (stage-production mismatch)"):null},Object.seal(a),e.exports=a},function(e,t,n){var o=n(1),i=n(0),r=function(){return o.storageInterface.getServiceInfo()},a=function(){var e=r();return e&&e.apiVersion||0},s={supportsClearRenditionCache:function(){return a()>=7},supportsTestExternalLink:function(){return a()>=10},updateElementActionMap:function(e){if(r()){if(a()<9){var t=e.types;e.types=i.ELEMENT_ACTION_PRODUCT_MAP.types,e.types["application/vnd.adobe.element.image+dcx"]=t}i.ELEMENT_ACTION_PRODUCT_MAP=e}},formatElementActionMapForClient:function(e){return e<9?{types:i.ELEMENT_ACTION_PRODUCT_MAP.types["application/vnd.adobe.element.image+dcx"],products:i.ELEMENT_ACTION_PRODUCT_MAP.products,installedApps:i.ELEMENT_ACTION_PRODUCT_MAP.installedApps}:i.ELEMENT_ACTION_PRODUCT_MAP}};Object.seal(s),e.exports=s},function(e,t){e.exports=require("child_process")},function(e){e.exports={name:"cc-libraries-api-js",version:"3.4.3",private:!0,description:"Adobe Creative Cloud Libraries API for JavaScript",dependencies:{"dcx-js":"git+ssh://git@git.corp.adobe.com:ProjectCentral/dcx-js.git#v1.7.23","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:{bufferutil:"1.3.0",ffi:"2.2.0","font-manager":"git+ssh://git@git.corp.adobe.com:michsmit/font-manager.git#v0.3.4","fs-ext":"1.2.1","idle-gc":"1.0.1","image-size":"0.6.2","node-ProxyResolver":"git+ssh://git@git.corp.adobe.com:ProjectCentral/node-ProxyResolver.git#v1.2.5","node-imslib":"git+ssh://git@git.corp.adobe.com:ProjectCentral/node-imslib.git#v1.2.7","node-vulcanjs":"git+ssh://git@git.corp.adobe.com:slade/VulcanJS.git#v1.2.5","node-thumbnailgenerator":"git+ssh://git@git.corp.adobe.com:ProjectCentral/node-ThumbnailGenerator.git#v1.4.2",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","@ccx/ingest":"git+ssh://git@git.corp.adobe.com:CCX/Ingest.git#2.0.0"},devDependencies:{"7zip":"0.0.6","@babel/core":"^7.1.2","@babel/preset-env":"^7.1.0","@ccx/hyperdrive-builder":"git+ssh://git@git.corp.adobe.com:CCX/hyperdrive-builder.git#v3.0.43","babel-loader":"^8.0.4",fetch:"^1.1.0",grunt:"1.0.1","grunt-contrib-clean":"1.0.0","grunt-contrib-compress":"1.3.0","grunt-contrib-copy":"1.0.0","grunt-eslint":"21.0.0","grunt-jsdoc":"2.1.0","grunt-node-gyp":"3.1.0","ignore-loader":"^0.1.2","ink-docstrap":"1.3.0",istanbul:"0.4.5","jasmine-node":"1.14.5",jsftp:"2.1.3",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",start:"node server",debug:"node server.js --debug"},cepPanels:[{source:"https://artifactory.corp.adobe.com/artifactory/generic-cc-libraries-release/2.3.1050r/CCLibraries.zxp",destination:"CC_LIBRARIES_PANEL_EXTENSION_2_3_1050"},{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"}],cepPanelsToRemove:["CC_LIBRARIES_PANEL_EXTENSION_2_3_1012","CC_LIBRARIES_PANEL_EXTENSION_2_3_1026_DEV","CC_LIBRARIES_PANEL_EXTENSION_2_3_1038_DEV","CC_LIBRARIES_PANEL_EXTENSION_2_3_1044_DEV","CC_LIBRARIES_PANEL_EXTENSION_2_3_1046_DEV","CC_LIBRARIES_PANEL_EXTENSION_2_3_1047_DEV","CC_LIBRARIES_PANEL_EXTENSION_2_3_1048","CC_LIBRARIES_PANEL_EXTENSION_2_6_60_DEV","CC_LIBRARIES_PANEL_EXTENSION_2_10_56"],thor:[{product:"ACCC",subproduct:"Application",version:"4.9",certification:"Integration Ready",name:"ACCCx4_9_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,n){var o=n(4),i=n(7);function r(e,t){e?this._setData(e):this._data={},this._readOnly=t}var a={unmodified:"unmodified",modified:"modified",pendingDelete:"pendingDelete",committedDelete:"committedDelete"};r.STATES=a,r._UploadResults=function(e){this.compositeId=e,this.records={}},r._UploadRecord=function(e,t,n,o,i,r){this.id=e,this.etag=t,this.version=n,this.md5=o,this.length=i,this.type=r},Object.defineProperties(r.prototype,{id:{get(){return this._data.id},set(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(this._owner)throw new o(o.READ_ONLY,"Cannot change the id of a component that is part of a branch or element.");if("string"!=typeof e||""===e)throw new o(o.INVALID_PARAMS,"Expecting a non-empty string.");this._data.id=e,this._setDirty()}},name:{get(){return this._data.name},set(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a string or undefined.");this._data.name=e,this._setDirty()}},type:{get(){return this._data.type},set(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e||""===e)throw new o(o.INVALID_PARAMS,"Expecting a non-empty string.");this._data.type=e,this._setDirty()}},path:{get(){return this._data.path},set(e){if(this._data.path!==e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(!i.isValidPath(e))throw new o(o.INVALID_PARAMS,"Expecting a valid path.");this._owner?this._owner._core._setPathOfComponent(this,e):(this._data.path=e,this._parentPath=""),this._setDirty()}}},parentPath:{get(){return this._parentPath},set(){throw new o(o.READ_ONLY,"parentPath is read-only.")}},absolutePath:{get(){return this._data.path&&this._owner?i.appendPathElements(this._parentPath,this._data.path):void 0},set(){throw new o(o.READ_ONLY,"absolutePath is read-only.")}},relationship:{get(){return this._data.rel},set(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a string or undefined.");this._data.rel=e,this._setDirty()}},state:{get(){return this._data.state},set(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new o(o.INVALID_PARAMS,"Expecting a string.");if(!a.hasOwnProperty(e))throw new o(o.INVALID_PARAMS,'State must be "modified", "unmodified", "pendingDelete", or "committedDelete".');this._data.state=e,this._setDirty()}},etag:{get(){return this._data.etag},set(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a string or undefined.");this._data.etag=e,this._setDirty()}},md5:{get(){return this._data.md5},set(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a string or undefined.");this._data.md5=e,this._setDirty()}},version:{get(){return this._data.version},set(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(void 0!==e&&"string"!=typeof e)throw new o(o.INVALID_PARAMS,"Expecting a string or undefined.");this._data.version=e,this._setDirty()}},length:{get(){return this._data.length},set(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("number"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a number or undefined.");this._data.length=e,this._setDirty()}},width:{get(){return this._data.width},set(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("number"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a number or undefined.");this._data.width=e,this._setDirty()}},height:{get(){return this._data.height},set(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("number"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a number or undefined.");this._data.height=e,this._setDirty()}}});var s={name:!0,id:!0,state:!0,path:!0,rel:!0,type:!0,etag:!0,length:!0,version:!0,md5:!0,width:!0,height:!0};r.prototype.getCustomKeys=function(){var e,t=[],n=Object.keys(this._data),o=n.length;for(e=0;e<o;e++){var i=n[e];s[i]||t.push(i)}return t},r.prototype.getValue=function(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "key" must be a string');return this._data[e]},r.prototype.setValue=function(e,t){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "key" must be a string');this._data[e]=t,this._setDirty()},r.prototype.removeValue=function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "key" must be a string');delete this._data[e],this._setDirty()},r.prototype.getLink=function(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "relationship" must be a string');return this._data._links?this._data._links[e]:void 0},r.prototype.setLink=function(e,t){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("object"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "link" must be an object.');if("string"!=typeof t)throw new o(o.INVALID_PARAMS,'Param "relationship" must be a string');var n=this._data._links;n||(n=this._data._links={}),n[t]=e,this._setDirty()},r.prototype.removeLink=function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "relationship" must be a string');var t=this._data._links;t&&(delete t[e],Object.keys(t).length<1&&delete this._data._links,this._setDirty())},r.prototype.isEqualTo=function(e,t){return i.objectsEqual(this._data,e._data,t)},r.prototype._setData=function(e){var t=this._verify(e);if(null===t)return this._data=e,this;throw t},r.prototype._setDirty=function(){this._owner&&this._owner._setDirty()},r.prototype._verify=function(e){return"string"!=typeof e.id?new o(o.INVALID_DATA,"Component is missing an id of type string"):null},e.exports=r},function(e,t){e.exports=require("crypto")},function(e,t){e.exports=require("url")},function(e,t,n){var o=n(4),i=o.networkError,r=o.unexpectedResponse,a=n(7),s=a.merge,c=n(52),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 o(o.INVALID_PARAMS,"Expecting a number.");this._maxRedirects=Math.floor(e)}},authenticationWhitelist:{get(){return this._authenticationWhitelist},set(e){if(!Array.isArray(e))throw new o(o.INVALID_PARAMS,"Expecting an array.");this._authenticationWhitelist=e}}}),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 n,o=t.length,i=this._authenticationWhitelist.length;for(n=0;n<i;n++){var r=this._authenticationWhitelist[n],s=r.length;if((o>s?t.slice(-s):t)===r)return!0}return!1},d.prototype.getAsset=function(e,t,n,c){if(!(e=this._resolveUrl(e)))return c(new o(o.WRONG_ENDPOINT,"Wrong endpoint: "+e));var l,d={};"string"==typeof t?d["If-None-Match"]=t:s(d,t);var p,h=this,u=0;function _(e,t){if(e)return c(i("Error downloading an asset",e,t));var n=t.statusCode;if(200===n)c(void 0,t);else if(304===n)c(void 0,t);else if(301===n||302===n||303===n||307===n)if(!h._service.handlesRedirects&&h.maxRedirects)if(u<h.maxRedirects){var o=t.headers.location;o?p(o):c(r("Missing location header in redirect response",e,t))}else c(r("Too many redirects",e,t));else c(r("Unexpected response getting an asset",e,t));else c(r("Unexpected response getting an asset",e,t))}return(l=(p=function(t){var o={responseType:n};return t&&(u++,o.reuseRequestDesc=l,h.isDomainOnWhitelist(t)||(d.Authorization=null)),h._service.invoke("GET",t||e,d,void 0,o,_)})()).progress=a.noOp,l},d.prototype.getAssetAsType=function(e,t,n,o){return this.getAsset(e,n,t,function(e,t){if(e)return o(e);if(200===t.statusCode){var n=t.response||t.responseText;o(void 0,n,t.headers.etag,t)}else 304===t.statusCode?o(void 0,null,t.headers.etag,t):o(r("Unexpected response getting asset",e,t))})},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 n=a.parseURI(e);(n.scheme||n.authority)&&(e=n.path,n.query&&(e+="?"+n.query),n.fragment&&(e+="#"+n.fragment))}return e},d.prototype._parseAsyncResponse=function(e){var t=e.responseText||e.response;if(!t)throw new o(o.INVALID_DATA,"No body data.");var n={},i=t.indexOf("\n");if(-1===i)throw new o(o.INVALID_DATA,"Could not find status line.");var r=t.slice(0,13===t.charCodeAt(i-1)?i-1:i).split(" ");if(n.statusCode=parseInt(r[1],10),!n.statusCode)throw new o(o.INVALID_DATA,"Could not find status code.");r.length>2&&(n.statusText=r[2]);var s=t.search(/\r?\n\r?\n/);-1===s&&(s=t.length);var c=t.slice(i+1,s);n.headers=a.parseHeaders(c);var l="\r"===t.charAt(s)?s+4:s+2;return n.response=t.slice(l),n},d.prototype._pollForAsyncResponse=function(e,t,n,o){var s=this,c=Date.now()+1e3*t,l={responseType:"text",reuseRequestDesc:n,noSoonerThen:c};a.log("asynchronous request - polling"),n=this._service.invoke("GET",e,void 0,void 0,l,function(t,c){if(t)return o(i("Error polling for an asynchronous reponse",t,c));var l=c.statusCode;if(202===l){a.log("asynchronous request - not yet ready");var d=c.headers["retry-after"];d&&(d=parseInt(d,10)),s._pollForAsyncResponse(e,d||s.DEFAULT_POLL_DELAY,n,o)}else if(200===l){a.log("asynchronous request - success");try{c=s._parseAsyncResponse(c)}catch(e){return o(r("Error parsing response body.",e,c))}200===(l=c.statusCode)||201===l||204===l?o(void 0,c):o(r("Unexpected response polling for an asynchronous response",t,c))}else a.log("asynchronous request - error"),o(r("Unexpected response polling for an asynchronous response",t,c))})},d.prototype._handle202Response=function(e,t,n,o){var i,a=e.responseText||e.response;try{i=JSON.parse(a)}catch(t){return o(r("Error parsing 202 response body.",t,e))}var s=i.href;if(!s)return o(r("202 response missing an href.",void 0,e));var c=e.headers["retry-after"];c=c?parseInt(c,10):n,this._pollForAsyncResponse(this._resolveUrl(s),c,t,o)},e.exports=d},function(e,t,n){var o=n(4),i=n(58),r=n(1),a=n(0),s=n(100),c=n(101),l=n(102),d=n(18),p=n(2),h=n(19),u=n(103),_=n(12),f=n(8),m=n(15),E=n(11),g=n(34),y=n(9),v=n(16),A=n(104),C=n(5),S=n(105);function I(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 C(["change","deepchange","sync","operation","commitError"]),this._operations=[],S.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.isPublic||(this._bookmarkManager=new c(this),this._fontManager=new l(this))}I.prototype._dispose=function(){S.disconnect(this)},I.prototype._removeAllListeners=function(){this._listenerManager.removeAll(),this._libraries.forEach(function(e){e._removeAllListeners()})},I.prototype._notifyChange=function(e){this._listenerManager.notify("deepchange"),e&&this._listenerManager.notify("change")},I.prototype._loadLibrary=function(e,t){const n=this._getCompositeDir(e),o=n=>{r.log(`Load error: ${n}`),f.deleteLibraryFromDisk(this,e,()=>t(null))},a=n=>{const o=new i(this,n,this.isPublic&&e);"pendingDelete"===n.current.compositeState?(this._pendingDeletes.push(o),t(null)):(this._libraries.push(o),this._libraryIdMap[o.id]=o,o._renditionCache.load().then(t))};r.dcx.newCompositeFromLocalStorage(n,(t,n)=>t?o(`DCX error loading composite for ${e}`):n&&n.current?m.validateLibrary(n)?this.isPublic||n.id===e?void(n.href&&n.current.isBound?n.loadBaseBranch((t,i)=>{t||!i?o(`missing base branch for ${e} (even though bound to server)`):a(n)}):a(n)):o(`library id ${n.id} doesn't match folder on disk ${e}`):o(`failed validation for ${e}`):o(`composite/branch not loaded for ${e}`))},I.prototype._load=function(e){this._loaded?e(null):(this._loaded=!0,f.readLibraryDirectory(this,(t,n)=>{if(!t&&n){var o=new _;n.forEach(e=>{m.validateLibraryId(e,this.isPublic)&&o.addOperation(this._loadLibrary,[e],this)}),o.addOperation(e=>this._externalLinkCache.load().then(e)),this.isPublic||o.addOperation(this._bookmarkManager.load,[],this._bookmarkManager),o.run(()=>{r.log("Loaded "+this._libraries.length+" libraries and "+this._pendingDeletes.length+" pending deletes"),e(null)},e=>this._reportCommitError(e))}else e(null)}))},I.prototype._removeFromPendingDeletes=function(e){var t=this._pendingDeletes.indexOf(e);-1!==t&&this._pendingDeletes.splice(t,1)},I.prototype._handlePendingDeletes=function(e){var t=this,n=new _;this._pendingDeletes.forEach(function(e){n.addOperation(function(n){e._deleteFromServer(!1,function(i){if(i&&i.code===o.UPDATE_CONFLICT)return t._removeFromPendingDeletes(e),t._libraries.push(e),t._libraryIdMap[e.id]=e,e._markDeletedLocally(!1),t._updateSyncState(),t._notifyChange(!0),void n(null,!0);i?n(i):(t._removeFromPendingDeletes(e),e._deletedFromDisk=!0,f.deleteLibraryFromDisk(t,e.id,function(e){n(e,!0)}))})})}),n.run(e)},I.prototype._doesLibraryExist=function(e){if(this._libraryIdMap[e])return!0;var t;for(t=0;t<this._pendingDeletes.length;t++)if(this._pendingDeletes[t].id===e)return!0;return!1},I.prototype._syncNewLibrary=function(e,t,n,a){var s=this,c=t||this._syncManager.getCompositePath(e),l=r.hasFileSystem()&&this._getCompositeDir(e),d=r.dcx.newCompositeWithHref(c,l);s._libraryIdMap[e]="pending",s._updateSyncState(),s._syncManager.pullComposite(d,s,function(t,r){if(t||!r)return delete s._libraryIdMap[e],s._updateSyncState(),t=t?t.code===o.NO_COMPOSITE||t.code===o.DELETED_COMPOSITE?null:E.getSyncError(t,e):new p(p.NETWORK_ERROR,"No pulled branch"),void a(t,!0);d.resolvePullWithBranch(r,function(t){if(t||!s.isPublic&&d.id!==e)return delete s._libraryIdMap[e],s._updateSyncState(),t=t?E.getCommitError(t,e):new p(p.CORRUPTED_LIBRARY,"Library id does not match sync group id"),void a(t,!0);var o=new i(s,d,s.isPublic&&e);s._libraries.push(o),s._libraryIdMap[o.id]=o,s._updateSyncState(),o._setCollaboration(n),v.prefetchRenditions(o),s._notifyChange(!0),a(null,!0)})})},I.prototype._syncNewLibraries=function(e,t){var n=this,o=new _;if(this._loadingHint){var i=[];e.forEach(function(e){-1!==n._loadingHint.indexOf(e.name)&&i.push(e)}),e.forEach(function(e){-1===n._loadingHint.indexOf(e.name)&&i.push(e)}),e=i}e.forEach(function(e){var t=e.name;n._doesLibraryExist(e.name)||o.addOperation(n._syncNewLibrary,[t,void 0,e],n)}),o.run(t)},I.prototype._syncExistingLibraries=function(e,t,n){var o=this,i=new _;this._libraries.forEach(function(n){var r=e&&e[n.id];if(r&&(n._setCollaboration(r),n._deletedFromServer&&(n._deletedFromServer=!1,n._notifyChange())),t)(t[n.id]||r&&!r.isUnmodified)&&i.addOperation(n._sync,[!1],n);else{var a=!e||r&&r.isUnmodified;void 0===n.collaboration?i.addOperation(n._sync,[a],n):a?i.addOperation(function(e){o._syncManager.hasCompositeChangedOnServer(n._dcxComposite,function(t){n._sync(!t,e)})}):i.addOperation(n._sync,[!1],n)}}),i.run(n)},I.prototype._dosync=function(e,t){var n=this;this._clearSyncErrors(),this._syncManager.getServerComposites(function(o,i,r){if(o)return o=E.getSyncError(o,void 0,{403:p.ACCESS_DENIED}),n._reportSyncError(o),void t(null,!1);var a=new _;a.addOperation(n._syncNewLibraries,[i],n),a.addOperation(n._syncExistingLibraries,[r,e],n),a.addOperation(n._handlePendingDeletes,[],n),e||a.addOperation(n._bookmarkManager.sync,[],n._bookmarkManager),a.run(function(e,n){t(null,n)},function(e){n._reportSyncError(e)})})},I.prototype._reportSyncError=function(e){e&&(r.log("Sync error: "+E.errorToString(e)),this._syncErrors.push(e))},I.prototype._clearSyncErrors=function(e){if(e){var t=[];this._syncErrors.forEach(function(n){n.libraryId!==e&&t.push(n)}),this._syncErrors=t}else this._syncErrors=[]},I.prototype._reportCommitError=function(e){this._lastCommitError=e,e&&(r.log("Commit error: "+E.errorToString(e)),this._listenerManager.notify("commitError",[e]))},I.prototype._updateRetryState=function(){if(!this._retryTimeoutId&&"syncing"!==this._syncState){if("error"===this._syncState){var e=this.getPrimarySyncError();if(e&&e.code===p.RETRYABLE_SERVER_ERROR){if(this._numRetries++,this._numRetries>a.ERROR_RETRY_INTERVALS.length)return this._retryTime="never",r.log("Retry Failed"),void(a.MAX_SYNC_INTERVAL=a.RETRY_FAIL_MAX_SYNC_INTERVAL);r.log("Retry "+this._numRetries);var t=e.underlyingError&&e.underlyingError.response&&e.underlyingError.response.headers,n=1e3*g.getRetryAfterHeader(t);n>0?(this._numRetries=a.ERROR_RETRY_INTERVALS.length,r.log("Got Retry-After header")):n=1e3*a.ERROR_RETRY_INTERVALS[this._numRetries-1],r.log("Retrying after "+n+"ms"),this._retryTime=(new Date).valueOf()+n;var o=this;return void(this._retryTimeoutId=setTimeout(function(){o._retryTimeoutId=void 0,o._retryTime=void 0,r.log("Starting retry"),o._syncWithParameters(!1)},n))}if(e&&e.code===p.EXCEEDS_QUOTA)return a.MAX_SYNC_INTERVAL=a.RETRY_FAIL_MAX_SYNC_INTERVAL,this._numRetries=a.ERROR_RETRY_INTERVALS.length+1,void(this._retryTime="never")}this._numRetries=0,this._retryTime=void 0}},I.prototype._updateSyncState=function(){var e,t=this,n=this._initialSyncInProgress;Object.keys(this._libraryIdMap).forEach(function(e){var o=t._libraryIdMap[e],i="pending"===o||o._isSyncing();n=n||i}),n?e="syncing":(this._syncErrors.length>0?(e="error",t._syncManager.clearSyncGroupCache(),d.reportError(this.getPrimarySyncError())):e="ok",this._syncProgressMap={},this._syncProgress=void 0);var o=this._syncState;this._syncState=e,this._updateRetryState(),o===e&&"error"!==this._syncState||this._listenerManager.notify("sync"),t._ensureDefaultLibrary()},I.prototype._updateProgress=function(e,t,n){n?this._syncProgressMap[e]={bytesLoaded:t||0,bytesTotal:n,progress:this._syncProgressMap[e]&&this._syncProgressMap[e].progress}:this._syncProgressMap[e]?(0===this._syncProgressMap[e].bytesTotal&&(this._syncProgressMap[e].bytesTotal=1e4),this._syncProgressMap[e].bytesLoaded=this._syncProgressMap[e].bytesTotal):this._syncProgressMap[e]={bytesLoaded:0,bytesTotal:0};var o=!1,i=t||0,r=(n||0)>0?Math.max(0,Math.min(100,Math.round(i/n*100))):void 0;this._syncProgressMap[e].progress!==r&&(this._syncProgressMap[e].progress=r,o=!0);var a=0,s=0,c=0,l=0,d=this._syncProgressMap;Object.keys(d).forEach(function(e){a++,d[e].bytesTotal>0&&s++,c+=d[e].bytesLoaded,l+=d[e].bytesTotal});var 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,o=!0),o&&this._listenerManager.notify("sync")},I.prototype._updateExternalLinkDownloadProgress=function(e,t,n,o){var i,r=e.element.library.id+"."+e.element.id+"."+e.id;n?(t=t||0,i=Math.max(0,Math.min(100,Math.round(t/n*100)))):o&&(i=-1),i!==this._externalLinkDownloadProgressMap[r]&&(void 0===i?delete this._externalLinkDownloadProgressMap[r]:this._externalLinkDownloadProgressMap[r]=i,this._listenerManager.notify("sync"))},I.prototype._getExternalLinkDownloadProgress=function(e){var t=e.element.library.id+"."+e.element.id+"."+e.id;return this._externalLinkDownloadProgressMap[t]},I.prototype._setInitialSyncState=function(e,t){this._initialSyncInProgress=e,this._loadingHint=t,this._updateSyncState()},I.prototype._resetPollBackoff=function(){this._backoffTicks=0,this._numBackoffs=0},I.prototype._getBaseDir=function(){const e=r.getPathSeparator();return f.getUserDir(this._userId)+e+this._cloudId},I.prototype._getLibraryDir=function(e,t){var n=r.getPathSeparator(),o=this._getBaseDir()+n+e;return t&&(o+=n+t),o},I.prototype._getCompositeDir=function(e){return this._getLibraryDir("dcx",e)},I.prototype._getTempDir=function(){var e=r.getPathSeparator();return this._getBaseDir()+e+".tmp"},I.prototype._getRenditionCacheDir=function(e){return this._getLibraryDir("renditions",e)},I.prototype._ensureDefaultLibrary=function(){var e="ok"===this.syncState&&!this.isInitialSyncInProgress&&a.SYNCING_ENABLED,t=0;if(this.libraries.forEach(function(e){e.isDeletedLocally||e.isDeletedFromServer||t++}),!this.isPublic&&e&&0===t){var n=h.translate("LIBS_DEFAULT_LIBRARY_NAME");r.log("Creating default library: "+n),this.createLibrary(n)}},I.prototype._doRemoveLibrary=function(e,t){var n=this,o=y.wrapCallback(t),i=this._libraries.indexOf(e);-1!==i&&(this._libraries.splice(i,1),delete this._libraryIdMap[e.id]),e._removeAllListeners(),a.SHARED_LOCAL_STORAGE?(e._dcxBranch.compositeState="pendingDelete",e._commit(!1,!0),e._markDeletedLocally(!0),o(null)):(n._pendingDeletes.push(e),a.SYNCING_ENABLED?e._deleteFromServer(!0,function(t){e._markDeletedLocally(!0),t?o(null):(n._removeFromPendingDeletes(e),e._deletedFromDisk=!0,f.deleteLibraryFromDisk(n,e.id,o))}):(e._dcxBranch.compositeState="pendingDelete",e._commit(!0,!0),e._markDeletedLocally(!0),o(null))),this._notifyChange(!0)},I.prototype._doExportLibrary=function(e,t,n,o){var i,s=this;if(a.SHARED_LOCAL_STORAGE){var c=r.uuid();return r.storageInterface.exportLibrary(e,t,c,n),this._addOperation(c,"export",{libraryId:e.id})}o=o||r.uuid(),e._setAutoGC("export_"+o,!1);var l=this._addOperation(o,"export",{libraryId:e.id},function(){i&&i()});return i=A.exportLibrary(e,t,function(e){l._updateProgress(e)},function(t){l._updateProgress(100),s._removeOperation(l),e._setAutoGC("export_"+o,!0),n(t)}),l},I.prototype._doImportLibrary=function(e,t,n){var o,i=this;if(a.SHARED_LOCAL_STORAGE){var s=r.uuid();return r.storageInterface.importLibrary(this,e,s,t),this._addOperation(s,"import")}var c=this._addOperation(n||r.uuid(),"import",void 0,function(){o&&o()});return o=A.importLibrary(this,e,function(e){c._updateProgress(e)},function(e,n){c._updateProgress(100),i._removeOperation(c),t(e,n)}),c},I.prototype._addOperation=function(e,t,n,o){var i=new u(this,e,t,n,o);return this._operations.push(i),this._operationIdMap[i.id]=i,this._notifyOperationChange(),i},I.prototype._removeOperation=function(e){var t=this._operations.indexOf(e);-1!==t&&(this._operations.splice(t,1),delete this._operationIdMap[e.id]),this._notifyOperationChange()},I.prototype._delayedRemoveOperation=function(e){var t=this;this._removeOperationTimeout[e.id]||(this._removeOperationTimeout[e.id]=setTimeout(function(){delete t._removeOperationTimeout[e.id],t._removeOperation(e)},a.REMOVE_OPERATION_TIMEOUT))},I.prototype._updateOperation=function(e,t,n,o){this._operationIdMap[e]||this._addOperation(e,t,n),this._removeOperationTimeout[e]&&(clearTimeout(this._removeOperationTimeout[e]),delete this._removeOperationTimeout[e]),this._operationIdMap[e]._updateProgress(o)},I.prototype._notifyOperationChange=function(){this._listenerManager.notify("operation")},Object.defineProperties(I.prototype,{libraries:{get(){return this._libraries},set(){throw new p(p.READ_ONLY,"Cannot modify libraries list directly")}},commitError:{get(){return this._lastCommitError},set(){throw new p(p.READ_ONLY,"commitError is a read-only property")}},syncState:{get(){return this._syncState},set(){throw new p(p.READ_ONLY,"syncState is a read-only property")}},syncErrors:{get(){return this._syncErrors},set(){throw new p(p.READ_ONLY,"syncErrors is a read-only property")}},syncProgress:{get(){return this._syncProgress},set(){throw new p(p.READ_ONLY,"syncProgress is a read-only property")}},isInitialSyncInProgress:{get(){return this._initialSyncInProgress},set(){throw new p(p.READ_ONLY,"isInitialSyncInProgress is a read-only property")}},isPolling:{get(){return void 0!==this._pollTimerId},set(){throw new p(p.READ_ONLY,"isPolling is a read-only property")}},isLoggedIn:{get(){if(!a.SHARED_LOCAL_STORAGE)return this._syncManager.isLoggedIn()},set(){throw new p(p.READ_ONLY,"isLoggedIn is a read-only property")}},retryTime:{get(){return"never"!==this._retryTime?this._retryTime:void 0},set(){throw new p(p.READ_ONLY,"retryTime is a read-only property")}},userId:{get(){return this._userId},set(){throw new p(p.READ_ONLY,"userId is a read-only property")}},cloudId:{get(){return this._cloudId},set(){throw new p(p.READ_ONLY,"cloudId is a read-only property")}},cloudInfo:{get(){return this._cloudInfo},set(){throw new p(p.READ_ONLY,"cloudInfo is a read-only property")}},isPublic:{get:()=>!1,set(){throw new p(p.READ_ONLY,"isPublic is a read-only property")}},bookmarks:{get(){return this._bookmarkManager.getBookmarks()},set(){throw new p(p.READ_ONLY,"bookmarks is a read-only property")}},fontManager:{get(){return this._fontManager},set(){throw new p(p.READ_ONLY,"fontManager is a read-only property")}},operations:{get(){return this._operations},set(){throw new p(p.READ_ONLY,"operations is a read-only property")}}}),I.prototype.addChangeListener=function(e){this._listenerManager.add("change",e)},I.prototype.removeChangeListener=function(e){this._listenerManager.remove("change",e)},I.prototype.addDeepChangeListener=function(e){this._listenerManager.add("deepchange",e)},I.prototype.removeDeepChangeListener=function(e){this._listenerManager.remove("deepchange",e)},I.prototype.createLibrary=function(e){var t=r.uuid(),n=a.COMPOSITE_TYPE,o=this._getCompositeDir(t),s=r.dcx.newEmptyComposite(e,n,o,t);s.current.rootNode.setValue(a.VERSION_KEY,a.VERSION),this._syncManager.prepareCompositeForPush(s);var c=new i(this,s);return c._updateCreatedTime(),this._libraries.push(c),this._libraryIdMap[c.id]=c,this._notifyChange(!0),c._commit(!1,!0),d.reportCreateLibrary(c),c},I.prototype.removeLibrary=function(e,t){this._doRemoveLibrary(e,t),d.reportDeleteLibrary(e)},I.prototype.removeDeletedLibraries=function(e,t){var n=this,o=y.wrapCallback(t);"function"==typeof e&&(o=e,e=void 0);var i=e&&e.exclude||[];function r(e,t){var o=n._libraries.indexOf(e);-1!==o&&(n._libraries.splice(o,1),delete n._libraryIdMap[e.id]),e._deletedFromDisk=!0,f.deleteLibraryFromDisk(n,e.id,t),e._markDeletedLocally(!0)}var a=new _,s=!1;this._libraries.forEach(function(e){if(e.isDeletedFromServer){var t=!0;i.forEach(function(n){t=t&&e!==n}),t&&(s=!0,a.addOperation(r,[e]))}}),a.run(function(e){s&&n._notifyChange(!0),o(e)})},I.prototype.exportLibrary=function(e,t,n){if(-1!==this._libraries.indexOf(e))if("string"==typeof t)if(0===t.length||t[t.length-1].match(/\\|\//))n(new p(p.INVALID_PARAMETER,"path must end in a filename"));else{if(t.substring(t.length-a.EXPORT_EXTENSION.length)!==a.EXPORT_EXTENSION&&(t+=a.EXPORT_EXTENSION),a.SHARED_LOCAL_STORAGE||r.hasFileSystem())return this._doExportLibrary(e,t,function(t){d.reportExportLibrary(t,e),n(t)});n(new p(p.REQUIRES_FILESYSTEM,"exportLibrary only supported when you have a filesystem"))}else n(new p(p.INVALID_PARAMETER,"path must be a string"));else n(new p(p.INVALID_PARAMETER,"library not in this collection"))},I.prototype.importLibrary=function(e,t){if("string"==typeof e){if(a.SHARED_LOCAL_STORAGE||r.hasFileSystem())return this._doImportLibrary(e,function(e,n){d.reportImportLibrary(e,n),t(e,n)});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"))},I.prototype.sync=function(e){this._syncWithParameters(!1,!1,void 0,e)},I.prototype.syncChanges=function(e,t){var n={};(e=e||[]).forEach(function(e){n[e]=!0}),this._syncWithParameters(!1,!1,n,t)},I.prototype.syncFull=function(e){this._syncManager.clearSyncGroupCache(),this._syncWithParameters(!1,!1,void 0,e)},I.prototype.syncBookmarks=function(e){this._bookmarkManager.sync(function(t){e&&e(t)})},I.prototype._syncWithParameters=function(e,t,n,o){var i=this,s=function(){o&&o(null)};if(a.SHARED_LOCAL_STORAGE)return r.storageInterface.sync(this),void s();if(a.SYNCING_ENABLED)if(this._retryTimeoutId)s();else{if(e||this._resetPollBackoff(),this.isPolling){if(this._syncing)return void s()}else if(this._syncing)return void i._pendingSyncs.push(s);if((new Date).valueOf()<this._lastSyncTime+a.MAX_SYNC_INTERVAL)return t?void s():void setTimeout(function(){i._syncWithParameters(e,!0,n,s)},a.MAX_SYNC_INTERVAL);r.log("Start Sync: "+this.cloudId+(e?" [polling]":"")),this._syncing=!0,this._lastSyncTime=(new Date).valueOf(),this._dosync(n,function(e,t){if(i._syncing=!1,i._updateSyncState(),r.log("End Sync: "+i.cloudId),t&&(i._backoffTicks=0,i._numBackoffs=0),i._pendingSyncs.length>0){var n=i._pendingSyncs;i._pendingSyncs=[],i.sync(function(){n.forEach(function(e){e()})})}s()})}else s()},I.prototype.addSyncListener=function(e){this._listenerManager.add("sync",e)},I.prototype.removeSyncListener=function(e){this._listenerManager.remove("sync",e)},I.prototype.getPrimarySyncError=function(){var e=this._syncErrors[0];return this._syncErrors.forEach(function(t){var n=E.getErrorPriority(t),o=E.getErrorPriority(e);n>o?e=t:n===o&&e.code===t.code&&e.libraryId!==t.libraryId&&(e=new p(e.code,"multiple errors (see libraryCollection.syncErrors)",void 0))}),e},I.prototype.getNewLibrarySyncProgress=function(){var e=this;if(this._newLibraryProgress)return this._newLibraryProgress;var t=[];return Object.keys(this._libraryIdMap).forEach(function(n){"pending"===e._libraryIdMap[n]&&t.push({id:n,progress:e._syncProgressMap[n]&&e._syncProgressMap[n].progress})}),t},I.prototype.addOperationChangeListener=function(e){this._listenerManager.add("operation",e)},I.prototype.removeOperationChangeListener=function(e){this._listenerManager.remove("operation",e)},I.prototype.addCommitErrorListener=function(e){this._listenerManager.add("commitError",e)},I.prototype.removeCommitErrorListener=function(e){this._listenerManager.remove("commitError",e)},I.prototype.startPolling=function(){if(a.SHARED_LOCAL_STORAGE)throw new p(p.NOT_SUPPORTED,"startPolling() not supported with shared local storage");if(!this.isPolling){var e=this,t=6e4*a.POLL_INTERVAL;this._pollTimerId=setInterval(function(){"never"!==e._retryTime&&(e._backoffTicks>0?e._backoffTicks--:(0===e._backoffTicks&&(e._numBackoffs++,e._backoffTicks=g.getBackoffTicks(e._numBackoffs)),e._syncWithParameters(!0)))},t)}},I.prototype.stopPolling=function(){if(a.SHARED_LOCAL_STORAGE)throw new p(p.NOT_SUPPORTED,"stopPolling() not supported with shared local storage");this.isPolling&&(clearInterval(this._pollTimerId),delete this._pollTimerId),this._retryTimeoutId&&(clearTimeout(this._retryTimeoutId),delete this._retryTimeoutId)},I.prototype.createBookmark=function(e,t,n){this._bookmarkManager.createBookmark(e,t,n)},I.prototype.removeBookmark=function(e,t){this._bookmarkManager.removeBookmark(e,t)},I.prototype.findBookmark=function(e){var t;return this.bookmarks&&this.bookmarks.some(function(n){if(n.url===e._dcxComposite.href)return t=n,!0}),t},I.prototype.getDefaultLibrary=function(){var e;return this.libraries.forEach(function(t){"incoming"!==t.collaboration&&(!e||(e.created||0)>(t.created||0))&&(e=t)}),e},I.prototype.getLibraryById=function(e){var t=this._libraryIdMap[e];if(t instanceof i)return t},I.prototype.getToolkitLibrary=function(e){let t=this._libraries.filter(t=>t.toolkitId===e);if(t.length)return t.sort((e,t)=>e.created-t.created),t[0];{const t=this.createLibrary(h.getToolkitName(e));return t.setValue(a.TOOLKIT_NAMESPACE,a.TOOLKIT_ID_KEY,e),t}},I.prototype.updateAccessToken=function(e){if(a.SHARED_LOCAL_STORAGE)throw new p(p.NOT_SUPPORTED,"updateAccessToken() not supported with shared local storage");this._syncManager.updateAccessToken(e),r.log("defined")},I.prototype.getTempDir=function(e){if(r.hasFileSystem()){var t=this._getTempDir();f.ensurePathExists(t,function(n){e(n,t)})}else e(new p(p.REQUIRES_FILESYSTEM,"getTempDir only supported when you have a filesystem"))},I.prototype.copyFileToTempDir=function(e,t){this.getTempDir(function(n,o){if(n)return void t(n);const i=f.getFileExtension(e),a=o+r.getPathSeparator()+r.uuid()+(i?"."+i:"");f.copyFile(e,a,function(e){e?f.deleteFile(a,()=>t(e)):t(null,a)})})},Object.freeze(I),Object.seal(I.prototype),e.exports=I},function(e,t,n){const o=n(1),i=n(8),r=n(11),a=e=>r.getCommitError(e);e.exports={stat(e){const t=o.fs;return new Promise((n,o)=>t.stat(e,(e,t)=>e?o(a(e)):n(t)))},statSync(e){try{return o.fs.statSync(e)}catch(e){}},unlink(e){const t=o.fs;return new Promise((n,o)=>t.unlink(e,e=>e?o(a(e)):n()))},readdir(e){const t=o.fs;return new Promise((n,o)=>t.readdir(e,(e,t)=>e?o(a(e)):n(t)))},rename:(e,t)=>new Promise((n,o)=>i.rename(e,t,e=>e?o(a(e)):n())),copy:(e,t)=>new Promise((n,o)=>i.copyFile(e,t,e=>e?o(a(e)):n())),ensureDir:e=>new Promise((t,n)=>i.ensurePathExists(e,e=>e?n(a(e)):t())),remove(e){return this.stat(e).then(t=>t&&t.isDirectory()?new Promise((t,n)=>i.recursiveDeleteDirectory(e,e=>e?n(a(e)):t())):this.unlink(e))}}},function(e,t,n){const o=n(1);e.exports={join:(...e)=>e.join(o.getPathSeparator()),relative(e,t){const n=o.getPathSeparator(),i=e.replace(/\\/g,n).split(n),r=t.replace(/\\/g,n).split(n);for(;i[0]===r[0];)i.shift(),r.shift();return new Array(i.length).fill("..").concat(r).join(n)}}},function(e,t,n){var o=n(0),i=n(16),r={getStockData:function(e){return e&&e.getValue(o.STOCK_NAMESPACE,o.STOCK_DATA_KEY)},getStockDataForElement:function(e,t,n){var o=void 0===t?e.getPrimaryRepresentation():e.representations[t],a=r.getStockData(o);return a&&o.isExternalLink&&(i.shouldPrefetchExternalLink(o)&&!o.getCachedContentPath()||o.getCachedExternalLinkError())?r.getStockDataForElement(e,void 0===t?0:t+1,n||a.content_id):(!a&&n&&(a={content_id:n}),a)},getElementStockId:function(e){var t=r.getStockDataForElement(e);if(t)return String(t.content_id)},getElementStockLicense:function(e){var t=r.getStockDataForElement(e);if(t&&t.state===o.STOCK_STATE_PURCHASED)return String(t.license)}};e.exports=r},function(e,t,n){var o=n(25),i=n(52),r=n(53),a=n(68),s=n(54),c=n(7),l=n(4),d=n(13),p=n(55);function h(e,t){e&&d._setFS(e),this._compositeOptions=c.merge({},t),t&&t.logCallback&&c._setLogCallback(t.logCallback)}h.COLLABORATION={PRIVATE:o.COLLABORATION.PRIVATE,SHARED_BY_USER:o.COLLABORATION.SHARED_BY_USER,SHARED_WITH_USER:o.COLLABORATION.SHARED_WITH_USER},h.AdobeDCXError=l,h.FileContent=i.FileContent,h.StreamProvider=i.StreamProvider,h.prototype.newEmptyComposite=function(e,t,n,i){var r=new o(e,t,null,i,null,this._compositeOptions);return n&&(r.path=n),r},h.prototype.newCompositeFromLocalStorage=function(e,t){try{if("string"!=typeof e)throw new l(l.INVALID_PARAMS,"");var n=new o(null,null,e,null,null,this._compositeOptions);n.loadCurrentFromLocalStorage(function(e){t(e,e?void 0:n)}),n.deleteTempFiles()}catch(e){t(e)}},h.prototype.newCompositeWithHref=function(e,t,n,i,r){var a=new o(n,r,null,i,e,this._compositeOptions);return t&&(a.path=t),a},h.prototype.newCompositeAsCopyOf=function(e,t,n,i,r,a){return o.newCompositeAsCopyOf(e,t,n,i,r,a,this._compositeOptions)},h.prototype.createHTTPService=function(e){return new i(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,n){var o=n(4),i=n(65),r=n(40),a=n(13),s=n(7);function c(e,t,n){this._readOnly=n,this._owner=t,this._setData(e),this._localStorage=void 0}function l(e,t,n,i,r,a,c,l){var d=t._owner._core,p=e._owner._core,h=n&&e.id===t.id,u=p._getSourceHrefOfComponent(e),_=d.getComponentWithId(t.id),f=i&&(!_||!_.etag)&&"unmodified"===e.state,m=!h&&!u,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(u=p._getHrefOfComponent(e),d._setSourceHrefOfComponent(u,t,c),!u&&E)throw new o(o.INVALID_STATE,"Failed to determine the source href of a component that does not have a local file.")}else if(E)throw new o(o.INVALID_STATE,"Could not use server-to-server copy for component "+e.id)}else d._setSourceHrefOfComponent(u,t,c);u&&(t.state="modified")}Object.defineProperties(c.prototype,{rootNode:{get(){return this.getChildWithAbsolutePath(i.ROOT_PATH)},set(){throw new o(o.READ_ONLY,'Property "rootNode" is read-only.')}},hasLocalStorage:{get(){return this._localStorage},set(){throw new o(o.READ_ONLY,"Cannot set the property hasLocalStorage.")}},isDirty:{get(){return this._isDirty},set(){throw new o(o.READ_ONLY,"Cannot set the property isDirty.")}},changeCount:{get(){return this._data.local&&this._data.local.change||0},set(){throw new o(o.READ_ONLY,"Cannot set the property changeCount.")}}}),c.prototype.getChildWithId=function(e){return this._allNodes[e]},c.prototype.getChildWithAbsolutePath=function(e){var t=this._absolutePaths[e.toLowerCase()];return t&&t instanceof i?t:void 0},c.prototype.getChildrenOf=function(e){if(!(e=e?this._allNodes[e.id]:this.rootNode))throw new o(o.INVALID_PARAMS,"Unknown node");var t,n=[],i=e._data.children;if(Array.isArray(i))for(t=0;t<i.length;t++){var r=i[t],a=this._allNodes[r.id];if(!a)throw new o(o.INVALID_DATA,"Node not in cache");n[n.length]=a}return n},c.prototype.addChild=function(e,t,n,r){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(t=t||s.generateUuid(),this._allNodes[t])throw new o(o.DUPLICATE_VALUE,"Node already exists in branch.");if(n&&("number"!=typeof n||n%1!=0))throw new o(o.INVALID_PARAMS,'Param "index" must be an integer.');var a=r?this._allNodes[r.id]:this.rootNode;if(!a)throw new o(o.INVALID_PARAMS,"Unknown parent node.");var c=new i;c.id=t,e&&(c.name=e),c._parentPath=a.absolutePath||a._parentPath;var l=a._data.children;return l?(n>=0&&n<=l.length||(n=l.length),n===l.length?l[n]=c._data:l.splice(n,0,c._data)):a._data.children=[c._data],this._allNodes[c.id]=c,c._owner=this._owner,this._setDirty(),c},c.prototype.removeChild=function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(!e)throw new o(o.INVALID_PARAMS,'Expecting param "node".');if(e.isRoot)throw new o(o.INVALID_PARAMS,"Cannot remove the root node.");var t=e.id;if(!t)throw new o(o.INVALID_PARAMS,'Param "node" must have an id.');var n=this._nodeDataOfParentOfNode(e);if(!n)throw new o(o.INVALID_PARAMS,"Node not found in this branch.");return n.parentNodeData.children.splice(n.index,1),0===n.parentNodeData.children.length&&delete n.parentNodeData.children,e=this._allNodes[t],this._removeNodeFromCachesRecursively(e._data),this._setDirty(),e},c.prototype.moveChild=function(e,t,n){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(!e)throw new o(o.INVALID_PARAMS,'Expecting param "node".');if(e.isRoot)throw new o(o.INVALID_PARAMS,"Cannot move the root node.");if(t&&("number"!=typeof t||t%1!=0))throw new o(o.INVALID_PARAMS,'Param "index" must be an integer.');var i=e.id;if(!i)throw new o(o.INVALID_PARAMS,'Param "node" must have an id.');var r=this._nodeDataOfParentOfNode(e);if(e=this._allNodes[i],!r)throw new o(o.INVALID_PARAMS,"Node not found in this branch.");var a=n?this._allNodes[n.id]:this.rootNode;if(!a)throw new o(o.INVALID_PARAMS,"Unknown parent node.");if(this._nodeIdIsDescendantOf(a.id,e._data))throw new o(o.INVALID_PARAMS,"Must not create a cycle.");var s=r.parentNodeData.children.splice(r.index,1)[0];try{var c=a._data.children;c?(t>=0&&t<=c.length||(t=c.length),t===c.length?c[t]=s:c.splice(t,0,s)):a._data.children=[s]}catch(e){throw r.parentNodeData.children.splice(r.index,0,s),e}return 0===r.parentNodeData.children.length&&delete r.parentNodeData.children,this._setDirty(),this._allNodes[i]},c.prototype.copyChild=function(e,t,n,o,i,r){return this._copyChild(e,t,n,o,i,!1,r)},c.prototype.replaceChild=function(e,t,n,o){return this._copyChild(e,void 0,void 0,t,n||e.id,!0,o)},c.prototype.allComponents=function(){var e,t=[];for(e in this._allComponents)this._allComponents.hasOwnProperty(e)&&t.push(this._allComponents[e]);return t},c.prototype.getComponentWithId=function(e){return this._allComponents[e]},c.prototype.getComponentWithAbsolutePath=function(e){var t=this._absolutePaths[e.toLowerCase()];return t&&t instanceof r?t:void 0},c.prototype.getComponentsOf=function(e){if(!(e=e?this._allNodes[e.id]:this.rootNode))throw new o(o.INVALID_PARAMS,"Unknown node");var t,n=[],i=e._data.components;if(Array.isArray(i))for(t=0;t<i.length;t++){var r=i[t],a=this._allComponents[r.id];if(!a)throw new o(o.INVALID_DATA,"Component not in cache");n[n.length]=a}return n},c.prototype.addComponent=function(e,t,n,i,a,c,l,d,p,h){var u=this._localStorage;if(!u)throw new o(o.NO_LOCAL_STORAGE,"No local storage. Use AdobeDCXCompositeXfer.uploadNewComponent() followed by addComponentWithUploadResults()");if("function"!=typeof h&&a)throw new o(o.INVALID_PARAMS,'Param "callback" must be a function.');if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(p&&"string"!=typeof p)throw new o(o.INVALID_PARAMS,'Param "id" must be of type string.');if(!a&&!l)throw new o(o.INVALID_PARAMS,"Must provide either source or sourceHref.");try{if(l){var _=this._getBranchOf(this).compositeHref;if(_){var f=s.endPointOf(_),m=s.endPointOf(l);if(f&&m&&f!==m)throw new o(o.WRONG_ENDPOINT,"Given source href has an invalid endpoint: "+m)}}var E=this._local();p=p||s.generateUuid();var g=new r;g.id=p,g.name=e,g.type=t,g.relationship=n,g.path=i,g.state="modified";var y=this,v=function(e){if(!e)try{if(p&&y._allComponents[p])throw new o(o.DUPLICATE_VALUE,'The "id" of a component must be unique.');var t=d?y._allNodes[d.id]:y.rootNode;if(!t)throw new o(o.INVALID_PARAMS,"Unknown parent node.");var n=y._normalizedAbsolutePathForItem(g,t);if(y._absolutePaths[n])throw new o(o.DUPLICATE_VALUE,"Duplicate absolute path: "+n);if(!s.isValidAbsolutePath(n))throw new o(o.INVALID_PARAMS,"Invalid absolute path: "+n);g._parentPath=t.absolutePath||t._parentPath;var i=t._data.components;i?i.push(g._data):t._data.components=[g._data],g._owner=y._owner,l&&y._setSourceHrefOfComponent(l,g),y._allComponents[g.id]=g,y._absolutePaths[n]=g,y._setDirty()}catch(t){u.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();u.ingestComponentAsset(g,a,c,E,v)}catch(e){if(h)return h(e);throw e}},c.prototype.addComponentWithUploadResults=function(e,t,n,i,a){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(a.compositeId!==this._owner.compositeId)throw new o(o.INVALID_PARAMS,"Param uploadResults does not appear valid to be for this composite.");var s=Object.keys(a.records);if(1!==s.length)throw new o(o.INVALID_PARAMS,"Param uploadResults must contain records of exactly one component upload.");if(this._localStorage)throw new o(o.INVALID_PARAMS,"This method is for in-browser use only. Use addComponent() instead.");var c=a.records[s[0]],l=c.id;if(this._allComponents[l])throw new o(o.DUPLICATE_VALUE,"Duplicate component id: "+l);var d=i?this._allNodes[i.id]:this.rootNode;if(!d)throw new o(o.INVALID_PARAMS,"Unknown parent node.");var p=new r;p.id=l,p.name=e,p.type=c.type,p.relationship=t,p.path=n,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 o(o.DUPLICATE_VALUE,"Duplicate absolute path: "+h);p._parentPath=d.absolutePath||d._parentPath;var u=d._data.components;return u?u.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,n,i){var r=this._localStorage;if(!r)throw new o(o.NO_LOCAL_STORAGE,"No local storage. Use AdobeDCXCompositeXfer.uploadComponent() to upload a new component asset and then call updateComponentWithUploadResults()");if("function"!=typeof i)throw new o(o.INVALID_PARAMS,'Param "callback" must be a function.');if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(!(e=this._allComponents[e.id]))throw new o(o.INVALID_PARAMS,"Unknown component.");try{var a=this;r.ingestComponentAsset(e,t,n,this._local(),function(t){if(!t)try{"modified"!==e.state?e.state="modified":a._setDirty(),a._setSourceHrefOfComponent(void 0,e)}catch(n){t=n,e=void 0}i(t,e)})}catch(e){i(e)}},c.prototype.updateComponentWithUploadResults=function(e,t){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(!(e=this._allComponents[e.id]))throw new o(o.INVALID_PARAMS,"Unknown component.");if(this._localStorage)throw new o(o.INVALID_PARAMS,"This method is for in-browser use only. Use updateComponent() instead.");if(t.compositeId!==this._owner.compositeId)throw new o(o.INVALID_PARAMS,"Param uploadResults does not appear valid to be for this composite.");var n=t.records[e.id];if(!n)throw new o(o.INVALID_PARAMS,"Param uploadResults does not contain an upload record for the given component.");return e.etag=n.etag,e.version=n.version,e.md5=n.md5,e.length=n.length,e},c.prototype.removeComponent=function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(!e)throw new o(o.INVALID_PARAMS,'Expecting param "component".');var t=e.id;if(!t)throw new o(o.INVALID_PARAMS,'Param "component" must have an id.');var n=this._nodeDataOfParentOfComponent(e);if(!n)throw new o(o.INVALID_PARAMS,"Component not found in this branch.");return n.parentNodeData.components.splice(n.index,1),0===n.parentNodeData.components.length&&delete n.parentNodeData.components,e=this._allComponents[t],delete this._allComponents[t],delete this._absolutePaths[this._normalizedAbsolutePathForItem(e)],this._localStorage&&(this._localStorage.removeComponentAsset(e,this._local()),this._setSourceHrefOfComponent(void 0,e)),e._owner=void 0,e._parentPath="",this._setDirty(),e},c.prototype.moveComponent=function(e,t){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(!e)throw new o(o.INVALID_PARAMS,'Expecting param "component".');var n=e.id;if(!n)throw new o(o.INVALID_PARAMS,'Param "component" must have an id.');var i=this._nodeDataOfParentOfComponent(e);if(!i)throw new o(o.INVALID_PARAMS,"Component not found in this branch.");var r=t?this._allNodes[t.id]:this.rootNode;if(!r)throw new o(o.INVALID_PARAMS,"Unknown parent node.");var a=this._normalizedAbsolutePathForItem(e,r);if(this._absolutePaths[a])throw new o(o.DUPLICATE_VALUE,"Duplicate absolute path: "+a);var s=i.parentNodeData.components.splice(i.index,1)[0],c=r._data.components;return c?c.push(s):r._data.components=[s],0===i.parentNodeData.components.length&&delete i.parentNodeData.components,e=this._allComponents[n],delete this._absolutePaths[this._normalizedAbsolutePathForItem(e)],e._parentPath=r.absolutePath||r._parentPath,this._absolutePaths[a]=e,this._setDirty(),e},c.prototype.copyComponent=function(e,t,n,o,i){return this._copyComponent(e,t,n,o,!1,i)},c.prototype.replaceComponent=function(e,t,n,o){return this._copyComponent(e,void 0,t,n||e.id,!0,o)},c.prototype.assetOfComponent=function(e,t){try{if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");if(!e)throw new o(o.INVALID_PARAMS,'Expecting param "component".');if(!e.id)throw new o(o.INVALID_PARAMS,'Param "component" must have an id.');var n=this._localStorage.componentAssetPath(e,this._local());if(!t)return n;a.exists(n,function(e){t(void 0,e?n:null)})}catch(e){if(!t)throw e;t(e)}},c.prototype._getHrefOfComponent=function(e){var t,n=this._getBranchOf(e).compositeHref;return n&&void 0!==e.version&&(t=s.appendPathElements(n,e.id),t+=";version="+e.version),t},c.prototype._setSourceHrefOfComponent=function(e,t,n){var o=t.id,i=this._componentSourceHrefLookup(!0,n);e?i[o]=e:i[o]&&delete i[o]},c.prototype._getSourceHrefOfComponent=function(e,t){var n=e.id,o=this._componentSourceHrefLookup(!1,t);if(o)return o[n]},c.prototype._copySourceHrefsFrom=function(e){var t=e._componentSourceHrefLookup(!1),n=this.allComponents(),o=n.length;if(o&&t){var i,r=this._componentSourceHrefLookup(!0);for(i=0;i<o;i++){var a=n[i].id;r[a]=t[a]}}},c.prototype._getBranchOf=function(e){return e._owner?this._getBranchOf(e._owner):e},c.prototype._isSameComposite=function(e){var t=this._getBranchOf(this),n=this._getBranchOf(e);return t._data.id===n._data.id&&(t.compositeHref===n.compositeHref&&this._localStorage===e._localStorage)},c.prototype._stringify=function(e,t){if(e){var n=this._data.local,o=null;try{delete this._data.local,o=JSON.stringify(this._data,void 0,t?2:void 0)}catch(e){throw e}finally{n&&(this._data.local=n)}return o}return JSON.stringify(this._data,void 0,t?2:void 0)},c.prototype._setData=function(e){var t=new i(e,this._readOnly,!0);t._owner=this._owner,t._parentPath="";var n={},a={},c={};a[t.id]=t,c[i.ROOT_PATH]=t;var l=this,d=function(e,t,n,a,c){var p,h,u,_=e.components;if(Array.isArray(_))for(p=0;p<_.length;p++){var f=_[p],m=new r(f,l._readOnly);if(t[m.id])throw new o(o.INVALID_DATA,"Duplicate component id: "+m.id);if(m._owner=l._owner,m._parentPath=c,a[u=l._normalizedAbsolutePathForItem(m)])throw new o(o.INVALID_DATA,"Duplicate absolute path: "+u);if(!s.isValidAbsolutePath(u))throw new o(o.INVALID_DATA,"Invalid absolute component path: "+u);t[m.id]=m,a[u]=m}var E=e.children;if(Array.isArray(E))for(p=0;p<E.length;p++){var g=E[p],y=new i(g,l._readOnly);if(n[y.id])throw new o(o.INVALID_DATA,"Duplicate node id: "+y.id);if(h=y.path,y._owner=l._owner,y._parentPath=c,h){if(a[u=l._normalizedAbsolutePathForItem(y)])throw new o(o.INVALID_DATA,"Duplicate absolute path: "+u);if(!s.isValidAbsolutePath(u))throw new o(o.INVALID_DATA,"Invalid node absolute path: "+u);a[u]=y}n[y.id]=y,d(g,t,n,a,y.path?s.appendPathElements(c,y.path):c)}};return d(e,n,a,c,i.ROOT_PATH),this._data=e,this._allComponents=n,this._allNodes=a,this._absolutePaths=c,this._isDirty=!1,this},c.prototype._removeNodeFromCachesRecursively=function(e){var t,n=e.components;if(Array.isArray(n))for(t=0;t<n.length;t++){var o=n[t].id,i=this._allComponents[o];delete this._allComponents[o],delete this._absolutePaths[this._normalizedAbsolutePathForItem(i)],i._owner=void 0,this._localStorage&&(this._localStorage.removeComponentAsset(i,this._local()),this._setSourceHrefOfComponent(void 0,i))}var r=e.children;if(Array.isArray(r))for(t=0;t<r.length;t++)this._removeNodeFromCachesRecursively(r[t]);var a=e.id,s=this._allNodes[a];delete this._allNodes[a],s.path&&delete this._absolutePaths[this._normalizedAbsolutePathForItem(s)],s._owner=void 0},c.prototype._local=function(){return this._data.local||(this._data.local={version:2}),this._data.local},c.prototype._componentSourceHrefLookup=function(e,t){if(e&&this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(t||(t=e?this._local():this._data.local)){var n=t["componentS2SCopy#srcHref"];return!n&&e&&(n=t["componentS2SCopy#srcHref"]={}),n}},c.prototype._recursiveReset=function(e,t){var n,o=e.components;if(o)for(n=o.length-1;n>=0;n--){var i=o[n];"committedDelete"===i.state?(delete o[n],delete this._allComponents[i.id],delete i._owner,this._localStorage&&this._localStorage.removeComponentAsset(i,this._local()),this._setSourceHrefOfComponent(void 0,i,this._local())):(delete i.etag,delete i.version,delete i.length,delete i.md5,i.state="modified",t&&t(i))}var r=e.children;if(r)for(n=0;n<r.length;n++)this._recursiveReset(r[n],t)},c.prototype._nodeIdIsDescendantOf=function(e,t){var n,o=t.children;if(o)for(n=0;n<o.length;n++){var i=o[n];if(i.id===e||this._nodeIdIsDescendantOf(e,i))return!0}return!1},c.prototype._recursivelyGetAllComponentsOfChild=function(e,t){t=t||[];var n,o,i=e._data||e,r=i.components;if(r)for(o=r.length,n=0;n<o;n++)t[t.length]=this._allComponents[r[n].id];var a=i.children;if(a)for(o=a.length,n=0;n<o;n++)t=this._recursivelyGetAllComponentsOfChild(a[n],t);return t},c.prototype._nodeDataOfParentOfNode=function(e,t){t=t||this._data;var n,o=e._data.id,i=t.children;if(i)for(n=0;n<i.length;n++){var r=i[n];if(r.id===o)return{parentNodeData:t,index:n};var a=this._nodeDataOfParentOfNode(e,r);if(a)return a}return null},c.prototype._nodeDataOfParentOfComponent=function(e,t){t=t||this._data;var n,o=e._data.id,i=t.components;if(i)for(n=0;n<i.length;n++){if(i[n].id===o)return{parentNodeData:t,index:n}}var r=t.children;if(r)for(n=0;n<r.length;n++){var a=r[n],s=this._nodeDataOfParentOfComponent(e,a);if(s)return s}return null},c.prototype._determineAbsolutePathChangesRecursively=function(e,t,n){var o,i=e.components;if(i)for(o=0;o<i.length;o++){var r=i[o],a=this._allComponents[r.id];n.push({item:a,parentPath:t,absPath:s.appendPathElements(t,r.path)})}var c=e.children;if(c)for(o=0;o<c.length;o++){var l=c[o],d=this._allNodes[l.id],p=l.path,h=p?s.appendPathElements(t,p):t;n.push({item:d,parentPath:t,absPath:p?h:void 0}),this._determineAbsolutePathChangesRecursively(l,h,n)}},c.prototype._setPathOfNode=function(e,t){var n=t?s.appendPathElements(e.parentPath,t):e.parentPath,i=[{item:e,absPath:t?n:void 0}];this._determineAbsolutePathChangesRecursively(e._data,n,i);var r,a,c=s.flatCopy(this._absolutePaths);for(r=0;r<i.length;r++){var l=i[r].item;l._data.path&&delete c[this._normalizedAbsolutePathForItem(l)]}for(r=0;r<i.length;r++)if((a=i[r]).absPath){var d=a.absPath.toLowerCase();if(c[d])throw new o(o.DUPLICATE_VALUE,"Duplicate absolute path: "+d);if(!s.isValidAbsolutePath(d))throw new o(o.INVALID_PARAMS,"Invalid absolute path: "+d);c[d]=a.item}for(r=0;r<i.length;r++)(a=i[r]).parentPath&&(a.item._parentPath=a.parentPath);e._data.path=t,this._absolutePaths=c},c.prototype._setPathOfComponent=function(e,t){if(!this._allComponents[e.id])throw new o(o.INVALID_PARAMS,"Unknown component.");var n=s.appendPathElements(e.parentPath,t).toLowerCase();if(this._absolutePaths[n])throw new o(o.DUPLICATE_VALUE,"Duplicate absolute path for component: "+n);if(!s.isValidAbsolutePath(n))throw new o(o.INVALID_PARAMS,"Invalid absolute path: "+n);delete this._absolutePaths[this._normalizedAbsolutePathForItem(e)],this._absolutePaths[n]=e,e._data.path=t},c.prototype._setDirty=function(e){if(!e){if("pending"===this._local().archivalState||"archived"===this._local().archivalState)throw new o(o.INVALID_STATE,"Cannot modify an archived composite.");"pendingDelete"!==this._data.state&&"committedDelete"!==this._data.state||console.error("Modifying deleted composite")}this._isDirty=!0,this._local().change=this.changeCount+1,e||"unmodified"!==this._data.state&&this._data.state||(this._data.state="modified")},c.prototype._normalizedAbsolutePathForItem=function(e,t){return(t?s.appendPathElements(t.absolutePath||t._parentPath,e.path):e.absolutePath).toLowerCase()},c.prototype._hasSameEndpoint=function(e){var t=this._getBranchOf(this).compositeHref,n=this._getBranchOf(e).compositeHref;if(t&&n){var o=s.endPointOf(t),i=s.endPointOf(n);if(o&&i&&o!==i)return!1}return!0},c.prototype._copyComponent=function(e,t,n,i,r,a){if(!e)throw new o(o.INVALID_PARAMS,'Expecting param "component".');if(a&&"function"!=typeof a)throw new o(o.INVALID_PARAMS,"Param callback must be a function.");var s=this,c=e._owner._core,d=this._isSameComposite(c),p=d||this._hasSameEndpoint(e),h=c._local(),u=this._localStorage,_=c._localStorage,f=u&&_;if(f&&!a&&!d)throw new o(o.INVALID_PARAMS,"Must pass a callback when copying between two different composites.");if(!f&&!p)throw new o(o.NO_LOCAL_STORAGE,"Cannot copy between two different endpoints without local storage.");var m=function(e,t,n){l(e,t,d,p,!i,f?u:void 0,n,h)},E=f?_.componentAssetPath(e,h):void 0;if(!a)return this._copyComponentModel(e,t,r,n,i,m);if(d||!E)try{a(void 0,this._copyComponentModel(e,t,r,n,i,m))}catch(e){a(e)}else{var g={};u.ingestComponentAsset(e,E,!0,g,function(o){if(o)a(o);else try{h=g,a(void 0,s._copyComponentModel(e,t,r,n,i,m))}catch(e){a(e)}})}},c.prototype._copyComponentModel=function(e,t,n,i,a,c){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(!e)throw new o(o.INVALID_PARAMS,'Expecting param "component".');var l=e._owner,d=new r(JSON.parse(JSON.stringify(e._data)));i?(d.path=i,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,u=this._allComponents[d.id];if(u&&!n)throw new o(o.DUPLICATE_VALUE,"Component already exists.");if(n&&!u)throw new o(o.INVALID_PARAMS,"Could not find existing component.");if(n){var _=this._nodeDataOfParentOfComponent(u);if(!_)throw new o(o.INVALID_PARAMS,"Parent node of existing component not found in this branch.");var f=_.parentNodeData.id;if(!(h=this._allNodes[f]))throw new o(o.INVALID_STATE,"Unknown parent node.");p=_.index}else if(!(h=t?this._allNodes[t.id]:this.rootNode))throw new o(o.INVALID_PARAMS,"Unknown parent node.");d._parentPath=h.absolutePath||h._parentPath;var m=this._normalizedAbsolutePathForItem(d),E=this._absolutePaths[m];if(E&&E!==u)throw new o(o.DUPLICATE_VALUE,"Duplicate absolute path: "+m);if(!s.isValidAbsolutePath(m))throw new o(o.INVALID_PARAMS,"Component path must be a valid path for a component.");var g=this._local();c&&c(e,d,g=s.deepCopy(g));var y=h._data.components;return n?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,n,i,r,a,s){if(!e)throw new o(o.INVALID_PARAMS,'Expecting param "node".');var c=this,d=e._owner._core,p=this._isSameComposite(d),h=p||this._hasSameEndpoint(e),u=d._local(),_=this._localStorage,f=d._localStorage,m=_&&f,E=d._recursivelyGetAllComponentsOfChild(e);if(E.length>0){if(m&&!s&&!p)throw new o(o.INVALID_PARAMS,"Must pass a callback when copying between two different composites.");if(!m&&!h)throw new o(o.NO_LOCAL_STORAGE,"Cannot copy components between two different endpoints without local storage.")}var g=function(e,t,n){l(e,t,p,h,!0,m?_:void 0,n,u)};if(!s)return this._copyChildModel(e,t,n,a,i,r,g);var y=function(){s(void 0,c._copyChildModel(e,t,n,a,i,r,g))};if(0===E.length||p||!m)try{y()}catch(e){s(e)}else{var v,A,C={},S=E.length,I=0,L=function(e){if(e&&!A&&(A=e),0===--I)if(A)s(A);else try{u=C,y()}catch(e){s(e)}};for(v=0;v<S;v++){var O=E[v],R=f.componentAssetPath(O,u);R&&(I++,_.ingestComponentAsset(O,R,!0,C,L))}if(0===I)try{y()}catch(e){s(e)}}},c.prototype._copyChildModel=function(e,t,n,a,c,l,d){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");var p=e._owner,h=new i(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(_&&!a)throw new o(o.DUPLICATE_VALUE,"Child node already exists.");if(a&&!_)throw new o(o.INVALID_PARAMS,"Could not find existing node to replace.");if(a){var f=this._nodeDataOfParentOfNode(_);if(!f)throw new o(o.INVALID_PARAMS,"Parent of existing node not found in this branch.");var m=f.parentNodeData.id;if(!(u=this._allNodes[m]))throw new o(o.INVALID_STATE,"Unknown parent node.");n=f.index}else if(!(u=t?this._allNodes[t.id]:this.rootNode))throw new o(o.INVALID_PARAMS,"Unknown parent node.");if(h._parentPath=u.absolutePath||u._parentPath,h.path){var E=this._normalizedAbsolutePathForItem(h),g=this._absolutePaths[E];if(g&&g!==_)throw new o(o.DUPLICATE_VALUE,"Duplicate absolute path: "+E);if(!s.isValidAbsolutePath(E))throw new o(o.INVALID_PARAMS,"Node path must be a valid path for a node.")}var y=s.flatCopy(this._allNodes),v=s.flatCopy(this._allComponents),A=s.flatCopy(this._absolutePaths),C=s.deepCopy(this._local()),S=function(e,t,n,o,i,r){var a,s;delete n[e.id],e.path&&delete i[t._normalizedAbsolutePathForItem(e)];var c=e._data.children;if(c)for(s=c.length,a=0;a<s;a++)S(n[c[a].id],t,n,o,i,r);var l=e._data.components;if(l)for(s=l.length,a=0;a<s;a++){var d=o[l[a].id];delete o[d.id],delete i[t._normalizedAbsolutePathForItem(d)],t._localStorage&&(t._localStorage.removeComponentAsset(d,r),t._setSourceHrefOfComponent(void 0,d,r))}};_&&S(_,this,y,v,A,C);var I=function(e,t,n,a,c,l,p,h){if(a[e.id])throw new o(o.DUPLICATE_VALUE,"Duplicate node id: "+e.id);var u;if(a[e.id]=e,e.path){if(l[u=t._core._normalizedAbsolutePathForItem(e)])throw new o(o.DUPLICATE_VALUE,"Duplicate absolute path: "+u);l[u]=e}var _,f,m=e._data.children;if(m)for(f=m.length,_=0;_<f;_++){var E=new i(m[_]);a[E.id]&&(E.id=s.generateUuid()),E._owner=t,E._parentPath=e.absolutePath||e._parentPath,I(E,t,n,a,c,l,p,h)}var g=e._data.components;if(g)for(f=g.length,_=0;_<f;_++){var y=new r(g[_]),v=y.id;if(c[v]&&(y.id=s.generateUuid(),y.state="modified",y.etag=void 0,y.version=void 0,y.md5=void 0,y.length=void 0),y._owner=t,y._parentPath=e.absolutePath||e._parentPath,d&&d(n.getComponentWithId(v),y,p),c[y.id])throw new o(o.DUPLICATE_VALUE,"Duplicate component id: "+y.id);if(c[y.id]=y,l[u=t._core._normalizedAbsolutePathForItem(y)])throw new o(o.DUPLICATE_VALUE,"Duplicate absolute path: "+u);l[u]=y}};if(I(h,this._owner,p,y,v,A,C,p._local()),a)u._data.children[n]=h._data;else{var L=u._data.children;L?(n>=0&&n<=L.length||(n=L.length),n===L.length?L[n]=h._data:L.splice(n,0,h._data)):u._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,n){var r,a=this,c=[],l=!1,d=function(e){return c.push(new o(o.INVALID_STATE,e)),t&&(l||(t("Branch for composite "+a.rootNode.id+" has the following errors:"),l=!0),t("   "+e)),!1},p=function(e,t){return!!e||d(t)},h=[],u=function(e){(h.indexOf(e)<0||d("Item "+e.id+" encountered more than once"))&&h.push(e)},_=s.flatCopy(this._allComponents),f=s.flatCopy(this._allNodes),m=s.flatCopy(this._absolutePaths),E=Object.keys(m),g=E.length;for(r=0;r<g;r++){var y=E[r];p("/"===y.charAt(0),"Absolute path "+y+" does not start with a slash.")}var v=function(e,t){var n,o,i=e.children;if(i)for(n=0;n<i.length;n++){var r=i[n],c=f[r.id];(c||d("Node "+r.id+" is not in cache."))&&(u(c),p(c._data===r,"Node "+c.id+" _data property incorrect."),delete f[c.id],c.path&&c._owner&&(o=a._normalizedAbsolutePathForItem(c),(m[o]||d("Absolute path of node "+c.id+" ("+o+") is not in cache."))&&delete m[o]),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(n=0;n<l.length;n++){var h=l[n],E=_[h.id];(E||d("Component "+h.id+" is not in cache."))&&(u(E),p(E._data===h,"Component "+E.id+" _data property incorrect."),delete _[E.id],E._owner&&(o=a._normalizedAbsolutePathForItem(E),(m[o]||d("Absolute path "+o+" is not in cache."))&&delete m[o]),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[i.ROOT_PATH];p(A,"Cannot find root node via path")&&(p(A.id===this._data.id,"Root node has correct id"),p(A.path===i.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[i.ROOT_PATH]),v(this._data,i.ROOT_PATH);var C=Object.keys(_);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 S=this._localStorage.componentIds(this._local());for(r=0;r<S.length;r++)p(this._allComponents[S[r]],"Component "+S[r]+" is in local storage mapping but could not be found in the manifest.");if(e)for(S=Object.keys(this._allComponents),r=0;r<S.length;r++){var I=S[r],L=this._allComponents[I],O=this._localStorage.componentAssetPath(L,this._local());p(O,"Component "+I+" does not have an entry in local storage mapping.")&&n&&p(n.existsSync(O),"Asset "+O+" does not exist.")}var R=this._componentSourceHrefLookup();if(R)for(g=(S=Object.keys(R)).length,r=0;r<g;r++){var T=this._allComponents[S[r]];T?p("modified"===T.state,"Component "+S[r]+" is in local source href mapping but has a state of "+T.state):p(!1,"Component "+S[r]+" is in local source href mapping but could not be found in the manifest.")}}return c.length?c:null},e.exports=c},function(e,t){e.exports=require("uuid/v4")},function(e,t,n){var o=n(4),i=n(13),r=3;function a(e,t,n){n?this._setData(n,e.href):this._data={"push-journal-format-version":r,"composite-href":e.href,"uploaded-components":{}},this._filePath=t,this._waitingCallbacks=[],this._commitInProgress=!1,this._needAnotherCommit=!1}a.readJournal=function(e,t,n,o){i.readFile(e,"utf8",function(i,r){var s;if(i&&i.code&&n&&(i=void 0),!i)try{r=JSON.parse(r),s=new a(t,e,r)}catch(o){n?s=new a(t,e):i=o}o(i,i?void 0:s)})},Object.defineProperties(a.prototype,{compositeHref:{get(){return this._data["composite-href"]},set(){throw new o(o.READ_ONLY,"This property is read-only.")}},manifestEtag:{get(){return this._data.etag},set(e){e?this._data.etag=e:delete this._data.etag}},currentBranchEtag:{get(){return this._data["current-branch-etag"]},set(e){e?this._data["current-branch-etag"]=e:delete this._data["current-branch-etag"]}},changeCount:{get(){return this._data.change},set(e){e?this._data.change=e:delete this._data.change}},compositeHasBeenCreated:{get(){return!!this._data["composite-created"]},set(e){e?this._data["composite-created"]=!0:delete this._data["composite-created"]}},compositeHasBeenDeleted:{get(){return!!this._data["composite-deleted"]},set(e){e?this._data["composite-deleted"]=!0:delete this._data["composite-deleted"]}},compositeHasBeenArchived:{get(){return!!this._data["composite-archived"]},set(e){e?this._data["composite-archived"]=!0:delete this._data["composite-archived"]}},isEmpty:{get(){return 0===Object.keys(this._data["uploaded-components"]).length&&!this.compositeHasBeenDeleted&&!this.manifestEtag},set(){throw new o(o.READ_ONLY,"This property is read-only.")}},isComplete:{get(){return!!(this._data.etag&&this._data.change||this._data["composite-deleted"]||this._data["composite-archived"])},set(){throw new o(o.READ_ONLY,"This property is read-only.")}}}),a.prototype.recordUploadedComponent=function(e,t,n,o,i,r,a){var s={etag:t,length:i,version:n,md5:o};r&&(s["storage-name"]=r),a&&(s["source-href"]=a),s.timestamp=(new Date).toISOString(),this._data["uploaded-components"][e]=s},a.prototype.idsOfAllUploadedComponents=function(){return Object.keys(this._data["uploaded-components"])};a.prototype.getRecordForUploadedComponent=function(e){var t=this._data["uploaded-components"][e];if(t&&!this.isComplete){var n=t.timestamp;if(!n)return this.removeRecordForUploadedComponent(e);if(n=new Date(n),isNaN(n.getTime()))return this.removeRecordForUploadedComponent(e);if(Date.now()-n.getTime()>=6048e5)return this.removeRecordForUploadedComponent(e)}return t},a.prototype.removeRecordForUploadedComponent=function(e){delete this._data["uploaded-components"][e]},a.prototype.applyToBranch=function(e,t){if(!this.isComplete)throw new o(o.INVALID_STATE,"Journal is not complete.");var n=e.isDirty;if(this.compositeHasBeenDeleted)e._data.state="committedDelete",e.manifestEtag=this.manifestEtag;else{this.compositeHasBeenArchived&&(e.compositeArchivalState="archived");var i,r="unmodified"!==e.compositeState&&this.changeCount!==e.changeCount,a=this.idsOfAllUploadedComponents(),s=a.length;for(i=0;i<s;i++){var c=a[i],l=e.getComponentWithId(c);if(l){var 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=n)},a.prototype.commitChanges=function(e){if(this._filePath){var t=this,n=function(e){t._needAnotherCommit=!1,t._commitInProgress=!0,t._waitingCallbacks=[],i.writeFileAtomically(t._filePath,JSON.stringify(t._data),"utf8",function(o){var i,r=e.length;for(i=0;i<r;i++)try{e[i](o)}catch(e){}t._needAnotherCommit?n(t._waitingCallbacks):t._commitInProgress=!1})};t._commitInProgress?(this._needAnotherCommit=!0,e&&this._waitingCallbacks.push(e)):n(e?[e]:[])}else e&&e()},a.prototype._setData=function(e,t){if(e["push-journal-format-version"]<=2){var n=e["uploaded-components"];if(n){var o,i=Object.keys(n),a=i.length;for(o=0;o<a;o++){var s=n[i[o]];"number"==typeof s.version&&(s.version=String(s.version))}}e["push-journal-format-version"]=r}var c=this._verify(e,t);if(null===c)return this._data=e,this;throw c},a.prototype._verify=function(e,t){return e["push-journal-format-version"]!==r?new o(o.INVALID_DATA,"Wrong push journal format version."):e["composite-href"]!==t?new o(o.INVALID_DATA,"Composite and journal hrefs mismatch."):e["uploaded-components"]?null:new o(o.INVALID_DATA,"Missing component list.")},e.exports=a},function(e,t,n){var o,i,r,a=n(7),s=n(4),c=n(13);i=n(26),r=n(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=i,this._XMLHttpRequest=o,this._handlesRedirects=void 0!==o,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||o,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,n,o,i,r){var p=(i=i||{}).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");n=l({},n,this._additionalHeaders),this._apiKey&&(n["x-api-key"]=this._apiKey);var h={method:e,href:t,headers:n,callback:r,body:o,options:i},u=i.reuseRequestDesc;if(u){if(this._requestQueue.indexOf(u)>=0||this._requestsOutstanding.indexOf(u)>=0)throw new s(s.INVALID_PARAMS,"Request descriptor still in use.");h=a.merge(u,h)}return this._doRequest(h),h},h.prototype._doRequest=function(e){var t,n,o,i=this,h=0,u=[],_=e.body,f=e.options.responseType;function m(t,o){t&&a.log("["+e.id+"] error: "+t),n&&n.end();var r=i._requestsOutstanding.indexOf(e);r>=0&&i._requestsOutstanding.splice(r,1);var c=e.callback;c&&(e.callback=void 0,t&&(t.clientRequest=e.clientRequest,t.xhr=e.xhr),t&&t.code!==s.SERVICE_IS_INACTIVE&&!i._isActive?t=new s(s.SERVICE_IS_INACTIVE,"Service is now inactive",t):e.timedOut&&(t=new s(s.TIMED_OUT,"timed out request",t)),c(t,o)),i._isActive&&i._checkQueue()}if(!this._isActive)return m(new s(s.SERVICE_IS_INACTIVE,"Network request in inactive state"));function E(t){t.pipe(o),t.on("error",function(t){return i.abort(e),m(new s(s.TERMINATED_INPUTSTREAM,"Input stream terminated abnormally",t))})}if(this._waitingForAuthentication||this._requestsOutstanding.length>=this._maxOutstanding||e.options.noSoonerThen)this._requestQueue.push(e),this._waitingForAuthentication||this._checkQueue();else{var g=e.headers;if(null===g.Authorization)delete g.Authorization;else{if(!this._allowAuthTokenToBeSentInsecurely_DONT_USE_THIS_IN_PRODUCTION&&0!==e.href.indexOf("https:"))return m(new s(s.INVALID_PARAMS,"Must not send auth token over unsecured connection"));this._authValue&&(g.Authorization=this._authValue)}if(this._currentAuthId&&(e.authId=this._currentAuthId),this._beforeHook&&this._beforeHook(e),e.id=a.generateUuid(),e.startTime=(new Date).valueOf(),g["X-Request-Id"]=e.id,this._https){this._requestsOutstanding.push(e);var y=r.parse(e.href),v=l({},this._additionalNodeOptions,y);v.method=e.method||"GET",v.headers=g,a.log("["+e.id+"] "+v.method+" "+e.href),o=this._https.request(v,function(t){var o=!1,r=!1,l=!1;function p(){if(!r)return r=!0,n=void 0,m(void 0,t)}var h=i._requestsOutstanding.indexOf(e);if(h<0)i._checkQueue();else{e.response=t;var _=(new Date).valueOf()-e.startTime;if(a.log("["+e.id+"] "+t.statusCode+" ("+_+"ms)"),401===t.statusCode&&i._authCallback)i._requestsOutstanding.splice(h,1),i._requestQueue.unshift(e),i._authFail(e),a.consumeStream(t);else{var E=e.progress;200===t.statusCode||201===t.statusCode||202===t.statusCode?(t.on("data",function(e){e.length&&E&&E(e.length),!n&&e&&u.push(e)}),i._https&&f instanceof d&&(n=c.createWriteStream(f.filename),t.pipe(n),o=!0)):a.consumeStream(t),t.once("end",function(){l=!0;var n=i._requestsOutstanding.indexOf(e);if(!(n<0||(i._requestsOutstanding.splice(n,1),i._checkQueue(),o||r)))return r=!0,t.response=Buffer.concat(u),"arraybuffer"===f?t.response=new ArrayBuffer(t.response):"text"===f&&(t.response=t.response.toString()),m(void 0,t)}),t.once("close",function(){if(!l&&!r)return r=!0,m(new s(s.NETWORK_ERROR,"incomplete response"))}),o&&(n.once("finish",p),n.once("close",p))}}}),e.clientRequest=o,o.once("error",m),i._timeout&&o.setTimeout(i._timeout,function(){e.timedOut=!0,o.abort()}),e.bytesSent=0,e.bytesReported=0,o.once("end",function(){if(e.progress){var t=e.bytesSent-e.bytesReported;t>0&&(e.progress(t),e.bytesReported+=t)}});var A=o.write;if(o.write=function(t){var n=t&&t.length;return n&&(e.bytesSent+=n),A.call(o,t,function(){e.progress&&t&&(e.progress(n),e.bytesReported+=n)})},_ instanceof d)E(c.createReadStream(_.filename));else if(_ instanceof p){if(_.getStream)E(_.getStream());else _.getStreamAsync&&_.getStreamAsync(function(t,n){if(t)return i.abort(e),m(new s(s.TERMINATED_INPUTSTREAM,"Error creating input stream",t));E(n)})}else if(_ instanceof Buffer)o.write(_),o.end();else if(_ instanceof ArrayBuffer)o.write(new Buffer(new Int8Array(_))),o.end();else if("string"==typeof _)o.write(new Buffer(_,"utf8")),o.end();else{if(_)return m(new s(s.INVALID_PARAMS,"Invalid data type"));o.end()}this._afterHook&&this._afterHook(e,o)}else{if(_ instanceof d)return c.canUseFileSystem?void c.readFile(_.filename,{},function(t,n){if(t)return m(t);e.body=n,i._doRequest(e)}):m(new s(s.INVALID_PARAMS,"Can't use FileContent without filesystem support"));var C;for(C in"function"==typeof Buffer&&_ instanceof Buffer&&(e.body=_=new Int8Array(_)),this._requestsOutstanding.push(e),a.log("["+e.id+"] "+e.method+" "+e.href),(t=new this._XMLHttpRequest).open(e.method,e.href,!0),this._withCredentials&&(t.withCredentials=!0),f&&(t.responseType=f instanceof d?"buffer":f),t.onreadystatechange=function(){var n=e.progress;if(n&&t.response){var o=t.response.length;n(o-h),h=o}if(4===t.readyState){if(0===t.status)return m(new s(s.UNEXPECTED,"XHR failure"));var r=i._requestsOutstanding.indexOf(e);if(r<0)i._checkQueue();else{var l=(new Date).valueOf()-e.startTime;if(a.log("["+e.id+"] "+t.status+" ("+l+"ms)"),i._requestsOutstanding.splice(r,1),401!==t.status||!i._authCallback){if(e.xhr=t,e.response=t,t.statusCode=t.status,t.headers=a.parseHeaders(t.getAllResponseHeaders()),f instanceof 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 n&&_&&n(_.length||_.size),m(void 0,t)}i._requestQueue.unshift(e),i._authFail(e),i._checkQueue()}}},g)g.hasOwnProperty(C)&&t.setRequestHeader(C,g[C]);e.xhr=t,i._timeout&&(t.timeout=i._timeout,t.ontimeout=function(){e.timedOut=!0,t.abort()}),_?t.send(_):t.send(),this._afterHook&&this._afterHook(e,t)}}},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"),n=e.callback;n&&(e.callback=void 0,n(t))}),void(this._checkQueueTimerId&&(clearTimeout(this._checkQueueTimerId),this._checkQueueTimerId=void 0,this._checkQueueTimerWhen=void 0))}for(var n,o=Date.now(),i=o+3e5,r=0;!(this._waitingForAuthentication||this._requestsOutstanding.length>=this._maxOutstanding||r>=this._requestQueue.length);){var a=this._requestQueue[r];(n=a.options.noSoonerThen||o)&&n>i&&(n=a.options.noSoonerThen=i),n<=o?(this._requestQueue.splice(r,1),a.options.noSoonerThen=void 0,this._doRequest(a)):r++}if(!this._waitingForAuthentication&&this._requestsOutstanding.length<this._maxOutstanding&&this._requestQueue.length>0){var c,l,d=this._requestQueue.length;for(l=0;l<d;l++)(n=this._requestQueue[l].options.noSoonerThen)&&n>i&&(n=this._requestQueue[l].options.noSoonerThen=i),n&&(c=c&&c<n?c:n);if(c&&(!this._checkQueueTimerWhen||this._checkQueueTimerWhen>c)){this._checkQueueTimerId&&clearTimeout(this._checkQueueTimerId),this._checkQueueTimerWhen=c;var p=this;this._checkQueueTimerId=setTimeout(function(){p._checkQueueTimerWhen=void 0,p._checkQueueTimerId=void 0,p._checkQueue()},c-o)}}},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())},h.prototype.abortAllWithToken=function(e){if(e){var t;for(t=0;t<this._requestQueue.length;++t)this._requestQueue[t].token===e&&(this._requestQueue.splice(t,1),--t);for(t=0;t<this._requestsOutstanding.length;++t)if(this._requestsOutstanding[t].token===e){var n=this._requestsOutstanding[t];this._requestsOutstanding.splice(t,1),--t,n.xhr&&n.xhr.abort(),n.clientRequest&&n.clientRequest.abort()}this._checkQueue()}},e.exports=h},function(e,t,n){var o=n(43),i=n(4),r=i.networkError,a=i.unexpectedResponse,s=n(25),c=n(7),l=n(13),d=c.appendPathElements,p="If-Match";function h(e,t){if(o.call(this,e,t),!this._endPoint)throw new i(i.INVALID_PARAMS,"Could not determine endpoint from: "+t);this.authenticationWhitelist=["adobe.com","adobe.io","fotolia.net"]}h.prototype=Object.create(o.prototype),h.prototype.name="AdobeStorageSession",h.FileContent=o.FileContent,h.StreamProvider=o.StreamProvider,h.prototype.getCollection=function(e,t,n){if(!(e=this._resolveUrl(e)))return n(new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+e));var o;e+="?order=asc&orderby=name";var s={};t&&(s["If-None-Match"]=t);var c=this;return this._service.invoke("GET",e,s,void 0,{responseType:"text"},function t(l,d){if(l)return n(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 i(i.INVALID_DATA,"Invalid JSON returned by server",e)).response=d,n(l)}o?o.children=o.children.concat(p.children):o=p;var u=d.headers["x-children-next-start"];if(u){var _=e+"&start="+u;c._service.invoke("GET",_,s,void 0,{responseType:"text"},t)}else n(void 0,o,d.headers.etag,d.headers)}else 304===d.statusCode?n(void 0,null,d.headers.etag,d.headers):n(a("Unexpected status code while getting a collection",void 0,d))})},h.prototype.pagedGetCollection=function(e,t,n,o,s,c,l,d){if(!(e=this._resolveUrl(e)))return d(new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+e));e+=function(e,t,n,o){var i=[],r="";return t&&i.push("order="+t),e&&i.push("orderBy="+e),n&&i.push("start="+n),o&&i.push("limit="+o),i.length>0&&(r="?"+i.join("&")),r}(n,o,s,c);var 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 n,o=t.responseText||t.response;try{n=JSON.parse(o)}catch(n){return(e=new i(i.INVALID_DATA,"Invalid JSON returned by server",n)).response=t,d(e)}l?l.children=l.children.concat(n.children):l=n,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,n){var o=this.getComponentHref(e,e.version);return this.getAsset(o,void 0,t,n)},h.prototype.getRenditionOfComponent=function(e,t,n,o,i){var r=this.getComponentRenditionHref(e,e.version,n);return this.getAsset(r,{accept:t},o,i)},h.prototype.getSyncGroups=function(e,t){var n=d(this._server,"assets");return this.getCollection(n,e,t)},h.prototype.getSyncGroup=function(e,t,n){var o=d(this._server,"assets",e);return this.getCollection(o,t,n)},h.prototype.getCompositeManifest=function(e,t,n){var o=e.href;return o&&(o=this._resolveUrl(o)),o?(o=d(o,"manifest"),this.getAssetAsType(o,"text",t,n)):n(new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+o))},h.prototype.headRequest=function(e,t){return this._service.invoke("HEAD",e,{},void 0,void 0,function(e,n){if(e)return t(e);t(e,n)})},h.prototype._checkForComponentAlreadyUploaded=function(e,t,n){if(!(l.canUseFileSystem&&e&&t&&t.filename))return n();l.getMD5Hash(t.filename,(t,o)=>{if(t)return n();this.headRequest(e,(e,t)=>{if(e)return n();const i=t&&t.statusCode,r=t&&t.headers["content-md5"];200!==i||r!==o?n():n(t,r)})})},h.prototype.remixComposite=function(e,t,n,o,i,r){var a={compositeId:o};i&&(a.creatorTool=i);var s={href:e};return t&&(s.authorization=t),this._invokeOperation("remix",s,{href:n},a,r)},h.prototype.createCompositeDirectory=function(e,t,n){var o=this,s=this._resolveUrl(e.href);if(!s)return n(new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+s));function l(e,t,n){var a={"Content-Type":"application/vnd.adobe.directory+json","X-Update":"content"};t&&(a[p]="*"),o._service.invoke("PUT",s,a,void 0,void 0,function(e,t){return e?n(r("Error Creating composite directory",e,t)):409===t.statusCode?((e=new i(i.ALREADY_EXISTS,e)).response=t,n(e)):void n(void 0,t)})}l(0,t,function(e,i){if(e)return n(e);var d=i.statusCode;if(200===d||201===d)n(void 0,i);else if(404===d){var p=c.parentDirectory(s);o._service.invoke("PUT",p,{},void 0,void 0,function(e,o){if(e)return n(r("Error creating composite directory",e,o));var i=o.statusCode;200===i||201===i||409===i?l(0,t,function(e,t){if(e)return n(e);var o=t.statusCode;200===o||201===o?n(void 0,t):n(r("Error creating composite directory",e,t))}):n(a("Unexpected response creating composite directory",e,o))})}else n(a("Unexpected response creating composite directory",e,i))})},h.prototype.deleteCompositeDirectory=function(e,t){var n=this,o=this._resolveUrl(e.href);if(!o)return t(new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+o));o+="?recursive=true&invocation_mode=sync,async";var s=this._service.invoke("DELETE",o,{"If-Match":"*"},void 0,void 0,function(e,o){if(e)return t(r("Error deleting composite directory",e,o));var i=o.statusCode;return 200===i||204===i||404===i?t(void 0,o):202===i?n._handle202Response(o,s,n.SYNC_ASYNC_DEFAULT_DELAY,t):void t(a("Unexpected response deleting composite directory",e,o))})},h.prototype.archiveCompositeDirectory=function(e,t){var n=this,o=this._makeRelativeUrl(e.href);if(!o)return t(new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+e.href));var s={"Content-Type":"application/vnd.adobe.directory+json",Link:"<"+o+">;rel=self"},c=this._resolveUrl("/archive/"+e.id)+"?invocation_mode=sync,async",l=this._service.invoke("PUT",c,s,void 0,void 0,function(e,o){if(e)return t(r("Error archiving composite directory",e,o));var i=o.statusCode;return 200===i||204===i||404===i?t(void 0,o):202===i?n._handle202Response(o,l,n.SYNC_ASYNC_DEFAULT_DELAY,t):void t(a("Unexpected response archiving composite directory",e,o))})},h.prototype.leaveSharedComposite=function(e,t){if(e.collaborationType!==s.COLLABORATION.SHARED_WITH_USER)throw new i(i.INVALID_STATE,"Composite's collaboration type must be sharedWithUser.");return this.deleteCompositeDirectory(e,t)},h.prototype.uploadComponent=function(e,t,n,o,r,a){if(!e._owner||!e._owner.compositeHref)throw new i(i.INVALID_STATE,"Component must be part of a branch of a bound composite.");return this.uploadAssetForComponentId(e.id,e.type,e._owner.compositeHref,t,n,o,r,a)},h.prototype.uploadAssetForComponentId=function(e,t,n,o,s,c,l,d){const h=this._constructComponentHref(n,e);let u=h;s&&(u+="?intermediates=false");var _={};t&&(_["Content-Type"]=t);const f=(e,t)=>{e?delete _[p]:_[p]="*";var n=this._service.invoke("PUT",u,_,l,void 0,function(e,n){if(e)return t(r("Error uploading component",e,n));var o=n.statusCode;if(200===o||201===o||204===o){var s;try{s=JSON.parse(n.responseText||n.response)}catch(o){return(e=new i(i.INVALID_DATA,"Invalid JSON returned by server",o)).response=n,t(e,n,s)}t(void 0,n,s)}else 507===o?((e=new i(i.EXCEEDS_QUOTA,"Exceeds quota",e)).response=n,t(e)):((e=a("Unexpected response uploading component",e)).response=n,t(e))});return n.token=c,n};return f(o,(e,t,n)=>{if(e){if(!(t=e.response))return d(e);var i=t.statusCode;o||404!==i?!o||409!==i&&412!==i?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,n)})},h.prototype.copyAssetToComponentId=function(e,t,n,o,s,c,l,d){var h=this._makeRelativeUrl(l);if(!h)return d(new i(i.WRONG_ENDPOINT,"Cannot copy asset: "+l));var u=this,_=this._constructComponentHref(n,e);_+="?invocation_mode=sync,async",s&&(_+="&intermediates=false");var f={};function m(e,t,n){e?delete f[p]:f[p]="*";var o=u._service.invoke("PUT",_,f,void 0,{responseType:"text"},function(e,i){if(e)return n(r("Error uploading component",e,i));var s=i.statusCode;200===s||201===s||204===s?n(void 0,i,t):202===s?u._handle202Response(i,o,u.SYNC_ASYNC_DEFAULT_DELAY,function(e,o){n(e,o,t)}):n(a("Unexpected response copying a component asset",e,i),i,t)});return o.token=c,o}t&&(f["Content-Type"]=t),f.Link="<"+h+">;rel=source";var E=function(e,t,n){var r;if(e){if(!(t=e.response))return d(e);var a=t.statusCode;n||404!==a&&409!==a&&412!==a?507===a?((e=new i(i.EXCEEDS_QUOTA,"Exceeds quota",e)).response=t,d(e)):d(e):m(!o,!0,E)}else{try{r=JSON.parse(t.responseText||t.response)}catch(n){return(e=new i(i.INVALID_DATA,"Invalid JSON returned by server",n)).response=t,d(e)}d(void 0,t,r)}};return m(o,!0,E)},h.prototype.updateManifest=function(e,t,n,o){var s=this.getBranchManifestHref(e),c={"Content-Type":"application/vnd.adobe.dcx-manifest+json"},l=e.manifestEtag;return n?c["If-Match"]="*":l&&(c["If-Match"]=l),this._service.invoke("PUT",s,c,t,void 0,function(e,t){if(e)return o(r("Error updating manifest",e,t));var s=t.statusCode;!t.headers.etag||200!==s&&201!==s&&204!==s?412===s||l&&!n&&409===s?((e=new i(i.UPDATE_CONFLICT,"Manifest has been changed")).response=t,o(e)):o(a("Unexpected response updating manifest",e,t)):o(void 0,t)})},h.prototype.getHrefForComposite=function(e,t){if(!e.type)throw new i(i.INVALID_STATE,"Composite needs a type");if(!e.id)throw new i(i.INVALID_STATE,"Composite needs an id");return e.href?e.href:this._resolveUrl(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 i(i.WRONG_ENDPOINT,"Wrong endpoint: "+t);return d(t,"manifest")},h.prototype.getBranchManifestHref=function(e){var t=this._resolveUrl(e.compositeHref);if(!t)throw new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+t);return d(t,"manifest")},h.prototype.getComponentHref=function(e,t){var n,o=e._owner;if(!o||!o.compositeHref)throw new i(i.INVALID_STATE,"Component must be part of a branch of a bound composite.");return o._core&&(n=o._core._getSourceHrefOfComponent(e)),n||this._constructComponentHref(o.compositeHref,e.id,t)},h.prototype.getComponentRenditionHref=function(e,t,n){var o=e._owner;if(!o||!o.compositeHref)throw new i(i.INVALID_STATE,"Component must be part of a branch of a bound composite.");if(o._core&&o._core._getSourceHrefOfComponent(e))throw new i(i.INVALID_STATE,"Getting a rendition of a source href not implemented.");return this._constructComponentRenditionHref(o.compositeHref,e,t,n)},h.prototype._constructComponentHref=function(e,t,n){var o=d(this._resolveUrl(e),t);return o&&void 0!==n&&(o+=";version="+n),o},h.prototype._invokeOperation=function(e,t,n,o,s){var l=this,d=this._resolveUrl("/ops");d+="?invocation_mode=sync,async";var p={op:e,id:c.generateUuid(),target:n,source:t};o&&(p.value=o),c.log("[invoke operation]: "+JSON.stringify(p,void 0,2));var h=function(e,t){var n;if(e)return(t=e.response)?void(507===t.statusCode?((e=new i(i.EXCEEDS_QUOTA,"Exceeds quota",e)).response=t,s(e)):s(e)):s(e);try{n=JSON.parse(t.responseText||t.response)}catch(n){return(e=new i(i.INVALID_DATA,"Invalid JSON returned by server",n)).response=t,s(e)}if(n.error)return(e=new i(i.UNEXPECTED_RESPONSE,"Error in operation result: "+JSON.stringify(n.error,void 0,2))).response=t,s(e);s(void 0,t,n)},u=l._service.invoke("POST",d,{"Content-Type":"application/vnd.adobe.asset-operation+json"},JSON.stringify(p),{responseType:"text"},function(t,n){if(t)return h(r("Error invoking operation "+e,t,n));var o=n.statusCode;200===o||201===o||204===o?h(void 0,n):202===o?l._handle202Response(n,u,l.SYNC_ASYNC_DEFAULT_DELAY,function(e,t){h(e,t)}):h(a("Unexpected response for operation "+e,t,n),n)});return u},h.prototype._constructComponentRenditionHref=function(e,t,n,o){var i=d(this._constructComponentHref(e,t.id),":rendition");return i+=";size="+(o||"full"),void 0!==n&&(i+=";version="+n),i},e.exports=h},function(e,t,n){var o,i,r=n(25),a=n(40),s=n(33),c=n(4),l=n(51),d=n(43),p=n(7),h=n(13),u=d.FileContent,_=a.STATES;function f(e,t,n){return c.wrapError(c.UNEXPECTED_RESPONSE,e,t,n)}function m(e,t,n){this._session=e,this._callback=t,this._cleanup=n,this._componentsPending=0,this.bytesTransfered=0,this.bytesTotal=0,this.onProgress=p.noOp;var o=this;this._reportProgress=function(e){if(e>0){o.bytesTransfered+=e;var t=o.onProgress;t&&t(o.bytesTransfered,o.bytesTotal)}}}m.prototype._callCallback=function(e,t){var n=this._callback;n&&(this._callback=void 0,n(e,t))},m.prototype._xferComplete=function(e,t){var n=this._cleanup;n?(this._cleanup=void 0,n(e,t)):this._callCallback(e,t)},m.prototype.abort=function(e){this._aborted||(this._aborted=!0,this._session._service.abortAllWithToken(this)),e||(this._callback=void 0,e=new Error("Aborted")),this._xferComplete(e)};var E={};E.pullComposite=function(e,t,n){if(!e.hasLocalStorage)throw new c(c.INVALID_PARAMS,"No local storage. Use AdobeDCXCompositeXfer.pullCompositeManifestOnly() to pull down the composite without local storage.");return this._pullComposite(e,t,"all",n)},E.pullMinimumComposite=function(e,t,n){if(!e.hasLocalStorage)throw new c(c.INVALID_PARAMS,"No local storage. Use AdobeDCXCompositeXfer.pullCompositeManifestOnly() to pull down the composite without local storage.");return this._pullComposite(e,t,"min",n)},E.pullCompositeManifestOnly=function(e,t,n){return this._pullComposite(e,t,"none",n)},E.downloadComponents=function(e,t,n,o){var i=function e(t){return t._owner?e(t._owner):t}(t),r=new m(n,o);return r._referenceBranch=i,E._pullComponents(r,i,e||t.allComponents()),r},E.pushComposite=function(e,t,n,o){var i,r=e._localStorage;(i=new m(n,o,function(t,n){if(i._owner&&e.hasLocalStorage&&r.unregisterInMemoryBranchOrElement(i._owner),!e.hasLocalStorage){var o=i._journal;e._pushJournal=o.isEmpty?void 0:o}i._callCallback(t,n)}))._composite=e,i._overwriteExisting=t;var a=!e.isBound;if(i._compositeIsNew=a,e.hasLocalStorage)e._loadBranch(r.currentManifestPath(),!1,function(t,n){if(t)return i._xferComplete(t);i._owner=n,e._localStorage.registerInMemoryBranchOrElement(n),l.readJournal(r.pushJournalPath(),e,!0,function(t,n){if(t)return i._xferComplete(t);i._journal=n,E._pushComposite(e,i)})});else{if(!e.href)return i._xferComplete(new c(c.INVALID_STATE,"New composite has no href"));i._owner=e.current.copy(),i._journal=e._pushJournal||new l(e),E._pushComposite(e,i)}return i},E.remixComposite=function(e,t,n,o,i,r,a){var s=p.parseURI(n).path;if(!s||!o||s.split("/").pop()!==o)throw new c(c.INVALID_PARAMS,"Invalid combination of params targetHref ("+n+") and compositeId ("+o+")");var l=new m(r,a);return r.remixComposite(e,t,n,o,i,function(e){l._xferComplete(e,e?void 0:n)}).token=l,l},E.uploadNewComponent=function(e,t,n,i,a,s){if(n._localStorage)throw new c(c.INVALID_PARAMS,"For in-browser use only. Use composite.current.addComponent() to add a new component asset");return o(i||p.generateUuid(),t,!0,n.collaborationType===r.COLLABORATION.SHARED_WITH_USER,e,n.id,n.href,a,s)},E.uploadComponent=function(e,t,n,i,a){if(n._localStorage)throw new c(c.INVALID_PARAMS,"For in-browser use only. Use composite.current.updateComponent() to update a component asset");return o(e.id,e.type,!1,n.collaborationType===r.COLLABORATION.SHARED_WITH_USER,t,n.id,n.href,i,a)},E.copyAssetForNewComponent=function(e,t,n,o,a,s){if(n._localStorage)throw new c(c.INVALID_PARAMS,"For in-browser use only. Use composite.current.addComponent() to add a new component asset");return i(o||p.generateUuid(),t,!0,n.collaborationType===r.COLLABORATION.SHARED_WITH_USER,e,n.id,n.href,a,s)},E.getURLForComponent=function(e,t){if(e._owner._localStorage)throw new c(c.INVALID_PARAMS,"For in-browser use only.");return t.getComponentHref(e,e.version)},E._pullComposite=function(e,t,n,o){if("string"!=typeof e.href)throw new c(c.INVALID_STATE,"Composite must have an href");var i;var r=function(o,r){if(o)return i._xferComplete(o);var a;r?(a=r.manifestEtag,i._referenceBranch=r):e.current&&(a=e.current.manifestEtag,i._referenceBranch=e.current);var l=t.getCompositeManifest(e,a,function(t,o,a){if(t)return t.response&&404===t.response.statusCode?i._xferComplete(new c(c.NO_COMPOSITE,"Composite missing or deleted",t.underlyingError||t)):i._xferComplete(t);if(null===o&&!r)return i._xferComplete(void 0,null);var l;if(null!==o)try{if((l=(new s).parse(o))._localStorage=e._localStorage,l.compositeHref=e.href,l._collaborationType=e.collaborationType,l._clientDataString=e.clientDataString,l.manifestEtag=a,l.compositeState===_.committedDelete||l.compositeState===_.pendingDelete)return void i._session.deleteCompositeDirectory(e,function(e){return e?i._xferComplete(new c(c.DELETED_COMPOSITE,"Error deleting composite directory",e)):i._xferComplete(new c(c.DELETED_COMPOSITE,"Composite is deleted"))});i._referenceBranch&&l.hasLocalStorage&&l._updateLocalDataFromBranch(i._referenceBranch)}catch(e){return i._xferComplete(new c(c.INVALID_JSON,"Corrupted manifest",e))}else l=r;var d,p,h=l.allComponents();for(d=0;d<h.length;++d)(p=h[d]).state===_.pendingDelete||p.state===_.committedDelete?l.removeComponent(p):p.state=_.unmodified;h=void 0,"all"===n?h=l.allComponents():"min"===n&&(p=l.getComponentWithAbsolutePath("/META-INF/metadata.xml"))&&(h=[p]),h?E._pullComponents(i,l,h):i._xferComplete(void 0,l)});l&&(l.token=i,l.progress=i._reportProgress)};return(i=new m(t,o,function(t,n){if(t){var o=t.pulledBranch;o?(o.compositeState=_.unmodified,o.hasLocalStorage?h.writeFileAtomically(e._localStorage.pulledManifestPath(),t.pulledBranch.localData,"utf8",function(){i._callCallback(t)}):i._callCallback(t)):i._callCallback(t)}else{if(null===n)return i._callCallback(void 0,null);if(n.compositeState=_.unmodified,n.readOnly=!0,n.hasLocalStorage){var r=e._localStorage.pulledManifestPath();h.writeFileAtomically(r,n.localData,"utf8",function(e){if(e)return i._callCallback(e);n.manifestPath=r,n._isDirty=!1,i._callCallback(void 0,n)})}else e._options.xhrBaseBranchSupport&&(e._pulledBranchData=n.localData),i._callCallback(void 0,n)}}))._composite=e,e.hasLocalStorage?e.loadPulledBranch(r):r(),i},E._pullComponents=function(e,t,n){if(!t.hasLocalStorage)throw new c(c.INVALID_PARAMS,"No local storage.");var o,i=e._session;function r(o,i){if(e._componentsPending-=1,o&&(e.failedComponents=e.failedComponents||[],e.failedComponents.push({component:i,error:o})),0===e._componentsPending&&!e._aborted){var r=e.failedComponents;if(r){o=new c(c.COMPONENT_DOWNLOAD_ERROR,"Failed to download all components");var a,s=r.length;for(a=0;a<s;a++){var l=r[a].error;if(l.code===c.OUT_OF_SPACE){o=new c(l.code,l.message);break}}o.pulledBranch=t,o.failedComponents=r}t.readOnly&&t.manifestPath&&(!r||n.length>r.length)?h.writeFileAtomically(t.manifestPath,t.localData,"utf8",function(n){o=o||n,e._xferComplete(o,o?void 0:t)}):e._xferComplete(o,o?void 0:t)}}function a(t){if(!e._aborted){e.bytesTotal+=t.length||0;var n=t._owner._localStorage.tempPathForComponent(t),o=p.parentDirectory(n);h.ensureDirectoryExists(o,function(o){if(o)return e.abort(o);var a=E._pullComponent(t,n,i,r);a.progress=e._reportProgress,a.token=e})}}function s(e){t.assetOfComponent(e,function(t,n){"string"!=typeof n?a(e):r(void 0,e)})}for(e._componentsPending=n.length,o=0;o<n.length;++o){var l,d=n[o];if(e._referenceBranch){var u=e._referenceBranch.getComponentWithId(d.id);u&&(l=u.etag)}d.etag!==l?a(d):s(d)}0===e._componentsPending&&e._xferComplete(void 0,t)},E._pullComponent=function(e,t,n,o){var i=e._owner;if(!e._owner.hasLocalStorage)throw new c(c.INVALID_PARAMS,"No local storage. Use AdobeDCXCompositeXfer.pullCompositeManifestOnly() to pull down the composite without local storage.");return n.getComponent(e,new u(t),function(n,r){if(n)o(n,e);else if(200===r.statusCode){var a=Number(r.headers["content-length"]);e.length&&!isNaN(a)&&a!==e.length?o(new c(c.UNEXPECTED_RESPONSE,"Incorrect content length",n,r)):i._localStorage.ingestComponentAsset(e,t,!1,i._local(),function(t){o(t,e,r.headers.etag)})}else 304===r.statusCode?o(void 0,e,r.headers.etag):o(f("Unexpected response getting a component",n,r),e)})},E._pushComposite=function(e,t){if(!e.href)return t._xferComplete(new c(c.INVALID_STATE,"New composite has no href"));var n=t._owner,o=t._journal,i=t._compositeIsNew,a=t._overwriteExisting,s=t._session,l=n.changeCount,d=n.remoteData.length+50;if(t.bytesTotal=d,n.compositeState===_.committedDelete)return t._xferComplete(new c(c.DELETED_COMPOSITE,"Attempt to push a deleted composite"));if("archived"===n.compositeArchivalState)return t._xferComplete(new c(c.DELETED_COMPOSITE,"Attempt to push an archived composite"));var p="pending"===n.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(!i&&!p&&n.compositeState===_.unmodified)return t._xferComplete();if(n.compositeState===_.pendingDelete)return i&&!a?t._xferComplete(new c(c.DELETED_COMPOSITE,"Attempt to delete unbound composite")):e.collaborationType===r.COLLABORATION.SHARED_WITH_USER?t._xferComplete(new c(c.INVALID_STATE,"Attempt to delete composite that is shared with this user.")):E._deleteComposite(t,a,function(e,n){t._xferComplete(e,n)});function u(n,o){p?s.archiveCompositeDirectory(e,function(i){if(i)return o(i);n.compositeArchivalState="archived",t._journal.compositeHasBeenArchived=!0,t._journal.commitChanges(function(t){if(t)return o(t);e.hasLocalStorage?h.writeFileAtomically(e._localStorage.pushedManifestPath(),n.localData,"utf8",function(e){if(e)return o(e);o(void 0,n)}):o(void 0,n)})}):o(void 0,n)}function m(n){if(i)return t._xferComplete(n);var o=s.getCompositeManifestHref(e);s.headRequest(o,function(e,o){return e?t._xferComplete(e):404===o.statusCode?(n=new c(c.NO_COMPOSITE,"Composite does not exist; may have been deleted"),t._xferComplete(n)):t._xferComplete(n)})}!function(e,t,n,o,i){function r(e){e||(t.compositeHasBeenCreated=!0);var n,o=t._compositeCreationCallbacks,i=o.length;for(n=0;n<i;n++)try{o[n](e)}catch(e){}t._compositeCreationCallbacks=void 0}e.isBound||t.compositeHasBeenCreated?i():t._compositeCreationCallbacks?t._compositeCreationCallbacks.push(i):(t._compositeCreationCallbacks=[i],o.createCompositeDirectory(e,n,function(t,i){if(t){if(t.code!==c.ALREADY_EXISTS)return r(f("Unexpected response creating a composite directory",t,i));if(n)r();else{var a=o.getCompositeManifestHref(e);o.headRequest(a,function(e,t){return e?r(e):404!==t.statusCode?r(e=new c(c.ALREADY_EXISTS,"Composite already exists and overwriteExisting not specified")):void r()})}}else r()}))}(e,o,a,s,function(i){if(i)return t._xferComplete(i);E._pushComponents(t,n,function(){var r=t.failedComponents;if(r){i=new c(c.COMPONENT_UPLOAD_ERROR,"One or more components failed to upload.");var p,f=r.length;for(p=0;p<f;p++){var E=r[p].error;if(E.code===c.EXCEEDS_QUOTA){i=new c(E.code,E.message);break}}return i.failedComponents=r,m(i)}if(n.compositeState===_.modified){n.compositeState=_.unmodified,o.manifestEtag&&o.currentBranchEtag===n.manifestEtag&&(n.manifestEtag=o.manifestEtag);var g=n.remoteData;t.bytesTotal+=g.length,t.bytesTotal-=d;var y=s.updateManifest(n,g,a,function(i,r){if(i)return m(i);var a=r.headers.etag;o.manifestEtag=a,o.currentBranchEtag=n.manifestEtag,o.changeCount=l,o.commitChanges(function(i){if(i)return t._xferComplete(i);o.applyToBranch(n),n.compositeState=_.unmodified,e.hasLocalStorage?h.writeFileAtomically(e._localStorage.pushedManifestPath(),n.localData,"utf8",function(e){if(e)return t._xferComplete(e);n._isDirty=!1,u(n,function(e,n){t._xferComplete(e,n)})}):(e._options.xhrBaseBranchSupport&&(e._pushedBranchData=n.localData),u(n,function(e,n){t._xferComplete(e,n)}))})});y&&(y.progress=t._reportProgress,y.token=t)}else u(n,function(e,n){t._xferComplete(e,n)})})})},E._deleteComposite=function(e,t,n){var o=e._composite,i=e._owner,r=e._session;i.compositeState=_.committedDelete;var a=i.remoteData;e.bytesTotal=a.length,e._journal.manifestEtag&&e._journal.currentBranchEtag===i.manifestEtag&&(i.manifestEtag=e._journal.manifestEtag),r.updateManifest(i,a,t,function(t){if(t)return n(t);r.deleteCompositeDirectory(o,function(t){if(t)return n(t);e._journal.compositeHasBeenDeleted=!0,e._journal.commitChanges(function(e){if(e)return n(e);o.hasLocalStorage?h.writeFileAtomically(o._localStorage.pushedManifestPath(),i.localData,"utf8",function(e){if(e)return n(e);n(void 0,i)}):n(void 0,i)})})})},E._pushComponents=function(e,t,n){var o,i=t.allComponents(),a=e._composite,s=a._localStorage,l={},d=e._journal;function f(t,o,i){o?l[t.id]=o:delete l[t.id],i&&(e.failedComponents=e.failedComponents||[],e.failedComponents.push({component:t,error:i})),0===Object.keys(l).length&&d.commitChanges(n)}function m(t,n,o){f(t,"uploading"),h.info(n,function(i,s){if(i)return i=new c(c.INVALID_STATE,"Component asset missing",i),void f(t,null,i);var l=s.size,h=p.filePathComponents(n).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=_.unmodified,void f(t,null);e.bytesTotal+=l;var E=e._session.uploadComponent(t,o,a.collaborationType===r.COLLABORATION.SHARED_WITH_USER,e,new u(n),function(e,n,o){if(!e){var i=n.headers.etag,r=n.headers["x-latest-version"],a=o.md5;i||(e=new c(c.UNEXPECTED_RESPONSE,"No etag")),r||(e=new c(c.UNEXPECTED_RESPONSE,"No version")),a||(e=new c(c.UNEXPECTED_RESPONSE,"No md5")),e||(t.etag=i,t.version=r,t.md5=a,t.length=l,t.state=_.unmodified,d.recordUploadedComponent(t.id,i,r,a,l,h),d.commitChanges())}f(t,null,e)});E&&(E.progress=e._reportProgress,E.token=e)})}function E(n,o,i){var l=d.getRecordForUploadedComponent(n.id);if(l&&l["source-href"]===o)return n.etag=l.etag,n.version=l.version,n.md5=l.md5,n.length=l.length,void(n.state=_.unmodified);f(n,"copying");var p=e._session.copyAssetToComponentId(n.id,n.type,e._composite.href,i,a.collaborationType===r.COLLABORATION.SHARED_WITH_USER,e,o,function(e,r,a){if(e){if(s){var l=s.componentAssetPath(n,t._local());if("string"==typeof l)return m(n,l,i)}}else{var p=r.headers.etag,h=r.headers["x-latest-version"],u=a.md5,E=a.size;p||(e=new c(c.UNEXPECTED_RESPONSE,"No etag")),h||(e=new c(c.UNEXPECTED_RESPONSE,"No version")),u||(e=new c(c.UNEXPECTED_RESPONSE,"No md5")),E||(e=new c(c.UNEXPECTED_RESPONSE,"No length")),e||(n.etag=p,n.version=h,n.md5=u,n.length=E,n.state=_.unmodified,d.recordUploadedComponent(n.id,p,h,u,E,void 0,o),d.commitChanges())}f(n,null,e)});p&&(p.progress=e._reportProgress,p.token=e)}for(o=0;o<i.length;++o){var g=i[o],y=g.state,v=!g.etag;if(y||(y=_.unmodified),v||y===_.modified){var A=t._core._getSourceHrefOfComponent(g);if(t.hasLocalStorage||A){var C=v||e._compositeIsNew;if(A)E(g,A,C);else{var S=s.componentAssetPath(g,t._local());"string"==typeof S&&m(g,S,C)}}else{var I=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:I})}}else y===_.unmodified?d.removeRecordForUploadedComponent(g.id):y!==_.committedDelete&&y!==_.pendingDelete||t.removeComponent(g)}0===Object.keys(l).length&&n()},o=function(e,t,n,o,i,r,s,l,d){if("function"!=typeof d)throw new c(c.INVALID_PARAMS,'Param "callback" must be a function.');var p=i.length||i.byteLength||i.size,h=new m(l,d);h.bytesTotal=p;var u=l.uploadAssetForComponentId(e,t,s,n,o,h,i,function(n,o,i){var s;if(!n)try{s=new a._UploadResults(r),p=p||u.bytesSent,s.records[e]=function(e,t,n,o,i){if("number"!=typeof t)throw new c(c.UNEXPECTED_RESPONSE,"No length");var r=o.headers.etag,s=o.headers["x-latest-version"],l=i.md5;if(!r)throw new c(c.UNEXPECTED_RESPONSE,"No etag");if(!s)throw new c(c.UNEXPECTED_RESPONSE,"No version");if(!l)throw new c(c.UNEXPECTED_RESPONSE,"No md5");return new a._UploadRecord(e,r,s,l,t,n)}(e,p,t,o,i)}catch(e){n=e,s=void 0}h._xferComplete(n,s)});return u&&(u.progress=h._reportProgress,u.token=h),h},i=function(e,t,n,o,i,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,n,o,p,i,function(n,o,i){if(!p._aborted){var s;if(!n)try{(s=new a._UploadResults(r)).records[e]=function(e,t,n,o){var i=o.headers.etag,r=o.headers["x-latest-version"],s=t.md5,l=t.size;if("number"!=typeof l)throw new c(c.UNEXPECTED_RESPONSE,"No length");if(!i)throw new c(c.UNEXPECTED_RESPONSE,"No etag");if(!r)throw new c(c.UNEXPECTED_RESPONSE,"No version");if(!s)throw new c(c.UNEXPECTED_RESPONSE,"No md5");return new a._UploadRecord(e,i,r,s,l,n)}(e,i,t,o)}catch(e){n=e,s=void 0}d(n,s)}});return h&&(h.progress=p._reportProgress,h.token=p),p},e.exports=E},function(e,t,n){var o=n(25),i=n(33),r=n(4),a=n(7),s=n(13);let c,l;c=n(56),l=n(57);var d={isSnapshot:function(e,t){var n,o=!1,i=function(e,i){o||(o=!0,n&&n.isOpen&&n.close(),t(e,i))};l.open(e,{lazyEntries:!0},function(e,t){e?-1!==["EPERM","EACCES","ENOENT"].indexOf(e.code)?i(e):i(new r(r.INVALID_DATA,"Error while opening snapshot: "+e)):((n=t).on("entry",function(e){"mimetype"===e.fileName?n.openReadStream(e,function(e,t){if(e)i(e);else{var n=[];t.on("data",function(e){n.push(e)}),t.on("error",function(e){i(e)}),t.on("end",function(){var e=Buffer.concat(n).toString();e&&u(e,"dcxucf")?i(null,!0):i(null,!1)})}}):i(null,!1)}).on("error",function(e){i(e)}),n.readEntry())})},importSnapshot:function(e,t,n,i,r,a){return this.importSnapshotToDirectory(e,t,n,i,r,function(e,t){if(e)a(e);else try{var n=new o(null,null,t,null,null,null);n.loadCurrentFromLocalStorage(function(e){a(e,e?void 0:n)}),n.deleteTempFiles()}catch(e){a(e)}})}};d.importSnapshotToDirectory=function(e,t,n,o,c,d){var p,h,_,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)}},S={},I={};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,o))if(1===g)"mimetype"===e.fileName?p.openReadStream(e,function(e,t){if(e)C(e);else{var n=[];t.on("data",function(e){n.push(e)}),t.on("error",function(e){C(e)}),t.on("end",function(){var e=Buffer.concat(n).toString();e&&u(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 n=[];t.on("data",function(e){n.push(e)}),t.on("error",function(e){C(e)}),t.on("end",function(){var e=Buffer.concat(n).toString();if(e){if(h=JSON.parse(e),(_=new i(h))._resetIdentity(),o){var t=_.getComponentWithAbsolutePath("/META-INF/metadata.xml");t&&_.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 n=t+"/"+m+"/components";s.ensureDirectoryExists(n,function(t){t?C(t):p.openReadStream(e,function(t,o){if(t)C(t);else{var i=a.generateUuid(),r=e.fileName.split("/"),l=r[r.length-1].split(".");l&&(i=i+"."+l[l.length-1]),S["/"+e.fileName]=i,o.on("end",function(){p.readEntry()}),o.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(n+"/"+i))}})})}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(S).forEach(function(e){var t=_.getComponentWithAbsolutePath(e);t&&(I[t.id]=S[e])}),h.local||(h.local={}),h.local["copyOnWrite#storageIds"]=I,n&&(h.local.compositeHref=n.endsWith("/")?n+h.id:n+"/"+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,n,o,i){var l,d,h=!1,_=function(e){if(!h){if(h=!0,e)return void s.deleteFile(d,()=>i(e));s.move(d,t,!1,e=>i(e||null))}};try{d=t.replace(/([^\\/]+)$/,"."+a.generateUuid()+"_$1"),l=s.createWriteStream(d)}catch(e){return void _(e)}var f,m=new c.ZipFile;if(e.type&&u(e.type,"dcx")){f=e.type+"ucf",m.addBuffer(new Buffer(f),"mimetype",{compress:!1});var E=p(e.current,n),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,S=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 n=e.path+"/components/"+t.path;g(t.type)?m.addFile(n,t.absolutePath,{compress:!0}):m.addFile(n,t.absolutePath,{compress:!1})}),m.end(),m.on("error",function(){_(new r(r.INVALID_DATA,"Missing component file locally."))}),m.outputStream.on("error",function(e){_(C?new r(r.UNEXPECTED,"Export cancelled"):e)}).on("data",function(e){S+=e.length,C||o(Math.min(100,Math.round(100*S/v)))}).pipe(l).on("close",function(){_(C?new r(r.UNEXPECTED,"Export cancelled"):null)}).on("error",function(e){_(e)}),function(){C||(C=!0,m.outputStream.end())}}_(new r(r.INVALID_PARAMS,"Invalid composite type"))};var p=function(e,t){var n=JSON.parse(e.localData);t&&t(n);var o=h(n,n.local["copyOnWrite#storageIds"]||{});return delete n.local,delete n.manifestEtag,n.state="unmodified",{manifest:n,lengths:o.lengths,componentMap:o.componentMap,components:o.components}},h=function(e,t,n,o,i){return i=i||[],n=n||{},o=o||{total:0},e.components&&e.components.forEach(function(e){n[e.id]=t[e.id];var r=e.length||1e5;o[e.id]=r,o.total+=r,e.state="unmodified",delete e.version,delete e.md5,delete e.etag,i.push(e)}),e.children&&e.children.forEach(function(e){h(e,t,n,o,i)}),{lengths:o,componentMap:n,components:i}},u=function(e,t){var n=e.split("/");if(2===n.length){var o=n[1];if(o.length<t.length+2)return!1;if(o.substring(o.length-t.length)!==t)return!1;var i=o.length-(t.length+1);return"+"===o.charAt(i)}return!1},_=/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}\.[^/\\]+$/i,f=function(e,t){if("mimetype"===e.fileName||"manifest"===e.fileName)return!0;var n=e.fileName.split("/");if(n){var o=n[n.length-1];return!t&&"metadata.xml"===o||o.match(_)}return!1},m=["text/"],E=["+json","+xml"],g=function(e){return m.forEach(function(t){if(e.startsWith(t))return!0}),E.forEach(function(t){if(e.endsWith(t))return!0}),!1};e.exports=d},function(e,t){e.exports=require("yazl")},function(e,t){e.exports=require("yauzl")},function(e,t,n){var o=n(4),i=n(71),r=n(96),a=n(0),s=n(18),c=n(2),l=n(1),d=n(19),p=n(12),h=n(21),u=n(16),_=n(15),f=n(11),m=n(8),E=n(9),g=n(27),y=n(5),v=n(99);function A(e,t,n){(this._collection=e,this._dcxComposite=t,this._dcxBranch=t.current,this._listenerManager=new y(["change"]),n?(this._publicId=n,this._writable=!1):this._writable=!0,this._filterCache={},this._renditionCache=new v(this),this._autoGCMode={},this._transactionCount=0,this._commitInProgress=!1,this._pendingCommit=!1,this._onCommitCallbacks=[],this._dcxLock=new h,this._networkLock=new h,this._syncState=void 0,this._deletedLocally=!1,this._deletedFromServer=!1,this._waitForSyncToFinishCallbacks=[],this._errors=[],this._pushFailedDueToQuota=!1,this._numUpdateConflicts=0,this._numActiveCopyNodeOperations=0,this._pendingCopyNodeOperations=[],this._dcxBranch.getChildrenOf().forEach(function(e){e.name===a.ELEMENTS_NAME&&(this._dcxElementsNode=e),e.name===a.REMOVED_ELEMENTS_NAME&&(this._dcxRemovedElementsNode=e),e.name===a.GROUPS_NAME&&(this._dcxGroupsNode=e)},this),this._dcxElementsNode||(this._dcxElementsNode=this._dcxBranch.addChild(a.ELEMENTS_NAME)),this._dcxCompositeRenditionMap=_.getCompositeRenditionMap(this._dcxBranch),this._elements=[],this._removedElements=[],this._groups=[],this._dcxBranch.getChildrenOf(this._dcxElementsNode).forEach(function(e){var t=new r(this,e);this._addElementToFilter(t),this._elements.push(t)},this),this._dcxRemovedElementsNode)&&(this._dcxBranch.getChildrenOf(this._dcxRemovedElementsNode).forEach(function(e){var t=new r(this,e);this._removedElements.push(t)},this),this._sortRemovedElements());this._dcxGroupsNode&&this._dcxBranch.getChildrenOf(this._dcxGroupsNode).forEach(function(e){var t=new i(this,e);this._groups.push(t)},this);l.hasFileSystem()||(this._dcxBaseBranch=this._dcxBranch.copy())}A.prototype._getRemovedElementsNode=function(){return this._dcxRemovedElementsNode||(this._dcxRemovedElementsNode=this._dcxBranch.addChild(a.REMOVED_ELEMENTS_NAME)),this._dcxRemovedElementsNode},A.prototype._getGroupsNode=function(){return this._dcxGroupsNode||(this._dcxGroupsNode=this._dcxBranch.addChild(a.GROUPS_NAME)),this._dcxGroupsNode},A.prototype._markDeletedLocally=function(e){this._deletedLocally=e,this._elements.forEach(function(t){t._markDeletedLocally(e)}),this._groups.forEach(function(t){t._markDeletedLocally(e)}),e&&this._listenerManager.removeAll()},A.prototype._removeAllListeners=function(){this._listenerManager.removeAll(),this._elements.forEach(function(e){e._removeAllListeners()})},A.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())}},A.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},A.prototype._doCommit=function(e){var t=this;function n(n){var o=t._onCommitCallbacks;t._onCommitCallbacks=[],o.forEach(function(e){e.waitForSuccess&&!n?t._onCommitCallbacks.push(e):t._waitForCommit(e.callback)}),function(){if(e&&!a.SHARED_LOCAL_STORAGE){if(t._deletedLocally)return;t._collection._clearSyncErrors(),t._push(),t._collection._resetPollBackoff()}}()}l.hasFileSystem()?this._commitInProgress?this._pendingCommit=!0:(this._commitInProgress=!0,l.storageInterface.commitManifest(this,(o,i)=>{!function(e,n){e&&(e=f.getCommitError(e,t.id,n)),t._collection._reportCommitError(e)}(o,"Failed to write composite to disk"),this._commitInProgress=!1,this._pendingCommit?(this._pendingCommit=!1,0===this._transactionCount&&this._doCommit(e)):n(i)})):n()},A.prototype._waitForCommit=function(e,t){this._commitInProgress||this._transactionCount>0?this._onCommitCallbacks.push({callback:e,waitForSuccess:t}):this._renditionCache._waitForCommit(e)},A.prototype._notifyChange=function(){this._listenerManager.notify("change"),this._collection._notifyChange()},A.prototype._commit=function(e,t){0===this._transactionCount&&(t||(this._updateModifiedTime(),this._notifyChange()),this._doCommit(!e))},A.prototype._wrapOperation=function(e,t){var n;this._beginOperation();try{n=e.call(t)}catch(e){throw this._transactionCount--,e}return this._endOperation(),n},A.prototype._beginOperation=function(){this._transactionCount++},A.prototype._endOperation=function(){this._transactionCount--,this._commit()},A.prototype._updateModifiedTime=function(){var e=(new Date).valueOf();this._dcxBranch.rootNode.setValue(a.MODIFIED_KEY,e)},A.prototype._updateCreatedTime=function(){var e=(new Date).valueOf();this._dcxBranch.rootNode.setValue(a.CREATED_KEY,e),this._dcxBranch.rootNode.setValue(a.MODIFIED_KEY,e)},A.prototype._getMissingLocalComponents=function(){var e=[];return this._elements.forEach(function(t){e=e.concat(t._getMissingLocalComponents())}),e},A.prototype._gcLocalData=function(e){var t=[],n={},o=[];if(this._removedElements.forEach(function(e){e._shouldGCLocalData()&&(t.push(e),e._forEachRepresentation(function(e){var t=e._dcxComponent,i=e._getCurrentComponentPath();t&&i&&t.etag&&"modified"!==t.state?(n[i]=n[i]||[],n[i].push(t.id)):i&&o.push(i)}))}),0!==t.length){o.forEach(function(e){delete n[e]}),this._elements.forEach(function(e){e._forEachRepresentation(function(e){var t=e._getCurrentComponentPath();t&&delete n[t]})});var i=[];Object.keys(n).forEach(function(e){i.push.apply(i,n[e])}),t.forEach(e=>this._renditionCache.clearCache(e)),l.log("Removing local files for components: [ "+i.join(", ")+" ]"),this._dcxComposite.removeLocalFilesForComponentsWithIDs(i,e)}else e(null)},A.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},A.prototype._setRenditionFromPath=function(e,t,n,o){if(!_.checkDeletedState(this,o)){var i=this._dcxCompositeRenditionMap[e],r=this,s=t&&l.getFileNameFromPath(t),c=m.getFileExtension(s),d=l.uuid()+"."+c;m.checkFileSize(t,function(c){c?o(c):l.storageInterface.notifyStartWrite(r,[],function(){r._dcxBranch.addComponent(s,n,"rendition",d,t,!0,void 0,r._dcxBranch.rootNode,void 0,function(t,n){t?o(t):_.checkDeletedState(r,o)||(n.setValue(a.MODIFIED_KEY,(new Date).valueOf()),n.setValue(a.RENDITION_TYPE_KEY,e),i&&r._dcxBranch.removeComponent(i),r._dcxCompositeRenditionMap=_.getCompositeRenditionMap(r._dcxBranch),r._commit(),o(null))})})})}},A.prototype._setRendition=function(e,t,n,o,i){var r,a=l.fs,s=this;function c(t){t?i(f.getCommitError(t,s.id,"error writing library rendition")):_.checkDeletedState(s,i)||s._setRenditionFromPath(e,r,o,i)}var d=this.collection._getTempDir();m.ensurePathExists(d,function(e){if(e)i(f.getCommitError(e,s.id,"error creating temp directory"));else if(!_.checkDeletedState(s,i)){var p=g.getExtensions(o)[0],h=l.uuid()+"."+p;r=d+l.getPathSeparator()+h,"buffer"===n?a.writeFile(r,t,c):a.writeFile(r,t,n,c)}})},A.prototype._setRenditionInBrowser=function(e,t,n,o){var i=this,r=this._dcxCompositeRenditionMap[e],s=this._collection._syncManager,c=l.uuid();s.uploadNewComponentForLibrary(t,c,n,"rendition",this,function(t,n){t?o(t):_.checkDeletedState(i,o)||(n.setValue(a.MODIFIED_KEY,(new Date).valueOf()),n.setValue(a.RENDITION_TYPE_KEY,e),r&&i._dcxBranch.removeComponent(r),i._dcxCompositeRenditionMap=_.getCompositeRenditionMap(i._dcxBranch),i._commit(),o(null))})},A.prototype._getFilterKey=function(e){return e&&-1!==a.ELEMENT_TYPE_FILTERS.indexOf(e)?e:"*"},A.prototype._removeElementFromFilter=function(e){var t=this._getFilterKey(e.type);if(this._filterCache[t]){var n=this._filterCache[t].indexOf(e);-1!==n&&this._filterCache[t].splice(n,1)}},A.prototype._addElementToFilter=function(e){var t=this._getFilterKey(e.type);this._filterCache[t]=this._filterCache[t]||[],this._filterCache[t].push(e)},A.prototype._doCreateGroup=function(e,t,n){var o=this._getGroupsNode(),r=this._dcxBranch.addChild(e,void 0,void 0,o);r.type=a.GROUP_TYPE,r.setValue(a.CLASSIFIER_KEY,n),r.setValue(a.ORDER_KEY,t);var s=new i(this,r);return s._updateCreatedTime(),this._groups.push(s),s},A.prototype._doRemoveGroup=function(e,t){var n=this._groups.indexOf(e);this._groups.splice(n,1),this.elements.slice().forEach(n=>{void 0!==n.getOrderInGroup(e)&&(n._doSetOrderInGroup(e,void 0,!0),t&&t(n))}),this._dcxBranch.removeChild(e._dcxNode),e._markDeletedLocally(!0)},A.prototype._getNumberOfElementsInGroup=function(e){if(e){var t=0;return this.elements.forEach(function(n){void 0!==n.getOrderInGroup(e)&&t++}),t}},A.prototype._doCopyGroup=function(e,t,n,o,i){var r=e.library!==t&&t._groups.every(function(t){return t.id!==e.id})?e.id:l.uuid();this._doCopyDCXGroup(e,t,n,o,r,i)},A.prototype._doCopyDCXGroup=function(e,t,n,o,r,a){var c=this;t._beginOperation(),o&&c._beginOperation();var d=function(e){t._endOperation(),o&&c.endOperation(),a(e)};l.storageInterface.notifyStartWrite(t,[this],function(){var l=t._getGroupsNode();t._dcxBranch.copyChild(e._dcxNode,l,void 0,r,r,function(r,l){if(!_.checkDeletedState(c,a))if(r)d(r);else{var h=new i(t,l);t._groups.push(h);var u=function(){_.checkDeletedState(c,a)||(t._endOperation(),o&&(c._doRemoveGroup(e),c.endOperation()),a(null,h))};if(n){var f=c.elements.filter(function(t){return void 0!==t.getOrderInGroup(e)}),m=new p;f.forEach(function(e){m.addOperation(c._doCopyElement,[e,t,o],c)}),m.run(function(t,n,o){if(t)d(t);else try{f.forEach(function(t,n){var i=t.getOrderInGroup(e),r=o[n];r._doSetOrderInGroup(h,i,!0),s.reportCopyElement(r,t)}),u()}catch(e){d(e)}})}else u()}})})},A.prototype._doCreateElement=function(e,t){var n=this._dcxBranch.addChild(e,void 0,void 0,this._dcxElementsNode);n.path=n.id,n.type=t;var o=new r(this,n);return o._updateCreatedTime(),this._elements.push(o),this._addElementToFilter(o),o},A.prototype._doRemoveElement=function(e,t){var n=this._elements.indexOf(e);-1!==n&&this._elements.splice(n,1),-1!==(n=this._removedElements.indexOf(e))&&this._removedElements.splice(n,1),this._removeElementFromFilter(e),t&&this._dcxBranch.removeChild(e._dcxNode),e._markDeletedLocally(!0)},A.prototype._ensureRemovedElementsSpace=function(){for(;this.removedElements.length>=a.MAX_REMOVED_ELEMENTS;)this._doRemoveElement(this.removedElements[0],!0)},A.prototype._sortRemovedElements=function(){this._removedElements.sort(function(e,t){return e.removed-t.removed})},A.prototype._doMarkElementRemoved=function(e,t){var n=this._elements.indexOf(e);-1!==n&&(this._ensureRemovedElementsSpace(),this._elements.splice(n,1),this._removeElementFromFilter(e),this._removedElements.push(e),this._sortRemovedElements(),t&&(e._dcxNode=this._dcxBranch.moveChild(e._dcxNode,void 0,this._getRemovedElementsNode()),e._updateTimestampOnRemove()))},A.prototype._doRestoreElement=function(e,t){var n=this._removedElements.indexOf(e);-1!==n&&(this._removedElements.splice(n,1),this._elements.push(e),this._addElementToFilter(e),t&&(e._dcxNode=this._dcxBranch.moveChild(e._dcxNode,void 0,this._dcxElementsNode),e._updateTimestampOnRestore(),e._stripObsoleteGroupsData()))},A.prototype._doCopyDCXNode=function(e,t,n,o,i){var r=this;if(this._numActiveCopyNodeOperations<a.MAX_DCX_CONCURRENT_COPIES)return this._numActiveCopyNodeOperations++,void e.copyChild(t,n,void 0,o,o,function(e,t){r._numActiveCopyNodeOperations--,i(e,t),r._pendingCopyNodeOperations.length>0&&r._pendingCopyNodeOperations.shift()()});this._pendingCopyNodeOperations.push(function(){r._doCopyDCXNode(e,t,n,o,i)})},A.prototype._doCopyDCXElement=function(e,t,n,o,i){var a=this;t._beginOperation(),l.storageInterface.notifyStartWrite(t,[this],function(){a._doCopyDCXNode(t._dcxBranch,e._dcxNode,t._dcxElementsNode,o,function(o,s){if(!_.checkDeletedState(a,i)){if(o)return t._endOperation(),void i(o);var c=new r(t,s);t._addElementToFilter(c),t._elements.push(c),c._stripObsoleteGroupsData();var d=function(){_.checkDeletedState(a,i)||(t._endOperation(),n&&a._wrapOperation(function(){a._doRemoveElement(e,!0)}),i(null,c))};l.hasFileSystem()?a._renditionCache.copyCache(e,c).then(d,d):d()}})})},A.prototype._doCopyElement=function(e,t,n,o){if(t._elements.length>=a.MAX_ELEMENTS)o(new c(c.EXCEEDS_MAX_LIBRARY_SIZE,"Library cannot have more than "+a.MAX_ELEMENTS+" elements",this.id));else{var i=e.id;t._elements.every(function(e){return e.id!==i})&&t._removedElements.every(function(e){return e.id!==i})||(i=l.uuid()),this._doCopyDCXElement(e,t,n,i,o)}},A.prototype.jasmineToString=function(){return this.toString()},A.prototype._setSyncState=function(e){this._syncState!==e&&(this._syncState=e,this._collection._updateSyncState(),this._checkSyncFinishedAndNotify())},A.prototype._isSyncing=function(){return void 0!==this._syncState},A.prototype._checkSyncFinishedAndNotify=function(){if(!this._isSyncing()){var e=this._waitForSyncToFinishCallbacks;this._waitForSyncToFinishCallbacks=[],e.forEach(function(e){e()})}},A.prototype._waitForSyncToFinish=function(e){this._waitForSyncToFinishCallbacks.push(e),this._checkSyncFinishedAndNotify()},A.prototype._getClientData=function(){var e={};if(this._dcxComposite.clientDataString)try{e=JSON.parse(this._dcxComposite.clientDataString)}catch(e){}return e},A.prototype._getClientDataValue=function(e){return this._getClientData()[e]},A.prototype._setClientDataValue=function(e,t){var n=this._getClientData();n[e]=t,this._dcxComposite.clientDataString=JSON.stringify(n)},A.prototype._setCollaboration=function(e){var t=e&&e.collaboration&&e.collaboration.toLowerCase(),n=e&&e.collaboration_role&&e.collaboration_role.toLowerCase(),o=this._getClientDataValue(a.DATA_COLLABORATION_ROLE);if(this.collaboration!==t||o!==n){var i=_.collaborationStateToDCX(t);this._dcxComposite.collaborationType=i,this._setClientDataValue(a.DATA_COLLABORATION_ROLE,n),this._commit(!0,!0),this._notifyChange(),this._revertLocalChangesIfNecessary()}},A.prototype._isDeletedError=function(e){var t=e&&(e.code===o.NO_COMPOSITE||e.code===o.DELETED_COMPOSITE),n=e&&e.code===o.UNEXPECTED_RESPONSE&&e.response&&401===e.response.statusCode;return t||this.collection.isPublic&&n},A.prototype._isAlreadyExistsError=function(e){var t=e&&e.code===o.ALREADY_EXISTS,n=e&&e.code===o.UNEXPECTED_RESPONSE&&e.response&&409===e.response.statusCode;return t||n},A.prototype._isReadOnlyError=function(e){if("incoming"!==this.collaboration)return!1;var t=!1;return!e||e.code!==o.COMPONENT_UPLOAD_ERROR&&e.code!==o.UNEXPECTED_RESPONSE||(e.code===o.UNEXPECTED_RESPONSE&&e.response&&403===e.response.statusCode&&(t=!0),e.code===o.COMPONENT_UPLOAD_ERROR&&Array.isArray(e.failedComponents)&&e.failedComponents.length>0&&(t=!0,e.failedComponents.forEach(function(e){e.error&&e.error.code===o.UNEXPECTED_RESPONSE&&e.error.response&&403===e.error.response.statusCode||(t=!1)}))),t},A.prototype._mergeAndSwitchToBranch=function(e,t,n){var o=this,c=void 0!==t,d=e.localData;function h(t,h){if(_.checkDeletedState(o,n))return;if(t)return void n(f.getCommitError(t,o.id));l.log("Starting merge "+(c?"(local)":"(remote)"));const m={},E=e=>m[e]=(m[e]||0)+1;h.name!==o.name&&(e.name=o.name);var g=e.rootNode.getValue(a.MODIFIED_KEY),y=Math.max(g||0,o.modified||0);h!==o._dcxBranch&&y&&g!==y&&e.rootNode.setValue(a.MODIFIED_KEY,y);const v=e=>{const t={};return _.getCustomDCXData(e.rootNode).forEach(e=>{t[e.namespace+"#"+e.key]=e.value}),t};let A={};const C=v(o._dcxBranch),S=v(h),I=v(e);Object.keys(C).forEach(function(e){A[e]=!0,JSON.stringify(C[e])!==JSON.stringify(S[e])&&(I[e]=C[e])}),Object.keys(I).forEach(function(e){A[e]||S[e]&&!C[e]&&delete I[e]});var L,O,R,T=_.getCompositeRenditionMap(e),N=_.getCompositeRenditionMap(h);Object.keys(o._dcxCompositeRenditionMap).forEach(function(t){var n=o._dcxCompositeRenditionMap[t],i=N[t],r=T[t];i&&n.id===i.id||(r?(n.getValue(a.MODIFIED_KEY)||0)>(r.getValue(a.MODIFIED_KEY)||0)&&(e.removeComponent(r),e.copyComponent(n,e.rootNode)):e.copyComponent(n,e.rootNode))}),Object.keys(N).forEach(function(t){var n=o._dcxCompositeRenditionMap[t],i=N[t],r=T[t];!n&&r&&r.id===i.id&&e.removeComponent(r)}),e.getChildrenOf().forEach(function(e){e.name===a.ELEMENTS_NAME&&(L=e),e.name===a.REMOVED_ELEMENTS_NAME&&(O=e),e.name===a.GROUPS_NAME&&(R=e)}),L||(L=e.addChild(a.ELEMENTS_NAME));var D=function(){O||(O=e.addChild(a.REMOVED_ELEMENTS_NAME))},b=[],w={},P=[],x=function(e,t,n,o){var i=t.getValue(a.ORDER_KEY),r=n&&n.getValue(a.ORDER_KEY),s=o&&o.getValue(a.ORDER_KEY);if(s!==i)e._dcxNode.setValue(a.ORDER_KEY,i);else if(r!==s)return e.order!==r&&e._dcxNode.setValue(a.ORDER_KEY,r),!0;return!1};o._groups.forEach(function(t){var n=t.id,o=t._dcxNode,i=t.modified,r=e.getChildWithId(n),s=r&&r.getValue(a.MODIFIED_KEY),c=h&&h.getChildWithId(n),d=c&&c.getValue(a.MODIFIED_KEY);if(!d&&!s||d&&!s&&i!==d){E("g1: group created locally");var p=e.copyChild(o,(R||(R=e.addChild(a.GROUPS_NAME)),R),void 0,void 0,void 0);t._setDCXNode(p)}else d&&!s&&i===d?(E("g2: group deleted on server"),P.push(t)):d===i&&d===s?(E("g3: no changes to group modified time"),t._setDCXNode(r),x(t,o,r,c)&&b.push(t)):d===i&&d!==s?(E("g4: updated group on server"),t._setDCXNode(r),b.push(t),x(t,o,r,c)):d!==i&&d===s?(E("g5: updated group locally"),t._setDCXNode(e.replaceChild(o,void 0,void 0)),x(t,o,r,c)&&b.push(t)):d!==i&&d!==s?(E("g6: updated group locally and on server (conflict)"),t._setDCXNode(e.replaceChild(o,void 0,void 0)),x(t,o,r,c)&&b.push(t)):l.log("ERROR: unexpected group merge case: base="+d+", current="+i+", pulled="+s);w[n]=!0}),P.forEach(e=>o._doRemoveGroup(e));var k=[],M=[],V=[],F=[],U=new p,B=function(t){var n=t.id,i=t._dcxNode,d=t.modified,p=t.removed,u=e.getChildWithId(n),_=u&&u.getValue(a.MODIFIED_KEY),f=u&&u.getValue(a.REMOVED_KEY),m=h&&h.getChildWithId(n),g=m&&m.getValue(a.MODIFIED_KEY),y=m&&m.getValue(a.REMOVED_KEY);o._dcxBranch=e;var v=function(){return p?(D(),O):L},A=function(){return!p&&t.removed?(V.push(t),!0):!(!p||t.removed)&&(F.push(t),!0)},C=function(){var e=!1,n=i.getValue(a.DESCRIPTION_DATA_KEY)||{time:0},o=u&&u.getValue(a.DESCRIPTION_DATA_KEY)||{time:0},r=m&&m.getValue(a.DESCRIPTION_DATA_KEY)||{time:0};if(n.time!==r.time){var s=i.getValue(a.DESCRIPTION_KEY);t._dcxNode.setValue(a.DESCRIPTION_KEY,s),t._dcxNode.setValue(a.DESCRIPTION_DATA_KEY,n)}else o.time!==r.time&&(e=!0);var c=i.getValue(a.GROUPS_KEY)||{},l=u&&u.getValue(a.GROUPS_KEY)||{},d=m&&m.getValue(a.GROUPS_KEY)||{},p={};return Object.keys(c).forEach(function(t){var n=c[t],o=l[t],i=d[t];i&&n.order===i.order?o||(e=!0):p[t]=n}),Object.keys(l).forEach(function(t){var n=c[t],o=l[t],i=d[t];i&&!n||p[t]||(p[t]=o,i&&o.order===i.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(!g&&!_||g&&!_&&d!==g){E("e1: created element locally");var S=e.copyChild(i,v(),void 0,void 0,void 0);t._setDCXNode(S,!0)}else if(g&&!_&&d===g)E("e2: deleted element on server"),M.push(t);else if(g===d&&g===_){E("e3: no changes to element modified time"),t._setDCXNode(u,!0),y!==p&&(y===f?p&&!f?(E("e3a: removed element locally"),D(),t._dcxNode=e.moveChild(t._dcxNode,void 0,O),t._updateTimestampOnRemove(p)):f&&!p&&(E("e3b: restored element locally"),t._dcxNode=e.moveChild(t._dcxNode,void 0,L),t._updateTimestampOnRestore()):p||(E("e3c: remove/restore element conflict - local restore wins"),t._dcxNode=e.moveChild(t._dcxNode,void 0,L),t._updateTimestampOnRestore()));var I=A(),R=C();(I||R)&&b.push(t),t._ensureRemovedDataValid(c&&!a.SHARED_LOCAL_STORAGE)}else if(g===d&&g!==_)E("e4: updated element on server"),t._setDCXNode(u,c),b.push(t),A(),C(),t._ensureModifiedDataValid(c&&!a.SHARED_LOCAL_STORAGE);else if(g!==d&&g===_){E("e5: updated element locally");var T=e.replaceChild(i,void 0,void 0);t._setDCXNode(T,!0),(p&&!f||f&&!p)&&(t._dcxNode=e.moveChild(t._dcxNode,void 0,v())),C()&&b.push(t)}else if(g!==d&&g!==_){E("e6: updated element locally and on server (conflict)"),t._setDCXNode(u),b.push(t),A(),t._ensureModifiedDataValid(c&&!a.SHARED_LOCAL_STORAGE);var N=l.uuid(),P=e.copyChild(i,v(),void 0,N,N),x=new r(o,P);if(k.push(x),w[x.id]=!0,l.hasFileSystem()){const e=e=>o._renditionCache.copyCache(t,x).then(e,e);U.addOperation(e)}s.reportCollisionElement(t)}else l.log("ERROR: unexpected element merge case: base="+g+", current="+d+", pulled="+_);o._dcxBranch=o._dcxComposite.current,w[n]=!0};o._elements.forEach(B),o._removedElements.forEach(B);var Y=function(e){e.removed?o._removedElements.push(e):(o._addElementToFilter(e),o._elements.push(e))};k.forEach(Y),o._sortRemovedElements(),M.forEach(function(e){o._doRemoveElement(e,!1)}),V.forEach(function(e){o._doMarkElementRemoved(e,!1)}),F.forEach(function(e){o._doRestoreElement(e,!1)}),o._dcxBranch=e,o._dcxElementsNode=L,o._dcxRemovedElementsNode=O,o._dcxGroupsNode=R,o._dcxCompositeRenditionMap=_.getCompositeRenditionMap(e);var H=function(t,n){if(!w[t.id]){var s=t.getValue(a.MODIFIED_KEY),l=h&&h.getChildWithId(t.id),d=l&&l.getValue(a.MODIFIED_KEY);if(d&&s&&d===s)E(n?"g7: deleted group locally":"e7: deleted element locally"),e.removeChild(t);else if(E(n?"g8: created group on server":"e8: created element on server"),n){var p=new i(o,t);o._groups.push(p)}else{var u=new r(o,t);Y(u),u._ensureCreatedDataValid(c&&!a.SHARED_LOCAL_STORAGE)}}},G=o._dcxBranch.getChildrenOf(o._dcxElementsNode),j=o._dcxRemovedElementsNode?o._dcxBranch.getChildrenOf(o._dcxRemovedElementsNode):[],W=o._dcxGroupsNode?o._dcxBranch.getChildrenOf(o._dcxGroupsNode):[];G.forEach(function(e){H(e)}),j.forEach(function(e){H(e)}),W.forEach(function(e){H(e,!0)}),Object.keys(m).sort().forEach(e=>{const t=m[e];l.log(`Merge Case ${e} (${t})`)}),o._transactionCount++,U.run(function(){_.checkDeletedState(o,n)||(o._transactionCount--,l.storageInterface.resolvePullWithBranch(o,e,d,c,function(t){_.checkDeletedState(o,n)||(t?n(f.getCommitError(t,o.id)):(l.hasFileSystem()||(o._dcxBaseBranch=e.copy()),a.SHARED_LOCAL_STORAGE||c||u.prefetchRenditions(o),n(null),b.forEach(function(e){e._listenerManager.notify("change")}),o._notifyChange()))}))})}this._waitForCommit(function(){_.checkDeletedState(o,n)||(t?h(null,t):"unmodified"===o._dcxBranch.compositeState?h(null,o._dcxBranch):o._loadBaseBranch(h))})},A.prototype._pull=function(e){var t=this;if(this._dcxComposite.href&&this._dcxBranch.isBound)if(this._deletedFromServer)e(null,!1);else{var n=function(n,o){_.checkDeletedState(t,e)||(n&&t._collection._reportSyncError(n),t._setSyncState(),t._networkLock.release(),e(n,o))};this._networkLock.obtain(function(o){o?e(null):_.checkDeletedState(t,e)||(this._setSyncState("downloading"),this._collection._syncManager.pullComposite(this._dcxComposite,this._collection,function(o,i){_.checkDeletedState(t,e)||(t._isDeletedError(o)?l.hasFileSystem()&&"modified"===t._dcxBranch.compositeState&&"incoming"!==t.collaboration?(t._doRebindToServer(!1,e),t._networkLock.release()):(t._deletedFromServer=!0,t._notifyChange(),n(null,!0)):o?n(f.getSyncError(o,t.id)):i?t._mergeAndSwitchToBranch(i,void 0,function(o){_.checkDeletedState(t,e)||n(o,!0)}):n(null,!1))}))},this)}else e(null,!1)},A.prototype._pushWithParameters=function(e,t){var n=this,i=function(e,n){t&&t(null,n)};if(a.SYNCING_ENABLED)if(this._collection._retryTimeoutId)i(0,!1);else if(this._dcxBranch.isBound&&"modified"!==this._dcxBranch.compositeState)i(0,!1);else if(this._deletedFromServer)i(0,!1);else if(this.isWritable)if(this._pushPending)i(0,!1);else{var r=function(e,o){_.checkDeletedState(n,i)||(n._pushFailedDueToQuota=!1,e&&(n._collection._reportSyncError(e),e.code===c.EXCEEDS_QUOTA&&(n._pushFailedDueToQuota=!0)),n._setSyncState(),n._collection._syncManager.pullMissingComponents(n,function(){_.checkDeletedState(n,t)||(n._networkLock.release(),u.prefetchRenditions(n),i(0,o))}))};this._pushPending=!0,this._networkLock.obtain(function(t){t?i(0,!1):this._waitForCommit(function(){var t;_.checkDeletedState(n,i)||(n._pushPending=!1,l.hasFileSystem()||(t=n._dcxBranch.copy()),n._setSyncState("uploading"),n._collection._syncManager.pushComposite(n._dcxComposite,n._collection,e,function(e){if(!_.checkDeletedState(n,i))if(n._isDeletedError(e))l.hasFileSystem()&&"modified"===n._dcxBranch.compositeState&&"incoming"!==n.collaboration?(n._doRebindToServer(!1,i),n._networkLock.release()):(n._deletedFromServer=!0,n._notifyChange(),r(null,!0));else{if(n._isAlreadyExistsError(e))return n._dcxComposite.name=d.translate("LIBS_RECOVERED_LIBRARY",{name:n._dcxComposite.name}),n._doRebindToServer(!0,i),void n._networkLock.release();if(n._isReadOnlyError(e))return l.log("Push failed due to read only. Reverting: "+n.id),n._setClientDataValue(a.DATA_COLLABORATION_ROLE,"viewer"),void n._revertLocalChangesIfNecessary(function(e){r(e,!1)});if(e&&e.code===c.TRANSFER_ABORTED)r(null,!0);else{if(e&&e.code===o.UPDATE_CONFLICT){if(l.log("Push failed due to conflict: "+n.id),n._numUpdateConflicts++,n._numUpdateConflicts<=a.MAX_UPDATE_CONFLICTS)return n._sync(!1,i),void n._networkLock.release();s.reportUnexpectedState(n,"updateConflict"),l.log("Reached maximum number of update-conflict retries: "+n.id)}n._numUpdateConflicts=0,e&&e.code===o.COMPONENT_UPLOAD_ERROR&&(l.log("Push failed due to component upload failure: "+n.id),_.removeMissingLocalComponents(n,e.failedComponents)),e?r(f.getSyncError(e,n.id)):l.storageInterface.acceptPush(n,function(e){_.checkDeletedState(n,i)||(e?r(f.getCommitError(e,n.id),!0):(l.hasFileSystem()||(n._dcxBaseBranch=t),r(null,!0)))})}}}))})},this)}else i(0,!1);else i(0,!1)},A.prototype._loadBaseBranch=function(e){var t=this;l.hasFileSystem()?t._dcxComposite.loadBaseBranch(function(n,o){t._waitForCommit(function(){e(n,o)})}):e(null,t._dcxBaseBranch)},A.prototype._revertLocalChangesIfNecessary=function(e){var t=this,n=E.wrapCallback(e);this.isWritable||"modified"!==this._dcxBranch.compositeState?n(null):this._loadBaseBranch(function(e,o){t._transactionCount++,_.recoverReadOnlyEdits(t,o,function(e){e&&l.log("Error recovering library changes: "+e),t._transactionCount--;var i=o.copy(),r=t.collaboration,s=t._getClientDataValue(a.DATA_COLLABORATION_ROLE);t._mergeAndSwitchToBranch(i,t._dcxBranch,function(e){if(e)l.log("Error Reverting: "+t.id),n(e);else{var o=_.collaborationStateToDCX(r);t._dcxComposite.collaborationType=o,t._setClientDataValue(a.DATA_COLLABORATION_ROLE,s),t._commit(!0,!0),t._waitForCommit(function(){t._notifyChange(),n(null)})}})})})},A.prototype._push=function(e){this._pushWithParameters(!1,e)},A.prototype._abortPushOrPull=function(){this._networkLock.abortPendingOperations(new c(c.TRANSFER_ABORTED)),this._collection._syncManager.abortPushOrPull(this.id)},A.prototype._deleteFromServer=function(e,t){var n=this;if(this._deletingFromServerInProgress||this._abortPushOrPull(),this._dcxComposite.href)if(this._deletedFromServer)t(null);else{this._deletingFromServerInProgress=!0;var i=function(e){n._deletingFromServerInProgress=!1,n._setSyncState(),n._networkLock.release(),t(e)};this._networkLock.obtain(function(r){r?t(null):this._deletedFromDisk?i(null):(this._setSyncState("uploading"),this._dcxBranch.compositeState="pendingDelete",this._commit(!0,!0),this._waitForCommit(function(){n._deletedFromDisk?i(null):n._collection._syncManager.pushDeletedComposite(n._dcxComposite,n._collection,n.collaboration,e,function(t){t?n._isDeletedError(t)?(n._deletedFromServer=!0,t=null):(e||t.code!==o.UPDATE_CONFLICT)&&(t=f.getSyncError(t,n.id),n._collection._reportSyncError(t)):n._deletedFromServer=!0,i(t)})}))},this)}else t(null)},A.prototype._doRebindToServer=function(e,t){var n=this;this._deletedFromServer=!1;var o=e||"incoming"===this.collaboration?"resetIdentity":"resetBinding",i=this.id;this._dcxComposite[o](function(e){_.checkDeletedState(n,t)||(e?t(e):(n._transactionCount++,n.id!==i&&(n._collection._libraryIdMap[n.id]=n,delete n._collection._libraryIdMap[i]),m.moveLibrary(n,i,function(e){_.checkDeletedState(n,t)||(n._transactionCount--,e?t(e):(n._collection._syncManager.prepareCompositeForPush(n._dcxComposite),n._setCollaboration(),n._commit(!1,!0),n._pushWithParameters(!0,t)))})))})},A.prototype._sync=function(e,t){var n=this;function o(e,o){t&&n._waitForSyncToFinish(function(){t(e,o)})}function i(e,t){_.checkDeletedState(n,o)||(e?o(e,t):n._push(function(e,i){_.checkDeletedState(n,o)||o(e,t||i)}))}!a.SHARED_LOCAL_STORAGE&&a.SYNCING_ENABLED?this._collection._retryTimeoutId?o(null,!1):(this._collection._clearSyncErrors(this.id),e?i(null,!1):this._pull(i)):o(null,!1)},A.prototype._getCompositeDir=function(){return this._collection._getCompositeDir(this.id)},A.prototype._getRenditionCacheDir=function(){return this._collection._getRenditionCacheDir(this.id)},A.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(A.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")}}}),A.prototype.toString=function(){return JSON.stringify(this._toJSON())},A.prototype.addChangeListener=function(e){_.checkDeletedState(this),this._listenerManager.add("change",e)},A.prototype.removeChangeListener=function(e){this._listenerManager.remove("change",e)},A.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})},A.prototype.getGroupById=function(e){return this._groups.find(function(t){return t.id===e})},A.prototype.createGroup=function(e,t,n){if(n=n||a.DEFAULT_GROUP_CLASSIFIER,_.checkDeletedState(this),!this.isWritable)throw new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id);var o=this._doCreateGroup(e,t,n);return this._commit(),s.reportCreateGroup(o),o},A.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 n=0;this._doRemoveGroup(e,e=>{t?(this.removeElement(e),n++):e._listenerManager.notify("change")}),this._commit(),s.reportDeleteGroup(e,t,n)},A.prototype.moveGroup=function(e,t,n,o){if(!_.checkDeletedState(this,o))if(this.isWritable)if(e)if(-1!==this._groups.indexOf(e))if(t)if(this!==t){var i;if(t.isWritable)return n&&(i=this._getNumberOfElementsInGroup(e)),this._doCopyGroup(e,t,n,!0,function(t,r){t?o(t):(s.reportMoveGroup(r,e,n,i),o(null,r))});o(new c(c.NOT_ALLOWED,"you do not have write access to the destination library",t.id))}else o(new c(c.INVALID_PARAMETER,"Move must have a different destination library",this.id));else o(new c(c.INVALID_PARAMETER,"No destination library specified",this.id));else o(new c(c.INVALID_PARAMETER,"Group not in this library",this.id));else o(new c(c.INVALID_PARAMETER,"No group specified",this.id));else o(new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id))},A.prototype.copyGroup=function(e,t,n,o){if(!_.checkDeletedState(this,o))if(e)if(-1!==this._groups.indexOf(e))if(t){var i;if(t.isWritable)return n&&(i=this._getNumberOfElementsInGroup(e)),this._doCopyGroup(e,t,n,!1,function(t,r){t?o(t):(s.reportCopyGroup(r,e,n,i),o(null,r))});o(new c(c.NOT_ALLOWED,"you do not have write access to the destination library",t.id))}else o(new c(c.INVALID_PARAMETER,"No destination library specified",this.id));else o(new c(c.INVALID_PARAMETER,"Group not in this library",this.id));else o(new c(c.INVALID_PARAMETER,"No group specified",this.id))},A.prototype.createElement=function(e,t){if(_.checkDeletedState(this),!this.isWritable)throw new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id);if(this._elements.length>=a.MAX_ELEMENTS)throw new c(c.EXCEEDS_MAX_LIBRARY_SIZE,"Library cannot have more than "+a.MAX_ELEMENTS+" elements",this.id);return this._wrapOperation(function(){var n=this._doCreateElement(e,t);return s.reportCreateElement(n),n.beginOperation(),n},this)},A.prototype.removeElement=function(e,t){if(_.checkDeletedState(this),!this.isWritable)throw new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id);if(!e)throw new c(c.INVALID_PARAMETER,"No element specified",this.id);if(-1===this._elements.indexOf(e)){if(-1===this._removedElements.indexOf(e))throw new c(c.INVALID_PARAMETER,"Element not in this library",this.id);if(!t)throw new c(c.INVALID_PARAMETER,"Element already removed",this.id)}return this._wrapOperation(function(){for(;e._transactionCount>0;)e.endOperation();t?this._doRemoveElement(e,!0):this._doMarkElementRemoved(e,!0),s.reportDeleteElement(e,t)},this)},A.prototype.restoreElement=function(e){if(_.checkDeletedState(this),!this.isWritable)throw new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id);if(!e)throw new c(c.INVALID_PARAMETER,"No element specified",this.id);if(-1===this._removedElements.indexOf(e)){if(-1===this._elements.indexOf(e))throw new c(c.INVALID_PARAMETER,"Element not in this library",this.id);throw new c(c.INVALID_PARAMETER,"Element already restored",this.id)}if(this._elements.length>=a.MAX_ELEMENTS)throw new c(c.EXCEEDS_MAX_LIBRARY_SIZE,"Library cannot have more than "+a.MAX_ELEMENTS+" elements",this.id);return this._wrapOperation(function(){this._doRestoreElement(e,!0),s.reportRestoreElement(e)},this)},A.prototype.copyElement=function(e,t,n){if(!_.checkDeletedState(this,n))if(e)if(-1!==this._elements.indexOf(e)||-1!==this._removedElements.indexOf(e))if(t){if(t.isWritable)return this._doCopyElement(e,t,!1,function(t,o){t?n(t):(s.reportCopyElement(o,e),n(null,o))});n(new c(c.NOT_ALLOWED,"you do not have write access to the destination library",t.id))}else n(new c(c.INVALID_PARAMETER,"No destination library specified",this.id));else n(new c(c.INVALID_PARAMETER,"Element not in this library",this.id));else n(new c(c.INVALID_PARAMETER,"No element specified",this.id))},A.prototype.moveElement=function(e,t,n){if(!_.checkDeletedState(this,n))if(this.isWritable)if(e)if(-1!==this._elements.indexOf(e)||-1!==this._removedElements.indexOf(e))if(t)if(this!==t){if(t.isWritable)return this._doCopyElement(e,t,!0,function(t,o){t?n(t):(s.reportMoveElement(o,e),n(null,o))});n(new c(c.NOT_ALLOWED,"you do not have write access to the destination library",t.id))}else n(new c(c.INVALID_PARAMETER,"Move must have a different destination library",this.id));else n(new c(c.INVALID_PARAMETER,"No destination library specified",this.id));else n(new c(c.INVALID_PARAMETER,"Element not in this library",this.id));else n(new c(c.INVALID_PARAMETER,"No element specified",this.id));else n(new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id))},A.prototype.getValues=function(){return _.getCustomDCXData(this._dcxBranch.rootNode)},A.prototype.setValue=function(e,t,n){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 o,i=_.getDCXKey(e,t);try{o=JSON.parse(JSON.stringify(n))}catch(e){throw new c(c.INVALID_PARAMETER,"Value cannot be serialized to JSON",this.id)}this._dcxBranch.rootNode.setValue(i,o),this._commit()},A.prototype.getValue=function(e,t){if(e===a.DL_NAMESPACE)throw new c(c.INVALID_PARAMETER,"Reserved namespace",this.id);var n=_.getDCXKey(e,t);return this._dcxBranch.rootNode.getValue(n)},A.prototype.removeValue=function(e,t){if(e===a.DL_NAMESPACE)throw new c(c.INVALID_PARAMETER,"Reserved namespace",this.id);const n=_.getDCXKey(e,t);this._dcxBranch.rootNode.removeValue(n)},A.prototype.getRenditionPath=function(e,t){if(l.hasFileSystem()){if(!_.checkDeletedState(this,t)&&this._checkRenditionType(e,t)){var n=this._dcxCompositeRenditionMap[e];if(!n)return t(null);var o=this._dcxBranch.assetOfComponent(n);if(o)return t(null,o);var i=this;this._networkLock.obtain(function(e){e?t(e):_.checkDeletedState(i,t)?i._networkLock.release():(i._setSyncState("downloading"),i._collection._syncManager.downloadComponent(i._dcxBranch,n,function(e){i._networkLock.release(),i._setSyncState(),e?t(f.getSyncError(e,i.id)):_.checkDeletedState(i,t)||(i._commit(!0,!0),t(null,i._dcxBranch.assetOfComponent(n)))}))})}}else t(new c(c.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this.id))},A.prototype.getRenditionURL=function(e){_.checkDeletedState(this),this._checkRenditionType(e);var t=this._dcxCompositeRenditionMap[e];if(t)return this._collection._syncManager.getSharedCloudContentURL(t)},A.prototype.getAuthenticatedRenditionURL=function(e,t){if(!_.checkDeletedState(this,t)&&this._checkRenditionType(e,t)){var n=this.getRenditionURL(e);if(!n)return t(null);this._collection._syncManager.appendAccessTokenToURL(n,t)}},A.prototype.setRendition=function(e,t,n,o,i){if(!_.checkDeletedState(this,i)&&this._checkRenditionType(e,i))if(t)if(this.isWritable)if(l.hasFileSystem()){if(!_.checkEncoding(n,["utf8","ascii","base64","buffer"],i))return;this._setRendition(e,t,n,o,i)}else{if(void 0!==n)return void i(new c(c.INVALID_PARAMETER,"Encoding parameter not supported in-browser"));this._setRenditionInBrowser(e,t,o,i)}else i(new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id));else i(new c(c.INVALID_PARAMETER,"content must exist",this.id))},A.prototype.setRenditionFromPath=function(e,t,n,o){_.checkDeletedState(this,o)||this._checkRenditionType(e,o)&&("string"==typeof t?l.hasFileSystem()?this.isWritable?this._setRenditionFromPath(e,t,n,o):o(new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id)):o(new c(c.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this.id)):o(new c(c.INVALID_PARAMETER,"path must be a string",this.id)))},A.prototype.removeRendition=function(e){if(_.checkDeletedState(this),this._checkRenditionType(e),!this.isWritable)throw new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id);var t=this._dcxCompositeRenditionMap[e];if(t)return this._wrapOperation(function(){this._dcxBranch.removeComponent(t),this._dcxCompositeRenditionMap=_.getCompositeRenditionMap(this._dcxBranch),this._commit()},this)},A.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()},A.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()},A.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]},A.prototype.sync=function(e){_.checkDeletedState(this,e)||this._sync(!1,e)},A.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))},A.prototype.getElementById=function(e,t){var n;return this.elements.forEach(function(t){t.id===e&&(n=t)}),n||t||this.removedElements.forEach(function(t){t.id===e&&(n=t)}),n},Object.freeze(A),Object.seal(A.prototype),e.exports=A},function(e,t,n){const o=n(45),i=n(46),r=n(1),a=n(0),s=n(21),c=n(8),l=n(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 n=()=>this._lock.release();let o=new Promise(e=>this._lock.obtain(e)).then(e);return t&&(o=o.then(e=>this._save().then(()=>e))),o.then(n,n),o}_load(){return!r.hasFileSystem()||a.SHARED_LOCAL_STORAGE?Promise.resolve():c.readJSONData(i.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 n=0;t&&n<e.length;n++)t=t[e[n]];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 n=i.join(this._rootDir,e);return a.SHARED_LOCAL_STORAGE||o.statSync(n)?n:void 0}_setCacheEntry(e,t){let n=this._cache;for(let t=0;t<e.length-1;t++){const o=e[t];n=n[o]=n[o]||{}}const o=e[e.length-1];return void 0===t?delete n[o]:n[o]=t,t}_setCache(e,t,n){const a=c.getFileExtension(t)||"png",s=`${r.uuid()}.${a}`;return o.ensureDir(this._rootDir).then(()=>(this._pendingCacheItems[s]=!0,o[n?"rename":"copy"](t,i.join(this._rootDir,s)))).then(()=>(delete this._pendingCacheItems[s],this._setCacheEntry(e,s),i.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,n=[]){Object.keys(t).forEach(o=>{"object"==typeof t[o]?this._iterate(e,t[o],n.concat(o)):e(n,t[o])})}_gcUnreferencedFiles(){const e={};return this._iterate((t,n)=>{e[n]=!0,delete this._pendingCacheItems[n]}),o.readdir(this._rootDir).then(t=>{const n=[];return t.forEach(t=>{const r=c.normaliseTempFileName(t);t===a.RENDITION_CACHE_FILE||e[t]||this._pendingCacheItems[r]||n.push(o.remove(i.join(this._rootDir,t)))}),Promise.all(n)})}}},function(e,t,n){var o=n(2);function i(e,t){this._id=e,this._url=t}Object.defineProperties(i.prototype,{id:{get(){return this._id},set(){throw new o(o.READ_ONLY,"Cannot change the id of an existing bookmark")}},url:{get(){return this._url},set(){throw new o(o.READ_ONLY,"Cannot change the url of an existing bookmark")}}}),Object.freeze(i),Object.seal(i.prototype),e.exports=i},function(e,t,n){var o=n(44),i=n(2),r=n(0),a=n(1),s=n(12),c=n(8);function l(e){e.IS_PUBLIC=!0,e.USER_ID=e.USER_ID||r.PUBLIC_USER_ID,this._newLibrariesLoading={},o.call(this,e)}Object.keys(o.prototype).forEach(function(e){0===e.indexOf("_")&&(l.prototype[e]=o.prototype[e])}),l.prototype._dosync=function(e,t){var n=this;this._clearSyncErrors();var o=new s;this._libraries.forEach(function(e){o.addOperation(function(t){n._syncManager.hasCompositeChangedOnServer(e._dcxComposite,function(n){e._sync(!n,t)})})}),o.run(function(e,n){t(null,n)},function(e){n._reportSyncError(e)})},Object.defineProperties(l.prototype,{libraries:{get(){return this._libraries},set(){throw new i(i.READ_ONLY,"Cannot modify libraries list directly")}},commitError:{get(){return this._lastCommitError},set(){throw new i(i.READ_ONLY,"commitError is a read-only property")}},syncState:{get(){return this._syncState},set(){throw new i(i.READ_ONLY,"syncState is a read-only property")}},syncErrors:{get(){return this._syncErrors},set(){throw new i(i.READ_ONLY,"syncErrors is a read-only property")}},syncProgress:{get(){return this._syncProgress},set(){throw new i(i.READ_ONLY,"syncProgress is a read-only property")}},isPolling:{get(){return void 0!==this._pollTimerId},set(){throw new i(i.READ_ONLY,"isPolling is a read-only property")}},retryTime:{get(){return"never"!==this._retryTime?this._retryTime:void 0},set(){throw new i(i.READ_ONLY,"retryTime is a read-only property")}},userId:{get(){return this._userId},set(){throw new i(i.READ_ONLY,"userId is a read-only property")}},cloudId:{get(){return this._cloudId},set(){throw new i(i.READ_ONLY,"cloudId is a read-only property")}},cloudInfo:{get(){return this._cloudInfo},set(){throw new i(i.READ_ONLY,"cloudInfo is a read-only property")}},isPublic:{get:()=>!0,set(){throw new i(i.READ_ONLY,"isPublic is a read-only property")}},operations:{get(){return this._operations},set(){throw new i(i.READ_ONLY,"operations is a read-only property")}}}),l.prototype.addChangeListener=function(e){o.prototype.addChangeListener.call(this,e)},l.prototype.removeChangeListener=function(e){o.prototype.removeChangeListener.call(this,e)},l.prototype.addDeepChangeListener=function(e){o.prototype.addDeepChangeListener.call(this,e)},l.prototype.removeDeepChangeListener=function(e){o.prototype.removeDeepChangeListener.call(this,e)},l.prototype.canLoadLibrary=function(e){var t=new RegExp(this._syncManager.getSyncGroupPath()+"/(.+)");return!!e.match(t)},l.prototype.loadLibrary=function(e,t,n){var o=this,s=this.getLibraryById(e);if(s)n(null,s);else if(!t||this.canLoadLibrary(t)){var c=this._newLibrariesLoading[e];c?c.push(n):(this._newLibrariesLoading[e]=[n],r.SHARED_LOCAL_STORAGE?a.storageInterface.loadPublicLibrary(this,e,t,l):this._syncNewLibrary(e,t,void 0,function(t){t?l(t):((s=o.getLibraryById(e))&&(s._loadedExternally=!0),l(null,s))}))}else n(new i(i.INVALID_PARAMETER,"Invalid library url"));function l(t,n){var i=o._newLibrariesLoading[e];delete o._newLibrariesLoading[e],i.forEach(function(e){e(t,n)})}},l.prototype.unloadLibrary=function(e,t){var n=this._libraries.indexOf(e);-1!==n?(this._libraries.splice(n,1),delete this._libraryIdMap[e.id],e._markDeletedLocally(!0),r.SHARED_LOCAL_STORAGE?a.storageInterface.unloadPublicLibrary(e,t):(e._deletedFromDisk=!0,c.deleteLibraryFromDisk(this,e.id,t)),this._listenerManager.notify("change")):t(null)},l.prototype.removeDeletedLibraries=function(e,t){o.prototype.removeDeletedLibraries.call(this,e,t)},l.prototype.exportLibrary=function(e,t,n){return o.prototype.exportLibrary.call(this,e,t,n)},l.prototype.sync=function(e){o.prototype.sync.call(this,e)},l.prototype.addSyncListener=function(e){o.prototype.addSyncListener.call(this,e)},l.prototype.removeSyncListener=function(e){o.prototype.removeSyncListener.call(this,e)},l.prototype.getPrimarySyncError=function(){return o.prototype.getPrimarySyncError.call(this)},l.prototype.getNewLibrarySyncProgress=function(){return o.prototype.getNewLibrarySyncProgress.call(this)},l.prototype.addOperationChangeListener=function(e){this._listenerManager.add("operation",e)},l.prototype.removeOperationChangeListener=function(e){this._listenerManager.remove("operation",e)},l.prototype.addCommitErrorListener=function(e){o.prototype.addCommitErrorListener.call(this,e)},l.prototype.removeCommitErrorListener=function(e){o.prototype.removeCommitErrorListener.call(this,e)},l.prototype.startPolling=function(){o.prototype.startPolling.call(this)},l.prototype.stopPolling=function(){o.prototype.stopPolling.call(this)},l.prototype.getLibraryById=function(e){return o.prototype.getLibraryById.call(this,e)},l.prototype.getTempDir=function(e){o.prototype.getTempDir.call(this,e)},Object.freeze(l),Object.seal(l.prototype),e.exports=l},function(e,t,n){var o=n(1),i=n(5);function r(e){this._socket=e,this._listenerManager=new i,this._socketListenerManager=new i,this._pendingWriteState={},this._pendingWriteDependencyMap={},this._init()}function a(e){return e+"_req"}function s(e){return e+"_res"}function c(e,t,n){return e+"#"+t+"#"+n}r.prototype._init=function(){var e=this;this._addSocketListener("message",function(t){var n=JSON.parse(t);e._logReceive(n.type),e._listenerManager.notify(n.type,[n.data])})},r.prototype._addSocketListener=function(e,t){this._socketListenerManager.add(e,t),this._socket.addListener(e,t)},r.prototype._removeSocketListeners=function(){var e=this;this._socketListenerManager.forEach(function(t,n){e._socket.removeListener(t,n)}),this._socketListenerManager.removeAll()},r.prototype._logSend=function(e){this._logCallback&&this._logCallback("SEND "+e)},r.prototype._logReceive=function(e){this._logCallback&&this._logCallback("RECEIVE "+e)},r.prototype._logError=function(e){this._logCallback&&this._logCallback("ERROR "+e)},r.prototype.setPendingWriteState=function(e,t,n){var o=c(e,t,n);this._pendingWriteState[o]=!0},r.prototype.setPendingWriteDependency=function(e,t,n,o,i,r){var a=c(e,t,n),s=c(o,i,r);a!==s&&(this._pendingWriteDependencyMap[a]=this._pendingWriteDependencyMap[a]||{},this._pendingWriteDependencyMap[a][s]={userId:o,cloudId:i,id:r})},r.prototype.clearPendingWriteState=function(e,t,n){var o=c(e,t,n),i=[];return Object.keys(this._pendingWriteDependencyMap[o]||{}).forEach(function(e){i.push(this._pendingWriteDependencyMap[o][e])},this),delete this._pendingWriteState[o],delete this._pendingWriteDependencyMap[o],i},r.prototype.getPendingWriteState=function(e,t,n,o){var i=c(e,t,n),r=!1;return!o&&this._pendingWriteState[i]&&(r=this._pendingWriteState[i]),Object.keys(this._pendingWriteDependencyMap).forEach(function(e){this._pendingWriteDependencyMap[e][i]&&(r=this._pendingWriteState[e]||r)},this),r},r.prototype.setLogCallback=function(e){this._logCallback=e},r.prototype.addListener=function(e,t){this._listenerManager.add(e,t)},r.prototype.removeListener=function(e,t){this._listenerManager.remove(e,t)},r.prototype.send=function(e,t){try{this._logSend(e),this._socket.send(JSON.stringify({type:e,data:t}))}catch(e){this._logError(e),this._socketListenerManager.notify("error",[e])}},r.prototype.addCallListener=function(e,t){var n=this;this.addListener(a(e),function(o){var i=o.id;t(o.data,function(t){n.send(s(e),{id:i,data:t})})})},r.prototype.removeCallListener=function(e,t){this.removeListener(a(e),t)},r.prototype.call=function(e,t,n){var i=this,r=o.uuid(),c=function(t){t.id===r&&(i.removeListener(s(e),c),n(t.data))};this.addListener(s(e),c),this.send(a(e),{id:r,data:t})},r.prototype.onOpen=function(e){this._addSocketListener("open",e)},r.prototype.onClose=function(e){this._addSocketListener("close",e)},r.prototype.onError=function(e){this._addSocketListener("error",e)},r.prototype.shutdown=function(){var e=this;this._addSocketListener("close",function(){e._removeSocketListeners(),e._listenerManager.removeAll()}),this._socket.close()},Object.freeze(r),Object.seal(r.prototype),e.exports=r},function(e,t,n){var o=n(21),i={},r={obtainLock:function(e,t){i[e]||(i[e]=new o),i[e].obtain(t)},releaseLock:function(e){i[e]&&i[e].release()},isLocked:function(e){return!!i[e]&&i[e].isLocked()},hasPendingRequest:function(e){return!!i[e]&&i[e].hasPendingRequest()}};e.exports=r},function(e,t,n){global.LOCALE_ROOT=__dirname+"/locale/";const o=n(38),i=n(20),r=n(24);var a=n(3),s=n(6),c=n(70),l=n(112),d=n(114),p=n(115),h=n(29),u=n(63),_=n(47),f=n(116),m=n(120),E=n(30),g=n(124),y=n(126),v=n(127),A=n(128),C=n(23),S=n(22),I=n(129),L=n(130),O=n(131),R=n(132),T=n(134),N=n(145),D=n(147),b=n(10),w=n(2),P=n(0),x=n(1),k=n(19),M=n(148),V=n(15),F=n(11),U=n(12),B=n(16),Y=n(8),H="Service",G=!1;process.argv.forEach(function(e){"--test"===e&&(console.log("Testing CCLibrary Process..."),G=!0)}),n(149).start(),l.clearTempFiles(a.getValue("ROOT_DIR")),Error.stackTraceLimit=1/0;var j=function(e){var t=0,n=function(){2===++t&&process.exit()},o=function(){s.removeLogWriteListener(o),n()};s.addLogWriteListener(o),s.log(H,"Uncaught exception: "+e+"\n"+e.stack),P.ANALYTICS_ENABLED?C.reportError("Uncaught",e+"\n"+e.stack,!0,n):n()};G||process.on("uncaughtException",j);const W=[new o.Server({port:0,host:"127.0.0.1",verifyClient(e,t){if("file://"!==e.origin&&!e.origin.match(/http:\/\/localhost:[0-9]+$/))return 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 X=new M;function q(e){u.isLocked(e.id)||(X.broadcast("librarychange",d.getLibraryData(e)),f.libraryChanged(e,!1))}function z(e){return e.isPublic?b.getLoadedPublicCollectionById(e.cloudId):b.getLoadedCollectionById(e.userId,e.cloudId)}function K(e,t){var n=z(e);return n&&n.getLibraryById(e[t||"id"])}function J(e,t,n){var o=K(e,n);return o&&o.getElementById(e[t||"element"])}function $(e){var t=J(e);return t&&t.getRepresentationById(e.representation)}var Q=function(e,t){var n=K(e);n&&n._setAutoGC("client_writing",t)};function Z(e,t,n){var o=function(){var o=function(){c.validateBookmarks()};n?e.syncChanges(n,o):t?e.syncFull(o):e.sync(o)};e.isPublic||e.isLoggedIn?o():E.getAccessToken(function(t,n){!t&&n&&(e.updateAccessToken(n),o())})}function ee(e){b.getLoadedCollections().forEach(function(t){e?t.isPublic||Z(t,!1,e):Z(t,!1)})}var te,ne="normal";var oe=[],ie=function(){var e=[],t={};oe.forEach(function(n){z(n)?(e.push(n),t[n.userId+"/"+n.cloudId]=!0):function(e){X.broadcast("collectionremoved",e)}(n)}),b.getLoadedCollections().forEach(function(n){var o=n.isPublic?P.PUBLIC_USER_ID:n.userId;t[o+"/"+n.cloudId]||(e.push({isPublic:n.isPublic,userId:o,cloudId:n.cloudId}),function(e){X.broadcast("collectionadded",d.getCollectionData(e)),X.broadcast("syncstate",d.getSyncStateData(e))}(n))}),oe=e};b.addLoadedCollectionsListener(ie);var re={};function ae(e){var t=(e.isPublic?"":e.userId)+"/"+e.cloudId;re[t]=re[t]||{};var n=re[t];e.libraries.forEach(function(e){n[e.id]||(n[e.id]=function(){q(e)},e.addChangeListener(n[e.id]),q(e))}),Object.keys(n).forEach(function(t){e.getLibraryById(t)||(X.broadcast("librarydeleted",d.getDeletedLibraryData(e,t)),f.libraryDeleted(t),delete n[t])})}const se=new R,ce=e=>{b.getLoadedCollections().forEach(function(t){t.isPublic||(e&&t.fontManager._clearCache(),X.broadcast("fontcachechanged",{isPublic:t.isPublic,userId:t.userId,cloudId:t.cloudId}))})};se.addChangeListener(()=>ce(!1));var le=0;function de(){const e=(e,t)=>{var n="client_"+le++,o=h.parseQueryString(t.url),r=o.version||0,l="true"===o.diagnostics;s.log(H,n,"Client connected: "+(l?"diagnostic":"version="+r));var _=X.newChannel(e);_.onClose(function(){s.log(H,n,"Client disconnected")}),_.setLogCallback(function(e){s.log(H,n,e)});var m=!1;if(o.token&&(m=o.token===a.getValue("SERVICE_TOKEN")||a.isWSSTokenValid(o.token)),o.diagnostics||C.reportEvent("clientConnected",{clientId:n,clientVersion:r,numClients:X.numChannels(),hasToken:void 0!==o.token,isRejected:!m}),l)_.shutdown();else{var v=d.getEnvironmentData(r);if(m&&_.send("environmentinfo",v),v.updateRequired)return s.log(H,n,"Incompatible version. Update required: "+v.updateRequired),void _.shutdown();if(!m)return s.log(H,n,"Client validation failed"),void _.shutdown();_.addListener("configure",function(e){e.CLIENT_DESCRIPTION&&s.log(H,"Configure: "+e.CLIENT_DESCRIPTION);var t=!1,n=!1;if(e.RENDITION_SIZES&&(t=p.mergeRenditionSizes(e.RENDITION_SIZES)),e.FULL_RENDITION_CONFIG&&(n=p.mergeFullRenditionConfig(e.FULL_RENDITION_CONFIG)),(t||n)&&(p.triggerRenditionPrefetch(),f.collectionsLoaded()),e.LOCAL_SETTINGS){p.mergeLocalSettings(e.LOCAL_SETTINGS)&&X.broadcast("environmentinfo",d.getEnvironmentData(),_)}}),_.addListener("sync",function(e){var t=z(e);(function(e){var t=e&&e.getPrimarySyncError();return!!t&&t.code===w.ACCESS_DENIED})(t)||(t&&Z(t),y.ping())}),_.addListener("configuresync",function(e){g.configureFileSyncing(e.enable)}),_.addCallListener("commit",function(e,t){var n=z(e);u.obtainLock(e.id,function(){function o(){X.getPendingWriteState(e.userId,e.cloudId,e.id,_)||Q(e,!0)}function i(o,i){u.releaseLock(e.id);var r=n.getLibraryById(e.id),a={};if(o)(a=r?d.getLibraryData(r):a).success=!1,t(a);else{const o=(o,s)=>{i||(!function(e,t,n){var o=e.getLibraryById(t);o?X.broadcast("librarychange",d.getLibraryData(o),n):X.broadcast("librarydeleted",d.getDeletedLibraryData(e,t),n)}(n,e.id,_),r?f.libraryChanged(r,!0):f.libraryDeleted(e.id)),a.success=!0,a.renditions=o?[]:s,function(n){_.clearPendingWriteState(e.userId,e.cloudId,e.id).forEach(function(e){X.getPendingWriteState(e.userId,e.cloudId,e.id)||Q(e,!0)}),t(n)}(a)},s=e.renditions||[];r?r._renditionCache.applyRequestSetCache(s).then(e=>o(null,e),o).then(()=>B.prefetchRenditions(r)):o(null,new Array(s.length).fill(null))}}var r=n.getLibraryById(e.id);if(r){var a=d.getLibraryData(r);V.areManifestsEqual(a.manifest,e.current)?(s.log(H,"Commit skipped: nothing changed"),o(),i(null,!0)):V.areManifestsEqual(a.manifest,e.base)?(s.log(H,"Commit proceeding: fast-forward"),o(),x.storageInterface.updateExistingLibrary(n,r,e.current,e.base,void 0,i)):(s.log(H,"Commit fail: base mismatch"),i(!0))}else s.log(H,"Commit proceeding: creating new library"),o(),x.storageInterface.createNewLibrary(n,e.id,e.current,i)})}),_.addCallListener("getrenditionpath",function(e,t){var n=J(e);n?n.getThumbnailPath(e.size,function(e,n){t(n)}):t()}),_.addCallListener("startcomponentwrite",function(e,t){Q(e,!1),_.setPendingWriteState(e.userId,e.cloudId,e.id),(e.dependencies||[]).forEach(function(t){Q(t,!1),_.setPendingWriteDependency(e.userId,e.cloudId,e.id,t.userId,t.cloudId,t.id)}),t()}),_.addCallListener("loadpubliclibrary",function(e,t){var n=z(e);n&&n.isPublic?n.loadLibrary(e.id,e.url,function(){t()}):t()}),_.addCallListener("unloadpubliclibrary",function(e,t){var n=z(e),o=n&&n.getLibraryById(e.id);n&&n.isPublic&&o?n.unloadLibrary(o,function(){t()}):t()}),_.addCallListener("createBookmark",function(e,t){var n=z(e);n&&!n.isPublic?n.createBookmark(e.id,e.url,function(e,n){t({err:e&&d.prepareErrorForSerialization(e),bookmark:n})}):t()}),_.addCallListener("removeBookmark",function(e,t){var n,o=z(e);if(o&&!o.isPublic&&(o.bookmarks.forEach(function(t){t.id===e.id&&(n=t)}),n))return void o.removeBookmark(n,t);t()}),_.addCallListener("downloadfile",function(e,t){var n=z(e);n?n._syncManager.getAssetFromURL(e.url,e.headers,e.tempDir,void 0,function(e,n,o,i){t({err:e&&d.prepareErrorForSerialization(e),tempFilePath:n,etag:o,responseHeaders:i&&i.headers})}):t({err:new w(w.INVALID_PARAMETER,"Library collection not found")})}),_.addCallListener("downloadexternallink",function(e,t){var n=$(e);n?n.getContentPath(function(e,n){t({err:e&&d.prepareErrorForSerialization(e),path:n})}):t({err:new w(w.INVALID_PARAMETER,"Representation not found")})}),_.addCallListener("testexternallink",function(e,t){var n=$(e);n?n.testExternalLink(function(e,n){t({err:e&&d.prepareErrorForSerialization(e),success:n})}):t({err:new w(w.INVALID_PARAMETER,"Representation not found")})}),_.addListener("clearcachedexternallink",function(e){var t=$(e);t&&t.isExternalLink&&t.clearCachedExternalLink()}),_.addCallListener("fscall",function(e,t){try{e.args.push(function(){var e=Array.prototype.slice.call(arguments);t(e)}),i[e.method].apply(i,e.args)}catch(e){t([e&&d.prepareErrorForSerialization(e)])}}),_.addCallListener("fspipe",function(e,t){try{var n=i.createReadStream(e.readStream.path,e.readStream.options),o=i.createWriteStream(e.writeStream.path,e.writeStream.options),r=!1,a=function(e){return function(){r||(r=!0,t({event:e,args:Array.prototype.slice.call(arguments)}))}};["end","error"].forEach(function(e){n.on(e,a(e))}),o.on("error",a("error")),n.pipe(o)}catch(e){t({event:"error",args:[e&&d.prepareErrorForSerialization(e)]})}}),_.addCallListener("performElementAction",function(e,t){s.log(H,"Recieved Element Action "+JSON.stringify(e));var n=J(e,"elementId","libraryId");I.launch({appCode:e.appCode,minVersion:e.minVersion,element:n,action:e.action},function(e,n){t({err:e,data:n})})}),_.addCallListener("importlibrary",function(e,t){var n=z(e);n?n._doImportLibrary(e.path,function(e,o){ae(n),t({err:e&&d.prepareErrorForSerialization(e),libraryId:o&&o.id})},e.operationId):t({err:new w(w.INVALID_PARAMETER,"Library collection not found")})}),_.addCallListener("exportlibrary",function(e,t){var n=K(e);n?n.collection._doExportLibrary(n,e.path,function(e){t({err:e&&d.prepareErrorForSerialization(e)})},e.operationId):t({err:new w(w.INVALID_PARAMETER,"Library not found")})}),_.addListener("canceloperation",function(e){var t=z(e);t&&t._operationIdMap[e.operationId]&&t._operationIdMap[e.operationId].cancel()}),_.addCallListener("getImageDimensions",function(e,t){Y.getImageDimensions(e,function(e){t({data:e})})}),_.addCallListener("getfontdata",function(e,t){var n=z(e);n&&n.fontManager?n.fontManager.getFontData(e.fontId,function(e,n){t({err:e&&d.prepareErrorForSerialization(e),data:n})}):t()}),_.addCallListener("getaccesstoken",function(e,t){E.getClientAccessToken(e.userId,e.clientId,e.clientSecret,e.scopes,function(e,n){t({err:e&&d.prepareErrorForSerialization(e),data:n})})}),_.addCallListener("computesha",function(e,t){Y.computeSHA(e.path).then(e=>t({err:null,data:e}),e=>t({err:d.prepareErrorForSerialization(e)}))}),_.addCallListener("isfontavailable",function(e,t){se.isFontAvailable(e.fontName,e.matchFamily).then(e=>t({data:e}))});var A=b.getLoadedCollections();0===A.length?_.send("clearcollections"):A.forEach(function(e){_.send("collectionadded",d.getCollectionData(e)),_.send("syncstate",d.getSyncStateData(e)),e.isPublic||_.send("bookmarkschanged",c.getCollectionBookmarksData(e))})}};W.forEach(t=>t.on("connection",e)),Ie.initialize(),a.setValue("SERVICE_PORT",W[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 pe=function(){I.updateInstallationMap(),X.broadcast("environmentinfo",d.getEnvironmentData())};g.addListener("installApplication",pe),g.addListener("uninstallApplication",pe),g.addListener("updateApplication",function(){I.updateInstallationMap(!0),pe()});const he=new D;he.addChangeListener(()=>X.broadcast("environmentinfo",d.getEnvironmentData()));var ue={};function _e(e){var t=e.userId+"/"+e.cloudId;if(ue[t]=ue[t]||{lastBroadcast:0},!ue[t].pendingBroadcast){var n=a.getValue("SYNC_STATE_BROADCAST_THROTTLE"),o=(new Date).valueOf();if(o-ue[t].lastBroadcast<n)ue[t].pendingBroadcast=setTimeout(function(){delete ue[t].pendingBroadcast,_e(e)},n);else{ue[t].lastBroadcast=o;var i=d.getSyncStateData(e);if(X.broadcast("syncstate",i),"error"===e.syncState){var r=e.getPrimarySyncError();C.reportError("SyncError",F.errorToString(r))}}}}function fe(e){var t=d.getOperationsData(e);X.broadcast("operationschanged",t)}function me(e,t){s.log(H,"Load public collection: "+JSON.stringify(e)),b.loadPublicLibraryCollection(e,function(e,n){if(e)return s.log(H,"Error loading public libraries: "+e),void j(e);n.startPolling(),n.addSyncListener(function(){ae(n),_e(n)}),n.addOperationChangeListener(function(){fe(n)}),n.addChangeListener(function(){ae(n)}),ae(n),f.collectionsLoaded(),t()})}function Ee(e){s.log(H,"Load library collection: "+JSON.stringify(e)),b.loadLibraryCollection(e,function(t,n){if(t)return s.log(H,"Error loading libraries: "+t),void j(t);n.addSyncListener(function(){ae(n),_e(n)}),n.addOperationChangeListener(function(){fe(n)}),ae(n),f.collectionsLoaded(),function(e,t){var n=new U;a.getEnvironment().PUBLIC_HOSTS.forEach(function(t){var o={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?(o.CLOUD_ID=P.CP_CLOUD_ID+"_"+t.host,o.REQUIRES_COMMUNITY_SESSION=!0):o.CLOUD_ID=t.host,n.addOperation(me,[o])}),n.run(t)}(e,function(){c.validateBookmarks(),c.sendBookmarksChanged(X),n.addChangeListener(function(){c.validateBookmarks(),c.sendBookmarksChanged(X)}),p.fixRenditions(b.getLoadedCollections())})})}function ge(e,t,n){var o=E.getUserId();s.log(H,"Loading collection for active cloud: "+JSON.stringify(t));var i={getAccessToken:E.getAccessToken,USER_ID:o,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_"+o,{activeCloud:t,numClouds:n}),!t)return i.CLOUD_INFO={switchingEnabled:n>1},void Ee(i);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");i.CLOUD_ID=t.id,i.STORAGE_HOSTNAME=h.stripProtocolPrefix(l),i.COLLABORATION_HOSTNAME=h.stripProtocolPrefix(d),i.CLOUD_INFO={name:t.name,parameters:t.parameters,switchingEnabled:n>1,viewURI:h.stripProtocolPrefix(p),syncURI:c,useJumpToken:!1},Ee(i)}}const ye=e=>{P.ANALYTICS_ENABLED!==e&&(P.ANALYTICS_ENABLED=e,C.setEnabled(e),X.broadcast("environmentinfo",d.getEnvironmentData()))};var ve=!1;function Ae(e,t,n,o){if(!ve){var i=E.getUserId();i?(ve=!0,ye(!!a.getValue(`ANALYTICS_ENABLED_${i}`)),g.getAnalyticsState(),e?ge(t,n,o):E.hasEntitlement("cce_private",function(e){if(s.log(H,"cc_private entitlement: "+e),!0===e)A.getActiveCloud(function(e,t,n){ge(e,t,n),C.reportEvent("getActiveCloud",{error:String(e),cloudId:t&&t.id,numClouds:n,cce_private:!0})});else if(!1===e)ge(null),A.getActiveCloud(function(e,t,n){C.reportEvent("getActiveCloud",{error:String(e),cloudId:t&&t.id,numClouds:n,cce_private:!1})});else{var t=a.getValue("CLOUD_DATA_"+i);ge(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 Ce(){b.getLoadedCollections().forEach(function(e){b.unloadLibraryCollection(e)}),re={},ve=!1,ye(!1),f.collectionsUnloaded()}function Se(e,t,n){E.setProxyCredentials(e,t),S.setProxyCredentials(e,t),n&&E.hasEntitlement("cce_private",function(e){void 0===e?(E.clearUserId(),E.getUserId(),Ce(),Ae()):b.getLoadedCollections().forEach(function(e){"error"===e.syncState&&Z(e)})})}var Ie=new T;function Le(){var e="CCLibrary/"+d.getCodeVersion()+" "+r.platform()+"/"+r.arch()+"/"+r.release(),t={log:s.log,analytics:C,getNodeTunnelOptions:S.getNodeTunnelOptionsForURL,renditionGenerator:O.generate},n={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:S.getOSLocale()};s.log(H,`locale: ${n.LOCALE}`);var o,i=a.getValue("WHITELISTED_DOMAINS");i&&(n.WHITELISTED_DOMAINS=i),b.configure(t,n),I.updateInstallationMap(),x.storageInterface.onAcceptPushedBranch(function(e){var t=-1!==b.getLoadedCollections().indexOf(e.collection),n=e.collection.getLibraryById(e.id)===e;t&&n&&q(e)}),x.storageInterface.onDownloadRendition(function(e){X.broadcast("renditioncachechange",d.getElementRenditionCacheData(e))}),A.addListener("cloudChange",function(e,t,n){var o=t?t.id:P.DEFAULT_CLOUD_ID;b.getLoadedCollections().some(function(e){return e.cloudId===o})?s.log(H,"Active cloud the same as already loaded"):(s.log(H,"Active cloud changed"),Ce(),Ae(!0,e,t,n),C.reportEvent("cloudChange",{cloudId:o,numClouds:n}))});var c=!1;y.addListener("libraryChange",function(e){o?c=!0:(ee(e),o=setTimeout(function(){c&&ee(),o=null,c=!1},a.getValue("CORE_SYNC_NOTIFICATION_DEBOUNCE")))}),y.addListener("bookmarkChange",function(){b.getLoadedCollections().forEach(function(e){e.isPublic||e.syncBookmarks()})}),y.addListener("fileSyncState",function(e,t){!function(e,t){if(ne!==e){if(clearTimeout(te),"normal"!==e){var n=a.getValue("CORE_SYNC_ANALYTICS_WAIT");te=setTimeout(function(){C.reportEvent("fileSyncState",{state:e,isNotification:!!t,reportingDelay:n})},n)}ne=e,b.isSyncingEnabled()&&"turned_off"===ne?(s.log(H,"Syncing disabled"),b.disableSyncing(),X.broadcast("environmentinfo",d.getEnvironmentData())):b.isSyncingEnabled()||"turned_off"===ne||(s.log(H,"Syncing enabled"),b.enableSyncing(),X.broadcast("environmentinfo",d.getEnvironmentData()),ee())}}(e,t)}),g.addListener("signOut",function(){Ce(),E.clearUserId()}),g.addListener("signIn",function(){Ae()}),g.addListener("proxySettingsChanged",function(e,t){Se(e,t,!0)});function l(e,t,n,o){L.sendToast({title:k.translate("LIBS_OPEN_IN_TITLE"),message:k.translate(e),key:t,data:n,overridable:o})}function h(e,t){var n={"ui.search_keyword":t.launchInfo.search_keyword,"event.context_guid":t.launchInfo.context_guid,"event.type":e,"event.category":"STOCK","event.subcategory":"Open-In","env.com.name":"stock_openin","consumer.name":t.launchInfo.appCode,"consumer.version":t.productInfo?t.productInfo.version:t.launchInfo.minVersion,"consumer.platform":r.platform(),"consumer.os_version":r.release(),"openin.element_id":t.launchInfo.elementRef,"openin.element_type":t.launchInfo.elementType,"openin.app_launch_status":t.productInfo?t.productInfo.isAlreadyRunning?"Running":"Launched":"Unknown"};t.error&&(n["event.error_desc"]=t.error),t.element&&(n["event.cloud_id"]=t.element.library.collection.cloudId,n["content.id"]=_.getElementStockId(t.element),n["content.status"]=_.getElementStockLicense(t.element),n["content.type"]=t.element.getPrimaryRepresentation().type),C.reportEvent("Library-Process-Open-In",n)}function u(e,t){s.log(H,"Open Stock -  launch product "+e.elementRef),I.launch({appCode:e.appCode,minVersion:e.appVersion||"0",element:t,action:"openStock"},function(n,o){if(n)return s.log(H,"Open Stock - Error opening product "+n),l("LIBS_OPEN_IN_PRODUCT_LAUNCH_FAILED_"+e.appCode),void h("error",{launchInfo:e,error:"Launch product failed",productInfo:o,element:t});s.log(H,"Open Stock - Open request success"),h("useElement",{launchInfo:e,productInfo:o,element:t})})}g.addListener("analyticsStateChanged",e=>{const t=E.getUserId();t&&(a.setValue(`ANALYTICS_ENABLED_${t}`,e),ye(e))}),g.getProxyCredentials(function(e,t){Se(e,t),Ae(),setTimeout(de,100)}),L.addListener("clickNotification",function(e){"LAUNCH_CC"===e&&I.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 n=I.appStatus({appCode:t.appCode,minVersion:t.appVersion||"0"});if("APP_NOT_INSTALLED"===n)return l("LIBS_OPEN_IN_NOT_INSTALLED_"+t.appCode,"LAUNCH_CC"),void h("notify",{launchInfo:t});if("NO_COMPATIBLE_VERSION"===n)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,n){if(e){s.log(H,"Open Stock - Error from find element "+e);var o="COLLECTION_NOT_FOUND"===e?"LIBS_OPEN_IN_COLLECTION_NOT_FOUND":"LIBS_OPEN_IN_DOWNLOAD_ERROR";return l(o),void h("error",{launchInfo:t,error:o})}s.log(H,"Open Stock -  downloading element "+t.elementRef),n.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"});B.prefetchRenditionsForElement(n,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(n.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),u(t,n))})):u(t,n)})})})}}),v.addListener("sharing.collaboration.updaterole",function(){b.getLoadedCollections().forEach(function(e){e.isPublic||Z(e,!0)})}),v.addListener("com.adobe.system.inform.typekit.generic.entitlementschanged",()=>ce(!0)),S.addListener("change",function(e){e&&g.getProxyCredentials(function(e,t){Se(e,t,!0)})}),S.addListener("error",function(e){C.reportError("ProxyResolverError",e)})}O.test(function(){}),l.obtainProcessLock("lockfile",function(e){e||G?S.getRootCA(function(e,t){if(t&&t.length>0){var o=n(26).globalAgent.options;o.ca=(o.ca||[]).concat(t)}if(G)return console.log("Testing OK"),void process.exit(0);Le()}):process.exit(1)}),e.exports={shutdown:function(){W.forEach(e=>e.close()),g.removeAllListeners(),y.removeAllListeners(),v.removeAllListeners(),A.removeAllListeners(),S.removeAllListeners(),he.removeAllListeners(),se.removeAllListeners(),Ie.shutdown(),b.removeLoadedCollectionsListener(ie),x.storageInterface.removeOnAcceptPushedBranchListeners(),Ce()},loadPublicCollection:me,unloadCollections:Ce,handleUncaughtException:j,waitForWSSInitialization:function(){return W[1].waitForInitialization()}}},function(e,t,n){var o=n(4),i=n(7);function r(e,t,n){e?this._setData(e):this._data={},this._readOnly=t,this._isRoot=n}r.ROOT_PATH="/",Object.defineProperties(r.prototype,{id:{get(){return this._data.id},set(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(this._owner)throw new o(o.READ_ONLY,"Cannot change the id of a node that is part of a branch or element.");if("string"!=typeof e||""===e)throw new o(o.INVALID_PARAMS,"Expecting a non-empty string.");this._data.id=e,this._setDirty()}},name:{get(){return this._data.name},set(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a string or undefined.");this._data.name=e,this._setDirty()}},type:{get(){return this._data.type},set(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a string or undefined.");this._data.type=e,this._setDirty()}},relationship:{get(){return this._data.rel},set(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a string or undefined.");this._data.rel=e,this._setDirty()}},path:{get(){return this._isRoot?"/":this._data.path},set(e){if(e!==this.path){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(this._isRoot)throw new o(o.READ_ONLY,"Cannot change the path of the root node.");if(e&&!i.isValidPath(e))throw new o(o.INVALID_PARAMS,"Expecting a valid path or undefined.");this._owner?this._owner._setPathOfNode(this,e||void 0):(this._data.path=e||void 0,this._parentPath=""),this._setDirty()}}},parentPath:{get(){return this._parentPath},set(){throw new o(o.READ_ONLY,"parentPath is read-only.")}},absolutePath:{get(){var e=this.path;return this._isRoot?e:e&&this._owner?i.appendPathElements(this._parentPath,e):void 0},set(){throw new o(o.READ_ONLY,"absolutePath is read-only.")}},isRoot:{get(){return this._isRoot},set(){throw new o(o.READ_ONLY,"isRoot is read-only.")}}}),r.prototype.getLink=function(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "relationship" must be a string');return this._data._links?this._data._links[e]:void 0},r.prototype.setLink=function(e,t){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("object"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "link" must be an object.');if("string"!=typeof t)throw new o(o.INVALID_PARAMS,'Param "relationship" must be a string');var n=this._data._links;n||(n=this._data._links={}),n[t]=e,this._setDirty()},r.prototype.removeLink=function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "relationship" must be a string');var t=this._data._links;t&&(delete t[e],Object.keys(t).length<1&&delete this._data._links,this._setDirty())};var a={components:!0,children:!0,"manifest-format-version":!0,id:!0,name:!0,type:!0,state:!0,local:!0},s={components:!0,children:!0,rel:!0,path:!0,id:!0,name:!0,type:!0};r.prototype.getCustomKeys=function(){var e,t=[],n=Object.keys(this._data),o=n.length;for(e=0;e<o;e++){var i=n[e];(this._isRoot?a[i]:s[i])||t.push(i)}return t},r.prototype.getValue=function(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "key" must be a string');if("children"===e||"components"===e)throw new o(o.INVALID_PARAMS,"Illegal key");return this._data[e]},r.prototype.setValue=function(e,t){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "key" must be a string');if("children"===e||"components"===e)throw new o(o.INVALID_PARAMS,"Illegal key");this._data[e]=t,this._setDirty()},r.prototype.removeValue=function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "key" must be a string');if("children"===e||"components"===e)throw new o(o.INVALID_PARAMS,"Illegal key");delete this._data[e],this._setDirty()},r.prototype.copy=function(){var e=null,t=this._data.children,n=this._data.components;try{t&&delete this._data.children,n&&delete this._data.components,e=new r(JSON.parse(JSON.stringify(this._data)))}finally{t&&(this._data.children=t),n&&(this._data.components=n)}return e},r.prototype.isEqualTo=function(e,t,n){return this._isEqual(this._data,e._data,i.merge({children:!0,components:!0},t),n)},r.prototype._isEqual=function(e,t,n,o){var r,a,s,c,l,d,p;if(!i.objectsEqual(e,t,n))return!1;if(a=e.components,s=t.components,(c=a?a.length:0)!==(s?s.length:0))return!1;if(c)for(r=0;r<c;r++){for(l=a[r],d=null,p=0;p<c;p++)if(l.id===s[p].id){d=s[p];break}if(!d)return!1;if(!i.objectsEqual(l,d,o))return!1}if(a=e.children,s=t.children,(c=a?a.length:0)!==(s?s.length:0))return!1;if(c)for(r=0;r<c;r++)if(!this._isEqual(a[r],s[r],n,o))return!1;return!0},r.prototype._setData=function(e){var t=this._verify(e);if(null===t)return this._data=e,this;throw t},r.prototype._verify=function(e){return"string"!=typeof e.id?new o(o.INVALID_DATA,"Node is missing an id of type string"):null},r.prototype._setDirty=function(){this._owner&&this._owner._setDirty()},e.exports=r},function(e,t,n){var o=n(49),i=n(4),r=n(7);function a(e,t,n){(this._owner=t,e)?e=this._setData(e,n):(e={id:r.generateUuid()},this._core=new o(e,this,n),this._data=e)}Object.defineProperties(a.prototype,{rootNode:{get(){return this._core.rootNode},set(e){this._core.rootNode=e}},name:{get(){return this._core.rootNode.name},set(e){var t=this._core;if(t._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new i(i.INVALID_PARAMS,"Expecting a string or undefined.");t.rootNode.name=e}},type:{get(){return this._core.rootNode.type},set(e){var t=this._core;if(t._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if("string"!=typeof e||""===e)throw new i(i.INVALID_PARAMS,"Expecting a non-empty string.");t.rootNode.type=e}},compositeHref:{get(){return this._owner.compositeHref},set(){throw new i(i.READ_ONLY,'Property "compositeHref" is read-only.')}},_localStorage:{get(){return this._core._localStorage},set(e){this._core._localStorage=e}},hasLocalStorage:{get(){return this._core.hasLocalStorage},set(e){this._core.hasLocalStorage=e}},_isDirty:{get(){return this._core._isDirty},set(e){this._core._isDirty=e}},isDirty:{get(){return this._isDirty},set(e){this._core.isDirty=e}},changeCount:{get(){return this._core.changeCount},set(e){this._core.changeCount=e}}}),a.prototype.getChildWithId=function(e){return this._core.getChildWithId(e)},a.prototype.getChildWithAbsolutePath=function(e){return this._core.getChildWithAbsolutePath(e)},a.prototype.getChildrenOf=function(e){return this._core.getChildrenOf(e)},a.prototype.addChild=function(e,t,n,o){return this._core.addChild(e,t,n,o)},a.prototype.removeChild=function(e){return this._core.removeChild(e)},a.prototype.moveChild=function(e,t,n){return this._core.moveChild(e,t,n)},a.prototype.copyChild=function(e,t,n,o,i,r){return this._core.copyChild(e,t,n,o,i,r)},a.prototype.allComponents=function(){return this._core.allComponents()},a.prototype.getComponentWithId=function(e){return this._core.getComponentWithId(e)},a.prototype.getComponentWithAbsolutePath=function(e){return this._core.getComponentWithAbsolutePath(e)},a.prototype.getComponentsOf=function(e){return this._core.getComponentsOf(e)},a.prototype.addComponent=function(e,t,n,o,i,r,a,s,c,l){return this._core.addComponent(e,t,n,o,i,r,a,s,c,l)},a.prototype.addComponentWithUploadResults=function(e,t,n,o,i){return this._core.addComponentWithUploadResults(e,t,n,o,i)},a.prototype.updateComponent=function(e,t,n,o){return this._core.updateComponent(e,t,n,o)},a.prototype.updateComponentWithUploadResults=function(e,t){return this._core.updateComponentWithUploadResults(e,t)},a.prototype.removeComponent=function(e){return this._core.removeComponent(e)},a.prototype.moveComponent=function(e,t){return this._core.moveComponent(e,t)},a.prototype.copyComponent=function(e,t,n,o,i){return this._core.copyComponent(e,t,n,o,i)},a.prototype.assetOfComponent=function(e,t){return this._core.assetOfComponent(e,t)},a.prototype.parse=function(e){if("string"!=typeof e)throw new i(i.INVALID_PARAMS,'Param "data" must be a string');var t=null;try{t=JSON.parse(e)}catch(e){throw new i(i.INVALID_JSON,"Manifest could not be parsed. Underlying error: "+e.message)}return this._setData(t,this._core._readOnly)},a.prototype.copy=function(){return new a(JSON.parse(JSON.stringify(this._data)),this._owner)},a.prototype._updateLocalDataFromBranch=function(e){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(!this._localStorage)throw new i(i.NO_LOCAL_STORAGE,"No local storage.");if(!e._localStorage)throw new i(i.NO_LOCAL_STORAGE,"No local storage for source.");if(this._localStorage.compositePath!==e._localStorage.compositePath)throw new i(i.INVALID_PARAMS,"Branches must have same storage path.");this._core._localStorage.copyLocalStorageData(e,e._core._local(),this,this._core._local()),this._core._copySourceHrefsFrom(e._core)},a.prototype._verify=function(e){return"string"!=typeof e.id?new i(i.INVALID_DATA,"Element is missing an id of type string"):"string"!=typeof e.name?new i(i.INVALID_DATA,"Element is missing a name of type string"):"string"!=typeof e.type?new i(i.INVALID_DATA,"Element is missing a type of type string"):null},a.prototype._setData=function(e,t){var n=this._verify(e);if(null===n)return this._core=new o(e,this,t),this._data=e,this;throw n},a.prototype._local=function(){return this._core._local()},a.prototype._setDirty=function(e){this._core._setDirty(e)},a.prototype._setPathOfNode=function(e,t){this._core._setPathOfNode(e,t)},a.prototype._verifyIntegrity=function(e,t,n){return this._core._verifyIntegrity(e,t,n)},e.exports=a},function(e,t,n){var o=n(4),i=n(7),r=n(13);function a(e,t){if("string"!=typeof e||""===e)throw new o(o.INVALID_PARAMS,'Param "compositePath" must be a non-empty string.');this._compositePath=e,this._preserveFileExtensions=t,this._inMemoryBranchesAndElements=[],this._inflightComponents=[]}Object.defineProperties(a.prototype,{compositePath:{get(){return this._compositePath},set(e){if("string"!=typeof e||""===e)throw new o(o.INVALID_PARAMS,'Param "compositePath" must be a non-empty string.');this._compositePath=e}}}),a.prototype.currentManifestPath=function(){return this._compositePath+"/manifest"},a.prototype.currentBaseManifestPath=function(){return this._compositePath+"/manifest.base"},a.prototype.pulledManifestPath=function(){return this._compositePath+"/pull.manifest"},a.prototype.pushedManifestPath=function(){return this._compositePath+"/push.manifest"},a.prototype.resolvePulledBranch=function(e,t){var n=this;r.writeFileAtomically(this.currentManifestPath(),e.localData,"utf8",function(e){e?(e.code!==o.OUT_OF_SPACE&&(e=new o(o.INVALID_STATE,"Could not write current manifest.",e)),t(e)):r.move(n.pulledManifestPath(),n.currentBaseManifestPath(),!1,function(e){e?t(new o(o.INVALID_STATE,"Could not move pull manifest.",e)):t()})})},a.prototype.acceptPushedBranch=function(e,t){var n=this;r.writeFileAtomically(this.currentManifestPath(),e.localData,"utf8",function(e){e?(e.code!==o.OUT_OF_SPACE&&(e=new o(o.INVALID_STATE,"Could not write current manifest.",e)),t(new o(o.INVALID_STATE,"Could not write current manifest.",e))):r.move(n.pushedManifestPath(),n.currentBaseManifestPath(),!1,function(e){e?t(new o(o.INVALID_STATE,"Could not move push manifest.",e)):n._deleteJournal(t)})})},a.prototype.discardPulledBranch=function(e){r.deleteFile(this.pulledManifestPath(),e)},a.prototype.discardPushedBranch=function(e){var t=this;r.deleteFile(this.pushedManifestPath(),function(n){n?e(n):t._deleteJournal(e)})},a.prototype.discardBaseBranch=function(e){r.deleteFile(this.currentBaseManifestPath(),e)},a.prototype.registerInMemoryBranchOrElement=function(e){if(this._inMemoryBranchesAndElements.indexOf(e)>=0)throw new o(o.INVALID_STATE,"Branch or element is already registered.");this._inMemoryBranchesAndElements.push(e)},a.prototype.unregisterInMemoryBranchOrElement=function(e){var t=this._inMemoryBranchesAndElements.indexOf(e);if(t<0)throw new o(o.INVALID_STATE,"Unknown branch or element.");this._inMemoryBranchesAndElements.splice(t,1)},a.prototype._deleteJournal=function(e){r.deleteFile(this.pushJournalPath(),e)};var s=/(\/)|(\.$)/;a.prototype.componentAssetName=function(e,t){var n=t["copyOnWrite#storageIds"],o=n?n[e.id]:null;return o&&s.test(o)&&(o=null),o},a.prototype.componentAssetPath=function(e,t){var n=this.componentAssetName(e,t);return n?this._componentPathFromName(n):null},a.prototype.ingestComponentAsset=function(e,t,n,i,a){var s=this,c=this._newFileNameForComponent(e),l=this._componentPathFromName(c);this._inflightComponents.push(c);var d=function(t){if(!t)try{s._setComponentName(e,i,c)}catch(e){t=e}var n=s._inflightComponents.indexOf(c);n<0&&!t&&(t=new o(o.INVALID_STATE,"Could not find inflight component.")),s._inflightComponents.splice(n,1),a(t)};n?r.copyFile(t,l,d):r.move(t,l,!0,d)},a.prototype.removeComponentAsset=function(e,t){var n=t["copyOnWrite#storageIds"];n&&delete n[e.id]},a.prototype.componentIds=function(e){var t=e["copyOnWrite#storageIds"];return t?Object.keys(t):[]},a.prototype.copyLocalStorageData=function(e,t,n,o){var i,r=n.allComponents(),a=r.length,s=t["copyOnWrite#storageIds"];if(s){var c=o["copyOnWrite#storageIds"];for(c||(c=o["copyOnWrite#storageIds"]={}),i=0;i<a;i++){var l=r[i],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 n,i,a,s,c,l=this,d=function(e){l._deleteComponentAsset(e,function(e){e&&!n&&(n=e),0===--c&&t(n)})},p=function(){try{var e,n=s.length,o=[];for(e=0;e<n;e++){var r=s[e].name,p=s[e].info;!i[r]&&p.mtime.getTime()<a&&l._inflightComponents.indexOf(r)<0&&o.push(r)}if((c=n=o.length)>0)for(e=0;e<n;e++)d(o[e])}catch(e){return void t(e)}0===c&&t()};this._gatherComponentAssetNames([this.currentManifestPath(),this.currentBaseManifestPath(),this.pulledManifestPath(),this.pushedManifestPath()],e,function(e,r,c,l){if(n)t(n);else{if(!e)try{if(r<1||!l)throw new o(o.INVALID_STATE,r<1?"No manifest found.":"Invalid time stamp");i=c,a=l}catch(t){e=t}e&&(n=e),s&&(n?t(n):p())}}),r.directoryListing(this._compositePath+"/components",function(e,o){if(n)t(n);else{if(!e)try{s=o}catch(t){e=t}e&&(n=e),i&&(n?t(n):p())}})},a.prototype.tempPathForComponent=function(){return this._compositePath+"/tmp/"+i.generateUuid()},a.prototype.deleteTempFiles=function(e){r.deleteDirectory(this._compositePath+"/tmp",e)},a.prototype.clientDataPath=function(){return this._compositePath+"/clientdata"},a.prototype.pushJournalPath=function(){return this._compositePath+"/push.journal"},a.prototype._copyComponentMapping=function(e,t,n,o){var i=t["copyOnWrite#storageIds"];if(i){var r=o["copyOnWrite#storageIds"];r||(r=o["copyOnWrite#storageIds"]={});var a=i[e];return a&&(r[n]=a),a}},a.prototype._componentPathFromName=function(e){return this._compositePath+"/components/"+e},a.prototype._newFileNameForComponent=function(e){var t=i.generateUuid();if(this._preserveFileExtensions){var n=e.path?i.filePathComponents(e.path).extension:null;n&&(t=t+"."+n)}return t},a.prototype._setComponentName=function(e,t,n){var o=t["copyOnWrite#storageIds"];o||(o=t["copyOnWrite#storageIds"]={}),o[e.id]=n},a.prototype._gatherComponentAssetNames=function(e,t,n){try{var o,a,s={},c=t||i.timeStamp(!0),l=e.length,d=l,p=0,h=function(e){if(e){e=e["copyOnWrite#storageIds"];var t,n=Object.keys(e);for(t=0;t<n.length;t++){var o=e[n[t]];s[o]=!0}}},u=function(e){r.exists(e,function(t){t?(p++,r.info(e,function(t,o){if(!t)try{var i=o.mtime.getTime();i<c&&(c=i),r.readFile(e,"utf8",function(e,t){if(d--,!e)try{t=JSON.parse(t),h(t.local)}catch(t){e=t}e&&!a&&(a=e),0===d&&n(a,p,s,c)})}catch(e){t=e}t&&(d--,a||(a=t),0===d&&n(a))})):0===--d&&n(a,p,s,c)})};for(o=0;o<l;o++)u(e[o]);for(l=this._inMemoryBranchesAndElements.length,o=0;o<l;o++)h(this._inMemoryBranchesAndElements[o]._local())}catch(e){n(e)}},a.prototype._deleteComponentAsset=function(e,t){r.deleteFile(this._componentPathFromName(e),t)},e.exports=a},function(e,t,n){var o=n(43),i=n(4),r=n(7),a=r.appendPathElements;function s(e,t){if(o.call(this,e,t),!this._endPoint)throw new i(i.INVALID_PARAMS,"Could not determine endpoint from: "+t);this.authenticationWhitelist=["adobe.com","adobe.io","fotolia.net"]}s.prototype=Object.create(o.prototype),s.prototype.name="AdobeCommunitySession",s.FileContent=o.FileContent,s.StreamProvider=o.StreamProvider,s.prototype.getCompositeManifestHref=function(e){var t=this._resolveUrl(e.href);if(!t)throw new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+t);return a(t,"manifest")},s.prototype.getComponent=function(e,t,n){var o=this.getComponentHref(e,e.version);return this.getAsset(o,void 0,t,n)},s.prototype.getRenditionOfComponent=function(e,t,n,o,i,r){var a=this.getComponentRenditionHref(e,e.version,t,n,o);return this.getAsset(a,{accept:t},i,r)},s.prototype.getCompositeManifest=function(e,t,n){var o=e.href;return o&&(o=this._resolveUrl(o)),o?(o=a(o,"manifest"),this.getAssetAsType(o,"text",t,n)):n(new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+o))},s.prototype.headRequest=function(e,t){return this._service.invoke("HEAD",e,{},void 0,void 0,function(e,n){if(e)return t(e);t(e,n)})},s.prototype.getComponentHref=function(e,t){var n,o=e._owner;if(!o||!o.compositeHref)throw new i(i.INVALID_STATE,"Component must be part of a branch of a bound composite.");return o._core&&(n=o._core._getSourceHrefOfComponent(e)),n||this._constructComponentHref(o.compositeHref,e,t)},s.prototype.getComponentRenditionHref=function(e,t,n,o,r){var a=e._owner;if(!a||!a.compositeHref)throw new i(i.INVALID_STATE,"Component must be part of a branch of a bound composite.");if(a._core&&a._core._getSourceHrefOfComponent(e))throw new i(i.INVALID_STATE,"Getting a rendition of a source href not implemented.");return this._constructComponentRenditionHref(a.compositeHref,e,t,n,o,r)},s.prototype._constructComponentHref=function(e,t,n){var o=t.absolutePath.slice(1),i=a(this._resolveUrl(e),o);return i&&void 0!==n&&(this._hrefUsesContentApis(e)?i+="/version/"+n:i+="?version="+n),i};var c=/^\/?content\/2\/[^/]+\/[^/]+/,l=/^\/?api\/v2\/[^/]+\/assets\/[^/]+/,d={"image/jpeg":"jpg","image/png":"png"};s.prototype._constructComponentRenditionHref=function(e,t,n,o,a,s){var p,h,u=t.absolutePath.slice(1),_=r.parseURI(e).path;if("/content/2/"===_.slice(0,"/content/2/".length)){var f=d[o];if(!f)throw new i(i.INVALID_PARAMS,"Unsupported rendition media type: "+o);if(!((p=c.exec(_))&&p.length>0))throw new i(i.INVALID_PARAMS,"Failed to parse composite href: "+e);h=this._resolveUrl(r.appendPathElements(p[0],"rendition",u,"version",n,"format",f,"dimension",a,"size",String(s)))}else{if(!((p=l.exec(_))&&p.length>0))throw new i(i.INVALID_PARAMS,"Failed to parse composite href: "+e);h=this._resolveUrl(r.appendPathElements(p[0],"rendition",a,String(s),u)+"?version="+n)}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,n){var o=n(10),i=n(6),r={getCollectionBookmarksData:function(e){var t=[];return e.bookmarks&&e.bookmarks.forEach(function(e){t.push({_id:e.id,_url:e.url})}),{isPublic:e.isPublic,userId:e.userId,cloudId:e.cloudId,bookmarks:t}},validateBookmarks:function(){var e=[];o.getLoadedCollections().forEach(function(t){t.isPublic||(e=e.concat(t.bookmarks))}),e.forEach(function(e){o.getLoadedCollections().forEach(function(t){t.isPublic&&!t.getLibraryById(e.id)&&t.canLoadLibrary(e.url)&&t.loadLibrary(e.id,e.url,function(t,n){t?i.log("BookmarkUtil","Error loading a public library: "+e.id+" url: "+e.url+" error: "+t):n&&delete n._loadedExternally})})}),o.getLoadedCollections().forEach(function(e){e.isPublic&&e.libraries.forEach(function(t){t._loadedExternally||(o.getLoadedCollections().some(function(e){return!e.isPublic&&e.findBookmark(t)})||e.unloadLibrary(t,function(e){e&&i.log("BookmarkUtil","Error unloading a public library: "+e)}))})})},sendBookmarksChanged:function(e){o.getLoadedCollections().forEach(function(t){t.isPublic||e.broadcast("bookmarkschanged",r.getCollectionBookmarksData(t))})}};e.exports=r},function(e,t,n){var o=n(0),i=n(2),r=n(18),a=n(15),s=n(5);function c(e,t){this._library=e,this._listenerManager=new s(["change"]),this._setDCXNode(t)}c.prototype._setDCXNode=function(e){this._dcxNode=e,this._deletedLocally=!1},c.prototype._getEventData=function(e){return this._dcxNode.getValue(o[e+"_DATA_KEY"])||{}},c.prototype._getEventContext=function(e){var t=JSON.parse(JSON.stringify(this._getEventData(e)));return delete t.deviceId,delete t.userId,t},c.prototype._isLocalEvent=function(e){var t=this._getEventData(e).deviceId;if(t&&o.DEVICE_ID)return t===o.DEVICE_ID},c.prototype._markDeletedLocally=function(e){this._deletedLocally=e,e&&this._listenerManager.removeAll()},c.prototype._commit=function(){this._updateModifiedTime(),this._library._commit(),this._listenerManager.notify("change"),r.reportUpdateGroup(this)},c.prototype._commitMetadata=function(){this._library._commit(),this._listenerManager.notify("change")},c.prototype._updateCreatedTime=function(){var e=(new Date).valueOf();this._dcxNode.setValue(o.CREATED_KEY,e),this._dcxNode.setValue(o.MODIFIED_KEY,e),this._setEventData("CREATED"),this._setEventData("MODIFIED")},c.prototype._updateModifiedTime=function(){var e=(new Date).valueOf();this._dcxNode.setValue(o.MODIFIED_KEY,e),this._setEventData("MODIFIED")},c.prototype._toJSON=function(){return{id:this.id,classifierName:this.classifierName,name:this.name,order:this.order}},c.prototype.toString=function(){return JSON.stringify(this._toJSON())},c.prototype.jasmineToString=function(){return this.toString()},c.prototype._setEventData=function(e){if(o.DEVICE_ID){var t={userId:this.library.collection.userId,deviceId:o.DEVICE_ID};o.DEVICE_DESCRIPTION&&(t.device=o.DEVICE_DESCRIPTION),o.APP_DESCRIPTION&&(t.app=o.APP_DESCRIPTION),this._dcxNode.setValue(o[e+"_DATA_KEY"],t)}else this._clearEventData(e)},c.prototype._clearEventData=function(e){this._dcxNode.getValue(o[e+"_DATA_KEY"])&&this._dcxNode.removeValue(o[e+"_DATA_KEY"])},Object.defineProperties(c.prototype,{id:{get(){return this._dcxNode.id},set(){throw new i(i.READ_ONLY,"Cannot change the id of an existing group",this._library.id)}},library:{get(){return this._library},set(){throw new i(i.READ_ONLY,"library is a read-only property",this._library.id)}},name:{get(){return this._dcxNode.name},set(e){if(a.checkDeletedState(this),!this.isWritable)throw new i(i.NOT_ALLOWED,"you do not have write access to this library",this._library.id);this._dcxNode.name=e,this._commit()}},classifierName:{get(){return this._dcxNode.getValue(o.CLASSIFIER_KEY)},set(){throw new i(i.READ_ONLY,"classifierName is a read-only property",this._library.id)}},order:{get(){return this._dcxNode.getValue(o.ORDER_KEY)},set(e){if(!this.isWritable)throw new i(i.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if("string"!=typeof e)throw new i(i.INVALID_PARAMETER,"order must be a string",this._library.id);this._dcxNode.setValue(o.ORDER_KEY,e),this._commitMetadata(),r.reportUpdateGroupMetadata(this,e)}},isWritable:{get(){return this._library.isWritable},set(){throw new i(i.READ_ONLY,"isWritable is a read-only property",this.id)}},created:{get(){return this._dcxNode.getValue(o.CREATED_KEY)},set(){throw new i(i.READ_ONLY,"Cannot change the created timestamp of a group directly",this._library.id)}},createdBy:{get(){return this._getEventData("CREATED").userId},set(){throw new i(i.READ_ONLY,"Cannot change the createdBy property of a group directly",this._library.id)}},createdContext:{get(){return this._getEventContext("CREATED")},set(){throw new i(i.READ_ONLY,"Cannot change the createdContext property of a group directly",this._library.id)}},wasCreatedLocally:{get(){return this._isLocalEvent("CREATED")},set(){throw new i(i.READ_ONLY,"Cannot change the wasCreatedLocally property of a group directly",this._library.id)}},modified:{get(){return this._dcxNode.getValue(o.MODIFIED_KEY)},set(){throw new i(i.READ_ONLY,"Cannot change the modified timestamp of a group directly",this._library.id)}},modifiedBy:{get(){return this._getEventData("MODIFIED").userId},set(){throw new i(i.READ_ONLY,"Cannot change the modifiedBy property of a group directly",this._library.id)}},modifiedContext:{get(){return this._getEventContext("MODIFIED")},set(){throw new i(i.READ_ONLY,"Cannot change the modifiedContext property of a group directly",this._library.id)}},wasModifiedLocally:{get(){return this._isLocalEvent("MODIFIED")},set(){throw new i(i.READ_ONLY,"Cannot change the wasModifiedLocally property of a group directly",this._library.id)}},isDeletedLocally:{get(){return this._deletedLocally},set(){throw new i(i.READ_ONLY,"isDeletedLocally is a read-only property",this._library.id)}}}),c.prototype.addChangeListener=function(e){a.checkDeletedState(this),this._listenerManager.add("change",e)},c.prototype.removeChangeListener=function(e){this._listenerManager.remove("change",e)},Object.freeze(c),Object.seal(c.prototype),e.exports=c},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){var o=n(1),i=n(0),r=n(97),a=n(18),s=n(2),c=n(98),l=n(21),d=n(15),p=n(16),h=n(11),u=n(5);function _(e,t){this._library=e,this._renditionFetchLock=new l,this._listenerManager=new u(["change"]),this._transactionCount=0,this._setDCXNode(t,!0)}_.prototype._setDCXNode=function(e,t){var n=this,o={};this._representations&&this._representations.forEach(function(e){o[e.id]=e}),this._dcxNode=e,this._representations=[],this._deletedLocally=!1,this._library._dcxBranch.getChildrenOf(e).forEach(function(e){var t=o[e.id];t?(t._setDCXNode(e),delete o[e.id]):t=new r(n,e),n._representations.push(t)}),this._library._dcxBranch.getComponentsOf(e).forEach(function(e){var t=o[e.id];t?(t._setDCXComponent(e),delete o[e.id]):t=new r(n,void 0,e),n._representations.push(t)}),d.sortRepresentations(this._representations),t||this.library._renditionCache.clearCache(this),this._displayName=void 0},_.prototype._markDeletedLocally=function(e){this._deletedLocally=e,this._representations.forEach(function(t){t._markDeletedLocally(e)}),e&&this._listenerManager.removeAll()},_.prototype._removeAllListeners=function(){this._listenerManager.removeAll()},_.prototype._toJSON=function(){var e={id:this.id,name:this.name,type:this.type,description:this.description,representations:[]};return this._representations.forEach(function(t){e.representations.push(t._toJSON())}),e.representations.sort(function(e,t){return e.type>t.type?1:e.type<t.type?-1:0}),e},_.prototype._addRepresentation=function(e,t){void 0!==t?this._representations.splice(t,0,e):this._representations.push(e)},_.prototype._removeRepresentation=function(e){var t=this._representations.indexOf(e);-1!==t&&this._representations.splice(t,1)},_.prototype._validateRelationship=function(e){if(-1===i.VALID_RELATIONS.indexOf(e))throw new s(s.INVALID_PARAMETER,"Unsupported relationship",this._library.id);this._representations.length>0&&"primary"===e&&this._representations.forEach(t=>{if(t!==e&&"primary"===t.relationship)throw new s(s.INVALID_PARAMETER,"Cannot have more than one primary representation",this._library.id)})},_.prototype._doCreateRepresentation=function(e,t,n){var o=this._library._dcxBranch.addChild(void 0,void 0,void 0,this._dcxNode);if(o.type=e,o.setValue(i.RELATIONSHIP_KEY,t),void 0===n){var a=this.representations[this.representations.length-1],s=Math.max(this.representations.length,a?a._getOrder()+1:0);o.setValue(i.REPRESENTATION_ORDER_KEY,s)}else o.setValue(i.REPRESENTATION_ORDER_KEY,n),this._representations.forEach(function(e,t){if(t>=n){var o=e._getDCXElement(),r=o.getValue(i.REPRESENTATION_ORDER_KEY);void 0!==r&&o.setValue(i.REPRESENTATION_ORDER_KEY,r+1)}});var c=new r(this,o);return this._addRepresentation(c,n),c},_.prototype._getEventData=function(e,t){var n=!t&&{},o=this._dcxNode.getValue(i[e+"_DATA_KEY"])||n;if("CREATED"!==e&&"DESCRIPTION"!==e){var r=this._dcxNode.getValue(i[e+"_KEY"]);r&&r===o.time||(o=n)}return o},_.prototype._isLocalEvent=function(e){var t=this._getEventData(e).deviceId;if(t&&i.DEVICE_ID)return t===i.DEVICE_ID},_.prototype._getEventContext=function(e){var t=JSON.parse(JSON.stringify(this._getEventData(e)));return delete t.time,delete t.deviceId,delete t.userId,t},_.prototype._clearEventData=function(e){this._dcxNode.getValue(i[e+"_DATA_KEY"])&&this._dcxNode.removeValue(i[e+"_DATA_KEY"])},_.prototype._setEventData=function(e,t){if(i.DEVICE_ID){var n={userId:this.library.collection.userId,deviceId:i.DEVICE_ID};i.DEVICE_DESCRIPTION&&(n.device=i.DEVICE_DESCRIPTION),i.APP_DESCRIPTION&&(n.app=i.APP_DESCRIPTION),t&&(n.time=t),this._dcxNode.setValue(i[e+"_DATA_KEY"],n)}else this._clearEventData(e)},_.prototype._updateModifiedTime=function(){var e=(new Date).valueOf();this._dcxNode.setValue(i.MODIFIED_KEY,e),this._setEventData("MODIFIED",e)},_.prototype._updateCreatedTime=function(){var e=(new Date).valueOf();this._dcxNode.setValue(i.CREATED_KEY,e),this._dcxNode.setValue(i.MODIFIED_KEY,e),this._setEventData("CREATED"),this._setEventData("MODIFIED",e)},_.prototype._updateTimestampOnRemove=function(e){var t=e||(new Date).valueOf();this._dcxNode.setValue(i.REMOVED_KEY,t),this._setEventData("REMOVED",t)},_.prototype._updateTimestampOnRestore=function(){this._dcxNode.removeValue(i.REMOVED_KEY),this._clearEventData("REMOVED")},_.prototype._ensureRemovedDataValid=function(e){this.removed&&!this._getEventData("REMOVED",!0)?e?this._setEventData("REMOVED",this.removed):this._clearEventData("REMOVED"):this.removed||this._clearEventData("REMOVED")},_.prototype._ensureModifiedDataValid=function(e){this._getEventData("MODIFIED",!0)||(e?this._setEventData("MODIFIED",this.modified):this._clearEventData("MODIFIED")),this._ensureRemovedDataValid(e)},_.prototype._ensureCreatedDataValid=function(e){e&&!this._getEventData("CREATED",!0)&&this._setEventData("CREATED"),this._ensureModifiedDataValid(e)},_.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)},_.prototype._commitMetadata=function(){this._listenerManager.notify("change"),this._library._commit()},_.prototype._wrapOperation=function(e,t){return this._library._wrapOperation(function(){var n=this._library._wrapOperation(e,t);return this._updateModifiedTime(),this._listenerManager.notify("change"),n},this)},_.prototype._getMissingLocalComponents=function(){var e=[];return this._representations.forEach(function(t){e=e.concat(t._getMissingLocalComponents())}),e},_.prototype._forEachRepresentation=function(e,t=this.representations){t.forEach(t=>{e(t),this._forEachRepresentation(e,t.children)})},_.prototype._shouldGCLocalData=function(){var e=(new Date).valueOf();return this.removed&&e-this.removed>=i.REMOVED_ELEMENTS_CACHE_TIMEOUT},_.prototype.jasmineToString=function(){return this.toString()},_.prototype._stripObsoleteGroupsData=function(e){var t=this._dcxNode.getValue(i.GROUPS_KEY);if(t){var n=(e=e||i.DEFAULT_GROUP_CLASSIFIER)+"#",o=!1;Object.keys(t).forEach(function(e){if(e.startsWith(n)){var i=e.substring(n.length);this.library.getGroupById(i)||(delete t[e],o=!0)}},this),o&&this._dcxNode.setValue(i.GROUPS_KEY,t)}},Object.defineProperties(_.prototype,{id:{get(){return this._dcxNode.id},set(){throw new s(s.READ_ONLY,"Cannot change the id of an existing element",this._library.id)}},library:{get(){return this._library},set(){throw new s(s.READ_ONLY,"library is a read-only property",this._library.id)}},isWritable:{get(){return this._library.isWritable},set(){throw new s(s.READ_ONLY,"isWritable is a read-only property",this.id)}},name:{get(){return this._dcxNode.name||""},set(e){if(d.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this._library.id);this._dcxNode.name=e,this._commit(!0)}},displayName:{get(){return void 0===this._displayName&&(this._displayName=o.getDisplayName(this)||""),this._displayName},set(){throw new s(s.READ_ONLY,"displayName is a read-only property",this._library.id)}},type:{get(){return this._dcxNode.type},set(){throw new s(s.READ_ONLY,"Cannot change the type of an existing element",this._library.id)}},tags:{get(){return this._dcxNode.getValue("tags")||[]},set(e){if(d.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if(!e||e.constructor!==Array)throw new s(s.INVALID_PARAMETER,"tags must be an array",this._library.id);if(!e.every(function(e){return"string"==typeof e}))throw new s(s.INVALID_PARAMETER,"tags must be an array of strings",this._library.id);0===e.length?this._dcxNode.removeValue("tags"):this._dcxNode.setValue("tags",e),this._commit(!0)}},description:{get(){return this._dcxNode.getValue(i.DESCRIPTION_KEY)||""},set(e){if(d.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this._library.id);this._dcxNode.setValue(i.DESCRIPTION_KEY,e);var t=(new Date).valueOf();this._setEventData("DESCRIPTION",t),this._commitMetadata(),a.reportSetDescription(this)}},descriptionModified:{get(){return this._getEventData("DESCRIPTION").time||0},set(){throw new s(s.READ_ONLY,"Cannot change the descriptionModified timestamp of an element directly",this._library.id)}},descriptionModifiedBy:{get(){return this._getEventData("DESCRIPTION").userId},set(){throw new s(s.READ_ONLY,"Cannot change the descriptionModifiedBy property of an element directly",this._library.id)}},descriptionModifiedContext:{get(){return this._getEventContext("DESCRIPTION")},set(){throw new s(s.READ_ONLY,"Cannot change the descriptionModifiedContext property of an element directly",this._library.id)}},wasDescriptionModifiedLocally:{get(){return this._isLocalEvent("DESCRIPTION")},set(){throw new s(s.READ_ONLY,"Cannot change the wasDescriptionModifiedLocally property of an element directly",this._library.id)}},modified:{get(){return this._dcxNode.getValue(i.MODIFIED_KEY)},set(){throw new s(s.READ_ONLY,"Cannot change the modified timestamp of an element directly",this._library.id)}},modifiedBy:{get(){return this._getEventData("MODIFIED").userId},set(){throw new s(s.READ_ONLY,"Cannot change the modifiedBy property of an element directly",this._library.id)}},modifiedContext:{get(){return this._getEventContext("MODIFIED")},set(){throw new s(s.READ_ONLY,"Cannot change the modifiedContext property of an element directly",this._library.id)}},wasModifiedLocally:{get(){return this._isLocalEvent("MODIFIED")},set(){throw new s(s.READ_ONLY,"Cannot change the wasModifiedLocally property of an element directly",this._library.id)}},created:{get(){return this._dcxNode.getValue(i.CREATED_KEY)},set(){throw new s(s.READ_ONLY,"Cannot change the created timestamp of an element directly",this._library.id)}},createdBy:{get(){return this._getEventData("CREATED").userId},set(){throw new s(s.READ_ONLY,"Cannot change the createdBy property of an element directly",this._library.id)}},createdContext:{get(){return this._getEventContext("CREATED")},set(){throw new s(s.READ_ONLY,"Cannot change the createdContext property of an element directly",this._library.id)}},wasCreatedLocally:{get(){return this._isLocalEvent("CREATED")},set(){throw new s(s.READ_ONLY,"Cannot change the wasCreatedLocally property of an element directly",this._library.id)}},removed:{get(){return this._dcxNode.getValue(i.REMOVED_KEY)},set(){throw new s(s.READ_ONLY,"Cannot change the removed timestamp of an element directly",this._library.id)}},removedBy:{get(){return this._getEventData("REMOVED").userId},set(){throw new s(s.READ_ONLY,"Cannot change the removedBy property of an element directly",this._library.id)}},removedContext:{get(){return this._getEventContext("REMOVED")},set(){throw new s(s.READ_ONLY,"Cannot change the removedContext property of an element directly",this._library.id)}},wasRemovedLocally:{get(){return this._isLocalEvent("REMOVED")},set(){throw new s(s.READ_ONLY,"Cannot change the wasRemovedLocally property of an element directly",this._library.id)}},representations:{get(){return this._representations},set(){throw new s(s.READ_ONLY,"Cannot modify representation list directly",this._library.id)}},isDeletedLocally:{get(){return this._deletedLocally},set(){throw new s(s.READ_ONLY,"isDeletedLocally is a read-only property",this._library.id)}},sourceRef:{get(){return this._dcxNode.getValue(i.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(i.SOURCE_REF_KEY,e),this._commit(!0)}}}),_.prototype.toString=function(){return JSON.stringify(this._toJSON())},_.prototype.addChangeListener=function(e){d.checkDeletedState(this),this._listenerManager.add("change",e)},_.prototype.removeChangeListener=function(e){this._listenerManager.remove("change",e)},_.prototype.beginOperation=function(){if(d.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this.id);this._transactionCount++,this._library._beginOperation()},_.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)},_.prototype.createRepresentation=function(e,t,n,o){if(d.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this._library.id);return this._wrapOperation(function(){if(e===i.LINK_REPRESENTATION_TYPE)throw new s(s.INVALID_PARAMETER,"Cannot create external link representation directly - use setContentFromURL instead",this._library.id);if(void 0!==n&&(n<0||n>this._representations.length))throw new s(s.INVALID_PARAMETER,"Invalid index",this._library.id);this._validateRelationship(t);var r=this._doCreateRepresentation(e,t,n);return o||this.library._renditionCache.clearCache(this,!0),r},this)},_.prototype.removeRepresentation=function(e){if(d.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this._library.id);return this._wrapOperation(function(){this._removeRepresentation(e),e._dcxComponent?this._library._dcxBranch.removeComponent(e._dcxComponent):this._library._dcxBranch.removeChild(e._dcxNode),this.library._renditionCache.clearCache(this,!0),e._markDeletedLocally(!0)},this)},_.prototype.removeAllRepresentations=function(){if(d.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this._library.id);return this._wrapOperation(function(){for(;this._representations[0];)this.removeRepresentation(this._representations[0])},this)},_.prototype.getPrimaryRepresentation=function(){var e;return this._representations.forEach(function(t){e||"primary"!==t.relationship||(e=t)}),e},_.prototype.getValue=function(e,t){if(e===i.DL_NAMESPACE)throw new s(s.INVALID_PARAMETER,"Reserved namespace",this._library.id);var n=d.getDCXKey(e,t);return this._dcxNode.getValue(n)},_.prototype.getValues=function(){return d.getCustomDCXData(this._dcxNode)},_.prototype.setValue=function(e,t,n){if(d.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if(e===i.DL_NAMESPACE)throw new s(s.INVALID_PARAMETER,"Reserved namespace",this._library.id);var o,r=d.getDCXKey(e,t);try{o=JSON.parse(JSON.stringify(n))}catch(e){throw new s(s.INVALID_PARAMETER,"Value cannot be serialized to JSON",this._library.id)}this._dcxNode.setValue(r,o),this._commit()},_.prototype.removeValue=function(e,t){if(e===i.DL_NAMESPACE)throw new s(s.INVALID_PARAMETER,"Reserved namespace",this.id);const n=d.getDCXKey(e,t);this._dcxNode.removeValue(n)},_.prototype._getRenditionCandidate=function(e){var t,n,o,i,r,a,s,c=0;if("vector"===e&&this.supportsVectorThumbnail())return this.getPrimaryRepresentation();for(n=0;n<this._representations.length&&(o=this._representations[n],i=Math.max(o.width||0,o.height||0),r=o.isFullSize?Number.POSITIVE_INFINITY:i,a="primary"===o.relationship,s="rendition"===o.relationship,(!t||o.isPreferredThumbnail&&!t.isPreferredThumbnail||a&&"primary"!==t.relationship||s&&"primary"!==t.relationship&&"rendition"!==t.relationship||s&&"rendition"===t.relationship&&r>c)&&p.canComputeRendition(o)&&(t=o,c=r),!s||"image/png"!==o.type||!e||i!==e);n++);return t},_.prototype._setRenditionCache=function(e,t,n,i,r){this.library._renditionCache.setCache(this,e,t,n).then(e=>{i&&o.storageInterface.notifyDownloadRendition(this),r(null,e)},r)},_.prototype.getThumbnailURL=function(e,t){var n=this;d.checkDeletedState(this,t)||this._library._waitForCommit(function(){if(!d.checkDeletedState(n,t)){var o=n._getRenditionCandidate(e);if(o)n._library._collection._syncManager.getSharedCloudRenditionUrl(o,e,t);else t(new s(s.THUMBNAIL_NOT_AVAILABLE,"no representation that can be converted into a thumbnail",n._library.id))}})},_.prototype.getAuthenticatedThumbnailURL=function(e,t){this.getThumbnailURL(e,function(e,n){e?t(e):this._library._collection._syncManager.appendAccessTokenToURL(n,t)}.bind(this))},_.prototype.getThumbnailPath=function(e,t){var n=this;o.hasFileSystem()?d.checkDeletedState(this,t)||this._library._waitForCommit(function(){if(!d.checkDeletedState(n,t))if(i.SHARED_LOCAL_STORAGE)o.storageInterface.getRenditionPath(n,e,t);else{var r=function(e,o){n._renditionFetchLock.release(),t(e,o)};n._renditionFetchLock.obtain(function(){if(!d.checkDeletedState(n,r)){var t=this.library._renditionCache.getCache(this,e);if(t)r(null,t);else{var i=this._getRenditionCandidate(e);if(i){if("rendition"===i.relationship&&"image/png"===i.type&&e&&Math.max(i.width||0,i.height||0)===e)return void i.getContentPath(r);var a=this._library._collection._syncManager,c=this.modified,l=function(t,o){n.modified>c?r(new s(s.STALE_THUMBNAIL,"element changed before the rendition was received",n._library.id,t)):d.checkDeletedState(n,r)||(t?r(new s(s.THUMBNAIL_NOT_AVAILABLE,"error generating thumbnail",n._library.id,t)):n._setRenditionCache(e,o,!0,!0,r))};o.hasRenditionGenerator()&&e&&"vector"!==e?i.getContentPath(function(t,n){if(!t&&n){var r=i.element.library.collection._getTempDir()+o.getPathSeparator()+o.uuid()+".png";o.renditionGenerator(n,r,e,function(t){t?a.getSharedCloudRendition(i,e,l):l(null,r)})}else a.getSharedCloudRendition(i,e,l)}):a.getSharedCloudRendition(i,e,l)}else r(new s(s.THUMBNAIL_NOT_AVAILABLE,"no representation that can be converted into a thumbnail",n._library.id))}}},n)}}):t(new s(s.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this._library.id))},_.prototype.getCachedThumbnailPath=function(e){return this.library._renditionCache.getCache(this,e)},_.prototype.getThumbnailContent=function(e,t,n){const i=o.fs;o.hasFileSystem()?d.checkDeletedState(this,n)||d.checkEncoding(t,["utf8","ascii","base64","buffer"],n)&&this.getThumbnailPath(e,(e,o)=>{if(!e&&o){if(!d.checkDeletedState(this,n)){var r=(e,t)=>{e&&(e=h.getCommitError(e,this._library.id,"error reading content from disk")),n(e,t)};"buffer"===t?i.readFile(o,r):i.readFile(o,t,r)}}else n(e)}):n(new s(s.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this._library.id))},_.prototype.setThumbnailCache=function(e,t,n){"string"==typeof t?o.hasFileSystem()?d.checkDeletedState(this,n)||this._setRenditionCache(e,t,!1,!1,n):n(new s(s.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this._library.id)):n(new s(s.INVALID_PARAMETER,"path must be a string",this._library.id))},_.prototype.supportsVectorThumbnail=function(){const e=this.getPrimaryRepresentation();return!!e&&i.VECTOR_RENDITION_ELEMENT_TYPES.indexOf(e.type)>-1},_.prototype._getActions=function(e){var t=this.getPrimaryRepresentation();if(!t)return[];var n=i.ELEMENT_ACTION_PRODUCT_MAP,o=[];((n.types[this.type]||{})[t.type]||[]).forEach(function(t){!n.products[t]||e&&e!==n.products[t].action||o.push(new c(this,n.products[t]))}.bind(this));var r=o.map(function(e,t){return{i:t,v:e}});return r.sort(function(e,t){return e.v.isCompatibleVersionInstalled&&!t.v.isCompatibleVersionInstalled?-1:t.v.isCompatibleVersionInstalled&&!e.v.isCompatibleVersionInstalled?1:e.i-t.i}),r.map(function(e){return e.v})},_.prototype.getActions=function(e){if(!i.SHARED_LOCAL_STORAGE)throw new s(s.NOT_SUPPORTED,"getActions() not supported without shared local storage");if(e&&-1===i.ELEMENT_ACTIONS.indexOf(e))throw new s(s.INVALID_PARAMETER,"Unknown id supplied. Potential ids are",i.ELEMENT_ACTIONS.join(", "));return this._getActions(e)},_.prototype.getGroups=function(e){e=e||i.DEFAULT_GROUP_CLASSIFIER;var t=this._dcxNode.getValue(i.GROUPS_KEY);if(!t)return[];var n=Object.keys(t);return this.library.getGroups(e).filter(function(e){return void 0!==this.getOrderInGroup(e)},this).sort(function(e,t){var o=n.indexOf(e.classifierName+"#"+e.id),i=n.indexOf(t.classifierName+"#"+t.id);return o===i?0:o<i?-1:1})},_.prototype.getOrderInGroup=function(e){if(!e)throw new s(s.INVALID_PARAMETER,"No group specified",this._library.id);if(e.library===this.library){var t=this._dcxNode.getValue(i.GROUPS_KEY)||{},n=e.classifierName+"#"+e.id;return t[n]&&t[n].order}},_.prototype._doSetOrderInGroup=function(e,t,n){var o=this._dcxNode.getValue(i.GROUPS_KEY)||{},r=e.classifierName+"#"+e.id;n&&Object.keys(o).forEach(function(t){t.startsWith(e.classifierName+"#")&&delete o[t]}),void 0===t&&o[r]&&delete o[r],void 0!==t&&(o[r]={order:t}),this._dcxNode.setValue(i.GROUPS_KEY,o)},_.prototype.setOrderInGroup=function(e,t,n){if(n=!1!==n,d.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if(!e)throw new s(s.INVALID_PARAMETER,"No group specified",this._library.id);if(e.library!==this.library)throw new s(s.INVALID_PARAMETER,"Cannot set element order in a group that is in a different library.",this._library.id);if("string"!=typeof t&&void 0!==t)throw new s(s.INVALID_PARAMETER,"order must be a string",this._library.id);this._doSetOrderInGroup(e,t,n),this._commitMetadata(),a.reportSetOrderInGroup(this,e,n)},_.prototype.getReference=function(){return"cloud-asset://"+this._library._collection._syncManager.getElementRefDomain()+this._library._collection._syncManager.getElementRefPath()+"/"+this._library.id+";node="+this.id},_.prototype.getRepresentationById=function(e){var t;return this.representations.forEach(function(n){n.id===e&&(t=n)}),t},Object.freeze(_),Object.seal(_.prototype),e.exports=_},function(e,t,n){var o=n(1),i=n(0),r=n(2),a=n(21),s=n(27),c=n(15),l=n(8),d=n(11),p=n(34),h=n(16);function u(e,t,n){e instanceof u?this._parent=e:this._element=e,t?this._setDCXNode(t):this._setDCXComponent(n),this._lock=new a,this._pendingDownloadCallbacks=[]}u.prototype._setDCXNode=function(e){let t={};this._children&&this._children.forEach(function(e){t[e.id]=e}),this._dcxNode=e,delete this._dcxComponent,this._deletedLocally=!1,this._children=[],this.element.library._dcxBranch.getChildrenOf(e).forEach(function(e){let n=t[e.id];n?(n._setDCXNode(e),delete t[e.id]):n=new u(this,e),this._children.push(n)},this),this.element.library._dcxBranch.getComponentsOf(e).forEach(function(e){let n=t[e.id];n?(n._setDCXComponent(e),delete t[e.id]):n=new u(this,void 0,e),this._children.push(n)},this)},u.prototype._setDCXComponent=function(e,t){this._dcxComponent=e,delete this._dcxNode,this._children=[],t||(this._deletedLocally=!1)},u.prototype._markDeletedLocally=function(e){this._deletedLocally=e},u.prototype._toJSON=function(){var e={id:this.id,type:this.type,relationship:this.relationship};return o.hasFileSystem()&&(e._componentPath=this._getComponentPath()),e},u.prototype._getOrder=function(){return this._getDCXElement().getValue(i.REPRESENTATION_ORDER_KEY)||0},u.prototype._setComponentInBrowser=function(e,t,n){var o=this;this.element._library._collection._syncManager.uploadNewComponentForRepresentation(e,t,this,function(e,t){c.checkDeletedState(o,n)?n(e):e?n(e):(c.copyCustomDCXData(o._dcxNode,t),o.element._library._dcxBranch.removeChild(o._dcxNode),o._setDCXComponent(t,!0),o._commit(),n(null))})},u.prototype._setComponentFromPath=function(e,t,n,r){var a=this,s=e&&o.getFileNameFromPath(e),d=l.getFileExtension(s),p=this.id+"."+d;l.checkFileSize(e,function(d){d?r(d):l.getImageDimensions(e,function(l){o.storageInterface.notifyStartWrite(a.element._library,[],function(){var o=a.element._library._dcxBranch;o.addComponent(s,a.type,a.relationship,p,e,n,void 0,a.element._dcxNode,a.id,function(e,n){c.checkDeletedState(a,r)||(e?r(e):(c.copyCustomDCXData(a._dcxNode,n),o.removeChild(a._dcxNode),a._setDCXComponent(n,!0),l&&(n.setValue("width",l.width),n.setValue("height",l.height)),t&&n.setValue(i.SHA_KEY,t),a._commit(),r(null)))})})})})},u.prototype._setComponent=function(e,t,n,i){var r,a=o.fs,p=this;function h(e){c.checkDeletedState(p,i)||(e?i(d.getCommitError(e,p.element._library.id,"error writing representation contents")):p._setComponentFromPath(r,void 0,!1,i))}var u=this.element.library.collection._getTempDir();l.ensurePathExists(u,function(l){if(!c.checkDeletedState(p,i))if(l)i(d.getCommitError(l,p.element._library.id,"error creating temp directory"));else{if(!n){var _=s.getExtensions(p.type)[0];n=p.id+"."+_}r=u+o.getPathSeparator()+n,"buffer"===t?a.writeFile(r,e,h):a.writeFile(r,e,t,h)}})},u.prototype._getCurrentComponentPath=function(){if(this._dcxComponent)return this.element._library._dcxBranch.assetOfComponent(this._dcxComponent)},u.prototype._getComponentPath=function(e,t){var n=this;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 o=this._getCurrentComponentPath();if(o||t)e(null,o);else{var i=this.element._library;i._networkLock.obtain(function(t){t?e(t):c.checkDeletedState(n,e)?i._networkLock.release():(i._setSyncState("downloading"),i._collection._syncManager.downloadRepresentation(n,function(t){i._networkLock.release(),i._setSyncState(),c.checkDeletedState(n,e)||(t?e(d.getSyncError(t,n.element._library.id)):(i._commit(!0,!0),n._getComponentPath(e,!0)))}))})}}else{var r=this._getContentFromData();if(r){var a=this.element.library._renditionCache.getCache(this.element,this.id);a?e(null,a):this._generateContentDataFile(r,e)}else e(null)}},u.prototype._getContentFromData=function(){if(o.hasFileSystem()){var e=i.REPRESENTATION_CONTENT_VALUES[this.type];if(e&&e.contentFromData)return this.getValue(e.namespace,e.key)}},u.prototype._setExternalLink=function(e,t){if(this._dcxNode.setValue(i.LINK_TYPE_KEY,this._dcxNode.type),this._dcxNode.type=i.LINK_REPRESENTATION_TYPE,this._dcxNode.setValue(i.LINK_URL_KEY,e),t){t=t.replace(/\\/g,"/");const n=i.DEFAULT_CONTENT_LOCATIONS.find(e=>t.startsWith(e));if(n){const e=t.substring(n.length);this._dcxNode.setValue(i.LINK_LOCAL_PATH_KEY,e)}return this.element.library.collection._externalLinkCache.ensureExternalLinkCache(e,t)}return Promise.resolve()},u.prototype._clearCachedExternalLink=function(e){const t=this.element.library.collection._externalLinkCache;t&&this.isExternalLink&&(!e||t.getCachedError(this))&&(i.SHARED_LOCAL_STORAGE?o.storageInterface.clearCachedExternalLink(this):h.shouldPrefetchExternalLink(this)?t.getExternalLink(this,!0).catch(()=>void 0):t.testExternalLink(this,!0).catch(()=>void 0))},u.prototype._getLinkLocalPaths=function(){const e=this._dcxNode&&this._dcxNode.getValue(i.LINK_LOCAL_PATH_KEY);return e?i.DEFAULT_CONTENT_LOCATIONS.map(t=>`${t}${e}`):[]},u.prototype._setContentFromPath=function(e,t,n){const r=o=>{const r=o&&i.SHA_CACHE[o];if(r){this._dcxNode.setValue(i.SHA_KEY,o);const t=()=>{this._commit(),n(null)};this._setExternalLink(r,e).then(t,t)}else this._setComponentFromPath(e,o,t,n)};o.storageInterface.computeSHA(e).then(r,()=>r())},u.prototype._generateContentDataFile=function(e,t){const n=this.element.library.collection._getTempDir(),i=s.getExtensions(this.type)[0];l.writeJSONData(n,this.id+"."+i,e).then(e=>{this.element.setThumbnailCache(this.id,e,(e,n)=>{o.storageInterface.notifyDownloadRendition(this.element),t(e,n)})},e=>t(d.getCommitError(e)))},u.prototype._getDCXElement=function(){return this._dcxComponent||this._dcxNode},u.prototype._commit=function(){this.element._commit()},u.prototype._getMissingLocalComponents=function(){return o.hasFileSystem()&&this._dcxComponent&&!this._getCurrentComponentPath()?[this._dcxComponent]:[]},u.prototype.jasmineToString=function(){return this.toString()},Object.defineProperties(u.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===i.LINK_REPRESENTATION_TYPE&&(e=this._getDCXElement().getValue(i.LINK_TYPE_KEY)),e},set(){throw new r(r.READ_ONLY,"Cannot change the content type of an existing representation",this.element._library.id)}},relationship:{get(){return this._dcxComponent?this._dcxComponent.relationship:this._dcxNode.getValue(i.RELATIONSHIP_KEY)||this._dcxNode.getValue("relationship")},set(e){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(i.RELATIONSHIP_KEY,e)}},width:{get(){return this._dcxComponent?this._dcxComponent.getValue("width"):this._dcxNode.getValue(i.WIDTH_KEY)},set(e){if(c.checkDeletedState(this),!this.isWritable)throw new r(r.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id);if(!this._dcxComponent&&!this.isExternalLink)throw new r(r.INVALID_PARAMETER,"Cannot set width on a representation without contents",this.element._library.id);if("number"!=typeof e||e<0)throw new r(r.INVALID_PARAMETER,"Invalid width",this.element._library.id);this._dcxComponent?this._dcxComponent.setValue("width",e):this._dcxNode.setValue(i.WIDTH_KEY,e),this._commit()}},height:{get(){return this._dcxComponent?this._dcxComponent.getValue("height"):this._dcxNode.getValue(i.HEIGHT_KEY)},set(e){if(c.checkDeletedState(this),!this.isWritable)throw new r(r.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id);if(!this._dcxComponent&&!this.isExternalLink)throw new r(r.INVALID_PARAMETER,"Cannot set height on a representation without contents",this.element._library.id);if("number"!=typeof e||e<0)throw new r(r.INVALID_PARAMETER,"Invalid height",this.element._library.id);this._dcxComponent?this._dcxComponent.setValue("height",e):this._dcxNode.setValue(i.HEIGHT_KEY,e),this._commit()}},isFullSize:{get(){return this._getDCXElement().getValue(i.IS_FULL_SIZE_KEY)},set(e){if(c.checkDeletedState(this),!this.isWritable)throw new r(r.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id);if(!this._dcxComponent&&!this.isExternalLink)throw new r(r.INVALID_PARAMETER,"Cannot set isFullSize on a representation without contents",this.element._library.id);if("boolean"!=typeof e)throw new r(r.INVALID_PARAMETER,"Invalid isFullSize",this.element._library.id);this._getDCXElement().setValue(i.IS_FULL_SIZE_KEY,e),this._commit()}},isPreferredThumbnail:{get(){return this._getDCXElement().getValue(i.IS_PREFERRED_THUMBNAIL_KEY)||!1},set(e){if(c.checkDeletedState(this),!this.isWritable)throw new r(r.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id);if("boolean"!=typeof e)throw new r(r.INVALID_PARAMETER,"Invalid isPreferredThumbnail",this.element._library.id);this._getDCXElement().setValue(i.IS_PREFERRED_THUMBNAIL_KEY,e),this._commit()}},contentLength:{get(){if(this.isExternalLink)return this._dcxNode.getValue(i.LENGTH_KEY);if(this._dcxComponent){if(void 0===this._dcxComponent.length&&o.hasFileSystem()){var e=this._getCurrentComponentPath();try{var t=o.fs.statSync(e);return t&&t.size}catch(e){}}return this._dcxComponent.length}},set(e){if(!this.isExternalLink)throw new r(r.READ_ONLY,"setContentLength can only be used for an externally-linked representation",this.element._library.id);if("number"!=typeof e||e<0)throw new r(r.INVALID_PARAMETER,"Invalid content length",this.element._library.id);this._dcxNode.setValue(i.LENGTH_KEY,e),this._commit()}},contentHash:{get(){return this._getDCXElement().getValue(i.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===i.LINK_REPRESENTATION_TYPE},set(){throw new r(r.READ_ONLY,"isExternalLink is a read-only property",this.element._library.id)}}}),u.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)},u.prototype.toString=function(){return JSON.stringify(this._toJSON())},u.prototype.getValue=function(e,t){if(e===i.DL_NAMESPACE)throw new r(r.INVALID_PARAMETER,"Reserved namespace",this.element._library.id);var n=c.getDCXKey(e,t);return this._getDCXElement().getValue(n)},u.prototype.getValues=function(){return c.getCustomDCXData(this._getDCXElement())},u.prototype.setValue=function(e,t,n){if(c.checkDeletedState(this),!this.isWritable)throw new r(r.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id);if(e===i.DL_NAMESPACE)throw new r(r.INVALID_PARAMETER,"Reserved namespace",this.element._library.id);var o,a=c.getDCXKey(e,t);try{o=JSON.parse(JSON.stringify(n))}catch(e){throw new r(r.INVALID_PARAMETER,"Value cannot be serialized to JSON",this.element._library.id)}this._getDCXElement().setValue(a,o),this._commit()},u.prototype.setContent=function(e,t,n,i){if(!c.checkDeletedState(this,i))if(this.isWritable)if(this._dcxComponent||this.isExternalLink)i(new r(r.INVALID_PARAMETER,"Cannot modify representation content once set",this.element._library.id));else if(o.hasFileSystem()){if(!c.checkEncoding(t,["utf8","ascii","base64","buffer"],i))return;this._setComponent(e,t,n,i)}else{if(void 0!==t)return void i(new r(r.INVALID_PARAMETER,"Encoding parameter not supported in-browser"));this._setComponentInBrowser(e,n,i)}else i(new r(r.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id))},u.prototype.setContentFromPath=function(e,t,n){"function"==typeof t&&(n=t,t=!1),o.hasFileSystem()?c.checkDeletedState(this,n)||(this.isWritable?this._dcxComponent||this.isExternalLink?n(new r(r.INVALID_PARAMETER,"Cannot modify representation content once set",this.element._library.id)):this._setContentFromPath(e,!t,n):n(new r(r.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id))):n(new r(r.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this.element._library.id))},u.prototype.setContentFromURL=function(e,t,n,i){if(o.hasFileSystem()||e){if(!c.checkDeletedState(this,i))if(this.isWritable)if("boolean"==typeof e)if(this._dcxComponent||this.isExternalLink)i(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 i(null);var a=this,h=this.element.library.collection,u=h._getTempDir();o.storageInterface.getAssetFromURL(h,t,n,u,function(e,t,n,o){if(e)i(d.getSyncError(e));else if(!c.checkDeletedState(a,i)){var r=p.getContentTypeHeader(o&&o.headers);if(r){var h=t+"."+s.getExtensions(r)[0];l.rename(t,h,function(e){e?i(d.getCommitError(e)):a._setComponentFromPath(h,void 0,!1,i)})}else a._setComponentFromPath(t,void 0,!1,i)}})}else i(new r(r.INVALID_PARAMETER,"Invalid createLink parameter: must be Boolean",this.element._library.id));else i(new r(r.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id))}else i(new r(r.NOT_IMPLEMENTED,"not yet implemented setContentFromURL without a filesystem",this.element._library.id))},u.prototype.getContentPath=function(e){o.hasFileSystem()?c.checkDeletedState(this,e)||this._getComponentPath(e):e(new r(r.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this.element._library.id))},u.prototype.getCachedContentPath=function(){if(!o.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},u.prototype.getContent=function(e,t){var n=o.fs,i=this;if(!c.checkDeletedState(this,t))if(o.hasFileSystem()){if(!c.checkEncoding(e,["utf8","ascii","base64","buffer"],t))return;this._getComponentPath(function(o,r){if(!o&&r){if(!c.checkDeletedState(i,t)){var a=function(e,n){e&&(e=d.getCommitError(e,i.element._library.id,"error reading content from disk")),t(e,n)};"buffer"===e?n.readFile(r,a):n.readFile(r,e,a)}}else t(o)})}else{if(!c.checkEncoding(e,["text","blob","arraybuffer"],t))return;if(!this._dcxComponent)return void t(null);this.element._library._collection._syncManager.getSharedCloudContent(this,e,t)}},u.prototype.getContentURL=function(){return this.isExternalLink?this._dcxNode.getValue(i.LINK_URL_KEY):this._dcxComponent?this.element._library._collection._syncManager.getSharedCloudContentURL(this._dcxComponent):void 0},u.prototype.getAuthenticatedContentURL=function(e){var t=this.getContentURL();this.element._library._collection._syncManager.appendAccessTokenToURL(t,e)},u.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(i.RELATIONSHIP_KEY,i.RELATIONSHIP_CHILD);var n=new u(this,t);return this._children.push(n),this._commit(),n},u.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()},u.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))},u.prototype.clearCachedExternalLink=function(){if(!this.isExternalLink||!this.getContentURL())throw new r(r.INVALID_PARAMETER,"Not an external link",this.element._library.id);this._clearCachedExternalLink()},u.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)},u.prototype.getExternalLinkDownloadProgress=function(){if(this.isExternalLink)return this.element.library.collection._getExternalLinkDownloadProgress(this)},Object.freeze(u),Object.seal(u.prototype),e.exports=u},function(e,t,n){var o=n(2),i=n(9),r=n(0),a=n(1),s=n(18);function c(e,t){this._element=e,this._id=t.action,this._appCode=t.appCode,this._appName=t.appName,this._minVersion=t.minVersion,this._installedVersions=r.ELEMENT_ACTION_PRODUCT_MAP.installedApps.filter(function(e){return e.code===t.appCode}).map(function(e){return e.version}).sort(i.compareVersions),this._invokable=this._installedVersions.length>0&&i.compareVersions(t.minVersion,this._installedVersions[0])>=0,Object.freeze(this._installedVersions)}Object.defineProperties(c.prototype,{id:{get(){return this._id},set(){throw new o(o.READ_ONLY,"Cannot change the id of an existing element action",this._id)}},element:{get(){return this._element},set(){throw new o(o.READ_ONLY,"element is a read-only property",this._element.id)}},appCode:{get(){return this._appCode},set(){throw new o(o.READ_ONLY,"Cannot change the app code of an element action",this._appCode)}},appName:{get(){return this._appName},set(){throw new o(o.READ_ONLY,"Cannot change the app name of an element action",this._appName)}},minAppVersion:{get(){return this._minVersion},set(){throw new o(o.READ_ONLY,"Cannot change the min version of an element action",this._minVersion)}},installedVersions:{get(){return this._installedVersions},set(){throw new o(o.READ_ONLY,"Cannot change the installed versions of an element action")}},isCompatibleVersionInstalled:{get(){return!!this._invokable},set(){throw new o(o.READ_ONLY,"Cannot change the compatibility of an element action")}}}),c.prototype.invoke=function(e){var t=i.wrapCallback(e);this.isCompatibleVersionInstalled?(s.reportElementActionInvoked(this),a.storageInterface.sendElementAction(this,function(e,n){e?(e=-1!==["APP_NOT_INSTALLED","NO_COMPATIBLE_VERSION"].indexOf(e)?new o(o.NO_COMPATIBLE_APP_FOUND,"A compatible version of application is needed for this action:"+e):new o(o.APP_LAUNCH_FAILED,"Launching the app failed:"+e),s.reportElementActionFailed(this,e)):s.reportElementActionSuccessful(this,n),t(e,n)})):t(new o(o.NO_COMPATIBLE_APP_FOUND,"A compatible version of application is needed for this action",this._appCode))},Object.freeze(c),Object.seal(c.prototype),e.exports=c},function(e,t,n){const o=n(45),i=n(46),r=n(0),a=n(35),s=n(59),c="renditions";e.exports=class extends s{constructor(e){super(e._getRenditionCacheDir()),this._library=e,this._pendingSetCache=[]}getCache(e,t="full"){const n=this._getCache([c,e.id,t]);return this._getFilePath(n)}setCache(e,t="full",n,o=!1){return r.SHARED_LOCAL_STORAGE?this._requestSetCache(e.id,t,n):this._doTransaction(()=>this._setCache([c,e.id,t],n,o))}clearCache(e,t){const n=this._getCache([c,e.id]);return n?(t&&r.SHARED_LOCAL_STORAGE&&a.supportsClearRenditionCache()&&Object.keys(n).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 n={},o=o=>{n[o.id]=this.serializeElementCache(o,e,t)};return this._library.elements.forEach(o),this._library.removedElements.forEach(o),n}serializeElementCache(e,t=!1,n){const o=Object.assign({},this._cache[c]&&this._cache[c][e.id]||{});return t&&this._convertToAbsolutePaths(o),this._addExternalLinksToElementCache(o,e,t,n),o}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 n=this._getCache([c,e.id]);let r;return Object.keys(n).some(a=>{if(!Number(a))return;const s=i.join(this._rootDir,n[a]),c=i&&o.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:n})=>({element:e,size:t,path:n})),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 n=this._cache[c]||{};let o=!1;Object.keys(n).forEach(t=>{e[t]||(this._setCacheEntry([c,t]),o=!0)});const i=o?this.save():Promise.resolve(),r=this._library.collection._externalLinkCache;return i.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 n=t.library._renditionCache,o=this._getCache([c,e.id])||{},i=Object.keys(o).map(i=>{const a=this._getFilePath(o[i],!0);if(!a)return Promise.resolve();var s=e.getRepresentationById(i);if(s&&!t.getRepresentationById(i)){const n=e.representations.indexOf(s);n>=0&&n<t.representations.length&&(i=t.representations[n].id)}return this._isPath(a)?r.SHARED_LOCAL_STORAGE?n._requestSetCache(t.id,i,a):n._setCache([c,t.id,i],a):Promise.resolve(n._setCacheEntry([c,t.id,i],a))});return Promise.all(i)}_requestSetCache(e,t,n){return new Promise((o,i)=>{this._pendingSetCache=this._pendingSetCache.filter(n=>!(n.element===e&&n.size===t&&"CLEAR"===n.path)),this._pendingSetCache.push({element:e,size:t,path:n,callback:(e,t)=>e?i(e):o(t)})})}_applyRequestSetCache(e){const t=e.map(({element:e,size:t,path:n})=>"CLEAR"===n?(this._setCacheEntry([c,e,t]),Promise.resolve()):this._setCache([c,e,t],n));return Promise.all(t)}_completeRequestSetCache(e){const t={};return e.forEach((e,n)=>{const o=this._requestingSetCache[n],i=this._library.getElementById(o.element);if(o&&i&&e&&0===e.indexOf(this._rootDir)){const n=e.substring(this._rootDir.length+1);this._setCacheEntry([c,o.element,o.size],n),t[i.id]=i}o&&o.callback(null,e)}),delete this._requestingSetCache,Object.keys(t).map(e=>t[e])}_clearCache(e,t){const n=t?[c,e.id,t]:[c,e.id];return this._setCacheEntry(n),this.save()}_convertToAbsolutePaths(e){Object.keys(e).forEach(t=>{const n=e[t];e[t]=this._isPath(n)?i.join(this._rootDir,n):n})}_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,n=!1,o){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]=!n&&a.startsWith(r._rootDir)?i.relative(this._rootDir,a):a,r._notifyDownloadRendition(t,o))}})}}},function(e,t,n){var o=n(53),i=n(54),r=n(7),a=n(4),s=n(0),c=n(2),l=n(1),d=n(34),p=n(11),h=n(8),u=n(9),_=n(15),f=n(27);function m(e,t){this._collection=e,this._isPublic=t.IS_PUBLIC,this._storageHost=t.STORAGE_HOSTNAME,this._collaborationHost=t.COLLABORATION_HOSTNAME,this._imageHost=t.CC_IMAGE_HOSTNAME,this._imageXHost=t.CC_IMAGE_X_HOSTNAME,this._typekitHost=t.TYPEKIT_HOSTNAME,this._ccLibraryHost=`https://${t.CC_LIBRARY_SERVICE_HOSTNAME}/api/v1`,this._storageAssetsPath=this._isPublic?t.STORAGE_ASSETS_PATH:s.STORAGE_ASSETS_PATH,this._apiKey=s.STORAGE_API_KEY,this._syncGroup=this._isPublic?t.SYNC_GROUP:s.LIBRARY_SYNC_GROUP,this._XHR=t.XHR,this._requiresCommunitySession=t.REQUIRES_COMMUNITY_SESSION,this._getAccessToken=t.getAccessToken,this._httpServices=[],this._storageService=this._createStorageSession(),this._renditionStorageService=this._createStorageSession(),this._temporaryStorageServices={},this._lastSyncGroupState={},this._hasSetAuthToken=!1,this._authToken=void 0,this._inProgressSyncMap={},s.SHARED_LOCAL_STORAGE||this._isPublic||this._updateAuthToken()}m.prototype._getCommonRequestHeaders=function(){var e={};return s.USER_AGENT_HEADER&&(e["User-Agent"]=s.USER_AGENT_HEADER),e},m.prototype._setAuthToken=function(e){this._hasSetAuthToken=!0,this._authToken=e,this._httpServices.forEach(function(t){e?(t.isActive=!0,t.setAuthToken(e)):t.isActive=!1})},m.prototype._updateAuthToken=function(e){var t=this,n=u.wrapCallback(e);this._getAccessToken(this._authToken,function(e,o){!e&&o?t._setAuthToken(o):(e&&e.code===c.ACCESS_DENIED&&(t._collection._reportSyncError(e),t._collection._updateSyncState()),t._setAuthToken()),n(null,o)})},m.prototype._getAuthToken=function(e){this._hasSetAuthToken?e(null,this._authToken):this._updateAuthToken(e)},m.prototype._authHandler=function(){this._updateAuthToken()},m.prototype._createStorageSession=function(){var e;return this._isPublic?e=l.dcx.createHTTPService():(e=l.dcx.createHTTPService(this._authHandler.bind(this)),this._httpServices.push(e)),e.setApiKey(this._apiKey),e.setTimeout(s.NETWORK_TIMEOUT),e.setAdditionalNodeOptions(l.getNodeTunnelOptions(this.getStorageHost())),e.setAdditionalHeaders(this._getCommonRequestHeaders()),this._XHR&&e._forceXhr(this._XHR),this._requiresCommunitySession?l.dcx.createCommunitySession(e,this.getStorageHost()):l.dcx.createStorageSession(e,this.getStorageHost())},m.prototype._createTemporaryStorageSession=function(e,t){var n;return t&&this._getAccessToken?(this._authToken||this._updateAuthToken(),(n=l.dcx.createHTTPService(this._authHandler.bind(this))).setApiKey(this._apiKey),n.setAdditionalHeaders(this._getCommonRequestHeaders()),n.setAuthToken(this._authToken),this._httpServices.push(n)):n=l.dcx.createHTTPService(),n.setTimeout(s.NETWORK_TIMEOUT),n.setAdditionalNodeOptions(l.getNodeTunnelOptions(e)),this._XHR&&n._forceXhr(this._XHR),l.dcx.createStorageSession(n,e)},m.prototype._getTemporaryStorageSession=function(e){var t=r.parseURI(e),n=t.scheme+"://"+t.authority,o=d.isAdobeDomain(t.authority);return this._temporaryStorageServices[n]||(this._temporaryStorageServices[n]=this._createTemporaryStorageSession(n,o)),this._temporaryStorageServices[n]},m.prototype.getServerComposites=function(e){var t=this,n=this._lastSyncGroupState.etag;this._storageService.getCollection(this.getSyncGroupPath(),n,function(n,o,i,r){if(n)n.response&&404===n.response.statusCode?e(null,[]):e(n);else{if(!o){var a=Math.max(s.DEFAULT_MAX_SYNC_INTERVAL,1e3*d.getRetryAfterHeader(r));return s.MAX_SYNC_INTERVAL=a,void e(null,[])}s.MAX_SYNC_INTERVAL=s.DEFAULT_MAX_SYNC_INTERVAL;var c=t._lastSyncGroupState.compositeEtags||{},l={},p=[],h={};(o.children||[]).forEach(function(e){e&&_.validateLibraryId(e.name,!1)&&(e.isUnmodified=e.etag&&c[e.name]===e.etag,p.push(e),h[e.name]=e,l[e.name]=e.etag)}),t._lastSyncGroupState={etag:i,compositeEtags:l},e(null,p,h)}})},m.prototype.clearSyncGroupCache=function(){this._lastSyncGroupState={}},m.prototype.doHeadRequest=function(e,t){var n;try{n=this._storageService.getCompositeManifestHref(e)}catch(e){return void t(e)}this._storageService.headRequest(n,t)},m.prototype.hasCompositeChangedOnServer=function(e,t){this.doHeadRequest(e,function(n,o){if(n)t(!0);else{var i=o&&o.headers&&o.headers.etag,r=e.current&&e.current.manifestEtag;t(i!==r)}})},m.prototype.downloadComponent=function(e,t,n){i.downloadComponents([t],e,this._storageService,n)},m.prototype.downloadRepresentation=function(e,t){var n=e._dcxComponent,o=e.element.library._dcxBranch;this.downloadComponent(o,n,t)},m.prototype.abortPushOrPull=function(e){this._inProgressSyncMap[e]&&(this._inProgressSyncMap[e].abort(new c(c.TRANSFER_ABORTED,"abort push or pull operation")),delete this._inProgressSyncMap[e])},m.prototype._isManifestOnly=function(){return"manifestOnly"===s.SYNC_POLICY||!l.hasFileSystem()},m.prototype._pullCompositeComponents=function(e,t,n,o,r){if(this._isManifestOnly())r(null);else{var a=i.downloadComponents(e,t,this._storageService,r);this._inProgressSyncMap[o]=a,a.onProgress=function(e,t){0!==t&&n._updateProgress(o,e,t)}}},m.prototype._pullComposite=function(e,t,n,o){var r=this;this._inProgressSyncMap[n]=i.pullCompositeManifestOnly(e,this._storageService,function(e,i){if(!e&&i){var a=i.getComponentsOf();i.getChildrenOf().forEach(function(e){e.name===s.ELEMENTS_NAME&&i.getChildrenOf(e).forEach(function(e){a=a.concat(i.getComponentsOf(e))})}),r._pullCompositeComponents(a,i,t,n,function(e){o(e,i)})}else o(e,i)})},m.prototype.pullComposite=function(e,t,n){var o=this,i=e.id;if(!i&&e.href){var r=e.href.split("/");i=r&&r[r.length-1]}l.log("Started pulling: "+i+(this._isManifestOnly()?" (manifest only)":""));var s=(new Date).valueOf();t._updateProgress(i),this._pullComposite(e,t,i,function(r,d){var p=(new Date).valueOf()-s;l.log("Finished pulling: "+i+(r?" ["+r.code+"]":"")+" duration="+p),delete o._inProgressSyncMap[i],t._updateProgress(i),d&&(d=d.copy(),_.ensureBranchDataValid(d)),r&&r.code===a.COMPONENT_DOWNLOAD_ERROR?o.doHeadRequest(e,function(e,t){if(!e&&t&&200===t.statusCode){var o=_.removeMissingComponents(r.pulledBranch.copy(),r.failedComponents);if(o)return void n(null,o)}n(r,d)}):r&&r.code===c.TRANSFER_ABORTED?n(null,void 0):n(r,d)})},m.prototype.pullMissingComponents=function(e,t){var n=this,o=e.id,i=e.collection,r=e._getMissingLocalComponents();if(this._isManifestOnly()||0===r.length)t(null);else{e._setSyncState("downloading"),l.log("Started pulling missing components: "+o);var a=(new Date).valueOf();i._updateProgress(o),this._pullCompositeComponents(r,e._dcxBranch,i,o,function(r){var s=(new Date).valueOf()-a;l.log("Finished pulling missing components: "+o+(r?" ["+r.code+"]":"")+" duration="+s),delete n._inProgressSyncMap[o],i._updateProgress(o),e._setSyncState(),r&&r.code===c.TRANSFER_ABORTED?t(null):t(r)})}},m.prototype.pushComposite=function(e,t,n,o){var r=this,a=e.id;l.log("Started pushing: "+a);var s=(new Date).valueOf();t._updateProgress(a),this._inProgressSyncMap[a]=i.pushComposite(e,n,this._storageService,function(e){var n=(new Date).valueOf()-s;l.log("Finished pushing: "+a+(e?" ["+e.code+"]":"")+" duration="+n),delete r._inProgressSyncMap[a],t._updateProgress(a),o(e)}),this._inProgressSyncMap[a].onProgress=function(e,n){0!==n&&t._updateProgress(a,e,n)}},m.prototype.pushDeletedComposite=function(e,t,n,o,i){var r=this;"incoming"===n?(l.log("Deleting incoming collaboration without pushing: "+e.id),this._storageService.deleteCompositeDirectory(e,i)):e.current&&!e.current.isBound?i(null):(l.log("Pushing deleted composite: "+e.id),this.pushComposite(e,t,o,function(n){if(n){if(n.code===a.UNEXPECTED_RESPONSE&&n.response&&404===n.response.statusCode)return void r._storageService.deleteCompositeDirectory(e,i);if(n.code===a.UPDATE_CONFLICT){var o=n;return void r.pullComposite(e,t,function(t){t&&t.code===a.NO_COMPOSITE?r._storageService.deleteCompositeDirectory(e,i):t&&t.code===a.DELETED_COMPOSITE?i(null):i(t||o)})}}i(n)}))},m.prototype.getStorageHost=function(){return"https://"+this._storageHost},m.prototype.getSyncGroupPath=function(){var e=this.getStorageHost()+(this._storageAssetsPath||"");return this._syncGroup?r.appendPathElements(e,this._syncGroup):e},m.prototype.getCompositePath=function(e){return r.appendPathElements(this.getSyncGroupPath(),e)},m.prototype.getComponentPath=function(e,t){return r.appendPathElements(this.getSyncGroupPath(),e,t)},m.prototype.getElementRefDomain=function(){return this._requiresCommunitySession?s.CP_CLOUD_ID:this._storageHost},m.prototype.getElementRefPath=function(){return s.STORAGE_ASSETS_PATH+s.LIBRARY_SYNC_GROUP},m.prototype.getElementRefDomainPath=function(){return this.getElementRefDomain()+this.getElementRefPath()},m.prototype.getCollaborationHost=function(){return"https://"+this._collaborationHost},m.prototype._getSharedCloudRenditionUrl=function(e,t,n){if(e._dcxComponent)try{n(null,this._requiresCommunitySession?this._storageService.getComponentRenditionHref(e._dcxComponent,e._dcxComponent.version,"image/png","width",t||"full"):this._storageService.getComponentRenditionHref(e._dcxComponent,e._dcxComponent.version,t||"full"))}catch(e){n(e)}else n("representation must be a component to generate a rendition")},m.prototype._getTypekitFontData=function(e,t){var n="https://"+this._typekitHost+"/v1/variations?include=trial,full,marketplace,purchased&include_marketplace_data=true&purpose=sync";this._getTemporaryStorageSession(n)._service.invoke("POST",n,null,JSON.stringify(e),{responseType:"text"},function(e,n){if(e||200!==n.statusCode)return t(e||"Typekit service call failed with: "+n.statusCode);try{t(null,JSON.parse(n.response))}catch(e){t(e)}})},m.prototype._retry404IfNeeded=function(e,t,n,o,i){var r=1e3*d.getRetryAfterHeader(t);if(s.RENDITION_RETRY_INTERVAL=Math.max(s.DEFAULT_RENDITION_RETRY_INTERVAL,r),s.RENDITION_404_BACKOFF=Math.max(s.DEFAULT_RENDITION_404_BACKOFF,r),n<s.RENDITION_MAX_RETRIES)return n++,l.log("404 fetching rendition: retrying ("+n+")"),void setTimeout(o,s.RENDITION_RETRY_INTERVAL,n);l.log("404 fetching rendition: reached maximum retries"),l.log("Backing off rendition fetch of "+e.id+" for "+s.RENDITION_404_BACKOFF+"ms"),e._lastRendition404=(new Date).valueOf(),i()},m.prototype._getImageServiceSVGRendition=function(e,t,n){var o=this,i=e.element,r="https://"+this._imageHost+"/createagc",a=this._getTemporaryStorageSession(r),s={"Content-Type":"application/vnd.adobe.image-operation+json"},c={inputs:{application_file:{href:i.getReference()}},outputs:{agc:{disposition:"location"}}};if(e.isDeletedLocally||e.element.library.isDeletedFromServer)n("Error: representation deleted");else{var d=function(t){o._getImageServiceSVGRendition(e,t,n)};a._service.invoke("POST",r,s,JSON.stringify(c),{responseType:"text"},function(p,u){if(p||200!==u.statusCode){var _=function(){return n(p||"Image service call failed with: "+u.statusCode)};return u&&404===u.statusCode?o._retry404IfNeeded(e,u&&u.headers,t,d,_):void _()}var f;try{f=JSON.parse(u.response)}catch(e){return n(e)}if(f&&f.outputs&&f.outputs.agc&&f.outputs.agc.location)return r="https://"+o._imageXHost+"/agctosvg",a=o._getTemporaryStorageSession(r),s={"Content-Type":"application/vnd.adobe.dwbedrockservice-operation+json"},c={inputs:{href:f.outputs.agc.location}},a._service.invoke("POST",r,s,JSON.stringify(c),{responseType:"text"},function(e,t){if(e||200!==t.statusCode)return n(e||"Image-x service call failed with: "+t.statusCode);var o=t.response,r=i.library.collection._getTempDir(),a=r+l.getPathSeparator()+l.uuid()+".svg";h.ensurePathExists(r,function(e){if(e)return n(e);l.fs.writeFile(a,o,function(e){if(e)return n(e);n(null,a)})})});n("Invalid image service response")})}},m.prototype._getAssetAsType=function(e,t,n,i,r,a){var c=this;if(a=a||0,e.isDeletedLocally||e.element.library.isDeletedFromServer)r("Error: representation deleted");else{var d=function(o){c._getAssetAsType(e,t,n,i,r,o)};if(a>0&&"uploading"===e.element.library.syncState)setTimeout(d,s.RENDITION_RETRY_INTERVAL,a);else{var h=n+l.getPathSeparator()+l.uuid()+".png",u=new o.FileContent(h);this._renditionStorageService.getAssetAsType(t,u,i,function(t){var n=t&&t.response&&t.response.headers,o=function(){r(t,h)};if(404===p.getErrorStatusCode(t))return c._retry404IfNeeded(e,n,a,d,o);o()})}}},m.prototype.getSharedCloudRenditionUrl=function(e,t,n){this._getSharedCloudRenditionUrl(e,t,n)},m.prototype.getSharedCloudRendition=function(e,t,n){var o=this;if(e.element.library.isDeletedFromServer)return l.log("Error: Trying to fetch rendition from deleted library."),void n("Error: library deleted");if((new Date).valueOf()-(e._lastRendition404||0)<s.RENDITION_404_BACKOFF)n("Error: got 404 on last rendition attempt - backing off");else if("vector"===t&&e.element.supportsVectorThumbnail()){var i=function(){"uploading"!==e.element.library.syncState?o._getImageServiceSVGRendition(e,0,n):setTimeout(i,s.RENDITION_RETRY_INTERVAL)};i()}else this._getSharedCloudRenditionUrl(e,t,function(t,i){if(t)n(t);else{var r={Accept:"image/png"},a=e.element.library.collection._getTempDir();h.ensurePathExists(a,function(t){t?n(t):o._getAssetAsType(e,i,a,r,n)})}})},m.prototype.getSharedCloudContentURL=function(e){return this._storageService.getComponentHref(e,e.version)},m.prototype.appendAccessTokenToURL=function(e,t){if(e){var n=this._apiKey;this._getAuthToken(function(o,i){t(null,e+="?api_key="+n+(i?"&user_token="+i:""))})}else t(null,void 0)},m.prototype.getSharedCloudContent=function(e,t,n){var o=this._storageService.getComponentHref(e._dcxComponent,e._dcxComponent.version);this._storageService.getAssetAsType(o,t,{},function(e,t){e?n(e):n(null,t)})},m.prototype.getAssetFromURL=function(e,t,n,i,r,c){var p=this;l.log("getAssetFromURL: "+e);var u=this._getTemporaryStorageSession(e),_=n+l.getPathSeparator()+l.uuid(),f=new o.FileContent(_);c=c||0,t=t||{},h.ensurePathExists(n,function(o){if(o)r(o);else{var h=u.getAssetAsType(e,f,t,function(o,u,f,m){if(h&&delete h.progress,o&&o.code===a.UNEXPECTED_RESPONSE){var E=o.response&&o.response.statusCode;if(l.log("getAssetFromURL: Unexpected Response "+E+" from "+e),d.isRedirect(E)){var g=d.getLocationHeader(o.response.headers);if(g&&c<s.MAX_REDIRECT_FOLLOW)return l.log("getAssetFromURL: Redirecting to "+g),void p.getAssetFromURL(g,t,n,i,r,c+1);o.response.statusCode=404}}r(o,_,f,m)});if(h&&i){var m,E=0;h.progress=function(e){E+=e,!m&&h.response&&h.response.headers&&(m=d.getContentLengthHeader(h.response.headers)),i(E,m||1)},i(0,1)}}})},m.prototype.doHeadRequestOfURL=function(e,t,n){var o=this;n=n||0,this._getTemporaryStorageSession(e).headRequest(e,function(i,r){var a=r?r.statusCode:i;if(l.log("doHeadRequestOfURL: "+e+" -> "+a),r&&d.isRedirect(r.statusCode)){var c=d.getLocationHeader(r.headers);if(c&&n<s.MAX_HEAD_REDIRECT_FOLLOW)return l.log("doHeadRequestOfURL: Redirecting to "+c),void o.doHeadRequestOfURL(c,t,n+1);n>0&&(r.statusCode=404)}t(i,r)})},m.prototype.prepareCompositeForPush=function(e){e.href=this.getCompositePath(e.id)},m.prototype.updateAccessToken=function(e){this._setAuthToken(e)},m.prototype.isLoggedIn=function(){return this._isPublic||this._httpServices[0].isActive},m.prototype.uploadNewComponentForRepresentation=function(e,t,n,o){var r=n._element._library._dcxComposite;i.uploadNewComponent(e,n.type,r,n.id,this._storageService,function(e,i){if(e)o(e);else{var a=t?t.lastIndexOf("."):-1,s=-1!==a&&t.substr(a+1).toLowerCase(),c=n.id+"."+s,l=r.current.addComponentWithUploadResults(t,n.relationship,c,n._element._dcxNode,i);o(null,l)}})},m.prototype.uploadNewComponentForLibrary=function(e,t,n,o,r,a){var s=r._dcxComposite;i.uploadNewComponent(e,n,s,t,this._storageService,function(e,i){if(e)a(e);else{var r=f.getExtensions(n)[0],c=t+"."+r,l=s.current.addComponentWithUploadResults(c,o,c,s,i);a(null,l)}})},m.prototype.pushClientTokenInfo=function(e,t,n){this._getTemporaryStorageSession(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 n(e||new Error("Failed to push client Token info to the server"));n(null,!0)})},Object.freeze(m),Object.seal(m.prototype),e.exports=m},function(e,t,n){var o=n(60),i=n(1),r=n(0),a=n(21),s=n(8),c=n(11);function l(e){this._collection=e,this._bookmarks=[],this._bookmarksEtag=void 0,this._bookmarksBase=void 0,this._syncModified=!1,this._lock=new a,this._service=e._syncManager._createTemporaryStorageSession(e._syncManager.getCollaborationHost(),!0)._service,this._bookmarksURL=e._syncManager.getCollaborationHost()+r.BOOKMARKS_PATH}function d(e,t){var n;return e.some(function(e){if(e.id===t)return n=e,!0}),n}function p(e){var t=[];return e.forEach(function(e){t.push({id:e.id,url:e.url})}),t}function h(e){var t=[];return e&&e.forEach(function(e){t.push(new o(e.id,e.url))}),t}l.prototype._getBookmarksDir=function(){return this._collection._getBaseDir()},l.prototype._saveBookmarks=function(e){if(i.hasFileSystem()){var t={bookmarks:p(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")))}else e(null)},l.prototype._loadBookmarks=function(e){if(i.hasFileSystem()){const t=this._getBookmarksDir()+i.getPathSeparator()+r.BOOKMARKS_FILENAME;s.readJSONData(t).then(t=>{t&&(this._bookmarks=h(t.bookmarks),this._bookmarksEtag=t.etag,this._bookmarksBase=t.bookmarks_base&&h(t.bookmarks_base)),e(null)},t=>e(c.getCommitError(t,null,"bookmarks could not be loaded")))}else e(null)},l.prototype._pullBookmarks=function(e){i.log("Pulling bookmarks");var t={},n=this;this._bookmarksEtag&&(t["If-None-Match"]=this._bookmarksEtag),this._service.invoke("GET",this._bookmarksURL,t,void 0,{responseType:"text"},function(t,o){if(t)return e(t);if(200===o.statusCode)try{var i=JSON.parse(o.response);n._syncModified=!0,e(null,h(i.bookmarks),o.headers.etag)}catch(t){e("Cannot parse data: "+o.response)}else 304===o.statusCode||404===o.statusCode?e(null,void 0,o.headers.etag):e("Unexpected response getting bookmarks: "+o.statusCode)})},l.prototype._mergeBookmarks=function(e,t){if(i.log("Merging bookmarks"),e){if(this._bookmarksBase){var n=this;e.forEach(function(t){var o=d(n._bookmarks,t.id),i=d(n._bookmarksBase,t.id);!o&&i&&e.splice(e.indexOf(t),1)}),this._bookmarks.forEach(function(t){var o=d(e,t.id),i=d(n._bookmarksBase,t.id);o||i||e.push(t)})}this._bookmarks=e}this._bookmarksEtag=t},l.prototype._pushBookmarks=function(e){i.log("Pushing bookmarks");var t={"Content-Type":"application/json"};this._bookmarksEtag&&(t["If-Match"]=this._bookmarksEtag);var n=this,o=JSON.stringify({bookmarks:p(this._bookmarks)});this._service.invoke("PUT",this._bookmarksURL,t,o,void 0,function(t,o){if(t)return e(t);var i=o.statusCode;!o.headers.etag||200!==i&&201!==i&&204!==i?409===i||412===i?n._pullBookmarks(function(t,o,i){if(t)return e(t);n._mergeBookmarks(o,i),n._pushBookmarks(e)}):e("Unexpected response updating bookmarks: "+i):e(null,o.headers.etag)})},l.prototype._commit=function(e){i.log("Commiting bookmarks");var t=this;this._lock.obtain(function(){t._saveBookmarks(function(n){t._lock.release(),n?t._collection._reportCommitError(n):e&&t.sync(function(e){e&&t._collection._reportSyncError(e)})})})},l.prototype._sync=function(e){var t=this;this._bookmarksBase?t._pushBookmarks(function(n,o){if(n)return e(n);t._bookmarksEtag=o,t._bookmarksBase=void 0,t._commit(),e(null)}):t._pullBookmarks(function(n,o,i){if(n)return e(n);o&&(t._bookmarks=o,t._bookmarksEtag=i,t._bookmarksBase=void 0,t._commit()),e(null)})},l.prototype._createBase=function(){this._bookmarksBase||(this._bookmarksBase=this._bookmarks.slice())},l.prototype.load=function(e){i.log("Loading bookmarks");var t=this;this._lock.obtain(function(){t._loadBookmarks(function(n){t._lock.release(),e(n)})})},l.prototype.sync=function(e){i.log("Syncing bookmarks");var t=this;this._lock.obtain(function(){t._syncModified=!1,t._sync(function(n){if(t._lock.release(),n)return n=c.getSyncError(n,null),e(n);e(null),t._syncModified&&t._collection._notifyChange(!0)})})},l.prototype.createBookmark=function(e,t,n){if(r.SHARED_LOCAL_STORAGE)i.storageInterface.createBookmark(this._collection,e,t,n);else{i.log("Creating bookmark: "+e+" url: "+t);var a=this;this._lock.obtain(function(){var i=d(a._bookmarks,e),s=!1;i||(a._createBase(),i=new o(e,t),a._bookmarks.push(i),s=!0),a._lock.release(),n(null,i,s),s&&(a._commit(r.SYNCING_ENABLED),a._collection._notifyChange(!0))})}},l.prototype.removeBookmark=function(e,t){if(r.SHARED_LOCAL_STORAGE)i.storageInterface.removeBookmark(this._collection,e,t);else{i.log("Removing bookmark: "+e.id+" url: "+e.id);var n=this;this._lock.obtain(function(){(e=d(n._bookmarks,e.id))&&(n._createBase(),n._bookmarks.splice(n._bookmarks.indexOf(e),1)),n._lock.release(),t(null),e&&(n._commit(r.SYNCING_ENABLED),n._collection._notifyChange(!0))})}},l.prototype.getBookmarks=function(){return this._bookmarks.slice()},Object.freeze(l),Object.seal(l.prototype),e.exports=l},function(e,t,n){var o=n(0),i=n(2),r=n(1),a=n(5);function s(e){this._collection=e,this._listenerManager=new a(["change"]),this._fontsCache={}}s.prototype._clearCache=function(){this._fontsCache={},this._listenerManager.notify("change")},s.prototype.addChangeListener=function(e){this._listenerManager.add("change",e)},s.prototype.removeChangeListener=function(e){this._listenerManager.remove("change",e)},s.prototype.getFontData=function(e,t){var n=this,a=this._fontsCache[e];a?t(null,a):o.SHARED_LOCAL_STORAGE?r.storageInterface.getFontData(this._collection,e,function(o,i){i&&(n._fontsCache[e]=i),t(o,i)}):this._collection._syncManager._getTypekitFontData([e],function(o,r){o?t(new i(i.NETWORK_ERROR,"Error occurred while getting font data",null,o)):(a=r&&r[0],n._fontsCache[e]=a,t(null,a))})},s.prototype.isSystemFontAvailable=function(e,t,n){if(!o.SHARED_LOCAL_STORAGE)return n(new i(i.NOT_SUPPORTED,"isSystemFontAvailable() is only supported with shared local storage"));r.storageInterface.isFontAvailable(e,t,n)},Object.freeze(s),Object.seal(s.prototype),e.exports=s},function(e,t,n){var o=n(2),i=n(1),r=n(0),a=n(5);function s(e,t,n,o,i){this._listenerManager=new a(["progress"]),this._collection=e,this._id=t,this._type=n,this._data=o,this._cancelCallback=i,this._progress=0}s.prototype._updateProgress=function(e){this._progress!==e&&(this._progress=e,this._listenerManager.notify("progress",[this]),this._collection._notifyOperationChange())},Object.defineProperties(s.prototype,{id:{get(){return this._id},set(){throw new o(o.READ_ONLY,"Cannot modify id directly")}},type:{get(){return this._type},set(){throw new o(o.READ_ONLY,"Cannot modify type directly")}},data:{get(){return this._data},set(){throw new o(o.READ_ONLY,"Cannot modify data directly")}},progress:{get(){return this._progress},set(){throw new o(o.READ_ONLY,"Cannot modify progress directly")}}}),s.prototype.addProgressListener=function(e){this._listenerManager.add("progress",e)},s.prototype.removeProgressListener=function(e){this._listenerManager.remove("progress",e)},s.prototype.cancel=function(){r.SHARED_LOCAL_STORAGE?i.storageInterface.cancelOperation(this._collection,this._id):this._cancelCallback&&this._cancelCallback()},Object.freeze(s),Object.seal(s.prototype),e.exports=s},function(e,t,n){const o=n(55),i=n(0),r=n(1),a=n(8),s=n(11),c=n(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,n,i)=>{let r,d;const p=(t,n)=>{if(d&&(t=new c(c.OPERATION_CANCELLED,"import cancelled")),t)return void i(t);r=void 0;const o=n.libraryId,l=n.extractPath,p=e._getCompositeDir(o),h=e=>{a.recursiveDeleteDirectory(l),a.recursiveDeleteDirectory(p),i(e)};a.rename(l,p,t=>{if(t)return h(s.getFileSystemError(t,"unable to move extracted zip after import"));e._loadLibrary(o,t=>{if(t)return h(t);const n=e.getLibraryById(o);if(!n)return h(new c(c.INVALID_DATA,"could not load library after import"));e._notifyChange(!0),n._push(),i(null,n)})})};return o.isSnapshot(t,(i,a)=>{if(i||d)return void p(i&&s.getSnapshotError(i,void 0,"error opening library archive"));const c=e._getTempDir();if(a){const i=e._syncManager.getSyncGroupPath();r=o.importSnapshot(t,c,i,!1,n,(e,t)=>{!e&&t?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,n,p)}),()=>{d||(d=!0,r&&r())}}),l._importNonSnapshotLibrary=((e,t,n,o,l)=>{const p=r.getPathSeparator(),h=r.fs,u=r.yauzl;if(!u)return void l(new c(c.NOT_SUPPORTED,"yauzl (unzip) module not present"));const _=r.uuid(),f=n+r.getPathSeparator()+_,m=e._syncManager.getCompositePath(_);let E,g=!1,y=-1,v=0,A=0;let C=!1;const S=e=>{C||(C=!0,e&&a.recursiveDeleteDirectory(f),l(e,e?void 0:{libraryId:_,extractPath:f}))},I=f+p+"components";return a.ensurePathExists(I,e=>{e?S(s.getFileSystemError(e,"unable to create temp dir")):u.open(t,{lazyEntries:!0},(e,t)=>{e?-1!==["EPERM","EACCES","ENOENT"].indexOf(e.code)?S(s.getFileSystemError(e,"error opening library archive")):S(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,n)=>{t?S(s.getFileSystemError(t,"error extracting zip file")):(n.on("end",()=>{E.readEntry()}),n.on("data",e=>{A+=e.length,(()=>{if(!g){let e=y/E.entryCount;v&&(e+=A/(v*E.entryCount)),o(Math.round(100*e))}})()}).on("error",e=>{S(s.getFileSystemError(e,"error extracting zip file"))}).pipe(h.createWriteStream(I+p+e.fileName)))})):E.openReadStream(e,(e,t)=>{if(e)return void S(s.getFileSystemError(e,"error reading zip file entry"));const n=[];t.on("data",e=>{n.push(e)}),t.on("error",e=>{S(s.getFileSystemError(e,"error extracting zip file"))}),t.on("end",()=>{const e=((e,t,n)=>{let o;try{o=JSON.parse(e)}catch(e){return null}if(!o||o.version!==i.EXPORT_VERSION)return null;const r=o.manifest,a=o.componentMap;return"object"!=typeof a||Object.keys(a).some(e=>"string"!=typeof a[e])?null:(r.id=t,r.local={version:2,change:1,compositeHref:n,"copyOnWrite#storageIds":o.componentMap},{json:o,manifest:r})})(Buffer.concat(n).toString(),_,m);e&&e.manifest?h.writeFile(f+p+"manifest",JSON.stringify(e.manifest,void 0,2),e=>{e?S(s.getFileSystemError(e,"unable to write manifest file")):E.readEntry()}):S(new c(c.INVALID_DATA,"unable to parse export data"))})}):E.readEntry()}).on("error",e=>{S(s.getFileSystemError(e,"error extracting zip file"))}).on("close",()=>{g?S(new c(c.OPERATION_CANCELLED,"import cancelled")):S()}),E.readEntry())})}),()=>{g||(g=!0,E&&E.close())}}),l.exportLibrary=((e,t,n,r)=>{let a;const l=o.exportSnapshot(e._dcxComposite,t,e=>(delete e[`${i.TOOLKIT_NAMESPACE}#${i.TOOLKIT_ID_KEY}`],e.children=e.children.filter(e=>e.name!==i.REMOVED_ELEMENTS_NAME),e),n,t=>{r(a?new c(c.OPERATION_CANCELLED,"export cancelled"):t&&s.getSnapshotError(t,e.id,"cannot export a snapshot file"))});return()=>{a||(a=!0,l())}}),Object.seal(l),e.exports=l},function(e,t,n){const o=n(45),i=n(46),r=n(1),a=n(2),s=n(0),c=n(27),l=n(8),d=n(11),p=n(35),h=n(34),u=n(59),_="urls",f=(e,t,n,o)=>new Promise((i,a)=>{const s=(new Date).valueOf();r.log("Downloading from external URL: "+t),e._syncManager.getAssetFromURL(t,{},n,o,(e,t,n,o)=>{r.log("Finished downloading from external URL: "+((new Date).valueOf()-s)+"ms"),e?a(e):i({tempFilePath:t,etag:n,response:o})})}),m=(e,t)=>new Promise(n=>{const o=(new Date).valueOf();r.log("HEAD request of external URL: "+t),r.storageInterface.doHeadRequestOfURL(e,t,function(e,t){r.log("Finished HEAD request of external URL: "+((new Date).valueOf()-o)+"ms"),n(t)})}),E={downloadExternalLink:e=>new Promise((t,n)=>{r.storageInterface.downloadExternalLink(e,(e,o)=>e?n(e):t(o))}),testExternalLink:e=>new Promise((t,n)=>{r.storageInterface.testExternalLink(e,(e,o)=>o?t():n())})},g={};class y extends u{static connect(e){const t=e.userId,n=g[t]=g[t]||new y(t);return n._connect(e),n}static disconnect(e){const t=e.userId;g[t]&&g[t]._disconnect(e)}constructor(e){super(i.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 n=this._getCacheEntry(e);return this._isErrorCode(n)?new a(n,"Broken link, or access denied"):null}getExternalLink(e,t=!1){const n=e.getContentURL(),o=h.validateURL(n,this._privateCollection);if(o)return Promise.reject(o);if(t)e.element.library._renditionCache._legacyClearCacheEntry(e),this._setCacheEntry([_,n]);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[n]){const t=()=>{this._notifyDownloadFinished(this._pendingDownloads[n]);const t=e.element;t.supportsVectorThumbnail()&&t.library._renditionCache._clearCache(t,"vector"),delete this._pendingDownloads[n]};this._pendingDownloads[n]={promise:this._doGetExternalLink(e),representations:[]},this._pendingDownloads[n].promise.then(t,t)}return this._pendingDownloads[n].representations.push(e),this._pendingDownloads[n].promise}testExternalLink(e,t=!1){const n=e.getContentURL();if(h.validateURL(n,this._privateCollection))return Promise.reject();if(t)e.element.library._renditionCache._legacyClearCacheEntry(e),this._setCacheEntry([_,n]);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[n]){const e=this._getOnDownloadProgressCallback("_pendingTests",n),t=()=>{this._notifyDownloadFinished(this._pendingTests[n]),e(),delete this._pendingTests[n]};this._pendingTests[n]={promise:this._doTest(n),representations:[]},e(0,1),this._pendingTests[n].promise.then(t,t)}return this._pendingTests[n].representations.push(e),this._pendingTests[n].promise}ensureExternalLinkCache(e,t){const n=this._getCache([_,e]);return this._getFilePath(n)?Promise.resolve():this._doTransaction(()=>this._setCache([_,e],t))}gc(){const e={};this._collections.forEach(t=>{t.libraries.forEach(t=>{Object.assign(e,this._getReferences(t))})});const t=this._cache[_]||{};let n=!1;return Object.keys(t).forEach(t=>{e[t]||(this._setCacheEntry([_,t]),n=!0)}),n?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),delete e._externalLinkCache),0===this._collections.length&&delete g[this._userId]}_getCacheEntry(e){const t=e.element.library._renditionCache._legacyGetCacheEntry(e);if(t)return t;const n=e.getContentURL(),o=this._getCache([_,n]);return this._getFilePath(o,!0)}_doGetExternalLink(e){const t=e.getContentURL(),n=e._getLinkLocalPaths().find(e=>o.statSync(e));return n?this._doTransaction(()=>this._setCache([_,t],n)):this._doDownload(t,e.type)}_doDownload(e,t){const n=this._getOnDownloadProgressCallback("_pendingDownloads",e),i=this._privateCollection._getTempDir();return f(this._privateCollection,e,i,n).then(({tempFilePath:i,response:r})=>{var a=h.getContentTypeHeader(r&&r.headers)||t,s=i+"."+(c.getExtensions(a)[0]||"data");const l=o.rename(i,s).then(()=>this._doTransaction(()=>this._setCache([_,e],s,!0)));return l.then(n,n),l}).catch(t=>{let o;var i=t&&t.response&&t.response.statusCode;return h.isUnrecoverableClientError(i)?(this._setCacheEntry([_,e],a.RENDITION_NOT_AVAILABLE),o=this.save().then(()=>Promise.reject(new a(a.RENDITION_NOT_AVAILABLE,"Broken link, or access denied")))):o=Promise.reject(d.getSyncError(t)),o.catch(()=>n(void 0,void 0,t)),o})}_doTest(e){return m(this._privateCollection,e).then(t=>{const n=t&&t.statusCode;let o;return h.isUnrecoverableClientError(n)?o=a.RENDITION_NOT_AVAILABLE:n&&n>=200&&n<400&&(o=s.RENDITION_CACHE_PLACEHOLDER),o?(this._setCacheEntry([_,e],o),this.save().then(()=>this._isErrorCode(o)?Promise.reject():Promise.resolve())):Promise.resolve()})}_getOnDownloadProgressCallback(e,t){return(n,o,i)=>{(this[e]&&this[e][t]&&this[e][t].representations).forEach(e=>{e.element.library.collection._updateExternalLinkDownloadProgress(e,n,o,i)})}}_notifyDownloadFinished(e){e.representations.forEach(e=>this._notifyDownloadRendition(e,!0))}_notifyDownloadRendition(e,t){const n=`${e.element.library.id}.${e.element.id}.${e.id}`;!0!==t&&this._sentNotifications[n]||(this._sentNotifications[n]=!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 n=t.isExternalLink&&t.getContentURL();n&&(this._referencedLinks[e.id].urlMap[n]=!0)})};e.elements.forEach(t),e.removedElements.forEach(t)}return this._referencedLinks[e.id].urlMap}}e.exports=y},function(e,t,n){var o=n(5);e.exports=class{constructor(){this._collections=[],this._listenerManager=new o(["change"])}getLibraryCollection(e,t){return this._collections.find(n=>!n.isPublic&&n.userId===e&&n.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,n){var o=n(25),i=n(33),r=n(44),a=n(61),s=n(58),c=n(60),l=n(2),d=n(0),p=n(1),h=n(62),u=n(108),_=n(109),f=n(12),m=n(15),E=n(9),g=n(35),y=n(8);function v(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 _(this),p.hasFileSystem()||p.setFileSystem(this.fs))}var A=function(e){var t={};return t.isPublic=e.isPublic,t.userId=e.userId,t.cloudId=e.cloudId,t},C=function(e,t){var n=A(e.collection);return n[t||"id"]=e.id,n},S=function(e,t,n){var o=C(e.library,n);return o[t||"element"]=e.id,o},I=function(e){var t=S(e.element);return t.representation=e.id,t};v.prototype._getBase=function(e){var t=this._baseBranches[e];return t&&t.base},v.prototype._setBase=function(e,t){this._baseBranches[e]=this._baseBranches[e]||{},this._baseBranches[e].base=t},v.prototype._getLogIndex=function(){return this._logIndex++},v.prototype._getServicePort=function(e){var t=d.VULCAN_PREFIX+d.VULCAN_QUERY_REQUEST,n=d.VULCAN_PREFIX+d.VULCAN_QUERY_RESPONSE;function o(t){var n;try{n=JSON.parse(t)}catch(e){}n?e(null,n):e("NO_DATA")}if(p.vulcanCall)p.vulcanCall(t,"",n,o);else if(p.hasCEPVulcan()){var i,r=p.getVulcanInterface(),a=p.getVulcanMessage(),s=function(t){r.removeMessageListener(n,s),clearTimeout(i),t?o(r.getPayload(t)):e("NO_VULCAN_MESSAGE")};r.addMessageListener(n,s),i=setTimeout(s,d.VULCAN_QUERY_TIMEOUT);var c=new a(t);c.setPayload(""),r.dispatchMessage(c)}},v.prototype._connectToPort=function(e,t){const n=t&&t.port,o=t&&t.token,i=t&&t.domain;if(this._portDiagnosis=t?t.portdiagnosis:"UNKNOWN",this._connectionPort=n,!this._channel&&n&&"SIMPLE_HOSTNAME_GOING_TO_PROXY"!==this._portDiagnosis){try{var r=new u(n,o,i);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)))}},v.prototype._connect=function(){this._getServicePort(this._connectToPort.bind(this))},v.prototype.shutdown=function(){this._onDisconnect()},v.prototype._onDisconnect=function(){this._channel&&(this._channel.shutdown(),this._channel=void 0),this._isConnected=!1,this._collectionManager.removeAllLibraryCollections()},v.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})},v.prototype._onEnvironmentInfo=function(e){this._serviceInfo=e,e.whitelistedDomains&&(d.WHITELISTED_DOMAINS=e.whitelistedDomains),e.elementActionProductMap&&g.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(function(e){e._listenerManager.notify("sync")})},v.prototype._onCollectionAdded=function(e){var t=this;d.ROOT_DIR=e.rootDir;var n,o=new f,i={USER_ID:e.userId,CLOUD_ID:e.cloudId,CLOUD_INFO:e.cloudInfo,STORAGE_HOSTNAME:e.storageHost,COLLABORATION_HOSTNAME:e.collaborationHost,CC_IMAGE_HOSTNAME:e.imageHost,CC_IMAGE_X_HOSTNAME:e.imageXHost,TYPEKIT_HOSTNAME:e.typekitHost,REQUIRES_COMMUNITY_SESSION:e.requiresCommunitySession};n=e.isPublic?new a(i):new r(i),e.libraries.forEach(function(e){o.addOperation(t.loadExistingLibrary,[n,e.id,e.path,e.manifest,e.deletedFromServer,e.renditionCache],t)}),o.run(function(){t._collectionManager.addLibraryCollection(n)})},v.prototype._getLibraryCollection=function(e){return e.isPublic?this._collectionManager.getPublicLibraryCollection(e.cloudId):this._collectionManager.getLibraryCollection(e.userId,e.cloudId)},v.prototype._onCollectionRemoved=function(e){var t=this._getLibraryCollection(e);t&&this._collectionManager.removeLibraryCollection(t)},v.prototype._onClearCollections=function(){this._collectionManager.removeAllLibraryCollections()},v.prototype._onSyncState=function(e){var t=this._getLibraryCollection(e);t&&(t._syncState=e.state,t._syncProgress=e.progress,t._syncProgressMap=e.progressMap,t._externalLinkDownloadProgressMap=e.externalLinkDownloadProgressMap||{},t._newLibraryProgress=e.newLibraryProgress,t._initialSyncInProgress=e.initialSyncInProgress,t._syncErrors=[],e.errors.forEach(function(e){t._syncErrors.push(new l(e.code,e.message,e.libraryId))}),e.libraryStates.forEach(function(e){var n=t.getLibraryById(e.id);n&&(n._syncState=e.state)}),t._listenerManager.notify("sync"))},v.prototype._onLibraryChange=function(e){var t=this._getLibraryCollection(e);if(t){var n=t.getLibraryById(e.id);n?(p.log("onLibraryChange: "+n.id),n._deletedFromServer!==e.deletedFromServer&&(n._deletedFromServer=e.deletedFromServer,n._notifyChange()),e.renditionCache=e.renditionCache||{},n._renditionCache.replaceCache(e.renditionCache),this.updateExistingLibrary(t,n,e.manifest,void 0,this._getBase(n.id),()=>{n._renditionCache.replaceCache(e.renditionCache)})):this.loadExistingLibrary(t,e.id,e.path,e.manifest,e.deletedFromServer,e.renditionCache)}},v.prototype._onRenditionCacheChange=function(e){var t=this._getLibraryCollection(e),n=t&&t.getLibraryById(e.id),o=n&&n.getElementById(e.elementId);o&&e.renditionCache&&(n._renditionCache.replaceElementCache(o,e.renditionCache),o._listenerManager.notify("change"))},v.prototype._onOperationsChanged=function(e){var t=this._getLibraryCollection(e),n={};e.operations.forEach(function(e){t._updateOperation(e.id,e.type,e.data,e.progress),n[e.id]=!0}),Object.keys(t._operationIdMap).forEach(function(e){n[e]||t._delayedRemoveOperation(t._operationIdMap[e])})},v.prototype._onLibraryDeleted=function(e){var t=this._getLibraryCollection(e);t&&this._deleteLibrary(t,e.id)},v.prototype._onBookmarksChanged=function(e){var t=this._getLibraryCollection(e);if(t&&e.bookmarks){var n=[];e.bookmarks.forEach(function(e){n.push(new c(e._id,e._url))}),t._bookmarkManager._bookmarks=n}},v.prototype._onFontCacheChanged=function(e){var t=this._getLibraryCollection(e);t&&t.fontManager&&t.fontManager._clearCache()},v.prototype.isConnected=function(){return this._isConnected},v.prototype.reconnect=function(){this._channel||this._connect()},v.prototype.getServiceInfo=function(){return this._serviceInfo?{updateRequired:this._serviceInfo.updateRequired,version:this._serviceInfo.codeVersion,buildNumber:this._serviceInfo.buildNumber,apiVersion:this._serviceInfo.version,environment:this._serviceInfo.environment,syncingEnabled:this._serviceInfo.syncingEnabled,portDiagnosis:this._portDiagnosis,connectionPort:this._connectionPort}:{portDiagnosis:this._portDiagnosis,connectionPort:this._connectionPort}},v.prototype.updateConfiguration=function(){d.SHARED_LOCAL_STORAGE&&this._channel&&this._isConnected&&this._sendConfiguration()},v.prototype.sync=function(e){this._channel.send("sync",A(e))},v.prototype.setSyncEnabled=function(e){this._channel.send("configuresync",{enable:e})},v.prototype.commitManifest=function(e,t){if(d.SHARED_LOCAL_STORAGE){const n=e._dcxBranch.localData,o=e._renditionCache.doRequestSetCache(),i=C(e);i.current=n,i.base=this._getBase(e.id),i.renditions=o.data,p.log("Start commit"),this._channel.call("commit",i,r=>{if(p.log("Finish commit: "+(r.success?"success":"fail")),r.success){if(p.log("Update base after commit"),this._setBase(e.id,n),r.renditions){o.complete(r.renditions).forEach(e=>e._listenerManager.notify("change"))}}else o.cancel(),e._waitForCommit(()=>{this.notifyStartWrite(e,[],()=>{e._deletedFromServer=r.deletedFromServer,this.updateExistingLibrary(e.collection,e,r.manifest,void 0,i.base,function(){e._commit(!0,!0)})})});t(null,r.success)})}else e._dcxLock.obtain(function(){e._gcLocalData(function(){e._dcxComposite.commitChanges(function(n){e._dcxLock.release(),e._renditionCache.gc(),t(n,!0)})})})},v.prototype.resolvePullWithBranch=function(e,t,n,o,i){p.log("resolvePullWithBranch"),d.SHARED_LOCAL_STORAGE?(e._dcxComposite._current=t,this._setBase(e.id,n),p.log("Finished resolvePullWithBranch: shared local storage"),i()):o?e._dcxLock.obtain(function(){e._dcxComposite._current=t,e._dcxLock.release(),p.log("Finished resolvePullWithBranch: local merge"),i()}):e._dcxLock.obtain(function(){e._dcxComposite.resolvePullWithBranch(t,function(t,n){e._dcxLock.release(),e._commit(!0,!0),e._waitForCommit(function(){p.log("Finished resolvePullWithBranch: remote merge"),i(t,n)})})})},v.prototype.acceptPush=function(e,t){var n=this;p.log("acceptPush"),e._dcxLock.obtain(function(){e._dcxComposite.acceptPush(function(o){e._dcxLock.release(),p.log("Finished acceptPush"),n._acceptPushedBranchListeners.forEach(function(t){t(e)}),t(o)})})},v.prototype.onAcceptPushedBranch=function(e){this._acceptPushedBranchListeners.push(e)},v.prototype.removeOnAcceptPushedBranchListeners=function(){this._acceptPushedBranchListeners=[]},v.prototype._deleteLibrary=function(e,t){p.log("deleteLibrary");var n=e.getLibraryById(t);if(n){var o=e._libraries.indexOf(n);-1!==o&&(e._libraries.splice(o,1),delete e._libraryIdMap[n.id]),n._markDeletedLocally(!0),e._notifyChange(!0)}},v.prototype._loadBranch=function(e,t,n){var o;try{(o=new i(void 0,n).parse(t))._localStorage=e._localStorage}catch(e){}return o},v.prototype._addLibrary=function(e,t,n,i,r){n=n||e._getCompositeDir(t);var a=new o(null,null,n,null,null,{preserveFileExtensions:!0}),c=this._loadBranch(a,i,!1);if(c)if("pendingDelete"!==c.compositeState){a._current=c,this._setBase(t,i);var 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))},v.prototype.createNewLibrary=function(e,t,n,o){var i=E.wrapCallback(o);p.log("createNewLibrary"),this._addLibrary(e,t,void 0,n,function(e,t){!e&&t?(t._commit(!1,!0),t._waitForCommit(i)):i(e)})},v.prototype.loadExistingLibrary=function(e,t,n,o,i,r,a){var s=E.wrapCallback(a);p.log("loadExistingLibrary"),this._addLibrary(e,t,void 0,o,function(e,t){!e&&t?(t._deletedFromServer=i,r&&t._renditionCache.replaceCache(r),s(null,t)):s(e)})},v.prototype.updateExistingLibrary=function(e,t,n,o,i,r){var a=this,s=E.wrapCallback(r),c="updateExistingLibrary["+this._getLogIndex()+"]: ";if(m.areManifestsEqual(t._dcxBranch.localData,n))return p.log(c+"already up-to-date"),void s();var h=this._loadBranch(t._dcxComposite,n,!1);if(p.log(c+"changes to update (state = "+(h&&h.compositeState)+")"),h){var u=m.ensureBranchDataValid(h);p.log(c+"fixed branch data: "+u),"pendingDelete"===h.compositeState?(e._doRemoveLibrary(t),s()):t._waitForCommit(function(){if(o){if(!m.areManifestsEqual(t._dcxBranch.localData,o))return p.log(c+"Commit aborting: something changed and it's no longer a fast-forward"),void s(!0)}else o=a._getBase(t.id);if(i&&o!==i)return p.log(c+"Commit aborting: base manifest changed before we got chance to update!"),void s(!0);var e=a._loadBranch(t._dcxComposite,o,!0)||h;p.log(c+"base "+e.changeCount+" -> updated "+h.changeCount),t._mergeAndSwitchToBranch(h,e,function(){p.log(c+"finished merge"),d.SHARED_LOCAL_STORAGE?s(null):(t._commit(!1,!0),t._waitForCommit(s))})})}else s(new l(l.CORRUPTED_LIBRARY,"Invalid manifest",t.id))},v.prototype.getRenditionPath=function(e,t,n,o){o=o||0;var i=this,r=E.wrapCallback(n),a=e.library._renditionCache.getCache(e,t||"full");if(a)r(null,a);else{var s=S(e);s.size=t,p.log("Get rendition path from CCLibrary process"),this._channel.call("getrenditionpath",s,function(a){if(!a&&o<d.LOCAL_RENDITION_MAX_RETRIES)return p.log("getrenditionpath: rendition not found"),void setTimeout(function(){i.getRenditionPath(e,t,n,o+1)},d.LOCAL_RENDITION_RETRY_INTERVAL);r(null,a)})}},v.prototype.notifyDownloadRendition=function(e){this._downloadRenditionListeners.forEach(function(t){t(e)}),e._listenerManager.notify("change")},v.prototype.onDownloadRendition=function(e){this._downloadRenditionListeners.push(e)},v.prototype.removeOnDownloadRenditionListeners=function(){this._downloadRenditionCacheListeners=[]},v.prototype.notifyStartWrite=function(e,t,n){var o=E.wrapCallback(n);if(d.SHARED_LOCAL_STORAGE){var i=C(e);i.dependencies=[],t.forEach(function(e){i.dependencies.push(C(e))}),this._channel.call("startcomponentwrite",i,function(){o(null)})}else o(null)},v.prototype.loadPublicLibrary=function(e,t,n,o){var i=E.wrapCallback(o),r=A(e);r.id=t,r.url=n,this._channel.call("loadpubliclibrary",r,function(){i(null)})},v.prototype.unloadPublicLibrary=function(e,t){var n=E.wrapCallback(t),o=C(e);this._channel.call("unloadpubliclibrary",o,function(){n(null)})},v.prototype.getAssetFromURL=function(e,t,n,o,i){if(d.SHARED_LOCAL_STORAGE){var r=A(e);r.url=t,r.headers=n,r.tempDir=o,this._channel.call("downloadfile",r,function(e){i(e.err,e.tempFilePath,e.etag,{headers:e.responseHeaders})})}else e._syncManager.getAssetFromURL(t,n,o,void 0,i)},v.prototype.doHeadRequestOfURL=function(e,t,n){d.SHARED_LOCAL_STORAGE?n(null):e._syncManager.doHeadRequestOfURL(t,n)},v.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)})},v.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)})},v.prototype.clearCachedExternalLink=function(e){p.log("Clear cached external link via CCLibrary process"),this._channel.send("clearcachedexternallink",I(e))},v.prototype.createBookmark=function(e,t,n,o){var i=E.wrapCallback(o),r=A(e);r.id=t,r.url=n,this._channel.call("createBookmark",r,function(e){var t=e&&e.err,n=e&&e.bookmark;n&&(n=new c(n._id,n._url)),i(t,n)})},v.prototype.removeBookmark=function(e,t,n){var o=E.wrapCallback(n),i=A(e);i.id=t.id,this._channel.call("removeBookmark",i,function(e){o(e)})},v.prototype.sendElementAction=function(e,t){var n=E.wrapCallback(t),o=S(e.element,"elementId","libraryId");o.appCode=e.appCode,o.minVersion=e.minAppVersion,o.action=e.id,this._channel.call("performElementAction",o,function(e){n(e.err,e.data)})},v.prototype.getImageDimensions=function(e,t){this._channel.call("getImageDimensions",e,function(e){t(e.data)})},v.prototype.importLibrary=function(e,t,n,o){var i=E.wrapCallback(o),r=A(e);r.path=t,r.operationId=n,this._channel.call("importlibrary",r,function(t){i(t.err,e.getLibraryById(t.libraryId))})},v.prototype.exportLibrary=function(e,t,n,o){var i=E.wrapCallback(o),r=C(e);r.path=t,r.operationId=n,this._channel.call("exportlibrary",r,function(e){i(e.err)})},v.prototype.cancelOperation=function(e,t){var n=A(e);n.operationId=t,this._channel.send("canceloperation",n)},v.prototype.getFontData=function(e,t,n){var o=E.wrapCallback(n),i=A(e);i.fontId=t,this._channel.call("getfontdata",i,function(e){o(e.err,e.data)})},v.prototype.isFontAvailable=function(e,t,n){const o=E.wrapCallback(n),i={fontName:e,matchFamily:t};this._channel.call("isfontavailable",i,({err:e,data:t})=>o(e,t))},v.prototype.getAccessToken=function(e,t,n,o,i){const r=E.wrapCallback(i),a={userId:e,clientId:t,clientSecret:n,scopes:o};this._channel.call("getaccesstoken",a,({err:e,data:t})=>r(e,t))},v.prototype.computeSHA=function(e){return d.SHARED_LOCAL_STORAGE?new Promise((t,n)=>{this._channel.call("computesha",{path:e},({err:e,data:o})=>e?n(e):t(o))}):y.computeSHA(e)},Object.freeze(v),Object.seal(v.prototype),e.exports=v},function(e,t,n){var o=n(0),i=n(5);function r(e,t,n){let r=n?`wss://${n}:${e}`:`ws://127.0.0.1:${e}`;r+=`/?version=${o.SHARED_LOCAL_STORAGE_VERSION}`,t&&(r+=`&token=${t}`),this._socket=new WebSocket(r),this._socket.onopen=this._onSocketOpen.bind(this),this._socket.onclose=this._onSocketClose.bind(this),this._socket.onmessage=this._onSocketMessage.bind(this),this._socket.onerror=this._onSocketError.bind(this),this._listenerManager=new i(["open","close","message","error"])}r.prototype._onSocketOpen=function(){this._listenerManager.notify("open")},r.prototype._onSocketClose=function(){this._listenerManager.notify("close")},r.prototype._onSocketMessage=function(e){this._listenerManager.notify("message",[e.data])},r.prototype._onSocketError=function(e){this._listenerManager.notify("error",[e])},r.prototype.send=function(e){this._socket.send(e)},r.prototype.addListener=function(e,t){this._listenerManager.add(e,t)},r.prototype.removeListener=function(e,t){this._listenerManager.remove(e,t)},r.prototype.close=function(){this._socket.close(),this._socket.onopen=void 0,this._socket.onclose=void 0,this._socket.onmessage=void 0,this._socket.onerror=void 0,this._listenerManager.removeAll()},Object.freeze(r),Object.seal(r.prototype),e.exports=r},function(e,t,n){var o=n(2),i=n(9),r={rename:!0,renameSync:!1,ftruncate:!1,ftruncateSync:!1,truncate:!1,truncateSync:!1,chown:!1,chownSync:!1,fchown:!1,fchownSync:!1,lchown:!1,lchownSync:!1,chmod:!1,chmodSync:!1,fchmod:!1,fchmodSync:!1,lchmod:!1,lchmodSync:!1,stat:!0,lstat:!1,fstat:!1,statSync:!1,lstatSync:!1,fstatSync:!1,link:!1,linkSync:!1,symlink:!1,symlinkSync:!1,readlink:!1,readlinkSync:!1,realpath:!1,realpathSync:!1,unlink:!0,unlinkSync:!1,rmdir:!0,rmdirSync:!1,mkdir:!0,mkdirSync:!1,readdir:!0,readdirSync:!1,close:!1,closeSync:!1,open:!1,openSync:!1,utimes:!0,utimesSync:!1,futimes:!1,futimesSync:!1,fsync:!1,fsyncSync:!1,write:!1,writeSync:!1,read:!1,readSync:!1,readFile:!0,readFileSync:!1,writeFile:!0,writeFileSync:!1,appendFile:!1,appendFileSync:!1,watchFile:!1,unwatchFile:!1,watch:!1,exists:!0,existsSync:!1,createReadStream:!1,createWriteStream:!1};function a(e){this._storageInterface=e}a.prototype._fsCall=function(e,t,n){var o=i.wrapCallback(n),r={method:e,args:t};this._storageInterface._channel.call("fscall",r,function(e){o.apply(null,e)})},a.prototype._pipeCall=function(e,t,n,o){var r=i.wrapCallback(o),a={readStream:{path:e,options:t},writeStream:n};this._storageInterface._channel.call("fspipe",a,r)},Object.keys(r).forEach(function(e){a.prototype[e]=r[e]?function(){var t,n=Array.prototype.slice.call(arguments);"function"==typeof n[n.length-1]&&(t=n.pop()),this._fsCall(e,n,t)}:function(){var t=new o(o.NOT_IMPLEMENTED,e+" is not implemented in shared local storage"),n=arguments[arguments.length-1];if("function"!=typeof n)throw t;n(t)}}),a.prototype.createReadStream=function(e){var t=this,n={on:function(e,t){n[e]=t},pipe:function(o,i){t._pipeCall(e,i,o,function(e){n[e.event]&&n[e.event].apply(null,e.args)})}};return n},a.prototype.createWriteStream=function(e,t){return{path:e,options:t}},Object.freeze(a),Object.seal(a.prototype),e.exports=a},function(e,t,n){var o=n(1),i=n(27),r=n(16),a=n(8),s={mimeTypeToExtensions:function(e){return i.getExtensions(e)},extensionToMimeTypes:function(e){return i.getMimeTypes(e)},canGenerateRenditionFromMimeType:function(e){return r.canComputeRenditionFromMimeType(e)},generateUuid:function(){return o.uuid()},copyFile:function(e,t,n,i){if(n)return a.copyFile(e,t,i);const r=o.getFileNameFromPath(t);a.getAvailablePath(t.substring(0,t.indexOf(r)),r,function(t,n){t?i(t):a.copyFile(e,n,i)})},getFileSize:function(e,t){a.statFile(e,function(e,n){t(e,n&&n.size)})}};Object.seal(s),e.exports=s},function(e,t,n){var o=n(18),i={reportUseElement:function(e,t,n){o.reportUseElement(e,t,n)},reportCheckoutElement:function(e,t,n){o.reportCheckoutElement(e,t,n)},reportCreateLink:function(e,t){o.reportCreateLink(e,t)},reportShareElementLink:function(e){o.reportShareElementLink(e)},reportShareLibraryLink:function(e){o.reportShareLibraryLink(e)}};Object.seal(i),e.exports=i},function(e,t,n){var o=n(28),i=n(113),r=n(3),a={obtainProcessLock:function(e,t){var n=r.getValue("ROOT_DIR");o.ensureDir(n,function(o){if(o)return console.error("Error: Could not create root directory: "+n),void t(!1);var r=i.openSync(n+"."+e,"w");i.flock(r,"exnb",function(e){if(e)return console.error("Error: CCLibrary process is already running."),void t(!1);t(!0)})})},clearTempFiles:function(e){try{var t=o.readdirSync(e);t&&t.forEach(function(t){if(-1!==t.indexOf(".TEMP_"))try{o.unlinkSync(e+"/"+t)}catch(e){}})}catch(e){}}};e.exports=a},function(e,t){e.exports=require("fs-ext")},function(e,t,n){var o,i=n(24),r=n(36),a=n(3),s=n(0),c=n(35),l=n(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(function(e){t.libraryStates.push({id:e.id,state:e._syncState})}),e._syncErrors.forEach(function(e){t.errors.push({code:e.code,message:e._message,libraryId:e.libraryId})}),t},d.prepareErrorForSerialization=function(e,t){return t=t||[e],Object.keys(e).forEach(function(n){if("underlyingError"===n&&e.underlyingError)-1===t.indexOf(e.underlyingError)?e.underlyingError=d.prepareErrorForSerialization(e.underlyingError,t.concat([e.underlyingError])):delete e.underlyingError;else try{JSON.stringify(e[n])}catch(t){delete e[n]}}),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(function(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+="-14"),t},d.getDeviceDescription=function(e){if(!o||e){var t,n=i.platform(),a={darwin:"mac",win32:"win",win64:"win"}[n]||n;if("darwin"===n)try{t=r.execSync("sw_vers -productVersion",{timeout:1e3}).toString().trim()}catch(e){}else t=i.release();o=a,t&&(o+="-"+t)}return o},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:"14",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,n){var o=n(3),i=n(6),r=n(10),a=n(16),s=n(0),c={mergeRenditionSizes:function(e){return a.addToRenditionSizeConfig(e),o.setValue("RENDITION_SIZES",s.RENDITION_SIZES)},mergeFullRenditionConfig:function(e){return a.addToFullRenditionConfig(e),o.setValue("FULL_RENDITION_CONFIG",s.FULL_RENDITION_CONFIG)},mergeLocalSettings:function(e){return Object.assign(s.LOCAL_SETTINGS,e),o.setValue("LOCAL_SETTINGS",s.LOCAL_SETTINGS)},triggerRenditionPrefetch:function(){r.getLoadedCollections().forEach(function(e){e.libraries.forEach(function(e){a.prefetchRenditions(e)})})},findElement:function(e,t){e=e||"";var n=new RegExp("cloud-asset://(.+)/([A-Za-z0-9-]+);node=([A-Za-z0-9-]+)"),o=e.match(n);if(o){var i,a,s,l=o[1],d=o[2],p=o[3];r.getLoadedCollections().every(function(e){return l!==e._syncManager.getElementRefDomainPath()||(i=e,(a=e.getLibraryById(d))&&(s=a.getElementById(p)),!1)}),s?t(null,s):0===r.getLoadedCollections().length?t("NO_COLLECTIONS_PRESENT"):i?a?a.sync(function(){(s=a.getElementById(p))?t(null,s):"error"===i.syncState?t("COLLECTION_SYNC_ERROR"):t("ELEMENT_NOT_FOUND")}):i.sync(function(){(a=i.getLibraryById(d))?c.findElement(e,t):"error"===i.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],n=t&&t.userId;if(!n)return;const r="VALIDATE_RENDITIONS_"+n;if(o.getValue(r))return;o.setValue(r,!0);const a=o.getValue("VALIDATE_RENDITIONS_SIZE_THRESHOLD");i.log("VALIDATE_RENDITIONS","Rendition invalidation check starting"),e.forEach(e=>{e.libraries.forEach(e=>{let t=!1;e.elements.forEach(n=>{const o=e._renditionCache.checkAndInvalidateRenditions(n,a);o&&(i.log("VALIDATE_RENDITIONS",o),t=!0)}),t&&(e._commit(!0,!0),e._notifyChange())})}),i.log("VALIDATE_RENDITIONS","Rendition invalidation check ending")}};e.exports=c},function(e,t,n){var o,i,r,a=n(30),s=n(3),c=n(6),l=n(63),d=n(17),p=n(10),h=n(47),u=n(119),_=n(0),f=n(5),m="ProductBridge",E="ProductBridgeLock",g=s.getValue("ROOT_DIR")+"librarylookupfile",y=new f(["syncBegin","syncEnd"]),v={},A={};function C(){r&&(clearTimeout(r),r=null)}function S(e){l.isLocked(E)||y.notify("syncBegin",[]),l.obtainLock(E,e)}function I(){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(i?_.VULCAN_LIBRARY_CHANGED_LOCAL_TYPE:_.VULCAN_LIBRARY_CHANGED_REMOTE_TYPE,e),v={},i=null}}function R(e,t,n){0!==Object.keys(v).length&&(v[e]||i!==n)&&O(),v[e]=t,i=n}function T(e,t,n){C(),c.log(m,"Saving lookup file"),e.userId=a.getUserId(),u.saveLookupMap(g,e,function(i){if(i)return c.log(m,i.toString()),o=null,void n();o=e,C(),r=setTimeout(function(){r=null,o=null,c.log(m,"Released lookup file")},s.getValue("PRODUCT_BRIDGE_INMEMORY_LIFETIME")),t?d.sendMessage(_.VULCAN_COLLECTIONS_LOADED_TYPE):L()||O(),c.log(m,"Lookup file saved"),c.log(m,"Lookup library count: "+Object.keys(o.libraries).length),n()})}function N(e){if(o)return e(o);c.log(m,"Reading lookup file"),u.readLookupMap(g,function(t,n){if(t)return c.log(m,t),void e(null);c.log(m,"Lookup file read"),e(o=n)})}function D(e,t,n){c.log(m,"Update Callback Received"),S(function(){N(function(o){if(!o)return I(),void A.collectionsLoaded();var i=e&&e.library,r=i&&o.libraries[i.id];if(r){var a=r.elements[e.id];if(a&&u.updateElementLookupData(a,t)){a.mod=u.getElementModifiedTime(e);var s={name:i.name,domain:i._collection._syncManager.getElementRefDomain(),path:i._collection._syncManager.getElementRefPath(),elements:{}};return s.elements[e.id]=a,R(i.id,s,n),void T(o,!1,function(){I()})}}L()||O(),I()})})}A.collectionsLoaded=function(){c.log(m,"Collections Loaded"),S(function(){v={},i=null;var e=p.getLoadedCollections(),t={elementTypes:s.getValue("PRODUCT_BRIDGE_ELEMENT_TYPES")||[],libraries:{}};e&&e.forEach(function(e){e.libraries.forEach(function(e){t.libraries[e.id]=u.buildLibraryLookupData(e,D)})}),T(t,!0,function(){I()})})},A.collectionsUnloaded=function(){c.log(m,"Collections Unloaded"),S(function(){!function(e){C(),c.log(m,"Deleting lookup file"),u.deleteLookupMap(g,function(t){t&&c.log(m,t.toString()),o=null,c.log(m,"Lookup file deleted"),e()})}(function(){d.sendMessage(_.VULCAN_COLLECTIONS_UNLOADED_TYPE),I()})})},A.libraryChanged=function(e,t){c.log(m,"Library Changed - "+(t?"Local":"Remote")+": "+e.id),S(function(){N(function(n){if(!n)return I(),void A.collectionsLoaded();var o,i=n.libraries[e.id],r=!1,a=function(e,n){D(e,n,t)};if(i){o={elements:{}},i.name!==e.name&&(i.name=e.name,r=!0);var s=[];e.elements.forEach(function(e){if(u.shouldIncludeInLookupData(e)){var t,n,c,l=i.elements[e.id];if(!(n=(n=!l||l.mod!==u.getElementModifiedTime(e))||!l||l.stockLicense!==h.getElementStockLicense(e)))l.reps.forEach(function(e){e.path||(c=c||[]).push(e.id)}),c&&(n=(t=u.buildElementLookupData(e,a)).reps.some(function(e){return e.path&&c.indexOf(e.id)>-1}));n&&(t=t||u.buildElementLookupData(e,a),o.elements[e.id]=t,i.elements[e.id]=t,r=!0),s.push(e.id)}}),Object.keys(i.elements).forEach(function(e){-1===s.indexOf(e)&&(o.elements[e]=null,delete i.elements[e],r=!0)})}else{var c=u.buildLibraryLookupData(e,a);o=c,n.libraries[e.id]=c,r=!0}if(!r)return L()||O(),void I();o.name=e.name,o.domain=e._collection._syncManager.getElementRefDomain(),o.path=e._collection._syncManager.getElementRefPath(),R(e.id,o,t),T(n,!1,function(){I()})})})},A.libraryDeleted=function(e){c.log(m,"Library Deleted: "+e),S(function(){O(),N(function(t){if(!t)return I(),void A.collectionsLoaded();delete t.libraries[e],T(t,!1,function(){I(),d.sendMessage(_.VULCAN_LIBRARY_DELETED_TYPE,e)})})})},A.isSyncing=function(){return L()||l.isLocked(E)},A.addListener=function(e,t){y.add(e,t)},A.removeListener=function(e,t){y.remove(e,t)},e.exports=A},function(e,t){e.exports=require("node-imslib")},function(e,t){e.exports=require("node-vulcanjs")},function(e,t,n){var o=n(20),i=n(3),r=n(47),a=n(1),s=n(16),c={normalizePath:function(e){return i.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 n=!1;return Array.isArray(t.reps)&&t.reps.forEach(function(t){n=e.reps.some(function(n,o){if(n.id===t.id&&n.path!==t.path)return e.reps[o]=t,!0})||n}),void 0!==t.stockLicense&&t.stockLicense!==e.stockLicense&&(n=!0,e.stockLicense=t.stockLicense,null===e.stockLicense&&delete e.stockLicense),n},buildElementLookupData:function(e,t){var n=e.modified,o={name:e.name,type:i.getValue("PRODUCT_BRIDGE_ELEMENT_TYPES").indexOf(e.type),mod:c.getElementModifiedTime(e),reps:[]},a=r.getElementStockId(e),l=r.getElementStockLicense(e);if(a&&(o.stockId=a),l&&(o.stockLicense=l),e.wasModifiedLocally&&(o.local=!0),e.representations.forEach(function(i){var a=!i.isExternalLink||s.shouldPrefetchExternalLink(i);if(i.isCompatibleType(i.type)&&a){const a={id:i.id};"primary"===i.relationship?o.reps.unshift(a):o.reps.push(a);const s=i.getCachedContentPath(),d=i.isExternalLink&&i.getCachedExternalLinkError();if(s||d)return a.type=i.type,void(s&&(a.path=c.normalizePath(s)));i.getContentPath((a,s)=>{if(s){var d={reps:[{id:i.id,type:i.type,path:c.normalizePath(s)}]};(l=r.getElementStockLicense(e))&&(d.stockLicense=l),n===e.modified&&t(e,d)}else i.isExternalLink&&r.getElementStockLicense(e)!==o.stockLicense&&t(e,{stockLicense:r.getElementStockLicense(e)||null})})}else i.isCompatibleType(i.type)&&i.isExternalLink&&i.testExternalLink(function(){r.getElementStockLicense(e)!==o.stockLicense&&t(e,{stockLicense:r.getElementStockLicense(e)||null})})}),s.shouldPrefetchFullRendition(e)){o.reps.push({id:"FULL_RENDITION"});var d=!0;e.getThumbnailPath(void 0,function(i,r){if(r){var a={id:"FULL_RENDITION",type:"image/png",path:c.normalizePath(r)};d?c.updateElementLookupData(o,{reps:[a]}):n===e.modified&&t(e,{reps:[a]})}}),d=!1}return o},buildLibraryLookupData:function(e,t){var n={name:e.name,domain:e._collection._syncManager.getElementRefDomain(),path:e._collection._syncManager.getElementRefPath(),elements:{}};return e.elements.forEach(function(e){c.shouldIncludeInLookupData(e)&&(n.elements[e.id]=c.buildElementLookupData(e,t))}),n},saveLookupMap:function(e,t,n){var i=e+".TEMP_"+a.uuid();o.writeFile(i,JSON.stringify(t),function(t){t?n(t):o.rename(i,e,function(e){n(e)})})},readLookupMap:function(e,t){o.exists(e,function(n){n?o.readFile(e,"utf8",function(e,n){try{n=n&&JSON.parse(n)}catch(t){n=void 0,e=t}t(e,n)}):t(null)})},deleteLookupMap:function(e,t){o.exists(e,function(n){n?o.unlink(e,function(e){t(e)}):t(null)})},shouldIncludeInLookupData:function(e){return-1!==(i.getValue("PRODUCT_BRIDGE_ELEMENT_TYPES")||[]).indexOf(e.type)}};e.exports=c},function(e,t,n){var o,i=n(3),r=n(17),a=n(22),s=n(122),c=n(0);r.addListener(c.VULCAN_SHUTDOWN_REQUEST,function(){o?o():process.exit(0)}),r.addListener(c.VULCAN_QUERY_REQUEST,function(e,t,n){s.perform(function(e){var o={port:i.getValue("SERVICE_PORT"),token:i.getValue("SERVICE_TOKEN")};e&&(o.portdiagnosis=e),i.setValue("SERVICE_LAST_QUERY_TIME",(new Date).valueOf()),r.sendMessage(c.VULCAN_QUERY_RESPONSE,JSON.stringify(o),t,n)})}),r.addListener(c.VULCAN_PROXY_QUERY_REQUEST,function(e,t,n){var o={};try{o=JSON.parse(e)}catch(e){}var i={requestId:o.requestId};if(!o.url||"string"!=typeof o.url)return i.err="url parameter must be specified, and must be a string",void r.sendMessage(c.VULCAN_PROXY_QUERY_RESPONSE,JSON.stringify(i),t,n);a.getProxyForURL(o.url,function(e,o){if(e)i.err=e;else{var s=a.getProxyCredentials();i.proxyHost=o.hostname,i.proxyPort=o.port,i.proxyUser=s.user,i.proxyPassword=s.password}r.sendMessage(c.VULCAN_PROXY_QUERY_RESPONSE,JSON.stringify(i),t,n)})}),a.addListener("change",function(){r.sendMessage(c.VULCAN_PROXY_CHANGE_MESSAGE,"","","")});var l={setShutdownListener:function(e){o=e},sendStartupMessage:function(){r.sendMessage(c.VULCAN_STARTUP_MESSAGE,"","","")}};e.exports=l},function(e,t){e.exports=require("node-ProxyResolver")},function(e,t,n){var o=n(123),i=n(3),r=n(38),a=n(6),s=n(22),c=n(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 n=c.format({protocol:"ws",host:"localhost:"+i.getValue("SERVICE_PORT")+"/",slashes:!0,query:{diagnostics:!0,token:i.getValue("SERVICE_TOKEN")}}),o=new r(n,{origin:"file://"});o.on("error",function(e){t(l.COULD_NOT_CONNECT_SOCKET,e)}),o.on("open",function(){o.close(),e()})})}function p(){return new Promise(function(e,t){s.isLocalhostProxied(function(n,o){!0===o?t(l.SIMPLE_HOSTNAME_GOING_TO_PROXY):e()})})}e.exports.perform=function(e){new Promise(function(e,t){o.lookup("localhost",function(n,o){"127.0.0.1"!==o?(a.log("DIAGNOSTICS","Expected localhost to resolve to 127.0.0.1, but instead it resolved to "+o),t(l.DNS_RESOLUTION_FAILED,n,o)):e()})}).then(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,n){var o=n(17),i=n(6),r=n(29),a=n(3),s=n(23),c=n(22),l=n(9),d=n(5),p=n(1),h="Thor";function u(e,t){var n=null;if(e){var o=new RegExp("<"+t+"[^<>]*>([^<>]*)</"+t+">",""),i=e.match(o);n=i&&i[1]}return n}function _(e){return e.replace("{{uuid}}",p.uuid())}function f(e){const t=r.parseXML(e),n=t&&t["feature-response"]&&t["feature-response"]["feature-entry"];if(!n)return i.log(h,`Failed to parse user feature XML: ${e}`),!1;const o=n.find(e=>e&&e.$&&"com.adobe.oobe.acc.v1.piip.user.status"===e.$.id),a=o&&o.$&&o.$.state;return i.log(h,`Obtained analytics state from Thor: ${a}`),"OptedIn"===a}var m=new d(["signIn","signOut","proxySettingsChanged","installApplication","uninstallApplication","updateApplication","analyticsStateChanged"]);o.addListener("accc.localapps.panel.refresh.ssoevent",function(e){var t=u(e,"event_type");i.log(h,"ACCC Sign-on State: "+t),"signin_success"===t?m.notify("signIn"):"signout_success"===t&&m.notify("signOut")}),o.addListener("com.adobe.aam.AAMIMSStatus",function(e){var t=u(e,"Status");i.log(h,"AAM Sign-on State: "+t),"USER_AUTH_SUCCESS"===t&&m.notify("signIn")}),o.addListener("com.adobe.aam.AAMSIGNOUTStatus",function(){i.log(h,"AAM Sign-on State: signOut"),m.notify("signOut")}),o.addListener("any.accc.app.ProductDeploymentEvent",function(e){var t={productCode:function(e){var t=e;return"PHSP"===e&&(t="PHXS"),t}(u(e,"productCode")),productVersion:u(e,"productVersion"),productLanguage:u(e,"productLanguage"),countryCode:u(e,"countryCode"),subscriptionStatus:u(e,"subscriptionStatus")};switch(u(e,"eventType")){case"Install":m.notify("installApplication",[t]);break;case"Uninstall":m.notify("uninstallApplication",[t]);break;case"Update":m.notify("updateApplication",[t])}}),o.addListener("any.accc.app.ProxySettingsChanged",function(e){var t=u(e,"proxyuser"),n=u(e,"proxypassword");null!==t&&null!==n&&m.notify("proxySettingsChanged",[t,n])}),o.addListener("any.accc.app.UserContextData",e=>{const t=f(e);m.notify("analyticsStateChanged",[t])});var E={addListener:function(e,t){m.add(e,t)},removeListener:function(e,t){m.remove(e,t)},removeAllListeners:function(e){m.removeAll(e)},getProxyCredentials:function(e){c.getProxyForURL("https://adobe.com",function(t,n){if(n&&n.hostname){var i={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")};o.call(i,function(t,n){if(t)return s.reportError("GetProxySettingsError","timed out getting proxy settings from Thor"),void e(null,null);var o=u(n,"proxyuser"),i=u(n,"proxypassword");s.reportEvent("getProxySettings",{isAuthenticatingProxy:!!o}),e(o,i)})}else e(null,null)})},configureFileSyncing:function(e,t){var n=l.wrapCallback(t),i=function(){var t={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")};o.call(t,function(e){e&&s.reportError("ConfigureFileSyncError","timed out turning on/off file sync via Thor"),n(e)})};o.isAppRunning("creativecloud")?i():o.launchApp("creativecloud",!1,"--showwindow=false",function(){setTimeout(i,a.getValue("THOR_LAUNCH_WAIT"))})},getAnalyticsState:function(e,t=0){const n=l.wrapCallback(e),s={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")};o.call(s,(o,s)=>{if(o)return i.log(h,"Error getting analytics opt-in state from Thor"),void(t<a.getValue("ANALYTICS_STATE_REQUEST_MAX_RETRIES")?setTimeout(()=>E.getAnalyticsState(e,t+1),a.getValue("ANALYTICS_STATE_REQUEST_RETRY_INTERVAL")):n(!1));const c=r.parseXML(s),l=c&&c.response;if(!l)return i.log(h,`Invalid analytics opt-in state response from Thor: ${s}`),void n(!1);const d=l.error&&l.error[0];if(d)return d&&d.$&&"SignInPending"===d.$.id?i.log(h,"User sign in pending. Analytics flag not received yet."):i.log(h,`Error fetching analytics opt-in state: ${JSON.stringify(d)}`),void n(!1);const p=f(l.UserfeatureXML&&l.UserfeatureXML[0]);m.notify("analyticsStateChanged",[p]),n(p)})}};e.exports=E},function(e,t,n){"use strict";function o(e,t){var n=e.toString();if(n.length<t){var o=[];o.length=t-n.length+1,n=o.join("0")+n}return n}function i(e,t){return Object.getOwnPropertyNames(t).forEach(function(n){if("object"==typeof t[n])"object"!=typeof e[n]&&(e[n]={}),i(e[n],t[n]);else{var o=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,o)}}),e}function r(e,t,n){e.forEach(function(e){setTimeout(function(){e(t,n)})})}var a={prod:"cc-api-data.adobe.io",stage:"cc-api-data-stage.adobe.io",dev:"cc-api-data-dev.adobe.io"},s={ENVIRONMENT:"prod",ALLOW_NO_TOKEN:!1,ANALYTICS_INGEST_TYPE:"dunamis",ANALYTICS_MAX_QUEUED_EVENTS:50,ANALYTICS_DEBOUNCE:1e4,ANALYTICS_API_KEY:null,ANALYTICS_X_PRODUCT:null,ANALYTICS_X_PRODUCT_LOCATION:void 0,ANALYTICS_PROJECT:null,ANALYTICS_USER_REGION:"UNKNOWN",TIMESTAMP_PROPERTY_NAME:"event.dts_end"},c=["ANALYTICS_API_KEY","ANALYTICS_X_PRODUCT","ANALYTICS_PROJECT"];function l(e,t){var n=this;e=e||{},t=t||{};var o=function(e){throw n._log(e),new Error("ERROR: "+e)};this._queuedEvents=[],this._queuedCallbacks=[],this._lastSendTime=0,this._isEnabled=!1,this._dependencies=i({},e),e.getAccessToken&&"function"==typeof e.getAccessToken||o("Missing dependency: getAccessToken"),this._options={},Object.keys(s).forEach(function(e){this._options[e]=t[e]||s[e]},this),c.forEach(function(e){this._options[e]||o("Missing option: "+e)},this)}l.prototype._log=function(e){var t=this._dependencies.log;t&&t("Ingest :: "+e)},l.prototype._getAgent=function(e,t){this._dependencies.getAgent?this._dependencies.getAgent(e,t):t(null,{})},l.prototype._getAccessToken=function(e){this._dependencies.getAccessToken(e)},l.prototype._clearAccessToken=function(){this._dependencies.clearAccessToken&&this._dependencies.clearAccessToken()},l.prototype._getEnvironment=function(){return a[this._options.ENVIRONMENT]?this._options.ENVIRONMENT:"prod"},l.prototype._getAnalyticsHost=function(){return a[this._getEnvironment()]},l.prototype._formatTimestamp=function(e){var t=e.getFullYear(),n=o(e.getMonth()+1,2),i=o(e.getDate(),2),r=o(e.getHours(),2),a=o(e.getMinutes(),2),s=o(e.getSeconds(),2),c=o(e.getMilliseconds(),3),l=e.getTimezoneOffset(),d=l<0?"+":"-",p=Math.floor(Math.abs(l)/60),h=Math.abs(l)%60;return t+"-"+n+"-"+i+"T"+r+":"+a+":"+s+"."+c+(d+o(p,2)+o(h,2))},l.prototype._updateDebounce=function(e){var t=e&&(e["retry-after"]||e["Retry-After"]),n=0;if(t){var o;try{o=parseInt(t,10)}catch(e){}if(o)n=Math.max(0,o);else{var i=Date.parse(t);if(i){var r=(new Date).valueOf();n=Math.max(0,i-r)/1e3+Math.floor(10*Math.random())}}}this._options.ANALYTICS_DEBOUNCE=Math.max(1e3*n,this._options.ANALYTICS_DEBOUNCE)},l.prototype._queueEvent=function(e){this._queuedEvents.length>=this._options.ANALYTICS_MAX_QUEUED_EVENTS&&this._queuedEvents.shift(),this._queuedEvents.push(e)},l.prototype._requeueEvents=function(e){this._queuedEvents=e.concat(this._queuedEvents),this._queuedEvents=function(e,t){var n=e;if(e&&e.length>t&&t>0){var o=e.length-t;n=e.slice(o,e.length)}return n}(this._queuedEvents,this._options.ANALYTICS_MAX_QUEUED_EVENTS)},l.prototype._sendAnalytics=function(e,t,o){var a=this;if(o=o||0,t&&this._queuedCallbacks.push(t),!this._isEnabled||0===this._queuedEvents.length){var s=this._queuedCallbacks;return this._queuedCallbacks=[],void(this._isEnabled?r(s,null,0):r(s,new Error("Analytics Disabled")))}var c=this._options.ANALYTICS_DEBOUNCE;if(e&&(c=0,clearTimeout(this._pendingSendAnalyticsTimeout),this._pendingSendAnalyticsTimeout=void 0),this._sendingEvents||this._pendingSendAnalyticsTimeout)this._log("Queued "+this._queuedEvents.length+" events to be sent.");else{var l=(new Date).valueOf();if(l-this._lastSendTime<c)this._pendingSendAnalyticsTimeout=setTimeout(function(){a._pendingSendAnalyticsTimeout=void 0,a._sendAnalytics()},c);else{this._lastSendTime=l,this._sendingEvents=this._queuedEvents,this._sendingCallbacks=this._queuedCallbacks,this._queuedEvents=[],this._queuedCallbacks=[];var 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},u=function(e){var t=a._queuedEvents.length,n=a._sendingEvents.length;e?(a._requeueEvents(a._sendingEvents),a._log(p+"Error sending "+n+" events: "+e)):a._log(p+"Success sending "+n+" events: "+JSON.stringify(a._sendingEvents)),delete a._sendingEvents;var o=a._sendingCallbacks;delete a._sendingCallbacks,e?r(o,e):r(o,null,n),t>0&&a._sendAnalytics()},_=function(e,t){if(a._updateDebounce(t),401===e&&0===o)return a._clearAccessToken(),a._requeueEvents(a._sendingEvents),delete a._sendingEvents,a._queuedCallbacks=a._sendingCallbacks.concat(a._queuedCallbacks),delete a._sendingCallbacks,a._log(p+"Access token is expired. Retry one more time."),void a._sendAnalytics(!0,void 0,o+1);200===e?u():u(new Error("Unexpected Response: "+e))};this._getAccessToken(function(e,t){if(e)u(e);else if(t&&0!==t.length||a._options.ALLOW_NO_TOKEN){var o="https://"+a._getAnalyticsHost();if(a._log(p+"Sending analytics to "+o+"/ingest"),"undefined"!=typeof global&&global.Buffer){var r={"x-api-key":a._options.ANALYTICS_API_KEY,"X-Product":a._options.ANALYTICS_X_PRODUCT,"X-Request-Id":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(o,function(e,t){t&&t.agent?s.agent=t&&t.agent:i(s,t||{});var o=n(26).request(s,function(e){e&&function(e){var t=function(){};e.on("data",t),e.on("end",t)}(e);var t=e&&e.statusCode,n=e&&e.headers;_(t,n)});o.once("error",function(e){u(e)}),o.end(JSON.stringify(h))})}else{!function(e){var n=new XMLHttpRequest;n.onreadystatechange=function(){if(4===this.readyState){var e=n.getAllResponseHeaders();_(this.status,e)}},n.onerror=function(e){u(new Error(e))},n.open("POST",o+"/ingest",!0),n.setRequestHeader("x-api-key",a._options.ANALYTICS_API_KEY),n.setRequestHeader("x-user-region",a._options.ANALYTICS_USER_REGION),n.setRequestHeader("Content-Type","application/json"),t&&n.setRequestHeader("Authorization","Bearer "+t),n.setRequestHeader("X-Product",a._options.ANALYTICS_X_PRODUCT),n.setRequestHeader("X-Product-Location",a._options.ANALYTICS_X_PRODUCT_LOCATION),n.setRequestHeader("X-Request-Id",d),n.send(e)}(JSON.stringify(h))}}else u(new Error("No access token"))})}}},l.prototype.enable=function(e){this._isEnabled=e,e&&this._sendAnalytics(!0)},l.prototype.postEvent=function(e,t){var n=this._formatTimestamp(new Date);e[this._options.TIMESTAMP_PROPERTY_NAME]=n;var o={time:n,project:this._options.ANALYTICS_PROJECT,environment:this._getEnvironment(),ingesttype:this._options.ANALYTICS_INGEST_TYPE,data:e};this._queueEvent(o),this._sendAnalytics(!1,t)},l.prototype.flush=function(e,t){this._sendAnalytics(e,t)},e.exports=l},function(e,t,n){var o,i,r,a=n(17),s=n(6),c=n(29),l=n(3),d=n(10),p=n(12),h=n(9),u=n(5),_=n(1),f=n(0),m={job:"files"},E={filterjob:"files",observe:{attrs:'type="sync.out.notify.job.status"'}},g={changemonitor:"cclibraries"},y={changemonitor:"cclibraries",pathprefix:[f.STORAGE_ASSETS_PATH+f.LIBRARY_SYNC_GROUP,f.BOOKMARKS_MONITOR_PATH]},v={filterchangemonitor:"cclibraries"},A=new RegExp(".*/([^/]+)/manifest$"),C=new RegExp(".*/([^/]+)$"),S=function(e){var t=c.parseXML(e,function(e){s.log("CoreSyncNotifications",e)}),n=t&&t.message||{};Object.keys(n).forEach(function(e){n[e]=n[e][0]});var o=n.events&&n.events.event;o&&(n.events=[],o.forEach(function(e){n.events.push(e.$)}));var i=n.errors&&n.errors.error;return i&&(delete n.errors,n.numErrors=i.length,n.firstError=i[0]&&i[0].$),n},I=function(e,t,n,o,i){i=i||0;var r=_.uuid(),c="sync.in.request."+t,d="sync.out.response."+t,p=JSON.parse(JSON.stringify(n));e&&(p.userid=e.userId,p.cloudid=function(e){return e===f.DEFAULT_CLOUD_ID?f.DEFAULT_CORESYNC_CLOUD_ID:e}(e.cloudId)),p.requestid=r,p.type=c;var h={requestType:c,responseType:d,payload:function(e){var t="";return Object.keys(e).forEach(function(n){var o=e[n];o.attrs?t+="<"+n+" "+o.attrs+" />":Array.isArray(o)?o.forEach(function(e){t+="<"+n+">"+e+"</"+n+">"}):t+="<"+n+">"+o+"</"+n+">"}),'<?xml version="1.0" encoding="utf-8"?><message>'+t+"</message>"}(p),targetId:"CORS",targetVersion:"",timeout:l.getValue("CORE_SYNC_REQUEST_TIMEOUT")};a.call(h,function(a,c){if(a)i<l.getValue("CORE_SYNC_NUM_RETRIES")?I(e,t,n,o,i+1):o(a);else{var d=S(c);if(!d||d.requestid!==r)return!1;s.log("CoreSyncNotifications",t+":\n"+JSON.stringify(d,void 0,2)),o(null,d)}})},L=new u(["libraryChange","bookmarkChange","fileSyncState"]),O={},R=!0,T=function(){i=void 0,o=void 0,O={}},N=function(e){return e.userId+"/"+e.cloudId},D=function(e,t){var n=!!t&&void 0===t.status;i=e||!t?String(e):"disabled"===t.majorstate||"does_not_exist"===t.status?"turned_off":"syncing"===t.majorstate||"idle"===t.majorstate?"normal":"error_"+(t.status||t.majorstate),L.notify("fileSyncState",[i,n])},b=function(e,t){I(e,"job.getstatus",m,function(e,n){D(e,n),t(e)})},w=function(e,t){I(e,"changemonitor.enable",g,function(e,n){if(e)t(e);else{var o=n&&n.status;"success"===o?t(null):(s.log("CoreSyncNotifications","Error enabling changemonitor: "+o),t("enable_error"))}})},P=function(e,t){I(void 0,"observer.create",e,function(e,n){if(e)t(e);else{var o=n&&n.status;"success"===o?t(null,n.observerid):(s.log("CoreSyncNotifications","Error creating observer: "+o),t("create_error"))}})},x=function(e,t){!function(e,t){I(e,"changemonitor.getstatus",g,function(n,o){if(n)t(n);else{var i=o&&o.status;if("does_not_exist"===i){var r=Object.assign({},y);e.cloudId!==f.DEFAULT_CLOUD_ID&&(r.syncurl=e.syncurl),I(e,"changemonitor.create",r,function(n,o){n?t(n):"success"===(i=o&&o.status)?w(e,t):(s.log("CoreSyncNotifications","Error creating changemonitor: "+i),t("create_error"))})}else"success"===i?"active"===o.majorstate?t(null):w(e,t):(s.log("CoreSyncNotifications","Unexpected changemonitor status: "+i),t("status_error"))}})}(e,function(n){n?t(n):(e.isEnabled=!0,e.observerId?t(null):P(v,function(n,o){n?t(n):(e.observerId=o,t(null))}))})},k=function(e,t){!function(e,t){I(void 0,"observer.destroy",{observerid:e},function(e,n){if(e)t(e);else{var o=n&&n.status;"success"===o?t(null):(s.log("CoreSyncNotifications","Error destroying observer: "+o),t("destroy_error"))}})}(e.observerId,function(){delete e.observerId,function(e,t){I(e,"changemonitor.destroy",g,function(e,n){if(e)t(e);else{var o=n&&n.status;"success"===o?t(null):(s.log("CoreSyncNotifications","Error destroying changemonitor: "+o),t("destroy_error"))}})}(e,t)})},M=[],V=function(e,t){var n=h.wrapCallback(e);if(t=t||0,M.push(n),!(M.length>1)){var a=function(e){var n=M;M=[],n.forEach(function(t){t(e)}),e?e&&!r&&t<l.getValue("CORE_SYNC_NUM_RETRIES")&&(r=setTimeout(function(){V(void 0,t+1)},l.getValue("CORE_SYNC_REQUEST_TIMEOUT"))):clearTimeout(r)};if(!R)return T(),void a(null);var s=new p;if(Object.keys(O).forEach(function(e){var t=O[e];d.getLoadedCollectionById(t.userId,t.cloudId)||(delete O[e],s.addOperation(k,[t]))}),d.getLoadedCollections().forEach(function(e){if(!e.isPublic){var t=N(e);if(O[t])O[t].isEnabled?"stopped"===O[t].state&&"normal"===i&&s.addOperation(x,[O[t]]):s.addOperation(x,[O[t]]);else{var n={userId:e.userId,cloudId:e.cloudId,syncurl:e.cloudInfo&&e.cloudInfo.syncURI};s.addOperation(function(e){x(n,function(o){o||(O[t]=n),e(o)})})}}}),!o){s.addOperation(function(e){P(E,function(t,n){t?e(t):(o=n,e(null))})});var c=d.getLoadedCollections()[0];c&&s.addOperation(b,[c])}s.run(a)}};d.addLoadedCollectionsListener(V),a.addListener("sync.out.broadcast.app.startedup",function(){T(),R=!0,V()}),a.addListener("sync.out.broadcast.app.shuttingdown",function(){L.notify("fileSyncState",["shutdown",!0]),R=!1,V()}),a.addListener("sync.out.notify.job.status",function(e){var t=S(e);s.log("CoreSyncNotifications","sync.out.notify.job.status:\n"+JSON.stringify(t,void 0,2)),D(null,t),V()}),a.addListener("sync.out.notify.changemonitor.status",function(e){var t=S(e);s.log("CoreSyncNotifications","sync.out.notify.changemonitor.status:\n"+JSON.stringify(t,void 0,2));var n=N({userId:t.userid,cloudId:function(e){return e===f.DEFAULT_CORESYNC_CLOUD_ID?f.DEFAULT_CLOUD_ID:e}(t.cloudid)});O[n]&&(O[n].state=t.majorstate,"disabled"===t.majorstate&&(s.log("CoreSyncNotifications","Change monitor was disabled - need to re-enable"),O[n].isEnabled=!1,V()))}),a.addListener("sync.out.notify.changemonitor.pathevent",function(e){var t={},n=!1;const o=S(e).events||[],i={};o.forEach(e=>{e&&(i[e.type]=i[e.type]||0,i[e.type]++)});const r=Object.keys(i).map(e=>`${e}: ${i[e]}`).join(", ");s.log("CoreSyncNotifications",`sync.out.notify.changemonitor.pathevent: ${r||"no events"}`),o.forEach(function(e){if(e)if(e.path!==f.BOOKMARKS_MONITOR_PATH){var o=e.path&&e.path.match(A);if(o)t[o[1]]=!0;else{var i=e.path&&e.path.match(C);"deleted"===e.type&&"folder"===e.file_type&&i&&(t[i[1]]=!0)}}else n=!0});var a=Object.keys(t);a.length>0&&(s.log("CoreSyncNotifications","Report library change"),L.notify("libraryChange",[a])),n&&(s.log("CoreSyncNotifications","Report bookmark change"),L.notify("bookmarkChange",[]))});var F={addListener:function(e,t){L.add(e,t)},removeListener:function(e,t){L.remove(e,t)},removeAllListeners:function(e){L.removeAll(e)},ping:function(e){V(e)}};e.exports=F},function(e,t,n){var o=n(17),i=n(3),r=n(6),a=n(29),s=n(23),c=n(5),l=n(9),d=n(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(function(t){e=e.concat(p[t])}),e}(),u=new c(h),_=function(e){return a.parseXML(e,function(t){r.log("ANS",t),s.reportError("ANS","Failed to parse ANS message: "+e)})},f=function(e,t){return e&&e[t]&&e[t][0]},m=function(e,t){return e&&e[t]||[]};o.addListener("cclibraries.notification.ans",function(e){var t=_(e),n=t&&t["notifications-signal"],a=n&&n["notification-signal"];a&&a.forEach(function(e){var t=e.$&&e.$["sub-type"];if(r.log("ANS","Received notification: "+t),-1!==h.indexOf(t)){var n=[];m(e,"notification-info").forEach(function(e){var t=f(e,"notification-ids"),o=m(t,"notification-id");n=n.concat(o)}),function(e,t){var n=d.uuid(),a="";e.forEach(function(e){a+="<notification-id>"+e+"</notification-id>"});var c={NOTIFICATION_IDS:a,REQUEST_ID:n,REQUEST_NAMESPACE:"cclibraries.notification.ans.byID.data"},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:i.getValue("GET_NOTIFICATION_TIMEOUT")};o.call(p,function(e,o){if(e)return"timeout"===e&&(r.log("ANS","Timed out getting notification data from Thor"),s.reportError("ANS","Timed out getting notification data from Thor")),void t(e);var i=[];if(o){var a=_(o),c=a&&a.notifications;if(f(c,"request-context")!==n)return!1;m(c,"notification").forEach(function(e){var t=f(e,"notification-id"),n=f(e,"payload");try{n=n&&JSON.parse(n)}catch(t){r.log("ANS","Failed to parse ANS payload: "+e.payload),s.reportError("ANS","Failed to parse ANS payload: "+e.payload)}i.push({id:t,payload:n,state:f(e,"state"),created:parseInt(f(e,"timestamp"),10),modified:parseInt(f(e,"modifiedTimeStamp"),10)})})}t(null,i)})}(n,function(e,n){e||n.forEach(function(e){u.notify(t,[e])})})}})});var E={};E.EVENTS=p,E.addListener=function(e,t){u.hasListeners(e)||function(e){var t;Object.keys(p).some(function(n){if(p[n].includes(e))return t=n,!0});var n={NOTIFICATION_TYPE:t,NOTIFICATION_SUB_TYPE:e,OBSERVER_NAMESPACE:"cclibraries.notification.ans"};o.sendMessage("accc.notifications",l.constructStringFromTemplate('<?xml version="1.0" encoding="utf-8"?><NEMessage action="RegisterObserver"><type>{{NOTIFICATION_TYPE}}</type><sub-type>{{NOTIFICATION_SUB_TYPE}}</sub-type><observer-namespace>{{OBSERVER_NAMESPACE}}</observer-namespace></NEMessage>',n),"ADCS","")}(e),u.add(e,t)},E.removeListener=function(e,t){u.remove(e,t)},E.removeAllListeners=function(e){u.removeAll(e)},E.setState=function(e){var t={NOTIFICATION_ID:e.id,STATE:e.state};o.sendMessage("accc.notifications",l.constructStringFromTemplate('<?xml version="1.0" encoding="utf-8"?><NEMessage action="UpdateServerNotification"><notification><notification-id>{{NOTIFICATION_ID}}</notification-id><state>{{STATE}}</state></notification></NEMessage>',t),"ADCS","")},e.exports=E},function(e,t,n){var o=n(3),i=n(5),r=n(1),a=n(39),s=n(17),c={Ipc:{GetActiveCloudRequest:"accc.app.GetActiveCloudRequest",GetActiveCloudResponse:"any.app.GetActiveCloudResponse",UpdateActiveCloud:"any.accc.app.UpdateActiveCloud",SuiteMessage:"vulcan.SuiteMessage."}};function l(e,t){a.parseString(e,function(e,n){if(e)t("Error parsing XML response: "+e);else{var o=n&&n.response&&n.response.clouds&&n.response.clouds[0],i=(o=o||n&&n.message&&n.message.clouds&&n.message.clouds[0])&&o.$&&o.$.activeCloud,r=o&&o.$&&o.$.trueCloudCount&&parseInt(o.$.trueCloudCount,10),a=o&&o._;if(i){var s=[];if(a)try{var c=new Buffer(a,"base64");s=JSON.parse(c.toString())}catch(e){}t(null,s,i,r)}else t("Invalid response from any.app.GetActiveCloudResponse")}})}var d=new i(["cloudChange"]);s.addListener(c.Ipc.UpdateActiveCloud,function(e){l(e,function(e,t,n,o){var i;e?d.notify("cloudChange",[e]):(t.forEach(function(e){e.id===n&&(i=e)}),d.notify("cloudChange",[e,i,o]))})});var p={};p.getClouds=function(e){var t,n=setTimeout(function(){s.removeListener(c.Ipc.GetActiveCloudResponse,t),e("GetActiveCloud timed out after "+o.getValue("GET_ACTIVE_CLOUD_TIMEOUT")+"ms")},o.getValue("GET_ACTIVE_CLOUD_TIMEOUT"));t=function(o){clearTimeout(n),l(o,e),s.removeListener(c.Ipc.GetActiveCloudResponse,t)},s.addListener(c.Ipc.GetActiveCloudResponse,t),s.sendMessage(c.Ipc.GetActiveCloudRequest,"<request><type>"+c.Ipc.GetActiveCloudRequest+"</type><requestid>"+r.uuid()+"</requestid></request>","ADCS","1.9.0")},p.getActiveCloud=function(e){p.getClouds(function(t,n,o,i){var r;t?e(t):(n.forEach(function(e){e.id===o&&(r=e)}),e(null,r,i))})},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,n){var o=n(3),i=n(17),r=n(23),a=n(6),s=n(0),c=n(9),l=n(1),d=n(14),p="ProductLauncher",h=o.getValue("PRODUCT_LAUNCHER_SUPPORTED_PRODUCTS"),u={};function _(e,t){var n=e.specifierInfo;if(e.element)if(e.action){if(!e.element._getActions(e.action).some(function(t){return t.appCode===e.specifierInfo.code})){var c=e.element.getPrimaryRepresentation(),d=e.element.type+":"+(c&&c.type),h="Unexpectedly trying to ["+e.action+"] "+d+" in "+n.code;a.log(p,"Error: "+h),r.reportError("ElementActionConfigMismatch",h)}var u=null,_={elementRef:e.element.getReference(),requestID:l.uuid(),appCode:n.code,path:n.path,action:e.action};if(!1===e.waitForCompletion)return i.sendMessage(s.VULCAN_APP_SEND_ACTION_MESSAGE,JSON.stringify(_),n.code,n.version),void t(null,n);a.log(p,"Sending open request: ",JSON.stringify(_)),i.addListener(s.VULCAN_APP_ACTION_ACCEPTED_MESSAGE,f),i.sendMessage(s.VULCAN_APP_SEND_ACTION_MESSAGE,JSON.stringify(_),n.code,n.version),u=setTimeout(function(){i.removeListener(s.VULCAN_APP_ACTION_ACCEPTED_MESSAGE,f,n.code,n.version),t("APP_SEND_ACTION_FAILED")},o.getValue("SEND_ACTION_TIMEOUT"))}else t("NO_ACTION_SPECIFIED");else t(null,n);function f(e,o,r){a.log(p,"Recieved edit accept from :",o," ",r,": ",e),e===_.requestID?(clearTimeout(u),i.removeListener(s.VULCAN_APP_ACTION_ACCEPTED_MESSAGE,f,n.code,n.version),t(null,n)):a.log(p,"RequestID didn't match: Expected "+_.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")}u.getAppDetails=function(e){var t=[];return s.ELEMENT_ACTION_PRODUCT_MAP.installedApps.forEach(function(n){if(n.code===e.appCode){var o={};Object.assign(o,n),-1===c.compareVersions(e.minVersion||0,o.version)?o.isUnsupported=!0:o.isAlreadyRunning=i.isAppRunning(o.specifier),t.push(o)}}),t.sort(function(t,n){if(!1!==e.prioritizeRunning){if(t.isAlreadyRunning&&!n.isAlreadyRunning)return-1;if(n.isAlreadyRunning&&!t.isAlreadyRunning)return 1}return c.compareVersions(t.version,n.version)}),a.log(p,"Installed app details: "+JSON.stringify(t)),t[0]},u.appStatus=function(e){return f(u.getAppDetails(e))};var m={};u.launch=function(e,t){const n=u.getAppDetails(e),r=f(n);if(t=t||(()=>void 0),"USABLE"!==r)return void t(r);var c=n.specifier;if(e.specifierInfo=n,n.isAlreadyRunning||!1===e.waitForCompletion&&!e.element)return a.log(p,"Switching focus to app: "+c),void i.launchApp(c,!0,"",function(){_(e,t)});if(m[c]=m[c]||[],m[c].push({options:e,callback:t}),m[c].length>1)return;function l(e){var t=m[c];delete m[c],t.forEach(e)}let h;function E(e,t,o){var r={};try{r=JSON.parse(e)}catch(n){return void a.log(p,"Unparsable payload received from "+t+" "+o,e)}d.normalize(r.path)===d.normalize(n.path)?(clearInterval(h),i.removeListener(s.VULCAN_APP_READY_MESSAGE,E),l(e=>_(e.options,e.callback))):a.log(p,"Received unknown app ready: "+e+" from "+t+" "+o+", specifier - "+JSON.stringify(n))}i.addListener(s.VULCAN_APP_READY_MESSAGE,E);const g=(e,t)=>{clearInterval(h),i.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>o.getValue("LAUNCH_APP_TIMEOUT")?g("APP_LAUNCH_TIMEOUT","Launch app timed out: "+c):i.isAppRunning(c)||g("APP_LAUNCH_FAILED","App was killed before it finished launching: "+c)},o.getValue("LAUNCH_APP_POLL_INTERVAL")),a.log(p,"Launching app: "+c),i.launchApp(c,!0,"",(e,t)=>{(e||!0!==t)&&g("APP_LAUNCH_FAILED","Vulcan could not launch app: "+c+" "+e)})},u.updateInstallationMap=function(e){var t=i.getSpecifiers();a.log(p,"Recieved the list of installed apps: "+t.join(", "));var n={};(s.ELEMENT_ACTION_PRODUCT_MAP.installedApps||[]).forEach(function(e){n[e.specifier]=e});var o=[];return t.forEach(function(t){if(!n[t]||e){var r=t.split("-");if(2===r.length){var s=h[r[0]];if(!s)return;var c=i.getAppPath(t);if(!c)return void a.log(p,"No application path for specifier: "+t);var l=i.getAppVersion(t);if(!l)return void a.log(p,"No application version for specifier: "+t+" at "+c+" ("+l+")");o.push({specifier:t,code:s,version:l,path:d.normalize(c)})}else a.log(p,"Unexpected app specifier structure: "+t)}else o.push(n[t])}),s.ELEMENT_ACTION_PRODUCT_MAP.installedApps=o,a.log(p,"Updated installation map: ",JSON.stringify(o)),o},e.exports=u},function(e,t,n){var o=n(6),i=n(29),r=n(17),a=n(3),s=n(5),c=n(9),l=n(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>',u=new s(["clickNotification"]);r.addListener("cclibrary.app.ShowNotificationResponse",function(e){var t,n,r,a,s=i.parseXML(e);try{r=s.response.requestid[0],a=s.response.context[0],t=(n=JSON.parse(a)).type}catch(t){o.log("Toast","Failed to parse, notification response "+e)}u.hasListeners("clickNotification")&&u.notify("clickNotification",[t,r,n.data])}),d.addListener=function(e,t){u.add(e,t)},d.removeListener=function(e,t){u.remove(e,t)};var _,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(!_)if(t)_=setTimeout(function(){_=void 0,e()},t);else if(0!==f.length){var n=f.shift(),o=c.constructStringFromTemplate(h,n);r.sendMessage(p,o,"ADCS",""),e(a.getValue("OS_TOAST_NOTIFICATIONS_BACKOFF"))}}(e.overridable?a.getValue("OS_TOAST_NOTIFICATIONS_DELAY"):0)},e.exports=d},function(e,t,n){var o,i,r=n(36),a=n(3),s=n(14),c=n(6),l=n(23),d=n(8),p=0,h={},u={_isEnabled:!0};u._scriptPath=s.join(__dirname,"localThumbnailsProcess.js"),u._startChildProcess=function(){o||(c.log("LocalThumbnails","Starting child process"),o=r.fork(u._scriptPath),process.on("exit",u._stopChildProcess),o.on("message",u._handleResponse),o.on("exit",u._handleExit))},u._stopChildProcess=function(e){o&&(c.log("LocalThumbnails","Stopping child process"),o.removeListener("message",u._handleResponse),o.removeListener("exit",u._handleExit),process.removeListener("exit",u._stopChildProcess),e||o.send({exit:!0}),o=void 0)},u._handleResponse=function(e){var t=h[e.id];if(delete h[e.id],t){0===Object.keys(h).length&&(i&&clearTimeout(i),i=setTimeout(function(){0===Object.keys(h).length&&u._stopChildProcess(),i=null},a.getValue("LOCAL_THUMBNAILS_SHUTDOWN_DELAY")));var n=" ("+((new Date).valueOf()-t.startTime)+"ms)";"__test__"===t.source?(c.log("LocalThumbnails","Testing: Success"+n),t.callback(e.err)):e.err?(c.log("LocalThumbnails","["+t.id+"] Error received: "+e.err+n),l.reportError("ThumbnailGeneratorError",e.err),t.callback(e.err)):(c.log("LocalThumbnails","["+t.id+"] Success"+n),t.callback(null,t.destination))}},u._handleExit=function(e,t){u._stopChildProcess(!0);var n=Object.keys(h);if(0!==n.length){var o="Unexpected exit: "+(null!==e?e:t);l.reportError("ThumbnailGeneratorError",o),n.forEach(function(e){var t=h[e];"__test__"===t.source?c.log("LocalThumbnails","Testing: Failed - "+o):c.log("LocalThumbnails","["+e+"] "+o),t.callback("unexpected_exit")}),h={}}},u.generate=function(e,t,n,i){if(u._isEnabled)if(e&&t){u._startChildProcess();var r={id:p++,startTime:(new Date).valueOf(),source:e,destination:t,size:n,callback:i};h[r.id]=r,"__test__"!==e&&c.log("LocalThumbnails","["+r.id+"] Requesting (size "+n+"): "+e),d.ensurePathExists(s.dirname(t),()=>{o.send({id:r.id,src:s.normalize(e),dest:s.normalize(t),size:n})})}else i("Missing source and/or destination path - source:"+e+"destination:"+t);else i("local_thumbnails_disabled")},u.test=function(e){u.generate("__test__","__test__",250,function(t){var n="unexpected_exit"!==t;u._isEnabled=n,e(n)})},e.exports=u},function(e,t,n){const o=n(20),i=n(133),r=n(23),a=n(5),s=n(3),c=n(6),l="SystemFonts";e.exports=class{constructor(){this._listenerManager=new a(["change"]),this._fontWatchers=[],this._changeCount=0,this._getFonts()}_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(()=>{this._pendingRefresh?this._pendingRefresh=!1:(clearInterval(t),c.log(l,"Loading system fonts"),i.getAvailableFonts(t=>{if(delete this._fetchingPromise,!t||this._pendingRefresh){const n=t?"System fonts changed while loading":"Failed to load system fonts";return this._pendingRefresh=!1,c.log(l,`${n} - loading again`),void e(this._getFonts())}c.log(l,`Loaded ${t.length} fonts`),this._fontCache=t,this._listenerManager.notify("change"),e(t)}))},s.getValue("FONT_WATCH_DEBOUNCE"))}),this._fetchingPromise)}_onChange(e){c.log(l,`Font directory changed: ${e}`),this._getFonts(!0).then(()=>this._changeCount=0),this._changeCount++,this._changeCount>s.getValue("FONT_WATCH_RESET")&&(c.log(l,"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&&s.getValue("FONT_DIRS").forEach((e,t)=>{if(this._fontWatchers[t])return;const n=()=>this._onChange(e),i=n=>{c.log(l,`Failed to watch font directory (${n&&n.code}): ${e}`),this._fontWatchers[t]=void 0,r.reportError(l,n&&n.code)};try{this._fontWatchers[t]=o.watch(e,{persistent:!1},n),c.log(l,`Watching font directory: ${e}`),this._fontWatchers[t].on("error",i)}catch(e){i(e)}})}isFontAvailable(e,t=!1){this._ensureWatchers();const n=t?"family":"postscriptName";return this._getFonts().then(t=>t.some(t=>t[n]===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()}}},function(e,t){e.exports=require("font-manager")},function(e,t,n){const o=n(135),i=n(10),r=n(30),a=n(3),s=n(6),c=n(17),l=n(1),d=n(136),p=n(138),h=n(139),u=n(140);let _=n(141);const f="API",m="cclibraries.api.QueryRequest",E="cclibraries.api.QueryResponse";e.exports=class{initialize(e){return this._server?Promise.reject("API is already initialized"):(this._server=o.createServer({name:"CCLibraries REST API"}),this._server.use(o.plugins.bodyParser()),this._server.use(o.plugins.queryParser({mapParams:!0})),this._server.use((e,t,n)=>{let o=this._logRequest(e,t);if(t.header("x-request-id",o),t.header("x-env",a.getEnvironment().LABEL),t.header("access-control-allow-origin","*"),t.charSet("utf-8"),"OPTIONS"===e.method)return n();if((e.headers.token||e.query.token)!==this._serviceToken)return t.send(401);if(0===i.getLoadedCollections().length){const e=r.getUserId();return t.send(403,{userId:e})}n()}),this._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 d(this._server),this._groupsRoute=new p(this._server),this._librariesRoute=new h(this._server),this._notificationsRoute=new u(this._server),this._searchRoute=new _(this._server),new Promise(t=>{this._server.listen(e||0,"127.0.0.1",()=>{s.log(f,`${this._server.name} listening at ${this._server.url}`),this._serviceHostname=this._server.url,this._serviceToken=l.uuid(),this._onConnectionHandler=this._connectionHandler.bind(this),c.addListener(m,this._onConnectionHandler),t()})}))}_logRequest(e,t){const n=Date.now(),o=e.headers["x-request-id"]||l.uuid();return s.log(f,`[${o}] ${e.method.toUpperCase()} ${e.headers.host}${e.href()}`),t.on("finish",()=>{s.log(f,`[${o}] ${t.statusCode} (${Date.now()-n}ms)`)}),o}_connectionHandler(e,t,n){let o;s.log(f,`Client connected: ${t} - ${n}`);try{o=e&&JSON.parse(e)}catch(t){s.log(f,`Parse error, client message: ${e}`)}const i=o&&o.apiVersion,r={apiVersion:a.getValue("REST_API_VERSION"),apiMinVersion:a.getValue("REST_API_MIN_VERSION"),apiMaxVersion:a.getValue("REST_API_MAX_VERSION")};!i||i<r.apiMinVersion?r.updateRequired="client":i>r.apiMaxVersion?r.updateRequired="server":(r.serviceHostname=this._serviceHostname,r.serviceToken=this._serviceToken),c.sendMessage(E,JSON.stringify(r),t,n)}shutdown(){this._server&&(this._serviceHostname=void 0,this._serviceToken=void 0,this._elementsRoute.dispose(),this._elementsRoute=void 0,this._groupsRoute.dispose(),this._groupsRoute=void 0,this._librariesRoute.dispose(),this._librariesRoute=void 0,this._notificationsRoute.dispose(),this._notificationsRoute=void 0,this._searchRoute.dispose(),this._searchRoute=void 0,this._server.rm(this._optionsRoute),this._optionsRoute=void 0,this._server.close(),this._server=void 0,c.removeListener(m,this._onConnectionHandler))}}},function(e,t){e.exports=require("restify")},function(e,t,n){const o=n(14),{getRequestHandler:i,getElementResponseData:r,updateCustomData:a,parseCustomData:s}=n(31),c=n(32),l=n(10),d=n(0);e.exports=class{constructor(e){this._server=e,this._routes=[],this._routes.push(this._server.get("/libraries/:libraryId/elements",i(this.getElements.bind(this)))),this._routes.push(this._server.post("/libraries/:libraryId/elements",i(this.createElement.bind(this),!0))),this._routes.push(this._server.get("/libraries/:libraryId/elements/:elementId",i(this.getElement.bind(this)))),this._routes.push(this._server.put("/libraries/:libraryId/elements/:elementId",i(this.updateElement.bind(this),!0))),this._routes.push(this._server.del("/libraries/:libraryId/elements/:elementId",i(this.removeElement.bind(this),!0))),this._routes.push(this._server.get("/libraries/:libraryId/elements/:elementId/representations/:representationId/path",i(this.getRepresentationPath.bind(this)))),this._routes.push(this._server.get("/libraries/:libraryId/removed_elements",i(this.getRemovedElements.bind(this)))),this._routes.push(this._server.get("/libraries/:libraryId/removed_elements/:elementId",i(this.getElement.bind(this),null,!0))),this._routes.push(this._server.del("/libraries/:libraryId/removed_elements/:elementId",i(this.removeElement.bind(this),null,!0)))}_buildRepresentations(e,t){const n=[];if(e.representations.length>0){const n=t.filter(e=>e.id).map(e=>e.id);e.representations.slice().forEach(t=>{n.includes(t.id)||e.removeRepresentation(t)})}return t.forEach((t,o)=>{if(t.id){const n=e.getRepresentationById(t.id);return void(n&&n._getDCXElement().setValue(d.REPRESENTATION_ORDER_KEY,o))}const i=e.createRepresentation(t.type,t.relationship,o);this._buildRepresentation(i,t,n)}),Promise.all(n)}_buildRepresentation(e,t,n){t.source&&(t.source.path||t.source.url)&&n.push(new Promise((n,o)=>{t.source.path?e.setContentFromPath(t.source.path,t.source.moveFile,e=>{e?o(e):n()}):t.source.url&&e.setContentFromURL(!!t.source.createLink,t.source.url,t.source.headers,e=>{e?o(e):n()})}).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 o=s(t.custom_data);o?(a(e,o),(t.children||[]).forEach(t=>{const o=e.createChild(t.type);this._buildRepresentation(o,t,n)})):n.push(Promise.reject(c.INVALID_CUSTOM_DATA))}_validateElementData(e,t,n,o,i){if(e&&"string"!=typeof e)return c.ELEMENT_NAME_INVALID;if(!o)return c.INVALID_CUSTOM_DATA;if(t&&(!Array.isArray(t)||!t.every(e=>"string"==typeof e)))return c.ELEMENT_TAGS_INVALID;if(n||!i){if(!n||!Array.isArray(n)||0===n.length)return c.REPRESENTATION_DATA_MISSING;for(let e of n){let t;if(i&&e.id){if(!(t=i.getRepresentationById(e.id)))return c.REPRESENTATION_ID_NOT_RESOLVED}else{const t=this._validateRepresentationData(e);if(t)return t}}if(n.filter(e=>{const t=i&&i.getRepresentationById(e.id);return"primary"===(t?t.relationship:e.relationship)}).length>1)return c.REPRESENTATION_REL_PRIMARY_FOUND}}_validateRepresentationData(e,t){if(!e.type)return c.REPRESENTATION_TYPE_MISSING;if(t){if(e.relationship)return c.REPRESENTATION_REL_INVALID}else{if(!e.relationship)return c.REPRESENTATION_REL_MISSING;if(!d.VALID_RELATIONS.includes(e.relationship))return c.REPRESENTATION_REL_INVALID}if(e.source&&!e.source.path&&!e.source.url)return c.REPRESENTATION_SOURCE_MISSING;if(void 0!==e.width&&"number"!=typeof e.width||e.width<0)return c.REPRESENTATION_WIDTH_INVALID;if(void 0!==e.height&&"number"!=typeof e.height||e.height<0)return c.REPRESENTATION_HEIGHT_INVALID;if(void 0!==e.content_length){if(!e.source.url||!e.source.createLink)return c.REPRESENTATION_CONTENT_LENGTH_UNEXPECTED;if("number"!=typeof e.content_length||e.content_length<0)return c.REPRESENTATION_CONTENT_LENGTH_INVALID}if(e.children){if(!Array.isArray(e.children))return c.REPRESENTATION_CHILDREN_INVALID;if(e.children.some(e=>this._validateRepresentationData(e,!0)))return c.REPRESENTATION_CHILDREN_INVALID}return void 0!==e.is_full_size&&"boolean"!=typeof e.is_full_size?c.REPRESENTATION_FULL_SIZE_INVALID:void 0}createElement(e,t,n){const o=t;if(!o)return Promise.reject(c.ELEMENT_DATA_MISSING);if(o.self||o.source)return this.copyOrMoveElements(e,t,n);if(!o.type)return Promise.reject(c.ELEMENT_TYPE_MISSING);if(n.elements.length>=d.MAX_ELEMENTS)return Promise.reject(c.LIBRARY_NOT_ENOUGH_SPACE);const i=o.tags,l=o.representations,p=s(o.custom_data),h=this._validateElementData(o.name,i,l,p);if(h)return Promise.reject(h);const u=n.createElement(o.name,o.type);return i&&(u.tags=i),a(u,p),new Promise((e,t)=>{this._buildRepresentations(u,l).then(()=>{u.endOperation(),e(r(u))}).catch(e=>{n.removeElement(u),t(c.getResponseError(e))})})}copyOrMoveElements(e,t,n){const o=!!t.self,i=t.self||t.source,a=i.id,s=i.elements;if(!a)return Promise.reject(c.LIBRARY_ID_MISSING);if(!s||!Array.isArray(s)||0===s.length)return Promise.reject(c.ELEMENT_IDS_MISSING);const p=l.getLibraryById(a);if(!p)return Promise.reject(c.LIBRARY_NOT_FOUND);if(o&&!p.isWritable)return Promise.reject(c.LIBRARY_NOT_WRITABLE);if(n.elements.length+s.length>d.MAX_ELEMENTS)return Promise.reject(c.LIBRARY_NOT_ENOUGH_SPACE);const h=s.map(e=>p.getElementById(e));if(h.some(e=>!e))return Promise.reject(c.ELEMENT_NOT_FOUND);n.beginOperation(),o&&p.beginOperation();const u=o?p.moveElement.bind(p):p.copyElement.bind(p),_=()=>{n.endOperation(),o&&p.endOperation()},f=[];return h.forEach(e=>{f.push(new Promise((t,o)=>{u(e,n,(e,n)=>{e?o(c.getResponseError(e)):t(n)})}))}),Promise.all(f).then(e=>(_(),{elements:e.map(r)})).catch(e=>(_(),Promise.reject(e)))}getElement(e,t,n){return Promise.resolve(r(n))}getElements(e,t,n){return Promise.resolve({elements:n.elements.map(r)})}getRemovedElements(e,t,n){return Promise.resolve({elements:n.removedElements.map(r)})}getRepresentationPath(e,t,n){return new Promise((e,t)=>{n.getContentPath((n,i)=>n?t(c.getResponseError(n)):i?void e({path:o.normalize(i)}):t(c.REPRESENTATION_PATH_NOT_FOUND))})}updateElement(e,t,n){const o=t;if(!o)return Promise.reject(c.ELEMENT_DATA_MISSING);const i=o.tags,l=o.representations,d=s(o.custom_data);if(!d)return Promise.reject(c.INVALID_CUSTOM_DATA);if(0===d.length&&!o.name&&!l&&!i)return Promise.reject(c.ELEMENT_BODY_MISSING);const p=this._validateElementData(o.name,i,l,d,n);return p?Promise.reject(p):(n.beginOperation(),o.name&&(n.name=o.name),a(n,d),o.tags&&(n.tags=i),l?new Promise((e,t)=>{this._buildRepresentations(n,l).then(()=>{n.endOperation(),e(r(n))}).catch(e=>{n.endOperation(),t(c.getResponseError(e))})}):(n.endOperation(),Promise.resolve(r(n))))}removeElement(e,t,n){return n.library.removeElement(n,e.permanent||n.removed),Promise.resolve()}dispose(){this._routes.forEach(e=>this._server.rm(e))}}},function(e,t){e.exports=require("restify-errors")},function(e,t,n){const{getRequestHandler:o,getGroupResponseData:i}=n(31),r=n(32);e.exports=class{constructor(e){this._server=e,this._routes=[],this._routes.push(this._server.get("/libraries/:libraryId/groups",o(this.getGroups.bind(this)))),this._routes.push(this._server.post("/libraries/:libraryId/groups",o(this.createGroup.bind(this),!0))),this._routes.push(this._server.get("/libraries/:libraryId/groups/:groupId",o(this.getGroup.bind(this)))),this._routes.push(this._server.put("/libraries/:libraryId/groups/:groupId",o(this.updateGroup.bind(this),!0))),this._routes.push(this._server.del("/libraries/:libraryId/groups/:groupId",o(this.removeGroup.bind(this),!0)))}createGroup(e,t,n){const o=t&&t.name,a=t&&t.classifier,s=t&&t.order;if(!o)return Promise.reject(r.GROUP_NAME_MISSING);if(!s)return Promise.reject(r.GROUP_ORDER_MISSING);const c=n.createGroup(o,s,a);return Promise.resolve(i(c))}removeGroup(e,t,n){return n.library.removeGroup(n,e.include_contents),Promise.resolve()}getGroup(e,t,n){return Promise.resolve(i(n))}getGroups(e,t,n){const o={groups:[]},r=e.classifier||/.*/;return o.groups=n.getGroups(r).map(e=>i(e)),Promise.resolve(o)}updateGroup(e,t,n){const o=t&&t.name,a=t&&t.order;return o||a?(n.library.beginOperation(),o&&(n.name=o),a&&(n.order=a),n.library.endOperation(),Promise.resolve(i(n))):Promise.reject(r.GROUP_BODY_MISSING)}dispose(){this._routes.forEach(e=>this._server.rm(e))}}},function(e,t,n){const{getRequestHandler:o,getLibraryResponseData:i,updateCustomData:r,parseCustomData:a}=n(31),s=n(32),c=n(10),l=n(19);e.exports=class{constructor(e){this._server=e,this._routes=[],this._routes.push(this._server.get("/libraries",o(this.getLibraries.bind(this)))),this._routes.push(this._server.post("/libraries",o(this.createLibrary.bind(this)))),this._routes.push(this._server.get("/libraries/:libraryId",o(this.getLibrary.bind(this)))),this._routes.push(this._server.put("/libraries/:libraryId",o(this.updateLibrary.bind(this),!0))),this._routes.push(this._server.del("/libraries/:libraryId",o(this.removeLibrary.bind(this))))}createLibrary(e,t){if(t&&t.follow)return this.followLibrary(e,t);const n=a(t&&t.custom_data);if(!n)return Promise.reject(s.INVALID_CUSTOM_DATA);const o=n.find(e=>"toolkit"===e.namespace&&"id"===e.key),d=o&&l.getToolkitName(o.value)||t&&t.name||e&&e.name;if(!d)return Promise.reject(s.LIBRARY_NAME_MISSING);const p=c.getLoadedCollections().find(e=>!e.isPublic);if(!p)return Promise.reject(s.COLLECTION_NOT_FOUND);const h=p.createLibrary(d);return r(h,n),Promise.resolve(i(h))}followLibrary(e,t){const n=t&&t.id,o=t&&t.url;if(!n)return Promise.reject(s.LIBRARY_ID_MISSING);if(!o)return Promise.reject(s.LIBRARY_URL_MISSING);const i=c.getLoadedCollections().find(e=>!e.isPublic);return i?new Promise((e,t)=>{i._bookmarkManager.createBookmark(n,o,n=>{n?t(n):e()})}):Promise.reject(s.COLLECTION_NOT_FOUND)}removeLibrary(e,t,n){return n.collection.removeLibrary(n,()=>{}),Promise.resolve()}getLibrary(e,t,n){return Promise.resolve(i(n,!0))}getLibraries(){const e={libraries:[]};return c.getLoadedCollections().forEach(t=>{t.libraries.forEach(t=>{t.isDeletedFromServer||e.libraries.push(i(t))})}),Promise.resolve(e)}updateLibrary(e,t,n){const o=t&&t.name||e&&e.name,c=a(t&&t.custom_data);return c?0!==c.length||o?(o&&(n.name=o),r(n,c),Promise.resolve(i(n))):Promise.reject(s.INVALID_UPDATE_REQUEST):Promise.reject(s.INVALID_CUSTOM_DATA)}dispose(){this._routes.forEach(e=>this._server.rm(e))}}},function(e,t,n){const{getPollingRequestHandler:o,getLibraryResponseData:i}=n(31),r=n(10);e.exports=class{constructor(e){this._server=e,this._routes=[],this._monitoredCollections=[],this._pendingSyncChangeCallbacks=[],this._pendingLibraryChangeCallbacks=[],this._onLibrariesChanged=this._librariesChanged.bind(this),this._onSyncStatusChanged=this._syncStatusChanged.bind(this),this._onCollectionsChanged=this._collectionsChanged.bind(this),r.addLoadedCollectionsListener(this._onCollectionsChanged),this._ensureCollectionListeners(),this._routes.push(this._server.post("/notifications/libraries",o(this.handleLibraryNotifications.bind(this)))),this._routes.push(this._server.post("/notifications/libraries/sync",o(this.handleSyncStatusNotifications.bind(this))))}_ensureCollectionListeners(){const e=r.getLoadedCollections();e.filter(e=>!this._monitoredCollections.includes(e)).forEach(e=>{e.addSyncListener(this._onSyncStatusChanged),e.addDeepChangeListener(this._onLibrariesChanged)}),this._monitoredCollections=e}_collectionsChanged(){this._ensureCollectionListeners(),this._librariesChanged(),this._syncStatusChanged()}_librariesChanged(){if(0===this._pendingLibraryChangeCallbacks.length)return;const e=this._getLibrariesData();this._pendingLibraryChangeCallbacks=this._pendingLibraryChangeCallbacks.filter(t=>!t(e))}_syncStatusChanged(){if(0===this._pendingSyncChangeCallbacks.length)return;const e=this._getSyncStatusData();this._pendingSyncChangeCallbacks=this._pendingSyncChangeCallbacks.filter(t=>!t(e))}_getLibrariesData(){const e={};return r.getLoadedCollections().forEach(t=>{t.libraries.forEach(t=>{t.isDeletedFromServer||(e[t.id]=t.modified)})}),e}_getSyncStatusData(){let e,t="ok";return r.getLoadedCollections().some(n=>{if("error"===n.syncState)return t=n.syncState,e=n.getPrimarySyncError(),!0;"syncing"===n.syncState&&(t=n.syncState)}),{state:t,error:e}}_getChangedLibrariesData(e,t){let n=Object.keys(t).length!==Object.keys(e).length;const o={};return Object.keys(t).forEach(a=>{const s=t[a];e[a]!==s?(o[a]=i(r.getLibraryById(a)),n=!0):o[a]=s}),n?o:void 0}_compareSyncStatusData(e,t){return!e||e.state!==t.state||e.error!==t.error}handleLibraryNotifications(e,t){const n=this._getLibrariesData(),o=this._getChangedLibrariesData(e,n);if(o)return void t(o);const i=n=>{const o=this._getChangedLibrariesData(e,n);if(o)return t(o),!0};return this._pendingLibraryChangeCallbacks.push(i),()=>{this._pendingLibraryChangeCallbacks.includes(i)&&this._pendingLibraryChangeCallbacks.splice(this._pendingLibraryChangeCallbacks.indexOf(i),1)}}handleSyncStatusNotifications(e,t){const n=this._getSyncStatusData();if(this._compareSyncStatusData(e,n))return void t(n);const o=n=>{if(this._compareSyncStatusData(e,n))return t(n)};return this._pendingSyncChangeCallbacks.push(o),()=>{this._pendingSyncChangeCallbacks.includes(o)&&this._pendingSyncChangeCallbacks.splice(this._pendingSyncChangeCallbacks.indexOf(o),1)}}dispose(){r.removeLoadedCollectionsListener(this._onCollectionsChanged),this._routes.forEach(e=>this._server.rm(e))}}},function(e,t,n){const{getRequestHandler:o,getElementResponseData:i,getLibraryResponseData:r,getPagedResponses:a,getSortOrder:s,parseFilterField:c,parseSortField:l}=n(31),d=n(32),p=n(10),{isSearchQueryEmpty:h,findMatchingElements:u,findMatchingLibraries:_,isValidModifiedFilter:f}=n(142),m=n(144),E=10;e.exports=class{constructor(e){this._server=e,this._routes=[],this._routes.push(this._server.post("/search",o(this.searchElements.bind(this)))),this._localizedSorter=new m,this._localizedSorter.init()}searchElements(e,t,n){let o=t.q;if(t.filters)for(let e in t.filters)t.filters[e]=c(e,t.filters[e]);if(h(o))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(n){if(g&&!g(n))return Promise.reject(d.CONFLICTING_OWNERSHIP);y.push(n)}else p.getLoadedCollections().forEach(e=>{e.libraries.forEach(e=>{g&&!g(e)||y.push(e)})});const v=u(o,y,t.filters).map(e=>i(e,!0,!n,t.thumbnail_cache)),A=n?[]:_(o,y,t.filters).map(e=>r(e,!1,!0)),C=v.concat(A),{orderBy:S,isAscending:I}=s(t.order_by);C.length>0&&this._localizedSorter.sortResponses(C,S,I);const L=t.limit&&parseInt(t.limit)||E,O=l(S,t.start),{pagedResults:R,isLastPage:T,nextStartValue:N}=a(C,S,I,L,O,this._localizedSorter),D={},b={count:R.length,order_by:t.order_by};return R.length>0&&(b.start=R[0][S]),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,n){const o=n(143),i="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[n,o]=t.modified_date;if(n&&e.modified<n||o&&e.modified>o)return!1}return!0}function h(e,t){const n={[i]:u,[r]:_,[a]:f,[s]:f,[c]:m}[e.type];return n&&n(e,t)}function u(e,t){let n=y.getRGBColor(e);return(n=n&&y.colorDataToHexString(n).toLowerCase())&&n.includes(t)}function _(e,t){const n=E(e,"application/vnd.adobe.colortheme+json"),o=n&&n.getValue("colortheme","data");if(o&&Array.isArray(o.swatches))for(let e=0;e<o.swatches.length;e++){const n=o.swatches[e];if(y.colorDataToHexString(n).toLowerCase().includes(t))return!0}return!1}function f(e,t){const n=E(e,"application/vnd.adobe.characterstyle+json"),o=n&&n.getValue("characterstyle","data"),i=o&&o.fontFamily&&o.fontFamily.toLowerCase(),r=o&&o.adbeFont&&o.adbeFont.style&&o.adbeFont.style.toLowerCase(),a=o&&o.fontSize&&o.fontSize.value&&o.fontSize.value.toString().toLowerCase();return i&&i.includes(t)||r&&r.includes(t)||a&&a.includes(t)}function m(e,t){const n=E(e,"application/vnd.adobe.text+json"),o=n&&n.getValue("text","data");let i=0;for(let e=0;e<o.paragraphs.length&&!(i>=6e3);e++){const n=g(o.paragraphs[e].text,6e3-i).toLowerCase();if(n.includes(t))return!0;i+=n.length}return!1}function E(e,t){return e.representations.find(e=>e.type===t)}function g(e,t,n=!0){const i=n?"...":"";return e.length<=t?e:o.ucs2.encode(o.ucs2.decode(e).slice(0,t))+i}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,n)=>{if(!t||!Array.isArray(t)||!e)return[];const o=d(e);if(0===o.length)return[];let i=[];return t.forEach(e=>{e.elements.forEach(e=>{p(e,n)&&function(e,t){const n=e.name.toLowerCase(),o=e.description&&e.description.toLowerCase(),i=e.getGroups()[0],r=i&&i.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 i=0;i<t.length;i++){const c=t[i],l=n.includes(c)||o&&o.includes(c)||r&&r.includes(c)||a&&a.includes(c)||s&&s.includes(c)||h(e,c);if(!l)return!1}return!0}(e,o)&&i.push(e)})}),i}),l.findMatchingLibraries=((e,t,n)=>{if(!t||!Array.isArray(t)||!e)return[];const o=d(e);if(0===o.length)return[];let i=[];return t.forEach(e=>{p(e,n)&&function(e,t){const n=e.name.toLowerCase();for(let e=0;e<t.length;e++){const o=t[e],i=n.includes(o);if(!i)return!1}return!0}(e,o)&&i.push(e)}),i}),l.isValidModifiedFilter=(e=>{if(!Array.isArray(e))return!1;const[t,n]=e;return!(!t&&!n||"number"!=typeof t&&null!==t||"number"!=typeof n&&null!==n||t&&n&&t>n)});const y={};y.getRGBColor=(e=>{if(!e||!e.representations)return;const t=e.representations;for(let e=0;e<t.length;e++){const n=t[e].getValue("color","data");if(n&&"RGB"===n.mode)return n}}),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,n){let o=function(e,t,n){return e<<16|t<<8|n}(e,t,n).toString(16);for(;o.length<6;)o="0"+o;return"#"+o}(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,n){const o=n(10);e.exports=class{init(e){e=e||o.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,n){return e.sort((e,o)=>{const i=n?this._compare(t(e),t(o)):this._compare(t(o),t(e));if(0===i){if(e.element_ref&&!o.element_ref)return n?-1:1;if(!e.element_ref&&o.element_ref)return n?1:-1}return i})}findNextIndex(e,t,n,o){let i=-1;for(let r=0;r<e.length;r++)if(o?1===this._compare(e[r][t],n):-1===this._compare(e[r][t],n)){i=r;break}return i}sortResponses(e,t,n){return e&&t&&0!==e.length?"modified_date"===t?this.sortByModified(e,n):"name"===t?this.sortByName(e,n):"size"===t?this.sortBySize(e,n):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,n){const o=n(26),i=n(6),r=n(146),a=n(28),s=n(14),c=n(41),l=n(3),d=n(38),p=n(19),h=n(10),u=n(1),_=n(0),f=n(30),m="TLS_SERVER",E="com",g="adobelocalhost",y=864e5,v=730,A=60,C="user.js",S='\n// Adobe Creative Cloud in Microsoft Office\nuser_pref("security.enterprise_roots.enabled", true);\n',I=()=>({sniPort:0,trustInProgress:!1,certificateIsTrusted:!1,delayOnDecline:_.TLS_DELAY_ON_DECLINE,delayOnReady:_.TLS_DELAY_ON_READY,tokens:l.getValue("WSS_TOKENS")||[],dataUploaded:{},dataUploadInProgress:{}});function L(e,t,n){return new Promise((r,a)=>{const s=o.createServer(e);s.on("listening",()=>{i.log(m,`${n} is up and running at port: ${s.address().port}`),r(s)}),s.on("error",e=>{i.log(m,`Failed to launch ${n} 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=I(),this._locationOfIdentity=s.join(l.getValue("ROOT_DIR"),"identity"),this._deviceID=l.getValue("SNI_SERVER_ID")||c.createHash("md5").update(u.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=>{i.log(m,`Identity is already present for ${this._deviceID}.adobelocalhost.com`);const t=new Date(e.validFrom),n=new Date(e.validTo),o=new Date,s=O(n,t),c=O(n,o);return s>v||c<A?(i.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(()=>(i.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 i.log(m,"Skipping Firefox setup - Firefox is not installed")}t.forEach(t=>{const n=s.join(e,t,C);if(a.existsSync(n))i.log(m,`Skipping Firefox setup for profile ${t} - system certificates already enabled`);else try{a.writeFileSync(n,S,"utf8"),i.log(m,`Enabling system certificates for Firefox profile: ${t}`)}catch(e){i.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&&i.log(m,"Certificate is already trusted"),!e)).then(t=>!!t&&(i.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=>i.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 i.log(m,`Upload secret token info for ${e} failed as there is no private collection loaded`);const n=u.uuid();this._config.dataUploadInProgress[e]=!0,i.log(m,`Uploading secret token info for ${e} to the server`),t._syncManager.pushClientTokenInfo(e,{token:n,deviceID:this._deviceID,port:this.wssPort},t=>{i.log(m,`Upload secret token info for ${e} was ${t?"failure":"success"}`),l.addWSSToken(n),this._config.dataUploaded[e]=!t,this._config.dataUploadInProgress[e]=!1})}_sniCallback(e,t){const n=()=>t("error"),o=e.split(".",4);if(o.some(function(e){return!e})||o[2]!==g||o[3]!==E)return i.log(m,`serverName received is not as per the requirement: ${e}`),void setImmediate(n);if(!this._isUserHashValid(o[1]))return i.log(m,`userHash does not match: ${o[1]}`),void setImmediate(n);const r=o[0];return function(e){const t=l.getValue("IDS_DECLINED_TO_TRUST_CERT")||{};return Boolean(t[e])}(r)&&!this._config.certificateIsTrusted?(i.log(m,"user has declined to trust the certificate"),setTimeout(n,this._config.delayOnDecline)):this._config.certificateIsTrusted?this._config.dataUploaded[r]?void setTimeout(n,this._config.delayOnReady):(this._uploadServerData(r),setImmediate(n)):(this._initiateCertificateTrustProcess(r),setImmediate(n))}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=_.TLS_DISCOVERY_PORT_RANGE,t=this.wssPort;let n,o;const r=this._sniCallback.bind(this);this._initializationPromise=this._ensureIdentityExists().then(t=>(n=a.readFileSync(t.cert),o=a.readFileSync(t.key),this._dCertificateLocation=t.dCert,function e(t,n,o,i,r){return i>r?Promise.reject(new Error("None of the ports in the specified range are available")):L({cert:t,key:n,SNICallback:o},i,"TLSDiscoveryServer").catch(()=>e(t,n,o,++i,r))}(n,o,r,e[0],e[1]))).then(e=>(this._sniServer=e,this._config.sniPort=e.address().port,L({cert:n,key:o},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=>(i.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=I()}}},function(e,t){e.exports=require("node_ssl")},function(e,t,n){const o=n(42),i=n(26),r=n(5),a=n(0),s=n(3),c=n(22),l=n(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({},o.parse(e),c.getNodeTunnelOptionsForURL(e));i.get(t,e=>{const t=e&&e.statusCode;if(200!==t)return void this._onFetchError(`status code: ${t}`);let n="";e.on("data",e=>n+=e),e.on("end",()=>{let e;try{e=JSON.parse(n)}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(n=>{e[n]=`${t}${e[n]}`}),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,n){var o=n(62);function i(){this._channels=[]}i.prototype.broadcast=function(e,t,n){this._channels.forEach(function(o){n&&o===n||o.send(e,t)})},i.prototype.newChannel=function(e){var t=this,n=new o(e);return this._channels.push(n),n.onClose(function(){var e=t._channels.indexOf(n);-1!==e&&t._channels.splice(e,1),n.shutdown()}),n},i.prototype.numChannels=function(){return this._channels.length},i.prototype.getPendingWriteState=function(e,t,n,o){var i=!1;return this._channels.forEach(function(r){i=i||r.getPendingWriteState(e,t,n,r===o)}),i},Object.freeze(i),Object.seal(i.prototype),e.exports=i},function(e,t){e.exports=require("idle-gc")}]);