(function(d){"function"===typeof define&&define.amd?define("jquery ./core ./widget ./button ./draggable ./mouse ./position ./resizable".split(" "),d):d(jQuery)})(function(d){return d.widget("ui.dialog",{version:"1.11.4",options:{appendTo:"body",autoOpen:!0,buttons:[],closeOnEscape:!0,closeText:"Close",dialogClass:"",draggable:!0,hide:null,height:"auto",maxHeight:null,maxWidth:null,minHeight:150,minWidth:150,modal:!1,position:{my:"center",at:"center",of:window,collision:"fit",using:function(a){var b=
d(this).css(a).offset().top;0>b&&d(this).css("top",a.top-b)}},resizable:!0,show:null,title:null,width:300,beforeClose:null,close:null,drag:null,dragStart:null,dragStop:null,focus:null,open:null,resize:null,resizeStart:null,resizeStop:null},sizeRelatedOptions:{buttons:!0,height:!0,maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0,width:!0},resizableRelatedOptions:{maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0},_create:function(){this.originalCss={display:this.element[0].style.display,width:this.element[0].style.width,
minHeight:this.element[0].style.minHeight,maxHeight:this.element[0].style.maxHeight,height:this.element[0].style.height};this.originalPosition={parent:this.element.parent(),index:this.element.parent().children().index(this.element)};this.originalTitle=this.element.attr("title");this.options.title=this.options.title||this.originalTitle;this._createWrapper();this.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(this.uiDialog);this._createTitlebar();this._createButtonPane();
this.options.draggable&&d.fn.draggable&&this._makeDraggable();this.options.resizable&&d.fn.resizable&&this._makeResizable();this._isOpen=!1;this._trackFocus()},_init:function(){this.options.autoOpen&&this.open()},_appendTo:function(){var a=this.options.appendTo;return a&&(a.jquery||a.nodeType)?d(a):this.document.find(a||"body").eq(0)},_destroy:function(){var a,b=this.originalPosition;this._untrackInstance();this._destroyOverlay();this.element.removeUniqueId().removeClass("ui-dialog-content ui-widget-content").css(this.originalCss).detach();
this.uiDialog.stop(!0,!0).remove();this.originalTitle&&this.element.attr("title",this.originalTitle);a=b.parent.children().eq(b.index);a.length&&a[0]!==this.element[0]?a.before(this.element):b.parent.append(this.element)},widget:function(){return this.uiDialog},disable:d.noop,enable:d.noop,close:function(a){var b,e=this;if(this._isOpen&&!1!==this._trigger("beforeClose",a)){this._isOpen=!1;this._focusedElement=null;this._destroyOverlay();this._untrackInstance();if(!this.opener.filter(":focusable").focus().length)try{(b=
this.document[0].activeElement)&&"body"!==b.nodeName.toLowerCase()&&d(b).blur()}catch(c){}this._hide(this.uiDialog,this.options.hide,function(){e._trigger("close",a)})}},isOpen:function(){return this._isOpen},moveToTop:function(){this._moveToTop()},_moveToTop:function(a,b){var e=!1,c=this.uiDialog.siblings(".ui-front:visible").map(function(){return+d(this).css("z-index")}).get(),c=Math.max.apply(null,c);c>=+this.uiDialog.css("z-index")&&(this.uiDialog.css("z-index",c+1),e=!0);e&&!b&&this._trigger("focus",
a);return e},open:function(){var a=this;this._isOpen?this._moveToTop()&&this._focusTabbable():(this._isOpen=!0,this.opener=d(this.document[0].activeElement),this._size(),this._position(),this._createOverlay(),this._moveToTop(null,!0),this.overlay&&this.overlay.css("z-index",this.uiDialog.css("z-index")-1),this._show(this.uiDialog,this.options.show,function(){a._focusTabbable();a._trigger("focus")}),this._makeFocusTarget(),this._trigger("open"))},_focusTabbable:function(){var a=this._focusedElement;
a||(a=this.element.find("[autofocus]"));a.length||(a=this.element.find(":tabbable"));a.length||(a=this.uiDialogButtonPane.find(":tabbable"));a.length||(a=this.uiDialogTitlebarClose.filter(":tabbable"));a.length||(a=this.uiDialog);a.eq(0).focus()},_keepFocus:function(a){function b(){var a=this.document[0].activeElement;this.uiDialog[0]===a||d.contains(this.uiDialog[0],a)||this._focusTabbable()}a.preventDefault();b.call(this);this._delay(b)},_createWrapper:function(){this.uiDialog=d("<div>").addClass("ui-dialog ui-widget ui-widget-content ui-corner-all ui-front "+
this.options.dialogClass).hide().attr({tabIndex:-1,role:"dialog"}).appendTo(this._appendTo());this._on(this.uiDialog,{keydown:function(a){if(this.options.closeOnEscape&&!a.isDefaultPrevented()&&a.keyCode&&a.keyCode===d.ui.keyCode.ESCAPE)a.preventDefault(),this.close(a);else if(a.keyCode===d.ui.keyCode.TAB&&!a.isDefaultPrevented()){var b=this.uiDialog.find(":tabbable"),e=b.filter(":first"),c=b.filter(":last");a.target!==c[0]&&a.target!==this.uiDialog[0]||a.shiftKey?a.target!==e[0]&&a.target!==this.uiDialog[0]||
!a.shiftKey||(this._delay(function(){c.focus()}),a.preventDefault()):(this._delay(function(){e.focus()}),a.preventDefault())}},mousedown:function(a){this._moveToTop(a)&&this._focusTabbable()}});this.element.find("[aria-describedby]").length||this.uiDialog.attr({"aria-describedby":this.element.uniqueId().attr("id")})},_createTitlebar:function(){var a;this.uiDialogTitlebar=d("<div>").addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").prependTo(this.uiDialog);this._on(this.uiDialogTitlebar,
{mousedown:function(a){d(a.target).closest(".ui-dialog-titlebar-close")||this.uiDialog.focus()}});this.uiDialogTitlebarClose=d("<button type='button'></button>").button({label:this.options.closeText,icons:{primary:"ui-icon-closethick"},text:!1}).addClass("ui-dialog-titlebar-close").appendTo(this.uiDialogTitlebar);this._on(this.uiDialogTitlebarClose,{click:function(a){a.preventDefault();this.close(a)}});a=d("<span>").uniqueId().addClass("ui-dialog-title").prependTo(this.uiDialogTitlebar);this._title(a);
this.uiDialog.attr({"aria-labelledby":a.attr("id")})},_title:function(a){this.options.title||a.html("&#160;");a.text(this.options.title)},_createButtonPane:function(){this.uiDialogButtonPane=d("<div>").addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix");this.uiButtonSet=d("<div>").addClass("ui-dialog-buttonset").appendTo(this.uiDialogButtonPane);this._createButtons()},_createButtons:function(){var a=this,b=this.options.buttons;this.uiDialogButtonPane.remove();this.uiButtonSet.empty();
d.isEmptyObject(b)||d.isArray(b)&&!b.length?this.uiDialog.removeClass("ui-dialog-buttons"):(d.each(b,function(b,c){var f,g;c=d.isFunction(c)?{click:c,text:b}:c;c=d.extend({type:"button"},c);f=c.click;c.click=function(){f.apply(a.element[0],arguments)};g={icons:c.icons,text:c.showText};delete c.icons;delete c.showText;d("<button></button>",c).button(g).appendTo(a.uiButtonSet)}),this.uiDialog.addClass("ui-dialog-buttons"),this.uiDialogButtonPane.appendTo(this.uiDialog))},_makeDraggable:function(){function a(a){return{position:a.position,
offset:a.offset}}var b=this,e=this.options;this.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",handle:".ui-dialog-titlebar",containment:"document",start:function(c,e){d(this).addClass("ui-dialog-dragging");b._blockFrames();b._trigger("dragStart",c,a(e))},drag:function(c,d){b._trigger("drag",c,a(d))},stop:function(c,f){var g=f.offset.left-b.document.scrollLeft(),k=f.offset.top-b.document.scrollTop();e.position={my:"left top",at:"left"+(0<=g?"+":"")+g+" top"+(0<=k?"+":"")+
k,of:b.window};d(this).removeClass("ui-dialog-dragging");b._unblockFrames();b._trigger("dragStop",c,a(f))}})},_makeResizable:function(){function a(a){return{originalPosition:a.originalPosition,originalSize:a.originalSize,position:a.position,size:a.size}}var b=this,e=this.options,c=e.resizable,f=this.uiDialog.css("position"),c="string"===typeof c?c:"n,e,s,w,se,sw,ne,nw";this.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:this.element,maxWidth:e.maxWidth,maxHeight:e.maxHeight,
minWidth:e.minWidth,minHeight:this._minHeight(),handles:c,start:function(c,e){d(this).addClass("ui-dialog-resizing");b._blockFrames();b._trigger("resizeStart",c,a(e))},resize:function(c,d){b._trigger("resize",c,a(d))},stop:function(c,f){var h=b.uiDialog.offset(),l=h.left-b.document.scrollLeft(),h=h.top-b.document.scrollTop();e.height=b.uiDialog.height();e.width=b.uiDialog.width();e.position={my:"left top",at:"left"+(0<=l?"+":"")+l+" top"+(0<=h?"+":"")+h,of:b.window};d(this).removeClass("ui-dialog-resizing");
b._unblockFrames();b._trigger("resizeStop",c,a(f))}}).css("position",f)},_trackFocus:function(){this._on(this.widget(),{focusin:function(a){this._makeFocusTarget();this._focusedElement=d(a.target)}})},_makeFocusTarget:function(){this._untrackInstance();this._trackingInstances().unshift(this)},_untrackInstance:function(){var a=this._trackingInstances(),b=d.inArray(this,a);-1!==b&&a.splice(b,1)},_trackingInstances:function(){var a=this.document.data("ui-dialog-instances");a||(a=[],this.document.data("ui-dialog-instances",
a));return a},_minHeight:function(){var a=this.options;return"auto"===a.height?a.minHeight:Math.min(a.minHeight,a.height)},_position:function(){var a=this.uiDialog.is(":visible");a||this.uiDialog.show();this.uiDialog.position(this.options.position);a||this.uiDialog.hide()},_setOptions:function(a){var b=this,e=!1,c={};d.each(a,function(a,d){b._setOption(a,d);a in b.sizeRelatedOptions&&(e=!0);a in b.resizableRelatedOptions&&(c[a]=d)});e&&(this._size(),this._position());this.uiDialog.is(":data(ui-resizable)")&&
this.uiDialog.resizable("option",c)},_setOption:function(a,b){var d,c=this.uiDialog;"dialogClass"===a&&c.removeClass(this.options.dialogClass).addClass(b);"disabled"!==a&&(this._super(a,b),"appendTo"===a&&this.uiDialog.appendTo(this._appendTo()),"buttons"===a&&this._createButtons(),"closeText"===a&&this.uiDialogTitlebarClose.button({label:""+b}),"draggable"===a&&((d=c.is(":data(ui-draggable)"))&&!b&&c.draggable("destroy"),!d&&b&&this._makeDraggable()),"position"===a&&this._position(),"resizable"===
a&&((d=c.is(":data(ui-resizable)"))&&!b&&c.resizable("destroy"),d&&"string"===typeof b&&c.resizable("option","handles",b),d||!1===b||this._makeResizable()),"title"===a&&this._title(this.uiDialogTitlebar.find(".ui-dialog-title")))},_size:function(){var a,b,d,c=this.options;this.element.show().css({width:"auto",minHeight:0,maxHeight:"none",height:0});c.minWidth>c.width&&(c.width=c.minWidth);a=this.uiDialog.css({height:"auto",width:c.width}).outerHeight();b=Math.max(0,c.minHeight-a);d="number"===typeof c.maxHeight?
Math.max(0,c.maxHeight-a):"none";"auto"===c.height?this.element.css({minHeight:b,maxHeight:d,height:"auto"}):this.element.height(Math.max(0,c.height-a));this.uiDialog.is(":data(ui-resizable)")&&this.uiDialog.resizable("option","minHeight",this._minHeight())},_blockFrames:function(){this.iframeBlocks=this.document.find("iframe").map(function(){var a=d(this);return d("<div>").css({position:"absolute",width:a.outerWidth(),height:a.outerHeight()}).appendTo(a.parent()).offset(a.offset())[0]})},_unblockFrames:function(){this.iframeBlocks&&
(this.iframeBlocks.remove(),delete this.iframeBlocks)},_allowInteraction:function(a){return d(a.target).closest(".ui-dialog").length?!0:!!d(a.target).closest(".ui-datepicker").length},_createOverlay:function(){if(this.options.modal){var a=!0;this._delay(function(){a=!1});this.document.data("ui-dialog-overlays")||this._on(this.document,{focusin:function(b){a||this._allowInteraction(b)||(b.preventDefault(),this._trackingInstances()[0]._focusTabbable())}});this.overlay=d("<div>").addClass("ui-widget-overlay ui-front").appendTo(this._appendTo());
this._on(this.overlay,{mousedown:"_keepFocus"});this.document.data("ui-dialog-overlays",(this.document.data("ui-dialog-overlays")||0)+1)}},_destroyOverlay:function(){if(this.options.modal&&this.overlay){var a=this.document.data("ui-dialog-overlays")-1;a?this.document.data("ui-dialog-overlays",a):this.document.unbind("focusin").removeData("ui-dialog-overlays");this.overlay.remove();this.overlay=null}}})});