(()=>{var e={n:t=>{var a=t&&t.__esModule?()=>t.default:()=>t;return e.d(a,{a}),a},d:(t,a)=>{for(var o in a)e.o(a,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:a[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};(()=>{"use strict";const t=window.wp.domReady;var a=e.n(t);const o=()=>{try{return window.self!==window.top}catch(e){return!0}},n="starter-templates-iframe-preview-data",r=()=>{let e="";const t=document.querySelector(".site-logo-img img");return t&&(e=t.src),e};let s=r();const l=(e,t)=>{if(!e)return"";if(e){const a=e.match(/'([^']+)'/);return a?a[1]:"inherit"===e?t:e}return t||void 0},i=e=>{switch(e.value.param){case"siteLogo":const t=document.querySelectorAll(".site-logo-img img");""===s&&(s=r());let a=e.value.data.url||s;if(a=e.value.data.dataUri||a,0===t.length&&""!==a){const t=document.createElement("span");t.classList.add("site-logo-img");const o=document.createElement("a");o.setAttribute("class","custom-logo-link"),o.setAttribute("href","#"),o.setAttribute("aria-current","page"),t.appendChild(o);const n=document.createElement("img");n.classList.add("custom-logo"),n.setAttribute("src",a),o.appendChild(n);const r=document.getElementById("ast-desktop-header").querySelectorAll(".ast-site-identity")[0],s=r.querySelectorAll(".ast-site-title-wrap")[0];r.insertBefore(t,s);const l=e.value.data.width||"";""!==l&&(n.style.width=l+"px",n.style.maxWidth=l+"px")}else if(""!==a)for(const[o,n]of Object.entries(t)){n.removeAttribute("srcset"),n.setAttribute("src",a);const t=e.value.data.width;""!==t&&(n.style.width=t+"px",n.style.maxWidth=t+"px")}break;case"colorPalette":const o=e.value.data.colors||[],n=starter_templates_zip_preview.AstColorPaletteVarPrefix,i=starter_templates_zip_preview.AstEleColorPaletteVarPrefix;if(0===o.length){document.querySelector("body").classList.remove("starter-templates-preview-palette");const e=document.getElementsByClassName("starter-templates-preview-palette");return void(e.length>0&&e[0].remove())}document.querySelector("body").classList.add("starter-templates-preview-palette");const d=Object.entries(o).map(((e,t)=>[`--e-global-color-${i[t].replace(/-/g,"")}: ${e[1]};`,`${n}${t}: ${e[1]};`])).map((e=>e.join(""))).join("");let c=document.getElementById("starter-templates-preview-palette-css");c||(c=document.createElement("style"),c.id="starter-templates-preview-palette-css",c.setAttribute("rel","stylesheet"),document.head.appendChild(c)),c.innerHTML=`.starter-templates-preview-palette{ ${d}}`;break;case"siteTypography":if(!Object.keys(e.value.data).length){const e=document.getElementById("starter-templates-typography");return void(e&&e.remove())}(e=>{if(!e)return;if(!document.getElementById("google-fonts-domain")){const e=document.createElement("link");e.id="google-fonts-domain",e.setAttribute("rel","preconnect"),e.setAttribute("href","https://fonts.gstatic.com"),document.head.appendChild(e)}let t=document.getElementById("st-previw-google-fonts-url");t||(t=document.createElement("link"),t.id="st-previw-google-fonts-url",t.setAttribute("rel","stylesheet"),document.head.appendChild(t));const a=[];let o=e["body-font-family"]||"",n=parseInt(e["body-font-weight"])||"";n&&(n=`:wght@${n}`),o&&(o=l(o),o=o.replace(" ","+"),a.push(`family=${o}${n}`));let r=e["headings-font-family"]||"",s=parseInt(e["headings-font-weight"])||"";s&&(s=`:wght@${s}`),r&&(r=l(r,o),r=r.replace(" ","+"),a.push(`family=${r}${s}`));const i=`https://fonts.googleapis.com/css2?${a.join("&")}&display=swap`;t.setAttribute("href",i)})(e.value.data),(e=>{if(!e)return;let t=document.getElementById("starter-templates-typography");t||(t=document.createElement("style"),t.id="starter-templates-typography",t.setAttribute("rel","stylesheet"),document.head.appendChild(t));let a="";a+="body, button, input, select, textarea, .ast-button, .ast-custom-button {",a+="\tfont-family: "+e["body-font-family"]+";",a+="\tfont-weight: "+e["body-font-weight"]+";",a+="\tfont-size: "+e["font-size-body"].desktop+e["font-size-body"]["desktop-unit"]+";",a+="\tline-height: "+e["body-line-height"]+";",a+="}",a+="h1, .entry-content h1, h2, .entry-content h2, h3, .entry-content h3, h4, .entry-content h4, h5, .entry-content h5, h6, .entry-content h6, .site-title, .site-title a {",a+="\tfont-family: "+e["headings-font-family"]+";",a+="\tline-height: "+e["headings-line-height"]+";",a+="\tfont-weight: "+e["headings-font-weight"]+";",a+="}",["h1","h2","h3","h4","h5","h6"].forEach((t=>{const o="inherit"===e["font-family-"+t]?e["headings-font-family"]:e["font-family-"+t],n="inherit"===e["font-weight-"+t]?e["headings-font-weight"]:e["font-weight-"+t];let r="";void 0!==o&&""!==o&&(r+=`${t}, .entry-content ${t} {`,r+="\tfont-family: "+o+";"),void 0!==e["line-height-"+t]&&""!==e["line-height-"+t]&&(r+="\tline-height: "+e["line-height-"+t]+";"),void 0!==n&&""!==n&&(r+="\tfont-weight: "+n+";"),a+=""!==r?r+"}":""})),t.innerHTML=a})(e.value.data);break;case"siteTitle":(e=>{const t=document.getElementById("ast-desktop-header"),a=t&&t.querySelectorAll(".ast-site-identity")[0],o=a&&a.querySelectorAll(".ast-site-title-wrap")[0];o&&(o.style.display=e?"block":"none")})(e.value.data);break;case"clearPreviewAssets":const m=document.getElementById("starter-templates-typography");m&&m.remove(),document.querySelector("body").classList.remove("starter-templates-preview-palette");const p=document.getElementsByClassName("starter-templates-preview-palette");p.length>0&&p[0].remove();break;case"completeOnboarding":localStorage.removeItem("starter-templates-iframe-preview-data")}};window.addEventListener("message",(function(e){if(o()&&(console.log("addEventListener message: ",e),"object"==typeof e.data&&"starterTemplatePreviewDispatch"===e.data.call)){const t=e.data;let a=JSON.parse(localStorage.getItem(n));null===a&&(a={},a.data={}),a.data[t.value.param]=t.value.data,delete a.data.clearPreviewAssets,t.url=window.location.origin,a.url=window.location.origin,"cleanStorage"===t.value.param?(delete a.data.cleanStorage,a.data.siteLogo=t.value.data,a.data.colorPalette={},a.data.siteTypography={},Object.keys(a.data).map((e=>i({value:{param:e,data:a.data[e]}})))):i(t),localStorage.setItem(n,JSON.stringify(a))}}),!1),a()((()=>{if(!o())return;const e=document.createElement("style");e.id="starter-templates-logo-css",document.getElementsByTagName("head")[0].appendChild(e),e.innerHTML=".site-logo-img img { transition: unset; } #wpadminbar { display: none; } html{  margin-top: 0 !important; }}";const t=(a=n,JSON.parse(localStorage.getItem(a)));var a;t&&Object.keys(t.data).map((e=>i({value:{param:e,data:t.data[e]}})))}))})()})();
!function(a){a.suggest=function(b,c){function d(){var a=o.offset();p.css({top:a.top+b.offsetHeight+"px",left:a.left+"px"})}function e(a){if(/27$|38$|40$/.test(a.keyCode)&&p.is(":visible")||/^13$|^9$/.test(a.keyCode)&&k())switch(a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0,a.returnValue=!1,a.keyCode){case 38:n();break;case 40:m();break;case 9:case 13:l();break;case 27:p.hide()}else o.val().length!=r&&(q&&clearTimeout(q),q=setTimeout(f,c.delay),r=o.val().length)}function f(){var b,d,e=a.trim(o.val());c.multiple&&(b=e.lastIndexOf(c.multipleSep),-1!=b&&(e=a.trim(e.substr(b+c.multipleSep.length)))),e.length>=c.minchars?(cached=g(e),cached?i(cached.items):a.get(c.source,{q:e},function(a){p.hide(),d=j(a,e),i(d),h(e,d,a.length)})):p.hide()}function g(a){var b;for(b=0;b<s.length;b++)if(s[b].q==a)return s.unshift(s.splice(b,1)[0]),s[0];return!1}function h(a,b,d){for(var e;s.length&&t+d>c.maxCacheSize;)e=s.pop(),t-=e.size;s.push({q:a,size:d,items:b}),t+=d}function i(b){var e,f="";if(b){if(!b.length)return void p.hide();for(d(),e=0;e<b.length;e++)f+="<li>"+b[e]+"</li>";p.html(f).show(),p.children("li").mouseover(function(){p.children("li").removeClass(c.selectClass),a(this).addClass(c.selectClass)}).click(function(a){a.preventDefault(),a.stopPropagation(),l()})}}function j(b,d){var e,f,g=[],h=b.split(c.delimiter);for(e=0;e<h.length;e++)f=a.trim(h[e]),f&&(f=f.replace(new RegExp(d,"ig"),function(a){return'<span class="'+c.matchClass+'">'+a+"</span>"}),g[g.length]=f);return g}function k(){var a;return p.is(":visible")?(a=p.children("li."+c.selectClass),a.length||(a=!1),a):!1}function l(){$currentResult=k(),$currentResult&&(c.multiple?(-1!=o.val().indexOf(c.multipleSep)?$currentVal=o.val().substr(0,o.val().lastIndexOf(c.multipleSep)+c.multipleSep.length)+" ":$currentVal="",o.val($currentVal+$currentResult.text()+c.multipleSep+" "),o.focus()):o.val($currentResult.text()),p.hide(),o.trigger("change"),c.onSelect&&c.onSelect.apply(o[0]))}function m(){$currentResult=k(),$currentResult?$currentResult.removeClass(c.selectClass).next().addClass(c.selectClass):p.children("li:first-child").addClass(c.selectClass)}function n(){var a=k();a?a.removeClass(c.selectClass).prev().addClass(c.selectClass):p.children("li:last-child").addClass(c.selectClass)}var o,p,q,r,s,t;o=a(b).attr("autocomplete","off"),p=a("<ul/>"),q=!1,r=0,s=[],t=0,p.addClass(c.resultsClass).appendTo("body"),d(),a(window).on("load",d).on("resize",d),o.blur(function(){setTimeout(function(){p.hide()},200)}),o.keydown(e)},a.fn.suggest=function(b,c){return b?(c=c||{},c.multiple=c.multiple||!1,c.multipleSep=c.multipleSep||",",c.source=b,c.delay=c.delay||100,c.resultsClass=c.resultsClass||"ac_results",c.selectClass=c.selectClass||"ac_over",c.matchClass=c.matchClass||"ac_match",c.minchars=c.minchars||2,c.delimiter=c.delimiter||"\n",c.onSelect=c.onSelect||!1,c.maxCacheSize=c.maxCacheSize||65536,this.each(function(){new a.suggest(this,c)}),this):void 0}}(jQuery);
jQuery(function($){
window.wpuf_validate_address=function(e){
var country=$("td.bill_required").find('.wpuf_biiling_country, .input');
var state=$("td.bill_required").find('.wpuf_biiling_state, .input');
var add_1=$("#wpuf_biiling_add_line_1");
var add_2=$("#wpuf_biiling_add_line_2");
var city=$("#wpuf_biiling_city");
var zip=$("#wpuf_biiling_zip_code");
var isValid=true;
if(( country.val()===''||state.val()==='') ||
(add_1.hasClass('bill_required')&&add_1.val()==="") ||
(add_2.hasClass('bill_required')&&add_2.val()==="") ||
(city.hasClass('bill_required')&&city.val()==="") ||
(zip.hasClass('bill_required')&&zip.val()==="") ){
isValid=false;
}
return isValid;
};
$('#wpuf-payment-gateway').submit(function (e){
let form_data=WP_User_Frontend.validateForm($(this));
if(!form_data){
e.preventDefault();
}
var billing_address_form=$('#wpuf-ajax-address-form');
if(billing_address_form.length){
var inputs=[
{ id: '#wpuf_biiling_country', name: 'billing_country' },
{ id: '#wpuf_biiling_state', name: 'billing_state' },
{ id: '#wpuf_biiling_add_line_1', name: 'billing_add_line1' },
{ id: '#wpuf_biiling_add_line_2', name: 'billing_add_line2' },
{ id: '#wpuf_biiling_city', name: 'billing_city' },
{ id: '#wpuf_biiling_zip_code', name: 'billing_zip' },
];
inputs.map(function(input){
$('<input type="hidden" name="billing_address[' + input.name + ']" />')
.appendTo('#wpuf-payment-gateway')
.val($(input.id).val());
});
}});
$('#wpuf-ajax-address-form').submit(function (e){
e.preventDefault();
$('#wpuf-payment-gateway').trigger('submit');
});
$(document.body).on('change', 'select#wpuf_biiling_country', function(){
var $this=$(this), $tr=$this.closest('tr');
var data={
action: 'wpuf_ajax_address',
country: $(this).val(),
field_name: $("#wpuf_biiling_state").attr("name"),
_wpnonce: $("#_wpnonce").val()
};
$.post(ajax_object.ajaxurl, data, function (response){
if('nostates'==response){
var text_field='<input type="text" name="' + data.field_name + '" value=""/>';
$this.parent().next().find('select').replaceWith(text_field);
}else{
$this.parent().next().find('input,select').show();
$this.parent().next().find('input,select').replaceWith(response);
$this.parent().next().find('input,select').prepend("<option value='' selected='selected'>- select -</option>");
}});
});
$(document).ready(function (){
wpuf_calculate_tax();
});
$(document.body).on('change', 'form#wpuf-ajax-address-form', function (){
wpuf_calculate_tax();
});
var ajax_tax_count=0;
function wpuf_calculate_tax(){
var $wpuf_cc_address=jQuery('#wpuf-address-country-state');
var $payment_form=jQuery('#wpuf-payment-gateway');
var $address_form=jQuery('#wpuf-ajax-address-form');
if(! $address_form.length){
return;
}
var postData={
action: 'wpuf_update_billing_address',
billing_country: $wpuf_cc_address.find('#wpuf_biiling_country').val(),
billing_state: $wpuf_cc_address.find('#wpuf_biiling_state').val(),
billing_add_line1: $wpuf_cc_address.find('#wpuf_biiling_add_line_1').val(),
billing_add_line2: $wpuf_cc_address.find('#wpuf_biiling_add_line_2').val(),
billing_city: $wpuf_cc_address.find('#wpuf_biiling_city').val(),
billing_zip: $wpuf_cc_address.find('#wpuf_biiling_zip_code').val(),
type: $payment_form.find('#wpuf_type').html(),
id: $payment_form.find('#wpuf_id').html(),
_wpnonce: $address_form.find('#_wpnonce').val(),
};
var current_ajax_count=++ajax_tax_count;
jQuery.ajax({
type: "POST",
data: postData,
dataType: "json",
url: ajax_object.ajaxurl,
success: function (tax_response){
if((current_ajax_count===ajax_tax_count)&&tax_response){
jQuery('#wpuf_pay_page_tax').html(tax_response.tax);
jQuery('#wpuf_pay_page_total').html(tax_response.cost);
var tax_data=new Object();
tax_data.postdata=postData;
tax_data.response=tax_response;
}}
}).fail(function (data){
if(window.console&&window.console.log){
console.log(data);
}});
}});
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery","../ie","../version","../widget"],e):e(jQuery)}(function(o){"use strict";var n=!1;return o(document).on("mouseup",function(){n=!1}),o.widget("ui.mouse",{version:"1.13.3",options:{cancel:"input, textarea, button, select, option",distance:1,delay:0},_mouseInit:function(){var t=this;this.element.on("mousedown."+this.widgetName,function(e){return t._mouseDown(e)}).on("click."+this.widgetName,function(e){if(!0===o.data(e.target,t.widgetName+".preventClickEvent"))return o.removeData(e.target,t.widgetName+".preventClickEvent"),e.stopImmediatePropagation(),!1}),this.started=!1},_mouseDestroy:function(){this.element.off("."+this.widgetName),this._mouseMoveDelegate&&this.document.off("mousemove."+this.widgetName,this._mouseMoveDelegate).off("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(e){var t,i,s;if(!n)return this._mouseMoved=!1,this._mouseStarted&&this._mouseUp(e),i=1===(this._mouseDownEvent=e).which,s=!("string"!=typeof(t=this).options.cancel||!e.target.nodeName)&&o(e.target).closest(this.options.cancel).length,i&&!s&&this._mouseCapture(e)&&(this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){t.mouseDelayMet=!0},this.options.delay)),this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=!1!==this._mouseStart(e),!this._mouseStarted)?e.preventDefault():(!0===o.data(e.target,this.widgetName+".preventClickEvent")&&o.removeData(e.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(e){return t._mouseMove(e)},this._mouseUpDelegate=function(e){return t._mouseUp(e)},this.document.on("mousemove."+this.widgetName,this._mouseMoveDelegate).on("mouseup."+this.widgetName,this._mouseUpDelegate),e.preventDefault(),n=!0)),!0},_mouseMove:function(e){if(this._mouseMoved){if(o.ui.ie&&(!document.documentMode||document.documentMode<9)&&!e.button)return this._mouseUp(e);if(!e.which)if(e.originalEvent.altKey||e.originalEvent.ctrlKey||e.originalEvent.metaKey||e.originalEvent.shiftKey)this.ignoreMissingWhich=!0;else if(!this.ignoreMissingWhich)return this._mouseUp(e)}return(e.which||e.button)&&(this._mouseMoved=!0),this._mouseStarted?(this._mouseDrag(e),e.preventDefault()):(this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=!1!==this._mouseStart(this._mouseDownEvent,e),this._mouseStarted?this._mouseDrag(e):this._mouseUp(e)),!this._mouseStarted)},_mouseUp:function(e){this.document.off("mousemove."+this.widgetName,this._mouseMoveDelegate).off("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,e.target===this._mouseDownEvent.target&&o.data(e.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(e)),this._mouseDelayTimer&&(clearTimeout(this._mouseDelayTimer),delete this._mouseDelayTimer),this.ignoreMissingWhich=!1,n=!1,e.preventDefault()},_mouseDistanceMet:function(e){return Math.max(Math.abs(this._mouseDownEvent.pageX-e.pageX),Math.abs(this._mouseDownEvent.pageY-e.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}})});
!function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery","./mouse","../data","../ie","../scroll-parent","../version","../widget"],t):t(jQuery)}(function(u){"use strict";return u.widget("ui.sortable",u.ui.mouse,{version:"1.13.3",widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3,activate:null,beforeStop:null,change:null,deactivate:null,out:null,over:null,receive:null,remove:null,sort:null,start:null,stop:null,update:null},_isOverAxis:function(t,e,i){return e<=t&&t<e+i},_isFloating:function(t){return/left|right/.test(t.css("float"))||/inline|table-cell/.test(t.css("display"))},_create:function(){this.containerCache={},this._addClass("ui-sortable"),this.refresh(),this.offset=this.element.offset(),this._mouseInit(),this._setHandleClassName(),this.ready=!0},_setOption:function(t,e){this._super(t,e),"handle"===t&&this._setHandleClassName()},_setHandleClassName:function(){var t=this;this._removeClass(this.element.find(".ui-sortable-handle"),"ui-sortable-handle"),u.each(this.items,function(){t._addClass(this.instance.options.handle?this.item.find(this.instance.options.handle):this.item,"ui-sortable-handle")})},_destroy:function(){this._mouseDestroy();for(var t=this.items.length-1;0<=t;t--)this.items[t].item.removeData(this.widgetName+"-item");return this},_mouseCapture:function(t,e){var i=null,s=!1,o=this;return!(this.reverting||this.options.disabled||"static"===this.options.type||(this._refreshItems(t),u(t.target).parents().each(function(){if(u.data(this,o.widgetName+"-item")===o)return i=u(this),!1}),!(i=u.data(t.target,o.widgetName+"-item")===o?u(t.target):i))||(this.options.handle&&!e&&(u(this.options.handle,i).find("*").addBack().each(function(){this===t.target&&(s=!0)}),!s)||(this.currentItem=i,this._removeCurrentsFromItems(),0)))},_mouseStart:function(t,e,i){var s,o,r=this.options;if((this.currentContainer=this).refreshPositions(),this.appendTo=u("parent"!==r.appendTo?r.appendTo:this.currentItem.parent()),this.helper=this._createHelper(t),this._cacheHelperProportions(),this._cacheMargins(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},u.extend(this.offset,{click:{left:t.pageX-this.offset.left,top:t.pageY-this.offset.top},relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),r.cursorAt&&this._adjustOffsetFromHelper(r.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!==this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),this.scrollParent=this.placeholder.scrollParent(),u.extend(this.offset,{parent:this._getParentOffset()}),r.containment&&this._setContainment(),r.cursor&&"auto"!==r.cursor&&(o=this.document.find("body"),this.storedCursor=o.css("cursor"),o.css("cursor",r.cursor),this.storedStylesheet=u("<style>*{ cursor: "+r.cursor+" !important; }</style>").appendTo(o)),r.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",r.zIndex)),r.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",r.opacity)),this.scrollParent[0]!==this.document[0]&&"HTML"!==this.scrollParent[0].tagName&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",t,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions(),!i)for(s=this.containers.length-1;0<=s;s--)this.containers[s]._trigger("activate",t,this._uiHash(this));return u.ui.ddmanager&&(u.ui.ddmanager.current=this),u.ui.ddmanager&&!r.dropBehaviour&&u.ui.ddmanager.prepareOffsets(this,t),this.dragging=!0,this._addClass(this.helper,"ui-sortable-helper"),this.helper.parent().is(this.appendTo)||(this.helper.detach().appendTo(this.appendTo),this.offset.parent=this._getParentOffset()),this.position=this.originalPosition=this._generatePosition(t),this.originalPageX=t.pageX,this.originalPageY=t.pageY,this.lastPositionAbs=this.positionAbs=this._convertPositionTo("absolute"),this._mouseDrag(t),!0},_scroll:function(t){var e=this.options,i=!1;return this.scrollParent[0]!==this.document[0]&&"HTML"!==this.scrollParent[0].tagName?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-t.pageY<e.scrollSensitivity?this.scrollParent[0].scrollTop=i=this.scrollParent[0].scrollTop+e.scrollSpeed:t.pageY-this.overflowOffset.top<e.scrollSensitivity&&(this.scrollParent[0].scrollTop=i=this.scrollParent[0].scrollTop-e.scrollSpeed),this.overflowOffset.left+this.scrollParent[0].offsetWidth-t.pageX<e.scrollSensitivity?this.scrollParent[0].scrollLeft=i=this.scrollParent[0].scrollLeft+e.scrollSpeed:t.pageX-this.overflowOffset.left<e.scrollSensitivity&&(this.scrollParent[0].scrollLeft=i=this.scrollParent[0].scrollLeft-e.scrollSpeed)):(t.pageY-this.document.scrollTop()<e.scrollSensitivity?i=this.document.scrollTop(this.document.scrollTop()-e.scrollSpeed):this.window.height()-(t.pageY-this.document.scrollTop())<e.scrollSensitivity&&(i=this.document.scrollTop(this.document.scrollTop()+e.scrollSpeed)),t.pageX-this.document.scrollLeft()<e.scrollSensitivity?i=this.document.scrollLeft(this.document.scrollLeft()-e.scrollSpeed):this.window.width()-(t.pageX-this.document.scrollLeft())<e.scrollSensitivity&&(i=this.document.scrollLeft(this.document.scrollLeft()+e.scrollSpeed))),i},_mouseDrag:function(t){var e,i,s,o,r=this.options;for(this.position=this._generatePosition(t),this.positionAbs=this._convertPositionTo("absolute"),this.options.axis&&"y"===this.options.axis||(this.helper[0].style.left=this.position.left+"px"),this.options.axis&&"x"===this.options.axis||(this.helper[0].style.top=this.position.top+"px"),r.scroll&&!1!==this._scroll(t)&&(this._refreshItemPositions(!0),u.ui.ddmanager)&&!r.dropBehaviour&&u.ui.ddmanager.prepareOffsets(this,t),this.dragDirection={vertical:this._getDragVerticalDirection(),horizontal:this._getDragHorizontalDirection()},e=this.items.length-1;0<=e;e--)if(s=(i=this.items[e]).item[0],(o=this._intersectsWithPointer(i))&&i.instance===this.currentContainer&&!(s===this.currentItem[0]||this.placeholder[1===o?"next":"prev"]()[0]===s||u.contains(this.placeholder[0],s)||"semi-dynamic"===this.options.type&&u.contains(this.element[0],s))){if(this.direction=1===o?"down":"up","pointer"!==this.options.tolerance&&!this._intersectsWithSides(i))break;this._rearrange(t,i),this._trigger("change",t,this._uiHash());break}return this._contactContainers(t),u.ui.ddmanager&&u.ui.ddmanager.drag(this,t),this._trigger("sort",t,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(t,e){var i,s,o,r;if(t)return u.ui.ddmanager&&!this.options.dropBehaviour&&u.ui.ddmanager.drop(this,t),this.options.revert?(s=(i=this).placeholder.offset(),r={},(o=this.options.axis)&&"x"!==o||(r.left=s.left-this.offset.parent.left-this.margins.left+(this.offsetParent[0]===this.document[0].body?0:this.offsetParent[0].scrollLeft)),o&&"y"!==o||(r.top=s.top-this.offset.parent.top-this.margins.top+(this.offsetParent[0]===this.document[0].body?0:this.offsetParent[0].scrollTop)),this.reverting=!0,u(this.helper).animate(r,parseInt(this.options.revert,10)||500,function(){i._clear(t)})):this._clear(t,e),!1},cancel:function(){if(this.dragging){this._mouseUp(new u.Event("mouseup",{target:null})),"original"===this.options.helper?(this.currentItem.css(this._storedCSS),this._removeClass(this.currentItem,"ui-sortable-helper")):this.currentItem.show();for(var t=this.containers.length-1;0<=t;t--)this.containers[t]._trigger("deactivate",null,this._uiHash(this)),this.containers[t].containerCache.over&&(this.containers[t]._trigger("out",null,this._uiHash(this)),this.containers[t].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),"original"!==this.options.helper&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),u.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?u(this.domPosition.prev).after(this.currentItem):u(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(e){var t=this._getItemsAsjQuery(e&&e.connected),i=[];return e=e||{},u(t).each(function(){var t=(u(e.item||this).attr(e.attribute||"id")||"").match(e.expression||/(.+)[\-=_](.+)/);t&&i.push((e.key||t[1]+"[]")+"="+(e.key&&e.expression?t[1]:t[2]))}),!i.length&&e.key&&i.push(e.key+"="),i.join("&")},toArray:function(t){var e=this._getItemsAsjQuery(t&&t.connected),i=[];return t=t||{},e.each(function(){i.push(u(t.item||this).attr(t.attribute||"id")||"")}),i},_intersectsWith:function(t){var e=this.positionAbs.left,i=e+this.helperProportions.width,s=this.positionAbs.top,o=s+this.helperProportions.height,r=t.left,n=r+t.width,h=t.top,a=h+t.height,l=this.offset.click.top,c=this.offset.click.left,l="x"===this.options.axis||h<s+l&&s+l<a,c="y"===this.options.axis||r<e+c&&e+c<n;return"pointer"===this.options.tolerance||this.options.forcePointerForContainers||"pointer"!==this.options.tolerance&&this.helperProportions[this.floating?"width":"height"]>t[this.floating?"width":"height"]?l&&c:r<e+this.helperProportions.width/2&&i-this.helperProportions.width/2<n&&h<s+this.helperProportions.height/2&&o-this.helperProportions.height/2<a},_intersectsWithPointer:function(t){var e="x"===this.options.axis||this._isOverAxis(this.positionAbs.top+this.offset.click.top,t.top,t.height),t="y"===this.options.axis||this._isOverAxis(this.positionAbs.left+this.offset.click.left,t.left,t.width);return!(!e||!t)&&(e=this.dragDirection.vertical,t=this.dragDirection.horizontal,this.floating?"right"===t||"down"===e?2:1:e&&("down"===e?2:1))},_intersectsWithSides:function(t){var e=this._isOverAxis(this.positionAbs.top+this.offset.click.top,t.top+t.height/2,t.height),t=this._isOverAxis(this.positionAbs.left+this.offset.click.left,t.left+t.width/2,t.width),i=this.dragDirection.vertical,s=this.dragDirection.horizontal;return this.floating&&s?"right"===s&&t||"left"===s&&!t:i&&("down"===i&&e||"up"===i&&!e)},_getDragVerticalDirection:function(){var t=this.positionAbs.top-this.lastPositionAbs.top;return 0!=t&&(0<t?"down":"up")},_getDragHorizontalDirection:function(){var t=this.positionAbs.left-this.lastPositionAbs.left;return 0!=t&&(0<t?"right":"left")},refresh:function(t){return this._refreshItems(t),this._setHandleClassName(),this.refreshPositions(),this},_connectWith:function(){var t=this.options;return t.connectWith.constructor===String?[t.connectWith]:t.connectWith},_getItemsAsjQuery:function(t){var e,i,s,o,r=[],n=[],h=this._connectWith();if(h&&t)for(e=h.length-1;0<=e;e--)for(i=(s=u(h[e],this.document[0])).length-1;0<=i;i--)(o=u.data(s[i],this.widgetFullName))&&o!==this&&!o.options.disabled&&n.push(["function"==typeof o.options.items?o.options.items.call(o.element):u(o.options.items,o.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),o]);function a(){r.push(this)}for(n.push(["function"==typeof this.options.items?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):u(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]),e=n.length-1;0<=e;e--)n[e][0].each(a);return u(r)},_removeCurrentsFromItems:function(){var i=this.currentItem.find(":data("+this.widgetName+"-item)");this.items=u.grep(this.items,function(t){for(var e=0;e<i.length;e++)if(i[e]===t.item[0])return!1;return!0})},_refreshItems:function(t){this.items=[],this.containers=[this];var e,i,s,o,r,n,h,a,l=this.items,c=[["function"==typeof this.options.items?this.options.items.call(this.element[0],t,{item:this.currentItem}):u(this.options.items,this.element),this]],p=this._connectWith();if(p&&this.ready)for(e=p.length-1;0<=e;e--)for(i=(s=u(p[e],this.document[0])).length-1;0<=i;i--)(o=u.data(s[i],this.widgetFullName))&&o!==this&&!o.options.disabled&&(c.push(["function"==typeof o.options.items?o.options.items.call(o.element[0],t,{item:this.currentItem}):u(o.options.items,o.element),o]),this.containers.push(o));for(e=c.length-1;0<=e;e--)for(r=c[e][1],a=(n=c[e][i=0]).length;i<a;i++)(h=u(n[i])).data(this.widgetName+"-item",r),l.push({item:h,instance:r,width:0,height:0,left:0,top:0})},_refreshItemPositions:function(t){for(var e,i,s=this.items.length-1;0<=s;s--)e=this.items[s],this.currentContainer&&e.instance!==this.currentContainer&&e.item[0]!==this.currentItem[0]||(i=this.options.toleranceElement?u(this.options.toleranceElement,e.item):e.item,t||(e.width=i.outerWidth(),e.height=i.outerHeight()),i=i.offset(),e.left=i.left,e.top=i.top)},refreshPositions:function(t){var e,i;if(this.floating=!!this.items.length&&("x"===this.options.axis||this._isFloating(this.items[0].item)),this.offsetParent&&this.helper&&(this.offset.parent=this._getParentOffset()),this._refreshItemPositions(t),this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(e=this.containers.length-1;0<=e;e--)i=this.containers[e].element.offset(),this.containers[e].containerCache.left=i.left,this.containers[e].containerCache.top=i.top,this.containers[e].containerCache.width=this.containers[e].element.outerWidth(),this.containers[e].containerCache.height=this.containers[e].element.outerHeight();return this},_createPlaceholder:function(i){var s,o,r=(i=i||this).options;r.placeholder&&r.placeholder.constructor!==String||(s=r.placeholder,o=i.currentItem[0].nodeName.toLowerCase(),r.placeholder={element:function(){var t=u("<"+o+">",i.document[0]);return i._addClass(t,"ui-sortable-placeholder",s||i.currentItem[0].className)._removeClass(t,"ui-sortable-helper"),"tbody"===o?i._createTrPlaceholder(i.currentItem.find("tr").eq(0),u("<tr>",i.document[0]).appendTo(t)):"tr"===o?i._createTrPlaceholder(i.currentItem,t):"img"===o&&t.attr("src",i.currentItem.attr("src")),s||t.css("visibility","hidden"),t},update:function(t,e){s&&!r.forcePlaceholderSize||(e.height()&&(!r.forcePlaceholderSize||"tbody"!==o&&"tr"!==o)||e.height(i.currentItem.innerHeight()-parseInt(i.currentItem.css("paddingTop")||0,10)-parseInt(i.currentItem.css("paddingBottom")||0,10)),e.width())||e.width(i.currentItem.innerWidth()-parseInt(i.currentItem.css("paddingLeft")||0,10)-parseInt(i.currentItem.css("paddingRight")||0,10))}}),i.placeholder=u(r.placeholder.element.call(i.element,i.currentItem)),i.currentItem.after(i.placeholder),r.placeholder.update(i,i.placeholder)},_createTrPlaceholder:function(t,e){var i=this;t.children().each(function(){u("<td>&#160;</td>",i.document[0]).attr("colspan",u(this).attr("colspan")||1).appendTo(e)})},_contactContainers:function(t){for(var e,i,s,o,r,n,h,a,l,c=null,p=null,f=this.containers.length-1;0<=f;f--)u.contains(this.currentItem[0],this.containers[f].element[0])||(this._intersectsWith(this.containers[f].containerCache)?c&&u.contains(this.containers[f].element[0],c.element[0])||(c=this.containers[f],p=f):this.containers[f].containerCache.over&&(this.containers[f]._trigger("out",t,this._uiHash(this)),this.containers[f].containerCache.over=0));if(c)if(1===this.containers.length)this.containers[p].containerCache.over||(this.containers[p]._trigger("over",t,this._uiHash(this)),this.containers[p].containerCache.over=1);else{for(i=1e4,s=null,o=(a=c.floating||this._isFloating(this.currentItem))?"left":"top",r=a?"width":"height",l=a?"pageX":"pageY",e=this.items.length-1;0<=e;e--)u.contains(this.containers[p].element[0],this.items[e].item[0])&&this.items[e].item[0]!==this.currentItem[0]&&(n=this.items[e].item.offset()[o],h=!1,t[l]-n>this.items[e][r]/2&&(h=!0),Math.abs(t[l]-n)<i)&&(i=Math.abs(t[l]-n),s=this.items[e],this.direction=h?"up":"down");(s||this.options.dropOnEmpty)&&(this.currentContainer===this.containers[p]?this.currentContainer.containerCache.over||(this.containers[p]._trigger("over",t,this._uiHash()),this.currentContainer.containerCache.over=1):(s?this._rearrange(t,s,null,!0):this._rearrange(t,null,this.containers[p].element,!0),this._trigger("change",t,this._uiHash()),this.containers[p]._trigger("change",t,this._uiHash(this)),this.currentContainer=this.containers[p],this.options.placeholder.update(this.currentContainer,this.placeholder),this.scrollParent=this.placeholder.scrollParent(),this.scrollParent[0]!==this.document[0]&&"HTML"!==this.scrollParent[0].tagName&&(this.overflowOffset=this.scrollParent.offset()),this.containers[p]._trigger("over",t,this._uiHash(this)),this.containers[p].containerCache.over=1))}},_createHelper:function(t){var e=this.options,t="function"==typeof e.helper?u(e.helper.apply(this.element[0],[t,this.currentItem])):"clone"===e.helper?this.currentItem.clone():this.currentItem;return t.parents("body").length||this.appendTo[0].appendChild(t[0]),t[0]===this.currentItem[0]&&(this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}),t[0].style.width&&!e.forceHelperSize||t.width(this.currentItem.width()),t[0].style.height&&!e.forceHelperSize||t.height(this.currentItem.height()),t},_adjustOffsetFromHelper:function(t){"string"==typeof t&&(t=t.split(" ")),"left"in(t=Array.isArray(t)?{left:+t[0],top:+t[1]||0}:t)&&(this.offset.click.left=t.left+this.margins.left),"right"in t&&(this.offset.click.left=this.helperProportions.width-t.right+this.margins.left),"top"in t&&(this.offset.click.top=t.top+this.margins.top),"bottom"in t&&(this.offset.click.top=this.helperProportions.height-t.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var t=this.offsetParent.offset();return"absolute"===this.cssPosition&&this.scrollParent[0]!==this.document[0]&&u.contains(this.scrollParent[0],this.offsetParent[0])&&(t.left+=this.scrollParent.scrollLeft(),t.top+=this.scrollParent.scrollTop()),{top:(t=this.offsetParent[0]===this.document[0].body||this.offsetParent[0].tagName&&"html"===this.offsetParent[0].tagName.toLowerCase()&&u.ui.ie?{top:0,left:0}:t).top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:t.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){var t;return"relative"===this.cssPosition?{top:(t=this.currentItem.position()).top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:t.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}:{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var t,e,i=this.options;"parent"===i.containment&&(i.containment=this.helper[0].parentNode),"document"!==i.containment&&"window"!==i.containment||(this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,"document"===i.containment?this.document.width():this.window.width()-this.helperProportions.width-this.margins.left,("document"===i.containment?this.document.height()||document.body.parentNode.scrollHeight:this.window.height()||this.document[0].body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]),/^(document|window|parent)$/.test(i.containment)||(t=u(i.containment)[0],i=u(i.containment).offset(),e="hidden"!==u(t).css("overflow"),this.containment=[i.left+(parseInt(u(t).css("borderLeftWidth"),10)||0)+(parseInt(u(t).css("paddingLeft"),10)||0)-this.margins.left,i.top+(parseInt(u(t).css("borderTopWidth"),10)||0)+(parseInt(u(t).css("paddingTop"),10)||0)-this.margins.top,i.left+(e?Math.max(t.scrollWidth,t.offsetWidth):t.offsetWidth)-(parseInt(u(t).css("borderLeftWidth"),10)||0)-(parseInt(u(t).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,i.top+(e?Math.max(t.scrollHeight,t.offsetHeight):t.offsetHeight)-(parseInt(u(t).css("borderTopWidth"),10)||0)-(parseInt(u(t).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top])},_convertPositionTo:function(t,e){e=e||this.position;var t="absolute"===t?1:-1,i="absolute"!==this.cssPosition||this.scrollParent[0]!==this.document[0]&&u.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,s=/(html|body)/i.test(i[0].tagName);return{top:e.top+this.offset.relative.top*t+this.offset.parent.top*t-("fixed"===this.cssPosition?-this.scrollParent.scrollTop():s?0:i.scrollTop())*t,left:e.left+this.offset.relative.left*t+this.offset.parent.left*t-("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():s?0:i.scrollLeft())*t}},_generatePosition:function(t){var e=this.options,i=t.pageX,s=t.pageY,o="absolute"!==this.cssPosition||this.scrollParent[0]!==this.document[0]&&u.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,r=/(html|body)/i.test(o[0].tagName);return"relative"!==this.cssPosition||this.scrollParent[0]!==this.document[0]&&this.scrollParent[0]!==this.offsetParent[0]||(this.offset.relative=this._getRelativeOffset()),this.originalPosition&&(this.containment&&(t.pageX-this.offset.click.left<this.containment[0]&&(i=this.containment[0]+this.offset.click.left),t.pageY-this.offset.click.top<this.containment[1]&&(s=this.containment[1]+this.offset.click.top),t.pageX-this.offset.click.left>this.containment[2]&&(i=this.containment[2]+this.offset.click.left),t.pageY-this.offset.click.top>this.containment[3])&&(s=this.containment[3]+this.offset.click.top),e.grid)&&(t=this.originalPageY+Math.round((s-this.originalPageY)/e.grid[1])*e.grid[1],s=!this.containment||t-this.offset.click.top>=this.containment[1]&&t-this.offset.click.top<=this.containment[3]?t:t-this.offset.click.top>=this.containment[1]?t-e.grid[1]:t+e.grid[1],t=this.originalPageX+Math.round((i-this.originalPageX)/e.grid[0])*e.grid[0],i=!this.containment||t-this.offset.click.left>=this.containment[0]&&t-this.offset.click.left<=this.containment[2]?t:t-this.offset.click.left>=this.containment[0]?t-e.grid[0]:t+e.grid[0]),{top:s-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.scrollParent.scrollTop():r?0:o.scrollTop()),left:i-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():r?0:o.scrollLeft())}},_rearrange:function(t,e,i,s){i?i[0].appendChild(this.placeholder[0]):e.item[0].parentNode.insertBefore(this.placeholder[0],"down"===this.direction?e.item[0]:e.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var o=this.counter;this._delay(function(){o===this.counter&&this.refreshPositions(!s)})},_clear:function(t,e){this.reverting=!1;var i,s=[];if(!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null,this.helper[0]===this.currentItem[0]){for(i in this._storedCSS)"auto"!==this._storedCSS[i]&&"static"!==this._storedCSS[i]||(this._storedCSS[i]="");this.currentItem.css(this._storedCSS),this._removeClass(this.currentItem,"ui-sortable-helper")}else this.currentItem.show();function o(e,i,s){return function(t){s._trigger(e,t,i._uiHash(i))}}for(this.fromOutside&&!e&&s.push(function(t){this._trigger("receive",t,this._uiHash(this.fromOutside))}),!this.fromOutside&&this.domPosition.prev===this.currentItem.prev().not(".ui-sortable-helper")[0]&&this.domPosition.parent===this.currentItem.parent()[0]||e||s.push(function(t){this._trigger("update",t,this._uiHash())}),this===this.currentContainer||e||(s.push(function(t){this._trigger("remove",t,this._uiHash())}),s.push(function(e){return function(t){e._trigger("receive",t,this._uiHash(this))}}.call(this,this.currentContainer)),s.push(function(e){return function(t){e._trigger("update",t,this._uiHash(this))}}.call(this,this.currentContainer))),i=this.containers.length-1;0<=i;i--)e||s.push(o("deactivate",this,this.containers[i])),this.containers[i].containerCache.over&&(s.push(o("out",this,this.containers[i])),this.containers[i].containerCache.over=0);if(this.storedCursor&&(this.document.find("body").css("cursor",this.storedCursor),this.storedStylesheet.remove()),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex","auto"===this._storedZIndex?"":this._storedZIndex),this.dragging=!1,e||this._trigger("beforeStop",t,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.cancelHelperRemoval||(this.helper[0]!==this.currentItem[0]&&this.helper.remove(),this.helper=null),!e){for(i=0;i<s.length;i++)s[i].call(this,t);this._trigger("stop",t,this._uiHash())}return this.fromOutside=!1,!this.cancelHelperRemoval},_trigger:function(){!1===u.Widget.prototype._trigger.apply(this,arguments)&&this.cancel()},_uiHash:function(t){var e=t||this;return{helper:e.helper,placeholder:e.placeholder||u([]),position:e.position,originalPosition:e.originalPosition,offset:e.positionAbs,item:e.currentItem,sender:t?t.element:null}}})});
!function(a){window.WPUF_Uploader=function(b,c,d,e,f,g){if(this.removed_files=[],this.container=c,this.browse_button=b,this.max=d||1,this.count=a("#"+c).find(".wpuf-attachment-list > li").length,this.perFileCount=0,this.UploadedFiles=0,a("#"+b).length)return a("ul.wpuf-attachment-list").sortable({placeholder:"highlight"}),a("ul.wpuf-attachment-list").disableSelection(),this.uploader=new plupload.Uploader({runtimes:"html5,html4",browse_button:b,container:c,multipart:!0,multipart_params:{action:"wpuf_upload_file",form_id:a("#"+b).data("form_id")},urlstream_upload:!0,file_data_name:"wpuf_file",max_file_size:g+"kb",url:wpuf_upload.plupload.url+"&type="+e,flash_swf_url:wpuf_upload.flash_swf_url,filters:[{title:"Allowed Files",extensions:f}]}),this.uploader.bind("Init",a.proxy(this,"init")),this.uploader.bind("FilesAdded",a.proxy(this,"added")),this.uploader.bind("QueueChanged",a.proxy(this,"upload")),this.uploader.bind("UploadProgress",a.proxy(this,"progress")),this.uploader.bind("Error",a.proxy(this,"error")),this.uploader.bind("FileUploaded",a.proxy(this,"uploaded")),this.uploader.init(),a("#"+c).on("click","a.attachment-delete",a.proxy(this.removeAttachment,this)),this.uploader},WPUF_Uploader.prototype={init:function(b,c){this.showHide(),a("#"+this.container).prepend('<div class="wpuf-file-warning"></div>')},showHide:function(){if(this.count>=this.max)return this.count,this.max,a("#"+this.container+" .wpuf-file-warning").html(wpuf_upload.warning),void a("#"+this.container).find(".file-selector").hide();a("#"+this.container+" .wpuf-file-warning").html(""),a("#"+this.container).find(".file-selector").show()},added:function(b,c){var d=a("#"+this.container).find(".wpuf-attachment-upload-filelist");this.showHide(),a.each(c,function(b,c){a(".wpuf-submit-button").attr("disabled","disabled"),d.append('<div class="upload-item" id="'+c.id+'"><div class="progress progress-striped active"><div class="bar"></div></div><div class="filename original">'+c.name+" ("+plupload.formatSize(c.size)+") <b></b></div></div>")}),b.refresh(),b.start()},upload:function(a){this.count=a.files.length-this.removed_files.length,this.showHide()},progress:function(b,c){var d=a("#"+c.id);a(".bar",d).css({width:c.percent+"%"}),a(".percent",d).html(c.percent+"%")},error:function(b,c){a("#"+this.container).find("#"+c.file.id).remove();var d="";switch(c.code){case-600:d=wpuf_upload.plupload.size_error;break;case-601:d=wpuf_upload.plupload.type_error;break;default:d="Error #"+c.code+": "+c.message}alert(d),this.count-=1,this.showHide(),this.uploader.refresh()},uploaded:function(b,c,d){try{var e=a.parseJSON(d.response)}catch(a){var f=!0}var g=this;if(a("#"+c.id+" b").html("100%"),a("#"+c.id).remove(),f){this.perFileCount++,this.UploadedFiles++;var h=a("#"+this.container).find(".wpuf-attachment-list");if(h.append(d.response),this.perFileCount>this.max){var i=a(".wpuf-image-wrap:last a.attachment-delete",h).data("attach-id");g.removeExtraAttachment(i),a(".wpuf-image-wrap",h).last().remove(),this.perFileCount--}}else alert(e.data.replace(/(<([^>]+)>)/gi,"")),b.files.pop(),this.count-=1,this.showHide();var j=this.UploadedFiles,k=b.files.length;if(this.count=a("#"+this.container).find(".wpuf-attachment-list > li").length,this.count>=this.max&&a("#"+this.container).find(".file-selector").hide(),k===j){if("undefined"!=typeof grecaptcha&&a(".wpuf-form-add #g-recaptcha-response").length&&!grecaptcha.getResponse().length)return;a(".wpuf-submit-button").removeAttr("disabled")}},removeAttachment:function(b){b.preventDefault();var c=this,d=a(b.currentTarget);Swal.fire({text:wpuf_upload.confirmMsg,icon:"warning",showCancelButton:!0,confirmButtonColor:"#d54e21",confirmButtonText:wpuf_upload.delete_it,cancelButtonText:wpuf_upload.cancel_it,customClass:{confirmButton:"btn btn-success",cancelButton:"btn btn-danger"}}).then(function(a){if(a.isConfirmed){var b={attach_id:d.data("attach-id"),nonce:wpuf_upload.nonce,action:"wpuf_file_del"};c.removed_files.push(b),jQuery("#del_attach").val(d.data("attach-id")),jQuery.post(wpuf_upload.ajaxurl,b,function(){c.perFileCount--,d.parent().parent().remove(),c.count-=1,c.showHide(),c.uploader.refresh()})}})},removeExtraAttachment:function(a){var b=this,c={attach_id:a,nonce:wpuf_upload.nonce,action:"wpuf_file_del"};this.removed_files.push(c),jQuery.post(wpuf_upload.ajaxurl,c,function(){b.count-=1,b.showHide(),b.uploader.refresh()})}}}(jQuery);
!function(a,b){a.fn.listautowidth=function(){return this.each(function(){var b=a(this).width(),c=b/a(this).children("li").length;a(this).children("li").each(function(){var b=a(this).outerWidth(!0)-a(this).width();a(this).width(c-b)})})},b.WP_User_Frontend={init:function(){this.enableMultistep(this);var c=a(".wpuf-form");c.on("click","img.wpuf-clone-field",this.cloneField),c.on("click","img.wpuf-clone-repeat-field",this.cloneRepeatField),c.on("click","img.wpuf-remove-field",this.removeField),c.on("click","img.wpuf-remove-repeat-field",this.removeRepeatField),c.on("click","a.wpuf-delete-avatar",this.deleteAvatar),c.on("click","a#wpuf-post-draft",this.draftPost),c.on("click","button#wpuf-account-update-profile",this.account_update_profile),a(".wpuf-form-add").on("submit",this.formSubmit),a("form#post").on("submit",this.adminPostSubmit),b.matchMedia("(max-width: 600px)").matches&&(a("table.items-table tr td .post-edit-icon").click(function(b){b.preventDefault(),a(this).parents("tr").find(".data-column").toggleClass("flex-column"),a(this).toggleClass("toggle-icon")}),a(".wpuf-dashboard-navigation ul li:first-child").after().click(function(b){b.preventDefault(),a(".wpuf-dashboard-navigation ul li").not(":first").toggle()})),a(".wpuf-form").on("step-change-fieldset",function(a,b,c){if(wpuf_plupload_items.length)for(var d=wpuf_plupload_items.length-1;d>=0;d--)wpuf_plupload_items[d]&&"function"==typeof wpuf_plupload_items[d].refresh&&wpuf_plupload_items[d].refresh();if(wpuf_map_items.length)for(var d=wpuf_map_items.length-1;d>=0;d--)google.maps.event.trigger(wpuf_map_items[d].map,"resize"),wpuf_map_items[d].map.setCenter(wpuf_map_items[d].center)}),this.ajaxCategory(),a(':submit[name="wpuf_user_subscription_cancel"]').click(function(b){b.preventDefault(),Swal.fire({text:wpuf_frontend.cancelSubMsg,icon:"warning",showCancelButton:!0,confirmButtonColor:"#d54e21",confirmButtonText:wpuf_frontend.delete_it,cancelButtonText:wpuf_frontend.cancel_it,customClass:{confirmButton:"btn btn-success",cancelButton:"btn btn-danger"}}).then(function(b){if(!b.isConfirmed)return!1;a("#wpuf_cancel_subscription").submit()})}),this.warningOnExit(),this.handleReadOnly()},warningOnExit:function(){a('input[name="submit"], #wpuf-post-draft').on("click",function(){b.onbeforeunload=null}),a(".wpuf-form-add").on("change",function(){a(".wpuf-form-add input, .wpuf-form-add select, .wpuf-form-add textarea").each(function(c){"hidden"===a(this).attr("type")&&"submit"===a(this).attr("type")&&-1===a(this).val()||(b.onbeforeunload=function(){return"you have changes"})})})},handleReadOnly:function(){a(".wpuf-form .read-only").each(function(){a("input, select, textarea",this).each(function(){a(this).attr("disabled",!0)})})},check_pass_strength:function(){var b=a("#pass1").val();if(a("#pass-strength-result").show(),a("#pass-strength-result").removeClass("short bad good strong"),!b)return a("#pass-strength-result").html("&nbsp;"),void a("#pass-strength-result").hide();if(void 0!==wp.passwordStrength)switch(wp.passwordStrength.meter(b,wp.passwordStrength.userInputDisallowedList(),b)){case 2:a("#pass-strength-result").addClass("bad").html(pwsL10n.bad);break;case 3:a("#pass-strength-result").addClass("good").html(pwsL10n.good);break;case 4:a("#pass-strength-result").addClass("strong").html(pwsL10n.strong);break;case 5:a("#pass-strength-result").addClass("short").html(pwsL10n.mismatch);break;default:a("#pass-strength-result").addClass("short").html(pwsL10n.short)}},enableMultistep:function(c){var d=this,e=0,f=a(':hidden[name="wpuf_multistep_type"]').val();if(null!=f){if(a("fieldset.wpuf-multistep-fieldset").find(".wpuf-multistep-prev-btn").first().remove(),a("fieldset.wpuf-multistep-fieldset").find(".wpuf-multistep-next-btn").last().remove(),a(".wpuf-form fieldset").removeClass("field-active").first().addClass("field-active"),"progressive"==f&&0!=a(".wpuf-form .wpuf-multistep-fieldset").length){a("fieldset.wpuf-multistep-fieldset legend").first();a(".wpuf-multistep-progressbar").html('<div class="wpuf-progress-percentage"></div>');var g=a(".wpuf-multistep-progressbar"),h=a(".wpuf-progress-percentage");a(".wpuf-multistep-progressbar").progressbar({change:function(){h.text(g.progressbar("value")+"%")}}),a(".wpuf-multistep-fieldset legend").hide()}else a(".wpuf-form").each(function(){var b=a(this),c=a(".wpuf-multistep-progressbar",b),d="";c.addClass("wizard-steps"),d+='<ul class="wpuf-step-wizard">',a(".wpuf-multistep-fieldset",this).each(function(){d+="<li>"+a.trim(a("legend",this).text())+"</li>",a("legend",this).hide()}),d+="</ul>",c.append(d),a(".wpuf-step-wizard li",c).first().addClass("active-step"),a(".wpuf-step-wizard",c).listautowidth()});this.change_fieldset(e,f),a("fieldset .wpuf-multistep-prev-btn, fieldset .wpuf-multistep-next-btn").click(function(g){if(a(this).hasClass("wpuf-multistep-next-btn")){0!=d.formStepCheck("",a(this).closest("fieldset"))&&c.change_fieldset(++e,f)}else a(this).hasClass("wpuf-multistep-prev-btn")&&c.change_fieldset(--e,f);var h=a("form.wpuf-form-add"),i=h.offset().top;return b.scrollTo({top:i-32,behavior:"smooth"}),!1})}},change_fieldset:function(b,c){var d=a("fieldset.wpuf-multistep-fieldset").eq(b);a("fieldset.wpuf-multistep-fieldset").removeClass("field-active").eq(b).addClass("field-active"),a(".wpuf-step-wizard li").each(function(){a(this).index()<=b?"step_by_step"==c?a(this).addClass("passed-wpuf-ms-bar"):a(".wpuf-ps-bar",this).addClass("passed-wpuf-ms-bar"):"step_by_step"==c?a(this).removeClass("passed-wpuf-ms-bar"):a(".wpuf-ps-bar",this).removeClass("passed-wpuf-ms-bar")}),a(".wpuf-step-wizard li").removeClass("wpuf-ms-bar-active active-step completed-step"),a(".passed-wpuf-ms-bar").addClass("completed-step").last().addClass("wpuf-ms-bar-active"),a(".wpuf-ms-bar-active").addClass("active-step");var e=a("fieldset.wpuf-multistep-fieldset").eq(b).find("legend").text();if(e=a.trim(e),"progressive"==c&&0!=a(".wpuf-form .wpuf-multistep-fieldset").length){var f=100*(b+1)/a("fieldset.wpuf-multistep-fieldset").length,f=Number(f.toFixed(2));a(".wpuf-multistep-progressbar").progressbar({value:f}),a(".wpuf-progress-percentage").text(e+" ("+f+"%)")}a(".wpuf-form").trigger("step-change-fieldset",[b,d])},ajaxCategory:function(){a(".category-wrap").on("change",".cat-ajax",function(){var b=a(this).data("form-id");currentLevel=parseInt(a(this).parent().attr("level")),WP_User_Frontend.getChildCats(a(this),currentLevel+1,"category",b)})},getChildCats:function(b,c,d,e){var f=a(b).val(),g="wpuf-category-dropdown-lvl-"+c,d=void 0!==d?d:"category",h=a(b).siblings("span").data("taxonomy");a.ajax({type:"post",url:wpuf_frontend.ajaxurl,data:{action:"wpuf_get_child_cat",catID:f,nonce:wpuf_frontend.nonce,field_attr:h,form_id:e},beforeSend:function(){a(b).parent().parent().next(".loading").addClass("wpuf-loading")},complete:function(){a(b).parent().parent().next(".loading").removeClass("wpuf-loading")},success:function(e){a(b).parent().nextAll().each(function(){a(this).remove()}),""!=e&&(a(b).parent().addClass("hasChild").parent().append('<div id="'+g+'" level="'+c+'"></div>'),b.parent().parent().find("#"+g).html(e).slideDown("fast")),a(document).trigger("wpuf-ajax-fetched-child-categories",g,c,d)}})},cloneField:function(b){b.preventDefault();var c=a(this).closest("tr"),d=c.clone();d.find("input").val(""),d.find(":checked").attr("checked",""),c.after(d)},removeField:function(){var b=a(this).closest("tr");b.siblings().addBack().length>1&&b.remove()},cloneRepeatField:function(b){b.preventDefault();var c=a(this).closest(".wpuf-column-field-inner-columns.column-repeat"),d=c.clone();d.find("input:not(:checkbox):not(:radio)").val(""),d.find("textarea").val(""),d.find(":checked").prop("checked",!1),c.after(d),WP_User_Frontend.calculateFieldsName(a(this).parents(".wpuf-field-columns")),WP_User_Frontend.setRowNumber(a(this).closest(".wpuf-field-columns"))},removeRepeatField:function(){var b=a(this).closest(".wpuf-column-field-inner-columns.column-repeat"),c=b.siblings().addBack(),d=c.length,e=a(c).index(a(this).closest(".wpuf-column-field-inner-columns.column-repeat"));d>1&&(WP_User_Frontend.setRowNumber(a(b).closest(".wpuf-field-columns"),d-1),b.remove()),e+1!==d&&WP_User_Frontend.calculateFieldsName(b)},setRowNumber:function(b,c){c||(c=a(b).children().length),a(b).parent(".wpuf-fields").find("input.repeat_row_numbers").val(c)},calculateFieldsName:function(b){var c=b.children(),d=[],e=[],f=[],g=".wpuf-column input, .wpuf-column textarea, .wpuf-column select, .wpuf-column .wpuf-rich-validation";a(c[0]).find(g).each(function(b,c){d.push(a(c).attr("name").split("_0_")),e.push(a(c).attr("id").split("_0_")),f.push(a(c).attr("class").split("_0_"))}),c.each(function(b,c){a(c).find(g).each(function(c,g){a(g).attr("name",d[c][0]+"_"+b+"_"+d[c][1]),a(g).attr("id",e[c][0]+"_"+b+"_"+e[c][1]),a(g).attr("class",f[c][0]+"_"+b+"_"+f[c][1])})})},adminPostSubmit:function(b){b.preventDefault();var c=a(this);if(WP_User_Frontend.validateForm(c))return!0},draftPost:function(b){b.preventDefault();var c=a(this),d=a(this).closest("form"),e=d.serialize()+"&action=wpuf_draft_post",f=d.find('input[type="hidden"][name="post_id"]').val(),g=[];a(".wpuf-rich-validation").each(function(b,c){var c=a(c),d=c.data("id"),e=c.data("name"),f=a.trim(tinyMCE.get(d).getContent());g.push(e+"="+encodeURIComponent(f))}),e=e+"&"+g.join("&"),c.after(' <span class="wpuf-loading"></span>'),a.post(wpuf_frontend.ajaxurl,e,function(b){if(void 0===f){var e='<input type="hidden" name="post_id" value="'+b.post_id+'">';e+='<input type="hidden" name="post_date" value="'+b.date+'">',e+='<input type="hidden" name="post_author" value="'+b.post_author+'">',e+='<input type="hidden" name="comment_status" value="'+b.comment_status+'">',d.append(e)}c.next("span.wpuf-loading").remove(),c.after('<span class="wpuf-draft-saved">&nbsp; '+b.message+"</span>"),a(".wpuf-draft-saved").delay(2500).fadeOut("fast",function(){a(this).remove()})})},account_update_profile:function(b){b.preventDefault();var c=a(this).closest("form");a.post(wpuf_frontend.ajaxurl,c.serialize(),function(a){a.success?(c.find(".wpuf-error").hide(),c.find(".wpuf-success").show()):(c.find(".wpuf-success").hide(),c.find(".wpuf-error").show(),c.find(".wpuf-error").text(a.data))})},formStepCheck:function(a,b){var c=b,d=(c.find("input[type=submit]"),WP_User_Frontend.validateForm(c));return d||WP_User_Frontend.addErrorNotice(self,"bottom"),d},formSubmit:function(c){c.preventDefault();var d=a(this),e=d.find("input[type=submit]");form_data=WP_User_Frontend.validateForm(d),form_data&&(d.find("li.wpuf-submit").append('<span class="wpuf-loading"></span>'),e.attr("disabled","disabled").addClass("button-primary-disabled"),a.post(wpuf_frontend.ajaxurl,form_data,function(c){if(c.success)a("body").trigger("wpuf:postform:success",c),c.data?c.data.show_message?(d.before('<div class="wpuf-success">'+c.data.message+"</div>"),d.slideUp("fast",function(){d.remove()}),a("html, body").animate({scrollTop:a(".wpuf-success").offset().top-100},"fast")):b.location=c.data.redirect_to:c.show_message?(d.before('<div class="wpuf-success">'+c.message+"</div>"),d.slideUp("fast",function(){d.remove()}),a("html, body").animate({scrollTop:a(".wpuf-success").offset().top-100},"fast")):b.location=c.redirect_to;else{if(void 0!==c.data.type&&"login"===c.data.type&&Swal.fire({text:c.error,icon:"warning",showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:"OK"}).then(function(a){a.isConfirmed?b.location=c.redirect_to:(e.removeAttr("disabled"),e.removeClass("button-primary-disabled"),d.find("span.wpuf-loading").remove())}),void 0!==c.type&&"login"===c.type)return void Swal.fire({text:c.error,icon:"warning",showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:"OK"}).then(function(a){a.isConfirmed?b.location=c.redirect_to:(e.removeAttr("disabled"),e.removeClass("button-primary-disabled"),d.find("span.wpuf-loading").remove())});d.find(".g-recaptcha").length>0&&grecaptcha.reset();const f=c.error?c.error:c.data.error;Swal.fire({html:f,icon:"warning",showCancelButton:!1,confirmButtonColor:"#d54e21",confirmButtonText:"OK",customClass:{cancelButton:"btn btn-danger"}}),e.removeAttr("disabled")}e.removeClass("button-primary-disabled"),d.find("span.wpuf-loading").remove()}))},isTelephoneField:function(b){return a(b).hasClass("wpuf_telephone")&&"yes"===a(b).data("show-list")},validateForm:function(c){var d=[],e=[];if(WP_User_Frontend.removeErrors(c),WP_User_Frontend.removeErrorNotice(c),c.find("input:visible, textarea:visible, select:visible, div.br-widget:visible, .wpuf-rich-validation:visible, div.wpuf-attachment-upload-filelist:visible").each(function(f,g){var h="",i=a(g).data("type"),j=a(g).data("required");switch(i){case"rich":var k=a(g).data("id"),l=a(g).data("name");w=a.trim(tinyMCE.get(k).getContent()),"yes"===j&&""===w&&e.push({type:"required",container:g});var m=WP_User_Frontend.editorLimit.isRestrictionFailed(g);if(m){e.push({type:"limit",container:g});break}var n=WP_User_Frontend.editorContainingShortcode(g);if(n.shortcodeFound){e.push({type:"custom",container:g,message:wpuf_frontend.protected_shortcodes_message.replace("%shortcode%","["+n.shortcode+"]")});break}d.push(l+"="+encodeURIComponent(w));break;case"textarea":case"text":if(w=a.trim(a(g).val()),"yes"===j&&""===w){e.push({type:"required",container:g});break}var m=WP_User_Frontend.editorLimit.isRestrictionFailed(g);if(m){e.push({type:"limit",container:g});break}if(WP_User_Frontend.isTelephoneField(g)){var o=b.intlTelInputGlobals.getInstance(g);if(""!==o.getNumber()&&!o.isValidNumber()){e.push({type:"validation",container:g});break}var p=a(g).attr("name"),q=o.getNumber();a("<input>").attr("type","hidden").attr("name",p).attr("value",q).appendTo(c);break}break;case"url":if(w=a.trim(a(g).val()),"yes"===j&&""===w){e.push({type:"required",container:g});break}if(""!==w&&!WP_User_Frontend.isValidURL(w)){e.push({type:"validation",container:g});break}break;case"password":case"confirm_password":var r=a(g).data("repeat"),s=a(g).data("strength"),t=a(g).data("minimum-length");if(w=a.trim(a(g).val()),"yes"===j&&""===w){e.push({type:"required",container:g});break}if(w.length<t){e.push({type:"custom",container:g,message:"Minimum "+t+" character is required"});break}if("yes"===r&&a(g).closest(".wpuf-form").find('[data-type="confirm_password"]').eq(0).val()!==w&&e.push({error_type:"mismatch",container:g}),s){var u=wp.passwordStrength.meter(w,wp.passwordStrength.userInputDisallowedList());"weak"===s&&u<2?e.push({type:"custom",container:g,message:wpuf_frontend.password_warning_weak}):"medium"===s&&u<3?e.push({type:"custom",container:g,message:wpuf_frontend.password_warning_medium}):"strong"===s&&u<4&&e.push({type:"custom",container:g,message:wpuf_frontend.password_warning_strong})}break;case"select":w=a(g).val(),"yes"===j&&"-1"===w&&e.push({type:"required",container:g});break;case"multiselect":w=a(g).val(),"yes"===j&&0===w.length&&e.push({type:"required",container:g});break;case"tax-checkbox":var v=a(g).children().find("input:checked").length;"yes"!==j||v||e.push({type:"required",container:g});break;case"radio":case"checkbox":h=a(g).parents(".wpuf-fields"),v=a(h).find("input:checked").length,"yes"!==j||v||e.push({type:"required",container:g});break;case"file":var v=a(g).find("ul").children().length;"yes"!==j||v||e.push({type:"required",container:a(g).closest(".wpuf-fields")});break;case"email":if(w=a(g).val(),"yes"===j&&""===w){e.push({type:"required",container:g});break}""===w||WP_User_Frontend.isValidEmail(w)||e.push({type:"validation",container:g});break;case"url":var w=a(g).val();if("yes"===j&&""===w){e.push({type:"validation",container:g});break}""===w||WP_User_Frontend.isValidURL(w)||e.push({type:"validation",container:g});break;default:if(a(g).attr("id")&&a(g).attr("id").startsWith("wpuf-map")){var x=a(g).parents(".wpuf-form-google-map-container");mapField=a(x).find('input[id^="wpuf-map-lat"]'),j=a(mapField).data("required"),w=a(mapField).val(),"yes"===j&&""===w&&e.push({type:"required",container:x})}a(g).hasClass("br-widget")&&(h=a(g).parents(".wpuf-fields"),j=a(h).find("select.wpuf-ratings").data("required"),v=a(g).find(".br-selected").length,"yes"!==j||v||e.push({type:"required",container:g}))}}),e.length){var f,g=e.length;for(f=0;f<g;f++)WP_User_Frontend.markError(e[f].container,e[f].type,e[f].message);return WP_User_Frontend.addErrorNotice(c,"end"),a(e[0].container).focus(),!1}c.find('li.wpuf-el[style*="display: none"] input').each(function(b,c){switch(a(c).attr("type")){case"url":case"email":a(c).val("")}});var h=c.find(":disabled").removeAttr("disabled"),i=c.serialize();return h.attr("disabled","disabled"),i=i+"&"+d.join("&")},addErrorNotice:function(b,c){"bottom"==c?a(".wpuf-multistep-fieldset:visible").append('<div class="wpuf-errors">'+wpuf_frontend.error_message+"</div>"):a(b).find("li.wpuf-submit").append('<div class="wpuf-errors">'+wpuf_frontend.error_message+"</div>")},removeErrorNotice:function(b){a(b).find(".wpuf-errors").remove()},markError:function(b,c,d){if(a(b).closest("div").addClass("has-error"),c){var e="",f=a(b).data("label");switch(e=f||a(b).closest("li").data("label"),c){case"required":case"mismatch":case"validation":e=e+" "+error_str_obj[c];break;case"limit":e="";break;case"custom":e=d}a(b).siblings(".wpuf-error-msg").remove(),a(b).closest(".wpuf-fields.wpuf-fields-address").length?(a(b).closest("div.wpuf-sub-fields").find("div.wpuf-error-msg").remove(),a(b).closest("div.wpuf-sub-fields").append('<div class="wpuf-error-msg">'+e+"</div>")):(a(b).closest("div.wpuf-fields").find("div.wpuf-error-msg").remove(),a(b).closest("div.wpuf-fields").append('<div class="wpuf-error-msg">'+e+"</div>"))}},removeErrors:function(b){a(b).find(".has-error").removeClass("has-error"),a(".wpuf-error-msg").remove()},isValidEmail:function(a){return new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i).test(a)},isValidURL:function(a){return new RegExp("^(http:\\/\\/www\\.|https:\\/\\/www\\.|http:\\/\\/|https:\\/\\/){1}[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,20}(:[0-9]{1,20})?(\\/.*)?$").test(a)},insertImage:function(b,c){if(a("#"+b).length){var d=new plupload.Uploader({runtimes:"html5,html4",browse_button:b,container:"wpuf-insert-image-container",multipart:!0,multipart_params:{action:"wpuf_insert_image",form_id:a("#"+b).data("form_id")},multiple_queues:!1,multi_selection:!1,urlstream_upload:!0,file_data_name:"wpuf_file",max_file_size:wpuf_upload.max_filesize,url:wpuf_upload.plupload.url,flash_swf_url:wpuf_upload.flash_swf_url,filters:[{title:"Allowed Files",extensions:"jpg,jpeg,gif,png,bmp"}]});d.bind("Init",function(a,b){}),d.bind("FilesAdded",function(b,c){var d=a("#wpuf-insert-image-container");a.each(c,function(a,b){d.append('<div class="upload-item" id="'+b.id+'"><div class="progress progress-striped active"><div class="bar"></div></div></div>')}),b.refresh(),b.start()}),d.bind("QueueChanged",function(a){d.start()}),d.bind("UploadProgress",function(b,c){var d=a("#"+c.id);a(".bar",d).css({width:c.percent+"%"}),a(".percent",d).html(c.percent+"%")}),d.bind("Error",function(a,b){alert("Error #"+b.code+": "+b.message)}),d.bind("FileUploaded",function(b,d,e){if(a("#"+d.id).remove(),"error"!==e.response){if("undefined"!=typeof tinyMCE)if("function"!=typeof tinyMCE.execInstanceCommand){var f=tinyMCE.get("post_content_"+c);null!==f&&f.insertContent(e.response)}else tinyMCE.execInstanceCommand ("post_content_"+c,"mceInsertContent",!1,e.response);var g=a("#post_content_"+c);g.val(g.val()+e.response)}else alert("Something went wrong")}),d.init()}},deleteAvatar:function(b){b.preventDefault(),confirm(a(this).data("confirm"))&&a.post(wpuf_frontend.ajaxurl,{action:"wpuf_delete_avatar",_wpnonce:wpuf_frontend.nonce},function(){a(b.target).parent().remove(),a("[id^=wpuf-avatar]").css("display","")})},editorLimit:{bind:function(b,c,d,e,f){"no"===d?(a("textarea#"+c).keyup(function(a){WP_User_Frontend.editorLimit.textLimit.call(this,a,b,e,f)}),a("input#"+c).keyup(function(a){WP_User_Frontend.editorLimit.textLimit.call(this,a,b,e,f)}),a("input#"+c).change(function(a){WP_User_Frontend.editorLimit.textLimit.call(this,a,b,e,f)}),a("textarea#"+c).on("paste",function(c){var d=a(this);setTimeout(function(){WP_User_Frontend.editorLimit.textLimit.call(d,c,b,e,f)},100)}),a("input#"+c).on("paste",function(c){var d=a(this);setTimeout(function(){WP_User_Frontend.editorLimit.textLimit.call(d,c,b,e,f)},100)})):setTimeout(function(){tinyMCE.get(c).onKeyUp.add(function(a,c){WP_User_Frontend.editorLimit.tinymce.onKeyUp(a,c,b,e,f)}),tinyMCE.get(c).onPaste.add(function(a,c){setTimeout(function(){WP_User_Frontend.editorLimit.tinymce.onPaste(a,c,b,e,f)},100)})},1e3)},checkTinyMCERestriction:function(b,c,d){var e=0,f=void 0!==c[0]&&null!==c[0]?parseInt(c[0]):0,g=(void 0!==c[1]&&null!==c[1]&&c[1].trim(),void 0!==c[2]&&null!==c[2]&&c[2].trim(),void 0!==c[3]&&null!==c[3]?c[3].trim():""),h=void 0!==c[4]&&null!==c[4]?c[4].trim():"",i="";"word"===g?(e=WP_User_Frontend.editorLimit.tinymce.getStats(d).words,i="word_"+h):(e=WP_User_Frontend.editorLimit.tinymce.getStats(d).chars,i="char_"+h);wpuf_frontend["word_"+h];return 0!==e&&(e>f&&"max"===h?(WP_User_Frontend.markError(b,"limit"),jQuery(".mce-path-item.mce-last",d.container).html(wpuf_frontend[i]+" "+e+"/"+f),!0):e<f&&"min"===h?(WP_User_Frontend.markError(b,"limit"),WP_User_Frontend.contentLimitMessage(a(b),g,h,f),!0):void 0)},isRestrictionFailed:function(b){var c=a(b).data("id"),d=(a(b).data("type"),!1),e=null,f=0,g=0,h="";if(a(b).closest("div.wpuf-fields").hasClass("has-error")&&a(b).closest("div.wpuf-fields").removeClass("has-error"),"undefined"!=typeof tinyMCE&&null!==tinyMCE.get(c)&&(d=!0,e=tinyMCE.get(c),e.focus()),a(b).closest("li.wpuf-el").find("script").html()){var i=a(b).closest("li.wpuf-el").find("script").html();h=i.match(/(?:bind\()(.*?(?=\)))/)?i.match(/(?:bind\()(.*?(?=\)))/)[1].replace(/['"]/g,"").split(","):""}if(d)return WP_User_Frontend.editorLimit.checkTinyMCERestriction(b,h,e);var j=void 0!==h[0]&&null!==h[0]?parseInt(h[0]):0,k=void 0!==h[3]&&null!==h[3]?h[3].trim():"",l=void 0!==h[4]&&null!==h[4]?h[4].trim():"";if(f=a(b).val().trim().length,g=a(b).val().trim().split(" ").length,0===f)return!1;if("word"===k){if(g>j&&"max"===l)return WP_User_Frontend.markError(b,"limit"),!0;if(g<j&&"min"===l)return WP_User_Frontend.markError(b,"limit"),!0}else{if(f>j&&"max"===l)return WP_User_Frontend.markError(b,"limit"),!0;if(f<j&&"min"===l)return WP_User_Frontend.markError(b,"limit"),!0}return!1},tinymce:{getStats:function(a){var b=a.getContent({format:"text"});return{chars:b.length,words:b.split(" ").length}},onKeyUp:function(b,c,d,e,f){var g=a(".wpuf-fields.wpuf_"+b.id);a(g.closest(".wpuf-fields")).hasClass("has-error")&&g.removeClass("has-error");var h=WP_User_Frontend.editorLimit.tinymce.getStats(b).chars;if(!h)return void g.closest(".wpuf-fields").find("span.wpuf-wordlimit-message").html("");"word"===e&&(h=WP_User_Frontend.editorLimit.tinymce.getStats(b).words),d&&h>d&&"max"===f?(WP_User_Frontend.markError(g,"limit"),WP_User_Frontend.contentLimitMessage(a(g),e,f,d)):d&&h<d&&"min"===f?(WP_User_Frontend.markError(g,"limit"),WP_User_Frontend.contentLimitMessage(a(g),e,f,d)):(jQuery(".mce-path-item.mce-last",b.container).html(""),g.closest(".wpuf-fields").find("span.wpuf-wordlimit-message").html(""))},onPaste:function(b,c,d,e,f){var g=b.getContent({format:"text"}),h=g.length,i=a(".wpuf-fields.wpuf_"+b.id);i.closest(".wpuf-fields").hasClass("has-error")&&i.closest(".wpuf-fields").removeClass("has-error"),h&&("word"===e&&(h=g.split(" ").length),d&&h>d&&"max"===f?(WP_User_Frontend.contentLimitMessage(i,e,f,d),WP_User_Frontend.markError(i,"limit")):d&&h<d&&"min"===f?(WP_User_Frontend.contentLimitMessage(i,e,f,d),WP_User_Frontend.markError(i,"limit")):i.closest(".wpuf-fields").find("span.wpuf-wordlimit-message").html(""),WP_User_Frontend.editorLimit.make_media_embed_code(g,b))}},textLimit:function(b,c,d,e){var f=a(this),g=f.val().length;f.closest(".wpuf-fields").hasClass("has-error")&&f.closest(".wpuf-fields").removeClass("has-error"),g&&("word"===d&&(g=f.val().split(" ").length),c&&g>c&&"max"===e?(WP_User_Frontend.contentLimitMessage(f,d,e,c),WP_User_Frontend.markError(f,"limit")):c&&g<c&&"min"===e?(WP_User_Frontend.contentLimitMessage(f,d,e,c),WP_User_Frontend.markError(f,"limit")):f.closest(".wpuf-fields").find("span.wpuf-wordlimit-message").html(""),"paste"===b.type&&(c&&g>c&&"max"===e?(WP_User_Frontend.contentLimitMessage(f,d,e,c),WP_User_Frontend.markError(f,"limit")):c&&g<c&&"min"===e?(WP_User_Frontend.contentLimitMessage(f,d,e,c),WP_User_Frontend.markError(f,"limit")):f.closest(".wpuf-fields").find("span.wpuf-wordlimit-message").html("")))},blockTyping:function(b){-1!==a.inArray(b.keyCode,[46,8,9,27,13,110,190,189])||65==b.keyCode&&!0===b.ctrlKey||b.keyCode>=35&&b.keyCode<=40||(b.preventDefault(),b.stopPropagation())},make_media_embed_code:function(b,c){a.post(ajaxurl,{action:"wpuf_make_media_embed_code",content:b},function(a){c.setContent(c.getContent()+c.setContent(a))})}},doUncheckRadioBtn:function(a){a.checked=!1},contentLimitMessage:function(a,b,c,d){var e="";"word"===b?"min"===c?(e=wpuf_frontend.word_min_title+"<br>",e+=wpuf_frontend.word_min_details.replace("%number%",d)):(e=wpuf_frontend.word_max_title+"<br>",e+=wpuf_frontend.word_max_details.replace("%number%",d)):"min"===c?(e=wpuf_frontend.char_min_title+"<br>",e+=wpuf_frontend.char_min_details.replace("%number%",d)):(e=wpuf_frontend.char_max_title+"<br>",e+=wpuf_frontend.char_max_details.replace("%number%",d)),a.closest(".wpuf-fields").find("span.wpuf-wordlimit-message").html(e)},editorContainingShortcode:function(b){var c=a(b),d=c.data("id"),e=a.trim(tinyMCE.get(d).getContent()).toLowerCase(),f=wpuf_frontend.protected_shortcodes;if(!f)return{shortcodeFound:!1};for(var g=0;g<f.length;g++){var h=f[g];if(new RegExp(h).test(e))return{shortcodeFound:!0,shortcode:h}}return{shortcodeFound:!1}}},a(function(){if(WP_User_Frontend.init(),a("ul.wpuf-payment-gateways").on("click","input[type=radio]",function(b){a(".wpuf-payment-instruction").slideUp(250),a(this).parents("li").find(".wpuf-payment-instruction").slideDown(250)}),a("ul.wpuf-payment-gateways li").find("input[type=radio]").is(":checked")){a("ul.wpuf-payment-gateways li").find("input[type=radio]:checked").parents("li").find(".wpuf-payment-instruction").slideDown(250)}else a("ul.wpuf-payment-gateways li").first().find("input[type=radio]").click()}),a(function(){a('input[name="first_name"], input[name="last_name"]').on("change keyup",function(){var b,c=a.makeArray(a('input[name="first_name"], input[name="last_name"]').map(function(){if(b=a(this).val())return b})).join(" ");a('input[name="display_name"]').val(c)})}),a(function(a){a('.wpuf-form-add input[name="dokan_store_name"]').on("focusout",function(){var b=a(this).val().toLowerCase().replace(/-+/g,"").replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");a('input[name="shopurl"]').val(b),a("#url-alart").text(b),a('input[name="shopurl"]').focus()}),a('.wpuf-form-add input[name="shopurl"]').keydown(function(b){a(this).val();-1!==a.inArray(b.keyCode,[46,8,9,27,13,91,109,110,173,189,190])||65==b.keyCode&&!0===b.ctrlKey||b.keyCode>=35&&b.keyCode<=39||(b.shiftKey||(b.keyCode<65||b.keyCode>90)&&(b.keyCode<48||b.keyCode>57))&&(b.keyCode<96||b.keyCode>105)&&b.preventDefault()}),a('.wpuf-form-add input[name="shopurl"]').keyup(function(b){a("#url-alart").text(a(this).val())}),a('.wpuf-form-add input[name="shopurl"]').on("focusout",function(){var b=a(this),c={action:"shop_url",url_slug:b.val(),_nonce:dokan.nonce};""!==b.val()&&a.post(dokan.ajaxurl,c,function(b){0==b?(a("#url-alart").removeClass("text-success").addClass("text-danger"),a("#url-alart-mgs").removeClass("text-success").addClass("text-danger").text(dokan.seller.notAvailable)):(a("#url-alart").removeClass("text-danger").addClass("text-success"),a("#url-alart-mgs").removeClass("text-danger").addClass("text-success").text(dokan.seller.available))})}),a(".wpuf-form-add #wpuf-map-add-location").attr("name","find_address")}),a(function(a){a(document).on("click",".wpuf-eye",function(){const b=a(this).siblings("input");"password"===b.attr("type")?(b.attr("type","text"),a(this).attr("src",wpuf_frontend.asset_url+"/images/eye-close.svg")):(b.attr("type","password"),a(this).attr("src",wpuf_frontend.asset_url+"/images/eye.svg"))})})}(jQuery,window);
(function (global, factory){
typeof exports==='object'&&typeof module!=='undefined' ? module.exports=factory() :
typeof define==='function'&&define.amd ? define(factory) :
(global=global||self, global.Sweetalert2=factory());
}(this, function (){ 'use strict';
const consolePrefix='SweetAlert2:';
const uniqueArray=arr=> {
const result=[];
for (let i=0; i < arr.length; i++){
if(result.indexOf(arr[i])===-1){
result.push(arr[i]);
}}
return result;
};
const capitalizeFirstLetter=str=> str.charAt(0).toUpperCase() + str.slice(1);
const toArray=nodeList=> Array.prototype.slice.call(nodeList);
const warn=message=> {
console.warn("".concat(consolePrefix, " ").concat(typeof message==='object' ? message.join(' '):message));
};
const error=message=> {
console.error("".concat(consolePrefix, " ").concat(message));
};
const previousWarnOnceMessages=[];
const warnOnce=message=> {
if(!previousWarnOnceMessages.includes(message)){
previousWarnOnceMessages.push(message);
warn(message);
}};
const warnAboutDeprecation=(deprecatedParam, useInstead)=> {
warnOnce("\"".concat(deprecatedParam, "\" is deprecated and will be removed in the next major release. Please use \"").concat(useInstead, "\" instead."));
};
const callIfFunction=arg=> typeof arg==='function' ? arg():arg;
const hasToPromiseFn=arg=> arg&&typeof arg.toPromise==='function';
const asPromise=arg=> hasToPromiseFn(arg) ? arg.toPromise():Promise.resolve(arg);
const isPromise=arg=> arg&&Promise.resolve(arg)===arg;
const defaultParams={
title: '',
titleText: '',
text: '',
html: '',
footer: '',
icon: undefined,
iconColor: undefined,
iconHtml: undefined,
template: undefined,
toast: false,
showClass: {
popup: 'swal2-show',
backdrop: 'swal2-backdrop-show',
icon: 'swal2-icon-show'
},
hideClass: {
popup: 'swal2-hide',
backdrop: 'swal2-backdrop-hide',
icon: 'swal2-icon-hide'
},
customClass: {},
target: 'body',
color: undefined,
backdrop: true,
heightAuto: true,
allowOutsideClick: true,
allowEscapeKey: true,
allowEnterKey: true,
stopKeydownPropagation: true,
keydownListenerCapture: false,
showConfirmButton: true,
showDenyButton: false,
showCancelButton: false,
preConfirm: undefined,
preDeny: undefined,
confirmButtonText: 'OK',
confirmButtonAriaLabel: '',
confirmButtonColor: undefined,
denyButtonText: 'No',
denyButtonAriaLabel: '',
denyButtonColor: undefined,
cancelButtonText: 'Cancel',
cancelButtonAriaLabel: '',
cancelButtonColor: undefined,
buttonsStyling: true,
reverseButtons: false,
focusConfirm: true,
focusDeny: false,
focusCancel: false,
returnFocus: true,
showCloseButton: false,
closeButtonHtml: '&times;',
closeButtonAriaLabel: 'Close this dialog',
loaderHtml: '',
showLoaderOnConfirm: false,
showLoaderOnDeny: false,
imageUrl: undefined,
imageWidth: undefined,
imageHeight: undefined,
imageAlt: '',
timer: undefined,
timerProgressBar: false,
width: undefined,
padding: undefined,
background: undefined,
input: undefined,
inputPlaceholder: '',
inputLabel: '',
inputValue: '',
inputOptions: {},
inputAutoTrim: true,
inputAttributes: {},
inputValidator: undefined,
returnInputValueOnDeny: false,
validationMessage: undefined,
grow: false,
position: 'center',
progressSteps: [],
currentProgressStep: undefined,
progressStepsDistance: undefined,
willOpen: undefined,
didOpen: undefined,
didRender: undefined,
willClose: undefined,
didClose: undefined,
didDestroy: undefined,
scrollbarPadding: true
};
const updatableParams=['allowEscapeKey', 'allowOutsideClick', 'background', 'buttonsStyling', 'cancelButtonAriaLabel', 'cancelButtonColor', 'cancelButtonText', 'closeButtonAriaLabel', 'closeButtonHtml', 'color', 'confirmButtonAriaLabel', 'confirmButtonColor', 'confirmButtonText', 'currentProgressStep', 'customClass', 'denyButtonAriaLabel', 'denyButtonColor', 'denyButtonText', 'didClose', 'didDestroy', 'footer', 'hideClass', 'html', 'icon', 'iconColor', 'iconHtml', 'imageAlt', 'imageHeight', 'imageUrl', 'imageWidth', 'preConfirm', 'preDeny', 'progressSteps', 'returnFocus', 'reverseButtons', 'showCancelButton', 'showCloseButton', 'showConfirmButton', 'showDenyButton', 'text', 'title', 'titleText', 'willClose'];
const deprecatedParams={};
const toastIncompatibleParams=['allowOutsideClick', 'allowEnterKey', 'backdrop', 'focusConfirm', 'focusDeny', 'focusCancel', 'returnFocus', 'heightAuto', 'keydownListenerCapture'];
const isValidParameter=paramName=> {
return Object.prototype.hasOwnProperty.call(defaultParams, paramName);
};
const isUpdatableParameter=paramName=> {
return updatableParams.indexOf(paramName)!==-1;
};
const isDeprecatedParameter=paramName=> {
return deprecatedParams[paramName];
};
const checkIfParamIsValid=param=> {
if(!isValidParameter(param)){
warn("Unknown parameter \"".concat(param, "\""));
}};
const checkIfToastParamIsValid=param=> {
if(toastIncompatibleParams.includes(param)){
warn("The parameter \"".concat(param, "\" is incompatible with toasts"));
}};
const checkIfParamIsDeprecated=param=> {
if(isDeprecatedParameter(param)){
warnAboutDeprecation(param, isDeprecatedParameter(param));
}};
const showWarningsForParams=params=> {
if(!params.backdrop&&params.allowOutsideClick){
warn('"allowOutsideClick" parameter requires `backdrop` parameter to be set to `true`');
}
for (const param in params){
checkIfParamIsValid(param);
if(params.toast){
checkIfToastParamIsValid(param);
}
checkIfParamIsDeprecated(param);
}};
const swalPrefix='swal2-';
const prefix=items=> {
const result={};
for (const i in items){
result[items[i]]=swalPrefix + items[i];
}
return result;
};
const swalClasses=prefix(['container', 'shown', 'height-auto', 'iosfix', 'popup', 'modal', 'no-backdrop', 'no-transition', 'toast', 'toast-shown', 'show', 'hide', 'close', 'title', 'html-container', 'actions', 'confirm', 'deny', 'cancel', 'default-outline', 'footer', 'icon', 'icon-content', 'image', 'input', 'file', 'range', 'select', 'radio', 'checkbox', 'label', 'textarea', 'inputerror', 'input-label', 'validation-message', 'progress-steps', 'active-progress-step', 'progress-step', 'progress-step-line', 'loader', 'loading', 'styled', 'top', 'top-start', 'top-end', 'top-left', 'top-right', 'center', 'center-start', 'center-end', 'center-left', 'center-right', 'bottom', 'bottom-start', 'bottom-end', 'bottom-left', 'bottom-right', 'grow-row', 'grow-column', 'grow-fullscreen', 'rtl', 'timer-progress-bar', 'timer-progress-bar-container', 'scrollbar-measure', 'icon-success', 'icon-warning', 'icon-info', 'icon-question', 'icon-error']);
const iconTypes=prefix(['success', 'warning', 'info', 'question', 'error']);
const getContainer=()=> document.body.querySelector(".".concat(swalClasses.container));
const elementBySelector=selectorString=> {
const container=getContainer();
return container ? container.querySelector(selectorString):null;
};
const elementByClass=className=> {
return elementBySelector(".".concat(className));
};
const getPopup=()=> elementByClass(swalClasses.popup);
const getIcon=()=> elementByClass(swalClasses.icon);
const getTitle=()=> elementByClass(swalClasses.title);
const getHtmlContainer=()=> elementByClass(swalClasses['html-container']);
const getImage=()=> elementByClass(swalClasses.image);
const getProgressSteps=()=> elementByClass(swalClasses['progress-steps']);
const getValidationMessage=()=> elementByClass(swalClasses['validation-message']);
const getConfirmButton=()=> elementBySelector(".".concat(swalClasses.actions, " .").concat(swalClasses.confirm));
const getDenyButton=()=> elementBySelector(".".concat(swalClasses.actions, " .").concat(swalClasses.deny));
const getInputLabel=()=> elementByClass(swalClasses['input-label']);
const getLoader=()=> elementBySelector(".".concat(swalClasses.loader));
const getCancelButton=()=> elementBySelector(".".concat(swalClasses.actions, " .").concat(swalClasses.cancel));
const getActions=()=> elementByClass(swalClasses.actions);
const getFooter=()=> elementByClass(swalClasses.footer);
const getTimerProgressBar=()=> elementByClass(swalClasses['timer-progress-bar']);
const getCloseButton=()=> elementByClass(swalClasses.close); // https://github.com/jkup/focusable/blob/master/index.js
const focusable="\n  a[href],\n  area[href],\n  input:not([disabled]),\n  select:not([disabled]),\n  textarea:not([disabled]),\n  button:not([disabled]),\n  iframe,\n  object,\n  embed,\n  [tabindex=\"0\"],\n  [contenteditable],\n  audio[controls],\n  video[controls],\n  summary\n";
const getFocusableElements=()=> {
const focusableElementsWithTabindex=toArray(getPopup().querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])'))
.sort((a, b)=> {
const tabindexA=parseInt(a.getAttribute('tabindex'));
const tabindexB=parseInt(b.getAttribute('tabindex'));
if(tabindexA > tabindexB){
return 1;
}else if(tabindexA < tabindexB){
return -1;
}
return 0;
});
const otherFocusableElements=toArray(getPopup().querySelectorAll(focusable)).filter(el=> el.getAttribute('tabindex')!=='-1');
return uniqueArray(focusableElementsWithTabindex.concat(otherFocusableElements)).filter(el=> isVisible(el));
};
const isModal=()=> {
return hasClass(document.body, swalClasses.shown)&&!hasClass(document.body, swalClasses['toast-shown'])&&!hasClass(document.body, swalClasses['no-backdrop']);
};
const isToast=()=> {
return getPopup()&&hasClass(getPopup(), swalClasses.toast);
};
const isLoading=()=> {
return getPopup().hasAttribute('data-loading');
};
const states={
previousBodyPadding: null
};
const setInnerHtml=(elem, html)=> {
elem.textContent='';
if(html){
const parser=new DOMParser();
const parsed=parser.parseFromString(html, "text/html");
toArray(parsed.querySelector('head').childNodes).forEach(child=> {
elem.appendChild(child);
});
toArray(parsed.querySelector('body').childNodes).forEach(child=> {
elem.appendChild(child);
});
}};
const hasClass=(elem, className)=> {
if(!className){
return false;
}
const classList=className.split(/\s+/);
for (let i=0; i < classList.length; i++){
if(!elem.classList.contains(classList[i])){
return false;
}}
return true;
};
const removeCustomClasses=(elem, params)=> {
toArray(elem.classList).forEach(className=> {
if(!Object.values(swalClasses).includes(className)&&!Object.values(iconTypes).includes(className)&&!Object.values(params.showClass).includes(className)){
elem.classList.remove(className);
}});
};
const applyCustomClass=(elem, params, className)=> {
removeCustomClasses(elem, params);
if(params.customClass&&params.customClass[className]){
if(typeof params.customClass[className]!=='string'&&!params.customClass[className].forEach){
return warn("Invalid type of customClass.".concat(className, "! Expected string or iterable object, got \"").concat(typeof params.customClass[className], "\""));
}
addClass(elem, params.customClass[className]);
}};
const getInput=(popup, inputType)=> {
if(!inputType){
return null;
}
switch (inputType){
case 'select':
case 'textarea':
case 'file':
return popup.querySelector(".".concat(swalClasses.popup, " > .").concat(swalClasses[inputType]));
case 'checkbox':
return popup.querySelector(".".concat(swalClasses.popup, " > .").concat(swalClasses.checkbox, " input"));
case 'radio':
return popup.querySelector(".".concat(swalClasses.popup, " > .").concat(swalClasses.radio, " input:checked"))||popup.querySelector(".".concat(swalClasses.popup, " > .").concat(swalClasses.radio, " input:first-child"));
case 'range':
return popup.querySelector(".".concat(swalClasses.popup, " > .").concat(swalClasses.range, " input"));
default:
return popup.querySelector(".".concat(swalClasses.popup, " > .").concat(swalClasses.input));
}};
const focusInput=input=> {
input.focus();
if(input.type!=='file'){
const val=input.value;
input.value='';
input.value=val;
}};
const toggleClass=(target, classList, condition)=> {
if(!target||!classList){
return;
}
if(typeof classList==='string'){
classList=classList.split(/\s+/).filter(Boolean);
}
classList.forEach(className=> {
if(Array.isArray(target)){
target.forEach(elem=> {
condition ? elem.classList.add(className):elem.classList.remove(className);
});
}else{
condition ? target.classList.add(className):target.classList.remove(className);
}});
};
const addClass=(target, classList)=> {
toggleClass(target, classList, true);
};
const removeClass=(target, classList)=> {
toggleClass(target, classList, false);
};
const getDirectChildByClass=(elem, className)=> {
const childNodes=toArray(elem.childNodes);
for (let i=0; i < childNodes.length; i++){
if(hasClass(childNodes[i], className)){
return childNodes[i];
}}
};
const applyNumericalStyle=(elem, property, value)=> {
if(value==="".concat(parseInt(value))){
value=parseInt(value);
}
if(value||parseInt(value)===0){
elem.style[property]=typeof value==='number' ? "".concat(value, "px"):value;
}else{
elem.style.removeProperty(property);
}};
const show=function (elem){
let display=arguments.length > 1&&arguments[1]!==undefined ? arguments[1]:'flex';
elem.style.display=display;
};
const hide=elem=> {
elem.style.display='none';
};
const setStyle=(parent, selector, property, value)=> {
const el=parent.querySelector(selector);
if(el){
el.style[property]=value;
}};
const toggle=(elem, condition, display)=> {
condition ? show(elem, display):hide(elem);
};
const isVisible=elem=> !!(elem&&(elem.offsetWidth||elem.offsetHeight||elem.getClientRects().length));
const allButtonsAreHidden=()=> !isVisible(getConfirmButton())&&!isVisible(getDenyButton())&&!isVisible(getCancelButton());
const isScrollable=elem=> !!(elem.scrollHeight > elem.clientHeight); // borrowed from https://stackoverflow.com/a/46352119
const hasCssAnimation=elem=> {
const style=window.getComputedStyle(elem);
const animDuration=parseFloat(style.getPropertyValue('animation-duration')||'0');
const transDuration=parseFloat(style.getPropertyValue('transition-duration')||'0');
return animDuration > 0||transDuration > 0;
};
const animateTimerProgressBar=function (timer){
let reset=arguments.length > 1&&arguments[1]!==undefined ? arguments[1]:false;
const timerProgressBar=getTimerProgressBar();
if(isVisible(timerProgressBar)){
if(reset){
timerProgressBar.style.transition='none';
timerProgressBar.style.width='100%';
}
setTimeout(()=> {
timerProgressBar.style.transition="width ".concat(timer / 1000, "s linear");
timerProgressBar.style.width='0%';
}, 10);
}};
const stopTimerProgressBar=()=> {
const timerProgressBar=getTimerProgressBar();
const timerProgressBarWidth=parseInt(window.getComputedStyle(timerProgressBar).width);
timerProgressBar.style.removeProperty('transition');
timerProgressBar.style.width='100%';
const timerProgressBarFullWidth=parseInt(window.getComputedStyle(timerProgressBar).width);
const timerProgressBarPercent=timerProgressBarWidth / timerProgressBarFullWidth * 100;
timerProgressBar.style.removeProperty('transition');
timerProgressBar.style.width="".concat(timerProgressBarPercent, "%");
};
const isNodeEnv=()=> typeof window==='undefined'||typeof document==='undefined';
const RESTORE_FOCUS_TIMEOUT=100;
const globalState={};
const focusPreviousActiveElement=()=> {
if(globalState.previousActiveElement&&globalState.previousActiveElement.focus){
globalState.previousActiveElement.focus();
globalState.previousActiveElement=null;
}else if(document.body){
document.body.focus();
}};
const restoreActiveElement=returnFocus=> {
return new Promise(resolve=> {
if(!returnFocus){
return resolve();
}
const x=window.scrollX;
const y=window.scrollY;
globalState.restoreFocusTimeout=setTimeout(()=> {
focusPreviousActiveElement();
resolve();
}, RESTORE_FOCUS_TIMEOUT);
window.scrollTo(x, y);
});
};
const sweetHTML="\n <div aria-labelledby=\"".concat(swalClasses.title, "\" aria-describedby=\"").concat(swalClasses['html-container'], "\" class=\"").concat(swalClasses.popup, "\" tabindex=\"-1\">\n   <button type=\"button\" class=\"").concat(swalClasses.close, "\"></button>\n   <ul class=\"").concat(swalClasses['progress-steps'], "\"></ul>\n   <div class=\"").concat(swalClasses.icon, "\"></div>\n   <img class=\"").concat(swalClasses.image, "\" />\n   <h2 class=\"").concat(swalClasses.title, "\" id=\"").concat(swalClasses.title, "\"></h2>\n   <div class=\"").concat(swalClasses['html-container'], "\" id=\"").concat(swalClasses['html-container'], "\"></div>\n   <input class=\"").concat(swalClasses.input, "\" />\n   <input type=\"file\" class=\"").concat(swalClasses.file, "\" />\n   <div class=\"").concat(swalClasses.range, "\">\n     <input type=\"range\" />\n     <output></output>\n   </div>\n   <select class=\"").concat(swalClasses.select, "\"></select>\n   <div class=\"").concat(swalClasses.radio, "\"></div>\n   <label for=\"").concat(swalClasses.checkbox, "\" class=\"").concat(swalClasses.checkbox, "\">\n     <input type=\"checkbox\" />\n     <span class=\"").concat(swalClasses.label, "\"></span>\n   </label>\n   <textarea class=\"").concat(swalClasses.textarea, "\"></textarea>\n   <div class=\"").concat(swalClasses['validation-message'], "\" id=\"").concat(swalClasses['validation-message'], "\"></div>\n   <div class=\"").concat(swalClasses.actions, "\">\n     <div class=\"").concat(swalClasses.loader, "\"></div>\n     <button type=\"button\" class=\"").concat(swalClasses.confirm, "\"></button>\n     <button type=\"button\" class=\"").concat(swalClasses.deny, "\"></button>\n     <button type=\"button\" class=\"").concat(swalClasses.cancel, "\"></button>\n   </div>\n   <div class=\"").concat(swalClasses.footer, "\"></div>\n   <div class=\"").concat(swalClasses['timer-progress-bar-container'], "\">\n     <div class=\"").concat(swalClasses['timer-progress-bar'], "\"></div>\n   </div>\n </div>\n").replace(/(^|\n)\s*/g, '');
const resetOldContainer=()=> {
const oldContainer=getContainer();
if(!oldContainer){
return false;
}
oldContainer.remove();
removeClass([document.documentElement, document.body], [swalClasses['no-backdrop'], swalClasses['toast-shown'], swalClasses['has-column']]);
return true;
};
const resetValidationMessage=()=> {
globalState.currentInstance.resetValidationMessage();
};
const addInputChangeListeners=()=> {
const popup=getPopup();
const input=getDirectChildByClass(popup, swalClasses.input);
const file=getDirectChildByClass(popup, swalClasses.file);
const range=popup.querySelector(".".concat(swalClasses.range, " input"));
const rangeOutput=popup.querySelector(".".concat(swalClasses.range, " output"));
const select=getDirectChildByClass(popup, swalClasses.select);
const checkbox=popup.querySelector(".".concat(swalClasses.checkbox, " input"));
const textarea=getDirectChildByClass(popup, swalClasses.textarea);
input.oninput=resetValidationMessage;
file.onchange=resetValidationMessage;
select.onchange=resetValidationMessage;
checkbox.onchange=resetValidationMessage;
textarea.oninput=resetValidationMessage;
range.oninput=()=> {
resetValidationMessage();
rangeOutput.value=range.value;
};
range.onchange=()=> {
resetValidationMessage();
range.nextSibling.value=range.value;
};};
const getTarget=target=> typeof target==='string' ? document.querySelector(target):target;
const setupAccessibility=params=> {
const popup=getPopup();
popup.setAttribute('role', params.toast ? 'alert':'dialog');
popup.setAttribute('aria-live', params.toast ? 'polite':'assertive');
if(!params.toast){
popup.setAttribute('aria-modal', 'true');
}};
const setupRTL=targetElement=> {
if(window.getComputedStyle(targetElement).direction==='rtl'){
addClass(getContainer(), swalClasses.rtl);
}};
const init=params=> {
const oldContainerExisted=resetOldContainer();
if(isNodeEnv()){
error('SweetAlert2 requires document to initialize');
return;
}
const container=document.createElement('div');
container.className=swalClasses.container;
if(oldContainerExisted){
addClass(container, swalClasses['no-transition']);
}
setInnerHtml(container, sweetHTML);
const targetElement=getTarget(params.target);
targetElement.appendChild(container);
setupAccessibility(params);
setupRTL(targetElement);
addInputChangeListeners();
};
const parseHtmlToContainer=(param, target)=> {
if(param instanceof HTMLElement){
target.appendChild(param);
}
else if(typeof param==='object'){
handleObject(param, target);
}
else if(param){
setInnerHtml(target, param);
}};
const handleObject=(param, target)=> {
if(param.jquery){
handleJqueryElem(target, param);
}else{
setInnerHtml(target, param.toString());
}};
const handleJqueryElem=(target, elem)=> {
target.textContent='';
if(0 in elem){
for (let i=0; (i in elem); i++){
target.appendChild(elem[i].cloneNode(true));
}}else{
target.appendChild(elem.cloneNode(true));
}};
const animationEndEvent=(()=> {
if(isNodeEnv()){
return false;
}
const testEl=document.createElement('div');
const transEndEventNames={
WebkitAnimation: 'webkitAnimationEnd',
animation: 'animationend'
};
for (const i in transEndEventNames){
if(Object.prototype.hasOwnProperty.call(transEndEventNames, i)&&typeof testEl.style[i]!=='undefined'){
return transEndEventNames[i];
}}
return false;
})();
const measureScrollbar=()=> {
const scrollDiv=document.createElement('div');
scrollDiv.className=swalClasses['scrollbar-measure'];
document.body.appendChild(scrollDiv);
const scrollbarWidth=scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
document.body.removeChild(scrollDiv);
return scrollbarWidth;
};
const renderActions=(instance, params)=> {
const actions=getActions();
const loader=getLoader();
if(!params.showConfirmButton&&!params.showDenyButton&&!params.showCancelButton){
hide(actions);
}else{
show(actions);
}
applyCustomClass(actions, params, 'actions');
renderButtons(actions, loader, params);
setInnerHtml(loader, params.loaderHtml);
applyCustomClass(loader, params, 'loader');
};
function renderButtons(actions, loader, params){
const confirmButton=getConfirmButton();
const denyButton=getDenyButton();
const cancelButton=getCancelButton();
renderButton(confirmButton, 'confirm', params);
renderButton(denyButton, 'deny', params);
renderButton(cancelButton, 'cancel', params);
handleButtonsStyling(confirmButton, denyButton, cancelButton, params);
if(params.reverseButtons){
if(params.toast){
actions.insertBefore(cancelButton, confirmButton);
actions.insertBefore(denyButton, confirmButton);
}else{
actions.insertBefore(cancelButton, loader);
actions.insertBefore(denyButton, loader);
actions.insertBefore(confirmButton, loader);
}}
}
function handleButtonsStyling(confirmButton, denyButton, cancelButton, params){
if(!params.buttonsStyling){
return removeClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
}
addClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
if(params.confirmButtonColor){
confirmButton.style.backgroundColor=params.confirmButtonColor;
addClass(confirmButton, swalClasses['default-outline']);
}
if(params.denyButtonColor){
denyButton.style.backgroundColor=params.denyButtonColor;
addClass(denyButton, swalClasses['default-outline']);
}
if(params.cancelButtonColor){
cancelButton.style.backgroundColor=params.cancelButtonColor;
addClass(cancelButton, swalClasses['default-outline']);
}}
function renderButton(button, buttonType, params){
toggle(button, params["show".concat(capitalizeFirstLetter(buttonType), "Button")], 'inline-block');
setInnerHtml(button, params["".concat(buttonType, "ButtonText")]);
button.setAttribute('aria-label', params["".concat(buttonType, "ButtonAriaLabel")]);
button.className=swalClasses[buttonType];
applyCustomClass(button, params, "".concat(buttonType, "Button"));
addClass(button, params["".concat(buttonType, "ButtonClass")]);
}
function handleBackdropParam(container, backdrop){
if(typeof backdrop==='string'){
container.style.background=backdrop;
}else if(!backdrop){
addClass([document.documentElement, document.body], swalClasses['no-backdrop']);
}}
function handlePositionParam(container, position){
if(position in swalClasses){
addClass(container, swalClasses[position]);
}else{
warn('The "position" parameter is not valid, defaulting to "center"');
addClass(container, swalClasses.center);
}}
function handleGrowParam(container, grow){
if(grow&&typeof grow==='string'){
const growClass="grow-".concat(grow);
if(growClass in swalClasses){
addClass(container, swalClasses[growClass]);
}}
}
const renderContainer=(instance, params)=> {
const container=getContainer();
if(!container){
return;
}
handleBackdropParam(container, params.backdrop);
handlePositionParam(container, params.position);
handleGrowParam(container, params.grow);
applyCustomClass(container, params, 'container');
};
var privateProps={
awaitingPromise: new WeakMap(),
promise: new WeakMap(),
innerParams: new WeakMap(),
domCache: new WeakMap()
};
const inputTypes=['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];
const renderInput=(instance, params)=> {
const popup=getPopup();
const innerParams=privateProps.innerParams.get(instance);
const rerender = !innerParams||params.input!==innerParams.input;
inputTypes.forEach(inputType=> {
const inputClass=swalClasses[inputType];
const inputContainer=getDirectChildByClass(popup, inputClass);
setAttributes(inputType, params.inputAttributes);
inputContainer.className=inputClass;
if(rerender){
hide(inputContainer);
}});
if(params.input){
if(rerender){
showInput(params);
}
setCustomClass(params);
}};
const showInput=params=> {
if(!renderInputType[params.input]){
return error("Unexpected type of input! Expected \"text\", \"email\", \"password\", \"number\", \"tel\", \"select\", \"radio\", \"checkbox\", \"textarea\", \"file\" or \"url\", got \"".concat(params.input, "\""));
}
const inputContainer=getInputContainer(params.input);
const input=renderInputType[params.input](inputContainer, params);
show(input);
setTimeout(()=> {
focusInput(input);
});
};
const removeAttributes=input=> {
for (let i=0; i < input.attributes.length; i++){
const attrName=input.attributes[i].name;
if(!['type', 'value', 'style'].includes(attrName)){
input.removeAttribute(attrName);
}}
};
const setAttributes=(inputType, inputAttributes)=> {
const input=getInput(getPopup(), inputType);
if(!input){
return;
}
removeAttributes(input);
for (const attr in inputAttributes){
input.setAttribute(attr, inputAttributes[attr]);
}};
const setCustomClass=params=> {
const inputContainer=getInputContainer(params.input);
if(params.customClass){
addClass(inputContainer, params.customClass.input);
}};
const setInputPlaceholder=(input, params)=> {
if(!input.placeholder||params.inputPlaceholder){
input.placeholder=params.inputPlaceholder;
}};
const setInputLabel=(input, prependTo, params)=> {
if(params.inputLabel){
input.id=swalClasses.input;
const label=document.createElement('label');
const labelClass=swalClasses['input-label'];
label.setAttribute('for', input.id);
label.className=labelClass;
addClass(label, params.customClass.inputLabel);
label.innerText=params.inputLabel;
prependTo.insertAdjacentElement('beforebegin', label);
}};
const getInputContainer=inputType=> {
const inputClass=swalClasses[inputType] ? swalClasses[inputType]:swalClasses.input;
return getDirectChildByClass(getPopup(), inputClass);
};
const renderInputType={};
renderInputType.text=renderInputType.email=renderInputType.password=renderInputType.number=renderInputType.tel=renderInputType.url=(input, params)=> {
if(typeof params.inputValue==='string'||typeof params.inputValue==='number'){
input.value=params.inputValue;
}else if(!isPromise(params.inputValue)){
warn("Unexpected type of inputValue! Expected \"string\", \"number\" or \"Promise\", got \"".concat(typeof params.inputValue, "\""));
}
setInputLabel(input, input, params);
setInputPlaceholder(input, params);
input.type=params.input;
return input;
};
renderInputType.file=(input, params)=> {
setInputLabel(input, input, params);
setInputPlaceholder(input, params);
return input;
};
renderInputType.range=(range, params)=> {
const rangeInput=range.querySelector('input');
const rangeOutput=range.querySelector('output');
rangeInput.value=params.inputValue;
rangeInput.type=params.input;
rangeOutput.value=params.inputValue;
setInputLabel(rangeInput, range, params);
return range;
};
renderInputType.select=(select, params)=> {
select.textContent='';
if(params.inputPlaceholder){
const placeholder=document.createElement('option');
setInnerHtml(placeholder, params.inputPlaceholder);
placeholder.value='';
placeholder.disabled=true;
placeholder.selected=true;
select.appendChild(placeholder);
}
setInputLabel(select, select, params);
return select;
};
renderInputType.radio=radio=> {
radio.textContent='';
return radio;
};
renderInputType.checkbox=(checkboxContainer, params)=> {
const checkbox=getInput(getPopup(), 'checkbox');
checkbox.value='1';
checkbox.id=swalClasses.checkbox;
checkbox.checked=Boolean(params.inputValue);
const label=checkboxContainer.querySelector('span');
setInnerHtml(label, params.inputPlaceholder);
return checkboxContainer;
};
renderInputType.textarea=(textarea, params)=> {
textarea.value=params.inputValue;
setInputPlaceholder(textarea, params);
setInputLabel(textarea, textarea, params);
const getMargin=el=> parseInt(window.getComputedStyle(el).marginLeft) + parseInt(window.getComputedStyle(el).marginRight); // https://github.com/sweetalert2/sweetalert2/issues/2291
setTimeout(()=> {
if('MutationObserver' in window){
const initialPopupWidth=parseInt(window.getComputedStyle(getPopup()).width);
const textareaResizeHandler=()=> {
const textareaWidth=textarea.offsetWidth + getMargin(textarea);
if(textareaWidth > initialPopupWidth){
getPopup().style.width="".concat(textareaWidth, "px");
}else{
getPopup().style.width=null;
}};
new MutationObserver(textareaResizeHandler).observe(textarea, {
attributes: true,
attributeFilter: ['style']
});
}});
return textarea;
};
const renderContent=(instance, params)=> {
const htmlContainer=getHtmlContainer();
applyCustomClass(htmlContainer, params, 'htmlContainer');
if(params.html){
parseHtmlToContainer(params.html, htmlContainer);
show(htmlContainer, 'block');
}
else if(params.text){
htmlContainer.textContent=params.text;
show(htmlContainer, 'block');
}else{
hide(htmlContainer);
}
renderInput(instance, params);
};
const renderFooter=(instance, params)=> {
const footer=getFooter();
toggle(footer, params.footer);
if(params.footer){
parseHtmlToContainer(params.footer, footer);
}
applyCustomClass(footer, params, 'footer');
};
const renderCloseButton=(instance, params)=> {
const closeButton=getCloseButton();
setInnerHtml(closeButton, params.closeButtonHtml);
applyCustomClass(closeButton, params, 'closeButton');
toggle(closeButton, params.showCloseButton);
closeButton.setAttribute('aria-label', params.closeButtonAriaLabel);
};
const renderIcon=(instance, params)=> {
const innerParams=privateProps.innerParams.get(instance);
const icon=getIcon();
if(innerParams&&params.icon===innerParams.icon){
setContent(icon, params);
applyStyles(icon, params);
return;
}
if(!params.icon&&!params.iconHtml){
return hide(icon);
}
if(params.icon&&Object.keys(iconTypes).indexOf(params.icon)===-1){
error("Unknown icon! Expected \"success\", \"error\", \"warning\", \"info\" or \"question\", got \"".concat(params.icon, "\""));
return hide(icon);
}
show(icon);
setContent(icon, params);
applyStyles(icon, params);
addClass(icon, params.showClass.icon);
};
const applyStyles=(icon, params)=> {
for (const iconType in iconTypes){
if(params.icon!==iconType){
removeClass(icon, iconTypes[iconType]);
}}
addClass(icon, iconTypes[params.icon]);
setColor(icon, params);
adjustSuccessIconBackgroundColor();
applyCustomClass(icon, params, 'icon');
};
const adjustSuccessIconBackgroundColor=()=> {
const popup=getPopup();
const popupBackgroundColor=window.getComputedStyle(popup).getPropertyValue('background-color');
const successIconParts=popup.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
for (let i=0; i < successIconParts.length; i++){
successIconParts[i].style.backgroundColor=popupBackgroundColor;
}};
const successIconHtml="\n  <div class=\"swal2-success-circular-line-left\"></div>\n  <span class=\"swal2-success-line-tip\"></span> <span class=\"swal2-success-line-long\"></span>\n  <div class=\"swal2-success-ring\"></div> <div class=\"swal2-success-fix\"></div>\n  <div class=\"swal2-success-circular-line-right\"></div>\n";
const errorIconHtml="\n  <span class=\"swal2-x-mark\">\n    <span class=\"swal2-x-mark-line-left\"></span>\n    <span class=\"swal2-x-mark-line-right\"></span>\n  </span>\n";
const setContent=(icon, params)=> {
icon.textContent='';
if(params.iconHtml){
setInnerHtml(icon, iconContent(params.iconHtml));
}else if(params.icon==='success'){
setInnerHtml(icon, successIconHtml);
}else if(params.icon==='error'){
setInnerHtml(icon, errorIconHtml);
}else{
const defaultIconHtml={
question: '?',
warning: '!',
info: 'i'
};
setInnerHtml(icon, iconContent(defaultIconHtml[params.icon]));
}};
const setColor=(icon, params)=> {
if(!params.iconColor){
return;
}
icon.style.color=params.iconColor;
icon.style.borderColor=params.iconColor;
for (const sel of ['.swal2-success-line-tip', '.swal2-success-line-long', '.swal2-x-mark-line-left', '.swal2-x-mark-line-right']){
setStyle(icon, sel, 'backgroundColor', params.iconColor);
}
setStyle(icon, '.swal2-success-ring', 'borderColor', params.iconColor);
};
const iconContent=content=> "<div class=\"".concat(swalClasses['icon-content'], "\">").concat(content, "</div>");
const renderImage=(instance, params)=> {
const image=getImage();
if(!params.imageUrl){
return hide(image);
}
show(image, '');
image.setAttribute('src', params.imageUrl);
image.setAttribute('alt', params.imageAlt);
applyNumericalStyle(image, 'width', params.imageWidth);
applyNumericalStyle(image, 'height', params.imageHeight);
image.className=swalClasses.image;
applyCustomClass(image, params, 'image');
};
const createStepElement=step=> {
const stepEl=document.createElement('li');
addClass(stepEl, swalClasses['progress-step']);
setInnerHtml(stepEl, step);
return stepEl;
};
const createLineElement=params=> {
const lineEl=document.createElement('li');
addClass(lineEl, swalClasses['progress-step-line']);
if(params.progressStepsDistance){
lineEl.style.width=params.progressStepsDistance;
}
return lineEl;
};
const renderProgressSteps=(instance, params)=> {
const progressStepsContainer=getProgressSteps();
if(!params.progressSteps||params.progressSteps.length===0){
return hide(progressStepsContainer);
}
show(progressStepsContainer);
progressStepsContainer.textContent='';
if(params.currentProgressStep >=params.progressSteps.length){
warn('Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)');
}
params.progressSteps.forEach((step, index)=> {
const stepEl=createStepElement(step);
progressStepsContainer.appendChild(stepEl);
if(index===params.currentProgressStep){
addClass(stepEl, swalClasses['active-progress-step']);
}
if(index!==params.progressSteps.length - 1){
const lineEl=createLineElement(params);
progressStepsContainer.appendChild(lineEl);
}});
};
const renderTitle=(instance, params)=> {
const title=getTitle();
toggle(title, params.title||params.titleText, 'block');
if(params.title){
parseHtmlToContainer(params.title, title);
}
if(params.titleText){
title.innerText=params.titleText;
}
applyCustomClass(title, params, 'title');
};
const renderPopup=(instance, params)=> {
const container=getContainer();
const popup=getPopup();
if(params.toast){
applyNumericalStyle(container, 'width', params.width);
popup.style.width='100%';
popup.insertBefore(getLoader(), getIcon());
}else{
applyNumericalStyle(popup, 'width', params.width);
}
applyNumericalStyle(popup, 'padding', params.padding);
if(params.color){
popup.style.color=params.color;
}
if(params.background){
popup.style.background=params.background;
}
hide(getValidationMessage());
addClasses(popup, params);
};
const addClasses=(popup, params)=> {
popup.className="".concat(swalClasses.popup, " ").concat(isVisible(popup) ? params.showClass.popup:'');
if(params.toast){
addClass([document.documentElement, document.body], swalClasses['toast-shown']);
addClass(popup, swalClasses.toast);
}else{
addClass(popup, swalClasses.modal);
}
applyCustomClass(popup, params, 'popup');
if(typeof params.customClass==='string'){
addClass(popup, params.customClass);
}
if(params.icon){
addClass(popup, swalClasses["icon-".concat(params.icon)]);
}};
const render=(instance, params)=> {
renderPopup(instance, params);
renderContainer(instance, params);
renderProgressSteps(instance, params);
renderIcon(instance, params);
renderImage(instance, params);
renderTitle(instance, params);
renderCloseButton(instance, params);
renderContent(instance, params);
renderActions(instance, params);
renderFooter(instance, params);
if(typeof params.didRender==='function'){
params.didRender(getPopup());
}};
const DismissReason=Object.freeze({
cancel: 'cancel',
backdrop: 'backdrop',
close: 'close',
esc: 'esc',
timer: 'timer'
});
const setAriaHidden=()=> {
const bodyChildren=toArray(document.body.children);
bodyChildren.forEach(el=> {
if(el===getContainer()||el.contains(getContainer())){
return;
}
if(el.hasAttribute('aria-hidden')){
el.setAttribute('data-previous-aria-hidden', el.getAttribute('aria-hidden'));
}
el.setAttribute('aria-hidden', 'true');
});
};
const unsetAriaHidden=()=> {
const bodyChildren=toArray(document.body.children);
bodyChildren.forEach(el=> {
if(el.hasAttribute('data-previous-aria-hidden')){
el.setAttribute('aria-hidden', el.getAttribute('data-previous-aria-hidden'));
el.removeAttribute('data-previous-aria-hidden');
}else{
el.removeAttribute('aria-hidden');
}});
};
const swalStringParams=['swal-title', 'swal-html', 'swal-footer'];
const getTemplateParams=params=> {
const template=typeof params.template==='string' ? document.querySelector(params.template):params.template;
if(!template){
return {};}
const templateContent=template.content;
showWarningsForElements(templateContent);
const result=Object.assign(getSwalParams(templateContent), getSwalButtons(templateContent), getSwalImage(templateContent), getSwalIcon(templateContent), getSwalInput(templateContent), getSwalStringParams(templateContent, swalStringParams));
return result;
};
const getSwalParams=templateContent=> {
const result={};
toArray(templateContent.querySelectorAll('swal-param')).forEach(param=> {
showWarningsForAttributes(param, ['name', 'value']);
const paramName=param.getAttribute('name');
const value=param.getAttribute('value');
if(typeof defaultParams[paramName]==='boolean'&&value==='false'){
result[paramName]=false;
}
if(typeof defaultParams[paramName]==='object'){
result[paramName]=JSON.parse(value);
}});
return result;
};
const getSwalButtons=templateContent=> {
const result={};
toArray(templateContent.querySelectorAll('swal-button')).forEach(button=> {
showWarningsForAttributes(button, ['type', 'color', 'aria-label']);
const type=button.getAttribute('type');
result["".concat(type, "ButtonText")]=button.innerHTML;
result["show".concat(capitalizeFirstLetter(type), "Button")]=true;
if(button.hasAttribute('color')){
result["".concat(type, "ButtonColor")]=button.getAttribute('color');
}
if(button.hasAttribute('aria-label')){
result["".concat(type, "ButtonAriaLabel")]=button.getAttribute('aria-label');
}});
return result;
};
const getSwalImage=templateContent=> {
const result={};
const image=templateContent.querySelector('swal-image');
if(image){
showWarningsForAttributes(image, ['src', 'width', 'height', 'alt']);
if(image.hasAttribute('src')){
result.imageUrl=image.getAttribute('src');
}
if(image.hasAttribute('width')){
result.imageWidth=image.getAttribute('width');
}
if(image.hasAttribute('height')){
result.imageHeight=image.getAttribute('height');
}
if(image.hasAttribute('alt')){
result.imageAlt=image.getAttribute('alt');
}}
return result;
};
const getSwalIcon=templateContent=> {
const result={};
const icon=templateContent.querySelector('swal-icon');
if(icon){
showWarningsForAttributes(icon, ['type', 'color']);
if(icon.hasAttribute('type')){
result.icon=icon.getAttribute('type');
}
if(icon.hasAttribute('color')){
result.iconColor=icon.getAttribute('color');
}
result.iconHtml=icon.innerHTML;
}
return result;
};
const getSwalInput=templateContent=> {
const result={};
const input=templateContent.querySelector('swal-input');
if(input){
showWarningsForAttributes(input, ['type', 'label', 'placeholder', 'value']);
result.input=input.getAttribute('type')||'text';
if(input.hasAttribute('label')){
result.inputLabel=input.getAttribute('label');
}
if(input.hasAttribute('placeholder')){
result.inputPlaceholder=input.getAttribute('placeholder');
}
if(input.hasAttribute('value')){
result.inputValue=input.getAttribute('value');
}}
const inputOptions=templateContent.querySelectorAll('swal-input-option');
if(inputOptions.length){
result.inputOptions={};
toArray(inputOptions).forEach(option=> {
showWarningsForAttributes(option, ['value']);
const optionValue=option.getAttribute('value');
const optionName=option.innerHTML;
result.inputOptions[optionValue]=optionName;
});
}
return result;
};
const getSwalStringParams=(templateContent, paramNames)=> {
const result={};
for (const i in paramNames){
const paramName=paramNames[i];
const tag=templateContent.querySelector(paramName);
if(tag){
showWarningsForAttributes(tag, []);
result[paramName.replace(/^swal-/, '')]=tag.innerHTML.trim();
}}
return result;
};
const showWarningsForElements=templateContent=> {
const allowedElements=swalStringParams.concat(['swal-param', 'swal-button', 'swal-image', 'swal-icon', 'swal-input', 'swal-input-option']);
toArray(templateContent.children).forEach(el=> {
const tagName=el.tagName.toLowerCase();
if(allowedElements.indexOf(tagName)===-1){
warn("Unrecognized element <".concat(tagName, ">"));
}});
};
const showWarningsForAttributes=(el, allowedAttributes)=> {
toArray(el.attributes).forEach(attribute=> {
if(allowedAttributes.indexOf(attribute.name)===-1){
warn(["Unrecognized attribute \"".concat(attribute.name, "\" on <").concat(el.tagName.toLowerCase(), ">."), "".concat(allowedAttributes.length ? "Allowed attributes are: ".concat(allowedAttributes.join(', ')):'To set the value, use HTML within the element.')]);
}});
};
var defaultInputValidators={
email: (string, validationMessage)=> {
return /^[a-zA-Z0-9.+_-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]{2,24}$/.test(string) ? Promise.resolve():Promise.resolve(validationMessage||'Invalid email address');
},
url: (string, validationMessage)=> {
return /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-z]{2,63}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)$/.test(string) ? Promise.resolve():Promise.resolve(validationMessage||'Invalid URL');
}};
function setDefaultInputValidators(params){
if(!params.inputValidator){
Object.keys(defaultInputValidators).forEach(key=> {
if(params.input===key){
params.inputValidator=defaultInputValidators[key];
}});
}}
function validateCustomTargetElement(params){
if(!params.target||typeof params.target==='string'&&!document.querySelector(params.target)||typeof params.target!=='string'&&!params.target.appendChild){
warn('Target parameter is not valid, defaulting to "body"');
params.target='body';
}}
function setParameters(params){
setDefaultInputValidators(params);
if(params.showLoaderOnConfirm&&!params.preConfirm){
warn('showLoaderOnConfirm is set to true, but preConfirm is not defined.\n' + 'showLoaderOnConfirm should be used together with preConfirm, see usage example:\n' + 'https://sweetalert2.github.io/#ajax-request');
}
validateCustomTargetElement(params);
if(typeof params.title==='string'){
params.title=params.title.split('\n').join('<br />');
}
init(params);
}
class Timer {
constructor(callback, delay){
this.callback=callback;
this.remaining=delay;
this.running=false;
this.start();
}
start(){
if(!this.running){
this.running=true;
this.started=new Date();
this.id=setTimeout(this.callback, this.remaining);
}
return this.remaining;
}
stop(){
if(this.running){
this.running=false;
clearTimeout(this.id);
this.remaining -=new Date().getTime() - this.started.getTime();
}
return this.remaining;
}
increase(n){
const running=this.running;
if(running){
this.stop();
}
this.remaining +=n;
if(running){
this.start();
}
return this.remaining;
}
getTimerLeft(){
if(this.running){
this.stop();
this.start();
}
return this.remaining;
}
isRunning(){
return this.running;
}}
const fixScrollbar=()=> {
if(states.previousBodyPadding!==null){
return;
}
if(document.body.scrollHeight > window.innerHeight){
states.previousBodyPadding=parseInt(window.getComputedStyle(document.body).getPropertyValue('padding-right'));
document.body.style.paddingRight="".concat(states.previousBodyPadding + measureScrollbar(), "px");
}};
const undoScrollbar=()=> {
if(states.previousBodyPadding!==null){
document.body.style.paddingRight="".concat(states.previousBodyPadding, "px");
states.previousBodyPadding=null;
}};
const iOSfix=()=> {
const iOS =
/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream||navigator.platform==='MacIntel'&&navigator.maxTouchPoints > 1;
if(iOS&&!hasClass(document.body, swalClasses.iosfix)){
const offset=document.body.scrollTop;
document.body.style.top="".concat(offset * -1, "px");
addClass(document.body, swalClasses.iosfix);
lockBodyScroll();
addBottomPaddingForTallPopups();
}};
const addBottomPaddingForTallPopups=()=> {
const ua=navigator.userAgent;
const iOS = !!ua.match(/iPad/i)||!!ua.match(/iPhone/i);
const webkit = !!ua.match(/WebKit/i);
const iOSSafari=iOS&&webkit&&!ua.match(/CriOS/i);
if(iOSSafari){
const bottomPanelHeight=44;
if(getPopup().scrollHeight > window.innerHeight - bottomPanelHeight){
getContainer().style.paddingBottom="".concat(bottomPanelHeight, "px");
}}
};
const lockBodyScroll=()=> {
const container=getContainer();
let preventTouchMove;
container.ontouchstart=e => {
preventTouchMove=shouldPreventTouchMove(e);
};
container.ontouchmove=e => {
if(preventTouchMove){
e.preventDefault();
e.stopPropagation();
}};};
const shouldPreventTouchMove=event=> {
const target=event.target;
const container=getContainer();
if(isStylus(event)||isZoom(event)){
return false;
}
if(target===container){
return true;
}
if(!isScrollable(container)&&target.tagName!=='INPUT' &&
target.tagName!=='TEXTAREA' &&
!(isScrollable(getHtmlContainer()) &&
getHtmlContainer().contains(target))){
return true;
}
return false;
};
const isStylus=event=> {
return event.touches&&event.touches.length&&event.touches[0].touchType==='stylus';
};
const isZoom=event=> {
return event.touches&&event.touches.length > 1;
};
const undoIOSfix=()=> {
if(hasClass(document.body, swalClasses.iosfix)){
const offset=parseInt(document.body.style.top, 10);
removeClass(document.body, swalClasses.iosfix);
document.body.style.top='';
document.body.scrollTop=offset * -1;
}};
const SHOW_CLASS_TIMEOUT=10;
const openPopup=params=> {
const container=getContainer();
const popup=getPopup();
if(typeof params.willOpen==='function'){
params.willOpen(popup);
}
const bodyStyles=window.getComputedStyle(document.body);
const initialBodyOverflow=bodyStyles.overflowY;
addClasses$1(container, popup, params);
setTimeout(()=> {
setScrollingVisibility(container, popup);
}, SHOW_CLASS_TIMEOUT);
if(isModal()){
fixScrollContainer(container, params.scrollbarPadding, initialBodyOverflow);
setAriaHidden();
}
if(!isToast()&&!globalState.previousActiveElement){
globalState.previousActiveElement=document.activeElement;
}
if(typeof params.didOpen==='function'){
setTimeout(()=> params.didOpen(popup));
}
removeClass(container, swalClasses['no-transition']);
};
const swalOpenAnimationFinished=event=> {
const popup=getPopup();
if(event.target!==popup){
return;
}
const container=getContainer();
popup.removeEventListener(animationEndEvent, swalOpenAnimationFinished);
container.style.overflowY='auto';
};
const setScrollingVisibility=(container, popup)=> {
if(animationEndEvent&&hasCssAnimation(popup)){
container.style.overflowY='hidden';
popup.addEventListener(animationEndEvent, swalOpenAnimationFinished);
}else{
container.style.overflowY='auto';
}};
const fixScrollContainer=(container, scrollbarPadding, initialBodyOverflow)=> {
iOSfix();
if(scrollbarPadding&&initialBodyOverflow!=='hidden'){
fixScrollbar();
}
setTimeout(()=> {
container.scrollTop=0;
});
};
const addClasses$1=(container, popup, params)=> {
addClass(container, params.showClass.backdrop); // this workaround with opacity is needed for https://github.com/sweetalert2/sweetalert2/issues/2059
popup.style.setProperty('opacity', '0', 'important');
show(popup, 'grid');
setTimeout(()=> {
addClass(popup, params.showClass.popup);
popup.style.removeProperty('opacity');
}, SHOW_CLASS_TIMEOUT);
addClass([document.documentElement, document.body], swalClasses.shown);
if(params.heightAuto&&params.backdrop&&!params.toast){
addClass([document.documentElement, document.body], swalClasses['height-auto']);
}};
const showLoading=buttonToReplace=> {
let popup=getPopup();
if(!popup){
new Swal();
}
popup=getPopup();
const loader=getLoader();
if(isToast()){
hide(getIcon());
}else{
replaceButton(popup, buttonToReplace);
}
show(loader);
popup.setAttribute('data-loading', true);
popup.setAttribute('aria-busy', true);
popup.focus();
};
const replaceButton=(popup, buttonToReplace)=> {
const actions=getActions();
const loader=getLoader();
if(!buttonToReplace&&isVisible(getConfirmButton())){
buttonToReplace=getConfirmButton();
}
show(actions);
if(buttonToReplace){
hide(buttonToReplace);
loader.setAttribute('data-button-to-replace', buttonToReplace.className);
}
loader.parentNode.insertBefore(loader, buttonToReplace);
addClass([popup, actions], swalClasses.loading);
};
const handleInputOptionsAndValue=(instance, params)=> {
if(params.input==='select'||params.input==='radio'){
handleInputOptions(instance, params);
}else if(['text', 'email', 'number', 'tel', 'textarea'].includes(params.input)&&(hasToPromiseFn(params.inputValue)||isPromise(params.inputValue))){
showLoading(getConfirmButton());
handleInputValue(instance, params);
}};
const getInputValue=(instance, innerParams)=> {
const input=instance.getInput();
if(!input){
return null;
}
switch (innerParams.input){
case 'checkbox':
return getCheckboxValue(input);
case 'radio':
return getRadioValue(input);
case 'file':
return getFileValue(input);
default:
return innerParams.inputAutoTrim ? input.value.trim():input.value;
}};
const getCheckboxValue=input=> input.checked ? 1:0;
const getRadioValue=input=> input.checked ? input.value:null;
const getFileValue=input=> input.files.length ? input.getAttribute('multiple')!==null ? input.files:input.files[0]:null;
const handleInputOptions=(instance, params)=> {
const popup=getPopup();
const processInputOptions=inputOptions=> populateInputOptions[params.input](popup, formatInputOptions(inputOptions), params);
if(hasToPromiseFn(params.inputOptions)||isPromise(params.inputOptions)){
showLoading(getConfirmButton());
asPromise(params.inputOptions).then(inputOptions=> {
instance.hideLoading();
processInputOptions(inputOptions);
});
}else if(typeof params.inputOptions==='object'){
processInputOptions(params.inputOptions);
}else{
error("Unexpected type of inputOptions! Expected object, Map or Promise, got ".concat(typeof params.inputOptions));
}};
const handleInputValue=(instance, params)=> {
const input=instance.getInput();
hide(input);
asPromise(params.inputValue).then(inputValue=> {
input.value=params.input==='number' ? parseFloat(inputValue)||0:"".concat(inputValue);
show(input);
input.focus();
instance.hideLoading();
}).catch(err=> {
error("Error in inputValue promise: ".concat(err));
input.value='';
show(input);
input.focus();
instance.hideLoading();
});
};
const populateInputOptions={
select: (popup, inputOptions, params)=> {
const select=getDirectChildByClass(popup, swalClasses.select);
const renderOption=(parent, optionLabel, optionValue)=> {
const option=document.createElement('option');
option.value=optionValue;
setInnerHtml(option, optionLabel);
option.selected=isSelected(optionValue, params.inputValue);
parent.appendChild(option);
};
inputOptions.forEach(inputOption=> {
const optionValue=inputOption[0];
const optionLabel=inputOption[1];
if(Array.isArray(optionLabel)){
const optgroup=document.createElement('optgroup');
optgroup.label=optionValue;
optgroup.disabled=false;
select.appendChild(optgroup);
optionLabel.forEach(o=> renderOption(optgroup, o[1], o[0]));
}else{
renderOption(select, optionLabel, optionValue);
}});
select.focus();
},
radio: (popup, inputOptions, params)=> {
const radio=getDirectChildByClass(popup, swalClasses.radio);
inputOptions.forEach(inputOption=> {
const radioValue=inputOption[0];
const radioLabel=inputOption[1];
const radioInput=document.createElement('input');
const radioLabelElement=document.createElement('label');
radioInput.type='radio';
radioInput.name=swalClasses.radio;
radioInput.value=radioValue;
if(isSelected(radioValue, params.inputValue)){
radioInput.checked=true;
}
const label=document.createElement('span');
setInnerHtml(label, radioLabel);
label.className=swalClasses.label;
radioLabelElement.appendChild(radioInput);
radioLabelElement.appendChild(label);
radio.appendChild(radioLabelElement);
});
const radios=radio.querySelectorAll('input');
if(radios.length){
radios[0].focus();
}}
};
const formatInputOptions=inputOptions=> {
const result=[];
if(typeof Map!=='undefined'&&inputOptions instanceof Map){
inputOptions.forEach((value, key)=> {
let valueFormatted=value;
if(typeof valueFormatted==='object'){
valueFormatted=formatInputOptions(valueFormatted);
}
result.push([key, valueFormatted]);
});
}else{
Object.keys(inputOptions).forEach(key=> {
let valueFormatted=inputOptions[key];
if(typeof valueFormatted==='object'){
valueFormatted=formatInputOptions(valueFormatted);
}
result.push([key, valueFormatted]);
});
}
return result;
};
const isSelected=(optionValue, inputValue)=> {
return inputValue&&inputValue.toString()===optionValue.toString();
};
function hideLoading(){
const innerParams=privateProps.innerParams.get(this);
if(!innerParams){
return;
}
const domCache=privateProps.domCache.get(this);
hide(domCache.loader);
if(isToast()){
if(innerParams.icon){
show(getIcon());
}}else{
showRelatedButton(domCache);
}
removeClass([domCache.popup, domCache.actions], swalClasses.loading);
domCache.popup.removeAttribute('aria-busy');
domCache.popup.removeAttribute('data-loading');
domCache.confirmButton.disabled=false;
domCache.denyButton.disabled=false;
domCache.cancelButton.disabled=false;
}
const showRelatedButton=domCache=> {
const buttonToReplace=domCache.popup.getElementsByClassName(domCache.loader.getAttribute('data-button-to-replace'));
if(buttonToReplace.length){
show(buttonToReplace[0], 'inline-block');
}else if(allButtonsAreHidden()){
hide(domCache.actions);
}};
function getInput$1(instance){
const innerParams=privateProps.innerParams.get(instance||this);
const domCache=privateProps.domCache.get(instance||this);
if(!domCache){
return null;
}
return getInput(domCache.popup, innerParams.input);
}
var privateMethods={
swalPromiseResolve: new WeakMap(),
swalPromiseReject: new WeakMap()
};
const isVisible$1=()=> {
return isVisible(getPopup());
};
const clickConfirm=()=> getConfirmButton()&&getConfirmButton().click();
const clickDeny=()=> getDenyButton()&&getDenyButton().click();
const clickCancel=()=> getCancelButton()&&getCancelButton().click();
const removeKeydownHandler=globalState=> {
if(globalState.keydownTarget&&globalState.keydownHandlerAdded){
globalState.keydownTarget.removeEventListener('keydown', globalState.keydownHandler, {
capture: globalState.keydownListenerCapture
});
globalState.keydownHandlerAdded=false;
}};
const addKeydownHandler=(instance, globalState, innerParams, dismissWith)=> {
removeKeydownHandler(globalState);
if(!innerParams.toast){
globalState.keydownHandler=e => keydownHandler(instance, e, dismissWith);
globalState.keydownTarget=innerParams.keydownListenerCapture ? window:getPopup();
globalState.keydownListenerCapture=innerParams.keydownListenerCapture;
globalState.keydownTarget.addEventListener('keydown', globalState.keydownHandler, {
capture: globalState.keydownListenerCapture
});
globalState.keydownHandlerAdded=true;
}};
const setFocus=(innerParams, index, increment)=> {
const focusableElements=getFocusableElements();
if(focusableElements.length){
index=index + increment;
if(index===focusableElements.length){
index=0;
}else if(index===-1){
index=focusableElements.length - 1;
}
return focusableElements[index].focus();
}
getPopup().focus();
};
const arrowKeysNextButton=['ArrowRight', 'ArrowDown'];
const arrowKeysPreviousButton=['ArrowLeft', 'ArrowUp'];
const keydownHandler=(instance, e, dismissWith)=> {
const innerParams=privateProps.innerParams.get(instance);
if(!innerParams){
return;
}
if(e.isComposing||e.keyCode===229){
return;
}
if(innerParams.stopKeydownPropagation){
e.stopPropagation();
}
if(e.key==='Enter'){
handleEnter(instance, e, innerParams);
}
else if(e.key==='Tab'){
handleTab(e, innerParams);
}
else if([...arrowKeysNextButton, ...arrowKeysPreviousButton].includes(e.key)){
handleArrows(e.key);
}
else if(e.key==='Escape'){
handleEsc(e, innerParams, dismissWith);
}};
const handleEnter=(instance, e, innerParams)=> {
if(!callIfFunction(innerParams.allowEnterKey)){
return;
}
if(e.target&&instance.getInput()&&e.target.outerHTML===instance.getInput().outerHTML){
if(['textarea', 'file'].includes(innerParams.input)){
return;
}
clickConfirm();
e.preventDefault();
}};
const handleTab=(e, innerParams)=> {
const targetElement=e.target;
const focusableElements=getFocusableElements();
let btnIndex=-1;
for (let i=0; i < focusableElements.length; i++){
if(targetElement===focusableElements[i]){
btnIndex=i;
break;
}}
if(!e.shiftKey){
setFocus(innerParams, btnIndex, 1);
}else{
setFocus(innerParams, btnIndex, -1);
}
e.stopPropagation();
e.preventDefault();
};
const handleArrows=key=> {
const confirmButton=getConfirmButton();
const denyButton=getDenyButton();
const cancelButton=getCancelButton();
if(![confirmButton, denyButton, cancelButton].includes(document.activeElement)){
return;
}
const sibling=arrowKeysNextButton.includes(key) ? 'nextElementSibling':'previousElementSibling';
let buttonToFocus=document.activeElement;
for (let i=0; i < getActions().children.length; i++){
buttonToFocus=buttonToFocus[sibling];
if(!buttonToFocus){
return;
}
if(isVisible(buttonToFocus)&&buttonToFocus instanceof HTMLButtonElement){
break;
}}
if(buttonToFocus instanceof HTMLButtonElement){
buttonToFocus.focus();
}};
const handleEsc=(e, innerParams, dismissWith)=> {
if(callIfFunction(innerParams.allowEscapeKey)){
e.preventDefault();
dismissWith(DismissReason.esc);
}};
function removePopupAndResetState(instance, container, returnFocus, didClose){
if(isToast()){
triggerDidCloseAndDispose(instance, didClose);
}else{
restoreActiveElement(returnFocus).then(()=> triggerDidCloseAndDispose(instance, didClose));
removeKeydownHandler(globalState);
}
const isSafari=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);
if(isSafari){
container.setAttribute('style', 'display:none !important');
container.removeAttribute('class');
container.innerHTML='';
}else{
container.remove();
}
if(isModal()){
undoScrollbar();
undoIOSfix();
unsetAriaHidden();
}
removeBodyClasses();
}
function removeBodyClasses(){
removeClass([document.documentElement, document.body], [swalClasses.shown, swalClasses['height-auto'], swalClasses['no-backdrop'], swalClasses['toast-shown']]);
}
function close(resolveValue){
resolveValue=prepareResolveValue(resolveValue);
const swalPromiseResolve=privateMethods.swalPromiseResolve.get(this);
const didClose=triggerClosePopup(this);
if(this.isAwaitingPromise()){
if(!resolveValue.isDismissed){
handleAwaitingPromise(this);
swalPromiseResolve(resolveValue);
}}else if(didClose){
swalPromiseResolve(resolveValue);
}}
function isAwaitingPromise(){
return !!privateProps.awaitingPromise.get(this);
}
const triggerClosePopup=instance=> {
const popup=getPopup();
if(!popup){
return false;
}
const innerParams=privateProps.innerParams.get(instance);
if(!innerParams||hasClass(popup, innerParams.hideClass.popup)){
return false;
}
removeClass(popup, innerParams.showClass.popup);
addClass(popup, innerParams.hideClass.popup);
const backdrop=getContainer();
removeClass(backdrop, innerParams.showClass.backdrop);
addClass(backdrop, innerParams.hideClass.backdrop);
handlePopupAnimation(instance, popup, innerParams);
return true;
};
function rejectPromise(error){
const rejectPromise=privateMethods.swalPromiseReject.get(this);
handleAwaitingPromise(this);
if(rejectPromise){
rejectPromise(error);
}}
const handleAwaitingPromise=instance=> {
if(instance.isAwaitingPromise()){
privateProps.awaitingPromise.delete(instance);
if(!privateProps.innerParams.get(instance)){
instance._destroy();
}}
};
const prepareResolveValue=resolveValue=> {
if(typeof resolveValue==='undefined'){
return {
isConfirmed: false,
isDenied: false,
isDismissed: true
};}
return Object.assign({
isConfirmed: false,
isDenied: false,
isDismissed: false
}, resolveValue);
};
const handlePopupAnimation=(instance, popup, innerParams)=> {
const container=getContainer();
const animationIsSupported=animationEndEvent&&hasCssAnimation(popup);
if(typeof innerParams.willClose==='function'){
innerParams.willClose(popup);
}
if(animationIsSupported){
animatePopup(instance, popup, container, innerParams.returnFocus, innerParams.didClose);
}else{
removePopupAndResetState(instance, container, innerParams.returnFocus, innerParams.didClose);
}};
const animatePopup=(instance, popup, container, returnFocus, didClose)=> {
globalState.swalCloseEventFinishedCallback=removePopupAndResetState.bind(null, instance, container, returnFocus, didClose);
popup.addEventListener(animationEndEvent, function (e){
if(e.target===popup){
globalState.swalCloseEventFinishedCallback();
delete globalState.swalCloseEventFinishedCallback;
}});
};
const triggerDidCloseAndDispose=(instance, didClose)=> {
setTimeout(()=> {
if(typeof didClose==='function'){
didClose.bind(instance.params)();
}
instance._destroy();
});
};
function setButtonsDisabled(instance, buttons, disabled){
const domCache=privateProps.domCache.get(instance);
buttons.forEach(button=> {
domCache[button].disabled=disabled;
});
}
function setInputDisabled(input, disabled){
if(!input){
return false;
}
if(input.type==='radio'){
const radiosContainer=input.parentNode.parentNode;
const radios=radiosContainer.querySelectorAll('input');
for (let i=0; i < radios.length; i++){
radios[i].disabled=disabled;
}}else{
input.disabled=disabled;
}}
function enableButtons(){
setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], false);
}
function disableButtons(){
setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], true);
}
function enableInput(){
return setInputDisabled(this.getInput(), false);
}
function disableInput(){
return setInputDisabled(this.getInput(), true);
}
function showValidationMessage(error){
const domCache=privateProps.domCache.get(this);
const params=privateProps.innerParams.get(this);
setInnerHtml(domCache.validationMessage, error);
domCache.validationMessage.className=swalClasses['validation-message'];
if(params.customClass&&params.customClass.validationMessage){
addClass(domCache.validationMessage, params.customClass.validationMessage);
}
show(domCache.validationMessage);
const input=this.getInput();
if(input){
input.setAttribute('aria-invalid', true);
input.setAttribute('aria-describedby', swalClasses['validation-message']);
focusInput(input);
addClass(input, swalClasses.inputerror);
}}
function resetValidationMessage$1(){
const domCache=privateProps.domCache.get(this);
if(domCache.validationMessage){
hide(domCache.validationMessage);
}
const input=this.getInput();
if(input){
input.removeAttribute('aria-invalid');
input.removeAttribute('aria-describedby');
removeClass(input, swalClasses.inputerror);
}}
function getProgressSteps$1(){
const domCache=privateProps.domCache.get(this);
return domCache.progressSteps;
}
function update(params){
const popup=getPopup();
const innerParams=privateProps.innerParams.get(this);
if(!popup||hasClass(popup, innerParams.hideClass.popup)){
return warn("You're trying to update the closed or closing popup, that won't work. Use the update() method in preConfirm parameter or show a new popup.");
}
const validUpdatableParams=filterValidParams(params);
const updatedParams=Object.assign({}, innerParams, validUpdatableParams);
render(this, updatedParams);
privateProps.innerParams.set(this, updatedParams);
Object.defineProperties(this, {
params: {
value: Object.assign({}, this.params, params),
writable: false,
enumerable: true
}});
}
const filterValidParams=params=> {
const validUpdatableParams={};
Object.keys(params).forEach(param=> {
if(isUpdatableParameter(param)){
validUpdatableParams[param]=params[param];
}else{
warn("Invalid parameter to update: \"".concat(param, "\". Updatable params are listed here: https://github.com/sweetalert2/sweetalert2/blob/master/src/utils/params.js\n\nIf you think this parameter should be updatable, request it here: https://github.com/sweetalert2/sweetalert2/issues/new?template=02_feature_request.md"));
}});
return validUpdatableParams;
};
function _destroy(){
const domCache=privateProps.domCache.get(this);
const innerParams=privateProps.innerParams.get(this);
if(!innerParams){
disposeWeakMaps(this);
return;
}
if(domCache.popup&&globalState.swalCloseEventFinishedCallback){
globalState.swalCloseEventFinishedCallback();
delete globalState.swalCloseEventFinishedCallback;
}
if(globalState.deferDisposalTimer){
clearTimeout(globalState.deferDisposalTimer);
delete globalState.deferDisposalTimer;
}
if(typeof innerParams.didDestroy==='function'){
innerParams.didDestroy();
}
disposeSwal(this);
}
const disposeSwal=instance=> {
disposeWeakMaps(instance);
delete instance.params;
delete globalState.keydownHandler;
delete globalState.keydownTarget;
delete globalState.currentInstance;
};
const disposeWeakMaps=instance=> {
if(instance.isAwaitingPromise()){
unsetWeakMaps(privateProps, instance);
privateProps.awaitingPromise.set(instance, true);
}else{
unsetWeakMaps(privateMethods, instance);
unsetWeakMaps(privateProps, instance);
}};
const unsetWeakMaps=(obj, instance)=> {
for (const i in obj){
obj[i].delete(instance);
}};
var instanceMethods=Object.freeze({
hideLoading: hideLoading,
disableLoading: hideLoading,
getInput: getInput$1,
close: close,
isAwaitingPromise: isAwaitingPromise,
rejectPromise: rejectPromise,
handleAwaitingPromise: handleAwaitingPromise,
closePopup: close,
closeModal: close,
closeToast: close,
enableButtons: enableButtons,
disableButtons: disableButtons,
enableInput: enableInput,
disableInput: disableInput,
showValidationMessage: showValidationMessage,
resetValidationMessage: resetValidationMessage$1,
getProgressSteps: getProgressSteps$1,
update: update,
_destroy: _destroy
});
const handleConfirmButtonClick=instance=> {
const innerParams=privateProps.innerParams.get(instance);
instance.disableButtons();
if(innerParams.input){
handleConfirmOrDenyWithInput(instance, 'confirm');
}else{
confirm(instance, true);
}};
const handleDenyButtonClick=instance=> {
const innerParams=privateProps.innerParams.get(instance);
instance.disableButtons();
if(innerParams.returnInputValueOnDeny){
handleConfirmOrDenyWithInput(instance, 'deny');
}else{
deny(instance, false);
}};
const handleCancelButtonClick=(instance, dismissWith)=> {
instance.disableButtons();
dismissWith(DismissReason.cancel);
};
const handleConfirmOrDenyWithInput=(instance, type
)=> {
const innerParams=privateProps.innerParams.get(instance);
if(!innerParams.input){
return error("The \"input\" parameter is needed to be set when using returnInputValueOn".concat(capitalizeFirstLetter(type)));
}
const inputValue=getInputValue(instance, innerParams);
if(innerParams.inputValidator){
handleInputValidator(instance, inputValue, type);
}else if(!instance.getInput().checkValidity()){
instance.enableButtons();
instance.showValidationMessage(innerParams.validationMessage);
}else if(type==='deny'){
deny(instance, inputValue);
}else{
confirm(instance, inputValue);
}};
const handleInputValidator=(instance, inputValue, type
)=> {
const innerParams=privateProps.innerParams.get(instance);
instance.disableInput();
const validationPromise=Promise.resolve().then(()=> asPromise(innerParams.inputValidator(inputValue, innerParams.validationMessage)));
validationPromise.then(validationMessage=> {
instance.enableButtons();
instance.enableInput();
if(validationMessage){
instance.showValidationMessage(validationMessage);
}else if(type==='deny'){
deny(instance, inputValue);
}else{
confirm(instance, inputValue);
}});
};
const deny=(instance, value)=> {
const innerParams=privateProps.innerParams.get(instance||undefined);
if(innerParams.showLoaderOnDeny){
showLoading(getDenyButton());
}
if(innerParams.preDeny){
privateProps.awaitingPromise.set(instance||undefined, true);
const preDenyPromise=Promise.resolve().then(()=> asPromise(innerParams.preDeny(value, innerParams.validationMessage)));
preDenyPromise.then(preDenyValue=> {
if(preDenyValue===false){
instance.hideLoading();
handleAwaitingPromise(instance);
}else{
instance.closePopup({
isDenied: true,
value: typeof preDenyValue==='undefined' ? value:preDenyValue
});
}}).catch(error$$1=> rejectWith(instance||undefined, error$$1));
}else{
instance.closePopup({
isDenied: true,
value
});
}};
const succeedWith=(instance, value)=> {
instance.closePopup({
isConfirmed: true,
value
});
};
const rejectWith=(instance, error$$1)=> {
instance.rejectPromise(error$$1);
};
const confirm=(instance, value)=> {
const innerParams=privateProps.innerParams.get(instance||undefined);
if(innerParams.showLoaderOnConfirm){
showLoading();
}
if(innerParams.preConfirm){
instance.resetValidationMessage();
privateProps.awaitingPromise.set(instance||undefined, true);
const preConfirmPromise=Promise.resolve().then(()=> asPromise(innerParams.preConfirm(value, innerParams.validationMessage)));
preConfirmPromise.then(preConfirmValue=> {
if(isVisible(getValidationMessage())||preConfirmValue===false){
instance.hideLoading();
handleAwaitingPromise(instance);
}else{
succeedWith(instance, typeof preConfirmValue==='undefined' ? value:preConfirmValue);
}}).catch(error$$1=> rejectWith(instance||undefined, error$$1));
}else{
succeedWith(instance, value);
}};
const handlePopupClick=(instance, domCache, dismissWith)=> {
const innerParams=privateProps.innerParams.get(instance);
if(innerParams.toast){
handleToastClick(instance, domCache, dismissWith);
}else{
handleModalMousedown(domCache);
handleContainerMousedown(domCache);
handleModalClick(instance, domCache, dismissWith);
}};
const handleToastClick=(instance, domCache, dismissWith)=> {
domCache.popup.onclick=()=> {
const innerParams=privateProps.innerParams.get(instance);
if(innerParams&&(isAnyButtonShown(innerParams)||innerParams.timer||innerParams.input)){
return;
}
dismissWith(DismissReason.close);
};};
const isAnyButtonShown=innerParams=> {
return innerParams.showConfirmButton||innerParams.showDenyButton||innerParams.showCancelButton||innerParams.showCloseButton;
};
let ignoreOutsideClick=false;
const handleModalMousedown=domCache=> {
domCache.popup.onmousedown=()=> {
domCache.container.onmouseup=function (e){
domCache.container.onmouseup=undefined;
if(e.target===domCache.container){
ignoreOutsideClick=true;
}};};
};
const handleContainerMousedown=domCache=> {
domCache.container.onmousedown=()=> {
domCache.popup.onmouseup=function (e){
domCache.popup.onmouseup=undefined;
if(e.target===domCache.popup||domCache.popup.contains(e.target)){
ignoreOutsideClick=true;
}};};
};
const handleModalClick=(instance, domCache, dismissWith)=> {
domCache.container.onclick=e => {
const innerParams=privateProps.innerParams.get(instance);
if(ignoreOutsideClick){
ignoreOutsideClick=false;
return;
}
if(e.target===domCache.container&&callIfFunction(innerParams.allowOutsideClick)){
dismissWith(DismissReason.backdrop);
}};};
const isJqueryElement=elem=> typeof elem==='object'&&elem.jquery;
const isElement=elem=> elem instanceof Element||isJqueryElement(elem);
const argsToParams=args=> {
const params={};
if(typeof args[0]==='object'&&!isElement(args[0])){
Object.assign(params, args[0]);
}else{
['title', 'html', 'icon'].forEach((name, index)=> {
const arg=args[index];
if(typeof arg==='string'||isElement(arg)){
params[name]=arg;
}else if(arg!==undefined){
error("Unexpected type of ".concat(name, "! Expected \"string\" or \"Element\", got ").concat(typeof arg));
}});
}
return params;
};
function fire(){
const Swal=this;
for (var _len=arguments.length, args=new Array(_len), _key=0; _key < _len; _key++){
args[_key]=arguments[_key];
}
return new Swal(...args);
}
function mixin(mixinParams){
class MixinSwal extends this {
_main(params, priorityMixinParams){
return super._main(params, Object.assign({}, mixinParams, priorityMixinParams));
}}
return MixinSwal;
}
const getTimerLeft=()=> {
return globalState.timeout&&globalState.timeout.getTimerLeft();
};
const stopTimer=()=> {
if(globalState.timeout){
stopTimerProgressBar();
return globalState.timeout.stop();
}};
const resumeTimer=()=> {
if(globalState.timeout){
const remaining=globalState.timeout.start();
animateTimerProgressBar(remaining);
return remaining;
}};
const toggleTimer=()=> {
const timer=globalState.timeout;
return timer&&(timer.running ? stopTimer():resumeTimer());
};
const increaseTimer=n => {
if(globalState.timeout){
const remaining=globalState.timeout.increase(n);
animateTimerProgressBar(remaining, true);
return remaining;
}};
const isTimerRunning=()=> {
return globalState.timeout&&globalState.timeout.isRunning();
};
let bodyClickListenerAdded=false;
const clickHandlers={};
function bindClickHandler(){
let attr=arguments.length > 0&&arguments[0]!==undefined ? arguments[0]:'data-swal-template';
clickHandlers[attr]=this;
if(!bodyClickListenerAdded){
document.body.addEventListener('click', bodyClickListener);
bodyClickListenerAdded=true;
}}
const bodyClickListener=event=> {
for (let el=event.target; el&&el!==document; el=el.parentNode){
for (const attr in clickHandlers){
const template=el.getAttribute(attr);
if(template){
clickHandlers[attr].fire({
template
});
return;
}}
}};
var staticMethods=Object.freeze({
isValidParameter: isValidParameter,
isUpdatableParameter: isUpdatableParameter,
isDeprecatedParameter: isDeprecatedParameter,
argsToParams: argsToParams,
isVisible: isVisible$1,
clickConfirm: clickConfirm,
clickDeny: clickDeny,
clickCancel: clickCancel,
getContainer: getContainer,
getPopup: getPopup,
getTitle: getTitle,
getHtmlContainer: getHtmlContainer,
getImage: getImage,
getIcon: getIcon,
getInputLabel: getInputLabel,
getCloseButton: getCloseButton,
getActions: getActions,
getConfirmButton: getConfirmButton,
getDenyButton: getDenyButton,
getCancelButton: getCancelButton,
getLoader: getLoader,
getFooter: getFooter,
getTimerProgressBar: getTimerProgressBar,
getFocusableElements: getFocusableElements,
getValidationMessage: getValidationMessage,
isLoading: isLoading,
fire: fire,
mixin: mixin,
showLoading: showLoading,
enableLoading: showLoading,
getTimerLeft: getTimerLeft,
stopTimer: stopTimer,
resumeTimer: resumeTimer,
toggleTimer: toggleTimer,
increaseTimer: increaseTimer,
isTimerRunning: isTimerRunning,
bindClickHandler: bindClickHandler
});
let currentInstance;
class SweetAlert {
constructor(){
if(typeof window==='undefined'){
return;
}
currentInstance=this;
for (var _len=arguments.length, args=new Array(_len), _key=0; _key < _len; _key++){
args[_key]=arguments[_key];
}
const outerParams=Object.freeze(this.constructor.argsToParams(args));
Object.defineProperties(this, {
params: {
value: outerParams,
writable: false,
enumerable: true,
configurable: true
}});
const promise=this._main(this.params);
privateProps.promise.set(this, promise);
}
_main(userParams){
let mixinParams=arguments.length > 1&&arguments[1]!==undefined ? arguments[1]:{};
showWarningsForParams(Object.assign({}, mixinParams, userParams));
if(globalState.currentInstance){
globalState.currentInstance._destroy();
if(isModal()){
unsetAriaHidden();
}}
globalState.currentInstance=this;
const innerParams=prepareParams(userParams, mixinParams);
setParameters(innerParams);
Object.freeze(innerParams);
if(globalState.timeout){
globalState.timeout.stop();
delete globalState.timeout;
}
clearTimeout(globalState.restoreFocusTimeout);
const domCache=populateDomCache(this);
render(this, innerParams);
privateProps.innerParams.set(this, innerParams);
return swalPromise(this, domCache, innerParams);
}
then(onFulfilled){
const promise=privateProps.promise.get(this);
return promise.then(onFulfilled);
}
finally(onFinally){
const promise=privateProps.promise.get(this);
return promise.finally(onFinally);
}}
const swalPromise=(instance, domCache, innerParams)=> {
return new Promise((resolve, reject)=> {
const dismissWith=dismiss=> {
instance.closePopup({
isDismissed: true,
dismiss
});
};
privateMethods.swalPromiseResolve.set(instance, resolve);
privateMethods.swalPromiseReject.set(instance, reject);
domCache.confirmButton.onclick=()=> handleConfirmButtonClick(instance);
domCache.denyButton.onclick=()=> handleDenyButtonClick(instance);
domCache.cancelButton.onclick=()=> handleCancelButtonClick(instance, dismissWith);
domCache.closeButton.onclick=()=> dismissWith(DismissReason.close);
handlePopupClick(instance, domCache, dismissWith);
addKeydownHandler(instance, globalState, innerParams, dismissWith);
handleInputOptionsAndValue(instance, innerParams);
openPopup(innerParams);
setupTimer(globalState, innerParams, dismissWith);
initFocus(domCache, innerParams);
setTimeout(()=> {
domCache.container.scrollTop=0;
});
});
};
const prepareParams=(userParams, mixinParams)=> {
const templateParams=getTemplateParams(userParams);
const params=Object.assign({}, defaultParams, mixinParams, templateParams, userParams);
params.showClass=Object.assign({}, defaultParams.showClass, params.showClass);
params.hideClass=Object.assign({}, defaultParams.hideClass, params.hideClass);
return params;
};
const populateDomCache=instance=> {
const domCache={
popup: getPopup(),
container: getContainer(),
actions: getActions(),
confirmButton: getConfirmButton(),
denyButton: getDenyButton(),
cancelButton: getCancelButton(),
loader: getLoader(),
closeButton: getCloseButton(),
validationMessage: getValidationMessage(),
progressSteps: getProgressSteps()
};
privateProps.domCache.set(instance, domCache);
return domCache;
};
const setupTimer=(globalState$$1, innerParams, dismissWith)=> {
const timerProgressBar=getTimerProgressBar();
hide(timerProgressBar);
if(innerParams.timer){
globalState$$1.timeout=new Timer(()=> {
dismissWith('timer');
delete globalState$$1.timeout;
}, innerParams.timer);
if(innerParams.timerProgressBar){
show(timerProgressBar);
applyCustomClass(timerProgressBar, innerParams, 'timerProgressBar');
setTimeout(()=> {
if(globalState$$1.timeout&&globalState$$1.timeout.running){
animateTimerProgressBar(innerParams.timer);
}});
}}
};
const initFocus=(domCache, innerParams)=> {
if(innerParams.toast){
return;
}
if(!callIfFunction(innerParams.allowEnterKey)){
return blurActiveElement();
}
if(!focusButton(domCache, innerParams)){
setFocus(innerParams, -1, 1);
}};
const focusButton=(domCache, innerParams)=> {
if(innerParams.focusDeny&&isVisible(domCache.denyButton)){
domCache.denyButton.focus();
return true;
}
if(innerParams.focusCancel&&isVisible(domCache.cancelButton)){
domCache.cancelButton.focus();
return true;
}
if(innerParams.focusConfirm&&isVisible(domCache.confirmButton)){
domCache.confirmButton.focus();
return true;
}
return false;
};
const blurActiveElement=()=> {
if(document.activeElement instanceof HTMLElement&&typeof document.activeElement.blur==='function'){
document.activeElement.blur();
}};
Object.assign(SweetAlert.prototype, instanceMethods);
Object.assign(SweetAlert, staticMethods);
Object.keys(instanceMethods).forEach(key=> {
SweetAlert[key]=function (){
if(currentInstance){
return currentInstance[key](...arguments);
}};});
SweetAlert.DismissReason=DismissReason;
SweetAlert.version='11.4.8';
const Swal=SweetAlert;
Swal.default=Swal;
return Swal;
}));
if(typeof this!=='undefined'&&this.Sweetalert2){  this.swal=this.sweetAlert=this.Swal=this.SweetAlert=this.Sweetalert2};
(function($){
var subscription={
init: function(){
$('input#wpuf-recuring-pay').on('click', this.showSubscriptionRecurring);
$('input#wpuf-trial-status').on('click', this.showSubscriptionPack);
$('.wpuf-coupon-info-wrap').on('click','a.wpuf-apply-coupon', this.couponApply);
$('.wpuf-coupon-info-wrap').on('click','a.wpuf-copon-show', this.couponShow);
$('.wpuf-coupon-info-wrap').on('click','a.wpuf-copon-cancel', this.couponCancel);
$('.wpuf-assing-pack-btn').on('click', this.showPackDropdown);
$('.wpuf-delete-pack-btn').on('click', this.deletePack);
$('.wpuf-disabled-link').click(this.packAlert);
this.changeExpirationFieldVisibility(':checkbox#wpuf-enable_post_expiration');
$('.wpuf-metabox-post_expiration').on('change',':checkbox#wpuf-enable_post_expiration',this.changeExpirationFieldVisibility);
$('.wpuf-metabox-post_expiration').on('change','select#wpuf-expiration_time_type',this.setTimeExpiration);
$('body.post-type-wpuf_subscription #post').submit(function(event){
if(document.activeElement.value==='Update'){
event.preventDefault();
Swal.fire({
title: 'Are you sure to update the subscription?',
text: 'The changes you made will be applied only to the new subscriptions and pending recurring payments.',
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Update'
}).then((result)=> {
if(result.isConfirmed){
$(this).unbind('submit').submit()
}});
}});
},
packAlert:function (){
alert(wpuf_subscription.pack_notice);
},
showPackDropdown: function(e){
e.preventDefault();
var self=$(this),
wrap=self.parents('.wpuf-user-subscription'),
sub_dropdown=wrap.find('.wpuf-pack-dropdown'),
sub_details=wrap.find('.wpuf-user-sub-info'),
cancel_btn=wrap.find('.wpuf-cancel-pack'),
add_btn=wrap.find('.wpuf-add-pack');
if(sub_dropdown.attr('disabled')==='disabled'){
sub_dropdown.show().removeAttr('disabled');
sub_details.hide().attr('disabled', true);
cancel_btn.show();
add_btn.hide();
}else{
sub_details.show().removeAttr('disabled');
sub_dropdown.hide().attr('disabled', true);
cancel_btn.hide();
add_btn.show();
}},
deletePack: function(e){
var self=$(this),
wrap=self.parents('.wpuf-user-subscription'),
sub_dropdown=wrap.find('.wpuf-pack-dropdown'),
selected_sub=wrap.find('#wpuf_sub_pack'),
userid=$(e.target).attr('data-userid'),
packid=$(e.target).attr('data-packid');
wrap.find('.wpuf-delete-pack-btn').attr('disabled', true);
wrap.css('opacity', 0.5);
$.post(ajaxurl,
{
'action':'wpuf_delete_user_package',
'userid':userid,
'packid':packid,
'wpuf_subscription_delete_nonce': wpuf_subs_vars.wpuf_subscription_delete_nonce
},
function(data){
if(data){
wrap.css('opacity', 1);
$('.wpuf-user-sub-info').remove();
$(e.target).remove();
selected_sub.val(-1);
sub_dropdown.show();
}}
);
},
couponCancel: function(e){
e.preventDefault();
var self=$(this),
data={
action: 'wpuf_coupon_cancel',
_wpnonce: wpuf_frontend.nonce,
pack_id: self.data('pack_id')
},
coupon_field=self.parents('.wpuf-coupon-info-wrap').find('input.wpuf-coupon-field');
coupon_field.addClass('wpuf-coupon-field-spinner');
$.post(wpuf_frontend.ajaxurl, data, function(res){
coupon_field.removeClass('wpuf-coupon-field-spinner');
if(res.success){
$('.wpuf-pack-inner').html(res.data.append_data);
$('.wpuf-coupon-id-field').val('');
var coupon_wrap=self.closest('.wpuf-copon-wrap');
coupon_wrap.hide();
coupon_wrap.siblings('.wpuf-copon-show').show();
$('.wpuf-subscription-success').html('');
$('.wpuf-subscription-error').html('');
}});
},
couponShow: function(e){
e.preventDefault();
var self=$(this);
self.hide();
self.parents('.wpuf-coupon-info-wrap').find('.wpuf-copon-wrap').show();
},
couponApply: function(e){
e.preventDefault();
var self=$(this),
coupon_field=self.parents('.wpuf-coupon-info-wrap').find('input.wpuf-coupon-field'),
coupon=coupon_field.val();
if(coupon===''){
$('.wpuf-subscription-error').html(wpuf_frontend.coupon_error);
return;
}
var data={
action: 'wpuf_coupon_apply',
_wpnonce: wpuf_frontend.nonce,
coupon: coupon,
pack_id: self.data('pack_id')
};
if(self.attr('disabled')==='disabled'){
}
self.attr('disabled', true);
coupon_field.addClass('wpuf-coupon-field-spinner');
$.post(wpuf_frontend.ajaxurl, data, function(res){
coupon_field.removeClass('wpuf-coupon-field-spinner');
if(res.success){
$('.wpuf-pack-inner').html(res.data.append_data);
$('.wpuf-coupon-id-field').val(res.data.coupon_id);
if(res.data.amount <=0){
$('.wpuf-nullamount-hide').hide();
}
$('.wpuf-subscription-success').html(res.data.message);
$('.wpuf-subscription-error').html('');
}else{
$('.wpuf-subscription-success').html('');
$('.wpuf-subscription-error').html(res.data.message);
}});
},
showSubscriptionRecurring: function(){
var self=$(this),
wrap=self.parents('table.form-table'),
pack_child=wrap.find('.wpuf-recurring-child'),
trial_checkbox=wrap.find('input#wpuf-trial-status'),
trial_child=wrap.find('.wpuf-trial-child'),
expire_field=wrap.find('.wpuf-subcription-expire');
if(self.is(':checked')){
if(trial_checkbox.is(':checked')){
trial_child.show();
}
pack_child.show();
expire_field.hide();
}else{
trial_child.hide();
pack_child.hide();
expire_field.show();
}},
showSubscriptionPack: function(){
var self=$(this),
pack_status=self.closest('table.form-table').find('.wpuf-trial-child');
if(self.is(':checked')){
pack_status.show();
}else{
pack_status.hide();
}},
setTimeExpiration: function(e){
var timeArray={
'day':30,
'month':12,
'year': 100
};
$('#wpuf-expiration_time_value').html('');
var timeVal=e.target?$(e.target).val():$(e).val();
for(var time=1; time <=timeArray[timeVal]; time++){
$('#wpuf-expiration_time_value').append('<option>'+ time +'</option>');
}},
changeExpirationFieldVisibility:function(e){
var checkbox_obj=e.target? $(e.target):$(e);
if(checkbox_obj.is(':checked')){
$('.wpuf_subscription_expiration_field').show();
}else{
$('.wpuf_subscription_expiration_field').hide();
}},
};
if(typeof datepicker==='function'){
$('.wpuf-date-picker').datepicker({ dateFormat: "yy-mm-dd" });
}
subscription.init();
})(jQuery);