@redocly/reference-docs 1.5.15 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli/commands/redocly-docs-cli.min.js +5 -5
- package/dist/console.redocly-reference-docs.min.js +1 -1
- package/dist/oauth2-redirect.js +1 -1
- package/dist/redocly-reference-docs.min.js +4 -4
- package/lib/services/check.d.ts +1 -0
- package/lib/services/check.js +1 -1
- package/lib-esm/services/check.d.ts +1 -0
- package/lib-esm/services/check.js +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Redocly Reference Docs
|
|
3
3
|
* (c) Copyright 2018 Redocly LLC, all rights reserved.
|
|
4
4
|
* -------------------------------------------------------------
|
|
5
|
-
* Version: "1.
|
|
5
|
+
* Version: "1.6.0"
|
|
6
6
|
*/
|
|
7
7
|
(this.webpackJsonpRedoclyReferenceDocs=this.webpackJsonpRedoclyReferenceDocs||[]).push([[0],Array(513).concat([function(e,t,n){"use strict";var r=n(517),o=n(547).f,i=n(657),a=n(514),s=n(558),l=n(525),c=n(522),u=function(e){var t=function(t,n,r){if(this instanceof e){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,n)}return new e(t,n,r)}return e.apply(this,arguments)};return t.prototype=e.prototype,t};e.exports=function(e,t){var n,f,p,d,h,v,g,m,y=e.target,b=e.global,x=e.stat,w=e.proto,k=b?r:x?r[y]:(r[y]||{}).prototype,C=b?a:a[y]||(a[y]={}),A=C.prototype;for(p in t)n=!i(b?p:y+(x?".":"#")+p,e.forced)&&k&&c(k,p),h=C[p],n&&(v=e.noTargetGet?(m=o(k,p))&&m.value:k[p]),d=n&&v?v:t[p],n&&typeof h==typeof d||(g=e.bind&&n?s(d,r):e.wrap&&n?u(d):w&&"function"==typeof d?s(Function.call,d):d,(e.sham||d&&d.sham||h&&h.sham)&&l(g,"sham",!0),C[p]=g,w&&(c(a,f=y+"Prototype")||l(a,f,{}),a[f][p]=d,e.real&&A&&!A[p]&&l(A,p,d)))}},function(e,t){e.exports={}},function(e,t){e.exports=function(e){try{return!!e()}catch(e){return!0}}},function(e,t,n){var r=n(514),o=n(522),i=n(613),a=n(530).f;e.exports=function(e){var t=r.Symbol||(r.Symbol={});o(t,e)||a(t,e,{value:i.f(e)})}},function(e,t,n){(function(t){var n=function(e){return e&&e.Math==Math&&e};e.exports=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof t&&t)||function(){return this}()||Function("return this")()}).call(this,n(15))},function(e,t,n){var r=n(517),o=n(609),i=n(522),a=n(582),s=n(607),l=n(661),c=o("wks"),u=r.Symbol,f=l?u:u&&u.withoutSetter||a;e.exports=function(e){return i(c,e)&&(s||"string"==typeof c[e])||(s&&i(u,e)?c[e]=u[e]:c[e]=f("Symbol."+e)),c[e]}},function(e,t){e.exports=function(e){return"object"==typeof e?null!==e:"function"==typeof e}},function(e,t,n){var r=n(515);e.exports=!r((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))},function(e,t,n){var r=n(519);e.exports=function(e){if(!r(e))throw TypeError(String(e)+" is not an object");return e}},function(e,t,n){var r=n(529),o={}.hasOwnProperty;e.exports=Object.hasOwn||function(e,t){return o.call(r(e),t)}},function(e,t){var n=Array.isArray;e.exports=n},function(e,t,n){e.exports=n(882)},function(e,t,n){var r=n(520),o=n(530),i=n(548);e.exports=r?function(e,t,n){return o.f(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}},function(e,t,n){var r=n(514);e.exports=function(e){return r[e+"Prototype"]}},function(e,t,n){var r=n(654),o=n(659),i=n(748),a=n(667),s=n(755),l=n(765),c=n(770),u=n(617),f=n(673);function p(e,t){var n=r(e);if(o){var s=o(e);t&&(s=i(s).call(s,(function(t){return a(e,t).enumerable}))),n.push.apply(n,s)}return n}e.exports=function(e){for(var t=1;t<arguments.length;t++){var n,r=null!=arguments[t]?arguments[t]:{};if(t%2)s(n=p(Object(r),!0)).call(n,(function(t){f(e,t,r[t])}));else if(l)c(e,l(r));else{var o;s(o=p(Object(r))).call(o,(function(t){u(e,t,a(r,t))}))}}return e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,n){var r=n(602),o=n(577);e.exports=function(e){return r(o(e))}},function(e,t,n){var r=n(577);e.exports=function(e){return Object(r(e))}},function(e,t,n){var r=n(520),o=n(656),i=n(521),a=n(578),s=Object.defineProperty;t.f=r?s:function(e,t,n){if(i(e),t=a(t,!0),i(n),o)try{return s(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(e[t]=n.value),e}},function(e,t,n){var r=n(514),o=n(517),i=function(e){return"function"==typeof e?e:void 0};e.exports=function(e,t){return arguments.length<2?i(r[e])||i(o[e]):r[e]&&r[e][t]||o[e]&&o[e][t]}},function(e,t,n){var r=n(676),o="object"==typeof self&&self&&self.Object===Object&&self,i=r||o||Function("return this")();e.exports=i},function(e,t){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},function(e,t,n){e.exports=n(881)},function(e,t){e.exports=function(e){return null!=e&&"object"==typeof e}},function(e,t,n){var r=n(591),o=n(839);function i(t){return"function"==typeof r&&"symbol"==typeof o?(e.exports=i=function(e){return typeof e},e.exports.default=e.exports,e.exports.__esModule=!0):(e.exports=i=function(e){return e&&"function"==typeof r&&e.constructor===r&&e!==r.prototype?"symbol":typeof e},e.exports.default=e.exports,e.exports.__esModule=!0),i(t)}e.exports=i,e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,n){e.exports=function(){"use strict";var e=navigator.userAgent,t=navigator.platform,n=/gecko\/\d/i.test(e),r=/MSIE \d/.test(e),o=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(e),i=/Edge\/(\d+)/.exec(e),a=r||o||i,s=a&&(r?document.documentMode||6:+(i||o)[1]),l=!i&&/WebKit\//.test(e),c=l&&/Qt\/\d+\.\d+/.test(e),u=!i&&/Chrome\//.test(e),f=/Opera\//.test(e),p=/Apple Computer/.test(navigator.vendor),d=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(e),h=/PhantomJS/.test(e),v=p&&(/Mobile\/\w+/.test(e)||navigator.maxTouchPoints>2),g=/Android/.test(e),m=v||g||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(e),y=v||/Mac/.test(t),b=/\bCrOS\b/.test(e),x=/win/i.test(t),w=f&&e.match(/Version\/(\d*\.\d*)/);w&&(w=Number(w[1])),w&&w>=15&&(f=!1,l=!0);var k=y&&(c||f&&(null==w||w<12.11)),C=n||a&&s>=9;function A(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var O,S=function(e,t){var n=e.className,r=A(t).exec(n);if(r){var o=n.slice(r.index+r[0].length);e.className=n.slice(0,r.index)+(o?r[1]+o:"")}};function E(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function j(e,t){return E(e).appendChild(t)}function T(e,t,n,r){var o=document.createElement(e);if(n&&(o.className=n),r&&(o.style.cssText=r),"string"==typeof t)o.appendChild(document.createTextNode(t));else if(t)for(var i=0;i<t.length;++i)o.appendChild(t[i]);return o}function M(e,t,n,r){var o=T(e,t,n,r);return o.setAttribute("role","presentation"),o}function P(e,t){if(3==t.nodeType&&(t=t.parentNode),e.contains)return e.contains(t);do{if(11==t.nodeType&&(t=t.host),t==e)return!0}while(t=t.parentNode)}function L(){var e;try{e=document.activeElement}catch(t){e=document.body||null}for(;e&&e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;return e}function I(e,t){var n=e.className;A(t).test(n)||(e.className+=(n?" ":"")+t)}function F(e,t){for(var n=e.split(" "),r=0;r<n.length;r++)n[r]&&!A(n[r]).test(t)&&(t+=" "+n[r]);return t}O=document.createRange?function(e,t,n,r){var o=document.createRange();return o.setEnd(r||e,n),o.setStart(e,t),o}:function(e,t,n){var r=document.body.createTextRange();try{r.moveToElementText(e.parentNode)}catch(e){return r}return r.collapse(!0),r.moveEnd("character",n),r.moveStart("character",t),r};var _=function(e){e.select()};function N(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function R(e,t,n){for(var r in t||(t={}),e)!e.hasOwnProperty(r)||!1===n&&t.hasOwnProperty(r)||(t[r]=e[r]);return t}function D(e,t,n,r,o){null==t&&-1==(t=e.search(/[^\s\u00a0]/))&&(t=e.length);for(var i=r||0,a=o||0;;){var s=e.indexOf("\t",i);if(s<0||s>=t)return a+(t-i);a+=s-i,a+=n-a%n,i=s+1}}v?_=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:a&&(_=function(e){try{e.select()}catch(e){}});var V=function(){this.id=null,this.f=null,this.time=0,this.handler=N(this.onTimeout,this)};function B(e,t){for(var n=0;n<e.length;++n)if(e[n]==t)return n;return-1}V.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},V.prototype.set=function(e,t){this.f=t;var n=+new Date+e;(!this.id||n<this.time)&&(clearTimeout(this.id),this.id=setTimeout(this.handler,e),this.time=n)};var U={toString:function(){return"CodeMirror.Pass"}},z={scroll:!1},W={origin:"*mouse"},H={origin:"+move"};function q(e,t,n){for(var r=0,o=0;;){var i=e.indexOf("\t",r);-1==i&&(i=e.length);var a=i-r;if(i==e.length||o+a>=t)return r+Math.min(a,t-o);if(o+=i-r,r=i+1,(o+=n-o%n)>=t)return r}}var G=[""];function $(e){for(;G.length<=e;)G.push(K(G)+" ");return G[e]}function K(e){return e[e.length-1]}function J(e,t){for(var n=[],r=0;r<e.length;r++)n[r]=t(e[r],r);return n}function Y(){}function X(e,t){var n;return Object.create?n=Object.create(e):(Y.prototype=e,n=new Y),t&&R(t,n),n}var Q=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function Z(e){return/\w/.test(e)||e>""&&(e.toUpperCase()!=e.toLowerCase()||Q.test(e))}function ee(e,t){return t?!!(t.source.indexOf("\\w")>-1&&Z(e))||t.test(e):Z(e)}function te(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var ne=/[\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 re(e){return e.charCodeAt(0)>=768&&ne.test(e)}function oe(e,t,n){for(;(n<0?t>0:t<e.length)&&re(e.charAt(t));)t+=n;return t}function ie(e,t,n){for(var r=t>n?-1:1;;){if(t==n)return t;var o=(t+n)/2,i=r<0?Math.ceil(o):Math.floor(o);if(i==t)return e(i)?t:n;e(i)?n=i:t=i+r}}var ae=null;function se(e,t,n){var r;ae=null;for(var o=0;o<e.length;++o){var i=e[o];if(i.from<t&&i.to>t)return o;i.to==t&&(i.from!=i.to&&"before"==n?r=o:ae=o),i.from==t&&(i.from!=i.to&&"before"!=n?r=o:ae=o)}return null!=r?r:ae}var le=function(){var e=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,t=/[stwN]/,n=/[LRr]/,r=/[Lb1n]/,o=/[1n]/;function i(e,t,n){this.level=e,this.from=t,this.to=n}return function(a,s){var l="ltr"==s?"L":"R";if(0==a.length||"ltr"==s&&!e.test(a))return!1;for(var c,u=a.length,f=[],p=0;p<u;++p)f.push((c=a.charCodeAt(p))<=247?"bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN".charAt(c):1424<=c&&c<=1524?"R":1536<=c&&c<=1785?"nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111".charAt(c-1536):1774<=c&&c<=2220?"r":8192<=c&&c<=8203?"w":8204==c?"b":"L");for(var d=0,h=l;d<u;++d){var v=f[d];"m"==v?f[d]=h:h=v}for(var g=0,m=l;g<u;++g){var y=f[g];"1"==y&&"r"==m?f[g]="n":n.test(y)&&(m=y,"r"==y&&(f[g]="R"))}for(var b=1,x=f[0];b<u-1;++b){var w=f[b];"+"==w&&"1"==x&&"1"==f[b+1]?f[b]="1":","!=w||x!=f[b+1]||"1"!=x&&"n"!=x||(f[b]=x),x=w}for(var k=0;k<u;++k){var C=f[k];if(","==C)f[k]="N";else if("%"==C){var A=void 0;for(A=k+1;A<u&&"%"==f[A];++A);for(var O=k&&"!"==f[k-1]||A<u&&"1"==f[A]?"1":"N",S=k;S<A;++S)f[S]=O;k=A-1}}for(var E=0,j=l;E<u;++E){var T=f[E];"L"==j&&"1"==T?f[E]="L":n.test(T)&&(j=T)}for(var M=0;M<u;++M)if(t.test(f[M])){var P=void 0;for(P=M+1;P<u&&t.test(f[P]);++P);for(var L="L"==(M?f[M-1]:l),I=L==("L"==(P<u?f[P]:l))?L?"L":"R":l,F=M;F<P;++F)f[F]=I;M=P-1}for(var _,N=[],R=0;R<u;)if(r.test(f[R])){var D=R;for(++R;R<u&&r.test(f[R]);++R);N.push(new i(0,D,R))}else{var V=R,B=N.length,U="rtl"==s?1:0;for(++R;R<u&&"L"!=f[R];++R);for(var z=V;z<R;)if(o.test(f[z])){V<z&&(N.splice(B,0,new i(1,V,z)),B+=U);var W=z;for(++z;z<R&&o.test(f[z]);++z);N.splice(B,0,new i(2,W,z)),B+=U,V=z}else++z;V<R&&N.splice(B,0,new i(1,V,R))}return"ltr"==s&&(1==N[0].level&&(_=a.match(/^\s+/))&&(N[0].from=_[0].length,N.unshift(new i(0,0,_[0].length))),1==K(N).level&&(_=a.match(/\s+$/))&&(K(N).to-=_[0].length,N.push(new i(0,u-_[0].length,u)))),"rtl"==s?N.reverse():N}}();function ce(e,t){var n=e.order;return null==n&&(n=e.order=le(e.text,t)),n}var ue=[],fe=function(e,t,n){if(e.addEventListener)e.addEventListener(t,n,!1);else if(e.attachEvent)e.attachEvent("on"+t,n);else{var r=e._handlers||(e._handlers={});r[t]=(r[t]||ue).concat(n)}};function pe(e,t){return e._handlers&&e._handlers[t]||ue}function de(e,t,n){if(e.removeEventListener)e.removeEventListener(t,n,!1);else if(e.detachEvent)e.detachEvent("on"+t,n);else{var r=e._handlers,o=r&&r[t];if(o){var i=B(o,n);i>-1&&(r[t]=o.slice(0,i).concat(o.slice(i+1)))}}}function he(e,t){var n=pe(e,t);if(n.length)for(var r=Array.prototype.slice.call(arguments,2),o=0;o<n.length;++o)n[o].apply(null,r)}function ve(e,t,n){return"string"==typeof t&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),he(e,n||t.type,e,t),we(t)||t.codemirrorIgnore}function ge(e){var t=e._handlers&&e._handlers.cursorActivity;if(t)for(var n=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),r=0;r<t.length;++r)-1==B(n,t[r])&&n.push(t[r])}function me(e,t){return pe(e,t).length>0}function ye(e){e.prototype.on=function(e,t){fe(this,e,t)},e.prototype.off=function(e,t){de(this,e,t)}}function be(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function xe(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function we(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function ke(e){be(e),xe(e)}function Ce(e){return e.target||e.srcElement}function Ae(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),y&&e.ctrlKey&&1==t&&(t=3),t}var Oe,Se,Ee=function(){if(a&&s<9)return!1;var e=T("div");return"draggable"in e||"dragDrop"in e}();function je(e){if(null==Oe){var t=T("span","");j(e,T("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(Oe=t.offsetWidth<=1&&t.offsetHeight>2&&!(a&&s<8))}var n=Oe?T("span",""):T("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return n.setAttribute("cm-text",""),n}function Te(e){if(null!=Se)return Se;var t=j(e,document.createTextNode("AخA")),n=O(t,0,1).getBoundingClientRect(),r=O(t,1,2).getBoundingClientRect();return E(e),!(!n||n.left==n.right)&&(Se=r.right-n.right<3)}var Me,Pe=3!="\n\nb".split(/\n/).length?function(e){for(var t=0,n=[],r=e.length;t<=r;){var o=e.indexOf("\n",t);-1==o&&(o=e.length);var i=e.slice(t,"\r"==e.charAt(o-1)?o-1:o),a=i.indexOf("\r");-1!=a?(n.push(i.slice(0,a)),t+=a+1):(n.push(i),t=o+1)}return n}:function(e){return e.split(/\r\n?|\n/)},Le=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(e){return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch(e){}return!(!t||t.parentElement()!=e)&&0!=t.compareEndPoints("StartToEnd",t)},Ie="oncopy"in(Me=T("div"))||(Me.setAttribute("oncopy","return;"),"function"==typeof Me.oncopy),Fe=null,_e={},Ne={};function Re(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),_e[e]=t}function De(e){if("string"==typeof e&&Ne.hasOwnProperty(e))e=Ne[e];else if(e&&"string"==typeof e.name&&Ne.hasOwnProperty(e.name)){var t=Ne[e.name];"string"==typeof t&&(t={name:t}),(e=X(t,e)).name=t.name}else{if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return De("application/xml");if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return De("application/json")}return"string"==typeof e?{name:e}:e||{name:"null"}}function Ve(e,t){t=De(t);var n=_e[t.name];if(!n)return Ve(e,"text/plain");var r=n(e,t);if(Be.hasOwnProperty(t.name)){var o=Be[t.name];for(var i in o)o.hasOwnProperty(i)&&(r.hasOwnProperty(i)&&(r["_"+i]=r[i]),r[i]=o[i])}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(var a in t.modeProps)r[a]=t.modeProps[a];return r}var Be={};function Ue(e,t){R(t,Be.hasOwnProperty(e)?Be[e]:Be[e]={})}function ze(e,t){if(!0===t)return t;if(e.copyState)return e.copyState(t);var n={};for(var r in t){var o=t[r];o instanceof Array&&(o=o.concat([])),n[r]=o}return n}function We(e,t){for(var n;e.innerMode&&(n=e.innerMode(t))&&n.mode!=e;)t=n.state,e=n.mode;return n||{mode:e,state:t}}function He(e,t,n){return!e.startState||e.startState(t,n)}var qe=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 Ge(e,t){if((t-=e.first)<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var n=e;!n.lines;)for(var r=0;;++r){var o=n.children[r],i=o.chunkSize();if(t<i){n=o;break}t-=i}return n.lines[t]}function $e(e,t,n){var r=[],o=t.line;return e.iter(t.line,n.line+1,(function(e){var i=e.text;o==n.line&&(i=i.slice(0,n.ch)),o==t.line&&(i=i.slice(t.ch)),r.push(i),++o})),r}function Ke(e,t,n){var r=[];return e.iter(t,n,(function(e){r.push(e.text)})),r}function Je(e,t){var n=t-e.height;if(n)for(var r=e;r;r=r.parent)r.height+=n}function Ye(e){if(null==e.parent)return null;for(var t=e.parent,n=B(t.lines,e),r=t.parent;r;t=r,r=r.parent)for(var o=0;r.children[o]!=t;++o)n+=r.children[o].chunkSize();return n+t.first}function Xe(e,t){var n=e.first;e:do{for(var r=0;r<e.children.length;++r){var o=e.children[r],i=o.height;if(t<i){e=o;continue e}t-=i,n+=o.chunkSize()}return n}while(!e.lines);for(var a=0;a<e.lines.length;++a){var s=e.lines[a].height;if(t<s)break;t-=s}return n+a}function Qe(e,t){return t>=e.first&&t<e.first+e.size}function Ze(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function et(e,t,n){if(void 0===n&&(n=null),!(this instanceof et))return new et(e,t,n);this.line=e,this.ch=t,this.sticky=n}function tt(e,t){return e.line-t.line||e.ch-t.ch}function nt(e,t){return e.sticky==t.sticky&&0==tt(e,t)}function rt(e){return et(e.line,e.ch)}function ot(e,t){return tt(e,t)<0?t:e}function it(e,t){return tt(e,t)<0?e:t}function at(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function st(e,t){if(t.line<e.first)return et(e.first,0);var n=e.first+e.size-1;return t.line>n?et(n,Ge(e,n).text.length):function(e,t){var n=e.ch;return null==n||n>t?et(e.line,t):n<0?et(e.line,0):e}(t,Ge(e,t.line).text.length)}function lt(e,t){for(var n=[],r=0;r<t.length;r++)n[r]=st(e,t[r]);return n}qe.prototype.eol=function(){return this.pos>=this.string.length},qe.prototype.sol=function(){return this.pos==this.lineStart},qe.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},qe.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},qe.prototype.eat=function(e){var t=this.string.charAt(this.pos);if("string"==typeof e?t==e:t&&(e.test?e.test(t):e(t)))return++this.pos,t},qe.prototype.eatWhile=function(e){for(var t=this.pos;this.eat(e););return this.pos>t},qe.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},qe.prototype.skipToEnd=function(){this.pos=this.string.length},qe.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},qe.prototype.backUp=function(e){this.pos-=e},qe.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=D(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?D(this.string,this.lineStart,this.tabSize):0)},qe.prototype.indentation=function(){return D(this.string,null,this.tabSize)-(this.lineStart?D(this.string,this.lineStart,this.tabSize):0)},qe.prototype.match=function(e,t,n){if("string"!=typeof e){var r=this.string.slice(this.pos).match(e);return r&&r.index>0?null:(r&&!1!==t&&(this.pos+=r[0].length),r)}var o=function(e){return n?e.toLowerCase():e};if(o(this.string.substr(this.pos,e.length))==o(e))return!1!==t&&(this.pos+=e.length),!0},qe.prototype.current=function(){return this.string.slice(this.start,this.pos)},qe.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},qe.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},qe.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};var ct=function(e,t){this.state=e,this.lookAhead=t},ut=function(e,t,n,r){this.state=t,this.doc=e,this.line=n,this.maxLookAhead=r||0,this.baseTokens=null,this.baseTokenPos=1};function ft(e,t,n,r){var o=[e.state.modeGen],i={};xt(e,t.text,e.doc.mode,n,(function(e,t){return o.push(e,t)}),i,r);for(var a=n.state,s=function(r){n.baseTokens=o;var s=e.state.overlays[r],l=1,c=0;n.state=!0,xt(e,t.text,s.mode,n,(function(e,t){for(var n=l;c<e;){var r=o[l];r>e&&o.splice(l,1,e,o[l+1],r),l+=2,c=Math.min(e,r)}if(t)if(s.opaque)o.splice(n,l-n,e,"overlay "+t),l=n+2;else for(;n<l;n+=2){var i=o[n+1];o[n+1]=(i?i+" ":"")+"overlay "+t}}),i),n.state=a,n.baseTokens=null,n.baseTokenPos=1},l=0;l<e.state.overlays.length;++l)s(l);return{styles:o,classes:i.bgClass||i.textClass?i:null}}function pt(e,t,n){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=dt(e,Ye(t)),o=t.text.length>e.options.maxHighlightLength&&ze(e.doc.mode,r.state),i=ft(e,t,r);o&&(r.state=o),t.stateAfter=r.save(!o),t.styles=i.styles,i.classes?t.styleClasses=i.classes:t.styleClasses&&(t.styleClasses=null),n===e.doc.highlightFrontier&&(e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier))}return t.styles}function dt(e,t,n){var r=e.doc,o=e.display;if(!r.mode.startState)return new ut(r,!0,t);var i=function(e,t,n){for(var r,o,i=e.doc,a=n?-1:t-(e.doc.mode.innerMode?1e3:100),s=t;s>a;--s){if(s<=i.first)return i.first;var l=Ge(i,s-1),c=l.stateAfter;if(c&&(!n||s+(c instanceof ct?c.lookAhead:0)<=i.modeFrontier))return s;var u=D(l.text,null,e.options.tabSize);(null==o||r>u)&&(o=s-1,r=u)}return o}(e,t,n),a=i>r.first&&Ge(r,i-1).stateAfter,s=a?ut.fromSaved(r,a,i):new ut(r,He(r.mode),i);return r.iter(i,t,(function(n){ht(e,n.text,s);var r=s.line;n.stateAfter=r==t-1||r%5==0||r>=o.viewFrom&&r<o.viewTo?s.save():null,s.nextLine()})),n&&(r.modeFrontier=s.line),s}function ht(e,t,n,r){var o=e.doc.mode,i=new qe(t,e.options.tabSize,n);for(i.start=i.pos=r||0,""==t&&vt(o,n.state);!i.eol();)gt(o,i,n.state),i.start=i.pos}function vt(e,t){if(e.blankLine)return e.blankLine(t);if(e.innerMode){var n=We(e,t);return n.mode.blankLine?n.mode.blankLine(n.state):void 0}}function gt(e,t,n,r){for(var o=0;o<10;o++){r&&(r[0]=We(e,n).mode);var i=e.token(t,n);if(t.pos>t.start)return i}throw new Error("Mode "+e.name+" failed to advance stream.")}ut.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return null!=t&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},ut.prototype.baseToken=function(e){if(!this.baseTokens)return null;for(;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}},ut.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},ut.fromSaved=function(e,t,n){return t instanceof ct?new ut(e,ze(e.mode,t.state),n,t.lookAhead):new ut(e,ze(e.mode,t),n)},ut.prototype.save=function(e){var t=!1!==e?ze(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new ct(t,this.maxLookAhead):t};var mt=function(e,t,n){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=n};function yt(e,t,n,r){var o,i,a=e.doc,s=a.mode,l=Ge(a,(t=st(a,t)).line),c=dt(e,t.line,n),u=new qe(l.text,e.options.tabSize,c);for(r&&(i=[]);(r||u.pos<t.ch)&&!u.eol();)u.start=u.pos,o=gt(s,u,c.state),r&&i.push(new mt(u,o,ze(a.mode,c.state)));return r?i:new mt(u,o,c.state)}function bt(e,t){if(e)for(;;){var n=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!n)break;e=e.slice(0,n.index)+e.slice(n.index+n[0].length);var r=n[1]?"bgClass":"textClass";null==t[r]?t[r]=n[2]:new RegExp("(?:^|\\s)"+n[2]+"(?:$|\\s)").test(t[r])||(t[r]+=" "+n[2])}return e}function xt(e,t,n,r,o,i,a){var s=n.flattenSpans;null==s&&(s=e.options.flattenSpans);var l,c=0,u=null,f=new qe(t,e.options.tabSize,r),p=e.options.addModeClass&&[null];for(""==t&&bt(vt(n,r.state),i);!f.eol();){if(f.pos>e.options.maxHighlightLength?(s=!1,a&&ht(e,t,r,f.pos),f.pos=t.length,l=null):l=bt(gt(n,f,r.state,p),i),p){var d=p[0].name;d&&(l="m-"+(l?d+" "+l:d))}if(!s||u!=l){for(;c<f.start;)o(c=Math.min(f.start,c+5e3),u);u=l}f.start=f.pos}for(;c<f.pos;){var h=Math.min(f.pos,c+5e3);o(h,u),c=h}}var wt=!1,kt=!1;function Ct(e,t,n){this.marker=e,this.from=t,this.to=n}function At(e,t){if(e)for(var n=0;n<e.length;++n){var r=e[n];if(r.marker==t)return r}}function Ot(e,t){for(var n,r=0;r<e.length;++r)e[r]!=t&&(n||(n=[])).push(e[r]);return n}function St(e,t){if(t.full)return null;var n=Qe(e,t.from.line)&&Ge(e,t.from.line).markedSpans,r=Qe(e,t.to.line)&&Ge(e,t.to.line).markedSpans;if(!n&&!r)return null;var o=t.from.ch,i=t.to.ch,a=0==tt(t.from,t.to),s=function(e,t,n){var r;if(e)for(var o=0;o<e.length;++o){var i=e[o],a=i.marker;if(null==i.from||(a.inclusiveLeft?i.from<=t:i.from<t)||i.from==t&&"bookmark"==a.type&&(!n||!i.marker.insertLeft)){var s=null==i.to||(a.inclusiveRight?i.to>=t:i.to>t);(r||(r=[])).push(new Ct(a,i.from,s?null:i.to))}}return r}(n,o,a),l=function(e,t,n){var r;if(e)for(var o=0;o<e.length;++o){var i=e[o],a=i.marker;if(null==i.to||(a.inclusiveRight?i.to>=t:i.to>t)||i.from==t&&"bookmark"==a.type&&(!n||i.marker.insertLeft)){var s=null==i.from||(a.inclusiveLeft?i.from<=t:i.from<t);(r||(r=[])).push(new Ct(a,s?null:i.from-t,null==i.to?null:i.to-t))}}return r}(r,i,a),c=1==t.text.length,u=K(t.text).length+(c?o:0);if(s)for(var f=0;f<s.length;++f){var p=s[f];if(null==p.to){var d=At(l,p.marker);d?c&&(p.to=null==d.to?null:d.to+u):p.to=o}}if(l)for(var h=0;h<l.length;++h){var v=l[h];null!=v.to&&(v.to+=u),null==v.from?At(s,v.marker)||(v.from=u,c&&(s||(s=[])).push(v)):(v.from+=u,c&&(s||(s=[])).push(v))}s&&(s=Et(s)),l&&l!=s&&(l=Et(l));var g=[s];if(!c){var m,y=t.text.length-2;if(y>0&&s)for(var b=0;b<s.length;++b)null==s[b].to&&(m||(m=[])).push(new Ct(s[b].marker,null,null));for(var x=0;x<y;++x)g.push(m);g.push(l)}return g}function Et(e){for(var t=0;t<e.length;++t){var n=e[t];null!=n.from&&n.from==n.to&&!1!==n.marker.clearWhenEmpty&&e.splice(t--,1)}return e.length?e:null}function jt(e){var t=e.markedSpans;if(t){for(var n=0;n<t.length;++n)t[n].marker.detachLine(e);e.markedSpans=null}}function Tt(e,t){if(t){for(var n=0;n<t.length;++n)t[n].marker.attachLine(e);e.markedSpans=t}}function Mt(e){return e.inclusiveLeft?-1:0}function Pt(e){return e.inclusiveRight?1:0}function Lt(e,t){var n=e.lines.length-t.lines.length;if(0!=n)return n;var r=e.find(),o=t.find(),i=tt(r.from,o.from)||Mt(e)-Mt(t);if(i)return-i;var a=tt(r.to,o.to)||Pt(e)-Pt(t);return a||t.id-e.id}function It(e,t){var n,r=kt&&e.markedSpans;if(r)for(var o=void 0,i=0;i<r.length;++i)(o=r[i]).marker.collapsed&&null==(t?o.from:o.to)&&(!n||Lt(n,o.marker)<0)&&(n=o.marker);return n}function Ft(e){return It(e,!0)}function _t(e){return It(e,!1)}function Nt(e,t){var n,r=kt&&e.markedSpans;if(r)for(var o=0;o<r.length;++o){var i=r[o];i.marker.collapsed&&(null==i.from||i.from<t)&&(null==i.to||i.to>t)&&(!n||Lt(n,i.marker)<0)&&(n=i.marker)}return n}function Rt(e,t,n,r,o){var i=Ge(e,t),a=kt&&i.markedSpans;if(a)for(var s=0;s<a.length;++s){var l=a[s];if(l.marker.collapsed){var c=l.marker.find(0),u=tt(c.from,n)||Mt(l.marker)-Mt(o),f=tt(c.to,r)||Pt(l.marker)-Pt(o);if(!(u>=0&&f<=0||u<=0&&f>=0)&&(u<=0&&(l.marker.inclusiveRight&&o.inclusiveLeft?tt(c.to,n)>=0:tt(c.to,n)>0)||u>=0&&(l.marker.inclusiveRight&&o.inclusiveLeft?tt(c.from,r)<=0:tt(c.from,r)<0)))return!0}}}function Dt(e){for(var t;t=Ft(e);)e=t.find(-1,!0).line;return e}function Vt(e,t){var n=Ge(e,t),r=Dt(n);return n==r?t:Ye(r)}function Bt(e,t){if(t>e.lastLine())return t;var n,r=Ge(e,t);if(!Ut(e,r))return t;for(;n=_t(r);)r=n.find(1,!0).line;return Ye(r)+1}function Ut(e,t){var n=kt&&t.markedSpans;if(n)for(var r=void 0,o=0;o<n.length;++o)if((r=n[o]).marker.collapsed){if(null==r.from)return!0;if(!r.marker.widgetNode&&0==r.from&&r.marker.inclusiveLeft&&zt(e,t,r))return!0}}function zt(e,t,n){if(null==n.to){var r=n.marker.find(1,!0);return zt(e,r.line,At(r.line.markedSpans,n.marker))}if(n.marker.inclusiveRight&&n.to==t.text.length)return!0;for(var o=void 0,i=0;i<t.markedSpans.length;++i)if((o=t.markedSpans[i]).marker.collapsed&&!o.marker.widgetNode&&o.from==n.to&&(null==o.to||o.to!=n.from)&&(o.marker.inclusiveLeft||n.marker.inclusiveRight)&&zt(e,t,o))return!0}function Wt(e){for(var t=0,n=(e=Dt(e)).parent,r=0;r<n.lines.length;++r){var o=n.lines[r];if(o==e)break;t+=o.height}for(var i=n.parent;i;i=(n=i).parent)for(var a=0;a<i.children.length;++a){var s=i.children[a];if(s==n)break;t+=s.height}return t}function Ht(e){if(0==e.height)return 0;for(var t,n=e.text.length,r=e;t=Ft(r);){var o=t.find(0,!0);r=o.from.line,n+=o.from.ch-o.to.ch}for(r=e;t=_t(r);){var i=t.find(0,!0);n-=r.text.length-i.from.ch,n+=(r=i.to.line).text.length-i.to.ch}return n}function qt(e){var t=e.display,n=e.doc;t.maxLine=Ge(n,n.first),t.maxLineLength=Ht(t.maxLine),t.maxLineChanged=!0,n.iter((function(e){var n=Ht(e);n>t.maxLineLength&&(t.maxLineLength=n,t.maxLine=e)}))}var Gt=function(e,t,n){this.text=e,Tt(this,t),this.height=n?n(this):1};function $t(e){e.parent=null,jt(e)}Gt.prototype.lineNo=function(){return Ye(this)},ye(Gt);var Kt={},Jt={};function Yt(e,t){if(!e||/^\s*$/.test(e))return null;var n=t.addModeClass?Jt:Kt;return n[e]||(n[e]=e.replace(/\S+/g,"cm-$&"))}function Xt(e,t){var n=M("span",null,null,l?"padding-right: .1px":null),r={pre:M("pre",[n],"CodeMirror-line"),content:n,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var o=0;o<=(t.rest?t.rest.length:0);o++){var i=o?t.rest[o-1]:t.line,a=void 0;r.pos=0,r.addToken=Zt,Te(e.display.measure)&&(a=ce(i,e.doc.direction))&&(r.addToken=en(r.addToken,a)),r.map=[],nn(i,r,pt(e,i,t!=e.display.externalMeasured&&Ye(i))),i.styleClasses&&(i.styleClasses.bgClass&&(r.bgClass=F(i.styleClasses.bgClass,r.bgClass||"")),i.styleClasses.textClass&&(r.textClass=F(i.styleClasses.textClass,r.textClass||""))),0==r.map.length&&r.map.push(0,0,r.content.appendChild(je(e.display.measure))),0==o?(t.measure.map=r.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(r.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(l){var s=r.content.lastChild;(/\bcm-tab\b/.test(s.className)||s.querySelector&&s.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return he(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=F(r.pre.className,r.textClass||"")),r}function Qt(e){var t=T("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Zt(e,t,n,r,o,i,l){if(t){var c,u=e.splitSpaces?function(e,t){if(e.length>1&&!/ /.test(e))return e;for(var n=t,r="",o=0;o<e.length;o++){var i=e.charAt(o);" "!=i||!n||o!=e.length-1&&32!=e.charCodeAt(o+1)||(i=" "),r+=i,n=" "==i}return r}(t,e.trailingSpace):t,f=e.cm.state.specialChars,p=!1;if(f.test(t)){c=document.createDocumentFragment();for(var d=0;;){f.lastIndex=d;var h=f.exec(t),v=h?h.index-d:t.length-d;if(v){var g=document.createTextNode(u.slice(d,d+v));a&&s<9?c.appendChild(T("span",[g])):c.appendChild(g),e.map.push(e.pos,e.pos+v,g),e.col+=v,e.pos+=v}if(!h)break;d+=v+1;var m=void 0;if("\t"==h[0]){var y=e.cm.options.tabSize,b=y-e.col%y;(m=c.appendChild(T("span",$(b),"cm-tab"))).setAttribute("role","presentation"),m.setAttribute("cm-text","\t"),e.col+=b}else"\r"==h[0]||"\n"==h[0]?((m=c.appendChild(T("span","\r"==h[0]?"␍":"","cm-invalidchar"))).setAttribute("cm-text",h[0]),e.col+=1):((m=e.cm.options.specialCharPlaceholder(h[0])).setAttribute("cm-text",h[0]),a&&s<9?c.appendChild(T("span",[m])):c.appendChild(m),e.col+=1);e.map.push(e.pos,e.pos+1,m),e.pos++}}else e.col+=t.length,c=document.createTextNode(u),e.map.push(e.pos,e.pos+t.length,c),a&&s<9&&(p=!0),e.pos+=t.length;if(e.trailingSpace=32==u.charCodeAt(t.length-1),n||r||o||p||i||l){var x=n||"";r&&(x+=r),o&&(x+=o);var w=T("span",[c],x,i);if(l)for(var k in l)l.hasOwnProperty(k)&&"style"!=k&&"class"!=k&&w.setAttribute(k,l[k]);return e.content.appendChild(w)}e.content.appendChild(c)}}function en(e,t){return function(n,r,o,i,a,s,l){o=o?o+" cm-force-border":"cm-force-border";for(var c=n.pos,u=c+r.length;;){for(var f=void 0,p=0;p<t.length&&!((f=t[p]).to>c&&f.from<=c);p++);if(f.to>=u)return e(n,r,o,i,a,s,l);e(n,r.slice(0,f.to-c),o,i,null,s,l),i=null,r=r.slice(f.to-c),c=f.to}}}function tn(e,t,n,r){var o=!r&&n.widgetNode;o&&e.map.push(e.pos,e.pos+t,o),!r&&e.cm.display.input.needsContentAttribute&&(o||(o=e.content.appendChild(document.createElement("span"))),o.setAttribute("cm-marker",n.id)),o&&(e.cm.display.input.setUneditable(o),e.content.appendChild(o)),e.pos+=t,e.trailingSpace=!1}function nn(e,t,n){var r=e.markedSpans,o=e.text,i=0;if(r)for(var a,s,l,c,u,f,p,d=o.length,h=0,v=1,g="",m=0;;){if(m==h){l=c=u=s="",p=null,f=null,m=1/0;for(var y=[],b=void 0,x=0;x<r.length;++x){var w=r[x],k=w.marker;if("bookmark"==k.type&&w.from==h&&k.widgetNode)y.push(k);else if(w.from<=h&&(null==w.to||w.to>h||k.collapsed&&w.to==h&&w.from==h)){if(null!=w.to&&w.to!=h&&m>w.to&&(m=w.to,c=""),k.className&&(l+=" "+k.className),k.css&&(s=(s?s+";":"")+k.css),k.startStyle&&w.from==h&&(u+=" "+k.startStyle),k.endStyle&&w.to==m&&(b||(b=[])).push(k.endStyle,w.to),k.title&&((p||(p={})).title=k.title),k.attributes)for(var C in k.attributes)(p||(p={}))[C]=k.attributes[C];k.collapsed&&(!f||Lt(f.marker,k)<0)&&(f=w)}else w.from>h&&m>w.from&&(m=w.from)}if(b)for(var A=0;A<b.length;A+=2)b[A+1]==m&&(c+=" "+b[A]);if(!f||f.from==h)for(var O=0;O<y.length;++O)tn(t,0,y[O]);if(f&&(f.from||0)==h){if(tn(t,(null==f.to?d+1:f.to)-h,f.marker,null==f.from),null==f.to)return;f.to==h&&(f=!1)}}if(h>=d)break;for(var S=Math.min(d,m);;){if(g){var E=h+g.length;if(!f){var j=E>S?g.slice(0,S-h):g;t.addToken(t,j,a?a+l:l,u,h+j.length==m?c:"",s,p)}if(E>=S){g=g.slice(S-h),h=S;break}h=E,u=""}g=o.slice(i,i=n[v++]),a=Yt(n[v++],t.cm.options)}}else for(var T=1;T<n.length;T+=2)t.addToken(t,o.slice(i,i=n[T]),Yt(n[T+1],t.cm.options))}function rn(e,t,n){this.line=t,this.rest=function(e){for(var t,n;t=_t(e);)e=t.find(1,!0).line,(n||(n=[])).push(e);return n}(t),this.size=this.rest?Ye(K(this.rest))-n+1:1,this.node=this.text=null,this.hidden=Ut(e,t)}function on(e,t,n){for(var r,o=[],i=t;i<n;i=r){var a=new rn(e.doc,Ge(e.doc,i),i);r=i+a.size,o.push(a)}return o}var an=null,sn=null;function ln(e,t){var n=pe(e,t);if(n.length){var r,o=Array.prototype.slice.call(arguments,2);an?r=an.delayedCallbacks:sn?r=sn:(r=sn=[],setTimeout(cn,0));for(var i=function(e){r.push((function(){return n[e].apply(null,o)}))},a=0;a<n.length;++a)i(a)}}function cn(){var e=sn;sn=null;for(var t=0;t<e.length;++t)e[t]()}function un(e,t,n,r){for(var o=0;o<t.changes.length;o++){var i=t.changes[o];"text"==i?dn(e,t):"gutter"==i?vn(e,t,n,r):"class"==i?hn(e,t):"widget"==i&&gn(e,t,r)}t.changes=null}function fn(e){return e.node==e.text&&(e.node=T("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),a&&s<8&&(e.node.style.zIndex=2)),e.node}function pn(e,t){var n=e.display.externalMeasured;return n&&n.line==t.line?(e.display.externalMeasured=null,t.measure=n.measure,n.built):Xt(e,t)}function dn(e,t){var n=t.text.className,r=pn(e,t);t.text==t.node&&(t.node=r.pre),t.text.parentNode.replaceChild(r.pre,t.text),t.text=r.pre,r.bgClass!=t.bgClass||r.textClass!=t.textClass?(t.bgClass=r.bgClass,t.textClass=r.textClass,hn(e,t)):n&&(t.text.className=n)}function hn(e,t){!function(e,t){var n=t.bgClass?t.bgClass+" "+(t.line.bgClass||""):t.line.bgClass;if(n&&(n+=" CodeMirror-linebackground"),t.background)n?t.background.className=n:(t.background.parentNode.removeChild(t.background),t.background=null);else if(n){var r=fn(t);t.background=r.insertBefore(T("div",null,n),r.firstChild),e.display.input.setUneditable(t.background)}}(e,t),t.line.wrapClass?fn(t).className=t.line.wrapClass:t.node!=t.text&&(t.node.className="");var n=t.textClass?t.textClass+" "+(t.line.textClass||""):t.line.textClass;t.text.className=n||""}function vn(e,t,n,r){if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass){var o=fn(t);t.gutterBackground=T("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px; width: "+r.gutterTotalWidth+"px"),e.display.input.setUneditable(t.gutterBackground),o.insertBefore(t.gutterBackground,t.text)}var i=t.line.gutterMarkers;if(e.options.lineNumbers||i){var a=fn(t),s=t.gutter=T("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(s.setAttribute("aria-hidden","true"),e.display.input.setUneditable(s),a.insertBefore(s,t.text),t.line.gutterClass&&(s.className+=" "+t.line.gutterClass),!e.options.lineNumbers||i&&i["CodeMirror-linenumbers"]||(t.lineNumber=s.appendChild(T("div",Ze(e.options,n),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),i)for(var l=0;l<e.display.gutterSpecs.length;++l){var c=e.display.gutterSpecs[l].className,u=i.hasOwnProperty(c)&&i[c];u&&s.appendChild(T("div",[u],"CodeMirror-gutter-elt","left: "+r.gutterLeft[c]+"px; width: "+r.gutterWidth[c]+"px"))}}}function gn(e,t,n){t.alignable&&(t.alignable=null);for(var r=A("CodeMirror-linewidget"),o=t.node.firstChild,i=void 0;o;o=i)i=o.nextSibling,r.test(o.className)&&t.node.removeChild(o);yn(e,t,n)}function mn(e,t,n,r){var o=pn(e,t);return t.text=t.node=o.pre,o.bgClass&&(t.bgClass=o.bgClass),o.textClass&&(t.textClass=o.textClass),hn(e,t),vn(e,t,n,r),yn(e,t,r),t.node}function yn(e,t,n){if(bn(e,t.line,t,n,!0),t.rest)for(var r=0;r<t.rest.length;r++)bn(e,t.rest[r],t,n,!1)}function bn(e,t,n,r,o){if(t.widgets)for(var i=fn(n),a=0,s=t.widgets;a<s.length;++a){var l=s[a],c=T("div",[l.node],"CodeMirror-linewidget"+(l.className?" "+l.className:""));l.handleMouseEvents||c.setAttribute("cm-ignore-events","true"),xn(l,c,n,r),e.display.input.setUneditable(c),o&&l.above?i.insertBefore(c,n.gutter||n.text):i.appendChild(c),ln(l,"redraw")}}function xn(e,t,n,r){if(e.noHScroll){(n.alignable||(n.alignable=[])).push(t);var o=r.wrapperWidth;t.style.left=r.fixedPos+"px",e.coverGutter||(o-=r.gutterTotalWidth,t.style.paddingLeft=r.gutterTotalWidth+"px"),t.style.width=o+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-r.gutterTotalWidth+"px"))}function wn(e){if(null!=e.height)return e.height;var t=e.doc.cm;if(!t)return 0;if(!P(document.body,e.node)){var n="position: relative;";e.coverGutter&&(n+="margin-left: -"+t.display.gutters.offsetWidth+"px;"),e.noHScroll&&(n+="width: "+t.display.wrapper.clientWidth+"px;"),j(t.display.measure,T("div",[e.node],null,n))}return e.height=e.node.parentNode.offsetHeight}function kn(e,t){for(var n=Ce(t);n!=e.wrapper;n=n.parentNode)if(!n||1==n.nodeType&&"true"==n.getAttribute("cm-ignore-events")||n.parentNode==e.sizer&&n!=e.mover)return!0}function Cn(e){return e.lineSpace.offsetTop}function An(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function On(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=j(e.measure,T("pre","x","CodeMirror-line-like")),n=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,r={left:parseInt(n.paddingLeft),right:parseInt(n.paddingRight)};return isNaN(r.left)||isNaN(r.right)||(e.cachedPaddingH=r),r}function Sn(e){return 50-e.display.nativeBarWidth}function En(e){return e.display.scroller.clientWidth-Sn(e)-e.display.barWidth}function jn(e){return e.display.scroller.clientHeight-Sn(e)-e.display.barHeight}function Tn(e,t,n){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var r=0;r<e.rest.length;r++)if(e.rest[r]==t)return{map:e.measure.maps[r],cache:e.measure.caches[r]};for(var o=0;o<e.rest.length;o++)if(Ye(e.rest[o])>n)return{map:e.measure.maps[o],cache:e.measure.caches[o],before:!0}}function Mn(e,t,n,r){return In(e,Ln(e,t),n,r)}function Pn(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[ur(e,t)];var n=e.display.externalMeasured;return n&&t>=n.lineN&&t<n.lineN+n.size?n:void 0}function Ln(e,t){var n=Ye(t),r=Pn(e,n);r&&!r.text?r=null:r&&r.changes&&(un(e,r,n,ir(e)),e.curOp.forceUpdate=!0),r||(r=function(e,t){var n=Ye(t=Dt(t)),r=e.display.externalMeasured=new rn(e.doc,t,n);r.lineN=n;var o=r.built=Xt(e,r);return r.text=o.pre,j(e.display.lineMeasure,o.pre),r}(e,t));var o=Tn(r,t,n);return{line:t,view:r,rect:null,map:o.map,cache:o.cache,before:o.before,hasHeights:!1}}function In(e,t,n,r,o){t.before&&(n=-1);var i,l=n+(r||"");return t.cache.hasOwnProperty(l)?i=t.cache[l]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(function(e,t,n){var r=e.options.lineWrapping,o=r&&En(e);if(!t.measure.heights||r&&t.measure.width!=o){var i=t.measure.heights=[];if(r){t.measure.width=o;for(var a=t.text.firstChild.getClientRects(),s=0;s<a.length-1;s++){var l=a[s],c=a[s+1];Math.abs(l.bottom-c.bottom)>2&&i.push((l.bottom+c.top)/2-n.top)}}i.push(n.bottom-n.top)}}(e,t.view,t.rect),t.hasHeights=!0),(i=function(e,t,n,r){var o,i=Nn(t.map,n,r),l=i.node,c=i.start,u=i.end,f=i.collapse;if(3==l.nodeType){for(var p=0;p<4;p++){for(;c&&re(t.line.text.charAt(i.coverStart+c));)--c;for(;i.coverStart+u<i.coverEnd&&re(t.line.text.charAt(i.coverStart+u));)++u;if((o=a&&s<9&&0==c&&u==i.coverEnd-i.coverStart?l.parentNode.getBoundingClientRect():Rn(O(l,c,u).getClientRects(),r)).left||o.right||0==c)break;u=c,c-=1,f="right"}a&&s<11&&(o=function(e,t){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!function(e){if(null!=Fe)return Fe;var t=j(e,T("span","x")),n=t.getBoundingClientRect(),r=O(t,0,1).getBoundingClientRect();return Fe=Math.abs(n.left-r.left)>1}(e))return t;var n=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*n,right:t.right*n,top:t.top*r,bottom:t.bottom*r}}(e.display.measure,o))}else{var d;c>0&&(f=r="right"),o=e.options.lineWrapping&&(d=l.getClientRects()).length>1?d["right"==r?d.length-1:0]:l.getBoundingClientRect()}if(a&&s<9&&!c&&(!o||!o.left&&!o.right)){var h=l.parentNode.getClientRects()[0];o=h?{left:h.left,right:h.left+or(e.display),top:h.top,bottom:h.bottom}:_n}for(var v=o.top-t.rect.top,g=o.bottom-t.rect.top,m=(v+g)/2,y=t.view.measure.heights,b=0;b<y.length-1&&!(m<y[b]);b++);var x=b?y[b-1]:0,w=y[b],k={left:("right"==f?o.right:o.left)-t.rect.left,right:("left"==f?o.left:o.right)-t.rect.left,top:x,bottom:w};return o.left||o.right||(k.bogus=!0),e.options.singleCursorHeightPerLine||(k.rtop=v,k.rbottom=g),k}(e,t,n,r)).bogus||(t.cache[l]=i)),{left:i.left,right:i.right,top:o?i.rtop:i.top,bottom:o?i.rbottom:i.bottom}}var Fn,_n={left:0,right:0,top:0,bottom:0};function Nn(e,t,n){for(var r,o,i,a,s,l,c=0;c<e.length;c+=3)if(s=e[c],l=e[c+1],t<s?(o=0,i=1,a="left"):t<l?i=1+(o=t-s):(c==e.length-3||t==l&&e[c+3]>t)&&(o=(i=l-s)-1,t>=l&&(a="right")),null!=o){if(r=e[c+2],s==l&&n==(r.insertLeft?"left":"right")&&(a=n),"left"==n&&0==o)for(;c&&e[c-2]==e[c-3]&&e[c-1].insertLeft;)r=e[2+(c-=3)],a="left";if("right"==n&&o==l-s)for(;c<e.length-3&&e[c+3]==e[c+4]&&!e[c+5].insertLeft;)r=e[(c+=3)+2],a="right";break}return{node:r,start:o,end:i,collapse:a,coverStart:s,coverEnd:l}}function Rn(e,t){var n=_n;if("left"==t)for(var r=0;r<e.length&&(n=e[r]).left==n.right;r++);else for(var o=e.length-1;o>=0&&(n=e[o]).left==n.right;o--);return n}function Dn(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function Vn(e){e.display.externalMeasure=null,E(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)Dn(e.display.view[t])}function Bn(e){Vn(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function Un(){return u&&g?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function zn(){return u&&g?-(document.body.getBoundingClientRect().top-parseInt(getComputedStyle(document.body).marginTop)):window.pageYOffset||(document.documentElement||document.body).scrollTop}function Wn(e){var t=0;if(e.widgets)for(var n=0;n<e.widgets.length;++n)e.widgets[n].above&&(t+=wn(e.widgets[n]));return t}function Hn(e,t,n,r,o){if(!o){var i=Wn(t);n.top+=i,n.bottom+=i}if("line"==r)return n;r||(r="local");var a=Wt(t);if("local"==r?a+=Cn(e.display):a-=e.display.viewOffset,"page"==r||"window"==r){var s=e.display.lineSpace.getBoundingClientRect();a+=s.top+("window"==r?0:zn());var l=s.left+("window"==r?0:Un());n.left+=l,n.right+=l}return n.top+=a,n.bottom+=a,n}function qn(e,t,n){if("div"==n)return t;var r=t.left,o=t.top;if("page"==n)r-=Un(),o-=zn();else if("local"==n||!n){var i=e.display.sizer.getBoundingClientRect();r+=i.left,o+=i.top}var a=e.display.lineSpace.getBoundingClientRect();return{left:r-a.left,top:o-a.top}}function Gn(e,t,n,r,o){return r||(r=Ge(e.doc,t.line)),Hn(e,r,Mn(e,r,t.ch,o),n)}function $n(e,t,n,r,o,i){function a(t,a){var s=In(e,o,t,a?"right":"left",i);return a?s.left=s.right:s.right=s.left,Hn(e,r,s,n)}r=r||Ge(e.doc,t.line),o||(o=Ln(e,r));var s=ce(r,e.doc.direction),l=t.ch,c=t.sticky;if(l>=r.text.length?(l=r.text.length,c="before"):l<=0&&(l=0,c="after"),!s)return a("before"==c?l-1:l,"before"==c);function u(e,t,n){return a(n?e-1:e,1==s[t].level!=n)}var f=se(s,l,c),p=ae,d=u(l,f,"before"==c);return null!=p&&(d.other=u(l,p,"before"!=c)),d}function Kn(e,t){var n=0;t=st(e.doc,t),e.options.lineWrapping||(n=or(e.display)*t.ch);var r=Ge(e.doc,t.line),o=Wt(r)+Cn(e.display);return{left:n,right:n,top:o,bottom:o+r.height}}function Jn(e,t,n,r,o){var i=et(e,t,n);return i.xRel=o,r&&(i.outside=r),i}function Yn(e,t,n){var r=e.doc;if((n+=e.display.viewOffset)<0)return Jn(r.first,0,null,-1,-1);var o=Xe(r,n),i=r.first+r.size-1;if(o>i)return Jn(r.first+r.size-1,Ge(r,i).text.length,null,1,1);t<0&&(t=0);for(var a=Ge(r,o);;){var s=er(e,a,o,t,n),l=Nt(a,s.ch+(s.xRel>0||s.outside>0?1:0));if(!l)return s;var c=l.find(1);if(c.line==o)return c;a=Ge(r,o=c.line)}}function Xn(e,t,n,r){r-=Wn(t);var o=t.text.length,i=ie((function(t){return In(e,n,t-1).bottom<=r}),o,0);return{begin:i,end:o=ie((function(t){return In(e,n,t).top>r}),i,o)}}function Qn(e,t,n,r){return n||(n=Ln(e,t)),Xn(e,t,n,Hn(e,t,In(e,n,r),"line").top)}function Zn(e,t,n,r){return!(e.bottom<=n)&&(e.top>n||(r?e.left:e.right)>t)}function er(e,t,n,r,o){o-=Wt(t);var i=Ln(e,t),a=Wn(t),s=0,l=t.text.length,c=!0,u=ce(t,e.doc.direction);if(u){var f=(e.options.lineWrapping?nr:tr)(e,t,n,i,u,r,o);s=(c=1!=f.level)?f.from:f.to-1,l=c?f.to:f.from-1}var p,d,h=null,v=null,g=ie((function(t){var n=In(e,i,t);return n.top+=a,n.bottom+=a,!!Zn(n,r,o,!1)&&(n.top<=o&&n.left<=r&&(h=t,v=n),!0)}),s,l),m=!1;if(v){var y=r-v.left<v.right-r,b=y==c;g=h+(b?0:1),d=b?"after":"before",p=y?v.left:v.right}else{c||g!=l&&g!=s||g++,d=0==g?"after":g==t.text.length?"before":In(e,i,g-(c?1:0)).bottom+a<=o==c?"after":"before";var x=$n(e,et(n,g,d),"line",t,i);p=x.left,m=o<x.top?-1:o>=x.bottom?1:0}return Jn(n,g=oe(t.text,g,1),d,m,r-p)}function tr(e,t,n,r,o,i,a){var s=ie((function(s){var l=o[s],c=1!=l.level;return Zn($n(e,et(n,c?l.to:l.from,c?"before":"after"),"line",t,r),i,a,!0)}),0,o.length-1),l=o[s];if(s>0){var c=1!=l.level,u=$n(e,et(n,c?l.from:l.to,c?"after":"before"),"line",t,r);Zn(u,i,a,!0)&&u.top>a&&(l=o[s-1])}return l}function nr(e,t,n,r,o,i,a){var s=Xn(e,t,r,a),l=s.begin,c=s.end;/\s/.test(t.text.charAt(c-1))&&c--;for(var u=null,f=null,p=0;p<o.length;p++){var d=o[p];if(!(d.from>=c||d.to<=l)){var h=In(e,r,1!=d.level?Math.min(c,d.to)-1:Math.max(l,d.from)).right,v=h<i?i-h+1e9:h-i;(!u||f>v)&&(u=d,f=v)}}return u||(u=o[o.length-1]),u.from<l&&(u={from:l,to:u.to,level:u.level}),u.to>c&&(u={from:u.from,to:c,level:u.level}),u}function rr(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Fn){Fn=T("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)Fn.appendChild(document.createTextNode("x")),Fn.appendChild(T("br"));Fn.appendChild(document.createTextNode("x"))}j(e.measure,Fn);var n=Fn.offsetHeight/50;return n>3&&(e.cachedTextHeight=n),E(e.measure),n||1}function or(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=T("span","xxxxxxxxxx"),n=T("pre",[t],"CodeMirror-line-like");j(e.measure,n);var r=t.getBoundingClientRect(),o=(r.right-r.left)/10;return o>2&&(e.cachedCharWidth=o),o||10}function ir(e){for(var t=e.display,n={},r={},o=t.gutters.clientLeft,i=t.gutters.firstChild,a=0;i;i=i.nextSibling,++a){var s=e.display.gutterSpecs[a].className;n[s]=i.offsetLeft+i.clientLeft+o,r[s]=i.clientWidth}return{fixedPos:ar(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:n,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function ar(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function sr(e){var t=rr(e.display),n=e.options.lineWrapping,r=n&&Math.max(5,e.display.scroller.clientWidth/or(e.display)-3);return function(o){if(Ut(e.doc,o))return 0;var i=0;if(o.widgets)for(var a=0;a<o.widgets.length;a++)o.widgets[a].height&&(i+=o.widgets[a].height);return n?i+(Math.ceil(o.text.length/r)||1)*t:i+t}}function lr(e){var t=e.doc,n=sr(e);t.iter((function(e){var t=n(e);t!=e.height&&Je(e,t)}))}function cr(e,t,n,r){var o=e.display;if(!n&&"true"==Ce(t).getAttribute("cm-not-content"))return null;var i,a,s=o.lineSpace.getBoundingClientRect();try{i=t.clientX-s.left,a=t.clientY-s.top}catch(e){return null}var l,c=Yn(e,i,a);if(r&&c.xRel>0&&(l=Ge(e.doc,c.line).text).length==c.ch){var u=D(l,l.length,e.options.tabSize)-l.length;c=et(c.line,Math.max(0,Math.round((i-On(e.display).left)/or(e.display))-u))}return c}function ur(e,t){if(t>=e.display.viewTo)return null;if((t-=e.display.viewFrom)<0)return null;for(var n=e.display.view,r=0;r<n.length;r++)if((t-=n[r].size)<0)return r}function fr(e,t,n,r){null==t&&(t=e.doc.first),null==n&&(n=e.doc.first+e.doc.size),r||(r=0);var o=e.display;if(r&&n<o.viewTo&&(null==o.updateLineNumbers||o.updateLineNumbers>t)&&(o.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=o.viewTo)kt&&Vt(e.doc,t)<o.viewTo&&dr(e);else if(n<=o.viewFrom)kt&&Bt(e.doc,n+r)>o.viewFrom?dr(e):(o.viewFrom+=r,o.viewTo+=r);else if(t<=o.viewFrom&&n>=o.viewTo)dr(e);else if(t<=o.viewFrom){var i=hr(e,n,n+r,1);i?(o.view=o.view.slice(i.index),o.viewFrom=i.lineN,o.viewTo+=r):dr(e)}else if(n>=o.viewTo){var a=hr(e,t,t,-1);a?(o.view=o.view.slice(0,a.index),o.viewTo=a.lineN):dr(e)}else{var s=hr(e,t,t,-1),l=hr(e,n,n+r,1);s&&l?(o.view=o.view.slice(0,s.index).concat(on(e,s.lineN,l.lineN)).concat(o.view.slice(l.index)),o.viewTo+=r):dr(e)}var c=o.externalMeasured;c&&(n<c.lineN?c.lineN+=r:t<c.lineN+c.size&&(o.externalMeasured=null))}function pr(e,t,n){e.curOp.viewChanged=!0;var r=e.display,o=e.display.externalMeasured;if(o&&t>=o.lineN&&t<o.lineN+o.size&&(r.externalMeasured=null),!(t<r.viewFrom||t>=r.viewTo)){var i=r.view[ur(e,t)];if(null!=i.node){var a=i.changes||(i.changes=[]);-1==B(a,n)&&a.push(n)}}}function dr(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function hr(e,t,n,r){var o,i=ur(e,t),a=e.display.view;if(!kt||n==e.doc.first+e.doc.size)return{index:i,lineN:n};for(var s=e.display.viewFrom,l=0;l<i;l++)s+=a[l].size;if(s!=t){if(r>0){if(i==a.length-1)return null;o=s+a[i].size-t,i++}else o=s-t;t+=o,n+=o}for(;Vt(e.doc,n)!=n;){if(i==(r<0?0:a.length-1))return null;n+=r*a[i-(r<0?1:0)].size,i+=r}return{index:i,lineN:n}}function vr(e){for(var t=e.display.view,n=0,r=0;r<t.length;r++){var o=t[r];o.hidden||o.node&&!o.changes||++n}return n}function gr(e){e.display.input.showSelection(e.display.input.prepareSelection())}function mr(e,t){void 0===t&&(t=!0);for(var n=e.doc,r={},o=r.cursors=document.createDocumentFragment(),i=r.selection=document.createDocumentFragment(),a=0;a<n.sel.ranges.length;a++)if(t||a!=n.sel.primIndex){var s=n.sel.ranges[a];if(!(s.from().line>=e.display.viewTo||s.to().line<e.display.viewFrom)){var l=s.empty();(l||e.options.showCursorWhenSelecting)&&yr(e,s.head,o),l||xr(e,s,i)}}return r}function yr(e,t,n){var r=$n(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),o=n.appendChild(T("div"," ","CodeMirror-cursor"));if(o.style.left=r.left+"px",o.style.top=r.top+"px",o.style.height=Math.max(0,r.bottom-r.top)*e.options.cursorHeight+"px",r.other){var i=n.appendChild(T("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));i.style.display="",i.style.left=r.other.left+"px",i.style.top=r.other.top+"px",i.style.height=.85*(r.other.bottom-r.other.top)+"px"}}function br(e,t){return e.top-t.top||e.left-t.left}function xr(e,t,n){var r=e.display,o=e.doc,i=document.createDocumentFragment(),a=On(e.display),s=a.left,l=Math.max(r.sizerWidth,En(e)-r.sizer.offsetLeft)-a.right,c="ltr"==o.direction;function u(e,t,n,r){t<0&&(t=0),t=Math.round(t),r=Math.round(r),i.appendChild(T("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px;\n top: "+t+"px; width: "+(null==n?l-e:n)+"px;\n height: "+(r-t)+"px"))}function f(t,n,r){var i,a,f=Ge(o,t),p=f.text.length;function d(n,r){return Gn(e,et(t,n),"div",f,r)}function h(t,n,r){var o=Qn(e,f,null,t),i="ltr"==n==("after"==r)?"left":"right";return d("after"==r?o.begin:o.end-(/\s/.test(f.text.charAt(o.end-1))?2:1),i)[i]}var v=ce(f,o.direction);return function(e,t,n,r){if(!e)return r(t,n,"ltr",0);for(var o=!1,i=0;i<e.length;++i){var a=e[i];(a.from<n&&a.to>t||t==n&&a.to==t)&&(r(Math.max(a.from,t),Math.min(a.to,n),1==a.level?"rtl":"ltr",i),o=!0)}o||r(t,n,"ltr")}(v,n||0,null==r?p:r,(function(e,t,o,f){var g="ltr"==o,m=d(e,g?"left":"right"),y=d(t-1,g?"right":"left"),b=null==n&&0==e,x=null==r&&t==p,w=0==f,k=!v||f==v.length-1;if(y.top-m.top<=3){var C=(c?x:b)&&k,A=(c?b:x)&&w?s:(g?m:y).left,O=C?l:(g?y:m).right;u(A,m.top,O-A,m.bottom)}else{var S,E,j,T;g?(S=c&&b&&w?s:m.left,E=c?l:h(e,o,"before"),j=c?s:h(t,o,"after"),T=c&&x&&k?l:y.right):(S=c?h(e,o,"before"):s,E=!c&&b&&w?l:m.right,j=!c&&x&&k?s:y.left,T=c?h(t,o,"after"):l),u(S,m.top,E-S,m.bottom),m.bottom<y.top&&u(s,m.bottom,null,y.top),u(j,y.top,T-j,y.bottom)}(!i||br(m,i)<0)&&(i=m),br(y,i)<0&&(i=y),(!a||br(m,a)<0)&&(a=m),br(y,a)<0&&(a=y)})),{start:i,end:a}}var p=t.from(),d=t.to();if(p.line==d.line)f(p.line,p.ch,d.ch);else{var h=Ge(o,p.line),v=Ge(o,d.line),g=Dt(h)==Dt(v),m=f(p.line,p.ch,g?h.text.length+1:null).end,y=f(d.line,g?0:null,d.ch).start;g&&(m.top<y.top-2?(u(m.right,m.top,null,m.bottom),u(s,y.top,y.left,y.bottom)):u(m.right,m.top,y.left-m.right,m.bottom)),m.bottom<y.top&&u(s,m.bottom,null,y.top)}n.appendChild(i)}function wr(e){if(e.state.focused){var t=e.display;clearInterval(t.blinker);var n=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval((function(){e.hasFocus()||Or(e),t.cursorDiv.style.visibility=(n=!n)?"":"hidden"}),e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function kr(e){e.hasFocus()||(e.display.input.focus(),e.state.focused||Ar(e))}function Cr(e){e.state.delayingBlurEvent=!0,setTimeout((function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,e.state.focused&&Or(e))}),100)}function Ar(e,t){e.state.delayingBlurEvent&&!e.state.draggingText&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(he(e,"focus",e,t),e.state.focused=!0,I(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),l&&setTimeout((function(){return e.display.input.reset(!0)}),20)),e.display.input.receivedFocus()),wr(e))}function Or(e,t){e.state.delayingBlurEvent||(e.state.focused&&(he(e,"blur",e,t),e.state.focused=!1,S(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout((function(){e.state.focused||(e.display.shift=!1)}),150))}function Sr(e){for(var t=e.display,n=t.lineDiv.offsetTop,r=0;r<t.view.length;r++){var o=t.view[r],i=e.options.lineWrapping,l=void 0,c=0;if(!o.hidden){if(a&&s<8){var u=o.node.offsetTop+o.node.offsetHeight;l=u-n,n=u}else{var f=o.node.getBoundingClientRect();l=f.bottom-f.top,!i&&o.text.firstChild&&(c=o.text.firstChild.getBoundingClientRect().right-f.left-1)}var p=o.line.height-l;if((p>.005||p<-.005)&&(Je(o.line,l),Er(o.line),o.rest))for(var d=0;d<o.rest.length;d++)Er(o.rest[d]);if(c>e.display.sizerWidth){var h=Math.ceil(c/or(e.display));h>e.display.maxLineLength&&(e.display.maxLineLength=h,e.display.maxLine=o.line,e.display.maxLineChanged=!0)}}}}function Er(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t){var n=e.widgets[t],r=n.node.parentNode;r&&(n.height=r.offsetHeight)}}function jr(e,t,n){var r=n&&null!=n.top?Math.max(0,n.top):e.scroller.scrollTop;r=Math.floor(r-Cn(e));var o=n&&null!=n.bottom?n.bottom:r+e.wrapper.clientHeight,i=Xe(t,r),a=Xe(t,o);if(n&&n.ensure){var s=n.ensure.from.line,l=n.ensure.to.line;s<i?(i=s,a=Xe(t,Wt(Ge(t,s))+e.wrapper.clientHeight)):Math.min(l,t.lastLine())>=a&&(i=Xe(t,Wt(Ge(t,l))-e.wrapper.clientHeight),a=l)}return{from:i,to:Math.max(a,i+1)}}function Tr(e,t){var n=e.display,r=rr(e.display);t.top<0&&(t.top=0);var o=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:n.scroller.scrollTop,i=jn(e),a={};t.bottom-t.top>i&&(t.bottom=t.top+i);var s=e.doc.height+An(n),l=t.top<r,c=t.bottom>s-r;if(t.top<o)a.scrollTop=l?0:t.top;else if(t.bottom>o+i){var u=Math.min(t.top,(c?s:t.bottom)-i);u!=o&&(a.scrollTop=u)}var f=e.options.fixedGutter?0:n.gutters.offsetWidth,p=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:n.scroller.scrollLeft-f,d=En(e)-n.gutters.offsetWidth,h=t.right-t.left>d;return h&&(t.right=t.left+d),t.left<10?a.scrollLeft=0:t.left<p?a.scrollLeft=Math.max(0,t.left+f-(h?0:10)):t.right>d+p-3&&(a.scrollLeft=t.right+(h?0:10)-d),a}function Mr(e,t){null!=t&&(Ir(e),e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+t)}function Pr(e){Ir(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function Lr(e,t,n){null==t&&null==n||Ir(e),null!=t&&(e.curOp.scrollLeft=t),null!=n&&(e.curOp.scrollTop=n)}function Ir(e){var t=e.curOp.scrollToPos;t&&(e.curOp.scrollToPos=null,Fr(e,Kn(e,t.from),Kn(e,t.to),t.margin))}function Fr(e,t,n,r){var o=Tr(e,{left:Math.min(t.left,n.left),top:Math.min(t.top,n.top)-r,right:Math.max(t.right,n.right),bottom:Math.max(t.bottom,n.bottom)+r});Lr(e,o.scrollLeft,o.scrollTop)}function _r(e,t){Math.abs(e.doc.scrollTop-t)<2||(n||lo(e,{top:t}),Nr(e,t,!0),n&&lo(e),ro(e,100))}function Nr(e,t,n){t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t)),(e.display.scroller.scrollTop!=t||n)&&(e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t))}function Rr(e,t,n,r){t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth)),(n?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!r||(e.doc.scrollLeft=t,fo(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function Dr(e){var t=e.display,n=t.gutters.offsetWidth,r=Math.round(e.doc.height+An(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:r,scrollHeight:r+Sn(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:n}}var Vr=function(e,t,n){this.cm=n;var r=this.vert=T("div",[T("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),o=this.horiz=T("div",[T("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=o.tabIndex=-1,e(r),e(o),fe(r,"scroll",(function(){r.clientHeight&&t(r.scrollTop,"vertical")})),fe(o,"scroll",(function(){o.clientWidth&&t(o.scrollLeft,"horizontal")})),this.checkedZeroWidth=!1,a&&s<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};Vr.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,n=e.scrollHeight>e.clientHeight+1,r=e.nativeBarWidth;if(n){this.vert.style.display="block",this.vert.style.bottom=t?r+"px":"0";var o=e.viewHeight-(t?r:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+o)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=n?r+"px":"0",this.horiz.style.left=e.barLeft+"px";var i=e.viewWidth-e.barLeft-(n?r:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+i)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(0==r&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:n?r:0,bottom:t?r:0}},Vr.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},Vr.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},Vr.prototype.zeroWidthHack=function(){var e=y&&!d?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new V,this.disableVert=new V},Vr.prototype.enableZeroWidthBar=function(e,t,n){e.style.pointerEvents="auto",t.set(1e3,(function r(){var o=e.getBoundingClientRect();("vert"==n?document.elementFromPoint(o.right-1,(o.top+o.bottom)/2):document.elementFromPoint((o.right+o.left)/2,o.bottom-1))!=e?e.style.pointerEvents="none":t.set(1e3,r)}))},Vr.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var Br=function(){};function Ur(e,t){t||(t=Dr(e));var n=e.display.barWidth,r=e.display.barHeight;zr(e,t);for(var o=0;o<4&&n!=e.display.barWidth||r!=e.display.barHeight;o++)n!=e.display.barWidth&&e.options.lineWrapping&&Sr(e),zr(e,Dr(e)),n=e.display.barWidth,r=e.display.barHeight}function zr(e,t){var n=e.display,r=n.scrollbars.update(t);n.sizer.style.paddingRight=(n.barWidth=r.right)+"px",n.sizer.style.paddingBottom=(n.barHeight=r.bottom)+"px",n.heightForcer.style.borderBottom=r.bottom+"px solid transparent",r.right&&r.bottom?(n.scrollbarFiller.style.display="block",n.scrollbarFiller.style.height=r.bottom+"px",n.scrollbarFiller.style.width=r.right+"px"):n.scrollbarFiller.style.display="",r.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(n.gutterFiller.style.display="block",n.gutterFiller.style.height=r.bottom+"px",n.gutterFiller.style.width=t.gutterWidth+"px"):n.gutterFiller.style.display=""}Br.prototype.update=function(){return{bottom:0,right:0}},Br.prototype.setScrollLeft=function(){},Br.prototype.setScrollTop=function(){},Br.prototype.clear=function(){};var Wr={native:Vr,null:Br};function Hr(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&S(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new Wr[e.options.scrollbarStyle]((function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),fe(t,"mousedown",(function(){e.state.focused&&setTimeout((function(){return e.display.input.focus()}),0)})),t.setAttribute("cm-not-content","true")}),(function(t,n){"horizontal"==n?Rr(e,t):_r(e,t)}),e),e.display.scrollbars.addClass&&I(e.display.wrapper,e.display.scrollbars.addClass)}var qr=0;function Gr(e){var t;e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++qr,markArrays:null},t=e.curOp,an?an.ops.push(t):t.ownsGroup=an={ops:[t],delayedCallbacks:[]}}function $r(e){var t=e.curOp;t&&function(e,t){var n=e.ownsGroup;if(n)try{!function(e){var t=e.delayedCallbacks,n=0;do{for(;n<t.length;n++)t[n].call(null);for(var r=0;r<e.ops.length;r++){var o=e.ops[r];if(o.cursorActivityHandlers)for(;o.cursorActivityCalled<o.cursorActivityHandlers.length;)o.cursorActivityHandlers[o.cursorActivityCalled++].call(null,o.cm)}}while(n<t.length)}(n)}finally{an=null,t(n)}}(t,(function(e){for(var t=0;t<e.ops.length;t++)e.ops[t].cm.curOp=null;!function(e){for(var t=e.ops,n=0;n<t.length;n++)Kr(t[n]);for(var r=0;r<t.length;r++)Jr(t[r]);for(var o=0;o<t.length;o++)Yr(t[o]);for(var i=0;i<t.length;i++)Xr(t[i]);for(var a=0;a<t.length;a++)Qr(t[a])}(e)}))}function Kr(e){var t=e.cm,n=t.display;!function(e){var t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=Sn(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=Sn(e)+"px",t.scrollbarsClipped=!0)}(t),e.updateMaxLine&&qt(t),e.mustUpdate=e.viewChanged||e.forceUpdate||null!=e.scrollTop||e.scrollToPos&&(e.scrollToPos.from.line<n.viewFrom||e.scrollToPos.to.line>=n.viewTo)||n.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new io(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function Jr(e){e.updatedDisplay=e.mustUpdate&&ao(e.cm,e.update)}function Yr(e){var t=e.cm,n=t.display;e.updatedDisplay&&Sr(t),e.barMeasure=Dr(t),n.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=Mn(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+Sn(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,n.sizer.offsetLeft+e.adjustWidthTo-En(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=n.input.prepareSelection())}function Xr(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&Rr(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1);var n=e.focus&&e.focus==L();e.preparedSelection&&t.display.input.showSelection(e.preparedSelection,n),(e.updatedDisplay||e.startHeight!=t.doc.height)&&Ur(t,e.barMeasure),e.updatedDisplay&&uo(t,e.barMeasure),e.selectionChanged&&wr(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),n&&kr(e.cm)}function Qr(e){var t=e.cm,n=t.display,r=t.doc;e.updatedDisplay&&so(t,e.update),null==n.wheelStartX||null==e.scrollTop&&null==e.scrollLeft&&!e.scrollToPos||(n.wheelStartX=n.wheelStartY=null),null!=e.scrollTop&&Nr(t,e.scrollTop,e.forceScroll),null!=e.scrollLeft&&Rr(t,e.scrollLeft,!0,!0),e.scrollToPos&&function(e,t){if(!ve(e,"scrollCursorIntoView")){var n=e.display,r=n.sizer.getBoundingClientRect(),o=null;if(t.top+r.top<0?o=!0:t.bottom+r.top>(window.innerHeight||document.documentElement.clientHeight)&&(o=!1),null!=o&&!h){var i=T("div","",null,"position: absolute;\n top: "+(t.top-n.viewOffset-Cn(e.display))+"px;\n height: "+(t.bottom-t.top+Sn(e)+n.barHeight)+"px;\n left: "+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(i),i.scrollIntoView(o),e.display.lineSpace.removeChild(i)}}}(t,function(e,t,n,r){var o;null==r&&(r=0),e.options.lineWrapping||t!=n||(n="before"==t.sticky?et(t.line,t.ch+1,"before"):t,t=t.ch?et(t.line,"before"==t.sticky?t.ch-1:t.ch,"after"):t);for(var i=0;i<5;i++){var a=!1,s=$n(e,t),l=n&&n!=t?$n(e,n):s,c=Tr(e,o={left:Math.min(s.left,l.left),top:Math.min(s.top,l.top)-r,right:Math.max(s.left,l.left),bottom:Math.max(s.bottom,l.bottom)+r}),u=e.doc.scrollTop,f=e.doc.scrollLeft;if(null!=c.scrollTop&&(_r(e,c.scrollTop),Math.abs(e.doc.scrollTop-u)>1&&(a=!0)),null!=c.scrollLeft&&(Rr(e,c.scrollLeft),Math.abs(e.doc.scrollLeft-f)>1&&(a=!0)),!a)break}return o}(t,st(r,e.scrollToPos.from),st(r,e.scrollToPos.to),e.scrollToPos.margin));var o=e.maybeHiddenMarkers,i=e.maybeUnhiddenMarkers;if(o)for(var a=0;a<o.length;++a)o[a].lines.length||he(o[a],"hide");if(i)for(var s=0;s<i.length;++s)i[s].lines.length&&he(i[s],"unhide");n.wrapper.offsetHeight&&(r.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&he(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function Zr(e,t){if(e.curOp)return t();Gr(e);try{return t()}finally{$r(e)}}function eo(e,t){return function(){if(e.curOp)return t.apply(e,arguments);Gr(e);try{return t.apply(e,arguments)}finally{$r(e)}}}function to(e){return function(){if(this.curOp)return e.apply(this,arguments);Gr(this);try{return e.apply(this,arguments)}finally{$r(this)}}}function no(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);Gr(t);try{return e.apply(this,arguments)}finally{$r(t)}}}function ro(e,t){e.doc.highlightFrontier<e.display.viewTo&&e.state.highlight.set(t,N(oo,e))}function oo(e){var t=e.doc;if(!(t.highlightFrontier>=e.display.viewTo)){var n=+new Date+e.options.workTime,r=dt(e,t.highlightFrontier),o=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),(function(i){if(r.line>=e.display.viewFrom){var a=i.styles,s=i.text.length>e.options.maxHighlightLength?ze(t.mode,r.state):null,l=ft(e,i,r,!0);s&&(r.state=s),i.styles=l.styles;var c=i.styleClasses,u=l.classes;u?i.styleClasses=u:c&&(i.styleClasses=null);for(var f=!a||a.length!=i.styles.length||c!=u&&(!c||!u||c.bgClass!=u.bgClass||c.textClass!=u.textClass),p=0;!f&&p<a.length;++p)f=a[p]!=i.styles[p];f&&o.push(r.line),i.stateAfter=r.save(),r.nextLine()}else i.text.length<=e.options.maxHighlightLength&&ht(e,i.text,r),i.stateAfter=r.line%5==0?r.save():null,r.nextLine();if(+new Date>n)return ro(e,e.options.workDelay),!0})),t.highlightFrontier=r.line,t.modeFrontier=Math.max(t.modeFrontier,r.line),o.length&&Zr(e,(function(){for(var t=0;t<o.length;t++)pr(e,o[t],"text")}))}}var io=function(e,t,n){var r=e.display;this.viewport=t,this.visible=jr(r,e.doc,t),this.editorIsHidden=!r.wrapper.offsetWidth,this.wrapperHeight=r.wrapper.clientHeight,this.wrapperWidth=r.wrapper.clientWidth,this.oldDisplayWidth=En(e),this.force=n,this.dims=ir(e),this.events=[]};function ao(e,t){var n=e.display,r=e.doc;if(t.editorIsHidden)return dr(e),!1;if(!t.force&&t.visible.from>=n.viewFrom&&t.visible.to<=n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&0==vr(e))return!1;po(e)&&(dr(e),t.dims=ir(e));var o=r.first+r.size,i=Math.max(t.visible.from-e.options.viewportMargin,r.first),a=Math.min(o,t.visible.to+e.options.viewportMargin);n.viewFrom<i&&i-n.viewFrom<20&&(i=Math.max(r.first,n.viewFrom)),n.viewTo>a&&n.viewTo-a<20&&(a=Math.min(o,n.viewTo)),kt&&(i=Vt(e.doc,i),a=Bt(e.doc,a));var s=i!=n.viewFrom||a!=n.viewTo||n.lastWrapHeight!=t.wrapperHeight||n.lastWrapWidth!=t.wrapperWidth;!function(e,t,n){var r=e.display;0==r.view.length||t>=r.viewTo||n<=r.viewFrom?(r.view=on(e,t,n),r.viewFrom=t):(r.viewFrom>t?r.view=on(e,t,r.viewFrom).concat(r.view):r.viewFrom<t&&(r.view=r.view.slice(ur(e,t))),r.viewFrom=t,r.viewTo<n?r.view=r.view.concat(on(e,r.viewTo,n)):r.viewTo>n&&(r.view=r.view.slice(0,ur(e,n)))),r.viewTo=n}(e,i,a),n.viewOffset=Wt(Ge(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var c=vr(e);if(!s&&0==c&&!t.force&&n.renderedView==n.view&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo))return!1;var u=function(e){if(e.hasFocus())return null;var t=L();if(!t||!P(e.display.lineDiv,t))return null;var n={activeElt:t};if(window.getSelection){var r=window.getSelection();r.anchorNode&&r.extend&&P(e.display.lineDiv,r.anchorNode)&&(n.anchorNode=r.anchorNode,n.anchorOffset=r.anchorOffset,n.focusNode=r.focusNode,n.focusOffset=r.focusOffset)}return n}(e);return c>4&&(n.lineDiv.style.display="none"),function(e,t,n){var r=e.display,o=e.options.lineNumbers,i=r.lineDiv,a=i.firstChild;function s(t){var n=t.nextSibling;return l&&y&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),n}for(var c=r.view,u=r.viewFrom,f=0;f<c.length;f++){var p=c[f];if(p.hidden);else if(p.node&&p.node.parentNode==i){for(;a!=p.node;)a=s(a);var d=o&&null!=t&&t<=u&&p.lineNumber;p.changes&&(B(p.changes,"gutter")>-1&&(d=!1),un(e,p,u,n)),d&&(E(p.lineNumber),p.lineNumber.appendChild(document.createTextNode(Ze(e.options,u)))),a=p.node.nextSibling}else{var h=mn(e,p,u,n);i.insertBefore(h,a)}u+=p.size}for(;a;)a=s(a)}(e,n.updateLineNumbers,t.dims),c>4&&(n.lineDiv.style.display=""),n.renderedView=n.view,function(e){if(e&&e.activeElt&&e.activeElt!=L()&&(e.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(e.activeElt.nodeName)&&e.anchorNode&&P(document.body,e.anchorNode)&&P(document.body,e.focusNode))){var t=window.getSelection(),n=document.createRange();n.setEnd(e.anchorNode,e.anchorOffset),n.collapse(!1),t.removeAllRanges(),t.addRange(n),t.extend(e.focusNode,e.focusOffset)}}(u),E(n.cursorDiv),E(n.selectionDiv),n.gutters.style.height=n.sizer.style.minHeight=0,s&&(n.lastWrapHeight=t.wrapperHeight,n.lastWrapWidth=t.wrapperWidth,ro(e,400)),n.updateLineNumbers=null,!0}function so(e,t){for(var n=t.viewport,r=!0;;r=!1){if(r&&e.options.lineWrapping&&t.oldDisplayWidth!=En(e))r&&(t.visible=jr(e.display,e.doc,n));else if(n&&null!=n.top&&(n={top:Math.min(e.doc.height+An(e.display)-jn(e),n.top)}),t.visible=jr(e.display,e.doc,n),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break;if(!ao(e,t))break;Sr(e);var o=Dr(e);gr(e),Ur(e,o),uo(e,o),t.force=!1}t.signal(e,"update",e),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 lo(e,t){var n=new io(e,t);if(ao(e,n)){Sr(e),so(e,n);var r=Dr(e);gr(e),Ur(e,r),uo(e,r),n.finish()}}function co(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px",ln(e,"gutterChanged",e)}function uo(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+Sn(e)+"px"}function fo(e){var t=e.display,n=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var r=ar(t)-t.scroller.scrollLeft+e.doc.scrollLeft,o=t.gutters.offsetWidth,i=r+"px",a=0;a<n.length;a++)if(!n[a].hidden){e.options.fixedGutter&&(n[a].gutter&&(n[a].gutter.style.left=i),n[a].gutterBackground&&(n[a].gutterBackground.style.left=i));var s=n[a].alignable;if(s)for(var l=0;l<s.length;l++)s[l].style.left=i}e.options.fixedGutter&&(t.gutters.style.left=r+o+"px")}}function po(e){if(!e.options.lineNumbers)return!1;var t=e.doc,n=Ze(e.options,t.first+t.size-1),r=e.display;if(n.length!=r.lineNumChars){var o=r.measure.appendChild(T("div",[T("div",n)],"CodeMirror-linenumber CodeMirror-gutter-elt")),i=o.firstChild.offsetWidth,a=o.offsetWidth-i;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(i,r.lineGutter.offsetWidth-a)+1,r.lineNumWidth=r.lineNumInnerWidth+a,r.lineNumChars=r.lineNumInnerWidth?n.length:-1,r.lineGutter.style.width=r.lineNumWidth+"px",co(e.display),!0}return!1}function ho(e,t){for(var n=[],r=!1,o=0;o<e.length;o++){var i=e[o],a=null;if("string"!=typeof i&&(a=i.style,i=i.className),"CodeMirror-linenumbers"==i){if(!t)continue;r=!0}n.push({className:i,style:a})}return t&&!r&&n.push({className:"CodeMirror-linenumbers",style:null}),n}function vo(e){var t=e.gutters,n=e.gutterSpecs;E(t),e.lineGutter=null;for(var r=0;r<n.length;++r){var o=n[r],i=o.className,a=o.style,s=t.appendChild(T("div",null,"CodeMirror-gutter "+i));a&&(s.style.cssText=a),"CodeMirror-linenumbers"==i&&(e.lineGutter=s,s.style.width=(e.lineNumWidth||1)+"px")}t.style.display=n.length?"":"none",co(e)}function go(e){vo(e.display),fr(e),fo(e)}function mo(e,t,r,o){var i=this;this.input=r,i.scrollbarFiller=T("div",null,"CodeMirror-scrollbar-filler"),i.scrollbarFiller.setAttribute("cm-not-content","true"),i.gutterFiller=T("div",null,"CodeMirror-gutter-filler"),i.gutterFiller.setAttribute("cm-not-content","true"),i.lineDiv=M("div",null,"CodeMirror-code"),i.selectionDiv=T("div",null,null,"position: relative; z-index: 1"),i.cursorDiv=T("div",null,"CodeMirror-cursors"),i.measure=T("div",null,"CodeMirror-measure"),i.lineMeasure=T("div",null,"CodeMirror-measure"),i.lineSpace=M("div",[i.measure,i.lineMeasure,i.selectionDiv,i.cursorDiv,i.lineDiv],null,"position: relative; outline: none");var c=M("div",[i.lineSpace],"CodeMirror-lines");i.mover=T("div",[c],null,"position: relative"),i.sizer=T("div",[i.mover],"CodeMirror-sizer"),i.sizerWidth=null,i.heightForcer=T("div",null,null,"position: absolute; height: 50px; width: 1px;"),i.gutters=T("div",null,"CodeMirror-gutters"),i.lineGutter=null,i.scroller=T("div",[i.sizer,i.heightForcer,i.gutters],"CodeMirror-scroll"),i.scroller.setAttribute("tabIndex","-1"),i.wrapper=T("div",[i.scrollbarFiller,i.gutterFiller,i.scroller],"CodeMirror"),a&&s<8&&(i.gutters.style.zIndex=-1,i.scroller.style.paddingRight=0),l||n&&m||(i.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(i.wrapper):e(i.wrapper)),i.viewFrom=i.viewTo=t.first,i.reportedViewFrom=i.reportedViewTo=t.first,i.view=[],i.renderedView=null,i.externalMeasured=null,i.viewOffset=0,i.lastWrapHeight=i.lastWrapWidth=0,i.updateLineNumbers=null,i.nativeBarWidth=i.barHeight=i.barWidth=0,i.scrollbarsClipped=!1,i.lineNumWidth=i.lineNumInnerWidth=i.lineNumChars=null,i.alignWidgets=!1,i.cachedCharWidth=i.cachedTextHeight=i.cachedPaddingH=null,i.maxLine=null,i.maxLineLength=0,i.maxLineChanged=!1,i.wheelDX=i.wheelDY=i.wheelStartX=i.wheelStartY=null,i.shift=!1,i.selForContextMenu=null,i.activeTouch=null,i.gutterSpecs=ho(o.gutters,o.lineNumbers),vo(i),r.init(i)}io.prototype.signal=function(e,t){me(e,t)&&this.events.push(arguments)},io.prototype.finish=function(){for(var e=0;e<this.events.length;e++)he.apply(null,this.events[e])};var yo=0,bo=null;function xo(e){var t=e.wheelDeltaX,n=e.wheelDeltaY;return null==t&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),null==n&&e.detail&&e.axis==e.VERTICAL_AXIS?n=e.detail:null==n&&(n=e.wheelDelta),{x:t,y:n}}function wo(e){var t=xo(e);return t.x*=bo,t.y*=bo,t}function ko(e,t){var r=xo(t),o=r.x,i=r.y,a=e.display,s=a.scroller,c=s.scrollWidth>s.clientWidth,u=s.scrollHeight>s.clientHeight;if(o&&c||i&&u){if(i&&y&&l)e:for(var p=t.target,d=a.view;p!=s;p=p.parentNode)for(var h=0;h<d.length;h++)if(d[h].node==p){e.display.currentWheelTarget=p;break e}if(o&&!n&&!f&&null!=bo)return i&&u&&_r(e,Math.max(0,s.scrollTop+i*bo)),Rr(e,Math.max(0,s.scrollLeft+o*bo)),(!i||i&&u)&&be(t),void(a.wheelStartX=null);if(i&&null!=bo){var v=i*bo,g=e.doc.scrollTop,m=g+a.wrapper.clientHeight;v<0?g=Math.max(0,g+v-50):m=Math.min(e.doc.height,m+v+50),lo(e,{top:g,bottom:m})}yo<20&&(null==a.wheelStartX?(a.wheelStartX=s.scrollLeft,a.wheelStartY=s.scrollTop,a.wheelDX=o,a.wheelDY=i,setTimeout((function(){if(null!=a.wheelStartX){var e=s.scrollLeft-a.wheelStartX,t=s.scrollTop-a.wheelStartY,n=t&&a.wheelDY&&t/a.wheelDY||e&&a.wheelDX&&e/a.wheelDX;a.wheelStartX=a.wheelStartY=null,n&&(bo=(bo*yo+n)/(yo+1),++yo)}}),200)):(a.wheelDX+=o,a.wheelDY+=i))}}a?bo=-.53:n?bo=15:u?bo=-.7:p&&(bo=-1/3);var Co=function(e,t){this.ranges=e,this.primIndex=t};Co.prototype.primary=function(){return this.ranges[this.primIndex]},Co.prototype.equals=function(e){if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(var t=0;t<this.ranges.length;t++){var n=this.ranges[t],r=e.ranges[t];if(!nt(n.anchor,r.anchor)||!nt(n.head,r.head))return!1}return!0},Co.prototype.deepCopy=function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new Ao(rt(this.ranges[t].anchor),rt(this.ranges[t].head));return new Co(e,this.primIndex)},Co.prototype.somethingSelected=function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},Co.prototype.contains=function(e,t){t||(t=e);for(var n=0;n<this.ranges.length;n++){var r=this.ranges[n];if(tt(t,r.from())>=0&&tt(e,r.to())<=0)return n}return-1};var Ao=function(e,t){this.anchor=e,this.head=t};function Oo(e,t,n){var r=e&&e.options.selectionsMayTouch,o=t[n];t.sort((function(e,t){return tt(e.from(),t.from())})),n=B(t,o);for(var i=1;i<t.length;i++){var a=t[i],s=t[i-1],l=tt(s.to(),a.from());if(r&&!a.empty()?l>0:l>=0){var c=it(s.from(),a.from()),u=ot(s.to(),a.to()),f=s.empty()?a.from()==a.head:s.from()==s.head;i<=n&&--n,t.splice(--i,2,new Ao(f?u:c,f?c:u))}}return new Co(t,n)}function So(e,t){return new Co([new Ao(e,t||e)],0)}function Eo(e){return e.text?et(e.from.line+e.text.length-1,K(e.text).length+(1==e.text.length?e.from.ch:0)):e.to}function jo(e,t){if(tt(e,t.from)<0)return e;if(tt(e,t.to)<=0)return Eo(t);var n=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=Eo(t).ch-t.to.ch),et(n,r)}function To(e,t){for(var n=[],r=0;r<e.sel.ranges.length;r++){var o=e.sel.ranges[r];n.push(new Ao(jo(o.anchor,t),jo(o.head,t)))}return Oo(e.cm,n,e.sel.primIndex)}function Mo(e,t,n){return e.line==t.line?et(n.line,e.ch-t.ch+n.ch):et(n.line+(e.line-t.line),e.ch)}function Po(e){e.doc.mode=Ve(e.options,e.doc.modeOption),Lo(e)}function Lo(e){e.doc.iter((function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)})),e.doc.modeFrontier=e.doc.highlightFrontier=e.doc.first,ro(e,100),e.state.modeGen++,e.curOp&&fr(e)}function Io(e,t){return 0==t.from.ch&&0==t.to.ch&&""==K(t.text)&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Fo(e,t,n,r){function o(e){return n?n[e]:null}function i(e,n,o){!function(e,t,n,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),null!=e.order&&(e.order=null),jt(e),Tt(e,n);var o=r?r(e):1;o!=e.height&&Je(e,o)}(e,n,o,r),ln(e,"change",e,t)}function a(e,t){for(var n=[],i=e;i<t;++i)n.push(new Gt(c[i],o(i),r));return n}var s=t.from,l=t.to,c=t.text,u=Ge(e,s.line),f=Ge(e,l.line),p=K(c),d=o(c.length-1),h=l.line-s.line;if(t.full)e.insert(0,a(0,c.length)),e.remove(c.length,e.size-c.length);else if(Io(e,t)){var v=a(0,c.length-1);i(f,f.text,d),h&&e.remove(s.line,h),v.length&&e.insert(s.line,v)}else if(u==f)if(1==c.length)i(u,u.text.slice(0,s.ch)+p+u.text.slice(l.ch),d);else{var g=a(1,c.length-1);g.push(new Gt(p+u.text.slice(l.ch),d,r)),i(u,u.text.slice(0,s.ch)+c[0],o(0)),e.insert(s.line+1,g)}else if(1==c.length)i(u,u.text.slice(0,s.ch)+c[0]+f.text.slice(l.ch),o(0)),e.remove(s.line+1,h);else{i(u,u.text.slice(0,s.ch)+c[0],o(0)),i(f,p+f.text.slice(l.ch),d);var m=a(1,c.length-1);h>1&&e.remove(s.line+1,h-1),e.insert(s.line+1,m)}ln(e,"change",e,t)}function _o(e,t,n){!function e(r,o,i){if(r.linked)for(var a=0;a<r.linked.length;++a){var s=r.linked[a];if(s.doc!=o){var l=i&&s.sharedHist;n&&!l||(t(s.doc,l),e(s.doc,r,l))}}}(e,null,!0)}function No(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,lr(e),Po(e),Ro(e),e.options.direction=t.direction,e.options.lineWrapping||qt(e),e.options.mode=t.modeOption,fr(e)}function Ro(e){("rtl"==e.doc.direction?I:S)(e.display.lineDiv,"CodeMirror-rtl")}function Do(e){this.done=[],this.undone=[],this.undoDepth=e?e.undoDepth:1/0,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e?e.maxGeneration:1}function Vo(e,t){var n={from:rt(t.from),to:Eo(t),text:$e(e,t.from,t.to)};return Ho(e,n,t.from.line,t.to.line+1),_o(e,(function(e){return Ho(e,n,t.from.line,t.to.line+1)}),!0),n}function Bo(e){for(;e.length&&K(e).ranges;)e.pop()}function Uo(e,t,n,r){var o=e.history;o.undone.length=0;var i,a,s=+new Date;if((o.lastOp==r||o.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&o.lastModTime>s-(e.cm?e.cm.options.historyEventDelay:500)||"*"==t.origin.charAt(0)))&&(i=function(e,t){return t?(Bo(e.done),K(e.done)):e.done.length&&!K(e.done).ranges?K(e.done):e.done.length>1&&!e.done[e.done.length-2].ranges?(e.done.pop(),K(e.done)):void 0}(o,o.lastOp==r)))a=K(i.changes),0==tt(t.from,t.to)&&0==tt(t.from,a.to)?a.to=Eo(t):i.changes.push(Vo(e,t));else{var l=K(o.done);for(l&&l.ranges||Wo(e.sel,o.done),i={changes:[Vo(e,t)],generation:o.generation},o.done.push(i);o.done.length>o.undoDepth;)o.done.shift(),o.done[0].ranges||o.done.shift()}o.done.push(n),o.generation=++o.maxGeneration,o.lastModTime=o.lastSelTime=s,o.lastOp=o.lastSelOp=r,o.lastOrigin=o.lastSelOrigin=t.origin,a||he(e,"historyAdded")}function zo(e,t,n,r){var o=e.history,i=r&&r.origin;n==o.lastSelOp||i&&o.lastSelOrigin==i&&(o.lastModTime==o.lastSelTime&&o.lastOrigin==i||function(e,t,n,r){var o=t.charAt(0);return"*"==o||"+"==o&&n.ranges.length==r.ranges.length&&n.somethingSelected()==r.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}(e,i,K(o.done),t))?o.done[o.done.length-1]=t:Wo(t,o.done),o.lastSelTime=+new Date,o.lastSelOrigin=i,o.lastSelOp=n,r&&!1!==r.clearRedo&&Bo(o.undone)}function Wo(e,t){var n=K(t);n&&n.ranges&&n.equals(e)||t.push(e)}function Ho(e,t,n,r){var o=t["spans_"+e.id],i=0;e.iter(Math.max(e.first,n),Math.min(e.first+e.size,r),(function(n){n.markedSpans&&((o||(o=t["spans_"+e.id]={}))[i]=n.markedSpans),++i}))}function qo(e){if(!e)return null;for(var t,n=0;n<e.length;++n)e[n].marker.explicitlyCleared?t||(t=e.slice(0,n)):t&&t.push(e[n]);return t?t.length?t:null:e}function Go(e,t){var n=function(e,t){var n=t["spans_"+e.id];if(!n)return null;for(var r=[],o=0;o<t.text.length;++o)r.push(qo(n[o]));return r}(e,t),r=St(e,t);if(!n)return r;if(!r)return n;for(var o=0;o<n.length;++o){var i=n[o],a=r[o];if(i&&a)e:for(var s=0;s<a.length;++s){for(var l=a[s],c=0;c<i.length;++c)if(i[c].marker==l.marker)continue e;i.push(l)}else a&&(n[o]=a)}return n}function $o(e,t,n){for(var r=[],o=0;o<e.length;++o){var i=e[o];if(i.ranges)r.push(n?Co.prototype.deepCopy.call(i):i);else{var a=i.changes,s=[];r.push({changes:s});for(var l=0;l<a.length;++l){var c=a[l],u=void 0;if(s.push({from:c.from,to:c.to,text:c.text}),t)for(var f in c)(u=f.match(/^spans_(\d+)$/))&&B(t,Number(u[1]))>-1&&(K(s)[f]=c[f],delete c[f])}}}return r}function Ko(e,t,n,r){if(r){var o=e.anchor;if(n){var i=tt(t,o)<0;i!=tt(n,o)<0?(o=t,t=n):i!=tt(t,n)<0&&(t=n)}return new Ao(o,t)}return new Ao(n||t,t)}function Jo(e,t,n,r,o){null==o&&(o=e.cm&&(e.cm.display.shift||e.extend)),ei(e,new Co([Ko(e.sel.primary(),t,n,o)],0),r)}function Yo(e,t,n){for(var r=[],o=e.cm&&(e.cm.display.shift||e.extend),i=0;i<e.sel.ranges.length;i++)r[i]=Ko(e.sel.ranges[i],t[i],null,o);ei(e,Oo(e.cm,r,e.sel.primIndex),n)}function Xo(e,t,n,r){var o=e.sel.ranges.slice(0);o[t]=n,ei(e,Oo(e.cm,o,e.sel.primIndex),r)}function Qo(e,t,n,r){ei(e,So(t,n),r)}function Zo(e,t,n){var r=e.history.done,o=K(r);o&&o.ranges?(r[r.length-1]=t,ti(e,t,n)):ei(e,t,n)}function ei(e,t,n){ti(e,t,n),zo(e,e.sel,e.cm?e.cm.curOp.id:NaN,n)}function ti(e,t,n){(me(e,"beforeSelectionChange")||e.cm&&me(e.cm,"beforeSelectionChange"))&&(t=function(e,t,n){var r={ranges:t.ranges,update:function(t){this.ranges=[];for(var n=0;n<t.length;n++)this.ranges[n]=new Ao(st(e,t[n].anchor),st(e,t[n].head))},origin:n&&n.origin};return he(e,"beforeSelectionChange",e,r),e.cm&&he(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges?Oo(e.cm,r.ranges,r.ranges.length-1):t}(e,t,n));var r=n&&n.bias||(tt(t.primary().head,e.sel.primary().head)<0?-1:1);ni(e,oi(e,t,r,!0)),n&&!1===n.scroll||!e.cm||"nocursor"==e.cm.getOption("readOnly")||Pr(e.cm)}function ni(e,t){t.equals(e.sel)||(e.sel=t,e.cm&&(e.cm.curOp.updateInput=1,e.cm.curOp.selectionChanged=!0,ge(e.cm)),ln(e,"cursorActivity",e))}function ri(e){ni(e,oi(e,e.sel,null,!1))}function oi(e,t,n,r){for(var o,i=0;i<t.ranges.length;i++){var a=t.ranges[i],s=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[i],l=ai(e,a.anchor,s&&s.anchor,n,r),c=ai(e,a.head,s&&s.head,n,r);(o||l!=a.anchor||c!=a.head)&&(o||(o=t.ranges.slice(0,i)),o[i]=new Ao(l,c))}return o?Oo(e.cm,o,t.primIndex):t}function ii(e,t,n,r,o){var i=Ge(e,t.line);if(i.markedSpans)for(var a=0;a<i.markedSpans.length;++a){var s=i.markedSpans[a],l=s.marker,c="selectLeft"in l?!l.selectLeft:l.inclusiveLeft,u="selectRight"in l?!l.selectRight:l.inclusiveRight;if((null==s.from||(c?s.from<=t.ch:s.from<t.ch))&&(null==s.to||(u?s.to>=t.ch:s.to>t.ch))){if(o&&(he(l,"beforeCursorEnter"),l.explicitlyCleared)){if(i.markedSpans){--a;continue}break}if(!l.atomic)continue;if(n){var f=l.find(r<0?1:-1),p=void 0;if((r<0?u:c)&&(f=si(e,f,-r,f&&f.line==t.line?i:null)),f&&f.line==t.line&&(p=tt(f,n))&&(r<0?p<0:p>0))return ii(e,f,t,r,o)}var d=l.find(r<0?-1:1);return(r<0?c:u)&&(d=si(e,d,r,d.line==t.line?i:null)),d?ii(e,d,t,r,o):null}}return t}function ai(e,t,n,r,o){var i=r||1,a=ii(e,t,n,i,o)||!o&&ii(e,t,n,i,!0)||ii(e,t,n,-i,o)||!o&&ii(e,t,n,-i,!0);return a||(e.cantEdit=!0,et(e.first,0))}function si(e,t,n,r){return n<0&&0==t.ch?t.line>e.first?st(e,et(t.line-1)):null:n>0&&t.ch==(r||Ge(e,t.line)).text.length?t.line<e.first+e.size-1?et(t.line+1,0):null:new et(t.line,t.ch+n)}function li(e){e.setSelection(et(e.firstLine(),0),et(e.lastLine()),z)}function ci(e,t,n){var r={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){return r.canceled=!0}};return n&&(r.update=function(t,n,o,i){t&&(r.from=st(e,t)),n&&(r.to=st(e,n)),o&&(r.text=o),void 0!==i&&(r.origin=i)}),he(e,"beforeChange",e,r),e.cm&&he(e.cm,"beforeChange",e.cm,r),r.canceled?(e.cm&&(e.cm.curOp.updateInput=2),null):{from:r.from,to:r.to,text:r.text,origin:r.origin}}function ui(e,t,n){if(e.cm){if(!e.cm.curOp)return eo(e.cm,ui)(e,t,n);if(e.cm.state.suppressEdits)return}if(!(me(e,"beforeChange")||e.cm&&me(e.cm,"beforeChange"))||(t=ci(e,t,!0))){var r=wt&&!n&&function(e,t,n){var r=null;if(e.iter(t.line,n.line+1,(function(e){if(e.markedSpans)for(var t=0;t<e.markedSpans.length;++t){var n=e.markedSpans[t].marker;!n.readOnly||r&&-1!=B(r,n)||(r||(r=[])).push(n)}})),!r)return null;for(var o=[{from:t,to:n}],i=0;i<r.length;++i)for(var a=r[i],s=a.find(0),l=0;l<o.length;++l){var c=o[l];if(!(tt(c.to,s.from)<0||tt(c.from,s.to)>0)){var u=[l,1],f=tt(c.from,s.from),p=tt(c.to,s.to);(f<0||!a.inclusiveLeft&&!f)&&u.push({from:c.from,to:s.from}),(p>0||!a.inclusiveRight&&!p)&&u.push({from:s.to,to:c.to}),o.splice.apply(o,u),l+=u.length-3}}return o}(e,t.from,t.to);if(r)for(var o=r.length-1;o>=0;--o)fi(e,{from:r[o].from,to:r[o].to,text:o?[""]:t.text,origin:t.origin});else fi(e,t)}}function fi(e,t){if(1!=t.text.length||""!=t.text[0]||0!=tt(t.from,t.to)){var n=To(e,t);Uo(e,t,n,e.cm?e.cm.curOp.id:NaN),hi(e,t,n,St(e,t));var r=[];_o(e,(function(e,n){n||-1!=B(r,e.history)||(yi(e.history,t),r.push(e.history)),hi(e,t,null,St(e,t))}))}}function pi(e,t,n){var r=e.cm&&e.cm.state.suppressEdits;if(!r||n){for(var o,i=e.history,a=e.sel,s="undo"==t?i.done:i.undone,l="undo"==t?i.undone:i.done,c=0;c<s.length&&(o=s[c],n?!o.ranges||o.equals(e.sel):o.ranges);c++);if(c!=s.length){for(i.lastOrigin=i.lastSelOrigin=null;;){if(!(o=s.pop()).ranges){if(r)return void s.push(o);break}if(Wo(o,l),n&&!o.equals(e.sel))return void ei(e,o,{clearRedo:!1});a=o}var u=[];Wo(a,l),l.push({changes:u,generation:i.generation}),i.generation=o.generation||++i.maxGeneration;for(var f=me(e,"beforeChange")||e.cm&&me(e.cm,"beforeChange"),p=function(n){var r=o.changes[n];if(r.origin=t,f&&!ci(e,r,!1))return s.length=0,{};u.push(Vo(e,r));var i=n?To(e,r):K(s);hi(e,r,i,Go(e,r)),!n&&e.cm&&e.cm.scrollIntoView({from:r.from,to:Eo(r)});var a=[];_o(e,(function(e,t){t||-1!=B(a,e.history)||(yi(e.history,r),a.push(e.history)),hi(e,r,null,Go(e,r))}))},d=o.changes.length-1;d>=0;--d){var h=p(d);if(h)return h.v}}}}function di(e,t){if(0!=t&&(e.first+=t,e.sel=new Co(J(e.sel.ranges,(function(e){return new Ao(et(e.anchor.line+t,e.anchor.ch),et(e.head.line+t,e.head.ch))})),e.sel.primIndex),e.cm)){fr(e.cm,e.first,e.first-t,t);for(var n=e.cm.display,r=n.viewFrom;r<n.viewTo;r++)pr(e.cm,r,"gutter")}}function hi(e,t,n,r){if(e.cm&&!e.cm.curOp)return eo(e.cm,hi)(e,t,n,r);if(t.to.line<e.first)di(e,t.text.length-1-(t.to.line-t.from.line));else if(!(t.from.line>e.lastLine())){if(t.from.line<e.first){var o=t.text.length-1-(e.first-t.from.line);di(e,o),t={from:et(e.first,0),to:et(t.to.line+o,t.to.ch),text:[K(t.text)],origin:t.origin}}var i=e.lastLine();t.to.line>i&&(t={from:t.from,to:et(i,Ge(e,i).text.length),text:[t.text[0]],origin:t.origin}),t.removed=$e(e,t.from,t.to),n||(n=To(e,t)),e.cm?function(e,t,n){var r=e.doc,o=e.display,i=t.from,a=t.to,s=!1,l=i.line;e.options.lineWrapping||(l=Ye(Dt(Ge(r,i.line))),r.iter(l,a.line+1,(function(e){if(e==o.maxLine)return s=!0,!0}))),r.sel.contains(t.from,t.to)>-1&&ge(e),Fo(r,t,n,sr(e)),e.options.lineWrapping||(r.iter(l,i.line+t.text.length,(function(e){var t=Ht(e);t>o.maxLineLength&&(o.maxLine=e,o.maxLineLength=t,o.maxLineChanged=!0,s=!1)})),s&&(e.curOp.updateMaxLine=!0)),function(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),!(e.highlightFrontier<t-10)){for(var n=e.first,r=t-1;r>n;r--){var o=Ge(e,r).stateAfter;if(o&&(!(o instanceof ct)||r+o.lookAhead<t)){n=r+1;break}}e.highlightFrontier=Math.min(e.highlightFrontier,n)}}(r,i.line),ro(e,400);var c=t.text.length-(a.line-i.line)-1;t.full?fr(e):i.line!=a.line||1!=t.text.length||Io(e.doc,t)?fr(e,i.line,a.line+1,c):pr(e,i.line,"text");var u=me(e,"changes"),f=me(e,"change");if(f||u){var p={from:i,to:a,text:t.text,removed:t.removed,origin:t.origin};f&&ln(e,"change",e,p),u&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(p)}e.display.selForContextMenu=null}(e.cm,t,r):Fo(e,t,r),ti(e,n,z),e.cantEdit&&ai(e,et(e.firstLine(),0))&&(e.cantEdit=!1)}}function vi(e,t,n,r,o){var i;r||(r=n),tt(r,n)<0&&(n=(i=[r,n])[0],r=i[1]),"string"==typeof t&&(t=e.splitLines(t)),ui(e,{from:n,to:r,text:t,origin:o})}function gi(e,t,n,r){n<e.line?e.line+=r:t<e.line&&(e.line=t,e.ch=0)}function mi(e,t,n,r){for(var o=0;o<e.length;++o){var i=e[o],a=!0;if(i.ranges){i.copied||((i=e[o]=i.deepCopy()).copied=!0);for(var s=0;s<i.ranges.length;s++)gi(i.ranges[s].anchor,t,n,r),gi(i.ranges[s].head,t,n,r)}else{for(var l=0;l<i.changes.length;++l){var c=i.changes[l];if(n<c.from.line)c.from=et(c.from.line+r,c.from.ch),c.to=et(c.to.line+r,c.to.ch);else if(t<=c.to.line){a=!1;break}}a||(e.splice(0,o+1),o=0)}}}function yi(e,t){var n=t.from.line,r=t.to.line,o=t.text.length-(r-n)-1;mi(e.done,n,r,o),mi(e.undone,n,r,o)}function bi(e,t,n,r){var o=t,i=t;return"number"==typeof t?i=Ge(e,at(e,t)):o=Ye(t),null==o?null:(r(i,o)&&e.cm&&pr(e.cm,o,n),i)}function xi(e){this.lines=e,this.parent=null;for(var t=0,n=0;n<e.length;++n)e[n].parent=this,t+=e[n].height;this.height=t}function wi(e){this.children=e;for(var t=0,n=0,r=0;r<e.length;++r){var o=e[r];t+=o.chunkSize(),n+=o.height,o.parent=this}this.size=t,this.height=n,this.parent=null}Ao.prototype.from=function(){return it(this.anchor,this.head)},Ao.prototype.to=function(){return ot(this.anchor,this.head)},Ao.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch},xi.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var n=e,r=e+t;n<r;++n){var o=this.lines[n];this.height-=o.height,$t(o),ln(o,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,n){this.height+=n,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var r=0;r<t.length;++r)t[r].parent=this},iterN:function(e,t,n){for(var r=e+t;e<r;++e)if(n(this.lines[e]))return!0}},wi.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var n=0;n<this.children.length;++n){var r=this.children[n],o=r.chunkSize();if(e<o){var i=Math.min(t,o-e),a=r.height;if(r.removeInner(e,i),this.height-=a-r.height,o==i&&(this.children.splice(n--,1),r.parent=null),0==(t-=i))break;e=0}else e-=o}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof xi))){var s=[];this.collapse(s),this.children=[new xi(s)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t<this.children.length;++t)this.children[t].collapse(e)},insertInner:function(e,t,n){this.size+=t.length,this.height+=n;for(var r=0;r<this.children.length;++r){var o=this.children[r],i=o.chunkSize();if(e<=i){if(o.insertInner(e,t,n),o.lines&&o.lines.length>50){for(var a=o.lines.length%25+25,s=a;s<o.lines.length;){var l=new xi(o.lines.slice(s,s+=25));o.height-=l.height,this.children.splice(++r,0,l),l.parent=this}o.lines=o.lines.slice(0,a),this.maybeSpill()}break}e-=i}},maybeSpill:function(){if(!(this.children.length<=10)){var e=this;do{var t=new wi(e.children.splice(e.children.length-5,5));if(e.parent){e.size-=t.size,e.height-=t.height;var n=B(e.parent.children,e);e.parent.children.splice(n+1,0,t)}else{var r=new wi(e.children);r.parent=e,e.children=[r,t],e=r}t.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()}},iterN:function(e,t,n){for(var r=0;r<this.children.length;++r){var o=this.children[r],i=o.chunkSize();if(e<i){var a=Math.min(t,i-e);if(o.iterN(e,a,n))return!0;if(0==(t-=a))break;e=0}else e-=i}}};var ki=function(e,t,n){if(n)for(var r in n)n.hasOwnProperty(r)&&(this[r]=n[r]);this.doc=e,this.node=t};function Ci(e,t,n){Wt(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&Mr(e,n)}ki.prototype.clear=function(){var e=this.doc.cm,t=this.line.widgets,n=this.line,r=Ye(n);if(null!=r&&t){for(var o=0;o<t.length;++o)t[o]==this&&t.splice(o--,1);t.length||(n.widgets=null);var i=wn(this);Je(n,Math.max(0,n.height-i)),e&&(Zr(e,(function(){Ci(e,n,-i),pr(e,r,"widget")})),ln(e,"lineWidgetCleared",e,this,r))}},ki.prototype.changed=function(){var e=this,t=this.height,n=this.doc.cm,r=this.line;this.height=null;var o=wn(this)-t;o&&(Ut(this.doc,r)||Je(r,r.height+o),n&&Zr(n,(function(){n.curOp.forceUpdate=!0,Ci(n,r,o),ln(n,"lineWidgetChanged",n,e,Ye(r))})))},ye(ki);var Ai=0,Oi=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++Ai};function Si(e,t,n,r,o){if(r&&r.shared)return function(e,t,n,r,o){(r=R(r)).shared=!1;var i=[Si(e,t,n,r,o)],a=i[0],s=r.widgetNode;return _o(e,(function(e){s&&(r.widgetNode=s.cloneNode(!0)),i.push(Si(e,st(e,t),st(e,n),r,o));for(var l=0;l<e.linked.length;++l)if(e.linked[l].isParent)return;a=K(i)})),new Ei(i,a)}(e,t,n,r,o);if(e.cm&&!e.cm.curOp)return eo(e.cm,Si)(e,t,n,r,o);var i=new Oi(e,o),a=tt(t,n);if(r&&R(r,i,!1),a>0||0==a&&!1!==i.clearWhenEmpty)return i;if(i.replacedWith&&(i.collapsed=!0,i.widgetNode=M("span",[i.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||i.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(i.widgetNode.insertLeft=!0)),i.collapsed){if(Rt(e,t.line,t,n,i)||t.line!=n.line&&Rt(e,n.line,t,n,i))throw new Error("Inserting collapsed marker partially overlapping an existing one");kt=!0}i.addToHistory&&Uo(e,{from:t,to:n,origin:"markText"},e.sel,NaN);var s,l=t.line,c=e.cm;if(e.iter(l,n.line+1,(function(r){c&&i.collapsed&&!c.options.lineWrapping&&Dt(r)==c.display.maxLine&&(s=!0),i.collapsed&&l!=t.line&&Je(r,0),function(e,t,n){var r=n&&window.WeakSet&&(n.markedSpans||(n.markedSpans=new WeakSet));r&&r.has(e.markedSpans)?e.markedSpans.push(t):(e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],r&&r.add(e.markedSpans)),t.marker.attachLine(e)}(r,new Ct(i,l==t.line?t.ch:null,l==n.line?n.ch:null),e.cm&&e.cm.curOp),++l})),i.collapsed&&e.iter(t.line,n.line+1,(function(t){Ut(e,t)&&Je(t,0)})),i.clearOnEnter&&fe(i,"beforeCursorEnter",(function(){return i.clear()})),i.readOnly&&(wt=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),i.collapsed&&(i.id=++Ai,i.atomic=!0),c){if(s&&(c.curOp.updateMaxLine=!0),i.collapsed)fr(c,t.line,n.line+1);else if(i.className||i.startStyle||i.endStyle||i.css||i.attributes||i.title)for(var u=t.line;u<=n.line;u++)pr(c,u,"text");i.atomic&&ri(c.doc),ln(c,"markerAdded",c,i)}return i}Oi.prototype.clear=function(){if(!this.explicitlyCleared){var e=this.doc.cm,t=e&&!e.curOp;if(t&&Gr(e),me(this,"clear")){var n=this.find();n&&ln(this,"clear",n.from,n.to)}for(var r=null,o=null,i=0;i<this.lines.length;++i){var a=this.lines[i],s=At(a.markedSpans,this);e&&!this.collapsed?pr(e,Ye(a),"text"):e&&(null!=s.to&&(o=Ye(a)),null!=s.from&&(r=Ye(a))),a.markedSpans=Ot(a.markedSpans,s),null==s.from&&this.collapsed&&!Ut(this.doc,a)&&e&&Je(a,rr(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var l=0;l<this.lines.length;++l){var c=Dt(this.lines[l]),u=Ht(c);u>e.display.maxLineLength&&(e.display.maxLine=c,e.display.maxLineLength=u,e.display.maxLineChanged=!0)}null!=r&&e&&this.collapsed&&fr(e,r,o+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&ri(e.doc)),e&&ln(e,"markerCleared",e,this,r,o),t&&$r(e),this.parent&&this.parent.clear()}},Oi.prototype.find=function(e,t){var n,r;null==e&&"bookmark"==this.type&&(e=1);for(var o=0;o<this.lines.length;++o){var i=this.lines[o],a=At(i.markedSpans,this);if(null!=a.from&&(n=et(t?i:Ye(i),a.from),-1==e))return n;if(null!=a.to&&(r=et(t?i:Ye(i),a.to),1==e))return r}return n&&{from:n,to:r}},Oi.prototype.changed=function(){var e=this,t=this.find(-1,!0),n=this,r=this.doc.cm;t&&r&&Zr(r,(function(){var o=t.line,i=Ye(t.line),a=Pn(r,i);if(a&&(Dn(a),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!Ut(n.doc,o)&&null!=n.height){var s=n.height;n.height=null;var l=wn(n)-s;l&&Je(o,o.height+l)}ln(r,"markerChanged",r,e)}))},Oi.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;t.maybeHiddenMarkers&&-1!=B(t.maybeHiddenMarkers,this)||(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},Oi.prototype.detachLine=function(e){if(this.lines.splice(B(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}},ye(Oi);var Ei=function(e,t){this.markers=e,this.primary=t;for(var n=0;n<e.length;++n)e[n].parent=this};function ji(e){return e.findMarks(et(e.first,0),e.clipPos(et(e.lastLine())),(function(e){return e.parent}))}function Ti(e){for(var t=function(t){var n=e[t],r=[n.primary.doc];_o(n.primary.doc,(function(e){return r.push(e)}));for(var o=0;o<n.markers.length;o++){var i=n.markers[o];-1==B(r,i.doc)&&(i.parent=null,n.markers.splice(o--,1))}},n=0;n<e.length;n++)t(n)}Ei.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();ln(this,"clear")}},Ei.prototype.find=function(e,t){return this.primary.find(e,t)},ye(Ei);var Mi=0,Pi=function(e,t,n,r,o){if(!(this instanceof Pi))return new Pi(e,t,n,r,o);null==n&&(n=0),wi.call(this,[new xi([new Gt("",null)])]),this.first=n,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.modeFrontier=this.highlightFrontier=n;var i=et(n,0);this.sel=So(i),this.history=new Do(null),this.id=++Mi,this.modeOption=t,this.lineSep=r,this.direction="rtl"==o?"rtl":"ltr",this.extend=!1,"string"==typeof e&&(e=this.splitLines(e)),Fo(this,{from:i,to:i,text:e}),ei(this,So(i),z)};Pi.prototype=X(wi.prototype,{constructor:Pi,iter:function(e,t,n){n?this.iterN(e-this.first,t-e,n):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var n=0,r=0;r<t.length;++r)n+=t[r].height;this.insertInner(e-this.first,t,n)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=Ke(this,this.first,this.first+this.size);return!1===e?t:t.join(e||this.lineSeparator())},setValue:no((function(e){var t=et(this.first,0),n=this.first+this.size-1;ui(this,{from:t,to:et(n,Ge(this,n).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0),this.cm&&Lr(this.cm,0,0),ei(this,So(t),z)})),replaceRange:function(e,t,n,r){vi(this,e,t=st(this,t),n=n?st(this,n):t,r)},getRange:function(e,t,n){var r=$e(this,st(this,e),st(this,t));return!1===n?r:r.join(n||this.lineSeparator())},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){if(Qe(this,e))return Ge(this,e)},getLineNumber:function(e){return Ye(e)},getLineHandleVisualStart:function(e){return"number"==typeof e&&(e=Ge(this,e)),Dt(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return st(this,e)},getCursor:function(e){var t=this.sel.primary();return null==e||"head"==e?t.head:"anchor"==e?t.anchor:"end"==e||"to"==e||!1===e?t.to():t.from()},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:no((function(e,t,n){Qo(this,st(this,"number"==typeof e?et(e,t||0):e),null,n)})),setSelection:no((function(e,t,n){Qo(this,st(this,e),st(this,t||e),n)})),extendSelection:no((function(e,t,n){Jo(this,st(this,e),t&&st(this,t),n)})),extendSelections:no((function(e,t){Yo(this,lt(this,e),t)})),extendSelectionsBy:no((function(e,t){Yo(this,lt(this,J(this.sel.ranges,e)),t)})),setSelections:no((function(e,t,n){if(e.length){for(var r=[],o=0;o<e.length;o++)r[o]=new Ao(st(this,e[o].anchor),st(this,e[o].head||e[o].anchor));null==t&&(t=Math.min(e.length-1,this.sel.primIndex)),ei(this,Oo(this.cm,r,t),n)}})),addSelection:no((function(e,t,n){var r=this.sel.ranges.slice(0);r.push(new Ao(st(this,e),st(this,t||e))),ei(this,Oo(this.cm,r,r.length-1),n)})),getSelection:function(e){for(var t,n=this.sel.ranges,r=0;r<n.length;r++){var o=$e(this,n[r].from(),n[r].to());t=t?t.concat(o):o}return!1===e?t:t.join(e||this.lineSeparator())},getSelections:function(e){for(var t=[],n=this.sel.ranges,r=0;r<n.length;r++){var o=$e(this,n[r].from(),n[r].to());!1!==e&&(o=o.join(e||this.lineSeparator())),t[r]=o}return t},replaceSelection:function(e,t,n){for(var r=[],o=0;o<this.sel.ranges.length;o++)r[o]=e;this.replaceSelections(r,t,n||"+input")},replaceSelections:no((function(e,t,n){for(var r=[],o=this.sel,i=0;i<o.ranges.length;i++){var a=o.ranges[i];r[i]={from:a.from(),to:a.to(),text:this.splitLines(e[i]),origin:n}}for(var s=t&&"end"!=t&&function(e,t,n){for(var r=[],o=et(e.first,0),i=o,a=0;a<t.length;a++){var s=t[a],l=Mo(s.from,o,i),c=Mo(Eo(s),o,i);if(o=s.to,i=c,"around"==n){var u=e.sel.ranges[a],f=tt(u.head,u.anchor)<0;r[a]=new Ao(f?c:l,f?l:c)}else r[a]=new Ao(l,l)}return new Co(r,e.sel.primIndex)}(this,r,t),l=r.length-1;l>=0;l--)ui(this,r[l]);s?Zo(this,s):this.cm&&Pr(this.cm)})),undo:no((function(){pi(this,"undo")})),redo:no((function(){pi(this,"redo")})),undoSelection:no((function(){pi(this,"undo",!0)})),redoSelection:no((function(){pi(this,"redo",!0)})),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,n=0,r=0;r<e.done.length;r++)e.done[r].ranges||++t;for(var o=0;o<e.undone.length;o++)e.undone[o].ranges||++n;return{undo:t,redo:n}},clearHistory:function(){var e=this;this.history=new Do(this.history),_o(this,(function(t){return t.history=e.history}),!0)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(e){return e&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function(){return{done:$o(this.history.done),undone:$o(this.history.undone)}},setHistory:function(e){var t=this.history=new Do(this.history);t.done=$o(e.done.slice(0),null,!0),t.undone=$o(e.undone.slice(0),null,!0)},setGutterMarker:no((function(e,t,n){return bi(this,e,"gutter",(function(e){var r=e.gutterMarkers||(e.gutterMarkers={});return r[t]=n,!n&&te(r)&&(e.gutterMarkers=null),!0}))})),clearGutter:no((function(e){var t=this;this.iter((function(n){n.gutterMarkers&&n.gutterMarkers[e]&&bi(t,n,"gutter",(function(){return n.gutterMarkers[e]=null,te(n.gutterMarkers)&&(n.gutterMarkers=null),!0}))}))})),lineInfo:function(e){var t;if("number"==typeof e){if(!Qe(this,e))return null;if(t=e,!(e=Ge(this,e)))return null}else if(null==(t=Ye(e)))return null;return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},addLineClass:no((function(e,t,n){return bi(this,e,"gutter"==t?"gutter":"class",(function(e){var r="text"==t?"textClass":"background"==t?"bgClass":"gutter"==t?"gutterClass":"wrapClass";if(e[r]){if(A(n).test(e[r]))return!1;e[r]+=" "+n}else e[r]=n;return!0}))})),removeLineClass:no((function(e,t,n){return bi(this,e,"gutter"==t?"gutter":"class",(function(e){var r="text"==t?"textClass":"background"==t?"bgClass":"gutter"==t?"gutterClass":"wrapClass",o=e[r];if(!o)return!1;if(null==n)e[r]=null;else{var i=o.match(A(n));if(!i)return!1;var a=i.index+i[0].length;e[r]=o.slice(0,i.index)+(i.index&&a!=o.length?" ":"")+o.slice(a)||null}return!0}))})),addLineWidget:no((function(e,t,n){return function(e,t,n,r){var o=new ki(e,n,r),i=e.cm;return i&&o.noHScroll&&(i.display.alignWidgets=!0),bi(e,t,"widget",(function(t){var n=t.widgets||(t.widgets=[]);if(null==o.insertAt?n.push(o):n.splice(Math.min(n.length,Math.max(0,o.insertAt)),0,o),o.line=t,i&&!Ut(e,t)){var r=Wt(t)<e.scrollTop;Je(t,t.height+wn(o)),r&&Mr(i,o.height),i.curOp.forceUpdate=!0}return!0})),i&&ln(i,"lineWidgetAdded",i,o,"number"==typeof t?t:Ye(t)),o}(this,e,t,n)})),removeLineWidget:function(e){e.clear()},markText:function(e,t,n){return Si(this,st(this,e),st(this,t),n,n&&n.type||"range")},setBookmark:function(e,t){var n={replacedWith:t&&(null==t.nodeType?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared,handleMouseEvents:t&&t.handleMouseEvents};return Si(this,e=st(this,e),e,n,"bookmark")},findMarksAt:function(e){var t=[],n=Ge(this,(e=st(this,e)).line).markedSpans;if(n)for(var r=0;r<n.length;++r){var o=n[r];(null==o.from||o.from<=e.ch)&&(null==o.to||o.to>=e.ch)&&t.push(o.marker.parent||o.marker)}return t},findMarks:function(e,t,n){e=st(this,e),t=st(this,t);var r=[],o=e.line;return this.iter(e.line,t.line+1,(function(i){var a=i.markedSpans;if(a)for(var s=0;s<a.length;s++){var l=a[s];null!=l.to&&o==e.line&&e.ch>=l.to||null==l.from&&o!=e.line||null!=l.from&&o==t.line&&l.from>=t.ch||n&&!n(l.marker)||r.push(l.marker.parent||l.marker)}++o})),r},getAllMarks:function(){var e=[];return this.iter((function(t){var n=t.markedSpans;if(n)for(var r=0;r<n.length;++r)null!=n[r].from&&e.push(n[r].marker)})),e},posFromIndex:function(e){var t,n=this.first,r=this.lineSeparator().length;return this.iter((function(o){var i=o.text.length+r;if(i>e)return t=e,!0;e-=i,++n})),st(this,et(n,t))},indexFromPos:function(e){var t=(e=st(this,e)).ch;if(e.line<this.first||e.ch<0)return 0;var n=this.lineSeparator().length;return this.iter(this.first,e.line,(function(e){t+=e.text.length+n})),t},copy:function(e){var t=new Pi(Ke(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep,this.direction);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,e&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(e){e||(e={});var t=this.first,n=this.first+this.size;null!=e.from&&e.from>t&&(t=e.from),null!=e.to&&e.to<n&&(n=e.to);var r=new Pi(Ke(this,t,n),e.mode||this.modeOption,t,this.lineSep,this.direction);return e.sharedHist&&(r.history=this.history),(this.linked||(this.linked=[])).push({doc:r,sharedHist:e.sharedHist}),r.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n],o=r.find(),i=e.clipPos(o.from),a=e.clipPos(o.to);if(tt(i,a)){var s=Si(e,i,a,r.primary,r.primary.type);r.markers.push(s),s.parent=r}}}(r,ji(this)),r},unlinkDoc:function(e){if(e instanceof Ea&&(e=e.doc),this.linked)for(var t=0;t<this.linked.length;++t)if(this.linked[t].doc==e){this.linked.splice(t,1),e.unlinkDoc(this),Ti(ji(this));break}if(e.history==this.history){var n=[e.id];_o(e,(function(e){return n.push(e.id)}),!0),e.history=new Do(null),e.history.done=$o(this.history.done,n),e.history.undone=$o(this.history.undone,n)}},iterLinkedDocs:function(e){_o(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(e){return this.lineSep?e.split(this.lineSep):Pe(e)},lineSeparator:function(){return this.lineSep||"\n"},setDirection:no((function(e){var t;"rtl"!=e&&(e="ltr"),e!=this.direction&&(this.direction=e,this.iter((function(e){return e.order=null})),this.cm&&Zr(t=this.cm,(function(){Ro(t),fr(t)})))}))}),Pi.prototype.eachLine=Pi.prototype.iter;var Li=0;function Ii(e){var t=this;if(Fi(t),!ve(t,e)&&!kn(t.display,e)){be(e),a&&(Li=+new Date);var n=cr(t,e,!0),r=e.dataTransfer.files;if(n&&!t.isReadOnly())if(r&&r.length&&window.FileReader&&window.File)for(var o=r.length,i=Array(o),s=0,l=function(){++s==o&&eo(t,(function(){var e={from:n=st(t.doc,n),to:n,text:t.doc.splitLines(i.filter((function(e){return null!=e})).join(t.doc.lineSeparator())),origin:"paste"};ui(t.doc,e),Zo(t.doc,So(st(t.doc,n),st(t.doc,Eo(e))))}))()},c=function(e,n){if(t.options.allowDropFileTypes&&-1==B(t.options.allowDropFileTypes,e.type))l();else{var r=new FileReader;r.onerror=function(){return l()},r.onload=function(){var e=r.result;/[\x00-\x08\x0e-\x1f]{2}/.test(e)||(i[n]=e),l()},r.readAsText(e)}},u=0;u<r.length;u++)c(r[u],u);else{if(t.state.draggingText&&t.doc.sel.contains(n)>-1)return t.state.draggingText(e),void setTimeout((function(){return t.display.input.focus()}),20);try{var f=e.dataTransfer.getData("Text");if(f){var p;if(t.state.draggingText&&!t.state.draggingText.copy&&(p=t.listSelections()),ti(t.doc,So(n,n)),p)for(var d=0;d<p.length;++d)vi(t.doc,"",p[d].anchor,p[d].head,"drag");t.replaceSelection(f,"around","paste"),t.display.input.focus()}}catch(e){}}}}function Fi(e){e.display.dragCursor&&(e.display.lineSpace.removeChild(e.display.dragCursor),e.display.dragCursor=null)}function _i(e){if(document.getElementsByClassName){for(var t=document.getElementsByClassName("CodeMirror"),n=[],r=0;r<t.length;r++){var o=t[r].CodeMirror;o&&n.push(o)}n.length&&n[0].operation((function(){for(var t=0;t<n.length;t++)e(n[t])}))}}var Ni=!1;function Ri(){var e;Ni||(fe(window,"resize",(function(){null==e&&(e=setTimeout((function(){e=null,_i(Di)}),100))})),fe(window,"blur",(function(){return _i(Or)})),Ni=!0)}function Di(e){var t=e.display;t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize()}for(var Vi={3:"Pause",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",145:"ScrollLock",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",224:"Mod",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"},Bi=0;Bi<10;Bi++)Vi[Bi+48]=Vi[Bi+96]=String(Bi);for(var Ui=65;Ui<=90;Ui++)Vi[Ui]=String.fromCharCode(Ui);for(var zi=1;zi<=12;zi++)Vi[zi+111]=Vi[zi+63235]="F"+zi;var Wi={};function Hi(e){var t,n,r,o,i=e.split(/-(?!$)/);e=i[i.length-1];for(var a=0;a<i.length-1;a++){var s=i[a];if(/^(cmd|meta|m)$/i.test(s))o=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else{if(!/^s(hift)?$/i.test(s))throw new Error("Unrecognized modifier name: "+s);r=!0}}return t&&(e="Alt-"+e),n&&(e="Ctrl-"+e),o&&(e="Cmd-"+e),r&&(e="Shift-"+e),e}function qi(e){var t={};for(var n in e)if(e.hasOwnProperty(n)){var r=e[n];if(/^(name|fallthrough|(de|at)tach)$/.test(n))continue;if("..."==r){delete e[n];continue}for(var o=J(n.split(" "),Hi),i=0;i<o.length;i++){var a=void 0,s=void 0;i==o.length-1?(s=o.join(" "),a=r):(s=o.slice(0,i+1).join(" "),a="...");var l=t[s];if(l){if(l!=a)throw new Error("Inconsistent bindings for "+s)}else t[s]=a}delete e[n]}for(var c in t)e[c]=t[c];return e}function Gi(e,t,n,r){var o=(t=Yi(t)).call?t.call(e,r):t[e];if(!1===o)return"nothing";if("..."===o)return"multi";if(null!=o&&n(o))return"handled";if(t.fallthrough){if("[object Array]"!=Object.prototype.toString.call(t.fallthrough))return Gi(e,t.fallthrough,n,r);for(var i=0;i<t.fallthrough.length;i++){var a=Gi(e,t.fallthrough[i],n,r);if(a)return a}}}function $i(e){var t="string"==typeof e?e:Vi[e.keyCode];return"Ctrl"==t||"Alt"==t||"Shift"==t||"Mod"==t}function Ki(e,t,n){var r=e;return t.altKey&&"Alt"!=r&&(e="Alt-"+e),(k?t.metaKey:t.ctrlKey)&&"Ctrl"!=r&&(e="Ctrl-"+e),(k?t.ctrlKey:t.metaKey)&&"Mod"!=r&&(e="Cmd-"+e),!n&&t.shiftKey&&"Shift"!=r&&(e="Shift-"+e),e}function Ji(e,t){if(f&&34==e.keyCode&&e.char)return!1;var n=Vi[e.keyCode];return null!=n&&!e.altGraphKey&&(3==e.keyCode&&e.code&&(n=e.code),Ki(n,e,t))}function Yi(e){return"string"==typeof e?Wi[e]:e}function Xi(e,t){for(var n=e.doc.sel.ranges,r=[],o=0;o<n.length;o++){for(var i=t(n[o]);r.length&&tt(i.from,K(r).to)<=0;){var a=r.pop();if(tt(a.from,i.from)<0){i.from=a.from;break}}r.push(i)}Zr(e,(function(){for(var t=r.length-1;t>=0;t--)vi(e.doc,"",r[t].from,r[t].to,"+delete");Pr(e)}))}function Qi(e,t,n){var r=oe(e.text,t+n,n);return r<0||r>e.text.length?null:r}function Zi(e,t,n){var r=Qi(e,t.ch,n);return null==r?null:new et(t.line,r,n<0?"after":"before")}function ea(e,t,n,r,o){if(e){"rtl"==t.doc.direction&&(o=-o);var i=ce(n,t.doc.direction);if(i){var a,s=o<0?K(i):i[0],l=o<0==(1==s.level)?"after":"before";if(s.level>0||"rtl"==t.doc.direction){var c=Ln(t,n);a=o<0?n.text.length-1:0;var u=In(t,c,a).top;a=ie((function(e){return In(t,c,e).top==u}),o<0==(1==s.level)?s.from:s.to-1,a),"before"==l&&(a=Qi(n,a,1))}else a=o<0?s.to:s.from;return new et(r,a,l)}}return new et(r,o<0?n.text.length:0,o<0?"before":"after")}Wi.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"},Wi.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"},Wi.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"},Wi.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"]},Wi.default=y?Wi.macDefault:Wi.pcDefault;var ta={selectAll:li,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),z)},killLine:function(e){return Xi(e,(function(t){if(t.empty()){var n=Ge(e.doc,t.head.line).text.length;return t.head.ch==n&&t.head.line<e.lastLine()?{from:t.head,to:et(t.head.line+1,0)}:{from:t.head,to:et(t.head.line,n)}}return{from:t.from(),to:t.to()}}))},deleteLine:function(e){return Xi(e,(function(t){return{from:et(t.from().line,0),to:st(e.doc,et(t.to().line+1,0))}}))},delLineLeft:function(e){return Xi(e,(function(e){return{from:et(e.from().line,0),to:e.from()}}))},delWrappedLineLeft:function(e){return Xi(e,(function(t){var n=e.charCoords(t.head,"div").top+5;return{from:e.coordsChar({left:0,top:n},"div"),to:t.from()}}))},delWrappedLineRight:function(e){return Xi(e,(function(t){var n=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:n},"div");return{from:t.from(),to:r}}))},undo:function(e){return e.undo()},redo:function(e){return e.redo()},undoSelection:function(e){return e.undoSelection()},redoSelection:function(e){return e.redoSelection()},goDocStart:function(e){return e.extendSelection(et(e.firstLine(),0))},goDocEnd:function(e){return e.extendSelection(et(e.lastLine()))},goLineStart:function(e){return e.extendSelectionsBy((function(t){return na(e,t.head.line)}),{origin:"+move",bias:1})},goLineStartSmart:function(e){return e.extendSelectionsBy((function(t){return ra(e,t.head)}),{origin:"+move",bias:1})},goLineEnd:function(e){return e.extendSelectionsBy((function(t){return function(e,t){var n=Ge(e.doc,t),r=function(e){for(var t;t=_t(e);)e=t.find(1,!0).line;return e}(n);return r!=n&&(t=Ye(r)),ea(!0,e,n,t,-1)}(e,t.head.line)}),{origin:"+move",bias:-1})},goLineRight:function(e){return e.extendSelectionsBy((function(t){var n=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:n},"div")}),H)},goLineLeft:function(e){return e.extendSelectionsBy((function(t){var n=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:n},"div")}),H)},goLineLeftSmart:function(e){return e.extendSelectionsBy((function(t){var n=e.cursorCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:n},"div");return r.ch<e.getLine(r.line).search(/\S/)?ra(e,t.head):r}),H)},goLineUp:function(e){return e.moveV(-1,"line")},goLineDown:function(e){return e.moveV(1,"line")},goPageUp:function(e){return e.moveV(-1,"page")},goPageDown:function(e){return e.moveV(1,"page")},goCharLeft:function(e){return e.moveH(-1,"char")},goCharRight:function(e){return e.moveH(1,"char")},goColumnLeft:function(e){return e.moveH(-1,"column")},goColumnRight:function(e){return e.moveH(1,"column")},goWordLeft:function(e){return e.moveH(-1,"word")},goGroupRight:function(e){return e.moveH(1,"group")},goGroupLeft:function(e){return e.moveH(-1,"group")},goWordRight:function(e){return e.moveH(1,"word")},delCharBefore:function(e){return e.deleteH(-1,"codepoint")},delCharAfter:function(e){return e.deleteH(1,"char")},delWordBefore:function(e){return e.deleteH(-1,"word")},delWordAfter:function(e){return e.deleteH(1,"word")},delGroupBefore:function(e){return e.deleteH(-1,"group")},delGroupAfter:function(e){return e.deleteH(1,"group")},indentAuto:function(e){return e.indentSelection("smart")},indentMore:function(e){return e.indentSelection("add")},indentLess:function(e){return e.indentSelection("subtract")},insertTab:function(e){return e.replaceSelection("\t")},insertSoftTab:function(e){for(var t=[],n=e.listSelections(),r=e.options.tabSize,o=0;o<n.length;o++){var i=n[o].from(),a=D(e.getLine(i.line),i.ch,r);t.push($(r-a%r))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){return Zr(e,(function(){for(var t=e.listSelections(),n=[],r=0;r<t.length;r++)if(t[r].empty()){var o=t[r].head,i=Ge(e.doc,o.line).text;if(i)if(o.ch==i.length&&(o=new et(o.line,o.ch-1)),o.ch>0)o=new et(o.line,o.ch+1),e.replaceRange(i.charAt(o.ch-1)+i.charAt(o.ch-2),et(o.line,o.ch-2),o,"+transpose");else if(o.line>e.doc.first){var a=Ge(e.doc,o.line-1).text;a&&(o=new et(o.line,1),e.replaceRange(i.charAt(0)+e.doc.lineSeparator()+a.charAt(a.length-1),et(o.line-1,a.length-1),o,"+transpose"))}n.push(new Ao(o,o))}e.setSelections(n)}))},newlineAndIndent:function(e){return Zr(e,(function(){for(var t=e.listSelections(),n=t.length-1;n>=0;n--)e.replaceRange(e.doc.lineSeparator(),t[n].anchor,t[n].head,"+input");t=e.listSelections();for(var r=0;r<t.length;r++)e.indentLine(t[r].from().line,null,!0);Pr(e)}))},openLine:function(e){return e.replaceSelection("\n","start")},toggleOverwrite:function(e){return e.toggleOverwrite()}};function na(e,t){var n=Ge(e.doc,t),r=Dt(n);return r!=n&&(t=Ye(r)),ea(!0,e,r,t,1)}function ra(e,t){var n=na(e,t.line),r=Ge(e.doc,n.line),o=ce(r,e.doc.direction);if(!o||0==o[0].level){var i=Math.max(n.ch,r.text.search(/\S/)),a=t.line==n.line&&t.ch<=i&&t.ch;return et(n.line,a?0:i,n.sticky)}return n}function oa(e,t,n){if("string"==typeof t&&!(t=ta[t]))return!1;e.display.input.ensurePolled();var r=e.display.shift,o=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),n&&(e.display.shift=!1),o=t(e)!=U}finally{e.display.shift=r,e.state.suppressEdits=!1}return o}var ia=new V;function aa(e,t,n,r){var o=e.state.keySeq;if(o){if($i(t))return"handled";if(/\'$/.test(t)?e.state.keySeq=null:ia.set(50,(function(){e.state.keySeq==o&&(e.state.keySeq=null,e.display.input.reset())})),sa(e,o+" "+t,n,r))return!0}return sa(e,t,n,r)}function sa(e,t,n,r){var o=function(e,t,n){for(var r=0;r<e.state.keyMaps.length;r++){var o=Gi(t,e.state.keyMaps[r],n,e);if(o)return o}return e.options.extraKeys&&Gi(t,e.options.extraKeys,n,e)||Gi(t,e.options.keyMap,n,e)}(e,t,r);return"multi"==o&&(e.state.keySeq=t),"handled"==o&&ln(e,"keyHandled",e,t,n),"handled"!=o&&"multi"!=o||(be(n),wr(e)),!!o}function la(e,t){var n=Ji(t,!0);return!!n&&(t.shiftKey&&!e.state.keySeq?aa(e,"Shift-"+n,t,(function(t){return oa(e,t,!0)}))||aa(e,n,t,(function(t){if("string"==typeof t?/^go[A-Z]/.test(t):t.motion)return oa(e,t)})):aa(e,n,t,(function(t){return oa(e,t)})))}var ca=null;function ua(e){var t=this;if(!(e.target&&e.target!=t.display.input.getField()||(t.curOp.focus=L(),ve(t,e)))){a&&s<11&&27==e.keyCode&&(e.returnValue=!1);var r=e.keyCode;t.display.shift=16==r||e.shiftKey;var o=la(t,e);f&&(ca=o?r:null,o||88!=r||Ie||!(y?e.metaKey:e.ctrlKey)||t.replaceSelection("",null,"cut")),n&&!y&&!o&&46==r&&e.shiftKey&&!e.ctrlKey&&document.execCommand&&document.execCommand("cut"),18!=r||/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)||function(e){var t=e.display.lineDiv;function n(e){18!=e.keyCode&&e.altKey||(S(t,"CodeMirror-crosshair"),de(document,"keyup",n),de(document,"mouseover",n))}I(t,"CodeMirror-crosshair"),fe(document,"keyup",n),fe(document,"mouseover",n)}(t)}}function fa(e){16==e.keyCode&&(this.doc.sel.shift=!1),ve(this,e)}function pa(e){var t=this;if(!(e.target&&e.target!=t.display.input.getField()||kn(t.display,e)||ve(t,e)||e.ctrlKey&&!e.altKey||y&&e.metaKey)){var n=e.keyCode,r=e.charCode;if(f&&n==ca)return ca=null,void be(e);if(!f||e.which&&!(e.which<10)||!la(t,e)){var o=String.fromCharCode(null==r?n:r);"\b"!=o&&(function(e,t,n){return aa(e,"'"+n+"'",t,(function(t){return oa(e,t,!0)}))}(t,e,o)||t.display.input.onKeyPress(e))}}}var da,ha,va=function(e,t,n){this.time=e,this.pos=t,this.button=n};function ga(e){var t=this,n=t.display;if(!(ve(t,e)||n.activeTouch&&n.input.supportsTouch()))if(n.input.ensurePolled(),n.shift=e.shiftKey,kn(n,e))l||(n.scroller.draggable=!1,setTimeout((function(){return n.scroller.draggable=!0}),100));else if(!ba(t,e)){var r=cr(t,e),o=Ae(e),i=r?function(e,t){var n=+new Date;return ha&&ha.compare(n,e,t)?(da=ha=null,"triple"):da&&da.compare(n,e,t)?(ha=new va(n,e,t),da=null,"double"):(da=new va(n,e,t),ha=null,"single")}(r,o):"single";window.focus(),1==o&&t.state.selectingText&&t.state.selectingText(e),r&&function(e,t,n,r,o){var i="Click";return"double"==r?i="Double"+i:"triple"==r&&(i="Triple"+i),aa(e,Ki(i=(1==t?"Left":2==t?"Middle":"Right")+i,o),o,(function(t){if("string"==typeof t&&(t=ta[t]),!t)return!1;var r=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),r=t(e,n)!=U}finally{e.state.suppressEdits=!1}return r}))}(t,o,r,i,e)||(1==o?r?function(e,t,n,r){a?setTimeout(N(kr,e),0):e.curOp.focus=L();var o,i=function(e,t,n){var r=e.getOption("configureMouse"),o=r?r(e,t,n):{};if(null==o.unit){var i=b?n.shiftKey&&n.metaKey:n.altKey;o.unit=i?"rectangle":"single"==t?"char":"double"==t?"word":"line"}return(null==o.extend||e.doc.extend)&&(o.extend=e.doc.extend||n.shiftKey),null==o.addNew&&(o.addNew=y?n.metaKey:n.ctrlKey),null==o.moveOnDrag&&(o.moveOnDrag=!(y?n.altKey:n.ctrlKey)),o}(e,n,r),c=e.doc.sel;e.options.dragDrop&&Ee&&!e.isReadOnly()&&"single"==n&&(o=c.contains(t))>-1&&(tt((o=c.ranges[o]).from(),t)<0||t.xRel>0)&&(tt(o.to(),t)>0||t.xRel<0)?function(e,t,n,r){var o=e.display,i=!1,c=eo(e,(function(t){l&&(o.scroller.draggable=!1),e.state.draggingText=!1,e.state.delayingBlurEvent&&(e.hasFocus()?e.state.delayingBlurEvent=!1:Cr(e)),de(o.wrapper.ownerDocument,"mouseup",c),de(o.wrapper.ownerDocument,"mousemove",u),de(o.scroller,"dragstart",f),de(o.scroller,"drop",c),i||(be(t),r.addNew||Jo(e.doc,n,null,null,r.extend),l&&!p||a&&9==s?setTimeout((function(){o.wrapper.ownerDocument.body.focus({preventScroll:!0}),o.input.focus()}),20):o.input.focus())})),u=function(e){i=i||Math.abs(t.clientX-e.clientX)+Math.abs(t.clientY-e.clientY)>=10},f=function(){return i=!0};l&&(o.scroller.draggable=!0),e.state.draggingText=c,c.copy=!r.moveOnDrag,fe(o.wrapper.ownerDocument,"mouseup",c),fe(o.wrapper.ownerDocument,"mousemove",u),fe(o.scroller,"dragstart",f),fe(o.scroller,"drop",c),e.state.delayingBlurEvent=!0,setTimeout((function(){return o.input.focus()}),20),o.scroller.dragDrop&&o.scroller.dragDrop()}(e,r,t,i):function(e,t,n,r){a&&Cr(e);var o=e.display,i=e.doc;be(t);var s,l,c=i.sel,u=c.ranges;if(r.addNew&&!r.extend?(l=i.sel.contains(n),s=l>-1?u[l]:new Ao(n,n)):(s=i.sel.primary(),l=i.sel.primIndex),"rectangle"==r.unit)r.addNew||(s=new Ao(n,n)),n=cr(e,t,!0,!0),l=-1;else{var f=ma(e,n,r.unit);s=r.extend?Ko(s,f.anchor,f.head,r.extend):f}r.addNew?-1==l?(l=u.length,ei(i,Oo(e,u.concat([s]),l),{scroll:!1,origin:"*mouse"})):u.length>1&&u[l].empty()&&"char"==r.unit&&!r.extend?(ei(i,Oo(e,u.slice(0,l).concat(u.slice(l+1)),0),{scroll:!1,origin:"*mouse"}),c=i.sel):Xo(i,l,s,W):(l=0,ei(i,new Co([s],0),W),c=i.sel);var p=n;function d(t){if(0!=tt(p,t))if(p=t,"rectangle"==r.unit){for(var o=[],a=e.options.tabSize,u=D(Ge(i,n.line).text,n.ch,a),f=D(Ge(i,t.line).text,t.ch,a),d=Math.min(u,f),h=Math.max(u,f),v=Math.min(n.line,t.line),g=Math.min(e.lastLine(),Math.max(n.line,t.line));v<=g;v++){var m=Ge(i,v).text,y=q(m,d,a);d==h?o.push(new Ao(et(v,y),et(v,y))):m.length>y&&o.push(new Ao(et(v,y),et(v,q(m,h,a))))}o.length||o.push(new Ao(n,n)),ei(i,Oo(e,c.ranges.slice(0,l).concat(o),l),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var b,x=s,w=ma(e,t,r.unit),k=x.anchor;tt(w.anchor,k)>0?(b=w.head,k=it(x.from(),w.anchor)):(b=w.anchor,k=ot(x.to(),w.head));var C=c.ranges.slice(0);C[l]=function(e,t){var n=t.anchor,r=t.head,o=Ge(e.doc,n.line);if(0==tt(n,r)&&n.sticky==r.sticky)return t;var i=ce(o);if(!i)return t;var a=se(i,n.ch,n.sticky),s=i[a];if(s.from!=n.ch&&s.to!=n.ch)return t;var l,c=a+(s.from==n.ch==(1!=s.level)?0:1);if(0==c||c==i.length)return t;if(r.line!=n.line)l=(r.line-n.line)*("ltr"==e.doc.direction?1:-1)>0;else{var u=se(i,r.ch,r.sticky),f=u-a||(r.ch-n.ch)*(1==s.level?-1:1);l=u==c-1||u==c?f<0:f>0}var p=i[c+(l?-1:0)],d=l==(1==p.level),h=d?p.from:p.to,v=d?"after":"before";return n.ch==h&&n.sticky==v?t:new Ao(new et(n.line,h,v),r)}(e,new Ao(st(i,k),b)),ei(i,Oo(e,C,l),W)}}var h=o.wrapper.getBoundingClientRect(),v=0;function g(t){e.state.selectingText=!1,v=1/0,t&&(be(t),o.input.focus()),de(o.wrapper.ownerDocument,"mousemove",m),de(o.wrapper.ownerDocument,"mouseup",y),i.history.lastSelOrigin=null}var m=eo(e,(function(t){0!==t.buttons&&Ae(t)?function t(n){var a=++v,s=cr(e,n,!0,"rectangle"==r.unit);if(s)if(0!=tt(s,p)){e.curOp.focus=L(),d(s);var l=jr(o,i);(s.line>=l.to||s.line<l.from)&&setTimeout(eo(e,(function(){v==a&&t(n)})),150)}else{var c=n.clientY<h.top?-20:n.clientY>h.bottom?20:0;c&&setTimeout(eo(e,(function(){v==a&&(o.scroller.scrollTop+=c,t(n))})),50)}}(t):g(t)})),y=eo(e,g);e.state.selectingText=y,fe(o.wrapper.ownerDocument,"mousemove",m),fe(o.wrapper.ownerDocument,"mouseup",y)}(e,r,t,i)}(t,r,i,e):Ce(e)==n.scroller&&be(e):2==o?(r&&Jo(t.doc,r),setTimeout((function(){return n.input.focus()}),20)):3==o&&(C?t.display.input.onContextMenu(e):Cr(t)))}}function ma(e,t,n){if("char"==n)return new Ao(t,t);if("word"==n)return e.findWordAt(t);if("line"==n)return new Ao(et(t.line,0),st(e.doc,et(t.line+1,0)));var r=n(e,t);return new Ao(r.from,r.to)}function ya(e,t,n,r){var o,i;if(t.touches)o=t.touches[0].clientX,i=t.touches[0].clientY;else try{o=t.clientX,i=t.clientY}catch(e){return!1}if(o>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&be(t);var a=e.display,s=a.lineDiv.getBoundingClientRect();if(i>s.bottom||!me(e,n))return we(t);i-=s.top-a.viewOffset;for(var l=0;l<e.display.gutterSpecs.length;++l){var c=a.gutters.childNodes[l];if(c&&c.getBoundingClientRect().right>=o)return he(e,n,e,Xe(e.doc,i),e.display.gutterSpecs[l].className,t),we(t)}}function ba(e,t){return ya(e,t,"gutterClick",!0)}function xa(e,t){kn(e.display,t)||function(e,t){return!!me(e,"gutterContextMenu")&&ya(e,t,"gutterContextMenu",!1)}(e,t)||ve(e,t,"contextmenu")||C||e.display.input.onContextMenu(t)}function wa(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),Bn(e)}va.prototype.compare=function(e,t,n){return this.time+400>e&&0==tt(t,this.pos)&&n==this.button};var ka={toString:function(){return"CodeMirror.Init"}},Ca={},Aa={};function Oa(e,t,n){if(!t!=!(n&&n!=ka)){var r=e.display.dragFunctions,o=t?fe:de;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 Sa(e){e.options.lineWrapping?(I(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(S(e.display.wrapper,"CodeMirror-wrap"),qt(e)),lr(e),fr(e),Bn(e),setTimeout((function(){return Ur(e)}),100)}function Ea(e,t){var n=this;if(!(this instanceof Ea))return new Ea(e,t);this.options=t=t?R(t):{},R(Ca,t,!1);var r=t.value;"string"==typeof r?r=new Pi(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var o=new Ea.inputStyles[t.inputStyle](this),i=this.display=new mo(e,r,o,t);for(var c in i.wrapper.CodeMirror=this,wa(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Hr(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:-1,cutIncoming:-1,selectingText:!1,draggingText:!1,highlight:new V,keySeq:null,specialChars:null},t.autofocus&&!m&&i.input.focus(),a&&s<11&&setTimeout((function(){return n.display.input.reset(!0)}),20),function(e){var t=e.display;fe(t.scroller,"mousedown",eo(e,ga)),fe(t.scroller,"dblclick",a&&s<11?eo(e,(function(t){if(!ve(e,t)){var n=cr(e,t);if(n&&!ba(e,t)&&!kn(e.display,t)){be(t);var r=e.findWordAt(n);Jo(e.doc,r.anchor,r.head)}}})):function(t){return ve(e,t)||be(t)}),fe(t.scroller,"contextmenu",(function(t){return xa(e,t)})),fe(t.input.getField(),"contextmenu",(function(n){t.scroller.contains(n.target)||xa(e,n)}));var n,r={end:0};function o(){t.activeTouch&&(n=setTimeout((function(){return t.activeTouch=null}),1e3),(r=t.activeTouch).end=+new Date)}function i(e,t){if(null==t.left)return!0;var n=t.left-e.left,r=t.top-e.top;return n*n+r*r>400}fe(t.scroller,"touchstart",(function(o){if(!ve(e,o)&&!function(e){if(1!=e.touches.length)return!1;var t=e.touches[0];return t.radiusX<=1&&t.radiusY<=1}(o)&&!ba(e,o)){t.input.ensurePolled(),clearTimeout(n);var i=+new Date;t.activeTouch={start:i,moved:!1,prev:i-r.end<=300?r:null},1==o.touches.length&&(t.activeTouch.left=o.touches[0].pageX,t.activeTouch.top=o.touches[0].pageY)}})),fe(t.scroller,"touchmove",(function(){t.activeTouch&&(t.activeTouch.moved=!0)})),fe(t.scroller,"touchend",(function(n){var r=t.activeTouch;if(r&&!kn(t,n)&&null!=r.left&&!r.moved&&new Date-r.start<300){var a,s=e.coordsChar(t.activeTouch,"page");a=!r.prev||i(r,r.prev)?new Ao(s,s):!r.prev.prev||i(r,r.prev.prev)?e.findWordAt(s):new Ao(et(s.line,0),st(e.doc,et(s.line+1,0))),e.setSelection(a.anchor,a.head),e.focus(),be(n)}o()})),fe(t.scroller,"touchcancel",o),fe(t.scroller,"scroll",(function(){t.scroller.clientHeight&&(_r(e,t.scroller.scrollTop),Rr(e,t.scroller.scrollLeft,!0),he(e,"scroll",e))})),fe(t.scroller,"mousewheel",(function(t){return ko(e,t)})),fe(t.scroller,"DOMMouseScroll",(function(t){return ko(e,t)})),fe(t.wrapper,"scroll",(function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0})),t.dragFunctions={enter:function(t){ve(e,t)||ke(t)},over:function(t){ve(e,t)||(function(e,t){var n=cr(e,t);if(n){var r=document.createDocumentFragment();yr(e,n,r),e.display.dragCursor||(e.display.dragCursor=T("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),j(e.display.dragCursor,r)}}(e,t),ke(t))},start:function(t){return function(e,t){if(a&&(!e.state.draggingText||+new Date-Li<100))ke(t);else if(!ve(e,t)&&!kn(e.display,t)&&(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!p)){var n=T("img",null,null,"position: fixed; left: 0; top: 0;");n.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",f&&(n.width=n.height=1,e.display.wrapper.appendChild(n),n._top=n.offsetTop),t.dataTransfer.setDragImage(n,0,0),f&&n.parentNode.removeChild(n)}}(e,t)},drop:eo(e,Ii),leave:function(t){ve(e,t)||Fi(e)}};var l=t.input.getField();fe(l,"keyup",(function(t){return fa.call(e,t)})),fe(l,"keydown",eo(e,ua)),fe(l,"keypress",eo(e,pa)),fe(l,"focus",(function(t){return Ar(e,t)})),fe(l,"blur",(function(t){return Or(e,t)}))}(this),Ri(),Gr(this),this.curOp.forceUpdate=!0,No(this,r),t.autofocus&&!m||this.hasFocus()?setTimeout((function(){n.hasFocus()&&!n.state.focused&&Ar(n)}),20):Or(this),Aa)Aa.hasOwnProperty(c)&&Aa[c](this,t[c],ka);po(this),t.finishInit&&t.finishInit(this);for(var u=0;u<ja.length;++u)ja[u](this);$r(this),l&&t.lineWrapping&&"optimizelegibility"==getComputedStyle(i.lineDiv).textRendering&&(i.lineDiv.style.textRendering="auto")}Ea.defaults=Ca,Ea.optionHandlers=Aa;var ja=[];function Ta(e,t,n,r){var o,i=e.doc;null==n&&(n="add"),"smart"==n&&(i.mode.indent?o=dt(e,t).state:n="prev");var a=e.options.tabSize,s=Ge(i,t),l=D(s.text,null,a);s.stateAfter&&(s.stateAfter=null);var c,u=s.text.match(/^\s*/)[0];if(r||/\S/.test(s.text)){if("smart"==n&&((c=i.mode.indent(o,s.text.slice(u.length),s.text))==U||c>150)){if(!r)return;n="prev"}}else c=0,n="not";"prev"==n?c=t>i.first?D(Ge(i,t-1).text,null,a):0:"add"==n?c=l+e.options.indentUnit:"subtract"==n?c=l-e.options.indentUnit:"number"==typeof n&&(c=l+n),c=Math.max(0,c);var f="",p=0;if(e.options.indentWithTabs)for(var d=Math.floor(c/a);d;--d)p+=a,f+="\t";if(p<c&&(f+=$(c-p)),f!=u)return vi(i,f,et(t,0),et(t,u.length),"+input"),s.stateAfter=null,!0;for(var h=0;h<i.sel.ranges.length;h++){var v=i.sel.ranges[h];if(v.head.line==t&&v.head.ch<u.length){var g=et(t,u.length);Xo(i,h,new Ao(g,g));break}}}Ea.defineInitHook=function(e){return ja.push(e)};var Ma=null;function Pa(e){Ma=e}function La(e,t,n,r,o){var i=e.doc;e.display.shift=!1,r||(r=i.sel);var a=+new Date-200,s="paste"==o||e.state.pasteIncoming>a,l=Pe(t),c=null;if(s&&r.ranges.length>1)if(Ma&&Ma.text.join("\n")==t){if(r.ranges.length%Ma.text.length==0){c=[];for(var u=0;u<Ma.text.length;u++)c.push(i.splitLines(Ma.text[u]))}}else l.length==r.ranges.length&&e.options.pasteLinesPerSelection&&(c=J(l,(function(e){return[e]})));for(var f=e.curOp.updateInput,p=r.ranges.length-1;p>=0;p--){var d=r.ranges[p],h=d.from(),v=d.to();d.empty()&&(n&&n>0?h=et(h.line,h.ch-n):e.state.overwrite&&!s?v=et(v.line,Math.min(Ge(i,v.line).text.length,v.ch+K(l).length)):s&&Ma&&Ma.lineWise&&Ma.text.join("\n")==l.join("\n")&&(h=v=et(h.line,0)));var g={from:h,to:v,text:c?c[p%c.length]:l,origin:o||(s?"paste":e.state.cutIncoming>a?"cut":"+input")};ui(e.doc,g),ln(e,"inputRead",e,g)}t&&!s&&Fa(e,t),Pr(e),e.curOp.updateInput<2&&(e.curOp.updateInput=f),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function Ia(e,t){var n=e.clipboardData&&e.clipboardData.getData("Text");if(n)return e.preventDefault(),t.isReadOnly()||t.options.disableInput||Zr(t,(function(){return La(t,n,0,null,"paste")})),!0}function Fa(e,t){if(e.options.electricChars&&e.options.smartIndent)for(var n=e.doc.sel,r=n.ranges.length-1;r>=0;r--){var o=n.ranges[r];if(!(o.head.ch>100||r&&n.ranges[r-1].head.line==o.head.line)){var i=e.getModeAt(o.head),a=!1;if(i.electricChars){for(var s=0;s<i.electricChars.length;s++)if(t.indexOf(i.electricChars.charAt(s))>-1){a=Ta(e,o.head.line,"smart");break}}else i.electricInput&&i.electricInput.test(Ge(e.doc,o.head.line).text.slice(0,o.head.ch))&&(a=Ta(e,o.head.line,"smart"));a&&ln(e,"electricInput",e,o.head.line)}}}function _a(e){for(var t=[],n=[],r=0;r<e.doc.sel.ranges.length;r++){var o=e.doc.sel.ranges[r].head.line,i={anchor:et(o,0),head:et(o+1,0)};n.push(i),t.push(e.getRange(i.anchor,i.head))}return{text:t,ranges:n}}function Na(e,t,n,r){e.setAttribute("autocorrect",n?"":"off"),e.setAttribute("autocapitalize",r?"":"off"),e.setAttribute("spellcheck",!!t)}function Ra(){var e=T("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),t=T("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return l?e.style.width="1000px":e.setAttribute("wrap","off"),v&&(e.style.border="1px solid black"),Na(e),t}function Da(e,t,n,r,o){var i=t,a=n,s=Ge(e,t.line),l=o&&"rtl"==e.direction?-n:n;function c(i){var a,c;if("codepoint"==r){var u=s.text.charCodeAt(t.ch+(n>0?0:-1));if(isNaN(u))a=null;else{var f=n>0?u>=55296&&u<56320:u>=56320&&u<57343;a=new et(t.line,Math.max(0,Math.min(s.text.length,t.ch+n*(f?2:1))),-n)}}else a=o?function(e,t,n,r){var o=ce(t,e.doc.direction);if(!o)return Zi(t,n,r);n.ch>=t.text.length?(n.ch=t.text.length,n.sticky="before"):n.ch<=0&&(n.ch=0,n.sticky="after");var i=se(o,n.ch,n.sticky),a=o[i];if("ltr"==e.doc.direction&&a.level%2==0&&(r>0?a.to>n.ch:a.from<n.ch))return Zi(t,n,r);var s,l=function(e,n){return Qi(t,e instanceof et?e.ch:e,n)},c=function(n){return e.options.lineWrapping?(s=s||Ln(e,t),Qn(e,t,s,n)):{begin:0,end:t.text.length}},u=c("before"==n.sticky?l(n,-1):n.ch);if("rtl"==e.doc.direction||1==a.level){var f=1==a.level==r<0,p=l(n,f?1:-1);if(null!=p&&(f?p<=a.to&&p<=u.end:p>=a.from&&p>=u.begin)){var d=f?"before":"after";return new et(n.line,p,d)}}var h=function(e,t,r){for(var i=function(e,t){return t?new et(n.line,l(e,1),"before"):new et(n.line,e,"after")};e>=0&&e<o.length;e+=t){var a=o[e],s=t>0==(1!=a.level),c=s?r.begin:l(r.end,-1);if(a.from<=c&&c<a.to)return i(c,s);if(c=s?a.from:l(a.to,-1),r.begin<=c&&c<r.end)return i(c,s)}},v=h(i+r,r,u);if(v)return v;var g=r>0?u.end:l(u.begin,-1);return null==g||r>0&&g==t.text.length||!(v=h(r>0?0:o.length-1,r,c(g)))?null:v}(e.cm,s,t,n):Zi(s,t,n);if(null==a){if(i||(c=t.line+l)<e.first||c>=e.first+e.size||(t=new et(c,t.ch,t.sticky),!(s=Ge(e,c))))return!1;t=ea(o,e.cm,s,t.line,l)}else t=a;return!0}if("char"==r||"codepoint"==r)c();else if("column"==r)c(!0);else if("word"==r||"group"==r)for(var u=null,f="group"==r,p=e.cm&&e.cm.getHelper(t,"wordChars"),d=!0;!(n<0)||c(!d);d=!1){var h=s.text.charAt(t.ch)||"\n",v=ee(h,p)?"w":f&&"\n"==h?"n":!f||/\s/.test(h)?null:"p";if(!f||d||v||(v="s"),u&&u!=v){n<0&&(n=1,c(),t.sticky="after");break}if(v&&(u=v),n>0&&!c(!d))break}var g=ai(e,t,i,a,!0);return nt(i,g)&&(g.hitSide=!0),g}function Va(e,t,n,r){var o,i,a=e.doc,s=t.left;if("page"==r){var l=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),c=Math.max(l-.5*rr(e.display),3);o=(n>0?t.bottom:t.top)+n*c}else"line"==r&&(o=n>0?t.bottom+3:t.top-3);for(;(i=Yn(e,s,o)).outside;){if(n<0?o<=0:o>=a.height){i.hitSide=!0;break}o+=5*n}return i}var Ba=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new V,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};function Ua(e,t){var n=Pn(e,t.line);if(!n||n.hidden)return null;var r=Ge(e.doc,t.line),o=Tn(n,r,t.line),i=ce(r,e.doc.direction),a="left";i&&(a=se(i,t.ch)%2?"right":"left");var s=Nn(o.map,t.ch,a);return s.offset="right"==s.collapse?s.end:s.start,s}function za(e,t){return t&&(e.bad=!0),e}function Wa(e,t,n){var r;if(t==e.display.lineDiv){if(!(r=e.display.lineDiv.childNodes[n]))return za(e.clipPos(et(e.display.viewTo-1)),!0);t=null,n=0}else for(r=t;;r=r.parentNode){if(!r||r==e.display.lineDiv)return null;if(r.parentNode&&r.parentNode==e.display.lineDiv)break}for(var o=0;o<e.display.view.length;o++){var i=e.display.view[o];if(i.node==r)return Ha(i,t,n)}}function Ha(e,t,n){var r=e.text.firstChild,o=!1;if(!t||!P(r,t))return za(et(Ye(e.line),0),!0);if(t==r&&(o=!0,t=r.childNodes[n],n=0,!t)){var i=e.rest?K(e.rest):e.line;return za(et(Ye(i),i.text.length),o)}var a=3==t.nodeType?t:null,s=t;for(a||1!=t.childNodes.length||3!=t.firstChild.nodeType||(a=t.firstChild,n&&(n=a.nodeValue.length));s.parentNode!=r;)s=s.parentNode;var l=e.measure,c=l.maps;function u(t,n,r){for(var o=-1;o<(c?c.length:0);o++)for(var i=o<0?l.map:c[o],a=0;a<i.length;a+=3){var s=i[a+2];if(s==t||s==n){var u=Ye(o<0?e.line:e.rest[o]),f=i[a]+r;return(r<0||s!=t)&&(f=i[a+(r?1:0)]),et(u,f)}}}var f=u(a,s,n);if(f)return za(f,o);for(var p=s.nextSibling,d=a?a.nodeValue.length-n:0;p;p=p.nextSibling){if(f=u(p,p.firstChild,0))return za(et(f.line,f.ch-d),o);d+=p.textContent.length}for(var h=s.previousSibling,v=n;h;h=h.previousSibling){if(f=u(h,h.firstChild,-1))return za(et(f.line,f.ch+v),o);v+=h.textContent.length}}Ba.prototype.init=function(e){var t=this,n=this,r=n.cm,o=n.div=e.lineDiv;function i(e){for(var t=e.target;t;t=t.parentNode){if(t==o)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(t.className))break}return!1}function a(e){if(i(e)&&!ve(r,e)){if(r.somethingSelected())Pa({lineWise:!1,text:r.getSelections()}),"cut"==e.type&&r.replaceSelection("",null,"cut");else{if(!r.options.lineWiseCopyCut)return;var t=_a(r);Pa({lineWise:!0,text:t.text}),"cut"==e.type&&r.operation((function(){r.setSelections(t.ranges,0,z),r.replaceSelection("",null,"cut")}))}if(e.clipboardData){e.clipboardData.clearData();var a=Ma.text.join("\n");if(e.clipboardData.setData("Text",a),e.clipboardData.getData("Text")==a)return void e.preventDefault()}var s=Ra(),l=s.firstChild;r.display.lineSpace.insertBefore(s,r.display.lineSpace.firstChild),l.value=Ma.text.join("\n");var c=L();_(l),setTimeout((function(){r.display.lineSpace.removeChild(s),c.focus(),c==o&&n.showPrimarySelection()}),50)}}o.contentEditable=!0,Na(o,r.options.spellcheck,r.options.autocorrect,r.options.autocapitalize),fe(o,"paste",(function(e){!i(e)||ve(r,e)||Ia(e,r)||s<=11&&setTimeout(eo(r,(function(){return t.updateFromDOM()})),20)})),fe(o,"compositionstart",(function(e){t.composing={data:e.data,done:!1}})),fe(o,"compositionupdate",(function(e){t.composing||(t.composing={data:e.data,done:!1})})),fe(o,"compositionend",(function(e){t.composing&&(e.data!=t.composing.data&&t.readFromDOMSoon(),t.composing.done=!0)})),fe(o,"touchstart",(function(){return n.forceCompositionEnd()})),fe(o,"input",(function(){t.composing||t.readFromDOMSoon()})),fe(o,"copy",a),fe(o,"cut",a)},Ba.prototype.screenReaderLabelChanged=function(e){e?this.div.setAttribute("aria-label",e):this.div.removeAttribute("aria-label")},Ba.prototype.prepareSelection=function(){var e=mr(this.cm,!1);return e.focus=L()==this.div,e},Ba.prototype.showSelection=function(e,t){e&&this.cm.display.view.length&&((e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e))},Ba.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},Ba.prototype.showPrimarySelection=function(){var e=this.getSelection(),t=this.cm,r=t.doc.sel.primary(),o=r.from(),i=r.to();if(t.display.viewTo==t.display.viewFrom||o.line>=t.display.viewTo||i.line<t.display.viewFrom)e.removeAllRanges();else{var a=Wa(t,e.anchorNode,e.anchorOffset),s=Wa(t,e.focusNode,e.focusOffset);if(!a||a.bad||!s||s.bad||0!=tt(it(a,s),o)||0!=tt(ot(a,s),i)){var l=t.display.view,c=o.line>=t.display.viewFrom&&Ua(t,o)||{node:l[0].measure.map[2],offset:0},u=i.line<t.display.viewTo&&Ua(t,i);if(!u){var f=l[l.length-1].measure,p=f.maps?f.maps[f.maps.length-1]:f.map;u={node:p[p.length-1],offset:p[p.length-2]-p[p.length-3]}}if(c&&u){var d,h=e.rangeCount&&e.getRangeAt(0);try{d=O(c.node,c.offset,u.offset,u.node)}catch(e){}d&&(!n&&t.state.focused?(e.collapse(c.node,c.offset),d.collapsed||(e.removeAllRanges(),e.addRange(d))):(e.removeAllRanges(),e.addRange(d)),h&&null==e.anchorNode?e.addRange(h):n&&this.startGracePeriod()),this.rememberSelection()}else e.removeAllRanges()}}},Ba.prototype.startGracePeriod=function(){var e=this;clearTimeout(this.gracePeriod),this.gracePeriod=setTimeout((function(){e.gracePeriod=!1,e.selectionChanged()&&e.cm.operation((function(){return e.cm.curOp.selectionChanged=!0}))}),20)},Ba.prototype.showMultipleSelections=function(e){j(this.cm.display.cursorDiv,e.cursors),j(this.cm.display.selectionDiv,e.selection)},Ba.prototype.rememberSelection=function(){var e=this.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},Ba.prototype.selectionInEditor=function(){var e=this.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return P(this.div,t)},Ba.prototype.focus=function(){"nocursor"!=this.cm.options.readOnly&&(this.selectionInEditor()&&L()==this.div||this.showSelection(this.prepareSelection(),!0),this.div.focus())},Ba.prototype.blur=function(){this.div.blur()},Ba.prototype.getField=function(){return this.div},Ba.prototype.supportsTouch=function(){return!0},Ba.prototype.receivedFocus=function(){var e=this;this.selectionInEditor()?this.pollSelection():Zr(this.cm,(function(){return e.cm.curOp.selectionChanged=!0})),this.polling.set(this.cm.options.pollInterval,(function t(){e.cm.state.focused&&(e.pollSelection(),e.polling.set(e.cm.options.pollInterval,t))}))},Ba.prototype.selectionChanged=function(){var e=this.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},Ba.prototype.pollSelection=function(){if(null==this.readDOMTimeout&&!this.gracePeriod&&this.selectionChanged()){var e=this.getSelection(),t=this.cm;if(g&&u&&this.cm.display.gutterSpecs.length&&function(e){for(var t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}(e.anchorNode))return this.cm.triggerOnKeyDown({type:"keydown",keyCode:8,preventDefault:Math.abs}),this.blur(),void this.focus();if(!this.composing){this.rememberSelection();var n=Wa(t,e.anchorNode,e.anchorOffset),r=Wa(t,e.focusNode,e.focusOffset);n&&r&&Zr(t,(function(){ei(t.doc,So(n,r),z),(n.bad||r.bad)&&(t.curOp.selectionChanged=!0)}))}}},Ba.prototype.pollContent=function(){null!=this.readDOMTimeout&&(clearTimeout(this.readDOMTimeout),this.readDOMTimeout=null);var e,t,n,r=this.cm,o=r.display,i=r.doc.sel.primary(),a=i.from(),s=i.to();if(0==a.ch&&a.line>r.firstLine()&&(a=et(a.line-1,Ge(r.doc,a.line-1).length)),s.ch==Ge(r.doc,s.line).text.length&&s.line<r.lastLine()&&(s=et(s.line+1,0)),a.line<o.viewFrom||s.line>o.viewTo-1)return!1;a.line==o.viewFrom||0==(e=ur(r,a.line))?(t=Ye(o.view[0].line),n=o.view[0].node):(t=Ye(o.view[e].line),n=o.view[e-1].node.nextSibling);var l,c,u=ur(r,s.line);if(u==o.view.length-1?(l=o.viewTo-1,c=o.lineDiv.lastChild):(l=Ye(o.view[u+1].line)-1,c=o.view[u+1].node.previousSibling),!n)return!1;for(var f=r.doc.splitLines(function(e,t,n,r,o){var i="",a=!1,s=e.doc.lineSeparator(),l=!1;function c(){a&&(i+=s,l&&(i+=s),a=l=!1)}function u(e){e&&(c(),i+=e)}function f(t){if(1==t.nodeType){var n=t.getAttribute("cm-text");if(n)return void u(n);var i,p=t.getAttribute("cm-marker");if(p){var d=e.findMarks(et(r,0),et(o+1,0),(g=+p,function(e){return e.id==g}));return void(d.length&&(i=d[0].find(0))&&u($e(e.doc,i.from,i.to).join(s)))}if("false"==t.getAttribute("contenteditable"))return;var h=/^(pre|div|p|li|table|br)$/i.test(t.nodeName);if(!/^br$/i.test(t.nodeName)&&0==t.textContent.length)return;h&&c();for(var v=0;v<t.childNodes.length;v++)f(t.childNodes[v]);/^(pre|p)$/i.test(t.nodeName)&&(l=!0),h&&(a=!0)}else 3==t.nodeType&&u(t.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "));var g}for(;f(t),t!=n;)t=t.nextSibling,l=!1;return i}(r,n,c,t,l)),p=$e(r.doc,et(t,0),et(l,Ge(r.doc,l).text.length));f.length>1&&p.length>1;)if(K(f)==K(p))f.pop(),p.pop(),l--;else{if(f[0]!=p[0])break;f.shift(),p.shift(),t++}for(var d=0,h=0,v=f[0],g=p[0],m=Math.min(v.length,g.length);d<m&&v.charCodeAt(d)==g.charCodeAt(d);)++d;for(var y=K(f),b=K(p),x=Math.min(y.length-(1==f.length?d:0),b.length-(1==p.length?d:0));h<x&&y.charCodeAt(y.length-h-1)==b.charCodeAt(b.length-h-1);)++h;if(1==f.length&&1==p.length&&t==a.line)for(;d&&d>a.ch&&y.charCodeAt(y.length-h-1)==b.charCodeAt(b.length-h-1);)d--,h++;f[f.length-1]=y.slice(0,y.length-h).replace(/^\u200b+/,""),f[0]=f[0].slice(d).replace(/\u200b+$/,"");var w=et(t,d),k=et(l,p.length?K(p).length-h:0);return f.length>1||f[0]||tt(w,k)?(vi(r.doc,f,w,k,"+input"),!0):void 0},Ba.prototype.ensurePolled=function(){this.forceCompositionEnd()},Ba.prototype.reset=function(){this.forceCompositionEnd()},Ba.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},Ba.prototype.readFromDOMSoon=function(){var e=this;null==this.readDOMTimeout&&(this.readDOMTimeout=setTimeout((function(){if(e.readDOMTimeout=null,e.composing){if(!e.composing.done)return;e.composing=null}e.updateFromDOM()}),80))},Ba.prototype.updateFromDOM=function(){var e=this;!this.cm.isReadOnly()&&this.pollContent()||Zr(this.cm,(function(){return fr(e.cm)}))},Ba.prototype.setUneditable=function(e){e.contentEditable="false"},Ba.prototype.onKeyPress=function(e){0==e.charCode||this.composing||(e.preventDefault(),this.cm.isReadOnly()||eo(this.cm,La)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0))},Ba.prototype.readOnlyChanged=function(e){this.div.contentEditable=String("nocursor"!=e)},Ba.prototype.onContextMenu=function(){},Ba.prototype.resetPosition=function(){},Ba.prototype.needsContentAttribute=!0;var qa=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new V,this.hasSelection=!1,this.composing=null};qa.prototype.init=function(e){var t=this,n=this,r=this.cm;this.createField(e);var o=this.textarea;function i(e){if(!ve(r,e)){if(r.somethingSelected())Pa({lineWise:!1,text:r.getSelections()});else{if(!r.options.lineWiseCopyCut)return;var t=_a(r);Pa({lineWise:!0,text:t.text}),"cut"==e.type?r.setSelections(t.ranges,null,z):(n.prevInput="",o.value=t.text.join("\n"),_(o))}"cut"==e.type&&(r.state.cutIncoming=+new Date)}}e.wrapper.insertBefore(this.wrapper,e.wrapper.firstChild),v&&(o.style.width="0px"),fe(o,"input",(function(){a&&s>=9&&t.hasSelection&&(t.hasSelection=null),n.poll()})),fe(o,"paste",(function(e){ve(r,e)||Ia(e,r)||(r.state.pasteIncoming=+new Date,n.fastPoll())})),fe(o,"cut",i),fe(o,"copy",i),fe(e.scroller,"paste",(function(t){if(!kn(e,t)&&!ve(r,t)){if(!o.dispatchEvent)return r.state.pasteIncoming=+new Date,void n.focus();var i=new Event("paste");i.clipboardData=t.clipboardData,o.dispatchEvent(i)}})),fe(e.lineSpace,"selectstart",(function(t){kn(e,t)||be(t)})),fe(o,"compositionstart",(function(){var e=r.getCursor("from");n.composing&&n.composing.range.clear(),n.composing={start:e,range:r.markText(e,r.getCursor("to"),{className:"CodeMirror-composing"})}})),fe(o,"compositionend",(function(){n.composing&&(n.poll(),n.composing.range.clear(),n.composing=null)}))},qa.prototype.createField=function(e){this.wrapper=Ra(),this.textarea=this.wrapper.firstChild},qa.prototype.screenReaderLabelChanged=function(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")},qa.prototype.prepareSelection=function(){var e=this.cm,t=e.display,n=e.doc,r=mr(e);if(e.options.moveInputWithCursor){var o=$n(e,n.sel.primary().head,"div"),i=t.wrapper.getBoundingClientRect(),a=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,o.top+a.top-i.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,o.left+a.left-i.left))}return r},qa.prototype.showSelection=function(e){var t=this.cm.display;j(t.cursorDiv,e.cursors),j(t.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},qa.prototype.reset=function(e){if(!this.contextMenuPending&&!this.composing){var t=this.cm;if(t.somethingSelected()){this.prevInput="";var n=t.getSelection();this.textarea.value=n,t.state.focused&&_(this.textarea),a&&s>=9&&(this.hasSelection=n)}else e||(this.prevInput=this.textarea.value="",a&&s>=9&&(this.hasSelection=null))}},qa.prototype.getField=function(){return this.textarea},qa.prototype.supportsTouch=function(){return!1},qa.prototype.focus=function(){if("nocursor"!=this.cm.options.readOnly&&(!m||L()!=this.textarea))try{this.textarea.focus()}catch(e){}},qa.prototype.blur=function(){this.textarea.blur()},qa.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},qa.prototype.receivedFocus=function(){this.slowPoll()},qa.prototype.slowPoll=function(){var e=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,(function(){e.poll(),e.cm.state.focused&&e.slowPoll()}))},qa.prototype.fastPoll=function(){var e=!1,t=this;t.pollingFast=!0,t.polling.set(20,(function n(){t.poll()||e?(t.pollingFast=!1,t.slowPoll()):(e=!0,t.polling.set(60,n))}))},qa.prototype.poll=function(){var e=this,t=this.cm,n=this.textarea,r=this.prevInput;if(this.contextMenuPending||!t.state.focused||Le(n)&&!r&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;var o=n.value;if(o==r&&!t.somethingSelected())return!1;if(a&&s>=9&&this.hasSelection===o||y&&/[\uf700-\uf7ff]/.test(o))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var i=o.charCodeAt(0);if(8203!=i||r||(r=""),8666==i)return this.reset(),this.cm.execCommand("undo")}for(var l=0,c=Math.min(r.length,o.length);l<c&&r.charCodeAt(l)==o.charCodeAt(l);)++l;return Zr(t,(function(){La(t,o.slice(l),r.length-l,null,e.composing?"*compose":null),o.length>1e3||o.indexOf("\n")>-1?n.value=e.prevInput="":e.prevInput=o,e.composing&&(e.composing.range.clear(),e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))})),!0},qa.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},qa.prototype.onKeyPress=function(){a&&s>=9&&(this.hasSelection=null),this.fastPoll()},qa.prototype.onContextMenu=function(e){var t=this,n=t.cm,r=n.display,o=t.textarea;t.contextMenuPending&&t.contextMenuPending();var i=cr(n,e),c=r.scroller.scrollTop;if(i&&!f){n.options.resetSelectionOnContextMenu&&-1==n.doc.sel.contains(i)&&eo(n,ei)(n.doc,So(i),z);var u,p=o.style.cssText,d=t.wrapper.style.cssText,h=t.wrapper.offsetParent.getBoundingClientRect();if(t.wrapper.style.cssText="position: static",o.style.cssText="position: absolute; width: 30px; height: 30px;\n top: "+(e.clientY-h.top-5)+"px; left: "+(e.clientX-h.left-5)+"px;\n z-index: 1000; background: "+(a?"rgba(255, 255, 255, .05)":"transparent")+";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",l&&(u=window.scrollY),r.input.focus(),l&&window.scrollTo(null,u),r.input.reset(),n.somethingSelected()||(o.value=t.prevInput=" "),t.contextMenuPending=m,r.selForContextMenu=n.doc.sel,clearTimeout(r.detectingSelectAll),a&&s>=9&&g(),C){ke(e);var v=function(){de(window,"mouseup",v),setTimeout(m,20)};fe(window,"mouseup",v)}else setTimeout(m,50)}function g(){if(null!=o.selectionStart){var e=n.somethingSelected(),i=""+(e?o.value:"");o.value="⇚",o.value=i,t.prevInput=e?"":"",o.selectionStart=1,o.selectionEnd=i.length,r.selForContextMenu=n.doc.sel}}function m(){if(t.contextMenuPending==m&&(t.contextMenuPending=!1,t.wrapper.style.cssText=d,o.style.cssText=p,a&&s<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=c),null!=o.selectionStart)){(!a||a&&s<9)&&g();var e=0,i=function(){r.selForContextMenu==n.doc.sel&&0==o.selectionStart&&o.selectionEnd>0&&""==t.prevInput?eo(n,li)(n):e++<10?r.detectingSelectAll=setTimeout(i,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(i,200)}}},qa.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled="nocursor"==e,this.textarea.readOnly=!!e},qa.prototype.setUneditable=function(){},qa.prototype.needsContentAttribute=!1,function(e){var t=e.optionHandlers;function n(n,r,o,i){e.defaults[n]=r,o&&(t[n]=i?function(e,t,n){n!=ka&&o(e,t,n)}:o)}e.defineOption=n,e.Init=ka,n("value","",(function(e,t){return e.setValue(t)}),!0),n("mode",null,(function(e,t){e.doc.modeOption=t,Po(e)}),!0),n("indentUnit",2,Po,!0),n("indentWithTabs",!1),n("smartIndent",!0),n("tabSize",4,(function(e){Lo(e),Bn(e),fr(e)}),!0),n("lineSeparator",null,(function(e,t){if(e.doc.lineSep=t,t){var n=[],r=e.doc.first;e.doc.iter((function(e){for(var o=0;;){var i=e.text.indexOf(t,o);if(-1==i)break;o=i+t.length,n.push(et(r,i))}r++}));for(var o=n.length-1;o>=0;o--)vi(e.doc,t,n[o],et(n[o].line,n[o].ch+t.length))}})),n("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"),n!=ka&&e.refresh()})),n("specialCharPlaceholder",Qt,(function(e){return e.refresh()}),!0),n("electricChars",!0),n("inputStyle",m?"contenteditable":"textarea",(function(){throw new Error("inputStyle can not (yet) be changed in a running editor")}),!0),n("spellcheck",!1,(function(e,t){return e.getInputField().spellcheck=t}),!0),n("autocorrect",!1,(function(e,t){return e.getInputField().autocorrect=t}),!0),n("autocapitalize",!1,(function(e,t){return e.getInputField().autocapitalize=t}),!0),n("rtlMoveVisually",!x),n("wholeLineUpdateBefore",!0),n("theme","default",(function(e){wa(e),go(e)}),!0),n("keyMap","default",(function(e,t,n){var r=Yi(t),o=n!=ka&&Yi(n);o&&o.detach&&o.detach(e,r),r.attach&&r.attach(e,o||null)})),n("extraKeys",null),n("configureMouse",null),n("lineWrapping",!1,Sa,!0),n("gutters",[],(function(e,t){e.display.gutterSpecs=ho(t,e.options.lineNumbers),go(e)}),!0),n("fixedGutter",!0,(function(e,t){e.display.gutters.style.left=t?ar(e.display)+"px":"0",e.refresh()}),!0),n("coverGutterNextToScrollbar",!1,(function(e){return Ur(e)}),!0),n("scrollbarStyle","native",(function(e){Hr(e),Ur(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)}),!0),n("lineNumbers",!1,(function(e,t){e.display.gutterSpecs=ho(e.options.gutters,t),go(e)}),!0),n("firstLineNumber",1,go,!0),n("lineNumberFormatter",(function(e){return e}),go,!0),n("showCursorWhenSelecting",!1,gr,!0),n("resetSelectionOnContextMenu",!0),n("lineWiseCopyCut",!0),n("pasteLinesPerSelection",!0),n("selectionsMayTouch",!1),n("readOnly",!1,(function(e,t){"nocursor"==t&&(Or(e),e.display.input.blur()),e.display.input.readOnlyChanged(t)})),n("screenReaderLabel",null,(function(e,t){t=""===t?null:t,e.display.input.screenReaderLabelChanged(t)})),n("disableInput",!1,(function(e,t){t||e.display.input.reset()}),!0),n("dragDrop",!0,Oa),n("allowDropFileTypes",null),n("cursorBlinkRate",530),n("cursorScrollMargin",0),n("cursorHeight",1,gr,!0),n("singleCursorHeightPerLine",!0,gr,!0),n("workTime",100),n("workDelay",100),n("flattenSpans",!0,Lo,!0),n("addModeClass",!1,Lo,!0),n("pollInterval",100),n("undoDepth",200,(function(e,t){return e.doc.history.undoDepth=t})),n("historyEventDelay",1250),n("viewportMargin",10,(function(e){return e.refresh()}),!0),n("maxHighlightLength",1e4,Lo,!0),n("moveInputWithCursor",!0,(function(e,t){t||e.display.input.resetPosition()})),n("tabindex",null,(function(e,t){return e.display.input.getField().tabIndex=t||""})),n("autofocus",null),n("direction","ltr",(function(e,t){return e.doc.setDirection(t)}),!0),n("phrases",null)}(Ea),function(e){var t=e.optionHandlers,n=e.helpers={};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,n){var r=this.options,o=r[e];r[e]==n&&"mode"!=e||(r[e]=n,t.hasOwnProperty(e)&&eo(this,t[e])(this,n,o),he(this,"optionChange",this,e))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](Yi(e))},removeKeyMap:function(e){for(var t=this.state.keyMaps,n=0;n<t.length;++n)if(t[n]==e||t[n].name==e)return t.splice(n,1),!0},addOverlay:to((function(t,n){var r=t.token?t:e.getMode(this.options,t);if(r.startState)throw new Error("Overlays may not be stateful.");!function(e,t,n){for(var r=0,o=n(t);r<e.length&&n(e[r])<=o;)r++;e.splice(r,0,t)}(this.state.overlays,{mode:r,modeSpec:t,opaque:n&&n.opaque,priority:n&&n.priority||0},(function(e){return e.priority})),this.state.modeGen++,fr(this)})),removeOverlay:to((function(e){for(var t=this.state.overlays,n=0;n<t.length;++n){var r=t[n].modeSpec;if(r==e||"string"==typeof e&&r.name==e)return t.splice(n,1),this.state.modeGen++,void fr(this)}})),indentLine:to((function(e,t,n){"string"!=typeof t&&"number"!=typeof t&&(t=null==t?this.options.smartIndent?"smart":"prev":t?"add":"subtract"),Qe(this.doc,e)&&Ta(this,e,t,n)})),indentSelection:to((function(e){for(var t=this.doc.sel.ranges,n=-1,r=0;r<t.length;r++){var o=t[r];if(o.empty())o.head.line>n&&(Ta(this,o.head.line,e,!0),n=o.head.line,r==this.doc.sel.primIndex&&Pr(this));else{var i=o.from(),a=o.to(),s=Math.max(n,i.line);n=Math.min(this.lastLine(),a.line-(a.ch?0:1))+1;for(var l=s;l<n;++l)Ta(this,l,e);var c=this.doc.sel.ranges;0==i.ch&&t.length==c.length&&c[r].from().ch>0&&Xo(this.doc,r,new Ao(i,c[r].to()),z)}}})),getTokenAt:function(e,t){return yt(this,e,t)},getLineTokens:function(e,t){return yt(this,et(e),t,!0)},getTokenTypeAt:function(e){e=st(this.doc,e);var t,n=pt(this,Ge(this.doc,e.line)),r=0,o=(n.length-1)/2,i=e.ch;if(0==i)t=n[2];else for(;;){var a=r+o>>1;if((a?n[2*a-1]:0)>=i)o=a;else{if(!(n[2*a+1]<i)){t=n[2*a+2];break}r=a+1}}var s=t?t.indexOf("overlay "):-1;return s<0?t:0==s?null:t.slice(0,s-1)},getModeAt:function(t){var n=this.doc.mode;return n.innerMode?e.innerMode(n,this.getTokenAt(t).state).mode:n},getHelper:function(e,t){return this.getHelpers(e,t)[0]},getHelpers:function(e,t){var r=[];if(!n.hasOwnProperty(t))return r;var o=n[t],i=this.getModeAt(e);if("string"==typeof i[t])o[i[t]]&&r.push(o[i[t]]);else if(i[t])for(var a=0;a<i[t].length;a++){var s=o[i[t][a]];s&&r.push(s)}else i.helperType&&o[i.helperType]?r.push(o[i.helperType]):o[i.name]&&r.push(o[i.name]);for(var l=0;l<o._global.length;l++){var c=o._global[l];c.pred(i,this)&&-1==B(r,c.val)&&r.push(c.val)}return r},getStateAfter:function(e,t){var n=this.doc;return dt(this,(e=at(n,null==e?n.first+n.size-1:e))+1,t).state},cursorCoords:function(e,t){var n=this.doc.sel.primary();return $n(this,null==e?n.head:"object"==typeof e?st(this.doc,e):e?n.from():n.to(),t||"page")},charCoords:function(e,t){return Gn(this,st(this.doc,e),t||"page")},coordsChar:function(e,t){return Yn(this,(e=qn(this,e,t||"page")).left,e.top)},lineAtHeight:function(e,t){return e=qn(this,{top:e,left:0},t||"page").top,Xe(this.doc,e+this.display.viewOffset)},heightAtLine:function(e,t,n){var r,o=!1;if("number"==typeof e){var i=this.doc.first+this.doc.size-1;e<this.doc.first?e=this.doc.first:e>i&&(e=i,o=!0),r=Ge(this.doc,e)}else r=e;return Hn(this,r,{top:0,left:0},t||"page",n||o).top+(o?this.doc.height-Wt(r):0)},defaultTextHeight:function(){return rr(this.display)},defaultCharWidth:function(){return or(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,n,r,o){var i,a,s,l=this.display,c=(e=$n(this,st(this.doc,e))).bottom,u=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),l.sizer.appendChild(t),"over"==r)c=e.top;else if("above"==r||"near"==r){var f=Math.max(l.wrapper.clientHeight,this.doc.height),p=Math.max(l.sizer.clientWidth,l.lineSpace.clientWidth);("above"==r||e.bottom+t.offsetHeight>f)&&e.top>t.offsetHeight?c=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=f&&(c=e.bottom),u+t.offsetWidth>p&&(u=p-t.offsetWidth)}t.style.top=c+"px",t.style.left=t.style.right="","right"==o?(u=l.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==o?u=0:"middle"==o&&(u=(l.sizer.clientWidth-t.offsetWidth)/2),t.style.left=u+"px"),n&&(i=this,a={left:u,top:c,right:u+t.offsetWidth,bottom:c+t.offsetHeight},null!=(s=Tr(i,a)).scrollTop&&_r(i,s.scrollTop),null!=s.scrollLeft&&Rr(i,s.scrollLeft))},triggerOnKeyDown:to(ua),triggerOnKeyPress:to(pa),triggerOnKeyUp:fa,triggerOnMouseDown:to(ga),execCommand:function(e){if(ta.hasOwnProperty(e))return ta[e].call(null,this)},triggerElectric:to((function(e){Fa(this,e)})),findPosH:function(e,t,n,r){var o=1;t<0&&(o=-1,t=-t);for(var i=st(this.doc,e),a=0;a<t&&!(i=Da(this.doc,i,o,n,r)).hitSide;++a);return i},moveH:to((function(e,t){var n=this;this.extendSelectionsBy((function(r){return n.display.shift||n.doc.extend||r.empty()?Da(n.doc,r.head,e,t,n.options.rtlMoveVisually):e<0?r.from():r.to()}),H)})),deleteH:to((function(e,t){var n=this.doc.sel,r=this.doc;n.somethingSelected()?r.replaceSelection("",null,"+delete"):Xi(this,(function(n){var o=Da(r,n.head,e,t,!1);return e<0?{from:o,to:n.head}:{from:n.head,to:o}}))})),findPosV:function(e,t,n,r){var o=1,i=r;t<0&&(o=-1,t=-t);for(var a=st(this.doc,e),s=0;s<t;++s){var l=$n(this,a,"div");if(null==i?i=l.left:l.left=i,(a=Va(this,l,o,n)).hitSide)break}return a},moveV:to((function(e,t){var n=this,r=this.doc,o=[],i=!this.display.shift&&!r.extend&&r.sel.somethingSelected();if(r.extendSelectionsBy((function(a){if(i)return e<0?a.from():a.to();var s=$n(n,a.head,"div");null!=a.goalColumn&&(s.left=a.goalColumn),o.push(s.left);var l=Va(n,s,e,t);return"page"==t&&a==r.sel.primary()&&Mr(n,Gn(n,l,"div").top-s.top),l}),H),o.length)for(var a=0;a<r.sel.ranges.length;a++)r.sel.ranges[a].goalColumn=o[a]})),findWordAt:function(e){var t=Ge(this.doc,e.line).text,n=e.ch,r=e.ch;if(t){var o=this.getHelper(e,"wordChars");"before"!=e.sticky&&r!=t.length||!n?++r:--n;for(var i=t.charAt(n),a=ee(i,o)?function(e){return ee(e,o)}:/\s/.test(i)?function(e){return/\s/.test(e)}:function(e){return!/\s/.test(e)&&!ee(e)};n>0&&a(t.charAt(n-1));)--n;for(;r<t.length&&a(t.charAt(r));)++r}return new Ao(et(e.line,n),et(e.line,r))},toggleOverwrite:function(e){null!=e&&e==this.state.overwrite||((this.state.overwrite=!this.state.overwrite)?I(this.display.cursorDiv,"CodeMirror-overwrite"):S(this.display.cursorDiv,"CodeMirror-overwrite"),he(this,"overwriteToggle",this,this.state.overwrite))},hasFocus:function(){return this.display.input.getField()==L()},isReadOnly:function(){return!(!this.options.readOnly&&!this.doc.cantEdit)},scrollTo:to((function(e,t){Lr(this,e,t)})),getScrollInfo:function(){var e=this.display.scroller;return{left:e.scrollLeft,top:e.scrollTop,height:e.scrollHeight-Sn(this)-this.display.barHeight,width:e.scrollWidth-Sn(this)-this.display.barWidth,clientHeight:jn(this),clientWidth:En(this)}},scrollIntoView:to((function(e,t){null==e?(e={from:this.doc.sel.primary().head,to:null},null==t&&(t=this.options.cursorScrollMargin)):"number"==typeof e?e={from:et(e,0),to:null}:null==e.from&&(e={from:e,to:null}),e.to||(e.to=e.from),e.margin=t||0,null!=e.from.line?function(e,t){Ir(e),e.curOp.scrollToPos=t}(this,e):Fr(this,e.from,e.to,e.margin)})),setSize:to((function(e,t){var n=this,r=function(e){return"number"==typeof e||/^\d+$/.test(String(e))?e+"px":e};null!=e&&(this.display.wrapper.style.width=r(e)),null!=t&&(this.display.wrapper.style.height=r(t)),this.options.lineWrapping&&Vn(this);var o=this.display.viewFrom;this.doc.iter(o,this.display.viewTo,(function(e){if(e.widgets)for(var t=0;t<e.widgets.length;t++)if(e.widgets[t].noHScroll){pr(n,o,"widget");break}++o})),this.curOp.forceUpdate=!0,he(this,"refresh",this)})),operation:function(e){return Zr(this,e)},startOperation:function(){return Gr(this)},endOperation:function(){return $r(this)},refresh:to((function(){var e=this.display.cachedTextHeight;fr(this),this.curOp.forceUpdate=!0,Bn(this),Lr(this,this.doc.scrollLeft,this.doc.scrollTop),co(this.display),(null==e||Math.abs(e-rr(this.display))>.5||this.options.lineWrapping)&&lr(this),he(this,"refresh",this)})),swapDoc:to((function(e){var t=this.doc;return t.cm=null,this.state.selectingText&&this.state.selectingText(),No(this,e),Bn(this),this.display.input.reset(),Lr(this,e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,ln(this,"swapDoc",this,t),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}},ye(e),e.registerHelper=function(t,r,o){n.hasOwnProperty(t)||(n[t]=e[t]={_global:[]}),n[t][r]=o},e.registerGlobalHelper=function(t,r,o,i){e.registerHelper(t,r,i),n[t]._global.push({pred:o,val:i})}}(Ea);var Ga="iter insert remove copy getEditor constructor".split(" ");for(var $a in Pi.prototype)Pi.prototype.hasOwnProperty($a)&&B(Ga,$a)<0&&(Ea.prototype[$a]=function(e){return function(){return e.apply(this.doc,arguments)}}(Pi.prototype[$a]));return ye(Pi),Ea.inputStyles={textarea:qa,contenteditable:Ba},Ea.defineMode=function(e){Ea.defaults.mode||"null"==e||(Ea.defaults.mode=e),Re.apply(this,arguments)},Ea.defineMIME=function(e,t){Ne[e]=t},Ea.defineMode("null",(function(){return{token:function(e){return e.skipToEnd()}}})),Ea.defineMIME("text/plain","null"),Ea.defineExtension=function(e,t){Ea.prototype[e]=t},Ea.defineDocExtension=function(e,t){Pi.prototype[e]=t},Ea.fromTextArea=function(e,t){if((t=t?R(t):{}).value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),null==t.autofocus){var n=L();t.autofocus=n==e||null!=e.getAttribute("autofocus")&&n==document.body}function r(){e.value=s.getValue()}var o;if(e.form&&(fe(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var i=e.form;o=i.submit;try{var a=i.submit=function(){r(),i.submit=o,i.submit(),i.submit=a}}catch(e){}}t.finishInit=function(n){n.save=r,n.getTextArea=function(){return e},n.toTextArea=function(){n.toTextArea=isNaN,r(),e.parentNode.removeChild(n.getWrapperElement()),e.style.display="",e.form&&(de(e.form,"submit",r),t.leaveSubmitMethodAlone||"function"!=typeof e.form.submit||(e.form.submit=o))}},e.style.display="none";var s=Ea((function(t){return e.parentNode.insertBefore(t,e.nextSibling)}),t);return s},function(e){e.off=de,e.on=fe,e.wheelEventPixels=wo,e.Doc=Pi,e.splitLines=Pe,e.countColumn=D,e.findColumn=q,e.isWordChar=Z,e.Pass=U,e.signal=he,e.Line=Gt,e.changeEnd=Eo,e.scrollbarModel=Wr,e.Pos=et,e.cmpPos=tt,e.modes=_e,e.mimeModes=Ne,e.resolveMode=De,e.getMode=Ve,e.modeExtensions=Be,e.extendMode=Ue,e.copyState=ze,e.startState=He,e.innerMode=We,e.commands=ta,e.keyMap=Wi,e.keyName=Ji,e.isModifierKey=$i,e.lookupKey=Gi,e.normalizeKeyMap=qi,e.StringStream=qe,e.SharedTextMarker=Ei,e.TextMarker=Oi,e.LineWidget=ki,e.e_preventDefault=be,e.e_stopPropagation=xe,e.e_stop=ke,e.addClass=I,e.contains=P,e.rmClass=S,e.keyNames=Vi}(Ea),Ea.version="5.61.1",Ea}()},function(e,t){e.exports=function(e){if("function"!=typeof e)throw TypeError(String(e)+" is not a function");return e}},function(e,t,n){var r=n(579),o=Math.min;e.exports=function(e){return e>0?o(r(e),9007199254740991):0}},function(e,t,n){var r,o,i,a=n(664),s=n(517),l=n(519),c=n(525),u=n(522),f=n(610),p=n(581),d=n(560),h=s.WeakMap;if(a||f.state){var v=f.state||(f.state=new h),g=v.get,m=v.has,y=v.set;r=function(e,t){if(m.call(v,e))throw new TypeError("Object already initialized");return t.facade=e,y.call(v,e,t),t},o=function(e){return g.call(v,e)||{}},i=function(e){return m.call(v,e)}}else{var b=p("state");d[b]=!0,r=function(e,t){if(u(e,b))throw new TypeError("Object already initialized");return t.facade=e,c(e,b,t),t},o=function(e){return u(e,b)?e[b]:{}},i=function(e){return u(e,b)}}e.exports={set:r,get:o,has:i,enforce:function(e){return i(e)?o(e):r(e,{})},getterFor:function(e){return function(t){var n;if(!l(t)||(n=o(t)).type!==e)throw TypeError("Incompatible receiver, "+e+" required");return n}}}},function(e,t,n){var r=n(558),o=n(602),i=n(529),a=n(539),s=n(615),l=[].push,c=function(e){var t=1==e,n=2==e,c=3==e,u=4==e,f=6==e,p=7==e,d=5==e||f;return function(h,v,g,m){for(var y,b,x=i(h),w=o(x),k=r(v,g,3),C=a(w.length),A=0,O=m||s,S=t?O(h,C):n||p?O(h,0):void 0;C>A;A++)if((d||A in w)&&(b=k(y=w[A],A,x),e))if(t)S[A]=b;else if(b)switch(e){case 3:return!0;case 5:return y;case 6:return A;case 2:l.call(S,y)}else switch(e){case 4:return!1;case 7:l.call(S,y)}return f?-1:c||u?u:S}};e.exports={forEach:c(0),map:c(1),filter:c(2),some:c(3),every:c(4),find:c(5),findIndex:c(6),filterOut:c(7)}},function(e,t,n){var r=n(777),o=n(782);e.exports=function(e,t){var n=o(e,t);return r(n)?n:void 0}},function(e,t,n){var r=n(553),o=n(778),i=n(779),a=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":a&&a in Object(e)?o(e):i(e)}},function(e,t,n){e.exports=n(877)},function(e,t,n){e.exports=n(889)},function(e,t,n){e.exports=n(968)},function(e,t,n){var r=n(520),o=n(576),i=n(548),a=n(528),s=n(578),l=n(522),c=n(656),u=Object.getOwnPropertyDescriptor;t.f=r?u:function(e,t){if(e=a(e),t=s(t,!0),c)try{return u(e,t)}catch(e){}if(l(e,t))return i(!o.f.call(e,t),e[t])}},function(e,t){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t){e.exports=!0},function(e,t,n){var r=n(614),o=n(530).f,i=n(525),a=n(522),s=n(747),l=n(518)("toStringTag");e.exports=function(e,t,n,c){if(e){var u=n?e:e.prototype;a(u,l)||o(u,l,{configurable:!0,value:t}),c&&!r&&i(u,"toString",s)}}},function(e,t,n){n(668);var r=n(760),o=n(517),i=n(564),a=n(525),s=n(552),l=n(518)("toStringTag");for(var c in r){var u=o[c],f=u&&u.prototype;f&&i(f)!==l&&a(f,l,c),s[c]=s.Array}},function(e,t){e.exports={}},function(e,t,n){var r=n(532).Symbol;e.exports=r},function(e,t,n){var r=n(585),o=n(620);e.exports=function(e){return null!=e&&o(e.length)&&!r(e)}},function(e,t,n){var r=n(680),o=n(681),i=n(554);e.exports=function(e){return i(e)?r(e):o(e)}},function(e,t,n){var r=n(521),o=n(693),i=n(539),a=n(558),s=n(627),l=n(692),c=function(e,t){this.stopped=e,this.result=t};e.exports=function(e,t,n){var u,f,p,d,h,v,g,m=n&&n.that,y=!(!n||!n.AS_ENTRIES),b=!(!n||!n.IS_ITERATOR),x=!(!n||!n.INTERRUPTED),w=a(t,m,1+y+x),k=function(e){return u&&l(u),new c(!0,e)},C=function(e){return y?(r(e),x?w(e[0],e[1],k):w(e[0],e[1])):x?w(e,k):w(e)};if(b)u=e;else{if("function"!=typeof(f=s(e)))throw TypeError("Target is not iterable");if(o(f)){for(p=0,d=i(e.length);d>p;p++)if((h=C(e[p]))&&h instanceof c)return h;return new c(!1)}u=f.call(e)}for(v=u.next;!(g=v.call(u)).done;){try{h=C(g.value)}catch(e){throw l(u),e}if("object"==typeof h&&h&&h instanceof c)return h}return new c(!1)}},function(e,t){var n={}.toString;e.exports=function(e){return n.call(e).slice(8,-1)}},function(e,t,n){var r=n(538);e.exports=function(e,t,n){if(r(e),void 0===t)return e;switch(n){case 0:return function(){return e.call(t)};case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,o){return e.call(t,n,r,o)}}return function(){return e.apply(t,arguments)}}},function(e,t,n){var r=n(658),o=n(606);e.exports=Object.keys||function(e){return r(e,o)}},function(e,t){e.exports={}},function(e,t,n){var r=n(557);e.exports=Array.isArray||function(e){return"Array"==r(e)}},function(e,t,n){var r,o=n(521),i=n(662),a=n(606),s=n(560),l=n(663),c=n(603),u=n(581),f=u("IE_PROTO"),p=function(){},d=function(e){return"<script>"+e+"<\/script>"},h=function(){try{r=document.domain&&new ActiveXObject("htmlfile")}catch(e){}var e,t;h=r?function(e){e.write(d("")),e.close();var t=e.parentWindow.Object;return e=null,t}(r):((t=c("iframe")).style.display="none",l.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(d("document.F=Object")),e.close(),e.F);for(var n=a.length;n--;)delete h.prototype[a[n]];return h()};s[f]=!0,e.exports=Object.create||function(e,t){var n;return null!==e?(p.prototype=o(e),n=new p,p.prototype=null,n[f]=e):n=h(),void 0===t?n:i(n,t)}},function(e,t,n){var r=n(525);e.exports=function(e,t,n,o){o&&o.enumerable?e[t]=n:r(e,t,n)}},function(e,t,n){var r=n(614),o=n(557),i=n(518)("toStringTag"),a="Arguments"==o(function(){return arguments}());e.exports=r?o:function(e){var t,n,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=Object(e),i))?n:a?o(t):"Object"==(r=o(t))&&"function"==typeof t.callee?"Arguments":r}},function(e,t,n){var r=n(515),o=n(518),i=n(580),a=o("species");e.exports=function(e){return i>=51||!r((function(){var t=[];return(t.constructor={})[a]=function(){return{foo:1}},1!==t[e](Boolean).foo}))}},function(e,t,n){var r=n(522),o=n(529),i=n(581),a=n(671),s=i("IE_PROTO"),l=Object.prototype;e.exports=a?Object.getPrototypeOf:function(e){return e=o(e),r(e,s)?e[s]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?l:null}},function(e,t,n){"use strict";var r=n(578),o=n(530),i=n(548);e.exports=function(e,t,n){var a=r(t);a in e?o.f(e,a,i(0,n)):e[a]=n}},function(e,t,n){var r=n(584),o=n(674);e.exports=function(e,t,n,i){var a=!n;n||(n={});for(var s=-1,l=t.length;++s<l;){var c=t[s],u=i?i(n[c],e[c],c,n,e):void 0;void 0===u&&(u=e[c]),a?o(n,c,u):r(n,c,u)}return n}},function(e,t){var n=Object.prototype;e.exports=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||n)}},function(e,t,n){var r=n(842),o=n(843),i=n(629),a=n(844);e.exports=function(e,t){return r(e)||o(e,t)||i(e,t)||a()},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,n){"use strict";var r=n(538),o=function(e){var t,n;this.promise=new e((function(e,r){if(void 0!==t||void 0!==n)throw TypeError("Bad Promise constructor");t=e,n=r})),this.resolve=r(t),this.reject=r(n)};e.exports.f=function(e){return new o(e)}},function(e,t,n){var r=n(590);e.exports=function(e){if("string"==typeof e||r(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}},function(e,t,n){e.exports=n(969)},function(e,t,n){var r=n(999),o=n(643),i=n(1e3),a=n(1001),s=n(1002),l=n(543),c=n(677),u=c(r),f=c(o),p=c(i),d=c(a),h=c(s),v=l;(r&&"[object DataView]"!=v(new r(new ArrayBuffer(1)))||o&&"[object Map]"!=v(new o)||i&&"[object Promise]"!=v(i.resolve())||a&&"[object Set]"!=v(new a)||s&&"[object WeakMap]"!=v(new s))&&(v=function(e){var t=l(e),n="[object Object]"==t?e.constructor:void 0,r=n?c(n):"";if(r)switch(r){case u:return"[object DataView]";case f:return"[object Map]";case p:return"[object Promise]";case d:return"[object Set]";case h:return"[object WeakMap]"}return t}),e.exports=v},function(e,t,n){"use strict";(function(e){n.d(t,"a",(function(){return Ge})),n.d(t,"b",(function(){return $e})),n.d(t,"c",(function(){return xe})),n.d(t,"d",(function(){return me})),n.d(t,"e",(function(){return ve}));var r=n(0),o=n.n(r),i=n(172);function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function l(e,t,n){return t&&s(e.prototype,t),n&&s(e,n),e}function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(){return(u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function f(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function p(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?f(Object(n),!0).forEach((function(t){c(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):f(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function d(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&v(e,t)}function h(e){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function v(e,t){return(v=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function g(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function m(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function y(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?m(e):t}function b(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=h(e);if(t){var o=h(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return y(this,n)}}function x(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,o=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==s.return||s.return()}finally{if(o)throw i}}return n}(e,t)||k(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(e){return function(e){if(Array.isArray(e))return C(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||k(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function k(e,t){if(e){if("string"==typeof e)return C(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?C(e,t):void 0}}function C(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var A=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(t){function n(e,t){for(var n=0,r=0;r<e.length;r++)n=(n<<5)-n+e.charCodeAt(r),n|=0;return t[Math.abs(n)%t.length]}function r(e,t){var n=t.namespace;if(t.useColors){var r=t.color,o=" ".concat("[3"+(r<8?r:"8;5;"+r),";1m").concat(n," [0m");e[0]=o+e[0].split("\n").join("\n"+o)}else e[0]=n+" "+e[0]}function o(e,t){if(e[0]=(t.useColors?"%c":"")+t.namespace,t.useColors){var n="color: "+t.color,r=0,o=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(r++,"%c"===e&&(o=r))})),e.splice(o,0,n)}}var i=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function a(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1?arguments[1]:void 0;return function(){for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];e&&o.unshift(e);var a=t.namespaces.split(",").map((function(e){return"*"===e[e.length-1]?new RegExp("^"+e.slice(0,e.length-1)+".*$"):new RegExp("^"+e+"$")}));a.some((function(t){return t.test(e)})),n(e,t.colors),t.useColors}}void 0===e||"renderer"===e.type||!0===e.browser||e.__nwjs?t.exports=function(t){return a(t,function(){var t;try{t=localStorage.getItem("debug")}catch(e){}return!t&&void 0!==e&&"env"in e&&(t=e.env.DEBUG),{namespaces:t||"",colors:i,useColors:!0,formatArgs:o}}())}:t.exports=function(t){return a(t,{namespaces:e.env.DEBUG||"",colors:[6,2,3,4,5,1],useColors:!0,formatArgs:r})}})),O=A("informed:ObjMap\t"),S=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return String.prototype.replace.call(e,/\['(.+?)'\]/g,".$1").split(/[,[\].]+?/).filter(Boolean)},E=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0,r=String.prototype.replace.call(t,/\['(.+?)'\]/g,".$1").split(/[,[\].]+?/).filter(Boolean).reduce((function(e,t){return null!=e?e[t]:e}),e);return void 0===r||r===e?n:r},j=function(e){return".".concat(e).replace(/(.*)[.[].*/,"$1").replace(/\./,"")},T=function(e,t){var n=j(t),r=function(e){return e.replace(j(e),"").replace(/\./,"")}(t),o=n?E(e,n):e;return!(!o||!Object.hasOwnProperty.call(o,r.replace(/\[(.*)\]/,"$1")))},M=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0;String.prototype.replace.call(t,/\['(.+?)'\]/g,".$1").split(/[,[\].]+?/).filter(Boolean).reduce((function(e,t,r,o){return r===o.length-1?(e[t]=n,e[t]):void 0===e[t]?(Number.isInteger(+o[r+1])?e[t]=[]:e[t]={},e[t]):(Number.isInteger(+o[r+1])&&!Array.isArray(e[t])&&(e[t]=[]),e[t])}),e)},P=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=!1;return String.prototype.replace.call(t,/\['(.+?)'\]/g,".$1").split(/[,[\].]+?/).filter(Boolean).reduce((function(e,t,r,o){return void 0===e?e:r===o.length-1?(delete e[t],n=!0,e[t]):e[t]}),e),n},L=function(e){var t=S(e);return Number.isInteger(+t[t.length-1])},I=function(){function e(){a(this,e)}return l(e,null,[{key:"empty",value:function(e){return 0===function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=Object.keys(e);return t.map((function(t){return e[t]}))}(e).length}},{key:"get",value:function(e,t){return E(e,t)}},{key:"has",value:function(e,t){return T(e,t)}},{key:"set",value:function(t,n,r){if(void 0!==r)O("SETTING",n,r),M(t,n,r);else if(L(n)&&void 0!==e.get(t,n)){O("Special case SETTING",n,"to undefined"),M(t,n,void 0);var o=S(n);F(t,o=o.slice(0,o.length-1))}else L(n)||void 0===e.get(t,n)||(O("Special case REMOVING",n,"from object completley"),e.delete(t,n))}},{key:"delete",value:function(e,t){O("DELETE",t),L(t)?(O("ARRAY",t),this.pullOut(e,t)):P(e,t);var n=S(t);F(e,n=n.slice(0,n.length-1))}},{key:"pullOut",value:function(e,t){var n=S(t),r=n[n.length-1];n=n.slice(0,n.length-1),O("Pulling out:",n,"index",r);var o=E(e,n);O("Array",o),Array.isArray(o)&&function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";String.prototype.replace.call(n,/\['(.+?)'\]/g,".$1").split(/[,[\].]+?/).filter(Boolean).reduce((function(e,n,r,o){return void 0===e?e:r===o.length-1&&Array.isArray(e)?(t=e.splice(n,1),e[n]):e[n]}),e)}(o,r),F(e,n)}}]),e}();function F(e,t){if(0!==t.length){var n=E(e,t);(Array.isArray(n)?n.every((function(e){return null==e})):"{}"===JSON.stringify(n))&&P(e,t),F(e,t.slice(0,t.length-1))}}var _=o.a.createContext({register:function(){},deregister:function(){},setValue:function(){},setTouched:function(){},setError:function(){},update:function(){},getField:function(){},expectRemoval:function(){},getInitialValue:function(){},getSavedValue:function(){}}),N=o.a.createContext({}),R=o.a.createContext({getFullField:function(){},getValues:function(){},getOptions:function(){return{}},setInitialValue:function(){},getInitialValue:function(){},getDerrivedValue:function(){},getSavedValue:function(){},removeSavedState:function(){}}),D=o.a.createContext(),V=o.a.createContext(),B=o.a.createContext(),U=o.a.createContext(),z=o.a.createContext(),W=o.a.createContext();function H(){return Object(r.useContext)(R)}function q(e){var t=Object(r.useRef)(),n=Object(r.useRef)(!0),o=x(Object(r.useState)(e),2),i=o[0],a=o[1];t.current=i;return Object(r.useEffect)((function(){return function(){n.current=!1}}),[]),[i,function(e){t.current=e,n.current&&a(e)},function(){return t.current}]}var G=function(e){return e.type&&e.type.name?e.type.name:e.displayName||e.name||"Component"},$=function(e){var t={};if(e.inner){if(0===e.inner.length)return void I.set(t,e.path,e.message);var n,r=function(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=k(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}(e.inner);try{for(r.s();!(n=r.n()).done;){var o=n.value;I.get(t,o.path)||I.set(t,o.path,o.message)}}catch(o){r.e(o)}finally{r.f()}}return t},K=function(e,t){try{e.validateSync(t,{abortEarly:!1})}catch(e){return $(e)}},J=function(e){if(e.inner){if(0===e.inner.length)return;return e.inner[0].message}},Y=function(e,t){try{e.validateSync(t,{abortEarly:!1})}catch(e){return J(e)}},X=function(e,t){e(t);var n={};return e.errors&&e.errors.forEach((function(e){var t=e.message,r=e.dataPath,o=e.keyword,i=e.params,a=r;"required"===o&&(a="".concat(a,".").concat(i.missingProperty)),a=a.replace(".",""),I.set(n,a,t)})),n},Q=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))},Z=function(e,t,n){var r=t["ui:control"],o=t["informed:props"],i=t["input:props"],a=t["ui:before"],s=t["ui:after"],l=t.oneOf,c=t.items,u=t.enum,f=t.title,d=t.minimum,h=t.maximum,v=t.minLength,g=t.maxLength,m=t.pattern,y=t.type,b=t.properties,x=Q();i&&i.id&&(x=i.id);var w={componentType:r,field:n?"".concat(n,".").concat(e):e,type:y,uiBefore:a,uiAfter:s,properties:"object"===y?b:void 0,items:"array"===y?c:void 0,props:p(p({label:f,id:x,min:d,max:h,minLength:v,maxLength:g,pattern:m},o),i)};if(l){var k=t.oneOf.map((function(e){var t=e["input:props"],n=void 0===t?{}:t;return p({value:e.const,label:e.title},n)}));w.props.options=k}if(u){var C=t.enum.map((function(e){return{value:e,label:e}}));w.props.options=C}if(c&&c.oneOf){var A=c.oneOf.map((function(e){var t=e["input:props"],n=void 0===t?{}:t;return p({value:e.const,label:e.title},n)}));w.props.options=A}return w},ee=function(e,t,n){if(!e||t)return[];var r=e.properties,o=void 0===r?{}:r,i=e.allOf,a=e.propertyOrder,s=void 0===a?[]:a;if(Object.keys(o).length>0){var l=Object.keys(o).sort((function(e,t){var n=s.indexOf(e),r=s.indexOf(t);return(n>-1?n:s.length+1)-(r>-1?r:s.length+1)})).map((function(e){var t=o[e];return Z(e,t,n)}));return i&&l.push({componentType:"conditionals",allOf:i}),l}return[]},te=function(e,t){if(!e)return{value:e,offset:0};var n=function(e,t){if("string"==typeof e)return e.split("").map((function(e){return"#"===e?/\d/:"*"===e?/[\w]/:e}));if("function"==typeof e)return e(t);if(Array.isArray(e))return e;throw new Error("Formatter must be string, array, or function")}(t,e),r=n.findIndex((function(e){return"string"!=typeof e})),o=n.length-w(n).reverse().findIndex((function(e){return"string"!=typeof e})),i=[],a=e.split(""),s=0,l=0,c=function(e,t){for(var n=0,r=-1,o=!0;o&&n<e.length;)e[n]==t[n]?r=n:o=!1,n+=1;return r}(n.slice(0,r),a.slice(0,r));c>-1&&(s=c+1,i=i.concat(n.slice(0,c+1)),l=c+1),c<0&&(i=i.concat(n.slice(0,r)),l=r);for(var u=l;u<n.length;u++){var f=n[u];if(s!=a.length){var p=a[s],d="string"==typeof f?f===p:f.test(p);d&&"string"==typeof f?(i.push(f),s+=1):d||"string"!=typeof f?d&&"string"!=typeof f?(i.push(p),s+=1):d||"string"==typeof f||(s+=1,u-=1):s!=a.length&&i.push(f)}else{if(!("string"==typeof f&&u>=o))break;i.push(f)}}return{value:i.join(""),offset:e?i.length-e.length:0}},ne="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?r.useLayoutEffect:r.useEffect,re=function(e){var t=e.value,n=e.inputRef,o=e.maintainCursor,i=void 0===o||o,a=x(q(0),3),s=a[0],l=a[1],c=a[2],u=x(q(0),3),f=u[0],p=u[1],d=u[2];return Object(r.useLayoutEffect)((function(){if(null!=n.current&&c()){var e=c()+d();0!=d()&&i?n.current.setSelectionRange(e+1,e+1):i&&n.current.setSelectionRange(e,e)}}),[t]),{setCursorOffset:p,setCursor:l,cursor:s,getCursor:c,cursorOffset:f}},oe=A("informed:useField\t"),ie=function(e,t,n,r,o){if(null!=e)return o?o(e):t?t(e):n&&!r?te(e,n).value:e},ae=function(e,t,n,r){return t&&n?t(e):r?te(e,r).value:e},se=function(e,t,n){var r=n.required;return e||t?function(n,r){return t?Y(t,n):e?e(n,r):void 0}:r?function(e){return pe(e,r)}:void 0},le=function(e){var t=e.fieldType,n=e.setValue,r=e.onChange,o=e.multiple,i=e.ref,a=function(e){return n(e)};return"text"!==t&&"textArea"!==t&&"number"!==t||(a=function(e){return n(e.target.value,e)}),"select"===t&&(a=function(){var e=Array.from(i.current).filter((function(e){return e.selected})).map((function(e){return e.value}));n(o?e:e[0]||"")}),"checkbox"===t&&(a=function(e){n(e.target.checked),r&&r(e)}),function(e){a(e)}},ce=function(e){var t=e.setTouched,n=e.onBlur;return function(e){t(!0),n&&n(e)}},ue=function(e){var t=e.fieldType,n=e.maskedValue,r=e.multiple,o=e.value;switch(t){case"text":case"number":return n||0===n?n:"";case"textArea":return n||"";case"select":return o||(r?[]:"");case"checkbox":return!!o;default:return o}},fe=function(e){switch(e){case"text":case"number":case"checkbox":return e;default:return}},pe=function(e,t){if(t&&(null==e||""===e))return"string"==typeof t?t:"This field is required"};function de(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0,n=e.field,i=e.validate,a=e.asyncValidate,s=e.validationSchema,l=e.mask,c=e.maskWithCursorOffset,u=e.format,f=e.parse,d=e.formatter,h=e.parser,v=e.initialValue,m=e.validateOnChange,y=e.validateOnBlur,b=e.validateOnMount,k=e.asyncValidateOnBlur,C=e.maskOnBlur,A=e.allowEmptyString,O=e.onValueChange,S=e.notify,E=e.keepState,j=e.maintainCursor,T=e.debug,M=e.shadow,P=e.step,L=e.fieldType,F=e.multiple,N=e.onChange,R=e.onBlur,D=e.formController,V=e.relevant,B=e.required,U=e.keepStateIfRelevant,z=e.initialize,G=g(e,["field","validate","asyncValidate","validationSchema","mask","maskWithCursorOffset","format","parse","formatter","parser","initialValue","validateOnChange","validateOnBlur","validateOnMount","asyncValidateOnBlur","maskOnBlur","allowEmptyString","onValueChange","notify","keepState","maintainCursor","debug","shadow","step","fieldType","multiple","onChange","onBlur","formController","relevant","required","keepStateIfRelevant","initialize"]),$=Object(r.useState)(Q()),K=x($,1),J=K[0],Y=Object(r.useContext)(_),X=Object(r.useContext)(W),Z=X||U,ee=H(),pe=Object(r.useRef)(),de=Object(r.useRef)(!0),he=Object(r.useRef)(),ve=Object(r.useRef)(!1),ge=function(){return!ve.current},me=function(){return ve.current};D&&(Y=D.updater,ee=D.getFormApi());var ye,be,xe=se(i,s,{required:B}),we=Object(r.useState)((function(){return Y.getInitialValue(n)})),ke=x(we,1),Ce=ke[0],Ae=Y.getSavedValue(n);(E||Z)&&Ae?(oe("Setting field ".concat(bt,"'s kept state"),Ae),ye=Ae.value,be=Ae.touched,ee.removeSavedState(bt)):ye=null!=v?v:Ce;var Oe=q(ie(ye,l,d,h,z)),Se=x(Oe,3),Ee=Se[0],je=Se[1],Te=Se[2],Me=q(b?xe(Ee):void 0),Pe=x(Me,3),Le=Pe[0],Ie=Pe[1],Fe=Pe[2],_e=q(be),Ne=x(_e,3),Re=Ne[0],De=Ne[1],Ve=Ne[2],Be=Object(r.useState)((function(){return ae(Ee,u,f,d)})),Ue=x(Be,2),ze=Ue[0],We=Ue[1],He=Object(r.useRef)(v),qe=Object(r.useRef)(n),Ge=Object(r.useRef)();He.current=v,qe.current=n;var $e=Object(r.useRef)(null),Ke=o.a.useMemo((function(){return t||$e}),[]),Je=re({value:Ee,inputRef:Ke,maintainCursor:!!j}),Ye=Je.getCursor,Xe=Je.setCursor,Qe=Je.setCursorOffset,Ze=function(){return!0},et=function(e){var t=V||Ze,n=ee.getFullField(qe.current)||qe.current,r={path:n,parentPath:n.replace(/(.*)[.[].*/,"$1"),get:function(e,t){return I.get(e,t)}};return X&&X.relevant?t(e,r)&&X.relevant(e,r):t(e,r)},tt=q(et(ee.getValues())),nt=x(tt,3),rt=nt[0],ot=nt[1],it=nt[2],at=function(e){return!X||!X.relevant||X.relevant(e)},st=function(){var e=et(ee.getValues());return e!=it()&&ot(e),e};Object(r.useEffect)((function(){rt||E||pe.current.reset()}),[rt]);var lt=function(){return M?ee.getDerrivedValue(n):Te()},ct=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.preventUpdate;P&&ee.getStep()<P?(oe("Setting ".concat(n,"'s error to undefined as we are not at that step")),Ie(void 0),Y.setError(J,void 0,!r)):(oe("Setting ".concat(n,"'s error to ").concat(e)),Ie(e),Y.setError(J,e,!r))},ut=function(t,r){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=t;ve.current=!0,oe("Setting ".concat(n," to ").concat(i)),z&&(i=z(i));var a=ee.getOptions(),s=i;if(""!==i||A||o.allowEmptyString||a.allowEmptyStrings||(i=void 0),"number"!==e.type&&"number"!==L||void 0===i||(i=+i),r&&r.target&&r.target.selectionStart&&Xe(r.target.selectionStart),l&&!C&&(s=l(i,Ye()),i=l(i,Ye())),c&&!C){var p=c(i,Ye());s=p.value,i=p.value,Qe(p.offset)}if(u&&f&&(i=f(i),s=u(i)),d){var v=te(i,d);Qe(v.offset),i=s=v.value}h&&(i=null!=i?h(i):i),xe&&m&&!o.initial&&(oe("Validating after change ".concat(n," ").concat(i)),ct(xe(i,ee.getValues()))),je(i),We(s),O&&O(i),Y.setValue(J,i,!o.preventUpdate)},ft=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=r.preventUpdate;if(oe("Field ".concat(n," has been touched")),xe&&y&&!t&&e&&(oe("Validating after blur ".concat(n," ").concat(lt())),ct(xe(lt(),ee.getValues()))),a&&k&&!t&&e&&(oe("Validating async after blur ".concat(n," ").concat(lt())),a(lt(),ee.getValues())),l&&C){var i=l(lt());je(i),We(i),O&&O(i),Y.setValue(J,i,!o)}if(c&&C){var s=c(lt());Qe(s.offset),je(s.value),We(s.value),O&&O(s.value),Y.setValue(J,s.value,!o)}De(e),Y.setTouched(J,e,!o)},pt=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.preventUpdate,n=ie(He.current||Y.getInitialValue(qe.current),l,d,h,z);ut(n,null,{initial:!0,preventUpdate:t}),ct(b?xe(n):void 0,{preventUpdate:t}),ft(void 0,!0,{preventUpdate:t}),ve.current=!1},dt=function(e){xe&&(oe("Field validating ".concat(n," ").concat(lt())),ct(xe(lt(),e||ee.getValues())))},ht=function(e){a&&(oe("Field async validating ".concat(n," ").concat(lt())),a(lt(),e||ee.getValues()))},vt={setValue:ut,setTouched:ft,setError:ct,reset:pt,validate:dt,asyncValidate:ht,getValue:lt,getTouched:Ve,getError:Fe,getIsRelevant:it,getDirty:me,getPristine:ge,getFieldState:function(){return{value:lt(),touched:Ve(),dirty:me(),pristine:ge()}},relevant:et,multistepRelevant:at,checkRelevant:st};pe.current=vt;var gt={value:Ee,error:Le,touched:Re,maskedValue:ze,isRelevant:rt,dirty:ve.current,pristine:!ve.current};M&&(gt={error:Le,touched:Re}),oe("Render",ee.getFullField(n),gt),ne((function(){var e=ee.getFullField(qe.current);return oe("Register",J,qe.current),he.current={field:e,fieldId:J,fieldApi:vt,fieldState:gt,notify:S,keepState:E,inMultistep:Z,shadow:M},Y.register(J,he.current),function(){var e=ee.getFullField(qe.current);oe("Deregister",J,e),Y.deregister(J)}}),[]),Object(r.useEffect)((function(){var e=ee.getFullField(n);return de.current?de.current=!1:(oe("Update",n,Z),he.current.field=e,Y.update(J,he.current,Ge.current)),function(){Ge.current=e}}),[n]),ne((function(){T&&Ke&&(Ke.current.style.border="5px solid orange",setTimeout((function(){Ke.current.style.borderWidth="2px",Ke.current.style.borderStyle="inset",Ke.current.style.borderColor="initial",Ke.current.style.borderImage="initial"}),500))}));var mt=[].concat(w(Object.values(gt)),w(Object.values(e)),w(Object.values(G))),yt=function(e){return Object(r.useMemo)((function(){return rt?e:null}),w(mt))},bt=n,xt=le({fieldType:L,setValue:ut,onChange:N,multiple:F,ref:Ke}),wt=ce({setTouched:ft,onBlur:R}),kt=ue({fieldType:L,maskedValue:ze,multiple:F,value:Ee}),Ct=fe(L);return{fieldState:gt,fieldApi:vt,render:yt,ref:Ke,userProps:p(p({},G),{},{multiple:F,onChange:N,onBlur:R,id:G.id||J}),informed:p({name:bt,multiple:F,onChange:xt,onBlur:wt,value:kt,ref:Ke,type:Ct,id:G.id||J},G)}}var he,ve=function(e){var t=o.a.forwardRef((function(t,n){var r=de(t,n),i=r.fieldState,a=r.fieldApi,s=r.render,l=r.ref,c=r.userProps;return s(o.a.createElement(e,u({fieldApi:a,fieldState:i,field:t.field,forwardedRef:l,debug:t.debug,type:t.type},c)))}));return t.displayName="asField(".concat(G(e),")"),t},ge=A("informed:Text\t"),me=ve((function(e){var t=e.fieldApi,n=e.fieldState,r=g(e,["fieldApi","fieldState"]),i=n.maskedValue,a=t.setValue,s=t.setTouched,l=r.onChange,c=r.onBlur,f=r.field,p=(r.initialValue,r.forwardedRef),d=r.debug,h=r.label,v=(r.title,r.id),m=g(r,["onChange","onBlur","field","initialValue","forwardedRef","debug","label","title","id"]);return ge("Render",f),ne((function(){d&&p&&(p.current.style.background="red",setTimeout((function(){p.current.style.background="white"}),500))})),o.a.createElement(o.a.Fragment,null,h?o.a.createElement("label",{htmlFor:v}," ",h," "):null,o.a.createElement("input",u({},m,{id:v,name:f,ref:p,value:i||0===i?i:"",onChange:function(e){a(e.target.value,e),l&&l(e)},onBlur:function(e){s(!0),c&&c(e)}})))})),ye=ve((function(e){var t=e.fieldApi,n=e.fieldState,r=g(e,["fieldApi","fieldState"]),i=n.maskedValue,a=t.setValue,s=t.setTouched,l=r.onChange,c=r.onBlur,f=r.field,p=(r.initialValue,r.forwardedRef),d=r.debug,h=r.label,v=r.id,m=g(r,["onChange","onBlur","field","initialValue","forwardedRef","debug","label","id"]);return ne((function(){d&&p&&(p.current.style.background="red",setTimeout((function(){p.current.style.background="white"}),500))})),o.a.createElement(o.a.Fragment,null,h?o.a.createElement("label",{htmlFor:v}," ",h," "):null,o.a.createElement("textarea",u({},m,{id:v,name:f,ref:p,value:i||"",onChange:function(e){a(e.target.value,e),l&&l(e)},onBlur:function(e){s(!0),c&&c(e)}})))})),be=A("informed:Select\t"),xe=ve((function(e){var t=e.fieldApi,n=e.fieldState,i=g(e,["fieldApi","fieldState"]),a=n.value,s=t.setTouched,l=i.onChange,c=i.onBlur,f=i.field,p=(i.initialValue,i.options),d=i.children,h=i.forwardedRef,v=i.debug,m=i.multiple,y=i.label,b=i.id,x=g(i,["onChange","onBlur","field","initialValue","options","children","forwardedRef","debug","multiple","label","id"]),w=Object(r.useRef)();return ne((function(){v&&h&&(h.current.style.background="red",setTimeout((function(){h.current.style.background="white"}),500))})),be("Render",f,a),o.a.createElement(o.a.Fragment,null,y?o.a.createElement("label",{htmlFor:b}," ",y," "):null,o.a.createElement("select",u({},x,{id:b,multiple:m,name:f,ref:h||w,value:a||(m?[]:""),onChange:function(e){var n=Array.from((h||w).current).filter((function(e){return e.selected})).map((function(e){return e.value}));t.setValue(m?n:n[0]||""),l&&e&&l(e)},onBlur:function(e){s(!0),c&&c(e)}}),p?p.map((function(e){return o.a.createElement("option",{key:e.value,value:e.value,disabled:e.disabled},e.label)})):d))})),we=ve((function(e){var t=e.fieldApi,n=e.fieldState,r=g(e,["fieldApi","fieldState"]),i=n.value,a=t.setValue,s=t.setTouched,l=r.onChange,c=r.onBlur,f=r.field,p=(r.initialValue,r.debug,r.forwardedRef),d=r.id,h=r.label,v=g(r,["onChange","onBlur","field","initialValue","debug","forwardedRef","id","label"]);return o.a.createElement(o.a.Fragment,null,h?o.a.createElement("label",{htmlFor:d}," ",h," "):null,o.a.createElement("input",u({},v,{id:d,name:f,ref:p,checked:!!i,onChange:function(e){a(e.target.checked),l&&l(e)},onBlur:function(e){s(!0),c&&c(e)},type:"checkbox"})))})),ke=(he=function(e){var t=e.radioGroupApi,n=e.radioGroupState,r=g(e,["radioGroupApi","radioGroupState"]),i=n.value,a=t.setValue,s=t.setTouched,l=t.onChange,c=t.onBlur,f=r.value,p=r.onChange,d=r.onBlur,h=r.field,v=(r.initialValue,r.forwardedRef),m=g(r,["value","onChange","onBlur","field","initialValue","forwardedRef"]);return o.a.createElement("input",u({},m,{name:h,ref:v,value:f,checked:i===f,onChange:function(e){e.target.checked&&(a(f),p&&p(e),l&&l(e))},onBlur:function(e){s(!0),d&&d(e),c&&c(e)},type:"radio"}))},o.a.forwardRef((function(e,t){return o.a.createElement(D.Consumer,null,(function(n){var r=n.radioGroupApi,i=n.radioGroupState;return o.a.createElement(he,u({radioGroupApi:r,radioGroupState:i,ref:t},e))}))}))),Ce=function(e){d(n,e);var t=b(n);function n(){return a(this,n),t.apply(this,arguments)}return l(n,[{key:"render",value:function(){var e=this.props,t=e.options,n=e.children;return o.a.createElement(D.Provider,{value:this.groupContext},t?t.map((function(e){return o.a.createElement("label",{key:e.value},e.label," ",o.a.createElement(ke,{value:e.value}))})):n)}},{key:"groupContext",get:function(){return{radioGroupApi:p(p({},this.props.fieldApi),{},{onChange:this.props.onChange,onBlur:this.props.onBlur}),radioGroupState:this.props.fieldState}}}]),n}(r.Component),Ae=ve(Ce);var Oe=A("informed:useArrayField\t"),Se=function(e){var t=e.field,n=e.initialValue,i=e.validate,a=e.arrayFieldApiRef,s=g(e,["field","initialValue","validate","arrayFieldApiRef"]),l=H(),c=x(Object(r.useState)(new Map),1)[0],u=Object(r.useContext)(_),f=l.getFullField(t),d=u.getInitialValue(t)||n||[],h=x(q(l.getSavedValue(f)&&l.getSavedValue(f).value||d),3),v=h[0],m=h[1],y=h[2],b=x(q(v?v.map((function(){return Q()})):[]),3),k=b[0],C=b[1],A=b[2],O=Object(r.useMemo)((function(){return function(e,t){var n=null==A()?0:A().length;return i?i(e,n,t):void 0}})),S=de(p({field:t,validate:i?O:void 0,shadow:!0},s)).fieldApi;ne((function(){var e=function(e){e!==f&&(Oe("".concat(f," changed")),RegExp("".concat(f,"\\[[0-9]+\\]")).test(e)&&S.validate())};return l.emitter.on("value",e),function(){l.emitter.removeListener("value",e)}}),[t]);var E=function(e,n){Oe("Swapping","".concat(t,"[").concat(e,"] and ").concat(t,"[").concat(n,"]"));var r=w(k);k[e]&&k[n]?(r[e]=k[n],r[n]=k[e]):console.warn("Attempted to swap ".concat(e," with ").concat(n," but one of them does not exist :(")),C(r)},j=function(){k.push(Q()),C(w(k))},T=function(e){k.push(Q()),C(w(k));var t=w(y());t[k.length-1]=e,m(t)},M=k.map((function(e,n){var r={remove:function(){return function(e){Oe("EXPECTING REMOVAL OF","".concat(t,"[").concat(e,"] and ").concat(t,"[").concat(k.length-1,"]")),u.expectRemoval("".concat(t,"[").concat(e,"]")),u.expectRemoval("".concat(t,"[").concat(k.length-1,"]"));var n=k.slice(0,e).concat(k.slice(e+1,k.length));C(n);var r=y(),o=r.slice(0,e).concat(r.slice(e+1,r.length));m(o)}(n)}},o={initialValue:v&&v[n],key:e,field:"".concat(t,"[").concat(n,"]"),index:n};return p(p({arrayFieldItemApi:r,arrayFieldItemState:o},r),o)})),P={add:j,swap:E,addWithInitialValue:T,reset:function(){var e=u.getInitialValue(t)||n||[];m(e);var r=e?e.map((function(){return Q()})):[];C(r)}};a&&(a.current=P);var L={fields:M,field:t},F=p(p({},u),{},{register:function(e,t){c.set(e,t);for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];u.register.apply(u,[e,t].concat(r))},deregister:function(e){c.delete(e);for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];u.deregister.apply(u,[e].concat(n))},getInitialValue:function(e){if(RegExp("".concat(f,"\\[[0-9]+\\]")).test(e)){var n=e.replace(t,""),r=I.get(y(),n);return Oe("Resetting ".concat(n," to ").concat(r)),r}return u.getInitialValue(e)}});return{render:function(e){return o.a.createElement(_.Provider,{value:F},o.a.createElement(B.Provider,{value:P},o.a.createElement(V.Provider,{value:L},e)))},add:j,swap:E,addWithInitialValue:T,fields:M,arrayFieldState:L,arrayFieldApi:P,field:t}};function Ee(e){var t=H();return Object(r.useMemo)((function(){return function(e,t){return p(p({},t),{},{getValue:function(n){return t.getValue("".concat(e,".").concat(n))},getTouched:function(n){return t.getTouched("".concat(e,".").concat(n))},getError:function(n){return t.getError("".concat(e,".").concat(n))},setValue:function(n,r){return t.setValue("".concat(e,".").concat(n),r)},setTouched:function(n,r){return t.setTouched("".concat(e,".").concat(n),r)},setError:function(n,r){return t.setError("".concat(e,".").concat(n),r)},getInitialValue:function(n){return t.getInitialValue("".concat(e,".").concat(n))},getSavedValue:function(n){return t.getSavedValue("".concat(e,".").concat(n))},getFullField:function(n){return"".concat(t.getFullField(e),".").concat(n)}})}(e,t)}),[e])}function je(){return Object(r.useContext)(N)}var Te=function(e){var t=e.when,n=e.children;return t(je())?n:null},Me=function(e){var t=e.relevant,n=e.field,r=g(e,["relevant","field"]),i=H();if(t){var a=i.getFullField(n),s={path:a,parentPath:a.replace(/(.*)[.[].*/,"$1"),get:function(e,t){return I.get(e,t)}};return o.a.createElement(Te,{when:function(e){var n=e.values;return t(n,s)}},o.a.createElement(Pe,u({field:n},r)))}return o.a.createElement(Pe,u({field:n},r))},Pe=function(e){var t=e.children,n=g(e,["children"]),r=Se(n),o=r.render,i=r.arrayFieldState,a=r.arrayFieldApi,s=r.field;return o("function"==typeof t?t(p(p({field:s,arrayFieldApi:a,arrayFieldState:i},a),i)):t)},Le=function(e){var t=e.arrayFieldItemState,n=e.arrayFieldItemApi,i=e.children,a=Object(r.useContext)(_),s=H(),l=x(Object(r.useState)(0),2),c=(l[0],l[1]),u=x(Object(r.useState)(new Map),1)[0],f=t.field,d=Ee(f);Object(r.useEffect)((function(){var e=function(e){e.slice(0,-1!=e.lastIndexOf("[")?e.lastIndexOf("]")+1:e.length)===f&&c(Math.random())};return s.emitter.on("value",e),function(){s.emitter.removeListener("value",e)}}),[f]);var h,v,g,m,y=(h=s.getState(),v=h.values,g=h.errors,m=h.touched,{values:I.get(v,f),errors:I.get(g,f),touched:I.get(m,f)}),b=p(p({},a),{},{register:function(e,t,n){u.set(e,t),a.register(e,t,n)},deregister:function(e){u.delete(e);for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];a.deregister.apply(a,[e].concat(n))}}),w=p(p(p({},n),d),{},{reset:function(){u.forEach((function(e){e.fieldApi.reset()}))}}),k=p(p({},t),y);return"function"==typeof i?o.a.createElement(_.Provider,{value:b},o.a.createElement(U.Provider,{value:w},o.a.createElement(z.Provider,{value:k},i(p(p({arrayFieldItemApi:w,arrayFieldItemState:k},w),k))))):o.a.createElement(_.Provider,{value:b},o.a.createElement(U.Provider,{value:w},o.a.createElement(z.Provider,{value:k},i)))};Me.Items=function(e){var t=e.children;return Object(r.useContext)(V).fields.map((function(e){var n=e.arrayFieldItemState,r=e.arrayFieldItemApi,i=n.key;return o.a.createElement(Le,{key:i,arrayFieldItemApi:r,arrayFieldItemState:n},t)}))};var Ie=function(e){var t=e.components,n=Object(r.useContext)(_).fieldMap;return t?t.map((function(e,t){var r=e["ui:control"],i=n[r];return o.a.createElement(i,{key:"ui-comp-".concat(t)})})):null},Fe=A("informed:FormFields\t"),_e=function e(t){var n=t.schema,i=t.prefix,a=t.onlyValidateSchema,s=Object(r.useContext)(_).fieldMap;return Object(r.useMemo)((function(){return ee(n,a,i).map((function(t,n){var r=t.field,i=t.props,a=t.type,l=t.properties,c=t.items,f=t.componentType,p=t.uiBefore,d=t.uiAfter,h=t.allOf,v=s[f];return Fe("Rendering Field",r,t),!v&&"object"===a&&l?o.a.createElement(e,{schema:t,prefix:r,key:"ScheamField-".concat(n)}):!v&&"array"===a&&c?o.a.createElement(Ne,u({key:"ScheamField-".concat(n),field:r,items:c,uiBefore:p,uiAfter:d},i)):v&&"array"===f&&c&&"array"===a?o.a.createElement(v,u({key:"ScheamField-".concat(n),field:r,items:c,uiBefore:p,uiAfter:d},i)):"conditionals"===f?h.map((function(t){var r=t.then,i=t.if.properties;return o.a.createElement(Te,{key:"ScheamField-".concat(n),when:function(e){var t=e.values;return Object.keys(i).every((function(e){var n=i[e];return t[e]===n.const}))}},o.a.createElement(e,{schema:r}))})):v?o.a.createElement(v,u({key:"ScheamField-".concat(n),field:r},i)):null}))}),[n,i])},Ne=function(e){var t=e.field,n=e.items,r=e.uiBefore,i=e.uiAfter,a=g(e,["field","items","uiBefore","uiAfter"]);return o.a.createElement(Me,u({field:t},a),o.a.createElement(Ie,{components:r}),o.a.createElement(Me.Items,null,(function(e){var t=e.field;return o.a.createElement(o.a.Fragment,null,o.a.createElement(Ie,{components:n["ui:before"]}),o.a.createElement(_e,{schema:n,prefix:t}),o.a.createElement(Ie,{components:n["ui:after"]}))})),o.a.createElement(Ie,{components:i}))},Re={select:xe,input:me,textarea:ye,checkbox:we,radio:Ae,add:function(){var e=Object(r.useContext)(B).add;return o.a.createElement("button",{onClick:function(){e()},type:"button"},"Add")},remove:function(){var e=Object(r.useContext)(U).remove;return o.a.createElement("button",{onClick:function(){e()},type:"button"},"Remove")},array:Ne},De=A("informed:Controller\t"),Ve=function(){},Be=function(e){d(n,e);var t=b(n);function n(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,n),(e=t.call(this)).options=r;var o=r.ajv,i=r.schema,s=r.fieldMap;return e.ajv=o?new o({allErrors:!0}):null,e.ajvValidate=o?e.ajv.compile(i):null,e.fieldMap=s||Re,e.fieldsById=new Map,e.fieldsByName={get:function(t){var n;return e.fieldsById.forEach((function(e){e&&e.field===t&&(n=e)})),n}},e.onScreen={},e.expectedRemovals={},e.pulledOut={},e.savedValues={},e.state={pristine:!0,dirty:!1,invalid:!1,submits:0,step:0,validating:0,submitting:!1,values:{},errors:{},touched:{}},e.dummyField={fieldApi:{setValue:Ve,setTouched:Ve,setError:Ve,reset:Ve,validate:Ve,getValue:Ve,getTouched:Ve,getError:Ve,getFieldState:Ve,checkRelevant:Ve,getPristine:Ve,getDirty:Ve}},e.deregister=e.deregister.bind(m(e)),e.register=e.register.bind(m(e)),e.getValue=e.getValue.bind(m(e)),e.getTouched=e.getTouched.bind(m(e)),e.getError=e.getError.bind(m(e)),e.getErrors=e.getErrors.bind(m(e)),e.setValue=e.setValue.bind(m(e)),e.getValues=e.getValues.bind(m(e)),e.getStep=e.getStep.bind(m(e)),e.setStep=e.setStep.bind(m(e)),e.back=e.back.bind(m(e)),e.next=e.next.bind(m(e)),e.setCurrent=e.setCurrent.bind(m(e)),e.setTouched=e.setTouched.bind(m(e)),e.setError=e.setError.bind(m(e)),e.setFormError=e.setFormError.bind(m(e)),e.submitForm=e.submitForm.bind(m(e)),e.reset=e.reset.bind(m(e)),e.update=e.update.bind(m(e)),e.validate=e.validate.bind(m(e)),e.screenValid=e.screenValid.bind(m(e)),e.keyDown=e.keyDown.bind(m(e)),e.getField=e.getField.bind(m(e)),e.getInitialValue=e.getInitialValue.bind(m(e)),e.setInitialValue=e.setInitialValue.bind(m(e)),e.getOptions=e.getOptions.bind(m(e)),e.getFormState=e.getFormState.bind(m(e)),e.expectRemoval=e.expectRemoval.bind(m(e)),e.getSavedValue=e.getSavedValue.bind(m(e)),e.removeSavedState=e.removeSavedState.bind(m(e)),e.getDerrivedValue=e.getDerrivedValue.bind(m(e)),e.setValues=e.setValues.bind(m(e)),e.resetField=e.resetField.bind(m(e)),e.fieldExists=e.fieldExists.bind(m(e)),e.validateField=e.validateField.bind(m(e)),e.notify=e.notify.bind(m(e)),e.validating=e.validating.bind(m(e)),e.validated=e.validated.bind(m(e)),e.getDirty=e.getDirty.bind(m(e)),e.getPristine=e.getPristine.bind(m(e)),e.updater={register:e.register,deregister:e.deregister,getField:e.getField,update:e.update,fieldMap:e.fieldMap,setValue:function(t,n){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=e.fieldsById.get(t);o.shadow||I.set(e.state.values,o.field,o.fieldApi.getValue()),o.fieldApi.relevant(e.state.values)||I.delete(e.state.values,o.field),e.fieldsById.forEach((function(t){var n=t.fieldApi.checkRelevant();t.fieldApi.multistepRelevant(e.state.values)&&(n||t.keepState)||(I.delete(e.state.values,t.field),I.delete(e.state.touched,t.field),I.delete(e.state.errors,t.field))})),r&&(e.emit("change"),e.emit("value",o.field,n))},setTouched:function(t,n){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=e.fieldsById.get(t);!o.shadow&&o.fieldApi.getIsRelevant()&&I.set(e.state.touched,o.field,o.fieldApi.getTouched()),o.shadow&&null!=o.fieldApi.getError()&&o.fieldApi.relevant(e.state.values)&&I.set(e.state.touched,o.field,o.fieldApi.getTouched()),r&&e.emit("change")},setError:function(t,n){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=e.fieldsById.get(t);!o.shadow&&o.fieldApi.getIsRelevant()&&I.set(e.state.errors,o.field,o.fieldApi.getError());var i=I.get(e.state.errors,o.field);(o.shadow&&null!=o.fieldApi.getError()&&o.fieldApi.relevant(e.state.values)||o.shadow&&void 0===o.fieldApi.getError()&&o.fieldApi.relevant(e.state.values)&&"string"==typeof i)&&I.set(e.state.errors,o.field,o.fieldApi.getError()),r&&e.emit("change")},expectRemoval:e.expectRemoval,getInitialValue:e.getInitialValue,getSavedValue:e.getSavedValue},e.formApi={setValue:e.setValue,setTouched:e.setTouched,setError:e.setError,setFormError:e.setFormError,setValues:e.setValues,setInitialValue:e.setInitialValue,getValue:e.getValue,getTouched:e.getTouched,getError:e.getError,reset:e.reset,submitForm:e.submitForm,getState:e.getFormState,getValues:e.getValues,getFullField:e.getFullField,fieldExists:e.fieldExists,getInitialValue:e.getInitialValue,validate:e.validate,validateField:e.validateField,screenValid:e.screenValid,resetField:e.resetField,getOptions:e.getOptions,emitter:m(e),getSavedValue:e.getSavedValue,removeSavedState:e.removeSavedState,getDerrivedValue:e.getDerrivedValue,getStep:e.getStep,setStep:e.setStep,next:e.next,back:e.back,setCurrent:e.setCurrent,validated:e.validated,validating:e.validating,getDirty:e.getDirty,getPristine:e.getPristine},e.on("value",(function(t){delete e.state.error,e.notify(t)})),e}return l(n,[{key:"setOptions",value:function(e){this.options=e}},{key:"setValue",value:function(e,t,n){this.getField(e).fieldApi.setValue(t,null,p({allowEmptyString:this.options.allowEmptyStrings},n))}},{key:"setTouched",value:function(e,t){this.getField(e).fieldApi.setTouched(t)}},{key:"setError",value:function(e,t){this.getField(e).fieldApi.setError(t)}},{key:"setFormError",value:function(e){this.state.error=e,this.emit("change")}},{key:"validating",value:function(){this.state.validating=this.state.validating+1,this.emit("change")}},{key:"validated",value:function(e,t){this.state.validating=this.state.validating-1,this.getError(e)||this.setError(e,t),this.state.validating>0||this.state.submitting&&(this.valid()?(De("Submit",this.state),this.emit("submit")):(De("Submit",this.state),this.emit("failure")),this.state.submitting=!1),this.emit("change")}},{key:"setStep",value:function(e){this.state.step=e,this.emit("change")}},{key:"setCurrent",value:function(e){this.state.Current=e,this.emit("change")}},{key:"back",value:function(e){this.state.step=this.state.step-1,this.state.Current=e,this.emit("change")}},{key:"next",value:function(e){this.validate(),this.screenValid()&&(this.state.step=this.state.step+1,this.state.Current=e),this.emit("change")}},{key:"setInitialValue",value:function(e,t){I.set(this.options.initialValues,e,t)}},{key:"getFormState",value:function(){return De("Returning form state"),p(p({},this.state),{},{pristine:this.pristine(),dirty:this.dirty(),invalid:this.invalid()})}},{key:"getFormApi",value:function(){return this.formApi}},{key:"getDerrivedValue",value:function(e){var t=this.getValues();return I.get(t,e)}},{key:"getValue",value:function(e){var t=this.getField(e).fieldApi.getValue();return De("Getting value for",e,t),t}},{key:"getTouched",value:function(e){var t=this.getField(e).fieldApi.getTouched();return De("Getting touched for",e,t),t}},{key:"getError",value:function(e){var t=this.getField(e).fieldApi.getError();return De("Getting error for",e,t),t}},{key:"getDirty",value:function(e){var t=this.getField(e).fieldApi.getDirty();return De("Getting dirty for",e,t),t}},{key:"getPristine",value:function(e){var t=this.getField(e).fieldApi.getPristine();return De("Getting pristine for",e,t),t}},{key:"getValues",value:function(){return De("Gettings values"),this.state.values}},{key:"getAllTouched",value:function(){return De("Gettings touched"),this.state.touched}},{key:"getErrors",value:function(){return De("Gettings errors"),this.state.errors}},{key:"getOptions",value:function(){return this.options}},{key:"getStep",value:function(){return this.state.step}},{key:"getSavedValue",value:function(e){var t=this.fieldsByName.get(e);return t&&t.shadow?I.get(this.savedValues,"shadow-".concat(e)):I.get(this.savedValues,e)}},{key:"removeSavedState",value:function(e){var t=this.fieldsByName.get(e);return t&&t.shadow?I.delete(this.savedValues,"shadow-".concat(e)):I.delete(this.savedValues,e)}},{key:"getFullField",value:function(e){return e}},{key:"getInitialValue",value:function(e){return I.get(this.options.initialValues,e)}},{key:"getField",value:function(e){De("Getting Field",e);var t=this.fieldsByName.get(e);return t||(console.warn("Attempting to get field ".concat(e," but it does not exist")),this.dummyField)}},{key:"notify",value:function(e){var t=this,n=this.getField(e);n&&n.notify&&n.notify.forEach((function(n){var r=".".concat(e),o="".concat(r.replace(/(.*)[.[].*/,"$1"),".").concat(n).slice(1),i=t.getField(o);i&&(De("Notifying",i.field),i.fieldApi.validate(),i.fieldApi.checkRelevant())}))}},{key:"validateField",value:function(e){this.getField(e).fieldApi.validate()}},{key:"resetField",value:function(e){this.getField(e).fieldApi.reset()}},{key:"fieldExists",value:function(e){return null!=this.fieldsByName.get(e)}},{key:"valid",value:function(){var e=this.getErrors();return!(!I.empty(e)||this.state.error)}},{key:"screenValid",value:function(){return!Object.entries(this.onScreen).some((function(e){return x(e,2)[1].fieldApi.getError()}))}},{key:"invalid",value:function(){var e=this.getErrors();return!(I.empty(e)&&!this.state.error)}},{key:"pristine",value:function(){var e=!0;return this.fieldsById.forEach((function(t){t.fieldApi.getPristine()||(e=!1)})),e}},{key:"dirty",value:function(){return!this.pristine()}},{key:"reset",value:function(){De("Resetting"),this.fieldsById.forEach((function(e){e.fieldApi.reset({preventUpdate:!0})})),this.emit("reset"),this.emit("change")}},{key:"setValues",value:function(e){De("Setting values"),this.fieldsById.forEach((function(t){var n=I.get(e,t.field);void 0!==n&&t.fieldApi.setValue(n,null,{preventUpdate:!0})})),this.emit("change")}},{key:"validate",value:function(){var e=this;De("Validating all fields");var t=this.getValues();if(this.options.validationSchema){var n=K(this.options.validationSchema,t);this.fieldsById.forEach((function(t){if(I.has(n,t.field)){var r=I.get(n,t.field);e.setError(t.field,r)}else e.setError(t.field,void 0)}))}if(this.options.schema&&this.options.ajv){var r=X(this.ajvValidate,t);this.fieldsById.forEach((function(t){if(I.has(r,t.field)){var n=I.get(r,t.field);e.setError(t.field,n)}else e.setError(t.field,void 0)}))}if(this.fieldsById.forEach((function(e){e.fieldApi.validate(t),e.fieldApi.setTouched(!0,!0)})),this.options.validate){var o=this.options.validate(t);this.setFormError(o)}if(this.options.validateFields){var i=this.options.validateFields(t);this.fieldsById.forEach((function(t){if(I.has(i,t.field)){var n=I.get(i,t.field);e.setError(t.field,n)}}))}}},{key:"asyncValidate",value:function(){De("Async Validating all fields");var e=this.getValues();this.fieldsById.forEach((function(t){t.fieldApi.asyncValidate(e)}))}},{key:"keyDown",value:function(e){if(13==e.keyCode&&this.options.preventEnter)return e.preventDefault(e),!1}},{key:"submitForm",value:function(e){this.state.submits=this.state.submits+1,this.state.submitting=!0,!this.options.dontPreventDefault&&e&&e.preventDefault(e),this.validate(),this.emit("change"),this.asyncValidate(),this.state.validating>0||(this.valid()?(De("Submit",this.state),this.emit("submit")):(De("Submit",this.state),this.emit("failure")),this.state.submitting=!1,this.emit("change"))}},{key:"register",value:function(e,t,n){var r=t.field,o=t.state;De("Register ID:",e,"Name:",r,o,"Initial",n);var i,a=r.slice(0,-1!=r.lastIndexOf("[")?r.lastIndexOf("]")+1:r.length);this.fieldsById.forEach((function(e,t){e&&e.field===r&&(i=t)})),//!this.expectedRemovals[magicValue] &&
|
|
8
8
|
i&&(t.keepState||t.inMultistep)?(De("Already Registered",r),this.fieldsById.delete(i))://!this.expectedRemovals[magicValue] &&
|