"use strict";function_classCallCheck(e,o){if(!(einstanceofo))thrownewTypeError("Cannot call a class as a function")}functionsetInputSelection(e,o,t){if(e.focus(),void0!==e.selectionStart)e.selectionStart=o,e.selectionEnd=t;elseif(document.selection&&document.selection.createRange){e.select();varn=document.selection.createRange();n.collapse(!0),n.moveEnd("character",t),n.moveStart("character",o),n.select()}}functionmakeSafePath(e){varo=_.split(_.trim(e),"/");returno=_.map(o,function(e){return_.kebabCase(_.deburr(_.trim(e)))}),_.join(_.filter(o,function(e){return!_.isEmpty(e)}),"/")}var_createClass=function(){functione(e,o){for(vart=0;t<o.length;t++){varn=o[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"inn&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}returnfunction(o,t,n){returnt&&e(o.prototype,t),n&&e(o,n),o}}();jQuery(document).ready(function(e){varo=this;e("a").smoothScroll({speed:400,offset:-70});newSticky(".stickyscroll");e(window).bind("beforeunload",function(){e("#notifload").addClass("active")}),e(document).ajaxSend(function(){e("#notifload").addClass("active")}).ajaxComplete(function(){e("#notifload").removeClass("active")});vart=newAlerts;alertsData&&_.forEach(alertsData,function(e){t.push(e)});varn=io(window.location.origin);if(e("#search-input").length){e("#search-input").focus(),e(".searchresults").css("display","block");vari=newVue({el:"#header-container",data:{searchq:"",searchres:[],searchsuggest:[],searchload:0,searchactive:!1,searchmoveidx:0,searchmovekey:"",searchmovearr:[]},watch:{searchq:function(e,o){i.searchmoveidx=0,e.length>=3?(i.searchactive=!0,i.searchload++,n.emit("search",{terms:e},function(e){i.searchres=e.match,i.searchsuggest=e.suggest,i.searchmovearr=_.concat([],i.searchres,i.searchsuggest),i.searchload>0&&i.searchload--})):(i.searchactive=!1,i.searchres=[],i.searchsuggest=[],i.searchmovearr=[],i.searchload=0)},searchmoveidx:function(e,o){i.searchmovekey=e>0?i.searchmovearr[e-1]?"res."+i.searchmovearr[e-1].entryPath:"sug."+i.searchmovearr[e-1]:""}},methods:{useSuggestion:function(e){i.searchq=e},closeSearch:function(){i.searchq=""},moveSelectSearch:function(){if(!(i.searchmoveidx<1)){vare=i.searchmoveidx-1;i.searchmovearr[e]?window.location.assign("/"+i.searchmovearr[e].entryPath):i.searchq=i.searchmovearr[e]}},moveDownSearch:function(){i.searchmoveidx<i.searchmovearr.length&&i.searchmoveidx++},moveUpSearch:function(){i.searchmoveidx>0&&i.searchmoveidx--}}});e("main").on("click",i.closeSearch)}if(e("#page-type-view").length){vara="home"!==e("#page-type-view").data("entrypath")?e("#page-type-view").data("entrypath"):"",r=a+"/new-page";e(".btn-create-prompt").on("click",function(o){e("#txt-create-prompt").val(r),e("#modal-create-prompt").toggleClass("is-active"),setInputSelection(e("#txt-create-prompt").get(0),a.length+1,r.length),e("#txt-create-prompt").removeClass("is-danger").next().addClass("is-hidden")}),e("#txt-create-prompt").on("keypress",function(o){13===o.which&&e(".btn-create-go").trigger("click")}),e(".btn-create-go").on("click",function(o){vart=makeSafePath(e("#txt-create-prompt").val());_.isEmpty(t)?e("#txt-create-prompt").addClass("is-danger").next().removeClass("is-hidden"):(e("#txt-create-prompt").parent().addClass("is-loading"),window.location.assign("/create/"+t))}),""!==a&&e(".btn-move-prompt").removeClass("is-hidden");varl=_.lastIndexOf(a,"/")+1;e(".btn-move-prompt").on("click",function(o){e("#txt-move-prompt").val(a),e("#modal-move-prompt").toggleClass("is-active"),setInputSelection(e("#txt-move-prompt").get(0),l,a.length),e("#txt-move-prompt").removeClass("is-danger").next().addClass("is-hidden")}),e("#txt-move-prompt").on("keypress",function(o){13===o.which&&e(".btn-move-go").trigger("click")}),e(".btn-move-go").on("click",function(o){varn=makeSafePath(e("#txt-move-prompt").val());_.isEmpty(n)||n===a||"home"===n?e("#txt-move-prompt").addClass("is-danger").next().removeClass("is-hidden"):(e("#txt-move-prompt").parent().addClass("is-loading"),e.ajax(window.location.href,{data:{move:n},dataType:"json",method:"PUT"}).then(
t.pushError("Unable to fetch updated listing","Try again later")):_.delay(function(){I.waitChangeComplete(e,o)},1500)})})},attachContextMenus:function(){varo=_.map(I.folders,function(o){return{name:""!==o?o:"/ (root)",icon:"fa-folder",callback:function(o,t){varn=_.toString(e(t.$trigger).data("uid")),i=_.nth(I.folders,o);I.moveFile(n,i)}}});e.contextMenu("destroy",".editor-modal-file-choices > figure"),e.contextMenu({selector:".editor-modal-file-choices > figure",appendTo:".editor-modal-file-choices",position:function(o,t,n){e(o.$trigger).addClass("is-contextopen");vari=e(o.$trigger).position(),a={w:e(o.$trigger).width()/5,h:e(o.$trigger).height()/2};o.$menu.css({top:i.top+a.h,left:i.left+a.w})},events:{hide:function(o){e(o.$trigger).removeClass("is-contextopen")}},items:{rename:{name:"Rename",icon:"fa-edit",callback:function(e,o){I.renameFileId=_.toString(o.$trigger[0].dataset.uid),I.renameFile()}},move:{name:"Move to...",icon:"fa-folder-open-o",items:o},delete:{name:"Delete",icon:"fa-trash",callback:function(e,o){I.deleteFileId=_.toString(o.$trigger[0].dataset.uid),I.deleteFileWarn(!0)}}}})}}});e("#btn-editor-file-upload input").on("change",function(o){varn=I.files.length;e(o.currentTarget).simpleUpload("/uploads/file",{name:"binfile",data:{folder:I.currentFolder},limit:20,expect:"json",maxFileSize:0,init:function(e){I.uploadSucceeded=!1,I.isLoadingText="Preparing to upload...",I.isLoading=!0},progress:function(e){I.isLoadingText="Uploading..."+Math.round(e)+"%"},success:function(e){if(e.ok){varo=_.filter(e.results,["ok",!1]);o.length?(_.forEach(o,function(e){t.pushError("Upload error",e.msg)}),o.length<e.results.length&&(t.push({title:"Some uploads succeeded",message:"Files that are not mentionned in the errors above were uploaded successfully."}),I.uploadSucceeded=!0)):I.uploadSucceeded=!0}elset.pushError("Upload error",e.msg)},error:function(e){t.pushError("Upload error",e.message)},finish:function(){I.uploadSucceeded?I.waitChangeComplete(n,!0):I.isLoading=!1}})});vary={youtube:newRegExp(/(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/)|(?:(?:watch)?\?v(?:i)?=|&v(?:i)?=))([^#&?]*).*/,"i"),vimeo:newRegExp(/vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/(?:[^\/]*)\/videos\/|album\/(?:\d+)\/video\/|)(\d+)(?:$|\/|\?)/,"i"),dailymotion:newRegExp(/(?:dailymotion\.com(?:\/embed)?(?:\/video|\/hub)|dai\.ly)\/([0-9a-z]+)(?:[-_0-9a-zA-Z]+(?:#video=)?([a-z0-9]+)?)?/,"i")},L=newVue({el:"#modal-editor-video",data:{link:""},methods:{open:function(o){e("#modal-editor-video").addClass("is-active"),e("#modal-editor-video input").focus()},cancel:function(o){k=!1,e("#modal-editor-video").removeClass("is-active"),L.link=""},insertVideo:function(e){F.codemirror.doc.somethingSelected()&&F.codemirror.execCommand("singleSelection");varo=_.findKey(y,function(e){returne.test(L.link)});_.isNil(o)&&(o="video");vart="[video]("+L.link+"){."+o+"}\n";F.codemirror.doc.replaceSelection(t),L.cancel()}}}),b=ace.require("ace/ext/modelist"),E=null,T=[],U=function(o){returne.ajax({url:"/js/ace/mode-"+o+".js",dataType:"script",cache:!0,beforeSend:function(){if(_.includes(T,o))return!1},success:function(){T.push(o)}})},N=newVue({el:"#modal-editor-codeblock",data:{modes:b.modesByName,modeSelected:"text",initContent:""},watch:{modeSelected:function(e,o){U(e).done(function(){ace.require("ace/mode/"+e),E.getSession().setMode("ace/mode/"+e)})}},methods:{open:function(o){e("#modal-editor-codeblock").addClass("is-active"),_.delay(function(){E=ace.edit("codeblock-editor"),E.setTheme("ace/theme/tomorrow_night"),E.getSession().setMode("ace/mode/"+N.modeSelected),E.setOption("fontSize","14px"),E.setOption("hScrollBarAlwaysVisible",!1),E.setOption("wrap",!0),E.setValue(N.initContent),E.focus(),E.renderer.updateFull()},300)},cancel:function(o){k=!1,e("#modal-editor-codeblock").removeClass("is-active"),N.initContent=""},insertCode:function(e){F.codemirror.doc.somethingSelected()&&F.codemirror.execCommand("singleSelection");varo="\n```"+N.modeSelected+"\n"+E.getValue()+"\n```\n";F.codemirror.doc.replaceSelection(o),N.cancel()}}}),F=newSimpleMDE({autofocus:!0,auto