/*************************************************************************
* ADOBE CONFIDENTIAL
* ___________________
*
*  Copyright 2015 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 all applicable intellectual property laws,
* including trade secret and or copyright laws.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/
import{sendAnalytics}from"../utils/util.js";let abortController=new AbortController,compressPdfFteAbortController=null,internalState={lruThreadsData:new Map};const state={gmailConfig:{},gmailConvertToPdfConfig:{},expressConfig:{},gmailImplicitDefaultViewershipConfig:{},gmailCompressPDFConfig:{},getMessagesForThreadId(e){let t=internalState.lruThreadsData.get(e);return t?(internalState.lruThreadsData.delete(e),internalState.lruThreadsData.set(e,t),t.messages):null},updateLRUThreadData(e){const t=this.gmailConfig?.selectors?.listView?.maxLRUSizeForThreadData||3e3,r=internalState.lruThreadsData;if(r.has(e.id))r.delete(e.id);else if(r.size===t){const e=r.keys().next().value;r.delete(e),sendAnalytics([["DCBrowserExt:Gmail:ResponseLRU:Full"]])}r.set(e.id,e)},setDataForThread(e){this.updateLRUThreadData(e)},get eventControllerSignal(){return abortController.signal},initCompressPdfFteAbortController:()=>(compressPdfFteAbortController=new AbortController,compressPdfFteAbortController.signal),abortCompressPdfFteController(){compressPdfFteAbortController&&(compressPdfFteAbortController.abort(),compressPdfFteAbortController=null)},nativeViewerPromptState:{nativeViewerPromptVisible:!1,previousFileDetailsElement:null,nativeViewerAttachmentURL:null,driveButtonAddedListeners:{}},expressState:{nativeViewerTouchpointVisible:!1,imageURL:null,mimeType:null,imageName:null,imageDriveURL:null,hoverCTA:{minimized:!1,shouldShow:!0,minimizeTimeout:null}},convertToPdfState:{convertToPdfVisible:!1,previousFileDetailsElement:null,convertToPdfAttachmentURL:null,convertToPdfAttachmentName:null},compressPdfFteState:{compressPDFTouchPointWithFTE:null},iconURL:"",iconURLListView:"",viewerURLPrefix:"",disconnectExpressObserver:!1,disconnectAcrobatObserver:!1,get disconnectBodyObserver(){return this.disconnectExpressObserver&&this.disconnectAcrobatObserver},adobeCleanFontAdded:!1,gmailResponseListenerAdded:!1,disconnectEventListeners(){this.disconnectExpressListeners(),this.disconnectAcrobatListeners()},disconnectExpressListeners(){this.disconnectExpressObserver=!0},disconnectAcrobatListeners(){abortController.abort(),this.abortCompressPdfFteController(),this.disconnectAcrobatObserver=!0},resetDOMElementListener(){abortController?.abort(),abortController=new AbortController},createStateToTransferToNewContentScript:()=>({internalState:internalState,gmailResponseListenerAdded:state?.gmailResponseListenerAdded,adobeCleanFontAdded:state?.adobeCleanFontAdded,isAcrobatDefaultForGmailPDFs:state?.isAcrobatDefaultForGmailPDFs,hoverCTAState:state?.expressState?.hoverCTAState}),contentScriptDisconnectStart(){chrome.runtime?.id||(this.disconnectEventListeners(),this.nativeViewerPromptState={},this.convertToPdfState={})},contentScriptDisconnectEnd(e){if(!chrome.runtime?.id)return;const t=e?.detail?.state;internalState=t?.internalState,this.gmailResponseListenerAdded=t?.gmailResponseListenerAdded,this.adobeCleanFontAdded=t?.adobeCleanFontAdded,this.isAcrobatDefaultForGmailPDFs=t?.isAcrobatDefaultForGmailPDFs},fteToolTip:{},isAcrobatDefaultForGmailPDFs:!1,implicitToastShownInSession:!1};export default state;