LWR.define("@salesforce/label/MyCommunities.errorInFileDownload/v/0_6_4",["exports"],function(e){"use strict";var o="MyCommunities.errorInFileDownload";e.default=o,Object.defineProperty(e,"__esModule",{value:!0})});LWR.define("mobileruntime/hybridAppManager/v/1",["exports","lwr/loaderLegacy/v/0_6_4","logger/v/1_66_56-238_0","@app/basePath/v/1","@app/loginPath/v/1","webruntime/routingService/v/1_66_56-238_0","@salesforce/label/MyCommunities.errorInFileDownload/v/0_6_4","webruntime/overrides/v/1_66_56-238_0"],function(m,l,a,T,O,I,N,c){"use strict";function u(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var d=u(T),f=u(O),S=u(N);function h(e,t){if(!L()){a.log("Native JS API is not available");return}const{invokeNative:n}=window.mycommunities.nativejsapi;return n(e,t)}function k(e=""){return new RegExp("^([a-z]+://)","i").test(e)}function C(e=""){if(!k(e))return!1;const t=new URL(e),n=window.location.host;return t.host!==n}function R(){if(!L()){a.log("Native JS API is not available");return}const{webAppBootstrapDone:e}=window.mycommunities.nativejsapi;a.log("Triggering webAppBootstrapDone"),e(!0),a.log("Initial load done! Splash Screen hidden")}function M(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(v=>e.includes(v))||!s.startsWith(t)}function F(e){if(!e)return null;switch(e.length){case 15:return x(e);case 18:return e;default:return null}}function b(){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 x(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 L(){return window.mycommunities&&window.mycommunities.nativejsapi}const j="/secur/frontdoor.jsp";function H({routeUrl:e}){const t=b()?window.cordova.require("com.salesforce.plugin.oauth"):null;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 W(){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 y(e){const t=new URL(f.default,window.location.href),n=new URL(e,window.location.href);return f.default&&t.pathname===n.pathname&&t.origin===n.origin}function P(e){const t=b()?window.cordova.require("com.salesforce.plugin.oauth"):null;t?t.authenticate(function(n){window.location.href=`${n.loginUrl}${j}?sid=${n.accessToken}&retURL=${encodeURIComponent(e||d.default)}&display=touch`},function(){throw new Error("Authentication via Cordova OAuth Plugin failed.")}):window.location.href=e||f.default}function q(e){if(typeof e=="object"){const{attributes:{url:t}={url:null}}=e;if(y(t)){const n=new URL(t,window.location.href);return P(n.searchParams.get("startURL")),!1}}return!0}async function G({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 I.generateUrl(e);if(o){const i=new URL(o,window.location.href);return P(i.pathname+i.search+i.hash),!1}}return!0}const B=["/sfc/servlet.shepherd","/servlet/servlet.FileDownload","/servlet/fileField","version/renditionDownload"];function w(){a.log("Handle showing of Toast Message for Error case.")}function J(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 v="/servlet/fileField";if(e.includes(v)){const g=new URLSearchParams(decodeURIComponent(e).split("?")[1]),p=g.get("entityId"),ne=g.get("field");return{recordId:p,fieldId:ne}}const te="version/renditionDownload";if(e.includes(te)){const p=new URL(e).searchParams.get("versionId");return{recordId:F(p)}}return null}function V(e){const t=h("downloadFile",e);if(t)return t.catch(n=>{a.log(`Error while downloading file of record id: ${e.recordId} message: ${n}`&&n.message),w()})}function X(e){if(!e){a.log(`${S.default}. URL is ${e}`),w();return}const t=J(e);if(!t){a.log(`Parsing the file URL "${e}" yielded null`),w();return}return V(t)}function Z(e){return e=e||"",B.some(t=>e.indexOf(t)>-1)}function E(e){const t=new URL(e,window.location.href);if(e=t.href,C(t))h("navigateToExternalURL",{url:e});else if(y(e))U({type:"standard__webPage",attributes:{url:t.pathname+t.searchParams+t.hash}},!1);else if(Z(e))X(e);else if(M(e,d.default))h("navigateToExternalURL",{url:e});else{const n=t.pathname,o=n==="/"||n===d.default;U(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 $(){z()}function z(){document.addEventListener("click",Q),document.addEventListener("notify-mobile-module",Y)}function K({route:e,routeInfoData:t}){const{type:n,id:o}=e||{},{isRoot:i,path:r}=t||{};document.dispatchEvent(new CustomEvent("routeChangeSuccess",{bubbles:!0,composed:!0,detail:{routeType:n,routeId:o,routeUrl:r,backNavigation:{canGoBack:!i}}}))}function Q(e){const t=e.composedPath()[0];if(t.tagName.toLowerCase()==="a")return e.preventDefault(),e.stopPropagation(),E(t.href)}function Y({detail:e}){const{action:t,data:n}=e||{action:"",data:null};switch(t){case"navigationcompleted":K(n||{});break;default:a.log(`No such ${t} exists in notify-mobile-module event. Please re-check!!`);break}}function _(){window.open=e=>E(e)}function A(){return/interactive|complete/.test(document.readyState)?R():document.addEventListener("DOMContentLoaded",R,!1),_(),$()}function D(){return H({routeUrl:window.location.pathname}),!1}c.PreNavigateOverrides.add(e=>G(e)),c.NavigationOverrides.add(e=>q(e)),c.PageNavigationFailureOverrides.add(async({error:e,isPublic:t})=>{const n=await W();return e?.constructor?.name==="LoaderError"&&!t&&n?D():!0}),c.SessionTimeoutOverrides.add(()=>D());function ee(e){Object.entries(e).forEach(([t,n])=>{LWR.define(t,[],function(){return n})})}ee({"mobileruntime/hybridAppManager":A}),m.hybridAppManager=A,Object.defineProperty(m,"__esModule",{value:!0})});
|