
/*************************************************************************
 * ADOBE CONFIDENTIAL
 * ___________________
 *
 * Copyright 2019 Adobe. All Rights Reserved.
 *
 * NOTICE: All information contained herein is, and remains
 * the property of Adobe and its suppliers, if any. The intellectual
 * and technical concepts contained herein are proprietary to Adobe
 * and its suppliers and are protected by all applicable intellectual
 * property laws, including trade secret and copyright laws.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Adobe.
 **************************************************************************/

(window.webpackJsonp=window.webpackJsonp||[]).push([[3],{ylat:function(e,t,o){"use strict";o.r(t);var i=o("q1tI"),r=o("2vnA"),n=o("okNM"),a=o("cCFZ"),s=o("3UBC"),l=o("lKWN"),p=o("RGcl"),c=o("Mqyo"),h=o("vcor"),d=o("/0Ih"),g=o("VExq"),m=o("QBtN"),u=function(e,t,o,i){var r,n=arguments.length,a=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,o,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(n<3?r(a):n>3?r(t,o,a):r(t,o))||a);return n>3&&a&&Object.defineProperty(t,o,a),a},b=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};const w=window.require("uxp").pluginLoader;class f{constructor(){this.triggerRefresh=Object(m.a)((e=!1)=>{(e||a.mainStore.user.state!==g.c.SIGNED_IN&&a.mainStore.user.state!==g.c.USER_CHANGED)&&this.lrApp.globalObject.triggerRefresh()},100),this.handleRequestAccessToken=async()=>a.mainStore.user.state===g.c.SIGNED_OUT||a.mainStore.user.state===g.c.NO_USER?null:(await Object(r.when)(()=>!!a.mainStore.user.accessToken),this._imsData={environment:a.mainStore.user.isStaging?"stage":"prod",subscriptionType:a.mainStore.user.subscriptionStatus,fetchToken:()=>a.mainStore.user.accessToken,fetchUserId:()=>a.mainStore.user.UserProfile.userId},this._imsData.fetchToken()),this.handleOpenLink=e=>{p.a.logClickedEvent("lightroom-view",{subtype:"open",action:e}),l.a.openDefaultBrowser(e,c.a.ADOBEACCOUNT)},this.handleReportEvent=(e,t)=>{switch(e){case"initialize-lr-organizer":p.a.logMiscellaneousEvent("lightroom",{eventType:"initialize"});break;case"initialize-lr-organizer-failed":p.a.logMiscellaneousEvent("lightroom",{eventType:"error",errorDesc:`Message: ${t.message}, Stack: ${t.stack}`.slice(0,1024)});break;case"rendered-lr-organizer":p.a.logRenderedEvent("lightroom-organizer");break;case"clicked-asset":p.a.logClickedEvent("lightroom-view",{subtype:"select",content:{id:t.assetId,extension:t.extension,mimetype:t.contentType,category:"image"}});break;case"clicked-import":p.a.logClickedEvent("lightroom-view",{subtype:"import",count:t.count});break;case"clicked-cancel-download":p.a.logClickedEvent("lightroom-view",{subtype:"cancel-download",count:t.count});break;case"clicked-refresh":p.a.logClickedEvent("lightroom-view",{subtype:"refresh"});break;case"download-failed":p.a.logMiscellaneousEvent("lightroom",{eventType:"error",subtype:"download",errorDesc:t.error,content:{id:t.assetId,extension:t.extension,mimetype:t.contentType,original_file_size:t.originalFileSize,category:"image"}})}},this.handleImportCompleted=async e=>{await Promise.all(e.map(async({path:e,filename:t,xmpString:o,adobeUserOrientation:i,assetId:r,extension:n,contentType:a})=>{try{p.a.logClickedEvent("lightroom-view",{subtype:"open",content:{id:r,extension:n,mimetype:a,category:"image"}});let l=null;if(o?(console.log("Open file with ACR settings"),l=await s.a.openPathWithXMP(e,t,o,i)):l=await s.a.openLocalDocument({path:e,title:t,skipMRU:!0,template:!0}),l){let e=t.replace(/\.\w+$/,"");s.a.releaseFileReference(e,l.documentID),p.a.logRenderedEvent("lightroom-edit",{id:r,extension:n,mimetype:a,category:"image"})}else p.a.logMiscellaneousEvent("lightroom",{eventType:"error",subtype:"open",errorDesc:"Failed to open photo",content:{id:r,extension:n,mimetype:a,category:"image",open_with_xmp:Boolean(o)}}),console.log("Unable to open photo",{path:e,xmpString:o,adobeUserOrientation:i})}catch(t){console.log(`Unable to open photo: ${t}`,{path:e,xmpString:o,adobeUserOrientation:i})}}))},this._globalProps={colorStop:this.colorStop,clientId:"CCXInAppWelcomeUXP",lrSDKConfig:{get token(){return a.mainStore.user.accessToken},clientId:d.a.LIGHTROOM_CLIENT_ID,environment:a.mainStore.user.isStaging?"stage":"prod",ozHost:a.mainStore.user.isStaging?"https://photos-stage.adobe.io/":"https://photos.adobe.io",hostOverride:a.mainStore.user.isStaging?"https://photos-stage.adobe.io/":"https://photos.adobe.io",disableAnalytics:!0},requestAccessToken:this.handleRequestAccessToken,locale:s.a.language,onImportCompleted:this.handleImportCompleted,onOpenLink:this.handleOpenLink,onReportEvent:this.handleReportEvent,onSDKLoad:e=>{window.LrSDK||(window.LrSDK=e)},vulcan:h.a},this._themeDisposer=Object(r.observe)(a.mainStore,"colorTheme",()=>{this.lrApp.globalObject.onThemeUpdate&&this.lrApp.globalObject.onThemeUpdate(this.colorStop)}),this._userDisposer=Object(r.observe)(a.mainStore.user,"state",()=>{this.triggerRefresh()}),this._tokenDisposer=Object(r.observe)(a.mainStore.user,"accessToken",()=>{this.triggerRefresh(!0)})}get colorStop(){return"dark"===a.mainStore.colorTheme?"darkest":"light"}updateImporterProps(){this._currentView&&(this.lrApp.globalObject.importerProps=Object.assign(this._currentView.importerProps||{},this._globalProps))}loadView(e){if(window.navigator&&(window.navigator.language||window.navigator.languages||window.navigator.userLanguage)||(window.navigator=window.navigator||{},window.navigator.language=s.a.language),this._currentView=e,this.lrApp)return;const t=w.provider.getRelativeProvider("cc-photos-importer-uxp");this.lrApp=w.loadUxpExtension(t,{apiLevel:w.UxpApiLevel.kFirstParty,allowCodeGenerationFromStrings:!0,allowDebugging:!0}),this.lrApp.addEventListener("initialize",()=>{console.log("LR Importer Initializes"),this.updateImporterProps()}),this.lrApp.addEventListener("reload",()=>{console.log("LR Importer Restarting...")}),this.lrApp.start(),this.panel=this.lrApp.contextInfo.createPanelFactory({panelId:"importer"}),this.container=w.createContainer(this.panel)}attachToContainer(e){e&&this.container.attachToNode(e)}detachFromContainer(){this.container.detach()}destroy(){this._themeDisposer&&this._themeDisposer(),this._userDisposer&&this._userDisposer(),this._tokenDisposer&&this._tokenDisposer()}}u([r.computed,b("design:type",Object),b("design:paramtypes",[])],f.prototype,"colorStop",null);var v=new f,y=function(e,t,o,i){var r,n=arguments.length,a=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,o,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(n<3?r(a):n>3?r(t,o,a):r(t,o))||a);return n>3&&a&&Object.defineProperty(t,o,a),a},k=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};let S=class extends i.Component{constructor(e){super(e),this._panelVisible=!1,this.updatePanelHeight=()=>{this.panelHeight=(window.innerHeight||document.getElementById("main").offsetHeight)-114-74-10,v.updateImporterProps()},this.container=i.createRef()}get colorStop(){return"dark"===a.mainStore.colorTheme?"darkest":"light"}componentDidMount(){window.addEventListener("resize",this.updatePanelHeight),this.updatePanelHeight(),this.showImporter()}componentWillUnmount(){window.removeEventListener("resize",this.updatePanelHeight),this.hideImporter()}loadImporter(){v.loadView(this)}showImporter(){this.loadImporter(),this._panelVisible||(this._panelVisible=!0,v.attachToContainer(this.container.current))}get importerProps(){return{style:{height:this.panelHeight,position:"relative",display:this.props.hidden?"none":void 0}}}hideImporter(){this._panelVisible&&(v.detachFromContainer(),this._panelVisible=!1)}render(){return i.createElement("div",{style:{height:"100%"},ref:this.container})}};y([r.observable,k("design:type",Object)],S.prototype,"panelHeight",void 0),y([r.computed,k("design:type",Object),k("design:paramtypes",[])],S.prototype,"colorStop",null),S=y([n.c,k("design:paramtypes",[Object])],S);t.default=S}}]);