/*!
 * Twinstone TDI (https://github.com/twinstone/tdi)
 * Version: 1.10.0
 *
 * Copyright Etnetera a.s. https://www.etnetera.cz
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
!function(d){var t="currentScript";t in d||Object.defineProperty(d,t,{get:function(){try{throw new Error}catch(t){var e,n=0,r=/.*at [^(]*\((.*):(.+):(.+)\)$/gi.exec(t.stack),a=r&&r[1]||!1,i=r&&r[2]||!1,o=d.location.href.replace(d.location.hash,""),s=d.getElementsByTagName("script");for(a===o&&(r=d.documentElement.outerHTML,i=new RegExp("(?:[^\\n]+?\\n){0,"+(i-2)+"}[^<]*<script>([\\d\\D]*?)<\\/script>[\\d\\D]*","i"),e=r.replace(i,"$1").trim());n<s.length;n++){if("interactive"===s[n].readyState)return s[n];if(s[n].src===a)return s[n];if(a===o&&s[n].innerHTML&&s[n].innerHTML.trim()===e)return s[n]}return null}}})}(document),function(){"use strict";if(void 0===jQuery)throw"Missing dependency: jQuery!";if(function(t,e){for(var n=t.split("."),r=e.split("."),a=0;a<3;a++){var i=Number(n[a]),o=Number(r[a]);if(o<i)return 1;if(i<o)return-1;if(!isNaN(i)&&isNaN(o))return 1;if(isNaN(i)&&!isNaN(o))return-1}return 0}(jQuery.fn.jquery,"1.10.2")<0)try{console.log("Recommended version of jQuery is 1.10.2 or higher."),console.log("See: https://github.com/twinstone/tdi/issues/8"),console.log("See: https://bugs.jquery.com/ticket/13936")}catch(t){}window.TDI={}}(),function(g){"use strict";var e,o,s,t=document.currentScript,i=t?t.nonce||t.getAttribute("nonce"):void 0,n="unload",r="pagehide";function a(t){t.persisted||($(document).off("click",e.linkClick,c).off("submit",e.formSubmit,u).off("click",e.formButtonActivate,l).off("change",e.fieldChange,f).off("keydown",e.fieldSubmit,m),window["pagehide"===t.type?r:n]=!0)}function d(t){var e=$(t.currentTarget);t.ctrlKey||t.metaKey||t.shiftKey||t.button&&1===t.button||(t.preventDefault(),e.trigger("tdi:ajax:beforeLinkClick",{link:e}))}function c(t){g.Ajax.send(t.target)}function u(t){var e=$(t.currentTarget);t.preventDefault(),e.trigger("tdi:ajax:beforeFormSubmit",{form:e})}function p(t){g.Ajax.send(t.target)}function l(t){var e=t.currentTarget,t=$(e),e=$(e.form);e.data("_submitButton",t),t.attr("name")&&(e.find("input.submit-action").remove(),$("<input>").attr("type","hidden").attr("name",t.attr("name")).attr("value",t.attr("value")).addClass("submit-action").appendTo(e))}function f(t){t=t.currentTarget;$(t).data("ajax-url")?g.Ajax.send(t):$(t.form).submit()}function m(t){var e=t.currentTarget;13===t.keyCode&&(t.preventDefault(),$(e).data("ajax-url")?g.Ajax.send(e):$(e.form).submit())}g.Ajax=(e={linkClick:["a.ajaxlink","a.tdi","a.infuse"].join(","),formSubmit:["form.ajaxform","form.tdi","form.infuse"].join(","),formButtonActivate:["form.ajaxform [type=submit]","form.tdi [type=submit]","form.infuse [type=submit]"].join(","),fieldChange:["select.ajaxselect","select.tdi","select.infuse","input[type=checkbox].tdi","input[type=checkbox].infuse","input[type=radio].tdi","input[type=radio].infuse"].join(","),fieldSubmit:["input[type=text].tdi","input[type=text].infuse"].join(",")},$(document).on("submit",e.formSubmit,u).on("click",e.linkClick,d).on("click",e.formButtonActivate,l).on("change",e.fieldChange,f).on("keydown",e.fieldSubmit,m),$(window).on("onpagehide"in window?r:n,a),$.event.special["tdi:ajax:beforeLinkClick"]={_default:c},$.event.special["tdi:ajax:beforeFormSubmit"]={_default:p},{send:function(t,e){e=e||{};var n=$(t),r=n.attr("name"),a=n.val(),i=n.data("confirm"),o=n.closest(n.data("related-ancestor")||"").add($(n.data("related-element")||"")).add($(n.attr("rel")||"")).add($(n.data("_submitButton")||"")),s=n.add(o),d=$(n.data("trigger-group")||""),c=n.data("ajax-url")||n.attr("href")||n.attr("action"),u=n.data("ajax-method")||n.attr("method"),p=n.data("ajax-xhr-fields")||{},t={};if(""!==c&&void 0!==c||!a||(c=a),r&&a&&(n.is("input[type=checkbox]")&&!1===n.prop("checked")?t[r]=0:t[r]=a),!n.is("[disabled], .disabled")&&(!i||window.confirm(i))){p={beforeStart:function(){var t=e.beforeStart&&e.beforeStart.apply(this,arguments);return(void 0===t||!0===t)&&(s.addClass("loading"),d.each(function(t,e){e.hasClass("disabled")||e.prop("disabled")||(e.addClass("disabled").prop("disabled",!0),e.data("_disabled",!0))}),o.get(0)&&o.addClass("loading-target"),e.start&&e.start.apply(this,arguments),!0)},beforeEnd:function(){var t=e.beforeEnd&&e.beforeEnd.apply(this,arguments);void 0!==t&&!0!==t||(s.removeClass("loading"),d.each(function(t,e){!0===e.data("_disabled")&&(e.removeClass("disabled").prop("disabled",!1),e.data("_disabled",!1))}),o.get(0)&&o.removeClass("loading-target"),e.end&&e.end.apply(this,arguments))},data:t,method:u,trigger:n,involvedElms:s,xhrFields:p};return n.is("form")?(p.end=function(){n.data("_submitButton",null),n.find("input.submit-action").remove()},g.Ajax.Request.sendForm(n,p)):g.Ajax.Request.send(c,p)}}}),g.Ajax.Request=(o=!!((t=new XMLHttpRequest)&&"upload"in t&&"onprogress"in t.upload),s=!!window.FormData,{send:function(t,r){(r=r||{}).url=g.Ajax.Request.ajaxifyUrl(t),r.xhrFields=r.xhrFields||{},r.type=r.type||r.method||"GET",r.async=!r.sync,r.data=r.data||"",r.dataType=r.dataType||"xml",o&&s&&r.data instanceof FormData&&(r.processData=!1,r.contentType=!1);t=$.extend({},r);return t.beforeSend=function(t,e){var n=r.beforeStart&&r.beforeStart(t,e,r);return(void 0===n||!0===n)&&($(document).trigger("tdi:ajax:_start",{xhr:t,settings:e,options:r}),r.start&&r.start(t,e,r),!0)},t.success=function(t,e,n){$(document).trigger("tdi:ajax:_success",{data:t,textStatus:e,xhr:n,options:r}),r.success&&r.success(t,e,n,r)},t.error=function(t,e,n){$(document).trigger("tdi:ajax:_error",{xhr:t,textStatus:e,error:n,options:r}),r.error&&r.error(t,e,n,r)},t.complete=function(t,e){var n=r.beforeEnd&&r.beforeEnd(t,e,r);void 0!==n&&!0!==n||($(document).trigger("tdi:ajax:_end",{xhr:t,textStatus:e,options:r}),r.end&&r.end(t,e,r))},$.ajax(t)},sendForm:function(t,n){n=n||{};var r=$(t),a=r.data("_submitButton"),t=r.data("ajax-url")||r.attr("action");if(r.attr("enctype")||r.attr("enctype","application/x-www-form-urlencoded"),n.contentType=r.attr("enctype")+"; charset=UTF-8",n.method=n.method||r.attr("method"),!(0<r.find("input[type=file]").length))return n.data=r.serialize(),g.Ajax.Request.send(t,n);if(n.method="post",r.attr("enctype","multipart/form-data"),n.contentType=r.attr("enctype")+"; charset=UTF-8",o&&s)return n.data=new FormData(r.get(0)),n.processData=!1,n.contentType=!1,g.Ajax.Request.send(t,n);if(n.url=g.Ajax.Request.ajaxifyUrl(t),!1===(n.beforeStart&&n.beforeStart(r,n)))return!1;$(document).trigger("tdi:ajax:_start",{xhr:r,settings:null,options:n}),n.start&&n.start(r,n),a&&a.addClass("loading");var i,t="form_iframe_"+(new Date).getTime();return document.documentMode&&document.documentMode<=8?i=document.createElement('<iframe name="'+t+'">'):(i=document.createElement("iframe")).name=t,i.style.display="none",document.body.appendChild(i),$(i).load(function(){var t=this.contentWindow.document.XMLDocument||this.contentWindow.document,e={responseXML:t,responseText:t.body?t.getElementsByTagName("html")[0].innerHTML:null};if(!1===(n.beforeEnd&&n.beforeEnd(r,n,t)))return!1;a&&a.removeClass("loading"),$(document).trigger("tdi:ajax:_success",{data:t,textStatus:"",xhr:e,options:n}),$(document).trigger("tdi:ajax:_end",{xhr:r,textStatus:null,options:n}),r.trigger("tdi:ajax:_formSubmit",{form:r,options:n,xhr:e,data:t}),n.end&&n.end(r,n,t),setTimeout(function(){$(i).off().remove(),r.removeAttr("target")},1e4)}),r.attr("action",n.url),r.attr("method",n.method||"post"),r.attr("target",t),r.attr("enctype","multipart/form-data"),r[0].submit(),null},ajaxifyUrl:function(t){var e="_infuse=1&_ts="+(new Date).getTime();return 0<=t.indexOf("?#")?t.replace(/\?#/,"?"+e+"#"):0<t.indexOf("&#")?t.replace(/&#/,"&"+e+"#"):0<=t.indexOf("?")?t.replace(/\?/,"?"+e+"&"):0<=t.indexOf("#")?t.replace(/#/,"?"+e+"#"):t+"?"+e}}),g.Ajax.Response=function(){var t,n,c,e,s,d,p,u;function l(t,e,n){t.trigger("tdi:ajax:done",[{responses:e,options:n}])}function f(t,e,n,r){$(document).trigger("tdi:ajax:error",[{status:t?t.status:"N/A",message:n||"Invalid Ajax response. The response must be a valid XML.",xhr:t,textStatus:e,options:r}])}function m(t,e){if(!t)return!1;var n=$(t),t=$.trim(n.text()),n={script_src:n.attr("src"),script_data:t,script_id:n.attr("id"),options:e,tag:n};p.scripts.push(n),$(document).trigger("tdi:ajax:beforeScript",n)}for(t in $(document).on("tdi:ajax:_start",function(t,e){var n,r;n=e.xhr,r=e.settings,e=e.options,u=!1,$(e.involvedElms||document).trigger("tdi:ajax:start",[{xhr:n,options:e,settings:r}])}),$(document).on("tdi:ajax:_success",function(t,e){!function(t,e,n,r){if(!t)return f(n,e,null,r);var a,i=$(t),t=i.find("status");"ok"!==t.text().toLowerCase()&&f(n,e,t.text(),r);i.find("response > *:not(status)").each(function(){var t=this.tagName.toLowerCase();"script"===t?d.push(this):s[t]?s[t](this,r):function(t,e){if(!t)return;for(var n=$(t),r=t.tagName.toLowerCase(),a=r.substr(0,1).toUpperCase()+r.substr(1),i=t.attributes,o={_name:r,contents:$.trim(n.text()),options:e,tag:n},s=0,d=i.length;s<d;s++)o[i[s].name]=i[s].value;$.event.special["tdi:ajax:before"+a]={_default:c},$(document).trigger("tdi:ajax:before"+a,o),p.unknowns.push(o)}(this,r)});var o=$(r.involvedElms).filter(function(t,e){return(document.body||document).contains(e)});0===o.length&&(o=$(document));(function(t,e,n){t.trigger("tdi:ajax:updatesDone",[{updates:e,options:n}])})(o,p.updates,r),function(t,e,n){t.trigger("tdi:ajax:insertsDone",[{inserts:e,options:n}])}(o,p.inserts,r),function(t,e,n){t.trigger("tdi:ajax:stylesDone",[{styles:e,options:n}])}(o,p.styles,r),function(t,e,n){t.trigger("tdi:ajax:popupsDone",[{popups:e,options:n}])}(o,p.popups,r),function(t,e,n){t.trigger("tdi:ajax:unknownsDone",[{unknowns:e,options:n}])}(o,p.unknowns,r),d.length?(a=window.setInterval(function(){var t,e,n;u&&(window.clearInterval(a),t=o,e=p.scripts,n=r,t.trigger("tdi:ajax:scriptsDone",[{scripts:e,options:n}]),l(o,p,r))},100),m(d.shift(),r)):l(o,p,r)}(e.data,e.textStatus,e.xhr,e.options)}),$(document).on("tdi:ajax:_error",function(t,e){f(e.xhr,e.textStatus,e.error,e.options)}),$(document).on("tdi:ajax:_end",function(t,e){e.xhr,e.textStatus,e=e.options,$(e.involvedElms||document).trigger("tdi:ajax:end",[{options:e}])}),s={update:function(t,e){if(!t)return!1;var n=$(t),r=n.attr("target"),a=n.attr("selector"),i=a?$(a):$(document.getElementById(r)),o=$.trim(n.text()),s=n.attr("replace"),d=n.attr("append"),c=n.attr("prepend"),u=n.attr("class-add")||"",t=n.attr("class-remove")||"",n={target_id:r,selector:a,target:i,content:o,content_empty:0===o.replace(/\&nbsp;/g,"").length,replace:s,append:d,prepend:c,class_add:u,class_remove:t,options:e,tag:n};0<i.length&&(i.first().trigger("tdi:ajax:beforeUpdate",n),p.updates.push(n))},insert:function(t,e){if(!t)return!1;var n=$(t),r=n.attr("target"),a=n.attr("selector"),i=a?$(a):$(document.getElementById(r)),o=$.trim(n.text()),t=n.attr("position")||"after",n={target_id:r,selector:a,target:i,content:o,position:t,inserted_node:void 0,options:e,tag:n};0<i.length&&(i.first().trigger("tdi:ajax:beforeInsert",n),p.inserts.push(n))},script:m,style:function(t,e){if(!t)return!1;var n=$(t),r=n.attr("src"),t=n.attr("id"),n={style_src:r,style_id:t,options:e,tag:n};$(document).trigger("tdi:ajax:beforeStyle",n),p.styles.push(n)},reload:function(t,e){if(!t)return!1;t=$(t),t={options:e,tag:t};$(document).trigger("tdi:ajax:beforeReload",t)},redirect:function(t,e){if(!t)return!1;t=$(t),t={href:t.attr("href"),options:e,tag:t};t.href&&$(document).trigger("tdi:ajax:beforeRedirect",t)},popup:function(t,e){if(!t)return!1;var n=$(t),r=n.attr("mode")||"popup",a=n.attr("href"),i=n.attr("width")||600,t=n.attr("height")||500,n={href:a,mode:r,width:parseInt(i),height:parseInt(t),options:e,tag:n};a&&($(document).trigger("tdi:ajax:beforePopup",n),p.popups.push(n))}},d=[],p={updates:[],inserts:[],scripts:[],styles:[],popups:[],unknowns:[]},c=function(t,e){(n[t.type]||function(t,e){$(document).trigger("tdi:ajax:"+e._name,e)}).call(this,t,$.isArray(e)?e[1]:e)},e=function(t){"tdi:ajax:beforeScript"===t.type&&(u=!0)},n={"tdi:ajax:beforeUpdate":function(t,e){var n;e.target.removeClass(e.class_remove).addClass(e.class_add),"true"===e.replace?(n=$(e.content),e.target.find("*").addBack().off(),e.target.replaceWith(n),e.target=n):"true"===e.append?e.target.append(e.content):"true"===e.prepend?e.target.prepend(e.content):(e.target.find("*").off(),e.target.html(e.content)),e.target.first().trigger("tdi:ajax:update",e)},"tdi:ajax:beforeInsert":function(t,e){e.inserted_node=$(e.content)["before"===e.position?"insertBefore":"insertAfter"](e.target),e.target.trigger("tdi:ajax:insert",e)},"tdi:ajax:beforeScript":function(t,n){function e(t){var e;n.script_data&&(e=document.createElement("script"),i&&(e.setAttribute("nonce",i),e.nonce=i),e.type="text/javascript",e.text=n.script_data,n.script_id&&(e.id=n.script_id+"_inline"),document.getElementsByTagName("head")[0].appendChild(e)),n.script_node=t,n.script_node_inline=e,$(document).trigger("tdi:ajax:script",n),r.length?m(r.shift()):u=!0}var r=d,a=!0;n.script_src?(n.script_id&&document.getElementById(n.script_id)&&(a=!1),a&&g.Tools.getScript(n.script_src,{id:n.script_id,complete:e,nonce:i})):e()},"tdi:ajax:beforeStyle":function(t,e){var n=!0;e.style_id&&document.getElementById(e.style_id)&&(n=!1),n&&g.Tools.getStyle(e.style_src,{id:e.style_id,complete:function(t){e.style_node=t,$(document).trigger("tdi:ajax:style",e)}})},"tdi:ajax:beforeReload":function(t,e){window.location.reload(!0)},"tdi:ajax:beforeRedirect":function(t,e){window.location.assign(e.href)},"tdi:ajax:beforePopup":function(t,e){var n="";"dialog"===e.mode&&(n+="width="+e.width+", height="+e.height),e.popup=window.open(e.href,"_blank",n),$(document).trigger("tdi:ajax:popup",e)}})$.event.special[t]={_default:c,postDispatch:e};return{}}()}(window.TDI),function(){"use strict";window.TDI.Tools={getScript:function(t,e){var n,r=!1;t&&(e=e||{},(n=document.createElement("script")).type="text/javascript",n.src=t,e.id&&(n.id=e.id),e.nonce&&(n.setAttribute("nonce",e.nonce),n.nonce=e.nonce),e.complete&&(n.onreadystatechange=function(){var t=this.readyState;r||"loaded"!==t&&"complete"!==t||(r=!0,n.onreadystatechange=null,e.complete(n))},n.onload=function(){r||(r=!0,e.complete(n))}),document.getElementsByTagName("head")[0].appendChild(n))},getStyle:function(t,e){var n;t&&(e=e||{},(n=document.createElement("link")).rel="stylesheet",n.type="text/css",n.media=e.media||"screen",n.href=t,e.id&&(n.id=e.id),document.getElementsByTagName("head")[0].appendChild(n),e.complete&&e.complete(n))}}}();