// Copyright (c) 2009-2017 SAP SE, All Rights Reserved
sap.ui.define(["sap/ushell/utils","sap/ushell/utils/objectOperations","sap/ushell/utils/clone","sap/ui/thirdparty/jquery","sap/base/Log","sap/base/util/ObjectPath"],function(u,o,c,q,L,O){"use strict";function g(d,A){return o.getMember(d,A);}function m(k,s,A){s=c(s);A=c(A);var i={};i.semanticObject=s.semanticObject;i.action=s.action;i.title=s.title||g(A,"sap|app.title");i.info=s.info||g(A,"sap|app.info");i.icon=s.icon||g(A,"sap|ui.icons.icon");i.subTitle=s.subTitle||g(A,"sap|app.subTitle");i.shortTitle=s.shortTitle||g(A,"sap|app.shortTitle");var T,d,e,h,D,j,I=false;var S=g(A,"sap|platform|runtime");i.resolutionResult=q.extend(true,{},S);if(S){i.resolutionResult["sap.platform.runtime"]=q.extend(true,{},S);}if(g(A,"sap|ui.technology")==="GUI"){i.resolutionResult["sap.gui"]=g(A,"sap|gui");}if(g(A,"sap|ui.technology")==="WDA"){i.resolutionResult["sap.wda"]=g(A,"sap|wda");}if(g(A,"sap|ui.technology")==="URL"){if(A["sap.url"]){i.resolutionResult["sap.platform.runtime"]=i.resolutionResult["sap.platform.runtime"]||{};i.resolutionResult.url=A["sap.url"].uri;i.resolutionResult["sap.platform.runtime"].url=A["sap.url"].uri;}else if(S&&S.uri){i.resolutionResult["sap.platform.runtime"].url=S.uri;i.resolutionResult.url=S.uri;}}if(!i.resolutionResult["sap.ui"]){i.resolutionResult["sap.ui"]={};}i.resolutionResult["sap.ui"].technology=g(A,"sap|ui.technology");i.resolutionResult.applicationType=this._formatApplicationType(i.resolutionResult,A);i.resolutionResult.systemAlias=i.resolutionResult.systemAlias||s.systemAlias;i.resolutionResult.systemAliasSemantics="apply";i.resolutionResult.text=i.title;i.deviceTypes=g(A,"sap|ui.deviceTypes")||{};i.resolutionResult.appId=g(A,"sap|app.id");["desktop","tablet","phone"].forEach(function(M){if(Object.prototype.hasOwnProperty.call(s.deviceTypes||{},M)){i.deviceTypes[M]=s.deviceTypes[M];}if(!Object.prototype.hasOwnProperty.call(i.deviceTypes,M)){i.deviceTypes[M]=true;}i.deviceTypes[M]=!!i.deviceTypes[M];});i.signature=s.signature||{};i.signature.parameters=i.signature.parameters||{};i.signature.additionalParameters=(s.signature||{}).additionalParameters||"allowed";var l=s.indicatorDataSource||g(A,"sap|app.crossNavigation.inbounds."+k+".indicatorDataSource");var n=l?"#Shell-dynamicTile":"#Shell-staticTile";if(g(A,"sap|app.type")==="tile"||g(A,"sap|flp.type")==="tile"){n=i.resolutionResult;n.url=g(A,"sap|platform|runtime.componentProperties.url");n.componentName=g(A,"sap|ui5.componentName");if(g(A,"sap|platform|runtime.includeManifest")){n.componentProperties=n.componentProperties||{};n.componentProperties.manifest=q.extend(true,{},A);delete n.componentProperties.manifest["sap.platform.runtime"];}h=g(A,"sap|app.crossNavigation.outbounds.target");I=true;}if(g(A,"sap|app.type")==="plugin"||g(A,"sap|flp.type")==="plugin"){return undefined;}if(g(A,"sap|flp.tileSize")){T=g(A,"sap|flp.tileSize");}if(g(A,"sap|app.description")){d=g(A,"sap|app.description");}if(g(A,"sap|ui.technology")==="GUI"&&g(A,"sap|gui.transaction")){e=g(A,"sap|gui.transaction");}if(g(A,"sap|ui.technology")==="WDA"&&g(A,"sap|wda.applicationId")){e=g(A,"sap|wda.applicationId");}if(g(A,"sap|app.dataSources")){D=g(A,"sap|app.dataSources");}if(g(A,"sap|app.id")){j=g(A,"sap|app.id");}i.tileResolutionResult={appId:j,title:i.title,subTitle:i.subTitle,icon:i.icon,size:T,info:i.info,tileComponentLoadInfo:n,indicatorDataSource:l,dataSources:D,description:d,runtimeInformation:S,technicalInformation:e,deviceTypes:i.deviceTypes};i.tileResolutionResult.isCustomTile=I;if(h){i.tileResolutionResult.targetOutbound=h;}return i;}function f(r,A){var s=r.applicationType;if(s){return s;}var C=g(A,"sap|platform|runtime.componentProperties.self.name")||g(A,"sap|ui5.componentName");if(g(A,"sap|flp.appType")==="UI5"||g(A,"sap|ui.technology")==="UI5"){r.applicationType="SAPUI5";r.additionalInformation="SAPUI5.Component="+C;r.url=g(A,"sap|platform|runtime.componentProperties.url");r.applicationDependencies=g(A,"sap|platform|runtime.componentProperties");return"SAPUI5";}if(g(A,"sap|ui.technology")==="GUI"){r.applicationType="TR";r["sap.gui"]=g(A,"sap|gui");r.systemAlias=g(A,"sap|app.destination.name");return"TR";}if(g(A,"sap|ui.technology")==="WDA"){r.applicationType="WDA";r["sap.wda"]=g(A,"sap|wda");r.systemAlias=g(A,"sap|app.destination.name");return"WDA";}if(g(A,"sap|ui.technology")==="URL"){r.applicationType="URL";r.systemAlias=g(A,"sap|app.destination.name");}return"URL";}function a(s){var d=this;if(!s){return[];}var i=[];try{var S=Object.keys(s.applications||{}).sort();S.forEach(function(A){try{var h=s.applications[A];var j=g(h,"sap|app.crossNavigation.inbounds");if(j){var l=Object.keys(j).sort();l.forEach(function(I){var k=j[I];var r=d.mapOne(I,k,h);if(r){i.push(r);}});}}catch(E){L.error("Error in application "+A+": "+E,E.stack);}});}catch(e){L.error(e);L.error(e.stack);return[];}return i;}function t(i){var s,p,C;s={target:{semanticObject:i.semanticObject,action:i.action},params:{}};p=O.get("signature.parameters",i)||{};Object.keys(p).forEach(function(k){if(p[k].filter&&Object.prototype.hasOwnProperty.call(p[k].filter,"value")&&(p[k].filter.format===undefined||p[k].filter.format==="plain")){s.params[k]=[p[k].filter.value];}if(p[k].launcherValue&&Object.prototype.hasOwnProperty.call(p[k].launcherValue,"value")&&(p[k].launcherValue.format===undefined||p[k].launcherValue.format==="plain")){s.params[k]=[p[k].launcherValue.value];}});C=sap.ushell.Container.getService("URLParsing").constructShellHash(s);if(!C){return undefined;}return C;}function b(d){var s,p,C;s={target:{semanticObject:d.semanticObject,action:d.action},params:{}};p=d.parameters||{};Object.keys(p).forEach(function(k){if(p.hasOwnProperty(k)&&typeof p[k].value==="object"){s.params[k]=[p[k].value.value];}});C=sap.ushell.Container.getService("URLParsing").constructShellHash(s);if(!C){return undefined;}return C;}return{formatSite:a,toHashFromInbound:t,toHashFromOutbound:b,mapOne:m,_formatApplicationType:f};},true);
