Current section
Files
Jump to
Current section
Files
priv/static/thesis.js
!function(e){function t(i){if(n[i])return n[i].exports;var o=n[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=4)}([function(e,t,n){"use strict";function i(){return null}function o(e){var t=e.nodeName,n=e.attributes;e.attributes={},t.defaultProps&&x(e.attributes,t.defaultProps),n&&x(e.attributes,n)}function r(e,t){var n,i,o;if(t){for(o in t)if(n=Q.test(o))break;if(n){i=e.attributes={};for(o in t)t.hasOwnProperty(o)&&(i[Q.test(o)?o.replace(/([A-Z0-9])/,"-$1").toLowerCase():o]=t[o])}}}function a(e,t,n){var i=t&&t._preactCompatRendered&&t._preactCompatRendered.base;i&&i.parentNode!==t&&(i=null),!i&&t&&(i=t.firstElementChild);for(var o=t.childNodes.length;o--;)t.childNodes[o]!==i&&t.removeChild(t.childNodes[o]);var r=Object(q.e)(e,t,i);return t&&(t._preactCompatRendered=r&&(r._component||{base:r})),"function"==typeof n&&n(),r&&r._component||r}function s(e,t,n,i){var o=Object(q.c)(ee,{context:e.context},t),r=a(o,n),s=r._component||r.base;return i&&i.call(s,r),s}function l(e){s(this,e.vnode,e.container)}function u(e,t){return Object(q.c)(l,{vnode:e,container:t})}function c(e){var t=e._preactCompatRendered&&e._preactCompatRendered.base;return!(!t||t.parentNode!==e)&&(Object(q.e)(Object(q.c)(i),e,t),!0)}function d(e){return g.bind(null,e)}function h(e,t){for(var n=t||0;n<e.length;n++){var i=e[n];Array.isArray(i)?h(i):i&&"object"==typeof i&&!y(i)&&(i.props&&i.type||i.attributes&&i.nodeName||i.children)&&(e[n]=g(i.type||i.nodeName,i.props||i.attributes,i.children))}}function f(e){return"function"==typeof e&&!(e.prototype&&e.prototype.render)}function p(e){return N({displayName:e.displayName||e.name,render:function(){return e(this.props,this.context)}})}function m(e){var t=e[z];return t?!0===t?e:t:(t=p(e),Object.defineProperty(t,z,{configurable:!0,value:!0}),t.displayName=e.displayName,t.propTypes=e.propTypes,t.defaultProps=e.defaultProps,Object.defineProperty(e,z,{configurable:!0,value:t}),t)}function g(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return h(e,2),v(q.c.apply(void 0,e))}function v(e){e.preactCompatNormalized=!0,w(e),f(e.nodeName)&&(e.nodeName=m(e.nodeName));var t=e.attributes.ref,n=t&&typeof t;return!te||"string"!==n&&"number"!==n||(e.attributes.ref=C(t,te)),E(e),e}function b(e,t){for(var n=[],i=arguments.length-2;i-- >0;)n[i]=arguments[i+2];if(!y(e))return e;var o=e.attributes||e.props,r=Object(q.c)(e.nodeName||e.type,x({},o),e.children||o&&o.children),a=[r,t];return n&&n.length?a.push(n):t&&t.children&&a.push(t.children),v(q.b.apply(void 0,a))}function y(e){return e&&(e instanceof G||e.$$typeof===V)}function C(e,t){return t._refProxies[e]||(t._refProxies[e]=function(n){t&&t.refs&&(t.refs[e]=n,null===n&&(delete t._refProxies[e],t=null))})}function E(e){var t=e.nodeName,n=e.attributes;if(n&&"string"==typeof t){var i={};for(var o in n)i[o.toLowerCase()]=o;if(i.ondoubleclick&&(n.ondblclick=n[i.ondoubleclick],delete n[i.ondoubleclick]),i.onchange&&("textarea"===t||"input"===t.toLowerCase()&&!/^fil|che|rad/i.test(n.type))){var r=i.oninput||"oninput";n[r]||(n[r]=L([n[r],n[i.onchange]]),delete n[i.onchange])}}}function w(e){var t=e.attributes||(e.attributes={});ae.enumerable="className"in t,t.className&&(t.class=t.className),Object.defineProperty(t,"className",ae)}function x(e,t){for(var n=arguments,i=1,o=void 0;i<arguments.length;i++)if(o=n[i])for(var r in o)o.hasOwnProperty(r)&&(e[r]=o[r]);return e}function T(e,t){for(var n in e)if(!(n in t))return!0;for(var i in t)if(e[i]!==t[i])return!0;return!1}function k(e){return e&&(e.base||1===e.nodeType&&e)||null}function S(){}function N(e){function t(e,t){_(this),B.call(this,e,t,X),D.call(this,e,t)}return e=x({constructor:t},e),e.mixins&&A(e,P(e.mixins)),e.statics&&x(t,e.statics),e.propTypes&&(t.propTypes=e.propTypes),e.defaultProps&&(t.defaultProps=e.defaultProps),e.getDefaultProps&&(t.defaultProps=e.getDefaultProps.call(t)),S.prototype=B.prototype,t.prototype=x(new S,e),t.displayName=e.displayName||"Component",t}function P(e){for(var t={},n=0;n<e.length;n++){var i=e[n];for(var o in i)i.hasOwnProperty(o)&&"function"==typeof i[o]&&(t[o]||(t[o]=[])).push(i[o])}return t}function A(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=L(t[n].concat(e[n]||ne),"getDefaultProps"===n||"getInitialState"===n||"getChildContext"===n))}function _(e){for(var t in e){var n=e[t];"function"!=typeof n||n.__bound||$.hasOwnProperty(t)||((e[t]=n.bind(e)).__bound=!0)}}function O(e,t,n){if("string"==typeof t&&(t=e.constructor.prototype[t]),"function"==typeof t)return t.apply(e,n)}function L(e,t){return function(){for(var n,i=arguments,o=this,r=0;r<e.length;r++){var a=O(o,e[r],i);if(t&&null!=a){n||(n={});for(var s in a)a.hasOwnProperty(s)&&(n[s]=a[s])}else void 0!==a&&(n=a)}return n}}function D(e,t){R.call(this,e,t),this.componentWillReceiveProps=L([R,this.componentWillReceiveProps||"componentWillReceiveProps"]),this.render=L([R,M,this.render||"render",I])}function R(e,t){if(e){var n=e.children;if(n&&Array.isArray(n)&&1===n.length&&("string"==typeof n[0]||"function"==typeof n[0]||n[0]instanceof G)&&(e.children=n[0],e.children&&"object"==typeof e.children&&(e.children.length=1,e.children[0]=e.children)),J){var i="function"==typeof this?this:this.constructor,o=this.propTypes||i.propTypes,r=this.displayName||i.name;o&&U.a.checkPropTypes(o,e,"prop",r)}}}function M(e){te=this}function I(){te===this&&(te=null)}function B(e,t,n){q.a.call(this,e,t),this.state=this.getInitialState?this.getInitialState():{},this.refs={},this._refProxies={},n!==X&&D.call(this,e,t)}function F(e,t){B.call(this,e,t)}function j(e){e()}Object.defineProperty(t,"__esModule",{value:!0}),n.d(t,"version",function(){return K}),n.d(t,"DOM",function(){return oe}),n.d(t,"Children",function(){return ie}),n.d(t,"render",function(){return a}),n.d(t,"createClass",function(){return N}),n.d(t,"createPortal",function(){return u}),n.d(t,"createFactory",function(){return d}),n.d(t,"createElement",function(){return g}),n.d(t,"cloneElement",function(){return b}),n.d(t,"isValidElement",function(){return y}),n.d(t,"findDOMNode",function(){return k}),n.d(t,"unmountComponentAtNode",function(){return c}),n.d(t,"Component",function(){return B}),n.d(t,"PureComponent",function(){return F}),n.d(t,"unstable_renderSubtreeIntoContainer",function(){return s}),n.d(t,"unstable_batchedUpdates",function(){return j}),n.d(t,"__spread",function(){return x});var H=n(2),U=n.n(H);n.d(t,"PropTypes",function(){return U.a});var q=n(7),K="15.1.0",W="a abbr address area article aside audio b base bdi bdo big blockquote body br button canvas caption cite code col colgroup data datalist dd del details dfn dialog div dl dt em embed fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 head header hgroup hr html i iframe img input ins kbd keygen label legend li link main map mark menu menuitem meta meter nav noscript object ol optgroup option output p param picture pre progress q rp rt ruby s samp script section select small source span strong style sub summary sup table tbody td textarea tfoot th thead time title tr track u ul var video wbr circle clipPath defs ellipse g image line linearGradient mask path pattern polygon polyline radialGradient rect stop svg text tspan".split(" "),V="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,z="undefined"!=typeof Symbol&&Symbol.for?Symbol.for("__preactCompatWrapper"):"__preactCompatWrapper",$={constructor:1,render:1,shouldComponentUpdate:1,componentWillReceiveProps:1,componentWillUpdate:1,componentDidUpdate:1,componentWillMount:1,componentDidMount:1,componentWillUnmount:1,componentDidUnmount:1},Q=/^(?:accent|alignment|arabic|baseline|cap|clip|color|fill|flood|font|glyph|horiz|marker|overline|paint|stop|strikethrough|stroke|text|underline|unicode|units|v|vector|vert|word|writing|x)[A-Z]/,X={},J=!1;try{J=!1}catch(e){}var G=Object(q.c)("a",null).constructor;G.prototype.$$typeof=V,G.prototype.preactCompatUpgraded=!1,G.prototype.preactCompatNormalized=!1,Object.defineProperty(G.prototype,"type",{get:function(){return this.nodeName},set:function(e){this.nodeName=e},configurable:!0}),Object.defineProperty(G.prototype,"props",{get:function(){return this.attributes},set:function(e){this.attributes=e},configurable:!0});var Y=q.d.event;q.d.event=function(e){return Y&&(e=Y(e)),e.persist=Object,e.nativeEvent=e,e};var Z=q.d.vnode;q.d.vnode=function(e){if(!e.preactCompatUpgraded){e.preactCompatUpgraded=!0;var t=e.nodeName,n=e.attributes=null==e.attributes?{}:x({},e.attributes);"function"==typeof t?(!0===t[z]||t.prototype&&"isReactComponent"in t.prototype)&&(e.children&&""===String(e.children)&&(e.children=void 0),e.children&&(n.children=e.children),e.preactCompatNormalized||v(e),o(e)):(e.children&&""===String(e.children)&&(e.children=void 0),e.children&&(n.children=e.children),n.defaultValue&&(n.value||0===n.value||(n.value=n.defaultValue),delete n.defaultValue),r(e,n))}Z&&Z(e)};var ee=function(){};ee.prototype.getChildContext=function(){return this.props.context},ee.prototype.render=function(e){return e.children[0]};for(var te,ne=[],ie={map:function(e,t,n){return null==e?null:(e=ie.toArray(e),n&&n!==e&&(t=t.bind(n)),e.map(t))},forEach:function(e,t,n){if(null==e)return null;e=ie.toArray(e),n&&n!==e&&(t=t.bind(n)),e.forEach(t)},count:function(e){return e&&e.length||0},only:function(e){if(e=ie.toArray(e),1!==e.length)throw new Error("Children.only() expects only one child.");return e[0]},toArray:function(e){return null==e?[]:ne.concat(e)}},oe={},re=W.length;re--;)oe[W[re]]=d(W[re]);var ae={configurable:!0,get:function(){return this.class},set:function(e){this.class=e}};x(B.prototype=new q.a,{constructor:B,isReactComponent:{},replaceState:function(e,t){var n=this;this.setState(e,t);for(var i in n.state)i in e||delete n.state[i]},getDOMNode:function(){return this.base},isMounted:function(){return!!this.base}}),S.prototype=B.prototype,F.prototype=new S,F.prototype.isPureReactComponent=!0,F.prototype.shouldComponentUpdate=function(e,t){return T(this.props,e)||T(this.state,t)};var se={version:K,DOM:oe,PropTypes:U.a,Children:ie,render:a,createClass:N,createPortal:u,createFactory:d,createElement:g,cloneElement:b,isValidElement:y,findDOMNode:k,unmountComponentAtNode:c,Component:B,PureComponent:F,unstable_renderSubtreeIntoContainer:s,unstable_batchedUpdates:j,__spread:x};t.default=se},function(e,t,n){"use strict";function i(e){if(e.status>=200&&e.status<300)return e;var t=new Error(e.statusText);throw t.response=e,t}function o(e){return e.json()}Object.defineProperty(t,"__esModule",{value:!0}),n(22);var r={get:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"json";return r.request(e,t,"GET",n)},post:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"json";return r.request(e,t,"POST",n)},put:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"json";return r.request(e,t,"PUT",n)},patch:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"json";return r.request(e,t,"PATCH",n)},delete:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"json";return r.request(e,t,"DELETE",n)},request:function(e,t,n,r){var a=new Headers;return"json"===r&&a.append("Content-Type","application/json"),a.append("Accept","application/json"),"json"===r&&(t=JSON.stringify(t)),"form"===r&&(t=new FormData(t)),window.fetch(e,{method:n,credentials:"same-origin",headers:a,body:t}).then(i).then(o)}};t.default=r},function(e,t,n){e.exports=n(5)()},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i="function"==typeof fetch?fetch.bind():function(e,t){return t=t||{},new Promise(function(n,i){function o(){var e,t=[],n=[],i={};return r.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(o,r,a){t.push(r=r.toLowerCase()),n.push([r,a]),e=i[r],i[r]=e?e+","+a:a}),{ok:2==(r.status/100|0),status:r.status,statusText:r.statusText,url:r.responseURL,clone:o,text:function(){return Promise.resolve(r.responseText)},json:function(){return Promise.resolve(r.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([r.response]))},headers:{keys:function(){return t},entries:function(){return n},get:function(e){return i[e.toLowerCase()]},has:function(e){return e.toLowerCase()in i}}}}var r=new XMLHttpRequest;r.open(t.method||"get",e,!0);for(var a in t.headers)r.setRequestHeader(a,t.headers[a]);r.withCredentials="include"==t.credentials,r.onload=function(){n(o())},r.onerror=i,r.send(t.body||null)})};t.default=i},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(0),r=i(o),a=n(0),s=i(a),l=n(8),u=i(l),c=n(34),d=i(c);n(35);var h=function(e){var t=e.getAttribute("data-redirect-url");t&&window.confirm("This page is set to redirect to "+t+". Follow redirect?")&&(window.location=t);var n=(0,d.default)(e);return s.default.render(r.default.createElement(u.default,{external:n}),e)};window.thesis=h,t.default=h},function(e,t,n){"use strict";function i(){}var o=n(6);e.exports=function(){function e(e,t,n,i,r,a){if(a!==o){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return n.checkPropTypes=i,n.PropTypes=n,n}},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,n){"use strict";function i(e,t){var n,i,o,r,a=R;for(r=arguments.length;r-- >2;)D.push(arguments[r]);for(t&&null!=t.children&&(D.length||D.push(t.children),delete t.children);D.length;)if((i=D.pop())&&void 0!==i.pop)for(r=i.length;r--;)D.push(i[r]);else"boolean"==typeof i&&(i=null),(o="function"!=typeof e)&&(null==i?i="":"number"==typeof i?i=String(i):"string"!=typeof i&&(o=!1)),o&&n?a[a.length-1]+=i:a===R?a=[i]:a.push(i),n=o;var s=new O;return s.nodeName=e,s.children=a,s.attributes=null==t?void 0:t,s.key=null==t?void 0:t.key,void 0!==L.vnode&&L.vnode(s),s}function o(e,t){for(var n in t)e[n]=t[n];return e}function r(e,t){null!=e&&("function"==typeof e?e(t):e.current=t)}function a(e,t){return i(e.nodeName,o(o({},e.attributes),t),arguments.length>2?[].slice.call(arguments,2):e.children)}function s(e){!e._dirty&&(e._dirty=!0)&&1==B.push(e)&&(L.debounceRendering||M)(l)}function l(){for(var e;e=B.pop();)e._dirty&&S(e)}function u(e,t,n){return"string"==typeof t||"number"==typeof t?void 0!==e.splitText:"string"==typeof t.nodeName?!e._componentConstructor&&c(e,t.nodeName):n||e._componentConstructor===t.nodeName}function c(e,t){return e.normalizedNodeName===t||e.nodeName.toLowerCase()===t.toLowerCase()}function d(e){var t=o({},e.attributes);t.children=e.children;var n=e.nodeName.defaultProps;if(void 0!==n)for(var i in n)void 0===t[i]&&(t[i]=n[i]);return t}function h(e,t){var n=t?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e);return n.normalizedNodeName=e,n}function f(e){var t=e.parentNode;t&&t.removeChild(e)}function p(e,t,n,i,o){if("className"===t&&(t="class"),"key"===t);else if("ref"===t)r(n,null),r(i,e);else if("class"!==t||o)if("style"===t){if(i&&"string"!=typeof i&&"string"!=typeof n||(e.style.cssText=i||""),i&&"object"==typeof i){if("string"!=typeof n)for(var a in n)a in i||(e.style[a]="");for(var a in i)e.style[a]="number"==typeof i[a]&&!1===I.test(a)?i[a]+"px":i[a]}}else if("dangerouslySetInnerHTML"===t)i&&(e.innerHTML=i.__html||"");else if("o"==t[0]&&"n"==t[1]){var s=t!==(t=t.replace(/Capture$/,""));t=t.toLowerCase().substring(2),i?n||e.addEventListener(t,m,s):e.removeEventListener(t,m,s),(e._listeners||(e._listeners={}))[t]=i}else if("list"!==t&&"type"!==t&&!o&&t in e){try{e[t]=null==i?"":i}catch(e){}null!=i&&!1!==i||"spellcheck"==t||e.removeAttribute(t)}else{var l=o&&t!==(t=t.replace(/^xlink:?/,""));null==i||!1===i?l?e.removeAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase()):e.removeAttribute(t):"function"!=typeof i&&(l?e.setAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase(),i):e.setAttribute(t,i))}else e.className=i||""}function m(e){return this._listeners[e.type](L.event&&L.event(e)||e)}function g(){for(var e;e=F.shift();)L.afterMount&&L.afterMount(e),e.componentDidMount&&e.componentDidMount()}function v(e,t,n,i,o,r){j++||(H=null!=o&&void 0!==o.ownerSVGElement,U=null!=e&&!("__preactattr_"in e));var a=b(e,t,n,i,r);return o&&a.parentNode!==o&&o.appendChild(a),--j||(U=!1,r||g()),a}function b(e,t,n,i,o){var r=e,a=H;if(null!=t&&"boolean"!=typeof t||(t=""),"string"==typeof t||"number"==typeof t)return e&&void 0!==e.splitText&&e.parentNode&&(!e._component||o)?e.nodeValue!=t&&(e.nodeValue=t):(r=document.createTextNode(t),e&&(e.parentNode&&e.parentNode.replaceChild(r,e),C(e,!0))),r.__preactattr_=!0,r;var s=t.nodeName;if("function"==typeof s)return N(e,t,n,i);if(H="svg"===s||"foreignObject"!==s&&H,s=String(s),(!e||!c(e,s))&&(r=h(s,H),e)){for(;e.firstChild;)r.appendChild(e.firstChild);e.parentNode&&e.parentNode.replaceChild(r,e),C(e,!0)}var l=r.firstChild,u=r.__preactattr_,d=t.children;if(null==u){u=r.__preactattr_={};for(var f=r.attributes,p=f.length;p--;)u[f[p].name]=f[p].value}return!U&&d&&1===d.length&&"string"==typeof d[0]&&null!=l&&void 0!==l.splitText&&null==l.nextSibling?l.nodeValue!=d[0]&&(l.nodeValue=d[0]):(d&&d.length||null!=l)&&y(r,d,n,i,U||null!=u.dangerouslySetInnerHTML),w(r,t.attributes,u),H=a,r}function y(e,t,n,i,o){var r,a,s,l,c,d=e.childNodes,h=[],p={},m=0,g=0,v=d.length,y=0,E=t?t.length:0;if(0!==v)for(var w=0;w<v;w++){var x=d[w],T=x.__preactattr_,k=E&&T?x._component?x._component.__key:T.key:null;null!=k?(m++,p[k]=x):(T||(void 0!==x.splitText?!o||x.nodeValue.trim():o))&&(h[y++]=x)}if(0!==E)for(var w=0;w<E;w++){l=t[w],c=null;var k=l.key;if(null!=k)m&&void 0!==p[k]&&(c=p[k],p[k]=void 0,m--);else if(g<y)for(r=g;r<y;r++)if(void 0!==h[r]&&u(a=h[r],l,o)){c=a,h[r]=void 0,r===y-1&&y--,r===g&&g++;break}c=b(c,l,n,i),s=d[w],c&&c!==e&&c!==s&&(null==s?e.appendChild(c):c===s.nextSibling?f(s):e.insertBefore(c,s))}if(m)for(var w in p)void 0!==p[w]&&C(p[w],!1);for(;g<=y;)void 0!==(c=h[y--])&&C(c,!1)}function C(e,t){var n=e._component;n?P(n):(null!=e.__preactattr_&&r(e.__preactattr_.ref,null),!1!==t&&null!=e.__preactattr_||f(e),E(e))}function E(e){for(e=e.lastChild;e;){var t=e.previousSibling;C(e,!0),e=t}}function w(e,t,n){var i;for(i in n)t&&null!=t[i]||null==n[i]||p(e,i,n[i],n[i]=void 0,H);for(i in t)"children"===i||"innerHTML"===i||i in n&&t[i]===("value"===i||"checked"===i?e[i]:n[i])||p(e,i,n[i],n[i]=t[i],H)}function x(e,t,n){var i,o=q.length;for(e.prototype&&e.prototype.render?(i=new e(t,n),A.call(i,t,n)):(i=new A(t,n),i.constructor=e,i.render=T);o--;)if(q[o].constructor===e)return i.nextBase=q[o].nextBase,q.splice(o,1),i;return i}function T(e,t,n){return this.constructor(e,n)}function k(e,t,n,i,o){e._disable||(e._disable=!0,e.__ref=t.ref,e.__key=t.key,delete t.ref,delete t.key,void 0===e.constructor.getDerivedStateFromProps&&(!e.base||o?e.componentWillMount&&e.componentWillMount():e.componentWillReceiveProps&&e.componentWillReceiveProps(t,i)),i&&i!==e.context&&(e.prevContext||(e.prevContext=e.context),e.context=i),e.prevProps||(e.prevProps=e.props),e.props=t,e._disable=!1,0!==n&&(1!==n&&!1===L.syncComponentUpdates&&e.base?s(e):S(e,1,o)),r(e.__ref,e))}function S(e,t,n,i){if(!e._disable){var r,a,s,l=e.props,u=e.state,c=e.context,h=e.prevProps||l,f=e.prevState||u,p=e.prevContext||c,m=e.base,b=e.nextBase,y=m||b,E=e._component,w=!1,T=p;if(e.constructor.getDerivedStateFromProps&&(u=o(o({},u),e.constructor.getDerivedStateFromProps(l,u)),e.state=u),m&&(e.props=h,e.state=f,e.context=p,2!==t&&e.shouldComponentUpdate&&!1===e.shouldComponentUpdate(l,u,c)?w=!0:e.componentWillUpdate&&e.componentWillUpdate(l,u,c),e.props=l,e.state=u,e.context=c),e.prevProps=e.prevState=e.prevContext=e.nextBase=null,e._dirty=!1,!w){r=e.render(l,u,c),e.getChildContext&&(c=o(o({},c),e.getChildContext())),m&&e.getSnapshotBeforeUpdate&&(T=e.getSnapshotBeforeUpdate(h,f));var N,A,_=r&&r.nodeName;if("function"==typeof _){var O=d(r);a=E,a&&a.constructor===_&&O.key==a.__key?k(a,O,1,c,!1):(N=a,e._component=a=x(_,O,c),a.nextBase=a.nextBase||b,a._parentComponent=e,k(a,O,0,c,!1),S(a,1,n,!0)),A=a.base}else s=y,N=E,N&&(s=e._component=null),(y||1===t)&&(s&&(s._component=null),A=v(s,r,c,n||!m,y&&y.parentNode,!0));if(y&&A!==y&&a!==E){var D=y.parentNode;D&&A!==D&&(D.replaceChild(A,y),N||(y._component=null,C(y,!1)))}if(N&&P(N),e.base=A,A&&!i){for(var R=e,M=e;M=M._parentComponent;)(R=M).base=A;A._component=R,A._componentConstructor=R.constructor}}for(!m||n?F.push(e):w||(e.componentDidUpdate&&e.componentDidUpdate(h,f,T),L.afterUpdate&&L.afterUpdate(e));e._renderCallbacks.length;)e._renderCallbacks.pop().call(e);j||i||g()}}function N(e,t,n,i){for(var o=e&&e._component,r=o,a=e,s=o&&e._componentConstructor===t.nodeName,l=s,u=d(t);o&&!l&&(o=o._parentComponent);)l=o.constructor===t.nodeName;return o&&l&&(!i||o._component)?(k(o,u,3,n,i),e=o.base):(r&&!s&&(P(r),e=a=null),o=x(t.nodeName,u,n),e&&!o.nextBase&&(o.nextBase=e,a=null),k(o,u,1,n,i),e=o.base,a&&e!==a&&(a._component=null,C(a,!1))),e}function P(e){L.beforeUnmount&&L.beforeUnmount(e);var t=e.base;e._disable=!0,e.componentWillUnmount&&e.componentWillUnmount(),e.base=null;var n=e._component;n?P(n):t&&(null!=t.__preactattr_&&r(t.__preactattr_.ref,null),e.nextBase=t,f(t),q.push(e),E(t)),r(e.__ref,null)}function A(e,t){this._dirty=!0,this.context=t,this.props=e,this.state=this.state||{},this._renderCallbacks=[]}function _(e,t,n){return v(n,e,{},!1,t,!1)}n.d(t,"c",function(){return i}),n.d(t,"b",function(){return a}),n.d(t,"a",function(){return A}),n.d(t,"e",function(){return _}),n.d(t,"d",function(){return L});var O=function(){},L={},D=[],R=[],M="function"==typeof Promise?Promise.resolve().then.bind(Promise.resolve()):setTimeout,I=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,B=[],F=[],j=0,H=!1,U=!1,q=[];o(A.prototype,{setState:function(e,t){this.prevState||(this.prevState=this.state),this.state=o(o({},this.state),"function"==typeof e?e(this.state,this.props):e),t&&this._renderCallbacks.push(t),s(this)},forceUpdate:function(e){e&&this._renderCallbacks.push(e),S(this,2)},render:function(){}})},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),l=n(0),u=i(l),c=n(0),d=(i(c),n(9)),h=i(d),f=n(10),p=i(f),m=n(11),g=i(m),v=n(12),b=i(v),y=n(13),C=i(y),E=n(14),w=i(E),x=n(15),T=i(x),k=n(16),S=i(k),N=n(17),P=i(N),A=n(23),_=i(A),O=n(24),L=i(O),D=n(25),R=i(D),M=n(28),I=i(M),B=n(30),F=i(B),j=n(33),H=i(j),U=function(e){function t(e){o(this,t);var n=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.state={editing:!1,path:n.props.external.path,title:n.props.external.getTitle(),description:n.props.external.getDescription(),template:n.props.external.template,templates:n.props.external.templates,isDynamicPage:n.props.external.isDynamicPage,redirectURL:n.props.external.pageRedirectURL,pageModified:!1,pageToolsHidden:!0,trayOpen:!1,trayType:null,deleted:!1,errorAlertText:null,importProgress:null,importContentQueueCount:0,importContentCompletedCount:0,notifications:JSON.parse(n.props.external.notifications)},n.trayCanceled=n.trayCanceled.bind(n),n.settingsTraySubmitted=n.settingsTraySubmitted.bind(n),n.cancelPressed=n.cancelPressed.bind(n),n.savePressed=n.savePressed.bind(n),n.editPressed=n.editPressed.bind(n),n.addPagePressed=n.addPagePressed.bind(n),n.deletePagePressed=n.deletePagePressed.bind(n),n.pageSettingsPressed=n.pageSettingsPressed.bind(n),n.importExportRestorePressed=n.importExportRestorePressed.bind(n),n.importData=n.importData.bind(n),n.updateImportProgress=n.updateImportProgress.bind(n),n.props.external.customHTMLEditor?n.htmlEditor=new n.props.external.customHTMLEditor({onChange:function(){return n.setState({pageModified:!0})}}):n.htmlEditor=new R.default({onChange:function(){return n.setState({pageModified:!0})}}),n.rawHtmlEditor=new I.default({openTray:n.openTray("raw-html"),closeTray:n.trayCanceled}),n.imageEditor=new F.default({ospryPublicKey:n.props.external.ospryPublicKey,fileUploader:n.props.external.fileUploader,openTray:n.openTray("image-url"),closeTray:n.trayCanceled}),n.textEditor=new H.default({onChange:function(){return n.setState({pageModified:!0})}}),n}return a(t,e),s(t,[{key:"openTray",value:function(e){var t=this;return function(n){t.setState({pageModified:!0,trayOpen:!0,trayType:e,trayData:n})}}},{key:"trayCanceled",value:function(){this.setState({trayOpen:!1,trayData:null})}},{key:"settingsTraySubmitted",value:function(e){if(e.new){var t={slug:e.path,title:e.title,description:e.description,redirect_url:e.redirectURL,template:e.template};this.save(t,[])}else this.setState({trayOpen:!1,pageModified:!0,path:e.path,title:e.title,description:e.description,template:e.template,redirectURL:e.redirectURL})}},{key:"addPagePressed",value:function(){this.setState({trayOpen:!0,trayType:"add-page"})}},{key:"deletePagePressed",value:function(){window.confirm("Are you sure you want to delete this page? There is no undo.")&&this.deletePage(this.state.path)}},{key:"editPressed",value:function(){this.state.editing?this.state.pageModified?this.cancelPressed():this.setState({editing:!1,pageModified:!1,trayOpen:!1,pageToolsHidden:!0}):this.state.errorAlertText?window.alert(this.state.errorAlertText):this.setState({editing:!0,pageToolsHidden:!1,trayOpen:!1})}},{key:"savePressed",value:function(){var e=this.pageSettings(),t=this.contentEditorContents();this.save(e,t)}},{key:"cancelPressed",value:function(){window.confirm("Discard changes and reload the page?")&&(this.setState({editing:!1}),window.location.reload())}},{key:"pageSettingsPressed",value:function(){this.state.trayOpen&&"page-settings"!==this.state.trayType?this.setState({trayType:"page-settings"}):this.setState({trayOpen:!this.state.trayOpen,trayType:"page-settings"})}},{key:"importExportRestorePressed",value:function(){this.state.trayOpen&&"import-export-restore"!==this.state.trayType?this.setState({trayType:"import-export-restore"}):this.setState({trayOpen:!this.state.trayOpen,trayType:"import-export-restore"})}},{key:"save",value:function(e,t){var n=this;this.props.external.save(e,t,function(){n.setState({editing:!1,pageModified:!1,trayOpen:!1}),n.setState({pageToolsHidden:!0})})}},{key:"deletePage",value:function(e){var t=this;this.props.external.delete(e,function(){t.setState({deleted:!0,editing:!1})})}},{key:"importData",value:function(e,t){var n=this;this.setState({importContentQueueCount:t.length,importContentCompletedCount:0,title:e.title,description:e.description,pageModified:!0},function(){for(var i=0;i<t.length;i++){var o=t[i];n.importContent(o,e)}window.importContentCounterTimeout=setTimeout(function(){n.setState({importProgress:{type:"error",text:"Something went wrong! Please refresh and try again."}})},2e4)})}},{key:"allContentEditors",value:function(){return document.querySelectorAll(".thesis-content")}},{key:"addContentEditors",value:function(){this.htmlEditor.enable(),this.rawHtmlEditor.enable(),this.imageEditor.enable(),this.textEditor.enable()}},{key:"removeContentEditors",value:function(){this.htmlEditor.disable(),this.rawHtmlEditor.disable(),this.imageEditor.disable(),this.textEditor.disable()}},{key:"pageSettings",value:function(){return{slug:this.state.path,title:this.state.title,description:this.state.description,redirect_url:this.state.redirectURL,template:this.state.template}}},{key:"contentEditorContents",value:function(){for(var e=[],t=this.allContentEditors(),n=0;n<t.length;n++){var i=t[n],o=i.getAttribute("data-thesis-content-id"),r=i.getAttribute("data-thesis-content-type"),a=i.getAttribute("data-thesis-content-meta"),s=this.getContent(r,i),l=i.getAttribute("data-thesis-content-global");e.push({name:o,content_type:r,content:s,meta:a,global:l})}return e}},{key:"getContent",value:function(e,t){switch(e){case"image":case"background_image":return this.imageEditor.getContent(t);case"text":return this.textEditor.content(t);case"html":return this.htmlEditor.content(t);case"raw_html":return this.rawHtmlEditor.content(t);default:return t.innerHTML}}},{key:"importContent",value:function(e,t){var n=this;switch(e.content_type){case"image":case"background_image":return this.imageEditor.uploadAndSet(e,t,function(){n.updateImportedContentCompletedCount()});case"text":return this.updateImportedContentCompletedCount(),this.textEditor.set(e.name,e);case"html":return this.updateImportedContentCompletedCount(),this.htmlEditor.set(e.name,e);case"raw_html":return this.updateImportedContentCompletedCount(),this.rawHtmlEditor.set(e.name,e);default:return!0}}},{key:"updateImportedContentCompletedCount",value:function(){var e=this;this.setState(function(t,n){var i=t.importContentCompletedCount+1;return i>=e.state.importContentQueueCount?(clearTimeout(window.importContentCounterTimeout),{importContentQueueCount:0,importContentCompletedCount:0,importProgress:null,trayOpen:!1}):{importContentCompletedCount:i}})}},{key:"updateImportProgress",value:function(e){this.setState({importProgress:e})}},{key:"checkForDuplicateContentBlocks",value:function(){for(var e=this.allContentEditors(),t={},n=0;n<e.length;n++){var i=e[n].dataset.thesisContentId;t[i]=t[i]?t[i]+1:1}var o=Object.values(t).findIndex(function(e){return e>1});if(o>0){var r=Object.keys(t)[o];this.setState({errorAlertText:("\n Content block: '"+r+"' occurs on the page more than once.\n This will cause issues and must be resolved. Check that each content\n block in your template has a unique name.\n ").replace(/^\s+|\s+$|\s+(?=\s)/g,"")})}}},{key:"componentDidMount",value:function(){this.checkForDuplicateContentBlocks()}},{key:"componentDidUpdate",value:function(){var e=document.querySelector("body");e.classList.add("thesis-body");var t=this.allContentEditors();if(this.state.editing?(e.classList.add("thesis-editing"),this.addContentEditors()):(e.classList.remove("thesis-editing"),this.removeContentEditors()),this.state.pageModified)e.classList.add("thesis-page-modified");else{e.classList.remove("thesis-page-modified");for(var n=0;n<t.length;n++)t[n].classList.remove("modified")}this.state.trayOpen?e.classList.add("thesis-tray-open"):e.classList.remove("thesis-tray-open"),this.props.external.setTitle(this.state.title),this.props.external.setDescription(this.state.description),this.props.external.setRedirectURL(this.state.redirectURL)}},{key:"canCreatePages",value:function(){return this.state.templates&&this.state.templates.length>0}},{key:"renderEditorClass",value:function(){var e="";return e+=this.state.editing?" active ":"",e+=this.state.pageToolsHidden?" thesis-page-tools-hidden ":"",e+="thesis-page-tools-count-"+this.editorClassButtonCount()}},{key:"editorClassButtonCount",value:function(){var e=5;return this.canCreatePages()&&e++,this.state.template&&e++,e}},{key:"parseNotifications",value:function(e){return this.state.notifications[e]?this.state.notifications[e]:[]}},{key:"renderEditButtonText",value:function(){return this.state.editing?"Editing Page":"Edit Page"}},{key:"renderFaderClass",value:function(){return this.renderEditorClass()}},{key:"renderTrayClass",value:function(){return this.state.trayType}},{key:"renderTray",value:function(){return"page-settings"===this.state.trayType?u.default.createElement(S.default,{hasErrors:!1,new:!1,path:this.state.path,title:this.state.title,description:this.state.description,template:this.state.template,templates:this.state.templates,isDynamicPage:this.state.isDynamicPage,redirectURL:this.state.redirectURL,onCancel:this.trayCanceled,onSubmit:this.settingsTraySubmitted}):"add-page"===this.state.trayType?u.default.createElement(S.default,{hasErrors:!1,new:!0,path:this.state.path.replace(/\/+$/,"")+"/newpage",title:"",description:"",template:"",templates:this.state.templates,isDynamicPage:this.state.isDynamicPage,redirectURL:"",onCancel:this.trayCanceled,onSubmit:this.settingsTraySubmitted}):"image-url"===this.state.trayType?this.imageEditor.tray(this.state.trayData):"raw-html"===this.state.trayType?this.rawHtmlEditor.tray(this.state.trayData):"import-export-restore"===this.state.trayType?u.default.createElement(P.default,{pageContents:this.contentEditorContents(),pageSettings:this.pageSettings(),importProgress:this.state.importProgress,updateImportProgress:this.updateImportProgress,onCancel:this.trayCanceled,importData:this.importData}):void 0}},{key:"render",value:function(){return this.state.deleted?u.default.createElement("div",{id:"thesis"}):u.default.createElement("div",{id:"thesis"},u.default.createElement("div",{id:"thesis-editor",className:this.renderEditorClass()},u.default.createElement(g.default,{onPress:this.pageSettingsPressed}),u.default.createElement(b.default,{onPress:this.importExportRestorePressed}),u.default.createElement(w.default,{onPress:this.savePressed}),u.default.createElement(C.default,{onPress:this.cancelPressed}),this.state.isDynamicPage?u.default.createElement(p.default,{onPress:this.deletePagePressed}):null,this.canCreatePages()?u.default.createElement(h.default,{onPress:this.addPagePressed}):null,u.default.createElement(T.default,{onPress:this.editPressed,text:this.renderEditButtonText()})),u.default.createElement("div",{id:"thesis-fader",className:this.renderFaderClass()}),u.default.createElement("div",{id:"thesis-tray",className:this.renderTrayClass()},u.default.createElement(L.default,{notifications:this.parseNotifications(this.state.trayType)}),this.renderTray(),u.default.createElement(_.default,null)))}}]),t}(u.default.Component);t.default=U},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),s=n(0),l=function(e){return e&&e.__esModule?e:{default:e}}(s),u=function(e){function t(){return i(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return r(t,e),a(t,[{key:"render",value:function(){return l.default.createElement("div",{onClick:this.props.onPress,className:"thesis-button add"},l.default.createElement("div",{className:"tooltip"},"Add New Page"),l.default.createElement("i",{className:"fa fa-plus fa-2x"}))}}]),t}(l.default.Component);t.default=u},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),s=n(0),l=function(e){return e&&e.__esModule?e:{default:e}}(s),u=function(e){function t(){return i(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return r(t,e),a(t,[{key:"render",value:function(){return l.default.createElement("div",{onClick:this.props.onPress,className:"thesis-button delete"},l.default.createElement("div",{className:"tooltip"},"Delete This Page"),l.default.createElement("i",{className:"fa fa-trash fa-2x"}))}}]),t}(l.default.Component);t.default=u},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),s=n(0),l=function(e){return e&&e.__esModule?e:{default:e}}(s),u=function(e){function t(){return i(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return r(t,e),a(t,[{key:"render",value:function(){return l.default.createElement("div",{onClick:this.props.onPress,className:"thesis-button settings"},l.default.createElement("div",{className:"tooltip"},"Page Settings"),l.default.createElement("i",{className:"fa fa-wrench fa-2x"}))}}]),t}(l.default.Component);t.default=u},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),s=n(0),l=function(e){return e&&e.__esModule?e:{default:e}}(s),u=function(e){function t(){return i(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return r(t,e),a(t,[{key:"render",value:function(){return l.default.createElement("div",{onClick:this.props.onPress,className:"thesis-button import-export"},l.default.createElement("div",{className:"tooltip"},"Import/Export/Restore Content"),l.default.createElement("i",{className:"fa fa-exchange fa-2x"}))}}]),t}(l.default.Component);t.default=u},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),s=n(0),l=function(e){return e&&e.__esModule?e:{default:e}}(s),u=function(e){function t(){return i(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return r(t,e),a(t,[{key:"render",value:function(){return l.default.createElement("div",{onClick:this.props.onPress,className:"thesis-button cancel"},l.default.createElement("div",{className:"tooltip"},"Discard Changes"),l.default.createElement("i",{className:"fa fa-remove fa-2x"}))}}]),t}(l.default.Component);t.default=u},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),s=n(0),l=function(e){return e&&e.__esModule?e:{default:e}}(s),u=function(e){function t(){return i(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return r(t,e),a(t,[{key:"render",value:function(){return l.default.createElement("div",{onClick:this.props.onPress,className:"thesis-button save"},l.default.createElement("div",{className:"tooltip"},"Publish Changes"),l.default.createElement("i",{className:"fa fa-save fa-2x"}))}}]),t}(l.default.Component);t.default=u},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),s=n(0),l=function(e){return e&&e.__esModule?e:{default:e}}(s),u=function(e){function t(){return i(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return r(t,e),a(t,[{key:"render",value:function(){return l.default.createElement("div",{onClick:this.props.onPress,className:"thesis-button edit"},l.default.createElement("div",{className:"tooltip"},this.props.text),l.default.createElement("i",{className:"fa fa-edit fa-2x"}))}}]),t}(l.default.Component);t.default=u},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),s=n(0),l=function(e){return e&&e.__esModule?e:{default:e}}(s),u=function(e){function t(e){i(this,t);var n=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e)),r=e.template||e.new&&e.templates[0]||null;return n.state={title:e.title,description:e.description,redirectURL:e.redirectURL,path:e.path,template:r,templates:e.templates,isDynamicPage:e.isDynamicPage,isValid:!0},n.titleChange=n.titleChange.bind(n),n.descriptionChange=n.descriptionChange.bind(n),n.redirectURLChange=n.redirectURLChange.bind(n),n.pathChange=n.pathChange.bind(n),n.templateChange=n.templateChange.bind(n),n.onSave=n.onSave.bind(n),n}return r(t,e),a(t,[{key:"componentWillReceiveProps",value:function(e){this.setState({title:e.title,description:e.description,redirectURL:e.redirectURL,path:e.path,template:e.template,templates:e.templates,isValid:!0})}},{key:"trayTitle",value:function(){return this.props.new?"Add Page":"Page Settings"}},{key:"titleChange",value:function(e){this.setState({title:e.target.value})}},{key:"descriptionChange",value:function(e){this.setState({description:e.target.value})}},{key:"redirectURLChange",value:function(e){this.setState({redirectURL:e.target.value})}},{key:"pathChange",value:function(e){this.setState({path:e.target.value})}},{key:"templateChange",value:function(e){this.setState({template:e.target.value})}},{key:"onSave",value:function(){this.props.onSubmit({new:this.props.new,title:this.state.title,description:this.state.description,redirectURL:this.state.redirectURL,path:this.state.path,template:this.state.template,templates:this.state.templates,isDynamicPage:this.state.isDynamicPage})}},{key:"isDynamicPage",value:function(){return this.props.new||this.state.isDynamicPage}},{key:"prettyTemplateName",value:function(e){return(e.charAt(0).toUpperCase()+e.slice(1)).replace(".html","")}},{key:"renderTemplates",value:function(){var e=this;return l.default.createElement("div",{className:"thesis-field-row"},l.default.createElement("label",null,l.default.createElement("span",null,"Page Template"),l.default.createElement("div",{className:"select"},l.default.createElement("select",{value:this.state.template,onChange:this.templateChange},this.state.templates.map(function(t){return l.default.createElement("option",{value:t},e.prettyTemplateName(t))})))))}},{key:"renderRedirectURL",value:function(){return l.default.createElement("div",{className:"thesis-field-row"},l.default.createElement("label",null,l.default.createElement("span",null,"Redirect URL (leave blank for none)"),l.default.createElement("input",{type:"text",value:this.state.redirectURL,onChange:this.redirectURLChange})))}},{key:"render",value:function(){return l.default.createElement("div",{className:"tray-container"},l.default.createElement("div",{className:"tray-wrap"},l.default.createElement("div",{className:"tray-title"},this.trayTitle()),l.default.createElement("div",{className:"thesis-field-row"},l.default.createElement("label",null,l.default.createElement("span",null,"Page Path"),l.default.createElement("input",{type:"text",value:this.state.path,disabled:!this.isDynamicPage(),onChange:this.pathChange,className:"page-path"}))),l.default.createElement("div",{className:"thesis-field-row"},l.default.createElement("label",null,l.default.createElement("span",null,"Page Title"),l.default.createElement("input",{type:"text",placeholder:"Example Title",value:this.state.title,onChange:this.titleChange,className:"page-title"}))),l.default.createElement("div",{className:"thesis-field-row"},l.default.createElement("label",null,l.default.createElement("span",null,"Page Description"),l.default.createElement("textarea",{placeholder:"Example page description.",value:this.state.description,onChange:this.descriptionChange,className:"page-description"}))),this.isDynamicPage()?this.renderRedirectURL():null,this.isDynamicPage()?this.renderTemplates():null,l.default.createElement("div",{className:"thesis-field-row errors",hidden:this.state.isValid}),l.default.createElement("div",{className:"thesis-field-row cta"},l.default.createElement("button",{className:"thesis-tray-cancel",onClick:this.props.onCancel},"Cancel"),l.default.createElement("button",{className:"thesis-tray-save",onClick:this.onSave},"Apply"))))}}]),t}(l.default.Component);t.default=u},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),l=n(0),u=i(l),c=n(18),d=i(c),h=n(1),f=i(h),p=function(e){function t(e){o(this,t);var n=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.state={stringifiedExportData:"",stringifiedImportData:"",exportDataButtonText:"Copy to Clipboard",revisions:[]},n.onExportCopy=n.onExportCopy.bind(n),n.stringifyExportData=n.stringifyExportData.bind(n),n.onImportDataPaste=n.onImportDataPaste.bind(n),n.onImportApply=n.onImportApply.bind(n),n.onRevisionSelect=n.onRevisionSelect.bind(n),n}return a(t,e),s(t,[{key:"componentWillReceiveProps",value:function(e){this.setState({stringifiedExportData:"",stringifiedImportData:"",exportDataButtonText:"Copy to Clipboard",revisions:[]})}},{key:"componentDidMount",value:function(){this.stringifyExportData(),this.getPageRevisions()}},{key:"componentDidUpdate",value:function(e,t){""===this.state.stringifiedExportData&&(this.stringifyExportData(),this.getPageRevisions())}},{key:"onExportCopy",value:function(){var e=this;this.setState({exportDataButtonText:"Copied!"}),clearTimeout(window.exportDataButtonTextTimeout),window.exportDataButtonTextTimeout=setTimeout(function(){e.setState({exportDataButtonText:"Copy to Clipboard"})},2e3)}},{key:"stringifyExportData",value:function(){var e={pageSettings:Object.assign({},this.props.pageSettings,{origin:window.location.origin}),pageContents:this.props.pageContents},t=JSON.stringify(e);this.setState({stringifiedExportData:t})}},{key:"onImportDataPaste",value:function(e){this.setState({stringifiedImportData:e.target.value})}},{key:"onImportApply",value:function(){this.props.updateImportProgress({type:"in-progress",text:"Importing content. This may take some time."});var e=this.getImportData();e?this.props.importData(e.pageSettings,e.pageContents):this.setImportProgressError({type:"error",text:"The data entered is invalid."})}},{key:"getImportData",value:function(){var e=this.parseStringifiedImportData();return e&&e.pageSettings&&e.pageContents?e:null}},{key:"getPageRevisions",value:function(){var e=this,t=this.props.pageSettings.slug;f.default.get("/thesis/backups?page_slug="+t,null,"query").then(function(t){e.setState({revisions:t})}).catch(function(e){window.alert(e)})}},{key:"parseStringifiedImportData",value:function(){try{return JSON.parse(this.state.stringifiedImportData)}catch(e){return null}}},{key:"setImportProgressError",value:function(e){var t=this;this.props.updateImportProgress(e),clearTimeout(window.importProgressErrorTimeout),window.importProgressErrorTimeout=setTimeout(function(){t.props.updateImportProgress(null),t.setState({stringifiedImportData:""})},3500)}},{key:"prettyRevisionName",value:function(e){return"Rev "+e.page_revision+" made on "+e.pretty_date}},{key:"onRevisionSelect",value:function(e){var t=this;f.default.get("/thesis/restore/"+e.target.value,null,"query").then(function(e){t.setState({stringifiedImportData:e.revision})}).catch(function(e){window.alert(e)})}},{key:"render",value:function(){return this.props.importProgress?this.renderImportStatus():this.renderImportExportActions()}},{key:"renderImportExportActions",value:function(){var e=this;return u.default.createElement("div",{className:"tray-container"},u.default.createElement("div",{className:"tray-wrap"},u.default.createElement("div",{className:"tray-title"},"Import / Export Content"),u.default.createElement("div",{className:"thesis-field-row"},u.default.createElement("label",null,u.default.createElement("span",null,"Export Page Content"),u.default.createElement("textarea",{value:this.state.stringifiedExportData,className:"thesis-tray-export-data-textarea",readOnly:!0}),u.default.createElement(d.default,{text:this.state.stringifiedExportData,onCopy:this.onExportCopy},u.default.createElement("button",{className:"thesis-tray-export"},this.state.exportDataButtonText)))),u.default.createElement("br",null),u.default.createElement("br",null),u.default.createElement("div",{className:"thesis-field-row"},u.default.createElement("label",null,u.default.createElement("span",null,"Import Page Content"),u.default.createElement("textarea",{placeholder:"Paste the exported data here.",className:"thesis-tray-import-data-textarea",onChange:this.onImportDataPaste,value:this.state.stringifiedImportData}))),u.default.createElement("br",null),u.default.createElement("br",null),u.default.createElement("div",{className:"thesis-field-row"},u.default.createElement("label",null,u.default.createElement("span",null,"Page Revisions"),u.default.createElement("div",{className:"select"},u.default.createElement("select",{value:"placeholder",onChange:this.onRevisionSelect},u.default.createElement("option",{value:"placeholder",disabled:!0},"- Select Revision -"),this.state.revisions.map(function(t){return u.default.createElement("option",{key:t.id,value:t.id},e.prettyRevisionName(t))}))))),u.default.createElement("div",{className:"thesis-field-row cta"},u.default.createElement("button",{className:"thesis-tray-cancel",onClick:this.props.onCancel},"Cancel"),u.default.createElement("button",{className:"thesis-tray-save",onClick:this.onImportApply},"Import"))))}},{key:"renderImportStatus",value:function(){return u.default.createElement("div",{className:"tray-container"},u.default.createElement("div",{className:"tray-wrap"},u.default.createElement("div",{className:"tray-title"},"Import / Export Content"),u.default.createElement("div",{className:"thesis-tray-import-progress "+this.props.importProgress.type},u.default.createElement("div",{className:"thesis-tray-loader"},u.default.createElement("span",null)),u.default.createElement("div",{className:"thesis-tray-import-status"},this.props.importProgress.text))))}}]),t}(u.default.Component);t.default=p},function(e,t,n){"use strict";var i=n(19),o=i.CopyToClipboard;o.CopyToClipboard=o,e.exports=o},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var n={};for(var i in e)t.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);return n}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0}),t.CopyToClipboard=void 0;var l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},u=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),c=n(0),d=i(c),h=n(20),f=i(h);(t.CopyToClipboard=function(e){function t(){var e,n,i,o;r(this,t);for(var s=arguments.length,l=Array(s),u=0;u<s;u++)l[u]=arguments[u];return n=i=a(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(l))),i.onClick=function(e){var t=i.props,n=t.text,o=t.onCopy,r=t.children,a=t.options,s=d.default.Children.only(r),l=(0,f.default)(n,a);o&&o(n,l),s&&s.props&&"function"==typeof s.props.onClick&&s.props.onClick(e)},o=n,a(i,o)}return s(t,e),u(t,[{key:"render",value:function(){var e=this.props,t=(e.text,e.onCopy,e.options,e.children),n=o(e,["text","onCopy","options","children"]),i=d.default.Children.only(t);return d.default.cloneElement(i,l({},n,{onClick:this.onClick}))}}]),t}(d.default.PureComponent)).defaultProps={onCopy:void 0,options:void 0}},function(e,t,n){"use strict";function i(e){var t=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return e.replace(/#{\s*key\s*}/g,t)}function o(e,t){var n,o,s,l,u,c,d=!1;t||(t={}),n=t.debug||!1;try{s=r(),l=document.createRange(),u=document.getSelection(),c=document.createElement("span"),c.textContent=e,c.style.all="unset",c.style.position="fixed",c.style.top=0,c.style.clip="rect(0, 0, 0, 0)",c.style.whiteSpace="pre",c.style.webkitUserSelect="text",c.style.MozUserSelect="text",c.style.msUserSelect="text",c.style.userSelect="text",document.body.appendChild(c),l.selectNode(c),u.addRange(l);if(!document.execCommand("copy"))throw new Error("copy command was unsuccessful");d=!0}catch(r){n&&console.error("unable to copy using execCommand: ",r),n&&console.warn("trying IE specific stuff");try{window.clipboardData.setData("text",e),d=!0}catch(r){n&&console.error("unable to copy using clipboardData: ",r),n&&console.error("falling back to prompt"),o=i("message"in t?t.message:a),window.prompt(o,e)}}finally{u&&("function"==typeof u.removeRange?u.removeRange(l):u.removeAllRanges()),c&&document.body.removeChild(c),s()}return d}var r=n(21),a="Copy to clipboard: #{key}, Enter";e.exports=o},function(e,t){e.exports=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var t=document.activeElement,n=[],i=0;i<e.rangeCount;i++)n.push(e.getRangeAt(i));switch(t.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":t.blur();break;default:t=null}return e.removeAllRanges(),function(){"Caret"===e.type&&e.removeAllRanges(),e.rangeCount||n.forEach(function(t){e.addRange(t)}),t&&t.focus()}}},function(e,t,n){window.fetch||(window.fetch=n(3).default||n(3))},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),s=n(0),l=function(e){return e&&e.__esModule?e:{default:e}}(s),u=function(e){function t(){return i(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return r(t,e),a(t,[{key:"render",value:function(){return l.default.createElement("div",{className:"thesis-attribution"},l.default.createElement("a",{href:"//github.com/infinitered/thesis-phoenix",target:"_blank"},"Thesis")," is maintained by ",l.default.createElement("a",{href:"//infinite.red",target:"_blank"},"Infinite Red"))}}]),t}(l.default.Component);t.default=u},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),s=n(0),l=function(e){return e&&e.__esModule?e:{default:e}}(s),u=function(e){function t(){return i(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return r(t,e),a(t,[{key:"renderNotifications",value:function(){if(this.props.notifications.length)return l.default.createElement("div",{className:"thesis-tray-notifications-wrap"},this.props.notifications.map(function(e){return l.default.createElement("div",{className:"thesis-tray-notification"},l.default.createElement("i",{className:"fa fa-exclamation-triangle fa-2x"}),e)}))}},{key:"render",value:function(){return l.default.createElement("div",{className:"thesis-tray-notifications"},this.renderNotifications())}}]),t}(l.default.Component);t.default=u},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),r=n(26),a=function(e){return e&&e.__esModule?e:{default:e}}(r),s=function(){function e(t){i(this,e),this.editor=null,this.editors=document.querySelectorAll(".thesis-content-html"),this.enabled=!1,this.onChange=t.onChange,this.changedHtmlEditor=this.changedHtmlEditor.bind(this)}return o(e,[{key:"enable",value:function(){this.enabled||(!this.editor&&this.editors.length>0&&(this.editor=new a.default(this.editors,this.mediumEditorOptions()),this.editor.subscribe("editableInput",this.changedHtmlEditor)),this.enabled=!0)}},{key:"disable",value:function(){this.enabled&&(this.editor&&this.editor.destroy(),this.editor=null,this.enabled=!1)}},{key:"content",value:function(e){return e.innerHTML}},{key:"set",value:function(e,t){var n=document.querySelector("[data-thesis-content-id='"+e+"']");n&&(n.innerHTML=t.content,n.classList.add("modified"))}},{key:"changedHtmlEditor",value:function(e,t){t.classList.add("modified"),this.onChange()}},{key:"mediumEditorOptions",value:function(){return{autoLink:!0,toolbar:{buttons:["bold","italic","underline","anchor","h1","h2","h3","h4","h5","h6","quote","orderedlist","unorderedlist","removeFormat","justifyLeft","justifyCenter","justifyRight"],static:!0,align:"center",sticky:!0,updateOnEmptySelection:!0},paste:{forcePlainText:!1,cleanPastedHTML:!0,cleanAttrs:["class","style","dir"],cleanTags:["meta","pre"]}}}}]),e}();t.default=s},function(e,t,n){(function(i){var o;/*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js */"classList"in document.createElement("_")||function(e){"use strict";if("Element"in e){var t=e.Element.prototype,n=Object,i=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},o=Array.prototype.indexOf||function(e){for(var t=0,n=this.length;t<n;t++)if(t in this&&this[t]===e)return t;return-1},r=function(e,t){this.name=e,this.code=DOMException[e],this.message=t},a=function(e,t){if(""===t)throw new r("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(t))throw new r("INVALID_CHARACTER_ERR","String contains an invalid character");return o.call(e,t)},s=function(e){for(var t=i.call(e.getAttribute("class")||""),n=t?t.split(/\s+/):[],o=0,r=n.length;o<r;o++)this.push(n[o]);this._updateClassName=function(){e.setAttribute("class",this.toString())}},l=s.prototype=[],u=function(){return new s(this)};if(r.prototype=Error.prototype,l.item=function(e){return this[e]||null},l.contains=function(e){return e+="",-1!==a(this,e)},l.add=function(){var e,t=arguments,n=0,i=t.length,o=!1;do{e=t[n]+"",-1===a(this,e)&&(this.push(e),o=!0)}while(++n<i);o&&this._updateClassName()},l.remove=function(){var e,t,n=arguments,i=0,o=n.length,r=!1;do{for(e=n[i]+"",t=a(this,e);-1!==t;)this.splice(t,1),r=!0,t=a(this,e)}while(++i<o);r&&this._updateClassName()},l.toggle=function(e,t){e+="";var n=this.contains(e),i=n?!0!==t&&"remove":!1!==t&&"add";return i&&this[i](e),!0===t||!1===t?t:!n},l.toString=function(){return this.join(" ")},n.defineProperty){var c={get:u,enumerable:!0,configurable:!0};try{n.defineProperty(t,"classList",c)}catch(e){-2146823252===e.number&&(c.enumerable=!1,n.defineProperty(t,"classList",c))}}else n.prototype.__defineGetter__&&t.__defineGetter__("classList",u)}}(self),/*! @source http://purl.eligrey.com/github/Blob.js/blob/master/Blob.js */function(e){"use strict";if(e.URL=e.URL||e.webkitURL,e.Blob&&e.URL)try{return void new Blob}catch(e){}var t=e.BlobBuilder||e.WebKitBlobBuilder||e.MozBlobBuilder||function(e){var t=function(e){return Object.prototype.toString.call(e).match(/^\[object\s(.*)\]$/)[1]},n=function(){this.data=[]},i=function(e,t,n){this.data=e,this.size=e.length,this.type=t,this.encoding=n},o=n.prototype,r=i.prototype,a=e.FileReaderSync,s=function(e){this.code=this[this.name=e]},l="NOT_FOUND_ERR SECURITY_ERR ABORT_ERR NOT_READABLE_ERR ENCODING_ERR NO_MODIFICATION_ALLOWED_ERR INVALID_STATE_ERR SYNTAX_ERR".split(" "),u=l.length,c=e.URL||e.webkitURL||e,d=c.createObjectURL,h=c.revokeObjectURL,f=c,p=e.btoa,m=e.atob,g=e.ArrayBuffer,v=e.Uint8Array,b=/^[\w-]+:\/*\[?[\w\.:-]+\]?(?::[0-9]+)?/;for(i.fake=r.fake=!0;u--;)s.prototype[l[u]]=u+1;return c.createObjectURL||(f=e.URL=function(e){var t,n=document.createElementNS("http://www.w3.org/1999/xhtml","a");return n.href=e,"origin"in n||("data:"===n.protocol.toLowerCase()?n.origin=null:(t=e.match(b),n.origin=t&&t[1])),n}),f.createObjectURL=function(e){var t,n=e.type;return null===n&&(n="application/octet-stream"),e instanceof i?(t="data:"+n,"base64"===e.encoding?t+";base64,"+e.data:"URI"===e.encoding?t+","+decodeURIComponent(e.data):p?t+";base64,"+p(e.data):t+","+encodeURIComponent(e.data)):d?d.call(c,e):void 0},f.revokeObjectURL=function(e){"data:"!==e.substring(0,5)&&h&&h.call(c,e)},o.append=function(e){var n=this.data;if(v&&(e instanceof g||e instanceof v)){for(var o="",r=new v(e),l=0,u=r.length;l<u;l++)o+=String.fromCharCode(r[l]);n.push(o)}else if("Blob"===t(e)||"File"===t(e)){if(!a)throw new s("NOT_READABLE_ERR");var c=new a;n.push(c.readAsBinaryString(e))}else e instanceof i?"base64"===e.encoding&&m?n.push(m(e.data)):"URI"===e.encoding?n.push(decodeURIComponent(e.data)):"raw"===e.encoding&&n.push(e.data):("string"!=typeof e&&(e+=""),n.push(unescape(encodeURIComponent(e))))},o.getBlob=function(e){return arguments.length||(e=null),new i(this.data.join(""),e,"raw")},o.toString=function(){return"[object BlobBuilder]"},r.slice=function(e,t,n){var o=arguments.length;return o<3&&(n=null),new i(this.data.slice(e,o>1?t:this.data.length),n,this.encoding)},r.toString=function(){return"[object Blob]"},r.close=function(){this.size=0,delete this.data},n}(e);e.Blob=function(e,n){var i=n?n.type||"":"",o=new t;if(e)for(var r=0,a=e.length;r<a;r++)Uint8Array&&e[r]instanceof Uint8Array?o.append(e[r].buffer):o.append(e[r]);var s=o.getBlob(i);return!s.slice&&s.webkitSlice&&(s.slice=s.webkitSlice),s};var n=Object.getPrototypeOf||function(e){return e.__proto__};e.Blob.prototype=n(new e.Blob)}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content||this),function(r,a){"use strict";"object"==typeof e&&void 0!==i&&i&&i.versions&&i.versions.electron||"object"!=typeof e?void 0!==(o=function(){return a}.call(t,n,t,e))&&(e.exports=o):e.exports=a}(0,function(){"use strict";function e(e,t){return this.init(e,t)}return e.extensions={},function(t){function n(e,t){var n,i=Array.prototype.slice.call(arguments,2);t=t||{};for(var o=0;o<i.length;o++){var r=i[o];if(r)for(n in r)r.hasOwnProperty(n)&&void 0!==r[n]&&(e||!1===t.hasOwnProperty(n))&&(t[n]=r[n])}return t}var i=!1;try{var o=document.createElement("div"),r=document.createTextNode(" ");o.appendChild(r),i=o.contains(r)}catch(e){}var a={isIE:"Microsoft Internet Explorer"===navigator.appName||"Netscape"===navigator.appName&&null!==new RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})").exec(navigator.userAgent),isEdge:null!==/Edge\/\d+/.exec(navigator.userAgent),isFF:navigator.userAgent.toLowerCase().indexOf("firefox")>-1,isMac:t.navigator.platform.toUpperCase().indexOf("MAC")>=0,keyCode:{BACKSPACE:8,TAB:9,ENTER:13,ESCAPE:27,SPACE:32,DELETE:46,K:75,M:77,V:86},isMetaCtrlKey:function(e){return!!(a.isMac&&e.metaKey||!a.isMac&&e.ctrlKey)},isKey:function(e,t){var n=a.getKeyCode(e);return!1===Array.isArray(t)?n===t:-1!==t.indexOf(n)},getKeyCode:function(e){var t=e.which;return null===t&&(t=null!==e.charCode?e.charCode:e.keyCode),t},blockContainerElementNames:["p","h1","h2","h3","h4","h5","h6","blockquote","pre","ul","li","ol","address","article","aside","audio","canvas","dd","dl","dt","fieldset","figcaption","figure","footer","form","header","hgroup","main","nav","noscript","output","section","video","table","thead","tbody","tfoot","tr","th","td"],emptyElementNames:["br","col","colgroup","hr","img","input","source","wbr"],extend:function(){var e=[!0].concat(Array.prototype.slice.call(arguments));return n.apply(this,e)},defaults:function(){var e=[!1].concat(Array.prototype.slice.call(arguments));return n.apply(this,e)},createLink:function(e,t,n,i){var o=e.createElement("a");return a.moveTextRangeIntoElement(t[0],t[t.length-1],o),o.setAttribute("href",n),i&&("_blank"===i&&o.setAttribute("rel","noopener noreferrer"),o.setAttribute("target",i)),o},findOrCreateMatchingTextNodes:function(e,t,n){for(var i=e.createTreeWalker(t,NodeFilter.SHOW_ALL,null,!1),o=[],r=0,s=!1,l=null,u=null;null!==(l=i.nextNode());)if(!(l.nodeType>3))if(3===l.nodeType){if(!s&&n.start<r+l.nodeValue.length&&(s=!0,u=a.splitStartNodeIfNeeded(l,n.start,r)),s&&a.splitEndNodeIfNeeded(l,u,n.end,r),s&&r===n.end)break;if(s&&r>n.end+1)throw new Error("PerformLinking overshot the target!");s&&o.push(u||l),r+=l.nodeValue.length,null!==u&&(r+=u.nodeValue.length,i.nextNode()),u=null}else"img"===l.tagName.toLowerCase()&&(!s&&n.start<=r&&(s=!0),s&&o.push(l));return o},splitStartNodeIfNeeded:function(e,t,n){return t!==n?e.splitText(t-n):null},splitEndNodeIfNeeded:function(e,t,n,i){var o,r;o=i+e.nodeValue.length+(t?t.nodeValue.length:0)-1,r=n-i-(t?e.nodeValue.length:0),o>=n&&i!==o&&0!==r&&(t||e).splitText(r)},splitByBlockElements:function(t){if(3!==t.nodeType&&1!==t.nodeType)return[];var n=[],i=e.util.blockContainerElementNames.join(",");if(3===t.nodeType||0===t.querySelectorAll(i).length)return[t];for(var o=0;o<t.childNodes.length;o++){var r=t.childNodes[o];if(3===r.nodeType)n.push(r);else if(1===r.nodeType){var a=r.querySelectorAll(i);0===a.length?n.push(r):n=n.concat(e.util.splitByBlockElements(r))}}return n},findAdjacentTextNodeWithContent:function(e,t,n){var i,o=!1,r=n.createNodeIterator(e,NodeFilter.SHOW_TEXT,null,!1);for(i=r.nextNode();i;){if(i===t)o=!0;else if(o&&3===i.nodeType&&i.nodeValue&&i.nodeValue.trim().length>0)break;i=r.nextNode()}return i},findPreviousSibling:function(e){if(!e||a.isMediumEditorElement(e))return!1;for(var t=e.previousSibling;!t&&!a.isMediumEditorElement(e.parentNode);)e=e.parentNode,t=e.previousSibling;return t},isDescendant:function(e,t,n){if(!e||!t)return!1;if(e===t)return!!n;if(1!==e.nodeType)return!1;if(i||3!==t.nodeType)return e.contains(t);for(var o=t.parentNode;null!==o;){if(o===e)return!0;o=o.parentNode}return!1},isElement:function(e){return!(!e||1!==e.nodeType)},throttle:function(e,t){var n,i,o,r=null,a=0,s=function(){a=Date.now(),r=null,o=e.apply(n,i),r||(n=i=null)};return t||0===t||(t=50),function(){var l=Date.now(),u=t-(l-a);return n=this,i=arguments,u<=0||u>t?(r&&(clearTimeout(r),r=null),a=l,o=e.apply(n,i),r||(n=i=null)):r||(r=setTimeout(s,u)),o}},traverseUp:function(e,t){if(!e)return!1;do{if(1===e.nodeType){if(t(e))return e;if(a.isMediumEditorElement(e))return!1}e=e.parentNode}while(e);return!1},htmlEntities:function(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")},insertHTMLCommand:function(t,n){var i,o,r,s,l,u,c,d=!1,h=["insertHTML",!1,n];if(!e.util.isEdge&&t.queryCommandSupported("insertHTML"))try{return t.execCommand.apply(t,h)}catch(e){}if(i=t.getSelection(),i.rangeCount){if(o=i.getRangeAt(0),c=o.commonAncestorContainer,a.isMediumEditorElement(c)&&!c.firstChild)o.selectNode(c.appendChild(t.createTextNode("")));else if(3===c.nodeType&&0===o.startOffset&&o.endOffset===c.nodeValue.length||3!==c.nodeType&&c.innerHTML===o.toString()){for(;!a.isMediumEditorElement(c)&&c.parentNode&&1===c.parentNode.childNodes.length&&!a.isMediumEditorElement(c.parentNode);)c=c.parentNode;o.selectNode(c)}for(o.deleteContents(),r=t.createElement("div"),r.innerHTML=n,s=t.createDocumentFragment();r.firstChild;)l=r.firstChild,u=s.appendChild(l);o.insertNode(s),u&&(o=o.cloneRange(),o.setStartAfter(u),o.collapse(!0),e.selection.selectRange(t,o)),d=!0}return t.execCommand.callListeners&&t.execCommand.callListeners(h,d),d},execFormatBlock:function(t,n){var i,o=a.getTopBlockContainer(e.selection.getSelectionStart(t));if("blockquote"===n){if(o&&(i=Array.prototype.slice.call(o.childNodes),i.some(function(e){return a.isBlockContainer(e)})))return t.execCommand("outdent",!1,null);if(a.isIE)return t.execCommand("indent",!1,n)}if(o&&n===o.nodeName.toLowerCase()&&(n="p"),a.isIE&&(n="<"+n+">"),o&&"blockquote"===o.nodeName.toLowerCase()){if(a.isIE&&"<p>"===n)return t.execCommand("outdent",!1,n);if((a.isFF||a.isEdge)&&"p"===n)return i=Array.prototype.slice.call(o.childNodes),i.some(function(e){return!a.isBlockContainer(e)})&&t.execCommand("formatBlock",!1,n),t.execCommand("outdent",!1,n)}return t.execCommand("formatBlock",!1,n)},setTargetBlank:function(e,t){var n,i=t||!1;if("a"===e.nodeName.toLowerCase())e.target="_blank",e.rel="noopener noreferrer";else for(e=e.getElementsByTagName("a"),n=0;n<e.length;n+=1)!1!==i&&i!==e[n].attributes.href.value||(e[n].target="_blank",e[n].rel="noopener noreferrer")},removeTargetBlank:function(e,t){var n;if("a"===e.nodeName.toLowerCase())e.removeAttribute("target"),e.removeAttribute("rel");else for(e=e.getElementsByTagName("a"),n=0;n<e.length;n+=1)t===e[n].attributes.href.value&&(e[n].removeAttribute("target"),e[n].removeAttribute("rel"))},addClassToAnchors:function(e,t){var n,i,o=t.split(" ");if("a"===e.nodeName.toLowerCase())for(i=0;i<o.length;i+=1)e.classList.add(o[i]);else{var r=e.getElementsByTagName("a");if(0===r.length){var s=a.getClosestTag(e,"a");e=s?[s]:[]}else e=r;for(n=0;n<e.length;n+=1)for(i=0;i<o.length;i+=1)e[n].classList.add(o[i])}},isListItem:function(e){if(!e)return!1;if("li"===e.nodeName.toLowerCase())return!0;for(var t=e.parentNode,n=t.nodeName.toLowerCase();"li"===n||!a.isBlockContainer(t)&&"div"!==n;){if("li"===n)return!0;if(!(t=t.parentNode))return!1;n=t.nodeName.toLowerCase()}return!1},cleanListDOM:function(t,n){if("li"===n.nodeName.toLowerCase()){var i=n.parentElement;"p"===i.parentElement.nodeName.toLowerCase()&&(a.unwrap(i.parentElement,t),e.selection.moveCursor(t,n.firstChild,n.firstChild.textContent.length))}},splitOffDOMTree:function(e,t,n){for(var i=t,o=null,r=!n;i!==e;){var a,s=i.parentNode,l=s.cloneNode(!1),u=r?i:s.firstChild;for(o&&(r?l.appendChild(o):a=o),o=l;u;){var c=u.nextSibling;u===i?(u.hasChildNodes()?u=u.cloneNode(!1):u.parentNode.removeChild(u),u.textContent&&o.appendChild(u),u=r?c:null):(u.parentNode.removeChild(u),(u.hasChildNodes()||u.textContent)&&o.appendChild(u),u=c)}a&&o.appendChild(a),i=s}return o},moveTextRangeIntoElement:function(e,t,n){if(!e||!t)return!1;var i=a.findCommonRoot(e,t);if(!i)return!1;if(t===e){var o=e.parentNode,r=e.nextSibling;return o.removeChild(e),n.appendChild(e),r?o.insertBefore(n,r):o.appendChild(n),n.hasChildNodes()}for(var s,l,u,c=[],d=0;d<i.childNodes.length;d++)if(u=i.childNodes[d],s){if(a.isDescendant(u,t,!0)){l=u;break}c.push(u)}else a.isDescendant(u,e,!0)&&(s=u);var h=l.nextSibling,f=i.ownerDocument.createDocumentFragment();return s===e?(s.parentNode.removeChild(s),f.appendChild(s)):f.appendChild(a.splitOffDOMTree(s,e)),c.forEach(function(e){e.parentNode.removeChild(e),f.appendChild(e)}),l===t?(l.parentNode.removeChild(l),f.appendChild(l)):f.appendChild(a.splitOffDOMTree(l,t,!0)),n.appendChild(f),l.parentNode===i?i.insertBefore(n,l):h?i.insertBefore(n,h):i.appendChild(n),n.hasChildNodes()},depthOfNode:function(e){for(var t=0,n=e;null!==n.parentNode;)n=n.parentNode,t++;return t},findCommonRoot:function(e,t){for(var n=a.depthOfNode(e),i=a.depthOfNode(t),o=e,r=t;n!==i;)n>i?(o=o.parentNode,n-=1):(r=r.parentNode,i-=1);for(;o!==r;)o=o.parentNode,r=r.parentNode;return o},isElementAtBeginningOfBlock:function(e){for(var t,n;!a.isBlockContainer(e)&&!a.isMediumEditorElement(e);){for(n=e;n=n.previousSibling;)if(t=3===n.nodeType?n.nodeValue:n.textContent,t.length>0)return!1;e=e.parentNode}return!0},isMediumEditorElement:function(e){return e&&e.getAttribute&&!!e.getAttribute("data-medium-editor-element")},getContainerEditorElement:function(e){return a.traverseUp(e,function(e){return a.isMediumEditorElement(e)})},isBlockContainer:function(e){return e&&3!==e.nodeType&&-1!==a.blockContainerElementNames.indexOf(e.nodeName.toLowerCase())},getClosestBlockContainer:function(e){return a.traverseUp(e,function(e){return a.isBlockContainer(e)||a.isMediumEditorElement(e)})},getTopBlockContainer:function(e){var t=!!a.isBlockContainer(e)&&e;return a.traverseUp(e,function(e){return a.isBlockContainer(e)&&(t=e),!(t||!a.isMediumEditorElement(e))&&(t=e,!0)}),t},getFirstSelectableLeafNode:function(e){for(;e&&e.firstChild;)e=e.firstChild;if(e=a.traverseUp(e,function(e){return-1===a.emptyElementNames.indexOf(e.nodeName.toLowerCase())}),"table"===e.nodeName.toLowerCase()){var t=e.querySelector("th, td");t&&(e=t)}return e},getFirstTextNode:function(e){return a.warn("getFirstTextNode is deprecated and will be removed in version 6.0.0"),a._getFirstTextNode(e)},_getFirstTextNode:function(e){if(3===e.nodeType)return e;for(var t=0;t<e.childNodes.length;t++){var n=a._getFirstTextNode(e.childNodes[t]);if(null!==n)return n}return null},ensureUrlHasProtocol:function(e){return-1===e.indexOf("://")?"http://"+e:e},warn:function(){void 0!==t.console&&"function"==typeof t.console.warn&&t.console.warn.apply(t.console,arguments)},deprecated:function(e,t,n){var i=e+" is deprecated, please use "+t+" instead.";n&&(i+=" Will be removed in "+n),a.warn(i)},deprecatedMethod:function(e,t,n,i){a.deprecated(e,t,i),"function"==typeof this[t]&&this[t].apply(this,n)},cleanupAttrs:function(e,t){t.forEach(function(t){e.removeAttribute(t)})},cleanupTags:function(e,t){-1!==t.indexOf(e.nodeName.toLowerCase())&&e.parentNode.removeChild(e)},unwrapTags:function(t,n){-1!==n.indexOf(t.nodeName.toLowerCase())&&e.util.unwrap(t,document)},getClosestTag:function(e,t){return a.traverseUp(e,function(e){return e.nodeName.toLowerCase()===t.toLowerCase()})},unwrap:function(e,t){for(var n=t.createDocumentFragment(),i=Array.prototype.slice.call(e.childNodes),o=0;o<i.length;o++)n.appendChild(i[o]);n.childNodes.length?e.parentNode.replaceChild(n,e):e.parentNode.removeChild(e)},guid:function(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()}};e.util=a}(window),function(){var t=function(t){e.util.extend(this,t)};t.extend=function(t){var n,i=this;n=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return i.apply(this,arguments)},e.util.extend(n,i);var o=function(){this.constructor=n};return o.prototype=i.prototype,n.prototype=new o,t&&e.util.extend(n.prototype,t),n},t.prototype={init:function(){},base:void 0,name:void 0,checkState:void 0,destroy:void 0,queryCommandState:void 0,isActive:void 0,isAlreadyApplied:void 0,setActive:void 0,setInactive:void 0,getInteractionElements:void 0,window:void 0,document:void 0,getEditorElements:function(){return this.base.elements},getEditorId:function(){return this.base.id},getEditorOption:function(e){return this.base.options[e]}},["execAction","on","off","subscribe","trigger"].forEach(function(e){t.prototype[e]=function(){return this.base[e].apply(this.base,arguments)}}),e.Extension=t}(),function(){function t(t){return e.util.isBlockContainer(t)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}var n={findMatchingSelectionParent:function(t,n){var i,o,r=n.getSelection();return 0!==r.rangeCount&&(i=r.getRangeAt(0),o=i.commonAncestorContainer,e.util.traverseUp(o,t))},getSelectionElement:function(t){return this.findMatchingSelectionParent(function(t){return e.util.isMediumEditorElement(t)},t)},exportSelection:function(e,t){if(!e)return null;var n=null,i=t.getSelection();if(i.rangeCount>0){var o,r=i.getRangeAt(0),a=r.cloneRange();a.selectNodeContents(e),a.setEnd(r.startContainer,r.startOffset),o=a.toString().length,n={start:o,end:o+r.toString().length},this.doesRangeStartWithImages(r,t)&&(n.startsWithImage=!0);var s=this.getTrailingImageCount(e,n,r.endContainer,r.endOffset);if(s&&(n.trailingImageCount=s),0!==o){var l=this.getIndexRelativeToAdjacentEmptyBlocks(t,e,r.startContainer,r.startOffset);-1!==l&&(n.emptyBlocksIndex=l)}}return n},importSelection:function(e,t,n,i){if(e&&t){var o=n.createRange();o.setStart(t,0),o.collapse(!0);var r,a=t,s=[],l=0,u=!1,c=!1,d=0,h=!1,f=!1,p=null;for((i||e.startsWithImage||void 0!==e.emptyBlocksIndex)&&(f=!0);!h&&a;)if(a.nodeType>3)a=s.pop();else{if(3!==a.nodeType||c){if(e.trailingImageCount&&c&&("img"===a.nodeName.toLowerCase()&&d++,d===e.trailingImageCount)){for(var m=0;a.parentNode.childNodes[m]!==a;)m++;o.setEnd(a.parentNode,m+1),h=!0}if(!h&&1===a.nodeType)for(var g=a.childNodes.length-1;g>=0;)s.push(a.childNodes[g]),g-=1}else r=l+a.length,!u&&e.start>=l&&e.start<=r&&(f||e.start<r?(o.setStart(a,e.start-l),u=!0):p=a),u&&e.end>=l&&e.end<=r&&(e.trailingImageCount?c=!0:(o.setEnd(a,e.end-l),h=!0)),l=r;h||(a=s.pop())}!u&&p&&(o.setStart(p,p.length),o.setEnd(p,p.length)),void 0!==e.emptyBlocksIndex&&(o=this.importSelectionMoveCursorPastBlocks(n,t,e.emptyBlocksIndex,o)),i&&(o=this.importSelectionMoveCursorPastAnchor(e,o)),this.selectRange(n,o)}},importSelectionMoveCursorPastAnchor:function(t,n){var i=function(e){return"a"===e.nodeName.toLowerCase()};if(t.start===t.end&&3===n.startContainer.nodeType&&n.startOffset===n.startContainer.nodeValue.length&&e.util.traverseUp(n.startContainer,i)){for(var o=n.startContainer,r=n.startContainer.parentNode;null!==r&&"a"!==r.nodeName.toLowerCase();)r.childNodes[r.childNodes.length-1]!==o?r=null:(o=r,r=r.parentNode);if(null!==r&&"a"===r.nodeName.toLowerCase()){for(var a=null,s=0;null===a&&s<r.parentNode.childNodes.length;s++)r.parentNode.childNodes[s]===r&&(a=s);n.setStart(r.parentNode,a+1),n.collapse(!0)}}return n},importSelectionMoveCursorPastBlocks:function(n,i,o,r){var a,s,l=n.createTreeWalker(i,NodeFilter.SHOW_ELEMENT,t,!1),u=r.startContainer,c=0;for(o=o||1,a=3===u.nodeType&&e.util.isBlockContainer(u.previousSibling)?u.previousSibling:e.util.getClosestBlockContainer(u);l.nextNode();)if(s){if(s=l.currentNode,++c===o)break;if(s.textContent.length>0)break}else a===l.currentNode&&(s=l.currentNode);return s||(s=a),r.setStart(e.util.getFirstSelectableLeafNode(s),0),r},getIndexRelativeToAdjacentEmptyBlocks:function(n,i,o,r){if(o.textContent.length>0&&r>0)return-1;var a=o;if(3!==a.nodeType&&(a=o.childNodes[r]),a){if(!e.util.isElementAtBeginningOfBlock(a))return-1;var s=e.util.findPreviousSibling(a);if(!s)return-1;if(s.nodeValue)return-1}for(var l=e.util.getClosestBlockContainer(o),u=n.createTreeWalker(i,NodeFilter.SHOW_ELEMENT,t,!1),c=0;u.nextNode();){var d=""===u.currentNode.textContent;if((d||c>0)&&(c+=1),u.currentNode===l)return c;d||(c=0)}return c},doesRangeStartWithImages:function(e,t){if(0!==e.startOffset||1!==e.startContainer.nodeType)return!1;if("img"===e.startContainer.nodeName.toLowerCase())return!0;var n=e.startContainer.querySelector("img");if(!n)return!1;for(var i=t.createTreeWalker(e.startContainer,NodeFilter.SHOW_ALL,null,!1);i.nextNode();){var o=i.currentNode;if(o===n)break;if(o.nodeValue)return!1}return!0},getTrailingImageCount:function(e,t,n,i){if(0===i||1!==n.nodeType)return 0;if("img"!==n.nodeName.toLowerCase()&&!n.querySelector("img"))return 0;for(var o=n.childNodes[i-1];o.hasChildNodes();)o=o.lastChild;for(var r,a=e,s=[],l=0,u=!1,c=!1,d=!1,h=0;!d&&a;)if(a.nodeType>3)a=s.pop();else{if(3!==a.nodeType||c){if("img"===a.nodeName.toLowerCase()&&h++,a===o)d=!0;else if(1===a.nodeType)for(var f=a.childNodes.length-1;f>=0;)s.push(a.childNodes[f]),f-=1}else h=0,r=l+a.length,!u&&t.start>=l&&t.start<=r&&(u=!0),u&&t.end>=l&&t.end<=r&&(c=!0),l=r;d||(a=s.pop())}return h},selectionContainsContent:function(e){var t=e.getSelection();if(!t||t.isCollapsed||!t.rangeCount)return!1;if(""!==t.toString().trim())return!0;var n=this.getSelectedParentElement(t.getRangeAt(0));return!(!n||!("img"===n.nodeName.toLowerCase()||1===n.nodeType&&n.querySelector("img")))},selectionInContentEditableFalse:function(e){var t,n=this.findMatchingSelectionParent(function(e){var n=e&&e.getAttribute("contenteditable");return"true"===n&&(t=!0),"#text"!==e.nodeName&&"false"===n},e);return!t&&n},getSelectionHtml:function(e){var t,n,i,o="",r=e.getSelection();if(r.rangeCount){for(i=e.createElement("div"),t=0,n=r.rangeCount;t<n;t+=1)i.appendChild(r.getRangeAt(t).cloneContents());o=i.innerHTML}return o},getCaretOffsets:function(e,t){var n,i;return t||(t=window.getSelection().getRangeAt(0)),n=t.cloneRange(),i=t.cloneRange(),n.selectNodeContents(e),n.setEnd(t.endContainer,t.endOffset),i.selectNodeContents(e),i.setStart(t.endContainer,t.endOffset),{left:n.toString().length,right:i.toString().length}},rangeSelectsSingleNode:function(e){var t=e.startContainer;return t===e.endContainer&&t.hasChildNodes()&&e.endOffset===e.startOffset+1},getSelectedParentElement:function(e){return e?this.rangeSelectsSingleNode(e)&&3!==e.startContainer.childNodes[e.startOffset].nodeType?e.startContainer.childNodes[e.startOffset]:3===e.startContainer.nodeType?e.startContainer.parentNode:e.startContainer:null},getSelectedElements:function(e){var t,n,i,o=e.getSelection();if(!o.rangeCount||o.isCollapsed||!o.getRangeAt(0).commonAncestorContainer)return[];if(t=o.getRangeAt(0),3===t.commonAncestorContainer.nodeType){for(n=[],i=t.commonAncestorContainer;i.parentNode&&1===i.parentNode.childNodes.length;)n.push(i.parentNode),i=i.parentNode;return n}return[].filter.call(t.commonAncestorContainer.getElementsByTagName("*"),function(e){return"function"!=typeof o.containsNode||o.containsNode(e,!0)})},selectNode:function(e,t){var n=t.createRange();n.selectNodeContents(e),this.selectRange(t,n)},select:function(e,t,n,i,o){var r=e.createRange();return r.setStart(t,n),i?r.setEnd(i,o):r.collapse(!0),this.selectRange(e,r),r},clearSelection:function(e,t){t?e.getSelection().collapseToStart():e.getSelection().collapseToEnd()},moveCursor:function(e,t,n){this.select(e,t,n)},getSelectionRange:function(e){var t=e.getSelection();return 0===t.rangeCount?null:t.getRangeAt(0)},selectRange:function(e,t){var n=e.getSelection();n.removeAllRanges(),n.addRange(t)},getSelectionStart:function(e){var t=e.getSelection().anchorNode;return t&&3===t.nodeType?t.parentNode:t}};e.selection=n}(),function(){function t(t,n){return!!t&&t.some(function(t){if("function"!=typeof t.getInteractionElements)return!1;var i=t.getInteractionElements();return!!i&&(Array.isArray(i)||(i=[i]),i.some(function(t){return e.util.isDescendant(t,n,!0)}))})}var n=function(e){this.base=e,this.options=this.base.options,this.events=[],this.disabledEvents={},this.customEvents={},this.listeners={}};n.prototype={InputEventOnContenteditableSupported:!e.util.isIE&&!e.util.isEdge,attachDOMEvent:function(t,n,i,o){var r=this.base.options.contentWindow,a=this.base.options.ownerDocument;t=e.util.isElement(t)||[r,a].indexOf(t)>-1?[t]:t,Array.prototype.forEach.call(t,function(e){e.addEventListener(n,i,o),this.events.push([e,n,i,o])}.bind(this))},detachDOMEvent:function(t,n,i,o){var r,a,s=this.base.options.contentWindow,l=this.base.options.ownerDocument;t&&(t=e.util.isElement(t)||[s,l].indexOf(t)>-1?[t]:t,Array.prototype.forEach.call(t,function(e){-1!==(r=this.indexOfListener(e,n,i,o))&&(a=this.events.splice(r,1)[0],a[0].removeEventListener(a[1],a[2],a[3]))}.bind(this)))},indexOfListener:function(e,t,n,i){var o,r,a;for(o=0,r=this.events.length;o<r;o+=1)if(a=this.events[o],a[0]===e&&a[1]===t&&a[2]===n&&a[3]===i)return o;return-1},detachAllDOMEvents:function(){for(var e=this.events.pop();e;)e[0].removeEventListener(e[1],e[2],e[3]),e=this.events.pop()},detachAllEventsFromElement:function(e){for(var t=this.events.filter(function(t){return t&&t[0].getAttribute&&t[0].getAttribute("medium-editor-index")===e.getAttribute("medium-editor-index")}),n=0,i=t.length;n<i;n++){var o=t[n];this.detachDOMEvent(o[0],o[1],o[2],o[3])}},attachAllEventsToElement:function(e){this.listeners.editableInput&&(this.contentCache[e.getAttribute("medium-editor-index")]=e.innerHTML),this.eventsCache&&this.eventsCache.forEach(function(t){this.attachDOMEvent(e,t.name,t.handler.bind(this))},this)},enableCustomEvent:function(e){void 0!==this.disabledEvents[e]&&delete this.disabledEvents[e]},disableCustomEvent:function(e){this.disabledEvents[e]=!0},attachCustomEvent:function(e,t){this.setupListener(e),this.customEvents[e]||(this.customEvents[e]=[]),this.customEvents[e].push(t)},detachCustomEvent:function(e,t){var n=this.indexOfCustomListener(e,t);-1!==n&&this.customEvents[e].splice(n,1)},indexOfCustomListener:function(e,t){return this.customEvents[e]&&this.customEvents[e].length?this.customEvents[e].indexOf(t):-1},detachAllCustomEvents:function(){this.customEvents={}},triggerCustomEvent:function(e,t,n){this.customEvents[e]&&!this.disabledEvents[e]&&this.customEvents[e].forEach(function(e){e(t,n)})},destroy:function(){this.detachAllDOMEvents(),this.detachAllCustomEvents(),this.detachExecCommand(),this.base.elements&&this.base.elements.forEach(function(e){e.removeAttribute("data-medium-focused")})},attachToExecCommand:function(){this.execCommandListener||(this.execCommandListener=function(e){this.handleDocumentExecCommand(e)}.bind(this),this.wrapExecCommand(),this.options.ownerDocument.execCommand.listeners.push(this.execCommandListener))},detachExecCommand:function(){var e=this.options.ownerDocument;if(this.execCommandListener&&e.execCommand.listeners){var t=e.execCommand.listeners.indexOf(this.execCommandListener);-1!==t&&e.execCommand.listeners.splice(t,1),e.execCommand.listeners.length||this.unwrapExecCommand()}},wrapExecCommand:function(){var e=this.options.ownerDocument;if(!e.execCommand.listeners){var t=function(t,n){e.execCommand.listeners&&e.execCommand.listeners.forEach(function(e){e({command:t[0],value:t[2],args:t,result:n})})},n=function(){var n=e.execCommand.orig.apply(this,arguments);if(!e.execCommand.listeners)return n;var i=Array.prototype.slice.call(arguments);return t(i,n),n};n.orig=e.execCommand,n.listeners=[],n.callListeners=t,e.execCommand=n}},unwrapExecCommand:function(){var e=this.options.ownerDocument;e.execCommand.orig&&(e.execCommand=e.execCommand.orig)},setupListener:function(e){if(!this.listeners[e]){switch(e){case"externalInteraction":this.attachDOMEvent(this.options.ownerDocument.body,"mousedown",this.handleBodyMousedown.bind(this),!0),this.attachDOMEvent(this.options.ownerDocument.body,"click",this.handleBodyClick.bind(this),!0),this.attachDOMEvent(this.options.ownerDocument.body,"focus",this.handleBodyFocus.bind(this),!0);break;case"blur":case"focus":this.setupListener("externalInteraction");break;case"editableInput":this.contentCache={},this.base.elements.forEach(function(e){this.contentCache[e.getAttribute("medium-editor-index")]=e.innerHTML},this),this.InputEventOnContenteditableSupported&&this.attachToEachElement("input",this.handleInput),this.InputEventOnContenteditableSupported||(this.setupListener("editableKeypress"),this.keypressUpdateInput=!0,this.attachDOMEvent(document,"selectionchange",this.handleDocumentSelectionChange.bind(this)),this.attachToExecCommand());break;case"editableClick":this.attachToEachElement("click",this.handleClick);break;case"editableBlur":this.attachToEachElement("blur",this.handleBlur);break;case"editableKeypress":this.attachToEachElement("keypress",this.handleKeypress);break;case"editableKeyup":this.attachToEachElement("keyup",this.handleKeyup);break;case"editableKeydown":this.attachToEachElement("keydown",this.handleKeydown);break;case"editableKeydownSpace":case"editableKeydownEnter":case"editableKeydownTab":case"editableKeydownDelete":this.setupListener("editableKeydown");break;case"editableMouseover":this.attachToEachElement("mouseover",this.handleMouseover);break;case"editableDrag":this.attachToEachElement("dragover",this.handleDragging),this.attachToEachElement("dragleave",this.handleDragging);break;case"editableDrop":this.attachToEachElement("drop",this.handleDrop);break;case"editablePaste":this.attachToEachElement("paste",this.handlePaste)}this.listeners[e]=!0}},attachToEachElement:function(e,t){this.eventsCache||(this.eventsCache=[]),this.base.elements.forEach(function(n){this.attachDOMEvent(n,e,t.bind(this))},this),this.eventsCache.push({name:e,handler:t})},cleanupElement:function(e){var t=e.getAttribute("medium-editor-index");t&&(this.detachAllEventsFromElement(e),this.contentCache&&delete this.contentCache[t])},focusElement:function(e){e.focus(),this.updateFocus(e,{target:e,type:"focus"})},updateFocus:function(n,i){var o,r=this.base.getFocusedElement();r&&"click"===i.type&&this.lastMousedownTarget&&(e.util.isDescendant(r,this.lastMousedownTarget,!0)||t(this.base.extensions,this.lastMousedownTarget))&&(o=r),o||this.base.elements.some(function(t){return!o&&e.util.isDescendant(t,n,!0)&&(o=t),!!o},this);var a=!e.util.isDescendant(r,n,!0)&&!t(this.base.extensions,n);o!==r&&(r&&a&&(r.removeAttribute("data-medium-focused"),this.triggerCustomEvent("blur",i,r)),o&&(o.setAttribute("data-medium-focused",!0),this.triggerCustomEvent("focus",i,o))),a&&this.triggerCustomEvent("externalInteraction",i)},updateInput:function(e,t){if(this.contentCache){var n=e.getAttribute("medium-editor-index"),i=e.innerHTML;i!==this.contentCache[n]&&this.triggerCustomEvent("editableInput",t,e),this.contentCache[n]=i}},handleDocumentSelectionChange:function(t){if(t.currentTarget&&t.currentTarget.activeElement){var n,i=t.currentTarget.activeElement;this.base.elements.some(function(t){return!!e.util.isDescendant(t,i,!0)&&(n=t,!0)},this),n&&this.updateInput(n,{target:i,currentTarget:n})}},handleDocumentExecCommand:function(){var e=this.base.getFocusedElement();e&&this.updateInput(e,{target:e,currentTarget:e})},handleBodyClick:function(e){this.updateFocus(e.target,e)},handleBodyFocus:function(e){this.updateFocus(e.target,e)},handleBodyMousedown:function(e){this.lastMousedownTarget=e.target},handleInput:function(e){this.updateInput(e.currentTarget,e)},handleClick:function(e){this.triggerCustomEvent("editableClick",e,e.currentTarget)},handleBlur:function(e){this.triggerCustomEvent("editableBlur",e,e.currentTarget)},handleKeypress:function(e){if(this.triggerCustomEvent("editableKeypress",e,e.currentTarget),this.keypressUpdateInput){var t={target:e.target,currentTarget:e.currentTarget};setTimeout(function(){this.updateInput(t.currentTarget,t)}.bind(this),0)}},handleKeyup:function(e){this.triggerCustomEvent("editableKeyup",e,e.currentTarget)},handleMouseover:function(e){this.triggerCustomEvent("editableMouseover",e,e.currentTarget)},handleDragging:function(e){this.triggerCustomEvent("editableDrag",e,e.currentTarget)},handleDrop:function(e){this.triggerCustomEvent("editableDrop",e,e.currentTarget)},handlePaste:function(e){this.triggerCustomEvent("editablePaste",e,e.currentTarget)},handleKeydown:function(t){return this.triggerCustomEvent("editableKeydown",t,t.currentTarget),e.util.isKey(t,e.util.keyCode.SPACE)?this.triggerCustomEvent("editableKeydownSpace",t,t.currentTarget):e.util.isKey(t,e.util.keyCode.ENTER)||t.ctrlKey&&e.util.isKey(t,e.util.keyCode.M)?this.triggerCustomEvent("editableKeydownEnter",t,t.currentTarget):e.util.isKey(t,e.util.keyCode.TAB)?this.triggerCustomEvent("editableKeydownTab",t,t.currentTarget):e.util.isKey(t,[e.util.keyCode.DELETE,e.util.keyCode.BACKSPACE])?this.triggerCustomEvent("editableKeydownDelete",t,t.currentTarget):void 0}},e.Events=n}(),function(){var t=e.Extension.extend({action:void 0,aria:void 0,tagNames:void 0,style:void 0,useQueryState:void 0,contentDefault:void 0,contentFA:void 0,classList:void 0,attrs:void 0,constructor:function(n){t.isBuiltInButton(n)?e.Extension.call(this,this.defaults[n]):e.Extension.call(this,n)},init:function(){e.Extension.prototype.init.apply(this,arguments),this.button=this.createButton(),this.on(this.button,"click",this.handleClick.bind(this))},getButton:function(){return this.button},getAction:function(){return"function"==typeof this.action?this.action(this.base.options):this.action},getAria:function(){return"function"==typeof this.aria?this.aria(this.base.options):this.aria},getTagNames:function(){return"function"==typeof this.tagNames?this.tagNames(this.base.options):this.tagNames},createButton:function(){var e=this.document.createElement("button"),t=this.contentDefault,n=this.getAria(),i=this.getEditorOption("buttonLabels");return e.classList.add("medium-editor-action"),e.classList.add("medium-editor-action-"+this.name),this.classList&&this.classList.forEach(function(t){e.classList.add(t)}),e.setAttribute("data-action",this.getAction()),n&&(e.setAttribute("title",n),e.setAttribute("aria-label",n)),this.attrs&&Object.keys(this.attrs).forEach(function(t){e.setAttribute(t,this.attrs[t])},this),"fontawesome"===i&&this.contentFA&&(t=this.contentFA),e.innerHTML=t,e},handleClick:function(e){e.preventDefault(),e.stopPropagation();var t=this.getAction();t&&this.execAction(t)},isActive:function(){return this.button.classList.contains(this.getEditorOption("activeButtonClass"))},setInactive:function(){this.button.classList.remove(this.getEditorOption("activeButtonClass")),delete this.knownState},setActive:function(){this.button.classList.add(this.getEditorOption("activeButtonClass")),delete this.knownState},queryCommandState:function(){var e=null;return this.useQueryState&&(e=this.base.queryCommandState(this.getAction())),e},isAlreadyApplied:function(e){var t,n,i=!1,o=this.getTagNames();return!1===this.knownState||!0===this.knownState?this.knownState:(o&&o.length>0&&(i=-1!==o.indexOf(e.nodeName.toLowerCase())),!i&&this.style&&(t=this.style.value.split("|"),n=this.window.getComputedStyle(e,null).getPropertyValue(this.style.prop),t.forEach(function(e){this.knownState||((i=-1!==n.indexOf(e))||"text-decoration"!==this.style.prop)&&(this.knownState=i)},this)),i)}});t.isBuiltInButton=function(t){return"string"==typeof t&&e.extensions.button.prototype.defaults.hasOwnProperty(t)},e.extensions.button=t}(),function(){e.extensions.button.prototype.defaults={bold:{name:"bold",action:"bold",aria:"bold",tagNames:["b","strong"],style:{prop:"font-weight",value:"700|bold"},useQueryState:!0,contentDefault:"<b>B</b>",contentFA:'<i class="fa fa-bold"></i>'},italic:{name:"italic",action:"italic",aria:"italic",tagNames:["i","em"],style:{prop:"font-style",value:"italic"},useQueryState:!0,contentDefault:"<b><i>I</i></b>",contentFA:'<i class="fa fa-italic"></i>'},underline:{name:"underline",action:"underline",aria:"underline",tagNames:["u"],style:{prop:"text-decoration",value:"underline"},useQueryState:!0,contentDefault:"<b><u>U</u></b>",contentFA:'<i class="fa fa-underline"></i>'},strikethrough:{name:"strikethrough",action:"strikethrough",aria:"strike through",tagNames:["strike"],style:{prop:"text-decoration",value:"line-through"},useQueryState:!0,contentDefault:"<s>A</s>",contentFA:'<i class="fa fa-strikethrough"></i>'},superscript:{name:"superscript",action:"superscript",aria:"superscript",tagNames:["sup"],contentDefault:"<b>x<sup>1</sup></b>",contentFA:'<i class="fa fa-superscript"></i>'},subscript:{name:"subscript",action:"subscript",aria:"subscript",tagNames:["sub"],contentDefault:"<b>x<sub>1</sub></b>",contentFA:'<i class="fa fa-subscript"></i>'},image:{name:"image",action:"image",aria:"image",tagNames:["img"],contentDefault:"<b>image</b>",contentFA:'<i class="fa fa-picture-o"></i>'},html:{name:"html",action:"html",aria:"evaluate html",tagNames:["iframe","object"],contentDefault:"<b>html</b>",contentFA:'<i class="fa fa-code"></i>'},orderedlist:{name:"orderedlist",action:"insertorderedlist",aria:"ordered list",tagNames:["ol"],useQueryState:!0,contentDefault:"<b>1.</b>",contentFA:'<i class="fa fa-list-ol"></i>'},unorderedlist:{name:"unorderedlist",action:"insertunorderedlist",aria:"unordered list",tagNames:["ul"],useQueryState:!0,contentDefault:"<b>•</b>",contentFA:'<i class="fa fa-list-ul"></i>'},indent:{name:"indent",action:"indent",aria:"indent",tagNames:[],contentDefault:"<b>→</b>",contentFA:'<i class="fa fa-indent"></i>'},outdent:{name:"outdent",action:"outdent",aria:"outdent",tagNames:[],contentDefault:"<b>←</b>",contentFA:'<i class="fa fa-outdent"></i>'},justifyCenter:{name:"justifyCenter",action:"justifyCenter",aria:"center justify",tagNames:[],style:{prop:"text-align",value:"center"},contentDefault:"<b>C</b>",contentFA:'<i class="fa fa-align-center"></i>'},justifyFull:{name:"justifyFull",action:"justifyFull",aria:"full justify",tagNames:[],style:{prop:"text-align",value:"justify"},contentDefault:"<b>J</b>",contentFA:'<i class="fa fa-align-justify"></i>'},justifyLeft:{name:"justifyLeft",action:"justifyLeft",aria:"left justify",tagNames:[],style:{prop:"text-align",value:"left"},contentDefault:"<b>L</b>",contentFA:'<i class="fa fa-align-left"></i>'},justifyRight:{name:"justifyRight",action:"justifyRight",aria:"right justify",tagNames:[],style:{prop:"text-align",value:"right"},contentDefault:"<b>R</b>",contentFA:'<i class="fa fa-align-right"></i>'},removeFormat:{name:"removeFormat",aria:"remove formatting",action:"removeFormat",contentDefault:"<b>X</b>",contentFA:'<i class="fa fa-eraser"></i>'},quote:{name:"quote",action:"append-blockquote",aria:"blockquote",tagNames:["blockquote"],contentDefault:"<b>“</b>",contentFA:'<i class="fa fa-quote-right"></i>'},pre:{name:"pre",action:"append-pre",aria:"preformatted text",tagNames:["pre"],contentDefault:"<b>0101</b>",contentFA:'<i class="fa fa-code fa-lg"></i>'},h1:{name:"h1",action:"append-h1",aria:"header type one",tagNames:["h1"],contentDefault:"<b>H1</b>",contentFA:'<i class="fa fa-header"><sup>1</sup>'},h2:{name:"h2",action:"append-h2",aria:"header type two",tagNames:["h2"],contentDefault:"<b>H2</b>",contentFA:'<i class="fa fa-header"><sup>2</sup>'},h3:{name:"h3",action:"append-h3",aria:"header type three",tagNames:["h3"],contentDefault:"<b>H3</b>",contentFA:'<i class="fa fa-header"><sup>3</sup>'},h4:{name:"h4",action:"append-h4",aria:"header type four",tagNames:["h4"],contentDefault:"<b>H4</b>",contentFA:'<i class="fa fa-header"><sup>4</sup>'},h5:{name:"h5",action:"append-h5",aria:"header type five",tagNames:["h5"],contentDefault:"<b>H5</b>",contentFA:'<i class="fa fa-header"><sup>5</sup>'},h6:{name:"h6",action:"append-h6",aria:"header type six",tagNames:["h6"],contentDefault:"<b>H6</b>",contentFA:'<i class="fa fa-header"><sup>6</sup>'}}}(),function(){var t=e.extensions.button.extend({init:function(){e.extensions.button.prototype.init.apply(this,arguments)},formSaveLabel:"✓",formCloseLabel:"×",activeClass:"medium-editor-toolbar-form-active",hasForm:!0,getForm:function(){},isDisplayed:function(){return!!this.hasForm&&this.getForm().classList.contains(this.activeClass)},showForm:function(){this.hasForm&&this.getForm().classList.add(this.activeClass)},hideForm:function(){this.hasForm&&this.getForm().classList.remove(this.activeClass)},showToolbarDefaultActions:function(){var e=this.base.getExtensionByName("toolbar");e&&e.showToolbarDefaultActions()},hideToolbarDefaultActions:function(){var e=this.base.getExtensionByName("toolbar");e&&e.hideToolbarDefaultActions()},setToolbarPosition:function(){var e=this.base.getExtensionByName("toolbar");e&&e.setToolbarPosition()}});e.extensions.form=t}(),function(){var t=e.extensions.form.extend({customClassOption:null,customClassOptionText:"Button",linkValidation:!1,placeholderText:"Paste or type a link",targetCheckbox:!1,targetCheckboxText:"Open in new window",name:"anchor",action:"createLink",aria:"link",tagNames:["a"],contentDefault:"<b>#</b>",contentFA:'<i class="fa fa-link"></i>',init:function(){e.extensions.form.prototype.init.apply(this,arguments),this.subscribe("editableKeydown",this.handleKeydown.bind(this))},handleClick:function(t){t.preventDefault(),t.stopPropagation();var n=e.selection.getSelectionRange(this.document);return"a"===n.startContainer.nodeName.toLowerCase()||"a"===n.endContainer.nodeName.toLowerCase()||e.util.getClosestTag(e.selection.getSelectedParentElement(n),"a")?this.execAction("unlink"):(this.isDisplayed()||this.showForm(),!1)},handleKeydown:function(t){e.util.isKey(t,e.util.keyCode.K)&&e.util.isMetaCtrlKey(t)&&!t.shiftKey&&this.handleClick(t)},getForm:function(){return this.form||(this.form=this.createForm()),this.form},getTemplate:function(){var e=['<input type="text" class="medium-editor-toolbar-input" placeholder="',this.placeholderText,'">'];return e.push('<a href="#" class="medium-editor-toolbar-save">',"fontawesome"===this.getEditorOption("buttonLabels")?'<i class="fa fa-check"></i>':this.formSaveLabel,"</a>"),e.push('<a href="#" class="medium-editor-toolbar-close">',"fontawesome"===this.getEditorOption("buttonLabels")?'<i class="fa fa-times"></i>':this.formCloseLabel,"</a>"),this.targetCheckbox&&e.push('<div class="medium-editor-toolbar-form-row">','<input type="checkbox" class="medium-editor-toolbar-anchor-target" id="medium-editor-toolbar-anchor-target-field-'+this.getEditorId()+'">','<label for="medium-editor-toolbar-anchor-target-field-'+this.getEditorId()+'">',this.targetCheckboxText,"</label>","</div>"),this.customClassOption&&e.push('<div class="medium-editor-toolbar-form-row">','<input type="checkbox" class="medium-editor-toolbar-anchor-button">',"<label>",this.customClassOptionText,"</label>","</div>"),e.join("")},isDisplayed:function(){return e.extensions.form.prototype.isDisplayed.apply(this)},hideForm:function(){e.extensions.form.prototype.hideForm.apply(this),this.getInput().value=""},showForm:function(t){var n=this.getInput(),i=this.getAnchorTargetCheckbox(),o=this.getAnchorButtonCheckbox();if(t=t||{value:""},"string"==typeof t&&(t={value:t}),this.base.saveSelection(),this.hideToolbarDefaultActions(),e.extensions.form.prototype.showForm.apply(this),this.setToolbarPosition(),n.value=t.value,n.focus(),i&&(i.checked="_blank"===t.target),o){var r=t.buttonClass?t.buttonClass.split(" "):[];o.checked=-1!==r.indexOf(this.customClassOption)}},destroy:function(){if(!this.form)return!1;this.form.parentNode&&this.form.parentNode.removeChild(this.form),delete this.form},getFormOpts:function(){var e=this.getAnchorTargetCheckbox(),t=this.getAnchorButtonCheckbox(),n={value:this.getInput().value.trim()};return this.linkValidation&&(n.value=this.checkLinkFormat(n.value)),n.target="_self",e&&e.checked&&(n.target="_blank"),t&&t.checked&&(n.buttonClass=this.customClassOption),n},doFormSave:function(){var e=this.getFormOpts();this.completeFormSave(e)},completeFormSave:function(e){this.base.restoreSelection(),this.execAction(this.action,e),this.base.checkSelection()},ensureEncodedUri:function(e){return e===decodeURI(e)?encodeURI(e):e},ensureEncodedUriComponent:function(e){return e===decodeURIComponent(e)?encodeURIComponent(e):e},ensureEncodedParam:function(e){var t=e.split("="),n=t[0],i=t[1];return n+(void 0===i?"":"="+this.ensureEncodedUriComponent(i))},ensureEncodedQuery:function(e){return e.split("&").map(this.ensureEncodedParam.bind(this)).join("&")},checkLinkFormat:function(e){var t=/^([a-z]+:)?\/\/|^(mailto|tel|maps):|^\#/i,n=t.test(e),i="",o=/^\+?\s?\(?(?:\d\s?\-?\)?){3,20}$/,r=e.match(/^(.*?)(?:\?(.*?))?(?:#(.*))?$/),a=r[1],s=r[2],l=r[3];if(o.test(e))return"tel:"+e;if(!n){var u=a.split("/")[0];(u.match(/.+(\.|:).+/)||"localhost"===u)&&(i="http://")}return i+this.ensureEncodedUri(a)+(void 0===s?"":"?"+this.ensureEncodedQuery(s))+(void 0===l?"":"#"+l)},doFormCancel:function(){this.base.restoreSelection(),this.base.checkSelection()},attachFormEvents:function(e){var t=e.querySelector(".medium-editor-toolbar-close"),n=e.querySelector(".medium-editor-toolbar-save"),i=e.querySelector(".medium-editor-toolbar-input");this.on(e,"click",this.handleFormClick.bind(this)),this.on(i,"keyup",this.handleTextboxKeyup.bind(this)),this.on(t,"click",this.handleCloseClick.bind(this)),this.on(n,"click",this.handleSaveClick.bind(this),!0)},createForm:function(){var e=this.document,t=e.createElement("div");return t.className="medium-editor-toolbar-form",t.id="medium-editor-toolbar-form-anchor-"+this.getEditorId(),t.innerHTML=this.getTemplate(),this.attachFormEvents(t),t},getInput:function(){return this.getForm().querySelector("input.medium-editor-toolbar-input")},getAnchorTargetCheckbox:function(){return this.getForm().querySelector(".medium-editor-toolbar-anchor-target")},getAnchorButtonCheckbox:function(){return this.getForm().querySelector(".medium-editor-toolbar-anchor-button")},handleTextboxKeyup:function(t){if(t.keyCode===e.util.keyCode.ENTER)return t.preventDefault(),void this.doFormSave();t.keyCode===e.util.keyCode.ESCAPE&&(t.preventDefault(),this.doFormCancel())},handleFormClick:function(e){e.stopPropagation()},handleSaveClick:function(e){e.preventDefault(),this.doFormSave()},handleCloseClick:function(e){e.preventDefault(),this.doFormCancel()}});e.extensions.anchor=t}(),function(){var t=e.Extension.extend({name:"anchor-preview",hideDelay:500,previewValueSelector:"a",showWhenToolbarIsVisible:!1,showOnEmptyLinks:!0,init:function(){this.anchorPreview=this.createPreview(),this.getEditorOption("elementsContainer").appendChild(this.anchorPreview),this.attachToEditables()},getInteractionElements:function(){return this.getPreviewElement()},getPreviewElement:function(){return this.anchorPreview},createPreview:function(){var e=this.document.createElement("div");return e.id="medium-editor-anchor-preview-"+this.getEditorId(),e.className="medium-editor-anchor-preview",e.innerHTML=this.getTemplate(),this.on(e,"click",this.handleClick.bind(this)),e},getTemplate:function(){return'<div class="medium-editor-toolbar-anchor-preview" id="medium-editor-toolbar-anchor-preview"> <a class="medium-editor-toolbar-anchor-preview-inner"></a></div>'},destroy:function(){this.anchorPreview&&(this.anchorPreview.parentNode&&this.anchorPreview.parentNode.removeChild(this.anchorPreview),delete this.anchorPreview)},hidePreview:function(){this.anchorPreview&&this.anchorPreview.classList.remove("medium-editor-anchor-preview-active"),this.activeAnchor=null},showPreview:function(e){return!(!this.anchorPreview.classList.contains("medium-editor-anchor-preview-active")&&!e.getAttribute("data-disable-preview"))||(this.previewValueSelector&&(this.anchorPreview.querySelector(this.previewValueSelector).textContent=e.attributes.href.value,this.anchorPreview.querySelector(this.previewValueSelector).href=e.attributes.href.value),this.anchorPreview.classList.add("medium-toolbar-arrow-over"),this.anchorPreview.classList.remove("medium-toolbar-arrow-under"),this.anchorPreview.classList.contains("medium-editor-anchor-preview-active")||this.anchorPreview.classList.add("medium-editor-anchor-preview-active"),this.activeAnchor=e,this.positionPreview(),this.attachPreviewHandlers(),this)},positionPreview:function(e){e=e||this.activeAnchor;var t,n,i,o,r,a=this.window.innerWidth,s=this.anchorPreview.offsetHeight,l=e.getBoundingClientRect(),u=this.diffLeft,c=this.diffTop,d=this.getEditorOption("elementsContainer"),h=["absolute","fixed"].indexOf(window.getComputedStyle(d).getPropertyValue("position"))>-1,f={};t=this.anchorPreview.offsetWidth/2;var p=this.base.getExtensionByName("toolbar");p&&(u=p.diffLeft,c=p.diffTop),n=u-t,h?(o=d.getBoundingClientRect(),["top","left"].forEach(function(e){f[e]=l[e]-o[e]}),f.width=l.width,f.height=l.height,l=f,a=o.width,r=d.scrollTop):r=this.window.pageYOffset,i=l.left+l.width/2,r+=s+l.top+l.height-c-this.anchorPreview.offsetHeight,this.anchorPreview.style.top=Math.round(r)+"px",this.anchorPreview.style.right="initial",i<t?(this.anchorPreview.style.left=n+t+"px",this.anchorPreview.style.right="initial"):a-i<t?(this.anchorPreview.style.left="auto",this.anchorPreview.style.right=0):(this.anchorPreview.style.left=n+i+"px",this.anchorPreview.style.right="initial")},attachToEditables:function(){this.subscribe("editableMouseover",this.handleEditableMouseover.bind(this)),this.subscribe("positionedToolbar",this.handlePositionedToolbar.bind(this))},handlePositionedToolbar:function(){this.showWhenToolbarIsVisible||this.hidePreview()},handleClick:function(e){var t=this.base.getExtensionByName("anchor"),n=this.activeAnchor;t&&n&&(e.preventDefault(),this.base.selectElement(this.activeAnchor),this.base.delay(function(){if(n){var e={value:n.attributes.href.value,target:n.getAttribute("target"),buttonClass:n.getAttribute("class")};t.showForm(e),n=null}}.bind(this))),this.hidePreview()},handleAnchorMouseout:function(){this.anchorToPreview=null,this.off(this.activeAnchor,"mouseout",this.instanceHandleAnchorMouseout),this.instanceHandleAnchorMouseout=null},handleEditableMouseover:function(t){var n=e.util.getClosestTag(t.target,"a");if(!1!==n){if(!this.showOnEmptyLinks&&(!/href=["']\S+["']/.test(n.outerHTML)||/href=["']#\S+["']/.test(n.outerHTML)))return!0;var i=this.base.getExtensionByName("toolbar");if(!this.showWhenToolbarIsVisible&&i&&i.isDisplayed&&i.isDisplayed())return!0;this.activeAnchor&&this.activeAnchor!==n&&this.detachPreviewHandlers(),this.anchorToPreview=n,this.instanceHandleAnchorMouseout=this.handleAnchorMouseout.bind(this),this.on(this.anchorToPreview,"mouseout",this.instanceHandleAnchorMouseout),this.base.delay(function(){this.anchorToPreview&&this.showPreview(this.anchorToPreview)}.bind(this))}},handlePreviewMouseover:function(){this.lastOver=(new Date).getTime(),this.hovering=!0},handlePreviewMouseout:function(e){e.relatedTarget&&/anchor-preview/.test(e.relatedTarget.className)||(this.hovering=!1)},updatePreview:function(){if(this.hovering)return!0;(new Date).getTime()-this.lastOver>this.hideDelay&&this.detachPreviewHandlers()},detachPreviewHandlers:function(){clearInterval(this.intervalTimer),this.instanceHandlePreviewMouseover&&(this.off(this.anchorPreview,"mouseover",this.instanceHandlePreviewMouseover),this.off(this.anchorPreview,"mouseout",this.instanceHandlePreviewMouseout),this.activeAnchor&&(this.off(this.activeAnchor,"mouseover",this.instanceHandlePreviewMouseover),this.off(this.activeAnchor,"mouseout",this.instanceHandlePreviewMouseout))),this.hidePreview(),this.hovering=this.instanceHandlePreviewMouseover=this.instanceHandlePreviewMouseout=null},attachPreviewHandlers:function(){this.lastOver=(new Date).getTime(),this.hovering=!0,this.instanceHandlePreviewMouseover=this.handlePreviewMouseover.bind(this),this.instanceHandlePreviewMouseout=this.handlePreviewMouseout.bind(this),this.intervalTimer=setInterval(this.updatePreview.bind(this),200),this.on(this.anchorPreview,"mouseover",this.instanceHandlePreviewMouseover),this.on(this.anchorPreview,"mouseout",this.instanceHandlePreviewMouseout),this.on(this.activeAnchor,"mouseover",this.instanceHandlePreviewMouseover),this.on(this.activeAnchor,"mouseout",this.instanceHandlePreviewMouseout)}});e.extensions.anchorPreview=t}(),function(){function t(t){return!e.util.getClosestTag(t,"a")}var n,i,o,r,a;n=[" ","\t","\n","\r"," "," "," "," "," ","\u2028","\u2029"],i="com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|ja|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw",o="(((?:(https?://|ftps?://|nntp://)|www\\d{0,3}[.]|[a-z0-9.\\-]+[.]("+i+")\\/)\\S+(?:[^\\s`!\\[\\]{};:'\".,?«»“”‘’])))|(([a-z0-9\\-]+\\.)?[a-z0-9\\-]+\\.("+i+"))",r=new RegExp("^("+i+")$","i"),a=new RegExp(o,"gi");var s=e.Extension.extend({init:function(){e.Extension.prototype.init.apply(this,arguments),this.disableEventHandling=!1,this.subscribe("editableKeypress",this.onKeypress.bind(this)),this.subscribe("editableBlur",this.onBlur.bind(this)),this.document.execCommand("AutoUrlDetect",!1,!1)},isLastInstance:function(){for(var e=0,t=0;t<this.window._mediumEditors.length;t++){var n=this.window._mediumEditors[t];null!==n&&void 0!==n.getExtensionByName("autoLink")&&e++}return 1===e},destroy:function(){this.document.queryCommandSupported("AutoUrlDetect")&&this.isLastInstance()&&this.document.execCommand("AutoUrlDetect",!1,!0)},onBlur:function(e,t){this.performLinking(t)},onKeypress:function(t){this.disableEventHandling||e.util.isKey(t,[e.util.keyCode.SPACE,e.util.keyCode.ENTER])&&(clearTimeout(this.performLinkingTimeout),this.performLinkingTimeout=setTimeout(function(){try{var e=this.base.exportSelection();this.performLinking(t.target)&&this.base.importSelection(e,!0)}catch(e){window.console&&window.console.error("Failed to perform linking",e),this.disableEventHandling=!0}}.bind(this),0))},performLinking:function(t){var n=e.util.splitByBlockElements(t),i=!1;0===n.length&&(n=[t]);for(var o=0;o<n.length;o++)i=this.removeObsoleteAutoLinkSpans(n[o])||i,i=this.performLinkingWithinElement(n[o])||i;return this.base.events.updateInput(t,{target:t,currentTarget:t}),i},removeObsoleteAutoLinkSpans:function(n){if(!n||3===n.nodeType)return!1;for(var i=n.querySelectorAll('span[data-auto-link="true"]'),o=!1,r=0;r<i.length;r++){var a=i[r].textContent;if(-1===a.indexOf("://")&&(a=e.util.ensureUrlHasProtocol(a)),i[r].getAttribute("data-href")!==a&&t(i[r])){o=!0;var s=a.replace(/\s+$/,"");if(i[r].getAttribute("data-href")===s){var l=a.length-s.length,u=e.util.splitOffDOMTree(i[r],this.splitTextBeforeEnd(i[r],l));i[r].parentNode.insertBefore(u,i[r].nextSibling)}else e.util.unwrap(i[r],this.document)}}return o},splitTextBeforeEnd:function(e,t){for(var n=this.document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null,!1),i=!0;i;)i=null!==n.lastChild();for(var o,r,a;t>0&&null!==a;)o=n.currentNode,r=o.nodeValue,r.length>t?(a=o.splitText(r.length-t),t=0):(a=n.previousNode(),t-=r.length);return a},performLinkingWithinElement:function(t){for(var n=this.findLinkableText(t),i=0;i<n.length;i++){var o=e.util.findOrCreateMatchingTextNodes(this.document,t,n[i]);this.shouldNotLink(o)||this.createAutoLink(o,n[i].href)}return!1},shouldNotLink:function(t){for(var n=!1,i=0;i<t.length&&!1===n;i++)n=!!e.util.traverseUp(t[i],function(e){return"a"===e.nodeName.toLowerCase()||e.getAttribute&&"true"===e.getAttribute("data-auto-link")});return n},findLinkableText:function(e){for(var t=e.textContent,i=null,o=[];null!==(i=a.exec(t));){var s=!0,l=i.index+i[0].length;s=!(0!==i.index&&-1===n.indexOf(t[i.index-1])||l!==t.length&&-1===n.indexOf(t[l])),s=s&&(-1!==i[0].indexOf("/")||r.test(i[0].split(".").pop().split("?").shift())),s&&o.push({href:i[0],start:i.index,end:l})}return o},createAutoLink:function(t,n){n=e.util.ensureUrlHasProtocol(n);var i=e.util.createLink(this.document,t,n,this.getEditorOption("targetBlank")?"_blank":null),o=this.document.createElement("span");for(o.setAttribute("data-auto-link","true"),o.setAttribute("data-href",n),i.insertBefore(o,i.firstChild);i.childNodes.length>1;)o.appendChild(i.childNodes[1])}});e.extensions.autoLink=s}(),function(){function t(t){var i=e.util.getContainerEditorElement(t);Array.prototype.slice.call(i.parentElement.querySelectorAll("."+n)).forEach(function(e){e.classList.remove(n)})}var n="medium-editor-dragover",i=e.Extension.extend({name:"fileDragging",allowedTypes:["image"],init:function(){e.Extension.prototype.init.apply(this,arguments),this.subscribe("editableDrag",this.handleDrag.bind(this)),this.subscribe("editableDrop",this.handleDrop.bind(this))},handleDrag:function(e){e.preventDefault(),e.dataTransfer.dropEffect="copy";var i=e.target.classList?e.target:e.target.parentElement;t(i),"dragover"===e.type&&i.classList.add(n)},handleDrop:function(e){e.preventDefault(),e.stopPropagation(),this.base.selectElement(e.target);var n=this.base.exportSelection();n.start=n.end,this.base.importSelection(n),e.dataTransfer.files&&Array.prototype.slice.call(e.dataTransfer.files).forEach(function(e){this.isAllowedFile(e)&&e.type.match("image")&&this.insertImageFile(e)},this),t(e.target)},isAllowedFile:function(e){return this.allowedTypes.some(function(t){return!!e.type.match(t)})},insertImageFile:function(t){if("function"==typeof FileReader){var n=new FileReader;n.readAsDataURL(t),n.addEventListener("load",function(t){var n=this.document.createElement("img");n.src=t.target.result,e.util.insertHTMLCommand(this.document,n.outerHTML)}.bind(this))}}});e.extensions.fileDragging=i}(),function(){var t=e.Extension.extend({name:"keyboard-commands",commands:[{command:"bold",key:"B",meta:!0,shift:!1,alt:!1},{command:"italic",key:"I",meta:!0,shift:!1,alt:!1},{command:"underline",key:"U",meta:!0,shift:!1,alt:!1}],init:function(){e.Extension.prototype.init.apply(this,arguments),this.subscribe("editableKeydown",this.handleKeydown.bind(this)),this.keys={},this.commands.forEach(function(e){var t=e.key.charCodeAt(0);this.keys[t]||(this.keys[t]=[]),this.keys[t].push(e)},this)},handleKeydown:function(t){var n=e.util.getKeyCode(t);if(this.keys[n]){var i=e.util.isMetaCtrlKey(t),o=!!t.shiftKey,r=!!t.altKey;this.keys[n].forEach(function(e){e.meta!==i||e.shift!==o||e.alt!==r&&void 0!==e.alt||(t.preventDefault(),t.stopPropagation(),"function"==typeof e.command?e.command.apply(this):!1!==e.command&&this.execAction(e.command))},this)}}});e.extensions.keyboardCommands=t}(),function(){var t=e.extensions.form.extend({name:"fontname",action:"fontName",aria:"change font name",contentDefault:"±",contentFA:'<i class="fa fa-font"></i>',fonts:["","Arial","Verdana","Times New Roman"],init:function(){e.extensions.form.prototype.init.apply(this,arguments)},handleClick:function(e){if(e.preventDefault(),e.stopPropagation(),!this.isDisplayed()){var t=this.document.queryCommandValue("fontName")+"";this.showForm(t)}return!1},getForm:function(){return this.form||(this.form=this.createForm()),this.form},isDisplayed:function(){return"block"===this.getForm().style.display},hideForm:function(){this.getForm().style.display="none",this.getSelect().value=""},showForm:function(e){var t=this.getSelect();this.base.saveSelection(),this.hideToolbarDefaultActions(),this.getForm().style.display="block",this.setToolbarPosition(),t.value=e||"",t.focus()},destroy:function(){if(!this.form)return!1;this.form.parentNode&&this.form.parentNode.removeChild(this.form),delete this.form},doFormSave:function(){this.base.restoreSelection(),this.base.checkSelection()},doFormCancel:function(){this.base.restoreSelection(),this.clearFontName(),this.base.checkSelection()},createForm:function(){var e,t=this.document,n=t.createElement("div"),i=t.createElement("select"),o=t.createElement("a"),r=t.createElement("a");n.className="medium-editor-toolbar-form",n.id="medium-editor-toolbar-form-fontname-"+this.getEditorId(),this.on(n,"click",this.handleFormClick.bind(this));for(var a=0;a<this.fonts.length;a++)e=t.createElement("option"),e.innerHTML=this.fonts[a],e.value=this.fonts[a],i.appendChild(e);return i.className="medium-editor-toolbar-select",n.appendChild(i),this.on(i,"change",this.handleFontChange.bind(this)),r.setAttribute("href","#"),r.className="medium-editor-toobar-save",r.innerHTML="fontawesome"===this.getEditorOption("buttonLabels")?'<i class="fa fa-check"></i>':"✓",n.appendChild(r),this.on(r,"click",this.handleSaveClick.bind(this),!0),o.setAttribute("href","#"),o.className="medium-editor-toobar-close",o.innerHTML="fontawesome"===this.getEditorOption("buttonLabels")?'<i class="fa fa-times"></i>':"×",n.appendChild(o),this.on(o,"click",this.handleCloseClick.bind(this)),n},getSelect:function(){return this.getForm().querySelector("select.medium-editor-toolbar-select")},clearFontName:function(){e.selection.getSelectedElements(this.document).forEach(function(e){"font"===e.nodeName.toLowerCase()&&e.hasAttribute("face")&&e.removeAttribute("face")})},handleFontChange:function(){var e=this.getSelect().value;""===e?this.clearFontName():this.execAction("fontName",{value:e})},handleFormClick:function(e){e.stopPropagation()},handleSaveClick:function(e){e.preventDefault(),this.doFormSave()},handleCloseClick:function(e){e.preventDefault(),this.doFormCancel()}});e.extensions.fontName=t}(),function(){var t=e.extensions.form.extend({name:"fontsize",action:"fontSize",aria:"increase/decrease font size",contentDefault:"±",contentFA:'<i class="fa fa-text-height"></i>',init:function(){e.extensions.form.prototype.init.apply(this,arguments)},handleClick:function(e){if(e.preventDefault(),e.stopPropagation(),!this.isDisplayed()){var t=this.document.queryCommandValue("fontSize")+"";this.showForm(t)}return!1},getForm:function(){return this.form||(this.form=this.createForm()),this.form},isDisplayed:function(){return"block"===this.getForm().style.display},hideForm:function(){this.getForm().style.display="none",this.getInput().value=""},showForm:function(e){var t=this.getInput();this.base.saveSelection(),this.hideToolbarDefaultActions(),this.getForm().style.display="block",this.setToolbarPosition(),t.value=e||"",t.focus()},destroy:function(){if(!this.form)return!1;this.form.parentNode&&this.form.parentNode.removeChild(this.form),delete this.form},doFormSave:function(){this.base.restoreSelection(),this.base.checkSelection()},doFormCancel:function(){this.base.restoreSelection(),this.clearFontSize(),this.base.checkSelection()},createForm:function(){var e=this.document,t=e.createElement("div"),n=e.createElement("input"),i=e.createElement("a"),o=e.createElement("a");return t.className="medium-editor-toolbar-form",t.id="medium-editor-toolbar-form-fontsize-"+this.getEditorId(),this.on(t,"click",this.handleFormClick.bind(this)),n.setAttribute("type","range"),n.setAttribute("min","1"),n.setAttribute("max","7"),n.className="medium-editor-toolbar-input",t.appendChild(n),this.on(n,"change",this.handleSliderChange.bind(this)),o.setAttribute("href","#"),o.className="medium-editor-toobar-save",o.innerHTML="fontawesome"===this.getEditorOption("buttonLabels")?'<i class="fa fa-check"></i>':"✓",t.appendChild(o),this.on(o,"click",this.handleSaveClick.bind(this),!0),i.setAttribute("href","#"),i.className="medium-editor-toobar-close",i.innerHTML="fontawesome"===this.getEditorOption("buttonLabels")?'<i class="fa fa-times"></i>':"×",t.appendChild(i),this.on(i,"click",this.handleCloseClick.bind(this)),t},getInput:function(){return this.getForm().querySelector("input.medium-editor-toolbar-input")},clearFontSize:function(){e.selection.getSelectedElements(this.document).forEach(function(e){"font"===e.nodeName.toLowerCase()&&e.hasAttribute("size")&&e.removeAttribute("size")})},handleSliderChange:function(){var e=this.getInput().value;"4"===e?this.clearFontSize():this.execAction("fontSize",{value:e})},handleFormClick:function(e){e.stopPropagation()},handleSaveClick:function(e){e.preventDefault(),this.doFormSave()},handleCloseClick:function(e){e.preventDefault(),this.doFormCancel()}});e.extensions.fontSize=t}(),function(){function t(){return[[new RegExp(/^[\s\S]*<body[^>]*>\s*|\s*<\/body[^>]*>[\s\S]*$/g),""],[new RegExp(/<!--StartFragment-->|<!--EndFragment-->/g),""],[new RegExp(/<br>$/i),""],[new RegExp(/<[^>]*docs-internal-guid[^>]*>/gi),""],[new RegExp(/<\/b>(<br[^>]*>)?$/gi),""],[new RegExp(/<span class="Apple-converted-space">\s+<\/span>/g)," "],[new RegExp(/<br class="Apple-interchange-newline">/g),"<br>"],[new RegExp(/<span[^>]*(font-style:italic;font-weight:(bold|700)|font-weight:(bold|700);font-style:italic)[^>]*>/gi),'<span class="replace-with italic bold">'],[new RegExp(/<span[^>]*font-style:italic[^>]*>/gi),'<span class="replace-with italic">'],[new RegExp(/<span[^>]*font-weight:(bold|700)[^>]*>/gi),'<span class="replace-with bold">'],[new RegExp(/<(\/?)(i|b|a)>/gi),"<$1$2>"],[new RegExp(/<a(?:(?!href).)+href=(?:"|”|“|"|“|”)(((?!"|”|“|"|“|”).)*)(?:"|”|“|"|“|”)(?:(?!>).)*>/gi),'<a href="$1">'],[new RegExp(/<\/p>\n+/gi),"</p>"],[new RegExp(/\n+<p/gi),"<p"],[new RegExp(/<\/?o:[a-z]*>/gi),""],[new RegExp(/<!\[if !supportLists\]>(((?!<!).)*)<!\[endif]\>/gi),"$1"]]}function n(e,t,n){var i=e.clipboardData||t.clipboardData||n.dataTransfer,o={};if(!i)return o;if(i.getData){var r=i.getData("Text");r&&r.length>0&&(o["text/plain"]=r)}if(i.types)for(var a=0;a<i.types.length;a++){var s=i.types[a];o[s]=i.getData(s)}return o}var i=null,o=null,r=function(e){e.stopPropagation()},a=e.Extension.extend({forcePlainText:!0,cleanPastedHTML:!1,preCleanReplacements:[],cleanReplacements:[],cleanAttrs:["class","style","dir"],cleanTags:["meta"],unwrapTags:[],init:function(){e.Extension.prototype.init.apply(this,arguments),(this.forcePlainText||this.cleanPastedHTML)&&(this.subscribe("editableKeydown",this.handleKeydown.bind(this)),this.getEditorElements().forEach(function(e){this.on(e,"paste",this.handlePaste.bind(this))},this),this.subscribe("addElement",this.handleAddElement.bind(this)))},handleAddElement:function(e,t){this.on(t,"paste",this.handlePaste.bind(this))},destroy:function(){(this.forcePlainText||this.cleanPastedHTML)&&this.removePasteBin()},handlePaste:function(e,t){if(!e.defaultPrevented){var i=n(e,this.window,this.document),o=i["text/html"],r=i["text/plain"];this.window.clipboardData&&void 0===e.clipboardData&&!o&&(o=r),(o||r)&&(e.preventDefault(),this.doPaste(o,r,t))}},doPaste:function(t,n,i){var o,r,a="";if(this.cleanPastedHTML&&t)return this.cleanPaste(t);if(n){if(this.getEditorOption("disableReturn")||i&&i.getAttribute("data-disable-return"))a=e.util.htmlEntities(n);else if(o=n.split(/[\r\n]+/g),o.length>1)for(r=0;r<o.length;r+=1)""!==o[r]&&(a+="<p>"+e.util.htmlEntities(o[r])+"</p>");else a=e.util.htmlEntities(o[0]);e.util.insertHTMLCommand(this.document,a)}},handlePasteBinPaste:function(e){if(e.defaultPrevented)return void this.removePasteBin();var t=n(e,this.window,this.document),i=t["text/html"],r=t["text/plain"],a=o;if(!this.cleanPastedHTML||i)return e.preventDefault(),this.removePasteBin(),this.doPaste(i,r,a),void this.trigger("editablePaste",{currentTarget:a,target:a},a);setTimeout(function(){this.cleanPastedHTML&&(i=this.getPasteBinHtml()),this.removePasteBin(),this.doPaste(i,r,a),this.trigger("editablePaste",{currentTarget:a,target:a},a)}.bind(this),0)},handleKeydown:function(t,n){e.util.isKey(t,e.util.keyCode.V)&&e.util.isMetaCtrlKey(t)&&(t.stopImmediatePropagation(),this.removePasteBin(),this.createPasteBin(n))},createPasteBin:function(t){var n,a=e.selection.getSelectionRange(this.document),s=this.window.pageYOffset;o=t,a&&(n=a.getClientRects(),n.length?s+=n[0].top:void 0!==a.startContainer.getBoundingClientRect?s+=a.startContainer.getBoundingClientRect().top:s+=a.getBoundingClientRect().top),i=a;var l=this.document.createElement("div");l.id=this.pasteBinId="medium-editor-pastebin-"+ +Date.now(),l.setAttribute("style","border: 1px red solid; position: absolute; top: "+s+"px; width: 10px; height: 10px; overflow: hidden; opacity: 0"),l.setAttribute("contentEditable",!0),l.innerHTML="%ME_PASTEBIN%",this.document.body.appendChild(l),this.on(l,"focus",r),this.on(l,"focusin",r),this.on(l,"focusout",r),l.focus(),e.selection.selectNode(l,this.document),this.boundHandlePaste||(this.boundHandlePaste=this.handlePasteBinPaste.bind(this)),this.on(l,"paste",this.boundHandlePaste)},removePasteBin:function(){null!==i&&(e.selection.selectRange(this.document,i),i=null),null!==o&&(o=null);var t=this.getPasteBin();t&&t&&(this.off(t,"focus",r),this.off(t,"focusin",r),this.off(t,"focusout",r),this.off(t,"paste",this.boundHandlePaste),t.parentElement.removeChild(t))},getPasteBin:function(){return this.document.getElementById(this.pasteBinId)},getPasteBinHtml:function(){var e=this.getPasteBin();if(!e)return!1;if(e.firstChild&&"mcepastebin"===e.firstChild.id)return!1;var t=e.innerHTML;return!(!t||"%ME_PASTEBIN%"===t)&&t},cleanPaste:function(e){var n,i,o,r,a=/<p|<br|<div/.test(e),s=[].concat(this.preCleanReplacements||[],t(),this.cleanReplacements||[]);for(n=0;n<s.length;n+=1)e=e.replace(s[n][0],s[n][1]);if(!a)return this.pasteHTML(e);for(o=this.document.createElement("div"),o.innerHTML="<p>"+e.split("<br><br>").join("</p><p>")+"</p>",i=o.querySelectorAll("a,p,div,br"),n=0;n<i.length;n+=1)switch(r=i[n],r.innerHTML=r.innerHTML.replace(/\n/gi," "),r.nodeName.toLowerCase()){case"p":case"div":this.filterCommonBlocks(r);break;case"br":this.filterLineBreak(r)}this.pasteHTML(o.innerHTML)},pasteHTML:function(t,n){n=e.util.defaults({},n,{cleanAttrs:this.cleanAttrs,cleanTags:this.cleanTags,unwrapTags:this.unwrapTags});var i,o,r,a,s=this.document.createDocumentFragment();for(s.appendChild(this.document.createElement("body")),a=s.querySelector("body"),a.innerHTML=t,this.cleanupSpans(a),i=a.querySelectorAll("*"),r=0;r<i.length;r+=1)o=i[r],"a"===o.nodeName.toLowerCase()&&this.getEditorOption("targetBlank")&&e.util.setTargetBlank(o),e.util.cleanupAttrs(o,n.cleanAttrs),e.util.cleanupTags(o,n.cleanTags),e.util.unwrapTags(o,n.unwrapTags);e.util.insertHTMLCommand(this.document,a.innerHTML.replace(/ /g," "))},isCommonBlock:function(e){return e&&("p"===e.nodeName.toLowerCase()||"div"===e.nodeName.toLowerCase())},filterCommonBlocks:function(e){/^\s*$/.test(e.textContent)&&e.parentNode&&e.parentNode.removeChild(e)},filterLineBreak:function(e){this.isCommonBlock(e.previousElementSibling)?this.removeWithParent(e):!this.isCommonBlock(e.parentNode)||e.parentNode.firstChild!==e&&e.parentNode.lastChild!==e?e.parentNode&&1===e.parentNode.childElementCount&&""===e.parentNode.textContent&&this.removeWithParent(e):this.removeWithParent(e)},removeWithParent:function(e){e&&e.parentNode&&(e.parentNode.parentNode&&1===e.parentNode.childElementCount?e.parentNode.parentNode.removeChild(e.parentNode):e.parentNode.removeChild(e))},cleanupSpans:function(t){var n,i,o,r=t.querySelectorAll(".replace-with"),a=function(e){return e&&"#text"!==e.nodeName&&"false"===e.getAttribute("contenteditable")};for(n=0;n<r.length;n+=1)i=r[n],o=this.document.createElement(i.classList.contains("bold")?"b":"i"),i.classList.contains("bold")&&i.classList.contains("italic")?o.innerHTML="<i>"+i.innerHTML+"</i>":o.innerHTML=i.innerHTML,i.parentNode.replaceChild(o,i);for(r=t.querySelectorAll("span"),n=0;n<r.length;n+=1){if(i=r[n],e.util.traverseUp(i,a))return!1;e.util.unwrap(i,this.document)}}});e.extensions.paste=a}(),function(){var t=e.Extension.extend({name:"placeholder",text:"Type your text",hideOnClick:!0,init:function(){e.Extension.prototype.init.apply(this,arguments),this.initPlaceholders(),this.attachEventHandlers()},initPlaceholders:function(){this.getEditorElements().forEach(this.initElement,this)},handleAddElement:function(e,t){this.initElement(t)},initElement:function(e){e.getAttribute("data-placeholder")||e.setAttribute("data-placeholder",this.text),this.updatePlaceholder(e)},destroy:function(){this.getEditorElements().forEach(this.cleanupElement,this)},handleRemoveElement:function(e,t){this.cleanupElement(t)},cleanupElement:function(e){e.getAttribute("data-placeholder")===this.text&&e.removeAttribute("data-placeholder")},showPlaceholder:function(t){t&&(e.util.isFF&&0===t.childNodes.length?(t.classList.add("medium-editor-placeholder-relative"),t.classList.remove("medium-editor-placeholder")):(t.classList.add("medium-editor-placeholder"),t.classList.remove("medium-editor-placeholder-relative")))},hidePlaceholder:function(e){e&&(e.classList.remove("medium-editor-placeholder"),e.classList.remove("medium-editor-placeholder-relative"))},updatePlaceholder:function(e,t){if(e.querySelector("img, blockquote, ul, ol, table")||""!==e.textContent.replace(/^\s+|\s+$/g,""))return this.hidePlaceholder(e);t||this.showPlaceholder(e)},attachEventHandlers:function(){this.hideOnClick&&this.subscribe("focus",this.handleFocus.bind(this)),this.subscribe("editableInput",this.handleInput.bind(this)),this.subscribe("blur",this.handleBlur.bind(this)),this.subscribe("addElement",this.handleAddElement.bind(this)),this.subscribe("removeElement",this.handleRemoveElement.bind(this))},handleInput:function(e,t){var n=this.hideOnClick&&t===this.base.getFocusedElement();this.updatePlaceholder(t,n)},handleFocus:function(e,t){this.hidePlaceholder(t)},handleBlur:function(e,t){this.updatePlaceholder(t)}});e.extensions.placeholder=t}(),function(){var t=e.Extension.extend({name:"toolbar",align:"center",allowMultiParagraphSelection:!0,buttons:["bold","italic","underline","anchor","h2","h3","quote"],diffLeft:0,diffTop:-10,firstButtonClass:"medium-editor-button-first",lastButtonClass:"medium-editor-button-last",standardizeSelectionStart:!1,static:!1,sticky:!1,stickyTopOffset:0,updateOnEmptySelection:!1,relativeContainer:null,init:function(){e.Extension.prototype.init.apply(this,arguments),this.initThrottledMethods(),this.relativeContainer?this.relativeContainer.appendChild(this.getToolbarElement()):this.getEditorOption("elementsContainer").appendChild(this.getToolbarElement())},forEachExtension:function(e,t){return this.base.extensions.forEach(function(n){if(n!==this)return e.apply(t||this,arguments)},this)},createToolbar:function(){var e=this.document.createElement("div");return e.id="medium-editor-toolbar-"+this.getEditorId(),e.className="medium-editor-toolbar",this.static?e.className+=" static-toolbar":this.relativeContainer?e.className+=" medium-editor-relative-toolbar":e.className+=" medium-editor-stalker-toolbar",e.appendChild(this.createToolbarButtons()),this.forEachExtension(function(t){t.hasForm&&e.appendChild(t.getForm())}),this.attachEventHandlers(),e},createToolbarButtons:function(){var t,n,i,o,r,a,s=this.document.createElement("ul");return s.id="medium-editor-toolbar-actions"+this.getEditorId(),s.className="medium-editor-toolbar-actions",s.style.display="block",this.buttons.forEach(function(i){"string"==typeof i?(r=i,a=null):(r=i.name,a=i),(o=this.base.addBuiltInExtension(r,a))&&"function"==typeof o.getButton&&(n=o.getButton(this.base),t=this.document.createElement("li"),e.util.isElement(n)?t.appendChild(n):t.innerHTML=n,s.appendChild(t))},this),i=s.querySelectorAll("button"),i.length>0&&(i[0].classList.add(this.firstButtonClass),i[i.length-1].classList.add(this.lastButtonClass)),s},destroy:function(){this.toolbar&&(this.toolbar.parentNode&&this.toolbar.parentNode.removeChild(this.toolbar),delete this.toolbar)},getInteractionElements:function(){return this.getToolbarElement()},getToolbarElement:function(){return this.toolbar||(this.toolbar=this.createToolbar()),this.toolbar},getToolbarActionsElement:function(){return this.getToolbarElement().querySelector(".medium-editor-toolbar-actions")},initThrottledMethods:function(){this.throttledPositionToolbar=e.util.throttle(function(){this.base.isActive&&this.positionToolbarIfShown()}.bind(this))},attachEventHandlers:function(){this.subscribe("blur",this.handleBlur.bind(this)),this.subscribe("focus",this.handleFocus.bind(this)),this.subscribe("editableClick",this.handleEditableClick.bind(this)),this.subscribe("editableKeyup",this.handleEditableKeyup.bind(this)),this.on(this.document.documentElement,"mouseup",this.handleDocumentMouseup.bind(this)),this.static&&this.sticky&&this.on(this.window,"scroll",this.handleWindowScroll.bind(this),!0),this.on(this.window,"resize",this.handleWindowResize.bind(this))},handleWindowScroll:function(){this.positionToolbarIfShown()},handleWindowResize:function(){this.throttledPositionToolbar()},handleDocumentMouseup:function(t){if(t&&t.target&&e.util.isDescendant(this.getToolbarElement(),t.target))return!1;this.checkState()},handleEditableClick:function(){setTimeout(function(){this.checkState()}.bind(this),0)},handleEditableKeyup:function(){this.checkState()},handleBlur:function(){clearTimeout(this.hideTimeout),clearTimeout(this.delayShowTimeout),this.hideTimeout=setTimeout(function(){this.hideToolbar()}.bind(this),1)},handleFocus:function(){this.checkState()},isDisplayed:function(){return this.getToolbarElement().classList.contains("medium-editor-toolbar-active")},showToolbar:function(){clearTimeout(this.hideTimeout),this.isDisplayed()||(this.getToolbarElement().classList.add("medium-editor-toolbar-active"),this.trigger("showToolbar",{},this.base.getFocusedElement()))},hideToolbar:function(){this.isDisplayed()&&(this.getToolbarElement().classList.remove("medium-editor-toolbar-active"),this.trigger("hideToolbar",{},this.base.getFocusedElement()))},isToolbarDefaultActionsDisplayed:function(){return"block"===this.getToolbarActionsElement().style.display},hideToolbarDefaultActions:function(){this.isToolbarDefaultActionsDisplayed()&&(this.getToolbarActionsElement().style.display="none")},showToolbarDefaultActions:function(){this.hideExtensionForms(),this.isToolbarDefaultActionsDisplayed()||(this.getToolbarActionsElement().style.display="block"),this.delayShowTimeout=this.base.delay(function(){this.showToolbar()}.bind(this))},hideExtensionForms:function(){this.forEachExtension(function(e){e.hasForm&&e.isDisplayed()&&e.hideForm()})},multipleBlockElementsSelected:function(){var t=/<[^\/>][^>]*><\/[^>]+>/gim,n=new RegExp("<("+e.util.blockContainerElementNames.join("|")+")[^>]*>","g"),i=e.selection.getSelectionHtml(this.document).replace(t,""),o=i.match(n);return!!o&&o.length>1},modifySelection:function(){var t=this.window.getSelection(),n=t.getRangeAt(0);if(this.standardizeSelectionStart&&n.startContainer.nodeValue&&n.startOffset===n.startContainer.nodeValue.length){var i=e.util.findAdjacentTextNodeWithContent(e.selection.getSelectionElement(this.window),n.startContainer,this.document);if(i){for(var o=0;0===i.nodeValue.substr(o,1).trim().length;)o+=1;n=e.selection.select(this.document,i,o,n.endContainer,n.endOffset)}}},checkState:function(){if(!this.base.preventSelectionUpdates){if(!this.base.getFocusedElement()||e.selection.selectionInContentEditableFalse(this.window))return this.hideToolbar();var t=e.selection.getSelectionElement(this.window);return!t||-1===this.getEditorElements().indexOf(t)||t.getAttribute("data-disable-toolbar")?this.hideToolbar():this.updateOnEmptySelection&&this.static?this.showAndUpdateToolbar():!e.selection.selectionContainsContent(this.document)||!1===this.allowMultiParagraphSelection&&this.multipleBlockElementsSelected()?this.hideToolbar():void this.showAndUpdateToolbar()}},showAndUpdateToolbar:function(){this.modifySelection(),this.setToolbarButtonStates(),this.trigger("positionToolbar",{},this.base.getFocusedElement()),this.showToolbarDefaultActions(),this.setToolbarPosition()},setToolbarButtonStates:function(){this.forEachExtension(function(e){"function"==typeof e.isActive&&"function"==typeof e.setInactive&&e.setInactive()}),this.checkActiveButtons()},checkActiveButtons:function(){var t,n=[],i=null,o=e.selection.getSelectionRange(this.document),r=function(e){"function"==typeof e.checkState?e.checkState(t):"function"==typeof e.isActive&&"function"==typeof e.isAlreadyApplied&&"function"==typeof e.setActive&&!e.isActive()&&e.isAlreadyApplied(t)&&e.setActive()};if(o&&(this.forEachExtension(function(e){if("function"==typeof e.queryCommandState&&null!==(i=e.queryCommandState()))return void(i&&"function"==typeof e.setActive&&e.setActive());n.push(e)}),t=e.selection.getSelectedParentElement(o),this.getEditorElements().some(function(n){return e.util.isDescendant(n,t,!0)})))for(;t&&(n.forEach(r),!e.util.isMediumEditorElement(t));)t=t.parentNode},positionToolbarIfShown:function(){this.isDisplayed()&&this.setToolbarPosition()},setToolbarPosition:function(){var e=this.base.getFocusedElement(),t=this.window.getSelection();if(!e)return this;!this.static&&t.isCollapsed||(this.showToolbar(),this.relativeContainer||(this.static?this.positionStaticToolbar(e):this.positionToolbar(t)),this.trigger("positionedToolbar",{},this.base.getFocusedElement()))},positionStaticToolbar:function(e){this.getToolbarElement().style.left="0";var t,n=this.document.documentElement&&this.document.documentElement.scrollTop||this.document.body.scrollTop,i=this.window.innerWidth,o=this.getToolbarElement(),r=e.getBoundingClientRect(),a=r.top+n,s=r.left+r.width/2,l=o.offsetHeight,u=o.offsetWidth,c=u/2;switch(this.sticky?n>a+e.offsetHeight-l-this.stickyTopOffset?(o.style.top=a+e.offsetHeight-l+"px",o.classList.remove("medium-editor-sticky-toolbar")):n>a-l-this.stickyTopOffset?(o.classList.add("medium-editor-sticky-toolbar"),o.style.top=this.stickyTopOffset+"px"):(o.classList.remove("medium-editor-sticky-toolbar"),o.style.top=a-l+"px"):o.style.top=a-l+"px",this.align){case"left":t=r.left;break;case"right":t=r.right-u;break;case"center":t=s-c}t<0?t=0:t+u>i&&(t=i-Math.ceil(u)-1),o.style.left=t+"px"},positionToolbar:function(e){this.getToolbarElement().style.left="0",this.getToolbarElement().style.right="initial";var t=e.getRangeAt(0),n=t.getBoundingClientRect();(!n||0===n.height&&0===n.width&&t.startContainer===t.endContainer)&&(n=1===t.startContainer.nodeType&&t.startContainer.querySelector("img")?t.startContainer.querySelector("img").getBoundingClientRect():t.startContainer.getBoundingClientRect());var i,o,r=this.window.innerWidth,a=this.getToolbarElement(),s=a.offsetHeight,l=a.offsetWidth,u=l/2,c=this.diffLeft-u,d=this.getEditorOption("elementsContainer"),h=["absolute","fixed"].indexOf(window.getComputedStyle(d).getPropertyValue("position"))>-1,f={},p={};h?(o=d.getBoundingClientRect(),["top","left"].forEach(function(e){p[e]=n[e]-o[e]}),p.width=n.width,p.height=n.height,n=p,r=o.width,f.top=d.scrollTop):f.top=this.window.pageYOffset,i=n.left+n.width/2,f.top+=n.top-s,n.top<50?(a.classList.add("medium-toolbar-arrow-over"),a.classList.remove("medium-toolbar-arrow-under"),f.top+=50+n.height-this.diffTop):(a.classList.add("medium-toolbar-arrow-under"),a.classList.remove("medium-toolbar-arrow-over"),f.top+=this.diffTop),i<u?(f.left=c+u,f.right="initial"):r-i<u?(f.left="auto",f.right=0):(f.left=c+i,f.right="initial"),["top","left","right"].forEach(function(e){a.style[e]=f[e]+(isNaN(f[e])?"":"px")})}});e.extensions.toolbar=t}(),function(){var t=e.Extension.extend({init:function(){e.Extension.prototype.init.apply(this,arguments),this.subscribe("editableDrag",this.handleDrag.bind(this)),this.subscribe("editableDrop",this.handleDrop.bind(this))},handleDrag:function(e){e.preventDefault(),e.dataTransfer.dropEffect="copy","dragover"===e.type?e.target.classList.add("medium-editor-dragover"):"dragleave"===e.type&&e.target.classList.remove("medium-editor-dragover")},handleDrop:function(t){var n;t.preventDefault(),t.stopPropagation(),t.dataTransfer.files&&(n=Array.prototype.slice.call(t.dataTransfer.files,0),n.some(function(t){if(t.type.match("image")){var n,i;n=new FileReader,n.readAsDataURL(t),i="medium-img-"+ +new Date,e.util.insertHTMLCommand(this.document,'<img class="medium-editor-image-loading" id="'+i+'" />'),n.onload=function(){var e=this.document.getElementById(i);e&&(e.removeAttribute("id"),e.removeAttribute("class"),e.src=n.result)}.bind(this)}}.bind(this))),t.target.classList.remove("medium-editor-dragover")}});e.extensions.imageDragging=t}(),function(){function t(t){var n=e.selection.getSelectionStart(this.options.ownerDocument),i=n.textContent,o=e.selection.getCaretOffsets(n);(void 0===i[o.left-1]||""===i[o.left-1].trim()||void 0!==i[o.left]&&""===i[o.left].trim())&&t.preventDefault()}function n(t,n){if(this.options.disableReturn||n.getAttribute("data-disable-return"))t.preventDefault();else if(this.options.disableDoubleReturn||n.getAttribute("data-disable-double-return")){var i=e.selection.getSelectionStart(this.options.ownerDocument);(i&&""===i.textContent.trim()&&"li"!==i.nodeName.toLowerCase()||i.previousElementSibling&&"br"!==i.previousElementSibling.nodeName.toLowerCase()&&""===i.previousElementSibling.textContent.trim())&&t.preventDefault()}}function i(t){var n=e.selection.getSelectionStart(this.options.ownerDocument);"pre"===(n&&n.nodeName.toLowerCase())&&(t.preventDefault(),e.util.insertHTMLCommand(this.options.ownerDocument," ")),e.util.isListItem(n)&&(t.preventDefault(),t.shiftKey?this.options.ownerDocument.execCommand("outdent",!1,null):this.options.ownerDocument.execCommand("indent",!1,null))}function o(t){var n,i=e.selection.getSelectionStart(this.options.ownerDocument),o=i.nodeName.toLowerCase(),r=/^(\s+|<br\/?>)?$/i,a=/h\d/i;e.util.isKey(t,[e.util.keyCode.BACKSPACE,e.util.keyCode.ENTER])&&i.previousElementSibling&&a.test(o)&&0===e.selection.getCaretOffsets(i).left?e.util.isKey(t,e.util.keyCode.BACKSPACE)&&r.test(i.previousElementSibling.innerHTML)?(i.previousElementSibling.parentNode.removeChild(i.previousElementSibling),t.preventDefault()):!this.options.disableDoubleReturn&&e.util.isKey(t,e.util.keyCode.ENTER)&&(n=this.options.ownerDocument.createElement("p"),n.innerHTML="<br>",i.previousElementSibling.parentNode.insertBefore(n,i),t.preventDefault()):e.util.isKey(t,e.util.keyCode.DELETE)&&i.nextElementSibling&&i.previousElementSibling&&!a.test(o)&&r.test(i.innerHTML)&&a.test(i.nextElementSibling.nodeName.toLowerCase())?(e.selection.moveCursor(this.options.ownerDocument,i.nextElementSibling),i.previousElementSibling.parentNode.removeChild(i),t.preventDefault()):e.util.isKey(t,e.util.keyCode.BACKSPACE)&&"li"===o&&r.test(i.innerHTML)&&!i.previousElementSibling&&!i.parentElement.previousElementSibling&&i.nextElementSibling&&"li"===i.nextElementSibling.nodeName.toLowerCase()?(n=this.options.ownerDocument.createElement("p"),n.innerHTML="<br>",i.parentElement.parentElement.insertBefore(n,i.parentElement),e.selection.moveCursor(this.options.ownerDocument,n),i.parentElement.removeChild(i),t.preventDefault()):e.util.isKey(t,e.util.keyCode.BACKSPACE)&&!1!==e.util.getClosestTag(i,"blockquote")&&0===e.selection.getCaretOffsets(i).left?(t.preventDefault(),e.util.execFormatBlock(this.options.ownerDocument,"p")):e.util.isKey(t,e.util.keyCode.ENTER)&&!1!==e.util.getClosestTag(i,"blockquote")&&0===e.selection.getCaretOffsets(i).right?(n=this.options.ownerDocument.createElement("p"),n.innerHTML="<br>",i.parentElement.insertBefore(n,i.nextSibling),e.selection.moveCursor(this.options.ownerDocument,n),t.preventDefault()):e.util.isKey(t,e.util.keyCode.BACKSPACE)&&e.util.isMediumEditorElement(i.parentElement)&&!i.previousElementSibling&&i.nextElementSibling&&r.test(i.innerHTML)&&(t.preventDefault(),e.selection.moveCursor(this.options.ownerDocument,i.nextSibling),i.parentElement.removeChild(i))}function r(t){var n,i=e.selection.getSelectionStart(this.options.ownerDocument);i&&(e.util.isMediumEditorElement(i)&&0===i.children.length&&!e.util.isBlockContainer(i)&&this.options.ownerDocument.execCommand("formatBlock",!1,"p"),!e.util.isKey(t,e.util.keyCode.ENTER)||e.util.isListItem(i)||e.util.isBlockContainer(i)||(n=i.nodeName.toLowerCase(),"a"===n?this.options.ownerDocument.execCommand("unlink",!1,null):t.shiftKey||t.ctrlKey||this.options.ownerDocument.execCommand("formatBlock",!1,"p")))}function a(e,t){var n=t.parentNode.querySelector('textarea[medium-editor-textarea-id="'+t.getAttribute("medium-editor-textarea-id")+'"]');n&&(n.value=t.innerHTML.trim())}function s(e){e._mediumEditors||(e._mediumEditors=[null]),this.id||(this.id=e._mediumEditors.length),e._mediumEditors[this.id]=this}function l(e){e._mediumEditors&&e._mediumEditors[this.id]&&(e._mediumEditors[this.id]=null)}function u(t,n,i){var o=[];if(t||(t=[]),"string"==typeof t&&(t=n.querySelectorAll(t)),e.util.isElement(t)&&(t=[t]),i)for(var r=0;r<t.length;r++){var a=t[r];!e.util.isElement(a)||a.getAttribute("data-medium-editor-element")||a.getAttribute("medium-editor-textarea-id")||o.push(a)}else o=Array.prototype.slice.apply(t);return o}function c(e){var t=e.parentNode.querySelector('textarea[medium-editor-textarea-id="'+e.getAttribute("medium-editor-textarea-id")+'"]');t&&(t.classList.remove("medium-editor-hidden"),t.removeAttribute("medium-editor-textarea-id")),e.parentNode&&e.parentNode.removeChild(e)}function d(e,t){return Object.keys(t).forEach(function(n){void 0===e[n]&&(e[n]=t[n])}),e}function h(e,t,n){return e=d(e,{window:n.options.contentWindow,document:n.options.ownerDocument,base:n}),"function"==typeof e.init&&e.init(),e.name||(e.name=t),e}function f(){return!this.elements.every(function(e){return!!e.getAttribute("data-disable-toolbar")})&&!1!==this.options.toolbar}function p(){return!!f.call(this)&&!1!==this.options.anchorPreview}function m(){return!1!==this.options.placeholder}function g(){return!1!==this.options.autoLink}function v(){return!1!==this.options.imageDragging}function b(){return!1!==this.options.keyboardCommands}function y(){return!this.options.extensions.imageDragging}function C(e){for(var t=this.options.ownerDocument.createElement("div"),n=Date.now(),i="medium-editor-"+n,o=e.attributes;this.options.ownerDocument.getElementById(i);)n++,i="medium-editor-"+n;t.className=e.className,t.id=i,t.innerHTML=e.value,e.setAttribute("medium-editor-textarea-id",i);for(var r=0,a=o.length;r<a;r++)t.hasAttribute(o[r].nodeName)||t.setAttribute(o[r].nodeName,o[r].value);return e.form&&this.on(e.form,"reset",function(e){e.defaultPrevented||this.resetContent(this.options.ownerDocument.getElementById(i))}.bind(this)),e.classList.add("medium-editor-hidden"),e.parentNode.insertBefore(t,e),t}function E(t,i){if(!t.getAttribute("data-medium-editor-element")){"textarea"===t.nodeName.toLowerCase()&&(t=C.call(this,t),this.instanceHandleEditableInput||(this.instanceHandleEditableInput=a.bind(this),this.subscribe("editableInput",this.instanceHandleEditableInput))),this.options.disableEditing||t.getAttribute("data-disable-editing")||(t.setAttribute("contentEditable",!0),t.setAttribute("spellcheck",this.options.spellcheck)),this.instanceHandleEditableKeydownEnter||(t.getAttribute("data-disable-return")||t.getAttribute("data-disable-double-return"))&&(this.instanceHandleEditableKeydownEnter=n.bind(this),this.subscribe("editableKeydownEnter",this.instanceHandleEditableKeydownEnter)),this.options.disableReturn||t.getAttribute("data-disable-return")||this.on(t,"keyup",r.bind(this));var o=e.util.guid();t.setAttribute("data-medium-editor-element",!0),t.classList.add("medium-editor-element"),t.setAttribute("role","textbox"),t.setAttribute("aria-multiline",!0),t.setAttribute("data-medium-editor-editor-index",i),t.setAttribute("medium-editor-index",o),N[o]=t.innerHTML,this.events.attachAllEventsToElement(t)}return t}function w(){this.subscribe("editableKeydownTab",i.bind(this)),this.subscribe("editableKeydownDelete",o.bind(this)),this.subscribe("editableKeydownEnter",o.bind(this)),this.options.disableExtraSpaces&&this.subscribe("editableKeydownSpace",t.bind(this)),this.instanceHandleEditableKeydownEnter||(this.options.disableReturn||this.options.disableDoubleReturn)&&(this.instanceHandleEditableKeydownEnter=n.bind(this),this.subscribe("editableKeydownEnter",this.instanceHandleEditableKeydownEnter))}function x(){if(this.extensions=[],Object.keys(this.options.extensions).forEach(function(e){"toolbar"!==e&&this.options.extensions[e]&&this.extensions.push(h(this.options.extensions[e],e,this))},this),y.call(this)){var t=this.options.fileDragging;t||(t={},v.call(this)||(t.allowedTypes=[])),this.addBuiltInExtension("fileDragging",t)}var n={paste:!0,"anchor-preview":p.call(this),autoLink:g.call(this),keyboardCommands:b.call(this),placeholder:m.call(this)};Object.keys(n).forEach(function(e){n[e]&&this.addBuiltInExtension(e)},this);var i=this.options.extensions.toolbar;if(!i&&f.call(this)){var o=e.util.extend({},this.options.toolbar,{allowMultiParagraphSelection:this.options.allowMultiParagraphSelection});i=new e.extensions.toolbar(o)}i&&this.extensions.push(h(i,"toolbar",this))}function T(t,n){var i=[["allowMultiParagraphSelection","toolbar.allowMultiParagraphSelection"]];return n&&i.forEach(function(t){n.hasOwnProperty(t[0])&&void 0!==n[t[0]]&&e.util.deprecated(t[0],t[1],"v6.0.0")}),e.util.defaults({},n,t)}function k(t,n){var i,o,r=/^append-(.+)$/gi,a=/justify([A-Za-z]*)$/g;if(i=r.exec(t))return e.util.execFormatBlock(this.options.ownerDocument,i[1]);if("fontSize"===t)return n.size&&e.util.deprecated(".size option for fontSize command",".value","6.0.0"),o=n.value||n.size,this.options.ownerDocument.execCommand("fontSize",!1,o);if("fontName"===t)return n.name&&e.util.deprecated(".name option for fontName command",".value","6.0.0"),o=n.value||n.name,this.options.ownerDocument.execCommand("fontName",!1,o);if("createLink"===t)return this.createLink(n);if("image"===t){var s=this.options.contentWindow.getSelection().toString().trim();return this.options.ownerDocument.execCommand("insertImage",!1,s)}if("html"===t){var l=this.options.contentWindow.getSelection().toString().trim();return e.util.insertHTMLCommand(this.options.ownerDocument,l)}if(a.exec(t)){var u=this.options.ownerDocument.execCommand(t,!1,null),c=e.selection.getSelectedParentElement(e.selection.getSelectionRange(this.options.ownerDocument));return c&&S.call(this,e.util.getTopBlockContainer(c)),u}return o=n&&n.value,this.options.ownerDocument.execCommand(t,!1,o)}function S(t){if(t){var n,i=Array.prototype.slice.call(t.childNodes).filter(function(e){var t="div"===e.nodeName.toLowerCase();return t&&!n&&(n=e.style.textAlign),t});i.length&&(this.saveSelection(),i.forEach(function(t){if(t.style.textAlign===n){var i=t.lastChild;if(i){e.util.unwrap(t,this.options.ownerDocument);var o=this.options.ownerDocument.createElement("BR");i.parentNode.insertBefore(o,i.nextSibling)}}},this),t.style.textAlign=n,this.restoreSelection())}}var N={};e.prototype={init:function(e,t){return this.options=T.call(this,this.defaults,t),this.origElements=e,this.options.elementsContainer||(this.options.elementsContainer=this.options.ownerDocument.body),this.setup()},setup:function(){this.isActive||(s.call(this,this.options.contentWindow),this.events=new e.Events(this),this.elements=[],this.addElements(this.origElements),0!==this.elements.length&&(this.isActive=!0,x.call(this),w.call(this)))},destroy:function(){this.isActive&&(this.isActive=!1,this.extensions.forEach(function(e){"function"==typeof e.destroy&&e.destroy()},this),this.events.destroy(),this.elements.forEach(function(e){this.options.spellcheck&&(e.innerHTML=e.innerHTML),e.removeAttribute("contentEditable"),e.removeAttribute("spellcheck"),e.removeAttribute("data-medium-editor-element"),e.classList.remove("medium-editor-element"),e.removeAttribute("role"),e.removeAttribute("aria-multiline"),e.removeAttribute("medium-editor-index"),e.removeAttribute("data-medium-editor-editor-index"),e.getAttribute("medium-editor-textarea-id")&&c(e)},this),this.elements=[],this.instanceHandleEditableKeydownEnter=null,this.instanceHandleEditableInput=null,l.call(this,this.options.contentWindow))},on:function(e,t,n,i){return this.events.attachDOMEvent(e,t,n,i),this},off:function(e,t,n,i){return this.events.detachDOMEvent(e,t,n,i),this},subscribe:function(e,t){return this.events.attachCustomEvent(e,t),this},unsubscribe:function(e,t){return this.events.detachCustomEvent(e,t),this},trigger:function(e,t,n){return this.events.triggerCustomEvent(e,t,n),this},delay:function(e){var t=this;return setTimeout(function(){t.isActive&&e()},this.options.delay)},serialize:function(){var e,t,n={},i=this.elements.length;for(e=0;e<i;e+=1)t=""!==this.elements[e].id?this.elements[e].id:"element-"+e,n[t]={value:this.elements[e].innerHTML.trim()};return n},getExtensionByName:function(e){var t;return this.extensions&&this.extensions.length&&this.extensions.some(function(n){return n.name===e&&(t=n,!0)}),t},addBuiltInExtension:function(t,n){var i,o=this.getExtensionByName(t);if(o)return o;switch(t){case"anchor":i=e.util.extend({},this.options.anchor,n),o=new e.extensions.anchor(i);break;case"anchor-preview":o=new e.extensions.anchorPreview(this.options.anchorPreview);break;case"autoLink":o=new e.extensions.autoLink;break;case"fileDragging":o=new e.extensions.fileDragging(n);break;case"fontname":o=new e.extensions.fontName(this.options.fontName);break;case"fontsize":o=new e.extensions.fontSize(n);break;case"keyboardCommands":o=new e.extensions.keyboardCommands(this.options.keyboardCommands);break;case"paste":o=new e.extensions.paste(this.options.paste);break;case"placeholder":o=new e.extensions.placeholder(this.options.placeholder);break;default:e.extensions.button.isBuiltInButton(t)&&(n?(i=e.util.defaults({},n,e.extensions.button.prototype.defaults[t]),o=new e.extensions.button(i)):o=new e.extensions.button(t))}return o&&this.extensions.push(h(o,t,this)),o},stopSelectionUpdates:function(){this.preventSelectionUpdates=!0},startSelectionUpdates:function(){this.preventSelectionUpdates=!1},checkSelection:function(){var e=this.getExtensionByName("toolbar");return e&&e.checkState(),this},queryCommandState:function(e){var t,n=/^full-(.+)$/gi,i=null;(t=n.exec(e))&&(e=t[1]);try{i=this.options.ownerDocument.queryCommandState(e)}catch(e){i=null}return i},execAction:function(t,n){var i,o,r=/^full-(.+)$/gi;return i=r.exec(t),i?(this.saveSelection(),this.selectAllContents(),o=k.call(this,i[1],n),this.restoreSelection()):o=k.call(this,t,n),"insertunorderedlist"!==t&&"insertorderedlist"!==t||e.util.cleanListDOM(this.options.ownerDocument,this.getSelectedParentElement()),this.checkSelection(),o},getSelectedParentElement:function(t){return void 0===t&&(t=this.options.contentWindow.getSelection().getRangeAt(0)),e.selection.getSelectedParentElement(t)},selectAllContents:function(){var t=e.selection.getSelectionElement(this.options.contentWindow);if(t){for(;1===t.children.length;)t=t.children[0];this.selectElement(t)}},selectElement:function(t){e.selection.selectNode(t,this.options.ownerDocument);var n=e.selection.getSelectionElement(this.options.contentWindow);n&&this.events.focusElement(n)},getFocusedElement:function(){var e;return this.elements.some(function(t){return!e&&t.getAttribute("data-medium-focused")&&(e=t),!!e},this),e},exportSelection:function(){var t=e.selection.getSelectionElement(this.options.contentWindow),n=this.elements.indexOf(t),i=null;return n>=0&&(i=e.selection.exportSelection(t,this.options.ownerDocument)),null!==i&&0!==n&&(i.editableElementIndex=n),i},saveSelection:function(){this.selectionState=this.exportSelection()},importSelection:function(t,n){if(t){var i=this.elements[t.editableElementIndex||0];e.selection.importSelection(t,i,this.options.ownerDocument,n)}},restoreSelection:function(){this.importSelection(this.selectionState)},createLink:function(t){var n,i=e.selection.getSelectionElement(this.options.contentWindow),o={};if(-1!==this.elements.indexOf(i)){try{if(this.events.disableCustomEvent("editableInput"),t.url&&e.util.deprecated(".url option for createLink",".value","6.0.0"),(n=t.url||t.value)&&n.trim().length>0){var r=this.options.contentWindow.getSelection();if(r){var a,s,l,u,c=r.getRangeAt(0),d=c.commonAncestorContainer;if(3===c.endContainer.nodeType&&3!==c.startContainer.nodeType&&0===c.startOffset&&c.startContainer.firstChild===c.endContainer&&(d=c.endContainer),s=e.util.getClosestBlockContainer(c.startContainer),l=e.util.getClosestBlockContainer(c.endContainer),3!==d.nodeType&&0!==d.textContent.length&&s===l){var h=s||i,f=this.options.ownerDocument.createDocumentFragment();this.execAction("unlink"),a=this.exportSelection(),f.appendChild(h.cloneNode(!0)),i===h?e.selection.select(this.options.ownerDocument,h.firstChild,0,h.lastChild,3===h.lastChild.nodeType?h.lastChild.nodeValue.length:h.lastChild.childNodes.length):e.selection.select(this.options.ownerDocument,h,0,h,h.childNodes.length);var p=this.exportSelection();u=e.util.findOrCreateMatchingTextNodes(this.options.ownerDocument,f,{start:a.start-p.start,end:a.end-p.start,editableElementIndex:a.editableElementIndex}),0===u.length&&(f=this.options.ownerDocument.createDocumentFragment(),f.appendChild(d.cloneNode(!0)),u=[f.firstChild.firstChild,f.firstChild.lastChild]),e.util.createLink(this.options.ownerDocument,u,n.trim());var m=(f.firstChild.innerHTML.match(/^\s+/)||[""])[0].length;e.util.insertHTMLCommand(this.options.ownerDocument,f.firstChild.innerHTML.replace(/^\s+/,"")),a.start-=m,a.end-=m,this.importSelection(a)}else this.options.ownerDocument.execCommand("createLink",!1,n);this.options.targetBlank||"_blank"===t.target?e.util.setTargetBlank(e.selection.getSelectionStart(this.options.ownerDocument),n):e.util.removeTargetBlank(e.selection.getSelectionStart(this.options.ownerDocument),n),t.buttonClass&&e.util.addClassToAnchors(e.selection.getSelectionStart(this.options.ownerDocument),t.buttonClass)}}if(this.options.targetBlank||"_blank"===t.target||t.buttonClass){o=this.options.ownerDocument.createEvent("HTMLEvents"),o.initEvent("input",!0,!0,this.options.contentWindow);for(var g=0,v=this.elements.length;g<v;g+=1)this.elements[g].dispatchEvent(o)}}finally{this.events.enableCustomEvent("editableInput")}this.events.triggerCustomEvent("editableInput",o,i)}},cleanPaste:function(e){this.getExtensionByName("paste").cleanPaste(e)},pasteHTML:function(e,t){this.getExtensionByName("paste").pasteHTML(e,t)},setContent:function(e,t){if(t=t||0,this.elements[t]){var n=this.elements[t];n.innerHTML=e,this.checkContentChanged(n)}},getContent:function(e){return e=e||0,this.elements[e]?this.elements[e].innerHTML.trim():null},checkContentChanged:function(t){t=t||e.selection.getSelectionElement(this.options.contentWindow),this.events.updateInput(t,{target:t,currentTarget:t})},resetContent:function(e){if(e){var t=this.elements.indexOf(e);return void(-1!==t&&this.setContent(N[e.getAttribute("medium-editor-index")],t))}this.elements.forEach(function(e,t){this.setContent(N[e.getAttribute("medium-editor-index")],t)},this)},addElements:function(e){var t=u(e,this.options.ownerDocument,!0);if(0===t.length)return!1;t.forEach(function(e){e=E.call(this,e,this.id),this.elements.push(e),this.trigger("addElement",{target:e,currentTarget:e},e)},this)},removeElements:function(e){var t=u(e,this.options.ownerDocument),n=t.map(function(e){return e.getAttribute("medium-editor-textarea-id")&&e.parentNode?e.parentNode.querySelector('div[medium-editor-textarea-id="'+e.getAttribute("medium-editor-textarea-id")+'"]'):e});this.elements=this.elements.filter(function(e){return-1===n.indexOf(e)||(this.events.cleanupElement(e),e.getAttribute("medium-editor-textarea-id")&&c(e),this.trigger("removeElement",{target:e,currentTarget:e},e),!1)},this)}},e.getEditorFromElement=function(e){var t=e.getAttribute("data-medium-editor-editor-index"),n=e&&e.ownerDocument&&(e.ownerDocument.defaultView||e.ownerDocument.parentWindow);return n&&n._mediumEditors&&n._mediumEditors[t]?n._mediumEditors[t]:null}}(),function(){e.prototype.defaults={activeButtonClass:"medium-editor-button-active",buttonLabels:!1,delay:0,disableReturn:!1,disableDoubleReturn:!1,disableExtraSpaces:!1,disableEditing:!1,autoLink:!1,elementsContainer:!1,contentWindow:window,ownerDocument:document,targetBlank:!1,extensions:{},spellcheck:!0}}(),e.parseVersionString=function(e){var t=e.split("-"),n=t[0].split("."),i=t.length>1?t[1]:"";return{major:parseInt(n[0],10),minor:parseInt(n[1],10),revision:parseInt(n[2],10),preRelease:i,toString:function(){return[n[0],n[1],n[2]].join(".")+(i?"-"+i:"")}}},e.version=e.parseVersionString.call(this,{version:"5.23.3"}.version),e}())}).call(t,n(27))},function(e,t){function n(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function o(e){if(c===setTimeout)return setTimeout(e,0);if((c===n||!c)&&setTimeout)return c=setTimeout,setTimeout(e,0);try{return c(e,0)}catch(t){try{return c.call(null,e,0)}catch(t){return c.call(this,e,0)}}}function r(e){if(d===clearTimeout)return clearTimeout(e);if((d===i||!d)&&clearTimeout)return d=clearTimeout,clearTimeout(e);try{return d(e)}catch(t){try{return d.call(null,e)}catch(t){return d.call(this,e)}}}function a(){m&&f&&(m=!1,f.length?p=f.concat(p):g=-1,p.length&&s())}function s(){if(!m){var e=o(a);m=!0;for(var t=p.length;t;){for(f=p,p=[];++g<t;)f&&f[g].run();g=-1,t=p.length}f=null,m=!1,r(e)}}function l(e,t){this.fun=e,this.array=t}function u(){}var c,d,h=e.exports={};!function(){try{c="function"==typeof setTimeout?setTimeout:n}catch(e){c=n}try{d="function"==typeof clearTimeout?clearTimeout:i}catch(e){d=i}}();var f,p=[],m=!1,g=-1;h.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];p.push(new l(e,t)),1!==p.length||m||o(s)},l.prototype.run=function(){this.fun.apply(null,this.array)},h.title="browser",h.browser=!0,h.env={},h.argv=[],h.version="",h.versions={},h.on=u,h.addListener=u,h.once=u,h.off=u,h.removeListener=u,h.removeAllListeners=u,h.emit=u,h.prependListener=u,h.prependOnceListener=u,h.listeners=function(e){return[]},h.binding=function(e){throw new Error("process.binding is not supported")},h.cwd=function(){return"/"},h.chdir=function(e){throw new Error("process.chdir is not supported")},h.umask=function(){return 0}},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),a=n(0),s=i(a),l=n(29),u=i(l),c=function(){function e(t){o(this,e),this.editors=document.querySelectorAll(".thesis-content-raw_html"),this.enabled=!1,this.openTray=t.openTray,this.closeTray=t.closeTray,this.clicked=this.clicked.bind(this),this.onSubmit=this.onSubmit.bind(this)}return r(e,[{key:"enable",value:function(){if(!this.enabled){for(var e=0;e<this.editors.length;e++)this.editors[e].addEventListener("click",this.clicked,!1);this.enabled=!0}}},{key:"disable",value:function(){if(this.enabled){for(var e=0;e<this.editors.length;e++)this.editors[e].removeEventListener("click",this.clicked,!1);this.enabled=!1}}},{key:"content",value:function(e){return e.innerHTML}},{key:"set",value:function(e,t){var n=document.querySelector("[data-thesis-content-id='"+e+"']");n&&(n.innerHTML=t.content,n.classList.add("modified"))}},{key:"clicked",value:function(e){var t=e.currentTarget.getAttribute("data-thesis-content-id"),n=e.currentTarget.innerHTML.trim();this.openTray({contentId:t,content:n})}},{key:"onSubmit",value:function(e){this.set(e.contentId,e),this.closeTray()}},{key:"tray",value:function(e){return s.default.createElement(u.default,{data:e,onCancel:this.closeTray,onSubmit:this.onSubmit})}}]),e}();t.default=c},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),s=n(0),l=function(e){return e&&e.__esModule?e:{default:e}}(s),u=function(e){function t(e){i(this,t);var n=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.state={contentId:e.data.contentId,content:e.data.content,isValid:!0},n.contentChange=n.contentChange.bind(n),n.onSave=n.onSave.bind(n),n}return r(t,e),a(t,[{key:"componentWillReceiveProps",value:function(e){null!==e.data&&this.setState({contentId:e.data.contentId,content:e.data.content.trim(),isValid:!0})}},{key:"contentChange",value:function(e){this.setState({content:e.target.value})}},{key:"onSave",value:function(){this.props.onSubmit(this.state)}},{key:"render",value:function(){return l.default.createElement("div",{className:"tray-container"},l.default.createElement("div",{className:"tray-wrap"},l.default.createElement("div",{className:"tray-title"},"Raw HTML"),l.default.createElement("div",{className:"thesis-field-row"},l.default.createElement("label",null,l.default.createElement("span",null,"HTML code"),l.default.createElement("textarea",{placeholder:"<h1>Any HTML you like</h1>",value:this.state.content,onChange:this.contentChange}))),l.default.createElement("div",{className:"thesis-field-row errors",hidden:this.state.isValid}),l.default.createElement("div",{className:"thesis-field-row cta"},l.default.createElement("button",{className:"thesis-tray-cancel",onClick:this.props.onCancel},"Cancel"),l.default.createElement("button",{className:"thesis-tray-save",onClick:this.onSave},"Apply"))))}}]),t}(l.default.Component);t.default=u},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),a=n(0),s=i(a),l=n(31),u=i(l),c=n(1),d=i(c),h=function(){function e(t){o(this,e),this.editors=document.querySelectorAll(".thesis-content-image, .thesis-content-background_image"),this.enabled=!1,this.ospryPublicKey=t.ospryPublicKey,this.fileUploader=t.fileUploader,this.openTray=t.openTray,this.closeTray=t.closeTray,this.clicked=this.clicked.bind(this),this.onSubmit=this.onSubmit.bind(this)}return r(e,[{key:"enable",value:function(){if(!this.enabled){for(var e=0;e<this.editors.length;e++)this.editors[e].addEventListener("click",this.clicked,!1);this.enabled=!0}}},{key:"disable",value:function(){if(this.enabled){for(var e=0;e<this.editors.length;e++)this.editors[e].removeEventListener("click",this.clicked,!1);this.enabled=!1}}},{key:"clicked",value:function(e){var t=e.currentTarget.getAttribute("data-thesis-content-id"),n=e.currentTarget.getAttribute("data-thesis-content-type"),i=JSON.parse(e.currentTarget.getAttribute("data-thesis-content-meta")),o="";"image"===n?o=e.currentTarget.querySelector("img").getAttribute("src"):"background_image"===n&&(o=this.getUrlFromStyle(e.currentTarget.style.backgroundImage)),this.openTray({contentId:t,url:o,alt:i.alt})}},{key:"tray",value:function(e){return s.default.createElement(u.default,{data:e,ospryPublicKey:this.ospryPublicKey,fileUploader:this.fileUploader,onCancel:this.closeTray,onSubmit:this.onSubmit})}},{key:"onSubmit",value:function(e){this.set(e.contentId,e),this.closeTray()}},{key:"getContent",value:function(e){return"image"===e.getAttribute("data-thesis-content-type")?e.querySelector("img").getAttribute("src"):this.getUrlFromStyle(e.style.backgroundImage)}},{key:"uploadAndSet",value:function(e,t,n){var i=this,o=this.determineImageUrl(e.content,t.origin),r=document.querySelector('[data-thesis-content-id="'+e.name+'"');if(!o||!r)return void n();o.upload?d.default.post("/thesis/files/import",{image_url:o.imageUrl,image_name:e.name}).then(function(t){n(),t.path.length>0&&i.set(e.name,{url:t.path},e.meta)}).catch(function(t){n(),window.alert(e.name+" could not be saved.")}):(n(),this.set(e.name,{url:o.imageUrl},e.meta))}},{key:"set",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=document.querySelector('[data-thesis-content-id="'+e+'"');if(i.classList.add("modified"),!n){var o=JSON.parse(i.getAttribute("data-thesis-content-meta")),r=Object.assign({},o,{alt:t.alt});n=JSON.stringify(r)}i.setAttribute("data-thesis-content-meta",n);var a=i.getAttribute("data-thesis-content-type");if("image"===a){var s=i.querySelector("img");s.src=t.url,s.alt=JSON.parse(n).alt}else"background_image"===a&&(i.style.backgroundImage='url("'+t.url+'")')}},{key:"determineImageUrl",value:function(e,t){return""===e.trim()?null:this.isImageAbsoluteUrl(e)?{imageUrl:e.trim()}:this.isImageUrlWithoutProtocol(e)?{imageUrl:"http:"+e.trim()}:void 0===t?{upload:!1,imageUrl:e}:{imageUrl:t+e.trim()}}},{key:"isImageAbsoluteUrl",value:function(e){var t=e.trim().indexOf("//");return t>4&&t<7}},{key:"isImageUrlWithoutProtocol",value:function(e){return 0===e.trim().indexOf("//")}},{key:"getUrlFromStyle",value:function(e){return e.replace(/\'/g,"").replace(/"/g,"").replace("url(","").replace(")","")}}]),e}();t.default=h},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),l=n(0),u=i(l),c=n(32),d=i(c),h=n(1),f=i(h),p=(0,d.default)(window),m=function(e){function t(e){o(this,t);var n=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.state={contentId:n.props.data.contentId,url:n.props.data.url,alt:n.props.data.alt,isValid:!0,fileName:""},n.urlChange=n.urlChange.bind(n),n.altChange=n.altChange.bind(n),n.onSave=n.onSave.bind(n),n.onOspryUpload=n.onOspryUpload.bind(n),n.uploadFile=n.uploadFile.bind(n),n.uploadFileToOspry=n.uploadFileToOspry.bind(n),n.renderForm=n.renderForm.bind(n),n.renderOspryForm=n.renderOspryForm.bind(n),n.renderUploaderForm=n.renderUploaderForm.bind(n),n.onCancel=e.onCancel,n}return a(t,e),s(t,[{key:"componentWillReceiveProps",value:function(e){null!==e.data&&this.setState({contentId:e.data.contentId,url:e.data.url,alt:e.data.alt,isValid:!0,fileName:""})}},{key:"urlChange",value:function(e){this.setState({url:e.target.value})}},{key:"altChange",value:function(e){this.setState({alt:e.target.value})}},{key:"onSave",value:function(){this.props.onSubmit({contentId:this.state.contentId,url:this.state.url,alt:this.state.alt,fileName:this.state.fileName})}},{key:"onOspryUpload",value:function(e,t){if(e)return window.alert(e);this.setState({url:t.httpsURL})}},{key:"uploadFile",value:function(e){var t=this;this.setState({fileName:e.target.files[0].name}),e.preventDefault(),f.default.post("/thesis/files/upload",e.target.form,"form").then(function(e){e.path.length>0&&t.setState({url:e.path})}).catch(function(e){window.alert(e)})}},{key:"uploadFileToOspry",value:function(e){this.setState({fileName:e.target.files[0].name});var t=new p(this.props.ospryPublicKey);e.preventDefault();var n=e.target;t.up({form:n,imageReady:this.onOspryUpload})}},{key:"previewImageStyle",value:function(){return{backgroundImage:"url("+this.state.url+")"}}},{key:"renderForm",value:function(){return this.props.ospryPublicKey?this.renderOspryForm():this.props.fileUploader?this.renderUploaderForm():void 0}},{key:"renderUploaderForm",value:function(){return u.default.createElement("div",{className:"thesis-field-row"},u.default.createElement("label",null,u.default.createElement("span",null,"Upload Image"),u.default.createElement("form",{onChange:this.uploadFile,className:"tray-file-upload"},u.default.createElement("span",null,this.state.fileName),u.default.createElement("input",{type:"file",accept:".svg,image/*",name:"file"}))))}},{key:"renderOspryForm",value:function(){if(this.props.ospryPublicKey)return u.default.createElement("div",{className:"thesis-field-row"},u.default.createElement("label",null,u.default.createElement("span",null,"Upload Image"),u.default.createElement("form",{onChange:this.uploadFileToOspry,className:"tray-file-upload"},u.default.createElement("span",null,this.state.fileName),u.default.createElement("input",{type:"file",accept:".jpg,.jpeg,.png,.gif,image/png,image/gif,image/jpeg,image/jpg"}))))}},{key:"render",value:function(){return u.default.createElement("div",{className:"tray-container"},u.default.createElement("div",{className:"tray-wrap"},u.default.createElement("div",{className:"tray-title"},"Image URL"),u.default.createElement("div",{className:"thesis-field-row"},u.default.createElement("div",{className:"tray-image-preview",style:this.previewImageStyle()})),u.default.createElement("div",{className:"thesis-field-row"},u.default.createElement("label",null,u.default.createElement("span",null,"Image URL"),u.default.createElement("input",{type:"text",placeholder:"http://placekitten.com/200/300",value:this.state.url,onChange:this.urlChange}))),this.renderForm(),u.default.createElement("div",{className:"thesis-field-row"},u.default.createElement("label",null,u.default.createElement("span",null,"Alt Text"),u.default.createElement("input",{type:"text",placeholder:"Describe the image",value:this.state.alt,onChange:this.altChange}))),u.default.createElement("div",{className:"thesis-field-row errors",hidden:this.state.isValid}),u.default.createElement("div",{className:"thesis-field-row cta"},u.default.createElement("button",{className:"thesis-tray-cancel",onClick:this.onCancel},"Cancel"),u.default.createElement("button",{className:"thesis-tray-save",onClick:this.onSave},"Apply"))))}}]),t}(u.default.Component);t.default=m},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i="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};// @preserve Copyright 2014 Ospry Labs, LLC. All rights reserved.t.default=function(t){var n="FormData"in t&&"XMLHttpRequest"in t&&"withCredentials"in new XMLHttpRequest,o=function(e){return"object"==(void 0===e?"undefined":i(e))&&null!==e&&!(e instanceof Array)},r=function(e){return"number"==typeof e},a=function(e){return"string"==typeof e},s=function(){},l=function(e,t){var n={};for(var i in t)t.hasOwnProperty(i)&&(n[i]=void 0===e[i]?t[i]:e[i]);return n},u=function e(t){if("input"===t.nodeName.toLowerCase()&&"file"===t.type.toLowerCase())return t;for(var n=t.children,i=0;i<n.length;i++){var o=e(n[i]);if(null!==o)return o}return null},c=function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent&&e.attachEvent("on"+t,n)},d=function(e,t,n){e.removeEventListener?e.removeEventListener(t,n,!1):e.detachEvent&&e.detachEvent("on"+t,n)},h="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",f=function(e){for(var t="",n=0;e>n;n++)t+=h[Math.floor(Math.random()*h.length)];return t},p=function(e){if(!a(e))throw"ospry: required public key is not a string";if(""===e)throw"ospry: required public key is missing";this._key=e,this._serverURL="https://api.ospry.io/v1"};p.formats=["jpeg","png","gif"],p.prototype.up=function(e){if(!o(e))throw"ospry: required options argument is not an object";if(e=l(e,{files:null,form:null,isPrivate:!1,imageReady:s,done:s}),n){if(null===e.files){if(null===e.form)throw"ospry: both form and files are missing from options (one of them should be set)";var t=u(e.form);if(null===t)throw"ospry: file input is missing from form";e.files=t.files}this._upXHR(e.files,e)}else{if(null===e.form)throw"ospry: form property is missing from options (older browsers only support form-based uploads)";this._upIFrame(e)}},p.prototype._upXHR=function(e,t){for(var n=0,i=function(i,o,r){t.imageReady(i,o,r),++n===e.length&&t.done()},o=0;o<e.length;o++)this._upXHRFile(e[o],t,o,i)},p.prototype._upXHRFile=function(e,t,n,i){var o=new FormData;o.append("key",this._key),o.append("isPrivate",t.isPrivate),o.append("file",e);var r=new XMLHttpRequest;r.onerror=function(){i({httpStatusCode:0,cause:"network-error",message:"Network error.",docsUrl:"https://ospry.io/docs#network-error"},null,n)},r.onload=function(){var e=JSON.parse(r.responseText);if(e.hasOwnProperty("error"))return void i(e.error,null,n);var t=e.results[0];if(t.hasOwnProperty("error"))return void i(t.error,null,n);var o=t.metadata;o.hasOwnProperty("timeCreated")&&(o.timeCreated=new Date(o.timeCreated)),i(null,o,n)},r.open("POST",this._serverURL+"/images",!0),r.send(o)},p.prototype._upIFrame=function(e){var n=u(e.form);if(null===n)throw"ospry: file input is missing from form";var i=n.getAttribute("name");n.setAttribute("name","file");var o="ospry-"+f(24),r=document.createElement("iframe");r.id=o,r.name=o,r.style.display="none",document.body.appendChild(r);var a=this._serverURL+"/images?frameId="+encodeURIComponent(o),s=document.createElement("form");s.setAttribute("method","POST"),s.setAttribute("action",a),s.setAttribute("target",o),s.setAttribute("enctype","multipart/form-data"),s.setAttribute("encoding","multipart/form-data"),s.style.display="none",document.body.appendChild(s);var l=document.createElement("input");l.setAttribute("name","key"),l.setAttribute("type","hidden"),l.setAttribute("value",this._key);var h=document.createElement("input");h.setAttribute("name","iframe"),h.setAttribute("type","hidden"),h.setAttribute("value","true");var p=document.createElement("input");p.setAttribute("name","isPrivate"),p.setAttribute("type","hidden"),p.setAttribute("value",e.isPrivate),s.appendChild(l),s.appendChild(h);var m=n.previousSibling;s.appendChild(n);var g=setTimeout(function(){document.body.removeChild(r),e.done()},6e4);c(t,"message",function n(i){if(i.source===r.contentWindow){clearTimeout(g),document.body.removeChild(s),document.body.removeChild(r),d(t,"message",n);var o=JSON.parse(i.data);if(o.hasOwnProperty("error"))return void e.done();for(var a=o.results,l=0;l<a.length;l++){var u=a[l];if(u.hasOwnProperty("error"))e.imageReady(u.error,null,l);else{var c=u.metadata;c.hasOwnProperty("timeCreated")&&(c.timeCreated=new Date(c.timeCreated)),e.imageReady(null,c,l)}}e.done()}}),s.submit(),null!==i&&""!==i?n.setAttribute("name",i):n.removeAttribute("name"),null!==m?m.parentNode.insertBefore(n,m.nextSibling):e.form.insertBefore(n,e.form.firstChild)},p.prototype.get=function(e){if(!o(e))throw"ospry: required options argument is not an object";if(e=l(e,{url:null,urls:null,format:null,maxWidth:null,maxHeight:null,preload:!0,imageReady:s,done:s}),null!==e.url&&(e.urls=[e.url]),null===e.urls)throw"ospry: no urls provided in options";if(0===e.urls.length)return void e.done();for(var t=0,n=function(n,i,o){e.imageReady(n,i,o),++t===e.urls.length&&e.done()},i=0;i<e.urls.length;i++){var r=new Image;e.preload&&(r.onerror=function(e,t){return function(){n({httpStatusCode:0,cause:"image-load-error",message:"Failed to load image.",docsUrl:"https://ospry.io/docs#image-load-error"},e,t)}}(r,i),r.onload=function(e,t){return function(){n(null,e,t)}}(r,i)),r.src=this.formatURL(e.urls[i],e),e.preload||n(null,r,i)}},p.prototype.formatURL=function(e,t){if(!a(e))throw"ospry: required url is not a string";if(void 0===t&&(t={}),!o(t))throw"ospry: options argument is not an object";if(t=l(t,{format:null,maxWidth:null,maxHeight:null}),null===t.format&&null===t.maxWidth&&null===t.maxHeight)return e;var n=m.parse(e);if(null===n)throw"ospry: invalid url";if(null!==t.format){if(!a(t.format))throw"ospry: format should be a string";if(""!==t.format){"jpg"===t.format&&(t.format="jpeg");for(var i=!1,s=0;s<p.formats.length;s++)if(p.formats[s]===t.format){i=!0;break}if(!i)throw"ospry: invalid format";n.set("format",t.format)}else n.remove("format")}if(null!==t.maxHeight){if(!r(t.maxHeight))throw"ospry: maxHeight should be a number";t.maxHeight>0?n.set("maxHeight",t.maxHeight):n.remove("maxHeight")}if(null!==t.maxWidth){if(!r(t.maxWidth))throw"ospry: maxWidth should be a number";t.maxWidth>0?n.set("maxWidth",t.maxWidth):n.remove("maxWidth")}return n.toString()};var m=function(){this.scheme=null,this.host=null,this.path=null,this.query={}};return m.parse=function(e){var t=new m,n=e.indexOf(":");if(-1===n)return null;t.scheme=e.slice(0,n),n+="://".length;var i=e.indexOf("/",n);if(-1===i)return null;t.host=e.slice(n,i);var o=e.indexOf("?",i);if(-1===o&&(o=e.length),t.path=e.slice(i,o),o!==e.length)for(var r=e.slice(o+1).split("&"),a=0;a<r.length;a++){var s=r[a],l=s.split("=");if(2!==l.length)return null;t.add(decodeURIComponent(l[0]),decodeURIComponent(l[1]))}return t},m.prototype.set=function(e,t){this.query[e]=[t]},m.prototype.add=function(e,t){this.query.hasOwnProperty(e)?this.query[e].push(t):this.query[e]=[t]},m.prototype.remove=function(e){delete this.query[e]},m.prototype.toString=function(){var e="";null!==this.scheme&&(e+=this.scheme+"://"),null!==this.host&&(e+=this.host),null!==this.path&&(e+=this.path);var t=this.query,n=[];for(var i in t)t.hasOwnProperty(i)&&n.push(i);n.sort();for(var o=!0,r=0;r<n.length;r++)for(var i=n[r],a=t[i],s=0;s<a.length;s++)o?(e+="?"+encodeURIComponent(i)+"="+encodeURIComponent(a[s]),o=!1):e+="&"+encodeURIComponent(i)+"="+encodeURIComponent(a[s]);return e},void 0!==e&&void 0!==e.exports?e.exports=p:"function"==typeof t.define&&t.define.amd?t.define("Ospry",function(){return p}):t.Ospry=p,p}},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),r=function(){function e(t){i(this,e),this.editors=document.querySelectorAll(".thesis-content-text"),this.enabled=!1,this.changed=this.changed.bind(this),this.onChange=t.onChange}return o(e,[{key:"enable",value:function(){if(!this.enabled){for(var e=0;e<this.editors.length;e++){var t=this.editors[e];t.contentEditable=!0,t.addEventListener("input",this.changed,!1),t.addEventListener("keydown",this.changed,!1)}this.enabled=!0}}},{key:"disable",value:function(){if(this.enabled){for(var e=0;e<this.editors.length;e++){var t=this.editors[e];t.contentEditable=!1,t.removeEventListener("input",this.changed,!1),t.removeEventListener("keydown",this.changed,!1)}this.enabled=!1}}},{key:"content",value:function(e){return e.textContent}},{key:"set",value:function(e,t){var n=document.querySelector("[data-thesis-content-id='"+e+"']");n&&(n.innerHTML=t.content,n.classList.add("modified"))}},{key:"changed",value:function(e){e.currentTarget.classList.add("modified"),13===e.keyCode&&e.preventDefault(),this.onChange()}}]),e}();t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(1),o=function(e){return e&&e.__esModule?e:{default:e}}(i),r=function(e){var t=document.querySelectorAll("meta[name=description]")[0];return{customHTMLEditor:window[e.getAttribute("data-html-editor")],fileUploader:e.getAttribute("data-file-uploader"),ospryPublicKey:e.getAttribute("data-ospry-public-key"),pageRedirectURL:e.getAttribute("data-redirect-url"),template:e.getAttribute("data-template"),templates:e.getAttribute("data-templates").split(",").filter(function(e){return""!==e}),isDynamicPage:e.getAttribute("data-dynamic-page"),path:window.location.pathname,getTitle:function(){return document.title},setTitle:function(e){return document.title=e},getDescription:function(){return t&&t.content},setDescription:function(e){return t&&(t.content=e)},getRedirectURL:function(){return e.getAttribute("data-redirect-url")},setRedirectURL:function(t){return e.setAttribute("data-redirect-url",t)},notifications:e.getAttribute("data-notifications"),save:function(e,t,n){o.default.put("/thesis/update",{page:e,contents:t}).then(function(t){e.slug!==window.location.pathname?window.location=e.slug:n()}).catch(function(e){window.alert("Something went wrong! Details: "+e)})},delete:function(e,t){o.default.delete("/thesis/delete",{path:e}).then(function(e){window.alert("Page has been deleted."),t()}).catch(function(e){window.alert("Something went wrong! Details: "+e)})}}};t.default=r},function(e,t){}]);