e.x;return e&&"explode"===n||!e&&"implode"===n?"start":e&&"implode"===n||!e&&"explode"===n?"end":"middle"}y.Pie=y.Base.extend({constructor:function(e,t,n,i){y.Pie.super.constructor.call(this,e,t,r,y.extend({},r,n),i)},createChart:function(s){var l,u,c=y.normalizeData(this.data),f=[],d=s.startAngle;this.svg=y.createSvg(this.container,s.width,s.height,s.donut?s.classNames.chartDonut:s.classNames.chartPie);var e=y.createChartRect(this.svg,s,r.padding),h=Math.min(e.width()/2,e.height()/2),p=s.total||c.normalized.series.reduce(function(e,t){return e+t},0),m=y.quantity(s.donutWidth);"%"===m.unit&&(m.value*=h/100),h-=s.donut&&!s.donutSolid?m.value/2:0,u="outside"===s.labelPosition||s.donut&&!s.donutSolid?h:"center"===s.labelPosition?0:s.donutSolid?h-m.value/2:h/2,u+=s.labelOffset;var g={x:e.x1+e.width()/2,y:e.y2+e.height()/2},v=1===c.raw.series.filter(function(e){return e.hasOwnProperty("value")?0!==e.value:0!==e}).length;c.raw.series.forEach(function(e,t){f[t]=this.svg.elem("g",null,null)}.bind(this)),s.showLabel&&(l=this.svg.elem("g",null,null)),c.raw.series.forEach(function(e,t){var n,i,r,o,a;0===c.normalized.series[t]&&s.ignoreEmptyValues||(f[t].attr({"ct:series-name":e.name}),f[t].addClass([s.classNames.series,e.className||s.classNames.series+"-"+y.alphaNumerate(t)].join(" ")),359.99<=(n=0":"","?":"","@":"","[":"","]":"","^":"","`":"","{":"","|":"","}":"","¡":"","£":"","¤":"","¥":"","¦":"","§":"","«":"","°":"","»":"","‘":"","’":"","“":"","”":"","\n":"-"," ":"-","-":"-","–":"-","—":"-","/":"-","\\":"-",_:"-","~":"-","À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","Æ":"Ae","Ç":"C","Ð":"D","È":"E","É":"E","Ê":"E","Ë":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","Œ":"Oe","Š":"S","Þ":"Th","Ù":"U","Ú":"U","Û":"U","Ü":"U","Ý":"Y","à":"a","á":"a","â":"a","ã":"a","ä":"ae","å":"a","æ":"ae","¢":"c","ç":"c","ð":"d","è":"e","é":"e","ê":"e","ë":"e","ì":"i","í":"i","î":"i","ï":"i","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"oe","ø":"o","œ":"oe","š":"s","ß":"ss","þ":"th","ù":"u","ú":"u","û":"u","ü":"ue","ý":"y","ÿ":"y","Ÿ":"y"};for(t in e=e.toLowerCase(),n)Object.prototype.hasOwnProperty.call(n,t)&&(e=e.split(t).join(n[t]));return e.replace(/[^a-z0-9-]/g,"").replace(/^-+|-+$/g,"").replace(/-+/g,"-")},validateSlug:function(e){return e.toLowerCase().replace(" ","-").replace(/[^a-z0-9-]/g,"")},debounce:function(e,t,n){var i,r,o,a=null;return function(){return i=this,r=arguments,a&&clearTimeout(a),n&&!a&&(o=e.apply(i,r)),a=setTimeout(function(){n||(o=e.apply(i,r)),a=null},t),o}},throttle:function(n,i){var r,o,a,s=0,l=null;return function(){var e=Date.now(),t=(s=0===s?e:s)+i-e;return r=this,o=arguments,t<=0||i"===t[0]&&(t=t.substring(1)),e))try{if(e.matches)return e.matches(t);if(e.msMatchesSelector)return e.msMatchesSelector(t);if(e.webkitMatchesSelector)return e.webkitMatchesSelector(t)}catch(e){return}}function O(e,t,n,i){if(e){n=n||document;do{if(null!=t&&(">"!==t[0]||e.parentNode===n)&&E(e,t)||i&&e===n)return e}while(e!==n&&(e=(r=e).host&&r!==document&&r.host.nodeType?r.host:r.parentNode))}var r;return null}var M,T=/\s+/g;function N(e,t,n){var i;e&&t&&(e.classList?e.classList[n?"add":"remove"](t):(i=(" "+e.className+" ").replace(T," ").replace(" "+t+" "," "),e.className=(i+(n?" "+t:"")).replace(T," ")))}function F(e,t,n){var i=e&&e.style;if(i){if(void 0===n)return document.defaultView&&document.defaultView.getComputedStyle?n=document.defaultView.getComputedStyle(e,""):e.currentStyle&&(n=e.currentStyle),void 0===t?n:n[t];i[t=!(t in i||-1!==t.indexOf("webkit"))?"-webkit-"+t:t]=n+("string"==typeof n?"":"px")}}function D(e,t){var n="";if("string"==typeof e)n=e;else do{var i=F(e,"transform")}while(i&&"none"!==i&&(n=i+" "+n),!t&&(e=e.parentNode));var r=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return r&&new r(n)}function I(e,t,n){if(e){var i=e.getElementsByTagName(t),r=0,o=i.length;if(n)for(;r=n.left-t&&r<=n.right+t,t=o>=n.top-t&&o<=n.bottom+t;return i&&t?a=e:void 0}}),a);if(t){var n,i={};for(n in e)e.hasOwnProperty(n)&&(i[n]=e[n]);i.target=i.rootEl=t,i.preventDefault=void 0,i.stopPropagation=void 0,t[G]._onDragOver(i)}}var r,o,a}function Ue(e){ne&&ne.parentNode[G]._isOutsideThisEl(e.target)}function qe(e,t){if(!e||!e.nodeType||1!==e.nodeType)throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(e));this.el=e,this.options=t=h({},t),e[G]=this;var n,i,r={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(e.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return We(e,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(e,t){e.setData("Text",t.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:!1!==qe.supportPointer&&"PointerEvent"in window&&!y,emptyInsertThreshold:5};for(n in Z.initializePlugins(this,e,r),r)n in t||(t[n]=r[n]);for(i in Re(t),this)"_"===i.charAt(0)&&"function"==typeof this[i]&&(this[i]=this[i].bind(this));this.nativeDraggable=!t.forceFallback&&ze,this.nativeDraggable&&(this.options.touchStartThreshold=1),t.supportPointer?S(e,"pointerdown",this._onTapStart):(S(e,"mousedown",this._onTapStart),S(e,"touchstart",this._onTapStart)),this.nativeDraggable&&(S(e,"dragover",this),S(e,"dragenter",this)),De.push(this.el),t.store&&t.store.get&&this.sort(t.store.get(this)||[]),h(this,V())}function Xe(e,t,n,i,r,o,a,s){var l,u,c=e[G],f=c.options.onMove;return!window.CustomEvent||b||w?(l=document.createEvent("Event")).initEvent("move",!0,!0):l=new CustomEvent("move",{bubbles:!0,cancelable:!0}),l.to=t,l.from=e,l.dragged=n,l.draggedRect=i,l.related=r||t,l.relatedRect=o||H(t),l.willInsertAfter=s,l.originalEvent=a,e.dispatchEvent(l),u=f?f.call(c,l,a):u}function Ge(e){e.draggable=!1}function Ve(){Fe=!1}function Ke(e){return setTimeout(e,0)}function Qe(e){return clearTimeout(e)}qe.prototype={constructor:qe,_isOutsideThisEl:function(e){this.el.contains(e)||e===this.el||(Ce=null)},_getDirection:function(e,t){return"function"==typeof this.options.direction?this.options.direction.call(this,e,t,ne):this.options.direction},_onTapStart:function(t){if(t.cancelable){var n=this,i=this.el,e=this.options,r=e.preventOnFilter,o=t.type,a=t.touches&&t.touches[0]||t.pointerType&&"touch"===t.pointerType&&t,s=(a||t).target,l=t.target.shadowRoot&&(t.path&&t.path[0]||t.composedPath&&t.composedPath()[0])||s,u=e.filter;if(!function(e){Ie.length=0;var t=e.getElementsByTagName("input"),n=t.length;for(;n--;){var i=t[n];i.checked&&Ie.push(i)}}(i),!ne&&!(/mousedown|pointerdown/.test(o)&&0!==t.button||e.disabled)&&!l.isContentEditable&&(this.nativeDraggable||!y||!s||"SELECT"!==s.tagName.toUpperCase())&&!((s=O(s,e.draggable,i,!1))&&s.animated||se===s)){if(ce=R(s),de=R(s,e.draggable),"function"==typeof u){if(u.call(this,t,s,this))return te({sortable:n,rootEl:l,name:"filter",targetEl:s,toEl:i,fromEl:i}),J("filter",n,{evt:t}),void(r&&t.cancelable&&t.preventDefault())}else if(u=u&&u.split(",").some(function(e){if(e=O(l,e.trim(),i,!1))return te({sortable:n,rootEl:e,name:"filter",targetEl:s,fromEl:i,toEl:i}),J("filter",n,{evt:t}),!0}))return void(r&&t.cancelable&&t.preventDefault());e.handle&&!O(l,e.handle,i,!1)||this._prepareDragStart(t,a,s)}}},_prepareDragStart:function(e,t,n){var i,r=this,o=r.el,a=r.options,s=o.ownerDocument;n&&!ne&&n.parentNode===o&&(i=H(n),oe=o,ie=(ne=n).parentNode,ae=ne.nextSibling,se=n,pe=a.group,ge={target:qe.dragged=ne,clientX:(t||e).clientX,clientY:(t||e).clientY},be=ge.clientX-i.left,we=ge.clientY-i.top,this._lastX=(t||e).clientX,this._lastY=(t||e).clientY,ne.style["will-change"]="all",i=function(){J("delayEnded",r,{evt:e}),qe.eventCanceled?r._onDrop():(r._disableDelayedDragEvents(),!g&&r.nativeDraggable&&(ne.draggable=!0),r._triggerDragStart(e,t),te({sortable:r,name:"choose",originalEvent:e}),N(ne,a.chosenClass,!0))},a.ignore.split(",").forEach(function(e){I(ne,e.trim(),Ge)}),S(s,"dragover",Ye),S(s,"mousemove",Ye),S(s,"touchmove",Ye),S(s,"mouseup",r._onDrop),S(s,"touchend",r._onDrop),S(s,"touchcancel",r._onDrop),g&&this.nativeDraggable&&(this.options.touchStartThreshold=4,ne.draggable=!0),J("delayStart",this,{evt:e}),!a.delay||a.delayOnTouchOnly&&!t||this.nativeDraggable&&(w||b)?i():qe.eventCanceled?this._onDrop():(S(s,"mouseup",r._disableDelayedDrag),S(s,"touchend",r._disableDelayedDrag),S(s,"touchcancel",r._disableDelayedDrag),S(s,"mousemove",r._delayedDragTouchMoveHandler),S(s,"touchmove",r._delayedDragTouchMoveHandler),a.supportPointer&&S(s,"pointermove",r._delayedDragTouchMoveHandler),r._dragStartTimer=setTimeout(i,a.delay)))},_delayedDragTouchMoveHandler:function(e){e=e.touches?e.touches[0]:e;Math.max(Math.abs(e.clientX-this._lastX),Math.abs(e.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){ne&&Ge(ne),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;L(e,"mouseup",this._disableDelayedDrag),L(e,"touchend",this._disableDelayedDrag),L(e,"touchcancel",this._disableDelayedDrag),L(e,"mousemove",this._delayedDragTouchMoveHandler),L(e,"touchmove",this._delayedDragTouchMoveHandler),L(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,t){t=t||"touch"==e.pointerType&&e,!this.nativeDraggable||t?this.options.supportPointer?S(document,"pointermove",this._onTouchMove):S(document,t?"touchmove":"mousemove",this._onTouchMove):(S(ne,"dragend",this),S(oe,"dragstart",this._onDragStart));try{document.selection?Ke(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch(e){}},_dragStarted:function(e,t){var n;Me=!1,oe&&ne?(J("dragStarted",this,{evt:t}),this.nativeDraggable&&S(document,"dragover",Ue),n=this.options,e||N(ne,n.dragClass,!1),N(ne,n.ghostClass,!0),qe.active=this,e&&this._appendGhost(),te({sortable:this,name:"start",originalEvent:t})):this._nulling()},_emulateDragOver:function(){if(ve){this._lastX=ve.clientX,this._lastY=ve.clientY,je();for(var e=document.elementFromPoint(ve.clientX,ve.clientY),t=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(ve.clientX,ve.clientY))!==t;)t=e;if(ne.parentNode[G]._isOutsideThisEl(e),t)do{if(t[G])if(t[G]._onDragOver({clientX:ve.clientX,clientY:ve.clientY,target:e,rootEl:t})&&!this.options.dragoverBubble)break}while(t=(e=t).parentNode);_e()}},_onTouchMove:function(e){if(ge){var t=this.options,n=t.fallbackTolerance,i=t.fallbackOffset,r=e.touches?e.touches[0]:e,o=re&&D(re,!0),a=re&&o&&o.a,s=re&&o&&o.d,t=He&&Ee&&j(Ee),a=(r.clientX-ge.clientX+i.x)/(a||1)+(t?t[0]-Ne[0]:0)/(a||1),s=(r.clientY-ge.clientY+i.y)/(s||1)+(t?t[1]-Ne[1]:0)/(s||1);if(!qe.active&&!Me){if(n&&Math.max(Math.abs(r.clientX-this._lastX),Math.abs(r.clientY-this._lastY))n.right+10||e.clientX<=n.right&&e.clientY>n.bottom&&e.clientX>=n.left:e.clientX>n.right&&e.clientY>n.top||e.clientX<=n.right&&e.clientY>n.bottom+10}(n,o,this)&&!m.animated){if(m===ne)return T(!1);if((s=m&&a===n.target?m:s)&&(b=H(s)),!1!==Xe(oe,a,ne,i,s,b,n,!!s))return M(),a.appendChild(ne),ie=a,D(),T(!0)}else if(m&&function(e,t,n){n=H(B(n.el,0,n.options,!0));return t?e.clientX",c+="",i=0;i<7;i++)c+='";for(c+="
",i=0;i<6;i++){for(r=0;r<7;r++)o<=s&&(0':'| ',c+=o++):1===o?(c+=' | ',c+=h.daysInMonth(h.mod(t-1,12),e)-u+r+1):(c+=' | ',c+=o++-s),c+=" | ";c+="
"}c+="
",$(".calendar-table",p).innerHTML=c,$$(".calendar-day",p).forEach(function(e){e.addEventListener("mousedown",function(e){e.stopPropagation(),e.preventDefault()}),e.addEventListener("click",function(){var e=m(),t=new Date(d.year,d.month,parseInt(this.textContent));e.setAttribute("data-date",t),e.value=h.formatDateTime(t),e.blur()})})}function t(){var e,t,n,i,r,o;(a=m())&&"block"===p.style.display&&(i=(n=a.getBoundingClientRect()).top+window.pageYOffset,r=n.left+window.pageXOffset,p.style.top=i+a.offsetHeight+"px",p.style.left=r+a.offsetLeft+"px",e=(o=p.getBoundingClientRect()).top+window.pageYOffset,t=o.left+window.pageXOffset,n=x.outerWidth(p),i=x.outerHeight(p),r=document.documentElement.clientWidth,o=document.documentElement.clientHeight,rh.daysInMonth(this.month,this.year)&&this.lastDay()},nextMonth:function(){this.month=h.mod(this.month+1,12),0===this.month&&this.nextYear(),this.day>h.daysInMonth(this.month,this.year)&&this.lastDay()},prevWeek:function(){this.day-=7,this.day<1&&(this.prevMonth(),this.day+=h.daysInMonth(this.month,this.year))},nextWeek:function(){this.day+=7,this.day>h.daysInMonth(this.month,this.year)&&(this.day-=h.daysInMonth(this.month,this.year),this.nextMonth())},prevDay:function(){this.day--,this.day<1&&(this.prevMonth(),this.lastDay())},nextDay:function(){this.day++,this.day>h.daysInMonth(this.month,this.year)&&(this.nextMonth(),this.day=1)},nextHour:function(){this.hours=h.mod(this.hours+1,24),0===this.hours&&this.nextDay()},prevHour:function(){this.hours=h.mod(this.hours-1,24),23===this.hours&&this.prevDay()},nextMinute:function(){this.minutes=h.mod(this.minutes+1,60),0===this.minutes&&this.nextHour()},prevMinute:function(){this.minutes=h.mod(this.minutes-1,60),59===this.minutes&&this.prevHour()},nextSecond:function(){this.seconds=h.mod(this.seconds+1,60),0===this.seconds&&this.nextMinute()},prevSecond:function(){this.seconds=h.mod(this.seconds-1,60),59===this.minutes&&this.prevMinute()}},h={_daysInMonth:[31,28,31,30,31,30,31,31,30,31,30,31],mod:function(e,t){return e-t*Math.floor(e/t)},pad:function(e,t){for(var n=e.toString();n.length=i.getTime()?t+1:e.getTime()>=n.getTime()?t:t-1},weekOfYear:function(e){var t=this.weekNumberingYear(e),t=this.weekStart(new Date(t,0,4),1),e=this.weekStart(e,1);return Math.round((e.getTime()-t.getTime())/6048e5)+1},has12HourFormat:function(e){e=e.match(/\[([^\]]*)\]|H{1,2}/);return null!==e&&"H"===e[0][0]},formatDateTime:function(n,e){var i=this;function r(e){var t=0',!0===f.time&&(p.innerHTML+='',u.inject("chevron-down",$(".prevHour",p)),u.inject("chevron-up",$(".nextHour",p)),u.inject("chevron-down",$(".prevMinute",p)),u.inject("chevron-up",$(".nextMinute",p)),x.longClick($(".nextHour",p),function(e){d.nextHour(),i(a),e.preventDefault()},750,250),x.longClick($(".prevHour",p),function(e){d.prevHour(),i(a),e.preventDefault()},750,250),x.longClick($(".nextMinute",p),function(e){d.nextMinute(),i(a),e.preventDefault()},750,250),x.longClick($(".prevMinute",p),function(e){d.prevMinute(),i(a),e.preventDefault()},750,250));return document.body.appendChild(p),u.inject("calendar-clock",$(".currentMonth",p)),u.inject("chevron-left",$(".prevMonth",p)),u.inject("chevron-right",$(".nextMonth",p)),$(".currentMonth",p).addEventListener("mousedown",function(e){var t=m(),n=new Date;d.setDate(n),i(t),t.blur(),e.preventDefault()}),x.longClick($(".prevMonth",p),function(e){d.prevMonth(),i(a),e.preventDefault()},750,500),x.longClick($(".nextMonth",p),function(e){d.nextMonth(),i(a),e.preventDefault()},750,500),window.addEventListener("mousedown",function(e){"none"!==p.style.display&&e.target.closest(".calendar")&&e.preventDefault()}),window.addEventListener("resize",x.throttle(t,100)),p}(),function(){var e=a.value;a.readOnly=!0,a.size=f.format.length,h.isValidDate(e)&&(e=new Date(e),a.setAttribute("data-date",e),a.value=h.formatDateTime(e));a.addEventListener("change",function(){""===this.value?this.setAttribute("data-date",""):this.value=h.formatDateTime(this.getAttribute("data-date"))}),a.addEventListener("keydown",function(e){var t=this.getAttribute("data-date");switch(d.setDate(h.isValidDate(t)?new Date(t):new Date),e.which){case 13:$(".calendar-day.selected",p).click(),p.style.display="none";break;case 8:this.value="",this.blur(),p.style.display="none";break;case 27:this.blur(),p.style.display="none";break;case 37:e.ctrlKey||e.metaKey?e.shiftKey?d.prevYear():d.prevMonth():d.prevDay(),i(this);break;case 38:d.prevWeek(),i(this);break;case 39:e.ctrlKey||e.metaKey?e.shiftKey?d.nextYear():d.nextMonth():d.nextDay(),i(this);break;case 40:d.nextWeek(),i(this);break;case 48:(e.ctrlKey||e.metaKey)&&d.setDate(new Date),i(this);break;default:return}e.stopPropagation(),e.preventDefault()}),a.addEventListener("focus",function(){var e=h.isValidDate(this.getAttribute("data-date"))?new Date(this.getAttribute("data-date")):new Date;d.setDate(e),r(d.year,d.month,d.day),n(d.hours,d.minutes),p.style.display="block",t()}),a.addEventListener("blur",function(){p.style.display="none"})}()}function ht(s,l){var u,c,f={years:31536e3,months:2592e3,weeks:604800,days:86400,hours:3600,minutes:60,seconds:1},d={},h={};function p(e,t){var n,i={};for(n in e=x.toSafeInteger(e),void 0===t&&(t=l.intervals),f)Object.prototype.hasOwnProperty.call(f,n)&&-1!==t.indexOf(n)&&(i[n]=Math.floor(e/f[n]),e-=i[n]*f[n]);return i}function m(){var e,t={},n=0,i=0;for(i in d)Object.prototype.hasOwnProperty.call(d,i)&&(t[i]=d[i].value);n=function(e){var t,n=0;for(t in e)Object.prototype.hasOwnProperty.call(e,t)&&Object.prototype.hasOwnProperty.call(f,t)&&(n+=e[t]*f[t]);return x.toSafeInteger(n)}(t),c.step&&(e=c.step*f[l.unit],n=Math.floor(n/e)*e),c.min&&(n=Math.max(n,c.min)),c.max&&(n=Math.min(n,c.max)),c.value=Math.round(n/f[l.unit])}function g(){for(var e in d)Object.prototype.hasOwnProperty.call(d,e)&&(d[e].style.width=Math.max(3,d[e].value.length+2)+"ch")}function v(){for(var e in d)Object.prototype.hasOwnProperty.call(d,e)&&(h[e].innerHTML=l.labels[e][1===parseInt(d[e].value)?0:1])}l=x.extendObject({},{unit:"seconds",intervals:["years","months","weeks","days","hours","minutes","seconds"],labels:{years:["year","years"],months:["month","months"],weeks:["week","weeks"],days:["day","days"],hours:["hour","hours"],minutes:["minute","minutes"],seconds:["second","seconds"]}},l),function(){var e,t;(c=document.createElement("input")).className="duration-hidden-input",c.name=s.name,c.id=s.id,c.type="text",c.value=s.value,c.readOnly=!0,c.hidden=!0,s.min&&(c.min=s.min);s.max&&(c.max=s.max);s.step&&(c.step=s.step);s.required&&(c.required=!0);s.disabled&&(c.disabled=!0);s.hasAttribute("data-intervals")&&(l.intervals=s.getAttribute("data-intervals").split(", "));s.hasAttribute("data-unit")&&(l.unit=s.getAttribute("data-unit"));e=s.value*f[l.unit],t=s.step*f[l.unit],t=function(e,t){var n,i,r,o,a;for((u=document.createElement("div")).className="duration-input",a=0;ax.getMaxSafeInteger();)this.value=this.value.slice(0,-1);g(),m(),v()}),r.addEventListener("blur",function(){m(),function(){var e,t=p(c.value*f[l.unit]);for(e in d)Object.prototype.hasOwnProperty.call(d,e)&&(d[e].value=t[e])}(),g(),v()}),r.addEventListener("focus",function(){u.classList.add("focused")}),r.addEventListener("blur",function(){u.classList.remove("focused")}),n.addEventListener("mousedown",function(e){var t=$("input",this);t&&e.target!==t&&(t.focus(),e.preventDefault())}),(o=document.createElement("label")).innerHTML=l.labels[i][1===parseInt(r.value)?0:1],h[i]=o,n.appendChild(r),n.appendChild(o),u.appendChild(n);return u.addEventListener("mousedown",function(e){e.target===this&&(r.focus(),e.preventDefault())}),u}(p(e||0),p(t||1)),s.parentNode.replaceChild(t,s),t.appendChild(c)}()}ut.prototype={startIndex:null,dragStart:function(e){e=e.oldDraggableIndex;this.startIndex=e},onSpill:function(e){var t=e.dragEl,n=e.putSortable;this.sortable.captureAnimationState(),n&&n.captureAnimationState();e=B(this.sortable.el,this.startIndex,this.options);e?this.sortable.el.insertBefore(t,e):this.sortable.el.appendChild(t),this.sortable.animateAll(),n&&n.animateAll()},drop:k},h(ut,{pluginName:"revertOnSpill"}),ct.prototype={onSpill:function(e){var t=e.dragEl,e=e.putSortable||this.sortable;e.captureAnimationState(),t.parentNode&&t.parentNode.removeChild(t),e.animateAll()},drop:k},h(ct,{pluginName:"removeOnSpill"}),qe.mount(new function(){function e(){for(var e in this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0},this)"_"===e.charAt(0)&&"function"==typeof this[e]&&(this[e]=this[e].bind(this))}return e.prototype={dragStarted:function(e){e=e.originalEvent;this.sortable.nativeDraggable?S(document,"dragover",this._handleAutoScroll):this.options.supportPointer?S(document,"pointermove",this._handleFallbackAutoScroll):e.touches?S(document,"touchmove",this._handleFallbackAutoScroll):S(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(e){e=e.originalEvent;this.options.dragOverBubble||e.rootEl||this._handleAutoScroll(e)},drop:function(){this.sortable.nativeDraggable?L(document,"dragover",this._handleAutoScroll):(L(document,"pointermove",this._handleFallbackAutoScroll),L(document,"touchmove",this._handleFallbackAutoScroll),L(document,"mousemove",this._handleFallbackAutoScroll)),st(),at(),clearTimeout(M),M=void 0},nulling:function(){nt=Je=Ze=ot=it=et=tt=null,rt.length=0},_handleFallbackAutoScroll:function(e){this._handleAutoScroll(e,!0)},_handleAutoScroll:function(t,n){var i,r=this,o=(t.touches?t.touches[0]:t).clientX,a=(t.touches?t.touches[0]:t).clientY,e=document.elementFromPoint(o,a);nt=t,n||this.options.forceAutoScrollFallback||w||b||y?(lt(t,this.options,e,n),i=_(e,!0),!ot||it&&o===et&&a===tt||(it&&st(),it=setInterval(function(){var e=_(document.elementFromPoint(o,a),!0);e!==i&&(i=e,at()),lt(t,r.options,e,n)},10),et=o,tt=a)):this.options.bubbleScroll&&_(e,!0)!==P()?lt(t,this.options,_(e,!1),!1):at()}},h(e,{pluginName:"scroll",initializeByDefault:!0})}),qe.mount(ct,ut);var pt,k={exports:{}},mt=k.exports=function(){var e=navigator.userAgent,t=navigator.platform,m=/gecko\/\d/i.test(e),n=/MSIE \d/.test(e),i=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(e),r=/Edge\/(\d+)/.exec(e),S=n||i||r,w=S&&(n?document.documentMode||6:+(r||i)[1]),g=!r&&/WebKit\//.test(e),o=g&&/Qt\/\d+\.\d+/.test(e),a=!r&&/Chrome\//.test(e),v=/Opera\//.test(e),c=/Apple Computer/.test(navigator.vendor),s=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(e),l=/PhantomJS/.test(e),u=c&&(/Mobile\/\w+/.test(e)||navigator.maxTouchPoints>2),f=/Android/.test(e),d=u||f||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(e),y=u||/Mac/.test(t),h=/\bCrOS\b/.test(e),p=/win/i.test(t),x=v&&e.match(/Version\/(\d*\.\d*)/);if(x)x=Number(x[1]);if(x&&x>=15){v=false;g=true}var b=y&&(o||v&&(x==null||x<12.11)),k=m||S&&w>=9;function C(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var L=function(e,t){var n=e.className;var i=C(t).exec(n);if(i){var r=n.slice(i.index+i[0].length);e.className=n.slice(0,i.index)+(r?i[1]+r:"")}},E;function M(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function T(e,t){return M(e).appendChild(t)}function O(e,t,n,i){var r=document.createElement(e);if(n)r.className=n;if(i)r.style.cssText=i;if(typeof t=="string")r.appendChild(document.createTextNode(t));else if(t)for(var o=0;o=t)return a+(t-o);a+=s-o;a+=n-a%n;o=s+1}}var B=function(){this.id=null;this.f=null;this.time=0;this.handler=H(this.onTimeout,this)};function W(e,t){for(var n=0;n=t)return i+Math.min(a,t-r);r+=o-i;r+=n-r%n;i=o+1;if(r>=t)return i}}var X=[""];function G(e){while(X.length<=e)X.push(V(X)+" ");return X[e]}function V(e){return e[e.length-1]}function K(e,t){var n=[];for(var i=0;i""&&(e.toUpperCase()!=e.toLowerCase()||ee.test(e))}function ne(e,t){if(!t)return te(e);if(t.source.indexOf("\\w")>-1&&te(e))return true;return t.test(e)}function ie(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return false;return true}var re=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;function oe(e){return e.charCodeAt(0)>=768&&re.test(e)}function ae(e,t,n){while((n<0?t>0:tn?-1:1;for(;;){if(t==n)return t;var r=(t+n)/2,o=i<0?Math.ceil(r):Math.floor(r);if(o==t)return e(o)?t:n;if(e(o))n=o;else t=o+i}}function le(e,t,n,i){if(!e)return i(t,n,"ltr",0);var r=false;for(var o=0;ot||t==n&&a.to==t){i(Math.max(a.from,t),Math.min(a.to,n),a.level==1?"rtl":"ltr",o);r=true}}if(!r)i(t,n,"ltr")}var ue=null;function ce(e,t,n){var i;ue=null;for(var r=0;rt)return r;if(o.to==t)if(o.from!=o.to&&n=="before")i=r;else ue=r;if(o.from==t)if(o.from!=o.to&&n!="before")i=r;else ue=r}return i!=null?i:ue}var fe=function(){var t="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN";var n="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function z(e){if(e<=247)return t.charAt(e);else if(1424<=e&&e<=1524)return"R";else if(1536<=e&&e<=1785)return n.charAt(e-1536);else if(1774<=e&&e<=2220)return"r";else if(8192<=e&&e<=8203)return"w";else if(e==8204)return"b";else return"L"}var B=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;var W=/[stwN]/,R=/[LRr]/,j=/[Lb1n]/,_=/[1n]/;function Y(e,t,n){this.level=e;this.from=t;this.to=n}return function(e,t){var n=t=="ltr"?"L":"R";if(e.length==0||t=="ltr"&&!B.test(e))return false;var i=e.length,r=[];for(var o=0;o-1)i[t]=r.slice(0,o).concat(r.slice(o+1))}}}function ve(e,t){var n=me(e,t);if(!n.length)return;var i=Array.prototype.slice.call(arguments,2);for(var r=0;r0}function we(e){e.prototype.on=function(e,t){pe(this,e,t)};e.prototype.off=function(e,t){ge(this,e,t)}}function ke(e){if(e.preventDefault)e.preventDefault();else e.returnValue=false}function Ce(e){if(e.stopPropagation)e.stopPropagation();else e.cancelBubble=true}function Se(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==false}function Le(e){ke(e);Ce(e)}function Ee(e){return e.target||e.srcElement}function Me(e){var t=e.which;if(t==null)if(e.button&1)t=1;else if(e.button&2)t=3;else if(e.button&4)t=2;if(y&&e.ctrlKey&&t==1)t=3;return t}var Te=function(){if(S&&w<9)return false;var e=O("div");return"draggable"in e||"dragDrop"in e}(),De,Ae;function Oe(e){if(De==null){var t=O("span","");T(e,O("span",[t,document.createTextNode("x")]));if(e.firstChild.offsetHeight!=0)De=t.offsetWidth<=1&&t.offsetHeight>2&&!(S&&w<8)}var n=De?O("span",""):O("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");n.setAttribute("cm-text","");return n}function Ne(e){if(Ae!=null)return Ae;var t=T(e,document.createTextNode("AخA"));var n=E(t,0,1).getBoundingClientRect();var i=E(t,1,2).getBoundingClientRect();M(e);if(!n||n.left==n.right)return false;return Ae=i.right-n.right<3}var Fe="\n\nb".split(/\n/).length!=3?function(e){var t=0,n=[],i=e.length;while(t<=i){var r=e.indexOf("\n",t);if(r==-1)r=e.length;var o=e.slice(t,e.charAt(r-1)=="\r"?r-1:r);var a=o.indexOf("\r");if(a!=-1){n.push(o.slice(0,a));t+=a+1}else{n.push(o);t=r+1}}return n}:function(e){return e.split(/\r\n?|\n/)},Ie=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(e){return false}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch(e){}if(!t||t.parentElement()!=e)return false;return t.compareEndPoints("StartToEnd",t)!=0},Pe=function(){var e=O("div");if("oncopy"in e)return true;e.setAttribute("oncopy","return;");return typeof e.oncopy=="function"}(),He=null;function $e(e){if(He!=null)return He;var t=T(e,O("span","x"));var n=t.getBoundingClientRect();var i=E(t,0,1).getBoundingClientRect();return He=Math.abs(n.left-i.left)>1}var ze={},Be={};function We(e,t){if(arguments.length>2)t.dependencies=Array.prototype.slice.call(arguments,2);ze[e]=t}function Re(e,t){Be[e]=t}function je(e){if(typeof e=="string"&&Be.hasOwnProperty(e))e=Be[e];else if(e&&typeof e.name=="string"&&Be.hasOwnProperty(e.name)){var t=Be[e.name];if(typeof t=="string")t={name:t};e=J(t,e);e.name=t.name}else if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return je("application/xml");else if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return je("application/json");if(typeof e=="string")return{name:e};else return e||{name:"null"}}function _e(e,t){t=je(t);var n=ze[t.name];if(!n)return _e(e,"text/plain");var i=n(e,t);if(Ye.hasOwnProperty(t.name)){var r=Ye[t.name];for(var o in r){if(!r.hasOwnProperty(o))continue;if(i.hasOwnProperty(o))i["_"+o]=i[o];i[o]=r[o]}}i.name=t.name;if(t.helperType)i.helperType=t.helperType;if(t.modeProps)for(var a in t.modeProps)i[a]=t.modeProps[a];return i}var Ye={};function Ue(e,t){var n=Ye.hasOwnProperty(e)?Ye[e]:Ye[e]={};$(t,n)}function qe(e,t){if(t===true)return t;if(e.copyState)return e.copyState(t);var n={};for(var i in t){var r=t[i];if(r instanceof Array)r=r.concat([]);n[i]=r}return n}function Xe(e,t){var n;while(e.innerMode){n=e.innerMode(t);if(!n||n.mode==e)break;t=n.state;e=n.mode}return n||{mode:e,state:t}}function Ge(e,t,n){return e.startState?e.startState(t,n):true}var Ve=function(e,t,n){this.pos=this.start=0;this.string=e;this.tabSize=t||8;this.lastColumnPos=this.lastColumnValue=0;this.lineStart=0;this.lineOracle=n};function Ke(e,t){t-=e.first;if(t<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");var n=e;while(!n.lines)for(var i=0;;++i){var r=n.children[i],o=r.chunkSize();if(t=e.first&&tn)return rt(n,Ke(e,n).text.length);return dt(t,Ke(e,t.line).text.length)}function dt(e,t){var n=e.ch;if(n==null||n>t)return rt(e.line,t);else if(n<0)return rt(e.line,0);else return e}function ht(e,t){var n=[];for(var i=0;i=this.string.length},Ve.prototype.sol=function(){return this.pos==this.lineStart},Ve.prototype.peek=function(){return this.string.charAt(this.pos)||undefined},Ve.prototype.next=function(){if(this.post},Ve.prototype.eatSpace=function(){var e=this.pos;while(/[\s\u00a0]/.test(this.string.charAt(this.pos)))++this.pos;return this.pos>e},Ve.prototype.skipToEnd=function(){this.pos=this.string.length},Ve.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1){this.pos=t;return true}},Ve.prototype.backUp=function(e){this.pos-=e},Ve.prototype.column=function(){if(this.lastColumnPos0)return null;if(o&&t!==false)this.pos+=o[0].length;return o}},Ve.prototype.current=function(){return this.string.slice(this.start,this.pos)},Ve.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},Ve.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},Ve.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};var pt=function(e,t){this.state=e;this.lookAhead=t},mt=function(e,t,n,i){this.state=t;this.doc=e;this.line=n;this.maxLookAhead=i||0;this.baseTokens=null;this.baseTokenPos=1};function gt(t,n,i,e){var l=[t.state.modeGen],r={};Lt(t,n.text,t.doc.mode,i,function(e,t){return l.push(e,t)},r,e);var u=i.state;var o=function(e){i.baseTokens=l;var o=t.state.overlays[e],a=1,s=0;i.state=true;Lt(t,n.text,o.mode,i,function(e,t){var n=a;while(se)l.splice(a,1,e,l[a+1],i);a+=2;s=Math.min(e,i)}if(!t)return;if(o.opaque){l.splice(n,a-n,e,"overlay "+t);a=n+2}else for(;ne.options.maxHighlightLength&&qe(e.doc.mode,i.state);var o=gt(e,t,i);if(r)i.state=r;t.stateAfter=i.save(!r);t.styles=o.styles;if(o.classes)t.styleClasses=o.classes;else if(t.styleClasses)t.styleClasses=null;if(n===e.doc.highlightFrontier)e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier)}return t.styles}function yt(n,i,e){var t=n.doc,r=n.display;if(!t.mode.startState)return new mt(t,true,i);var o=Et(n,i,e);var a=o>t.first&&Ke(t,o-1).stateAfter;var s=a?mt.fromSaved(t,a,o):new mt(t,Ge(t.mode),o);t.iter(o,i,function(e){xt(n,e.text,s);var t=s.line;e.stateAfter=t==i-1||t%5==0||t>=r.viewFrom&&tt.start)return o}throw new Error("Mode "+e.name+" failed to advance stream.")}mt.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);if(t!=null&&e>this.maxLookAhead)this.maxLookAhead=e;return t},mt.prototype.baseToken=function(e){if(!this.baseTokens)return null;while(this.baseTokens[this.baseTokenPos]<=e)this.baseTokenPos+=2;var t=this.baseTokens[this.baseTokenPos+1];return{type:t&&t.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-e}},mt.prototype.nextLine=function(){this.line++;if(this.maxLookAhead>0)this.maxLookAhead--},mt.fromSaved=function(e,t,n){if(t instanceof pt)return new mt(e,qe(e.mode,t.state),n,t.lookAhead);else return new mt(e,qe(e.mode,t),n)},mt.prototype.save=function(e){var t=e!==false?qe(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new pt(t,this.maxLookAhead):t};var kt=function(e,t,n){this.start=e.start;this.end=e.pos;this.string=e.current();this.type=t||null;this.state=n};function Ct(e,t,n,i){var r=e.doc,o=r.mode,a;t=ft(r,t);var s=Ke(r,t.line),l=yt(e,t.line,n);var u=new Ve(s.text,e.options.tabSize,l),c;if(i)c=[];while((i||u.pose.options.maxHighlightLength){s=false;if(a)xt(e,t,i,c.pos);c.pos=t.length;f=null}else f=St(wt(n,c,i.state,d),o);if(d){var h=d[0].name;if(h)f="m-"+(f?h+" "+f:h)}if(!s||u!=f){while(la;--s){if(s<=o.first)return o.first;var l=Ke(o,s-1),u=l.stateAfter;if(u&&(!n||s+(u instanceof pt?u.lookAhead:0)<=o.modeFrontier))return s;var c=z(l.text,null,e.options.tabSize);if(r==null||i>c){r=s-1;i=c}}return r}function Mt(e,t){e.modeFrontier=Math.min(e.modeFrontier,t);if(e.highlightFrontiern;i--){var r=Ke(e,i).stateAfter;if(r&&(!(r instanceof pt)||i+r.lookAhead=t:o.to>t);(i||(i=[])).push(new Nt(a,o.from,l?null:o.to))}}return i}function $t(e,t,n){var i;if(e)for(var r=0;r=t:o.to>t);if(s||o.from==t&&a.type=="bookmark"&&(!n||o.marker.insertLeft)){var l=o.from==null||(a.inclusiveLeft?o.from<=t:o.from0&&s)for(var b=0;b0)continue;var c=[l,1],f=ot(u.from,s.from),d=ot(u.to,s.to);if(f<0||!a.inclusiveLeft&&!f)c.push({from:u.from,to:s.from});if(d>0||!a.inclusiveRight&&!d)c.push({from:s.to,to:u.to});r.splice.apply(r,c);l+=c.length-3}}return r}function Rt(e){var t=e.markedSpans;if(!t)return;for(var n=0;nt)&&(!i||Ut(i,o.marker)<0))i=o.marker}return i}function Kt(e,t,n,i,r){var o=Ke(e,t);var a=Dt&&o.markedSpans;if(a)for(var s=0;s=0&&f<=0||c<=0&&f>=0)continue;if(c<=0&&(l.marker.inclusiveRight&&r.inclusiveLeft?ot(u.to,n)>=0:ot(u.to,n)>0)||c>=0&&(l.marker.inclusiveRight&&r.inclusiveLeft?ot(u.from,i)<=0:ot(u.from,i)<0))return true}}function Qt(e){var t;while(t=Xt(e))e=t.find(-1,true).line;return e}function Zt(e){var t;while(t=Gt(e))e=t.find(1,true).line;return e}function Jt(e){var t,n;while(t=Gt(e)){e=t.find(1,true).line;(n||(n=[])).push(e)}return n}function en(e,t){var n=Ke(e,t),i=Qt(n);if(n==i)return t;return et(i)}function tn(e,t){if(t>e.lastLine())return t;var n=Ke(e,t),i;if(!nn(e,n))return t;while(i=Gt(n))n=i.find(1,true).line;return et(n)+1}function nn(e,t){var n=Dt&&t.markedSpans;if(n)for(var i=void 0,r=0;rn.maxLineLength){n.maxLineLength=t;n.maxLine=e}})}var ln=function(e,t,n){this.text=e;jt(this,t);this.height=n?n(this):1};function un(e,t,n,i){e.text=t;if(e.stateAfter)e.stateAfter=null;if(e.styles)e.styles=null;if(e.order!=null)e.order=null;Rt(e);jt(e,n);var r=i?i(e):1;if(r!=e.height)Je(e,r)}function cn(e){e.parent=null;Rt(e)}ln.prototype.lineNo=function(){return et(this)},we(ln);var fn={},dn={};function hn(e,t){if(!e||/^\s*$/.test(e))return null;var n=t.addModeClass?dn:fn;return n[e]||(n[e]=e.replace(/\S+/g,"cm-$&"))}function pn(e,t){var n=D("span",null,null,g?"padding-right: .1px":null);var i={pre:D("pre",[n],"CodeMirror-line"),content:n,col:0,pos:0,cm:e,trailingSpace:false,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var r=0;r<=(t.rest?t.rest.length:0);r++){var o=r?t.rest[r-1]:t.line,a=void 0;i.pos=0;i.addToken=gn;if(Ne(e.display.measure)&&(a=de(o,e.doc.direction)))i.addToken=yn(i.addToken,a);i.map=[];var s=t!=e.display.externalMeasured&&et(o);bn(o,i,vt(e,o,s));if(o.styleClasses){if(o.styleClasses.bgClass)i.bgClass=I(o.styleClasses.bgClass,i.bgClass||"");if(o.styleClasses.textClass)i.textClass=I(o.styleClasses.textClass,i.textClass||"")}if(i.map.length==0)i.map.push(0,0,i.content.appendChild(Oe(e.display.measure)));if(r==0){t.measure.map=i.map;t.measure.cache={}}else{(t.measure.maps||(t.measure.maps=[])).push(i.map);(t.measure.caches||(t.measure.caches=[])).push({})}}if(g){var l=i.content.lastChild;if(/\bcm-tab\b/.test(l.className)||l.querySelector&&l.querySelector(".cm-tab"))i.content.className="cm-tab-wrap-hack"}ve(e,"renderLine",e,t.line,i.pre);if(i.pre.className)i.textClass=I(i.pre.className,i.textClass||"");return i}function mn(e){var t=O("span","•","cm-invalidchar");t.title="\\u"+e.charCodeAt(0).toString(16);t.setAttribute("aria-label",t.title);return t}function gn(e,t,n,i,r,o,a){if(!t)return;var s=e.splitSpaces?vn(t,e.trailingSpace):t;var l=e.cm.state.specialChars,u=false;var c;if(!l.test(t)){e.col+=t.length;c=document.createTextNode(s);e.map.push(e.pos,e.pos+t.length,c);if(S&&w<9)u=true;e.pos+=t.length}else{c=document.createDocumentFragment();var f=0;while(true){l.lastIndex=f;var d=l.exec(t);var h=d?d.index-f:t.length-f;if(h){var p=document.createTextNode(s.slice(f,f+h));if(S&&w<9)c.appendChild(O("span",[p]));else c.appendChild(p);e.map.push(e.pos,e.pos+h,p);e.col+=h;e.pos+=h}if(!d)break;f+=h+1;var m=void 0;if(d[0]=="\t"){var g=e.cm.options.tabSize,v=g-e.col%g;m=c.appendChild(O("span",G(v),"cm-tab"));m.setAttribute("role","presentation");m.setAttribute("cm-text","\t");e.col+=v}else if(d[0]=="\r"||d[0]=="\n"){m=c.appendChild(O("span",d[0]=="\r"?"␍":"","cm-invalidchar"));m.setAttribute("cm-text",d[0]);e.col+=1}else{m=e.cm.options.specialCharPlaceholder(d[0]);m.setAttribute("cm-text",d[0]);if(S&&w<9)c.appendChild(O("span",[m]));else c.appendChild(m);e.col+=1}e.map.push(e.pos,e.pos+1,m);e.pos++}}e.trailingSpace=s.charCodeAt(t.length-1)==32;if(n||i||r||u||o||a){var y=n||"";if(i)y+=i;if(r)y+=r;var x=O("span",[c],y,o);if(a)for(var b in a)if(a.hasOwnProperty(b)&&b!="style"&&b!="class")x.setAttribute(b,a[b]);return e.content.appendChild(x)}e.content.appendChild(c)}function vn(e,t){if(e.length>1&&!/ /.test(e))return e;var n=t,i="";for(var r=0;rs&&u.from<=s)break}if(u.to>=l)return f(e,t,n,i,r,o,a);f(e,t.slice(0,u.to-s),n,i,null,o,a);i=null;t=t.slice(u.to-s);s=u.to}}}function xn(e,t,n,i){var r=!i&&n.widgetNode;if(r)e.map.push(e.pos,e.pos+t,r);if(!i&&e.cm.display.input.needsContentAttribute){if(!r)r=e.content.appendChild(document.createElement("span"));r.setAttribute("cm-marker",n.id)}if(r){e.cm.display.input.setUneditable(r);e.content.appendChild(r)}e.pos+=t;e.trailingSpace=false}function bn(e,t,n){var i=e.markedSpans,r=e.text,o=0;if(!i){for(var a=1;al||C.collapsed&&k.to==l&&k.from==l)){if(k.to!=null&&k.to!=l&&h>k.to){h=k.to;m=""}if(C.className)p+=" "+C.className;if(C.css)d=(d?d+";":"")+C.css;if(C.startStyle&&k.from==l)g+=" "+C.startStyle;if(C.endStyle&&k.to==h)(b||(b=[])).push(C.endStyle,k.to);if(C.title)(y||(y={})).title=C.title;if(C.attributes)for(var S in C.attributes)(y||(y={}))[S]=C.attributes[S];if(C.collapsed&&(!v||Ut(v.marker,C)<0))v=k}else if(k.from>l&&h>k.from)h=k.from}if(b)for(var L=0;L=s)break;var M=Math.min(s,h);while(true){if(c){var T=l+c.length;if(!v){var D=T>M?c.slice(0,M-l):c;t.addToken(t,D,f?f+p:p,g,l+D.length==h?m:"",d,y)}if(T>=M){c=c.slice(M-l);l=M;break}l=T;g=""}c=r.slice(o,o=n[u++]);f=hn(n[u++],t.cm.options)}}}function wn(e,t,n){this.line=t;this.rest=Jt(t);this.size=this.rest?et(V(this.rest))-n+1:1;this.node=this.text=null;this.hidden=nn(e,t)}function kn(e,t,n){var i=[],r;for(var o=t;o2)o.push((l.bottom+u.top)/2-n.top)}}o.push(n.bottom-n.top)}}function Qn(e,t,n){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var i=0;in)return{map:e.measure.maps[r],cache:e.measure.caches[r],before:true}}function Zn(e,t){t=Qt(t);var n=et(t);var i=e.display.externalMeasured=new wn(e.doc,t,n);i.lineN=n;var r=i.built=pn(e,i);i.text=r.pre;T(e.display.lineMeasure,r.pre);return i}function Jn(e,t,n,i){return ni(e,ti(e,t),n,i)}function ei(e,t){if(t>=e.display.viewFrom&&t=n.lineN&&tt){o=l-s;r=o-1;if(t>=l)a="right"}if(r!=null){i=e[u+2];if(s==l&&n==(i.insertLeft?"left":"right"))a=n;if(n=="left"&&r==0)while(u&&e[u-2]==e[u-3]&&e[u-1].insertLeft){i=e[(u-=3)+2];a="left"}if(n=="right"&&r==l-s)while(u=0;r--)if((n=e[r]).left!=n.right)break;return n}function si(e,t,n,i){var r=oi(t.map,n,i);var o=r.node,a=r.start,s=r.end,l=r.collapse;var u;if(o.nodeType==3){for(var c=0;c<4;c++){while(a&&oe(t.line.text.charAt(r.coverStart+a)))--a;while(r.coverStart+s0)l=i="right";var f;if(e.options.lineWrapping&&(f=o.getClientRects()).length>1)u=f[i=="right"?f.length-1:0];else u=o.getBoundingClientRect()}if(S&&w<9&&!a&&(!u||!u.left&&!u.right)){var d=o.parentNode.getClientRects()[0];if(d)u={left:d.left,right:d.left+Di(e.display),top:d.top,bottom:d.bottom};else u=ii}var h=u.top-t.rect.top,p=u.bottom-t.rect.top;var m=(h+p)/2;var g=t.view.measure.heights;var v=0;for(;v=o.text.length){t=o.text.length;n="before"}else if(t<=0){t=0;n="after"}if(!u)return l(n=="before"?t-1:t,n=="before");function c(e,t,n){var i=u[t],r=i.level==1;return l(n?e-1:e,r!=n)}var f=ce(u,t,n);var d=ue;var h=c(t,f,n=="before");if(d!=null)h.other=c(t,d,n!="before");return h}function xi(e,t){var n=0;t=ft(e.doc,t);if(!e.options.lineWrapping)n=Di(e.display)*t.ch;var i=Ke(e.doc,t.line);var r=on(i)+Yn(e.display);return{left:n,right:n,top:r,bottom:r+i.height}}function bi(e,t,n,i,r){var o=rt(e,t,n);o.xRel=r;if(i)o.outside=i;return o}function wi(e,t,n){var i=e.doc;n+=e.display.viewOffset;if(n<0)return bi(i.first,0,null,-1,-1);var r=tt(i,n),o=i.first+i.size-1;if(r>o)return bi(i.first+i.size-1,Ke(i,o).text.length,null,1,1);if(t<0)t=0;var a=Ke(i,r);for(;;){var s=Li(e,a,r,t,n);var l=Vt(a,s.ch+(s.xRel>0||s.outside>0?1:0));if(!l)return s;var u=l.find(1);if(u.line==r)return u;a=Ke(i,r=u.line)}}function ki(t,e,n,i){i-=pi(e);var r=e.text.length;var o=se(function(e){return ni(t,n,e-1).bottom<=i},r,0);r=se(function(e){return ni(t,n,e).top>i},o,r);return{begin:o,end:r}}function Ci(e,t,n,i){if(!n)n=ti(e,t);var r=mi(e,t,ni(e,n,i),"line").top;return ki(e,t,n,r)}function Si(e,t,n,i){return e.bottom<=n?false:e.top>n?true:(i?e.left:e.right)>t}function Li(n,e,t,i,r){r-=on(e);var o=ti(n,e);var a=pi(e);var s=0,l=e.text.length,u=true;var c=de(e,n.doc.direction);if(c){var f=(n.options.lineWrapping?Mi:Ei)(n,e,t,o,c,i,r);u=f.level!=1;s=u?f.from:f.to-1;l=u?f.to:f.from-1}var d=null,h=null;var p=se(function(e){var t=ni(n,o,e);t.top+=a;t.bottom+=a;if(!Si(t,i,r,false))return false;if(t.top<=r&&t.left<=i){d=e;h=t}return true},s,l);var m,g,v=false;if(h){var y=i-h.left=b.bottom?1:0}p=ae(e.text,p,1);return bi(t,p,g,v,i-m)}function Ei(i,r,o,a,s,l,u){var e=se(function(e){var t=s[e],n=t.level!=1;return Si(yi(i,rt(o,n?t.to:t.from,n?"before":"after"),"line",r,a),l,u,true)},0,s.length-1);var t=s[e];if(e>0){var n=t.level!=1;var c=yi(i,rt(o,n?t.from:t.to,n?"after":"before"),"line",r,a);if(Si(c,l,u,true)&&c.top>u)t=s[e-1]}return t}function Mi(e,t,n,i,r,o,a){var s=ki(e,t,i,a);var l=s.begin;var u=s.end;if(/\s/.test(t.text.charAt(u-1)))u--;var c=null,f=null;for(var d=0;d=u||h.to<=l)continue;var p=h.level!=1;var m=ni(e,i,p?Math.min(u,h.to)-1:Math.max(l,h.from)).right;var g=mg){c=h;f=g}}if(!c)c=r[r.length-1];if(c.fromu)c={from:c.from,to:u,level:c.level};return c}function Ti(e){if(e.cachedTextHeight!=null)return e.cachedTextHeight;if(ri==null){ri=O("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t){ri.appendChild(document.createTextNode("x"));ri.appendChild(O("br"))}ri.appendChild(document.createTextNode("x"))}T(e.measure,ri);var n=ri.offsetHeight/50;if(n>3)e.cachedTextHeight=n;M(e.measure);return n||1}function Di(e){if(e.cachedCharWidth!=null)return e.cachedCharWidth;var t=O("span","xxxxxxxxxx");var n=O("pre",[t],"CodeMirror-line-like");T(e.measure,n);var i=t.getBoundingClientRect(),r=(i.right-i.left)/10;if(r>2)e.cachedCharWidth=r;return r||10}function Ai(e){var t=e.display,n={},i={};var r=t.gutters.clientLeft;for(var o=t.gutters.firstChild,a=0;o;o=o.nextSibling,++a){var s=e.display.gutterSpecs[a].className;n[s]=o.offsetLeft+o.clientLeft+r;i[s]=o.clientWidth}return{fixedPos:Oi(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:n,gutterWidth:i,wrapperWidth:t.wrapper.clientWidth}}function Oi(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function Ni(i){var r=Ti(i.display),o=i.options.lineWrapping;var a=o&&Math.max(5,i.display.scroller.clientWidth/Di(i.display)-3);return function(e){if(nn(i.doc,e))return 0;var t=0;if(e.widgets)for(var n=0;n0&&(u=Ke(e.doc,l.line).text).length==l.ch){var c=z(u,u.length,e.options.tabSize)-u.length;l=rt(l.line,Math.max(0,Math.round((o-qn(e.display).left)/Di(e.display))-c))}return l}function Pi(e,t){if(t>=e.display.viewTo)return null;t-=e.display.viewFrom;if(t<0)return null;var n=e.display.view;for(var i=0;it))r.updateLineNumbers=t;e.curOp.viewChanged=true;if(t>=r.viewTo){if(Dt&&en(e.doc,t)r.viewFrom)zi(e);else{r.viewFrom+=i;r.viewTo+=i}else if(t<=r.viewFrom&&n>=r.viewTo)zi(e);else if(t<=r.viewFrom){var o=Bi(e,n,n+i,1);if(o){r.view=r.view.slice(o.index);r.viewFrom=o.lineN;r.viewTo+=i}else zi(e)}else if(n>=r.viewTo){var a=Bi(e,t,t,-1);if(a){r.view=r.view.slice(0,a.index);r.viewTo=a.lineN}else zi(e)}else{var s=Bi(e,t,t,-1);var l=Bi(e,n,n+i,1);if(s&&l){r.view=r.view.slice(0,s.index).concat(kn(e,s.lineN,l.lineN)).concat(r.view.slice(l.index));r.viewTo+=i}else zi(e)}var u=r.externalMeasured;if(u)if(n=r.lineN&&t=i.viewTo)return;var o=i.view[Pi(e,t)];if(o.node==null)return;var a=o.changes||(o.changes=[]);if(W(a,n)==-1)a.push(n)}function zi(e){e.display.viewFrom=e.display.viewTo=e.doc.first;e.display.view=[];e.display.viewOffset=0}function Bi(e,t,n,i){var r=Pi(e,t),o,a=e.display.view;if(!Dt||n==e.doc.first+e.doc.size)return{index:r,lineN:n};var s=e.display.viewFrom;for(var l=0;l0){if(r==a.length-1)return null;o=s+a[r].size-t;r++}else o=s-t;t+=o;n+=o}while(en(e.doc,n)!=n){if(r==(i<0?0:a.length-1))return null;n+=i*a[r-(i<0?1:0)].size;r+=i}return{index:r,lineN:n}}function Wi(e,t,n){var i=e.display,r=i.view;if(r.length==0||t>=i.viewTo||n<=i.viewFrom){i.view=kn(e,t,n);i.viewFrom=t}else{if(i.viewFrom>t)i.view=kn(e,t,i.viewFrom).concat(i.view);else if(i.viewFromn)i.view=i.view.slice(0,Pi(e,n))}i.viewTo=n}function Ri(e){var t=e.display.view,n=0;for(var i=0;i=e.display.viewTo||s.to().line0)t.blinker=setInterval(function(){if(!e.hasFocus())Qi(e);t.cursorDiv.style.visibility=(n=!n)?"":"hidden"},e.options.cursorBlinkRate);else if(e.options.cursorBlinkRate<0)t.cursorDiv.style.visibility="hidden"}function Gi(e){if(!e.hasFocus()){e.display.input.focus();if(!e.state.focused)Ki(e)}}function Vi(e){e.state.delayingBlurEvent=true;setTimeout(function(){if(e.state.delayingBlurEvent){e.state.delayingBlurEvent=false;if(e.state.focused)Qi(e)}},100)}function Ki(e,t){if(e.state.delayingBlurEvent&&!e.state.draggingText)e.state.delayingBlurEvent=false;if(e.options.readOnly=="nocursor")return;if(!e.state.focused){ve(e,"focus",e,t);e.state.focused=true;F(e.display.wrapper,"CodeMirror-focused");if(!e.curOp&&e.display.selForContextMenu!=e.doc.sel){e.display.input.reset();if(g)setTimeout(function(){return e.display.input.reset(true)},20)}e.display.input.receivedFocus()}Xi(e)}function Qi(e,t){if(e.state.delayingBlurEvent)return;if(e.state.focused){ve(e,"blur",e,t);e.state.focused=false;L(e.display.wrapper,"CodeMirror-focused")}clearInterval(e.display.blinker);setTimeout(function(){if(!e.state.focused)e.display.shift=false},150)}function Zi(e){var t=e.display;var n=t.lineDiv.offsetTop;for(var i=0;i.005||c<-.005){Je(r.line,a);Ji(r.line);if(r.rest)for(var f=0;fe.display.sizerWidth){var d=Math.ceil(s/Di(e.display));if(d>e.display.maxLineLength){e.display.maxLineLength=d;e.display.maxLine=r.line;e.display.maxLineChanged=true}}}}function Ji(e){if(e.widgets)for(var t=0;t=a){o=tt(t,on(Ke(t,l))-e.wrapper.clientHeight);a=l}}return{from:o,to:Math.max(a,o+1)}}function tr(e,t){if(ye(e,"scrollCursorIntoView"))return;var n=e.display,i=n.sizer.getBoundingClientRect(),r=null;if(t.top+i.top<0)r=true;else if(t.bottom+i.top>(window.innerHeight||document.documentElement.clientHeight))r=false;if(r!=null&&!l){var o=O("div","",null,"position: absolute;\n top: "+(t.top-n.viewOffset-Yn(e.display))+"px;\n height: "+(t.bottom-t.top+Xn(e)+n.barHeight)+"px;\n left: "+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(o);o.scrollIntoView(r);e.display.lineSpace.removeChild(o)}}function nr(e,t,n,i){if(i==null)i=0;var r;if(!e.options.lineWrapping&&t==n){n=t.sticky=="before"?rt(t.line,t.ch+1,"before"):t;t=t.ch?rt(t.line,t.sticky=="before"?t.ch-1:t.ch,"after"):t}for(var o=0;o<5;o++){var a=false;var s=yi(e,t);var l=!n||n==t?s:yi(e,n);r={left:Math.min(s.left,l.left),top:Math.min(s.top,l.top)-i,right:Math.max(s.left,l.left),bottom:Math.max(s.bottom,l.bottom)+i};var u=rr(e,r);var c=e.doc.scrollTop,f=e.doc.scrollLeft;if(u.scrollTop!=null){fr(e,u.scrollTop);if(Math.abs(e.doc.scrollTop-c)>1)a=true}if(u.scrollLeft!=null){hr(e,u.scrollLeft);if(Math.abs(e.doc.scrollLeft-f)>1)a=true}if(!a)break}return r}function ir(e,t){var n=rr(e,t);if(n.scrollTop!=null)fr(e,n.scrollTop);if(n.scrollLeft!=null)hr(e,n.scrollLeft)}function rr(e,t){var n=e.display,i=Ti(e.display);if(t.top<0)t.top=0;var r=e.curOp&&e.curOp.scrollTop!=null?e.curOp.scrollTop:n.scroller.scrollTop;var o=Vn(e),a={};if(t.bottom-t.top>o)t.bottom=t.top+o;var s=e.doc.height+Un(n);var l=t.tops-i;if(t.topr+o){var c=Math.min(t.top,(u?s:t.bottom)-o);if(c!=r)a.scrollTop=c}var f=e.options.fixedGutter?0:n.gutters.offsetWidth;var d=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:n.scroller.scrollLeft-f;var h=Gn(e)-n.gutters.offsetWidth;var p=t.right-t.left>h;if(p)t.right=t.left+h;if(t.left<10)a.scrollLeft=0;else if(t.lefth+d-3)a.scrollLeft=t.right+(p?0:10)-h;return a}function or(e,t){if(t==null)return;ur(e);e.curOp.scrollTop=(e.curOp.scrollTop==null?e.doc.scrollTop:e.curOp.scrollTop)+t}function ar(e){ur(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function sr(e,t,n){if(t!=null||n!=null)ur(e);if(t!=null)e.curOp.scrollLeft=t;if(n!=null)e.curOp.scrollTop=n}function lr(e,t){ur(e);e.curOp.scrollToPos=t}function ur(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var n=xi(e,t.from),i=xi(e,t.to);cr(e,n,i,t.margin)}}function cr(e,t,n,i){var r=rr(e,{left:Math.min(t.left,n.left),top:Math.min(t.top,n.top)-i,right:Math.max(t.right,n.right),bottom:Math.max(t.bottom,n.bottom)+i});sr(e,r.scrollLeft,r.scrollTop)}function fr(e,t){if(Math.abs(e.doc.scrollTop-t)<2)return;if(!m)jr(e,{top:t});dr(e,t,true);if(m)jr(e);Ir(e,100)}function dr(e,t,n){t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t));if(e.display.scroller.scrollTop==t&&!n)return;e.doc.scrollTop=t;e.display.scrollbars.setScrollTop(t);if(e.display.scroller.scrollTop!=t)e.display.scroller.scrollTop=t}function hr(e,t,n,i){t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth));if((n?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!i)return;e.doc.scrollLeft=t;qr(e);if(e.display.scroller.scrollLeft!=t)e.display.scroller.scrollLeft=t;e.display.scrollbars.setScrollLeft(t)}function pr(e){var t=e.display,n=t.gutters.offsetWidth;var i=Math.round(e.doc.height+Un(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?n:0,docHeight:i,scrollHeight:i+Xn(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:n}}var mr=function(e,t,n){this.cm=n;var i=this.vert=O("div",[O("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar");var r=this.horiz=O("div",[O("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");i.tabIndex=r.tabIndex=-1;e(i);e(r);pe(i,"scroll",function(){if(i.clientHeight)t(i.scrollTop,"vertical")});pe(r,"scroll",function(){if(r.clientWidth)t(r.scrollLeft,"horizontal")});this.checkedZeroWidth=false;if(S&&w<8)this.horiz.style.minHeight=this.vert.style.minWidth="18px"};mr.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1;var n=e.scrollHeight>e.clientHeight+1;var i=e.nativeBarWidth;if(n){this.vert.style.display="block";this.vert.style.bottom=t?i+"px":"0";var r=e.viewHeight-(t?i:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+r)+"px"}else{this.vert.style.display="";this.vert.firstChild.style.height="0"}if(t){this.horiz.style.display="block";this.horiz.style.right=n?i+"px":"0";this.horiz.style.left=e.barLeft+"px";var o=e.viewWidth-e.barLeft-(n?i:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+o)+"px"}else{this.horiz.style.display="";this.horiz.firstChild.style.width="0"}if(!this.checkedZeroWidth&&e.clientHeight>0){if(i==0)this.zeroWidthHack();this.checkedZeroWidth=true}return{right:n?i:0,bottom:t?i:0}},mr.prototype.setScrollLeft=function(e){if(this.horiz.scrollLeft!=e)this.horiz.scrollLeft=e;if(this.disableHoriz)this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},mr.prototype.setScrollTop=function(e){if(this.vert.scrollTop!=e)this.vert.scrollTop=e;if(this.disableVert)this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},mr.prototype.zeroWidthHack=function(){var e=y&&!s?"12px":"18px";this.horiz.style.height=this.vert.style.width=e;this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none";this.disableHoriz=new B;this.disableVert=new B},mr.prototype.enableZeroWidthBar=function(n,i,r){n.style.pointerEvents="auto";function o(){var e=n.getBoundingClientRect();var t=r=="vert"?document.elementFromPoint(e.right-1,(e.top+e.bottom)/2):document.elementFromPoint((e.right+e.left)/2,e.bottom-1);if(t!=n)n.style.pointerEvents="none";else i.set(1e3,o)}i.set(1e3,o)},mr.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz);e.removeChild(this.vert)};var gr=function(){};function vr(e,t){if(!t)t=pr(e);var n=e.display.barWidth,i=e.display.barHeight;yr(e,t);for(var r=0;r<4&&n!=e.display.barWidth||i!=e.display.barHeight;r++){if(n!=e.display.barWidth&&e.options.lineWrapping)Zi(e);yr(e,pr(e));n=e.display.barWidth;i=e.display.barHeight}}function yr(e,t){var n=e.display;var i=n.scrollbars.update(t);n.sizer.style.paddingRight=(n.barWidth=i.right)+"px";n.sizer.style.paddingBottom=(n.barHeight=i.bottom)+"px";n.heightForcer.style.borderBottom=i.bottom+"px solid transparent";if(i.right&&i.bottom){n.scrollbarFiller.style.display="block";n.scrollbarFiller.style.height=i.bottom+"px";n.scrollbarFiller.style.width=i.right+"px"}else n.scrollbarFiller.style.display="";if(i.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter){n.gutterFiller.style.display="block";n.gutterFiller.style.height=i.bottom+"px";n.gutterFiller.style.width=t.gutterWidth+"px"}else n.gutterFiller.style.display=""}gr.prototype.update=function(){return{bottom:0,right:0}},gr.prototype.setScrollLeft=function(){},gr.prototype.setScrollTop=function(){},gr.prototype.clear=function(){};var xr={native:mr,null:gr};function br(n){if(n.display.scrollbars){n.display.scrollbars.clear();if(n.display.scrollbars.addClass)L(n.display.wrapper,n.display.scrollbars.addClass)}n.display.scrollbars=new xr[n.options.scrollbarStyle](function(e){n.display.wrapper.insertBefore(e,n.display.scrollbarFiller);pe(e,"mousedown",function(){if(n.state.focused)setTimeout(function(){return n.display.input.focus()},0)});e.setAttribute("cm-not-content","true")},function(e,t){if(t=="horizontal")hr(n,e);else fr(n,e)},n);if(n.display.scrollbars.addClass)F(n.display.wrapper,n.display.scrollbars.addClass)}var wr=0;function kr(e){e.curOp={cm:e,viewChanged:false,startHeight:e.doc.height,forceUpdate:false,updateInput:0,typing:false,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:false,updateMaxLine:false,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:false,id:++wr,markArrays:null};Sn(e.curOp)}function Cr(e){var t=e.curOp;if(t)En(t,function(e){for(var t=0;t=n.viewTo)||n.maxLineChanged&&t.options.lineWrapping;e.update=e.mustUpdate&&new Hr(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function Er(e){e.updatedDisplay=e.mustUpdate&&Wr(e.cm,e.update)}function Mr(e){var t=e.cm,n=t.display;if(e.updatedDisplay)Zi(t);e.barMeasure=pr(t);if(n.maxLineChanged&&!t.options.lineWrapping){e.adjustWidthTo=Jn(t,n.maxLine,n.maxLine.text.length).left+3;t.display.sizerWidth=e.adjustWidthTo;e.barMeasure.scrollWidth=Math.max(n.scroller.clientWidth,n.sizer.offsetLeft+e.adjustWidthTo+Xn(t)+t.display.barWidth);e.maxScrollLeft=Math.max(0,n.sizer.offsetLeft+e.adjustWidthTo-Gn(t))}if(e.updatedDisplay||e.selectionChanged)e.preparedSelection=n.input.prepareSelection()}function Tr(e){var t=e.cm;if(e.adjustWidthTo!=null){t.display.sizer.style.minWidth=e.adjustWidthTo+"px";if(e.maxScrollLeft=l.display.viewTo)return;var c=+new Date+l.options.workTime;var f=yt(l,u.highlightFrontier);var d=[];u.iter(f.line,Math.min(u.first+u.size,l.display.viewTo+500),function(e){if(f.line>=l.display.viewFrom){var t=e.styles;var n=e.text.length>l.options.maxHighlightLength?qe(u.mode,f.state):null;var i=gt(l,e,f,true);if(n)f.state=n;e.styles=i.styles;var r=e.styleClasses,o=i.classes;if(o)e.styleClasses=o;else if(r)e.styleClasses=null;var a=!t||t.length!=e.styles.length||r!=o&&(!r||!o||r.bgClass!=o.bgClass||r.textClass!=o.textClass);for(var s=0;!a&&sc){Ir(l,l.options.workDelay);return true}});u.highlightFrontier=f.line;u.modeFrontier=Math.max(u.modeFrontier,f.line);if(d.length)Ar(l,function(){for(var e=0;e=n.viewFrom&&t.visible.to<=n.viewTo&&(n.updateLineNumbers==null||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&Ri(e)==0)return false;if(Xr(e)){zi(e);t.dims=Ai(e)}var r=i.first+i.size;var o=Math.max(t.visible.from-e.options.viewportMargin,i.first);var a=Math.min(r,t.visible.to+e.options.viewportMargin);if(n.viewFroma&&n.viewTo-a<20)a=Math.min(r,n.viewTo);if(Dt){o=en(e.doc,o);a=tn(e.doc,a)}var s=o!=n.viewFrom||a!=n.viewTo||n.lastWrapHeight!=t.wrapperHeight||n.lastWrapWidth!=t.wrapperWidth;Wi(e,o,a);n.viewOffset=on(Ke(e.doc,n.viewFrom));e.display.mover.style.top=n.viewOffset+"px";var l=Ri(e);if(!s&&l==0&&!t.force&&n.renderedView==n.view&&(n.updateLineNumbers==null||n.updateLineNumbers>=n.viewTo))return false;var u=zr(e);if(l>4)n.lineDiv.style.display="none";_r(e,n.updateLineNumbers,t.dims);if(l>4)n.lineDiv.style.display="";n.renderedView=n.view;Br(u);M(n.cursorDiv);M(n.selectionDiv);n.gutters.style.height=n.sizer.style.minHeight=0;if(s){n.lastWrapHeight=t.wrapperHeight;n.lastWrapWidth=t.wrapperWidth;Ir(e,400)}n.updateLineNumbers=null;return true}function Rr(e,t){var n=t.viewport;for(var i=true;;i=false){if(!i||!e.options.lineWrapping||t.oldDisplayWidth==Gn(e)){if(n&&n.top!=null)n={top:Math.min(e.doc.height+Un(e.display)-Vn(e),n.top)};t.visible=er(e.display,e.doc,n);if(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break}else if(i)t.visible=er(e.display,e.doc,n);if(!Wr(e,t))break;Zi(e);var r=pr(e);ji(e);vr(e,r);Ur(e,r);t.force=false}t.signal(e,"update",e);if(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo){t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo);e.display.reportedViewFrom=e.display.viewFrom;e.display.reportedViewTo=e.display.viewTo}}function jr(e,t){var n=new Hr(e,t);if(Wr(e,n)){Zi(e);Rr(e,n);var i=pr(e);ji(e);vr(e,i);Ur(e,i);n.finish()}}function _r(n,e,t){var i=n.display,r=n.options.lineNumbers;var o=i.lineDiv,a=o.firstChild;function s(e){var t=e.nextSibling;if(g&&y&&n.display.currentWheelTarget==e)e.style.display="none";else e.parentNode.removeChild(e);return t}var l=i.view,u=i.viewFrom;for(var c=0;c-1)h=false;An(n,f,u,t)}if(h){M(f.lineNumber);f.lineNumber.appendChild(document.createTextNode(it(n.options,u)))}a=f.node.nextSibling}u+=f.size}while(a)a=s(a)}function Yr(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px";Tn(e,"gutterChanged",e)}function Ur(e,t){e.display.sizer.style.minHeight=t.docHeight+"px";e.display.heightForcer.style.top=t.docHeight+"px";e.display.gutters.style.height=t.docHeight+e.display.barHeight+Xn(e)+"px"}function qr(e){var t=e.display,n=t.view;if(!t.alignWidgets&&(!t.gutters.firstChild||!e.options.fixedGutter))return;var i=Oi(t)-t.scroller.scrollLeft+e.doc.scrollLeft;var r=t.gutters.offsetWidth,o=i+"px";for(var a=0;aa.clientWidth;var l=a.scrollHeight>a.clientHeight;if(!(i&&s||r&&l))return;if(r&&y&&g)e:for(var u=t.target,c=o.view;u!=a;u=u.parentNode)for(var f=0;f=0&&ot(e,i.to())<=0)return n}return-1};var ro=function(e,t){this.anchor=e;this.head=t};function oo(e,t,n){var i=e&&e.options.selectionsMayTouch;var r=t[n];t.sort(function(e,t){return ot(e.from(),t.from())});n=W(t,r);for(var o=1;o0:l>=0){var u=ut(s.from(),a.from()),c=lt(s.to(),a.to());var f=s.empty()?a.from()==a.head:s.from()==s.head;if(o<=n)--n;t.splice(--o,2,new ro(f?c:u,f?u:c))}}return new io(t,n)}function ao(e,t){return new io([new ro(e,t||e)],0)}function so(e){if(!e.text)return e.to;return rt(e.from.line+e.text.length-1,V(e.text).length+(e.text.length==1?e.from.ch:0))}function lo(e,t){if(ot(e,t.from)<0)return e;if(ot(e,t.to)<=0)return so(t);var n=e.line+t.text.length-(t.to.line-t.from.line)-1,i=e.ch;if(e.line==t.to.line)i+=so(t).ch-t.to.ch;return rt(n,i)}function uo(e,t){var n=[];for(var i=0;i1)e.remove(s.line+1,p-1);e.insert(s.line+1,v)}Tn(e,"change",e,i)}function vo(e,a,s){function l(e,t,n){if(e.linked)for(var i=0;i1&&!e.done[e.done.length-2].ranges){e.done.pop();return V(e.done)}}function Lo(e,t,n,i){var r=e.history;r.undone.length=0;var o=+new Date,a;var s;if((r.lastOp==i||r.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&r.lastModTime>o-(e.cm?e.cm.options.historyEventDelay:500)||t.origin.charAt(0)=="*"))&&(a=So(r,r.lastOp==i))){s=V(a.changes);if(ot(t.from,t.to)==0&&ot(t.from,s.to)==0)s.to=so(t);else a.changes.push(ko(e,t))}else{var l=V(r.done);if(!l||!l.ranges)To(e.sel,r.done);a={changes:[ko(e,t)],generation:r.generation};r.done.push(a);while(r.done.length>r.undoDepth){r.done.shift();if(!r.done[0].ranges)r.done.shift()}}r.done.push(n);r.generation=++r.maxGeneration;r.lastModTime=r.lastSelTime=o;r.lastOp=r.lastSelOp=i;r.lastOrigin=r.lastSelOrigin=t.origin;if(!s)ve(e,"historyAdded")}function Eo(e,t,n,i){var r=t.charAt(0);return r=="*"||r=="+"&&n.ranges.length==i.ranges.length&&n.somethingSelected()==i.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function Mo(e,t,n,i){var r=e.history,o=i&&i.origin;if(n==r.lastSelOp||o&&r.lastSelOrigin==o&&(r.lastModTime==r.lastSelTime&&r.lastOrigin==o||Eo(e,o,V(r.done),t)))r.done[r.done.length-1]=t;else To(t,r.done);r.lastSelTime=+new Date;r.lastSelOrigin=o;r.lastSelOp=n;if(i&&i.clearRedo!==false)Co(r.undone)}function To(e,t){var n=V(t);if(!(n&&n.ranges&&n.equals(e)))t.push(e)}function Do(t,n,e,i){var r=n["spans_"+t.id],o=0;t.iter(Math.max(t.first,e),Math.min(t.first+t.size,i),function(e){if(e.markedSpans)(r||(r=n["spans_"+t.id]={}))[o]=e.markedSpans;++o})}function Ao(e){if(!e)return null;var t;for(var n=0;n-1){V(s)[f]=u[f];delete u[f]}}}return i}function Io(e,t,n,i){if(i){var r=e.anchor;if(n){var o=ot(t,r)<0;if(o!=ot(n,r)<0){r=t;t=n}else if(o!=ot(t,n)<0)t=n}return new ro(r,t)}else return new ro(n||t,t)}function Po(e,t,n,i,r){if(r==null)r=e.cm&&(e.cm.display.shift||e.extend);Ro(e,new io([Io(e.sel.primary(),t,n,r)],0),i)}function Ho(e,t,n){var i=[];var r=e.cm&&(e.cm.display.shift||e.extend);for(var o=0;o=t.ch:s.to>t.ch))){if(r){ve(l,"beforeCursorEnter");if(l.explicitlyCleared)if(!o.markedSpans)break;else{--a;continue}}if(!l.atomic)continue;if(n){var f=l.find(i<0?1:-1),d=void 0;if(i<0?c:u)f=Go(e,f,-i,f&&f.line==t.line?o:null);if(f&&f.line==t.line&&(d=ot(f,n))&&(i<0?d<0:d>0))return qo(e,f,t,i,r)}var h=l.find(i<0?-1:1);if(i<0?u:c)h=Go(e,h,i,h.line==t.line?o:null);return h?qo(e,h,t,i,r):null}}return t}function Xo(e,t,n,i,r){var o=i||1;var a=qo(e,t,n,o,r)||!r&&qo(e,t,n,o,true)||qo(e,t,n,-o,r)||!r&&qo(e,t,n,-o,true);if(!a){e.cantEdit=true;return rt(e.first,0)}return a}function Go(e,t,n,i){if(n<0&&t.ch==0)if(t.line>e.first)return ft(e,rt(t.line-1));else return null;else if(n>0&&t.ch==(i||Ke(e,t.line)).text.length)if(t.line=0;--r)Zo(e,{from:i[r].from,to:i[r].to,text:r?[""]:t.text,origin:t.origin});else Zo(e,t)}function Zo(e,n){if(n.text.length==1&&n.text[0]==""&&ot(n.from,n.to)==0)return;var t=uo(e,n);Lo(e,n,t,e.cm?e.cm.curOp.id:NaN);ta(e,n,t,zt(e,n));var i=[];vo(e,function(e,t){if(!t&&W(i,e.history)==-1){aa(e.history,n);i.push(e.history)}ta(e,n,null,zt(e,n))})}function Jo(r,o,e){var t=r.cm&&r.cm.state.suppressEdits;if(t&&!e)return;var n=r.history,a,i=r.sel;var s=o=="undo"?n.done:n.undone,l=o=="undo"?n.undone:n.done;var u=0;for(;u=0;--h){var p=d(h);if(p)return p.v}}function ea(e,t){if(t==0)return;e.first+=t;e.sel=new io(K(e.sel.ranges,function(e){return new ro(rt(e.anchor.line+t,e.anchor.ch),rt(e.head.line+t,e.head.ch))}),e.sel.primIndex);if(e.cm){Hi(e.cm,e.first,e.first-t,t);for(var n=e.cm.display,i=n.viewFrom;ie.lastLine())return;if(t.from.lineo)t={from:t.from,to:rt(o,Ke(e,o).text.length),text:[t.text[0]],origin:t.origin};t.removed=Qe(e,t.from,t.to);if(!n)n=uo(e,t);if(e.cm)na(e.cm,t,i);else go(e,t,i);jo(e,n,_);if(e.cantEdit&&Xo(e,rt(e.firstLine(),0)))e.cantEdit=false}function na(e,t,n){var i=e.doc,r=e.display,o=t.from,a=t.to;var s=false,l=o.line;if(!e.options.lineWrapping){l=et(Qt(Ke(i,o.line)));i.iter(l,a.line+1,function(e){if(e==r.maxLine){s=true;return true}})}if(i.sel.contains(t.from,t.to)>-1)xe(e);go(i,t,n,Ni(e));if(!e.options.lineWrapping){i.iter(l,o.line+t.text.length,function(e){var t=an(e);if(t>r.maxLineLength){r.maxLine=e;r.maxLineLength=t;r.maxLineChanged=true;s=false}});if(s)e.curOp.updateMaxLine=true}Mt(i,o.line);Ir(e,400);var u=t.text.length-(a.line-o.line)-1;if(t.full)Hi(e);else if(o.line==a.line&&t.text.length==1&&!mo(e.doc,t))$i(e,o.line,"text");else Hi(e,o.line,a.line+1,u);var c=be(e,"changes"),f=be(e,"change");if(f||c){var d={from:o,to:a,text:t.text,removed:t.removed,origin:t.origin};if(f)Tn(e,"change",e,d);if(c)(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(d)}e.display.selForContextMenu=null}function ia(e,t,n,i,r){var o;if(!i)i=n;if(ot(i,n)<0)o=[i,n],n=o[0],i=o[1];if(typeof t=="string")t=e.splitLines(t);Qo(e,{from:n,to:i,text:t,origin:r})}function ra(e,t,n,i){if(n1||!(this.children[0]instanceof la))){var s=[];this.collapse(s);this.children=[new la(s)];this.children[0].parent=this}},collapse:function(e){for(var t=0;t50){var a=r.lines.length%25+25;for(var s=a;s10);e.parent.maybeSpill()},iterN:function(e,t,n){for(var i=0;i0||a==0&&o.clearWhenEmpty!==false)return o;if(o.replacedWith){o.collapsed=true;o.widgetNode=D("span",[o.replacedWith],"CodeMirror-widget");if(!e.handleMouseEvents)o.widgetNode.setAttribute("cm-ignore-events","true");if(e.insertLeft)o.widgetNode.insertLeft=true}if(o.collapsed){if(Kt(t,n.line,n,i,o)||n.line!=i.line&&Kt(t,i.line,n,i,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");Ot()}if(o.addToHistory)Lo(t,{from:n,to:i,origin:"markText"},t.sel,NaN);var s=n.line,l=t.cm,u;t.iter(s,i.line+1,function(e){if(l&&o.collapsed&&!l.options.lineWrapping&&Qt(e)==l.display.maxLine)u=true;if(o.collapsed&&s!=n.line)Je(e,0);Pt(e,new Nt(o,s==n.line?n.ch:null,s==i.line?i.ch:null),t.cm&&t.cm.curOp);++s});if(o.collapsed)t.iter(n.line,i.line+1,function(e){if(nn(t,e))Je(e,0)});if(o.clearOnEnter)pe(o,"beforeCursorEnter",function(){return o.clear()});if(o.readOnly){At();if(t.history.done.length||t.history.undone.length)t.clearHistory()}if(o.collapsed){o.id=++ha;o.atomic=true}if(l){if(u)l.curOp.updateMaxLine=true;if(o.collapsed)Hi(l,n.line,i.line+1);else if(o.className||o.startStyle||o.endStyle||o.css||o.attributes||o.title)for(var c=n.line;c<=i.line;c++)$i(l,c,"text");if(o.atomic)Yo(l.doc);Tn(l,"markerAdded",l,o)}return o}pa.prototype.clear=function(){if(this.explicitlyCleared)return;var e=this.doc.cm,t=e&&!e.curOp;if(t)kr(e);if(be(this,"clear")){var n=this.find();if(n)Tn(this,"clear",n.from,n.to)}var i=null,r=null;for(var o=0;oe.display.maxLineLength){e.display.maxLine=u;e.display.maxLineLength=c;e.display.maxLineChanged=true}}if(i!=null&&e&&this.collapsed)Hi(e,i,r+1);this.lines.length=0;this.explicitlyCleared=true;if(this.atomic&&this.doc.cantEdit){this.doc.cantEdit=false;if(e)Yo(e.doc)}if(e)Tn(e,"markerCleared",e,this,i,r);if(t)Cr(e);if(this.parent)this.parent.clear()},pa.prototype.find=function(e,t){if(e==null&&this.type=="bookmark")e=1;var n,i;for(var r=0;r=0;l--)Qo(this,i[l]);if(s)Wo(this,s);else if(this.cm)ar(this.cm)}),undo:Fr(function(){Jo(this,"undo")}),redo:Fr(function(){Jo(this,"redo")}),undoSelection:Fr(function(){Jo(this,"undo",true)}),redoSelection:Fr(function(){Jo(this,"redo",true)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){var e=this.history,t=0,n=0;for(var i=0;i=e.ch))t.push(r.marker.parent||r.marker)}return t},findMarks:function(r,o,a){r=ft(this,r);o=ft(this,o);var s=[],l=r.line;this.iter(r.line,o.line+1,function(e){var t=e.markedSpans;if(t)for(var n=0;n=i.to||i.from==null&&l!=r.line||i.from!=null&&l==o.line&&i.from>=o.ch)&&(!a||a(i.marker)))s.push(i.marker.parent||i.marker)}++l});return s},getAllMarks:function(){var i=[];this.iter(function(e){var t=e.markedSpans;if(t)for(var n=0;nn){i=n;return true}n-=t;++r});return ft(this,rt(r,i))},indexFromPos:function(e){e=ft(this,e);var t=e.ch;if(e.linet)t=e.from;if(e.to!=null&&e.to-1){i.state.draggingText(e);setTimeout(function(){return i.display.input.focus()},20);return}try{var c=e.dataTransfer.getData("Text");if(c){var f;if(i.state.draggingText&&!i.state.draggingText.copy)f=i.listSelections();jo(i.doc,ao(t,t));if(f)for(var d=0;d=0;e--)ia(t.doc,"",i[e].from,i[e].to,"+delete");ar(t)})}function qa(e,t,n){var i=ae(e.text,t+n,n);return i<0||i>e.text.length?null:i}function Xa(e,t,n){var i=qa(e,t.ch,n);return i==null?null:new rt(t.line,i,n<0?"after":"before")}function Ga(e,t,n,i,r){if(e){if(t.doc.direction=="rtl")r=-r;var o=de(n,t.doc.direction);if(o){var a=r<0?V(o):o[0];var s=r<0==(a.level==1);var l=s?"after":"before";var u;if(a.level>0||t.doc.direction=="rtl"){var c=ti(t,n);u=r<0?n.text.length-1:0;var f=ni(t,c,u).top;u=se(function(e){return ni(t,c,e).top==f},r<0==(a.level==1)?a.from:a.to-1,u);if(l=="before")u=qa(n,u,1)}else u=r<0?a.to:a.from;return new rt(i,u,l)}}return new rt(i,r<0?n.text.length:0,r<0?"before":"after")}function Va(t,n,s,e){var l=de(n,t.doc.direction);if(!l)return Xa(n,s,e);if(s.ch>=n.text.length){s.ch=n.text.length;s.sticky="before"}else if(s.ch<=0){s.ch=0;s.sticky="after"}var i=ce(l,s.ch,s.sticky),r=l[i];if(t.doc.direction=="ltr"&&r.level%2==0&&(e>0?r.to>s.ch:r.from=r.from&&d>=c.begin:d<=r.to&&d<=c.end)){var h=f?"before":"after";return new rt(s.line,d,h)}}var p=function(e,t,n){var i=function(e,t){return t?new rt(s.line,u(e,1),"before"):new rt(s.line,e,"after")};for(;e>=0&&e0==(r.level!=1);var a=o?n.begin:u(n.end,-1);if(r.from<=a&&a0?c.end:u(c.begin,-1);if(g!=null&&!(e>0&&g==n.text.length)){m=p(e>0?0:l.length-1,e,a(g));if(m)return m}return null}$a.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},$a.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},$a.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"},$a.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},$a["default"]=y?$a.macDefault:$a.pcDefault;var Ka={selectAll:Vo,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),_)},killLine:function(n){return Ua(n,function(e){if(e.empty()){var t=Ke(n.doc,e.head.line).text.length;if(e.head.ch==t&&e.head.line0){i=new rt(i.line,i.ch+1);a.replaceRange(r.charAt(i.ch-1)+r.charAt(i.ch-2),rt(i.line,i.ch-2),i,"+transpose")}else if(i.line>a.doc.first){var o=Ke(a.doc,i.line-1).text;if(o){i=new rt(i.line,1);a.replaceRange(r.charAt(0)+a.doc.lineSeparator()+o.charAt(o.length-1),rt(i.line-1,o.length-1),i,"+transpose")}}}t.push(new ro(i,i))}a.setSelections(t)})},newlineAndIndent:function(i){return Ar(i,function(){var e=i.listSelections();for(var t=e.length-1;t>=0;t--)i.replaceRange(i.doc.lineSeparator(),e[t].anchor,e[t].head,"+input");e=i.listSelections();for(var n=0;n-1&&(ot((a=o.ranges[a]).from(),t)<0||t.xRel>0)&&(ot(a.to(),t)>0||t.xRel<0))ws(e,i,t,r);else Cs(e,i,t,r)}function ws(t,n,i,r){var o=t.display,a=false;var s=Or(t,function(e){if(g)o.scroller.draggable=false;t.state.draggingText=false;if(t.state.delayingBlurEvent)if(t.hasFocus())t.state.delayingBlurEvent=false;else Vi(t);ge(o.wrapper.ownerDocument,"mouseup",s);ge(o.wrapper.ownerDocument,"mousemove",l);ge(o.scroller,"dragstart",u);ge(o.scroller,"drop",s);if(!a){ke(e);if(!r.addNew)Po(t.doc,i,null,null,r.extend);if(g&&!c||S&&w==9)setTimeout(function(){o.wrapper.ownerDocument.body.focus({preventScroll:true});o.input.focus()},20);else o.input.focus()}});var l=function(e){a=a||Math.abs(n.clientX-e.clientX)+Math.abs(n.clientY-e.clientY)>=10};var u=function(){return a=true};if(g)o.scroller.draggable=true;t.state.draggingText=s;s.copy=!r.moveOnDrag;pe(o.wrapper.ownerDocument,"mouseup",s);pe(o.wrapper.ownerDocument,"mousemove",l);pe(o.scroller,"dragstart",u);pe(o.scroller,"drop",s);t.state.delayingBlurEvent=true;setTimeout(function(){return o.input.focus()},20);if(o.scroller.dragDrop)o.scroller.dragDrop()}function ks(e,t,n){if(n=="char")return new ro(t,t);if(n=="word")return e.findWordAt(t);if(n=="line")return new ro(rt(t.line,0),ft(e.doc,rt(t.line+1,0)));var i=n(e,t);return new ro(i.from,i.to)}function Cs(g,e,v,y){if(S)Vi(g);var o=g.display,x=g.doc;ke(e);var b,w,k=x.sel,t=k.ranges;if(y.addNew&&!y.extend){w=x.sel.contains(v);if(w>-1)b=t[w];else b=new ro(v,v)}else{b=x.sel.primary();w=x.sel.primIndex}if(y.unit=="rectangle"){if(!y.addNew)b=new ro(v,v);v=Ii(g,e,true,true);w=-1}else{var n=ks(g,v,y.unit);if(y.extend)b=Io(b,n.anchor,n.head,y.extend);else b=n}if(!y.addNew){w=0;Ro(x,new io([b],0),Y);k=x.sel}else if(w==-1){w=t.length;Ro(x,oo(g,t.concat([b]),w),{scroll:false,origin:"*mouse"})}else if(t.length>1&&t[w].empty()&&y.unit=="char"&&!y.extend){Ro(x,oo(g,t.slice(0,w).concat(t.slice(w+1)),0),{scroll:false,origin:"*mouse"});k=x.sel}else $o(x,w,b,Y);var C=v;function a(e){if(ot(C,e)==0)return;C=e;if(y.unit=="rectangle"){var t=[],n=g.options.tabSize;var i=z(Ke(x,v.line).text,v.ch,n);var r=z(Ke(x,e.line).text,e.ch,n);var o=Math.min(i,r),a=Math.max(i,r);for(var s=Math.min(v.line,e.line),l=Math.min(g.lastLine(),Math.max(v.line,e.line));s<=l;s++){var u=Ke(x,s).text,c=q(u,o,n);if(o==a)t.push(new ro(rt(s,c),rt(s,c)));else if(u.length>c)t.push(new ro(rt(s,c),rt(s,q(u,a,n))))}if(!t.length)t.push(new ro(v,v));Ro(x,oo(g,k.ranges.slice(0,w).concat(t),w),{origin:"*mouse",scroll:false});g.scrollIntoView(e)}else{var f=b;var d=ks(g,e,y.unit);var h=f.anchor,p;if(ot(d.anchor,h)>0){p=d.head;h=ut(f.from(),d.anchor)}else{p=d.anchor;h=lt(f.to(),d.head)}var m=k.ranges.slice(0);m[w]=Ss(g,new ro(ft(x,h),p));Ro(x,oo(g,m,w),Y)}}var s=o.wrapper.getBoundingClientRect();var l=0;function u(e){var t=++l;var n=Ii(g,e,true,y.unit=="rectangle");if(!n)return;if(ot(n,C)!=0){g.curOp.focus=N();a(n);var i=er(o,x);if(n.line>=i.to||n.lines.bottom?20:0;if(r)setTimeout(Or(g,function(){if(l!=t)return;o.scroller.scrollTop+=r;u(e)}),50)}}function i(e){g.state.selectingText=false;l=Infinity;if(e){ke(e);o.input.focus()}ge(o.wrapper.ownerDocument,"mousemove",r);ge(o.wrapper.ownerDocument,"mouseup",c);x.history.lastSelOrigin=null}var r=Or(g,function(e){if(e.buttons===0||!Me(e))i(e);else u(e)});var c=Or(g,i);g.state.selectingText=c;pe(o.wrapper.ownerDocument,"mousemove",r);pe(o.wrapper.ownerDocument,"mouseup",c)}function Ss(e,t){var n=t.anchor;var i=t.head;var r=Ke(e.doc,n.line);if(ot(n,i)==0&&n.sticky==i.sticky)return t;var o=de(r);if(!o)return t;var a=ce(o,n.ch,n.sticky),s=o[a];if(s.from!=n.ch&&s.to!=n.ch)return t;var l=a+(s.from==n.ch==(s.level!=1)?0:1);if(l==0||l==o.length)return t;var u;if(i.line!=n.line)u=(i.line-n.line)*(e.doc.direction=="ltr"?1:-1)>0;else{var c=ce(o,i.ch,i.sticky);var f=c-a||(i.ch-n.ch)*(s.level==1?-1:1);if(c==l-1||c==l)u=f<0;else u=f>0}var d=o[l+(u?-1:0)];var h=u==(d.level==1);var p=h?d.from:d.to,m=h?"after":"before";return n.ch==p&&n.sticky==m?t:new ro(new rt(n.line,p,m),i)}function Ls(e,t,n,i){var r,o;if(t.touches){r=t.touches[0].clientX;o=t.touches[0].clientY}else try{r=t.clientX;o=t.clientY}catch(e){return false}if(r>=Math.floor(e.display.gutters.getBoundingClientRect().right))return false;if(i)ke(t);var a=e.display;var s=a.lineDiv.getBoundingClientRect();if(o>s.bottom||!be(e,n))return Se(t);o-=s.top-a.viewOffset;for(var l=0;l=r){var c=tt(e.doc,o);var f=e.display.gutterSpecs[l];ve(e,n,e,c,f.className,t);return Se(t)}}}function Es(e,t){return Ls(e,t,"gutterClick",true)}function Ms(e,t){if(_n(e.display,t)||Ts(e,t))return;if(ye(e,t,"contextmenu"))return;if(!k)e.display.input.onContextMenu(t)}function Ts(e,t){if(!be(e,"gutterContextMenu"))return false;return Ls(e,t,"gutterContextMenu",false)}function Ds(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-");fi(e)}hs.prototype.compare=function(e,t,n){return this.time+ds>e&&ot(t,this.pos)==0&&n==this.button};var As={toString:function(){return"CodeMirror.Init"}},Os={},Ns={};function Fs(r){var o=r.optionHandlers;function e(e,t,i,n){r.defaults[e]=t;if(i)o[e]=n?function(e,t,n){if(n!=As)i(e,t,n)}:i}r.defineOption=e;r.Init=As;e("value","",function(e,t){return e.setValue(t)},true);e("mode",null,function(e,t){e.doc.modeOption=t;ho(e)},true);e("indentUnit",2,ho,true);e("indentWithTabs",false);e("smartIndent",true);e("tabSize",4,function(e){po(e);fi(e);Hi(e)},true);e("lineSeparator",null,function(e,i){e.doc.lineSep=i;if(!i)return;var r=[],o=e.doc.first;e.doc.iter(function(e){for(var t=0;;){var n=e.text.indexOf(i,t);if(n==-1)break;t=n+i.length;r.push(rt(o,n))}o++});for(var t=r.length-1;t>=0;t--)ia(e.doc,i,r[t],rt(r[t].line,r[t].ch+i.length))});e("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,function(e,t,n){e.state.specialChars=new RegExp(t.source+(t.test("\t")?"":"|\t"),"g");if(n!=As)e.refresh()});e("specialCharPlaceholder",mn,function(e){return e.refresh()},true);e("electricChars",true);e("inputStyle",d?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},true);e("spellcheck",false,function(e,t){return e.getInputField().spellcheck=t},true);e("autocorrect",false,function(e,t){return e.getInputField().autocorrect=t},true);e("autocapitalize",false,function(e,t){return e.getInputField().autocapitalize=t},true);e("rtlMoveVisually",!p);e("wholeLineUpdateBefore",true);e("theme","default",function(e){Ds(e);Kr(e)},true);e("keyMap","default",function(e,t,n){var i=Ya(t);var r=n!=As&&Ya(n);if(r&&r.detach)r.detach(e,i);if(i.attach)i.attach(e,r||null)});e("extraKeys",null);e("configureMouse",null);e("lineWrapping",false,Ps,true);e("gutters",[],function(e,t){e.display.gutterSpecs=Gr(t,e.options.lineNumbers);Kr(e)},true);e("fixedGutter",true,function(e,t){e.display.gutters.style.left=t?Oi(e.display)+"px":"0";e.refresh()},true);e("coverGutterNextToScrollbar",false,function(e){return vr(e)},true);e("scrollbarStyle","native",function(e){br(e);vr(e);e.display.scrollbars.setScrollTop(e.doc.scrollTop);e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},true);e("lineNumbers",false,function(e,t){e.display.gutterSpecs=Gr(e.options.gutters,t);Kr(e)},true);e("firstLineNumber",1,Kr,true);e("lineNumberFormatter",function(e){return e},Kr,true);e("showCursorWhenSelecting",false,ji,true);e("resetSelectionOnContextMenu",true);e("lineWiseCopyCut",true);e("pasteLinesPerSelection",true);e("selectionsMayTouch",false);e("readOnly",false,function(e,t){if(t=="nocursor"){Qi(e);e.display.input.blur()}e.display.input.readOnlyChanged(t)});e("screenReaderLabel",null,function(e,t){t=t===""?null:t;e.display.input.screenReaderLabelChanged(t)});e("disableInput",false,function(e,t){if(!t)e.display.input.reset()},true);e("dragDrop",true,Is);e("allowDropFileTypes",null);e("cursorBlinkRate",530);e("cursorScrollMargin",0);e("cursorHeight",1,ji,true);e("singleCursorHeightPerLine",true,ji,true);e("workTime",100);e("workDelay",100);e("flattenSpans",true,po,true);e("addModeClass",false,po,true);e("pollInterval",100);e("undoDepth",200,function(e,t){return e.doc.history.undoDepth=t});e("historyEventDelay",1250);e("viewportMargin",10,function(e){return e.refresh()},true);e("maxHighlightLength",1e4,po,true);e("moveInputWithCursor",true,function(e,t){if(!t)e.display.input.resetPosition()});e("tabindex",null,function(e,t){return e.display.input.getField().tabIndex=t||""});e("autofocus",null);e("direction","ltr",function(e,t){return e.doc.setDirection(t)},true);e("phrases",null)}function Is(e,t,n){var i=n&&n!=As;if(!t!=!i){var r=e.display.dragFunctions;var o=t?pe:ge;o(e.display.scroller,"dragstart",r.start);o(e.display.scroller,"dragenter",r.enter);o(e.display.scroller,"dragover",r.over);o(e.display.scroller,"dragleave",r.leave);o(e.display.scroller,"drop",r.drop)}}function Ps(e){if(e.options.lineWrapping){F(e.display.wrapper,"CodeMirror-wrap");e.display.sizer.style.minWidth="";e.display.sizerWidth=null}else{L(e.display.wrapper,"CodeMirror-wrap");sn(e)}Fi(e);Hi(e);fi(e);setTimeout(function(){return vr(e)},100)}function Hs(e,t){var n=this;if(!(this instanceof Hs))return new Hs(e,t);this.options=t=t?$(t):{};$(Os,t,false);var i=t.value;if(typeof i=="string")i=new ka(i,t.mode,null,t.lineSeparator,t.direction);else if(t.mode)i.modeOption=t.mode;this.doc=i;var r=new Hs.inputStyles[t.inputStyle](this);var o=this.display=new Qr(e,i,r,t);o.wrapper.CodeMirror=this;Ds(this);if(t.lineWrapping)this.display.wrapper.className+=" CodeMirror-wrap";br(this);this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:false,delayingBlurEvent:false,focused:false,suppressEdits:false,pasteIncoming:-1,cutIncoming:-1,selectingText:false,draggingText:false,highlight:new B,keySeq:null,specialChars:null};if(t.autofocus&&!d)o.input.focus();if(S&&w<11)setTimeout(function(){return n.display.input.reset(true)},20);$s(this);Aa();kr(this);this.curOp.forceUpdate=true;yo(this,i);if(t.autofocus&&!d||this.hasFocus())setTimeout(function(){if(n.hasFocus()&&!n.state.focused)Ki(n)},20);else Qi(this);for(var a in Ns)if(Ns.hasOwnProperty(a))Ns[a](this,t[a],As);Xr(this);if(t.finishInit)t.finishInit(this);for(var s=0;s20*20}pe(o.scroller,"touchstart",function(e){if(!ye(r,e)&&!s(e)&&!Es(r,e)){o.input.ensurePolled();clearTimeout(n);var t=+new Date;o.activeTouch={start:t,moved:false,prev:t-i.end<=300?i:null};if(e.touches.length==1){o.activeTouch.left=e.touches[0].pageX;o.activeTouch.top=e.touches[0].pageY}}});pe(o.scroller,"touchmove",function(){if(o.activeTouch)o.activeTouch.moved=true});pe(o.scroller,"touchend",function(e){var t=o.activeTouch;if(t&&!_n(o,e)&&t.left!=null&&!t.moved&&new Date-t.start<300){var n=r.coordsChar(o.activeTouch,"page"),i;if(!t.prev||l(t,t.prev))i=new ro(n,n);else if(!t.prev.prev||l(t,t.prev.prev))i=r.findWordAt(n);else i=new ro(rt(n.line,0),ft(r.doc,rt(n.line+1,0)));r.setSelection(i.anchor,i.head);r.focus();ke(e)}a()});pe(o.scroller,"touchcancel",a);pe(o.scroller,"scroll",function(){if(o.scroller.clientHeight){fr(r,o.scroller.scrollTop);hr(r,o.scroller.scrollLeft,true);ve(r,"scroll",r)}});pe(o.scroller,"mousewheel",function(e){return no(r,e)});pe(o.scroller,"DOMMouseScroll",function(e){return no(r,e)});pe(o.wrapper,"scroll",function(){return o.wrapper.scrollTop=o.wrapper.scrollLeft=0});o.dragFunctions={enter:function(e){if(!ye(r,e))Le(e)},over:function(e){if(!ye(r,e)){Ea(r,e);Le(e)}},start:function(e){return La(r,e)},drop:Or(r,Sa),leave:function(e){if(!ye(r,e))Ma(r)}};var e=o.input.getField();pe(e,"keyup",function(e){return cs.call(r,e)});pe(e,"keydown",Or(r,ls));pe(e,"keypress",Or(r,fs));pe(e,"focus",function(e){return Ki(r,e)});pe(e,"blur",function(e){return Qi(r,e)})}Hs.defaults=Os,Hs.optionHandlers=Ns;var zs=[];function Bs(e,t,n,i){var r=e.doc,o;if(n==null)n="add";if(n=="smart")if(!r.mode.indent)n="prev";else o=yt(e,t).state;var a=e.options.tabSize;var s=Ke(r,t),l=z(s.text,null,a);if(s.stateAfter)s.stateAfter=null;var u=s.text.match(/^\s*/)[0],c;if(!i&&!/\S/.test(s.text)){c=0;n="not"}else if(n=="smart"){c=r.mode.indent(o,s.text.slice(u.length),s.text);if(c==j||c>150){if(!i)return;n="prev"}}if(n=="prev")if(t>r.first)c=z(Ke(r,t-1).text,null,a);else c=0;else if(n=="add")c=l+e.options.indentUnit;else if(n=="subtract")c=l-e.options.indentUnit;else if(typeof n=="number")c=l+n;c=Math.max(0,c);var f="",d=0;if(e.options.indentWithTabs)for(var h=Math.floor(c/a);h;--h){d+=a;f+="\t"}if(da;var l=Fe(t),u=null;if(s&&i.ranges.length>1)if(Ws&&Ws.text.join("\n")==t){if(i.ranges.length%Ws.text.length==0){u=[];for(var c=0;c=0;d--){var h=i.ranges[d];var p=h.from(),m=h.to();if(h.empty())if(n&&n>0)p=rt(p.line,p.ch-n);else if(e.state.overwrite&&!s)m=rt(m.line,Math.min(Ke(o,m.line).text.length,m.ch+V(l).length));else if(s&&Ws&&Ws.lineWise&&Ws.text.join("\n")==l.join("\n"))p=m=rt(p.line,0);var g={from:p,to:m,text:u?u[d%u.length]:l,origin:r||(s?"paste":e.state.cutIncoming>a?"cut":"+input")};Qo(e.doc,g);Tn(e,"inputRead",e,g)}if(t&&!s)Ys(e,t);ar(e);if(e.curOp.updateInput<2)e.curOp.updateInput=f;e.curOp.typing=true;e.state.pasteIncoming=e.state.cutIncoming=-1}function _s(e,t){var n=e.clipboardData&&e.clipboardData.getData("Text");if(n){e.preventDefault();if(!t.isReadOnly()&&!t.options.disableInput)Ar(t,function(){return js(t,n,0,null,"paste")});return true}}function Ys(e,t){if(!e.options.electricChars||!e.options.smartIndent)return;var n=e.doc.sel;for(var i=n.ranges.length-1;i>=0;i--){var r=n.ranges[i];if(r.head.ch>100||i&&n.ranges[i-1].head.line==r.head.line)continue;var o=e.getModeAt(r.head);var a=false;if(o.electricChars){for(var s=0;s-1){a=Bs(e,r.head.line,"smart");break}}else if(o.electricInput)if(o.electricInput.test(Ke(e.doc,r.head.line).text.slice(0,r.head.ch)))a=Bs(e,r.head.line,"smart");if(a)Tn(e,"electricInput",e,r.head.line)}}function Us(e){var t=[],n=[];for(var i=0;i0)$o(this.doc,i,new ro(o,u[i].to()),_)}else if(r.head.line>n){Bs(this,r.head.line,e,true);n=r.head.line;if(i==this.doc.sel.primIndex)ar(this)}}}),getTokenAt:function(e,t){return Ct(this,e,t)},getLineTokens:function(e,t){return Ct(this,rt(e),t,true)},getTokenTypeAt:function(e){e=ft(this.doc,e);var t=vt(this,Ke(this.doc,e.line));var n=0,i=(t.length-1)/2,r=e.ch;var o;if(r==0)o=t[2];else for(;;){var a=n+i>>1;if((a?t[a*2-1]:0)>=r)i=a;else if(t[a*2+1]o){e=o;i=true}r=Ke(this.doc,e)}else r=e;return mi(this,r,{top:0,left:0},t||"page",n||i).top+(i?this.doc.height-on(r):0)},defaultTextHeight:function(){return Ti(this.display)},defaultCharWidth:function(){return Di(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,n,i,r){var o=this.display;e=yi(this,ft(this.doc,e));var a=e.bottom,s=e.left;t.style.position="absolute";t.setAttribute("cm-ignore-events","true");this.display.input.setUneditable(t);o.sizer.appendChild(t);if(i=="over")a=e.top;else if(i=="above"||i=="near"){var l=Math.max(o.wrapper.clientHeight,this.doc.height),u=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);if((i=="above"||e.bottom+t.offsetHeight>l)&&e.top>t.offsetHeight)a=e.top-t.offsetHeight;else if(e.bottom+t.offsetHeight<=l)a=e.bottom;if(s+t.offsetWidth>u)s=u-t.offsetWidth}t.style.top=a+"px";t.style.left=t.style.right="";if(r=="right"){s=o.sizer.clientWidth-t.offsetWidth;t.style.right="0px"}else{if(r=="left")s=0;else if(r=="middle")s=(o.sizer.clientWidth-t.offsetWidth)/2;t.style.left=s+"px"}if(n)ir(this,{left:s,top:a,right:s+t.offsetWidth,bottom:a+t.offsetHeight})},triggerOnKeyDown:Nr(ls),triggerOnKeyPress:Nr(fs),triggerOnKeyUp:cs,triggerOnMouseDown:Nr(vs),execCommand:function(e){if(Ka.hasOwnProperty(e))return Ka[e].call(null,this)},triggerElectric:Nr(function(e){Ys(this,e)}),findPosH:function(e,t,n,i){var r=1;if(t<0){r=-1;t=-t}var o=ft(this.doc,e);for(var a=0;a0&&s(n.charAt(i-1)))--i;while(r.5||this.options.lineWrapping)Fi(this);ve(this,"refresh",this)}),swapDoc:Nr(function(e){var t=this.doc;t.cm=null;if(this.state.selectingText)this.state.selectingText();yo(this,e);fi(this);this.display.input.reset();sr(this,e.scrollLeft,e.scrollTop);this.curOp.forceScroll=true;Tn(this,"swapDoc",this,t);return t}),phrase:function(e){var t=this.options.phrases;return t&&Object.prototype.hasOwnProperty.call(t,e)?t[e]:e},getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}};we(r);r.registerHelper=function(e,t,n){if(!u.hasOwnProperty(e))u[e]=r[e]={_global:[]};u[e][t]=n};r.registerGlobalHelper=function(e,t,n,i){r.registerHelper(e,t,i);u[e]._global.push({pred:n,val:i})}}function Vs(r,o,a,s,l){var e=o;var t=a;var u=Ke(r,o.line);var c=l&&r.direction=="rtl"?-a:a;function f(){var e=o.line+c;if(e=r.first+r.size)return false;o=new rt(e,o.ch,o.sticky);return u=Ke(r,e)}function n(e){var t;if(s=="codepoint"){var n=u.text.charCodeAt(o.ch+(a>0?0:-1));if(isNaN(n))t=null;else{var i=a>0?n>=55296&&n<56320:n>=56320&&n<57343;t=new rt(o.line,Math.max(0,Math.min(u.text.length,o.ch+a*(i?2:1))),-a)}}else if(l)t=Va(r.cm,u,o,a);else t=Xa(u,o,a);if(t==null)if(!e&&f())o=Ga(l,r.cm,u,o.line,c);else return false;else o=t;return true}if(s=="char"||s=="codepoint")n();else if(s=="column")n(true);else if(s=="word"||s=="group"){var i=null,d=s=="group";var h=r.cm&&r.cm.getHelper(o,"wordChars");for(var p=true;;p=false){if(a<0&&!n(!p))break;var m=u.text.charAt(o.ch)||"\n";var g=ne(m,h)?"w":d&&m=="\n"?"n":!d||/\s/.test(m)?null:"p";if(d&&!p&&!g)g="s";if(i&&i!=g){if(a<0){a=1;n();o.sticky="after"}break}if(g)i=g;if(a>0&&!n(!p))break}}var v=Xo(r,o,e,t,true);if(at(e,v))v.hitSide=true;return v}function Ks(e,t,n,i){var r=e.doc,o=t.left,a;if(i=="page"){var s=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);var l=Math.max(s-.5*Ti(e.display),3);a=(n>0?t.bottom:t.top)+n*l}else if(i=="line")a=n>0?t.bottom+3:t.top-3;var u;for(;;){u=wi(e,o,a);if(!u.outside)break;if(n<0?a<=0:a>=r.height){u.hitSide=true;break}a+=n*5}return u}var Qs=function(e){this.cm=e;this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null;this.polling=new B;this.composing=null;this.gracePeriod=false;this.readDOMTimeout=null};function Zs(e,t){var n=ei(e,t.line);if(!n||n.hidden)return null;var i=Ke(e.doc,t.line);var r=Qn(n,i,t.line);var o=de(i,e.doc.direction),a="left";if(o){var s=ce(o,t.ch);a=s%2?"right":"left"}var l=oi(r.map,t.ch,a);l.offset=l.collapse=="right"?l.end:l.start;return l}function Js(e){for(var t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return true;return false}function el(e,t){if(t)e.bad=true;return e}function tl(s,e,t,l,u){var n="",c=false,f=s.doc.lineSeparator(),d=false;function h(t){return function(e){return e.id==t}}function p(){if(c){n+=f;if(d)n+=f;c=d=false}}function m(e){if(e){p();n+=e}}function g(e){if(e.nodeType==1){var t=e.getAttribute("cm-text");if(t){m(t);return}var n=e.getAttribute("cm-marker"),i;if(n){var r=s.findMarks(rt(l,0),rt(u+1,0),h(+n));if(r.length&&(i=r[0].find(0)))m(Qe(s.doc,i.from,i.to).join(f));return}if(e.getAttribute("contenteditable")=="false")return;var o=/^(pre|div|p|li|table|br)$/i.test(e.nodeName);if(!/^br$/i.test(e.nodeName)&&e.textContent.length==0)return;if(o)p();for(var a=0;a=t.display.viewTo||r.line=t.display.viewFrom&&Zs(t,i)||{node:s[0].measure.map[2],offset:0};var u=r.linee.firstLine())i=rt(i.line-1,Ke(e.doc,i.line-1).length);if(r.ch==Ke(e.doc,r.line).text.length&&r.linet.viewTo-1)return false;var o,a,s;if(i.line==t.viewFrom||(o=Pi(e,i.line))==0){a=et(t.view[0].line);s=t.view[0].node}else{a=et(t.view[o].line);s=t.view[o-1].node.nextSibling}var l=Pi(e,r.line);var u,c;if(l==t.view.length-1){u=t.viewTo-1;c=t.lineDiv.lastChild}else{u=et(t.view[l+1].line)-1;c=t.view[l+1].node.previousSibling}if(!s)return false;var f=e.doc.splitLines(tl(e,s,c,a,u));var d=Qe(e.doc,rt(a,0),rt(u,Ke(e.doc,u).text.length));while(f.length>1&&d.length>1)if(V(f)==V(d)){f.pop();d.pop();u--}else if(f[0]==d[0]){f.shift();d.shift();a++}else break;var h=0,p=0;var m=f[0],g=d[0],v=Math.min(m.length,g.length);while(hi.ch&&y.charCodeAt(y.length-p-1)==x.charCodeAt(x.length-p-1)){h--;p++}f[f.length-1]=y.slice(0,y.length-p).replace(/^\u200b+/,"");f[0]=f[0].slice(h).replace(/\u200b+$/,"");var w=rt(a,h);var k=rt(u,d.length?V(d).length-p:0);if(f.length>1||f[0]||ot(w,k)){ia(e.doc,f,w,k,"+input");return true}},Qs.prototype.ensurePolled=function(){this.forceCompositionEnd()},Qs.prototype.reset=function(){this.forceCompositionEnd()},Qs.prototype.forceCompositionEnd=function(){if(!this.composing)return;clearTimeout(this.readDOMTimeout);this.composing=null;this.updateFromDOM();this.div.blur();this.div.focus()},Qs.prototype.readFromDOMSoon=function(){var e=this;if(this.readDOMTimeout!=null)return;this.readDOMTimeout=setTimeout(function(){e.readDOMTimeout=null;if(e.composing)if(e.composing.done)e.composing=null;else return;e.updateFromDOM()},80)},Qs.prototype.updateFromDOM=function(){var e=this;if(this.cm.isReadOnly()||!this.pollContent())Ar(this.cm,function(){return Hi(e.cm)})},Qs.prototype.setUneditable=function(e){e.contentEditable="false"},Qs.prototype.onKeyPress=function(e){if(e.charCode==0||this.composing)return;e.preventDefault();if(!this.cm.isReadOnly())Or(this.cm,js)(this.cm,String.fromCharCode(e.charCode==null?e.keyCode:e.charCode),0)},Qs.prototype.readOnlyChanged=function(e){this.div.contentEditable=String(e!="nocursor")},Qs.prototype.onContextMenu=function(){},Qs.prototype.resetPosition=function(){},Qs.prototype.needsContentAttribute=true;var rl=function(e){this.cm=e;this.prevInput="";this.pollingFast=false;this.polling=new B;this.hasSelection=false;this.composing=null};function ol(t,n){n=n?$(n):{};n.value=t.value;if(!n.tabindex&&t.tabIndex)n.tabindex=t.tabIndex;if(!n.placeholder&&t.placeholder)n.placeholder=t.placeholder;if(n.autofocus==null){var e=N();n.autofocus=e==t||t.getAttribute("autofocus")!=null&&e==document.body}function i(){t.value=s.getValue()}var r;if(t.form){pe(t.form,"submit",i);if(!n.leaveSubmitMethodAlone){var o=t.form;r=o.submit;try{var a=o.submit=function(){i();o.submit=r;o.submit();o.submit=a}}catch(e){}}}n.finishInit=function(e){e.save=i;e.getTextArea=function(){return t};e.toTextArea=function(){e.toTextArea=isNaN;i();t.parentNode.removeChild(e.getWrapperElement());t.style.display="";if(t.form){ge(t.form,"submit",i);if(!n.leaveSubmitMethodAlone&&typeof t.form.submit=="function")t.form.submit=r}}};t.style.display="none";var s=Hs(function(e){return t.parentNode.insertBefore(e,t.nextSibling)},n);return s}function al(e){e.off=ge;e.on=pe;e.wheelEventPixels=to;e.Doc=ka;e.splitLines=Fe;e.countColumn=z;e.findColumn=q;e.isWordChar=te;e.Pass=j;e.signal=ve;e.Line=ln;e.changeEnd=so;e.scrollbarModel=xr;e.Pos=rt;e.cmpPos=ot;e.modes=ze;e.mimeModes=Be;e.resolveMode=je;e.getMode=_e;e.modeExtensions=Ye;e.extendMode=Ue;e.copyState=qe;e.startState=Ge;e.innerMode=Xe;e.commands=Ka;e.keyMap=$a;e.keyName=_a;e.isModifierKey=Ra;e.lookupKey=Wa;e.normalizeKeyMap=Ba;e.StringStream=Ve;e.SharedTextMarker=ga;e.TextMarker=pa;e.LineWidget=ca;e.e_preventDefault=ke;e.e_stopPropagation=Ce;e.e_stop=Le;e.addClass=F;e.contains=A;e.rmClass=L;e.keyNames=Fa}rl.prototype.init=function(n){var e=this;var i=this,r=this.cm;this.createField(n);var o=this.textarea;n.wrapper.insertBefore(this.wrapper,n.wrapper.firstChild);if(u)o.style.width="0px";pe(o,"input",function(){if(S&&w>=9&&e.hasSelection)e.hasSelection=null;i.poll()});pe(o,"paste",function(e){if(ye(r,e)||_s(e,r))return;r.state.pasteIncoming=+new Date;i.fastPoll()});function t(e){if(ye(r,e))return;if(r.somethingSelected())Rs({lineWise:false,text:r.getSelections()});else if(!r.options.lineWiseCopyCut)return;else{var t=Us(r);Rs({lineWise:true,text:t.text});if(e.type=="cut")r.setSelections(t.ranges,null,_);else{i.prevInput="";o.value=t.text.join("\n");P(o)}}if(e.type=="cut")r.state.cutIncoming=+new Date}pe(o,"cut",t);pe(o,"copy",t);pe(n.scroller,"paste",function(e){if(_n(n,e)||ye(r,e))return;if(!o.dispatchEvent){r.state.pasteIncoming=+new Date;i.focus();return}var t=new Event("paste");t.clipboardData=e.clipboardData;o.dispatchEvent(t)});pe(n.lineSpace,"selectstart",function(e){if(!_n(n,e))ke(e)});pe(o,"compositionstart",function(){var e=r.getCursor("from");if(i.composing)i.composing.range.clear();i.composing={start:e,range:r.markText(e,r.getCursor("to"),{className:"CodeMirror-composing"})}});pe(o,"compositionend",function(){if(i.composing){i.poll();i.composing.range.clear();i.composing=null}})},rl.prototype.createField=function(e){this.wrapper=Xs();this.textarea=this.wrapper.firstChild},rl.prototype.screenReaderLabelChanged=function(e){if(e)this.textarea.setAttribute("aria-label",e);else this.textarea.removeAttribute("aria-label")},rl.prototype.prepareSelection=function(){var e=this.cm,t=e.display,n=e.doc;var i=_i(e);if(e.options.moveInputWithCursor){var r=yi(e,n.sel.primary().head,"div");var o=t.wrapper.getBoundingClientRect(),a=t.lineDiv.getBoundingClientRect();i.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,r.top+a.top-o.top));i.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,r.left+a.left-o.left))}return i},rl.prototype.showSelection=function(e){var t=this.cm,n=t.display;T(n.cursorDiv,e.cursors);T(n.selectionDiv,e.selection);if(e.teTop!=null){this.wrapper.style.top=e.teTop+"px";this.wrapper.style.left=e.teLeft+"px"}},rl.prototype.reset=function(e){if(this.contextMenuPending||this.composing)return;var t=this.cm;if(t.somethingSelected()){this.prevInput="";var n=t.getSelection();this.textarea.value=n;if(t.state.focused)P(this.textarea);if(S&&w>=9)this.hasSelection=n}else if(!e){this.prevInput=this.textarea.value="";if(S&&w>=9)this.hasSelection=null}},rl.prototype.getField=function(){return this.textarea},rl.prototype.supportsTouch=function(){return false},rl.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"&&(!d||N()!=this.textarea))try{this.textarea.focus()}catch(e){}},rl.prototype.blur=function(){this.textarea.blur()},rl.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},rl.prototype.receivedFocus=function(){this.slowPoll()},rl.prototype.slowPoll=function(){var e=this;if(this.pollingFast)return;this.polling.set(this.cm.options.pollInterval,function(){e.poll();if(e.cm.state.focused)e.slowPoll()})},rl.prototype.fastPoll=function(){var t=false,n=this;n.pollingFast=true;function i(){var e=n.poll();if(!e&&!t){t=true;n.polling.set(60,i)}else{n.pollingFast=false;n.slowPoll()}}n.polling.set(20,i)},rl.prototype.poll=function(){var e=this;var t=this.cm,n=this.textarea,i=this.prevInput;if(this.contextMenuPending||!t.state.focused||Ie(n)&&!i&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return false;var r=n.value;if(r==i&&!t.somethingSelected())return false;if(S&&w>=9&&this.hasSelection===r||y&&/[\uf700-\uf7ff]/.test(r)){t.display.input.reset();return false}if(t.doc.sel==t.display.selForContextMenu){var o=r.charCodeAt(0);if(o==8203&&!i)i="";if(o==8666){this.reset();return this.cm.execCommand("undo")}}var a=0,s=Math.min(i.length,r.length);while(a1e3||r.indexOf("\n")>-1)n.value=e.prevInput="";else e.prevInput=r;if(e.composing){e.composing.range.clear();e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"})}});return true},rl.prototype.ensurePolled=function(){if(this.pollingFast&&this.poll())this.pollingFast=false},rl.prototype.onKeyPress=function(){if(S&&w>=9)this.hasSelection=null;this.fastPoll()},rl.prototype.onContextMenu=function(e){var n=this,i=n.cm,r=i.display,o=n.textarea;if(n.contextMenuPending)n.contextMenuPending();var t=Ii(i,e),a=r.scroller.scrollTop;if(!t||v)return;var s=i.options.resetSelectionOnContextMenu;if(s&&i.doc.sel.contains(t)==-1)Or(i,Ro)(i.doc,ao(t),_);var l=o.style.cssText,u=n.wrapper.style.cssText;var c=n.wrapper.offsetParent.getBoundingClientRect();n.wrapper.style.cssText="position: static";o.style.cssText="position: absolute; width: 30px; height: 30px;\n top: "+(e.clientY-c.top-5)+"px; left: "+(e.clientX-c.left-5)+"px;\n z-index: 1000; background: "+(S?"rgba(255, 255, 255, .05)":"transparent")+";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";var f;if(g)f=window.scrollY;r.input.focus();if(g)window.scrollTo(null,f);r.input.reset();if(!i.somethingSelected())o.value=n.prevInput=" ";n.contextMenuPending=h;r.selForContextMenu=i.doc.sel;clearTimeout(r.detectingSelectAll);function d(){if(o.selectionStart!=null){var e=i.somethingSelected();var t=""+(e?o.value:"");o.value="⇚";o.value=t;n.prevInput=e?"":"";o.selectionStart=1;o.selectionEnd=t.length;r.selForContextMenu=i.doc.sel}}function h(){if(n.contextMenuPending!=h)return;n.contextMenuPending=false;n.wrapper.style.cssText=u;o.style.cssText=l;if(S&&w<9)r.scrollbars.setScrollTop(r.scroller.scrollTop=a);if(o.selectionStart!=null){if(!S||S&&w<9)d();var e=0,t=function(){if(r.selForContextMenu==i.doc.sel&&o.selectionStart==0&&o.selectionEnd>0&&n.prevInput=="")Or(i,Vo)(i);else if(e++<10)r.detectingSelectAll=setTimeout(t,500);else{r.selForContextMenu=null;r.input.reset()}};r.detectingSelectAll=setTimeout(t,200)}}if(S&&w>=9)d();if(k){Le(e);var p=function(){ge(window,"mouseup",p);setTimeout(h,20)};pe(window,"mouseup",p)}else setTimeout(h,50)},rl.prototype.readOnlyChanged=function(e){if(!e)this.reset();this.textarea.disabled=e=="nocursor";this.textarea.readOnly=!!e},rl.prototype.setUneditable=function(){},rl.prototype.needsContentAttribute=false,Fs(Hs),Gs(Hs);var sl="iter insert remove copy getEditor constructor".split(" "),ll;for(ll in ka.prototype)if(ka.prototype.hasOwnProperty(ll)&&W(sl,ll)<0)Hs.prototype[ll]=function(e){return function(){return e.apply(this.doc,arguments)}}(ka.prototype[ll]);return we(ka),Hs.inputStyles={textarea:rl,contenteditable:Qs},Hs.defineMode=function(e){if(!Hs.defaults.mode&&e!="null")Hs.defaults.mode=e;We.apply(this,arguments)},Hs.defineMIME=Re,Hs.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),Hs.defineMIME("text/plain","null"),Hs.defineExtension=function(e,t){Hs.prototype[e]=t},Hs.defineDocExtension=function(e,t){ka.prototype[e]=t},Hs.fromTextArea=ol,al(Hs),Hs.version="5.62.0",Hs}(),gt=pt={init:function(){$$("[data-modal]").forEach(function(e){e.addEventListener("click",function(){var e=this.getAttribute("data-modal"),t=this.getAttribute("data-modal-action");t?pt.show(e,t):pt.show(e)})}),$$(".modal [data-dismiss]").forEach(function(e){e.addEventListener("click",function(){this.hasAttribute("data-validate")&&!pt.validate(this.getAttribute("data-dismiss"))||pt.hide(this.getAttribute("data-dismiss"))})}),$$(".modal").forEach(function(e){e.addEventListener("click",function(e){e.target===this&&pt.hide()})}),document.addEventListener("keyup",function(e){27===e.which&&pt.hide()}),window.addEventListener("focus",function(){var e=$(".modal.show");e&&x.firstFocusableElement(e).focus()})},show:function(e,t,n){e=document.getElementById(e);e&&(e.classList.add("show"),t&&$("form",e).setAttribute("action",t),document.activeElement.blur(),($("[autofocus]",e)?$("[autofocus]",e):x.firstFocusableElement(e)).focus(),"function"==typeof n&&n(e),$$(".tooltip").forEach(function(e){e.parentNode.removeChild(e)}),this.createBackdrop())},hide:function(e){void 0!==e?document.getElementById(e).classList.remove("show"):$$(".modal").forEach(function(e){e.classList.remove("show")}),this.removeBackdrop()},createBackdrop:function(){var e;$(".modal-backdrop")||((e=document.createElement("div")).className="modal-backdrop",document.body.appendChild(e))},removeBackdrop:function(){var e=$(".modal-backdrop");e&&e.parentNode.removeChild(e)},validate:function(e){var t=!1,n=document.getElementById(e);return $$("[required]",e).forEach(function(e){return""===e.value?(e.classList("input-invalid"),e.focus(),$(".modal-error",n).style.display="block",t=!1):void(t=!0)}),t}};!function(L){var E={autoSelfClosers:{area:true,base:true,br:true,col:true,command:true,embed:true,frame:true,hr:true,img:true,input:true,keygen:true,link:true,meta:true,param:true,source:true,track:true,wbr:true,menuitem:true},implicitlyClosed:{dd:true,li:true,optgroup:true,option:true,p:true,rp:true,rt:true,tbody:true,td:true,tfoot:true,th:true,tr:true},contextGrabbers:{dd:{dd:true,dt:true},dt:{dd:true,dt:true},li:{li:true},option:{option:true,optgroup:true},optgroup:{optgroup:true},p:{address:true,article:true,aside:true,blockquote:true,dir:true,div:true,dl:true,fieldset:true,footer:true,form:true,h1:true,h2:true,h3:true,h4:true,h5:true,h6:true,header:true,hgroup:true,hr:true,menu:true,nav:true,ol:true,p:true,pre:true,section:true,table:true,ul:true},rp:{rp:true,rt:true},rt:{rp:true,rt:true},tbody:{tbody:true,tfoot:true},td:{td:true,th:true},tfoot:{tbody:true},th:{td:true,th:true},thead:{tbody:true,tfoot:true},tr:{tr:true}},doNotIndent:{pre:true},allowUnquoted:true,allowMissing:true,caseFold:true},M={autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:false,allowMissing:false,allowMissingTagName:false,caseFold:false};if(L.defineMode("xml",function(e,t){var a=e.indentUnit;var s={};var n=t.htmlMode?E:M;for(var i in n)s[i]=n[i];for(var i in t)s[i]=t[i];var o,l;function u(t,n){function e(e){n.tokenize=e;return e(t,n)}var i=t.next();if(i=="<")if(t.eat("!"))if(t.eat("["))if(t.match("CDATA["))return e(f("atom","]]>"));else return null;else if(t.match("--"))return e(f("comment","--\x3e"));else if(t.match("DOCTYPE",true,true)){t.eatWhile(/[\w\._\-]/);return e(d(1))}else return null;else if(t.eat("?")){t.eatWhile(/[\w\._\-]/);n.tokenize=f("meta","?>");return"meta"}else{o=t.eat("/")?"closeTag":"openTag";n.tokenize=c;return"tag bracket"}else if(i=="&"){var r;if(t.eat("#"))if(t.eat("x"))r=t.eatWhile(/[a-fA-F\d]/)&&t.eat(";");else r=t.eatWhile(/[\d]/)&&t.eat(";");else r=t.eatWhile(/[\w\.\-:]/)&&t.eat(";");return r?"atom":"error"}else{t.eatWhile(/[^&<]/);return null}}u.isInText=true;function c(e,t){var n=e.next();if(n==">"||n=="/"&&e.eat(">")){t.tokenize=u;o=n==">"?"endTag":"selfcloseTag";return"tag bracket"}else if(n=="="){o="equals";return null}else if(n=="<"){t.tokenize=u;t.state=g;t.tagName=t.tagStart=null;var i=t.tokenize(e,t);return i?i+" tag error":"tag error"}else if(/[\'\"]/.test(n)){t.tokenize=r(n);t.stringStartCol=e.column();return t.tokenize(e,t)}else{e.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/);return"word"}}function r(n){var e=function(e,t){while(!e.eol())if(e.next()==n){t.tokenize=c;break}return"string"};e.isInAttribute=true;return e}function f(n,i){return function(e,t){while(!e.eol()){if(e.match(i)){t.tokenize=u;break}e.next()}return n}}function d(i){return function(e,t){var n;while((n=e.next())!=null)if(n=="<"){t.tokenize=d(i+1);return t.tokenize(e,t)}else if(n==">")if(i==1){t.tokenize=u;break}else{t.tokenize=d(i-1);return t.tokenize(e,t)}return"meta"}}function h(e,t,n){this.prev=e.context;this.tagName=t||"";this.indent=e.indented;this.startOfLine=n;if(s.doNotIndent.hasOwnProperty(t)||e.context&&e.context.noIndent)this.noIndent=true}function p(e){if(e.context)e.context=e.context.prev}function m(e,t){var n;while(true){if(!e.context)return;n=e.context.tagName;if(!s.contextGrabbers.hasOwnProperty(n)||!s.contextGrabbers[n].hasOwnProperty(t))return;p(e)}}function g(e,t,n){if(e=="openTag"){n.tagStart=t.column();return v}else if(e=="closeTag")return y;else return g}function v(e,t,n){if(e=="word"){n.tagName=t.current();l="tag";return w}else if(s.allowMissingTagName&&e=="endTag"){l="tag bracket";return w(e,t,n)}else{l="error";return v}}function y(e,t,n){if(e=="word"){var i=t.current();if(n.context&&n.context.tagName!=i&&s.implicitlyClosed.hasOwnProperty(n.context.tagName))p(n);if(n.context&&n.context.tagName==i||s.matchClosing===false){l="tag";return x}else{l="tag error";return b}}else if(s.allowMissingTagName&&e=="endTag"){l="tag bracket";return x(e,t,n)}else{l="error";return b}}function x(e,t,n){if(e!="endTag"){l="error";return x}p(n);return g}function b(e,t,n){l="error";return x(e,t,n)}function w(e,t,n){if(e=="word"){l="attribute";return k}else if(e=="endTag"||e=="selfcloseTag"){var i=n.tagName,r=n.tagStart;n.tagName=n.tagStart=null;if(e=="selfcloseTag"||s.autoSelfClosers.hasOwnProperty(i))m(n,i);else{m(n,i);n.context=new h(n,i,r==n.indented)}return g}l="error";return w}function k(e,t,n){if(e=="equals")return C;if(!s.allowMissing)l="error";return w(e,t,n)}function C(e,t,n){if(e=="string")return S;if(e=="word"&&s.allowUnquoted){l="string";return w}l="error";return w(e,t,n)}function S(e,t,n){if(e=="string")return S;return w(e,t,n)}return{startState:function(e){var t={tokenize:u,state:g,indented:e||0,tagName:null,tagStart:null,context:null};if(e!=null)t.baseIndent=e;return t},token:function(e,t){if(!t.tagName&&e.sol())t.indented=e.indentation();if(e.eatSpace())return null;o=null;var n=t.tokenize(e,t);if((n||o)&&n!="comment"){l=null;t.state=t.state(o||n,e,t);if(l)n=l=="error"?n+" error":l}return n},indent:function(e,t,n){var i=e.context;if(e.tokenize.isInAttribute)if(e.tagStart==e.indented)return e.stringStartCol+1;else return e.indented+a;if(i&&i.noIndent)return L.Pass;if(e.tokenize!=c&&e.tokenize!=u)return n?n.match(/^(\s*)/)[0].length:0;if(e.tagName)if(s.multilineTagIndentPastTag!==false)return e.tagStart+e.tagName.length+2;else return e.tagStart+a*(s.multilineTagIndentFactor||1);if(s.alignCDATA&&/$/,blockCommentStart:"\x3c!--",blockCommentEnd:"--\x3e",configuration:s.htmlMode?"html":"xml",helperType:s.htmlMode?"html":"xml",skipAttribute:function(e){if(e.state==C)e.state=w},xmlCurrentTag:function(e){return e.tagName?{name:e.tagName,close:e.type=="closeTag"}:null},xmlCurrentContext:function(e){var t=[];for(var n=e.context;n;n=n.prev)t.push(n.tagName);return t.reverse()}}}),L.defineMIME("text/xml","xml"),L.defineMIME("application/xml","xml"),!L.mimeModes.hasOwnProperty("text/html"))L.defineMIME("text/html",{name:"xml",htmlMode:true})}(k.exports);var vt,yt,xt,bt,wt;function kt(e){var o=mt.fromTextArea(e,{mode:{name:"markdown",highlightFormatting:!0},theme:"formwork",indentUnit:4,lineWrapping:!0,addModeClass:!0,extraKeys:{Enter:"newlineAndIndentContinueMarkdownList"},configureMouse:function(){return{extend:!1,addNew:!1}}}),t=$(".editor-toolbar[data-for="+e.id+"]"),n=e.parentNode.classList.contains("editor-wrap")?e.parentNode:null,i=[];function r(){return/\n+===\n+/.test(o.getValue())}function a(){r()?$("[data-command=summary]",t).setAttribute("disabled",""):$("[data-command=summary]",t).removeAttribute("disabled")}function s(){var e=o.getLine(o.getCursor().line);return 0===e.length?void 0:e.slice(-1)}function l(){switch(s()){case void 0:return"";case"\n":return"\n";default:return"\n\n"}}function u(e,t,n){var i,r;void 0===t&&(t=e),i=!0===n?"":o.getSelection(),r=o.getCursor(),n=e.split("\n").length-1,o.replaceSelection(e+i+t),o.setCursor(r.line+n,r.ch+e.length-n),o.focus()}function c(e,t){for(var n=0;n ","")}),$("[data-command=link]",t).addEventListener("click",function(){var e=o.getSelection();/^(https?:\/\/|mailto:)/i.test(e)?u("[","]("+e+")",!0):""!==e?u("["+e+"](http://",")",!0):u("[","](http://)")}),$("[data-command=image]",t).addEventListener("click",function(){gt.show("imagesModal",null,function(e){var t=$(".image-picker-thumbnail.selected",e);t&&t.classList.remove("selected"),$(".image-picker-confirm",e).addEventListener("click",function e(){var t=$(".image-picker-thumbnail.selected",$("#imagesModal")).getAttribute("data-filename");void 0!==t?u(l()+""):u(l()+""),this.removeEventListener("click",e)})})}),$("[data-command=summary]",t).addEventListener("click",function(){var e;r()||(u((void 0===(e=s())||"\n"===e?"":"\n")+"\n===\n\n",""),this.setAttribute("disabled",""))}),$("[data-command=undo]",t).addEventListener("click",function(){o.undo(),o.focus()}),$("[data-command=redo]",t).addEventListener("click",function(){o.redo(),o.focus()}),a(),o.on("changes",x.debounce(function(){e.value=o.getValue(),a(),o.historySize().undo<1?$("[data-command=undo]").setAttribute("disabled",""):$("[data-command=undo]").removeAttribute("disabled"),o.historySize().redo<1?$("[data-command=redo]").setAttribute("disabled",""):$("[data-command=redo]").removeAttribute("disabled")},500)),o.on("beforeSelectionChange",function(e,t){var n=function(e){var t,n=[];for(t=0;t'),i=!0}),e.addEventListener("drag",o),e.addEventListener("dragstart",o),e.addEventListener("dragend",o),e.addEventListener("dragover",a),e.addEventListener("dragenter",a),e.addEventListener("dragleave",function(e){this.classList.remove("drag"),e.preventDefault()}),e.addEventListener("drop",function(e){e.preventDefault(),i||(t.files=e.dataTransfer.files,x.triggerEvent(t,"change"))}),e.addEventListener("click",function(e){i&&e.preventDefault()})}function St(i){var r=x.serializeForm(i);function e(e){n()&&(e.preventDefault(),e.returnValue="")}function o(){window.removeEventListener("beforeunload",e)}function n(e){var t,n;if(void 0===e&&(e=!0),t=$$("input[type=file]",i),!0===e&&0-1&&e.substring(i+1,e.length);if(r)return o.findModeByExtension(r)},o.findModeByName=function(e){e=e.toLowerCase();for(var t=0;t` "'(~:]+/,b=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,w=/^\s*\[[^\]]+?\]:.*$/,k=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/;function C(e,t,n){return(t.f=t.inline=n)(e,t)}function S(e,t,n){return(t.f=t.block=n)(e,t)}function i(e){var t,n;return e.linkTitle=!1,e.linkHref=!1,e.linkText=!1,e.em=!1,e.strong=!1,e.strikethrough=!1,e.quote=0,e.indentedCode=!1,e.f!=L||(n=!(n=r)?"xml"==(t=vt.innerMode(h,e.htmlState)).mode.name&&null===t.state.tagStart&&!t.state.context&&t.state.tokenize.isInText:n)&&(e.f=T,e.block=o,e.htmlState=null),e.trailingSpace=0,e.trailingSpaceNewLine=!1,e.prevLine=e.thisLine,e.thisLine={stream:null},null}function o(e,t){var n=e.column()===t.indentation,i=!(c=t.prevLine.stream)||!/\S/.test(c.string),r=t.indentedCode,o=t.prevLine.hr,a=!1!==t.list,s=(t.listStack[t.listStack.length-1]||0)+3;t.indentedCode=!1;var l=t.indentation;if(null===t.indentationDiff&&(t.indentationDiff=t.indentation,a)){for(t.list=null;l