text: /**
   * @license
   * Copyright (c) 2014, 2018, Oracle and/or its affiliates.
   * The Universal Permissive License (UPL), Version 1.0
   */
  "use strict";define(["ojs/ojcore","jquery","promise","ojs/ojcomponentcore","ojs/ojpopupcore","ojs/ojanimation"],function(e,t){var i,s,o={properties:{autoDismiss:{type:"string",enumValues:["focusLoss","none"],value:"focusLoss"},chrome:{type:"string",enumValues:["default","none"],value:"default"},initialFocus:{type:"string",enumValues:["auto","firstFocusable","none","popup"],value:"auto"},modality:{type:"string",enumValues:["modal","modeless"],value:"modeless"},position:{type:"object",properties:{at:{type:"object",properties:{horizontal:{type:"string",enumValues:["center","end","left","right","start"],value:"start"},vertical:{type:"string",enumValues:["bottom","center","top"],value:"top"}}},collision:{type:"string",enumValues:["fit","flip","flipcenter","flipfit","none"],value:"flip"},my:{type:"object",properties:{horizontal:{type:"string",enumValues:["center","end","left","right","start"],value:"start"},vertical:{type:"string",enumValues:["bottom","center","top"],value:"top"}}},of:{type:"string|object"},offset:{type:"object",properties:{x:{type:"number",value:0},y:{type:"number",value:0}}}}},tail:{type:"string",enumValues:["none","simple"],value:"none"},translations:{type:"object",value:{}}},methods:{open:{},close:{},isOpen:{},refresh:{},setProperty:{},getProperty:{},setProperties:{},getNodeBySubId:{},getSubIdByNode:{}},events:{ojBeforeOpen:{},ojOpen:{},ojBeforeClose:{},ojClose:{},ojFocus:{},ojAnimateStart:{},ojAnimateEnd:{}},extension:{}};i=["oj-left","oj-center","oj-right","oj-top","oj-middle","oj-bottom"],s={"right-top":"oj-right oj-top","right-middle":"oj-right oj-middle","right-bottom":"oj-right oj-bottom","left-top":"oj-left oj-top","left-middle":"oj-left oj-middle","left-bottom":"oj-left oj-bottom","center-top":"oj-center oj-top","center-middle":"oj-left oj-middle","center-bottom":"oj-center oj-bottom"},e.__registerWidget("oj.ojPopup",t.oj.baseComponent,{widgetEventPrefix:"oj",options:{animation:null,autoDismiss:"focusLoss",chrome:"default",initialFocus:"auto",position:{my:{horizontal:"start",vertical:"top"},offset:{x:0,y:0},at:{horizontal:"start",vertical:"bottom"},of:void 0,collision:"flip"},tail:"none",modality:"modeless",role:"tooltip",beforeOpen:null,open:null,beforeClose:null,close:null,focus:null,animateStart:null,animateEnd:null},_ComponentCreate:function(){this._super();var i=this._getRootStyle(),s=this.element;s.hide().addClass(i).attr("aria-hidden","true"),s.addClass("oj-component");var o=t("<div>");o.addClass([i,"content"].join("-")),o.attr("role","presentation"),o.append(s[0].childNodes),o.appendTo(s),this._content=o,this._setChrome(),this._setupFocus(s);var n=this.options;n.position=e.PositionUtils.coerceToJet(n.position)},_AfterCreate:function(){this._super(),this.element.uniqueId(),this._createTail()},_destroy:function(){e.ZOrderUtils.getStatus(this.element)===e.ZOrderUtils.STATUS.OPEN&&this._closeImplicitly(),this._setWhenReady("none"),this._destroyTail(),delete this._popupServiceEvents;var t=this.element;t.hide().attr("aria-hidden","true").removeUniqueId();var i=this._content;delete this._content,t.append(i[0].childNodes),i.remove();var s=this._closeDelayTimer;s&&(delete this._closeDelayTimer,s()),this._super()},open:function(t,i){if(!this._isOperationPending("open",[t,i])){e.ZOrderUtils.getStatus(this.element)===e.ZOrderUtils.STATUS.OPEN&&this._closeImplicitly(),this._setLauncher(t);var s=this.element;if(t=this._launcher,!1!==this._trigger("beforeOpen")){this._setWhenReady("open");var o=this.options;(i=i||o.position).of||(this._hasPositionOfLauncherOverride=!0,i.of=t),this._setPosition(i),this._setAutoDismiss(o.autoDismiss),this._addDescribedBy(),this._IsCustomElement()&&s[0].hasAttribute("role")||s.attr("role",o.role),i=this._getPositionAsJqUi();var n=this._getRootStyle(),r=[n,"layer"].join("-"),a=o.tail;"none"!==a&&(r+=" "+[n,"tail",a].join("-"));var l={};l[e.PopupService.OPTION.POPUP]=s,l[e.PopupService.OPTION.LAUNCHER]=t,l[e.PopupService.OPTION.POSITION]=i,l[e.PopupService.OPTION.EVENTS]=this._getPopupServiceEvents(),l[e.PopupService.OPTION.LAYER_SELECTORS]=r,l[e.PopupService.OPTION.MODALITY]=o.modality,l[e.PopupService.OPTION.CUSTOM_ELEMENT]=this._IsCustomElement(),e.PopupService.getInstance().open(l)}}},_beforeOpenHandler:function(t){var i=t[e.PopupService.OPTION.POPUP],s=t[e.PopupService.OPTION.POSITION];i.show(),i.position(s);var o=this.options.animation;if(o&&o.open){var n=o.actionPrefix,r=n?[n,"open"].join("-"):"open";return e.AnimationUtils.startAnimation(i[0],r,e.PositionUtils.addTransformOriginAnimationEffectsOption(i,o.open),this)}},_afterOpenHandler:function(t){var i=t[e.PopupService.OPTION.POPUP],s=t[e.PopupService.OPTION.LAUNCHER];this._initVoiceOverAssist(),this._trigger("open"),this._intialFocus(),this._on(i,{keydown:this._keyHandler,keyup:this._keyHandler}),s&&s.length>0&&this._on(s,{keydown:this._keyHandler,keyup:this._keyHandler})},_GetContextMenu:function(){if(!this._IsCustomElement())return this._super();var t=e.BaseCustomElementBridge.getSlotMap(this._content[0]).contextMenu;return t&&t.length>0?t[0]:void 0},close:function(){if(!this._isOperationPending("close",[])&&e.ZOrderUtils.getStatus(this.element)===e.ZOrderUtils.STATUS.OPEN&&(!1!==this._trigger("beforeClose")||this._ignoreBeforeCloseResultant)){this._setWhenReady("close"),this._restoreFocus();var t=this._launcher,i=this.element;this._off(i,"keydown keyup"),t&&t.length>0&&this._off(t,"keydown keyup"),this._destroyVoiceOverAssist();var s={};s[e.PopupService.OPTION.POPUP]=i,e.PopupService.getInstance().close(s)}},_beforeCloseHandler:function(t){var i=t[e.PopupService.OPTION.POPUP],s=this.options.animation;if(!this._ignoreBeforeCloseResultant&&s&&s.close){var o=i.attr("style"),n=s.actionPrefix,r=n?[n,"close"].join("-"):"close";return e.AnimationUtils.startAnimation(i[0],r,e.PositionUtils.addTransformOriginAnimationEffectsOption(i,s.close),this).then(function(){i.attr("style",o),i.hide()})}i.hide()},_afterCloseHandler:function(e){this._removeDescribedBy(),this._setAutoDismiss(),delete this._launcher,this._trigger("close"),this._hasPositionOfLauncherOverride&&(this.options.position.of=null,delete this._hasPositionOfLauncherOverride)},isOpen:function(){var t=e.ZOrderUtils.getStatus(this.element);return t===e.ZOrderUtils.STATUS.OPENING||t===e.ZOrderUtils.STATUS.OPEN||t===e.ZOrderUtils.STATUS.CLOSING},refresh:function(){if(this._super(),e.ZOrderUtils.getStatus(this.element)===e.ZOrderUtils.STATUS.OPEN&&this._reposition()){var t=this.element;e.PopupService.getInstance().triggerOnDescendents(t,e.PopupService.EVENT.POPUP_REFRESH)}},_setOption:function(t,i){var s=this.options;switch(t){case"tail":i!==s.tail&&this._setTail(i);break;case"chrome":i!==s.chrome&&this._setChrome(i);break;case"position":return this._setPosition(i),void this.refresh();case"autoDismiss":e.ZOrderUtils.getStatus(this.element)===e.ZOrderUtils.STATUS.OPEN&&i!==s.autoDismiss&&this._setAutoDismiss(i);break;case"modality":if(e.ZOrderUtils.getStatus(this.element)===e.ZOrderUtils.STATUS.OPEN){var o=this.element,n={};n[e.PopupService.OPTION.POPUP]=o,n[e.PopupService.OPTION.MODALITY]=i,e.PopupService.getInstance().changeOptions(n)}}this._superApply(arguments)},_getRootStyle:function(){return"oj-popup"},_setTail:function(e){this._destroyTail(),this._createTail(e),this._reposition()},_createTail:function(i){var s=i||this.options.tail;if("none"!==s){var o=this._getRootStyle(),n=[o,"tail"].join("-"),r=[n,s].join("-"),a=t("<div>").hide();a.addClass(n).addClass(r),a.attr("role","presentation"),this._tailId=a.attr("id",this._getSubId("tail")).attr("id");var l=this.element;if(a.appendTo(l),l.addClass(r),e.ZOrderUtils.getStatus(this.element)===e.ZOrderUtils.STATUS.OPEN){var u=[o,"layer"].join("-");u+=" "+r;var c={};c[e.PopupService.OPTION.POPUP]=l,c[e.PopupService.OPTION.LAYER_SELECTORS]=u,e.PopupService.getInstance().changeOptions(c)}}},_getTail:function(){var e=this._tailId;return e?t(document.getElementById(e)):null},_destroyTail:function(){var t=this._getTail();t&&t.remove(),delete this._tailId;var i=this.options.tail,s=this._getRootStyle(),o=[s,"tail",i].join("-"),n=this.element;if(n.removeClass(o),e.ZOrderUtils.getStatus(this.element)===e.ZOrderUtils.STATUS.OPEN){var r=[s,"layer"].join("-"),a={};a[e.PopupService.OPTION.POPUP]=n,a[e.PopupService.OPTION.LAYER_SELECTORS]=r,e.PopupService.getInstance().changeOptions(a)}},_setChrome:function(e){var t=e||this.options.chrome,i=[this._getRootStyle(),"no-chrome"].join("-"),s=this.element;"default"===t&&s.hasClass(i)?s.removeClass(i):"none"!==t||s.hasClass(i)||s.addClass(i)},_setLauncher:function(i){if(i?"string"===t.type(i)?i=t(i):1===i.nodeType&&(i=t(i)):i=t(document.activeElement),i instanceof t&&i.length>1)for(var s=this.element,o=0;o<i.length;o++){var n=i[0];if(!e.DomUtils.isAncestorOrSelf(s[0],n)){i=t(n);break}}else i instanceof t&&!(i instanceof t&&0===i.length)||(i=t(document.activeElement));this._launcher=i},_setPosition:function(t){var i=this.options;t&&(i.position=e.PositionUtils.coerceToJet(t,i.position))},_getPositionAsJqUi:function(){var i=this.options,s=e.PositionUtils.coerceToJqUi(i.position),o="rtl"===this._GetReadingDirection(),n=(s=e.PositionUtils.normalizeHorizontalAlignment(s,o)).using;return n=t.isFunction(n)?n:null,s.using=this._usingHandler.bind(this,n),s},_resolveBusyStateAndCloseImplicitly:function(e){e(),delete this._closeDelayTimer,this._closeImplicitly()},_resolveBusyStateAndCancelDelayedClosure:function(e,t){window.clearTimeout(e),t()},_usingHandler:function(t,o,n){var r=n.element.element;if(o.top!==r.css("top")||o.left!==r.css("left")){var a=this._getTail();if(a){a.hide();for(var l=0;l<i.length;l++)a.removeClass(i[l]),r.removeClass(i[l]);if(a.removeAttr("style"),n.target&&0===n.target.height&&0===n.target.width){var u="rtl"===this._GetReadingDirection(),c=e.PositionUtils.normalizeHorizontalAlignment(this.options.position,u).my;if(!e.StringUtils.isEmptyOrUndefined(c)){var p="center"===c.horizontal?c.horizontal:n.horizontal,h="center"===c.vertical?"middle":c.vertical;n.horizontal=p,n.vertical=h}}var d=[n.horizontal,n.vertical].join("-"),f=s[d];if(a.addClass(f),r.addClass(f),a.show(),"left"===n.horizontal){var m=a.outerWidth();m-=m+e.DomUtils.getCSSLengthAsInt(a.css("left")),o.left=o.left+(m-2)}else"right"===n.horizontal&&(m=a.outerWidth(),m-=m+e.DomUtils.getCSSLengthAsInt(a.css("right")),o.left=o.left-(m-2));if("top"===n.vertical){var _=a.outerHeight();_-=_+e.DomUtils.getCSSLengthAsInt(a.css(n.vertical)),o.top=o.top+(_-2)}else"bottom"===n.vertical&&(_=a.outerHeight(),_-=_+e.DomUtils.getCSSLengthAsInt(a.css(n.vertical)),o.top=o.top-(_-2));if(r.css(o),"center"===n.horizontal&&"middle"!==n.vertical){var v=r.width(),g=Math.round((v/2-a.outerWidth()/2)/v*100);a.css({left:g+"%"})}else if("middle"===n.vertical){var P=r.height(),O=Math.round((P/2-a.outerHeight()/2)/P*100);a.css({top:O+"%"})}}else r.css(o);if(e.PositionUtils.captureTransformOriginAnimationEffectsOption(r,n),t&&t(o,n),"focusLoss"===this.options.autoDismiss&&e.PositionUtils.isAligningPositionClipped(n)){this._ignoreRestoreFocus=!0;var S=e.Context.getContext(this.element[0]).getBusyContext(),y={description:["ojPopup identified by '",this.element.attr("id"),"' is pending implicit closure."].join("")},T=S.addBusyState(y),U=window.setTimeout(this._resolveBusyStateAndCloseImplicitly.bind(this,T),0);this._closeDelayTimer=this._resolveBusyStateAndCancelDelayedClosure.bind(this,U,T)}}},_reposition:function(){var i=this.element,s=this._getPositionAsJqUi();if(e.StringUtils.isString(s.of)){var o=t(s.of);if(0===o.length)return!1;s.of=o}return i.position(s),!0},_intialFocus:function(t){var i=this._deriveInitialFocus();if(t&&"none"===i&&(i="popup"),"firstFocusable"===i){for(var s,o=this._content.find(":focusable"),n=0;n<o.length;n++)if(e.FocusUtils.isFocusable(o[n])){s=o[n];break}s?(s.focus(),this._trigger("focus")):i="popup"}if("popup"===i){var r=this.element;r.attr("tabindex","-1");var a=this._closeSkipLink;a?a.getLink().focus():r.focus(),this._trigger("focus")}},_deriveInitialFocus:function(){var t=this.options,i=t.initialFocus;return"auto"===i&&(i="modal"===t.modality?e.DomUtils.isTouchSupported()?"popup":"firstFocusable":"none"),i},_isFocusInPopup:function(t,i){if(t||(t=document.activeElement),!t)return!1;var s=this.element;return i&&(s=s.parent()),e.DomUtils.isAncestorOrSelf(s[0],t)},_isFocusInLauncher:function(t){t||(t=document.activeElement);var i=this._launcher;return e.DomUtils.isAncestorOrSelf(i[0],t)},_restoreFocus:function(){this._ignoreRestoreFocus?delete this._ignoreRestoreFocus:this._isFocusInPopup(null,!0)&&this._launcher.focus()},_keyHandler:function(e){if(!e.isDefaultPrevented()){var i=e.type,s=this._content,o=e.target;if("keyup"===i&&e.keyCode===t.ui.keyCode.ESCAPE&&(this._isFocusInPopup(o)||this._isFocusInLauncher(o)))e.preventDefault(),this.close();else if("keydown"===i&&117===e.keyCode)this._isFocusInPopup(o)?"modeless"===this.options.modality?(e.preventDefault(),this._launcher.focus()):this.close():this._isFocusInLauncher(o)&&(e.preventDefault(),this._intialFocus(!0));else if("keydown"===i&&e.keyCode===t.ui.keyCode.TAB&&this._isFocusInPopup(o)){var n=s.find(":tabbable");if(n.length>0){var r=n[0],a=n[n.length-1],l=this.element;r!==o&&l[0]!==o||!e.shiftKey?a!==o||e.shiftKey||(e.preventDefault(),a===r?(l.attr("tabindex","-1"),l.focus()):t(r).focus()):(e.preventDefault(),r===a&&r===o?(l.attr("tabindex","-1"),l.focus()):t(a).focus())}else e.preventDefault(),"modeless"===this.options.modality?this._launcher.focus():this.close()}}},_setAutoDismiss:function(t){var i=this._focusLossCallback,s=this._getPopupServiceEvents();if(i&&(delete s[e.PopupService.EVENT.POPUP_AUTODISMISS],delete this._focusLossCallback),"focusLoss"===t&&(i=this._focusLossCallback=this._dismissalHandler.bind(this),s[e.PopupService.EVENT.POPUP_AUTODISMISS]=i),e.ZOrderUtils.getStatus(this.element)===e.ZOrderUtils.STATUS.OPEN){var o=this.element,n={};n[e.PopupService.OPTION.POPUP]=o,n[e.PopupService.OPTION.EVENTS]=s,e.PopupService.getInstance().changeOptions(n)}},_dismissalHandler:function(t){if(e.ZOrderUtils.getStatus(this.element)===e.ZOrderUtils.STATUS.OPEN){var i=this._launcher,s=this.element.parent(),o=t.target,n=this._focusSkipLink;if(n){var r=n.getLink();if(r&&e.DomUtils.isAncestorOrSelf(r[0],o))return}if(!e.DomUtils.isAncestorOrSelf(i[0],o)&&!e.DomUtils.isAncestorOrSelf(s[0],o)){if(e.FocusUtils.isFocusable(o)){if("mousedown"===t.type||"touchstart"===t.type)return;this._ignoreRestoreFocus=!0}this.close()}}},_addDescribedBy:function(){var e=this._launcher,i=this.element.attr("id"),s=e.attr("aria-describedby"),o=s?s.split(/\s+/):[];o.push(i),s=t.trim(o.join(" ")),e.attr("aria-describedby",s)},_removeDescribedBy:function(){var e=this._launcher,i=this.element;if(e&&0!==e.length){var s=i.attr("id"),o=e.attr("aria-describedby"),n=o?o.split(/\s+/):[],r=t.inArray(s,n);-1!==r&&n.splice(r,1),(o=t.trim(n.join(" ")))?e.attr("aria-describedby",o):e.removeAttr("aria-describedby")}},_initVoiceOverAssist:function(){var t,i=e.AgentUtils.getAgentInfo().os===e.AgentUtils.OS.IOS||e.AgentUtils.getAgentInfo().os===e.AgentUtils.OS.ANDROID,s=this._liveRegion;s||(s=this._liveRegion=new e.PopupLiveRegion);var o=this._deriveInitialFocus();if(t=i?this.getTranslatedString("none"===o?"ariaLiveRegionInitialFocusNoneTouch":"ariaLiveRegionInitialFocusFirstFocusableTouch"):this.getTranslatedString("none"===o?"ariaLiveRegionInitialFocusNone":"ariaLiveRegionInitialFocusFirstFocusable"),s.announce(t),i){var n=this._getSubId("focusSkipLink"),r=this._launcher,a=this._intialFocus.bind(this,!0);t=this.getTranslatedString("ariaFocusSkipLink"),this._focusSkipLink=new e.PopupSkipLink(r,t,a,n);var l=this._content,u=this._getSubId("closeSkipLink");a=this._closeImplicitly.bind(this),t=this.getTranslatedString("ariaCloseSkipLink"),this._closeSkipLink=new e.PopupSkipLink(l,t,a,u)}},_destroyVoiceOverAssist:function(){this._liveRegion.destroy(),delete this._liveRegion;var e=this._focusSkipLink;e&&(e.destroy(),delete this._focusSkipLink);var t=this._closeSkipLink;t&&(t.destroy(),delete this._closeSkipLink)},_getSubId:function(t){var i=this.element.attr("id");return e.StringUtils.isEmptyOrUndefined(i)&&(i=this.uuid),[i,t].join("_")},_surrogateRemoveHandler:function(){this.element.remove()},_getPopupServiceEvents:function(){if(!this._popupServiceEvents){var t=this._popupServiceEvents={};t[e.PopupService.EVENT.POPUP_CLOSE]=this._closeImplicitly.bind(this),t[e.PopupService.EVENT.POPUP_REMOVE]=this._surrogateRemoveHandler.bind(this),t[e.PopupService.EVENT.POPUP_REFRESH]=this.refresh.bind(this),t[e.PopupService.EVENT.POPUP_BEFORE_OPEN]=this._beforeOpenHandler.bind(this),t[e.PopupService.EVENT.POPUP_AFTER_OPEN]=this._afterOpenHandler.bind(this),t[e.PopupService.EVENT.POPUP_BEFORE_CLOSE]=this._beforeCloseHandler.bind(this),t[e.PopupService.EVENT.POPUP_AFTER_CLOSE]=this._afterCloseHandler.bind(this)}return this._popupServiceEvents},_closeImplicitly:function(){this._ignoreBeforeCloseResultant=!0,this.close(),delete this._ignoreBeforeCloseResultant},_setWhenReady:function(t){var i=this._whenReadyMediator;i&&(i.destroy(),delete this._whenReadyMediator),["open","close"].indexOf(t)<0||(this._whenReadyMediator=new e.PopupWhenReadyMediator(this.element,t,"ojPopup",this._IsCustomElement()))},_isOperationPending:function(e,t){var i=this._whenReadyMediator;return!!i&&i.isOperationPending(this,e,e,t)},_setupFocus:function(e){var i=this;this._focusable({applyHighlight:!0,setupHandlers:function(s,o){i._on(e,{focus:function(e){s(t(e.currentTarget))},blur:function(e){o(t(e.currentTarget))}})}})},_NotifyDetached:function(){e.ZOrderUtils.getStatus(this.element)===e.ZOrderUtils.STATUS.OPEN&&this._closeImplicitly(),this._super()}}),e.Components.setDefaultOptions({ojPopup:{modality:e.Components.createDynamicPropertyGetter(function(){return(e.ThemeUtils.parseJSONFromFontFamily("oj-popup-option-defaults")||{}).modality}),animation:e.Components.createDynamicPropertyGetter(function(){return(e.ThemeUtils.parseJSONFromFontFamily("oj-popup-option-defaults")||{}).animation})}}),o.extension._WIDGET_NAME="ojPopup",e.CustomElementBridge.registerMetadata("oj-popup","baseComponent",o),e.CustomElementBridge.register("oj-popup",{metadata:e.CustomElementBridge.getMetadata("oj-popup")})});