{"size": 30405, "ext": "js", "max_stars_repo_path": "admin/assets/js/app.min.js", "max_stars_repo_name": "aukc1970/formwork", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "admin/assets/js/app.min.js", "max_issues_repo_name": "aukc1970/formwork", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "admin/assets/js/app.min.js", "max_forks_repo_name": "aukc1970/formwork", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 30405.0, "max_line_length": 30405, "alphanum_fraction": 0.6435454695}
var Formwork={baseUri:$("meta[name=base-uri]").attr("content"),init:function(){Formwork.Modals.init(),Formwork.Forms.init(),Formwork.Dropdowns.init(),Formwork.Tooltips.init(),Formwork.Dashboard.init(),Formwork.Pages.init(),Formwork.Updates.init(),$(".toggle-navigation").on("click",function(){$(".sidebar").toggleClass("show")}),$("[data-chart-data]").each(function(){var t=$(this).data("chart-data");new Formwork.Chart(this,t)}),$("meta[name=notification]").each(function(){var t=$(this);new Formwork.Notification(t.attr("content"),t.attr("data-type"),t.attr("data-interval")),t.remove()}),0<$("[data-command=save]").length&&$(document).on("keydown",function(){if(!event.altKey&&(event.ctrlKey||event.metaKey)&&83===event.which)return $("[data-command=save]").trigger("click"),!1})}};$(function(){Formwork.init()}),Formwork.Chart=function(t,e){var a=new Chartist.Line(t,e,{showArea:!0,fullWidth:!0,scaleMinSpace:20,divisor:5,chartPadding:20,lineSmooth:!1,low:0,axisX:{showGrid:!1,labelOffset:{x:0,y:10}},axisY:{onlyInteger:!0,offset:15,labelOffset:{x:0,y:5}}}),n=-1!==navigator.userAgent.indexOf("Firefox");$(a.container).on("mouseover",".ct-point",function(){var t=$(this),e={x:0,y:-8};if(n){var a=parseFloat(t.css("stroke-width"));e.x+=a/2,e.y+=a/2}new Formwork.Tooltip(t.attr("ct:value"),{referenceElement:t,offset:e}).show()})},Formwork.Dashboard={init:function(){$("[data-command=clear-cache]").on("click",function(){new Formwork.Request({method:"POST",url:Formwork.baseUri+"cache/clear/",data:{"csrf-token":$("meta[name=csrf-token]").attr("content")}},function(t){Formwork.Notification(t.message,t.status,5e3)})}),$("[data-command=make-backup]").on("click",function(){var a=$(this);a.attr("disabled",!0),new Formwork.Request({method:"POST",url:Formwork.baseUri+"backup/make/",data:{"csrf-token":$("meta[name=csrf-token]").attr("content")}},function(e){Formwork.Notification(e.message,e.status,5e3),setTimeout(function(){if("success"===e.status){var t=$("meta[name=csrf-token]").attr("content");Formwork.Utils.download(e.data.uri,t)}a.removeAttr("disabled")},1e3)})})}},Formwork.Dropdowns={init:function(){0<$(".dropdown").length&&$(document).on("click",function(t){var e=$(t.target).closest(".dropdown-button");if(0<e.length){var a=$("#"+e.attr("data-dropdown"),".dropdown"),n=a.is(":visible");t.preventDefault()}$(".dropdown-menu").hide(),void 0===a||n||a.show()})}},Formwork.Editor=function(t){var e=document.getElementById(t),r=CodeMirror.fromTextArea(e,{mode:"markdown",theme:"formwork",indentUnit:4,lineWrapping:!0,addModeClass:!0,extraKeys:{Enter:"newlineAndIndentContinueMarkdownList"}}),a=".editor-toolbar[data-for="+t+"]";function n(){return/\n+===\n+/.test(r.getValue())}function o(){$("[data-command=summary]",a).attr("disabled",n())}function i(){var t=r.getLine(r.getCursor().line);return 0===t.length?void 0:t.slice(-1)}function s(){switch(i()){case void 0:return"";case"\n":return"\n";default:return"\n\n"}}function l(t,e,a){void 0===e&&(e=t);var n=!0===a?"":r.getSelection(),o=r.getCursor(),i=t.split("\n").length-1;r.replaceSelection(t+n+e),r.setCursor(o.line+i,o.ch+t.length-i),r.focus()}$("[data-command=bold]",a).on("click",function(){l("**")}),$("[data-command=italic]",a).on("click",function(){l("_")}),$("[data-command=ul]",a).on("click",function(){l(s()+"- ","")}),$("[data-command=ol]",a).on("click",function(){var t=/^\d+\./.exec(function(t){var e=t.lastIndexOf("\n");return-1!==e?t.substring(e+1):t}(r.getValue()));l(t?"\n"+(parseInt(t)+1)+". ":s()+"1. ","")}),$("[data-command=quote]",a).on("click",function(){l(s()+"> ","")}),$("[data-command=link]",a).on("click",function(){var t=r.getSelection();/^(https?:\/\/|mailto:)/i.test(t)?l("[","]("+t+")",!0):""!==t?l("["+t+"](http://",")",!0):l("[","](http://)")}),$("[data-command=image]",a).on("click",function(){Formwork.Modals.show("imagesModal",null,function(t){$(".image-picker-thumbnail.selected",t).removeClass("selected"),$(".image-picker-confirm",t).data("target",function(t){void 0!==t?l(s()+"![","]("+t+")"):l(s()+"![](",")")})})}),$("[data-command=summary]",a).on("click",function(){if(!n()){var t=i();l((void 0===t||"\n"===t?"":"\n")+"\n===\n\n",""),$(this).attr("disabled",!0)}}),$("[data-command=undo]",a).on("click",function(){r.undo(),r.focus()}),$("[data-command=redo]",a).on("click",function(){r.redo(),r.focus()}),o(),r.on("changes",Formwork.Utils.debounce(function(){e.value=r.getValue(),o(),$("[data-command=undo]").attr("disabled",r.historySize().undo<1),$("[data-command=redo]").attr("disabled",r.historySize().redo<1)},500)),$(document).on("keydown",function(t){if(!t.altKey&&(t.ctrlKey||t.metaKey))switch(t.which){case 66:return $("[data-command=bold]",a).trigger("click"),!1;case 73:return $("[data-command=italic]",a).trigger("click"),!1;case 75:return $("[data-command=link]",a).trigger("click"),!1}})},Formwork.Form=function(t){var e=$(window),n=$(t);function a(t){void 0===t&&(t=!0);var e=$(":file",n);if(!0===t&&0<e.length)for(var a=0;a<e.length;a++)if(0<e[a].files.length)return!0;return n.serialize()!==n.data("originalData")}n.data("originalData",n.serialize()),e.on("beforeunload",function(){if(a())return!0}),n.on("submit",function(){e.off("beforeunload")}),$("input:file[data-auto-upload]",n).on("change",function(){a(!1)||n.trigger("submit")}),$("[data-command=continue]","#changesModal").on("click",function(){e.off("beforeunload"),window.location.href=$(this).attr("data-href")}),$('a[href]:not([href^="#"]):not([target="_blank"])').on("click",function(t){if(a()){var e=this;t.preventDefault(),Formwork.Modals.show("changesModal",null,function(t){$("[data-command=continue]",t).attr("data-href",e.href)})}})},Formwork.Forms={init:function(){$("[data-form]").each(function(){new Formwork.Form($(this))}),$("input[data-enable]").on("change",function(){var t=$(this),a=t.is(":checked");$.each(t.attr("data-enable").split(","),function(t,e){$('input[name="'+e+'"]').attr("disabled",!a)})}),$(".input-reset").on("click",function(){var t=$("#"+$(this).attr("data-reset"));t.val(""),t.trigger("change")}),$("input:file").each(function(){var t=$(this),e=$('label[for="'+t.attr("id")+'"] span').html();t.data("originalLabel",e)}).on("change input",function(){var t=$(this),e=$('label[for="'+t.attr("id")+'"] span'),a=t.prop("files");a.length?e.text(a[0].name):e.html(t.data("originalLabel"))}),$(".file-input-label").on("drag dragstart dragend dragover dragenter dragleave drop",function(t){t.preventDefault()}).on("drop",function(t){var e=$("#"+$(this).attr("for"));e.prop("files",t.originalEvent.dataTransfer.files),e.trigger("change")}).on("dragover dragenter",function(){$(this).addClass("drag")}).on("dragleave drop",function(){$(this).removeClass("drag")}),$("input[data-field=tags]").tagInput(),$(".image-input").on("click",function(){var e=$(this),a=e.val();Formwork.Modals.show("imagesModal",null,function(t){$(".image-picker-confirm",t).data("target",e),$(".image-picker-thumbnail.selected",t).removeClass("selected"),a&&$('.image-picker-thumbnail[data-filename="'+a+'"]',t).addClass("selected")})}),$(".image-picker").each(function(){var t=$(this),e=t.children("option");if(0<e.length){for(var a=$("<div>",{class:"image-picker-thumbnails"}),n=0;n<e.length;n++)$("<div>",{class:"image-picker-thumbnail","data-uri":e[n].value,"data-filename":e[n].text}).css({"background-image":"url("+e[n].value+")"}).appendTo(a);t.before(a),$(".image-picker-empty-state").hide()}t.hide()}),$(".image-picker-confirm").on("click",function(){var t=$(this),e=t.data("target"),a=$(".image-picker-thumbnail.selected",t.parent()).attr("data-filename");"function"==typeof e?e(a):t.data("target").val(a)}),$(".image-picker-thumbnail").on("click",function(){var t=$(this);t.siblings().removeClass("selected"),t.addClass("selected"),t.parent().siblings(".image-input").val(t.attr("data-uri"))}),$(".image-picker-thumbnail").on("dblclick",function(){$(this).trigger("click"),$(".image-picker-confirm").trigger("click")}),$("[data-command=upload]").on("click",function(){$("#"+$(this).attr("data-upload-target")).trigger("click")}),$(".editor-textarea").each(function(){new Formwork.Editor($(this).attr("id"))}),$("input[type=range]").on("change input",function(){var t=$(this);t.next(".range-input-value").text(t.val())}),$(".array-input").each(function(){if($(".array-input-add",this).on("click",function(){var t=$(this).closest(".array-input-row"),e=t.clone(!0);e.find(".array-input-key, .array-input-value").val(""),t.after(e)}),$(".array-input-remove",this).on("click",function(){var t=$(this).closest(".array-input-row");0<t.siblings(".array-input-row").length?t.remove():(t.find(".array-input-key, .array-input-value").val(""),$(this).siblings(".array-input-key").trigger("keyup"))}),$(this).hasClass("array-input-associative")){var t=$(this).attr("data-name");$(".array-input-key",this).on("keyup",function(){$(this).siblings(".array-input-value").attr("name",t+"["+$(this).val()+"]")}),$(".array-input-value",this).on("keyup",function(){$(this).attr("name",t+"["+$(this).siblings(".array-input-key").val()+"]")})}Sortable.create(this,{handle:".sort-handle",forceFallback:!0})})}},Formwork.Modals={init:function(){$("[data-modal]").on("click",function(){var t=$(this),e=t.attr("data-modal"),a=t.attr("data-modal-action");a?Formwork.Modals.show(e,a):Formwork.Modals.show(e)}),$(".modal [data-dismiss]").on("click",function(){var t=$(this);if(t.is("[data-validate]")&&!Formwork.Modals.validate(t.attr("data-dismiss")))return;Formwork.Modals.hide(t.attr("data-dismiss"))}),$(".modal").on("click",function(t){t.target===this&&Formwork.Modals.hide()}),$(document).on("keyup",function(t){27===t.which&&Formwork.Modals.hide()})},show:function(t,e,a){var n=$("#"+t);n.length&&(n.addClass("show"),null!==e&&$("form",n).attr("action",e),$("[autofocus]",n).first().trigger("focus"),"function"==typeof a&&a(n),$(".tooltip").remove(),this.createBackdrop())},hide:function(t){(void 0===t?$(".modal"):$("#"+t)).removeClass("show"),this.removeBackdrop()},createBackdrop:function(){$(".modal-backdrop").length||$("<div>",{class:"modal-backdrop"}).appendTo("body")},removeBackdrop:function(){$(".modal-backdrop").remove()},validate:function(t){var e=!1,a=$("#"+t);return $("[required]",a).each(function(){var t=$(this);if(""===t.val())return t.addClass("input-invalid").trigger("focus"),$(".modal-error",a).show(),e=!1;e=!0}),e}},Formwork.Notification=function(t,e,a){var n=$("<div>",{class:"notification"}).text(t);if(0<$(".notification").length){var o=$(".notification:not(.fadeout)").last(),i=o.offset().top+o.outerHeight(!0)-$(window).scrollTop();n.css("top",i)}e&&n.addClass("notification-"+e),n.appendTo("body");var r=setTimeout(s,a);function s(){var e=!1,a=n.outerHeight(!0);$(".notification").each(function(){var t=$(this);t.is(n)?(e=!0,t.addClass("fadeout")):e&&t.css("top","-="+a)}),setTimeout(function(){n.remove()},400)}n.on("click",s),n.on("mouseenter",function(){clearTimeout(r)}),n.on("mouseleave",function(){r=setTimeout(s,1e3)})},Formwork.Pages={init:function(){$(".page-children-toggle").on("click",function(t){t.stopPropagation();var e=$(this);e.closest("li").children(".pages-list").toggle(),e.toggleClass("toggle-expanded toggle-collapsed")}),$(".page-details a").on("click",function(t){t.stopPropagation()}),$("[data-command=expand-all-pages]").on("click",function(){$(this).trigger("blur"),$(".pages-children").show(),$(".page-children-toggle",".pages-list").removeClass("toggle-collapsed").addClass("toggle-expanded")}),$("[data-command=collapse-all-pages]").on("click",function(){$(this).trigger("blur"),$(".pages-children").hide(),$(".page-children-toggle",".pages-list").removeClass("toggle-expanded").addClass("toggle-collapsed")}),$("[data-command=reorder-pages]").on("click",function(){$(this).trigger("blur").toggleClass("active"),$(".pages-list .sort-handle").toggle()}),$(".page-search").on("focus",function(){$(".pages-children").each(function(){var t=$(this);t.data("visible",t.is(":visible"))})}),$(".page-search").on("keyup",Formwork.Utils.debounce(function(){var t=$(this).val();if(0===t.length)$(".pages-children").each(function(){var t=$(this);t.toggle(t.data("visible"))}),$(".page-details").css("padding-left",""),$(".pages-item, .page-children-toggle").show();else{var n=new RegExp(Formwork.Utils.escapeRegExp(t),"i");$(".pages-children").show(),$(".page-children-toggle").hide(),$(".page-details").css("padding-left","0"),$(".page-title a").each(function(){var t=$(this),e=t.closest(".pages-item"),a=!!t.text().match(n);e.toggle(a)})}},100)),$(".page-details").on("click",function(){var t=$(".page-children-toggle",this).first();t.length&&t.trigger("click")}),$("#page-title","#newPageModal").on("keyup",function(){$("#page-slug","#newPageModal").val(Formwork.Utils.slug($(this).val()))}),$("#page-slug","#newPageModal, #slugModal").on("keyup",function(){var t=$(this);t.val(t.val().toLowerCase().replace(" ","-").replace(/[^a-z0-9-]/g,""))}).on("blur",function(){""===$(this).val()&&$("#page-title","#newPageModal").trigger("keyup")}),$("#page-parent","#newPageModal").on("change",function(){var t=$("option:selected",this),e=$("#page-template","#newPageModal"),a=t.attr("data-allowed-templates");a?(a=a.split(", "),e.data("previousValue",e.val()).val(a[0]).find("option").each(function(){var t=$(this);-1===a.indexOf(t.val())&&t.attr("disabled",!0)})):$("option[disabled]",e).length&&e.val(e.data("previousValue")).removeData("previousValue").find("option").removeAttr("disabled")}),$("[data-command=change-slug]").on("click",function(){Formwork.Modals.show("slugModal",null,function(t){var e=$("#slug").val();$("#page-slug",t).val(e).attr("placeholder",e).trigger("focus")})}),$("#page-slug","#slugModal").on("keydown",function(t){13===t.which&&$("[data-command=continue]","#slugModal").trigger("click")}),$("[data-command=generate-slug]","#slugModal").on("click",function(){var t=Formwork.Utils.slug($("#title").val());$("#page-slug","#slugModal").val(t).trigger("focus")}),$("[data-command=continue]","#slugModal").on("click",function(){var t=$("#page-slug").val().replace(/^-+|-+$/,"");if(0<t.length){var e=$(".page-route span").text();$("#page-slug, #slug").val(t),$(".page-route span").text(e.replace(/\/[a-z0-9-]+\/$/,"/"+t+"/"))}Formwork.Modals.hide("slugModal")}),$(".pages-list").each(function(){var t=$(this);if("false"!==t.attr("data-sortable-children")){var a=Sortable.create(this,{handle:".sort-handle",filter:"[data-sortable=false]",forceFallback:!0,onClone:function(t){$(t.item).closest(".pages-list").addClass("dragging"),$(".pages-children",t.item).hide(),$(".page-children-toggle").removeClass("toggle-expanded").addClass("toggle-collapsed").css("opacity","0.5")},onMove:function(t){if("false"===$(t.related).attr("data-sortable"))return!1;$(".pages-children",t.related).hide()},onEnd:function(e){if($(e.item).closest(".pages-list").removeClass("dragging"),$(".page-children-toggle").css("opacity",""),e.newIndex!==e.oldIndex){a.option("disabled",!0);var t={"csrf-token":$("meta[name=csrf-token]").attr("content"),parent:$(this.el).attr("data-parent"),from:e.oldIndex,to:e.newIndex};new Formwork.Request({method:"POST",url:Formwork.baseUri+"pages/reorder/",data:t},function(t){t.status&&Formwork.Notification(t.message,t.status,5e3),t.status&&"error"!==t.status||a.sort($(e.from).data("originalOrder")),a.option("disabled",!1),$(e.from).data("originalOrder",a.toArray())})}}});t.data("originalOrder",a.toArray())}}),$(document).on("keydown",function(t){if((t.ctrlKey||t.metaKey)&&70===t.which&&$(".page-search:not(:focus)").length)return $(".page-search").trigger("focus"),!1})}},Formwork.Request=function(t,a){var n=$.ajax(t);return"function"==typeof a&&n.always(function(){var t=n.responseJSON||{},e=t.code||n.status;400===parseInt(e)?location.reload():a(t,n)}),n},Formwork.Tooltip=function(t,s){var e,a,n={container:document.body,referenceElement:document.body,position:"top",offset:{x:0,y:0},delay:500},l=$(s.referenceElement);function o(){clearTimeout(a),void 0!==e&&e.fadeOut(100,function(){e.remove()})}return s=$.extend({},n,s),l.on("mouseout",o),l.is("button, .button")&&l.on("click",o),{show:function(){a=setTimeout(function(){(e=$('<div class="tooltip" role="tooltip">').appendTo(s.container)).text(t).css(function(t){var e=l.offset();if(0===e.top&&0===e.left){var a=l[0].getBoundingClientRect();e.top=a.top+window.pageYOffset,e.left=a.left+window.pageXOffset}var n=e.top,o=e.left,i=(l.outerWidth()-t.outerWidth())/2,r=(l.outerHeight()-t.outerHeight())/2;switch(s.position){case"top":return{top:Math.round(n-t.outerHeight()+s.offset.y),left:Math.round(o+i+s.offset.x)};case"right":return{top:Math.round(n+r+s.offset.y),left:Math.round(o+l.outerWidth()+s.offset.x)};case"bottom":return{top:Math.round(n+l.outerHeight()+s.offset.y),left:Math.round(o+i+s.offset.x)};case"left":return{top:Math.round(n+r+s.offset.y),left:Math.round(o-t.outerWidth()+s.offset.x)}}}(e)).fadeIn(200)},s.delay)},remove:o}},Formwork.Tooltips={init:function(){$("[title]").each(function(){var t=$(this);t.attr("data-tooltip",t.attr("title")).removeAttr("title")}),$("[data-tooltip]").on("mouseover",function(){var t=$(this);new Formwork.Tooltip(t.attr("data-tooltip"),{referenceElement:t,position:"bottom",offset:{x:0,y:4}}).show()}),$('[data-overflow-tooltip="true"]').on("mouseover",function(){var t=$(this);t.prop("offsetWidth")<t.prop("scrollWidth")&&new Formwork.Tooltip(t.text().trim(),{referenceElement:t,position:"bottom",offset:{x:0,y:4}}).show()})}},Formwork.Updates={init:function(){0<$("#updater-component").length&&(setTimeout(function(){var t={"csrf-token":$("meta[name=csrf-token]").attr("content")};new Formwork.Request({method:"POST",url:Formwork.baseUri+"updates/check/",data:t},function(t){$(".update-status").html(t.message),!1===t.data.uptodate?($(".spinner").addClass("spinner-info"),$(".new-version-name").text(t.data.release.name),$(".new-version").show()):($(".spinner").addClass("spinner-success"),$(".current-version").show())})},1e3),$("[data-command=install-updates]").on("click",function(){$(".new-version").hide(),$(".spinner").removeClass("spinner-info"),$(".update-status").text($(".update-status").attr("data-installing-text"));var t={"csrf-token":$("meta[name=csrf-token]").attr("content")};new Formwork.Request({method:"POST",url:Formwork.baseUri+"updates/update/",data:t},function(t){$(".update-status").text(t.data.status),new Formwork.Notification(t.message,t.status,5e3),"success"===t.status?($(".spinner").addClass("spinner-success"),$(".current-version-name").text($(".new-version-name").text()),$(".current-version").show()):$(".spinner").addClass("spinner-error")})}))}},Formwork.Utils={debounce:function(t,e,a){var n,o,i=null;return function(){n=this,o=arguments,i&&clearTimeout(i),a&&!i&&t.apply(n,o),i=setTimeout(function(){a||t.apply(n,o),i=null},e)}},download:function(t,e){var a=$("<form>").attr({action:t,method:"post"});a.append($("<input>").attr({type:"hidden",name:"csrf-token",value:e})),a.appendTo("body").trigger("submit").remove()},escapeRegExp:function(t){return t.replace(/[-[\]/{}()*+?.\\^$|]/g,"\\$&")},slug:function(t){var e={"\t":"","\r":"","!":"",'"':"","#":"",$:"","%":"","'":"-","(":"",")":"","*":"","+":"",",":"",".":"",":":"",";":"","<":"","=":"",">":"","?":"","@":"","[":"","]":"","^":"","`":"","{":"","|":"","}":"","¡":"","£":"","¤":"","¥":"","¦":"","§":"","«":"","°":"","»":"","‘":"","’":"","“":"","”":"","\n":"-"," ":"-","-":"-","–":"-","—":"-","/":"-","\\":"-",_:"-","~":"-","À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","Æ":"Ae","Ç":"C","Ð":"D","È":"E","É":"E","Ê":"E","Ë":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","Œ":"Oe","Š":"S","Þ":"Th","Ù":"U","Ú":"U","Û":"U","Ü":"U","Ý":"Y","à":"a","á":"a","â":"a","ã":"a","ä":"ae","å":"a","æ":"ae","¢":"c","ç":"c","ð":"d","è":"e","é":"e","ê":"e","ë":"e","ì":"i","í":"i","î":"i","ï":"i","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"oe","ø":"o","œ":"oe","š":"s","ß":"ss","þ":"th","ù":"u","ú":"u","û":"u","ü":"ue","ý":"y","ÿ":"y","Ÿ":"y"};for(var a in t=t.toLowerCase(),e)e.hasOwnProperty(a)&&(t=t.split(a).join(e[a]));return t.replace(/[^a-z0-9-]/g,"").replace(/^-+|-+$/g,"").replace(/-+/g,"-")},throttle:function(e,a){var n,o,i=null;return function t(){n=this,o=arguments,i||(e.apply(n,o),i=setTimeout(function(){t.apply(n,o),i=null},a))}},uriPrependBase:function(t,e){var a=/^\/+|\/+$/gm;t=t.replace(a,"").split("/"),e=e.replace(a,"").split("/");for(var n=0;n<e.length;n++)e[n]===t[0]&&e[n+1]!==t[0]&&(e=e.slice(0,n));return"/"+e.concat(t).join("/")+"/"}},function(f){f.fn.datePicker=function(u){var o,i,t=new Date,r={year:t.getFullYear(),month:t.getMonth(),day:t.getDate(),setDate:function(t){this.year=t.getFullYear(),this.month=t.getMonth(),this.day=t.getDate()},lastDay:function(){this.day=h.daysInMonth(this.month,this.year)},prevYear:function(){this.year--},nextYear:function(){this.year++},prevMonth:function(){this.month=h.mod(this.month-1,12),11===this.month&&this.prevYear(),this.day>h.daysInMonth(this.month,this.year)&&this.lastDay()},nextMonth:function(){this.month=h.mod(this.month+1,12),0===this.month&&this.nextYear(),this.day>h.daysInMonth(this.month,this.year)&&this.lastDay()},prevWeek:function(){this.day-=7,this.day<1&&(this.prevMonth(),this.day+=h.daysInMonth(this.month,this.year))},nextWeek:function(){this.day+=7,this.day>h.daysInMonth(this.month,this.year)&&(this.day-=h.daysInMonth(this.month,this.year),this.nextMonth())},prevDay:function(){this.day--,this.day<1&&(this.prevMonth(),this.lastDay())},nextDay:function(){this.day++,this.day>h.daysInMonth(this.month,this.year)&&(this.nextMonth(),this.day=1)}},h={_daysInMonth:[31,28,31,30,31,30,31,31,30,31,30,31],mod:function(t,e){return(t%e+e)%e},pad:function(t){return 1===t.toString().length?"0"+t:t},isValidDate:function(t){return t&&!isNaN(Date.parse(t))},isLeapYear:function(t){return t%4==0&&t%100!=0||t%400==0},daysInMonth:function(t,e){return 1===t&&this.isLeapYear(e)?29:this._daysInMonth[t]},formatDateTime:function(t){var e=u.format,a=t.getFullYear(),n=t.getMonth()+1,o=t.getDate(),i=t.getHours(),r=t.getMinutes(),s=t.getSeconds(),l=i<12;return-1<e.indexOf("a")&&(i=0<h.mod(i,12)?h.mod(i,12):12),e.replace("YYYY",a).replace("YY",a.toString().substr(-2)).replace("MM",h.pad(n)).replace("DD",h.pad(o)).replace("hh",h.pad(i)).replace("mm",h.pad(r)).replace("ss",h.pad(s)).replace("a",l?"AM":"PM")}};function s(){var t=new Date(r.year,r.month,r.day);e(r.year,r.month,r.day),o.val(h.formatDateTime(t)),o.data("date",t)}function e(t,e,a){var n=1,o=new Date(t,e,1).getDay(),i=h.daysInMonth(e,t),r=u.monthLabels[e],s=h.mod(o-u.weekStarts,7),l='<table class="calendar-table">';l+='<tr><th class="calendar-header" colspan="7">',l+=r+"&nbsp;"+t,l+="</th></tr>",l+="<tr>";for(var c=0;c<7;c++)l+='<td class="calendar-header-day">',l+=u.dayLabels[h.mod(c+u.weekStarts,7)],l+="</td>";for(l+="</tr><tr>",c=0;c<6;c++){for(var d=0;d<7;d++)n<=i&&(0<c||s<=d)?(l+=n===a?'<td class="calendar-day selected">':'<td class="calendar-day">',l+=n++):1===n?(l+='<td class="calendar-prev-month-day">',l+=h.daysInMonth(h.mod(e-1,12),t)-s+d+1):(l+='<td class="calendar-next-month-day">',l+=n++-i),l+="</td>";l+="</tr><tr>"}l+="</tr></table>",f(".calendar-table").replaceWith(l)}function a(){o&&i.is(":visible")&&(i.css({top:o.offset().top+o.outerHeight(),left:o.offset().left}),i.offset().left+i.outerWidth(!0)>f(window).width()&&i.css("left",f(window).width()-i.outerWidth(!0)),f(window).scrollTop()+f(window).height()<i.position().top+i.outerHeight(!0)&&f(window).scrollTop(i.position().top+i.outerHeight(!0)-f(window).height()))}u=f.extend({},f.fn.datePicker.defaults,u),this.each(function(){var n=f(this),t=n.val();n.prop("readonly",!0),n.prop("size",u.format.length),h.isValidDate(t)&&(t=new Date(t),n.data("date",t),n.val(h.formatDateTime(t))),n.on("change",function(){""===n.val()?n.data("date",""):n.val(h.formatDateTime(n.data("date")))}),n.on("keydown",function(t){var e=f(this).data("date");switch(r.setDate(h.isValidDate(e)?e:new Date),t.which){case 13:return f(".calendar-day.selected").trigger("click"),i.hide(),!1;case 8:return n.val(""),o.trigger("blur"),i.hide(),!1;case 27:return o.trigger("blur"),i.hide(),!1;case 37:t.ctrlKey||t.metaKey?t.shiftKey?r.prevYear():r.prevMonth():r.prevDay();break;case 38:r.prevWeek();break;case 39:t.ctrlKey||t.metaKey?t.shiftKey?r.nextYear():r.nextMonth():r.nextDay();break;case 40:r.nextWeek();break;case 48:if(t.ctrlKey||t.metaKey){var a=new Date;r.setDate(a)}break;default:return!0}return s(),!1})}),i=f('<div class="calendar"><div class="calendar-buttons"><button type="button" class="prevMonth"><i class="i-chevron-left"></i></button><button type="button" class="currentMonth">'+u.todayLabel+'</button><button type="button" class="nextMonth"><i class="i-chevron-right"></i></button></div><div class="calendar-separator"></div><table class="calendar-table"></table>').appendTo("body"),f(".currentMonth").on("click",function(){var t=new Date;r.setDate(t),s(),o.trigger("blur")}),f(".prevMonth").longclick(function(){r.prevMonth(),e(r.year,r.month)},750,500),f(".nextMonth").longclick(function(){r.nextMonth(),e(r.year,r.month)},750,500),f(".prevMonth, .currentMonth, .nextMonth").on("mousedown",function(){return!1}),i.on("mousedown",".calendar-day",!1),i.on("click",".calendar-day",function(){var t=new Date(r.year,r.month,parseInt(f(this).text()));o.data("date",t),o.val(h.formatDateTime(t)),o.trigger("blur")}),f(".date-input").on("blur",function(){i.hide()}),f(".date-input").on("focus",function(){o=f(this);var t=h.isValidDate(o.data("date"))?new Date(o.data("date")):new Date;r.setDate(t),e(r.year,r.month,r.day),i.show(),a()}),f(window).on("touchstart",function(){var t=f(event.target);t.is(".date-input")||t.parents(".calendar, .date-input").length||o.trigger("blur")}),f(window).on("resize",Formwork.Utils.throttle(a,100))},f.fn.datePicker.defaults={dayLabels:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],monthLabels:["January","February","March","April","May","June","July","August","September","October","November","December"],weekStarts:0,todayLabel:"Today",format:"YYYY-MM-DD"}}(jQuery),function(t){t.fn.longclick=function(e,a,n){var o;function i(){clearTimeout(o)}t(window).on("mouseup",i),t(this).on("mousedown",function(t){1!==t.which?i():(e(),o=window.setTimeout(function(){o=window.setInterval(e,n||250)},a||500))}).on("mouseout",i)}}(jQuery),function(y){y.fn.tagInput=function(){this.each(function(){var t,e,a,n={addKeyCodes:[32]},o=y(this),i=(t=o.is("[required]"),e=o.is("[disabled]"),a=y('<div class="tag-input"'+(e?" disabled":"")+'>\n<input class="tag-inner-input" id="'+o.attr("id")+'" type="text" size="" placeholder="'+o.attr("placeholder")+'"'+(e?" disabled":"")+'>\n<input class="tag-hidden-input" name="'+o.attr("name")+'" hidden readonly value="'+o.attr("value")+'"'+(t?" required":"")+(e?" disabled":"")+">\n</div>"),o.replaceWith(a),a),r=y(".tag-hidden-input",i),s=y(".tag-inner-input",i),l=function(){if(o.is("[data-options]")){var t=y.parseJSON(o.attr("data-options")),e=y('<div class="dropdown-list"></div>');for(var a in i.append(e),t)e.append('<div class="dropdown-item" data-value="'+a+'">'+t[a]+"</div>");return e}return null}(),c=[];function d(){r.val(s.data("tags").join(", ")),u()}function u(){var t=s.data("placeholder");0<t.length&&(0===s.data("tags").length?(s.attr("placeholder",t),s.prop("size",t.length)):(s.attr("placeholder",""),s.prop("size",1)))}function h(t){s.before('\n<span class="tag">'+t+'<i class="tag-remove"></i></span>')}function f(t){!function(t){return-1===s.data("tags").indexOf(t)&&(null===l||0<y('[data-value="'+t+'"]',l).length)}(t)?u():(s.data("tags").push(t),h(t),d()),s.val(""),null!==l&&g()}function p(t){var e=s.data("tags"),a=e.indexOf(t);-1<a&&(e.splice(a,1),s.data("tags",e),d()),null!==l&&g()}function g(){var e=s.data("tags");y(".dropdown-item",l).each(function(){var t=-1===e.indexOf(y(this).attr("data-value"));y(this).toggle(t)}),y(".dropdown-item",l).removeClass("selected"),l.toggle(0<y(".dropdown-item",l).filter(":visible").length)}function m(){var t=y(".dropdown-item",l).filter(".selected:visible");0<t.length&&s.val(t.attr("data-value"))}function v(){return y(".dropdown-item",l).filter(":visible")}function $(t){y(".dropdown-item",l).removeClass("selected"),0<t.length&&(t.addClass("selected"),function(t){var e=l.scrollTop(),a=l.position().top,n=l.outerHeight(),o=a+n,i=t.position().top,r=t.outerHeight(),s=i+r;0<o-s&&o-s<r?l.scrollTop(e+r):(n<s||s<a)&&l.scrollTop(e+i)}(t))}function w(){$(v().first())}function k(){var t=v().filter(".selected").prevAll(":visible").first();0<t.length?$(t):$(v().last())}r.val()&&(c=r.val().split(", "),y.each(c,function(t,e){e=e.trim(),h(c[t]=e)})),s.data("tags",c),i.on("mousedown",".tag-remove",!1).on("click",".tag-remove",function(){var t=y(this).parent();return p(t.text()),t.remove(),!1}),void 0!==s.attr("placeholder")?(s.data("placeholder",s.attr("placeholder")),u()):s.data("placeholder",""),i.on("mousedown",function(){return s.trigger("focus"),!1}),null!==l&&(s.on("focus",function(){l.is(":visible")||(g(),l.show())}).on("blur",function(){l.is(":visible")&&l.hide()}).on("keydown",function(t){switch(t.which){case 8:g();break;case 13:if(l.is(":visible"))return m(),!1;break;case 38:if(l.is(":visible"))return k(),!1;break;case 40:if(l.is(":visible"))return function(){var t=v().filter(".selected").nextAll(":visible").first();0<t.length?$(t):w()}(),!1;break;default:if(-1<n.addKeyCodes.indexOf(t.which))return m(),!1}}).on("keyup",Formwork.Utils.debounce(function(t){var e=s.val().trim();switch(t.which){case 27:l.hide();break;case 38:case 40:return!0;default:l.show(),function(n){l.show(),y(".dropdown-item",l).each(function(){var t=y(this),e=new RegExp(Formwork.Utils.escapeRegExp(n),"i"),a=!!y(this).text().match(e);t.is(":visible")&&t.toggle(a)}),l.toggle(0<y(".dropdown-item",l).filter(":visible").length)}(e),0<e.length&&w()}},100)),l.on("click",".dropdown-item",function(){f(y(this).attr("data-value"))})),s.on("focus",function(){i.addClass("focused")}).on("blur",function(){var t=s.val().trim();""!==t&&f(t),i.removeClass("focused")}).on("keydown",function(t){var e=s.val().trim();switch(t.which){case 8:return""===e?(p(s.prev().text()),s.prev().remove(),!1):(s.prop("size",Math.max(s.val().length,s.attr("placeholder").length,1)),!0);case 13:case 188:return""!==e&&f(e),!1;case 27:return s.val(""),u(),s.trigger("blur"),!1;default:if(""!==e&&-1<n.addKeyCodes.indexOf(t.which))return f(e),!1;0<e.length&&s.prop("size",s.val().length+2)}})})}}(jQuery);