t)return o;i.to==t&&(i.from!=i.to&&"before"==n?r=o:Ye=o),i.from==t&&(i.from!=i.to&&"before"!=n?r=o:Ye=o)}return null!=r?r:Ye}var Qe=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";var n=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,r=/[stwN]/,o=/[LRr]/,i=/[Lb1n]/,a=/[1n]/;function s(e,t,n){this.level=e,this.from=t,this.to=n}return function(l,u){var c,d="ltr"==u?"L":"R";if(0==l.length||"ltr"==u&&!n.test(l))return!1;for(var p=l.length,f=[],h=0;h-1&&(r[t]=o.slice(0,i).concat(o.slice(i+1)))}}}function nt(e,t){var n=et(e,t);if(n.length)for(var r=Array.prototype.slice.call(arguments,2),o=0;o0}function at(e){e.prototype.on=function(e,t){Ze(this,e,t)},e.prototype.off=function(e,t){tt(this,e,t)}}function st(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function lt(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function ut(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function ct(e){st(e),lt(e)}function dt(e){return e.target||e.srcElement}function pt(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),b&&e.ctrlKey&&1==t&&(t=3),t}var ft,ht,mt=function(){if(a&&s<9)return!1;var e=M("div");return"draggable"in e||"dragDrop"in e}();function gt(e){if(null==ft){var t=M("span","");O(e,M("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(ft=t.offsetWidth<=1&&t.offsetHeight>2&&!(a&&s<8))}var n=ft?M("span",""):M("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return n.setAttribute("cm-text",""),n}function vt(e){if(null!=ht)return ht;var t=O(e,document.createTextNode("AخA")),n=E(t,0,1).getBoundingClientRect(),r=E(t,1,2).getBoundingClientRect();return T(e),!(!n||n.left==n.right)&&(ht=r.right-n.right<3)}var bt,yt=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/)},_t=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)},wt="oncopy"in(bt=M("div"))||(bt.setAttribute("oncopy","return;"),"function"==typeof bt.oncopy),kt=null,Ct={},St={};function Et(e){if("string"==typeof e&&St.hasOwnProperty(e))e=St[e];else if(e&&"string"==typeof e.name&&St.hasOwnProperty(e.name)){var t=St[e.name];"string"==typeof t&&(t={name:t}),(e=J(t,e)).name=t.name}else{if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return Et("application/xml");if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return Et("application/json")}return"string"==typeof e?{name:e}:e||{name:"null"}}function xt(e,t){t=Et(t);var n=Ct[t.name];if(!n)return xt(e,"text/plain");var r=n(e,t);if(Tt.hasOwnProperty(t.name)){var o=Tt[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 Tt={};function Ot(e,t){var n=Tt.hasOwnProperty(e)?Tt[e]:Tt[e]={};I(t,n)}function Mt(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 Lt(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 At(e,t,n){return!e.startState||e.startState(t,n)}var Pt=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};Pt.prototype.eol=function(){return this.pos>=this.string.length},Pt.prototype.sol=function(){return this.pos==this.lineStart},Pt.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},Pt.prototype.next=function(){if(this.post},Pt.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},Pt.prototype.skipToEnd=function(){this.pos=this.string.length},Pt.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},Pt.prototype.backUp=function(e){this.pos-=e},Pt.prototype.column=function(){return this.lastColumnPos0?null:(r&&!1!==t&&(this.pos+=r[0].length),r)}var o=function(e){return n?e.toLowerCase():e},i=this.string.substr(this.pos,e.length);if(o(i)==o(e))return!1!==t&&(this.pos+=e.length),!0},Pt.prototype.current=function(){return this.string.slice(this.start,this.pos)},Pt.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},Pt.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},Pt.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};var Dt=function(e,t){this.state=e,this.lookAhead=t},Nt=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 jt(e,t,n,r){var o=[e.state.modeGen],i={};Wt(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,u=0;n.state=!0,Wt(e,t.text,s.mode,n,function(e,t){for(var n=l;ue&&o.splice(l,1,e,o[l+1],r),l+=2,u=Math.min(e,r)}if(t)if(s.opaque)o.splice(n,l-n,e,"overlay "+t),l=n+2;else for(;ne.options.maxHighlightLength&&Mt(e.doc.mode,r.state),i=jt(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 It(e,t,n){var r=e.doc,o=e.display;if(!r.mode.startState)return new Nt(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=se(i,s-1),u=l.stateAfter;if(u&&(!n||s+(u instanceof Dt?u.lookAhead:0)<=i.modeFrontier))return s;var c=R(l.text,null,e.options.tabSize);(null==o||r>c)&&(o=s-1,r=c)}return o}(e,t,n),a=i>r.first&&se(r,i-1).stateAfter,s=a?Nt.fromSaved(r,a,i):new Nt(r,At(r.mode),i);return r.iter(i,t,function(n){Rt(e,n.text,s);var r=s.line;n.stateAfter=r==t-1||r%5==0||r>=o.viewFrom&&rt.start)return i}throw new Error("Mode "+e.name+" failed to advance stream.")}Nt.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return null!=t&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},Nt.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}},Nt.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},Nt.fromSaved=function(e,t,n){return t instanceof Dt?new Nt(e,Mt(e.mode,t.state),n,t.lookAhead):new Nt(e,Mt(e.mode,t),n)},Nt.prototype.save=function(e){var t=!1!==e?Mt(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new Dt(t,this.maxLookAhead):t};var Ut=function(e,t,n){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=n};function Vt(e,t,n,r){var o,i=e.doc,a=i.mode;t=ke(i,t);var s,l=se(i,t.line),u=It(e,t.line,n),c=new Pt(l.text,e.options.tabSize,u);for(r&&(s=[]);(r||c.pose.options.maxHighlightLength?(s=!1,a&&Rt(e,t,r,d.pos),d.pos=t.length,l=null):l=zt(Ht(n,d,r.state,p),i),p){var f=p[0].name;f&&(l="m-"+(l?f+" "+l:f))}if(!s||c!=l){for(;u1&&!/ /.test(e))return e;for(var n=t,r="",o=0;ou&&d.from<=u);p++);if(d.to>=c)return e(n,r,o,i,a,s,l);e(n,r.slice(0,d.to-u),o,i,null,s,l),i=null,r=r.slice(d.to-u),u=d.to}}}function en(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 tn(e,t,n){var r=e.markedSpans,o=e.text,i=0;if(r)for(var a,s,l,u,c,d,p,f=o.length,h=0,m=1,g="",v=0;;){if(v==h){l=u=c=d=s="",p=null,v=1/0;for(var b=[],y=void 0,_=0;_h||k.collapsed&&w.to==h&&w.from==h)?(null!=w.to&&w.to!=h&&v>w.to&&(v=w.to,u=""),k.className&&(l+=" "+k.className),k.css&&(s=(s?s+";":"")+k.css),k.startStyle&&w.from==h&&(c+=" "+k.startStyle),k.endStyle&&w.to==v&&(y||(y=[])).push(k.endStyle,w.to),k.title&&!d&&(d=k.title),k.collapsed&&(!p||je(p.marker,k)<0)&&(p=w)):w.from>h&&v>w.from&&(v=w.from)}if(y)for(var C=0;C=f)break;for(var E=Math.min(f,v);;){if(g){var x=h+g.length;if(!p){var T=x>E?g.slice(0,E-h):g;t.addToken(t,T,a?a+l:l,c,h+T.length==v?u:"",d,s)}if(x>=E){g=g.slice(E-h),h=E;break}h=x,c=""}g=o.slice(i,i=n[m++]),a=$t(n[m++],t.cm.options)}}else for(var O=1;On)return{map:e.measure.maps[o],cache:e.measure.caches[o],before:!0}}function Mn(e,t,n,r){return Pn(e,An(e,t),n,r)}function Ln(e,t){if(t>=e.display.viewFrom&&t=n.lineN&&t2&&i.push((l.bottom+u.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=jn(t.map,n,r),l=i.node,u=i.start,c=i.end,d=i.collapse;if(3==l.nodeType){for(var p=0;p<4;p++){for(;u&&oe(t.line.text.charAt(i.coverStart+u));)--u;for(;i.coverStart+c1}(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 f;u>0&&(d=r="right"),o=e.options.lineWrapping&&(f=l.getClientRects()).length>1?f["right"==r?f.length-1:0]:l.getBoundingClientRect()}if(a&&s<9&&!u&&(!o||!o.left&&!o.right)){var h=l.parentNode.getClientRects()[0];o=h?{left:h.left,right:h.left+tr(e.display),top:h.top,bottom:h.bottom}:Nn}for(var m=o.top-t.rect.top,g=o.bottom-t.rect.top,v=(m+g)/2,b=t.view.measure.heights,y=0;yt)&&(o=(i=l-s)-1,t>=l&&(a="right")),null!=o){if(r=e[u+2],s==l&&n==(r.insertLeft?"left":"right")&&(a=n),"left"==n&&0==o)for(;u&&e[u-2]==e[u-3]&&e[u-1].insertLeft;)r=e[2+(u-=3)],a="left";if("right"==n&&o==l-s)for(;u=0&&(n=e[o]).left==n.right;o--);return n}function In(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t=r.text.length?(l=r.text.length,u="before"):l<=0&&(l=0,u="after"),!s)return a("before"==u?l-1:l,"before"==u);function c(e,t,n){var r=s[t],o=1==r.level;return a(n?e-1:e,o!=n)}var d=$e(s,l,u),p=Ye,f=c(l,d,"before"==u);return null!=p&&(f.other=c(l,p,"before"!=u)),f}function Kn(e,t){var n=0;t=ke(e.doc,t),e.options.lineWrapping||(n=tr(e.display)*t.ch);var r=se(e.doc,t.line),o=Ge(r)+kn(e.display);return{left:n,right:n,top:o,bottom:o+r.height}}function Yn(e,t,n,r,o){var i=me(e,t,n);return i.xRel=o,r&&(i.outside=!0),i}function $n(e,t,n){var r=e.doc;if((n+=e.display.viewOffset)<0)return Yn(r.first,0,null,!0,-1);var o=pe(r,n),i=r.first+r.size-1;if(o>i)return Yn(r.first+r.size-1,se(r,i).text.length,null,!0,1);t<0&&(t=0);for(var a=se(r,o);;){var s=Zn(e,a,o,t,n),l=Re(a),u=l&&l.find(0,!0);if(!l||!(s.ch>u.from.ch||s.ch==u.from.ch&&s.xRel>0))return s;o=de(a=u.to.line)}}function Qn(e,t,n,r){r-=Vn(t);var o=t.text.length,i=ae(function(t){return Pn(e,n,t-1).bottom<=r},o,0);return o=ae(function(t){return Pn(e,n,t).top>r},i,o),{begin:i,end:o}}function Xn(e,t,n,r){n||(n=An(e,t));var o=zn(e,t,Pn(e,n,r),"line").top;return Qn(e,t,n,o)}function Jn(e,t,n,r){return!(e.bottom<=n)&&(e.top>n||(r?e.left:e.right)>t)}function Zn(e,t,n,r,o){o-=Ge(t);var i=An(e,t),a=Vn(t),s=0,l=t.text.length,u=!0,c=Xe(t,e.doc.direction);if(c){var d=(e.options.lineWrapping?function(e,t,n,r,o,i,a){var s=Qn(e,t,r,a),l=s.begin,u=s.end;/\s/.test(t.text.charAt(u-1))&&u--;for(var c=null,d=null,p=0;p=u||f.to<=l)){var h=1!=f.level,m=Pn(e,r,h?Math.min(u,f.to)-1:Math.max(l,f.from)).right,g=mg)&&(c=f,d=g)}}return c||(c=o[o.length-1]),c.fromu&&(c={from:c.from,to:u,level:c.level}),c}:function(e,t,n,r,o,i,a){var s=ae(function(s){var l=o[s],u=1!=l.level;return Jn(qn(e,me(n,u?l.to:l.from,u?"before":"after"),"line",t,r),i,a,!0)},0,o.length-1),l=o[s];if(s>0){var u=1!=l.level,c=qn(e,me(n,u?l.from:l.to,u?"after":"before"),"line",t,r);Jn(c,i,a,!0)&&c.top>a&&(l=o[s-1])}return l})(e,t,n,i,c,r,o);u=1!=d.level,s=u?d.from:d.to-1,l=u?d.to:d.from-1}var p,f,h=null,m=null,g=ae(function(t){var n=Pn(e,i,t);return n.top+=a,n.bottom+=a,!!Jn(n,r,o,!1)&&(n.top<=o&&n.left<=r&&(h=t,m=n),!0)},s,l),v=!1;if(m){var b=r-m.left=_.bottom}return g=ie(t.text,g,1),Yn(n,g,f,v,r-p)}function er(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Dn){Dn=M("pre");for(var t=0;t<49;++t)Dn.appendChild(document.createTextNode("x")),Dn.appendChild(M("br"));Dn.appendChild(document.createTextNode("x"))}O(e.measure,Dn);var n=Dn.offsetHeight/50;return n>3&&(e.cachedTextHeight=n),T(e.measure),n||1}function tr(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=M("span","xxxxxxxxxx"),n=M("pre",[t]);O(e.measure,n);var r=t.getBoundingClientRect(),o=(r.right-r.left)/10;return o>2&&(e.cachedCharWidth=o),o||10}function nr(e){for(var t=e.display,n={},r={},o=t.gutters.clientLeft,i=t.gutters.firstChild,a=0;i;i=i.nextSibling,++a)n[e.options.gutters[a]]=i.offsetLeft+i.clientLeft+o,r[e.options.gutters[a]]=i.clientWidth;return{fixedPos:rr(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:n,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function rr(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function or(e){var t=er(e.display),n=e.options.lineWrapping,r=n&&Math.max(5,e.display.scroller.clientWidth/tr(e.display)-3);return function(o){if(ze(e.doc,o))return 0;var i=0;if(o.widgets)for(var a=0;a=e.display.viewTo)return null;if((t-=e.display.viewFrom)<0)return null;for(var n=e.display.view,r=0;r=e.display.viewTo||s.to().linet||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")}(m,n||0,null==r?p:r,function(e,t,o,d){var g="ltr"==o,v=f(e,g?"left":"right"),b=f(t-1,g?"right":"left"),y=null==n&&0==e,_=null==r&&t==p,w=0==d,k=!m||d==m.length-1;if(b.top-v.top<=3){var C=(u?y:_)&&w,S=(u?_:y)&&k,E=C?s:(g?v:b).left,x=S?l:(g?b:v).right;c(E,v.top,x-E,v.bottom)}else{var T,O,M,L;g?(T=u&&y&&w?s:v.left,O=u?l:h(e,o,"before"),M=u?s:h(t,o,"after"),L=u&&_&&k?l:b.right):(T=u?h(e,o,"before"):s,O=!u&&y&&w?l:v.right,M=!u&&_&&k?s:b.left,L=u?h(t,o,"after"):l),c(T,v.top,O-T,v.bottom),v.bottom0?t.blinker=setInterval(function(){return t.cursorDiv.style.visibility=(n=!n)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function hr(e){e.state.focused||(e.display.input.focus(),gr(e))}function mr(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,vr(e))},100)}function gr(e,t){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(nt(e,"focus",e,t),e.state.focused=!0,D(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()),fr(e))}function vr(e,t){e.state.delayingBlurEvent||(e.state.focused&&(nt(e,"blur",e,t),e.state.focused=!1,x(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function br(e){for(var t=e.display,n=t.lineDiv.offsetTop,r=0;r.005||c<-.005)&&(ce(o.line,i),yr(o.line),o.rest))for(var d=0;d=a&&(i=pe(t,Ge(se(t,l))-e.wrapper.clientHeight),a=l)}return{from:i,to:Math.max(a,i+1)}}function wr(e){var t=e.display,n=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var r=rr(t)-t.scroller.scrollLeft+e.doc.scrollLeft,o=t.gutters.offsetWidth,i=r+"px",a=0;ai&&(t.bottom=t.top+i);var s=e.doc.height+Cn(n),l=t.tops-r;if(t.topo+i){var c=Math.min(t.top,(u?s:t.bottom)-i);c!=o&&(a.scrollTop=c)}var d=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:n.scroller.scrollLeft,p=xn(e)-(e.options.fixedGutter?n.gutters.offsetWidth:0),f=t.right-t.left>p;return f&&(t.right=t.left+p),t.left<10?a.scrollLeft=0:t.leftp+d-3&&(a.scrollLeft=t.right+(f?0:10)-p),a}function Sr(e,t){null!=t&&(Tr(e),e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+t)}function Er(e){Tr(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function xr(e,t,n){null==t&&null==n||Tr(e),null!=t&&(e.curOp.scrollLeft=t),null!=n&&(e.curOp.scrollTop=n)}function Tr(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var n=Kn(e,t.from),r=Kn(e,t.to);Or(e,n,r,t.margin)}}function Or(e,t,n,r){var o=Cr(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});xr(e,o.scrollLeft,o.scrollTop)}function Mr(e,t){Math.abs(e.doc.scrollTop-t)<2||(n||ao(e,{top:t}),Lr(e,t,!0),n&&ao(e),to(e,100))}function Lr(e,t,n){t=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 Ar(e,t,n,r){t=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,wr(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function Pr(e){var t=e.display,n=t.gutters.offsetWidth,r=Math.round(e.doc.height+Cn(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+En(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:n}}var Dr=function(e,t,n){this.cm=n;var r=this.vert=M("div",[M("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),o=this.horiz=M("div",[M("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");e(r),e(o),Ze(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),Ze(o,"scroll",function(){o.clientWidth&&t(o.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,a&&s<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};Dr.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}},Dr.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},Dr.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},Dr.prototype.zeroWidthHack=function(){var e=b&&!f?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new B,this.disableVert=new B},Dr.prototype.enableZeroWidthBar=function(e,t,n){e.style.pointerEvents="auto",t.set(1e3,function r(){var o=e.getBoundingClientRect(),i="vert"==n?document.elementFromPoint(o.right-1,(o.top+o.bottom)/2):document.elementFromPoint((o.right+o.left)/2,o.bottom-1);i!=e?e.style.pointerEvents="none":t.set(1e3,r)})},Dr.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var Nr=function(){};function jr(e,t){t||(t=Pr(e));var n=e.display.barWidth,r=e.display.barHeight;Fr(e,t);for(var o=0;o<4&&n!=e.display.barWidth||r!=e.display.barHeight;o++)n!=e.display.barWidth&&e.options.lineWrapping&&br(e),Fr(e,Pr(e)),n=e.display.barWidth,r=e.display.barHeight}function Fr(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=""}Nr.prototype.update=function(){return{bottom:0,right:0}},Nr.prototype.setScrollLeft=function(){},Nr.prototype.setScrollTop=function(){},Nr.prototype.clear=function(){};var Ir={native:Dr,null:Nr};function Rr(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&x(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new Ir[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),Ze(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?Ar(e,t):Mr(e,t)},e),e.display.scrollbars.addClass&&D(e.display.wrapper,e.display.scrollbars.addClass)}var Br=0;function Hr(e){var t;e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Br},t=e.curOp,on?on.ops.push(t):t.ownsGroup=on={ops:[t],delayedCallbacks:[]}}function Ur(e){var t=e.curOp;!function(e,t){var n=e.ownsGroup;if(n)try{!function(e){var t=e.delayedCallbacks,n=0;do{for(;n=n.viewTo)||n.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new ro(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function zr(e){var t=e.cm,n=t.display;e.updatedDisplay&&br(t),e.barMeasure=Pr(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+En(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,n.sizer.offsetLeft+e.adjustWidthTo-xn(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=n.input.prepareSelection())}function Wr(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft1&&(a=!0)),null!=u.scrollLeft&&(Ar(e,u.scrollLeft),Math.abs(e.doc.scrollLeft-d)>1&&(a=!0)),!a)break}return o}(t,ke(r,e.scrollToPos.from),ke(r,e.scrollToPos.to),e.scrollToPos.margin);!function(e,t){if(!rt(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=M("div","",null,"position: absolute;\n top: "+(t.top-n.viewOffset-kn(e.display))+"px;\n height: "+(t.bottom-t.top+En(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,o)}var i=e.maybeHiddenMarkers,a=e.maybeUnhiddenMarkers;if(i)for(var s=0;st)&&(o.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=o.viewTo)Ee&&Ue(e.doc,t)o.viewFrom?Jr(e):(o.viewFrom+=r,o.viewTo+=r);else if(t<=o.viewFrom&&n>=o.viewTo)Jr(e);else if(t<=o.viewFrom){var i=Zr(e,n,n+r,1);i?(o.view=o.view.slice(i.index),o.viewFrom=i.lineN,o.viewTo+=r):Jr(e)}else if(n>=o.viewTo){var a=Zr(e,t,t,-1);a?(o.view=o.view.slice(0,a.index),o.viewTo=a.lineN):Jr(e)}else{var s=Zr(e,t,t,-1),l=Zr(e,n,n+r,1);s&&l?(o.view=o.view.slice(0,s.index).concat(rn(e,s.lineN,l.lineN)).concat(o.view.slice(l.index)),o.viewTo+=r):Jr(e)}var u=o.externalMeasured;u&&(n=o.lineN&&t=r.viewTo)){var i=r.view[sr(e,t)];if(null!=i.node){var a=i.changes||(i.changes=[]);-1==H(a,n)&&a.push(n)}}}function Jr(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Zr(e,t,n,r){var o,i=sr(e,t),a=e.display.view;if(!Ee||n==e.doc.first+e.doc.size)return{index:i,lineN:n};for(var s=e.display.viewFrom,l=0;l0){if(i==a.length-1)return null;o=s+a[i].size-t,i++}else o=s-t;t+=o,n+=o}for(;Ue(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 eo(e){for(var t=e.display.view,n=0,r=0;r=e.display.viewTo)){var n=+new Date+e.options.workTime,r=It(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?Mt(t.mode,r.state):null,l=jt(e,i,r,!0);s&&(r.state=s),i.styles=l.styles;var u=i.styleClasses,c=l.classes;c?i.styleClasses=c:u&&(i.styleClasses=null);for(var d=!a||a.length!=i.styles.length||u!=c&&(!u||!c||u.bgClass!=c.bgClass||u.textClass!=c.textClass),p=0;!d&&pn)return to(e,e.options.workDelay),!0}),t.highlightFrontier=r.line,t.modeFrontier=Math.max(t.modeFrontier,r.line),o.length&&qr(e,function(){for(var t=0;t=n.viewFrom&&t.visible.to<=n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&0==eo(e))return!1;kr(e)&&(Jr(e),t.dims=nr(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.viewFroma&&n.viewTo-a<20&&(a=Math.min(o,n.viewTo)),Ee&&(i=Ue(e.doc,i),a=Ve(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=rn(e,t,n),r.viewFrom=t):(r.viewFrom>t?r.view=rn(e,t,r.viewFrom).concat(r.view):r.viewFromn&&(r.view=r.view.slice(0,sr(e,n)))),r.viewTo=n}(e,i,a),n.viewOffset=Ge(se(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var u=eo(e);if(!s&&0==u&&!t.force&&n.renderedView==n.view&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo))return!1;var c=function(e){if(e.hasFocus())return null;var t=P();if(!t||!A(e.display.lineDiv,t))return null;var n={activeElt:t};if(window.getSelection){var r=window.getSelection();r.anchorNode&&r.extend&&A(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 u>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&&b&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),n}for(var u=r.view,c=r.viewFrom,d=0;d-1&&(f=!1),un(e,p,c,n)),f&&(T(p.lineNumber),p.lineNumber.appendChild(document.createTextNode(he(e.options,c)))),a=p.node.nextSibling}else{var h=gn(e,p,c,n);i.insertBefore(h,a)}c+=p.size}for(;a;)a=s(a)}(e,n.updateLineNumbers,t.dims),u>4&&(n.lineDiv.style.display=""),n.renderedView=n.view,function(e){if(e&&e.activeElt&&e.activeElt!=P()&&(e.activeElt.focus(),e.anchorNode&&A(document.body,e.anchorNode)&&A(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)}}(c),T(n.cursorDiv),T(n.selectionDiv),n.gutters.style.height=n.sizer.style.minHeight=0,s&&(n.lastWrapHeight=t.wrapperHeight,n.lastWrapWidth=t.wrapperWidth,to(e,400)),n.updateLineNumbers=null,!0}function io(e,t){for(var n=t.viewport,r=!0;(r&&e.options.lineWrapping&&t.oldDisplayWidth!=xn(e)||(n&&null!=n.top&&(n={top:Math.min(e.doc.height+Cn(e.display)-Tn(e),n.top)}),t.visible=_r(e.display,e.doc,n),!(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)))&&oo(e,t);r=!1){br(e);var o=Pr(e);lr(e),jr(e,o),lo(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 ao(e,t){var n=new ro(e,t);if(oo(e,n)){br(e),io(e,n);var r=Pr(e);lr(e),jr(e,r),lo(e,r),n.finish()}}function so(e){var t=e.display.gutters.offsetWidth;e.display.sizer.style.marginLeft=t+"px"}function lo(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+En(e)+"px"}function uo(e){var t=e.display.gutters,n=e.options.gutters;T(t);for(var r=0;r-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}ro.prototype.signal=function(e,t){it(e,t)&&this.events.push(arguments)},ro.prototype.finish=function(){for(var e=0;es.clientWidth,c=s.scrollHeight>s.clientHeight;if(o&&u||i&&c){if(i&&b&&l)e:for(var p=t.target,f=a.view;p!=s;p=p.parentNode)for(var h=0;h=0&&ge(e,r.to())<=0)return n}return-1};var bo=function(e,t){this.anchor=e,this.head=t};function yo(e,t){var n=e[t];e.sort(function(e,t){return ge(e.from(),t.from())}),t=H(e,n);for(var r=1;r=0){var a=_e(i.from(),o.from()),s=ye(i.to(),o.to()),l=i.empty()?o.from()==o.head:i.from()==i.head;r<=t&&--t,e.splice(--r,2,new bo(l?s:a,l?a:s))}}return new vo(e,t)}function _o(e,t){return new vo([new bo(e,t||e)],0)}function wo(e){return e.text?me(e.from.line+e.text.length-1,$(e.text).length+(1==e.text.length?e.from.ch:0)):e.to}function ko(e,t){if(ge(e,t.from)<0)return e;if(ge(e,t.to)<=0)return wo(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+=wo(t).ch-t.to.ch),me(n,r)}function Co(e,t){for(var n=[],r=0;r1&&e.remove(s.line+1,h-1),e.insert(s.line+1,v)}sn(e,"change",e,t)}function Mo(e,t,n){!function e(r,o,i){if(r.linked)for(var a=0;as-e.cm.options.historyEventDelay||"*"==t.origin.charAt(0)))&&(i=function(e,t){return t?(No(e.done),$(e.done)):e.done.length&&!$(e.done).ranges?$(e.done):e.done.length>1&&!e.done[e.done.length-2].ranges?(e.done.pop(),$(e.done)):void 0}(o,o.lastOp==r)))a=$(i.changes),0==ge(t.from,t.to)&&0==ge(t.from,a.to)?a.to=wo(t):i.changes.push(Do(e,t));else{var l=$(o.done);for(l&&l.ranges||Io(e.sel,o.done),i={changes:[Do(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||nt(e,"historyAdded")}function Fo(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,$(o.done),t))?o.done[o.done.length-1]=t:Io(t,o.done),o.lastSelTime=+new Date,o.lastSelOrigin=i,o.lastSelOp=n,r&&!1!==r.clearRedo&&No(o.undone)}function Io(e,t){var n=$(t);n&&n.ranges&&n.equals(e)||t.push(e)}function Ro(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 Bo(e){if(!e)return null;for(var t,n=0;n-1&&($(s)[d]=u[d],delete u[d])}}}return r}function Vo(e,t,n,r){if(r){var o=e.anchor;if(n){var i=ge(t,o)<0;i!=ge(n,o)<0?(o=t,t=n):i!=ge(t,n)<0&&(t=n)}return new bo(o,t)}return new bo(n||t,t)}function zo(e,t,n,r,o){null==o&&(o=e.cm&&(e.cm.display.shift||e.extend)),Yo(e,new vo([Vo(e.sel.primary(),t,n,o)],0),r)}function Wo(e,t,n){for(var r=[],o=e.cm&&(e.cm.display.shift||e.extend),i=0;i=t.ch:s.to>t.ch))){if(o&&(nt(l,"beforeCursorEnter"),l.explicitlyCleared)){if(i.markedSpans){--a;continue}break}if(!l.atomic)continue;if(n){var u=l.find(r<0?1:-1),c=void 0;if((r<0?l.inclusiveRight:l.inclusiveLeft)&&(u=ti(e,u,-r,u&&u.line==t.line?i:null)),u&&u.line==t.line&&(c=ge(u,n))&&(r<0?c<0:c>0))return Zo(e,u,t,r,o)}var d=l.find(r<0?-1:1);return(r<0?l.inclusiveLeft:l.inclusiveRight)&&(d=ti(e,d,r,d.line==t.line?i:null)),d?Zo(e,d,t,r,o):null}}return t}function ei(e,t,n,r,o){var i=r||1,a=Zo(e,t,n,i,o)||!o&&Zo(e,t,n,i,!0)||Zo(e,t,n,-i,o)||!o&&Zo(e,t,n,-i,!0);return a||(e.cantEdit=!0,me(e.first,0))}function ti(e,t,n,r){return n<0&&0==t.ch?t.line>e.first?ke(e,me(t.line-1)):null:n>0&&t.ch==(r||se(e,t.line)).text.length?t.line0)){var c=[l,1],d=ge(u.from,s.from),p=ge(u.to,s.to);(d<0||!a.inclusiveLeft&&!d)&&c.push({from:u.from,to:s.from}),(p>0||!a.inclusiveRight&&!p)&&c.push({from:s.to,to:u.to}),o.splice.apply(o,c),l+=c.length-3}}return o}(e,t.from,t.to);if(r)for(var o=r.length-1;o>=0;--o)ii(e,{from:r[o].from,to:r[o].to,text:o?[""]:t.text,origin:t.origin});else ii(e,t)}}function ii(e,t){if(1!=t.text.length||""!=t.text[0]||0!=ge(t.from,t.to)){var n=Co(e,t);jo(e,t,n,e.cm?e.cm.curOp.id:NaN),li(e,t,n,Me(e,t));var r=[];Mo(e,function(e,n){n||-1!=H(r,e.history)||(pi(e.history,t),r.push(e.history)),li(e,t,null,Me(e,t))})}}function ai(e,t,n){if(!e.cm||!e.cm.state.suppressEdits||n){for(var r,o=e.history,i=e.sel,a="undo"==t?o.done:o.undone,s="undo"==t?o.undone:o.done,l=0;l=0;--p){var f=d(p);if(f)return f.v}}}}function si(e,t){if(0!=t&&(e.first+=t,e.sel=new vo(Q(e.sel.ranges,function(e){return new bo(me(e.anchor.line+t,e.anchor.ch),me(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){Qr(e.cm,e.first,e.first-t,t);for(var n=e.cm.display,r=n.viewFrom;re.lastLine())){if(t.from.linei&&(t={from:t.from,to:me(i,se(e,i).text.length),text:[t.text[0]],origin:t.origin}),t.removed=le(e,t.from,t.to),n||(n=Co(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=de(He(se(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&&ot(e),Oo(r,t,n,or(e)),e.options.lineWrapping||(r.iter(l,i.line+t.text.length,function(e){var t=qe(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.highlightFrontiern;r--){var o=se(e,r).stateAfter;if(o&&(!(o instanceof Dt)||r+o.lookAhead1||!(this.children[0]instanceof hi))){var s=[];this.collapse(s),this.children=[new hi(s)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t50){for(var a=o.lines.length%25+25,s=a;s10);e.parent.maybeSpill()}},iterN:function(e,t,n){for(var r=0;r0||0==a&&!1!==i.clearWhenEmpty)return i;if(i.replacedWith&&(i.collapsed=!0,i.widgetNode=L("span",[i.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||i.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(i.widgetNode.insertLeft=!0)),i.collapsed){if(Be(e,t.line,t,n,i)||t.line!=n.line&&Be(e,n.line,t,n,i))throw new Error("Inserting collapsed marker partially overlapping an existing one");Ee=!0}i.addToHistory&&jo(e,{from:t,to:n,origin:"markText"},e.sel,NaN);var s,l=t.line,u=e.cm;if(e.iter(l,n.line+1,function(e){u&&i.collapsed&&!u.options.lineWrapping&&He(e)==u.display.maxLine&&(s=!0),i.collapsed&&l!=t.line&&ce(e,0),function(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}(e,new xe(i,l==t.line?t.ch:null,l==n.line?n.ch:null)),++l}),i.collapsed&&e.iter(t.line,n.line+1,function(t){ze(e,t)&&ce(t,0)}),i.clearOnEnter&&Ze(i,"beforeCursorEnter",function(){return i.clear()}),i.readOnly&&(Se=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),i.collapsed&&(i.id=++bi,i.atomic=!0),u){if(s&&(u.curOp.updateMaxLine=!0),i.collapsed)Qr(u,t.line,n.line+1);else if(i.className||i.title||i.startStyle||i.endStyle||i.css)for(var c=t.line;c<=n.line;c++)Xr(u,c,"text");i.atomic&&Xo(u.doc),sn(u,"markerAdded",u,i)}return i}yi.prototype.clear=function(){if(!this.explicitlyCleared){var e=this.doc.cm,t=e&&!e.curOp;if(t&&Hr(e),it(this,"clear")){var n=this.find();n&&sn(this,"clear",n.from,n.to)}for(var r=null,o=null,i=0;ie.display.maxLineLength&&(e.display.maxLine=u,e.display.maxLineLength=c,e.display.maxLineChanged=!0)}null!=r&&e&&this.collapsed&&Qr(e,r,o+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Xo(e.doc)),e&&sn(e,"markerCleared",e,this,r,o),t&&Ur(e),this.parent&&this.parent.clear()}},yi.prototype.find=function(e,t){var n,r;null==e&&"bookmark"==this.type&&(e=1);for(var o=0;o=0;l--)oi(this,r[l]);s?Ko(this,s):this.cm&&Er(this.cm)}),undo:$r(function(){ai(this,"undo")}),redo:$r(function(){ai(this,"redo")}),undoSelection:$r(function(){ai(this,"undo",!0)}),redoSelection:$r(function(){ai(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.ch)&&t.push(o.marker.parent||o.marker)}return t},findMarks:function(e,t,n){e=ke(this,e),t=ke(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=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;re)return t=e,!0;e-=i,++n}),ke(this,me(n,t))},indexFromPos:function(e){var t=(e=ke(this,e)).ch;if(e.linet&&(t=e.from),null!=e.to&&e.to-1)return t.state.draggingText(e),void setTimeout(function(){return t.display.input.focus()},20);try{var c=e.dataTransfer.getData("Text");if(c){var d;if(t.state.draggingText&&!t.state.draggingText.copy&&(d=t.listSelections()),$o(t.doc,_o(n,n)),d)for(var p=0;p=0;t--)ui(e.doc,"",r[t].from,r[t].to,"+delete");Er(e)})}function qi(e,t,n){var r=ie(e.text,t+n,n);return r<0||r>e.text.length?null:r}function Ki(e,t,n){var r=qi(e,t.ch,n);return null==r?null:new me(t.line,r,n<0?"after":"before")}function Yi(e,t,n,r,o){if(e){var i=Xe(n,t.doc.direction);if(i){var a,s=o<0?$(i):i[0],l=o<0==(1==s.level),u=l?"after":"before";if(s.level>0||"rtl"==t.doc.direction){var c=An(t,n);a=o<0?n.text.length-1:0;var d=Pn(t,c,a).top;a=ae(function(e){return Pn(t,c,e).top==d},o<0==(1==s.level)?s.from:s.to-1,a),"before"==u&&(a=qi(n,a,1))}else a=o<0?s.to:s.from;return new me(r,a,u)}}return new me(r,o<0?n.text.length:0,o<0?"before":"after")}Ii.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"},Ii.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"},Ii.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"},Ii.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"]},Ii.default=b?Ii.macDefault:Ii.pcDefault;var $i={selectAll:ni,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),z)},killLine:function(e){return Gi(e,function(t){if(t.empty()){var n=se(e.doc,t.head.line).text.length;return t.head.ch==n&&t.head.line0)o=new me(o.line,o.ch+1),e.replaceRange(i.charAt(o.ch-1)+i.charAt(o.ch-2),me(o.line,o.ch-2),o,"+transpose");else if(o.line>e.doc.first){var a=se(e.doc,o.line-1).text;a&&(o=new me(o.line,1),e.replaceRange(i.charAt(0)+e.doc.lineSeparator()+a.charAt(a.length-1),me(o.line-1,a.length-1),o,"+transpose"))}n.push(new bo(o,o))}e.setSelections(n)})},newlineAndIndent:function(e){return qr(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-1&&(ge((o=u.ranges[o]).from(),t)<0||t.xRel>0)&&(ge(o.to(),t)>0||t.xRel<0)?function(e,t,n,r){var o=e.display,i=!1,u=Kr(e,function(t){l&&(o.scroller.draggable=!1),e.state.draggingText=!1,tt(document,"mouseup",u),tt(document,"mousemove",c),tt(o.scroller,"dragstart",d),tt(o.scroller,"drop",u),i||(st(t),r.addNew||zo(e.doc,n,null,null,r.extend),l||a&&9==s?setTimeout(function(){document.body.focus(),o.input.focus()},20):o.input.focus())}),c=function(e){i=i||Math.abs(t.clientX-e.clientX)+Math.abs(t.clientY-e.clientY)>=10},d=function(){return i=!0};l&&(o.scroller.draggable=!0),e.state.draggingText=u,u.copy=!r.moveOnDrag,o.scroller.dragDrop&&o.scroller.dragDrop(),Ze(document,"mouseup",u),Ze(document,"mousemove",c),Ze(o.scroller,"dragstart",d),Ze(o.scroller,"drop",u),mr(e),setTimeout(function(){return o.input.focus()},20)}(e,r,t,i):function(e,t,n,r){var o=e.display,i=e.doc;st(t);var a,s,l=i.sel,u=l.ranges;if(r.addNew&&!r.extend?(s=i.sel.contains(n),a=s>-1?u[s]:new bo(n,n)):(a=i.sel.primary(),s=i.sel.primIndex),"rectangle"==r.unit)r.addNew||(a=new bo(n,n)),n=ar(e,t,!0,!0),s=-1;else{var c=da(e,n,r.unit);a=r.extend?Vo(a,c.anchor,c.head,r.extend):c}r.addNew?-1==s?(s=u.length,Yo(i,yo(u.concat([a]),s),{scroll:!1,origin:"*mouse"})):u.length>1&&u[s].empty()&&"char"==r.unit&&!r.extend?(Yo(i,yo(u.slice(0,s).concat(u.slice(s+1)),0),{scroll:!1,origin:"*mouse"}),l=i.sel):Go(i,s,a,W):(s=0,Yo(i,new vo([a],0),W),l=i.sel);var d=n;function p(t){if(0!=ge(d,t))if(d=t,"rectangle"==r.unit){for(var o=[],u=e.options.tabSize,c=R(se(i,n.line).text,n.ch,u),p=R(se(i,t.line).text,t.ch,u),f=Math.min(c,p),h=Math.max(c,p),m=Math.min(n.line,t.line),g=Math.min(e.lastLine(),Math.max(n.line,t.line));m<=g;m++){var v=se(i,m).text,b=q(v,f,u);f==h?o.push(new bo(me(m,b),me(m,b))):v.length>b&&o.push(new bo(me(m,b),me(m,q(v,h,u))))}o.length||o.push(new bo(n,n)),Yo(i,yo(l.ranges.slice(0,s).concat(o),s),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var y,_=a,w=da(e,t,r.unit),k=_.anchor;ge(w.anchor,k)>0?(y=w.head,k=_e(_.from(),w.anchor)):(y=w.anchor,k=ye(_.to(),w.head));var C=l.ranges.slice(0);C[s]=function(e,t){var n=t.anchor,r=t.head,o=se(e.doc,n.line);if(0==ge(n,r)&&n.sticky==r.sticky)return t;var i=Xe(o);if(!i)return t;var a=$e(i,n.ch,n.sticky),s=i[a];if(s.from!=n.ch&&s.to!=n.ch)return t;var l,u=a+(s.from==n.ch==(1!=s.level)?0:1);if(0==u||u==i.length)return t;if(r.line!=n.line)l=(r.line-n.line)*("ltr"==e.doc.direction?1:-1)>0;else{var c=$e(i,r.ch,r.sticky),d=c-a||(r.ch-n.ch)*(1==s.level?-1:1);l=c==u-1||c==u?d<0:d>0}var p=i[u+(l?-1:0)],f=l==(1==p.level),h=f?p.from:p.to,m=f?"after":"before";return n.ch==h&&n.sticky==m?t:new bo(new me(n.line,h,m),r)}(e,new bo(ke(i,k),y)),Yo(i,yo(C,s),W)}}var f=o.wrapper.getBoundingClientRect(),h=0;function m(t){e.state.selectingText=!1,h=1/0,st(t),o.input.focus(),tt(document,"mousemove",g),tt(document,"mouseup",v),i.history.lastSelOrigin=null}var g=Kr(e,function(t){pt(t)?function t(n){var a=++h,s=ar(e,n,!0,"rectangle"==r.unit);if(s)if(0!=ge(s,d)){e.curOp.focus=P(),p(s);var l=_r(o,i);(s.line>=l.to||s.linef.bottom?20:0;u&&setTimeout(Kr(e,function(){h==a&&(o.scroller.scrollTop+=u,t(n))}),50)}}(t):m(t)}),v=Kr(e,m);e.state.selectingText=v,Ze(document,"mousemove",g),Ze(document,"mouseup",v)}(e,r,t,i)}(t,r,i,e):dt(e)==n.scroller&&st(e):2==o?(r&&zo(t.doc,r),setTimeout(function(){return n.input.focus()},20)):3==o&&(C?ha(t,e):mr(t)))}}function da(e,t,n){if("char"==n)return new bo(t,t);if("word"==n)return e.findWordAt(t);if("line"==n)return new bo(me(t.line,0),ke(e.doc,me(t.line+1,0)));var r=n(e,t);return new bo(r.from,r.to)}function pa(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(t){return!1}if(o>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&st(t);var a=e.display,s=a.lineDiv.getBoundingClientRect();if(i>s.bottom||!it(e,n))return ut(t);i-=s.top-a.viewOffset;for(var l=0;l=o){var c=pe(e.doc,i),d=e.options.gutters[l];return nt(e,n,e,c,d,t),ut(t)}}}function fa(e,t){return pa(e,t,"gutterClick",!0)}function ha(e,t){wn(e.display,t)||function(e,t){return!!it(e,"gutterContextMenu")&&pa(e,t,"gutterContextMenu",!1)}(e,t)||rt(e,t,"contextmenu")||e.display.input.onContextMenu(t)}function ma(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)}ua.prototype.compare=function(e,t,n){return this.time+400>e&&0==ge(t,this.pos)&&n==this.button};var ga={toString:function(){return"CodeMirror.Init"}},va={},ba={};function ya(e){uo(e),Qr(e),wr(e)}function _a(e,t,n){var r=n&&n!=ga;if(!t!=!r){var o=e.display.dragFunctions,i=t?Ze:tt;i(e.display.scroller,"dragstart",o.start),i(e.display.scroller,"dragenter",o.enter),i(e.display.scroller,"dragover",o.over),i(e.display.scroller,"dragleave",o.leave),i(e.display.scroller,"drop",o.drop)}}function wa(e){e.options.lineWrapping?(D(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(x(e.display.wrapper,"CodeMirror-wrap"),Ke(e)),ir(e),Qr(e),Bn(e),setTimeout(function(){return jr(e)},100)}function ka(e,t){var r=this;if(!(this instanceof ka))return new ka(e,t);this.options=t=t?I(t):{},I(va,t,!1),co(t);var o=t.value;"string"==typeof o&&(o=new Ei(o,t.mode,null,t.lineSeparator,t.direction)),this.doc=o;var i=new ka.inputStyles[t.inputStyle](this),u=this.display=new function(e,t,r){var o=this;this.input=r,o.scrollbarFiller=M("div",null,"CodeMirror-scrollbar-filler"),o.scrollbarFiller.setAttribute("cm-not-content","true"),o.gutterFiller=M("div",null,"CodeMirror-gutter-filler"),o.gutterFiller.setAttribute("cm-not-content","true"),o.lineDiv=L("div",null,"CodeMirror-code"),o.selectionDiv=M("div",null,null,"position: relative; z-index: 1"),o.cursorDiv=M("div",null,"CodeMirror-cursors"),o.measure=M("div",null,"CodeMirror-measure"),o.lineMeasure=M("div",null,"CodeMirror-measure"),o.lineSpace=L("div",[o.measure,o.lineMeasure,o.selectionDiv,o.cursorDiv,o.lineDiv],null,"position: relative; outline: none");var i=L("div",[o.lineSpace],"CodeMirror-lines");o.mover=M("div",[i],null,"position: relative"),o.sizer=M("div",[o.mover],"CodeMirror-sizer"),o.sizerWidth=null,o.heightForcer=M("div",null,null,"position: absolute; height: "+U+"px; width: 1px;"),o.gutters=M("div",null,"CodeMirror-gutters"),o.lineGutter=null,o.scroller=M("div",[o.sizer,o.heightForcer,o.gutters],"CodeMirror-scroll"),o.scroller.setAttribute("tabIndex","-1"),o.wrapper=M("div",[o.scrollbarFiller,o.gutterFiller,o.scroller],"CodeMirror"),a&&s<8&&(o.gutters.style.zIndex=-1,o.scroller.style.paddingRight=0),l||n&&v||(o.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(o.wrapper):e(o.wrapper)),o.viewFrom=o.viewTo=t.first,o.reportedViewFrom=o.reportedViewTo=t.first,o.view=[],o.renderedView=null,o.externalMeasured=null,o.viewOffset=0,o.lastWrapHeight=o.lastWrapWidth=0,o.updateLineNumbers=null,o.nativeBarWidth=o.barHeight=o.barWidth=0,o.scrollbarsClipped=!1,o.lineNumWidth=o.lineNumInnerWidth=o.lineNumChars=null,o.alignWidgets=!1,o.cachedCharWidth=o.cachedTextHeight=o.cachedPaddingH=null,o.maxLine=null,o.maxLineLength=0,o.maxLineChanged=!1,o.wheelDX=o.wheelDY=o.wheelStartX=o.wheelStartY=null,o.shift=!1,o.selForContextMenu=null,o.activeTouch=null,r.init(o)}(e,o,i);for(var c in u.wrapper.CodeMirror=this,uo(this),ma(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Rr(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 B,keySeq:null,specialChars:null},t.autofocus&&!v&&u.input.focus(),a&&s<11&&setTimeout(function(){return r.display.input.reset(!0)},20),function(e){var t=e.display;Ze(t.scroller,"mousedown",Kr(e,ca)),Ze(t.scroller,"dblclick",a&&s<11?Kr(e,function(t){if(!rt(e,t)){var n=ar(e,t);if(n&&!fa(e,t)&&!wn(e.display,t)){st(t);var r=e.findWordAt(n);zo(e.doc,r.anchor,r.head)}}}):function(t){return rt(e,t)||st(t)}),C||Ze(t.scroller,"contextmenu",function(t){return ha(e,t)});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}Ze(t.scroller,"touchstart",function(o){if(!rt(e,o)&&!function(e){if(1!=e.touches.length)return!1;var t=e.touches[0];return t.radiusX<=1&&t.radiusY<=1}(o)&&!fa(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)}}),Ze(t.scroller,"touchmove",function(){t.activeTouch&&(t.activeTouch.moved=!0)}),Ze(t.scroller,"touchend",function(n){var r=t.activeTouch;if(r&&!wn(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 bo(s,s):!r.prev.prev||i(r,r.prev.prev)?e.findWordAt(s):new bo(me(s.line,0),ke(e.doc,me(s.line+1,0))),e.setSelection(a.anchor,a.head),e.focus(),st(n)}o()}),Ze(t.scroller,"touchcancel",o),Ze(t.scroller,"scroll",function(){t.scroller.clientHeight&&(Mr(e,t.scroller.scrollTop),Ar(e,t.scroller.scrollLeft,!0),nt(e,"scroll",e))}),Ze(t.scroller,"mousewheel",function(t){return go(e,t)}),Ze(t.scroller,"DOMMouseScroll",function(t){return go(e,t)}),Ze(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function(t){rt(e,t)||ct(t)},over:function(t){rt(e,t)||(function(e,t){var n=ar(e,t);if(n){var r=document.createDocumentFragment();cr(e,n,r),e.display.dragCursor||(e.display.dragCursor=M("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),O(e.display.dragCursor,r)}}(e,t),ct(t))},start:function(t){return function(e,t){if(a&&(!e.state.draggingText||+new Date-xi<100))ct(t);else if(!rt(e,t)&&!wn(e.display,t)&&(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!p)){var n=M("img",null,null,"position: fixed; left: 0; top: 0;");n.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",d&&(n.width=n.height=1,e.display.wrapper.appendChild(n),n._top=n.offsetTop),t.dataTransfer.setDragImage(n,0,0),d&&n.parentNode.removeChild(n)}}(e,t)},drop:Kr(e,Ti),leave:function(t){rt(e,t)||Oi(e)}};var l=t.input.getField();Ze(l,"keyup",function(t){return ia.call(e,t)}),Ze(l,"keydown",Kr(e,oa)),Ze(l,"keypress",Kr(e,aa)),Ze(l,"focus",function(t){return gr(e,t)}),Ze(l,"blur",function(t){return vr(e,t)})}(this),Ai(),Hr(this),this.curOp.forceUpdate=!0,Lo(this,o),t.autofocus&&!v||this.hasFocus()?setTimeout(F(gr,this),20):vr(this),ba)ba.hasOwnProperty(c)&&ba[c](r,t[c],ga);kr(this),t.finishInit&&t.finishInit(this);for(var f=0;f150)){if(!r)return;n="prev"}}else u=0,n="not";"prev"==n?u=t>i.first?R(se(i,t-1).text,null,a):0:"add"==n?u=l+e.options.indentUnit:"subtract"==n?u=l-e.options.indentUnit:"number"==typeof n&&(u=l+n),u=Math.max(0,u);var d="",p=0;if(e.options.indentWithTabs)for(var f=Math.floor(u/a);f;--f)p+=a,d+="\t";if(p1)if(Ea&&Ea.text.join("\n")==t){if(r.ranges.length%Ea.text.length==0){u=[];for(var c=0;c=0;d--){var p=r.ranges[d],f=p.from(),h=p.to();p.empty()&&(n&&n>0?f=me(f.line,f.ch-n):e.state.overwrite&&!s?h=me(h.line,Math.min(se(i,h.line).text.length,h.ch+$(l).length)):Ea&&Ea.lineWise&&Ea.text.join("\n")==t&&(f=h=me(f.line,0))),a=e.curOp.updateInput;var m={from:f,to:h,text:u?u[d%u.length]:l,origin:o||(s?"paste":e.state.cutIncoming?"cut":"+input")};oi(e.doc,m),sn(e,"inputRead",e,m)}t&&!s&&Ma(e,t),Er(e),e.curOp.updateInput=a,e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=!1}function Oa(e,t){var n=e.clipboardData&&e.clipboardData.getData("Text");if(n)return e.preventDefault(),t.isReadOnly()||t.options.disableInput||qr(t,function(){return Ta(t,n,0,null,"paste")}),!0}function Ma(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-1){a=Sa(e,o.head.line,"smart");break}}else i.electricInput&&i.electricInput.test(se(e.doc,o.head.line).text.slice(0,o.head.ch))&&(a=Sa(e,o.head.line,"smart"));a&&sn(e,"electricInput",e,o.head.line)}}}function La(e){for(var t=[],n=[],r=0;r=t.text.length?(n.ch=t.text.length,n.sticky="before"):n.ch<=0&&(n.ch=0,n.sticky="after");var i=$e(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=a.from&&p>=c.begin)){var f=d?"before":"after";return new me(n.line,p,f)}}var h=function(e,t,r){for(var i=function(e,t){return t?new me(n.line,l(e,1),"before"):new me(n.line,e,"after")};e>=0&&e0==(1!=a.level),u=s?r.begin:l(r.end,-1);if(a.from<=u&&u0?c.end:l(c.begin,-1);return null==g||r>0&&g==t.text.length||!(m=h(r>0?0:o.length-1,r,u(g)))?null:m}(e.cm,s,t,n):Ki(s,t,n))){if(r||((a=t.line+n)=e.first+e.size||(t=new me(a,t.ch,t.sticky),!(s=se(e,a)))))return!1;t=Yi(o,e.cm,s,t.line,n)}else t=i;return!0}if("char"==r)l();else if("column"==r)l(!0);else if("word"==r||"group"==r)for(var u=null,c="group"==r,d=e.cm&&e.cm.getHelper(t,"wordChars"),p=!0;!(n<0)||l(!p);p=!1){var f=s.text.charAt(t.ch)||"\n",h=te(f,d)?"w":c&&"\n"==f?"n":!c||/\s/.test(f)?null:"p";if(!c||p||h||(h="s"),u&&u!=h){n<0&&(n=1,l(),t.sticky="after");break}if(h&&(u=h),n>0&&!l(!p))break}var m=ei(e,t,i,a,!0);return ve(i,m)&&(m.hitSide=!0),m}function Na(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),u=Math.max(l-.5*er(e.display),3);o=(n>0?t.bottom:t.top)+n*u}else"line"==r&&(o=n>0?t.bottom+3:t.top-3);for(;(i=$n(e,s,o)).outside;){if(n<0?o<=0:o>=a.height){i.hitSide=!0;break}o+=5*n}return i}var ja=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new B,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};function Fa(e,t){var n=Ln(e,t.line);if(!n||n.hidden)return null;var r=se(e.doc,t.line),o=On(n,r,t.line),i=Xe(r,e.doc.direction),a="left";if(i){var s=$e(i,t.ch);a=s%2?"right":"left"}var l=jn(o.map,t.ch,a);return l.offset="right"==l.collapse?l.end:l.start,l}function Ia(e,t){return t&&(e.bad=!0),e}function Ra(e,t,n){var r;if(t==e.display.lineDiv){if(!(r=e.display.lineDiv.childNodes[n]))return Ia(e.clipPos(me(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=t.display.viewTo||i.line=t.display.viewFrom&&Fa(t,o)||{node:l[0].measure.map[2],offset:0},c=i.liner.firstLine()&&(a=me(a.line-1,se(r.doc,a.line-1).length)),s.ch==se(r.doc,s.line).text.length&&s.lineo.viewTo-1)return!1;a.line==o.viewFrom||0==(e=sr(r,a.line))?(t=de(o.view[0].line),n=o.view[0].node):(t=de(o.view[e].line),n=o.view[e-1].node.nextSibling);var l,u,c=sr(r,s.line);if(c==o.view.length-1?(l=o.viewTo-1,u=o.lineDiv.lastChild):(l=de(o.view[c+1].line)-1,u=o.view[c+1].node.previousSibling),!n)return!1;for(var d=r.doc.splitLines(function(e,t,n,r,o){var i="",a=!1,s=e.doc.lineSeparator();function l(){a&&(i+=s,a=!1)}function u(e){e&&(l(),i+=e)}function c(t){if(1==t.nodeType){var n=t.getAttribute("cm-text");if(null!=n)return void u(n||t.textContent.replace(/\u200b/g,""));var i,d=t.getAttribute("cm-marker");if(d){var p=e.findMarks(me(r,0),me(o+1,0),(m=+d,function(e){return e.id==m}));return void(p.length&&(i=p[0].find(0))&&u(le(e.doc,i.from,i.to).join(s)))}if("false"==t.getAttribute("contenteditable"))return;var f=/^(pre|div|p)$/i.test(t.nodeName);f&&l();for(var h=0;h1&&p.length>1;)if($(d)==$(p))d.pop(),p.pop(),l--;else{if(d[0]!=p[0])break;d.shift(),p.shift(),t++}for(var f=0,h=0,m=d[0],g=p[0],v=Math.min(m.length,g.length);fa.ch&&b.charCodeAt(b.length-h-1)==y.charCodeAt(y.length-h-1);)f--,h++;d[d.length-1]=b.slice(0,b.length-h).replace(/^\u200b+/,""),d[0]=d[0].slice(f).replace(/\u200b+$/,"");var w=me(t,f),k=me(l,p.length?$(p).length-h:0);return d.length>1||d[0]||ge(w,k)?(ui(r.doc,d,w,k,"+input"),!0):void 0},ja.prototype.ensurePolled=function(){this.forceCompositionEnd()},ja.prototype.reset=function(){this.forceCompositionEnd()},ja.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},ja.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))},ja.prototype.updateFromDOM=function(){var e=this;!this.cm.isReadOnly()&&this.pollContent()||qr(this.cm,function(){return Qr(e.cm)})},ja.prototype.setUneditable=function(e){e.contentEditable="false"},ja.prototype.onKeyPress=function(e){0!=e.charCode&&(e.preventDefault(),this.cm.isReadOnly()||Kr(this.cm,Ta)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0))},ja.prototype.readOnlyChanged=function(e){this.div.contentEditable=String("nocursor"!=e)},ja.prototype.onContextMenu=function(){},ja.prototype.resetPosition=function(){},ja.prototype.needsContentAttribute=!0;var Ha=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new B,this.hasSelection=!1,this.composing=null};Ha.prototype.init=function(e){var t=this,n=this,r=this.cm,o=this.wrapper=Pa(),i=this.textarea=o.firstChild;function l(e){if(!rt(r,e)){if(r.somethingSelected())xa({lineWise:!1,text:r.getSelections()});else{if(!r.options.lineWiseCopyCut)return;var t=La(r);xa({lineWise:!0,text:t.text}),"cut"==e.type?r.setSelections(t.ranges,null,z):(n.prevInput="",i.value=t.text.join("\n"),j(i))}"cut"==e.type&&(r.state.cutIncoming=!0)}}e.wrapper.insertBefore(o,e.wrapper.firstChild),m&&(i.style.width="0px"),Ze(i,"input",function(){a&&s>=9&&t.hasSelection&&(t.hasSelection=null),n.poll()}),Ze(i,"paste",function(e){rt(r,e)||Oa(e,r)||(r.state.pasteIncoming=!0,n.fastPoll())}),Ze(i,"cut",l),Ze(i,"copy",l),Ze(e.scroller,"paste",function(t){wn(e,t)||rt(r,t)||(r.state.pasteIncoming=!0,n.focus())}),Ze(e.lineSpace,"selectstart",function(t){wn(e,t)||st(t)}),Ze(i,"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"})}}),Ze(i,"compositionend",function(){n.composing&&(n.poll(),n.composing.range.clear(),n.composing=null)})},Ha.prototype.prepareSelection=function(){var e=this.cm,t=e.display,n=e.doc,r=ur(e);if(e.options.moveInputWithCursor){var o=qn(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},Ha.prototype.showSelection=function(e){var t=this.cm,n=t.display;O(n.cursorDiv,e.cursors),O(n.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},Ha.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&&j(this.textarea),a&&s>=9&&(this.hasSelection=n)}else e||(this.prevInput=this.textarea.value="",a&&s>=9&&(this.hasSelection=null))}},Ha.prototype.getField=function(){return this.textarea},Ha.prototype.supportsTouch=function(){return!1},Ha.prototype.focus=function(){if("nocursor"!=this.cm.options.readOnly&&(!v||P()!=this.textarea))try{this.textarea.focus()}catch(e){}},Ha.prototype.blur=function(){this.textarea.blur()},Ha.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},Ha.prototype.receivedFocus=function(){this.slowPoll()},Ha.prototype.slowPoll=function(){var e=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},Ha.prototype.fastPoll=function(){var e=!1,t=this;t.pollingFast=!0,t.polling.set(20,function n(){var r=t.poll();r||e?(t.pollingFast=!1,t.slowPoll()):(e=!0,t.polling.set(60,n))})},Ha.prototype.poll=function(){var e=this,t=this.cm,n=this.textarea,r=this.prevInput;if(this.contextMenuPending||!t.state.focused||_t(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||b&&/[\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,u=Math.min(r.length,o.length);l1e3||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},Ha.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},Ha.prototype.onKeyPress=function(){a&&s>=9&&(this.hasSelection=null),this.fastPoll()},Ha.prototype.onContextMenu=function(e){var t=this,n=t.cm,r=n.display,o=t.textarea,i=ar(n,e),u=r.scroller.scrollTop;if(i&&!d){var c=n.options.resetSelectionOnContextMenu;c&&-1==n.doc.sel.contains(i)&&Kr(n,Yo)(n.doc,_o(i),z);var p=o.style.cssText,f=t.wrapper.style.cssText;t.wrapper.style.cssText="position: absolute";var h,m=t.wrapper.getBoundingClientRect();if(o.style.cssText="position: absolute; width: 30px; height: 30px;\n top: "+(e.clientY-m.top-5)+"px; left: "+(e.clientX-m.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&&(h=window.scrollY),r.input.focus(),l&&window.scrollTo(null,h),r.input.reset(),n.somethingSelected()||(o.value=t.prevInput=" "),t.contextMenuPending=!0,r.selForContextMenu=n.doc.sel,clearTimeout(r.detectingSelectAll),a&&s>=9&&v(),C){ct(e);var g=function(){tt(window,"mouseup",g),setTimeout(b,20)};Ze(window,"mouseup",g)}else setTimeout(b,50)}function v(){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 b(){if(t.contextMenuPending=!1,t.wrapper.style.cssText=f,o.style.cssText=p,a&&s<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=u),null!=o.selectionStart){(!a||a&&s<9)&&v();var e=0,i=function(){r.selForContextMenu==n.doc.sel&&0==o.selectionStart&&o.selectionEnd>0&&""==t.prevInput?Kr(n,ni)(n):e++<10?r.detectingSelectAll=setTimeout(i,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(i,200)}}},Ha.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled="nocursor"==e},Ha.prototype.setUneditable=function(){},Ha.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!=ga&&o(e,t,n)}:o)}e.defineOption=n,e.Init=ga,n("value","",function(e,t){return e.setValue(t)},!0),n("mode",null,function(e,t){e.doc.modeOption=t,Eo(e)},!0),n("indentUnit",2,Eo,!0),n("indentWithTabs",!1),n("smartIndent",!0),n("tabSize",4,function(e){xo(e),Bn(e),Qr(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(me(r,i))}r++});for(var o=n.length-1;o>=0;o--)ui(e.doc,t,n[o],me(n[o].line,n[o].ch+t.length))}}),n("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff]/g,function(e,t,n){e.state.specialChars=new RegExp(t.source+(t.test("\t")?"":"|\t"),"g"),n!=ga&&e.refresh()}),n("specialCharPlaceholder",Xt,function(e){return e.refresh()},!0),n("electricChars",!0),n("inputStyle",v?"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("rtlMoveVisually",!_),n("wholeLineUpdateBefore",!0),n("theme","default",function(e){ma(e),ya(e)},!0),n("keyMap","default",function(e,t,n){var r=Wi(t),o=n!=ga&&Wi(n);o&&o.detach&&o.detach(e,r),r.attach&&r.attach(e,o||null)}),n("extraKeys",null),n("configureMouse",null),n("lineWrapping",!1,wa,!0),n("gutters",[],function(e){co(e.options),ya(e)},!0),n("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?rr(e.display)+"px":"0",e.refresh()},!0),n("coverGutterNextToScrollbar",!1,function(e){return jr(e)},!0),n("scrollbarStyle","native",function(e){Rr(e),jr(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),n("lineNumbers",!1,function(e){co(e.options),ya(e)},!0),n("firstLineNumber",1,ya,!0),n("lineNumberFormatter",function(e){return e},ya,!0),n("showCursorWhenSelecting",!1,lr,!0),n("resetSelectionOnContextMenu",!0),n("lineWiseCopyCut",!0),n("pasteLinesPerSelection",!0),n("readOnly",!1,function(e,t){"nocursor"==t&&(vr(e),e.display.input.blur()),e.display.input.readOnlyChanged(t)}),n("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),n("dragDrop",!0,_a),n("allowDropFileTypes",null),n("cursorBlinkRate",530),n("cursorScrollMargin",0),n("cursorHeight",1,lr,!0),n("singleCursorHeightPerLine",!0,lr,!0),n("workTime",100),n("workDelay",100),n("flattenSpans",!0,xo,!0),n("addModeClass",!1,xo,!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,xo,!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)}(ka),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)&&Kr(this,t[e])(this,n,o),nt(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"](Wi(e))},removeKeyMap:function(e){for(var t=this.state.keyMaps,n=0;nn&&(Sa(this,o.head.line,e,!0),n=o.head.line,r==this.doc.sel.primIndex&&Er(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;l0&&Go(this.doc,r,new bo(i,u[r].to()),z)}}}),getTokenAt:function(e,t){return Vt(this,e,t)},getLineTokens:function(e,t){return Vt(this,me(e),t,!0)},getTokenTypeAt:function(e){e=ke(this.doc,e);var t,n=Ft(this,se(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&&(e=i,o=!0),r=se(this.doc,e)}else r=e;return zn(this,r,{top:0,left:0},t||"page",n||o).top+(o?this.doc.height-Ge(r):0)},defaultTextHeight:function(){return er(this.display)},defaultCharWidth:function(){return tr(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,u=(e=qn(this,ke(this.doc,e))).bottom,c=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),l.sizer.appendChild(t),"over"==r)u=e.top;else if("above"==r||"near"==r){var d=Math.max(l.wrapper.clientHeight,this.doc.height),p=Math.max(l.sizer.clientWidth,l.lineSpace.clientWidth);("above"==r||e.bottom+t.offsetHeight>d)&&e.top>t.offsetHeight?u=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=d&&(u=e.bottom),c+t.offsetWidth>p&&(c=p-t.offsetWidth)}t.style.top=u+"px",t.style.left=t.style.right="","right"==o?(c=l.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==o?c=0:"middle"==o&&(c=(l.sizer.clientWidth-t.offsetWidth)/2),t.style.left=c+"px"),n&&(i=this,a={left:c,top:u,right:c+t.offsetWidth,bottom:u+t.offsetHeight},null!=(s=Cr(i,a)).scrollTop&&Mr(i,s.scrollTop),null!=s.scrollLeft&&Ar(i,s.scrollLeft))},triggerOnKeyDown:Yr(oa),triggerOnKeyPress:Yr(aa),triggerOnKeyUp:ia,triggerOnMouseDown:Yr(ca),execCommand:function(e){if($i.hasOwnProperty(e))return $i[e].call(null,this)},triggerElectric:Yr(function(e){Ma(this,e)}),findPosH:function(e,t,n,r){var o=1;t<0&&(o=-1,t=-t);for(var i=ke(this.doc,e),a=0;a0&&s(n.charAt(r-1));)--r;for(;o.5)&&ir(this),nt(this,"refresh",this)}),swapDoc:Yr(function(e){var t=this.doc;return t.cm=null,Lo(this,e),Bn(this),this.display.input.reset(),xr(this,e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,sn(this,"swapDoc",this,t),t}),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}},at(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})}}(ka);var Ua,Va="iter insert remove copy getEditor constructor".split(" ");for(var za in Ei.prototype)Ei.prototype.hasOwnProperty(za)&&H(Va,za)<0&&(ka.prototype[za]=function(e){return function(){return e.apply(this.doc,arguments)}}(Ei.prototype[za]));return at(Ei),ka.inputStyles={textarea:Ha,contenteditable:ja},ka.defineMode=function(e){ka.defaults.mode||"null"==e||(ka.defaults.mode=e),function(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Ct[e]=t}.apply(this,arguments)},ka.defineMIME=function(e,t){St[e]=t},ka.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),ka.defineMIME("text/plain","null"),ka.defineExtension=function(e,t){ka.prototype[e]=t},ka.defineDocExtension=function(e,t){Ei.prototype[e]=t},ka.fromTextArea=function(e,t){if((t=t?I(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=P();t.autofocus=n==e||null!=e.getAttribute("autofocus")&&n==document.body}function r(){e.value=s.getValue()}var o;if(e.form&&(Ze(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(t){t.save=r,t.getTextArea=function(){return e},t.toTextArea=function(){t.toTextArea=isNaN,r(),e.parentNode.removeChild(t.getWrapperElement()),e.style.display="",e.form&&(tt(e.form,"submit",r),"function"==typeof e.form.submit&&(e.form.submit=o))}},e.style.display="none";var s=ka(function(t){return e.parentNode.insertBefore(t,e.nextSibling)},t);return s},(Ua=ka).off=tt,Ua.on=Ze,Ua.wheelEventPixels=mo,Ua.Doc=Ei,Ua.splitLines=yt,Ua.countColumn=R,Ua.findColumn=q,Ua.isWordChar=ee,Ua.Pass=V,Ua.signal=nt,Ua.Line=Gt,Ua.changeEnd=wo,Ua.scrollbarModel=Ir,Ua.Pos=me,Ua.cmpPos=ge,Ua.modes=Ct,Ua.mimeModes=St,Ua.resolveMode=Et,Ua.getMode=xt,Ua.modeExtensions=Tt,Ua.extendMode=Ot,Ua.copyState=Mt,Ua.startState=At,Ua.innerMode=Lt,Ua.commands=$i,Ua.keyMap=Ii,Ua.keyName=zi,Ua.isModifierKey=Ui,Ua.lookupKey=Hi,Ua.normalizeKeyMap=Bi,Ua.StringStream=Pt,Ua.SharedTextMarker=wi,Ua.TextMarker=yi,Ua.LineWidget=gi,Ua.e_preventDefault=st,Ua.e_stopPropagation=lt,Ua.e_stop=ct,Ua.addClass=D,Ua.contains=A,Ua.rmClass=x,Ua.keyNames=Di,ka.version="5.34.0",ka}()},function(e,t,n){"use strict";e.exports=function(e,t,n,r,o,i,a,s){if(!e){var l;if(void 0===t)l=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[n,r,o,i,a,s],c=0;(l=new Error(t.replace(/%s/g,function(){return u[c++]}))).name="Invariant Violation"}throw l.framesToPop=1,l}}},function(e,t,n){"use strict";function r(e,t,n,r){this.col=n,this.line=t,this.text=e,this.type=r}e.exports=r,r.fromToken=function(e){return new r(e.value,e.startLine,e.startCol)},r.prototype={constructor:r,valueOf:function(){return this.toString()},toString:function(){return this.text}}},function(e,t,n){"use strict";e.exports=b;var r=n(956),o=n(915),i=n(904),a=n(957),s=n(955),l=n(954),u=n(953),c=n(952),d=n(927),p=n(951),f=n(926),h=n(949),m=n(948),g=n(914),v=n(1085);function b(e){r.call(this),this.options=e||{},this._tokenStream=null}b.DEFAULT_TYPE=0,b.COMBINATOR_TYPE=1,b.MEDIA_FEATURE_TYPE=2,b.MEDIA_QUERY_TYPE=3,b.PROPERTY_NAME_TYPE=4,b.PROPERTY_VALUE_TYPE=5,b.PROPERTY_VALUE_PART_TYPE=6,b.SELECTOR_TYPE=7,b.SELECTOR_PART_TYPE=8,b.SELECTOR_SUB_PART_TYPE=9,b.prototype=function(){var e,t=new r,n={__proto__:null,constructor:b,DEFAULT_TYPE:0,COMBINATOR_TYPE:1,MEDIA_FEATURE_TYPE:2,MEDIA_QUERY_TYPE:3,PROPERTY_NAME_TYPE:4,PROPERTY_VALUE_TYPE:5,PROPERTY_VALUE_PART_TYPE:6,SELECTOR_TYPE:7,SELECTOR_PART_TYPE:8,SELECTOR_SUB_PART_TYPE:9,_stylesheet:function(){var e,t,n,r=this._tokenStream;for(this.fire("startstylesheet"),this._charset(),this._skipCruft();r.peek()===g.IMPORT_SYM;)this._import(),this._skipCruft();for(;r.peek()===g.NAMESPACE_SYM;)this._namespace(),this._skipCruft();for(n=r.peek();n>g.EOF;){try{switch(n){case g.MEDIA_SYM:this._media(),this._skipCruft();break;case g.PAGE_SYM:this._page(),this._skipCruft();break;case g.FONT_FACE_SYM:this._font_face(),this._skipCruft();break;case g.KEYFRAMES_SYM:this._keyframes(),this._skipCruft();break;case g.VIEWPORT_SYM:this._viewport(),this._skipCruft();break;case g.DOCUMENT_SYM:this._document(),this._skipCruft();break;case g.SUPPORTS_SYM:this._supports(),this._skipCruft();break;case g.UNKNOWN_SYM:if(r.get(),this.options.strict)throw new o("Unknown @ rule.",r.LT(0).startLine,r.LT(0).startCol);for(this.fire({type:"error",error:null,message:"Unknown @ rule: "+r.LT(0).value+".",line:r.LT(0).startLine,col:r.LT(0).startCol}),e=0;r.advance([g.LBRACE,g.RBRACE])===g.LBRACE;)e++;for(;e;)r.advance([g.RBRACE]),e--;break;case g.S:this._readWhitespace();break;default:if(!this._ruleset())switch(n){case g.CHARSET_SYM:throw t=r.LT(1),this._charset(!1),new o("@charset not allowed here.",t.startLine,t.startCol);case g.IMPORT_SYM:throw t=r.LT(1),this._import(!1),new o("@import not allowed here.",t.startLine,t.startCol);case g.NAMESPACE_SYM:throw t=r.LT(1),this._namespace(!1),new o("@namespace not allowed here.",t.startLine,t.startCol);default:r.get(),this._unexpectedToken(r.token())}}}catch(e){if(!(e instanceof o)||this.options.strict)throw e;this.fire({type:"error",error:e,message:e.message,line:e.line,col:e.col})}n=r.peek()}n!==g.EOF&&this._unexpectedToken(r.token()),this.fire("endstylesheet")},_charset:function(e){var t,n,r,o=this._tokenStream;o.match(g.CHARSET_SYM)&&(n=o.token().startLine,r=o.token().startCol,this._readWhitespace(),o.mustMatch(g.STRING),t=o.token().value,this._readWhitespace(),o.mustMatch(g.SEMICOLON),!1!==e&&this.fire({type:"charset",charset:t,line:n,col:r}))},_import:function(e){var t,n,r,o=this._tokenStream;o.mustMatch(g.IMPORT_SYM),n=o.token(),this._readWhitespace(),o.mustMatch([g.STRING,g.URI]),t=o.token().value.replace(/^(?:url\()?["']?([^"']+?)["']?\)?$/,"$1"),this._readWhitespace(),r=this._media_query_list(),o.mustMatch(g.SEMICOLON),this._readWhitespace(),!1!==e&&this.fire({type:"import",uri:t,media:r,line:n.startLine,col:n.startCol})},_namespace:function(e){var t,n,r,o,i=this._tokenStream;i.mustMatch(g.NAMESPACE_SYM),t=i.token().startLine,n=i.token().startCol,this._readWhitespace(),i.match(g.IDENT)&&(r=i.token().value,this._readWhitespace()),i.mustMatch([g.STRING,g.URI]),o=i.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/,"$1"),this._readWhitespace(),i.mustMatch(g.SEMICOLON),this._readWhitespace(),!1!==e&&this.fire({type:"namespace",prefix:r,uri:o,line:t,col:n})},_supports:function(e){var t,n,r=this._tokenStream;if(r.match(g.SUPPORTS_SYM)){for(t=r.token().startLine,n=r.token().startCol,this._readWhitespace(),this._supports_condition(),this._readWhitespace(),r.mustMatch(g.LBRACE),this._readWhitespace(),!1!==e&&this.fire({type:"startsupports",line:t,col:n});this._ruleset(););r.mustMatch(g.RBRACE),this._readWhitespace(),this.fire({type:"endsupports",line:t,col:n})}},_supports_condition:function(){var e,t=this._tokenStream;if(t.match(g.IDENT))"not"===(e=t.token().value.toLowerCase())?(t.mustMatch(g.S),this._supports_condition_in_parens()):t.unget();else for(this._supports_condition_in_parens(),this._readWhitespace();t.peek()===g.IDENT;)"and"!==(e=t.LT(1).value.toLowerCase())&&"or"!==e||(t.mustMatch(g.IDENT),this._readWhitespace(),this._supports_condition_in_parens(),this._readWhitespace())},_supports_condition_in_parens:function(){var e=this._tokenStream;e.match(g.LPAREN)?(this._readWhitespace(),e.match(g.IDENT)?"not"===e.token().value.toLowerCase()?(this._readWhitespace(),this._supports_condition(),this._readWhitespace(),e.mustMatch(g.RPAREN)):(e.unget(),this._supports_declaration_condition(!1)):(this._supports_condition(),this._readWhitespace(),e.mustMatch(g.RPAREN))):this._supports_declaration_condition()},_supports_declaration_condition:function(e){var t=this._tokenStream;!1!==e&&t.mustMatch(g.LPAREN),this._readWhitespace(),this._declaration(),t.mustMatch(g.RPAREN)},_media:function(){var e,t,n,r=this._tokenStream;for(r.mustMatch(g.MEDIA_SYM),e=r.token().startLine,t=r.token().startCol,this._readWhitespace(),n=this._media_query_list(),r.mustMatch(g.LBRACE),this._readWhitespace(),this.fire({type:"startmedia",media:n,line:e,col:t});;)if(r.peek()===g.PAGE_SYM)this._page();else if(r.peek()===g.FONT_FACE_SYM)this._font_face();else if(r.peek()===g.VIEWPORT_SYM)this._viewport();else if(r.peek()===g.DOCUMENT_SYM)this._document();else if(r.peek()===g.SUPPORTS_SYM)this._supports();else if(r.peek()===g.MEDIA_SYM)this._media();else if(!this._ruleset())break;r.mustMatch(g.RBRACE),this._readWhitespace(),this.fire({type:"endmedia",media:n,line:e,col:t})},_media_query_list:function(){var e=this._tokenStream,t=[];for(this._readWhitespace(),e.peek()!==g.IDENT&&e.peek()!==g.LPAREN||t.push(this._media_query());e.match(g.COMMA);)this._readWhitespace(),t.push(this._media_query());return t},_media_query:function(){var e=this._tokenStream,t=null,n=null,r=null,o=[];if(e.match(g.IDENT)&&("only"!==(n=e.token().value.toLowerCase())&&"not"!==n?(e.unget(),n=null):r=e.token()),this._readWhitespace(),e.peek()===g.IDENT?(t=this._media_type(),null===r&&(r=e.token())):e.peek()===g.LPAREN&&(null===r&&(r=e.LT(1)),o.push(this._media_expression())),null===t&&0===o.length)return null;for(this._readWhitespace();e.match(g.IDENT);)"and"!==e.token().value.toLowerCase()&&this._unexpectedToken(e.token()),this._readWhitespace(),o.push(this._media_expression());return new l(n,t,o,r.startLine,r.startCol)},_media_type:function(){return this._media_feature()},_media_expression:function(){var e,t,n=this._tokenStream,r=null;return n.mustMatch(g.LPAREN),e=this._media_feature(),this._readWhitespace(),n.match(g.COLON)&&(this._readWhitespace(),t=n.LT(1),r=this._expression()),n.mustMatch(g.RPAREN),this._readWhitespace(),new s(e,r?new i(r,t.startLine,t.startCol):null)},_media_feature:function(){var e=this._tokenStream;return this._readWhitespace(),e.mustMatch(g.IDENT),i.fromToken(e.token())},_page:function(){var e,t,n=this._tokenStream,r=null,o=null;n.mustMatch(g.PAGE_SYM),e=n.token().startLine,t=n.token().startCol,this._readWhitespace(),n.match(g.IDENT)&&"auto"===(r=n.token().value).toLowerCase()&&this._unexpectedToken(n.token()),n.peek()===g.COLON&&(o=this._pseudo_page()),this._readWhitespace(),this.fire({type:"startpage",id:r,pseudo:o,line:e,col:t}),this._readDeclarations(!0,!0),this.fire({type:"endpage",id:r,pseudo:o,line:e,col:t})},_margin:function(){var e,t,n=this._tokenStream,r=this._margin_sym();return!!r&&(e=n.token().startLine,t=n.token().startCol,this.fire({type:"startpagemargin",margin:r,line:e,col:t}),this._readDeclarations(!0),this.fire({type:"endpagemargin",margin:r,line:e,col:t}),!0)},_margin_sym:function(){var e=this._tokenStream;return e.match([g.TOPLEFTCORNER_SYM,g.TOPLEFT_SYM,g.TOPCENTER_SYM,g.TOPRIGHT_SYM,g.TOPRIGHTCORNER_SYM,g.BOTTOMLEFTCORNER_SYM,g.BOTTOMLEFT_SYM,g.BOTTOMCENTER_SYM,g.BOTTOMRIGHT_SYM,g.BOTTOMRIGHTCORNER_SYM,g.LEFTTOP_SYM,g.LEFTMIDDLE_SYM,g.LEFTBOTTOM_SYM,g.RIGHTTOP_SYM,g.RIGHTMIDDLE_SYM,g.RIGHTBOTTOM_SYM])?i.fromToken(e.token()):null},_pseudo_page:function(){var e=this._tokenStream;return e.mustMatch(g.COLON),e.mustMatch(g.IDENT),e.token().value},_font_face:function(){var e,t,n=this._tokenStream;n.mustMatch(g.FONT_FACE_SYM),e=n.token().startLine,t=n.token().startCol,this._readWhitespace(),this.fire({type:"startfontface",line:e,col:t}),this._readDeclarations(!0),this.fire({type:"endfontface",line:e,col:t})},_viewport:function(){var e,t,n=this._tokenStream;n.mustMatch(g.VIEWPORT_SYM),e=n.token().startLine,t=n.token().startCol,this._readWhitespace(),this.fire({type:"startviewport",line:e,col:t}),this._readDeclarations(!0),this.fire({type:"endviewport",line:e,col:t})},_document:function(){var e,t=this._tokenStream,n=[],r="";for(t.mustMatch(g.DOCUMENT_SYM),e=t.token(),/^@\-([^\-]+)\-/.test(e.value)&&(r=RegExp.$1),this._readWhitespace(),n.push(this._document_function());t.match(g.COMMA);)this._readWhitespace(),n.push(this._document_function());t.mustMatch(g.LBRACE),this._readWhitespace(),this.fire({type:"startdocument",functions:n,prefix:r,line:e.startLine,col:e.startCol});for(var o=!0;o;)switch(t.peek()){case g.PAGE_SYM:this._page();break;case g.FONT_FACE_SYM:this._font_face();break;case g.VIEWPORT_SYM:this._viewport();break;case g.MEDIA_SYM:this._media();break;case g.KEYFRAMES_SYM:this._keyframes();break;case g.DOCUMENT_SYM:this._document();break;default:o=Boolean(this._ruleset())}t.mustMatch(g.RBRACE),e=t.token(),this._readWhitespace(),this.fire({type:"enddocument",functions:n,prefix:r,line:e.startLine,col:e.startCol})},_document_function:function(){var e,t=this._tokenStream;return t.match(g.URI)?(e=t.token().value,this._readWhitespace()):e=this._function(),e},_operator:function(e){var t=this._tokenStream,n=null;return(t.match([g.SLASH,g.COMMA])||e&&t.match([g.PLUS,g.STAR,g.MINUS]))&&(n=t.token(),this._readWhitespace()),n?d.fromToken(n):null},_combinator:function(){var e,t=this._tokenStream,n=null;return t.match([g.PLUS,g.GREATER,g.TILDE])&&(e=t.token(),n=new a(e.value,e.startLine,e.startCol),this._readWhitespace()),n},_unary_operator:function(){var e=this._tokenStream;return e.match([g.MINUS,g.PLUS])?e.token().value:null},_property:function(){var e,t,n,r,o=this._tokenStream,i=null,a=null;return o.peek()===g.STAR&&this.options.starHack&&(o.get(),a=(t=o.token()).value,n=t.startLine,r=t.startCol),o.match(g.IDENT)&&("_"===(e=(t=o.token()).value).charAt(0)&&this.options.underscoreHack&&(a="_",e=e.substring(1)),i=new u(e,a,n||t.startLine,r||t.startCol),this._readWhitespace()),i},_ruleset:function(){var e,t=this._tokenStream;try{e=this._selectors_group()}catch(e){if(!(e instanceof o)||this.options.strict)throw e;if(this.fire({type:"error",error:e,message:e.message,line:e.line,col:e.col}),t.advance([g.RBRACE])!==g.RBRACE)throw e;return!0}return e&&(this.fire({type:"startrule",selectors:e,line:e[0].line,col:e[0].col}),this._readDeclarations(!0),this.fire({type:"endrule",selectors:e,line:e[0].line,col:e[0].col})),e},_selectors_group:function(){var e,t=this._tokenStream,n=[];if(null!==(e=this._selector()))for(n.push(e);t.match(g.COMMA);)this._readWhitespace(),null!==(e=this._selector())?n.push(e):this._unexpectedToken(t.LT(1));return n.length?n:null},_selector:function(){var e=this._tokenStream,t=[],n=null,r=null,o=null;if(null===(n=this._simple_selector_sequence()))return null;for(t.push(n);;)if(null!==(r=this._combinator()))t.push(r),null===(n=this._simple_selector_sequence())?this._unexpectedToken(e.LT(1)):t.push(n);else{if(!this._readWhitespace())break;o=new a(e.token().value,e.token().startLine,e.token().startCol),r=this._combinator(),null===(n=this._simple_selector_sequence())?null!==r&&this._unexpectedToken(e.LT(1)):(null!==r?t.push(r):t.push(o),t.push(n))}return new p(t,t[0].line,t[0].col)},_simple_selector_sequence:function(){var e,t,n=this._tokenStream,r=null,o=[],i="",a=[function(){return n.match(g.HASH)?new h(n.token().value,"id",n.token().startLine,n.token().startCol):null},this._class,this._attrib,this._pseudo,this._negation],s=0,l=a.length,u=null;for(e=n.LT(1).startLine,t=n.LT(1).startCol,(r=this._type_selector())||(r=this._universal()),null!==r&&(i+=r);n.peek()!==g.S;){for(;s1&&e.unget()),null)},_class:function(){var e,t=this._tokenStream;return t.match(g.DOT)?(t.mustMatch(g.IDENT),e=t.token(),new h("."+e.value,"class",e.startLine,e.startCol-1)):null},_element_name:function(){var e,t=this._tokenStream;return t.match(g.IDENT)?(e=t.token(),new h(e.value,"elementName",e.startLine,e.startCol)):null},_namespace_prefix:function(){var e=this._tokenStream,t="";return e.LA(1)!==g.PIPE&&e.LA(2)!==g.PIPE||(e.match([g.IDENT,g.STAR])&&(t+=e.token().value),e.mustMatch(g.PIPE),t+="|"),t.length?t:null},_universal:function(){var e,t=this._tokenStream,n="";return(e=this._namespace_prefix())&&(n+=e),t.match(g.STAR)&&(n+="*"),n.length?n:null},_attrib:function(){var e,t,n=this._tokenStream,r=null;return n.match(g.LBRACKET)?(r=(t=n.token()).value,r+=this._readWhitespace(),(e=this._namespace_prefix())&&(r+=e),n.mustMatch(g.IDENT),r+=n.token().value,r+=this._readWhitespace(),n.match([g.PREFIXMATCH,g.SUFFIXMATCH,g.SUBSTRINGMATCH,g.EQUALS,g.INCLUDES,g.DASHMATCH])&&(r+=n.token().value,r+=this._readWhitespace(),n.mustMatch([g.IDENT,g.STRING]),r+=n.token().value,r+=this._readWhitespace()),n.mustMatch(g.RBRACKET),new h(r+"]","attribute",t.startLine,t.startCol)):null},_pseudo:function(){var e,t,n=this._tokenStream,r=null,i=":";if(n.match(g.COLON)){if(n.match(g.COLON)&&(i+=":"),n.match(g.IDENT)?(r=n.token().value,e=n.token().startLine,t=n.token().startCol-i.length):n.peek()===g.FUNCTION&&(e=n.LT(1).startLine,t=n.LT(1).startCol-i.length,r=this._functional_pseudo()),!r){var a=n.LT(1).startLine,s=n.LT(0).startCol;throw new o("Expected a `FUNCTION` or `IDENT` after colon at line "+a+", col "+s+".",a,s)}r=new h(i+r,"pseudo",e,t)}return r},_functional_pseudo:function(){var e=this._tokenStream,t=null;return e.match(g.FUNCTION)&&(t=e.token().value,t+=this._readWhitespace(),t+=this._expression(),e.mustMatch(g.RPAREN),t+=")"),t},_expression:function(){for(var e=this._tokenStream,t="";e.match([g.PLUS,g.MINUS,g.DIMENSION,g.NUMBER,g.STRING,g.IDENT,g.LENGTH,g.FREQ,g.ANGLE,g.TIME,g.RESOLUTION,g.SLASH]);)t+=e.token().value,t+=this._readWhitespace();return t.length?t:null},_negation:function(){var e,t,n,r=this._tokenStream,o="",i=null;return r.match(g.NOT)&&(o=r.token().value,e=r.token().startLine,t=r.token().startCol,o+=this._readWhitespace(),o+=n=this._negation_arg(),o+=this._readWhitespace(),r.match(g.RPAREN),o+=r.token().value,(i=new h(o,"not",e,t)).args.push(n)),i},_negation_arg:function(){var e,t,n=this._tokenStream,r=[this._type_selector,this._universal,function(){return n.match(g.HASH)?new h(n.token().value,"id",n.token().startLine,n.token().startCol):null},this._class,this._attrib,this._pseudo],o=null,i=0,a=r.length;for(e=n.LT(1).startLine,t=n.LT(1).startCol;i0?new c(t,t[0].line,t[0].col):null},_term:function(e){var t,n,r,o,i=this._tokenStream,a=null,s=null,l=null;return null!==(t=this._unary_operator())&&(r=i.token().startLine,o=i.token().startCol),i.peek()===g.IE_FUNCTION&&this.options.ieFilters?(a=this._ie_function(),null===t&&(r=i.token().startLine,o=i.token().startCol)):e&&i.match([g.LPAREN,g.LBRACE,g.LBRACKET])?(s=(n=i.token()).endChar,a=n.value+this._expr(e).text,null===t&&(r=i.token().startLine,o=i.token().startCol),i.mustMatch(g.type(s)),a+=s,this._readWhitespace()):i.match([g.NUMBER,g.PERCENTAGE,g.LENGTH,g.ANGLE,g.TIME,g.FREQ,g.STRING,g.IDENT,g.URI,g.UNICODE_RANGE])?(a=i.token().value,null===t&&(r=i.token().startLine,o=i.token().startCol,l=d.fromToken(i.token())),this._readWhitespace()):null===(n=this._hexcolor())?(null===t&&(r=i.LT(1).startLine,o=i.LT(1).startCol),null===a&&(a=i.LA(3)===g.EQUALS&&this.options.ieFilters?this._ie_function():this._function())):(a=n.value,null===t&&(r=n.startLine,o=n.startCol)),null!==l?l:null!==a?new d(null!==t?t+a:a,r,o):null},_function:function(){var e,t=this._tokenStream,n=null;if(t.match(g.FUNCTION)){if(n=t.token().value,this._readWhitespace(),n+=this._expr(!0),this.options.ieFilters&&t.peek()===g.EQUALS)do{for(this._readWhitespace()&&(n+=t.token().value),t.LA(0)===g.COMMA&&(n+=t.token().value),t.match(g.IDENT),n+=t.token().value,t.match(g.EQUALS),n+=t.token().value,e=t.peek();e!==g.COMMA&&e!==g.S&&e!==g.RPAREN;)t.get(),n+=t.token().value,e=t.peek()}while(t.match([g.COMMA,g.S]));t.match(g.RPAREN),n+=")",this._readWhitespace()}return n},_ie_function:function(){var e,t=this._tokenStream,n=null;if(t.match([g.IE_FUNCTION,g.FUNCTION])){n=t.token().value;do{for(this._readWhitespace()&&(n+=t.token().value),t.LA(0)===g.COMMA&&(n+=t.token().value),t.match(g.IDENT),n+=t.token().value,t.match(g.EQUALS),n+=t.token().value,e=t.peek();e!==g.COMMA&&e!==g.S&&e!==g.RPAREN;)t.get(),n+=t.token().value,e=t.peek()}while(t.match([g.COMMA,g.S]));t.match(g.RPAREN),n+=")",this._readWhitespace()}return n},_hexcolor:function(){var e,t=this._tokenStream,n=null;if(t.match(g.HASH)){if(e=(n=t.token()).value,!/#[a-f0-9]{3,6}/i.test(e))throw new o("Expected a hex color but found '"+e+"' at line "+n.startLine+", col "+n.startCol+".",n.startLine,n.startCol);this._readWhitespace()}return n},_keyframes:function(){var e,t,n,r=this._tokenStream,o="";for(r.mustMatch(g.KEYFRAMES_SYM),e=r.token(),/^@\-([^\-]+)\-/.test(e.value)&&(o=RegExp.$1),this._readWhitespace(),n=this._keyframe_name(),this._readWhitespace(),r.mustMatch(g.LBRACE),this.fire({type:"startkeyframes",name:n,prefix:o,line:e.startLine,col:e.startCol}),this._readWhitespace(),t=r.peek();t===g.IDENT||t===g.PERCENTAGE;)this._keyframe_rule(),this._readWhitespace(),t=r.peek();this.fire({type:"endkeyframes",name:n,prefix:o,line:e.startLine,col:e.startCol}),this._readWhitespace(),r.mustMatch(g.RBRACE),this._readWhitespace()},_keyframe_name:function(){var e=this._tokenStream;return e.mustMatch([g.IDENT,g.STRING]),i.fromToken(e.token())},_keyframe_rule:function(){var e=this._key_list();this.fire({type:"startkeyframerule",keys:e,line:e[0].line,col:e[0].col}),this._readDeclarations(!0),this.fire({type:"endkeyframerule",keys:e,line:e[0].line,col:e[0].col})},_key_list:function(){var e=this._tokenStream,t=[];for(t.push(this._key()),this._readWhitespace();e.match(g.COMMA);)this._readWhitespace(),t.push(this._key()),this._readWhitespace();return t},_key:function(){var e,t=this._tokenStream;if(t.match(g.PERCENTAGE))return i.fromToken(t.token());if(t.match(g.IDENT)){if(e=t.token(),/from|to/i.test(e.value))return i.fromToken(e);t.unget()}this._unexpectedToken(t.LT(1))},_skipCruft:function(){for(;this._tokenStream.match([g.S,g.CDO,g.CDC]););},_readDeclarations:function(e,t){var n,r=this._tokenStream;this._readWhitespace(),e&&r.mustMatch(g.LBRACE),this._readWhitespace();try{for(;;){if(r.match(g.SEMICOLON)||t&&this._margin());else{if(!this._declaration())break;if(!r.match(g.SEMICOLON))break}this._readWhitespace()}r.mustMatch(g.RBRACE),this._readWhitespace()}catch(e){if(!(e instanceof o)||this.options.strict)throw e;if(this.fire({type:"error",error:e,message:e.message,line:e.line,col:e.col}),(n=r.advance([g.SEMICOLON,g.RBRACE]))===g.SEMICOLON)this._readDeclarations(!1,t);else if(n!==g.RBRACE)throw e}},_readWhitespace:function(){for(var e=this._tokenStream,t="";e.match(g.S);)t+=e.token().value;return t},_unexpectedToken:function(e){throw new o("Unexpected token '"+e.value+"' at line "+e.startLine+", col "+e.startCol+".",e.startLine,e.startCol)},_verifyEnd:function(){this._tokenStream.LA(1)!==g.EOF&&this._unexpectedToken(this._tokenStream.LT(1))},_validateProperty:function(e,t){v.validate(e,t)},parse:function(e){this._tokenStream=new m(e,g),this._stylesheet()},parseStyleSheet:function(e){return this.parse(e)},parseMediaQuery:function(e){this._tokenStream=new m(e,g);var t=this._media_query();return this._verifyEnd(),t},parsePropertyValue:function(e){this._tokenStream=new m(e,g),this._readWhitespace();var t=this._expr();return this._readWhitespace(),this._verifyEnd(),t},parseRule:function(e){this._tokenStream=new m(e,g),this._readWhitespace();var t=this._ruleset();return this._readWhitespace(),this._verifyEnd(),t},parseSelector:function(e){this._tokenStream=new m(e,g),this._readWhitespace();var t=this._selector();return this._readWhitespace(),this._verifyEnd(),t},parseStyleAttribute:function(e){e+="}",this._tokenStream=new m(e,g),this._readDeclarations()}};for(e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e]);return t}()},function(e,t,n){"use strict";var r=n(0),o=n.n(r),i=n(15),a=n.n(i),s=n(42),l=n.n(s),u=n(4),c=n.n(u),d=(n(1182),Object.assign||function(e){for(var t=1;t=a&&this.openSettings()}t&&!r&&(b()(this.controlRef.focus)||this.controlRef.focus())}},{key:"render",value:function(){var e,t=this,n=_()(["upload","background"],this.props.fieldType),i=this.isEnabledDynamicContent(this.props.value),a=Object(A.b)(this.props.value),s=this.getDynamicContentFieldOptions(this.props.type),u=!n||g()(this.props.value),c=o.a.cloneElement(this.props.children,{ref:function(e){return t.controlRef=e}});if(g()(s))return o.a.createElement(r.Fragment,null,this.props.children);var d="";if("ETBuilderControlTinyMCE"===c.type.displayName){c=o.a.cloneElement(c,{onModeSwitch:this.updateButtonPositionForTinyMCE});g()(this.state.classModifier)||(this.props.modalWidth>=538&&this.props.modalWidth<998?d=this.state.classModifier+"-medium":this.props.modalWidth>=998&&this.props.modalWidth<1202&&(d=this.state.classModifier+"-wide"))}return o.a.createElement("div",{className:l()((e={"et-fb-settings-option-dynamic":!0},Le(e,"et-fb-settings-option-dynamic--"+this.props.fieldType,!0),Le(e,"et-fb-settings-option-dynamic--"+this.state.classModifier,this.state.classModifier),Le(e,"et-fb-settings-option-dynamic--"+d,!!d),e))},i&&this.state.settingsOpen&&o.a.createElement(ie,{title:this.getDynamicContentFieldLabel(a.content),fields:this.getDynamicContentSettingsFields(a.content,this.props.type),values:a.settings,onChange:this.handleSettingsChange,onClose:this.closeSettings}),i&&o.a.createElement(Oe,{fieldType:this.props.fieldType,value:this.props.value,label:this.getDynamicContentFieldLabel(a.content),mode:this.props.previewMode,attributes:this.props.previewAttributes,settingsFields:this.props.showSettingsButton?this.getDynamicContentSettingsFields(a.content,this.props.type):{},showDisableButton:this.props.showDisableButton,dynamicEnabled:-1!==this.props.dynamicAttributes.indexOf(this.props.fieldName),onSettings:this.openSettings,onDisable:this.handleDisable}),!i&&o.a.createElement(r.Fragment,null,o.a.createElement("div",{className:"et-fb-settings-option-select-discrete"},o.a.createElement(ae.a,{ref:function(e){return t.selectRef=e},name:this.props.fieldName+"_dynamic_content",value:i?a.content:"",options:this.getDynamicContentFieldOptions(this.props.type),__onChange:this.handleDynamicContentChange,selectFirst:!1})),c,u&&o.a.createElement(Ee,{type:this.props.fieldType,icon:"dynamic",tooltip:ETBuilderBackend.i18n.dynamicContent.tooltips.enable,className:l()("et-fb-settings-option-dynamic__enable","et-fb-settings-option-dynamic__enable--"+this.props.fieldType),onClick:this.handleEnable})))}}]),t}();Pe.supportedFieldTypes=["text","tiny_mce","upload"],Pe.propTypes={children:a.a.element.isRequired,type:a.a.string.isRequired,fieldName:a.a.string.isRequired,fieldType:a.a.oneOf(Pe.supportedFieldTypes).isRequired,previewMode:a.a.oneOf(["image","background"]),previewAttributes:a.a.object,isContentField:a.a.bool,dynamicAttributes:a.a.arrayOf(a.a.string).isRequired,value:a.a.string.isRequired,showSettingsButton:a.a.bool,showDisableButton:a.a.bool,onChange:a.a.func,onReset:a.a.func,modalWidth:a.a.number},Pe.defaultProps={previewMode:"image",previewAttributes:{},isContentField:!1,showSettingsButton:!0,showDisableButton:!0,onChange:x.a,onReset:x.a};t.a=Pe},function(e,t,n){"use strict";var r=n(2),o=n.n(r),i=n(4),a=n.n(i),s=n(8),l=n.n(s),u=n(0),c=n.n(u),d=n(5),p=n.n(d),f=n(21),h=n.n(f),m=n(15),g=n.n(m),v=n(54),b=n.n(v),y=n(10),w=n.n(y),k=n(24),C=function(){function e(e,t){for(var n=0;n=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}(e,["pos","style","className"]);return c.a.createElement("div",_e({},o,{style:n,className:"spinner "+ye()(r)}),c.a.createElement("div",{className:"spinner-item",style:{transform:"translateX("+t+"px)"}}))},ke=n(42),Ce=n.n(ke),Se=(n(1133),function(){function e(e,t){for(var n=0;nthis.getX()?this.props.onRight(t-this.getX(),e):this.props.onLeft(this.getX()-t,e),this.props.onDragX(t-this.getX(),e),this.setX(t)),this.getY()!==n&&(n>this.getY()?this.props.onRight(n-this.getY(),e):this.props.onLeft(this.getY()-n,e),this.props.onDragY(n-this.getY(),e),this.setY(n))}},{key:"onMouseUp",value:function(e){jQuery(document).off("mousemove",this.onMouseMove),jQuery(document).off("mouseup",this.onMouseUp),jQuery("html").removeClass("et-pb-dragme-noselect"),this.props.onDragEnd(e),this.setX(),this.setY()}},{key:"render",value:function(){return c.a.createElement("div",{className:this.props.className,style:this.props.style,onMouseDown:this.onMouseDown},this.props.children)}},{key:"getX",value:function(){return this.x||0}},{key:"setX",value:function(e){return this.x=parseInt(e),this}},{key:"getY",value:function(){return this.y||0}},{key:"setY",value:function(e){return this.y=parseInt(e),this}}]),t}();Te.propTypes={onDragStart:p.a.func,onDragEnd:p.a.func,onDragX:p.a.func,onDragY:p.a.func,onTop:p.a.func,onBottom:p.a.func,onLeft:p.a.func,onRight:p.a.func,style:p.a.object,className:p.a.string},Te.defaultProps={onDragStart:Ce.a,onDragEnd:Ce.a,onDragX:Ce.a,onDragY:Ce.a,onTop:Ce.a,onBottom:Ce.a,onLeft:Ce.a,onRight:Ce.a};var Oe=Te,Me=(n(1131),n(567)),Le=function(){function e(e,t){for(var n=0;n1?1:this.getStep())}},{key:"onChange",value:function(e){this.props.readonly||(this.setUpdateSource(1),this.props.onChange(Object(ze.a)(this.getDefaultUnit(),e,this.sanitize)))}},{key:"onIncrease",value:function(){this.props.readonly||(this.setUpdateSource(2),this.props.onChange(Object(ze.a)(this.getDefaultUnit(),this.getValue(),this.sanitizeIncrease)))}},{key:"onDecrease",value:function(){this.props.readonly||(this.setUpdateSource(2),this.props.onChange(Object(ze.a)(this.getDefaultUnit(),this.getValue(),this.sanitizeDecrease)))}},{key:"handleSpinnerChange",value:function(e,t){var n=t.shiftKey;this.setUpdateSource(3);var r=this.normalize(Object(Me.d)(e,0))*(n?10:1);0!==r&&this.props.onChange(Object(ze.a)(this.getDefaultUnit(),this.getValue(),ne()(this.sanitize,Be()(r))))}},{key:"renderLabel",value:function(){return!oe()(this.props.label)&&c.a.createElement("span",{className:"et-fb-settings-option-input-label"},this.props.label)}},{key:"getValue",value:function(){return this.props.value||this.props.defaultValue||0}},{key:"getSpeed",value:function(){return Math.abs(this.props.speed)*(this.getStep()>=1?1:.1)}},{key:"getStep",value:function(){return this._step||this.props.step}},{key:"getDefaultUnit",value:function(){return Object(Ue.b)(this.props.defaultValue,this.props.defaultUnit)}},{key:"makeActive",value:function(){this.setState({active:!0})}},{key:"makeInactive",value:function(){this.setState({active:!1})}},{key:"sanitize",value:function(e){return Object(Me.e)(this.props.min,this.props.max,Object(Me.f)(Object(Me.b)(this.props.precision),e))}},{key:"setUpdateSource",value:function(e){this._updateSource=[e,je()(this._updateSource||[void 0])];var t=this.getStep(),n=this.props.step,r=Object(Me.b)(this.getNumericValue()),o=r>Object(Me.b)(n)?Object(Me.g)(r,n):this.isSameSource()?t:n;this._step=o}},{key:"isSameSource",value:function(){var e=this._updateSource||[void 0,void 0];return je()(e)===Ie()(e)}},{key:"render",value:function(){var e=this.state.active?"active":"";return c.a.createElement("div",{className:"et-fb-settings-option--numeric-spinner-control "+e},c.a.createElement(Ve.a,{onChange:this.onChange,onIncrease:this.onIncrease,onDecrease:this.onDecrease,value:this.props.value,step:this.getStep(),onFocus:this.makeActive,onBlur:this.makeInactive,placeholder:this.props.defaultValue,readonly:o()(this.props,"readonly",!1)}),c.a.createElement("div",{className:"numeric-spinner-control-label-wrapper"},!this.props.readonly&&c.a.createElement(De,{onChange:this.handleSpinnerChange}),this.renderLabel()))}}]),t}();Ge.propTypes={onChange:p.a.func.isRequired,step:p.a.number,precision:p.a.number,min:p.a.number,max:p.a.number,value:p.a.string,placeholder:p.a.string,defaultValue:p.a.string,defaultUnit:p.a.string,speed:p.a.number},Ge.defaultProps={step:1,min:-9999999999,max:9999999999,defaultValue:"",speed:.5,precision:.01};var qe=Ge,Ke=(n(1121),n(13)),Ye=function(e){return!oe()(e)&&0!==parseInt(e)&&"false"!==e},$e=function(e){return e&&!1!==e?"true":"false"},Qe=function(e,t){return e||t},Xe=P()({displayName:"ETBuilderControlInputMargins",mixins:[h.a],getInitialState:function(){var e=x.a.getPreviewMode().replace("zoom","desktop"),t=o()(this.props,"value.activeTab","desktop"),n="wireframe"===e?t:e;return{activeTab:n,value:this.getCurrentInputValue(n)}},getDefaultValues:function(){var e=x.a.getPreviewMode();return"zoom"!==e&&"wireframe"!==e||(e="desktop"),{desktop:["","","",""],tablet:["","","",""],phone:["","","",""],activeTab:e,isResponsive:!1}},componentWillMount:function(){var e=this;this._onTopChange=this._onInputChange(0).bind(this),this._onRightChange=this._onInputChange(1).bind(this),this._onBottomChange=this._onInputChange(2).bind(this),this._onLeftChange=this._onInputChange(3).bind(this),this.getTopBottomLink=ne()(Ye,ce()(4),function(t){return pe()(t,e.getDefaultValue(),Qe)},le()("|"),this.getStateValue),this.getLeftRightLink=ne()(Ye,ce()(5),function(t){return pe()(t,e.getDefaultValue(),Qe)},le()("|"),this.getStateValue)},componentDidMount:function(){x.a.addPreviewModeListener(this._onPreviewModeChange),this.saveValue=F()(this.updateOptionValue,0,{leading:!1})},componentWillUnmount:function(){x.a.removePreviewModeListener(this._onPreviewModeChange)},componentWillReceiveProps:function(e){var t=o()(e,"value.activeTab"),n=x.a.getPreviewMode().replace("zoom","desktop"),r="wireframe"===n?t:n,i=this.hasResponsiveValue()?r:"desktop",a=o()(e,"value",{}),s=V()(a)?a[i]:a;r===this.state.activeTab&&s===this.getStateValue()||this.setState({activeTab:r,value:s})},_onPreviewModeChange:function(){var e="zoom"!==x.a.getPreviewMode()&&this.getValue("isResponsive")?x.a.getPreviewMode():"desktop";l()(["desktop","tablet","phone"],e)&&this.setState({activeTab:e,value:this.getCurrentInputValue(e)})},getCSSProperty:function(){return o()({custom_padding:"padding",custom_margin:"margin"},this.props.type)},getValues:function(e){var t=this.getDefaultValues(),n=a()(e)?this.props:e,r=a()(n.value)||""===n.value?t:N()(n.value),o=["desktop","tablet","phone"];return W()(r)&&(r={desktop:r}),w()(r,function(e,n){if(l()(o,n)){var i=a()(e)||R()(e)?e:e.split("|");R()(i)&&2===q()(i)&&(i=[i[0],"",i[1],""]),r[n]=!a()(e)&&me.b.hasValue(e)?i:t[n]}else"activeTab"===n&&(r.activeTab=l()(o,e)?e:t.activeTab)}),r},getValue:function(e,t){var n=this.getValues(t);return a()(n)||a()(n[e])?"":n[e]},getStateValue:function(){return ae()(this.state.value)},getDefaultValue:function(e){var t=me.b.getPrevBreakpoint(e),n=o()(this.props,"default_"+e,"");return t?n?n.split("|"):this.getDefaultValue(t):o()(this.props,"default","").split("|")},getCascadedDefault:function(e){var t=me.b.getPrevBreakpoint(e);return t?me.b.get(this.getCascadedValue(t),this.getDefaultValue(e)):this.getDefaultValue(e)},getCascadedValue:function(e){for(var t=me.b.getBreakpoints(),n=J()(t,e),r=this.getValue(e);n>0;n--){var o=t[n-1];r=Q()(r,this.getValue(o),function(e,t){return me.b.hasValue(e)?e:t})}return r},getCurrentInputValue:function(e,t){var n=void 0,r="desktop";return a()(e)?(this.getActiveTab("tablet")&&this.getValue("isResponsive")&&(r="tablet"),this.getActiveTab("phone")&&this.getValue("isResponsive")&&(r="phone")):r=e,n=this.getValue(r,t),a()(n)||!R()(n)?"||||":n.join("|")},getActiveTab:function(e){var t="zoom"===x.a.getPreviewMode()?"desktop":o()(this,"state.activeTab");return this.hasResponsiveValue()?e===t:e===this.getValue("activeTab")},getPropsNameSuffix:function(){var e=this.state.activeTab;return!l()(["zoom","wireframe","desktop"],e)&&this.hasResponsiveValue()?"_"+e:""},getPropsNameLastEdited:function(){return this.props.name+"_last_edited"},getPropsValueLastEdited:function(e,t){return(e?"on":"off")+"|"+(t=e?t:"desktop")},hasMobileOptions:function(){return me.b.hasValue(this.props.mobile_options)},hasResponsiveValue:function(){return this.hasMobileOptions()&&V()(this.props.value)&&this.props.value.isResponsive},shouldDisplayResetButton:function(){if(this.props.readonly||this.props.disableReset)return!1;var e=this.getValue("activeTab"),t=this.getStateValue().split("|"),n=o()(this.getDefaultValues(),e,["","","",""]);return!H()(t,n)},toggleResponsive:function(e){e.preventDefault();var t=!this.getValue("isResponsive"),n=t?o()(this,"state.activeTab","desktop"):"desktop";t&&this.removePaddingMobile(),this.props._onChange(this.getPropsNameLastEdited(),this.getPropsValueLastEdited(t,n)),this.setState({activeTab:x.a.getPreviewMode(),value:this.getCurrentInputValue(n)})},reset:function(e){e.preventDefault();var t=this.getDefaultValues(),n=this.getValue("activeTab");this.getValues()[n]=t[n],this.props._onChange(this.props.name+this.getPropsNameSuffix(),t[n].join("|")),this.setState({value:t[n].join("|")})},changeTab:function(e){var t=x.a.getActiveModule(),n=this.getValue("isResponsive"),r=e.target.getAttribute("data-tab"),o=x.a.getPreviewMode();if("hover"===r)return ge.b.switchResponsiveMode("desktop"),ge.b.toggleModuleHover(!0),void ge.b.moduleSettingsChange(t,"hover_enabled",1);ge.b.toggleModuleHover(!1),ge.b.moduleSettingsChange(t,"hover_enabled",0),this.setState({activeTab:r,value:this.getCurrentInputValue(r)}),"wireframe"!==o&&ge.b.switchResponsiveMode(r),this.props._onChange(this.getPropsNameLastEdited(),this.getPropsValueLastEdited(n,r)),this.removePaddingMobile()},removePaddingMobile:function(){var e=o()(this,"props.name",!1),t=o()(this,"props.module.props.module.props.attrs.padding_mobile",!1),n=o()(this,"props.module.props.module.props.attrs.column_padding_mobile",!1);"custom_padding"===e&&me.b.hasValue(t)&&this.props._onChange("padding_mobile",""),l()(["padding_1","padding_2","padding_3","padding_4","padding_5","padding_6"],e)&&me.b.hasValue(n)&&this.props._onChange("column_padding_mobile","")},getInput:function(e,t,n,r){var i="et-fb-"+this.props.name,a="padding"===this.getCSSProperty()?0:void 0,s=n===r?"":n,l=o()({top:this._onTopChange,right:this._onRightChange,bottom:this._onBottomChange,left:this._onLeftChange},t);return c.a.createElement("div",{className:"et-fb-settings-option-input-wrap "+t},c.a.createElement(qe,{id:i+"-input-"+t,name:this.props.name+"-input-"+t,type:"text",className:"et-fb-settings-option-input et-fb-settings-option-input-margin et-fb-settings-option-input-margin--"+t,value:Y()(s),defaultValue:r,"data-tab":e,"data-order":"0",onChange:l,speed:4,min:a,label:ETBuilderBackend.i18n.controls.inputMargin[t],defaultUnit:"px",property:this.getCSSProperty(),readonly:o()(this.props,"readonly",!1)}))},inputsWrap:function(e){var t=this.getStateValue().split("|"),n=this.getCascadedDefault(e);return c.a.createElement("div",{className:"et-fb-settings-option-inputs-wrap"},this.getInput(e,"top",t[0],n[0]),c.a.createElement(ve.a,{active:this.getTopBottomLink(),onClick:this._topBottomLink}),this.getInput(e,"bottom",t[2],n[2]),this.getInput(e,"left",t[3],n[3]),c.a.createElement(ve.a,{active:this.getLeftRightLink(),onClick:this._leftRightLink}),this.getInput(e,"right",t[1],n[1]))},render:function(){var e=this.getActiveTab("desktop")?"active":"",t=this.getActiveTab("tablet")?"active":"",n=this.getActiveTab("phone")?"active":"",r=this.getValue("isResponsive"),i=ETBuilderBackend.i18n.controls.responsiveTabs,a="et-fb-settings-option-inner et-fb-settings-option-inner-responsive et-fb-settings-option-inner-input-margins",s=void 0,l=void 0,u=void 0,d=void 0;if(r&&(a+=" et-fb-settings-option-inner-responsive--active"),this.getValue("isResponsive")){var p=Ke.a.getFieldBaseName(o()(this,"props.name","")),f=x.a.getActiveModule(),h=Ke.a.isEnabled("props.attrs."+p,f),m=!0===x.a.getHoverMode()?"active":"",g=h?c.a.createElement("li",{className:m,"data-tab":"hover",onClick:this.changeTab},ETBuilderBackend.i18n.controls.tabs.hover):"",v=h?"et-fb-settings-option-responsive-tab-nav et-fb-settings-option-responsive-tab-nav-hover-active ":"et-fb-settings-option-responsive-tab-nav";"active"===m&&(e=""),s=c.a.createElement("ul",{className:v},c.a.createElement("li",{className:e,"data-tab":"desktop",onClick:this.changeTab},i.desktop),g,c.a.createElement("li",{className:t,"data-tab":"tablet",onClick:this.changeTab},i.tablet),c.a.createElement("li",{className:n,"data-tab":"phone",onClick:this.changeTab},i.phone))}!this.getActiveTab("desktop")&&this.hasResponsiveValue()||(l=this.inputsWrap("desktop")),this.getActiveTab("tablet")&&r&&(u=this.inputsWrap("tablet")),this.getActiveTab("phone")&&r&&(d=this.inputsWrap("phone")),this.shouldDisplayResetButton()&&c.a.createElement("button",{className:"et-fb-settings-option-button--reset",onClick:this.reset});this.hasMobileOptions()&&c.a.createElement("button",{className:"et-fb-settings-option-button--responsive",onClick:this.toggleResponsive});return c.a.createElement("div",{className:a},s,l,u,d)},_topBottomLink:function(){if(!this.props.readonly){var e=this.getLastVerticalUpdated(),t=this.getStateValue().split("|");t[4]=$e(!this.getTopBottomLink()),this.getTopBottomLink()||t[0]===t[2]||(oe()(e)?oe()(t[0])?t[0]=t[2]:t[2]=t[0]:"top"===e?t[2]=t[0]:t[0]=t[2]),this.updatePadding(t.join("|"))}},_leftRightLink:function(){if(!this.props.readonly){var e=this.getLastHorizontalUpdated(),t=this.getStateValue().split("|");t[5]=$e(!this.getLeftRightLink()),this.getLeftRightLink()||t[1]===t[3]||(oe()(e)?oe()(t[3])?t[3]=t[1]:t[1]=t[3]:"left"===e?t[1]=t[3]:t[3]=t[1]),this.updatePadding(t.join("|"))}},_onInputChange:ee()(function(e,t){if(!this.props.readonly){var n=this.getStateValue().split("|");switch(n[e]=t,e){case 0:n[2]=this.getTopBottomLink()?n[e]:n[2],this._lastVUpdated="top";break;case 1:n[3]=this.getLeftRightLink()?n[e]:n[3],this._lastHUpdated="right";break;case 2:n[0]=this.getTopBottomLink()?n[e]:n[0],this._lastVUpdated="bottom";break;case 3:n[1]=this.getLeftRightLink()?n[e]:n[1],this._lastHUpdated="left"}this.updatePadding(n.join("|"))}}),getLastVerticalUpdated:function(){return this._lastVUpdated},getLastHorizontalUpdated:function(){return this._lastHUpdated},updatePadding:function(e){this.removePaddingMobile(),this.setState({value:e}),this.saveValue.cancel(),this.saveValue()},updateOptionValue:function(){this.props._onChange(this.props.name+this.getPropsNameSuffix(),this.getStateValue())}});Xe.defaultProps={default:"|||||"};var Je=Xe,Ze=n(14),et=n.n(Ze),tt=(n(1119),function(){function e(e,t){for(var n=0;n0&&n.find("style#"+r).remove(),o='';else{if(n.find("style#et-fb-font-"+r).length>0)return;o=''}n.append(o)}else"font-weight"===t&&n.find("style#"+r).length>0&&n.find("style#"+r).remove()}},{key:"getUploadedFonts",value:function(){var e=ETBuilderBackend.customFonts;return St()(e)?[]:Dt()(e)}},{key:"getFontWeightOptions",value:function(){var e=ETBuilderBackend.googleFonts,t=ETBuilderBackend.customFonts,n=this.getValue("font"),r=o()(t,n,!1),i=Dt()(ETBuilderBackend.allFontWeights),s={},l=[];if(""===n)l=["300","400","600","700","800"];else{if(r||(r=o()(e,n,!1)),!r||a()(r.styles))return ETBuilderBackend.allFontWeights;l=r.styles.split(",")}var u=Mt()(At()(["400","700"],l),i);return w()(u,function(e){s[e]=ETBuilderBackend.allFontWeights[e]}),s}},{key:"getFontWeight",value:function(){var e=this.getValue("bold");return!0===e?"700":l()(Dt()(this.getFontWeightOptions()),e)?e:"400"}},{key:"updateFontWeight",value:function(e){this.udpdateOptionValue("bold",e)}},{key:"updateLineColor",value:function(e,t){this.udpdateOptionValue("line_color",t)}},{key:"updateLineStyle",value:function(e){this.udpdateOptionValue("line_style",e)}},{key:"udpdateOptionValue",value:function(e,t){var n=this.getValues();n[e]=t,w()([["uppercase","capitalize"],["underline","line_through"]],function(t){l()(t,e)&&w()(t,function(t){t!==e&&(n[t]=!1)})}),this.updateFontStyle(n)}},{key:"toggleButton",value:function(e){e.preventDefault();var t=jQuery(e.target).closest(".et-fb-select-fontstyle-button").attr("data-button"),n=!this.getValues()[t];this.udpdateOptionValue(t,n)}},{key:"fontStyleButtonClassNames",value:function(e){var t;return g()((Ft(t={"et-fb-select-fontstyle-button":!0},"et-fb-select-fontstyle-button--"+e,!0),Ft(t,"et-fb-select-fontstyle-option--"+this.props.name,!0),t))}},{key:"fieldClassNames",value:function(e,t){var n;return g()(he()({},(Ft(n={"et-fb-font-option-container":!0,"et-fb-font-option-container-with-label":!0},"et-fb-font-option-container--"+this.props.name,!0),Ft(n,"et-fb-font-option-container--sub",!0),Ft(n,"et-fb-font-option-container--sub-"+e,!0),n),t))}},{key:"_onMouseEnter",value:function(e){!this.props.rightClickOpened&&this.props.isSettingsModal&&ge.b.setHoveredSubElement(e)}},{key:"_onMouseLeave",value:function(){!this.props.rightClickOpened&&this.props.isSettingsModal&&ge.b.setHoveredSubElement(!1)}},{key:"_extraProps",value:function(){var e={readonly:this.props.readonly,disableReset:this.props.disableReset};return he()({},e)}},{key:"_isFilterActive",value:function(){return l()(["styles_modified","active_content"],this.props.filterSelected)}},{key:"_isRenderSubFieldLabel",value:function(e){return!!a()(this.props.subFieldLabel)||(W()(this.props.subFieldLabel)?e===this.props.subFieldLabel:R()(this.props.subFieldLabel)?l()(this.props.subFieldLabel,e):this.props.subFieldLabel)}},{key:"_isRenderSubField",value:function(e){return!!a()(this.props.subField)||(W()(this.props.subField)?e===this.props.subField:R()(this.props.subField)?l()(this.props.subField,e):this.props.subField)}},{key:"_renderSubFieldFontFamily",value:function(){var e=this;if(!this._isRenderSubField("font"))return!1;var t=this.getValue("font");if(this._isFilterActive()&&(!t||"Default"===t))return!1;var n=this.fieldClassNames("font");return c.a.createElement("div",{className:n,onMouseEnter:function(){return e._onMouseEnter("font")},onMouseLeave:function(){return e._onMouseLeave("font")}},this._isRenderSubFieldLabel("font")&&this.props.formLabel,this._isRenderSubFieldLabel("font")&&this.props.formDescription,c.a.createElement(mt.a,Nt({default:"Default",recentCategory:"font_family",value:t,name:this.props.name,options:ETBuilderBackend.googleFontsList,additionalOptions:{uploaded:this.state.uploadedFonts},searchPlaceholder:It.searchFonts,searchable:!0,displayRecent:!0,_hoverAction:this._previewFontOnHover,__onChange:this.updateFontFamily},this._extraProps())))}},{key:"_renderSubFieldFontWeight",value:function(){var e=this;if(!this._isRenderSubField("weight"))return!1;var t=this.getFontWeight();if(this._isFilterActive()&&(!t||l()(["400","normal"],t)))return!1;var n=a()(this.props.group_label)?It.fontWeight:this.props.group_label+" "+It.fontWeight,r=!!this._isRenderSubFieldLabel("weight")&&c.a.createElement("label",{className:"et-fb-form__label",htmlFor:this.props.name+"_weight"},c.a.createElement("span",{className:"et-fb-form__label-text"},Rt.decode(n))),o=this.fieldClassNames("weight");return c.a.createElement("div",{className:o,onMouseEnter:function(){return e._onMouseEnter("weight")},onMouseLeave:function(){return e._onMouseLeave("weight")}},r,c.a.createElement(mt.a,Nt({className:"et-fb-font-weight-option",name:this.props.name+"_weight",default:"normal",value:t,options:this.getFontWeightOptions(),__onChange:this.updateFontWeight},this._extraProps())))}},{key:"_renderSubFieldFontStyle",value:function(){var e=this;if(!this._isRenderSubField("style"))return!1;var t=[{slug:"italic",icon:"text-italic"},{slug:"uppercase",icon:"text-uppercase"},{slug:"capitalize",icon:"text-smallcaps"},{slug:"underline",icon:"text-underline"},{slug:"line_through",icon:"text-strikethrough"}].filter(function(t){return!e._isFilterActive()||e._isFilterActive()&&e.getValue(t.slug)});if(St()(t))return!1;var n=t.map(function(t){var n=e.getValue(t.slug)?lt.a.activeTabIcon:lt.a.optionTabIcon;return c.a.createElement("button",{key:t.slug,className:e.fontStyleButtonClassNames(t.slug),onClick:e.toggleButton,"data-button":t.slug},c.a.createElement(k.a,{icon:t.icon,color:n}))}),r=a()(this.props.group_label)?It.fontStyle:this.props.group_label+" "+It.fontStyle,o=!!this._isRenderSubFieldLabel("style")&&c.a.createElement("label",{className:"et-fb-form__label",htmlFor:this.props.name+"_style"},c.a.createElement("span",{className:"et-fb-form__label-text"},Rt.decode(r))),i=this.fieldClassNames("style");return c.a.createElement("div",{className:i,onMouseEnter:function(){return e._onMouseEnter("style")},onMouseLeave:function(){return e._onMouseLeave("style")}},o,n)}},{key:"_renderSubFieldFontLineColor",value:function(){var e=this;if(!this._isRenderSubField("line_color"))return!1;var t=this.getValue("underline"),n=this.getValue("line_through");if(!t&&!n)return!1;var r=this.getValue("line_color");if(this._isFilterActive()&&!r)return!1;var o=t?It.underline:It.strikethrough,i=a()(this.props.group_label)?o+" "+It.color:this.props.group_label+" "+o+" "+It.color,s=!!this._isRenderSubFieldLabel("line_color")&&c.a.createElement("label",{className:"et-fb-form__label",htmlFor:this.props.name+"_line_color"},c.a.createElement("span",{className:"et-fb-form__label-text"},Rt.decode(i))),l=this.fieldClassNames("line_color",{"et-fb-option--color-alpha":!0});return c.a.createElement("div",{className:l,onMouseEnter:function(){return e._onMouseEnter("line_color")},onMouseLeave:function(){return e._onMouseLeave("line_color")}},s,c.a.createElement(L.a,Nt({name:this.props.name+"_line_color",type:"color-alpha",value:r,animate:!0,_onChange:this.updateLineColor},this._extraProps())))}},{key:"_renderSubFieldFontLineStyle",value:function(){var e=this;if(!this._isRenderSubField("line_style"))return!1;var t=this.getValue("underline"),n=this.getValue("line_through");if(!t&&!n)return!1;var r=St()(this.getValue("line_style"))?"solid":this.getValue("line_style");if(this._isFilterActive()&&"solid"===r)return!1;var o=t?It.underline:It.strikethrough,i=a()(this.props.group_label)?o+" "+It.style:this.props.group_label+" "+o+" "+It.style,s=!!this._isRenderSubFieldLabel("line_style")&&c.a.createElement("label",{className:"et-fb-form__label",htmlFor:this.props.name+"_line_style"},c.a.createElement("span",{className:"et-fb-form__label-text"},Rt.decode(i))),l=this.fieldClassNames("line_style");return c.a.createElement("div",{className:l,onMouseEnter:function(){return e._onMouseEnter("line_style")},onMouseLeave:function(){return e._onMouseLeave("line_style")}},s,c.a.createElement(mt.a,Nt({name:this.props.name+"_line_style",className:"et-fb-font-line-style-option",default:"solid",value:r,options:["solid","double","dotted","dashed","wavy"],__onChange:this.updateLineStyle},this._extraProps())))}},{key:"render",value:function(){var e=g()(Ft({"et-fb-settings-option-inner":!0,"et-fb-settings-option-inner--select-fontstyle":!0},"et-fb-settings-option-inner--"+this.props.name,!0));return c.a.createElement("div",{className:e},this._renderSubFieldFontFamily(),this._renderSubFieldFontWeight(),this._renderSubFieldFontStyle(),this._renderSubFieldFontLineColor(),this._renderSubFieldFontLineStyle())}}]),t}();Ht.propTypes=Bt;var Ut=Ht,Vt=(n(1073),function(){function e(e,t){for(var n=0;n/g,function(e){return e.replace(/[\r\n]+/g,"")})),-1===(e=e.replace(/<[^<>]+>/g,function(e){return e.replace(/[\r\n]+/g," ")})).indexOf("]*>[\s\S]+?<\/\1>/g,function(e){return e.replace(/(\r\n|\n)/g,"")})),-1!==e.indexOf("[caption")&&(r=!0,e=e.replace(/\[caption[\s\S]+?\[\/caption\]/g,function(e){return(e=(e=e.replace(/
]*)>/g,"")).replace(/<[a-zA-Z0-9]+( [^<>]+)?>/g,function(e){return e.replace(/[\r\n\t]+/," ")})).replace(/\s*\n\s*/g,"")})),e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e+="\n\n").replace(/
\s*
/gi,"\n\n")).replace(new RegExp("(<(?:"+t+")(?: [^>]*)?>)","gi"),"\n$1")).replace(new RegExp("((?:"+t+")>)","gi"),"$1\n\n")).replace(/
]*)?>/gi,"
\n\n")).replace(/\s*")).replace(/\r\n|\r/g,"\n")).replace(/\n\s*\n+/g,"\n\n")).replace(/([\s\S]+?)\n\n/g,"$1
\n")).replace(/\s*?<\/p>/gi,"")).replace(new RegExp("
\\s*(?(?:"+t+")(?: [^>]*)?>)\\s*
","gi"),"$1")).replace(/(
/gi,"$1")).replace(/\s*
]*)>/gi,"")).replace(/<\/blockquote>\s*<\/p>/gi,"
")).replace(new RegExp("\\s*(?(?:"+t+")(?: [^>]*)?>)","gi"),"$1")).replace(new RegExp("(?(?:"+t+")(?: [^>]*)?>)\\s*
","gi"),"$1")).replace(/\s*\n/gi,"
\n")).replace(new RegExp("(?(?:"+t+")[^>]*>)\\s*
","gi"),"$1")).replace(/
(\s*<\/?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)/gi,"$1")).replace(/(?:|
)*\s*\[caption([^\[]+)\[\/caption\]\s*(?:<\/p>|
)*/gi,"[caption$1[/caption]")).replace(/(<(?:div|th|td|form|fieldset|dd)[^>]*>)(.*?)<\/p>/g,function(e,t,n){return n.match(/
]*)?>/)?e:t+"
"+n+"
"}),n&&(e=e.replace(//g,"\n")),r&&(e=e.replace(/]*)>/g,"
")),e},removep:function(e){var t="blockquote|ul|ol|li|table|thead|tbody|tfoot|tr|th|td|h[1-6]|fieldset",n=t+"|div|p",r=t+"|pre",o=!1,i=!1;return e?(-1===e.indexOf("]*>[\s\S]+?<\/\1>/g,function(e){return(e=(e=e.replace(/
(\r\n|\n)?/g,"")).replace(/<\/?p( [^>]*)?>(\r\n|\n)?/g,"")).replace(/\r?\n/g,"")})),-1!==e.indexOf("[caption")&&(i=!0,e=e.replace(/\[caption[\s\S]+?\[\/caption\]/g,function(e){return e.replace(/
]*)>/g,"").replace(/[\r\n\t]+/,"")})),-1!==(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(new RegExp("\\s*("+n+")>\\s*","g"),"$1>\n")).replace(new RegExp("\\s*<((?:"+n+")(?: [^>]*)?)>","g"),"\n<$1>")).replace(/(]+>.*?)<\/p>/g,"$1
")).replace(/]*)?>\s*
/gi,"
\n\n")).replace(/\s*
/gi,"")).replace(/\s*<\/p>\s*/gi,"\n\n")).replace(/\n[\s\u00a0]+\n/g,"\n\n")).replace(/\s*
\s*/gi,"\n")).replace(/\s*
\s*/g,"
\n")).replace(/\s*\[caption([^\[]+)\[\/caption\]\s*/gi,"\n\n[caption$1[/caption]\n\n")).replace(/caption\]\n\n+\[caption/g,"caption]\n\n[caption")).replace(new RegExp("\\s*<((?:"+r+")(?: [^>]*)?)\\s*>","g"),"\n<$1>")).replace(new RegExp("\\s*("+r+")>\\s*","g"),"$1>\n")).replace(/
]*)>/g,"\t")).indexOf("