text: /*!
   * OpenUI5
   * (c) Copyright 2009-2020 SAP SE or an SAP affiliate company.
   * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
   */
  sap.ui.define(["sap/ui/core/IconPool","sap/ui/base/EventProvider","sap/m/library","sap/m/OverflowToolbarButton","sap/m/OverflowToolbarLayoutData","./SemanticContainer"],function(t,e,o,n,i,r){"use strict";var s=o.ButtonType;var a=r.extend("sap.f.semantic.SemanticShareMenu",{constructor:function(t,e){r.call(this,t,e);this._aShareMenuActions=[];this._aCustomShareActions=[];this._setMode(a._Mode.initial)}});a._Mode={initial:"initial",menu:"menu"};a.prototype.addCustomAction=function(t){this._onControlAdded(t);this._callContainerAggregationMethod("insertButton",t,this._getCustomActionInsertIndex());this._aCustomShareActions.push(t);return this};a.prototype.insertCustomAction=function(t,e){this._onControlAdded(t);this._callContainerAggregationMethod("insertButton",t,this._getCustomActionInsertIndex(e));this._aCustomShareActions.splice(e,0,t);return this};a.prototype.getCustomActions=function(){return this._aCustomShareActions};a.prototype.indexOfCustomAction=function(t){return this._aCustomShareActions.indexOf(t)};a.prototype.removeCustomAction=function(t){var e=this._callContainerAggregationMethod("removeButton",t);this._aCustomShareActions.splice(this._aCustomShareActions.indexOf(t),1);this._onControlRemoved();return e};a.prototype.removeAllCustomActions=function(){var t=[];this._aCustomShareActions.forEach(function(e){var o=this._callContainerAggregationMethod("removeButton",e);if(o){t.push(e)}},this);this._aCustomShareActions=[];this._onControlRemoved();return t};a.prototype.destroyCustomActions=function(){this.removeAllCustomActions(true).forEach(function(t){t.destroy()});return this};a.prototype.addContent=function(t){var e=this._getControl(t);this._onControlAdded(e);this._aShareMenuActions.push(t);this._preProcessOverflowToolbarButton(e);this._callContainerAggregationMethod("insertButton",e,this._getSemanticActionInsertIndex(t));return this};a.prototype.removeContent=function(t){var e=this._getControl(t);this._callContainerAggregationMethod("removeButton",e);this._aShareMenuActions.splice(this._aShareMenuActions.indexOf(t),1);this._postProcessOverflowToolbarButton(t);this._onControlRemoved();return this};a.prototype.destroy=function(){this._oShareMenuBtn=null;this._aShareMenuActions=null;this._aCustomShareActions=null;return r.prototype.destroy.call(this)};a.prototype._getMode=function(){return this._mode};a.prototype._setMode=function(t){if(this._getMode()===t){return this}if(t===a._Mode.initial){if(this._getMode()){this._fireContentChanged(true)}this._mode=a._Mode.initial;return this}if(t===a._Mode.menu){this._mode=a._Mode.menu;this._fireContentChanged(false)}return this};a.prototype._fireContentChanged=function(t){e.prototype.fireEvent.call(this._getParent(),"_shareMenuContentChanged",{bEmpty:t})};a.prototype._getShareMenuButton=function(){var e=this._getContainer();if(!this._oShareMenuBtn){this._oShareMenuBtn=new n(e.getId()+"-shareButton",{icon:t.getIconURI("action"),tooltip:sap.ui.getCore().getLibraryResourceBundle("sap.f").getText("SEMANTIC_CONTROL_ACTION_SHARE"),layoutData:new i({closeOverflowOnInteraction:false}),text:sap.ui.getCore().getLibraryResourceBundle("sap.f").getText("SEMANTIC_CONTROL_ACTION_SHARE"),type:s.Transparent,press:function(){e.openBy(this._oShareMenuBtn)}.bind(this)});this._oShareMenuBtn.addEventDelegate({onAfterRendering:function(){this._oShareMenuBtn.$().attr("aria-haspopup",true)}.bind(this)},this)}return this._oShareMenuBtn};a.prototype._getCustomActionInsertIndex=function(t){var e=this._aCustomShareActions.length;if(t===undefined){return this._aShareMenuActions.length+e}t=t>=e?e:t;t+=this._aShareMenuActions.length;return t};a.prototype._getSemanticActionInsertIndex=function(t){this._aShareMenuActions.sort(this._sortControlByOrder.bind(this));return this._aShareMenuActions.indexOf(t)};a.prototype._onControlAdded=function(t){if(this._isInitialMode()){this._setMode(a._Mode.menu,t)}};a.prototype._onControlRemoved=function(){var t=this._aShareMenuActions.length,e=this._aCustomShareActions.length,o=t+e===0;if(this._isMenuMode()&&o){this._setMode(a._Mode.initial)}};a.prototype._preProcessOverflowToolbarButton=function(t){if(t instanceof n){t._bInOverflow=true}};a.prototype._postProcessOverflowToolbarButton=function(t){if(t instanceof n){delete t._bInOverflow}};a.prototype._isInitialMode=function(){return this._getMode()===a._Mode.initial};a.prototype._isMenuMode=function(){return this._getMode()===a._Mode.menu};return a});