From f2450b2be533fb0cf7b8da02f5eac73b0b1ca5ee Mon Sep 17 00:00:00 2001 From: Ro Date: Wed, 25 Aug 2021 16:12:35 -0700 Subject: [PATCH 1/4] fixed incorrect input type (#52), cleaned up site restore process (#53) --- brain/utility/Setup.inc.php | 34 +++++++++++++++++++------------ brain/views/dash/init.twig | 2 +- public/assets/scripts/dash.min.js | 11 +--------- src/com/Base.js | 2 +- 4 files changed, 24 insertions(+), 25 deletions(-) diff --git a/brain/utility/Setup.inc.php b/brain/utility/Setup.inc.php index 4018863..5f09f47 100644 --- a/brain/utility/Setup.inc.php +++ b/brain/utility/Setup.inc.php @@ -101,6 +101,7 @@ class SetUp $backup = $request->getUploadedFiles(); $file = $backup["backup-upload"]; + $size = $file->getSize(); $name = $file->getClientFileName(); //park it so it can be read @@ -128,11 +129,11 @@ class SetUp //move to appropriate spots /* - rename( - "../content/settings/settings.json", - "../config/settings.json" - ); - */ + rename( + "../content/settings/settings.json", + "../config/settings.json" + ); + */ //load up old config file $newConfig = json_decode( @@ -151,15 +152,22 @@ class SetUp rename("../content/settings/tags.json", "../config/tags.json"); - rename( - "../content/public/assets/images/blog", - "../public/assets/images/blog" - ); + //images path for blog and user + $blogImagePath = "../public/assets/images/blog"; + $userImagePath = "../public/assets/images/user"; - rename( - "../content/public/assets/images/user", - "../public/assets/images/user" - ); + //check to see if image dirs are empty, if not chill + if ($globs = glob($blogImagePath . "/*")) { + //directory not empty, relax + } else { + rename("../content/public/assets/images/blog", $blogImagePath); + } + + if ($globs = glob($userImagePath . "/*")) { + //directory not empty, relax + } else { + rename("../content/public/assets/images/user", $userImagePath); + } rename("../content/content/pages/", "../content/pages"); diff --git a/brain/views/dash/init.twig b/brain/views/dash/init.twig index 93c42c3..3187c54 100644 --- a/brain/views/dash/init.twig +++ b/brain/views/dash/init.twig @@ -28,7 +28,7 @@
- +
diff --git a/public/assets/scripts/dash.min.js b/public/assets/scripts/dash.min.js index 5042fec..e375eec 100644 --- a/public/assets/scripts/dash.min.js +++ b/public/assets/scripts/dash.min.js @@ -1,11 +1,2 @@ -!function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:null;e(this,t),this.percentComplete=0,this.baseURL=null,this.status=!1,r&&(this.baseURL=r),this._request(this.baseURL?this.baseURL+c:c).then((function(e){e.type===I&&(n.token=e.token)}))}return n(t,[{key:"login",value:function(e){var t=this;return new Promise((function(n,r){t.baseURL?e.remote=!0:e.remote=!1,t.key?e.key=t.key:e.key=null,t._request(t.baseURL?t.baseURL+h:h,"getAuthStatus",s,l,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"sync",value:function(e,t){var n=this;return new Promise((function(r,o){var i="";switch(e){case"syncSite":i="/api/v1/settings/sync";break;case"syncNav":i="/api/v1/settings/nav-sync"}n._request(n.baseURL?n.baseURL+i:i,p,s,l,t).then((function(e){r(e)})).catch((function(e){o(e)}))}))}},{key:"publish",value:function(e){var t=this;return new Promise((function(n,r){t._request(t.baseURL?t.baseURL+d:d,g,s,l,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"pageActions",value:function(e,t){var n,r,o,i=this;switch(e){case m:n="/api/v1/page/create",r=m,o=u;break;case v:n="/api/v1/page/write",r=v,o=u;break;case y:n="/api/v1/page/delete",r=y,o=l}return this.baseURL?t.remote=!0:t.remote=!1,new Promise((function(e,a){i._request(i.baseURL?i.baseURL+n:n,r,s,o,t).then((function(t){e(t)})).catch((function(e){a(e)}))}))}},{key:"sendMail",value:function(e){var t=this;return new Promise((function(n,r){t._request(t.baseURL?t.baseURL+f:f,"sendMail",s,l,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"getInfo",value:function(e){var t,n,r=this;return"site"==e?(t="/api/v1/settings/site",n=w):(t="/api/v1/settings/member",n=E),new Promise((function(e,o){r._request(r.baseURL?r.baseURL+t:t,n).then((function(t){e(t)})).catch((function(e){o(e)}))}))}},{key:"_request",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"GET",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:l,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,i=this;return new Promise((function(a,c){var d=new XMLHttpRequest;if(d.upload.onprogress=i.handleLoadProgress,d.open(n,e,!0),d.onload=function(){if(200==d.status){var e=JSON.parse(d.response);a(e)}else{var t=JSON.parse(d.response);c(t)}},"PUT"==n||n==s)switch(t!==p&&t!==v&&t!==m&&t!==y&&t!==g&&t!==b||d.setRequestHeader("fipamo-access-token",i.token),r){case l:d.setRequestHeader("Content-type","application/"+r),d.send(JSON.stringify(o));break;case u:d.send(o)}else t!==w&&t!==E||d.setRequestHeader("fipamo-access-token",i.token),d.send()}))}},{key:"handleLoadProgress",value:function(e){this.percentComplete=Math.ceil(e.loaded/e.total*100)}}]),t}(),S="POST",T="json",D="x-www-form-urlencoded",x="/api/v1/status",P="apiUseAuthorized",_=function(){function t(){var n=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;e(this,t),this.percentComplete=0,this.token=null,this.baseURL=null,this.key=null,o&&(this.key=o),r&&(this.baseURL=r),this._request(this.baseURL?this.baseURL+x+"?key="+this.key:x+"?key="+this.key).then((function(e){e.type===P&&(n.token=e.token)}))}return n(t,[{key:"create",value:function(e){var t=this;return new Promise((function(n,r){t._request("/api/v1/init","blogInit",S,T,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"restore",value:function(e){var t=this;return new Promise((function(n,r){var o;o=new FormData(e),t._request("/api/v1/restore","restoreBackup","POST","x-www-form-urlencoded",o).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"backup",value:function(){var e=this;return new Promise((function(t,n){var r;r={task:"create_backup"},e._request("/api/v1/backup","createBackup","POST","json",r).then((function(e){t(e)})).catch((function(e){n(e)}))}))}},{key:"secret",value:function(e){var t=this;return new Promise((function(n,r){t._request("/api/v1/get-secret","retrieveSecret",S,T,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"newPass",value:function(e){var t=this;return new Promise((function(n,r){t._request("/api/v1/reset-password","resetPassword",S,T,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"imageUpload",value:function(e,t){var n=this;return new Promise((function(r,o){var i="";switch(e){case"avatar-upload":i="/api/v1/settings/add-avatar";break;case"background-upload":i="/api/v1/settings/add-feature-background";break;default:i="/api/v1/page/add-entry-image"}var a=new FormData;n.baseURL?(a.append("key",n.key),a.append("remote",!0)):a.append("remote",!1);for(var s=0;s2&&void 0!==arguments[2]?arguments[2]:"GET",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:T,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,i=this;return new Promise((function(t,a){var s=new XMLHttpRequest;if(s.upload.onprogress=i.handleLoadProgress,s.open(n,e,!0),s.onload=function(){if(200==s.status){var e=JSON.parse(s.response);t(e)}else{var n=JSON.parse(s.response);a(n)}},"PUT"==n||n==S)switch(r){case T:s.setRequestHeader("Content-type","application/"+r),s.send(JSON.stringify(o));break;case D:s.send(o)}else s.send()}))}},{key:"handleLoadProgress",value:function(e){this.percentComplete=Math.ceil(e.loaded/e.total*100)}}]),t}(),B=function(){function t(){e(this,t)}return n(t,[{key:"imgLoad",value:function(e){return new Promise((function(t,n){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){200===r.status?t(r.response):n(new Error("Image didn't load successfully; error code:"+r.statusText))},r.onerror=function(){n(new Error("There was a network error."))},r.send()}))}},{key:"loadImage",value:function(e){var t=this;return new Promise((function(n,r){(new Image).crossOrigin="",t.imgLoad(e).then((function(e){var t=window.URL.createObjectURL(e);n(t)}),(function(e){r(e)}))}))}},{key:"formDataToJSON",value:function(e){var t={};return new FormData(e).forEach((function(e,n){t.hasOwnProperty(n)?(Array.isArray(t[n])||(t[n]=[t[n]]),t[n].push(e)):t[n]=e})),t}}]),t}(),A="requestLame",C="postUpdated";new function t(){e(this,t)};var L=function(){function t(){e(this,t)}return n(t,[{key:"cleanString",value:function(e){return e.replace(/(^\-+|[^a-zA-Z0-9\/_| -]+|\-+$)/g,"").toLowerCase().replace(/[\/_| -]+/g,"-")}},{key:"decodeHTML",value:function(e,t){var n=0,r=0,o=!1;void 0===t&&(t=2),e=e.toString().replace(/</g,"<").replace(/>/g,">");var i={ENT_NOQUOTES:0,ENT_HTML_QUOTE_SINGLE:1,ENT_HTML_QUOTE_DOUBLE:2,ENT_COMPAT:2,ENT_QUOTES:3,ENT_IGNORE:4};if(0===t&&(o=!0),"number"!=typeof t){for(t=[].concat(t),r=0;r]*>/g,"\n"),r.append("id",document.getElementById("post-edit-index").getAttribute("data-index")),r.append("uuid",document.getElementById("post-edit-index").getAttribute("data-uuid")),r.append("layout",document.getElementById("post-edit-index").getAttribute("data-layout")),r.append("current_title",document.getElementById("post-edit-index").getAttribute("data-slug")),r.append("content",i),r.append("title",document.getElementById("post_title").value),r.append("created",document.getElementById("post-date").getAttribute("data-raw")),r.append("slug",(new L).cleanString(document.getElementById("post_title").value)),r.append("tags",document.getElementById("post_tags").value),r.append("menu",document.getElementById("option-menu-pin").getAttribute("data-active")),r.append("featured",document.getElementById("option-feature").getAttribute("data-active")),r.append("published",document.getElementById("option-published").getAttribute("data-active")),null!=e||null!=e)e.type.match("image.*")?r.append("feature_image",e,e.name):n("Not an image file");else if(document.getElementById("featured-image")){var a=document.getElementById("featured-image").src;null!=a||null!=a?r.append("feature_image",a):r.append("feature_image",null)}t(r)}))}}]),t}(),M="editorDelete",N="editorUploadImage",R="editorSave",U="editorUpdate";new function t(){e(this,t)};var H=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopStyle","borderRightStyle","borderBottomStyle","borderLeftStyle","borderTopWidth","boxSizing","fontFamily","fontSize","fontWeight","height","letterSpacing","lineHeight","marginBottom","marginLeft","marginRight","marginTop","outlineWidth","overflow","overflowX","overflowY","paddingBottom","paddingLeft","paddingRight","paddingTop","textAlign","textOverflow","textTransform","whiteSpace","wordBreak","wordWrap"],F=function(e,t){var n=document.createElement("div");return function(t){var r=function(){var t={position:"absolute",left:-9999,top:0,zIndex:-2e3};return"TEXTAREA"===e.tagName&&H.push("width"),H.forEach((function(n){t[n]=getComputedStyle(e)[n]})),t}();Object.keys(r).forEach((function(e){n.style[e]=r[e]})),n.innerHTML=t,e.parentNode.insertBefore(n,e.nextSibling)}(t),{rect:function(){var e=n.ownerDocument.getElementById("caret-position-marker"),t={left:e.offsetLeft,top:e.offsetTop,height:e.offsetHeight};return n.parentNode.removeChild(n),t}}};function X(e){return(X="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var q=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.customPos,n=e.iframe,r=e.noShadowCaret;return n?{iframe:n,window:n.contentWindow,document:n.contentDocument||n.contentWindow.document,noShadowCaret:r,customPos:t}:{window:window,document:document,noShadowCaret:r,customPos:t}},Y=function(e){return"object"===X(e)&&null!==e},j=function(e,t){var n=function(){return e.selectionStart},r=function(r){var o=function(e){return e.replace(/<|>|`|"|&/g,"?").replace(/\r\n|\r|\n/g,"
")};(t.customPos||0===t.customPos)&&(r=t.customPos);var i=void 0===r?n():r,a=e.value.slice(0,i),s=e.value.slice(i),l=''.concat(o(a),"");l+='|',l+=''.concat(o(s),"");var u=F(e,l).rect();return u.pos=n(),u};return{getPos:n,setPos:function(t){return e.setSelectionRange(t,t),e},getOffset:function(n){var o=function(e,t){var n=t&&t.window||window,r=t&&t.document||document,o=e.getBoundingClientRect(),i=r.documentElement,a=n.pageXOffset||i.scrollLeft,s=n.pageYOffset||i.scrollTop;return{top:o.top+s,left:o.left+a}}(e),i=r(n);return{top:o.top+i.top+t.document.body.scrollTop,left:o.left+i.left+t.document.body.scrollLeft,height:i.height}},getPosition:r}},W=function(e,t){return function(e){return!!(e.contentEditable?"true"===e.contentEditable:"true"===e.getAttribute("contenteditable"))}(e)?function(e,t){var n=function(){var n=r(),o={height:0,left:0,right:0};if(!n)return o;var i=t.customPos||0===t.customPos;if(n.endOffset-1>0&&n.endContainer!==e||i){var a=n.cloneRange(),s=i?t.customPos:n.endOffset;a.setStart(n.endContainer,s-1<0?0:s-1),a.setEnd(n.endContainer,s);var l=a.getBoundingClientRect();o={height:l.height,left:l.left+l.width,top:l.top},a.detach()}if((!o||o&&0===o.height)&&!t.noShadowCaret){var u=n.cloneRange(),c=t.document.createTextNode("|");u.insertNode(c),u.selectNode(c);var d=u.getBoundingClientRect();o={height:d.height,left:d.left,top:d.top},c.parentNode.removeChild(c),u.detach()}if(o){var f=t.document.documentElement;o.top+=t.window.pageYOffset-(f.clientTop||0),o.left+=t.window.pageXOffset-(f.clientLeft||0)}return o},r=function(){if(t.window.getSelection){var e=t.window.getSelection();return e.rangeCount>0?e.getRangeAt(0):null}},o=function(){var t=r(),n=t.cloneRange();n.selectNodeContents(e),n.setEnd(t.endContainer,t.endOffset);var o=n.toString().length;return n.detach(),o};return{getPos:o,setPos:function(n){var r=t.window.getSelection();if(r){var o=0,i=!1;!function e(a,s){for(var l=0;l=a){i=!0;var c=t.document.createRange();c.setStart(u,a-o),r.removeAllRanges(),r.addRange(c);break}o+=u.length}else e(n,u)}}(n,e)}return e},getPosition:function(){var r=n(),i=o(),a=e.getBoundingClientRect(),s=a.top+t.document.body.scrollTop,l=a.left+t.document.body.scrollLeft;return r.left-=l,r.top-=s,r.pos=i,r},getOffset:n,getRange:r}}(e,t):j(e,t)},z=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n;Y(t)&&(r=t,t=null);var o=q(r),i=W(e,o);return t||0===t?i.setPos(t):i.getPosition()},G=function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(i,t);var r=a(i);function i(t,n){var o;return e(this,i),(o=r.call(this)).textEditor=t,o.fixLimit=n,o.caretPos=null,o.url="",o.setInputs(),window.addEventListener("scroll",(function(){})),o.refresh(),o}return n(i,[{key:"setInputs",value:function(){for(var e=this,t=this,n=document.querySelectorAll(".editor-button"),r=0,o=n.length;r/g)>-1){var o=z(e.textEditor).pos;t.refresh(),z(e.textEditor,o)}}))}},{key:"refresh",value:function(){var e=this.textEditor.innerText;e=e.replace(new RegExp("\r?\n","g"),"
");var t=document.createElement("div");t.innerText=e,this.textEditor.innerHTML=t.innerText,this.textEditor.style.maxWidth="900px"}},{key:"notify",value:function(e,t){switch(e){case C:document.getElementById("submit-update").classList.add("icon-hide"),document.getElementById("submit-good").classList.remove("icon-hide"),document.getElementById("edit-update").classList.remove("submit-start"),document.getElementById("edit-update").classList.add("submit-cool"),setTimeout((function(){document.getElementById("submit-update").classList.remove("icon-hide"),document.getElementById("submit-good").classList.add("icon-hide"),document.getElementById("edit-update").classList.add("submit-start"),document.getElementById("edit-update").classList.remove("submit-cool")}),2e3);break;case"postAdded":break;case N:var n,r;z(this.textEditor,this.caretPos),(n=window.getSelection()).rangeCount&&((r=n.getRangeAt(0)).deleteContents(),r.insertNode(document.createTextNode("![image alt text]("+t+" 'image title')"))),this.refresh()}}},{key:"handleEditorOption",value:function(e){var t,n,r;if(e.preventDefault(),(t=window.getSelection()).rangeCount)switch(n=t.getRangeAt(0),r=t.getRangeAt(0).toString(),n.deleteContents(),e.target.id){case"edit-bold":n.insertNode(document.createTextNode("**"+r+"**"));break;case"edit-italic":n.insertNode(document.createTextNode("*"+r+"*"));break;case"edit-strikethrough":n.insertNode(document.createTextNode(""+r+""));break;case"edit-header1":n.insertNode(document.createTextNode("# "+r));break;case"edit-header2":n.insertNode(document.createTextNode("## "+r));break;case"edit-header3":n.insertNode(document.createTextNode("### "+r));break;case"edit-image":this.caretPos=z(this.textEditor).pos,this.emitEvent(N);break;case"submit-save":case"edit-save":this.emitEvent(R);break;case"submit-update":case"edit-update":this.emitEvent(U);break;case"edit-link":n.insertNode(document.createTextNode("["+r+"](PASTE URL HERE)"));break;case"edit-delete":this.emitEvent(M)}this.refresh()}}]),i}(function(){function t(){e(this,t),this.listeners=new Map}return n(t,[{key:"addListener",value:function(e,t){this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t)}},{key:"removeListener",value:function(e,t){var n,r=this.listeners.get(e);return!!(r&&r.length&&(n=r.reduce((function(e,n,r){return"function"==typeof n&&n===t?e=r:e}),-1))>-1)&&(r.splice(n,1),this.listeners.set(e,r),!0)}},{key:"emitEvent",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r-1}function ee(e,t){return e.apply(null,t)}var te={arr:function(e){return Array.isArray(e)},obj:function(e){return K(Object.prototype.toString.call(e),"Object")},pth:function(e){return te.obj(e)&&e.hasOwnProperty("totalLength")},svg:function(e){return e instanceof SVGElement},inp:function(e){return e instanceof HTMLInputElement},dom:function(e){return e.nodeType||te.svg(e)},str:function(e){return"string"==typeof e},fnc:function(e){return"function"==typeof e},und:function(e){return void 0===e},nil:function(e){return te.und(e)||null===e},hex:function(e){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)},rgb:function(e){return/^rgb/.test(e)},hsl:function(e){return/^hsl/.test(e)},col:function(e){return te.hex(e)||te.rgb(e)||te.hsl(e)},key:function(e){return!Q.hasOwnProperty(e)&&!V.hasOwnProperty(e)&&"targets"!==e&&"keyframes"!==e}};function ne(e){var t=/\(([^)]+)\)/.exec(e);return t?t[1].split(",").map((function(e){return parseFloat(e)})):[]}function re(e,t){var n=ne(e),r=Z(te.und(n[0])?1:n[0],.1,100),o=Z(te.und(n[1])?100:n[1],.1,100),i=Z(te.und(n[2])?10:n[2],.1,100),a=Z(te.und(n[3])?0:n[3],.1,100),s=Math.sqrt(o/r),l=i/(2*Math.sqrt(o*r)),u=l<1?s*Math.sqrt(1-l*l):0,c=l<1?(l*s-a)/u:-a+s;function d(e){var n=t?t*e/1e3:e;return n=l<1?Math.exp(-n*l*s)*(1*Math.cos(u*n)+c*Math.sin(u*n)):(1+c*n)*Math.exp(-n*s),0===e||1===e?e:1-n}return t?d:function(){var t=$.springs[e];if(t)return t;for(var n=1/6,r=0,o=0;;)if(1===d(r+=n)){if(++o>=16)break}else o=0;var i=r*n*1e3;return $.springs[e]=i,i}}function oe(e){return void 0===e&&(e=10),function(t){return Math.ceil(Z(t,1e-6,1)*e)*(1/e)}}var ie,ae,se=function(){var e=.1;function t(e,t){return 1-3*t+3*e}function n(e,t){return 3*t-6*e}function r(e){return 3*e}function o(e,o,i){return((t(o,i)*e+n(o,i))*e+r(o))*e}function i(e,o,i){return 3*t(o,i)*e*e+2*n(o,i)*e+r(o)}return function(t,n,r,a){if(0<=t&&t<=1&&0<=r&&r<=1){var s=new Float32Array(11);if(t!==n||r!==a)for(var l=0;l<11;++l)s[l]=o(l*e,t,r);return function(e){return t===n&&r===a||0===e||1===e?e:o(u(e),n,a)}}function u(n){for(var a=0,l=1;10!==l&&s[l]<=n;++l)a+=e;--l;var u=a+(n-s[l])/(s[l+1]-s[l])*e,c=i(u,t,r);return c>=.001?function(e,t,n,r){for(var a=0;a<4;++a){var s=i(t,n,r);if(0===s)return t;t-=(o(t,n,r)-e)/s}return t}(n,u,t,r):0===c?u:function(e,t,n,r,i){var a,s,l=0;do{(a=o(s=t+(n-t)/2,r,i)-e)>0?n=s:t=s}while(Math.abs(a)>1e-7&&++l<10);return s}(n,a,a+e,t,r)}}}(),le=(ie={linear:function(){return function(e){return e}}},ae={Sine:function(){return function(e){return 1-Math.cos(e*Math.PI/2)}},Circ:function(){return function(e){return 1-Math.sqrt(1-e*e)}},Back:function(){return function(e){return e*e*(3*e-2)}},Bounce:function(){return function(e){for(var t,n=4;e<((t=Math.pow(2,--n))-1)/11;);return 1/Math.pow(4,3-n)-7.5625*Math.pow((3*t-2)/22-e,2)}},Elastic:function(e,t){void 0===e&&(e=1),void 0===t&&(t=.5);var n=Z(e,1,10),r=Z(t,.1,2);return function(e){return 0===e||1===e?e:-n*Math.pow(2,10*(e-1))*Math.sin((e-1-r/(2*Math.PI)*Math.asin(1/n))*(2*Math.PI)/r)}}},["Quad","Cubic","Quart","Quint","Expo"].forEach((function(e,t){ae[e]=function(){return function(e){return Math.pow(e,t+2)}}})),Object.keys(ae).forEach((function(e){var t=ae[e];ie["easeIn"+e]=t,ie["easeOut"+e]=function(e,n){return function(r){return 1-t(e,n)(1-r)}},ie["easeInOut"+e]=function(e,n){return function(r){return r<.5?t(e,n)(2*r)/2:1-t(e,n)(-2*r+2)/2}},ie["easeOutIn"+e]=function(e,n){return function(r){return r<.5?(1-t(e,n)(1-2*r))/2:(t(e,n)(2*r-1)+1)/2}}})),ie);function ue(e,t){if(te.fnc(e))return e;var n=e.split("(")[0],r=le[n],o=ne(e);switch(n){case"spring":return re(e,t);case"cubicBezier":return ee(se,o);case"steps":return ee(oe,o);default:return ee(r,o)}}function ce(e){try{return document.querySelectorAll(e)}catch(e){return}}function de(e,t){for(var n=e.length,r=arguments.length>=2?t:void 0,o=[],i=0;i1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}if(0==a)t=n=r=s;else{var c=s<.5?s*(1+a):s+a-s*a,d=2*s-c;t=u(d,c,i+1/3),n=u(d,c,i),r=u(d,c,i-1/3)}return"rgba("+255*t+","+255*n+","+255*r+","+l+")"}(e):void 0;var t,n}function be(e){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(e);if(t)return t[1]}function we(e,t){return te.fnc(e)?e(t.target,t.id,t.total):e}function Ee(e,t){return e.getAttribute(t)}function Ie(e,t,n){if(pe([n,"deg","rad","turn"],be(t)))return t;var r=$.CSS[t+n];if(!te.und(r))return r;var o=document.createElement(e.tagName),i=e.parentNode&&e.parentNode!==document?e.parentNode:document.body;i.appendChild(o),o.style.position="absolute",o.style.width=100+n;var a=100/o.offsetWidth;i.removeChild(o);var s=a*parseFloat(t);return $.CSS[t+n]=s,s}function ke(e,t,n){if(t in e.style){var r=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),o=e.style[t]||getComputedStyle(e).getPropertyValue(r)||"0";return n?Ie(e,o,n):o}}function Se(e,t){return te.dom(e)&&!te.inp(e)&&(!te.nil(Ee(e,t))||te.svg(e)&&e[t])?"attribute":te.dom(e)&&pe(J,t)?"transform":te.dom(e)&&"transform"!==t&&ke(e,t)?"css":null!=e[t]?"object":void 0}function Te(e){if(te.dom(e)){for(var t,n=e.style.transform||"",r=/(\w+)\(([^)]*)\)/g,o=new Map;t=r.exec(n);)o.set(t[1],t[2]);return o}}function De(e,t,n,r){var o=K(t,"scale")?1:0+function(e){return K(e,"translate")||"perspective"===e?"px":K(e,"rotate")||K(e,"skew")?"deg":void 0}(t),i=Te(e).get(t)||o;return n&&(n.transforms.list.set(t,i),n.transforms.last=t),r?Ie(e,i,r):i}function xe(e,t,n,r){switch(Se(e,t)){case"transform":return De(e,t,r,n);case"css":return ke(e,t,n);case"attribute":return Ee(e,t);default:return e[t]||0}}function Pe(e,t){var n=/^(\*=|\+=|-=)/.exec(e);if(!n)return e;var r=be(e)||0,o=parseFloat(t),i=parseFloat(e.replace(n[0],""));switch(n[0][0]){case"+":return o+i+r;case"-":return o-i+r;case"*":return o*i+r}}function _e(e,t){if(te.col(e))return ye(e);if(/\s/g.test(e))return e;var n=be(e),r=n?e.substr(0,e.length-n.length):e;return t?r+t:r}function Be(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function Ae(e){for(var t,n=e.points,r=0,o=0;o0&&(r+=Be(t,i)),t=i}return r}function Ce(e){if(e.getTotalLength)return e.getTotalLength();switch(e.tagName.toLowerCase()){case"circle":return function(e){return 2*Math.PI*Ee(e,"r")}(e);case"rect":return function(e){return 2*Ee(e,"width")+2*Ee(e,"height")}(e);case"line":return function(e){return Be({x:Ee(e,"x1"),y:Ee(e,"y1")},{x:Ee(e,"x2"),y:Ee(e,"y2")})}(e);case"polyline":return Ae(e);case"polygon":return function(e){var t=e.points;return Ae(e)+Be(t.getItem(t.numberOfItems-1),t.getItem(0))}(e)}}function Le(e,t){var n=t||{},r=n.el||function(e){for(var t=e.parentNode;te.svg(t)&&te.svg(t.parentNode);)t=t.parentNode;return t}(e),o=r.getBoundingClientRect(),i=Ee(r,"viewBox"),a=o.width,s=o.height,l=n.viewBox||(i?i.split(" "):[0,0,a,s]);return{el:r,viewBox:l,x:l[0]/1,y:l[1]/1,w:a,h:s,vW:l[2],vH:l[3]}}function Oe(e,t,n){function r(n){void 0===n&&(n=0);var r=t+n>=1?t+n:0;return e.el.getPointAtLength(r)}var o=Le(e.el,e.svg),i=r(),a=r(-1),s=r(1),l=n?1:o.w/o.vW,u=n?1:o.h/o.vH;switch(e.property){case"x":return(i.x-o.x)*l;case"y":return(i.y-o.y)*u;case"angle":return 180*Math.atan2(s.y-a.y,s.x-a.x)/Math.PI}}function Me(e,t){var n=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=_e(te.pth(e)?e.totalLength:e,t)+"";return{original:r,numbers:r.match(n)?r.match(n).map(Number):[0],strings:te.str(e)||t?r.split(n):[]}}function Ne(e){return de(e?fe(te.arr(e)?e.map(he):he(e)):[],(function(e,t,n){return n.indexOf(e)===t}))}function Re(e){var t=Ne(e);return t.map((function(e,n){return{target:e,id:n,total:t.length,transforms:{list:Te(e)}}}))}function Ue(e,t){var n=ge(t);if(/^spring/.test(n.easing)&&(n.duration=re(n.easing)),te.arr(e)){var r=e.length;2===r&&!te.obj(e[0])?e={value:e}:te.fnc(t.duration)||(n.duration=t.duration/r)}var o=te.arr(e)?e:[e];return o.map((function(e,n){var r=te.obj(e)&&!te.pth(e)?e:{value:e};return te.und(r.delay)&&(r.delay=n?0:t.delay),te.und(r.endDelay)&&(r.endDelay=n===o.length-1?t.endDelay:0),r})).map((function(e){return ve(e,n)}))}function He(e,t){var n=[],r=t.keyframes;for(var o in r&&(t=ve(function(e){for(var t=de(fe(e.map((function(e){return Object.keys(e)}))),(function(e){return te.key(e)})).reduce((function(e,t){return e.indexOf(t)<0&&e.push(t),e}),[]),n={},r=function(r){var o=t[r];n[o]=e.map((function(e){var t={};for(var n in e)te.key(n)?n==o&&(t.value=e[n]):t[n]=e[n];return t}))},o=0;o0?requestAnimationFrame(t):void 0}return"undefined"!=typeof document&&document.addEventListener("visibilitychange",(function(){Ve.suspendWhenDocumentHidden&&(Qe()?e=cancelAnimationFrame(e):(ze.forEach((function(e){return e._onDocumentVisibility()})),Ge()))})),function(){e||Qe()&&Ve.suspendWhenDocumentHidden||!(ze.length>0)||(e=requestAnimationFrame(t))}}();function Qe(){return!!document&&document.hidden}function Ve(e){void 0===e&&(e={});var t,n=0,r=0,o=0,i=0,a=null;function s(e){var t=window.Promise&&new Promise((function(e){return a=e}));return e.finished=t,t}var l=function(e){var t=me(Q,e),n=me(V,e),r=He(n,e),o=Re(e.targets),i=Ye(o,r),a=je(i,n),s=We;return We++,ve(t,{id:s,children:[],animatables:o,animations:i,duration:a.duration,delay:a.delay,endDelay:a.endDelay})}(e);function u(){var e=l.direction;"alternate"!==e&&(l.direction="normal"!==e?"normal":"reverse"),l.reversed=!l.reversed,t.forEach((function(e){return e.reversed=l.reversed}))}function c(e){return l.reversed?l.duration-e:e}function d(){n=0,r=c(l.currentTime)*(1/Ve.speed)}function f(e,t){t&&t.seek(e-t.timelineOffset)}function h(e){for(var t=0,n=l.animations,r=n.length;t2||(y=Math.round(y*h)/h)),p.push(y)}var E=f.length;if(E){m=f[0];for(var I=0;I0&&(l.began=!0,p("begin")),!l.loopBegan&&l.currentTime>0&&(l.loopBegan=!0,p("loopBegin")),v<=g&&0!==l.currentTime&&h(0),(v>=m&&l.currentTime!==d||!d)&&h(d),v>g&&v=d&&(r=0,l.remaining&&!0!==l.remaining&&l.remaining--,l.remaining?(n=o,p("loopComplete"),l.loopBegan=!1,"alternate"===l.direction&&u()):(l.paused=!0,l.completed||(l.completed=!0,p("loopComplete"),p("complete"),!l.passThrough&&"Promise"in window&&(a(),s(l)))))}return s(l),l.reset=function(){var e=l.direction;l.passThrough=!1,l.currentTime=0,l.progress=0,l.paused=!0,l.began=!1,l.loopBegan=!1,l.changeBegan=!1,l.completed=!1,l.changeCompleted=!1,l.reversePlayback=!1,l.reversed="reverse"===e,l.remaining=l.loop,t=l.children;for(var n=i=t.length;n--;)l.children[n].reset();(l.reversed&&!0!==l.loop||"alternate"===e&&1===l.loop)&&l.remaining++,h(l.reversed?l.duration:0)},l._onDocumentVisibility=d,l.set=function(e,t){return qe(e,t),l},l.tick=function(e){o=e,n||(n=o),g((o+(r-n))*Ve.speed)},l.seek=function(e){g(c(e))},l.pause=function(){l.paused=!0,d()},l.play=function(){l.paused&&(l.completed&&l.reset(),l.paused=!1,ze.push(l),d(),Ge())},l.reverse=function(){u(),l.completed=!l.reversed,d()},l.restart=function(){l.reset(),l.play()},l.remove=function(e){$e(Ne(e),l)},l.reset(),l.autoplay&&l.play(),l}function Je(e,t){for(var n=t.length;n--;)pe(e,t[n].animatable.target)&&t.splice(n,1)}function $e(e,t){var n=t.animations,r=t.children;Je(e,n);for(var o=r.length;o--;){var i=r[o],a=i.animations;Je(e,a),a.length||i.children.length||r.splice(o,1)}n.length||r.length||t.pause()}Ve.version="3.2.1",Ve.speed=1,Ve.suspendWhenDocumentHidden=!0,Ve.running=ze,Ve.remove=function(e){for(var t=Ne(e),n=ze.length;n--;){$e(t,ze[n])}},Ve.get=xe,Ve.set=qe,Ve.convertPx=Ie,Ve.path=function(e,t){var n=te.str(e)?ce(e)[0]:e,r=t||100;return function(e){return{property:e,el:n,svg:Le(n),totalLength:Ce(n)*(r/100)}}},Ve.setDashoffset=function(e){var t=Ce(e);return e.setAttribute("stroke-dasharray",t),t},Ve.stagger=function(e,t){void 0===t&&(t={});var n=t.direction||"normal",r=t.easing?ue(t.easing):null,o=t.grid,i=t.axis,a=t.from||0,s="first"===a,l="center"===a,u="last"===a,c=te.arr(e),d=c?parseFloat(e[0]):parseFloat(e),f=c?parseFloat(e[1]):0,h=be(c?e[1]:e)||0,p=t.start||0+(c?d:0),g=[],m=0;return function(e,t,v){if(s&&(a=0),l&&(a=(v-1)/2),u&&(a=v-1),!g.length){for(var y=0;y-1&&ze.splice(o,1);for(var s=0;s'].join(""),document.getElementById("featured-image-drop").innerHTML="",document.getElementById("featured-image-drop").appendChild(n)}}(n),o.readAsDataURL(n)}}}},{key:"handleImageUpload",value:function(e,t){var n=this;it.alert("Uploading Image",null),(new _).imageUpload(e,t).then((function(e){"postImageAdded"==e.type&&n.editor.notify(N,e.url),it.alert("Image Added to Entry",!0)})).catch((function(){it.alert("Uh oh. Image not added",!1)}))}}]),t}();at.uploadFiles=[];var st=function(){function t(n){e(this,t),this.currentPage=null,this.choosePage(n),this.start()}return n(t,[{key:"start",value:function(){}},{key:"choosePage",value:function(e){switch(this.currentPage="",e){case"edit":case"add":this.currentPage=new at}}}]),t}(),lt=function(){function t(){e(this,t)}return n(t,[{key:"getInfo",value:function(){var e,t,n=document.getElementById("settings-handle").value,r=document.getElementById("settings-email").value,o=document.getElementById("settings-url").value,i=document.getElementById("settings-title").value,a=document.getElementById("settings-desc").value,s=document.getElementById("background").src,l="",u=document.querySelectorAll(".theme-select"),c=document.getElementById("smtp-domain").value,d=document.getElementById("smtp-email").value,f=document.getElementById("smtp-pass").value,h=document.getElementById("mg-domain").value,p=document.getElementById("mg-key").value,g="",m=document.querySelectorAll(".mail-option"),v=document.getElementById("api-access-toggle").getAttribute("data-enabled");for(e=0,t=u.length;e - * @author owenm - * @license MIT - */ -function pt(e){return(pt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function gt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function mt(){return(mt=Object.assign||function(e){for(var t=1;t=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function bt(e){if("undefined"!=typeof window&&window.navigator)return!!navigator.userAgent.match(e)}var wt=bt(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Et=bt(/Edge/i),It=bt(/firefox/i),kt=bt(/safari/i)&&!bt(/chrome/i)&&!bt(/android/i),St=bt(/iP(ad|od|hone)/i),Tt=bt(/chrome/i)&&bt(/android/i),Dt={capture:!1,passive:!1};function xt(e,t,n){e.addEventListener(t,n,!wt&&Dt)}function Pt(e,t,n){e.removeEventListener(t,n,!wt&&Dt)}function _t(e,t){if(t){if(">"===t[0]&&(t=t.substring(1)),e)try{if(e.matches)return e.matches(t);if(e.msMatchesSelector)return e.msMatchesSelector(t);if(e.webkitMatchesSelector)return e.webkitMatchesSelector(t)}catch(e){return!1}return!1}}function Bt(e){return e.host&&e!==document&&e.host.nodeType?e.host:e.parentNode}function At(e,t,n,r){if(e){n=n||document;do{if(null!=t&&(">"===t[0]?e.parentNode===n&&_t(e,t):_t(e,t))||r&&e===n)return e;if(e===n)break}while(e=Bt(e))}return null}var Ct,Lt=/\s+/g;function Ot(e,t,n){if(e&&t)if(e.classList)e.classList[n?"add":"remove"](t);else{var r=(" "+e.className+" ").replace(Lt," ").replace(" "+t+" "," ");e.className=(r+(n?" "+t:"")).replace(Lt," ")}}function Mt(e,t,n){var r=e&&e.style;if(r){if(void 0===n)return document.defaultView&&document.defaultView.getComputedStyle?n=document.defaultView.getComputedStyle(e,""):e.currentStyle&&(n=e.currentStyle),void 0===t?n:n[t];t in r||-1!==t.indexOf("webkit")||(t="-webkit-"+t),r[t]=n+("string"==typeof n?"":"px")}}function Nt(e,t){var n="";if("string"==typeof e)n=e;else do{var r=Mt(e,"transform");r&&"none"!==r&&(n=r+" "+n)}while(!t&&(e=e.parentNode));var o=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return o&&new o(n)}function Rt(e,t,n){if(e){var r=e.getElementsByTagName(t),o=0,i=r.length;if(n)for(;o=i:o<=i))return r;if(r===Ut())break;r=Wt(r,!1)}return!1}function Xt(e,t,n){for(var r=0,o=0,i=e.children;o2&&void 0!==arguments[2]?arguments[2]:{},r=n.evt,o=yt(n,["evt"]);en.pluginEvent.bind(Qn)(e,t,vt({dragEl:rn,parentEl:on,ghostEl:an,rootEl:sn,nextEl:ln,lastDownEl:un,cloneEl:cn,cloneHidden:dn,dragStarted:Sn,putSortable:vn,activeSortable:Qn.active,originalEvent:r,oldIndex:fn,oldDraggableIndex:pn,newIndex:hn,newDraggableIndex:gn,hideGhostForTarget:jn,unhideGhostForTarget:Wn,cloneNowHidden:function(){dn=!0},cloneNowShown:function(){dn=!1},dispatchSortableEvent:function(e){nn({sortable:t,name:e,originalEvent:r})}},o))};function nn(e){!function(e){var t=e.sortable,n=e.rootEl,r=e.name,o=e.targetEl,i=e.cloneEl,a=e.toEl,s=e.fromEl,l=e.oldIndex,u=e.newIndex,c=e.oldDraggableIndex,d=e.newDraggableIndex,f=e.originalEvent,h=e.putSortable,p=e.extraEventProperties;if(t=t||n&&n[Jt]){var g,m=t.options,v="on"+r.charAt(0).toUpperCase()+r.substr(1);!window.CustomEvent||wt||Et?(g=document.createEvent("Event")).initEvent(r,!0,!0):g=new CustomEvent(r,{bubbles:!0,cancelable:!0}),g.to=a||n,g.from=s||n,g.item=o||n,g.clone=i,g.oldIndex=l,g.newIndex=u,g.oldDraggableIndex=c,g.newDraggableIndex=d,g.originalEvent=f,g.pullMode=h?h.lastPutMode:void 0;var y=vt({},p,en.getEventProperties(r,t));for(var b in y)g[b]=y[b];n&&n.dispatchEvent(g),m[v]&&m[v].call(t,g)}}(vt({putSortable:vn,cloneEl:cn,targetEl:rn,rootEl:sn,oldIndex:fn,oldDraggableIndex:pn,newIndex:hn,newDraggableIndex:gn},e))}var rn,on,an,sn,ln,un,cn,dn,fn,hn,pn,gn,mn,vn,yn,bn,wn,En,In,kn,Sn,Tn,Dn,xn,Pn,_n=!1,Bn=!1,An=[],Cn=!1,Ln=!1,On=[],Mn=!1,Nn=[],Rn="undefined"!=typeof document,Un=St,Hn=Et||wt?"cssFloat":"float",Fn=Rn&&!Tt&&!St&&"draggable"in document.createElement("div"),Xn=function(){if(Rn){if(wt)return!1;var e=document.createElement("x");return e.style.cssText="pointer-events:auto","auto"===e.style.pointerEvents}}(),qn=function(e,t){var n=Mt(e),r=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),o=Xt(e,0,t),i=Xt(e,1,t),a=o&&Mt(o),s=i&&Mt(i),l=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+Ht(o).width,u=s&&parseInt(s.marginLeft)+parseInt(s.marginRight)+Ht(i).width;if("flex"===n.display)return"column"===n.flexDirection||"column-reverse"===n.flexDirection?"vertical":"horizontal";if("grid"===n.display)return n.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(o&&a.float&&"none"!==a.float){var c="left"===a.float?"left":"right";return!i||"both"!==s.clear&&s.clear!==c?"horizontal":"vertical"}return o&&("block"===a.display||"flex"===a.display||"table"===a.display||"grid"===a.display||l>=r&&"none"===n[Hn]||i&&"none"===n[Hn]&&l+u>r)?"vertical":"horizontal"},Yn=function(e){function t(e,n){return function(r,o,i,a){var s=r.options.group.name&&o.options.group.name&&r.options.group.name===o.options.group.name;if(null==e&&(n||s))return!0;if(null==e||!1===e)return!1;if(n&&"clone"===e)return e;if("function"==typeof e)return t(e(r,o,i,a),n)(r,o,i,a);var l=(n?r:o).options.group.name;return!0===e||"string"==typeof e&&e===l||e.join&&e.indexOf(l)>-1}}var n={},r=e.group;r&&"object"==pt(r)||(r={name:r}),n.name=r.name,n.checkPull=t(r.pull,!0),n.checkPut=t(r.put),n.revertClone=r.revertClone,e.group=n},jn=function(){!Xn&&an&&Mt(an,"display","none")},Wn=function(){!Xn&&an&&Mt(an,"display","")};Rn&&document.addEventListener("click",(function(e){if(Bn)return e.preventDefault(),e.stopPropagation&&e.stopPropagation(),e.stopImmediatePropagation&&e.stopImmediatePropagation(),Bn=!1,!1}),!0);var zn=function(e){if(rn){e=e.touches?e.touches[0]:e;var t=(o=e.clientX,i=e.clientY,An.some((function(e){if(!qt(e)){var t=Ht(e),n=e[Jt].options.emptyInsertThreshold,r=o>=t.left-n&&o<=t.right+n,s=i>=t.top-n&&i<=t.bottom+n;return n&&r&&s?a=e:void 0}})),a);if(t){var n={};for(var r in e)e.hasOwnProperty(r)&&(n[r]=e[r]);n.target=n.rootEl=t,n.preventDefault=void 0,n.stopPropagation=void 0,t[Jt]._onDragOver(n)}}var o,i,a},Gn=function(e){rn&&rn.parentNode[Jt]._isOutsideThisEl(e.target)};function Qn(e,t){if(!e||!e.nodeType||1!==e.nodeType)throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(e));this.el=e,this.options=t=mt({},t),e[Jt]=this;var n={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(e.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return qn(e,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(e,t){e.setData("Text",t.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:!1!==Qn.supportPointer&&"PointerEvent"in window&&!kt,emptyInsertThreshold:5};for(var r in en.initializePlugins(this,e,n),n)!(r in t)&&(t[r]=n[r]);for(var o in Yn(t),this)"_"===o.charAt(0)&&"function"==typeof this[o]&&(this[o]=this[o].bind(this));this.nativeDraggable=!t.forceFallback&&Fn,this.nativeDraggable&&(this.options.touchStartThreshold=1),t.supportPointer?xt(e,"pointerdown",this._onTapStart):(xt(e,"mousedown",this._onTapStart),xt(e,"touchstart",this._onTapStart)),this.nativeDraggable&&(xt(e,"dragover",this),xt(e,"dragenter",this)),An.push(this.el),t.store&&t.store.get&&this.sort(t.store.get(this)||[]),mt(this,$t())}function Vn(e,t,n,r,o,i,a,s){var l,u,c=e[Jt],d=c.options.onMove;return!window.CustomEvent||wt||Et?(l=document.createEvent("Event")).initEvent("move",!0,!0):l=new CustomEvent("move",{bubbles:!0,cancelable:!0}),l.to=t,l.from=e,l.dragged=n,l.draggedRect=r,l.related=o||t,l.relatedRect=i||Ht(t),l.willInsertAfter=s,l.originalEvent=a,e.dispatchEvent(l),d&&(u=d.call(c,l,a)),u}function Jn(e){e.draggable=!1}function $n(){Mn=!1}function Zn(e){for(var t=e.tagName+e.className+e.src+e.href+e.textContent,n=t.length,r=0;n--;)r+=t.charCodeAt(n);return r.toString(36)}function Kn(e){return setTimeout(e,0)}function er(e){return clearTimeout(e)}Qn.prototype={constructor:Qn,_isOutsideThisEl:function(e){this.el.contains(e)||e===this.el||(Tn=null)},_getDirection:function(e,t){return"function"==typeof this.options.direction?this.options.direction.call(this,e,t,rn):this.options.direction},_onTapStart:function(e){if(e.cancelable){var t=this,n=this.el,r=this.options,o=r.preventOnFilter,i=e.type,a=e.touches&&e.touches[0]||e.pointerType&&"touch"===e.pointerType&&e,s=(a||e).target,l=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||s,u=r.filter;if(function(e){Nn.length=0;var t=e.getElementsByTagName("input"),n=t.length;for(;n--;){var r=t[n];r.checked&&Nn.push(r)}}(n),!rn&&!(/mousedown|pointerdown/.test(i)&&0!==e.button||r.disabled)&&!l.isContentEditable&&(this.nativeDraggable||!kt||!s||"SELECT"!==s.tagName.toUpperCase())&&!((s=At(s,r.draggable,n,!1))&&s.animated||un===s)){if(fn=Yt(s),pn=Yt(s,r.draggable),"function"==typeof u){if(u.call(this,e,s,this))return nn({sortable:t,rootEl:l,name:"filter",targetEl:s,toEl:n,fromEl:n}),tn("filter",t,{evt:e}),void(o&&e.cancelable&&e.preventDefault())}else if(u&&(u=u.split(",").some((function(r){if(r=At(l,r.trim(),n,!1))return nn({sortable:t,rootEl:r,name:"filter",targetEl:s,fromEl:n,toEl:n}),tn("filter",t,{evt:e}),!0}))))return void(o&&e.cancelable&&e.preventDefault());r.handle&&!At(l,r.handle,n,!1)||this._prepareDragStart(e,a,s)}}},_prepareDragStart:function(e,t,n){var r,o=this,i=o.el,a=o.options,s=i.ownerDocument;if(n&&!rn&&n.parentNode===i){var l=Ht(n);if(sn=i,on=(rn=n).parentNode,ln=rn.nextSibling,un=n,mn=a.group,Qn.dragged=rn,yn={target:rn,clientX:(t||e).clientX,clientY:(t||e).clientY},In=yn.clientX-l.left,kn=yn.clientY-l.top,this._lastX=(t||e).clientX,this._lastY=(t||e).clientY,rn.style["will-change"]="all",r=function(){tn("delayEnded",o,{evt:e}),Qn.eventCanceled?o._onDrop():(o._disableDelayedDragEvents(),!It&&o.nativeDraggable&&(rn.draggable=!0),o._triggerDragStart(e,t),nn({sortable:o,name:"choose",originalEvent:e}),Ot(rn,a.chosenClass,!0))},a.ignore.split(",").forEach((function(e){Rt(rn,e.trim(),Jn)})),xt(s,"dragover",zn),xt(s,"mousemove",zn),xt(s,"touchmove",zn),xt(s,"mouseup",o._onDrop),xt(s,"touchend",o._onDrop),xt(s,"touchcancel",o._onDrop),It&&this.nativeDraggable&&(this.options.touchStartThreshold=4,rn.draggable=!0),tn("delayStart",this,{evt:e}),!a.delay||a.delayOnTouchOnly&&!t||this.nativeDraggable&&(Et||wt))r();else{if(Qn.eventCanceled)return void this._onDrop();xt(s,"mouseup",o._disableDelayedDrag),xt(s,"touchend",o._disableDelayedDrag),xt(s,"touchcancel",o._disableDelayedDrag),xt(s,"mousemove",o._delayedDragTouchMoveHandler),xt(s,"touchmove",o._delayedDragTouchMoveHandler),a.supportPointer&&xt(s,"pointermove",o._delayedDragTouchMoveHandler),o._dragStartTimer=setTimeout(r,a.delay)}}},_delayedDragTouchMoveHandler:function(e){var t=e.touches?e.touches[0]:e;Math.max(Math.abs(t.clientX-this._lastX),Math.abs(t.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){rn&&Jn(rn),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;Pt(e,"mouseup",this._disableDelayedDrag),Pt(e,"touchend",this._disableDelayedDrag),Pt(e,"touchcancel",this._disableDelayedDrag),Pt(e,"mousemove",this._delayedDragTouchMoveHandler),Pt(e,"touchmove",this._delayedDragTouchMoveHandler),Pt(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,t){t=t||"touch"==e.pointerType&&e,!this.nativeDraggable||t?this.options.supportPointer?xt(document,"pointermove",this._onTouchMove):xt(document,t?"touchmove":"mousemove",this._onTouchMove):(xt(rn,"dragend",this),xt(sn,"dragstart",this._onDragStart));try{document.selection?Kn((function(){document.selection.empty()})):window.getSelection().removeAllRanges()}catch(e){}},_dragStarted:function(e,t){if(_n=!1,sn&&rn){tn("dragStarted",this,{evt:t}),this.nativeDraggable&&xt(document,"dragover",Gn);var n=this.options;!e&&Ot(rn,n.dragClass,!1),Ot(rn,n.ghostClass,!0),Qn.active=this,e&&this._appendGhost(),nn({sortable:this,name:"start",originalEvent:t})}else this._nulling()},_emulateDragOver:function(){if(bn){this._lastX=bn.clientX,this._lastY=bn.clientY,jn();for(var e=document.elementFromPoint(bn.clientX,bn.clientY),t=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(bn.clientX,bn.clientY))!==t;)t=e;if(rn.parentNode[Jt]._isOutsideThisEl(e),t)do{if(t[Jt]){if(t[Jt]._onDragOver({clientX:bn.clientX,clientY:bn.clientY,target:e,rootEl:t})&&!this.options.dragoverBubble)break}e=t}while(t=t.parentNode);Wn()}},_onTouchMove:function(e){if(yn){var t=this.options,n=t.fallbackTolerance,r=t.fallbackOffset,o=e.touches?e.touches[0]:e,i=an&&Nt(an,!0),a=an&&i&&i.a,s=an&&i&&i.d,l=Un&&Pn&&jt(Pn),u=(o.clientX-yn.clientX+r.x)/(a||1)+(l?l[0]-On[0]:0)/(a||1),c=(o.clientY-yn.clientY+r.y)/(s||1)+(l?l[1]-On[1]:0)/(s||1);if(!Qn.active&&!_n){if(n&&Math.max(Math.abs(o.clientX-this._lastX),Math.abs(o.clientY-this._lastY))r.right+o||e.clientX<=r.right&&e.clientY>r.bottom&&e.clientX>=r.left:e.clientX>r.right&&e.clientY>r.top||e.clientX<=r.right&&e.clientY>r.bottom+o}(e,o,this)&&!g.animated){if(g===rn)return B(!1);if(g&&i===e.target&&(a=g),a&&(n=Ht(a)),!1!==Vn(sn,i,rn,t,a,n,e,!!a))return _(),i.appendChild(rn),on=i,A(),B(!0)}else if(a.parentNode===i){n=Ht(a);var m,v,y,b=rn.parentNode!==i,w=!function(e,t,n){var r=n?e.left:e.top,o=n?e.right:e.bottom,i=n?e.width:e.height,a=n?t.left:t.top,s=n?t.right:t.bottom,l=n?t.width:t.height;return r===a||o===s||r+i/2===a+l/2}(rn.animated&&rn.toRect||t,a.animated&&a.toRect||n,o),E=o?"top":"left",I=Ft(a,"top","top")||Ft(rn,"top","top"),k=I?I.scrollTop:void 0;if(Tn!==a&&(v=n[E],Cn=!1,Ln=!w&&s.invertSwap||b),0!==(m=function(e,t,n,r,o,i,a,s){var l=r?e.clientY:e.clientX,u=r?n.height:n.width,c=r?n.top:n.left,d=r?n.bottom:n.right,f=!1;if(!a)if(s&&xnc+u*i/2:ld-xn)return-Dn}else if(l>c+u*(1-o)/2&&ld-u*i/2))return l>c+u/2?1:-1;return 0}(e,a,n,o,w?1:s.swapThreshold,null==s.invertedSwapThreshold?s.swapThreshold:s.invertedSwapThreshold,Ln,Tn===a))){var S=Yt(rn);do{S-=m,y=on.children[S]}while(y&&("none"===Mt(y,"display")||y===an))}if(0===m||y===a)return B(!1);Tn=a,Dn=m;var T=a.nextElementSibling,D=!1,x=Vn(sn,i,rn,t,a,n,e,D=1===m);if(!1!==x)return 1!==x&&-1!==x||(D=1===x),Mn=!0,setTimeout($n,30),_(),D&&!T?i.appendChild(rn):a.parentNode.insertBefore(rn,D?T:a),I&&Qt(I,0,k-I.scrollTop),on=rn.parentNode,void 0===v||Ln||(xn=Math.abs(v-Ht(a)[E])),A(),B(!0)}if(i.contains(rn))return B(!1)}return!1}function P(s,l){tn(s,h,vt({evt:e,isOwner:c,axis:o?"vertical":"horizontal",revert:r,dragRect:t,targetRect:n,canSort:d,fromSortable:f,target:a,completed:B,onMove:function(n,r){return Vn(sn,i,rn,t,n,Ht(n),e,r)},changed:A},l))}function _(){P("dragOverAnimationCapture"),h.captureAnimationState(),h!==f&&f.captureAnimationState()}function B(t){return P("dragOverCompleted",{insertion:t}),t&&(c?u._hideClone():u._showClone(h),h!==f&&(Ot(rn,vn?vn.options.ghostClass:u.options.ghostClass,!1),Ot(rn,s.ghostClass,!0)),vn!==h&&h!==Qn.active?vn=h:h===Qn.active&&vn&&(vn=null),f===h&&(h._ignoreWhileAnimating=a),h.animateAll((function(){P("dragOverAnimationComplete"),h._ignoreWhileAnimating=null})),h!==f&&(f.animateAll(),f._ignoreWhileAnimating=null)),(a===rn&&!rn.animated||a===i&&!a.animated)&&(Tn=null),s.dragoverBubble||e.rootEl||a===document||(rn.parentNode[Jt]._isOutsideThisEl(e.target),!t&&zn(e)),!s.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),p=!0}function A(){hn=Yt(rn),gn=Yt(rn,s.draggable),nn({sortable:h,name:"change",toEl:i,newIndex:hn,newDraggableIndex:gn,originalEvent:e})}},_ignoreWhileAnimating:null,_offMoveEvents:function(){Pt(document,"mousemove",this._onTouchMove),Pt(document,"touchmove",this._onTouchMove),Pt(document,"pointermove",this._onTouchMove),Pt(document,"dragover",zn),Pt(document,"mousemove",zn),Pt(document,"touchmove",zn)},_offUpEvents:function(){var e=this.el.ownerDocument;Pt(e,"mouseup",this._onDrop),Pt(e,"touchend",this._onDrop),Pt(e,"pointerup",this._onDrop),Pt(e,"touchcancel",this._onDrop),Pt(document,"selectstart",this)},_onDrop:function(e){var t=this.el,n=this.options;hn=Yt(rn),gn=Yt(rn,n.draggable),tn("drop",this,{evt:e}),on=rn&&rn.parentNode,hn=Yt(rn),gn=Yt(rn,n.draggable),Qn.eventCanceled||(_n=!1,Ln=!1,Cn=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),er(this.cloneId),er(this._dragStartId),this.nativeDraggable&&(Pt(document,"drop",this),Pt(t,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),kt&&Mt(document.body,"user-select",""),Mt(rn,"transform",""),e&&(Sn&&(e.cancelable&&e.preventDefault(),!n.dropBubble&&e.stopPropagation()),an&&an.parentNode&&an.parentNode.removeChild(an),(sn===on||vn&&"clone"!==vn.lastPutMode)&&cn&&cn.parentNode&&cn.parentNode.removeChild(cn),rn&&(this.nativeDraggable&&Pt(rn,"dragend",this),Jn(rn),rn.style["will-change"]="",Sn&&!_n&&Ot(rn,vn?vn.options.ghostClass:this.options.ghostClass,!1),Ot(rn,this.options.chosenClass,!1),nn({sortable:this,name:"unchoose",toEl:on,newIndex:null,newDraggableIndex:null,originalEvent:e}),sn!==on?(hn>=0&&(nn({rootEl:on,name:"add",toEl:on,fromEl:sn,originalEvent:e}),nn({sortable:this,name:"remove",toEl:on,originalEvent:e}),nn({rootEl:on,name:"sort",toEl:on,fromEl:sn,originalEvent:e}),nn({sortable:this,name:"sort",toEl:on,originalEvent:e})),vn&&vn.save()):hn!==fn&&hn>=0&&(nn({sortable:this,name:"update",toEl:on,originalEvent:e}),nn({sortable:this,name:"sort",toEl:on,originalEvent:e})),Qn.active&&(null!=hn&&-1!==hn||(hn=fn,gn=pn),nn({sortable:this,name:"end",toEl:on,originalEvent:e}),this.save())))),this._nulling()},_nulling:function(){tn("nulling",this),sn=rn=on=an=ln=cn=un=dn=yn=bn=Sn=hn=gn=fn=pn=Tn=Dn=vn=mn=Qn.dragged=Qn.ghost=Qn.clone=Qn.active=null,Nn.forEach((function(e){e.checked=!0})),Nn.length=wn=En=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":rn&&(this._onDragOver(e),function(e){e.dataTransfer&&(e.dataTransfer.dropEffect="move");e.cancelable&&e.preventDefault()}(e));break;case"selectstart":e.preventDefault()}},toArray:function(){for(var e,t=[],n=this.el.children,r=0,o=n.length,i=this.options;r { window.location = "/dashboard"; - }, 800); + }, 1500); } }) .catch((err) => { From fdc6cb2cf2681b83ffe92bb24afc610c82e9b454 Mon Sep 17 00:00:00 2001 From: Ro Date: Sun, 12 Sep 2021 14:40:27 -0700 Subject: [PATCH 2/4] added form token to session to validate form submission from frontend --- brain/controller/DashControl.inc.php | 1 + brain/data/Auth.inc.php | 3 +++ brain/data/Session.inc.php | 1 + brain/views/dash/page-edit.twig | 1 + public/assets/scripts/dash.min.js | 11 ++++++++++- 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/brain/controller/DashControl.inc.php b/brain/controller/DashControl.inc.php index d0f5bff..436b8e2 100644 --- a/brain/controller/DashControl.inc.php +++ b/brain/controller/DashControl.inc.php @@ -101,6 +101,7 @@ class DashControl "title" => "Fipamo | Edit Page", "page" => (new Book("../content/pages"))->findPageById($uuid), "mode" => $mode, + "token" => Session::get("form_token"), "status" => Session::active(), ]; } else { diff --git a/brain/data/Auth.inc.php b/brain/data/Auth.inc.php index 0f67e3c..094880f 100644 --- a/brain/data/Auth.inc.php +++ b/brain/data/Auth.inc.php @@ -53,9 +53,12 @@ class Auth time() + 3600, "localhost" ); //expires in an hour + + $form_token = md5(uniqid(microtime(), true)); Session::start(); Session::set("member", $member); Session::set("token", $token); + Session::set("form_token", $form_token); $result = "good_login"; } else { diff --git a/brain/data/Session.inc.php b/brain/data/Session.inc.php index 7bbc245..f5063c9 100644 --- a/brain/data/Session.inc.php +++ b/brain/data/Session.inc.php @@ -8,6 +8,7 @@ class Session private static $data = [ "member" => "", "token" => "", + "form_token" => "", ]; public static function start() { diff --git a/brain/views/dash/page-edit.twig b/brain/views/dash/page-edit.twig index 4e33c22..d435552 100644 --- a/brain/views/dash/page-edit.twig +++ b/brain/views/dash/page-edit.twig @@ -78,6 +78,7 @@ {% endapply %} +
diff --git a/public/assets/scripts/dash.min.js b/public/assets/scripts/dash.min.js index e375eec..bdcbf6d 100644 --- a/public/assets/scripts/dash.min.js +++ b/public/assets/scripts/dash.min.js @@ -1,2 +1,11 @@ -"use strict";var _Base=_interopRequireDefault(require("./Base"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}document.addEventListener("DOMContentLoaded",(function(){new _Base.default}),!1); +!function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:null;e(this,t),this.percentComplete=0,this.baseURL=null,this.status=!1,r&&(this.baseURL=r),this._request(this.baseURL?this.baseURL+c:c).then((function(e){e.type===I&&(n.token=e.token)}))}return n(t,[{key:"login",value:function(e){var t=this;return new Promise((function(n,r){t.baseURL?e.remote=!0:e.remote=!1,t.key?e.key=t.key:e.key=null,t._request(t.baseURL?t.baseURL+h:h,"getAuthStatus",s,l,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"sync",value:function(e,t){var n=this;return new Promise((function(r,o){var i="";switch(e){case"syncSite":i="/api/v1/settings/sync";break;case"syncNav":i="/api/v1/settings/nav-sync"}n._request(n.baseURL?n.baseURL+i:i,p,s,l,t).then((function(e){r(e)})).catch((function(e){o(e)}))}))}},{key:"publish",value:function(e){var t=this;return new Promise((function(n,r){t._request(t.baseURL?t.baseURL+d:d,g,s,l,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"pageActions",value:function(e,t){var n,r,o,i=this;switch(e){case m:n="/api/v1/page/create",r=m,o=u;break;case v:n="/api/v1/page/write",r=v,o=u;break;case y:n="/api/v1/page/delete",r=y,o=l}return this.baseURL?t.remote=!0:t.remote=!1,new Promise((function(e,a){i._request(i.baseURL?i.baseURL+n:n,r,s,o,t).then((function(t){e(t)})).catch((function(e){a(e)}))}))}},{key:"sendMail",value:function(e){var t=this;return new Promise((function(n,r){t._request(t.baseURL?t.baseURL+f:f,"sendMail",s,l,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"getInfo",value:function(e){var t,n,r=this;return"site"==e?(t="/api/v1/settings/site",n=w):(t="/api/v1/settings/member",n=E),new Promise((function(e,o){r._request(r.baseURL?r.baseURL+t:t,n).then((function(t){e(t)})).catch((function(e){o(e)}))}))}},{key:"_request",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"GET",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:l,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,i=this;return new Promise((function(a,c){var d=new XMLHttpRequest;if(d.upload.onprogress=i.handleLoadProgress,d.open(n,e,!0),d.onload=function(){if(200==d.status){var e=JSON.parse(d.response);a(e)}else{var t=JSON.parse(d.response);c(t)}},"PUT"==n||n==s)switch(t!==p&&t!==v&&t!==m&&t!==y&&t!==g&&t!==b||d.setRequestHeader("fipamo-access-token",i.token),r){case l:d.setRequestHeader("Content-type","application/"+r),d.send(JSON.stringify(o));break;case u:d.send(o)}else t!==w&&t!==E||d.setRequestHeader("fipamo-access-token",i.token),d.send()}))}},{key:"handleLoadProgress",value:function(e){this.percentComplete=Math.ceil(e.loaded/e.total*100)}}]),t}(),S="POST",T="json",D="x-www-form-urlencoded",x="/api/v1/status",P="apiUseAuthorized",_=function(){function t(){var n=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;e(this,t),this.percentComplete=0,this.token=null,this.baseURL=null,this.key=null,o&&(this.key=o),r&&(this.baseURL=r),this._request(this.baseURL?this.baseURL+x+"?key="+this.key:x+"?key="+this.key).then((function(e){e.type===P&&(n.token=e.token)}))}return n(t,[{key:"create",value:function(e){var t=this;return new Promise((function(n,r){t._request("/api/v1/init","blogInit",S,T,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"restore",value:function(e){var t=this;return new Promise((function(n,r){var o;o=new FormData(e),t._request("/api/v1/restore","restoreBackup","POST","x-www-form-urlencoded",o).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"backup",value:function(){var e=this;return new Promise((function(t,n){var r;r={task:"create_backup"},e._request("/api/v1/backup","createBackup","POST","json",r).then((function(e){t(e)})).catch((function(e){n(e)}))}))}},{key:"secret",value:function(e){var t=this;return new Promise((function(n,r){t._request("/api/v1/get-secret","retrieveSecret",S,T,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"newPass",value:function(e){var t=this;return new Promise((function(n,r){t._request("/api/v1/reset-password","resetPassword",S,T,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"imageUpload",value:function(e,t){var n=this;return new Promise((function(r,o){var i="";switch(e){case"avatar-upload":i="/api/v1/settings/add-avatar";break;case"background-upload":i="/api/v1/settings/add-feature-background";break;default:i="/api/v1/page/add-entry-image"}var a=new FormData;n.baseURL?(a.append("key",n.key),a.append("remote",!0)):a.append("remote",!1);for(var s=0;s2&&void 0!==arguments[2]?arguments[2]:"GET",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:T,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,i=this;return new Promise((function(t,a){var s=new XMLHttpRequest;if(s.upload.onprogress=i.handleLoadProgress,s.open(n,e,!0),s.onload=function(){if(200==s.status){var e=JSON.parse(s.response);t(e)}else{var n=JSON.parse(s.response);a(n)}},"PUT"==n||n==S)switch(r){case T:s.setRequestHeader("Content-type","application/"+r),s.send(JSON.stringify(o));break;case D:s.send(o)}else s.send()}))}},{key:"handleLoadProgress",value:function(e){this.percentComplete=Math.ceil(e.loaded/e.total*100)}}]),t}(),B=function(){function t(){e(this,t)}return n(t,[{key:"imgLoad",value:function(e){return new Promise((function(t,n){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){200===r.status?t(r.response):n(new Error("Image didn't load successfully; error code:"+r.statusText))},r.onerror=function(){n(new Error("There was a network error."))},r.send()}))}},{key:"loadImage",value:function(e){var t=this;return new Promise((function(n,r){(new Image).crossOrigin="",t.imgLoad(e).then((function(e){var t=window.URL.createObjectURL(e);n(t)}),(function(e){r(e)}))}))}},{key:"formDataToJSON",value:function(e){var t={};return new FormData(e).forEach((function(e,n){t.hasOwnProperty(n)?(Array.isArray(t[n])||(t[n]=[t[n]]),t[n].push(e)):t[n]=e})),t}}]),t}(),A="requestLame",C="postUpdated";new function t(){e(this,t)};var L=function(){function t(){e(this,t)}return n(t,[{key:"cleanString",value:function(e){return e.replace(/(^\-+|[^a-zA-Z0-9\/_| -]+|\-+$)/g,"").toLowerCase().replace(/[\/_| -]+/g,"-")}},{key:"decodeHTML",value:function(e,t){var n=0,r=0,o=!1;void 0===t&&(t=2),e=e.toString().replace(/</g,"<").replace(/>/g,">");var i={ENT_NOQUOTES:0,ENT_HTML_QUOTE_SINGLE:1,ENT_HTML_QUOTE_DOUBLE:2,ENT_COMPAT:2,ENT_QUOTES:3,ENT_IGNORE:4};if(0===t&&(o=!0),"number"!=typeof t){for(t=[].concat(t),r=0;r]*>/g,"\n"),r.append("id",document.getElementById("post-edit-index").getAttribute("data-index")),r.append("uuid",document.getElementById("post-edit-index").getAttribute("data-uuid")),r.append("layout",document.getElementById("post-edit-index").getAttribute("data-layout")),r.append("current_title",document.getElementById("post-edit-index").getAttribute("data-slug")),r.append("content",i),r.append("title",document.getElementById("post_title").value),r.append("created",document.getElementById("post-date").getAttribute("data-raw")),r.append("slug",(new L).cleanString(document.getElementById("post_title").value)),r.append("tags",document.getElementById("post_tags").value),r.append("menu",document.getElementById("option-menu-pin").getAttribute("data-active")),r.append("featured",document.getElementById("option-feature").getAttribute("data-active")),r.append("published",document.getElementById("option-published").getAttribute("data-active")),null!=e||null!=e)e.type.match("image.*")?r.append("feature_image",e,e.name):n("Not an image file");else if(document.getElementById("featured-image")){var a=document.getElementById("featured-image").src;null!=a||null!=a?r.append("feature_image",a):r.append("feature_image",null)}t(r)}))}}]),t}(),M="editorDelete",N="editorUploadImage",R="editorSave",U="editorUpdate";new function t(){e(this,t)};var H=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopStyle","borderRightStyle","borderBottomStyle","borderLeftStyle","borderTopWidth","boxSizing","fontFamily","fontSize","fontWeight","height","letterSpacing","lineHeight","marginBottom","marginLeft","marginRight","marginTop","outlineWidth","overflow","overflowX","overflowY","paddingBottom","paddingLeft","paddingRight","paddingTop","textAlign","textOverflow","textTransform","whiteSpace","wordBreak","wordWrap"],F=function(e,t){var n=document.createElement("div");return function(t){var r=function(){var t={position:"absolute",left:-9999,top:0,zIndex:-2e3};return"TEXTAREA"===e.tagName&&H.push("width"),H.forEach((function(n){t[n]=getComputedStyle(e)[n]})),t}();Object.keys(r).forEach((function(e){n.style[e]=r[e]})),n.innerHTML=t,e.parentNode.insertBefore(n,e.nextSibling)}(t),{rect:function(){var e=n.ownerDocument.getElementById("caret-position-marker"),t={left:e.offsetLeft,top:e.offsetTop,height:e.offsetHeight};return n.parentNode.removeChild(n),t}}};function X(e){return(X="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var q=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.customPos,n=e.iframe,r=e.noShadowCaret;return n?{iframe:n,window:n.contentWindow,document:n.contentDocument||n.contentWindow.document,noShadowCaret:r,customPos:t}:{window:window,document:document,noShadowCaret:r,customPos:t}},Y=function(e){return"object"===X(e)&&null!==e},j=function(e,t){var n=function(){return e.selectionStart},r=function(r){var o=function(e){return e.replace(/<|>|`|"|&/g,"?").replace(/\r\n|\r|\n/g,"
")};(t.customPos||0===t.customPos)&&(r=t.customPos);var i=void 0===r?n():r,a=e.value.slice(0,i),s=e.value.slice(i),l=''.concat(o(a),"");l+='|',l+=''.concat(o(s),"");var u=F(e,l).rect();return u.pos=n(),u};return{getPos:n,setPos:function(t){return e.setSelectionRange(t,t),e},getOffset:function(n){var o=function(e,t){var n=t&&t.window||window,r=t&&t.document||document,o=e.getBoundingClientRect(),i=r.documentElement,a=n.pageXOffset||i.scrollLeft,s=n.pageYOffset||i.scrollTop;return{top:o.top+s,left:o.left+a}}(e),i=r(n);return{top:o.top+i.top+t.document.body.scrollTop,left:o.left+i.left+t.document.body.scrollLeft,height:i.height}},getPosition:r}},W=function(e,t){return function(e){return!!(e.contentEditable?"true"===e.contentEditable:"true"===e.getAttribute("contenteditable"))}(e)?function(e,t){var n=function(){var n=r(),o={height:0,left:0,right:0};if(!n)return o;var i=t.customPos||0===t.customPos;if(n.endOffset-1>0&&n.endContainer!==e||i){var a=n.cloneRange(),s=i?t.customPos:n.endOffset;a.setStart(n.endContainer,s-1<0?0:s-1),a.setEnd(n.endContainer,s);var l=a.getBoundingClientRect();o={height:l.height,left:l.left+l.width,top:l.top},a.detach()}if((!o||o&&0===o.height)&&!t.noShadowCaret){var u=n.cloneRange(),c=t.document.createTextNode("|");u.insertNode(c),u.selectNode(c);var d=u.getBoundingClientRect();o={height:d.height,left:d.left,top:d.top},c.parentNode.removeChild(c),u.detach()}if(o){var f=t.document.documentElement;o.top+=t.window.pageYOffset-(f.clientTop||0),o.left+=t.window.pageXOffset-(f.clientLeft||0)}return o},r=function(){if(t.window.getSelection){var e=t.window.getSelection();return e.rangeCount>0?e.getRangeAt(0):null}},o=function(){var t=r(),n=t.cloneRange();n.selectNodeContents(e),n.setEnd(t.endContainer,t.endOffset);var o=n.toString().length;return n.detach(),o};return{getPos:o,setPos:function(n){var r=t.window.getSelection();if(r){var o=0,i=!1;!function e(a,s){for(var l=0;l=a){i=!0;var c=t.document.createRange();c.setStart(u,a-o),r.removeAllRanges(),r.addRange(c);break}o+=u.length}else e(n,u)}}(n,e)}return e},getPosition:function(){var r=n(),i=o(),a=e.getBoundingClientRect(),s=a.top+t.document.body.scrollTop,l=a.left+t.document.body.scrollLeft;return r.left-=l,r.top-=s,r.pos=i,r},getOffset:n,getRange:r}}(e,t):j(e,t)},z=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n;Y(t)&&(r=t,t=null);var o=q(r),i=W(e,o);return t||0===t?i.setPos(t):i.getPosition()},G=function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(i,t);var r=a(i);function i(t,n){var o;return e(this,i),(o=r.call(this)).textEditor=t,o.fixLimit=n,o.caretPos=null,o.url="",o.setInputs(),window.addEventListener("scroll",(function(){})),o.refresh(),o}return n(i,[{key:"setInputs",value:function(){for(var e=this,t=this,n=document.querySelectorAll(".editor-button"),r=0,o=n.length;r/g)>-1){var o=z(e.textEditor).pos;t.refresh(),z(e.textEditor,o)}}))}},{key:"refresh",value:function(){var e=this.textEditor.innerText;e=e.replace(new RegExp("\r?\n","g"),"
");var t=document.createElement("div");t.innerText=e,this.textEditor.innerHTML=t.innerText,this.textEditor.style.maxWidth="900px"}},{key:"notify",value:function(e,t){switch(e){case C:document.getElementById("submit-update").classList.add("icon-hide"),document.getElementById("submit-good").classList.remove("icon-hide"),document.getElementById("edit-update").classList.remove("submit-start"),document.getElementById("edit-update").classList.add("submit-cool"),setTimeout((function(){document.getElementById("submit-update").classList.remove("icon-hide"),document.getElementById("submit-good").classList.add("icon-hide"),document.getElementById("edit-update").classList.add("submit-start"),document.getElementById("edit-update").classList.remove("submit-cool")}),2e3);break;case"postAdded":break;case N:var n,r;z(this.textEditor,this.caretPos),(n=window.getSelection()).rangeCount&&((r=n.getRangeAt(0)).deleteContents(),r.insertNode(document.createTextNode("![image alt text]("+t+" 'image title')"))),this.refresh()}}},{key:"handleEditorOption",value:function(e){var t,n,r;if(e.preventDefault(),(t=window.getSelection()).rangeCount)switch(n=t.getRangeAt(0),r=t.getRangeAt(0).toString(),n.deleteContents(),e.target.id){case"edit-bold":n.insertNode(document.createTextNode("**"+r+"**"));break;case"edit-italic":n.insertNode(document.createTextNode("*"+r+"*"));break;case"edit-strikethrough":n.insertNode(document.createTextNode(""+r+""));break;case"edit-header1":n.insertNode(document.createTextNode("# "+r));break;case"edit-header2":n.insertNode(document.createTextNode("## "+r));break;case"edit-header3":n.insertNode(document.createTextNode("### "+r));break;case"edit-image":this.caretPos=z(this.textEditor).pos,this.emitEvent(N);break;case"submit-save":case"edit-save":this.emitEvent(R);break;case"submit-update":case"edit-update":this.emitEvent(U);break;case"edit-link":n.insertNode(document.createTextNode("["+r+"](PASTE URL HERE)"));break;case"edit-delete":this.emitEvent(M)}this.refresh()}}]),i}(function(){function t(){e(this,t),this.listeners=new Map}return n(t,[{key:"addListener",value:function(e,t){this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t)}},{key:"removeListener",value:function(e,t){var n,r=this.listeners.get(e);return!!(r&&r.length&&(n=r.reduce((function(e,n,r){return"function"==typeof n&&n===t?e=r:e}),-1))>-1)&&(r.splice(n,1),this.listeners.set(e,r),!0)}},{key:"emitEvent",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r-1}function ee(e,t){return e.apply(null,t)}var te={arr:function(e){return Array.isArray(e)},obj:function(e){return K(Object.prototype.toString.call(e),"Object")},pth:function(e){return te.obj(e)&&e.hasOwnProperty("totalLength")},svg:function(e){return e instanceof SVGElement},inp:function(e){return e instanceof HTMLInputElement},dom:function(e){return e.nodeType||te.svg(e)},str:function(e){return"string"==typeof e},fnc:function(e){return"function"==typeof e},und:function(e){return void 0===e},nil:function(e){return te.und(e)||null===e},hex:function(e){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)},rgb:function(e){return/^rgb/.test(e)},hsl:function(e){return/^hsl/.test(e)},col:function(e){return te.hex(e)||te.rgb(e)||te.hsl(e)},key:function(e){return!Q.hasOwnProperty(e)&&!V.hasOwnProperty(e)&&"targets"!==e&&"keyframes"!==e}};function ne(e){var t=/\(([^)]+)\)/.exec(e);return t?t[1].split(",").map((function(e){return parseFloat(e)})):[]}function re(e,t){var n=ne(e),r=Z(te.und(n[0])?1:n[0],.1,100),o=Z(te.und(n[1])?100:n[1],.1,100),i=Z(te.und(n[2])?10:n[2],.1,100),a=Z(te.und(n[3])?0:n[3],.1,100),s=Math.sqrt(o/r),l=i/(2*Math.sqrt(o*r)),u=l<1?s*Math.sqrt(1-l*l):0,c=l<1?(l*s-a)/u:-a+s;function d(e){var n=t?t*e/1e3:e;return n=l<1?Math.exp(-n*l*s)*(1*Math.cos(u*n)+c*Math.sin(u*n)):(1+c*n)*Math.exp(-n*s),0===e||1===e?e:1-n}return t?d:function(){var t=$.springs[e];if(t)return t;for(var n=1/6,r=0,o=0;;)if(1===d(r+=n)){if(++o>=16)break}else o=0;var i=r*n*1e3;return $.springs[e]=i,i}}function oe(e){return void 0===e&&(e=10),function(t){return Math.ceil(Z(t,1e-6,1)*e)*(1/e)}}var ie,ae,se=function(){var e=.1;function t(e,t){return 1-3*t+3*e}function n(e,t){return 3*t-6*e}function r(e){return 3*e}function o(e,o,i){return((t(o,i)*e+n(o,i))*e+r(o))*e}function i(e,o,i){return 3*t(o,i)*e*e+2*n(o,i)*e+r(o)}return function(t,n,r,a){if(0<=t&&t<=1&&0<=r&&r<=1){var s=new Float32Array(11);if(t!==n||r!==a)for(var l=0;l<11;++l)s[l]=o(l*e,t,r);return function(e){return t===n&&r===a||0===e||1===e?e:o(u(e),n,a)}}function u(n){for(var a=0,l=1;10!==l&&s[l]<=n;++l)a+=e;--l;var u=a+(n-s[l])/(s[l+1]-s[l])*e,c=i(u,t,r);return c>=.001?function(e,t,n,r){for(var a=0;a<4;++a){var s=i(t,n,r);if(0===s)return t;t-=(o(t,n,r)-e)/s}return t}(n,u,t,r):0===c?u:function(e,t,n,r,i){var a,s,l=0;do{(a=o(s=t+(n-t)/2,r,i)-e)>0?n=s:t=s}while(Math.abs(a)>1e-7&&++l<10);return s}(n,a,a+e,t,r)}}}(),le=(ie={linear:function(){return function(e){return e}}},ae={Sine:function(){return function(e){return 1-Math.cos(e*Math.PI/2)}},Circ:function(){return function(e){return 1-Math.sqrt(1-e*e)}},Back:function(){return function(e){return e*e*(3*e-2)}},Bounce:function(){return function(e){for(var t,n=4;e<((t=Math.pow(2,--n))-1)/11;);return 1/Math.pow(4,3-n)-7.5625*Math.pow((3*t-2)/22-e,2)}},Elastic:function(e,t){void 0===e&&(e=1),void 0===t&&(t=.5);var n=Z(e,1,10),r=Z(t,.1,2);return function(e){return 0===e||1===e?e:-n*Math.pow(2,10*(e-1))*Math.sin((e-1-r/(2*Math.PI)*Math.asin(1/n))*(2*Math.PI)/r)}}},["Quad","Cubic","Quart","Quint","Expo"].forEach((function(e,t){ae[e]=function(){return function(e){return Math.pow(e,t+2)}}})),Object.keys(ae).forEach((function(e){var t=ae[e];ie["easeIn"+e]=t,ie["easeOut"+e]=function(e,n){return function(r){return 1-t(e,n)(1-r)}},ie["easeInOut"+e]=function(e,n){return function(r){return r<.5?t(e,n)(2*r)/2:1-t(e,n)(-2*r+2)/2}},ie["easeOutIn"+e]=function(e,n){return function(r){return r<.5?(1-t(e,n)(1-2*r))/2:(t(e,n)(2*r-1)+1)/2}}})),ie);function ue(e,t){if(te.fnc(e))return e;var n=e.split("(")[0],r=le[n],o=ne(e);switch(n){case"spring":return re(e,t);case"cubicBezier":return ee(se,o);case"steps":return ee(oe,o);default:return ee(r,o)}}function ce(e){try{return document.querySelectorAll(e)}catch(e){return}}function de(e,t){for(var n=e.length,r=arguments.length>=2?t:void 0,o=[],i=0;i1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}if(0==a)t=n=r=s;else{var c=s<.5?s*(1+a):s+a-s*a,d=2*s-c;t=u(d,c,i+1/3),n=u(d,c,i),r=u(d,c,i-1/3)}return"rgba("+255*t+","+255*n+","+255*r+","+l+")"}(e):void 0;var t,n}function be(e){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(e);if(t)return t[1]}function we(e,t){return te.fnc(e)?e(t.target,t.id,t.total):e}function Ee(e,t){return e.getAttribute(t)}function Ie(e,t,n){if(pe([n,"deg","rad","turn"],be(t)))return t;var r=$.CSS[t+n];if(!te.und(r))return r;var o=document.createElement(e.tagName),i=e.parentNode&&e.parentNode!==document?e.parentNode:document.body;i.appendChild(o),o.style.position="absolute",o.style.width=100+n;var a=100/o.offsetWidth;i.removeChild(o);var s=a*parseFloat(t);return $.CSS[t+n]=s,s}function ke(e,t,n){if(t in e.style){var r=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),o=e.style[t]||getComputedStyle(e).getPropertyValue(r)||"0";return n?Ie(e,o,n):o}}function Se(e,t){return te.dom(e)&&!te.inp(e)&&(!te.nil(Ee(e,t))||te.svg(e)&&e[t])?"attribute":te.dom(e)&&pe(J,t)?"transform":te.dom(e)&&"transform"!==t&&ke(e,t)?"css":null!=e[t]?"object":void 0}function Te(e){if(te.dom(e)){for(var t,n=e.style.transform||"",r=/(\w+)\(([^)]*)\)/g,o=new Map;t=r.exec(n);)o.set(t[1],t[2]);return o}}function De(e,t,n,r){var o=K(t,"scale")?1:0+function(e){return K(e,"translate")||"perspective"===e?"px":K(e,"rotate")||K(e,"skew")?"deg":void 0}(t),i=Te(e).get(t)||o;return n&&(n.transforms.list.set(t,i),n.transforms.last=t),r?Ie(e,i,r):i}function xe(e,t,n,r){switch(Se(e,t)){case"transform":return De(e,t,r,n);case"css":return ke(e,t,n);case"attribute":return Ee(e,t);default:return e[t]||0}}function Pe(e,t){var n=/^(\*=|\+=|-=)/.exec(e);if(!n)return e;var r=be(e)||0,o=parseFloat(t),i=parseFloat(e.replace(n[0],""));switch(n[0][0]){case"+":return o+i+r;case"-":return o-i+r;case"*":return o*i+r}}function _e(e,t){if(te.col(e))return ye(e);if(/\s/g.test(e))return e;var n=be(e),r=n?e.substr(0,e.length-n.length):e;return t?r+t:r}function Be(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function Ae(e){for(var t,n=e.points,r=0,o=0;o0&&(r+=Be(t,i)),t=i}return r}function Ce(e){if(e.getTotalLength)return e.getTotalLength();switch(e.tagName.toLowerCase()){case"circle":return function(e){return 2*Math.PI*Ee(e,"r")}(e);case"rect":return function(e){return 2*Ee(e,"width")+2*Ee(e,"height")}(e);case"line":return function(e){return Be({x:Ee(e,"x1"),y:Ee(e,"y1")},{x:Ee(e,"x2"),y:Ee(e,"y2")})}(e);case"polyline":return Ae(e);case"polygon":return function(e){var t=e.points;return Ae(e)+Be(t.getItem(t.numberOfItems-1),t.getItem(0))}(e)}}function Le(e,t){var n=t||{},r=n.el||function(e){for(var t=e.parentNode;te.svg(t)&&te.svg(t.parentNode);)t=t.parentNode;return t}(e),o=r.getBoundingClientRect(),i=Ee(r,"viewBox"),a=o.width,s=o.height,l=n.viewBox||(i?i.split(" "):[0,0,a,s]);return{el:r,viewBox:l,x:l[0]/1,y:l[1]/1,w:a,h:s,vW:l[2],vH:l[3]}}function Oe(e,t,n){function r(n){void 0===n&&(n=0);var r=t+n>=1?t+n:0;return e.el.getPointAtLength(r)}var o=Le(e.el,e.svg),i=r(),a=r(-1),s=r(1),l=n?1:o.w/o.vW,u=n?1:o.h/o.vH;switch(e.property){case"x":return(i.x-o.x)*l;case"y":return(i.y-o.y)*u;case"angle":return 180*Math.atan2(s.y-a.y,s.x-a.x)/Math.PI}}function Me(e,t){var n=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=_e(te.pth(e)?e.totalLength:e,t)+"";return{original:r,numbers:r.match(n)?r.match(n).map(Number):[0],strings:te.str(e)||t?r.split(n):[]}}function Ne(e){return de(e?fe(te.arr(e)?e.map(he):he(e)):[],(function(e,t,n){return n.indexOf(e)===t}))}function Re(e){var t=Ne(e);return t.map((function(e,n){return{target:e,id:n,total:t.length,transforms:{list:Te(e)}}}))}function Ue(e,t){var n=ge(t);if(/^spring/.test(n.easing)&&(n.duration=re(n.easing)),te.arr(e)){var r=e.length;2===r&&!te.obj(e[0])?e={value:e}:te.fnc(t.duration)||(n.duration=t.duration/r)}var o=te.arr(e)?e:[e];return o.map((function(e,n){var r=te.obj(e)&&!te.pth(e)?e:{value:e};return te.und(r.delay)&&(r.delay=n?0:t.delay),te.und(r.endDelay)&&(r.endDelay=n===o.length-1?t.endDelay:0),r})).map((function(e){return ve(e,n)}))}function He(e,t){var n=[],r=t.keyframes;for(var o in r&&(t=ve(function(e){for(var t=de(fe(e.map((function(e){return Object.keys(e)}))),(function(e){return te.key(e)})).reduce((function(e,t){return e.indexOf(t)<0&&e.push(t),e}),[]),n={},r=function(r){var o=t[r];n[o]=e.map((function(e){var t={};for(var n in e)te.key(n)?n==o&&(t.value=e[n]):t[n]=e[n];return t}))},o=0;o0?requestAnimationFrame(t):void 0}return"undefined"!=typeof document&&document.addEventListener("visibilitychange",(function(){Ve.suspendWhenDocumentHidden&&(Qe()?e=cancelAnimationFrame(e):(ze.forEach((function(e){return e._onDocumentVisibility()})),Ge()))})),function(){e||Qe()&&Ve.suspendWhenDocumentHidden||!(ze.length>0)||(e=requestAnimationFrame(t))}}();function Qe(){return!!document&&document.hidden}function Ve(e){void 0===e&&(e={});var t,n=0,r=0,o=0,i=0,a=null;function s(e){var t=window.Promise&&new Promise((function(e){return a=e}));return e.finished=t,t}var l=function(e){var t=me(Q,e),n=me(V,e),r=He(n,e),o=Re(e.targets),i=Ye(o,r),a=je(i,n),s=We;return We++,ve(t,{id:s,children:[],animatables:o,animations:i,duration:a.duration,delay:a.delay,endDelay:a.endDelay})}(e);function u(){var e=l.direction;"alternate"!==e&&(l.direction="normal"!==e?"normal":"reverse"),l.reversed=!l.reversed,t.forEach((function(e){return e.reversed=l.reversed}))}function c(e){return l.reversed?l.duration-e:e}function d(){n=0,r=c(l.currentTime)*(1/Ve.speed)}function f(e,t){t&&t.seek(e-t.timelineOffset)}function h(e){for(var t=0,n=l.animations,r=n.length;t2||(y=Math.round(y*h)/h)),p.push(y)}var E=f.length;if(E){m=f[0];for(var I=0;I0&&(l.began=!0,p("begin")),!l.loopBegan&&l.currentTime>0&&(l.loopBegan=!0,p("loopBegin")),v<=g&&0!==l.currentTime&&h(0),(v>=m&&l.currentTime!==d||!d)&&h(d),v>g&&v=d&&(r=0,l.remaining&&!0!==l.remaining&&l.remaining--,l.remaining?(n=o,p("loopComplete"),l.loopBegan=!1,"alternate"===l.direction&&u()):(l.paused=!0,l.completed||(l.completed=!0,p("loopComplete"),p("complete"),!l.passThrough&&"Promise"in window&&(a(),s(l)))))}return s(l),l.reset=function(){var e=l.direction;l.passThrough=!1,l.currentTime=0,l.progress=0,l.paused=!0,l.began=!1,l.loopBegan=!1,l.changeBegan=!1,l.completed=!1,l.changeCompleted=!1,l.reversePlayback=!1,l.reversed="reverse"===e,l.remaining=l.loop,t=l.children;for(var n=i=t.length;n--;)l.children[n].reset();(l.reversed&&!0!==l.loop||"alternate"===e&&1===l.loop)&&l.remaining++,h(l.reversed?l.duration:0)},l._onDocumentVisibility=d,l.set=function(e,t){return qe(e,t),l},l.tick=function(e){o=e,n||(n=o),g((o+(r-n))*Ve.speed)},l.seek=function(e){g(c(e))},l.pause=function(){l.paused=!0,d()},l.play=function(){l.paused&&(l.completed&&l.reset(),l.paused=!1,ze.push(l),d(),Ge())},l.reverse=function(){u(),l.completed=!l.reversed,d()},l.restart=function(){l.reset(),l.play()},l.remove=function(e){$e(Ne(e),l)},l.reset(),l.autoplay&&l.play(),l}function Je(e,t){for(var n=t.length;n--;)pe(e,t[n].animatable.target)&&t.splice(n,1)}function $e(e,t){var n=t.animations,r=t.children;Je(e,n);for(var o=r.length;o--;){var i=r[o],a=i.animations;Je(e,a),a.length||i.children.length||r.splice(o,1)}n.length||r.length||t.pause()}Ve.version="3.2.1",Ve.speed=1,Ve.suspendWhenDocumentHidden=!0,Ve.running=ze,Ve.remove=function(e){for(var t=Ne(e),n=ze.length;n--;){$e(t,ze[n])}},Ve.get=xe,Ve.set=qe,Ve.convertPx=Ie,Ve.path=function(e,t){var n=te.str(e)?ce(e)[0]:e,r=t||100;return function(e){return{property:e,el:n,svg:Le(n),totalLength:Ce(n)*(r/100)}}},Ve.setDashoffset=function(e){var t=Ce(e);return e.setAttribute("stroke-dasharray",t),t},Ve.stagger=function(e,t){void 0===t&&(t={});var n=t.direction||"normal",r=t.easing?ue(t.easing):null,o=t.grid,i=t.axis,a=t.from||0,s="first"===a,l="center"===a,u="last"===a,c=te.arr(e),d=c?parseFloat(e[0]):parseFloat(e),f=c?parseFloat(e[1]):0,h=be(c?e[1]:e)||0,p=t.start||0+(c?d:0),g=[],m=0;return function(e,t,v){if(s&&(a=0),l&&(a=(v-1)/2),u&&(a=v-1),!g.length){for(var y=0;y-1&&ze.splice(o,1);for(var s=0;s'].join(""),document.getElementById("featured-image-drop").innerHTML="",document.getElementById("featured-image-drop").appendChild(n)}}(n),o.readAsDataURL(n)}}}},{key:"handleImageUpload",value:function(e,t){var n=this;it.alert("Uploading Image",null),(new _).imageUpload(e,t).then((function(e){"postImageAdded"==e.type&&n.editor.notify(N,e.url),it.alert("Image Added to Entry",!0)})).catch((function(){it.alert("Uh oh. Image not added",!1)}))}}]),t}();at.uploadFiles=[];var st=function(){function t(n){e(this,t),this.currentPage=null,this.choosePage(n),this.start()}return n(t,[{key:"start",value:function(){}},{key:"choosePage",value:function(e){switch(this.currentPage="",e){case"edit":case"add":this.currentPage=new at}}}]),t}(),lt=function(){function t(){e(this,t)}return n(t,[{key:"getInfo",value:function(){var e,t,n=document.getElementById("settings-handle").value,r=document.getElementById("settings-email").value,o=document.getElementById("settings-url").value,i=document.getElementById("settings-title").value,a=document.getElementById("settings-desc").value,s=document.getElementById("background").src,l="",u=document.querySelectorAll(".theme-select"),c=document.getElementById("smtp-domain").value,d=document.getElementById("smtp-email").value,f=document.getElementById("smtp-pass").value,h=document.getElementById("mg-domain").value,p=document.getElementById("mg-key").value,g="",m=document.querySelectorAll(".mail-option"),v=document.getElementById("api-access-toggle").getAttribute("data-enabled");for(e=0,t=u.length;e + * @author owenm + * @license MIT + */ +function pt(e){return(pt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function gt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function mt(){return(mt=Object.assign||function(e){for(var t=1;t=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function bt(e){if("undefined"!=typeof window&&window.navigator)return!!navigator.userAgent.match(e)}var wt=bt(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Et=bt(/Edge/i),It=bt(/firefox/i),kt=bt(/safari/i)&&!bt(/chrome/i)&&!bt(/android/i),St=bt(/iP(ad|od|hone)/i),Tt=bt(/chrome/i)&&bt(/android/i),Dt={capture:!1,passive:!1};function xt(e,t,n){e.addEventListener(t,n,!wt&&Dt)}function Pt(e,t,n){e.removeEventListener(t,n,!wt&&Dt)}function _t(e,t){if(t){if(">"===t[0]&&(t=t.substring(1)),e)try{if(e.matches)return e.matches(t);if(e.msMatchesSelector)return e.msMatchesSelector(t);if(e.webkitMatchesSelector)return e.webkitMatchesSelector(t)}catch(e){return!1}return!1}}function Bt(e){return e.host&&e!==document&&e.host.nodeType?e.host:e.parentNode}function At(e,t,n,r){if(e){n=n||document;do{if(null!=t&&(">"===t[0]?e.parentNode===n&&_t(e,t):_t(e,t))||r&&e===n)return e;if(e===n)break}while(e=Bt(e))}return null}var Ct,Lt=/\s+/g;function Ot(e,t,n){if(e&&t)if(e.classList)e.classList[n?"add":"remove"](t);else{var r=(" "+e.className+" ").replace(Lt," ").replace(" "+t+" "," ");e.className=(r+(n?" "+t:"")).replace(Lt," ")}}function Mt(e,t,n){var r=e&&e.style;if(r){if(void 0===n)return document.defaultView&&document.defaultView.getComputedStyle?n=document.defaultView.getComputedStyle(e,""):e.currentStyle&&(n=e.currentStyle),void 0===t?n:n[t];t in r||-1!==t.indexOf("webkit")||(t="-webkit-"+t),r[t]=n+("string"==typeof n?"":"px")}}function Nt(e,t){var n="";if("string"==typeof e)n=e;else do{var r=Mt(e,"transform");r&&"none"!==r&&(n=r+" "+n)}while(!t&&(e=e.parentNode));var o=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return o&&new o(n)}function Rt(e,t,n){if(e){var r=e.getElementsByTagName(t),o=0,i=r.length;if(n)for(;o=i:o<=i))return r;if(r===Ut())break;r=Wt(r,!1)}return!1}function Xt(e,t,n){for(var r=0,o=0,i=e.children;o2&&void 0!==arguments[2]?arguments[2]:{},r=n.evt,o=yt(n,["evt"]);en.pluginEvent.bind(Qn)(e,t,vt({dragEl:rn,parentEl:on,ghostEl:an,rootEl:sn,nextEl:ln,lastDownEl:un,cloneEl:cn,cloneHidden:dn,dragStarted:Sn,putSortable:vn,activeSortable:Qn.active,originalEvent:r,oldIndex:fn,oldDraggableIndex:pn,newIndex:hn,newDraggableIndex:gn,hideGhostForTarget:jn,unhideGhostForTarget:Wn,cloneNowHidden:function(){dn=!0},cloneNowShown:function(){dn=!1},dispatchSortableEvent:function(e){nn({sortable:t,name:e,originalEvent:r})}},o))};function nn(e){!function(e){var t=e.sortable,n=e.rootEl,r=e.name,o=e.targetEl,i=e.cloneEl,a=e.toEl,s=e.fromEl,l=e.oldIndex,u=e.newIndex,c=e.oldDraggableIndex,d=e.newDraggableIndex,f=e.originalEvent,h=e.putSortable,p=e.extraEventProperties;if(t=t||n&&n[Jt]){var g,m=t.options,v="on"+r.charAt(0).toUpperCase()+r.substr(1);!window.CustomEvent||wt||Et?(g=document.createEvent("Event")).initEvent(r,!0,!0):g=new CustomEvent(r,{bubbles:!0,cancelable:!0}),g.to=a||n,g.from=s||n,g.item=o||n,g.clone=i,g.oldIndex=l,g.newIndex=u,g.oldDraggableIndex=c,g.newDraggableIndex=d,g.originalEvent=f,g.pullMode=h?h.lastPutMode:void 0;var y=vt({},p,en.getEventProperties(r,t));for(var b in y)g[b]=y[b];n&&n.dispatchEvent(g),m[v]&&m[v].call(t,g)}}(vt({putSortable:vn,cloneEl:cn,targetEl:rn,rootEl:sn,oldIndex:fn,oldDraggableIndex:pn,newIndex:hn,newDraggableIndex:gn},e))}var rn,on,an,sn,ln,un,cn,dn,fn,hn,pn,gn,mn,vn,yn,bn,wn,En,In,kn,Sn,Tn,Dn,xn,Pn,_n=!1,Bn=!1,An=[],Cn=!1,Ln=!1,On=[],Mn=!1,Nn=[],Rn="undefined"!=typeof document,Un=St,Hn=Et||wt?"cssFloat":"float",Fn=Rn&&!Tt&&!St&&"draggable"in document.createElement("div"),Xn=function(){if(Rn){if(wt)return!1;var e=document.createElement("x");return e.style.cssText="pointer-events:auto","auto"===e.style.pointerEvents}}(),qn=function(e,t){var n=Mt(e),r=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),o=Xt(e,0,t),i=Xt(e,1,t),a=o&&Mt(o),s=i&&Mt(i),l=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+Ht(o).width,u=s&&parseInt(s.marginLeft)+parseInt(s.marginRight)+Ht(i).width;if("flex"===n.display)return"column"===n.flexDirection||"column-reverse"===n.flexDirection?"vertical":"horizontal";if("grid"===n.display)return n.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(o&&a.float&&"none"!==a.float){var c="left"===a.float?"left":"right";return!i||"both"!==s.clear&&s.clear!==c?"horizontal":"vertical"}return o&&("block"===a.display||"flex"===a.display||"table"===a.display||"grid"===a.display||l>=r&&"none"===n[Hn]||i&&"none"===n[Hn]&&l+u>r)?"vertical":"horizontal"},Yn=function(e){function t(e,n){return function(r,o,i,a){var s=r.options.group.name&&o.options.group.name&&r.options.group.name===o.options.group.name;if(null==e&&(n||s))return!0;if(null==e||!1===e)return!1;if(n&&"clone"===e)return e;if("function"==typeof e)return t(e(r,o,i,a),n)(r,o,i,a);var l=(n?r:o).options.group.name;return!0===e||"string"==typeof e&&e===l||e.join&&e.indexOf(l)>-1}}var n={},r=e.group;r&&"object"==pt(r)||(r={name:r}),n.name=r.name,n.checkPull=t(r.pull,!0),n.checkPut=t(r.put),n.revertClone=r.revertClone,e.group=n},jn=function(){!Xn&&an&&Mt(an,"display","none")},Wn=function(){!Xn&&an&&Mt(an,"display","")};Rn&&document.addEventListener("click",(function(e){if(Bn)return e.preventDefault(),e.stopPropagation&&e.stopPropagation(),e.stopImmediatePropagation&&e.stopImmediatePropagation(),Bn=!1,!1}),!0);var zn=function(e){if(rn){e=e.touches?e.touches[0]:e;var t=(o=e.clientX,i=e.clientY,An.some((function(e){if(!qt(e)){var t=Ht(e),n=e[Jt].options.emptyInsertThreshold,r=o>=t.left-n&&o<=t.right+n,s=i>=t.top-n&&i<=t.bottom+n;return n&&r&&s?a=e:void 0}})),a);if(t){var n={};for(var r in e)e.hasOwnProperty(r)&&(n[r]=e[r]);n.target=n.rootEl=t,n.preventDefault=void 0,n.stopPropagation=void 0,t[Jt]._onDragOver(n)}}var o,i,a},Gn=function(e){rn&&rn.parentNode[Jt]._isOutsideThisEl(e.target)};function Qn(e,t){if(!e||!e.nodeType||1!==e.nodeType)throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(e));this.el=e,this.options=t=mt({},t),e[Jt]=this;var n={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(e.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return qn(e,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(e,t){e.setData("Text",t.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:!1!==Qn.supportPointer&&"PointerEvent"in window&&!kt,emptyInsertThreshold:5};for(var r in en.initializePlugins(this,e,n),n)!(r in t)&&(t[r]=n[r]);for(var o in Yn(t),this)"_"===o.charAt(0)&&"function"==typeof this[o]&&(this[o]=this[o].bind(this));this.nativeDraggable=!t.forceFallback&&Fn,this.nativeDraggable&&(this.options.touchStartThreshold=1),t.supportPointer?xt(e,"pointerdown",this._onTapStart):(xt(e,"mousedown",this._onTapStart),xt(e,"touchstart",this._onTapStart)),this.nativeDraggable&&(xt(e,"dragover",this),xt(e,"dragenter",this)),An.push(this.el),t.store&&t.store.get&&this.sort(t.store.get(this)||[]),mt(this,$t())}function Vn(e,t,n,r,o,i,a,s){var l,u,c=e[Jt],d=c.options.onMove;return!window.CustomEvent||wt||Et?(l=document.createEvent("Event")).initEvent("move",!0,!0):l=new CustomEvent("move",{bubbles:!0,cancelable:!0}),l.to=t,l.from=e,l.dragged=n,l.draggedRect=r,l.related=o||t,l.relatedRect=i||Ht(t),l.willInsertAfter=s,l.originalEvent=a,e.dispatchEvent(l),d&&(u=d.call(c,l,a)),u}function Jn(e){e.draggable=!1}function $n(){Mn=!1}function Zn(e){for(var t=e.tagName+e.className+e.src+e.href+e.textContent,n=t.length,r=0;n--;)r+=t.charCodeAt(n);return r.toString(36)}function Kn(e){return setTimeout(e,0)}function er(e){return clearTimeout(e)}Qn.prototype={constructor:Qn,_isOutsideThisEl:function(e){this.el.contains(e)||e===this.el||(Tn=null)},_getDirection:function(e,t){return"function"==typeof this.options.direction?this.options.direction.call(this,e,t,rn):this.options.direction},_onTapStart:function(e){if(e.cancelable){var t=this,n=this.el,r=this.options,o=r.preventOnFilter,i=e.type,a=e.touches&&e.touches[0]||e.pointerType&&"touch"===e.pointerType&&e,s=(a||e).target,l=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||s,u=r.filter;if(function(e){Nn.length=0;var t=e.getElementsByTagName("input"),n=t.length;for(;n--;){var r=t[n];r.checked&&Nn.push(r)}}(n),!rn&&!(/mousedown|pointerdown/.test(i)&&0!==e.button||r.disabled)&&!l.isContentEditable&&(this.nativeDraggable||!kt||!s||"SELECT"!==s.tagName.toUpperCase())&&!((s=At(s,r.draggable,n,!1))&&s.animated||un===s)){if(fn=Yt(s),pn=Yt(s,r.draggable),"function"==typeof u){if(u.call(this,e,s,this))return nn({sortable:t,rootEl:l,name:"filter",targetEl:s,toEl:n,fromEl:n}),tn("filter",t,{evt:e}),void(o&&e.cancelable&&e.preventDefault())}else if(u&&(u=u.split(",").some((function(r){if(r=At(l,r.trim(),n,!1))return nn({sortable:t,rootEl:r,name:"filter",targetEl:s,fromEl:n,toEl:n}),tn("filter",t,{evt:e}),!0}))))return void(o&&e.cancelable&&e.preventDefault());r.handle&&!At(l,r.handle,n,!1)||this._prepareDragStart(e,a,s)}}},_prepareDragStart:function(e,t,n){var r,o=this,i=o.el,a=o.options,s=i.ownerDocument;if(n&&!rn&&n.parentNode===i){var l=Ht(n);if(sn=i,on=(rn=n).parentNode,ln=rn.nextSibling,un=n,mn=a.group,Qn.dragged=rn,yn={target:rn,clientX:(t||e).clientX,clientY:(t||e).clientY},In=yn.clientX-l.left,kn=yn.clientY-l.top,this._lastX=(t||e).clientX,this._lastY=(t||e).clientY,rn.style["will-change"]="all",r=function(){tn("delayEnded",o,{evt:e}),Qn.eventCanceled?o._onDrop():(o._disableDelayedDragEvents(),!It&&o.nativeDraggable&&(rn.draggable=!0),o._triggerDragStart(e,t),nn({sortable:o,name:"choose",originalEvent:e}),Ot(rn,a.chosenClass,!0))},a.ignore.split(",").forEach((function(e){Rt(rn,e.trim(),Jn)})),xt(s,"dragover",zn),xt(s,"mousemove",zn),xt(s,"touchmove",zn),xt(s,"mouseup",o._onDrop),xt(s,"touchend",o._onDrop),xt(s,"touchcancel",o._onDrop),It&&this.nativeDraggable&&(this.options.touchStartThreshold=4,rn.draggable=!0),tn("delayStart",this,{evt:e}),!a.delay||a.delayOnTouchOnly&&!t||this.nativeDraggable&&(Et||wt))r();else{if(Qn.eventCanceled)return void this._onDrop();xt(s,"mouseup",o._disableDelayedDrag),xt(s,"touchend",o._disableDelayedDrag),xt(s,"touchcancel",o._disableDelayedDrag),xt(s,"mousemove",o._delayedDragTouchMoveHandler),xt(s,"touchmove",o._delayedDragTouchMoveHandler),a.supportPointer&&xt(s,"pointermove",o._delayedDragTouchMoveHandler),o._dragStartTimer=setTimeout(r,a.delay)}}},_delayedDragTouchMoveHandler:function(e){var t=e.touches?e.touches[0]:e;Math.max(Math.abs(t.clientX-this._lastX),Math.abs(t.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){rn&&Jn(rn),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;Pt(e,"mouseup",this._disableDelayedDrag),Pt(e,"touchend",this._disableDelayedDrag),Pt(e,"touchcancel",this._disableDelayedDrag),Pt(e,"mousemove",this._delayedDragTouchMoveHandler),Pt(e,"touchmove",this._delayedDragTouchMoveHandler),Pt(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,t){t=t||"touch"==e.pointerType&&e,!this.nativeDraggable||t?this.options.supportPointer?xt(document,"pointermove",this._onTouchMove):xt(document,t?"touchmove":"mousemove",this._onTouchMove):(xt(rn,"dragend",this),xt(sn,"dragstart",this._onDragStart));try{document.selection?Kn((function(){document.selection.empty()})):window.getSelection().removeAllRanges()}catch(e){}},_dragStarted:function(e,t){if(_n=!1,sn&&rn){tn("dragStarted",this,{evt:t}),this.nativeDraggable&&xt(document,"dragover",Gn);var n=this.options;!e&&Ot(rn,n.dragClass,!1),Ot(rn,n.ghostClass,!0),Qn.active=this,e&&this._appendGhost(),nn({sortable:this,name:"start",originalEvent:t})}else this._nulling()},_emulateDragOver:function(){if(bn){this._lastX=bn.clientX,this._lastY=bn.clientY,jn();for(var e=document.elementFromPoint(bn.clientX,bn.clientY),t=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(bn.clientX,bn.clientY))!==t;)t=e;if(rn.parentNode[Jt]._isOutsideThisEl(e),t)do{if(t[Jt]){if(t[Jt]._onDragOver({clientX:bn.clientX,clientY:bn.clientY,target:e,rootEl:t})&&!this.options.dragoverBubble)break}e=t}while(t=t.parentNode);Wn()}},_onTouchMove:function(e){if(yn){var t=this.options,n=t.fallbackTolerance,r=t.fallbackOffset,o=e.touches?e.touches[0]:e,i=an&&Nt(an,!0),a=an&&i&&i.a,s=an&&i&&i.d,l=Un&&Pn&&jt(Pn),u=(o.clientX-yn.clientX+r.x)/(a||1)+(l?l[0]-On[0]:0)/(a||1),c=(o.clientY-yn.clientY+r.y)/(s||1)+(l?l[1]-On[1]:0)/(s||1);if(!Qn.active&&!_n){if(n&&Math.max(Math.abs(o.clientX-this._lastX),Math.abs(o.clientY-this._lastY))r.right+o||e.clientX<=r.right&&e.clientY>r.bottom&&e.clientX>=r.left:e.clientX>r.right&&e.clientY>r.top||e.clientX<=r.right&&e.clientY>r.bottom+o}(e,o,this)&&!g.animated){if(g===rn)return B(!1);if(g&&i===e.target&&(a=g),a&&(n=Ht(a)),!1!==Vn(sn,i,rn,t,a,n,e,!!a))return _(),i.appendChild(rn),on=i,A(),B(!0)}else if(a.parentNode===i){n=Ht(a);var m,v,y,b=rn.parentNode!==i,w=!function(e,t,n){var r=n?e.left:e.top,o=n?e.right:e.bottom,i=n?e.width:e.height,a=n?t.left:t.top,s=n?t.right:t.bottom,l=n?t.width:t.height;return r===a||o===s||r+i/2===a+l/2}(rn.animated&&rn.toRect||t,a.animated&&a.toRect||n,o),E=o?"top":"left",I=Ft(a,"top","top")||Ft(rn,"top","top"),k=I?I.scrollTop:void 0;if(Tn!==a&&(v=n[E],Cn=!1,Ln=!w&&s.invertSwap||b),0!==(m=function(e,t,n,r,o,i,a,s){var l=r?e.clientY:e.clientX,u=r?n.height:n.width,c=r?n.top:n.left,d=r?n.bottom:n.right,f=!1;if(!a)if(s&&xnc+u*i/2:ld-xn)return-Dn}else if(l>c+u*(1-o)/2&&ld-u*i/2))return l>c+u/2?1:-1;return 0}(e,a,n,o,w?1:s.swapThreshold,null==s.invertedSwapThreshold?s.swapThreshold:s.invertedSwapThreshold,Ln,Tn===a))){var S=Yt(rn);do{S-=m,y=on.children[S]}while(y&&("none"===Mt(y,"display")||y===an))}if(0===m||y===a)return B(!1);Tn=a,Dn=m;var T=a.nextElementSibling,D=!1,x=Vn(sn,i,rn,t,a,n,e,D=1===m);if(!1!==x)return 1!==x&&-1!==x||(D=1===x),Mn=!0,setTimeout($n,30),_(),D&&!T?i.appendChild(rn):a.parentNode.insertBefore(rn,D?T:a),I&&Qt(I,0,k-I.scrollTop),on=rn.parentNode,void 0===v||Ln||(xn=Math.abs(v-Ht(a)[E])),A(),B(!0)}if(i.contains(rn))return B(!1)}return!1}function P(s,l){tn(s,h,vt({evt:e,isOwner:c,axis:o?"vertical":"horizontal",revert:r,dragRect:t,targetRect:n,canSort:d,fromSortable:f,target:a,completed:B,onMove:function(n,r){return Vn(sn,i,rn,t,n,Ht(n),e,r)},changed:A},l))}function _(){P("dragOverAnimationCapture"),h.captureAnimationState(),h!==f&&f.captureAnimationState()}function B(t){return P("dragOverCompleted",{insertion:t}),t&&(c?u._hideClone():u._showClone(h),h!==f&&(Ot(rn,vn?vn.options.ghostClass:u.options.ghostClass,!1),Ot(rn,s.ghostClass,!0)),vn!==h&&h!==Qn.active?vn=h:h===Qn.active&&vn&&(vn=null),f===h&&(h._ignoreWhileAnimating=a),h.animateAll((function(){P("dragOverAnimationComplete"),h._ignoreWhileAnimating=null})),h!==f&&(f.animateAll(),f._ignoreWhileAnimating=null)),(a===rn&&!rn.animated||a===i&&!a.animated)&&(Tn=null),s.dragoverBubble||e.rootEl||a===document||(rn.parentNode[Jt]._isOutsideThisEl(e.target),!t&&zn(e)),!s.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),p=!0}function A(){hn=Yt(rn),gn=Yt(rn,s.draggable),nn({sortable:h,name:"change",toEl:i,newIndex:hn,newDraggableIndex:gn,originalEvent:e})}},_ignoreWhileAnimating:null,_offMoveEvents:function(){Pt(document,"mousemove",this._onTouchMove),Pt(document,"touchmove",this._onTouchMove),Pt(document,"pointermove",this._onTouchMove),Pt(document,"dragover",zn),Pt(document,"mousemove",zn),Pt(document,"touchmove",zn)},_offUpEvents:function(){var e=this.el.ownerDocument;Pt(e,"mouseup",this._onDrop),Pt(e,"touchend",this._onDrop),Pt(e,"pointerup",this._onDrop),Pt(e,"touchcancel",this._onDrop),Pt(document,"selectstart",this)},_onDrop:function(e){var t=this.el,n=this.options;hn=Yt(rn),gn=Yt(rn,n.draggable),tn("drop",this,{evt:e}),on=rn&&rn.parentNode,hn=Yt(rn),gn=Yt(rn,n.draggable),Qn.eventCanceled||(_n=!1,Ln=!1,Cn=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),er(this.cloneId),er(this._dragStartId),this.nativeDraggable&&(Pt(document,"drop",this),Pt(t,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),kt&&Mt(document.body,"user-select",""),Mt(rn,"transform",""),e&&(Sn&&(e.cancelable&&e.preventDefault(),!n.dropBubble&&e.stopPropagation()),an&&an.parentNode&&an.parentNode.removeChild(an),(sn===on||vn&&"clone"!==vn.lastPutMode)&&cn&&cn.parentNode&&cn.parentNode.removeChild(cn),rn&&(this.nativeDraggable&&Pt(rn,"dragend",this),Jn(rn),rn.style["will-change"]="",Sn&&!_n&&Ot(rn,vn?vn.options.ghostClass:this.options.ghostClass,!1),Ot(rn,this.options.chosenClass,!1),nn({sortable:this,name:"unchoose",toEl:on,newIndex:null,newDraggableIndex:null,originalEvent:e}),sn!==on?(hn>=0&&(nn({rootEl:on,name:"add",toEl:on,fromEl:sn,originalEvent:e}),nn({sortable:this,name:"remove",toEl:on,originalEvent:e}),nn({rootEl:on,name:"sort",toEl:on,fromEl:sn,originalEvent:e}),nn({sortable:this,name:"sort",toEl:on,originalEvent:e})),vn&&vn.save()):hn!==fn&&hn>=0&&(nn({sortable:this,name:"update",toEl:on,originalEvent:e}),nn({sortable:this,name:"sort",toEl:on,originalEvent:e})),Qn.active&&(null!=hn&&-1!==hn||(hn=fn,gn=pn),nn({sortable:this,name:"end",toEl:on,originalEvent:e}),this.save())))),this._nulling()},_nulling:function(){tn("nulling",this),sn=rn=on=an=ln=cn=un=dn=yn=bn=Sn=hn=gn=fn=pn=Tn=Dn=vn=mn=Qn.dragged=Qn.ghost=Qn.clone=Qn.active=null,Nn.forEach((function(e){e.checked=!0})),Nn.length=wn=En=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":rn&&(this._onDragOver(e),function(e){e.dataTransfer&&(e.dataTransfer.dropEffect="move");e.cancelable&&e.preventDefault()}(e));break;case"selectstart":e.preventDefault()}},toArray:function(){for(var e,t=[],n=this.el.children,r=0,o=n.length,i=this.options;r Date: Mon, 13 Sep 2021 15:43:54 -0700 Subject: [PATCH 3/4] added form token auth to page editing, updated API --- brain/api/v1/PagesAPI.inc.php | 19 ++++++++++++++++++- brain/views/dash/page-edit.twig | 2 +- public/assets/scripts/dash.min.js | 4 ++-- src/com/actions/PageActions.js | 4 ++++ src/libraries/FipamoAdminAPI.js | 1 + 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/brain/api/v1/PagesAPI.inc.php b/brain/api/v1/PagesAPI.inc.php index 76f3d63..4ea4a30 100644 --- a/brain/api/v1/PagesAPI.inc.php +++ b/brain/api/v1/PagesAPI.inc.php @@ -104,7 +104,24 @@ class PagesAPI case "delete": case "create": case "write": - $result = (new Book("../content/pages"))->editPage($task, $request); + $body = $request->getParsedBody(); + if (!isset($body["form_token"])) { + $result = [ + "message" => "No form token. Not good, sport.", + "type" => "TASK_FORM_AUTH", + ]; + } else { + if ($body["form_token"] == Session::get("form_token")) { + //TODO: Verify form fields + $result = (new Book("../content/pages"))->editPage($task, $request); + } else { + $result = [ + "message" => "Form token, auth failed. Uh oh.", + "type" => "TASK_FORM_AUTH", + ]; + } + } + break; case "add-entry-image": $result = ImagesAPI::uploadImage($request); diff --git a/brain/views/dash/page-edit.twig b/brain/views/dash/page-edit.twig index d435552..df9c483 100644 --- a/brain/views/dash/page-edit.twig +++ b/brain/views/dash/page-edit.twig @@ -78,7 +78,7 @@ {% endapply %} - + diff --git a/public/assets/scripts/dash.min.js b/public/assets/scripts/dash.min.js index bdcbf6d..bf4858c 100644 --- a/public/assets/scripts/dash.min.js +++ b/public/assets/scripts/dash.min.js @@ -1,5 +1,5 @@ -!function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:null;e(this,t),this.percentComplete=0,this.baseURL=null,this.status=!1,r&&(this.baseURL=r),this._request(this.baseURL?this.baseURL+c:c).then((function(e){e.type===I&&(n.token=e.token)}))}return n(t,[{key:"login",value:function(e){var t=this;return new Promise((function(n,r){t.baseURL?e.remote=!0:e.remote=!1,t.key?e.key=t.key:e.key=null,t._request(t.baseURL?t.baseURL+h:h,"getAuthStatus",s,l,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"sync",value:function(e,t){var n=this;return new Promise((function(r,o){var i="";switch(e){case"syncSite":i="/api/v1/settings/sync";break;case"syncNav":i="/api/v1/settings/nav-sync"}n._request(n.baseURL?n.baseURL+i:i,p,s,l,t).then((function(e){r(e)})).catch((function(e){o(e)}))}))}},{key:"publish",value:function(e){var t=this;return new Promise((function(n,r){t._request(t.baseURL?t.baseURL+d:d,g,s,l,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"pageActions",value:function(e,t){var n,r,o,i=this;switch(e){case m:n="/api/v1/page/create",r=m,o=u;break;case v:n="/api/v1/page/write",r=v,o=u;break;case y:n="/api/v1/page/delete",r=y,o=l}return this.baseURL?t.remote=!0:t.remote=!1,new Promise((function(e,a){i._request(i.baseURL?i.baseURL+n:n,r,s,o,t).then((function(t){e(t)})).catch((function(e){a(e)}))}))}},{key:"sendMail",value:function(e){var t=this;return new Promise((function(n,r){t._request(t.baseURL?t.baseURL+f:f,"sendMail",s,l,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"getInfo",value:function(e){var t,n,r=this;return"site"==e?(t="/api/v1/settings/site",n=w):(t="/api/v1/settings/member",n=E),new Promise((function(e,o){r._request(r.baseURL?r.baseURL+t:t,n).then((function(t){e(t)})).catch((function(e){o(e)}))}))}},{key:"_request",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"GET",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:l,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,i=this;return new Promise((function(a,c){var d=new XMLHttpRequest;if(d.upload.onprogress=i.handleLoadProgress,d.open(n,e,!0),d.onload=function(){if(200==d.status){var e=JSON.parse(d.response);a(e)}else{var t=JSON.parse(d.response);c(t)}},"PUT"==n||n==s)switch(t!==p&&t!==v&&t!==m&&t!==y&&t!==g&&t!==b||d.setRequestHeader("fipamo-access-token",i.token),r){case l:d.setRequestHeader("Content-type","application/"+r),d.send(JSON.stringify(o));break;case u:d.send(o)}else t!==w&&t!==E||d.setRequestHeader("fipamo-access-token",i.token),d.send()}))}},{key:"handleLoadProgress",value:function(e){this.percentComplete=Math.ceil(e.loaded/e.total*100)}}]),t}(),S="POST",T="json",D="x-www-form-urlencoded",x="/api/v1/status",P="apiUseAuthorized",_=function(){function t(){var n=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;e(this,t),this.percentComplete=0,this.token=null,this.baseURL=null,this.key=null,o&&(this.key=o),r&&(this.baseURL=r),this._request(this.baseURL?this.baseURL+x+"?key="+this.key:x+"?key="+this.key).then((function(e){e.type===P&&(n.token=e.token)}))}return n(t,[{key:"create",value:function(e){var t=this;return new Promise((function(n,r){t._request("/api/v1/init","blogInit",S,T,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"restore",value:function(e){var t=this;return new Promise((function(n,r){var o;o=new FormData(e),t._request("/api/v1/restore","restoreBackup","POST","x-www-form-urlencoded",o).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"backup",value:function(){var e=this;return new Promise((function(t,n){var r;r={task:"create_backup"},e._request("/api/v1/backup","createBackup","POST","json",r).then((function(e){t(e)})).catch((function(e){n(e)}))}))}},{key:"secret",value:function(e){var t=this;return new Promise((function(n,r){t._request("/api/v1/get-secret","retrieveSecret",S,T,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"newPass",value:function(e){var t=this;return new Promise((function(n,r){t._request("/api/v1/reset-password","resetPassword",S,T,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"imageUpload",value:function(e,t){var n=this;return new Promise((function(r,o){var i="";switch(e){case"avatar-upload":i="/api/v1/settings/add-avatar";break;case"background-upload":i="/api/v1/settings/add-feature-background";break;default:i="/api/v1/page/add-entry-image"}var a=new FormData;n.baseURL?(a.append("key",n.key),a.append("remote",!0)):a.append("remote",!1);for(var s=0;s2&&void 0!==arguments[2]?arguments[2]:"GET",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:T,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,i=this;return new Promise((function(t,a){var s=new XMLHttpRequest;if(s.upload.onprogress=i.handleLoadProgress,s.open(n,e,!0),s.onload=function(){if(200==s.status){var e=JSON.parse(s.response);t(e)}else{var n=JSON.parse(s.response);a(n)}},"PUT"==n||n==S)switch(r){case T:s.setRequestHeader("Content-type","application/"+r),s.send(JSON.stringify(o));break;case D:s.send(o)}else s.send()}))}},{key:"handleLoadProgress",value:function(e){this.percentComplete=Math.ceil(e.loaded/e.total*100)}}]),t}(),B=function(){function t(){e(this,t)}return n(t,[{key:"imgLoad",value:function(e){return new Promise((function(t,n){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){200===r.status?t(r.response):n(new Error("Image didn't load successfully; error code:"+r.statusText))},r.onerror=function(){n(new Error("There was a network error."))},r.send()}))}},{key:"loadImage",value:function(e){var t=this;return new Promise((function(n,r){(new Image).crossOrigin="",t.imgLoad(e).then((function(e){var t=window.URL.createObjectURL(e);n(t)}),(function(e){r(e)}))}))}},{key:"formDataToJSON",value:function(e){var t={};return new FormData(e).forEach((function(e,n){t.hasOwnProperty(n)?(Array.isArray(t[n])||(t[n]=[t[n]]),t[n].push(e)):t[n]=e})),t}}]),t}(),A="requestLame",C="postUpdated";new function t(){e(this,t)};var L=function(){function t(){e(this,t)}return n(t,[{key:"cleanString",value:function(e){return e.replace(/(^\-+|[^a-zA-Z0-9\/_| -]+|\-+$)/g,"").toLowerCase().replace(/[\/_| -]+/g,"-")}},{key:"decodeHTML",value:function(e,t){var n=0,r=0,o=!1;void 0===t&&(t=2),e=e.toString().replace(/</g,"<").replace(/>/g,">");var i={ENT_NOQUOTES:0,ENT_HTML_QUOTE_SINGLE:1,ENT_HTML_QUOTE_DOUBLE:2,ENT_COMPAT:2,ENT_QUOTES:3,ENT_IGNORE:4};if(0===t&&(o=!0),"number"!=typeof t){for(t=[].concat(t),r=0;r]*>/g,"\n"),r.append("id",document.getElementById("post-edit-index").getAttribute("data-index")),r.append("uuid",document.getElementById("post-edit-index").getAttribute("data-uuid")),r.append("layout",document.getElementById("post-edit-index").getAttribute("data-layout")),r.append("current_title",document.getElementById("post-edit-index").getAttribute("data-slug")),r.append("content",i),r.append("title",document.getElementById("post_title").value),r.append("created",document.getElementById("post-date").getAttribute("data-raw")),r.append("slug",(new L).cleanString(document.getElementById("post_title").value)),r.append("tags",document.getElementById("post_tags").value),r.append("menu",document.getElementById("option-menu-pin").getAttribute("data-active")),r.append("featured",document.getElementById("option-feature").getAttribute("data-active")),r.append("published",document.getElementById("option-published").getAttribute("data-active")),null!=e||null!=e)e.type.match("image.*")?r.append("feature_image",e,e.name):n("Not an image file");else if(document.getElementById("featured-image")){var a=document.getElementById("featured-image").src;null!=a||null!=a?r.append("feature_image",a):r.append("feature_image",null)}t(r)}))}}]),t}(),M="editorDelete",N="editorUploadImage",R="editorSave",U="editorUpdate";new function t(){e(this,t)};var H=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopStyle","borderRightStyle","borderBottomStyle","borderLeftStyle","borderTopWidth","boxSizing","fontFamily","fontSize","fontWeight","height","letterSpacing","lineHeight","marginBottom","marginLeft","marginRight","marginTop","outlineWidth","overflow","overflowX","overflowY","paddingBottom","paddingLeft","paddingRight","paddingTop","textAlign","textOverflow","textTransform","whiteSpace","wordBreak","wordWrap"],F=function(e,t){var n=document.createElement("div");return function(t){var r=function(){var t={position:"absolute",left:-9999,top:0,zIndex:-2e3};return"TEXTAREA"===e.tagName&&H.push("width"),H.forEach((function(n){t[n]=getComputedStyle(e)[n]})),t}();Object.keys(r).forEach((function(e){n.style[e]=r[e]})),n.innerHTML=t,e.parentNode.insertBefore(n,e.nextSibling)}(t),{rect:function(){var e=n.ownerDocument.getElementById("caret-position-marker"),t={left:e.offsetLeft,top:e.offsetTop,height:e.offsetHeight};return n.parentNode.removeChild(n),t}}};function X(e){return(X="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var q=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.customPos,n=e.iframe,r=e.noShadowCaret;return n?{iframe:n,window:n.contentWindow,document:n.contentDocument||n.contentWindow.document,noShadowCaret:r,customPos:t}:{window:window,document:document,noShadowCaret:r,customPos:t}},Y=function(e){return"object"===X(e)&&null!==e},j=function(e,t){var n=function(){return e.selectionStart},r=function(r){var o=function(e){return e.replace(/<|>|`|"|&/g,"?").replace(/\r\n|\r|\n/g,"
")};(t.customPos||0===t.customPos)&&(r=t.customPos);var i=void 0===r?n():r,a=e.value.slice(0,i),s=e.value.slice(i),l=''.concat(o(a),"");l+='|',l+=''.concat(o(s),"");var u=F(e,l).rect();return u.pos=n(),u};return{getPos:n,setPos:function(t){return e.setSelectionRange(t,t),e},getOffset:function(n){var o=function(e,t){var n=t&&t.window||window,r=t&&t.document||document,o=e.getBoundingClientRect(),i=r.documentElement,a=n.pageXOffset||i.scrollLeft,s=n.pageYOffset||i.scrollTop;return{top:o.top+s,left:o.left+a}}(e),i=r(n);return{top:o.top+i.top+t.document.body.scrollTop,left:o.left+i.left+t.document.body.scrollLeft,height:i.height}},getPosition:r}},W=function(e,t){return function(e){return!!(e.contentEditable?"true"===e.contentEditable:"true"===e.getAttribute("contenteditable"))}(e)?function(e,t){var n=function(){var n=r(),o={height:0,left:0,right:0};if(!n)return o;var i=t.customPos||0===t.customPos;if(n.endOffset-1>0&&n.endContainer!==e||i){var a=n.cloneRange(),s=i?t.customPos:n.endOffset;a.setStart(n.endContainer,s-1<0?0:s-1),a.setEnd(n.endContainer,s);var l=a.getBoundingClientRect();o={height:l.height,left:l.left+l.width,top:l.top},a.detach()}if((!o||o&&0===o.height)&&!t.noShadowCaret){var u=n.cloneRange(),c=t.document.createTextNode("|");u.insertNode(c),u.selectNode(c);var d=u.getBoundingClientRect();o={height:d.height,left:d.left,top:d.top},c.parentNode.removeChild(c),u.detach()}if(o){var f=t.document.documentElement;o.top+=t.window.pageYOffset-(f.clientTop||0),o.left+=t.window.pageXOffset-(f.clientLeft||0)}return o},r=function(){if(t.window.getSelection){var e=t.window.getSelection();return e.rangeCount>0?e.getRangeAt(0):null}},o=function(){var t=r(),n=t.cloneRange();n.selectNodeContents(e),n.setEnd(t.endContainer,t.endOffset);var o=n.toString().length;return n.detach(),o};return{getPos:o,setPos:function(n){var r=t.window.getSelection();if(r){var o=0,i=!1;!function e(a,s){for(var l=0;l=a){i=!0;var c=t.document.createRange();c.setStart(u,a-o),r.removeAllRanges(),r.addRange(c);break}o+=u.length}else e(n,u)}}(n,e)}return e},getPosition:function(){var r=n(),i=o(),a=e.getBoundingClientRect(),s=a.top+t.document.body.scrollTop,l=a.left+t.document.body.scrollLeft;return r.left-=l,r.top-=s,r.pos=i,r},getOffset:n,getRange:r}}(e,t):j(e,t)},z=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n;Y(t)&&(r=t,t=null);var o=q(r),i=W(e,o);return t||0===t?i.setPos(t):i.getPosition()},G=function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(i,t);var r=a(i);function i(t,n){var o;return e(this,i),(o=r.call(this)).textEditor=t,o.fixLimit=n,o.caretPos=null,o.url="",o.setInputs(),window.addEventListener("scroll",(function(){})),o.refresh(),o}return n(i,[{key:"setInputs",value:function(){for(var e=this,t=this,n=document.querySelectorAll(".editor-button"),r=0,o=n.length;r/g)>-1){var o=z(e.textEditor).pos;t.refresh(),z(e.textEditor,o)}}))}},{key:"refresh",value:function(){var e=this.textEditor.innerText;e=e.replace(new RegExp("\r?\n","g"),"
");var t=document.createElement("div");t.innerText=e,this.textEditor.innerHTML=t.innerText,this.textEditor.style.maxWidth="900px"}},{key:"notify",value:function(e,t){switch(e){case C:document.getElementById("submit-update").classList.add("icon-hide"),document.getElementById("submit-good").classList.remove("icon-hide"),document.getElementById("edit-update").classList.remove("submit-start"),document.getElementById("edit-update").classList.add("submit-cool"),setTimeout((function(){document.getElementById("submit-update").classList.remove("icon-hide"),document.getElementById("submit-good").classList.add("icon-hide"),document.getElementById("edit-update").classList.add("submit-start"),document.getElementById("edit-update").classList.remove("submit-cool")}),2e3);break;case"postAdded":break;case N:var n,r;z(this.textEditor,this.caretPos),(n=window.getSelection()).rangeCount&&((r=n.getRangeAt(0)).deleteContents(),r.insertNode(document.createTextNode("![image alt text]("+t+" 'image title')"))),this.refresh()}}},{key:"handleEditorOption",value:function(e){var t,n,r;if(e.preventDefault(),(t=window.getSelection()).rangeCount)switch(n=t.getRangeAt(0),r=t.getRangeAt(0).toString(),n.deleteContents(),e.target.id){case"edit-bold":n.insertNode(document.createTextNode("**"+r+"**"));break;case"edit-italic":n.insertNode(document.createTextNode("*"+r+"*"));break;case"edit-strikethrough":n.insertNode(document.createTextNode(""+r+""));break;case"edit-header1":n.insertNode(document.createTextNode("# "+r));break;case"edit-header2":n.insertNode(document.createTextNode("## "+r));break;case"edit-header3":n.insertNode(document.createTextNode("### "+r));break;case"edit-image":this.caretPos=z(this.textEditor).pos,this.emitEvent(N);break;case"submit-save":case"edit-save":this.emitEvent(R);break;case"submit-update":case"edit-update":this.emitEvent(U);break;case"edit-link":n.insertNode(document.createTextNode("["+r+"](PASTE URL HERE)"));break;case"edit-delete":this.emitEvent(M)}this.refresh()}}]),i}(function(){function t(){e(this,t),this.listeners=new Map}return n(t,[{key:"addListener",value:function(e,t){this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t)}},{key:"removeListener",value:function(e,t){var n,r=this.listeners.get(e);return!!(r&&r.length&&(n=r.reduce((function(e,n,r){return"function"==typeof n&&n===t?e=r:e}),-1))>-1)&&(r.splice(n,1),this.listeners.set(e,r),!0)}},{key:"emitEvent",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r-1}function ee(e,t){return e.apply(null,t)}var te={arr:function(e){return Array.isArray(e)},obj:function(e){return K(Object.prototype.toString.call(e),"Object")},pth:function(e){return te.obj(e)&&e.hasOwnProperty("totalLength")},svg:function(e){return e instanceof SVGElement},inp:function(e){return e instanceof HTMLInputElement},dom:function(e){return e.nodeType||te.svg(e)},str:function(e){return"string"==typeof e},fnc:function(e){return"function"==typeof e},und:function(e){return void 0===e},nil:function(e){return te.und(e)||null===e},hex:function(e){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)},rgb:function(e){return/^rgb/.test(e)},hsl:function(e){return/^hsl/.test(e)},col:function(e){return te.hex(e)||te.rgb(e)||te.hsl(e)},key:function(e){return!Q.hasOwnProperty(e)&&!V.hasOwnProperty(e)&&"targets"!==e&&"keyframes"!==e}};function ne(e){var t=/\(([^)]+)\)/.exec(e);return t?t[1].split(",").map((function(e){return parseFloat(e)})):[]}function re(e,t){var n=ne(e),r=Z(te.und(n[0])?1:n[0],.1,100),o=Z(te.und(n[1])?100:n[1],.1,100),i=Z(te.und(n[2])?10:n[2],.1,100),a=Z(te.und(n[3])?0:n[3],.1,100),s=Math.sqrt(o/r),l=i/(2*Math.sqrt(o*r)),u=l<1?s*Math.sqrt(1-l*l):0,c=l<1?(l*s-a)/u:-a+s;function d(e){var n=t?t*e/1e3:e;return n=l<1?Math.exp(-n*l*s)*(1*Math.cos(u*n)+c*Math.sin(u*n)):(1+c*n)*Math.exp(-n*s),0===e||1===e?e:1-n}return t?d:function(){var t=$.springs[e];if(t)return t;for(var n=1/6,r=0,o=0;;)if(1===d(r+=n)){if(++o>=16)break}else o=0;var i=r*n*1e3;return $.springs[e]=i,i}}function oe(e){return void 0===e&&(e=10),function(t){return Math.ceil(Z(t,1e-6,1)*e)*(1/e)}}var ie,ae,se=function(){var e=.1;function t(e,t){return 1-3*t+3*e}function n(e,t){return 3*t-6*e}function r(e){return 3*e}function o(e,o,i){return((t(o,i)*e+n(o,i))*e+r(o))*e}function i(e,o,i){return 3*t(o,i)*e*e+2*n(o,i)*e+r(o)}return function(t,n,r,a){if(0<=t&&t<=1&&0<=r&&r<=1){var s=new Float32Array(11);if(t!==n||r!==a)for(var l=0;l<11;++l)s[l]=o(l*e,t,r);return function(e){return t===n&&r===a||0===e||1===e?e:o(u(e),n,a)}}function u(n){for(var a=0,l=1;10!==l&&s[l]<=n;++l)a+=e;--l;var u=a+(n-s[l])/(s[l+1]-s[l])*e,c=i(u,t,r);return c>=.001?function(e,t,n,r){for(var a=0;a<4;++a){var s=i(t,n,r);if(0===s)return t;t-=(o(t,n,r)-e)/s}return t}(n,u,t,r):0===c?u:function(e,t,n,r,i){var a,s,l=0;do{(a=o(s=t+(n-t)/2,r,i)-e)>0?n=s:t=s}while(Math.abs(a)>1e-7&&++l<10);return s}(n,a,a+e,t,r)}}}(),le=(ie={linear:function(){return function(e){return e}}},ae={Sine:function(){return function(e){return 1-Math.cos(e*Math.PI/2)}},Circ:function(){return function(e){return 1-Math.sqrt(1-e*e)}},Back:function(){return function(e){return e*e*(3*e-2)}},Bounce:function(){return function(e){for(var t,n=4;e<((t=Math.pow(2,--n))-1)/11;);return 1/Math.pow(4,3-n)-7.5625*Math.pow((3*t-2)/22-e,2)}},Elastic:function(e,t){void 0===e&&(e=1),void 0===t&&(t=.5);var n=Z(e,1,10),r=Z(t,.1,2);return function(e){return 0===e||1===e?e:-n*Math.pow(2,10*(e-1))*Math.sin((e-1-r/(2*Math.PI)*Math.asin(1/n))*(2*Math.PI)/r)}}},["Quad","Cubic","Quart","Quint","Expo"].forEach((function(e,t){ae[e]=function(){return function(e){return Math.pow(e,t+2)}}})),Object.keys(ae).forEach((function(e){var t=ae[e];ie["easeIn"+e]=t,ie["easeOut"+e]=function(e,n){return function(r){return 1-t(e,n)(1-r)}},ie["easeInOut"+e]=function(e,n){return function(r){return r<.5?t(e,n)(2*r)/2:1-t(e,n)(-2*r+2)/2}},ie["easeOutIn"+e]=function(e,n){return function(r){return r<.5?(1-t(e,n)(1-2*r))/2:(t(e,n)(2*r-1)+1)/2}}})),ie);function ue(e,t){if(te.fnc(e))return e;var n=e.split("(")[0],r=le[n],o=ne(e);switch(n){case"spring":return re(e,t);case"cubicBezier":return ee(se,o);case"steps":return ee(oe,o);default:return ee(r,o)}}function ce(e){try{return document.querySelectorAll(e)}catch(e){return}}function de(e,t){for(var n=e.length,r=arguments.length>=2?t:void 0,o=[],i=0;i1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}if(0==a)t=n=r=s;else{var c=s<.5?s*(1+a):s+a-s*a,d=2*s-c;t=u(d,c,i+1/3),n=u(d,c,i),r=u(d,c,i-1/3)}return"rgba("+255*t+","+255*n+","+255*r+","+l+")"}(e):void 0;var t,n}function be(e){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(e);if(t)return t[1]}function we(e,t){return te.fnc(e)?e(t.target,t.id,t.total):e}function Ee(e,t){return e.getAttribute(t)}function Ie(e,t,n){if(pe([n,"deg","rad","turn"],be(t)))return t;var r=$.CSS[t+n];if(!te.und(r))return r;var o=document.createElement(e.tagName),i=e.parentNode&&e.parentNode!==document?e.parentNode:document.body;i.appendChild(o),o.style.position="absolute",o.style.width=100+n;var a=100/o.offsetWidth;i.removeChild(o);var s=a*parseFloat(t);return $.CSS[t+n]=s,s}function ke(e,t,n){if(t in e.style){var r=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),o=e.style[t]||getComputedStyle(e).getPropertyValue(r)||"0";return n?Ie(e,o,n):o}}function Se(e,t){return te.dom(e)&&!te.inp(e)&&(!te.nil(Ee(e,t))||te.svg(e)&&e[t])?"attribute":te.dom(e)&&pe(J,t)?"transform":te.dom(e)&&"transform"!==t&&ke(e,t)?"css":null!=e[t]?"object":void 0}function Te(e){if(te.dom(e)){for(var t,n=e.style.transform||"",r=/(\w+)\(([^)]*)\)/g,o=new Map;t=r.exec(n);)o.set(t[1],t[2]);return o}}function De(e,t,n,r){var o=K(t,"scale")?1:0+function(e){return K(e,"translate")||"perspective"===e?"px":K(e,"rotate")||K(e,"skew")?"deg":void 0}(t),i=Te(e).get(t)||o;return n&&(n.transforms.list.set(t,i),n.transforms.last=t),r?Ie(e,i,r):i}function xe(e,t,n,r){switch(Se(e,t)){case"transform":return De(e,t,r,n);case"css":return ke(e,t,n);case"attribute":return Ee(e,t);default:return e[t]||0}}function Pe(e,t){var n=/^(\*=|\+=|-=)/.exec(e);if(!n)return e;var r=be(e)||0,o=parseFloat(t),i=parseFloat(e.replace(n[0],""));switch(n[0][0]){case"+":return o+i+r;case"-":return o-i+r;case"*":return o*i+r}}function _e(e,t){if(te.col(e))return ye(e);if(/\s/g.test(e))return e;var n=be(e),r=n?e.substr(0,e.length-n.length):e;return t?r+t:r}function Be(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function Ae(e){for(var t,n=e.points,r=0,o=0;o0&&(r+=Be(t,i)),t=i}return r}function Ce(e){if(e.getTotalLength)return e.getTotalLength();switch(e.tagName.toLowerCase()){case"circle":return function(e){return 2*Math.PI*Ee(e,"r")}(e);case"rect":return function(e){return 2*Ee(e,"width")+2*Ee(e,"height")}(e);case"line":return function(e){return Be({x:Ee(e,"x1"),y:Ee(e,"y1")},{x:Ee(e,"x2"),y:Ee(e,"y2")})}(e);case"polyline":return Ae(e);case"polygon":return function(e){var t=e.points;return Ae(e)+Be(t.getItem(t.numberOfItems-1),t.getItem(0))}(e)}}function Le(e,t){var n=t||{},r=n.el||function(e){for(var t=e.parentNode;te.svg(t)&&te.svg(t.parentNode);)t=t.parentNode;return t}(e),o=r.getBoundingClientRect(),i=Ee(r,"viewBox"),a=o.width,s=o.height,l=n.viewBox||(i?i.split(" "):[0,0,a,s]);return{el:r,viewBox:l,x:l[0]/1,y:l[1]/1,w:a,h:s,vW:l[2],vH:l[3]}}function Oe(e,t,n){function r(n){void 0===n&&(n=0);var r=t+n>=1?t+n:0;return e.el.getPointAtLength(r)}var o=Le(e.el,e.svg),i=r(),a=r(-1),s=r(1),l=n?1:o.w/o.vW,u=n?1:o.h/o.vH;switch(e.property){case"x":return(i.x-o.x)*l;case"y":return(i.y-o.y)*u;case"angle":return 180*Math.atan2(s.y-a.y,s.x-a.x)/Math.PI}}function Me(e,t){var n=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=_e(te.pth(e)?e.totalLength:e,t)+"";return{original:r,numbers:r.match(n)?r.match(n).map(Number):[0],strings:te.str(e)||t?r.split(n):[]}}function Ne(e){return de(e?fe(te.arr(e)?e.map(he):he(e)):[],(function(e,t,n){return n.indexOf(e)===t}))}function Re(e){var t=Ne(e);return t.map((function(e,n){return{target:e,id:n,total:t.length,transforms:{list:Te(e)}}}))}function Ue(e,t){var n=ge(t);if(/^spring/.test(n.easing)&&(n.duration=re(n.easing)),te.arr(e)){var r=e.length;2===r&&!te.obj(e[0])?e={value:e}:te.fnc(t.duration)||(n.duration=t.duration/r)}var o=te.arr(e)?e:[e];return o.map((function(e,n){var r=te.obj(e)&&!te.pth(e)?e:{value:e};return te.und(r.delay)&&(r.delay=n?0:t.delay),te.und(r.endDelay)&&(r.endDelay=n===o.length-1?t.endDelay:0),r})).map((function(e){return ve(e,n)}))}function He(e,t){var n=[],r=t.keyframes;for(var o in r&&(t=ve(function(e){for(var t=de(fe(e.map((function(e){return Object.keys(e)}))),(function(e){return te.key(e)})).reduce((function(e,t){return e.indexOf(t)<0&&e.push(t),e}),[]),n={},r=function(r){var o=t[r];n[o]=e.map((function(e){var t={};for(var n in e)te.key(n)?n==o&&(t.value=e[n]):t[n]=e[n];return t}))},o=0;o0?requestAnimationFrame(t):void 0}return"undefined"!=typeof document&&document.addEventListener("visibilitychange",(function(){Ve.suspendWhenDocumentHidden&&(Qe()?e=cancelAnimationFrame(e):(ze.forEach((function(e){return e._onDocumentVisibility()})),Ge()))})),function(){e||Qe()&&Ve.suspendWhenDocumentHidden||!(ze.length>0)||(e=requestAnimationFrame(t))}}();function Qe(){return!!document&&document.hidden}function Ve(e){void 0===e&&(e={});var t,n=0,r=0,o=0,i=0,a=null;function s(e){var t=window.Promise&&new Promise((function(e){return a=e}));return e.finished=t,t}var l=function(e){var t=me(Q,e),n=me(V,e),r=He(n,e),o=Re(e.targets),i=Ye(o,r),a=je(i,n),s=We;return We++,ve(t,{id:s,children:[],animatables:o,animations:i,duration:a.duration,delay:a.delay,endDelay:a.endDelay})}(e);function u(){var e=l.direction;"alternate"!==e&&(l.direction="normal"!==e?"normal":"reverse"),l.reversed=!l.reversed,t.forEach((function(e){return e.reversed=l.reversed}))}function c(e){return l.reversed?l.duration-e:e}function d(){n=0,r=c(l.currentTime)*(1/Ve.speed)}function f(e,t){t&&t.seek(e-t.timelineOffset)}function h(e){for(var t=0,n=l.animations,r=n.length;t2||(y=Math.round(y*h)/h)),p.push(y)}var E=f.length;if(E){m=f[0];for(var I=0;I0&&(l.began=!0,p("begin")),!l.loopBegan&&l.currentTime>0&&(l.loopBegan=!0,p("loopBegin")),v<=g&&0!==l.currentTime&&h(0),(v>=m&&l.currentTime!==d||!d)&&h(d),v>g&&v=d&&(r=0,l.remaining&&!0!==l.remaining&&l.remaining--,l.remaining?(n=o,p("loopComplete"),l.loopBegan=!1,"alternate"===l.direction&&u()):(l.paused=!0,l.completed||(l.completed=!0,p("loopComplete"),p("complete"),!l.passThrough&&"Promise"in window&&(a(),s(l)))))}return s(l),l.reset=function(){var e=l.direction;l.passThrough=!1,l.currentTime=0,l.progress=0,l.paused=!0,l.began=!1,l.loopBegan=!1,l.changeBegan=!1,l.completed=!1,l.changeCompleted=!1,l.reversePlayback=!1,l.reversed="reverse"===e,l.remaining=l.loop,t=l.children;for(var n=i=t.length;n--;)l.children[n].reset();(l.reversed&&!0!==l.loop||"alternate"===e&&1===l.loop)&&l.remaining++,h(l.reversed?l.duration:0)},l._onDocumentVisibility=d,l.set=function(e,t){return qe(e,t),l},l.tick=function(e){o=e,n||(n=o),g((o+(r-n))*Ve.speed)},l.seek=function(e){g(c(e))},l.pause=function(){l.paused=!0,d()},l.play=function(){l.paused&&(l.completed&&l.reset(),l.paused=!1,ze.push(l),d(),Ge())},l.reverse=function(){u(),l.completed=!l.reversed,d()},l.restart=function(){l.reset(),l.play()},l.remove=function(e){$e(Ne(e),l)},l.reset(),l.autoplay&&l.play(),l}function Je(e,t){for(var n=t.length;n--;)pe(e,t[n].animatable.target)&&t.splice(n,1)}function $e(e,t){var n=t.animations,r=t.children;Je(e,n);for(var o=r.length;o--;){var i=r[o],a=i.animations;Je(e,a),a.length||i.children.length||r.splice(o,1)}n.length||r.length||t.pause()}Ve.version="3.2.1",Ve.speed=1,Ve.suspendWhenDocumentHidden=!0,Ve.running=ze,Ve.remove=function(e){for(var t=Ne(e),n=ze.length;n--;){$e(t,ze[n])}},Ve.get=xe,Ve.set=qe,Ve.convertPx=Ie,Ve.path=function(e,t){var n=te.str(e)?ce(e)[0]:e,r=t||100;return function(e){return{property:e,el:n,svg:Le(n),totalLength:Ce(n)*(r/100)}}},Ve.setDashoffset=function(e){var t=Ce(e);return e.setAttribute("stroke-dasharray",t),t},Ve.stagger=function(e,t){void 0===t&&(t={});var n=t.direction||"normal",r=t.easing?ue(t.easing):null,o=t.grid,i=t.axis,a=t.from||0,s="first"===a,l="center"===a,u="last"===a,c=te.arr(e),d=c?parseFloat(e[0]):parseFloat(e),f=c?parseFloat(e[1]):0,h=be(c?e[1]:e)||0,p=t.start||0+(c?d:0),g=[],m=0;return function(e,t,v){if(s&&(a=0),l&&(a=(v-1)/2),u&&(a=v-1),!g.length){for(var y=0;y-1&&ze.splice(o,1);for(var s=0;s'].join(""),document.getElementById("featured-image-drop").innerHTML="",document.getElementById("featured-image-drop").appendChild(n)}}(n),o.readAsDataURL(n)}}}},{key:"handleImageUpload",value:function(e,t){var n=this;it.alert("Uploading Image",null),(new _).imageUpload(e,t).then((function(e){"postImageAdded"==e.type&&n.editor.notify(N,e.url),it.alert("Image Added to Entry",!0)})).catch((function(){it.alert("Uh oh. Image not added",!1)}))}}]),t}();at.uploadFiles=[];var st=function(){function t(n){e(this,t),this.currentPage=null,this.choosePage(n),this.start()}return n(t,[{key:"start",value:function(){}},{key:"choosePage",value:function(e){switch(this.currentPage="",e){case"edit":case"add":this.currentPage=new at}}}]),t}(),lt=function(){function t(){e(this,t)}return n(t,[{key:"getInfo",value:function(){var e,t,n=document.getElementById("settings-handle").value,r=document.getElementById("settings-email").value,o=document.getElementById("settings-url").value,i=document.getElementById("settings-title").value,a=document.getElementById("settings-desc").value,s=document.getElementById("background").src,l="",u=document.querySelectorAll(".theme-select"),c=document.getElementById("smtp-domain").value,d=document.getElementById("smtp-email").value,f=document.getElementById("smtp-pass").value,h=document.getElementById("mg-domain").value,p=document.getElementById("mg-key").value,g="",m=document.querySelectorAll(".mail-option"),v=document.getElementById("api-access-toggle").getAttribute("data-enabled");for(e=0,t=u.length;e0&&void 0!==arguments[0]?arguments[0]:null;e(this,t),this.percentComplete=0,this.baseURL=null,this.status=!1,r&&(this.baseURL=r),this._request(this.baseURL?this.baseURL+c:c).then((function(e){e.type===I&&(n.token=e.token)}))}return n(t,[{key:"login",value:function(e){var t=this;return new Promise((function(n,r){t.baseURL?e.remote=!0:e.remote=!1,t.key?e.key=t.key:e.key=null,t._request(t.baseURL?t.baseURL+h:h,"getAuthStatus",s,l,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"sync",value:function(e,t){var n=this;return new Promise((function(r,o){var i="";switch(e){case"syncSite":i="/api/v1/settings/sync";break;case"syncNav":i="/api/v1/settings/nav-sync"}n._request(n.baseURL?n.baseURL+i:i,p,s,l,t).then((function(e){r(e)})).catch((function(e){o(e)}))}))}},{key:"publish",value:function(e){var t=this;return new Promise((function(n,r){t._request(t.baseURL?t.baseURL+d:d,g,s,l,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"pageActions",value:function(e,t){var n,r,o,i=this;switch(e){case m:n="/api/v1/page/create",r=m,o=u;break;case v:n="/api/v1/page/write",r=v,o=u;break;case y:n="/api/v1/page/delete",r=y,o=l}return this.baseURL?t.remote=!0:t.remote=!1,new Promise((function(e,a){i._request(i.baseURL?i.baseURL+n:n,r,s,o,t).then((function(t){e(t)})).catch((function(e){a(e)}))}))}},{key:"sendMail",value:function(e){var t=this;return new Promise((function(n,r){t._request(t.baseURL?t.baseURL+f:f,"sendMail",s,l,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"getInfo",value:function(e){var t,n,r=this;return"site"==e?(t="/api/v1/settings/site",n=w):(t="/api/v1/settings/member",n=E),new Promise((function(e,o){r._request(r.baseURL?r.baseURL+t:t,n).then((function(t){e(t)})).catch((function(e){o(e)}))}))}},{key:"_request",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"GET",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:l,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,i=this;return new Promise((function(a,c){var d=new XMLHttpRequest;if(d.upload.onprogress=i.handleLoadProgress,d.open(n,e,!0),d.onload=function(){if(200==d.status){var e=JSON.parse(d.response);a(e)}else{var t=JSON.parse(d.response);c(t)}},"PUT"==n||n==s)switch(t!==p&&t!==v&&t!==m&&t!==y&&t!==g&&t!==b||d.setRequestHeader("fipamo-access-token",i.token),r){case l:d.setRequestHeader("Content-type","application/"+r),d.send(JSON.stringify(o));break;case u:d.send(o)}else t!==w&&t!==E||d.setRequestHeader("fipamo-access-token",i.token),d.send()}))}},{key:"handleLoadProgress",value:function(e){this.percentComplete=Math.ceil(e.loaded/e.total*100)}}]),t}(),S="POST",T="json",D="x-www-form-urlencoded",x="/api/v1/status",P="apiUseAuthorized",_=function(){function t(){var n=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;e(this,t),this.percentComplete=0,this.token=null,this.baseURL=null,this.key=null,o&&(this.key=o),r&&(this.baseURL=r),this._request(this.baseURL?this.baseURL+x+"?key="+this.key:x+"?key="+this.key).then((function(e){e.type===P&&(n.token=e.token)}))}return n(t,[{key:"create",value:function(e){var t=this;return new Promise((function(n,r){t._request("/api/v1/init","blogInit",S,T,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"restore",value:function(e){var t=this;return new Promise((function(n,r){var o;o=new FormData(e),t._request("/api/v1/restore","restoreBackup","POST","x-www-form-urlencoded",o).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"backup",value:function(){var e=this;return new Promise((function(t,n){var r;r={task:"create_backup"},e._request("/api/v1/backup","createBackup","POST","json",r).then((function(e){t(e)})).catch((function(e){n(e)}))}))}},{key:"secret",value:function(e){var t=this;return new Promise((function(n,r){t._request("/api/v1/get-secret","retrieveSecret",S,T,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"newPass",value:function(e){var t=this;return new Promise((function(n,r){t._request("/api/v1/reset-password","resetPassword",S,T,e).then((function(e){n(e)})).catch((function(e){r(e)}))}))}},{key:"imageUpload",value:function(e,t){var n=this;return new Promise((function(r,o){var i="";switch(e){case"avatar-upload":i="/api/v1/settings/add-avatar";break;case"background-upload":i="/api/v1/settings/add-feature-background";break;default:i="/api/v1/page/add-entry-image"}var a=new FormData;n.baseURL?(a.append("key",n.key),a.append("remote",!0)):a.append("remote",!1);for(var s=0;s2&&void 0!==arguments[2]?arguments[2]:"GET",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:T,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,i=this;return new Promise((function(t,a){var s=new XMLHttpRequest;if(s.upload.onprogress=i.handleLoadProgress,s.open(n,e,!0),s.onload=function(){if(200==s.status){var e=JSON.parse(s.response);t(e)}else{var n=JSON.parse(s.response);a(n)}},"PUT"==n||n==S)switch(r){case T:s.setRequestHeader("Content-type","application/"+r),s.send(JSON.stringify(o));break;case D:s.send(o)}else s.send()}))}},{key:"handleLoadProgress",value:function(e){this.percentComplete=Math.ceil(e.loaded/e.total*100)}}]),t}(),B=function(){function t(){e(this,t)}return n(t,[{key:"imgLoad",value:function(e){return new Promise((function(t,n){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){200===r.status?t(r.response):n(new Error("Image didn't load successfully; error code:"+r.statusText))},r.onerror=function(){n(new Error("There was a network error."))},r.send()}))}},{key:"loadImage",value:function(e){var t=this;return new Promise((function(n,r){(new Image).crossOrigin="",t.imgLoad(e).then((function(e){var t=window.URL.createObjectURL(e);n(t)}),(function(e){r(e)}))}))}},{key:"formDataToJSON",value:function(e){var t={};return new FormData(e).forEach((function(e,n){t.hasOwnProperty(n)?(Array.isArray(t[n])||(t[n]=[t[n]]),t[n].push(e)):t[n]=e})),t}}]),t}(),A="requestLame",C="postUpdated";new function t(){e(this,t)};var L=function(){function t(){e(this,t)}return n(t,[{key:"cleanString",value:function(e){return e.replace(/(^\-+|[^a-zA-Z0-9\/_| -]+|\-+$)/g,"").toLowerCase().replace(/[\/_| -]+/g,"-")}},{key:"decodeHTML",value:function(e,t){var n=0,r=0,o=!1;void 0===t&&(t=2),e=e.toString().replace(/</g,"<").replace(/>/g,">");var i={ENT_NOQUOTES:0,ENT_HTML_QUOTE_SINGLE:1,ENT_HTML_QUOTE_DOUBLE:2,ENT_COMPAT:2,ENT_QUOTES:3,ENT_IGNORE:4};if(0===t&&(o=!0),"number"!=typeof t){for(t=[].concat(t),r=0;r]*>/g,"\n"),r.append("id",document.getElementById("post-edit-index").getAttribute("data-index")),r.append("uuid",document.getElementById("post-edit-index").getAttribute("data-uuid")),r.append("layout",document.getElementById("post-edit-index").getAttribute("data-layout")),r.append("current_title",document.getElementById("post-edit-index").getAttribute("data-slug")),r.append("content",i),r.append("title",document.getElementById("post_title").value),r.append("created",document.getElementById("post-date").getAttribute("data-raw")),r.append("slug",(new L).cleanString(document.getElementById("post_title").value)),r.append("tags",document.getElementById("post_tags").value),r.append("menu",document.getElementById("option-menu-pin").getAttribute("data-active")),r.append("featured",document.getElementById("option-feature").getAttribute("data-active")),r.append("published",document.getElementById("option-published").getAttribute("data-active")),r.append("form_token",document.getElementById("form_token").value),null!=e||null!=e)e.type.match("image.*")?r.append("feature_image",e,e.name):n("Not an image file");else if(document.getElementById("featured-image")){var a=document.getElementById("featured-image").src;null!=a||null!=a?r.append("feature_image",a):r.append("feature_image",null)}t(r)}))}}]),t}(),M="editorDelete",N="editorUploadImage",R="editorSave",U="editorUpdate";new function t(){e(this,t)};var H=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopStyle","borderRightStyle","borderBottomStyle","borderLeftStyle","borderTopWidth","boxSizing","fontFamily","fontSize","fontWeight","height","letterSpacing","lineHeight","marginBottom","marginLeft","marginRight","marginTop","outlineWidth","overflow","overflowX","overflowY","paddingBottom","paddingLeft","paddingRight","paddingTop","textAlign","textOverflow","textTransform","whiteSpace","wordBreak","wordWrap"],F=function(e,t){var n=document.createElement("div");return function(t){var r=function(){var t={position:"absolute",left:-9999,top:0,zIndex:-2e3};return"TEXTAREA"===e.tagName&&H.push("width"),H.forEach((function(n){t[n]=getComputedStyle(e)[n]})),t}();Object.keys(r).forEach((function(e){n.style[e]=r[e]})),n.innerHTML=t,e.parentNode.insertBefore(n,e.nextSibling)}(t),{rect:function(){var e=n.ownerDocument.getElementById("caret-position-marker"),t={left:e.offsetLeft,top:e.offsetTop,height:e.offsetHeight};return n.parentNode.removeChild(n),t}}};function X(e){return(X="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var q=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.customPos,n=e.iframe,r=e.noShadowCaret;return n?{iframe:n,window:n.contentWindow,document:n.contentDocument||n.contentWindow.document,noShadowCaret:r,customPos:t}:{window:window,document:document,noShadowCaret:r,customPos:t}},Y=function(e){return"object"===X(e)&&null!==e},j=function(e,t){var n=function(){return e.selectionStart},r=function(r){var o=function(e){return e.replace(/<|>|`|"|&/g,"?").replace(/\r\n|\r|\n/g,"
")};(t.customPos||0===t.customPos)&&(r=t.customPos);var i=void 0===r?n():r,a=e.value.slice(0,i),s=e.value.slice(i),l=''.concat(o(a),"");l+='|',l+=''.concat(o(s),"");var u=F(e,l).rect();return u.pos=n(),u};return{getPos:n,setPos:function(t){return e.setSelectionRange(t,t),e},getOffset:function(n){var o=function(e,t){var n=t&&t.window||window,r=t&&t.document||document,o=e.getBoundingClientRect(),i=r.documentElement,a=n.pageXOffset||i.scrollLeft,s=n.pageYOffset||i.scrollTop;return{top:o.top+s,left:o.left+a}}(e),i=r(n);return{top:o.top+i.top+t.document.body.scrollTop,left:o.left+i.left+t.document.body.scrollLeft,height:i.height}},getPosition:r}},W=function(e,t){return function(e){return!!(e.contentEditable?"true"===e.contentEditable:"true"===e.getAttribute("contenteditable"))}(e)?function(e,t){var n=function(){var n=r(),o={height:0,left:0,right:0};if(!n)return o;var i=t.customPos||0===t.customPos;if(n.endOffset-1>0&&n.endContainer!==e||i){var a=n.cloneRange(),s=i?t.customPos:n.endOffset;a.setStart(n.endContainer,s-1<0?0:s-1),a.setEnd(n.endContainer,s);var l=a.getBoundingClientRect();o={height:l.height,left:l.left+l.width,top:l.top},a.detach()}if((!o||o&&0===o.height)&&!t.noShadowCaret){var u=n.cloneRange(),c=t.document.createTextNode("|");u.insertNode(c),u.selectNode(c);var d=u.getBoundingClientRect();o={height:d.height,left:d.left,top:d.top},c.parentNode.removeChild(c),u.detach()}if(o){var f=t.document.documentElement;o.top+=t.window.pageYOffset-(f.clientTop||0),o.left+=t.window.pageXOffset-(f.clientLeft||0)}return o},r=function(){if(t.window.getSelection){var e=t.window.getSelection();return e.rangeCount>0?e.getRangeAt(0):null}},o=function(){var t=r(),n=t.cloneRange();n.selectNodeContents(e),n.setEnd(t.endContainer,t.endOffset);var o=n.toString().length;return n.detach(),o};return{getPos:o,setPos:function(n){var r=t.window.getSelection();if(r){var o=0,i=!1;!function e(a,s){for(var l=0;l=a){i=!0;var c=t.document.createRange();c.setStart(u,a-o),r.removeAllRanges(),r.addRange(c);break}o+=u.length}else e(n,u)}}(n,e)}return e},getPosition:function(){var r=n(),i=o(),a=e.getBoundingClientRect(),s=a.top+t.document.body.scrollTop,l=a.left+t.document.body.scrollLeft;return r.left-=l,r.top-=s,r.pos=i,r},getOffset:n,getRange:r}}(e,t):j(e,t)},z=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n;Y(t)&&(r=t,t=null);var o=q(r),i=W(e,o);return t||0===t?i.setPos(t):i.getPosition()},G=function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(i,t);var r=a(i);function i(t,n){var o;return e(this,i),(o=r.call(this)).textEditor=t,o.fixLimit=n,o.caretPos=null,o.url="",o.setInputs(),window.addEventListener("scroll",(function(){})),o.refresh(),o}return n(i,[{key:"setInputs",value:function(){for(var e=this,t=this,n=document.querySelectorAll(".editor-button"),r=0,o=n.length;r/g)>-1){var o=z(e.textEditor).pos;t.refresh(),z(e.textEditor,o)}}))}},{key:"refresh",value:function(){var e=this.textEditor.innerText;e=e.replace(new RegExp("\r?\n","g"),"
");var t=document.createElement("div");t.innerText=e,this.textEditor.innerHTML=t.innerText,this.textEditor.style.maxWidth="900px"}},{key:"notify",value:function(e,t){switch(e){case C:document.getElementById("submit-update").classList.add("icon-hide"),document.getElementById("submit-good").classList.remove("icon-hide"),document.getElementById("edit-update").classList.remove("submit-start"),document.getElementById("edit-update").classList.add("submit-cool"),setTimeout((function(){document.getElementById("submit-update").classList.remove("icon-hide"),document.getElementById("submit-good").classList.add("icon-hide"),document.getElementById("edit-update").classList.add("submit-start"),document.getElementById("edit-update").classList.remove("submit-cool")}),2e3);break;case"postAdded":break;case N:var n,r;z(this.textEditor,this.caretPos),(n=window.getSelection()).rangeCount&&((r=n.getRangeAt(0)).deleteContents(),r.insertNode(document.createTextNode("![image alt text]("+t+" 'image title')"))),this.refresh()}}},{key:"handleEditorOption",value:function(e){var t,n,r;if(e.preventDefault(),(t=window.getSelection()).rangeCount)switch(n=t.getRangeAt(0),r=t.getRangeAt(0).toString(),n.deleteContents(),e.target.id){case"edit-bold":n.insertNode(document.createTextNode("**"+r+"**"));break;case"edit-italic":n.insertNode(document.createTextNode("*"+r+"*"));break;case"edit-strikethrough":n.insertNode(document.createTextNode(""+r+""));break;case"edit-header1":n.insertNode(document.createTextNode("# "+r));break;case"edit-header2":n.insertNode(document.createTextNode("## "+r));break;case"edit-header3":n.insertNode(document.createTextNode("### "+r));break;case"edit-image":this.caretPos=z(this.textEditor).pos,this.emitEvent(N);break;case"submit-save":case"edit-save":this.emitEvent(R);break;case"submit-update":case"edit-update":this.emitEvent(U);break;case"edit-link":n.insertNode(document.createTextNode("["+r+"](PASTE URL HERE)"));break;case"edit-delete":this.emitEvent(M)}this.refresh()}}]),i}(function(){function t(){e(this,t),this.listeners=new Map}return n(t,[{key:"addListener",value:function(e,t){this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t)}},{key:"removeListener",value:function(e,t){var n,r=this.listeners.get(e);return!!(r&&r.length&&(n=r.reduce((function(e,n,r){return"function"==typeof n&&n===t?e=r:e}),-1))>-1)&&(r.splice(n,1),this.listeners.set(e,r),!0)}},{key:"emitEvent",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r-1}function ee(e,t){return e.apply(null,t)}var te={arr:function(e){return Array.isArray(e)},obj:function(e){return K(Object.prototype.toString.call(e),"Object")},pth:function(e){return te.obj(e)&&e.hasOwnProperty("totalLength")},svg:function(e){return e instanceof SVGElement},inp:function(e){return e instanceof HTMLInputElement},dom:function(e){return e.nodeType||te.svg(e)},str:function(e){return"string"==typeof e},fnc:function(e){return"function"==typeof e},und:function(e){return void 0===e},nil:function(e){return te.und(e)||null===e},hex:function(e){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)},rgb:function(e){return/^rgb/.test(e)},hsl:function(e){return/^hsl/.test(e)},col:function(e){return te.hex(e)||te.rgb(e)||te.hsl(e)},key:function(e){return!Q.hasOwnProperty(e)&&!V.hasOwnProperty(e)&&"targets"!==e&&"keyframes"!==e}};function ne(e){var t=/\(([^)]+)\)/.exec(e);return t?t[1].split(",").map((function(e){return parseFloat(e)})):[]}function re(e,t){var n=ne(e),r=Z(te.und(n[0])?1:n[0],.1,100),o=Z(te.und(n[1])?100:n[1],.1,100),i=Z(te.und(n[2])?10:n[2],.1,100),a=Z(te.und(n[3])?0:n[3],.1,100),s=Math.sqrt(o/r),l=i/(2*Math.sqrt(o*r)),u=l<1?s*Math.sqrt(1-l*l):0,c=l<1?(l*s-a)/u:-a+s;function d(e){var n=t?t*e/1e3:e;return n=l<1?Math.exp(-n*l*s)*(1*Math.cos(u*n)+c*Math.sin(u*n)):(1+c*n)*Math.exp(-n*s),0===e||1===e?e:1-n}return t?d:function(){var t=$.springs[e];if(t)return t;for(var n=1/6,r=0,o=0;;)if(1===d(r+=n)){if(++o>=16)break}else o=0;var i=r*n*1e3;return $.springs[e]=i,i}}function oe(e){return void 0===e&&(e=10),function(t){return Math.ceil(Z(t,1e-6,1)*e)*(1/e)}}var ie,ae,se=function(){var e=.1;function t(e,t){return 1-3*t+3*e}function n(e,t){return 3*t-6*e}function r(e){return 3*e}function o(e,o,i){return((t(o,i)*e+n(o,i))*e+r(o))*e}function i(e,o,i){return 3*t(o,i)*e*e+2*n(o,i)*e+r(o)}return function(t,n,r,a){if(0<=t&&t<=1&&0<=r&&r<=1){var s=new Float32Array(11);if(t!==n||r!==a)for(var l=0;l<11;++l)s[l]=o(l*e,t,r);return function(e){return t===n&&r===a||0===e||1===e?e:o(u(e),n,a)}}function u(n){for(var a=0,l=1;10!==l&&s[l]<=n;++l)a+=e;--l;var u=a+(n-s[l])/(s[l+1]-s[l])*e,c=i(u,t,r);return c>=.001?function(e,t,n,r){for(var a=0;a<4;++a){var s=i(t,n,r);if(0===s)return t;t-=(o(t,n,r)-e)/s}return t}(n,u,t,r):0===c?u:function(e,t,n,r,i){var a,s,l=0;do{(a=o(s=t+(n-t)/2,r,i)-e)>0?n=s:t=s}while(Math.abs(a)>1e-7&&++l<10);return s}(n,a,a+e,t,r)}}}(),le=(ie={linear:function(){return function(e){return e}}},ae={Sine:function(){return function(e){return 1-Math.cos(e*Math.PI/2)}},Circ:function(){return function(e){return 1-Math.sqrt(1-e*e)}},Back:function(){return function(e){return e*e*(3*e-2)}},Bounce:function(){return function(e){for(var t,n=4;e<((t=Math.pow(2,--n))-1)/11;);return 1/Math.pow(4,3-n)-7.5625*Math.pow((3*t-2)/22-e,2)}},Elastic:function(e,t){void 0===e&&(e=1),void 0===t&&(t=.5);var n=Z(e,1,10),r=Z(t,.1,2);return function(e){return 0===e||1===e?e:-n*Math.pow(2,10*(e-1))*Math.sin((e-1-r/(2*Math.PI)*Math.asin(1/n))*(2*Math.PI)/r)}}},["Quad","Cubic","Quart","Quint","Expo"].forEach((function(e,t){ae[e]=function(){return function(e){return Math.pow(e,t+2)}}})),Object.keys(ae).forEach((function(e){var t=ae[e];ie["easeIn"+e]=t,ie["easeOut"+e]=function(e,n){return function(r){return 1-t(e,n)(1-r)}},ie["easeInOut"+e]=function(e,n){return function(r){return r<.5?t(e,n)(2*r)/2:1-t(e,n)(-2*r+2)/2}},ie["easeOutIn"+e]=function(e,n){return function(r){return r<.5?(1-t(e,n)(1-2*r))/2:(t(e,n)(2*r-1)+1)/2}}})),ie);function ue(e,t){if(te.fnc(e))return e;var n=e.split("(")[0],r=le[n],o=ne(e);switch(n){case"spring":return re(e,t);case"cubicBezier":return ee(se,o);case"steps":return ee(oe,o);default:return ee(r,o)}}function ce(e){try{return document.querySelectorAll(e)}catch(e){return}}function de(e,t){for(var n=e.length,r=arguments.length>=2?t:void 0,o=[],i=0;i1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}if(0==a)t=n=r=s;else{var c=s<.5?s*(1+a):s+a-s*a,d=2*s-c;t=u(d,c,i+1/3),n=u(d,c,i),r=u(d,c,i-1/3)}return"rgba("+255*t+","+255*n+","+255*r+","+l+")"}(e):void 0;var t,n}function be(e){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(e);if(t)return t[1]}function we(e,t){return te.fnc(e)?e(t.target,t.id,t.total):e}function Ee(e,t){return e.getAttribute(t)}function Ie(e,t,n){if(pe([n,"deg","rad","turn"],be(t)))return t;var r=$.CSS[t+n];if(!te.und(r))return r;var o=document.createElement(e.tagName),i=e.parentNode&&e.parentNode!==document?e.parentNode:document.body;i.appendChild(o),o.style.position="absolute",o.style.width=100+n;var a=100/o.offsetWidth;i.removeChild(o);var s=a*parseFloat(t);return $.CSS[t+n]=s,s}function ke(e,t,n){if(t in e.style){var r=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),o=e.style[t]||getComputedStyle(e).getPropertyValue(r)||"0";return n?Ie(e,o,n):o}}function Se(e,t){return te.dom(e)&&!te.inp(e)&&(!te.nil(Ee(e,t))||te.svg(e)&&e[t])?"attribute":te.dom(e)&&pe(J,t)?"transform":te.dom(e)&&"transform"!==t&&ke(e,t)?"css":null!=e[t]?"object":void 0}function Te(e){if(te.dom(e)){for(var t,n=e.style.transform||"",r=/(\w+)\(([^)]*)\)/g,o=new Map;t=r.exec(n);)o.set(t[1],t[2]);return o}}function De(e,t,n,r){var o=K(t,"scale")?1:0+function(e){return K(e,"translate")||"perspective"===e?"px":K(e,"rotate")||K(e,"skew")?"deg":void 0}(t),i=Te(e).get(t)||o;return n&&(n.transforms.list.set(t,i),n.transforms.last=t),r?Ie(e,i,r):i}function xe(e,t,n,r){switch(Se(e,t)){case"transform":return De(e,t,r,n);case"css":return ke(e,t,n);case"attribute":return Ee(e,t);default:return e[t]||0}}function Pe(e,t){var n=/^(\*=|\+=|-=)/.exec(e);if(!n)return e;var r=be(e)||0,o=parseFloat(t),i=parseFloat(e.replace(n[0],""));switch(n[0][0]){case"+":return o+i+r;case"-":return o-i+r;case"*":return o*i+r}}function _e(e,t){if(te.col(e))return ye(e);if(/\s/g.test(e))return e;var n=be(e),r=n?e.substr(0,e.length-n.length):e;return t?r+t:r}function Be(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function Ae(e){for(var t,n=e.points,r=0,o=0;o0&&(r+=Be(t,i)),t=i}return r}function Ce(e){if(e.getTotalLength)return e.getTotalLength();switch(e.tagName.toLowerCase()){case"circle":return function(e){return 2*Math.PI*Ee(e,"r")}(e);case"rect":return function(e){return 2*Ee(e,"width")+2*Ee(e,"height")}(e);case"line":return function(e){return Be({x:Ee(e,"x1"),y:Ee(e,"y1")},{x:Ee(e,"x2"),y:Ee(e,"y2")})}(e);case"polyline":return Ae(e);case"polygon":return function(e){var t=e.points;return Ae(e)+Be(t.getItem(t.numberOfItems-1),t.getItem(0))}(e)}}function Le(e,t){var n=t||{},r=n.el||function(e){for(var t=e.parentNode;te.svg(t)&&te.svg(t.parentNode);)t=t.parentNode;return t}(e),o=r.getBoundingClientRect(),i=Ee(r,"viewBox"),a=o.width,s=o.height,l=n.viewBox||(i?i.split(" "):[0,0,a,s]);return{el:r,viewBox:l,x:l[0]/1,y:l[1]/1,w:a,h:s,vW:l[2],vH:l[3]}}function Oe(e,t,n){function r(n){void 0===n&&(n=0);var r=t+n>=1?t+n:0;return e.el.getPointAtLength(r)}var o=Le(e.el,e.svg),i=r(),a=r(-1),s=r(1),l=n?1:o.w/o.vW,u=n?1:o.h/o.vH;switch(e.property){case"x":return(i.x-o.x)*l;case"y":return(i.y-o.y)*u;case"angle":return 180*Math.atan2(s.y-a.y,s.x-a.x)/Math.PI}}function Me(e,t){var n=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=_e(te.pth(e)?e.totalLength:e,t)+"";return{original:r,numbers:r.match(n)?r.match(n).map(Number):[0],strings:te.str(e)||t?r.split(n):[]}}function Ne(e){return de(e?fe(te.arr(e)?e.map(he):he(e)):[],(function(e,t,n){return n.indexOf(e)===t}))}function Re(e){var t=Ne(e);return t.map((function(e,n){return{target:e,id:n,total:t.length,transforms:{list:Te(e)}}}))}function Ue(e,t){var n=ge(t);if(/^spring/.test(n.easing)&&(n.duration=re(n.easing)),te.arr(e)){var r=e.length;2===r&&!te.obj(e[0])?e={value:e}:te.fnc(t.duration)||(n.duration=t.duration/r)}var o=te.arr(e)?e:[e];return o.map((function(e,n){var r=te.obj(e)&&!te.pth(e)?e:{value:e};return te.und(r.delay)&&(r.delay=n?0:t.delay),te.und(r.endDelay)&&(r.endDelay=n===o.length-1?t.endDelay:0),r})).map((function(e){return ve(e,n)}))}function He(e,t){var n=[],r=t.keyframes;for(var o in r&&(t=ve(function(e){for(var t=de(fe(e.map((function(e){return Object.keys(e)}))),(function(e){return te.key(e)})).reduce((function(e,t){return e.indexOf(t)<0&&e.push(t),e}),[]),n={},r=function(r){var o=t[r];n[o]=e.map((function(e){var t={};for(var n in e)te.key(n)?n==o&&(t.value=e[n]):t[n]=e[n];return t}))},o=0;o0?requestAnimationFrame(t):void 0}return"undefined"!=typeof document&&document.addEventListener("visibilitychange",(function(){Ve.suspendWhenDocumentHidden&&(Qe()?e=cancelAnimationFrame(e):(ze.forEach((function(e){return e._onDocumentVisibility()})),Ge()))})),function(){e||Qe()&&Ve.suspendWhenDocumentHidden||!(ze.length>0)||(e=requestAnimationFrame(t))}}();function Qe(){return!!document&&document.hidden}function Ve(e){void 0===e&&(e={});var t,n=0,r=0,o=0,i=0,a=null;function s(e){var t=window.Promise&&new Promise((function(e){return a=e}));return e.finished=t,t}var l=function(e){var t=me(Q,e),n=me(V,e),r=He(n,e),o=Re(e.targets),i=Ye(o,r),a=je(i,n),s=We;return We++,ve(t,{id:s,children:[],animatables:o,animations:i,duration:a.duration,delay:a.delay,endDelay:a.endDelay})}(e);function u(){var e=l.direction;"alternate"!==e&&(l.direction="normal"!==e?"normal":"reverse"),l.reversed=!l.reversed,t.forEach((function(e){return e.reversed=l.reversed}))}function c(e){return l.reversed?l.duration-e:e}function d(){n=0,r=c(l.currentTime)*(1/Ve.speed)}function f(e,t){t&&t.seek(e-t.timelineOffset)}function h(e){for(var t=0,n=l.animations,r=n.length;t2||(y=Math.round(y*h)/h)),p.push(y)}var E=f.length;if(E){m=f[0];for(var I=0;I0&&(l.began=!0,p("begin")),!l.loopBegan&&l.currentTime>0&&(l.loopBegan=!0,p("loopBegin")),v<=g&&0!==l.currentTime&&h(0),(v>=m&&l.currentTime!==d||!d)&&h(d),v>g&&v=d&&(r=0,l.remaining&&!0!==l.remaining&&l.remaining--,l.remaining?(n=o,p("loopComplete"),l.loopBegan=!1,"alternate"===l.direction&&u()):(l.paused=!0,l.completed||(l.completed=!0,p("loopComplete"),p("complete"),!l.passThrough&&"Promise"in window&&(a(),s(l)))))}return s(l),l.reset=function(){var e=l.direction;l.passThrough=!1,l.currentTime=0,l.progress=0,l.paused=!0,l.began=!1,l.loopBegan=!1,l.changeBegan=!1,l.completed=!1,l.changeCompleted=!1,l.reversePlayback=!1,l.reversed="reverse"===e,l.remaining=l.loop,t=l.children;for(var n=i=t.length;n--;)l.children[n].reset();(l.reversed&&!0!==l.loop||"alternate"===e&&1===l.loop)&&l.remaining++,h(l.reversed?l.duration:0)},l._onDocumentVisibility=d,l.set=function(e,t){return qe(e,t),l},l.tick=function(e){o=e,n||(n=o),g((o+(r-n))*Ve.speed)},l.seek=function(e){g(c(e))},l.pause=function(){l.paused=!0,d()},l.play=function(){l.paused&&(l.completed&&l.reset(),l.paused=!1,ze.push(l),d(),Ge())},l.reverse=function(){u(),l.completed=!l.reversed,d()},l.restart=function(){l.reset(),l.play()},l.remove=function(e){$e(Ne(e),l)},l.reset(),l.autoplay&&l.play(),l}function Je(e,t){for(var n=t.length;n--;)pe(e,t[n].animatable.target)&&t.splice(n,1)}function $e(e,t){var n=t.animations,r=t.children;Je(e,n);for(var o=r.length;o--;){var i=r[o],a=i.animations;Je(e,a),a.length||i.children.length||r.splice(o,1)}n.length||r.length||t.pause()}Ve.version="3.2.1",Ve.speed=1,Ve.suspendWhenDocumentHidden=!0,Ve.running=ze,Ve.remove=function(e){for(var t=Ne(e),n=ze.length;n--;){$e(t,ze[n])}},Ve.get=xe,Ve.set=qe,Ve.convertPx=Ie,Ve.path=function(e,t){var n=te.str(e)?ce(e)[0]:e,r=t||100;return function(e){return{property:e,el:n,svg:Le(n),totalLength:Ce(n)*(r/100)}}},Ve.setDashoffset=function(e){var t=Ce(e);return e.setAttribute("stroke-dasharray",t),t},Ve.stagger=function(e,t){void 0===t&&(t={});var n=t.direction||"normal",r=t.easing?ue(t.easing):null,o=t.grid,i=t.axis,a=t.from||0,s="first"===a,l="center"===a,u="last"===a,c=te.arr(e),d=c?parseFloat(e[0]):parseFloat(e),f=c?parseFloat(e[1]):0,h=be(c?e[1]:e)||0,p=t.start||0+(c?d:0),g=[],m=0;return function(e,t,v){if(s&&(a=0),l&&(a=(v-1)/2),u&&(a=v-1),!g.length){for(var y=0;y-1&&ze.splice(o,1);for(var s=0;s'].join(""),document.getElementById("featured-image-drop").innerHTML="",document.getElementById("featured-image-drop").appendChild(n)}}(n),o.readAsDataURL(n)}}}},{key:"handleImageUpload",value:function(e,t){var n=this;it.alert("Uploading Image",null),(new _).imageUpload(e,t).then((function(e){"postImageAdded"==e.type&&n.editor.notify(N,e.url),it.alert("Image Added to Entry",!0)})).catch((function(){it.alert("Uh oh. Image not added",!1)}))}}]),t}();at.uploadFiles=[];var st=function(){function t(n){e(this,t),this.currentPage=null,this.choosePage(n),this.start()}return n(t,[{key:"start",value:function(){}},{key:"choosePage",value:function(e){switch(this.currentPage="",e){case"edit":case"add":this.currentPage=new at}}}]),t}(),lt=function(){function t(){e(this,t)}return n(t,[{key:"getInfo",value:function(){var e,t,n=document.getElementById("settings-handle").value,r=document.getElementById("settings-email").value,o=document.getElementById("settings-url").value,i=document.getElementById("settings-title").value,a=document.getElementById("settings-desc").value,s=document.getElementById("background").src,l="",u=document.querySelectorAll(".theme-select"),c=document.getElementById("smtp-domain").value,d=document.getElementById("smtp-email").value,f=document.getElementById("smtp-pass").value,h=document.getElementById("mg-domain").value,p=document.getElementById("mg-key").value,g="",m=document.querySelectorAll(".mail-option"),v=document.getElementById("api-access-toggle").getAttribute("data-enabled");for(e=0,t=u.length;e diff --git a/src/com/actions/PageActions.js b/src/com/actions/PageActions.js index 7c4a640..d368285 100644 --- a/src/com/actions/PageActions.js +++ b/src/com/actions/PageActions.js @@ -56,6 +56,10 @@ export default class PostActions { "published", document.getElementById("option-published").getAttribute("data-active") ); + pageInfo.append( + "form_token", + document.getElementById("form_token").value + ); if (image != null || image != undefined) { if (image.type.match("image.*")) { pageInfo.append("feature_image", image, image.name); diff --git a/src/libraries/FipamoAdminAPI.js b/src/libraries/FipamoAdminAPI.js index b42cfa4..ac57953 100644 --- a/src/libraries/FipamoAdminAPI.js +++ b/src/libraries/FipamoAdminAPI.js @@ -217,6 +217,7 @@ class FipamoAdminAPI { * @param {boolean} form[].menu - property that indicates page is included in site menu * @param {boolean} form[].featured - property that indicates page is featured * @param {boolean} form[].published - property that indicates page is public + * @param {string} form[].form_token - hidden property to authenticate form submission * @param {input} form[].feature_image - main image for page * @example * api.pageActions(TASK, data).then(response=>{ From 934d29f4cfc4cb88e0ef7cc38f19870a6a4ccf9b Mon Sep 17 00:00:00 2001 From: Ro Date: Tue, 14 Sep 2021 12:47:57 -0700 Subject: [PATCH 4/4] added field check for page edits to make sure unnecessary fields are not being added --- brain/api/v1/PagesAPI.inc.php | 36 ++++++++++++++++++++++++++++++++++- brain/data/Book.inc.php | 4 +++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/brain/api/v1/PagesAPI.inc.php b/brain/api/v1/PagesAPI.inc.php index 4ea4a30..79bbc8b 100644 --- a/brain/api/v1/PagesAPI.inc.php +++ b/brain/api/v1/PagesAPI.inc.php @@ -105,6 +105,7 @@ class PagesAPI case "create": case "write": $body = $request->getParsedBody(); + $passed = true; if (!isset($body["form_token"])) { $result = [ "message" => "No form token. Not good, sport.", @@ -113,7 +114,40 @@ class PagesAPI } else { if ($body["form_token"] == Session::get("form_token")) { //TODO: Verify form fields - $result = (new Book("../content/pages"))->editPage($task, $request); + $keys = [ + "id", + "uuid", + "layout", + "current_title", + "content", + "title", + "created", + "slug", + "tags", + "menu", + "featured", + "published", + "form_token", + "feature_image", + ]; + + foreach ($body as $key => $item) { + if (!in_array($key, $keys)) { + //found unnecessary key, so reject submission + $passed = false; + } + } + if ($passed) { + $result = (new Book("../content/pages"))->editPage( + $task, + $request + ); + } else { + $result = [ + "message" => "Form token, auth failed. Uh oh.", + "type" => "TASK_FORM_AUTH", + ]; + } } else { $result = [ "message" => "Form token, auth failed. Uh oh.", diff --git a/brain/data/Book.inc.php b/brain/data/Book.inc.php index ff3e578..fe40cc3 100644 --- a/brain/data/Book.inc.php +++ b/brain/data/Book.inc.php @@ -148,7 +148,9 @@ class Book "id" => $uuid, ]; - //**just testing to see why indexing isn't working ** + //TODO: When form submission is successful, make new form token + $form_token = md5(uniqid(microtime(), true)); + Session::set("form_token", $form_token); //once saved, update menu $body["path"] = $path;