/*
 * Generated by the Jasper component of Apache Tomcat
 * Version: JspC/ApacheTomcat9
 * Generated at: 2026-07-06 05:23:26 UTC
 * Note: The last modified time of this file was set to
 *       the last modified time of the source file after
 *       generation to assist with modification tracking.
 */
package org.apache.jsp.tag.web.silverpeas.gallery;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import org.silverpeas.components.gallery.GalleryComponentSettings;

public final class handleMediaPreview_tag
    extends javax.servlet.jsp.tagext.SimpleTagSupport
    implements org.apache.jasper.runtime.JspSourceDependent,
                 org.apache.jasper.runtime.JspSourceImports {

  private static final javax.servlet.jsp.JspFactory _jspxFactory =
          javax.servlet.jsp.JspFactory.getDefaultFactory();

  private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants;

  static {
    _jspx_dependants = new java.util.LinkedHashMap<java.lang.String,java.lang.Long>(6);
    _jspx_dependants.put("uri:http://java.sun.com/jsp/jstl/core", Long.valueOf(1783313422412L));
    _jspx_dependants.put("uri:http://java.sun.com/jsp/jstl/core!/META-INF/c.tld", Long.valueOf(1531470420000L));
    _jspx_dependants.put("uri:http://www.silverpeas.com/tld/silverFunctions", Long.valueOf(1783313428948L));
    _jspx_dependants.put("uri:http://www.silverpeas.com/tld/silverFunctions!/META-INF/silverFunctions.tld", Long.valueOf(1783313424000L));
    _jspx_dependants.put("uri:http://www.silverpeas.com/tld/viewGenerator", Long.valueOf(1783313428948L));
    _jspx_dependants.put("uri:http://www.silverpeas.com/tld/viewGenerator!/META-INF/viewGenerator.tld", Long.valueOf(1783313424000L));
  }

  private static final java.util.Set<java.lang.String> _jspx_imports_packages;

  private static final java.util.Set<java.lang.String> _jspx_imports_classes;

  static {
    _jspx_imports_packages = new java.util.LinkedHashSet<>(4);
    _jspx_imports_packages.add("javax.servlet");
    _jspx_imports_packages.add("javax.servlet.http");
    _jspx_imports_packages.add("javax.servlet.jsp");
    _jspx_imports_classes = new java.util.LinkedHashSet<>(2);
    _jspx_imports_classes.add("org.silverpeas.components.gallery.GalleryComponentSettings");
  }

  private javax.servlet.jsp.JspContext jspContext;
  private java.io.Writer _jspx_sout;
  private volatile javax.el.ExpressionFactory _el_expressionfactory;
  private volatile org.apache.tomcat.InstanceManager _jsp_instancemanager;

  public void setJspContext(javax.servlet.jsp.JspContext ctx) {
    super.setJspContext(ctx);
    java.util.ArrayList _jspx_nested = null;
    java.util.ArrayList _jspx_at_begin = null;
    java.util.ArrayList _jspx_at_end = null;
    this.jspContext = new org.apache.jasper.runtime.JspContextWrapper(this, ctx, _jspx_nested, _jspx_at_begin, _jspx_at_end, null);
  }

  public javax.servlet.jsp.JspContext getJspContext() {
    return this.jspContext;
  }
  private java.lang.String jquerySelector;

  public java.lang.String getJquerySelector() {
    return this.jquerySelector;
  }

  public void setJquerySelector(java.lang.String jquerySelector) {
    this.jquerySelector = jquerySelector;
    jspContext.setAttribute("jquerySelector", jquerySelector);
  }

  public java.util.Map<java.lang.String,java.lang.Long> getDependants() {
    return _jspx_dependants;
  }

  public java.util.Set<java.lang.String> getPackageImports() {
    return _jspx_imports_packages;
  }

  public java.util.Set<java.lang.String> getClassImports() {
    return _jspx_imports_classes;
  }

  public javax.el.ExpressionFactory _jsp_getExpressionFactory() {
    return _el_expressionfactory;
  }

  public org.apache.tomcat.InstanceManager _jsp_getInstanceManager() {
    return _jsp_instancemanager;
  }

  private void _jspInit(javax.servlet.ServletConfig config) {
    _el_expressionfactory = _jspxFactory.getJspApplicationContext(config.getServletContext()).getExpressionFactory();
    _jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(config);
  }

  public void _jspDestroy() {
  }

  public void doTag() throws javax.servlet.jsp.JspException, java.io.IOException {
    javax.servlet.jsp.PageContext _jspx_page_context = (javax.servlet.jsp.PageContext)jspContext;
    javax.servlet.http.HttpServletRequest request = (javax.servlet.http.HttpServletRequest) _jspx_page_context.getRequest();
    javax.servlet.http.HttpServletResponse response = (javax.servlet.http.HttpServletResponse) _jspx_page_context.getResponse();
    javax.servlet.http.HttpSession session = _jspx_page_context.getSession();
    javax.servlet.ServletContext application = _jspx_page_context.getServletContext();
    javax.servlet.ServletConfig config = _jspx_page_context.getServletConfig();
    javax.servlet.jsp.JspWriter out = jspContext.getOut();
    _jspInit(config);
    jspContext.getELContext().putContext(javax.servlet.jsp.JspContext.class,jspContext);
    if( getJquerySelector() != null ) 
      _jspx_page_context.setAttribute("jquerySelector", getJquerySelector());

    try {
      out.write("\n\n\n\n\n\n\n\n\n\n");
      if (_jspx_meth_c_005fset_005f0(_jspx_page_context))
        return;
      out.write('\n');
      //  c:set
      org.apache.taglibs.standard.tag.rt.core.SetTag _jspx_th_c_005fset_005f1 = new org.apache.taglibs.standard.tag.rt.core.SetTag();
      _jsp_getInstanceManager().newInstance(_jspx_th_c_005fset_005f1);
      try {
        _jspx_th_c_005fset_005f1.setPageContext(_jspx_page_context);
        _jspx_th_c_005fset_005f1.setParent(new javax.servlet.jsp.tagext.TagAdapter((javax.servlet.jsp.tagext.SimpleTag) this ));
        // /WEB-INF/tags/silverpeas/gallery/handleMediaPreview.tag(36,0) name = var type = java.lang.String reqTime = false required = false fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null
        _jspx_th_c_005fset_005f1.setVar("NB_MAX_THUMBNAIL");
        // /WEB-INF/tags/silverpeas/gallery/handleMediaPreview.tag(36,0) name = value type = javax.el.ValueExpression reqTime = true required = false fragment = false deferredValue = true expectedTypeName = java.lang.Object deferredMethod = false methodSignature = null
        _jspx_th_c_005fset_005f1.setValue(GalleryComponentSettings.getMaxNumberOfPreviewThumbnail());
        int _jspx_eval_c_005fset_005f1 = _jspx_th_c_005fset_005f1.doStartTag();
        if (_jspx_th_c_005fset_005f1.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
          throw new javax.servlet.jsp.SkipPageException();
        }
      } finally {
        org.apache.jasper.runtime.JspRuntimeLibrary.releaseTag(_jspx_th_c_005fset_005f1, _jsp_getInstanceManager());
      }
      out.write("\n\n<style type=\"text/css\">\n  .photoPreviewTip {\n    max-width: none;\n    max-height: none;\n  }\n</style>\n\n<script type=\"text/javascript\">\n  (function() {\n\n    whenSilverpeasReady(function() {\n\n      $('");
      out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${jquerySelector}", java.lang.String.class, (javax.servlet.jsp.PageContext)this.getJspContext(), null));
      out.write("').each(function() {\n        $(this).qtip({\n          prerender : true,\n          style : {\n            classes : 'qtip-bootstrap photoPreviewTip'\n          },\n          content : {\n            title : {\n              text : $(this).attr(\"tipTitle\")\n            },\n            text : \"<img src='\" + $(this).attr(\"tipUrl\") + \"' id='tipUrl_\" + $(this).attr(\"id\") + \"' />\"\n          },\n          position : {\n            my : 'right middle',\n            at : 'left middle',\n            adjust : {\n              method : \"flipinvert\"\n            },\n            viewport : $(window)\n          },\n          show : {\n            solo : true\n          }\n        });\n      });\n\n      var mouseEnterCallback = function() {\n        if (this.intervalID) {\n          window.clearInterval(this.intervalID);\n        } else {\n          if (this.providerData) {\n            var thumbnailUrl = this.providerData.thumbnailUrl;\n            var thumbnailDefinition = this.providerData.thumbnailDefinition;\n            if (thumbnailUrl) {\n              this.getPreviewElement().setAttribute('src', thumbnailUrl);\n");
      out.write("            }\n            if (thumbnailDefinition) {\n              this.getPreviewElement().setAttribute('width', thumbnailDefinition.width);\n              this.getPreviewElement().setAttribute('height', thumbnailDefinition.height);\n            }\n          }\n        }\n        this.intervalID = setInterval(changePicture.bind(this), 1000);\n      };\n\n      var mouseLeaveCallback = function() {\n        window.clearInterval(this.intervalID);\n      };\n\n      var changePicture = function() {\n        var src;\n        this.changePictureCount++;\n        if (this.providerData) {\n          ");
      out.write("\n          var thumbnailUrls = this.providerData.thumbnailPreviewUrls;\n          if (thumbnailUrls.length > 1) {\n            src = thumbnailUrls[this.changePictureCount % thumbnailUrls.length];\n          }\n        } else {\n          ");
      out.write("\n          src = this.getPreviewElement().getAttribute('src').replace(/thumbnail[/][0-9]+/g,\n              'thumbnail/' + (this.changePictureCount % ");
      out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${NB_MAX_THUMBNAIL}", java.lang.String.class, (javax.servlet.jsp.PageContext)this.getJspContext(), null));
      out.write("));\n        }\n        if (src) {\n          this.getPreviewElement().setAttribute(\"src\", src);\n        }\n      };\n\n      ");
      out.write("\n      ");
      out.write("\n      var ThumbnailPreview = function(mediaElement, providerData) {\n        this.intervalID = false;\n        this.mediaElement = mediaElement;\n        this.providerData = providerData;\n        this.changePictureCount = 0;\n        var previewElement;\n\n        if (this.providerData) {\n          if (!this.providerData.thumbnailPreviewUrls) {\n            this.providerData.thumbnailPreviewUrls = [];\n          }\n          var thumbnailUrl = this.providerData.thumbnailUrl;\n          if (thumbnailUrl) {\n            this.mediaElement.setAttribute('src', thumbnailUrl);\n            this.providerData.thumbnailPreviewUrls.unshift(thumbnailUrl);\n          }\n        }\n\n        this.getPreviewElement = function() {\n          if (!previewElement) {\n            previewElement =\n                document.querySelector(\"#tipUrl_\" + this.mediaElement.getAttribute(\"id\"));\n          }\n          return previewElement;\n        };\n\n        ");
      out.write("\n        mediaElement.addEventListener('mouseenter', mouseEnterCallback.bind(this));\n        mediaElement.addEventListener('mouseover', mouseEnterCallback.bind(this));\n        mediaElement.addEventListener('mouseleave', mouseLeaveCallback.bind(this));\n        mediaElement.addEventListener('mouseout', mouseLeaveCallback.bind(this));\n      };\n\n      var providerData = '");
      if (_jspx_meth_c_005furl_005f0(_jspx_page_context))
        return;
      out.write("';\n\n      [].slice.call(document.querySelectorAll(\".videoPreview, .streamingPreview\"), 0)\n          .forEach(function(mediaElement) {\n            if (mediaElement.classList.contains(\"videoPreview\")) {\n\n              new ThumbnailPreview(mediaElement, null);\n\n            } else if (mediaElement.classList.contains(\"streamingPreview\")) {\n\n              var streamingId = mediaElement.getAttribute(\"id\").replace(/mediaId_/g, '');\n              silverpeasAjax(providerData.replace(/streamingId/g, streamingId)).then(\n                  function(request) {\n                    var providerData = request.responseAsJson();\n                    new ThumbnailPreview(mediaElement, providerData);\n                  });\n\n            }\n          });\n    });\n  })();\n</script>");
    } catch( java.lang.Throwable t ) {
      if( t instanceof javax.servlet.jsp.SkipPageException )
          throw (javax.servlet.jsp.SkipPageException) t;
      if( t instanceof java.io.IOException )
          throw (java.io.IOException) t;
      if( t instanceof java.lang.IllegalStateException )
          throw (java.lang.IllegalStateException) t;
      if( t instanceof javax.servlet.jsp.JspException )
          throw (javax.servlet.jsp.JspException) t;
      throw new javax.servlet.jsp.JspException(t);
    } finally {
      jspContext.getELContext().putContext(javax.servlet.jsp.JspContext.class,super.getJspContext());
      ((org.apache.jasper.runtime.JspContextWrapper) jspContext).syncEndTagFile();
    }
  }

  private boolean _jspx_meth_c_005fset_005f0(javax.servlet.jsp.PageContext _jspx_page_context)
          throws java.lang.Throwable {
    javax.servlet.jsp.JspWriter out = _jspx_page_context.getOut();
    //  c:set
    org.apache.taglibs.standard.tag.rt.core.SetTag _jspx_th_c_005fset_005f0 = new org.apache.taglibs.standard.tag.rt.core.SetTag();
    _jsp_getInstanceManager().newInstance(_jspx_th_c_005fset_005f0);
    try {
      _jspx_th_c_005fset_005f0.setPageContext(_jspx_page_context);
      _jspx_th_c_005fset_005f0.setParent(new javax.servlet.jsp.tagext.TagAdapter((javax.servlet.jsp.tagext.SimpleTag) this ));
      // /WEB-INF/tags/silverpeas/gallery/handleMediaPreview.tag(35,0) name = var type = java.lang.String reqTime = false required = false fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null
      _jspx_th_c_005fset_005f0.setVar("componentId");
      // /WEB-INF/tags/silverpeas/gallery/handleMediaPreview.tag(35,0) name = value type = javax.el.ValueExpression reqTime = true required = false fragment = false deferredValue = true expectedTypeName = java.lang.Object deferredMethod = false methodSignature = null
      _jspx_th_c_005fset_005f0.setValue(new org.apache.jasper.el.JspValueExpression("/WEB-INF/tags/silverpeas/gallery/handleMediaPreview.tag(35,0) '${requestScope.browseContext[3]}'",_jsp_getExpressionFactory().createValueExpression(this.getJspContext().getELContext(),"${requestScope.browseContext[3]}",java.lang.Object.class)).getValue(this.getJspContext().getELContext()));
      int _jspx_eval_c_005fset_005f0 = _jspx_th_c_005fset_005f0.doStartTag();
      if (_jspx_th_c_005fset_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
        throw new javax.servlet.jsp.SkipPageException();
      }
    } finally {
      org.apache.jasper.runtime.JspRuntimeLibrary.releaseTag(_jspx_th_c_005fset_005f0, _jsp_getInstanceManager());
    }
    return false;
  }

  private boolean _jspx_meth_c_005furl_005f0(javax.servlet.jsp.PageContext _jspx_page_context)
          throws java.lang.Throwable {
    javax.servlet.jsp.JspWriter out = _jspx_page_context.getOut();
    //  c:url
    org.apache.taglibs.standard.tag.rt.core.UrlTag _jspx_th_c_005furl_005f0 = new org.apache.taglibs.standard.tag.rt.core.UrlTag();
    _jsp_getInstanceManager().newInstance(_jspx_th_c_005furl_005f0);
    try {
      _jspx_th_c_005furl_005f0.setPageContext(_jspx_page_context);
      _jspx_th_c_005furl_005f0.setParent(new javax.servlet.jsp.tagext.TagAdapter((javax.servlet.jsp.tagext.SimpleTag) this ));
      // /WEB-INF/tags/silverpeas/gallery/handleMediaPreview.tag(153,26) name = value type = null reqTime = true required = false fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null
      _jspx_th_c_005furl_005f0.setValue((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("/services/gallery/${componentId}/streamings/streamingId/providerData", java.lang.String.class, (javax.servlet.jsp.PageContext)this.getJspContext(), null));
      int _jspx_eval_c_005furl_005f0 = _jspx_th_c_005furl_005f0.doStartTag();
      if (_jspx_th_c_005furl_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
        throw new javax.servlet.jsp.SkipPageException();
      }
    } finally {
      org.apache.jasper.runtime.JspRuntimeLibrary.releaseTag(_jspx_th_c_005furl_005f0, _jsp_getInstanceManager());
    }
    return false;
  }
}
