text: /*!
   * OpenUI5
   * (c) Copyright 2009-2019 SAP SE or an SAP affiliate company.
   * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
   */
  sap.ui.define(['./library','sap/ui/core/Control','sap/ui/core/Popup','sap/m/Text','sap/m/Button','sap/ui/core/ResizeHandler','sap/ui/Device','sap/ui/core/Icon','sap/ui/layout/VerticalLayout','./InstanceManager','sap/ui/core/InvisibleText','sap/ui/core/library','./LightBoxRenderer','sap/m/BusyIndicator',"sap/ui/thirdparty/jquery"],function(l,C,P,T,B,R,D,I,V,a,b,c,L,d,q){'use strict';var O=c.OpenState;var e=c.TextAlign;var f=l.ButtonType;var g=l.LightBoxLoadingStates;var h=C.extend('sap.m.LightBox',{metadata:{interfaces:['sap.ui.core.PopupInterface'],library:'sap.m',aggregations:{imageContent:{type:'sap.m.LightBoxItem',multiple:true,bindable:"bindable"},_closeButton:{type:'sap.m.Button',multiple:false,visibility:'hidden'},_errorIcon:{type:'sap.ui.core.Icon',multiple:false,visibility:'hidden'},_errorTitle:{type:'sap.m.Text',multiple:false,visibility:'hidden'},_errorSubtitle:{type:'sap.m.Text',multiple:false,visibility:'hidden'},_verticalLayout:{type:'sap.ui.layout.VerticalLayout',multiple:false,visibility:'hidden'},_invisiblePopupText:{type:"sap.ui.core.InvisibleText",multiple:false,visibility:"hidden"},_busy:{type:"sap.m.BusyIndicator",multiple:false,visibility:"hidden"}},events:{},defaultAggregation:'imageContent',designtime:"sap/m/designtime/LightBox.designtime"}});h.prototype.init=function(){this._createPopup();this._width=0;this._height=0;this._isRendering=true;this._resizeListenerId=null;this._$lightBox=null;this._rb=sap.ui.getCore().getLibraryResourceBundle("sap.m");this._closeButtonText=this._rb.getText("LIGHTBOX_CLOSE_BUTTON");if(sap.ui.getCore().getConfiguration().getAccessibility()){this.setAggregation("_invisiblePopupText",new b());}};h.prototype.onBeforeRendering=function(){var o=this._getImageContent(),n=o._getNativeImage(),s=o.getImageSrc(),S=o._getImageState();this._createErrorControls();if(n.getAttribute('src')!==s){n.src=s;}if(this._resizeListenerId){D.resize.detachHandler(this._onResizeHandler);R.deregister(this._resizeListenerId);this._resizeListenerId=null;}switch(S){case g.Loading:this._timeoutId=setTimeout(function(){o._setImageState(g.TimeOutError);},10000);break;case g.Loaded:clearTimeout(this._timeoutId);this._calculateSizes(n);break;case g.Error:clearTimeout(this._timeoutId);break;default:break;}var j=this.getAggregation('_invisiblePopupText');if(o&&j){j.setText(this._rb.getText("LIGHTBOX_ARIA_ENLARGED",[o.getTitle(),o.getSubtitle()]));}this._isRendering=true;};h.prototype.onAfterRendering=function(){this._isRendering=false;this._$lightBox=this.$();if(!this._resizeListenerId){this._onResizeHandler=this._onResize.bind(this);D.resize.attachHandler(this._onResizeHandler);this._resizeListenerId=R.register(this,this._onResizeHandler);}};h.prototype.forceInvalidate=C.prototype.invalidate;h.prototype.invalidate=function(o){var j=this._getImageContent();if(this.isOpen()){if(j&&j.getImageSrc()){this.forceInvalidate(o);}else{this.close();}}return this;};h.prototype.exit=function(){if(this._oPopup){this._oPopup.detachOpened(this._fnOpened,this);this._oPopup.detachClosed(this._fnClosed,this);this._oPopup.destroy();this._oPopup=null;}if(this._resizeListenerId){D.resize.detachHandler(this._onResizeHandler);R.deregister(this._resizeListenerId);this._resizeListenerId=null;}a.removeLightBoxInstance(this);};h.prototype.open=function(){var j=this._getImageContent();this._oPopup.setContent(this);if(j&&j.getImageSrc()){this._oPopup.open(300,'center center','center center',document.body,null);a.addLightBoxInstance(this);}return this;};h.prototype.isOpen=function(){if(this._oPopup&&this._oPopup.isOpen()){return true;}return false;};h.prototype.close=function(){if(this._resizeListenerId){D.resize.detachHandler(this._onResizeHandler);R.deregister(this._resizeListenerId);this._resizeListenerId=null;}this._oPopup.close();a.removeLightBoxInstance(this);return this;};h.prototype._getCloseButton=function(){var j=this.getAggregation('_closeButton');if(!j){j=new B({id:this.getId()+'-closeButton',text:this._closeButtonText,type:f.Transparent,press:function(){this.close();}.bind(this)});this.setAggregation('_closeButton',j,true);}return j;};h.prototype._getBusyIndicator=function(){var j=this.getAggregation("_busy");if(!j){j=new d();this.setAggregation("_busy",j,true);}return j;};h.prototype._imageStateChanged=function(n){var s=n===g.Loaded||n===g.Error;if(s&&!this._isRendering){this.rerender();}};h.prototype._createPopup=function(){this._oPopup=new P(this,true,true);this._oPopup.attachOpened(this._fnOpened,this);this._oPopup.attachClosed(this._fnClosed,this);};h.prototype._fnOpened=function(){var t=this;t._onResize();q('#sap-ui-blocklayer-popup').on("click",function(){t.close();});};h.prototype._fnClosed=function(){q('#sap-ui-blocklayer-popup').off("click");};h.prototype._createErrorControls=function(){var r=this._rb;var j;var k;if(this._getImageContent()._getImageState()===g.TimeOutError){j=r.getText('LIGHTBOX_IMAGE_TIMED_OUT');k=r.getText('LIGHTBOX_IMAGE_TIMED_OUT_DETAILS');}else{j=r.getText('LIGHTBOX_IMAGE_ERROR');k=r.getText('LIGHTBOX_IMAGE_ERROR_DETAILS');}if(!this.getAggregation('_verticalLayout')){var m=new T({text:j,textAlign:e.Center}).addStyleClass("sapMLightBoxErrorTitle"),n=new T({text:k,textAlign:e.Center}).addStyleClass("sapMLightBoxErrorSubtitle"),o=new I({src:"sap-icon://picture"}).addStyleClass("sapMLightBoxErrorIcon");this.setAggregation('_verticalLayout',new V({content:[o,m,n]}).addStyleClass('sapMLightBoxVerticalLayout'));}};h.prototype._onResize=function(){var m=i()/2+'px',t=m,j=m,k='',n='',o=this._getImageContent(),p=this.getDomRef(),r,s,u=i(),v=2;if(o._getImageState()===g.Loaded){this._calculateSizes(o._getNativeImage());r=this._width;s=this._height;this._$lightBox.width(r);this._$lightBox.height(s);}else{r=p.clientWidth;s=p.clientHeight;}if(window.innerWidth>r+u){j='50%';n=Math.round(-r/2);}if(window.innerHeight>s+u){t='50%';k=Math.round(-s/2);}if(sap.ui.getCore().getConfiguration().getTheme()==='sap_hcb'){k-=v;n-=v;}this._$lightBox.css({'top':t,'margin-top':k,'left':j,'margin-left':n});};h.prototype._calculateSizes=function(j){var F=this._calculateFooterHeightInPx(),k=288-F,m=this._getImageContent().getAggregation("_image"),n;this._setImageSize(m,j.naturalWidth,j.naturalHeight);this._calculateAndSetLightBoxSize(m);n=this._pxToNumber(m.getHeight());this.toggleStyleClass('sapMLightBoxMinSize',(n<k));this._isBusy=false;};h.prototype._calculateFooterHeightInPx=function(){var j=this.$().parents().hasClass('sapUiSizeCompact');var s=this._getImageContent().getSubtitle();var k=2.5;if(!j){k+=0.5;}if(s){k+=1.5;}return k*16;};h.prototype._calculateAndSetLightBoxSize=function(j){var k,m,n=(20*16),o=(18*16),F=this._calculateFooterHeightInPx();k=this._pxToNumber(j.getHeight());m=this._pxToNumber(j.getWidth());this._width=Math.max(n,m);this._height=Math.max(o,k+F);this._isLightBoxBiggerThanMinDimensions=(m>=n)&&(k>=(o-F));};h.prototype._setImageSize=function(j,k,m){var n=this._calculateFooterHeightInPx(),o=this._getDimensions(k,m,n),w=o.width+'px',p=o.height+'px',r=j.getDomRef();j.setProperty('width',w,true);j.setProperty('height',p,true);if(r){r.style.width=w;r.style.height=p;}};h.prototype._getDimensions=function(j,k,m){var n=20*16,o=18*16,$=q(window),w=$.height(),p=$.width(),r=i(),s=Math.max(p-r,n),t=Math.max(w-r,o),u;t-=m;if(k<=t){if(j<=s){}else{k*=s/j;j=s;}}else{if(j<=s){j*=t/k;k=t;}else{u=Math.max(j/s,k/t);j/=u;k/=u;}}return{width:Math.round(j),height:Math.round(k)};};h.prototype._pxToNumber=function(s){return(s.substring(0,(s.length-2)))*1;};h.prototype._getImageContent=function(){var r=this.getAggregation('imageContent');return r&&r[0];};function i(){var s=D.system;if(s.desktop){return 4*16;}if(s.tablet){return 2*16;}return 0;}h.prototype.onsapescape=function(E){var j=this._oPopup.getOpenState();if(j!==O.CLOSED&&j!==O.CLOSING){this.close();E.stopPropagation();}};return h;});
  