buli
2023-06-05 e9b970ea36eea5dcf93fd5b965bf13d7010ce0ad
1
LWR.define("@salesforce/label/MyCommunities.errorInFileDownload/v/0_8_14",["exports"],function(c){"use strict";var l="MyCommunities.errorInFileDownload";c.default=l,Object.defineProperty(c,"__esModule",{value:!0})}),LWR.define("mobileruntime/hybridAppManager/v/1",["exports","lwr/loaderLegacy/v/0_8_14","logger/v/1_66_219-242_0","webruntime/routingService/v/1_66_219-242_0","@salesforce/site/Id/v/1","webruntime/transport/v/1_66_219-242_0","@app/basePath/v/1","@app/loginPath/v/1","@salesforce/label/MyCommunities.errorInFileDownload/v/0_8_14","webruntime/overrides/v/1_66_219-242_0"],function(c,l,a,L,C,N,I,S,M,d){"use strict";function u(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var F=u(C),f=u(I),h=u(S),k=u(M);function j(){if(window.navigator?.userAgent?.includes("android")){const{head:e}=document,t=document.createElement("script");t.src="/localhost/cordova.js",e.appendChild(t)}}function x(){window.native={sendAILTNData:function(e){if(!e?.logLines)return new Promise(function(t,n){n("Received null or invalid payload")})},refreshNotifications:function(){document.dispatchEvent(new CustomEvent("refreshNotifications",{detail:{},bubbles:!0,cancelable:!0,composed:!1}))},navigateTo:function(e){return new Promise(function(t,n){if(!e){n("Received invalid pageReference payload");return}L.generateUrl(e).then(o=>{window.open(new URL(o,window.location.href)),t()},o=>n(o))})}}}const W=`/services/data/v57.0/connect/sites/${F.default}/cms/delivery/contents?contentTypeFQN=sfdc_cms__mobilePublisherConfig&includeContentBody=true`;function p(e,t){if(!v()){a.log("Native JS API is not available");return}const{invokeNative:n}=window.mycommunities.nativejsapi;return n(e,t)}function B(e=""){return new RegExp("^([a-z]+://)","i").test(e)}function H(e=""){if(!B(e))return!1;const t=new URL(e),n=window.location.host;return t.host!==n}async function G(){if(!v()){a.log("Native JS API is not available");return}j();try{const e=await N.fetch(W,{method:"GET"});if(e.status===200){const t=await e.json(),n=window.location.href.endsWith("/")?window.location.href.slice(0,-1):window.location.href,{nativeTabMenu:o}=t.contents[0]?.contentBody||{};o?.menuItems?.forEach((i,r)=>{i.id=(r+1)*10,i.position=r+1,i.name=i.name||" ",i.targetUrl=n+i.targetUrl,i.iconDetails.mimeType="image/png",i.iconDetails.url=`data:image/png;base64,${i.payload}`}),w(o)}else a.log("Failed to fetch bottom tab bar. Status is: ",e.status),w(!0)}catch(e){a.log("Failed to fetch bottom tab bar",e),w(!0)}a.log("Initial load done! Splash Screen hidden")}function J(e,t){const n=new URL(e||"",window.location.origin);e=n.href;const o="/servlet/networks/switch",i=n.pathname,r=i.indexOf("/s/"),s=r===-1?i:i.substring(0,r+2);return[o,encodeURIComponent(o)].some(b=>e.includes(b))||!s.startsWith(t)}function q(e){if(!e)return null;switch(e.length){case 15:return Z(e);case 18:return e;default:return null}}function V(){const{cordova:e}=window;return typeof e!="undefined"&&e&&e.require("cordova/channel")&&e.require("cordova/channel").onDeviceReady&&e.require("cordova/channel").onDeviceReady.state===2}function g(){return V()?window.cordova.require("com.salesforce.plugin.oauth"):null}function Q(e){if(!e)return!1;const t="/secur/logout.jsp";return e.includes(t)||e.includes(encodeURIComponent(t))}function X(e){const t=g();t&&t.logout(e)}function P(){a.log("hybrid_app_manager_utils:handle_page_loaded"),x(),v()&&(typeof window.mycommunities.nativejsapi.webAppPageLoadDone=="function"?(a.log("hybrid_app_manager_utils:handle_page_loaded: webAppPageLoadDone function called"),window.mycommunities.nativejsapi.webAppPageLoadDone()):a.log("hybrid_app_manager_utils:handle_page_loaded:webAppPageLoadDone function is not available"))}function w(e){const{webAppBootstrapDone:t}=window.mycommunities.nativejsapi;a.log("Triggering webAppBootstrapDone"),t(e)}function Z(e){let t="";const n="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456";for(let o=0;o<3;++o){let i=0;for(let r=0;r<5;r++){const s=e.charAt(o*5+r);s>="A"&&s<="Z"&&(i+=1<<r)}t+=n.charAt(i)}return e+t}function v(){return window?.mycommunities?.nativejsapi}const z="/secur/frontdoor.jsp";function K({routeUrl:e}){const t=g();t?t.authenticate(function(n){n&&n.csrfToken&&n.accessToken&&(document.cookie=`sid=${n.accessToken}; path=/; secure=true`,window.localStorage.setItem("sid",n.csrfToken),e!=null&&window.open(e))},function(){a.logError("Error in handler Session Timeout. Cordova OAuth Plugin authentication failed.")}):a.logError("Error in handler Session Timeout. OAuth Plugin is not available.")}async function Y(){let e=!1;const t=await l.load("@app/user/v/1");try{await l.load(`@app/user?c=${crypto.randomUUID()}`,"mobileruntime/hybridAppManager/v/1")}catch(n){e=!t.isGuest}return e}function A(e){const t=new URL(h.default,window.location.href),n=new URL(e,window.location.href);return h.default&&t.pathname===n.pathname&&t.origin===n.origin}function E(e){const t=g();t?t.authenticate(function(n){window.location.href=`${n.loginUrl}${z}?sid=${n.accessToken}&retURL=${encodeURIComponent(e||f.default)}&display=touch`},function(){throw new Error("Authentication via Cordova OAuth Plugin failed.")}):window.location.href=e||h.default}function $(e){if(typeof e=="object"){const{attributes:{url:t}={url:null}}=e;if(A(t)){const n=new URL(t,window.location.href);return E(n.searchParams.get("startURL")),!1}}return!0}async function _({next:{route:e,data:t}={}}={}){if(t&&t.isPublic!==!1)return!0;const{default:n}=await l.load("@app/user/v/1");if(n.isGuest){const o=await L.generateUrl(e);if(o){const i=new URL(o,window.location.href);return E(i.pathname+i.search+i.hash),!1}}return!0}const ee=["/sfc/servlet.shepherd","/servlet/servlet.FileDownload","/servlet/fileField","version/renditionDownload"];function m(){a.log("Handle showing of Toast Message for Error case.")}function te(e){const t="/sfc/servlet.:type/:contentType/download/:recordId",n=new RegExp(t.replace(/:[^\s/]+/g,"([\\w-]+)")),o=e.match(n);if(o&&o.length===4)return{recordId:o[3]};const i="/servlet/servlet.:type?file=:recordId",r=new RegExp(i.replace(/:[^\s/?]+/g,"([\\w-]+)").replace(/\?/g,"[?]")),s=e.match(r);if(s&&s.length===3)return{recordId:s[2]};const b="/servlet/fileField";if(e.includes(b)){const y=new URLSearchParams(decodeURIComponent(e).split("?")[1]),R=y.get("entityId"),pe=y.get("field");return{recordId:R,fieldId:pe}}const he="version/renditionDownload";if(e.includes(he)){const R=new URL(e).searchParams.get("versionId");return{recordId:q(R)}}return null}function ne(e){const t=p("downloadFile",e);if(t)return t.catch(n=>{a.log(`Error while downloading file of record id: ${e.recordId} message: ${n}`&&n.message),m()})}function oe(e){if(!e){a.log(`${k.default}. URL is ${e}`),m();return}const t=te(e);if(!t){a.log(`Parsing the file URL "${e}" yielded null`),m();return}return ne(t)}function ie(e){return e=e||"",ee.some(t=>e.indexOf(t)>-1)}const ae=globalThis.open;function D(e){const t=new URL(e,window.location.href);if(e=t.href,e.indexOf("/")!==0&&e.indexOf("http://")!==0&&e.indexOf("https://")!==0)return ae(e,"_self");if(Q(e))X(e);else if(H(t))p("navigateToExternalURL",{url:e});else if(A(e))U({type:"standard__webPage",attributes:{url:t.pathname+t.searchParams+t.hash}},!1);else if(ie(e))oe(e);else if(J(e,f.default))p("navigateToExternalURL",{url:e});else{const n=t.pathname,o=n==="/"||n===f.default;U({type:"standard__webPage",attributes:{url:n}},o)}}function U(e,t){return document.dispatchEvent(new CustomEvent("notify-client-module",{cancelable:!0,composed:!0,detail:{action:"navigate",data:{routeObj:e,replaceState:t}}}))}function re(){se()}function se(){document.addEventListener("click",le),document.addEventListener("notify-mobile-module",de)}function ce({pathMatch:e,route:t,routeDefinition:n}){const{id:o}=t||{},{type:i}=t?.pageReference||{},{isRoot:r}=n?.metadata||{};document.dispatchEvent(new CustomEvent("routeChangeSuccess",{bubbles:!0,composed:!0,detail:{routeType:i,routeId:o,routeUrl:e,backNavigation:{canGoBack:!r}}}))}function le(e){const t=e.composedPath()[0];if(t.tagName.toLowerCase()==="a")return e.preventDefault(),e.stopPropagation(),D(t.href)}function de({detail:e}){const{action:t,data:n}=e||{action:"",data:null};switch(t){case"navigationcompleted":ce(n?.routeResult||{});break;default:a.log(`No such ${t} exists in notify-mobile-module event. Please re-check!!`);break}}function ue(){window.open=e=>D(e)}function T(){return G(),/interactive|complete/.test(document.readyState)?P():document.addEventListener("DOMContentLoaded",P,!1),ue(),re()}function O(){return K({routeUrl:window.location.pathname}),!1}d.PreNavigateOverrides.add(e=>_(e)),d.NavigationOverrides.add(e=>$(e)),d.PageNavigationFailureOverrides.add(async({error:e,isPublic:t})=>{const n=await Y();return e?.constructor?.name==="LoaderError"&&!t&&n?O():!0}),d.SessionTimeoutOverrides.add(()=>O());function fe(e){Object.entries(e).forEach(([t,n])=>{LWR.define(t,[],function(){return n})})}fe({"mobileruntime/hybridAppManager":T}),c.hybridAppManager=T,Object.defineProperty(c,"__esModule",{value:!0})});