@wavemaker/app-runtime-wm-build 11.3.3-next.25043 → 11.3.3-next.25045

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -79998,6 +79998,9 @@
79998
79998
  }
79999
79999
  } : _a, scripts = _b.resources.scripts;
80000
80000
  var baseUrl = getPrefabBaseUrl(prefabName);
80001
+ scripts = scripts.filter((function(script) {
80002
+ return !script.startsWith("npm://");
80003
+ }));
80001
80004
  var _scripts = scripts.map((function(url) {
80002
80005
  return getPrefabResourceUrl(url, baseUrl);
80003
80006
  }));
@@ -855,7 +855,7 @@ var p=function(e,t){return(p=Object.setPrototypeOf||{__proto__:[]}instanceof Arr
855
855
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
856
856
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
857
857
  PERFORMANCE OF THIS SOFTWARE.
858
- ***************************************************************************** */Object.create;function A(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,o,r=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function I(e,t,n){if(n||2===arguments.length)for(var i,o=0,r=t.length;o<r;o++)!i&&o in t||(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}Object.create;var D="wavemaker.persistedcookies",N=function(){function e(){this.cookieInfo={},this.serviceName="CookeService"}return e.prototype.persistCookie=function(e,t,n){var i=this;return new Promise((function(o,r){n?o(n):i.getCookie(e,t).then((function(e){return o(e.cookieValue)}),r)})).then((function(n){i.cookieInfo[e+"-"+t]={hostname:e.replace(/:[0-9]+/,""),name:t,value:i.rotateLTR(n)},localStorage.setItem(D,JSON.stringify(i.cookieInfo))}))},e.prototype.getCookie=function(e,t){return new Promise((function(n,i){if(v.isIos()){var o=window.cordova.plugin.http.getCookieString(e);if(o){var r=o.indexOf(t);if(r>=0){var a=r+t.length+1,s=o.indexOf(";",a);return void n({cookieValue:o.substring(a,s>=0?s:void 0)})}}i()}else window.cookieEmperor.getCookie(e,t,n,i)}))},e.prototype.setCookie=function(e,t,n){return new Promise((function(i,o){if(v.isIos()){var r=t+"="+n;window.cordova.plugin.http.setCookie(e,r),i()}else window.cookieEmperor.setCookie(e,t,n,i,o)}))},e.prototype.clearAll=function(){return new Promise((function(e,t){v.isIos()?(window.cordova.plugin.http.clearCookies(),e("")):window.cookieEmperor.clearAll(e,t)}))},e.prototype.start=function(){var e=this,t=localStorage.getItem(D),n=[];if(t){var i=JSON.parse(t);_.forEach(i,(function(t){t.name&&t.value&&n.push(e.getCookie(t.hostname,t.name).catch((function(){return new Promise((function(n,i){window.cookieEmperor.setCookie(t.hostname,t.name,e.rotateRTL(t.value),n,i)}))})))}))}return Promise.all(n)},e.prototype.getServiceName=function(){return e.SERVICE_NAME},e.prototype.rotateLTR=function(e){var t=e.split(""),n=[],i=Math.floor(e.length/3);return t.forEach((function(e,o){n[(o+i)%t.length]=t[o]})),n.join("")},e.prototype.rotateRTL=function(e){var t=e.split(""),n=[],i=Math.floor(e.length/3);return t.forEach((function(e,o){n[(t.length+o-i)%t.length]=t[o]})),n.join("")},e}();N.SERVICE_NAME="CookieService",N.\u0275prov=C.\u0275\u0275defineInjectable({factory:function(){return new N},token:N,providedIn:"root"}),N.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}];var x=function(){function e(e,t,n){this.elRef=e,this.fileSelectorService=t,this.processManagementService=n}return e.prototype.ngAfterViewInit=function(){var e=$(this.elRef.nativeElement).find(">[wmNetworkInfoToaster], >[wmAppUpdate], >[wmMobileFileBrowser]"),t=$("body");v.hasCordova()?(e.appendTo(t),this.fileSelectorService.setFileBrowser(this.fileBrowserComponent)):e.remove(),$(this.elRef.nativeElement).find(">[wmProgressManager]").appendTo(t),this.processManagementService.setUIComponent(this.processManagerComponent)},e}();x.decorators=[{type:n.Component,args:[{selector:"[wmAppExt]",template:"<ng-container> \n <div wmNetworkInfoToaster></div>\n <div wmAppUpdate></div>\n <div wmMobileFileBrowser></div>\n <div wmProcessManager></div>\n </ng-container>"}]}],x.ctorParameters=function(){return[{type:n.ElementRef},{type:E.FileSelectorService},{type:E.ProcessManagementService}]},x.propDecorators={fileBrowserComponent:[{type:n.ViewChild,args:[E.FileBrowserComponent]}],processManagerComponent:[{type:n.ViewChild,args:[E.ProcessManagerComponent]}]};var k=function(){function e(e,t,n,i,o,r){this.app=e,this.deviceService=i,this.networkService=o,this.requestInterceptors=[],v.hasCordova()&&(this.requestInterceptors.push(new L(e,t,r)),this.requestInterceptors.push(new M(e)))}return e.prototype.intercept=function(e,t){var n=this,i=(new T.Subject,localStorage.getItem(S.CONSTANTS.XSRF_COOKIE_NAME)),o=v.getWmProjectProperties().xsrf_header_name;i&&o&&this.app.deployedUrl&&(e.url.indexOf("://")<0||e.url.startsWith(this.app.deployedUrl))&&(e=e.clone({headers:e.headers.set(o,i)}));var r={request:e};return T.from(this.deviceService.whenReady().then((function(){return v.executePromiseChain(n.getInterceptors(),[r])}))).pipe(R.mergeMap((function(){return t.handle(r.request)})))},e.prototype.getInterceptors=function(){return this.requestInterceptors.map((function(e){return function(t){return e.intercept(t.request).then((function(e){return t.request=e}))}}))},e.prototype.onHttpError=function(e){v.hasCordova&&(!e||!e.status||e.status<0||404===e.status)&&this.networkService.isConnected()&&this.networkService.isAvailable(!0)},e}();k.decorators=[{type:n.Injectable}],k.ctorParameters=function(){return[{type:v.App},{type:s.File},{type:b.DeviceFileDownloadService},{type:b.DeviceService},{type:b.NetworkService},{type:P.SecurityService}]};var M=function(){function e(e){this.app=e}return e.prototype.intercept=function(t){var n=t,i=t.url;return i.indexOf("://")<0&&e.REMOTE_SERVICE_URL_PATTERNS.find((function(e){return e.test(i)}))&&(i=this.app.deployedUrl+i),(i=v.removeExtraSlashes(i))!==t.url&&(n=t.clone({url:i})),Promise.resolve(n)},e}();M.REMOTE_SERVICE_URL_PATTERNS=[new RegExp("^((./)|/)?services/"),new RegExp("j_spring_security_check"),new RegExp("j_spring_security_logout")];var L=function(){function e(e,t,n){this.app=e,this.file=t,this.securityService=n,this.initialized=!1}return e.prototype.intercept=function(t){var n=this;return new Promise((function(i,o){return!e.PREFAB_URL_PATTERN.test(t.url)&&e.PAGE_URL_PATTERN.test(t.url)?Promise.resolve().then((function(){if(!n.initialized)return n.init()})).then((function(){var e=_.split(t.url,"/"),r=e[e.length-2];return!n.publicPages||n.publicPages[r]||n.securityService.getConfig((function(e){!e.securityEnabled||e.authenticated?i(t):(o("Page '"+r+"' is not accessible to the user."),n.app.notify("http401",{page:r}))}),(function(){return o("Security call failed.")})),Promise.resolve(t)})).then(i,o):i(t)}))},e.prototype.init=function(){var e=this,t=cordova.file.applicationDirectory+"www/metadata/app";return this.file.readAsText(t,"public-pages.json").then((function(t){e.initialized||(e.publicPages={},e.initialized=!0,_.forEach(JSON.parse(t),(function(t){return e.publicPages[t]=!0})))})).catch((function(){e.initialized=!0}))},e}();L.PAGE_URL_PATTERN=new RegExp("page.min.json$"),L.PREFAB_URL_PATTERN=new RegExp("^app/prefabs/.*/page.min.json$");var F=function(){function e(e,t,n){this.app=e,this.httpService=t,this.extAppMessageService=n}return e.prototype.execute=function(e,t,n){var i=this;return void 0===n&&(n=!1),this.httpService.get("/services/webprocess/prepare?processName="+e+"&hookUrl="+t+"&requestSourceType=MOBILE").then((function(t){return n?i.executeWithSystemBrowser(t):i.executeWithInAppBrowser(t,e)})).then((function(e){return i.httpService.get("/services/webprocess/decode?encodedProcessdata="+e)}))},e.prototype.executeWithSystemBrowser=function(e){var t=this;return new Promise((function(n){var i=t.extAppMessageService.subscribe("^services/webprocess/LOGIN",(function(e){n(e.data.process_output),i()}));window.open(t.app.deployedUrl+"services/webprocess/start?process="+encodeURIComponent(e),"_system")}))},e.prototype.executeWithInAppBrowser=function(e,t){var n=this;return new Promise((function(i,o){var r=cordova.InAppBrowser.open(n.app.deployedUrl+"services/webprocess/start?process="+encodeURIComponent(e),"_blank","location=yes,clearcache=yes"),a=!1;r.addEventListener("loadstop",(function(){r.executeScript({code:n.getScriptToInject(t)},(function(e){e&&e[0]&&(a=!0,r.close(),i(e[0]))}))})),r.addEventListener("exit",(function(){a||o("Login process is stopped")}))}))},e.prototype.getScriptToInject=function(e){return"\n (function() {\n var elements = document.querySelectorAll('body.flex>a.link');\n for (var i = 0; i < elements.length; i++) {\n var href = elements[i].href;\n if (href && href.indexOf('://services/webprocess/"+e+"?process_output=')) {\n return href.split('process_output=')[1];\n }\n }\n window.isWebLoginProcess = true;\n })();\n "},e}();F.decorators=[{type:n.Injectable}],F.ctorParameters=function(){return[{type:v.App},{type:v.AbstractHttpService},{type:b.ExtAppMessageService}]};var j=6e4,B="keyboard",G=[i.AppVersion,o.BarcodeScanner,r.Calendar,a.Camera,s.File,l.FileOpener,c.Device,u.Geolocation,p.MediaCapture,d.Network,h.SQLite,m.Vibration,f.LocationAccuracy,g.Diagnostic],V=function(){function e(t,n,i,o,r,a,s,l,c){var p=this;this.app=t,this.cookieService=n,this.deviceFileOpenerService=i,this.deviceService=o,this.securityService=r,this.httpService=a,this.extAppMessageService=s,this.networkService=l,this.webProcessService=c,this._$appEl=$(".wm-app").first(),this._$appEl.width()>=768?(t.isTabletApplicationType=!0,this._$appEl.addClass("wm-tablet-app")):this._$appEl.addClass("wm-mobile-app"),t.subscribe("on-viewport-details",(function(e){p.applyOSTheme(e)})),e.initializeRuntime(this,this.app,this.deviceFileOpenerService,this.deviceService)}return e.forRoot=function(){return{ngModule:e,providers:I(I([F,{provide:t.HTTP_INTERCEPTORS,useClass:k,multi:!0}],A(G)),[y.FileExtensionFromMimePipe,{provide:w.PushService,useClass:w.PushServiceImpl}])}},e.initializeRuntime=function(e,t,n,i){if(!this.initialized){if(this.initialized=!0,t.deployedUrl=e.getDeployedUrl(),v.hasCordova()){var o=t.subscribe("pageReady",(function(e){navigator.splashscreen.hide(),o()}));t.subscribe("userLoggedIn",(function(){cordova&&cordova.wavemaker.syncCookies()})),e.handleKeyBoardClass(),t.subscribe("device-file-download",(function(e){n.openRemoteFile(e.url,e.extension,e.name,e.headers).then(e.successCb,e.errorCb)}));var r=window.__zone_symbol__FileReader;r&&r.READ_CHUNK_SIZE&&(window.FileReader=r),window.open=window.cordova.InAppBrowser.open,e.addAuthInBrowser()}i.start(),i.whenReady().then((function(){v.hasCordova()&&(e._$appEl.addClass("cordova"),e.exposeOAuthService(),window.StatusBar&&window.StatusBar.overlaysWebView(!1))}))}},e.prototype.exposeOAuthService=function(){var e=this;window.OAuthInMobile=function(t){return new Promise((function(n,i){var o="^services/oauth/"+t+"$",r=e.extAppMessageService.subscribe(o,(function(e){n(e.data.access_token),r(),clearTimeout(a)})),a=setTimeout((function(){r(),i("Time out for oauth message after 0 seconds")}),j)}))};var t=window.handleOpenURL;t.isReady=!0,t(t.lastURL)},e.prototype.applyOSTheme=function(e){var t=$('link[theme="wmtheme"][href ^="themes"][href $="/style.css"]').first();if(t.length){var n=t.attr("href").replace(new RegExp("/[a-z]*/style.css$"),"/"+e.toLowerCase()+"/style.css"),i=v.loadStyleSheet(n,{name:"theme",value:"wmtheme"});t=t.length>0&&t[0],i&&t&&(v.insertAfter(i,t),v.removeNode(t))}var o,r="android"===e.toLowerCase()?"wm-ios-styles":"wm-android-styles",a="wm-"+e.toLowerCase()+"-styles",s=$("link[href *="+r+"]").first();if(s.length||(o=!0,s=$("script[src *="+r+"]").first()),s.length){i=void 0;o?((i=(i=s.clone())[0]).src=i.src.replace(r,a),v.loadScript(i.src,!1),s=s[0],v.insertAfter(i,s),v.removeNode(s)):(i=(i=$("link[href *="+a+"]").first())[0],v.loadStyleSheet(i.href,{name:"theme",value:"wmtheme"}),v.removeNode(s[0]))}},e.prototype.handleKeyBoardClass=function(){var e=this,t=window.innerHeight;window.addEventListener("resize",(function(){window.innerHeight<t?e._$appEl.addClass(B):e._$appEl.removeClass(B)}))},e.prototype.getDeployedUrl=function(){var e=S.$rootScope.project.deployedUrl;if(v.hasCordova()){var t=$('meta[name="liveSync.deployedUrl"]').attr("value"),n=this.deviceService.getConfig();e=t||this.deviceService.getBaseUrl(),this.app.customUrlScheme=n.customUrlScheme}return"NONE"===e||e.endsWith("/")||(e+="/"),S.$rootScope.project.deployedUrl=e,e},e.prototype.addAuthInBrowser=function(){var e=this,t=!1;this.securityService.authInBrowser=function(){return e.networkService.isConnected()?t?Promise.reject("Authentication is in process."):(t=!0,e.webProcessService.execute("LOGIN","/",!0).then((function(n){return(n=JSON.parse(n&&n.replace(/&quot;/g,'"')))[S.CONSTANTS.XSRF_COOKIE_NAME]&&localStorage.setItem(S.CONSTANTS.XSRF_COOKIE_NAME,n[S.CONSTANTS.XSRF_COOKIE_NAME]),t=!1,e.cookieService.clearAll().then((function(){var t=_.keys(n).map((function(t){return e.cookieService.setCookie(e.app.deployedUrl,t,n[t])}));return Promise.all(t)}))})).then((function(){return e.app.notify("userLoggedIn",{})})).catch((function(e){return t=!1,Promise.reject(e)}))):Promise.reject("In offline, app cannot contact the server.")}},e}();V.initialized=!1,V.decorators=[{type:n.NgModule,args:[{declarations:[x],exports:[x],imports:[b.MobileCoreModule,O.VariablesModule,E.BasicModule],bootstrap:[]}]}],V.ctorParameters=function(){return[{type:v.App},{type:N},{type:b.DeviceFileOpenerService},{type:b.DeviceService},{type:P.SecurityService},{type:v.AbstractHttpService},{type:b.ExtAppMessageService},{type:b.NetworkService},{type:F}]},e.AppExtComponent=x,e.CookieService=N,e.MAX_WAIT_TIME_4_OAUTH_MESSAGE=j,e.MobileHttpInterceptor=k,e.MobileRuntimeModule=V,e.WebProcessService=F,Object.defineProperty(e,"__esModule",{value:!0})})),function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common/http"),require("@wm/mobile/components/basic"),require("@wm/mobile/components/basic/search"),require("@wm/mobile/components/containers/segmented-control"),require("@wm/mobile/components/data/media-list"),require("@wm/mobile/components/device/barcode-scanner"),require("@wm/mobile/components/device/camera"),require("@wm/mobile/components/input/file-upload"),require("@wm/mobile/components/page"),require("@wm/mobile/components/page/left-panel"),require("@wm/mobile/components/page/mobile-navbar"),require("@wm/mobile/components/page/tab-bar"),require("@awesome-cordova-plugins/file/ngx"),require("@wm/core"),require("@wm/mobile/core")):"function"==typeof define&&define.amd?define("@wm/mobile/components/runtime-dynamic",["exports","@angular/core","@angular/common/http","@wm/mobile/components/basic","@wm/mobile/components/basic/search","@wm/mobile/components/containers/segmented-control","@wm/mobile/components/data/media-list","@wm/mobile/components/device/barcode-scanner","@wm/mobile/components/device/camera","@wm/mobile/components/input/file-upload","@wm/mobile/components/page","@wm/mobile/components/page/left-panel","@wm/mobile/components/page/mobile-navbar","@wm/mobile/components/page/tab-bar","@awesome-cordova-plugins/file/ngx","@wm/core","@wm/mobile/core"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).wm=e.wm||{},e.wm.mobile=e.wm.mobile||{},e.wm.mobile.runtime=e.wm.mobile.runtime||{},e.wm.mobile.runtime.dynamic={}),e.ng.core,e.ng.common.http,e.wm.mobile.components.basic,e.wm.mobile.components.basic.search,e.wm.mobile.components.containers.segmentedcontrol,e.wm.mobile.components.data.medialist,e.wm.mobile.components.device.barcodescanner,e.wm.mobile.components.device.camera,e.wm.mobile.components.input.fileupload,e.wm.mobile.components.page,e.wm.mobile.components.page.leftpanel,e.wm.mobile.components.page.mobilenavbar,e.wm.mobile.components.page.tabbar,e.awesomeCordova.plugins,e.wm.core,e.wm.mobile.core)}(this,(function(e,t,n,i,o,r,a,s,l,c,p,u,d,h,m,f,g){"use strict";var v=function(){function e(e,t,n,i){var o=this;if(this.app=e,this.deviceService=t,this.networkService=n,this.file=i,this.urlsToSkip=[],this.deployedUrl="",this.localAppUrl="",this.syncAppUrl="",this.urlsToLoadFromLocal={"config.json":"config.json"},this.urlsToLoadFromLive={"metadata/app/service-definitions.json":"services/servicedefs","metadata/app/security-config.json":"services/security/info"},this.prefabServicePattern=/^metadata\/prefabs\/.*\/service-definitions.json$/,this.isLiveSyncEnabled=!1,this.settings={enabled:!1,position:null,show:!0,cordovaPlugins:null},this.loadSettings(),this.isLiveSyncEnabled=this.settings.enabled&&f.hasCordova(),this.deployedUrl=$('meta[name="liveSync.deployedUrl"]').attr("value"),this.localAppUrl=$('meta[name="liveSync.localAppUrl"]').attr("value"),this.syncAppUrl=$('meta[name="liveSync.syncAppUrl"]').attr("value"),this.defineAPI(),!this.isLiveSyncEnabled)return this.goToLocalApp(),void(this.deviceService.isAppConnectedToPreview()&&this.deviceService.whenReady().then((function(){o.deployedUrl=e.deployedUrl,o.networkService.isConnected()&&(o.renderUI(),o.localAppUrl||o.settings.cordovaPlugins||o.getPlugins().then((function(e){o.settings.cordovaPlugins=e,o.saveSettings()})))})));this.syncAppUrl&&this.deployedUrl?(this.deviceService.getConfig().baseUrl=this.deployedUrl,this.patchSQLite(),this.patchHistoryApi(),Object.keys(this.urlsToLoadFromLocal).forEach((function(e){o.urlsToLoadFromLocal[e]=o.syncAppUrl+o.urlsToLoadFromLocal[e]})),this.patchApp(),this.renderUI()):(window.navigator.splashscreen.hide=function(){},this.deployedUrl=e.deployedUrl,this.isLiveSyncEnabled=!1,this.deviceService.whenReady().then((function(){o.networkService.isConnected()&&o.launch()})))}return e.prototype.goToLocalApp=function(){this.localAppUrl&&(location.href=this.localAppUrl)},e.prototype.defineAPI=function(){var e=this;window.liveSync=function(t){e.settings.enabled!==!!t&&e.networkService.isConnected()&&(e.settings.enabled=!!t,e.saveSettings(),setTimeout((function(){window.navigator.splashscreen.show(),location.reload()}),100))}},e.prototype.transformPrefabServicedefinitions=function(e){var t=0;return this.prefabServicePattern.test(e)?(t="metadata/prefabs/".length,"services/prefabs/"+e.substring(t,e.indexOf("/",t))+"/servicedefs"):e},e.prototype.intercept=function(e,t){if(!this.isLiveSyncEnabled)return t.handle(e);var n=this.app.deployedUrl,i=e.url;return i=this.urlsToLoadFromLive[i]||this.urlsToLoadFromLocal[i]||i,(i=this.transformPrefabServicedefinitions(i)).startsWith("//")&&(i=n.split("//")[0]+i),(i.indexOf("://")<0||this.urlsToSkip.indexOf(i)>=0)&&(i=n+"/"+i),e=e.clone({url:i}),t.handle(e)},e.prototype.mashUpHtmlFile=function(){var e=this,t=cordova.file.cacheDirectory;return new Promise((function(t,n){$.ajax({url:e.deployedUrl+"index.html",dataType:"html",success:t,error:n})})).then((function(n){var i=location.port?":"+location.port:"",o=e.localAppUrl||location.protocol+"//"+location.hostname+i+location.pathname,r=o;if(r.endsWith(".html")){var a=r.split("/").slice(0);r=a.slice(0,a.length-1).join("/")}r+="/cordova.js";var s=location.protocol+"//"+location.hostname+i+f.transformFileURI(t+"live-index.html");return n=(n=n.replace("cordova.js",r)).replace("<head>",'\n <head>\n <base href="'+e.deployedUrl+'">\n <meta name="liveSync.deployedUrl" value="'+e.deployedUrl+'">\n <meta name="liveSync.syncAppUrl" value="'+s+'">\n <meta name="liveSync.localAppUrl" value="'+o+'">'),e.file.writeFile(t,"live-index.html",n,{replace:!0}).then((function(){return s}))}))},e.prototype.getPlugins=function(){var e=this;return new Promise((function(t,n){$.get(e.deployedUrl+"config.xml").done((function(e){var n={};$(e).find("plugin").each((function(e){n[$(this).attr("name")]=$(this).attr("spec")})),t(n)})).fail(n)}))},e.prototype.hasPluginsChanged=function(){var e=this;return this.deviceService.whenReady().then((function(){return e.getPlugins()})).then((function(t){var n=e.settings.cordovaPlugins||{};return!!Object.keys(t).find((function(e){return!n[e]||n[e]!==t[e]}))}))},e.prototype.launch=function(){return this.mashUpHtmlFile().then((function(e){localStorage.setItem("WM.NetworkService.isConnected","true"),localStorage.setItem("WM.NetworkService._autoConnect","true"),sessionStorage.setItem("debugMode","true"),setTimeout((function(){window.navigator.splashscreen.show(),window.location.href=e}),2e3)}))},e.prototype.patchSQLite=function(){delete window.SQLitePlugin},e.prototype.patchApp=function(){var e=this;this.app.reload=function(){e.networkService.isConnected()&&(window.navigator.splashscreen.show(),e.launch())},window.reloadApp=this.app.reload},e.prototype.patchHistoryApi=function(){var e=this.syncAppUrl,t=window.history.replaceState;window.history.replaceState=function(n,i,o){o.startsWith("#")&&(o=e+o),t.call(window.history,n,i,o)};var n=window.history.pushState;window.history.pushState=function(t,i,o){o.startsWith("#")&&(o=e+o),n.call(window.history,t,i,o)}},e.prototype.loadSettings=function(){var e=sessionStorage.getItem("wm.liveSync.settings");try{this.settings=e?JSON.parse(e):this.settings}catch(e){this.saveSettings()}},e.prototype.saveSettings=function(){sessionStorage.setItem("wm.liveSync.settings",JSON.stringify(this.settings))},e.prototype.renderUI=function(){var e=this;this.settings.enabled&&this.hasPluginsChanged().then((function(e){e&&new y({title:"Require new build",info:"Cordova Plugins in this app do not match with configuration of project in Studio. So, new Cordova Build is required for Live Sync to work properly.",iconClass:"fa fa-warning fa-4x live-sync-warning-icon",actions:[{title:"Got it",primary:!0}]}).render()})),new b(this.settings,(function(){e.saveSettings()})).render()},e}();v.decorators=[{type:t.Injectable}],v.ctorParameters=function(){return[{type:f.App},{type:g.DeviceService},{type:g.NetworkService},{type:m.File}]};var y=function(){function e(e){this.options=e,this.$ele=$("<div><div>")}return e.prototype.dismiss=function(){this.$ele.remove()},e.prototype.render=function(){this.$ele=$('<div class="live-sync-modal live-sync-control">\n <div class="live-sync-info-container">\n <span class="'+this.options.iconClass+'">\n </span>\n <label class="live-sync-title">\n '+this.options.title+'\n </label>\n <label class="live-sync-description"> \n '+this.options.info+'\n </label>\n <div class="live-sync-action-panel">\n '+this.options.actions.map((function(e){return e?'\n <button \n type="button"\n class="live-sync-action '+(e.primary?" live-sync-primary-action":"")+'">\n '+e.title+"\n </button>":""})).join("")+"\n </div>\n </div>\n </div>\n "),$("body").append(this.$ele);var e=this;this.$ele.find(".live-sync-action").each((function(t){$(this).bind("click",(function(){var n=e.options.actions[t].action;n&&n(e),e.dismiss()}))}))},e}(),b=function(){function e(e,t){this.settings=e,this.onChange=t,this.$ele=$('<div class="live-sync-control">\n <button class="live-sync-control-btn" type="button">\n </button>\n </div>')}return e.prototype.setPosition=function(){var e=this.$ele.find(".live-sync-control-btn"),t=this.settings.position;t&&(e.css("left",t.left+"px"),e.css("top",t.top+"px"))},e.prototype.listenForShowEvent=function(){var e=this;$("body").bind("touchstart",(function(){var t=setTimeout((function(){e.settings.show=!0,e.onChange(),e.showConfirmation()}),5e3);$("body").bind("touchend",(function(){clearTimeout(t)}))}))},e.prototype.showConfirmation=function(){var e=this;new y({title:"Enable Live Sync?",info:"App UI is pulled from studio. But, offline functionality is turned off.",iconClass:"live-sync-control-icon",actions:[{title:"No",action:function(){e.settings.show=!1,e.onChange(),e.showHelpInfo()}},{title:"Yes",action:function(){window.liveSync(!0)},primary:!0}]}).render()},e.prototype.showHelpInfo=function(){new y({title:"",info:"Tap and hold anywhere for 5 seconds to turn on Live Sync.",iconClass:"live-sync-retrieval-info-icon",actions:[{title:"Got it",primary:!0}]}).render()},e.prototype.renderButton=function(){var e=this,t=this.$ele.find(".live-sync-control-btn");this.$ele.on("touchstart",(function(n){n.stopPropagation();var i=!0;$(document).on("touchmove.liveSync",(function(n){var o=n.originalEvent.touches[0];o&&o.pageX&&(e.settings.position={left:o.pageX,top:o.pageY}),e.setPosition(),i&&(t.addClass("touched"),i=!1)})),$(document).one("touchend",(function(n){e.onChange(),t.removeClass("touched"),$(document).off("touchmove.liveSync")}))})),t.click((function(){return window.reloadApp()})),$("body").append(this.$ele)},e.prototype.render=function(){this.setPosition(),this.settings.enabled?this.renderButton():this.settings.show&&this.showConfirmation(),this.listenForShowEvent()},e}(),w=[i.BasicModule,o.SearchModule,r.SegmentedControlModule,a.MediaListModule,s.BarcodeScannerModule,l.CameraModule,c.FileUploadModule,p.PageModule,u.LeftPanelModule,d.MobileNavbarModule,h.TabBarModule],P=function(){};P.decorators=[{type:t.NgModule,args:[{providers:[{provide:n.HTTP_INTERCEPTORS,useClass:v,multi:!0}]}]}],e.MOBILE_COMPONENT_MODULES_FOR_ROOT=w,e.MobileRuntimeDynamicModule=P,e["\u0275a"]=v,Object.defineProperty(e,"__esModule",{value:!0})})),function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/router"),require("@angular/common"),require("@wm/core"),require("@wm/security"),require("@wm/variables"),require("@wm/components/page"),require("rxjs"),require("@wm/components/base"),require("@wm/components/prefab"),require("@angular/common/http"),require("@angular/platform-browser"),require("ngx-toastr"),require("@wm/components/dialogs"),require("@wm/components/dialogs/confirm-dialog"),require("@wm/components/dialogs/design-dialog"),require("@wm/mobile/runtime"),require("@wm/http"),require("@wm/oAuth"),require("ngx-bootstrap/chronos"),require("ngx-bootstrap/datepicker"),require("ngx-bootstrap/utils"),require("rxjs/operators"),require("@wm/transpiler"),require("@wm/build-task")):"function"==typeof define&&define.amd?define("@wm/runtime/base",["exports","@angular/core","@angular/router","@angular/common","@wm/core","@wm/security","@wm/variables","@wm/components/page","rxjs","@wm/components/base","@wm/components/prefab","@angular/common/http","@angular/platform-browser","ngx-toastr","@wm/components/dialogs","@wm/components/dialogs/confirm-dialog","@wm/components/dialogs/design-dialog","@wm/mobile/runtime","@wm/http","@wm/oAuth","ngx-bootstrap/chronos","ngx-bootstrap/datepicker","ngx-bootstrap/utils","rxjs/operators","@wm/transpiler","@wm/build-task"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).wm=e.wm||{},e.wm.runtime=e.wm.runtime||{},e.wm.runtime.base={}),e.ng.core,e.ng.router,e.ng.common,e.wm.core,e.wm.security,e.wm.variables,e.wm.components.page,e.rxjs,e.wm.components.base,e.wm.components.prefab,e.ng.common.http,e.ng.platformBrowser,e.ngxToastr,e.wm.components.dialogs,e.wm.components.dialogs.confirmdialog,e.wm.components.dialogs.designdialog,e.wm.mobile.runtime,e.wm.http,e.wm.oAuth,e["ngx-bootstrap"].chronos,e["ngx-bootstrap"].datepicker,e["ngx-bootstrap"].utils,e.rxjs.operators,e.wm.transpiler,e.wm.buildTask)}(this,(function(e,t,n,i,o,r,a,s,l,c,p,u,d,h,m,f,g,v,y,b,w,P,O,S,E,T){"use strict";function R(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var C,A=R(t),I=R(o),D=R(d);e.ComponentType=void 0,(C=e.ComponentType||(e.ComponentType={}))[C.PAGE=0]="PAGE",C[C.PREFAB=1]="PREFAB",C[C.PARTIAL=2]="PARTIAL";var N,x=function(){function e(){}return e.prototype.clearComponentFactoryRefCache=function(){},e}(),k=function(){},M=function(){},L=function(){},F=function(){};!function(e){e.HIDE_TEMPLATES_SHOW_CASE="hide-templates-show-case",e.SHOW_TEMPLATES_SHOW_CASE="show-templates-show-case",e.UPDATE_LOCATION="update-location-path",e.SELECT_TEMPLATE="select-template",e.TEMPLATEBUNDLE_CONFIG="template-bundle-config",e.ON_LOAD="on-load"}(N||(N={}));var j=function(){function e(e,t,n,i,o,r,a,s,l,c){var p=this;this.$http=e,this.$security=t,this.$dialog=n,this.$router=i,this.$app=o,this.$variables=r,this.$metadata=a,this.$spinner=s,this.$i18n=l,this.$datePipe=c,this.appVariablesLoaded=!1,this.appVariablesFired=!1,this._noRedirect=!1,this.$http.registerOnSessionTimeout(this.handle401.bind(this)),this.$variables.registerDependency("appManager",this),this.$app.subscribe("toggle-variable-state",(function(e){var t,n=e.variable,i=e.active;if(!_.isEmpty(_.trim(n.spinnerContext)))if(i){if(n._spinnerId&&n._spinnerId.length&&_.forEach(n._spinnerId,(function(e){e.slice(0,e.lastIndexOf("_"))!==n._id||!p.$spinner.messagesByContext||!p.$spinner.messagesByContext[n.spinnerContext]||n.spinnerMessage!==p.$spinner.messagesByContext[n.spinnerContext].finalMessage&&n.spinnerMessage!==p.$spinner.messagesByContext[n.spinnerContext][e]||(t=!0)})),!t){n._spinnerId=n._spinnerId||[];var o=p.$spinner.show(n.spinnerMessage,n._id+"_"+Date.now(),n.spinnerclass,n.spinnerContext);n._spinnerId.push(o)}}else p.$spinner.hide(n._spinnerId.shift())})),this.$app.subscribe("userLoggedIn",(function(){p.setLandingPage(),p.lastLoggedUserId&&p.$security.getConfig((function(e){e&&e.userInfo.userId!==p.lastLoggedUserId&&p.$app.clearPageCache()}),null)})),this.$app.subscribe("userLoggedOut",(function(){return p.setLandingPage().then((function(){p.$app.clearPageCache()}))})),this.$app.subscribe("http401",(function(e){return void 0===e&&(e={}),p.handle401(e.page,e.options)}))}return e.prototype.showLoginDialog=function(){this.$spinner.hide("globalSpinner"),this.$dialog.open("CommonLoginDialog"),o.$appDigest()},e.prototype.loadAppJS=function(){},e.prototype.loadCommonPage=function(){},e.prototype.loadSecurityConfig=function(e){var t=this;return this.$security.load(e).then((function(e){return t.$app.landingPageName||t.setLandingPage(),e}))},e.prototype.loadMetadata=function(){return this.$metadata.load()},e.prototype.loadAppVariables=function(e){var t=this;if(this.appVariablesLoaded)return Promise.resolve();var n=function(e){var n=t.$variables.register("app",e,t.$app);_.extend(t.$app.Variables,n.Variables),_.extend(t.$app.Actions,n.Actions),t.updateLoggedInUserVariable(),t.updateSupportedLocaleVariable(),t.appVariablesLoaded=!0,t.appVariablesFired=!1};return o.isDefined(e)?(n(e),Promise.resolve()):this.$http.get("./app.variables.json").then((function(e){return n(e)}))},e.prototype.isAppVariablesFired=function(e){return o.isDefined(e)&&(this.appVariablesFired=e),this.appVariablesFired},e.prototype.clearLoggedInUserVariable=function(e){e.isAuthenticated=!1,e.roles=[],e.name=void 0,e.id=void 0,e.tenantId=void 0},e.prototype.updateLoggedInUserVariable=function(){var e=this,t=_.get(this.$app,"Variables.loggedInUser.dataSet");if(t)return this.$security.load().then((function(){var n=e.$security.get();if(!(n&&n.securityEnabled&&n.authenticated))throw e.clearLoggedInUserVariable(t),t.isSecurityEnabled=n&&n.securityEnabled,null;return t.isAuthenticated=n.authenticated,t.roles=n.userInfo.userRoles,t.name=n.userInfo.userName,t.id=n.userInfo.userId,t.tenantId=n.userInfo.tenantId,t.userAttributes=n.userInfo.userAttributes,n})).catch((function(e){t.isAuthenticated=!1,t.roles=[],t.name=void 0,t.id=void 0,t.tenantId=void 0,t.userAttributes={}}))},e.prototype.updateSupportedLocaleVariable=function(){_.get(this.$app,"Variables.supportedLocale")},e.prototype.handleSSOLogin=function(e){var t,n,i=this;if(t=this.$security.getRedirectPage(e),a.CONSTANTS.hasCordova){var o=_.get(this.$security.get(),"userInfo.userName");this.$security.authInBrowser().then((function(){return i.reloadAppData()})).then((function(){var e=_.get(i.$security.get(),"userInfo.userName");e&&e===o?a.routerService.navigate([t]):a.routerService.navigate(["/"])}))}else{t=t?"?redirectPage="+encodeURIComponent(t):"",n=(n=this.$security.getQueryString(this.$security.getRedirectedRouteQueryParams()))?"?"+n:"",document.body.textContent=_.get(this.getAppLocale(),["MESSAGE_LOGIN_REDIRECTION"])||"Redirecting to sso login...";var r=this.getDeployedURL()+"services/security/ssologin"+t+n;window.self!==window.top&&"WM_PREVIEW_WINDOW"===window.parent.name?(window.parent.location.href=window.self.location.href,window.parent.name=""):window.location.href=r}},e.prototype.handle401=function(e,t){var n,i,o="DIALOG",r="PAGE",a="SSO",s=this.$security.get(),l={};if(i=s.loginConfig,this.lastLoggedUserId=s.userInfo&&s.userInfo.userId,s.userInfo&&s.userInfo.userName){switch(s.authenticated=!1,(n=i.sessionTimeout||{type:o}).type.toUpperCase()){case o:this.showLoginDialog();break;case r:e||(e=this.$security.getCurrentRoutePage()),l.redirectTo=e,l=_.merge(l,this.$security.getRedirectedRouteQueryParams()),e!==n.pageName&&this.$router.navigate([n.pageName],{queryParams:l});break;case a:this.handleSSOLogin(s)}this.setLandingPage()}else switch(i.type.toUpperCase()){case o:this.noRedirect(!0),this.showLoginDialog();break;case r:e=this.$security.getRedirectPage(s,e),l.redirectTo=e;var c=t&&t.queryParams||this.$security.getRedirectedRouteQueryParams();l=_.merge(l,c),this.$router.navigate([i.pageName],{queryParams:l}),this.$app.landingPageName=i.pageName;break;case a:this.handleSSOLogin(s)}},e.prototype.reloadAppData=function(){var e=this;return this.loadSecurityConfig(!0).then((function(){return e.loadMetadata().then((function(){return e.updateLoggedInUserVariable()}))}))},e.prototype.noRedirect=function(e){return _.isUndefined(e)||(this._noRedirect=e),this._noRedirect},e.prototype.executeSessionFailureRequests=function(){this.$http.executeSessionFailureRequests()},e.prototype.pushToSessionFailureRequests=function(e){this.$http.pushToSessionFailureQueue(e)},e.prototype.getDeployedURL=function(){return this.$app.deployedUrl?this.$app.deployedUrl:a.$rootScope.project.deployedUrl},e.prototype.getCustomUrlScheme=function(){return this.$app.customUrlScheme},e.prototype.notify=function(e,t){this.$app.notify(e,t)},e.prototype.subscribe=function(e,t){return this.$app.subscribe(e,t)},e.prototype.getActivePage=function(){return this.$app.activePage},e.prototype.getAppLocale=function(){return this.$app.appLocale},e.prototype.getSelectedLocale=function(){return this.$i18n.getSelectedLocale()},e.prototype.notifyApp=function(e,t,n){this.$app.notifyApp(e,t,n)},e.prototype.appOnBeforeServiceCall=function(e){return o.triggerFn(this.$app.onBeforeServiceCall,e)},e.prototype.appOnServiceSuccess=function(e,t){return o.triggerFn(this.$app.onServiceSuccess,e,t)},e.prototype.appOnServiceError=function(e,t){return o.triggerFn(this.$app.onServiceError,e,t)},e.prototype.appVariablesReady=function(){o.triggerFn(this.$app.onAppVariablesReady)},e.prototype.beforeAppReady=function(){o.triggerFn(this.$app.onBeforeAppReady)},e.prototype.getPipe=function(e){if("date"===e)return this.$datePipe},e.prototype.setLandingPage=function(){var e=this;return this.$security.getPageByLoggedInUser().then((function(t){return e.$app.landingPageName=t}))},e.prototype.isPrefabType=function(){return this.$app.isPrefabType},e.prototype.isTemplateBundleType=function(){return this.$app.isTemplateBundleType},e.prototype.postMessage=function(e){window.top.postMessage(e,"*")},e.prototype.showTemplate=function(e){var t=this.templates[e];this.$router.navigate([t.id])},e.prototype.postTemplateBundleInfo=function(){var e=this;return window.onmessage=function(t){var n=t.data;if(_.isObject(n))switch(n.key){case N.HIDE_TEMPLATES_SHOW_CASE:break;case N.SELECT_TEMPLATE:e.showTemplate(n.templateIndex)}},setTimeout((function(){e.postMessage({key:N.ON_LOAD})})),o.fetchContent("json","./config.json",!0,(function(t){e.templates=[],t.error||(e.templates=t.templates,e.postMessage({key:N.TEMPLATEBUNDLE_CONFIG,config:t}))}))},e.prototype.postAppTypeInfo=function(){if(this.isTemplateBundleType())return this.postTemplateBundleInfo()},e}();j.SERVICE_NAME="AppManagerService",j.decorators=[{type:t.Injectable}],j.ctorParameters=function(){return[{type:o.AbstractHttpService},{type:r.SecurityService},{type:o.AbstractDialogService},{type:n.Router},{type:o.App},{type:a.VariablesService},{type:a.MetadataService},{type:o.AbstractSpinnerService},{type:o.AbstractI18nService},{type:i.DatePipe}]};var B=function(e){return"__self__"===e},G=function(e){return B(e)?".":"app/prefabs/"+e},V=new Set,U=new Map,W=new Set,q=function(e,t){var n=e;return o.stringStartsWith(e,"http://|https://|//")||(n=(t+n).replace("//","/")),n},z=q,H=function(){function e(e,t){this.$metadata=e,this.prefabConfigProvider=t}return e.prototype.getConfig=function(e){return this.prefabConfigProvider.getConfig(e)},e.prototype.loadServiceDefs=function(e){return B(e)?Promise.resolve():this.$metadata.load(e)},e.prototype.loadStyles=function(e,t){var n=(void 0===t?{resources:{styles:[]}}:t).resources.styles,i=G(e),r=n.map((function(e){if(!_.endsWith(e,"/pages/Main/Main.css"))return q(e,i)})).filter((function(e){return!!e}));return o.loadStyleSheets(r),Promise.resolve()},e.prototype.loadScripts=function(e,t){var n=(void 0===t?{resources:{scripts:[]}}:t).resources.scripts,i=G(e),r=n.map((function(e){return q(e,i)}));return o.loadScripts(r,!0)},e.prototype.setInProgress=function(e){var t,n,i=new Promise((function(e,i){t=e,n=i}));i.resolve=t,i.reject=n,U.set(e,i)},e.prototype.resolveInProgress=function(e){U.get(e)&&(U.get(e).resolve(),U.delete(e))},e.prototype.loadDependencies=function(e){var t=this;return W.has(e)?Promise.resolve():V.has(e)?Promise.reject(""):U.get(e)?U.get(e):(this.setInProgress(e),this.getConfig(e).then((function(n){return Promise.all([t.loadStyles(e,n),t.loadScripts(e,n),t.loadServiceDefs(e)]).then((function(){t.resolveInProgress(e),W.add(e)}))})))},e}();H.decorators=[{type:t.Injectable}],H.ctorParameters=function(){return[{type:a.MetadataService},{type:k}]};
858
+ ***************************************************************************** */Object.create;function A(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,o,r=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function I(e,t,n){if(n||2===arguments.length)for(var i,o=0,r=t.length;o<r;o++)!i&&o in t||(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}Object.create;var D="wavemaker.persistedcookies",N=function(){function e(){this.cookieInfo={},this.serviceName="CookeService"}return e.prototype.persistCookie=function(e,t,n){var i=this;return new Promise((function(o,r){n?o(n):i.getCookie(e,t).then((function(e){return o(e.cookieValue)}),r)})).then((function(n){i.cookieInfo[e+"-"+t]={hostname:e.replace(/:[0-9]+/,""),name:t,value:i.rotateLTR(n)},localStorage.setItem(D,JSON.stringify(i.cookieInfo))}))},e.prototype.getCookie=function(e,t){return new Promise((function(n,i){if(v.isIos()){var o=window.cordova.plugin.http.getCookieString(e);if(o){var r=o.indexOf(t);if(r>=0){var a=r+t.length+1,s=o.indexOf(";",a);return void n({cookieValue:o.substring(a,s>=0?s:void 0)})}}i()}else window.cookieEmperor.getCookie(e,t,n,i)}))},e.prototype.setCookie=function(e,t,n){return new Promise((function(i,o){if(v.isIos()){var r=t+"="+n;window.cordova.plugin.http.setCookie(e,r),i()}else window.cookieEmperor.setCookie(e,t,n,i,o)}))},e.prototype.clearAll=function(){return new Promise((function(e,t){v.isIos()?(window.cordova.plugin.http.clearCookies(),e("")):window.cookieEmperor.clearAll(e,t)}))},e.prototype.start=function(){var e=this,t=localStorage.getItem(D),n=[];if(t){var i=JSON.parse(t);_.forEach(i,(function(t){t.name&&t.value&&n.push(e.getCookie(t.hostname,t.name).catch((function(){return new Promise((function(n,i){window.cookieEmperor.setCookie(t.hostname,t.name,e.rotateRTL(t.value),n,i)}))})))}))}return Promise.all(n)},e.prototype.getServiceName=function(){return e.SERVICE_NAME},e.prototype.rotateLTR=function(e){var t=e.split(""),n=[],i=Math.floor(e.length/3);return t.forEach((function(e,o){n[(o+i)%t.length]=t[o]})),n.join("")},e.prototype.rotateRTL=function(e){var t=e.split(""),n=[],i=Math.floor(e.length/3);return t.forEach((function(e,o){n[(t.length+o-i)%t.length]=t[o]})),n.join("")},e}();N.SERVICE_NAME="CookieService",N.\u0275prov=C.\u0275\u0275defineInjectable({factory:function(){return new N},token:N,providedIn:"root"}),N.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}];var x=function(){function e(e,t,n){this.elRef=e,this.fileSelectorService=t,this.processManagementService=n}return e.prototype.ngAfterViewInit=function(){var e=$(this.elRef.nativeElement).find(">[wmNetworkInfoToaster], >[wmAppUpdate], >[wmMobileFileBrowser]"),t=$("body");v.hasCordova()?(e.appendTo(t),this.fileSelectorService.setFileBrowser(this.fileBrowserComponent)):e.remove(),$(this.elRef.nativeElement).find(">[wmProgressManager]").appendTo(t),this.processManagementService.setUIComponent(this.processManagerComponent)},e}();x.decorators=[{type:n.Component,args:[{selector:"[wmAppExt]",template:"<ng-container> \n <div wmNetworkInfoToaster></div>\n <div wmAppUpdate></div>\n <div wmMobileFileBrowser></div>\n <div wmProcessManager></div>\n </ng-container>"}]}],x.ctorParameters=function(){return[{type:n.ElementRef},{type:E.FileSelectorService},{type:E.ProcessManagementService}]},x.propDecorators={fileBrowserComponent:[{type:n.ViewChild,args:[E.FileBrowserComponent]}],processManagerComponent:[{type:n.ViewChild,args:[E.ProcessManagerComponent]}]};var k=function(){function e(e,t,n,i,o,r){this.app=e,this.deviceService=i,this.networkService=o,this.requestInterceptors=[],v.hasCordova()&&(this.requestInterceptors.push(new L(e,t,r)),this.requestInterceptors.push(new M(e)))}return e.prototype.intercept=function(e,t){var n=this,i=(new T.Subject,localStorage.getItem(S.CONSTANTS.XSRF_COOKIE_NAME)),o=v.getWmProjectProperties().xsrf_header_name;i&&o&&this.app.deployedUrl&&(e.url.indexOf("://")<0||e.url.startsWith(this.app.deployedUrl))&&(e=e.clone({headers:e.headers.set(o,i)}));var r={request:e};return T.from(this.deviceService.whenReady().then((function(){return v.executePromiseChain(n.getInterceptors(),[r])}))).pipe(R.mergeMap((function(){return t.handle(r.request)})))},e.prototype.getInterceptors=function(){return this.requestInterceptors.map((function(e){return function(t){return e.intercept(t.request).then((function(e){return t.request=e}))}}))},e.prototype.onHttpError=function(e){v.hasCordova&&(!e||!e.status||e.status<0||404===e.status)&&this.networkService.isConnected()&&this.networkService.isAvailable(!0)},e}();k.decorators=[{type:n.Injectable}],k.ctorParameters=function(){return[{type:v.App},{type:s.File},{type:b.DeviceFileDownloadService},{type:b.DeviceService},{type:b.NetworkService},{type:P.SecurityService}]};var M=function(){function e(e){this.app=e}return e.prototype.intercept=function(t){var n=t,i=t.url;return i.indexOf("://")<0&&e.REMOTE_SERVICE_URL_PATTERNS.find((function(e){return e.test(i)}))&&(i=this.app.deployedUrl+i),(i=v.removeExtraSlashes(i))!==t.url&&(n=t.clone({url:i})),Promise.resolve(n)},e}();M.REMOTE_SERVICE_URL_PATTERNS=[new RegExp("^((./)|/)?services/"),new RegExp("j_spring_security_check"),new RegExp("j_spring_security_logout")];var L=function(){function e(e,t,n){this.app=e,this.file=t,this.securityService=n,this.initialized=!1}return e.prototype.intercept=function(t){var n=this;return new Promise((function(i,o){return!e.PREFAB_URL_PATTERN.test(t.url)&&e.PAGE_URL_PATTERN.test(t.url)?Promise.resolve().then((function(){if(!n.initialized)return n.init()})).then((function(){var e=_.split(t.url,"/"),r=e[e.length-2];return!n.publicPages||n.publicPages[r]||n.securityService.getConfig((function(e){!e.securityEnabled||e.authenticated?i(t):(o("Page '"+r+"' is not accessible to the user."),n.app.notify("http401",{page:r}))}),(function(){return o("Security call failed.")})),Promise.resolve(t)})).then(i,o):i(t)}))},e.prototype.init=function(){var e=this,t=cordova.file.applicationDirectory+"www/metadata/app";return this.file.readAsText(t,"public-pages.json").then((function(t){e.initialized||(e.publicPages={},e.initialized=!0,_.forEach(JSON.parse(t),(function(t){return e.publicPages[t]=!0})))})).catch((function(){e.initialized=!0}))},e}();L.PAGE_URL_PATTERN=new RegExp("page.min.json$"),L.PREFAB_URL_PATTERN=new RegExp("^app/prefabs/.*/page.min.json$");var F=function(){function e(e,t,n){this.app=e,this.httpService=t,this.extAppMessageService=n}return e.prototype.execute=function(e,t,n){var i=this;return void 0===n&&(n=!1),this.httpService.get("/services/webprocess/prepare?processName="+e+"&hookUrl="+t+"&requestSourceType=MOBILE").then((function(t){return n?i.executeWithSystemBrowser(t):i.executeWithInAppBrowser(t,e)})).then((function(e){return i.httpService.get("/services/webprocess/decode?encodedProcessdata="+e)}))},e.prototype.executeWithSystemBrowser=function(e){var t=this;return new Promise((function(n){var i=t.extAppMessageService.subscribe("^services/webprocess/LOGIN",(function(e){n(e.data.process_output),i()}));window.open(t.app.deployedUrl+"services/webprocess/start?process="+encodeURIComponent(e),"_system")}))},e.prototype.executeWithInAppBrowser=function(e,t){var n=this;return new Promise((function(i,o){var r=cordova.InAppBrowser.open(n.app.deployedUrl+"services/webprocess/start?process="+encodeURIComponent(e),"_blank","location=yes,clearcache=yes"),a=!1;r.addEventListener("loadstop",(function(){r.executeScript({code:n.getScriptToInject(t)},(function(e){e&&e[0]&&(a=!0,r.close(),i(e[0]))}))})),r.addEventListener("exit",(function(){a||o("Login process is stopped")}))}))},e.prototype.getScriptToInject=function(e){return"\n (function() {\n var elements = document.querySelectorAll('body.flex>a.link');\n for (var i = 0; i < elements.length; i++) {\n var href = elements[i].href;\n if (href && href.indexOf('://services/webprocess/"+e+"?process_output=')) {\n return href.split('process_output=')[1];\n }\n }\n window.isWebLoginProcess = true;\n })();\n "},e}();F.decorators=[{type:n.Injectable}],F.ctorParameters=function(){return[{type:v.App},{type:v.AbstractHttpService},{type:b.ExtAppMessageService}]};var j=6e4,B="keyboard",G=[i.AppVersion,o.BarcodeScanner,r.Calendar,a.Camera,s.File,l.FileOpener,c.Device,u.Geolocation,p.MediaCapture,d.Network,h.SQLite,m.Vibration,f.LocationAccuracy,g.Diagnostic],V=function(){function e(t,n,i,o,r,a,s,l,c){var p=this;this.app=t,this.cookieService=n,this.deviceFileOpenerService=i,this.deviceService=o,this.securityService=r,this.httpService=a,this.extAppMessageService=s,this.networkService=l,this.webProcessService=c,this._$appEl=$(".wm-app").first(),this._$appEl.width()>=768?(t.isTabletApplicationType=!0,this._$appEl.addClass("wm-tablet-app")):this._$appEl.addClass("wm-mobile-app"),t.subscribe("on-viewport-details",(function(e){p.applyOSTheme(e)})),e.initializeRuntime(this,this.app,this.deviceFileOpenerService,this.deviceService)}return e.forRoot=function(){return{ngModule:e,providers:I(I([F,{provide:t.HTTP_INTERCEPTORS,useClass:k,multi:!0}],A(G)),[y.FileExtensionFromMimePipe,{provide:w.PushService,useClass:w.PushServiceImpl}])}},e.initializeRuntime=function(e,t,n,i){if(!this.initialized){if(this.initialized=!0,t.deployedUrl=e.getDeployedUrl(),v.hasCordova()){var o=t.subscribe("pageReady",(function(e){navigator.splashscreen.hide(),o()}));t.subscribe("userLoggedIn",(function(){cordova&&cordova.wavemaker.syncCookies()})),e.handleKeyBoardClass(),t.subscribe("device-file-download",(function(e){n.openRemoteFile(e.url,e.extension,e.name,e.headers).then(e.successCb,e.errorCb)}));var r=window.__zone_symbol__FileReader;r&&r.READ_CHUNK_SIZE&&(window.FileReader=r),window.open=window.cordova.InAppBrowser.open,e.addAuthInBrowser()}i.start(),i.whenReady().then((function(){v.hasCordova()&&(e._$appEl.addClass("cordova"),e.exposeOAuthService(),window.StatusBar&&window.StatusBar.overlaysWebView(!1))}))}},e.prototype.exposeOAuthService=function(){var e=this;window.OAuthInMobile=function(t){return new Promise((function(n,i){var o="^services/oauth/"+t+"$",r=e.extAppMessageService.subscribe(o,(function(e){n(e.data.access_token),r(),clearTimeout(a)})),a=setTimeout((function(){r(),i("Time out for oauth message after 0 seconds")}),j)}))};var t=window.handleOpenURL;t.isReady=!0,t(t.lastURL)},e.prototype.applyOSTheme=function(e){var t=$('link[theme="wmtheme"][href ^="themes"][href $="/style.css"]').first();if(t.length){var n=t.attr("href").replace(new RegExp("/[a-z]*/style.css$"),"/"+e.toLowerCase()+"/style.css"),i=v.loadStyleSheet(n,{name:"theme",value:"wmtheme"});t=t.length>0&&t[0],i&&t&&(v.insertAfter(i,t),v.removeNode(t))}var o,r="android"===e.toLowerCase()?"wm-ios-styles":"wm-android-styles",a="wm-"+e.toLowerCase()+"-styles",s=$("link[href *="+r+"]").first();if(s.length||(o=!0,s=$("script[src *="+r+"]").first()),s.length){i=void 0;o?((i=(i=s.clone())[0]).src=i.src.replace(r,a),v.loadScript(i.src,!1),s=s[0],v.insertAfter(i,s),v.removeNode(s)):(i=(i=$("link[href *="+a+"]").first())[0],v.loadStyleSheet(i.href,{name:"theme",value:"wmtheme"}),v.removeNode(s[0]))}},e.prototype.handleKeyBoardClass=function(){var e=this,t=window.innerHeight;window.addEventListener("resize",(function(){window.innerHeight<t?e._$appEl.addClass(B):e._$appEl.removeClass(B)}))},e.prototype.getDeployedUrl=function(){var e=S.$rootScope.project.deployedUrl;if(v.hasCordova()){var t=$('meta[name="liveSync.deployedUrl"]').attr("value"),n=this.deviceService.getConfig();e=t||this.deviceService.getBaseUrl(),this.app.customUrlScheme=n.customUrlScheme}return"NONE"===e||e.endsWith("/")||(e+="/"),S.$rootScope.project.deployedUrl=e,e},e.prototype.addAuthInBrowser=function(){var e=this,t=!1;this.securityService.authInBrowser=function(){return e.networkService.isConnected()?t?Promise.reject("Authentication is in process."):(t=!0,e.webProcessService.execute("LOGIN","/",!0).then((function(n){return(n=JSON.parse(n&&n.replace(/&quot;/g,'"')))[S.CONSTANTS.XSRF_COOKIE_NAME]&&localStorage.setItem(S.CONSTANTS.XSRF_COOKIE_NAME,n[S.CONSTANTS.XSRF_COOKIE_NAME]),t=!1,e.cookieService.clearAll().then((function(){var t=_.keys(n).map((function(t){return e.cookieService.setCookie(e.app.deployedUrl,t,n[t])}));return Promise.all(t)}))})).then((function(){return e.app.notify("userLoggedIn",{})})).catch((function(e){return t=!1,Promise.reject(e)}))):Promise.reject("In offline, app cannot contact the server.")}},e}();V.initialized=!1,V.decorators=[{type:n.NgModule,args:[{declarations:[x],exports:[x],imports:[b.MobileCoreModule,O.VariablesModule,E.BasicModule],bootstrap:[]}]}],V.ctorParameters=function(){return[{type:v.App},{type:N},{type:b.DeviceFileOpenerService},{type:b.DeviceService},{type:P.SecurityService},{type:v.AbstractHttpService},{type:b.ExtAppMessageService},{type:b.NetworkService},{type:F}]},e.AppExtComponent=x,e.CookieService=N,e.MAX_WAIT_TIME_4_OAUTH_MESSAGE=j,e.MobileHttpInterceptor=k,e.MobileRuntimeModule=V,e.WebProcessService=F,Object.defineProperty(e,"__esModule",{value:!0})})),function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common/http"),require("@wm/mobile/components/basic"),require("@wm/mobile/components/basic/search"),require("@wm/mobile/components/containers/segmented-control"),require("@wm/mobile/components/data/media-list"),require("@wm/mobile/components/device/barcode-scanner"),require("@wm/mobile/components/device/camera"),require("@wm/mobile/components/input/file-upload"),require("@wm/mobile/components/page"),require("@wm/mobile/components/page/left-panel"),require("@wm/mobile/components/page/mobile-navbar"),require("@wm/mobile/components/page/tab-bar"),require("@awesome-cordova-plugins/file/ngx"),require("@wm/core"),require("@wm/mobile/core")):"function"==typeof define&&define.amd?define("@wm/mobile/components/runtime-dynamic",["exports","@angular/core","@angular/common/http","@wm/mobile/components/basic","@wm/mobile/components/basic/search","@wm/mobile/components/containers/segmented-control","@wm/mobile/components/data/media-list","@wm/mobile/components/device/barcode-scanner","@wm/mobile/components/device/camera","@wm/mobile/components/input/file-upload","@wm/mobile/components/page","@wm/mobile/components/page/left-panel","@wm/mobile/components/page/mobile-navbar","@wm/mobile/components/page/tab-bar","@awesome-cordova-plugins/file/ngx","@wm/core","@wm/mobile/core"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).wm=e.wm||{},e.wm.mobile=e.wm.mobile||{},e.wm.mobile.runtime=e.wm.mobile.runtime||{},e.wm.mobile.runtime.dynamic={}),e.ng.core,e.ng.common.http,e.wm.mobile.components.basic,e.wm.mobile.components.basic.search,e.wm.mobile.components.containers.segmentedcontrol,e.wm.mobile.components.data.medialist,e.wm.mobile.components.device.barcodescanner,e.wm.mobile.components.device.camera,e.wm.mobile.components.input.fileupload,e.wm.mobile.components.page,e.wm.mobile.components.page.leftpanel,e.wm.mobile.components.page.mobilenavbar,e.wm.mobile.components.page.tabbar,e.awesomeCordova.plugins,e.wm.core,e.wm.mobile.core)}(this,(function(e,t,n,i,o,r,a,s,l,c,p,u,d,h,m,f,g){"use strict";var v=function(){function e(e,t,n,i){var o=this;if(this.app=e,this.deviceService=t,this.networkService=n,this.file=i,this.urlsToSkip=[],this.deployedUrl="",this.localAppUrl="",this.syncAppUrl="",this.urlsToLoadFromLocal={"config.json":"config.json"},this.urlsToLoadFromLive={"metadata/app/service-definitions.json":"services/servicedefs","metadata/app/security-config.json":"services/security/info"},this.prefabServicePattern=/^metadata\/prefabs\/.*\/service-definitions.json$/,this.isLiveSyncEnabled=!1,this.settings={enabled:!1,position:null,show:!0,cordovaPlugins:null},this.loadSettings(),this.isLiveSyncEnabled=this.settings.enabled&&f.hasCordova(),this.deployedUrl=$('meta[name="liveSync.deployedUrl"]').attr("value"),this.localAppUrl=$('meta[name="liveSync.localAppUrl"]').attr("value"),this.syncAppUrl=$('meta[name="liveSync.syncAppUrl"]').attr("value"),this.defineAPI(),!this.isLiveSyncEnabled)return this.goToLocalApp(),void(this.deviceService.isAppConnectedToPreview()&&this.deviceService.whenReady().then((function(){o.deployedUrl=e.deployedUrl,o.networkService.isConnected()&&(o.renderUI(),o.localAppUrl||o.settings.cordovaPlugins||o.getPlugins().then((function(e){o.settings.cordovaPlugins=e,o.saveSettings()})))})));this.syncAppUrl&&this.deployedUrl?(this.deviceService.getConfig().baseUrl=this.deployedUrl,this.patchSQLite(),this.patchHistoryApi(),Object.keys(this.urlsToLoadFromLocal).forEach((function(e){o.urlsToLoadFromLocal[e]=o.syncAppUrl+o.urlsToLoadFromLocal[e]})),this.patchApp(),this.renderUI()):(window.navigator.splashscreen.hide=function(){},this.deployedUrl=e.deployedUrl,this.isLiveSyncEnabled=!1,this.deviceService.whenReady().then((function(){o.networkService.isConnected()&&o.launch()})))}return e.prototype.goToLocalApp=function(){this.localAppUrl&&(location.href=this.localAppUrl)},e.prototype.defineAPI=function(){var e=this;window.liveSync=function(t){e.settings.enabled!==!!t&&e.networkService.isConnected()&&(e.settings.enabled=!!t,e.saveSettings(),setTimeout((function(){window.navigator.splashscreen.show(),location.reload()}),100))}},e.prototype.transformPrefabServicedefinitions=function(e){var t=0;return this.prefabServicePattern.test(e)?(t="metadata/prefabs/".length,"services/prefabs/"+e.substring(t,e.indexOf("/",t))+"/servicedefs"):e},e.prototype.intercept=function(e,t){if(!this.isLiveSyncEnabled)return t.handle(e);var n=this.app.deployedUrl,i=e.url;return i=this.urlsToLoadFromLive[i]||this.urlsToLoadFromLocal[i]||i,(i=this.transformPrefabServicedefinitions(i)).startsWith("//")&&(i=n.split("//")[0]+i),(i.indexOf("://")<0||this.urlsToSkip.indexOf(i)>=0)&&(i=n+"/"+i),e=e.clone({url:i}),t.handle(e)},e.prototype.mashUpHtmlFile=function(){var e=this,t=cordova.file.cacheDirectory;return new Promise((function(t,n){$.ajax({url:e.deployedUrl+"index.html",dataType:"html",success:t,error:n})})).then((function(n){var i=location.port?":"+location.port:"",o=e.localAppUrl||location.protocol+"//"+location.hostname+i+location.pathname,r=o;if(r.endsWith(".html")){var a=r.split("/").slice(0);r=a.slice(0,a.length-1).join("/")}r+="/cordova.js";var s=location.protocol+"//"+location.hostname+i+f.transformFileURI(t+"live-index.html");return n=(n=n.replace("cordova.js",r)).replace("<head>",'\n <head>\n <base href="'+e.deployedUrl+'">\n <meta name="liveSync.deployedUrl" value="'+e.deployedUrl+'">\n <meta name="liveSync.syncAppUrl" value="'+s+'">\n <meta name="liveSync.localAppUrl" value="'+o+'">'),e.file.writeFile(t,"live-index.html",n,{replace:!0}).then((function(){return s}))}))},e.prototype.getPlugins=function(){var e=this;return new Promise((function(t,n){$.get(e.deployedUrl+"config.xml").done((function(e){var n={};$(e).find("plugin").each((function(e){n[$(this).attr("name")]=$(this).attr("spec")})),t(n)})).fail(n)}))},e.prototype.hasPluginsChanged=function(){var e=this;return this.deviceService.whenReady().then((function(){return e.getPlugins()})).then((function(t){var n=e.settings.cordovaPlugins||{};return!!Object.keys(t).find((function(e){return!n[e]||n[e]!==t[e]}))}))},e.prototype.launch=function(){return this.mashUpHtmlFile().then((function(e){localStorage.setItem("WM.NetworkService.isConnected","true"),localStorage.setItem("WM.NetworkService._autoConnect","true"),sessionStorage.setItem("debugMode","true"),setTimeout((function(){window.navigator.splashscreen.show(),window.location.href=e}),2e3)}))},e.prototype.patchSQLite=function(){delete window.SQLitePlugin},e.prototype.patchApp=function(){var e=this;this.app.reload=function(){e.networkService.isConnected()&&(window.navigator.splashscreen.show(),e.launch())},window.reloadApp=this.app.reload},e.prototype.patchHistoryApi=function(){var e=this.syncAppUrl,t=window.history.replaceState;window.history.replaceState=function(n,i,o){o.startsWith("#")&&(o=e+o),t.call(window.history,n,i,o)};var n=window.history.pushState;window.history.pushState=function(t,i,o){o.startsWith("#")&&(o=e+o),n.call(window.history,t,i,o)}},e.prototype.loadSettings=function(){var e=sessionStorage.getItem("wm.liveSync.settings");try{this.settings=e?JSON.parse(e):this.settings}catch(e){this.saveSettings()}},e.prototype.saveSettings=function(){sessionStorage.setItem("wm.liveSync.settings",JSON.stringify(this.settings))},e.prototype.renderUI=function(){var e=this;this.settings.enabled&&this.hasPluginsChanged().then((function(e){e&&new y({title:"Require new build",info:"Cordova Plugins in this app do not match with configuration of project in Studio. So, new Cordova Build is required for Live Sync to work properly.",iconClass:"fa fa-warning fa-4x live-sync-warning-icon",actions:[{title:"Got it",primary:!0}]}).render()})),new b(this.settings,(function(){e.saveSettings()})).render()},e}();v.decorators=[{type:t.Injectable}],v.ctorParameters=function(){return[{type:f.App},{type:g.DeviceService},{type:g.NetworkService},{type:m.File}]};var y=function(){function e(e){this.options=e,this.$ele=$("<div><div>")}return e.prototype.dismiss=function(){this.$ele.remove()},e.prototype.render=function(){this.$ele=$('<div class="live-sync-modal live-sync-control">\n <div class="live-sync-info-container">\n <span class="'+this.options.iconClass+'">\n </span>\n <label class="live-sync-title">\n '+this.options.title+'\n </label>\n <label class="live-sync-description"> \n '+this.options.info+'\n </label>\n <div class="live-sync-action-panel">\n '+this.options.actions.map((function(e){return e?'\n <button \n type="button"\n class="live-sync-action '+(e.primary?" live-sync-primary-action":"")+'">\n '+e.title+"\n </button>":""})).join("")+"\n </div>\n </div>\n </div>\n "),$("body").append(this.$ele);var e=this;this.$ele.find(".live-sync-action").each((function(t){$(this).bind("click",(function(){var n=e.options.actions[t].action;n&&n(e),e.dismiss()}))}))},e}(),b=function(){function e(e,t){this.settings=e,this.onChange=t,this.$ele=$('<div class="live-sync-control">\n <button class="live-sync-control-btn" type="button">\n </button>\n </div>')}return e.prototype.setPosition=function(){var e=this.$ele.find(".live-sync-control-btn"),t=this.settings.position;t&&(e.css("left",t.left+"px"),e.css("top",t.top+"px"))},e.prototype.listenForShowEvent=function(){var e=this;$("body").bind("touchstart",(function(){var t=setTimeout((function(){e.settings.show=!0,e.onChange(),e.showConfirmation()}),5e3);$("body").bind("touchend",(function(){clearTimeout(t)}))}))},e.prototype.showConfirmation=function(){var e=this;new y({title:"Enable Live Sync?",info:"App UI is pulled from studio. But, offline functionality is turned off.",iconClass:"live-sync-control-icon",actions:[{title:"No",action:function(){e.settings.show=!1,e.onChange(),e.showHelpInfo()}},{title:"Yes",action:function(){window.liveSync(!0)},primary:!0}]}).render()},e.prototype.showHelpInfo=function(){new y({title:"",info:"Tap and hold anywhere for 5 seconds to turn on Live Sync.",iconClass:"live-sync-retrieval-info-icon",actions:[{title:"Got it",primary:!0}]}).render()},e.prototype.renderButton=function(){var e=this,t=this.$ele.find(".live-sync-control-btn");this.$ele.on("touchstart",(function(n){n.stopPropagation();var i=!0;$(document).on("touchmove.liveSync",(function(n){var o=n.originalEvent.touches[0];o&&o.pageX&&(e.settings.position={left:o.pageX,top:o.pageY}),e.setPosition(),i&&(t.addClass("touched"),i=!1)})),$(document).one("touchend",(function(n){e.onChange(),t.removeClass("touched"),$(document).off("touchmove.liveSync")}))})),t.click((function(){return window.reloadApp()})),$("body").append(this.$ele)},e.prototype.render=function(){this.setPosition(),this.settings.enabled?this.renderButton():this.settings.show&&this.showConfirmation(),this.listenForShowEvent()},e}(),w=[i.BasicModule,o.SearchModule,r.SegmentedControlModule,a.MediaListModule,s.BarcodeScannerModule,l.CameraModule,c.FileUploadModule,p.PageModule,u.LeftPanelModule,d.MobileNavbarModule,h.TabBarModule],P=function(){};P.decorators=[{type:t.NgModule,args:[{providers:[{provide:n.HTTP_INTERCEPTORS,useClass:v,multi:!0}]}]}],e.MOBILE_COMPONENT_MODULES_FOR_ROOT=w,e.MobileRuntimeDynamicModule=P,e["\u0275a"]=v,Object.defineProperty(e,"__esModule",{value:!0})})),function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/router"),require("@angular/common"),require("@wm/core"),require("@wm/security"),require("@wm/variables"),require("@wm/components/page"),require("rxjs"),require("@wm/components/base"),require("@wm/components/prefab"),require("@angular/common/http"),require("@angular/platform-browser"),require("ngx-toastr"),require("@wm/components/dialogs"),require("@wm/components/dialogs/confirm-dialog"),require("@wm/components/dialogs/design-dialog"),require("@wm/mobile/runtime"),require("@wm/http"),require("@wm/oAuth"),require("ngx-bootstrap/chronos"),require("ngx-bootstrap/datepicker"),require("ngx-bootstrap/utils"),require("rxjs/operators"),require("@wm/transpiler"),require("@wm/build-task")):"function"==typeof define&&define.amd?define("@wm/runtime/base",["exports","@angular/core","@angular/router","@angular/common","@wm/core","@wm/security","@wm/variables","@wm/components/page","rxjs","@wm/components/base","@wm/components/prefab","@angular/common/http","@angular/platform-browser","ngx-toastr","@wm/components/dialogs","@wm/components/dialogs/confirm-dialog","@wm/components/dialogs/design-dialog","@wm/mobile/runtime","@wm/http","@wm/oAuth","ngx-bootstrap/chronos","ngx-bootstrap/datepicker","ngx-bootstrap/utils","rxjs/operators","@wm/transpiler","@wm/build-task"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).wm=e.wm||{},e.wm.runtime=e.wm.runtime||{},e.wm.runtime.base={}),e.ng.core,e.ng.router,e.ng.common,e.wm.core,e.wm.security,e.wm.variables,e.wm.components.page,e.rxjs,e.wm.components.base,e.wm.components.prefab,e.ng.common.http,e.ng.platformBrowser,e.ngxToastr,e.wm.components.dialogs,e.wm.components.dialogs.confirmdialog,e.wm.components.dialogs.designdialog,e.wm.mobile.runtime,e.wm.http,e.wm.oAuth,e["ngx-bootstrap"].chronos,e["ngx-bootstrap"].datepicker,e["ngx-bootstrap"].utils,e.rxjs.operators,e.wm.transpiler,e.wm.buildTask)}(this,(function(e,t,n,i,o,r,a,s,l,c,p,u,d,h,m,f,g,v,y,b,w,P,O,S,E,T){"use strict";function R(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var C,A=R(t),I=R(o),D=R(d);e.ComponentType=void 0,(C=e.ComponentType||(e.ComponentType={}))[C.PAGE=0]="PAGE",C[C.PREFAB=1]="PREFAB",C[C.PARTIAL=2]="PARTIAL";var N,x=function(){function e(){}return e.prototype.clearComponentFactoryRefCache=function(){},e}(),k=function(){},M=function(){},L=function(){},F=function(){};!function(e){e.HIDE_TEMPLATES_SHOW_CASE="hide-templates-show-case",e.SHOW_TEMPLATES_SHOW_CASE="show-templates-show-case",e.UPDATE_LOCATION="update-location-path",e.SELECT_TEMPLATE="select-template",e.TEMPLATEBUNDLE_CONFIG="template-bundle-config",e.ON_LOAD="on-load"}(N||(N={}));var j=function(){function e(e,t,n,i,o,r,a,s,l,c){var p=this;this.$http=e,this.$security=t,this.$dialog=n,this.$router=i,this.$app=o,this.$variables=r,this.$metadata=a,this.$spinner=s,this.$i18n=l,this.$datePipe=c,this.appVariablesLoaded=!1,this.appVariablesFired=!1,this._noRedirect=!1,this.$http.registerOnSessionTimeout(this.handle401.bind(this)),this.$variables.registerDependency("appManager",this),this.$app.subscribe("toggle-variable-state",(function(e){var t,n=e.variable,i=e.active;if(!_.isEmpty(_.trim(n.spinnerContext)))if(i){if(n._spinnerId&&n._spinnerId.length&&_.forEach(n._spinnerId,(function(e){e.slice(0,e.lastIndexOf("_"))!==n._id||!p.$spinner.messagesByContext||!p.$spinner.messagesByContext[n.spinnerContext]||n.spinnerMessage!==p.$spinner.messagesByContext[n.spinnerContext].finalMessage&&n.spinnerMessage!==p.$spinner.messagesByContext[n.spinnerContext][e]||(t=!0)})),!t){n._spinnerId=n._spinnerId||[];var o=p.$spinner.show(n.spinnerMessage,n._id+"_"+Date.now(),n.spinnerclass,n.spinnerContext);n._spinnerId.push(o)}}else p.$spinner.hide(n._spinnerId.shift())})),this.$app.subscribe("userLoggedIn",(function(){p.setLandingPage(),p.lastLoggedUserId&&p.$security.getConfig((function(e){e&&e.userInfo.userId!==p.lastLoggedUserId&&p.$app.clearPageCache()}),null)})),this.$app.subscribe("userLoggedOut",(function(){return p.setLandingPage().then((function(){p.$app.clearPageCache()}))})),this.$app.subscribe("http401",(function(e){return void 0===e&&(e={}),p.handle401(e.page,e.options)}))}return e.prototype.showLoginDialog=function(){this.$spinner.hide("globalSpinner"),this.$dialog.open("CommonLoginDialog"),o.$appDigest()},e.prototype.loadAppJS=function(){},e.prototype.loadCommonPage=function(){},e.prototype.loadSecurityConfig=function(e){var t=this;return this.$security.load(e).then((function(e){return t.$app.landingPageName||t.setLandingPage(),e}))},e.prototype.loadMetadata=function(){return this.$metadata.load()},e.prototype.loadAppVariables=function(e){var t=this;if(this.appVariablesLoaded)return Promise.resolve();var n=function(e){var n=t.$variables.register("app",e,t.$app);_.extend(t.$app.Variables,n.Variables),_.extend(t.$app.Actions,n.Actions),t.updateLoggedInUserVariable(),t.updateSupportedLocaleVariable(),t.appVariablesLoaded=!0,t.appVariablesFired=!1};return o.isDefined(e)?(n(e),Promise.resolve()):this.$http.get("./app.variables.json").then((function(e){return n(e)}))},e.prototype.isAppVariablesFired=function(e){return o.isDefined(e)&&(this.appVariablesFired=e),this.appVariablesFired},e.prototype.clearLoggedInUserVariable=function(e){e.isAuthenticated=!1,e.roles=[],e.name=void 0,e.id=void 0,e.tenantId=void 0},e.prototype.updateLoggedInUserVariable=function(){var e=this,t=_.get(this.$app,"Variables.loggedInUser.dataSet");if(t)return this.$security.load().then((function(){var n=e.$security.get();if(!(n&&n.securityEnabled&&n.authenticated))throw e.clearLoggedInUserVariable(t),t.isSecurityEnabled=n&&n.securityEnabled,null;return t.isAuthenticated=n.authenticated,t.roles=n.userInfo.userRoles,t.name=n.userInfo.userName,t.id=n.userInfo.userId,t.tenantId=n.userInfo.tenantId,t.userAttributes=n.userInfo.userAttributes,n})).catch((function(e){t.isAuthenticated=!1,t.roles=[],t.name=void 0,t.id=void 0,t.tenantId=void 0,t.userAttributes={}}))},e.prototype.updateSupportedLocaleVariable=function(){_.get(this.$app,"Variables.supportedLocale")},e.prototype.handleSSOLogin=function(e){var t,n,i=this;if(t=this.$security.getRedirectPage(e),a.CONSTANTS.hasCordova){var o=_.get(this.$security.get(),"userInfo.userName");this.$security.authInBrowser().then((function(){return i.reloadAppData()})).then((function(){var e=_.get(i.$security.get(),"userInfo.userName");e&&e===o?a.routerService.navigate([t]):a.routerService.navigate(["/"])}))}else{t=t?"?redirectPage="+encodeURIComponent(t):"",n=(n=this.$security.getQueryString(this.$security.getRedirectedRouteQueryParams()))?"?"+n:"",document.body.textContent=_.get(this.getAppLocale(),["MESSAGE_LOGIN_REDIRECTION"])||"Redirecting to sso login...";var r=this.getDeployedURL()+"services/security/ssologin"+t+n;window.self!==window.top&&"WM_PREVIEW_WINDOW"===window.parent.name?(window.parent.location.href=window.self.location.href,window.parent.name=""):window.location.href=r}},e.prototype.handle401=function(e,t){var n,i,o="DIALOG",r="PAGE",a="SSO",s=this.$security.get(),l={};if(i=s.loginConfig,this.lastLoggedUserId=s.userInfo&&s.userInfo.userId,s.userInfo&&s.userInfo.userName){switch(s.authenticated=!1,(n=i.sessionTimeout||{type:o}).type.toUpperCase()){case o:this.showLoginDialog();break;case r:e||(e=this.$security.getCurrentRoutePage()),l.redirectTo=e,l=_.merge(l,this.$security.getRedirectedRouteQueryParams()),e!==n.pageName&&this.$router.navigate([n.pageName],{queryParams:l});break;case a:this.handleSSOLogin(s)}this.setLandingPage()}else switch(i.type.toUpperCase()){case o:this.noRedirect(!0),this.showLoginDialog();break;case r:e=this.$security.getRedirectPage(s,e),l.redirectTo=e;var c=t&&t.queryParams||this.$security.getRedirectedRouteQueryParams();l=_.merge(l,c),this.$router.navigate([i.pageName],{queryParams:l}),this.$app.landingPageName=i.pageName;break;case a:this.handleSSOLogin(s)}},e.prototype.reloadAppData=function(){var e=this;return this.loadSecurityConfig(!0).then((function(){return e.loadMetadata().then((function(){return e.updateLoggedInUserVariable()}))}))},e.prototype.noRedirect=function(e){return _.isUndefined(e)||(this._noRedirect=e),this._noRedirect},e.prototype.executeSessionFailureRequests=function(){this.$http.executeSessionFailureRequests()},e.prototype.pushToSessionFailureRequests=function(e){this.$http.pushToSessionFailureQueue(e)},e.prototype.getDeployedURL=function(){return this.$app.deployedUrl?this.$app.deployedUrl:a.$rootScope.project.deployedUrl},e.prototype.getCustomUrlScheme=function(){return this.$app.customUrlScheme},e.prototype.notify=function(e,t){this.$app.notify(e,t)},e.prototype.subscribe=function(e,t){return this.$app.subscribe(e,t)},e.prototype.getActivePage=function(){return this.$app.activePage},e.prototype.getAppLocale=function(){return this.$app.appLocale},e.prototype.getSelectedLocale=function(){return this.$i18n.getSelectedLocale()},e.prototype.notifyApp=function(e,t,n){this.$app.notifyApp(e,t,n)},e.prototype.appOnBeforeServiceCall=function(e){return o.triggerFn(this.$app.onBeforeServiceCall,e)},e.prototype.appOnServiceSuccess=function(e,t){return o.triggerFn(this.$app.onServiceSuccess,e,t)},e.prototype.appOnServiceError=function(e,t){return o.triggerFn(this.$app.onServiceError,e,t)},e.prototype.appVariablesReady=function(){o.triggerFn(this.$app.onAppVariablesReady)},e.prototype.beforeAppReady=function(){o.triggerFn(this.$app.onBeforeAppReady)},e.prototype.getPipe=function(e){if("date"===e)return this.$datePipe},e.prototype.setLandingPage=function(){var e=this;return this.$security.getPageByLoggedInUser().then((function(t){return e.$app.landingPageName=t}))},e.prototype.isPrefabType=function(){return this.$app.isPrefabType},e.prototype.isTemplateBundleType=function(){return this.$app.isTemplateBundleType},e.prototype.postMessage=function(e){window.top.postMessage(e,"*")},e.prototype.showTemplate=function(e){var t=this.templates[e];this.$router.navigate([t.id])},e.prototype.postTemplateBundleInfo=function(){var e=this;return window.onmessage=function(t){var n=t.data;if(_.isObject(n))switch(n.key){case N.HIDE_TEMPLATES_SHOW_CASE:break;case N.SELECT_TEMPLATE:e.showTemplate(n.templateIndex)}},setTimeout((function(){e.postMessage({key:N.ON_LOAD})})),o.fetchContent("json","./config.json",!0,(function(t){e.templates=[],t.error||(e.templates=t.templates,e.postMessage({key:N.TEMPLATEBUNDLE_CONFIG,config:t}))}))},e.prototype.postAppTypeInfo=function(){if(this.isTemplateBundleType())return this.postTemplateBundleInfo()},e}();j.SERVICE_NAME="AppManagerService",j.decorators=[{type:t.Injectable}],j.ctorParameters=function(){return[{type:o.AbstractHttpService},{type:r.SecurityService},{type:o.AbstractDialogService},{type:n.Router},{type:o.App},{type:a.VariablesService},{type:a.MetadataService},{type:o.AbstractSpinnerService},{type:o.AbstractI18nService},{type:i.DatePipe}]};var B=function(e){return"__self__"===e},G=function(e){return B(e)?".":"app/prefabs/"+e},V=new Set,U=new Map,W=new Set,q=function(e,t){var n=e;return o.stringStartsWith(e,"http://|https://|//")||(n=(t+n).replace("//","/")),n},z=q,H=function(){function e(e,t){this.$metadata=e,this.prefabConfigProvider=t}return e.prototype.getConfig=function(e){return this.prefabConfigProvider.getConfig(e)},e.prototype.loadServiceDefs=function(e){return B(e)?Promise.resolve():this.$metadata.load(e)},e.prototype.loadStyles=function(e,t){var n=(void 0===t?{resources:{styles:[]}}:t).resources.styles,i=G(e),r=n.map((function(e){if(!_.endsWith(e,"/pages/Main/Main.css"))return q(e,i)})).filter((function(e){return!!e}));return o.loadStyleSheets(r),Promise.resolve()},e.prototype.loadScripts=function(e,t){var n=(void 0===t?{resources:{scripts:[]}}:t).resources.scripts,i=G(e),r=(n=n.filter((function(e){return!e.startsWith("npm://")}))).map((function(e){return q(e,i)}));return o.loadScripts(r,!0)},e.prototype.setInProgress=function(e){var t,n,i=new Promise((function(e,i){t=e,n=i}));i.resolve=t,i.reject=n,U.set(e,i)},e.prototype.resolveInProgress=function(e){U.get(e)&&(U.get(e).resolve(),U.delete(e))},e.prototype.loadDependencies=function(e){var t=this;return W.has(e)?Promise.resolve():V.has(e)?Promise.reject(""):U.get(e)?U.get(e):(this.setInProgress(e),this.getConfig(e).then((function(n){return Promise.all([t.loadStyles(e,n),t.loadScripts(e,n),t.loadServiceDefs(e)]).then((function(){t.resolveInProgress(e),W.add(e)}))})))},e}();H.decorators=[{type:t.Injectable}],H.ctorParameters=function(){return[{type:a.MetadataService},{type:k}]};
859
859
  /*! *****************************************************************************
860
860
  Copyright (c) Microsoft Corporation.
861
861