<%--
/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * The contents of this file are subject to the terms of the Liferay Enterprise
 * Subscription License ("License"). You may not use this file except in
 * compliance with the License. You can obtain a copy of the License by
 * contacting Liferay, Inc. See the License for the specific language governing
 * permissions and limitations under the License, including but not limited to
 * distribution rights of the Software.
 *
 *
 *
 */
--%>

<%@ include file="/preview/init.jsp" %>

<%
String randomNamespace = PortalUtil.generateRandomKey(request, "portlet_document_library_view_file_entry_preview") + StringPool.UNDERLINE;

FileVersion fileVersion = (FileVersion)request.getAttribute(WebKeys.DOCUMENT_LIBRARY_FILE_VERSION);

String previewQueryString = "&imagePreview=1";

int status = ParamUtil.getInteger(request, "status", WorkflowConstants.STATUS_ANY);

if (status != WorkflowConstants.STATUS_ANY) {
	previewQueryString += "&status=" + status;
}

String previewURL = DLURLHelperUtil.getPreviewURL(fileVersion.getFileEntry(), fileVersion, themeDisplay, previewQueryString);
%>

<liferay-util:html-top
	outputKey="document_library_preview_image_css"
>
	<link href="<%= PortalUtil.getStaticResourceURL(request, application.getContextPath() + "/preview/css/main.css") %>" rel="stylesheet" type="text/css" />
</liferay-util:html-top>

<c:choose>
	<c:when test="<%= Objects.equals(fileVersion.getMimeType(), ContentTypes.IMAGE_SVG_XML) %>">
		<div class="preview-file">
			<div class="preview-file-container preview-file-max-height">
				<img alt="<%= HtmlUtil.escapeAttribute(fileVersion.getDescription()) %>" class="preview-file-image-vectorial" src="<%= previewURL %>" />
			</div>
		</div>
	</c:when>
	<c:otherwise>
		<div id="<portlet:namespace /><%= randomNamespace %>previewImage">
			<react:component
				module="preview/js/ImagePreviewer.es"
				props='<%=
					HashMapBuilder.<String, Object>put(
						"alt", fileVersion.getDescription()
					).put(
						"imageURL", previewURL
					).build()
				%>'
			/>
		</div>
	</c:otherwise>
</c:choose>