<%
import java.util.HashSet;

def rcontext = _ctx.getRequestContext() ;
if (rcontext.isMaximizePortlet()) {
  return;
}

/* Loading needed Fonts files in top of the page as a 'preload' resource to include it in response when using HTTP/2 */
%><%/* Fonts Preload */%>
<link rel="preload" href="/platform-ui/skin/fonts/flUhRq6tzZclQEJ-Vdg-IuiaDsNc.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/platform-ui/skin/fonts/fa-solid-900.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/platform-ui/skin/fonts/fa-regular-400.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/platform-ui/skin/fonts/materialdesignicons-webfont.woff2?v=5.9.55" as="font" type="font/woff2" crossorigin>
<%/* Loading needed stylesheets in top of the page as a 'preload' resource to include it in response*/%>
<link rel="preload" as="style" type="text/css" href="<%=uicomponent.getBrandingUrl()%>">
<%
// Loading needed stylesheets in top of the page as a 'preload' resource to include it in response
def portalSkins = uicomponent.getPortalSkins();
/* Preloded Portal Stylesheets */
for (skinConfig in portalSkins) {
  def url = skinConfig.createURL(rcontext.controllerContext);
  url.setOrientation(orientation);
%><link rel="preload" href= "$url" as="style" type="text/css" />
<%
}
/* Preloded Portlet Skins */
def portletSkins = uicomponent.getPortletSkins();
for (portletSkin in portletSkins) {
  def url = portletSkin.createURL(rcontext.controllerContext);
  url.setOrientation(orientation);
%><link rel="preload" href= "$url" as="style" type="text/css" /><%
}
/* Preloded Portlet Stylesheets */
def portletAdditionalStylesheets = uicomponent.getPortletStylesheets();
for (portletStylesheet in portletAdditionalStylesheets) {
%><link rel="preload" href= "$portletStylesheet" as="style" type="text/css" />
<%
}
/* Preloded Custom Skins */
def customSkins = uicomponent.getCustomSkins();
for (customSkin in customSkins) {
 def url = customSkin.createURL(rcontext.controllerContext);
 url.setOrientation(orientation);
%><link rel="preload" href= "$url" as="style" type="text/css" />
<%
}
/* Preloded Scripts */
def jsManager = rcontext.getJavascriptManager();
def jsConfig = uicomponent.getJSConfig();
def jsConfigPaths = jsConfig.get("paths");
def scriptsIdsMap = jsManager.getPageScripts();
def scriptsIds = scriptsIdsMap.keySet();
def scriptPaths = new HashSet<>();
for (scriptsId in scriptsIds) {
  def isRemote = scriptsIdsMap.get(scriptsId) || !jsConfigPaths.has(scriptsId);
  def scriptPath = isRemote ? scriptsId : jsConfigPaths.get(scriptsId);
  if (!scriptPaths.contains(scriptPath)) {
    scriptPaths.add(scriptPath);
%><link rel="preload" href= "$scriptPath" as="script" type="text/javascript" <%=isRemote ? "crossorigin" : "" %>/>
<% 
  }
}
%>