/*************************************************************************
* 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{util as e}from"./util.js";import{common as t}from"./common.js";import{analytics as a,events as s}from"../common/analytics.js";import{Proxy as i}from"./proxy.js";import{floodgate as r}from"./floodgate.js";import{authProvider as o}from"./auth-provider.js";import{sharepointModule as n}from"./sharepoint-module.js";import{privateApi as l}from"./private-api.js";import{gmailConvertToPdfInit as c}from"./gmail-convert-to-pdf-module.js";import{gmailCompressPDFInit as d}from"./gmail-compress-pdf-module.js";import{viewerModuleUtils as p}from"./viewer-module-utils.js";import{SETTINGS as u}from"./settings.js";import{dcLocalStorage as g,dcSessionStorage as m}from"../common/local-storage.js";import{OFFSCREEN_DOCUMENT_PATH as h}from"../common/constant.js";import{CACHE_PURGE_SCHEME as b}from"./constant.js";import{closeExpress as f,getModalSessionId as v,launchExpress as I,removeSessionFromUnloadedExpressSessions as w}from"./express.js";import{isExpressContextMenuEnabled as T,toggleExpressTouchpoints as E}from"./express/express-context-menu.js";import{isExpressMenuEnabled as F}from"./express/express-enablement.js";import{loggingApi as _}from"../common/loggingApi.js";import{resetDVSessionCount as S,getDVSessionCountString as P,fetchDefaultViewershipConfig as x}from"../content_scripts/utils/util.js";import{sendPingEventHandler as C,checkForImsSidCookie as k}from"../common/util.js";import{getAccountSpecificRedirectUrl as D}from"./gsuite/util.js";import{checkForBlockedDomain as L,handleAddWebpageToProjectAction as M,isAddWebpageToProjectEnabled as y,toggleAddWebpageToProjectContextMenu as R}from"./add-webpage-to-project.js";import{getActiveExperimentAnalyticsArray as N,setExperimentCodeForAnalytics as O,removeExperimentCodeForAnalytics as A}from"../common/experimentUtils.js";import{initTemporaryURLBufferIndexedDB as V}from"../common/temporaryURLBufferIndexDB.js";import{linkedinInit as U}from"./linkedin-module.js";import{googleQueryAnalyzer as G}from"./googleQueryAnalyzer.js";import{executeDirectVerb as W}from"./direct-verb-utils.js";import{implicitDefaultViewershipInit as B}from"./implicit-default-viewership-module.js";import{googleDocsInit as H}from"./gsuite/google-docs-module.js";let j=null,J={},$={};class z{constructor(){this.tabs={},this.version=-1,this.NMHConnStatus=!0,this.activeTab=void 0,this.isAllowedLocalFileAccess=!1}proxy(...e){return i.proxy.bind(this)(...e)}LOG(...e){return t.LOG(...e)}setIsAllowedLocalFileAccess(e){const t=g.getItem("isAllowedLocalFileAccess");this.isAllowedLocalFileAccess=e,g.setItem("isAllowedLocalFileAccess",e),e&&!0!==t&&"true"!==g.getItem("pdfViewer")&&(g.setItem("pdfViewer","true"),l.setViewerState("enabled"))}registerHandlers(t){$=e.extend($,t)}registerModule(e,t){J[e]=t}getModule(e){return J[e]}getTabLastMessage(e){return this.tabs[e]}updateTabMessage(t,a){this.tabs[t]?this.tabs[t]=e.extend(this.tabs[t],a):this.tabs[t]=a}setNMHConnectionStatus(e){this.NMHConnStatus=e}legacyShim(){return this.version<=1}setVersion(e){this.version=e}resetPersistPrefCount(){g.setItem("persist-menu-closed",0)}incrementPersistPrefCount(e){let t=g.getItem("persist-menu-closed");t<10&&"false"!==g.getItem("always-show-pdf-menu")&&(t++,g.setItem("persist-menu-closed",t)),t>=10&&(g.setItem("always-show-pdf-menu","false"),e||a.event(a.e.PERSIST_PDF_OPENPDF_PREF_OFF))}diffDays(e,t){const a=Math.abs(e-t);return Math.floor(a/864e5)}enableReprompt(){if(!g.getItem("repromptCount")||parseInt(g.getItem("repromptCount"))<u.REPROMPT_DORMANT_USER_ATTEMPTS){let e=Date.now(),t=g.getItem("fteDenied")&&10===parseInt(g.getItem("fteDenied")),a=g.getItem("pdfViewer"),s=u.VIEWER_ENABLED,i=!g.getItem("reprompt-user-timestamp"),r=g.getItem("repromptCount")?g.getItem("repromptCount"):0,o=g.getItem("reprompt-user-timestamp")&&this.diffDays(e,g.getItem("reprompt-user-timestamp"))>=u.REPROMPT_DORMANT_USER_TIME_INTERVALS[r];return s&&!a&&t&&(o||i)}return!1}async isEnablePersistMenu(e){if(e&&"mime-native"===e.viewer&&(u.IS_ERP_READER||u.IS_READER)&&g.getItem("openInAcrobatEnable")&&"admin"!==g.getItem("installSource"))return!1;if(await l.isInstalledViaUpsell()&&!g.getItem("pdfViewer"))return!1;if(e&&"mime"===e.viewer)return!1;if(u.VIEWER_ENABLED&&(u.IS_ACROBAT&&!u.VIEWER_ENABLED_FOR_ACROBAT||g.getItem("fteDenied")||"true"!==g.getItem("pdfViewer")||this.resetPersistPrefCount()),u.REPROMPT_DORMANT_USER&&this.enableReprompt()){let e=g.getItem("repromptCount")?parseInt(g.getItem("repromptCount"))+1:1;g.setItem("repromptCount",e),g.setItem("fteDenied",9),g.setItem("persist-menu-closed",9),g.removeItem("always-show-pdf-menu")}return"false"!==g.getItem("always-show-pdf-menu")&&(g.getItem("persist-menu-closed")<10?!(this.legacyShim()&&(!u.VIEWER_ENABLED||g.getItem("pdfViewer"))):"true"===g.getItem("always-show-pdf-menu")&&(this.resetPersistPrefCount(),!0))}isViewerEnabled(){return!(!u.VIEWER_ENABLED||u.IS_ACROBAT&&!u.VIEWER_ENABLED_FOR_ACROBAT||"true"!==g.getItem("pdfViewer"))}async relayMessageToContentScript(e,t,a){if(1==e.newUI&&"dismiss"===e.content_op)e.persist=!1,null!=e.tabId&&(this.tabs[e.tabId].persist=!1),this.incrementPersistPrefCount(e.fteClosed);else if(1==e.newUI&&"pdf_menu"===e.panel_op){await this.isEnablePersistMenu(e)?null!=e.tabId&&(this.tabs[e.tabId].persist=!0):e.persist=!1,this.resetPersistPrefCount()}this.sendMessage(e,t,a)}isViewerEnabledOrFromExternalTouchPoint(e){return this.isViewerEnabled()||p.isPDFURLFromExternalTouchPoint(e)}sendViewerStartupInformation(t,s,i){if(this.isViewerEnabledOrFromExternalTouchPoint(s)&&e.isViewerURL(s)||t.mimeHandled){if("viewer-startup"===t.main_op&&(delete t.main_op,t.isFrictionlessEnabled=u.FRICTIONLESS_ENABLED,t.isSharePointEnabled=n.isFeatureEnabled(),t.isSharePointURL=!1),t.isSharePointEnabled)try{let e=new URL(s).searchParams.get("pdfurl");t.isSharePointURL=n.isAllowListedSharePointURL(e)}catch(e){}t.mimeHandled&&(a.event(a.e.VIEWER_EXTN_PDF_OPENED,{tabURL:s}),s.startsWith("file://")?a.event(a.e.VIEWER_PDF_LOCAL_FILE):a.event(a.e.VIEWER_PDF_OPENED_MIME_HANDLER)),t.isFillnSignEnabled=u.FILL_N_SIGN_ENABLED,r.getFeaturesAndGroups().then(({featureFlags:e})=>{t.featureFlags=e,i(t)}).catch(a=>{i(t),e.consoleLog(a)})}}async sendViewerPreviewInformation(e,t){this.sendMessage({dend_op:"viewer-type",viewer:"mime",tabId:e.tabId,is_pdf:!0}),await p.updateVariables(this.version),t()}handlerTabs(e){e&&e.tabId&&"outermost_frame"===e.frameType&&communicate.filterLoadedTabs(e)}async filterLoadedTabs(e){const t=await l.isMimeHandlerAvailable(),a=g.getItem("loadedTabsInfo");if(a&&a.tabsInfo){const s=a.tabsInfo||[];if(t){if(s.includes(e.tabId)){const t=s.filter(t=>t!==e.tabId);t.length>0?g.setItem("loadedTabsInfo",{tabsInfo:t}):g.removeItem("loadedTabsInfo")}}else{-1!==s.findIndex(t=>t.id==e.tabId)&&this.getCurrentTabInfoAndUpdateLoadedTabs()}}}async getCurrentTabInfoAndUpdateLoadedTabs(){const e=await l.isMimeHandlerAvailable(),t=g.getItem("loadedTabsInfo"),a=t?.tabsInfo;if(!e&&a){const e=`chrome-extension://${chrome.runtime.id}/*`;let t=await chrome.tabs.query({url:e});t=t.filter(e=>e.url!==chrome.runtime.getURL("browser/js/local-fte.html")),t.length?g.setItem("loadedTabsInfo",{tabsInfo:t}):g.removeItem("loadedTabsInfo")}}async handleFrictionlessStartup(e,t){if(!u.FRICTIONLESS_ENABLED)return void t({pdf_action:null});if(e.show_frictionless=!0,e.startup_time){const t=this.getModule("frictionlessHandler");if(t){t.startNewInteraction(e.tabId).startup_time=e.startup_time}}const a=u.TEST_MODE||e.show_frictionless,s="false"!==g.getItem("always-show-pdftools"),i=1!=e.suppress_frictionless,r=G&&G.isGoogleQuery(e),o={pdf_action:null};if(!(a&&s&&i&&r))return void t(o);const n=G.getSearchQuery(e);n?G.mapQueryStringToAction(n,e,e=>{t(e||o)}):t(o)}handler(i,n,u){var T,F=this;if(!i)return;if(this.dump(i,"Communicate Handler receive: "),i.mimeHandled){var S={id:i.tabId,url:i.url};n.tab=S}const P=`chrome-extension://${chrome.runtime.id}/browser/js/popup.html`,x=`chrome-extension://${chrome.runtime.id}/${h}`,D=`chrome-extension://${chrome.runtime.id}/resources/SidePanel/index.html`,A=n.url?.split("?")[0]||n.tab?.url;if([P,x,D].includes(A)&&(n.tab=i.tab,delete i.tab),n&&n.tab&&(i.tabId=n.tab.id,this.activeTab||(this.activeTab=n.tab.id),i.main_op)){switch(T=i.main_op,delete i.main_op,a.logBrowserAnalytics(i),this.tabs[i.tabId]&&this.tabs[i.tabId].suppress_frictionless&&(i.suppress_frictionless=this.tabs[i.tabId].suppress_frictionless),i.version=this.version,i.NMHConnStatus=this.NMHConnStatus,T){case"frictionless-startup":this.handleFrictionlessStartup(i,u);break;case"embedded-pdf-touch-point-added":chrome.tabs.sendMessage(i.tabId,{type:"added-embedded-pdf-touch-point",frameId:i?.frameId,position:i?.position}),chrome.tabs.sendMessage(i.tabId,{action:"reRenderShowOneChild"});break;case"reRenderShowOneChild":chrome.tabs.sendMessage(i.tabId,{action:"reRenderShowOneChild"});break;case"hideAIMarkerPopup":chrome.tabs.sendMessage(i.tabId,{content_op:"hideAIMarkerPopup",href:i.href});break;case"updateIframeHeight":chrome.tabs.sendMessage(i.tabId,{content_op:"updateIframeHeight",href:i.href,menuOpen:i.menuOpen});break;case"validateOverlappingElements":chrome.tabs.sendMessage(i.tabId,{content_op:"validateOverlappingElements",elementRect:i.elementRect,link:i.link});break;case"outlook-touch-point-added":chrome.tabs.sendMessage(i.tabId,{action:"reRenderShowOneChild"});break;case"linkedin-touch-point-added":chrome.tabs.sendMessage(i.tabId,{type:"added-linkedin-pdf-touch-point",frameId:i?.frameId,position:i?.position}),chrome.tabs.sendMessage(i.tabId,{action:"reRenderShowOneChild"});break;case"fte-eligible-linkedin-chat-touch-point-added":chrome.tabs.sendMessage(i.tabId,{type:"added-linkedin-chat-pdf-touch-point"}),chrome.tabs.sendMessage(i.tabId,{action:"reRenderShowOneChild"});break;case"log-error":_.error(i.log);break;case"log-info":_.info(i.log);break;case"resolve-analytics-event":if(i.eventKey){const e=s[i.eventKey];u({eventValue:e||null})}else u({eventValue:null});break;case"getEnv":const h=t.getEnv();u(h);break;case"update_env":t.updateEnvironment(i);break;case"getVersion":u(this.version);break;case"isEdge":u(e.isEdge());break;case"getFrictionlessLocale":u(e.getFrictionlessLocale(chrome.i18n.getMessage("@@ui_locale")));break;case"embedded-pdf-touch-point-fte":chrome.tabs.sendMessage(i.tabId,{type:"add-fte-for-embedded-pdf-touch-point"},{frameId:i.frameId});break;case"outlook-fte-render":chrome.tabs.sendMessage(i.tabId,{type:"add-fte-for-outlook-touch-point"});break;case"linkedin-fte-render":chrome.tabs.sendMessage(i.tabId,{type:"add-fte-for-linkedin-touch-point"},{frameId:i.frameId});break;case"linkedin-chat-fte-render":chrome.tabs.sendMessage(i.tabId,{type:"add-fte-for-linkedin-chat-touch-point"});break;case"changeDefaultViewershipForSurface":this.handleChangeDefaultViewershipForSurface(i,n);break;case"acrobat-gmail-fte-config":case"acrobat-gmail-convert-to-pdf-verb-fte-config":this.gmailFteConfigUpdated(i);break;case"reRenderShowOneChild":chrome.tabs.sendMessage(i.tabId,{action:"reRenderShowOneChild"});break;case"get-express-modal-session-id":u({sessionId:v(i.tabId)});break;case"express-init":this.expressInit(u);break;case"whatsapp-express-init":this.whatsappExpressInit(u);break;case"gmail-express-init":this.gmailExpressInit(u);break;case"google-image-preview-express-init":this.googleImagePreviewExpressInit(u);break;case"gdrive-express-init":this.gdriveExpressInit(u);break;case"facebook-express-init":this.facebookExpressInit(u);break;case"chatgpt-express-init":this.chatgptExpressInit(u);break;case"chatgpt-init":this.chatgptInit(u);break;case"gmail-init":this.gmailInit(u);break;case"google_docs_init":H(i,u,this.version);break;case"google_docs_touch_point_added":chrome.tabs.sendMessage(i.tabId,{type:"acrobat-gdocs-touch-point-added"}),chrome.tabs.sendMessage(i.tabId,{action:"reRenderShowOneChild"});break;case"gmail-convert-to-pdf-init":c(u);break;case"gmail-compress-pdf-init":d(u);break;case"implicit-default-viewership-init":B(i?.surfaceId,u);break;case"acrobat-gdrive-fte-state":this.gdriveFteStateUpdated(i);break;case"gdrive-init":this.gdriveInit(u,i.tabId);break;case"outlook-init":this.outlookInit(u);break;case"outlook-express-init":this.outlookExpressInit(u);break;case"linkedin-init":U(this.version,n).then(u);break;case"embedded-pdf-touch-point-config":this.embeddedPDFTouchPointConfig(i,u,n);break;case"gdrive-download-init":this.gDriveDownloadPageInit(u);break;case"viewer-preview":return this.sendViewerPreviewInformation(i,u),!0;case"get-features&groups":return r.getFeaturesAndGroups(i.cachePurge).then(e=>u(e)),!0;case"getFloodgateFlag":r.hasFlag(i.flag,i.cachePurge).then(u);break;case"getFloodgateMeta":u(r.getFeatureMeta(i.flag));break;case"isUserSignedIn":o.isUserSignedIn().then(u);const S=g.getItem("imsConsciousTabs")||[];S.includes(i.tabId)||(S.push(i.tabId),g.setItem("imsConsciousTabs",S));break;case"openRecentFileLink":let P=i.recent_file_url;new URLSearchParams(i.recent_file_url)?.has("acrobatPromotionSource")&&(P=chrome.runtime.getURL("viewer.html")+"?pdfurl="+encodeURIComponent(i.recent_file_url)+"&pdffilename="+encodeURIComponent(i.file_name)),e.createTab(P);break;case"openOnboardingTutorialFile":let x=new URL(i.onboardingDemoFileURL);x.searchParams.set("blob-uri",i.blobParam),x.searchParams.set("returnURL",i.pdfURL),x.searchParams.set("returnTabId",i.tabId),x=x.toString(),e.createTab(x);break;case"returnToYourFile":const D=`chrome-extension://${chrome.runtime.id}/*`;chrome.tabs.query({url:D},t=>{let a=t?.find(e=>e.id==i.returnTabId);a?chrome.tabs.update(a.id,{active:!0}):e.createTab(i.returnURL)});break;case"openLocalFileThoughFilePicker":e.createTab("").then(({id:e})=>{const t=chrome.runtime.getURL("viewer.html")+"?pdfurl="+encodeURIComponent(i.fileURL)+"&pdffilename="+encodeURIComponent(i.file_name)+(i.openGenAIAssistantPanel?"&ogap="+i.openGenAIAssistantPanel:"")+"&tabId="+e+(i.openLocalFileSource?"&olfs="+i.openLocalFileSource:"");chrome.tabs.update(e,{url:t})});break;case"viewer-type":setTimeout(()=>{this.sendMessage({dend_op:"viewer-type",viewer:i.viewer,tabId:i.tabId,is_pdf:!0})},500);case"init-floodgate":setTimeout(()=>{r.init(),r.getFeaturesAndGroups()},2e3);break;case"complete_conversion":e.createTab(i.conversion_url);break;case"analytics":break;case"pdf-contentType-event":r.hasFlag("dc-cv-content-type-pdf-analtyics",b.NO_CALL).then(e=>{"true"===g.getItem("pdfViewer")&&e&&a.event(a.e.PDF_CONTENT_TYPE_EVENT)});break;case"relay_to_content":this.relayMessageToContentScript(i,i.shouldCache??!0,u);break;case"viewer-startup":i.main_op="viewer-startup",this.sendViewerStartupInformation(i,n.tab.url,u);break;case"check-cookie":u(g.getItem(i.key));break;case"set-cookie":g.setItem(i.key,i.value);break;case"set-pdf-marker-action":m.setWithTTL("pdfMarkerAction",!0,5e3),u({success:!0});break;case"check-mime-viewer-availability":l.isMimeHandlerAvailable().then(e=>{e?"false"===g.getItem("pdfViewer")||"true"===g.getItem("cdnFailure")?this.sendMessage({dend_op:"viewer-type",tabId:n.tab.id,viewer:"mime-native",is_pdf:!0}):i.url&&i.url.startsWith("file://")&&(this.isAllowedLocalFileAccess||(a.event(a.e.VIEWER_PDF_LOCAL_FILE_IGNORED),F.sendMessage({dend_op:"viewer-type",tabId:n.tab.id,viewer:"mime-native",is_pdf:!0}))):this.sendMessage({dend_op:"viewer-type",tabId:n.tab.id,viewer:"native",is_pdf:!0})});break;case"uninstall":l.setViewerState("disabled"),g.setItem("pdfViewer","false"),g.setItem("always-show-pdf-menu","false"),e.mimeReloadAllTabs(),g.removeItem("userEligibleForUninstall"),chrome.runtime.setUninstallURL(""),a.event(a.e.UNINSTALL_DIALOG_UNINSTALLED_SUCCESSFUL),setTimeout(()=>{chrome.management.uninstallSelf()},1e3);break;case"caret_mode_toggle_handler":chrome.runtime.sendMessage({main_op:"relay_to_content",content_op:"caret_mode_toggle_handler",status:i.toggleCaretModeValue});break;case"initialise-popup":this.initialisePopup(n.tab,u);break;case"addExperimentCodeForAnalytics":O(i.experimentCode);break;case"cancelWebpageConversion":case"clearStatus":this.cancelConversion(this.tabs[n.tab.id]);break;case"triggerBufferSave":chrome.runtime.sendMessage({main_op:"triggerBufferSave"});break;case"closeExpressApp":f(n.tab.id);break;case"reloadCurrentTab":n.tab&&n.tab.id&&chrome.tabs.reload(n.tab.id);break;case"toggle-express-touch-points":E(i.allowed);break;case"removeSessionFromUnloadedExpressSessions":w(n.tab.id,i.touchpoint,i.domain);break;case"handleViewerFloodgateResponse":r.handleViewerFloodgateResponse(i.fgResponse);break;case"launch-express":I({srcUrl:i.imgUrl,intent:i.intent,touchpoint:i.touchpoint},n.tab);break;case"execute-direct-verb":W({srcUrl:i.fileUrl,name:i.fileName,viewerURL:i.viewerURL,promotionSource:i.promotionSource,verb:i.verb});break;case"get-tab-id":u({tabId:n.tab.id});break;case"get-webpage-html-by-tab-id":const A=i.sourceTabId||i.tabId;return A?((async()=>{try{await chrome.scripting.executeScript({target:{tabId:A},files:["content_scripts/extract-webpage-html.js"]});const e=await chrome.scripting.executeScript({target:{tabId:A},func:async()=>{if("function"==typeof getExtractWebpageHTML&&await getExtractWebpageHTML(),"function"==typeof window.extractWebpageHTML)return await window.extractWebpageHTML(document);throw new Error("extractWebpageHTML not found")}});e&&e[0]&&e[0].result?u({success:!0,html:e[0].result.html,title:e[0].result.title}):u({success:!1,error:"Extraction failed or returned no result"})}catch(e){u({success:!1,error:e.toString()})}})(),!0):void u({success:!1,error:"No sourceTabId provided"});case"local-storage-remove":g.removeItem(i?.key);break;case"getExperimentCodes":u(N());break;case"isAddWebpageToProjectEnabled":y().then(e=>u(e));break;case"kw-is-blocked-domain":L({domain:i.domain}).then(e=>u(e));break;case"add-webpage-to-project":M({...i,url:n?.tab?.url});break;case"toggle-add-webpage-to-project-context-menu":R();break;case"openPDFInNewTab":if(i.url?.match(/\.pdf(?=\?|#|$)/i)){const t=chrome.runtime.getURL("viewer.html")+"?pdfurl="+encodeURIComponent(i.url);e.createTab(t)}break;case"get-welcome-pdf-url":const V=t.getWelcomePdfUrlHost(),G=e.getWelcomePDFUrl(V);u(G);break;case"initializeViewerVariables":p.initializeViewerVariables(this.version);break;case"check-ims-cookie":k().then(e=>u(e));break;case"akamai-ping":C();break;case"extnStorageSetKey":g.setItem(i.key,i.value).then(()=>{u({success:!0})});break;case"extnStorageRemoveKey":g.removeItem(i.key).then(()=>{u({success:!0})});break;case"extnStorageGetKey":u(g.getItem(i.key));break;case"log-event-once":a.logEventOnce(i.eventName,i.options);break;case"createNewTabWithUrl":e.createTab(i.url,null,{openerTabId:n?.tab?.id});break;default:return $[T]?(a.setOp({preview:"Copy",image_preview:"Image",send:"Send",fillsign:"FillSign",export:"Export",acom:"GotoAcom",to_pdf:"ConvertToPdf"}[i.handleResult]),$[T](i,n,u)):void e.consoleLog("failed to find handler for: "+T)}return!0}}gmailSelectors(){return Promise.resolve((()=>{const e=r.getFeatureMeta("dc-cv-gmail-selectors"),t=r.getFeatureMeta("dc-cv-gmail-selectors-list-view"),a=r.getFeatureMeta("dc-cv-gmail-selectors-native-viewer");let s={};try{s.messageView=JSON.parse(e),s.listView=JSON.parse(t),s.nativeViewer=JSON.parse(a)}catch(e){}return s})())}gmailFteToolTipConfig(){return Promise.resolve((()=>{let e=r.getFeatureMeta("dc-cv-gmail-fte-tooltip");try{e=JSON.parse(e)}catch(t){e={tooltip:{shortCoolDown:7,longCoolDown:60,maxFteCount:-1,resetDay:-1}}}return e})())}initStorageForGSuiteFlows(e,t,a){g.setItem(`${e}-pdf-dv-feature-enablement-status`,t?.toString()),g.setItem(`${e}-pdf-dv-feature-control-enablement-status`,a?.toString())}fetchFeatureEnablementStatusForDefaultViewership(e){return r.hasFlag(`dc-cv-${e}-default-viewership`)}getPdfToolsFteToolTipStrings(){return{title:e.getTranslation("pdfToolsFteTooltipTitle"),description:e.getTranslation("pdfToolsFteTooltipDescription"),button:e.getTranslation("pdfToolsFteTooltipButton")}}async gmailInit(t){const[a,s,i,o,n,l]=await Promise.all([this.gmailSelectors(),this.gmailFteToolTipConfig(),x("gmail"),this.fetchFeatureEnablementStatusForDefaultViewership("gmail"),r.hasFlag("dc-cv-gmail-acrobat-touch-point"),r.hasFlag("dc-cv-gmail-pdftools-touch-point")]);this.initStorageForGSuiteFlows("gmail",o,!1);try{await p.initializeViewerVariables(this.version)}catch(e){console.error("Error initializing viewer variables for Gmail:",e)}t({touchPointSettingEnabled:e.isAcrobatTouchPointEnabled("acrobat-touch-point-in-gmail"),selectors:a,acrobatPromptText:e.getTranslation("gsuiteOpenWithAcrobat"),gmailFteToolTipStrings:this.getSurfaceFTEToolTipStrings(o,"gmail"),pdfToolsFteToolTipStrings:this.getPdfToolsFteToolTipStrings(),fteConfig:s,isAcrobatDefaultForSurface:"true"===i,enableDefaultViewershipFeatureForGmail:o,enableGmailTouchPoint:n,enablePdfToolsTouchPoint:l})}getSurfaceFTEToolTipStringsForGdriveNonDV(){return{title:e.getTranslation("acrobatGsuiteFteToolTipTitleNonDV"),description:e.getTranslation("acrobatGsuiteFteToolTipDescriptionNonDV",e.getTranslation("surfaceNameGdrive")),button:e.getTranslation("closeButton")}}getSurfaceFTEToolTipStrings(t,a){let s,i;return"gmail"===a?i=e.getTranslation("surfaceNameGmail"):"gdrive"===a&&(i=e.getTranslation("surfaceNameGdrive")),s=t&&!g.getItem(`${a}-pdf-default-viewership-user-disabled`)?{title:e.getTranslation("acrobatGsuiteFteToolTipTitleDV"),description:e.getTranslation("acrobatGsuiteFteToolTipDescriptionDV",i),button:e.getTranslation("closeButton")}:{title:e.getTranslation("acrobatGsuiteFteToolTipTitleNonDV"),description:e.getTranslation("acrobatGsuiteFteToolTipDescriptionNonDV",i),button:e.getTranslation("closeButton")},s}async embeddedPDFTouchPointConfig(t,a,s){const i=await r.hasFlag("dc-cv-embedded-pdf-touch-point"),o="false"===g.getItem("acrobat-touch-point-in-embedded-pdf");try{await p.initializeViewerVariables(this.version)}catch(e){console.error("Error initializing viewer variables for embedded PDF:",e)}let n;try{n=JSON.parse(r.getFeatureMeta("dc-cv-embedded-pdf-touch-point"))}catch(e){n={tooltip:{shortCoolDown:7,longCoolDown:60,maxFteCount:-1,resetDay:-1},blockedDomains:["outlook.office.com","attachments.office.net"]}}const l=i&&!o;l?O("EMP"):A("EMP"),a({enableEmbeddedPDFTouchPoint:l,touchPointConfig:n,touchPointText:e.getTranslation("embeddedPDFOpenInAcrobatTooltip"),fteToolTipStrings:{title:e.getTranslation("embeddedPDFTouchPointFTEHeader"),description:e.getTranslation("embeddedPDFTouchPointFTEBody"),button:e.getTranslation("closeButton")},menuItemStrings:{hideIconForNow:e.getTranslation("embeddedPDFHideIconForNow"),openPDFInAcrobat:e.getTranslation("embeddedPDFOpenPDFInAcrobat"),managePreferences:e.getTranslation("embeddedPDFManagePreferences")},tabId:t?.tabId,frameId:s?.frameId,contextMenuTooltipText:e.getTranslation("preferences")})}async outlookInit(t){const[a,s]=await Promise.all([r.hasFlag("dc-cv-outlook-pdf-touch-point"),r.hasFlag("dc-cv-outlook-pdf-touch-point-control")]);try{await p.initializeViewerVariables(this.version)}catch(e){console.error("Error initializing viewer variables for Outlook:",e)}let i,o,n;const l=!e.isAcrobatTouchPointEnabled("acrobat-touch-point-in-outlook");try{const e=JSON.parse(r.getFeatureMeta("dc-cv-outlook-pdf-touch-point"));i=e?e.tooltip:{},o=e?e.selectors:{},n=!!e&&e.fteEnabled}catch(e){i={shortCoolDown:7,longCoolDown:60,maxFteCount:-1,resetDay:-1}}a?(A("OTC"),O("OT")):s?(A("OT"),O("OTC")):(A("OT"),A("OTC")),t({enableOutlookPDFTouchPoint:a&&!l,selectors:o,fteConfig:i,touchPointString:e.getTranslation("gsuiteOpenWithAcrobat"),fteToolTipStrings:{title:e.getTranslation("outlookPDFTouchPointFTEHeader"),description:e.getTranslation("outlookPDFTouchPointFTEBody"),button:e.getTranslation("closeButton")},errorToastStrings:{title:e.getTranslation("outlookErrorToastTitle"),description:e.getTranslation("outlookErrorToastDescription")},enableOutlookFteTooltip:n})}async gdriveInit(t){const[a,s,i,o,n,l,c,d,u,m,h,b,f,v,I,w,T,E]=await Promise.all([r.hasFlag("dc-cv-gdrive-open-in-extension"),r.getFeatureMeta("dc-cv-gdrive-selectors"),r.hasFlag("dc-cv-gdrive-fte-tooltip"),r.getFeatureMeta("dc-cv-gdrive-fte-tooltip"),r.hasFlag("dc-cv-gdrive-grid-view-touchpoint"),r.getFeatureMeta("dc-cv-gdrive-grid-view-selectors"),r.hasFlag("dc-cv-gdrive-list-view-touchpoint"),r.getFeatureMeta("dc-cv-gdrive-list-view-selectors"),r.getFeatureMeta("dc-cv-gdrive-pdf-selectors"),r.hasFlag("dc-cv-gdrive-triple-dot-menu-analytics"),r.hasFlag("dc-cv-gdrive-list-grid-view-fte-tooltip"),r.hasFlag("dc-cv-gdrive-grid-view-touchpoint-migration"),r.hasFlag("dc-cv-gdrive-list-view-touchpoint-migration"),r.hasFlag("dc-cv-gdrive-search-bar-analytics"),r.getFeatureMeta("dc-cv-gdrive-search-selectors"),x("gdrive"),this.fetchFeatureEnablementStatusForDefaultViewership("gdrive"),r.hasFlag("dc-cv-gdrive-default-viewership-control")]);try{await p.initializeViewerVariables(this.version)}catch(e){console.error("Error initializing viewer variables for GDrive:",e)}let F,_,S,P,C,k,D;try{F=s?JSON.parse(s):{},_=o?JSON.parse(o):{},S=l?JSON.parse(l):{},P=d?JSON.parse(d):{},C=I?JSON.parse(I):{},D=u?JSON.parse(u):{},S.pdfSvgPath=D?.svg,P.pdfSvgPath=D?.svg,F.GoogleDriveListView=P,F.GoogleDriveGridView=S,F.GoogleDriveSearchBar=C,k=e.isAcrobatTouchPointEnabled("acrobat-touch-point-in-gdrive")}catch(e){_={tooltip:{shortCoolDown:7,longCoolDown:60,maxFteCount:-1,resetDay:-1}},k=!1}const L=n||b,M=c||f;n&&g.setItem("gvt","dc-cv-gdrive-grid-view-touchpoint"),c&&g.setItem("lvt","dc-cv-gdrive-list-view-touchpoint"),t({acrobatTouchPointEnabled:k,enableOpenInExtension:a,acrobatPromptText:e.getTranslation("gsuiteOpenWithAcrobat"),selectors:F,fteToolTipStrings:this.getSurfaceFTEToolTipStrings(T,"gdrive"),fteToolTipStringsForNativeViewNonDV:this.getSurfaceFTEToolTipStringsForGdriveNonDV(),enableGDriveGridViewTouchPoint:L,enableGDriveListViewTouchPoint:M,enableGDriveTripleDotMenuAnalytics:m,enableGDriveSearchBarAnalytics:v,fteConfig:_,enableFteToolTip:i,enableFteToolTipForListGridView:h,isAcrobatDefaultForSurface:"true"===w,enableDefaultViewershipFeatureForGoogleDrive:T}),this.initStorageForGSuiteFlows("gdrive",T,E)}gdriveFteStateUpdated(e){chrome.tabs.query({url:["https://drive.google.com/*"]},function(t){t?.forEach(function(t){t.id!==e.tabId&&chrome.tabs.sendMessage(t.id,{content_op:"acrobatGdriveFteStateUpdated",fteState:e?.fteState})})})}async gDriveDownloadPageInit(t){const[a]=await Promise.all([r.getFeatureMeta("dc-cv-gdrive-download-page-selectors")]);let s,i;try{s=JSON.parse(a),i=e.isAcrobatTouchPointEnabled("acrobat-touch-point-in-gdrive")}catch(e){i=!1}t({selectors:s,acrobatTouchPointEnabled:i})}gmailFteConfigUpdated(e){chrome.tabs.query({url:["https://mail.google.com/*"]},function(t){t?.forEach(function(t){t?.id!==e.tabId&&chrome.tabs.sendMessage(t.id,{content_op:"acrobatGmailFteStateUpdated",fteState:e?.fteState})})})}async handleChangeDefaultViewershipForSurface(e,t){if(!await this.fetchFeatureEnablementStatusForDefaultViewership(e.surfaceId))return;const s={gmail:{baseURL:"https://mail.google.com/*",basePath:"/mail/"},gdrive:{baseURL:"https://drive.google.com/*",basePath:"/drive/"}},i=`${e.surfaceId}-pdf-default-viewership`;if(g.getItem(i)!==e.isDefault?.toString()){const r=i+"-user-disabled";if(e.isDefault){if(e.isDefault){g.removeItem(r),a.event(`DCBrowserExt:${e.surfaceId}:DefaultViewership:Enabled`,{eventContext:e.source,...e.pageSource&&{pageSource:e.pageSource}}),S(e.surfaceId);if(["tripleDotMenu","extensionPreferencePage","extensionPopup"].includes(e.source)){const t=g.getItem("viewerStorage")||{},a=`${e.surfaceId}-default-viewership-coach-mark-shown`;t[a]||(t[a]="true",g.setItem("viewerStorage",t))}}}else{g.setItem(r,"true"),P(e.surfaceId).then(t=>{a.event(`DCBrowserExt:${e.surfaceId}:DefaultViewership:Disabled`,{dvDisableSessionCount:t,eventContext:e.source,...e.pageSource&&{pageSource:e.pageSource}})});const i=t?.tab?.id;if("implicitCoachmarkCTA"===e.source&&i){g.setItem(`${e.surfaceId}-show-implicit-dv-toast`,"true");const a=s[e.surfaceId]?.baseURL?.replace(/\/\*$/,""),r=s[e.surfaceId]?.basePath,o=t?.tab?.openerTabId;if(o)chrome.tabs.get(o,e=>{if(e&&e.windowId===t?.tab?.windowId&&e.url?.startsWith(a))chrome.tabs.update(e.id,{active:!0}),chrome.tabs.remove(i),chrome.tabs.sendMessage(e.id,{content_op:"show-implicit-dv-toast"});else{const e=D(t?.tab?.url,a,r);chrome.tabs.update(i,{url:e})}});else{const e=D(t?.tab?.url,a,r);chrome.tabs.update(i,{url:e})}}}g.setItem(i,e.isDefault?.toString()),chrome.tabs.query({url:s[e.surfaceId]?.baseURL},t=>{t?.forEach(t=>{e.tabId===t.id&&e.syncToOtherTabsOnly||chrome.tabs.sendMessage(t.id,{content_op:"changeDefaultViewershipForSurface",isDefault:e.isDefault,surfaceId:e.surfaceId,source:e.source})})})}}async expressInit(t){const[a]=await Promise.all([T()]),s=a.enableExpressContextMenu,i=a.enableExpressOptionsPagePreference,o=a.enableExpressTooltip,n=r.getFeatureMeta("dc-cv-express-context-menu-tooltip");let l;try{l=JSON.parse(n)}catch(e){l={minimumImageDimension:{height:100,width:150},imageCount:5}}const c=r.getFeatureMeta("dc-cv-express-context-menu-tooltip-allow-list");let d={allowListArray:[]};if(c)try{d.allowListArray=JSON.parse(c)}catch(e){}t({enableExpressContextMenu:s,shouldEnableExpressTouchpointsPreference:i,showExpressTooltip:o,imageDimension:l.minimumImageDimension,imageCount:l.imageCount,allowInfo:d,expressTooltipStrings:{title:e.getTranslation("expressFteTitle"),description:e.getTranslation("expressFteDescription"),footer:e.getTranslation("expressFTEFooter"),popoverTitle:e.getTranslation("expressPopoverFTETitle"),popoverDescription:e.getTranslation("expressPopoverFTEDescription")}})}async whatsappExpressInit(t){const a=await F("whatsapp-preview"),s=await F("whatsapp-hover"),i=r.getFeatureMeta("dc-cv-express-whatsapp-preview"),o=r.getFeatureMeta("dc-cv-express-whatsapp-hover");let n,l;try{n=JSON.parse(i)}catch(e){n=null}try{l=JSON.parse(o)}catch(e){l=null}const c=await r.hasFlag("dc-cv-express-whatsapp-fte");t({enableWhatsappPreviewExpressMenu:a.enableWhatsappPreviewExpressMenu,enableWhatsappHoverExpressMenu:s.enableWhatsappHoverExpressMenu,enableWhatsappPreviewExpressFte:c,enableExpressOptionsPagePreference:a.enableExpressOptionsPagePreference||s.enableExpressOptionsPagePreference,selectors:{...n?.selectorList,...l?.selectorList},fteStrings:{title:e.getTranslation("expressContextualFteTitle","WhatsApp"),description:e.getTranslation("expressContextualFteDescription"),ctaLabel:e.getTranslation("expressContextualFteCtaLabel")}})}async gmailExpressInit(t){const[a,s,i,o,n]=await Promise.all([F("gmail-native-viewer"),F("gmail-message-view"),r.hasFlag("dc-cv-express-gmail-fte"),r.hasFlag("dc-cv-gmail-convert-to-pdf-in-images"),r.hasFlag("dc-cv-gmail-convert-to-pdf-in-images-control")]),l=r.getFeatureMeta("dc-cv-express-gmail-native-viewer"),c=r.getFeatureMeta("dc-cv-express-gmail-message-view"),d=r.getFeatureMeta("dc-cv-gmail-convert-to-pdf-in-images"),p=r.getFeatureMeta("dc-cv-gmail-convert-to-pdf-in-images-control");let u,m,h;try{u=JSON.parse(l)}catch(e){u=null}try{m=JSON.parse(c)}catch(e){m=null}try{o?h=JSON.parse(d):n&&(h=JSON.parse(p))}catch(e){h=null}const b=function(e,t){const a=g.getItem("locale"),s="en-US"===a||"en-GB"===a;return s&&e||!s&&t}(h?.enLocaleEnabled,h?.nonEnLocaleEnabled);o&&b?(A("GCIC"),O("GCI")):n&&b?(A("GCI"),O("GCIC")):(A("GCI"),A("GCIC")),t({...a,...s,enableExpressOptionsPagePreference:a.enableExpressOptionsPagePreference||s.enableExpressOptionsPagePreference,selectors:{...u?.selectorList,...m?.selectorList},enableGmailExpressFte:i,fteStrings:{title:e.getTranslation("expressContextualFteTitle","Gmail"),description:e.getTranslation("expressContextualFteDescription"),ctaLabel:e.getTranslation("expressContextualFteCtaLabel")},imageToolsDropdownFteStrings:{title:e.getTranslation("imageToolsDropdownFteTitle"),description:e.getTranslation("imageToolsDropdownFteDescription"),ctaLabel:e.getTranslation("expressContextualFteCtaLabel")},convertToPdfFteStrings:{title:e.getTranslation("gmailConvertToPdfFteToolTipTitle"),description:e.getTranslation("gmailConvertToPdfFteToolTipDescription"),ctaLabel:e.getTranslation("expressContextualFteCtaLabel")},enableGmailConvertToPdfInImages:o&&b,enableGmailConvertToPdfInImagesControl:n&&b})}async googleImagePreviewExpressInit(t){const a=await F("google-image-preview"),s=r.getFeatureMeta("dc-cv-express-google-image-preview"),i=await r.hasFlag("dc-cv-express-google-image-preview-single-cta"),o=await r.hasFlag("dc-cv-express-google-image-preview-fte");let n;try{n=JSON.parse(s)}catch(e){n=null}t({...a,selectors:n?.selectorList,singleCTAEnabled:i,enableGoogleImagePreviewExpressFte:o,fteStrings:{title:e.getTranslation("expressContextualFteTitle","Google Images"),description:e.getTranslation("expressContextualFteDescription"),ctaLabel:e.getTranslation("expressContextualFteCtaLabel")}})}async gdriveExpressInit(t){const a=await F("gdrive-native-viewer"),s=r.getFeatureMeta("dc-cv-express-gdrive-native-viewer"),i=await r.hasFlag("dc-cv-express-gdrive-native-viewer-fte");let o;try{o=JSON.parse(s)}catch(e){o=null}t({...a,selectors:{...o?.selectors},enableGdriveExpressFte:i,fteStrings:{title:e.getTranslation("expressContextualFteTitle","Google Drive"),description:e.getTranslation("expressContextualFteDescription"),ctaLabel:e.getTranslation("expressContextualFteCtaLabel")}})}async facebookExpressInit(e){const t=await F("facebook-preview"),a=r.getFeatureMeta("dc-cv-express-facebook-preview");let s;try{s=JSON.parse(a)}catch(e){s=null}e({...t,selectors:s?.selectors})}async chatgptExpressInit(t){const a=await F("chatgpt-preview"),s=r.getFeatureMeta("dc-cv-express-chatgpt-preview"),i=r.getFeatureMeta("dc-cv-express-chatgpt-selectors"),o=await r.hasFlag("dc-cv-express-chatgpt-connected-app-moderation"),n=r.getFeatureMeta("dc-cv-express-chatgpt-connected-app-moderation");let l,c;try{l=JSON.parse(s)}catch(e){l=null}try{c=JSON.parse(n)}catch(e){c=null}try{l&&(l.selectorList={...l.selectorList,...JSON.parse(i)})}catch(e){}t({enableChatGPTPreviewExpressMenu:a.enableChatGPTPreviewExpressMenu&&l?.preview,enableChatGPTChatViewExpressMenu:a.enableChatGPTPreviewExpressMenu&&l?.chatView,enableChatGPTWebImagesPreviewExpressMenu:a.enableChatGPTPreviewExpressMenu&&l?.webImagesPreview,enableChatGPTExpressFte:l?.fte,enableExpressOptionsPagePreference:a.enableExpressOptionsPagePreference,selectors:l?.selectorList,enableConnectedAppBasedModeration:{enabled:o,config:c},fteStrings:{title:e.getTranslation("expressContextualFteTitle","ChatGPT"),description:e.getTranslation("expressContextualFteDescription"),ctaLabel:e.getTranslation("expressContextualFteCtaLabel")}})}async outlookExpressInit(t){const a=await F("outlook-native-viewer"),s=r.getFeatureMeta("dc-cv-express-outlook-native-viewer");let i;try{i=JSON.parse(s)}catch(e){i=null}t({enableOutlookNVExpressMenu:a.enableOutlookNVExpressMenu&&i?.preview,enableOutlookAttachmentViewExpressMenu:a.enableOutlookNVExpressMenu&&i?.attachmentView,enableOutlookInEmailImageViewExpressMenu:a.enableOutlookNVExpressMenu&&i?.inEmailImageView,enableOutlookExpressFte:i?.fte,enableExpressOptionsPagePreference:a.enableExpressOptionsPagePreference,selectors:i?.selectorList,fteStrings:{title:e.getTranslation("expressContextualFteTitle","Outlook"),description:e.getTranslation("expressContextualFteDescription"),ctaLabel:e.getTranslation("expressContextualFteCtaLabel")}})}async chatgptInit(e){const t=await r.hasFlag("dc-cv-chatgpt-analytics-visited");let a=r.getFeatureMeta("dc-cv-chatgpt-analytics-visited");try{a=JSON.parse(a)}catch(e){a={}}e({enableChatGPTAnalytics:t,metaData:a})}async initialisePopup(a,s){let i={hostedURL:t.getPopupCDNUrl()};if(this.tabs[a.id]){i=e.extend(i,this.tabs[a.id]);const t=`chrome-extension://${chrome.runtime.id}`;a.url.startsWith(t)&&(i.is_extension_url=!0);["chrome://extensions/",t,"chrome://newtab/","https://chrome.google.com","https://acrobat.adobe.com/link/file/?uri=","https://acrobat.adobe.com/id/urn:","https://acrobat.adobe.com/link/review/?uri="].some(e=>a.url.startsWith(e))&&(i.isBlacklistedUrl=!0);if(!["downloading","pdf_downloading","waiting","in_progress","complete"].includes(i.current_status)||i.isBlacklistedUrl){const e=i.is_pdf;this.clearStatus(i),i.is_pdf=e}e.isLocalFileUrl(a.url)&&(i.is_pdf=!0,i.isFillnSignEnabled=u.FILL_N_SIGN_ENABLED),i.isAcrobat=e.isAcrobatAvailable(this.version),i.autoOpenPDFInAcrobat="false"!==g.getItem("ViewResultsPref")}s(i)}echoRequest(t){var a,s,i;if(!(u.CHROME_VERSION<u.SUPPORTED_VERSION)){if(!this.avoidUrl(t.url)){var r=t.id||t.tabId;return this.tabs[r]&&("cancelled"!==(a=this.tabs[r]).current_status&&"pdf_opened"!==a.current_status&&"pdf_failure"!==a.current_status&&"viewer_menu"!==a.panel_op||(i=a.is_pdf,this.clearStatus(a),a.is_pdf=i),a.current_status&&(a.panel_op="status"),s=a.is_pdf?"pdf_menu":"html_menu",a.panel_op&&"load-frictionless"===a.panel_op&&delete a.panel_op,"resize_window"===a.content_op&&(delete a.content_op,delete a.window_height),a.panel_op=a.panel_op||s,"html_menu"===s&&(a.persist=!1),a.incognito=t.incognito,e.isLocalFileUrl(t.url)&&(a.panel_op="pdf_menu",a.is_pdf=!0,a.isFillnSignEnabled=u.FILL_N_SIGN_ENABLED),t.url.startsWith(`chrome-extension://${chrome.runtime.id}`)?(a.panel_op="viewer_menu",a.is_viewer=!0):a.is_viewer=!1,e.consoleLog("repeat cached request: "+a.panel_op)),a}this.disable(t.id)}}setGlobals(e){this.globals=e}dump(t,a){var s,i=[a];for(s in t)t.hasOwnProperty(s)&&i.push("  "+s+": "+t[s]);e.consoleLog(i.join("\n"))}sendMessage(t,s=!0,i){var r,o=t.tabId;this.dump(t,"Sending message:"),t.version=this.version,e.consoleLog("sendMessage version",t),s&&(this.tabs[o]=e.extend(this.tabs[o],t)),t.NMHConnStatus=this.NMHConnStatus,t.show_frictionless=!0,t.is_edge=e.isEdge(),"flickr"===t.panel_op&&(r=a.e.FLICKR_OFFER_SHOWN),r&&a.checkAndLogAnalytics(r),e.sendMessage(t,this.globals,i),delete t.mimeHandled,delete this.tabs[o].mimeHandled}deferMessage(e){"undefined"==typeof setTimeout?this.sendMessage(e):setTimeout(this.proxy(this.sendMessage,e),0)}sendMessageToPopup(t,a=!0){const s=t.tabId;t.version=this.version,a&&(this.tabs[s]=e.extend(this.tabs[s],t)),t.NMHConnStatus=this.NMHConnStatus,t.is_edge=e.isEdge(),chrome.runtime.sendMessage(t)}filenameFromUrl(e){try{const t=decodeURIComponent(e),a=t.split("?")[0].split("/").filter(e=>e.length>0),s=a.length>0?a[a.length-1]:"untitled";let i=s;const r=s.length-4;return(s.length<4||s.toLowerCase().indexOf(".pdf")!==r)&&(i+=".pdf"),i}catch(e){return"untitled.pdf"}}async pdf_menu(t,s){var i;if(delete(i=this.tabs[s.tab.id]=e.extend(this.tabs[s.tab.id],{tabId:s.tab.id})).dend_op,i.filename=this.filenameFromUrl(t.url),i.panel_op="pdf_menu",i.url=t.url,i.viewer=t.viewer,i.incognito=s.tab.incognito,i.fteFeatureFlag=t.fteFeatureFlag,i.isFillnSignEnabled=u.FILL_N_SIGN_ENABLED,i.isSharePointEnabled=n.isFeatureEnabled(),1==i.isSharePointEnabled&&(i.isSharePointURL=n.isAllowListedSharePointURL(i.url)),1==t.persist){const e=await this.isEnablePersistMenu(t);i.persist=!!e}else i.persist=!1;const r=g.getItem("fteDenied");var o=!(0==t.version||1==t.version||t.version===u.READER_VER||t.version===u.ERP_READER_VER);const l=u.VIEWER_ENABLED&&!g.getItem("pdfViewer")&&(!r||10!==parseInt(r))&&(!o||u.VIEWER_ENABLED_FOR_ACROBAT);if("false"!==g.getItem("always-show-pdf-menu")&&"mime"!==i.viewer&&(1!=i.persist||l||(delete i.fteFeatureFlag,a.event(a.e.PERSIST_PDF_MENU_SHOWN)),this.deferMessage(i)),l){let e,s=g.getItem("repromptCount");switch(t.fteFeatureFlag){case"dc-cv-fte-pdf-redcard":e=a.e.PERSIST_PDF_MENU_RED_CARD_FTE_SHOWN;break;case"dc-cv-fte-pdf-dmb":e=a.e.PERSIST_PDF_MENU_DMB_FTE_SHOWN;break;default:e=a.e.PERSIST_PDF_MENU_FTE_SHOWN}s?a.event(e,{LAUNCH:"Reprompt"}):a.event(e,{LAUNCH:"Launch"})}if(!i.incognito)if("true"!==g.getItem("pdfViewer")||"native"!==i.viewer&&"mime-native"!==i.viewer){if(!g.getItem("pdfViewer")||"false"===g.getItem("pdfViewer")){let e="Acrobat";this.legacyShim()?e="NoApp":this.version!==u.READER_VER&&this.version!==u.ERP_READER_VER||(e="Reader"),"native"!==i.viewer&&"mime-native"!==i.viewer||a.event(a.e.VIEWER_DISABLED_PDF_OPEN_NATIVE_VIEWER,{APPLICATION:e})}}else a.event(a.e.VIEWER_ENABLED_PDF_OPEN_NATIVE_VIEWER)}loaded(t){this.tabs[t]=e.extend(this.tabs[t],{tabId:t,loaded:!0})}setIsPDF(t,a){this.tabs[t]=e.extend(this.tabs[t],{tabId:t,is_pdf:a})}cancelConversion(e){this.getModule("acro-web2pdf").cancelConversion(e.tabId),delete e.current_status,delete e.file_path,delete e.domtitle,delete e.timing,delete e.panel_op,delete e.is_pdf,delete e.newUI}clearStatus(e,t){"in_progress"!==e.current_status&&"downloading"!==e.current_status&&(t||"waiting"!==e.current_status)&&this.cancelConversion(e)}loading(t){var a=t.id;this.tabs[a]=e.extend(this.tabs[a],{tabId:a,loaded:!1}),this.clearStatus(this.tabs[a],!0)}async active(t){this.activeTab=t.tabId,this.tabs[this.activeTab]=e.extend(this.tabs[this.activeTab],{tabId:t.tabId});if(await this.isEnablePersistMenu()){var a=this.echoRequest(this.tabs[this.activeTab]);a&&a.persist&&this.sendMessage(a)}}disable(e){this.tabs[e]&&(this.tabs[e].loaded=!1)}close(e){this.getModule("acro-web2pdf").cancelConversion(e),delete this.tabs[e],this.activeTab===e&&(this.activeTab=null),V().cleanTemporaryURLBufferEntry(e)}tabReplace(e,t){this.close(t),this.loaded(e)}activeTab(){return this.activeTab}noop(){}avoidUrl(t){if(t=t||"",u.VIEWER_ENABLED&&g.getItem("pdfViewer")&&e.isViewerURL(t))return!1;if(this.version===u.ERP_READER_VER)return!0;if(t.startsWith("https://chrome.google.com"))return!0;if(this.version==u.READER_VER&&0==u.FRICTIONLESS_ENABLED)return!t.endsWith(".pdf")&&!t.endsWith(".PDF");if((0==this.version||1==this.version&&0==this.NMHConnStatus)&&!1===u.FRICTIONLESS_ENABLED)return!1;g.getItem("appLocale");const a=this.isAllowedLocalFileAccess&&e.isLocalFileUrl(t);return!t.startsWith("http")&&!a}}j||(j=new z,j.registerHandlers({"send-analytics":j.proxy(j.noop)}));export const communicate=j;