(function(){"use strict";function t(e){this.options=e,this.from=this.to=0}function n(e){return e===!0&&(e={}),e.gutter==null&&(e.gutter="CodeMirror-foldgutter"),e.indicatorOpen==null&&(e.indicatorOpen="CodeMirror-foldgutter-open"),e.indicatorFolded==null&&(e.indicatorFolded="CodeMirror-foldgutter-folded"),e}function r(t,n){var r=t.findMarksAt(e(n));for(var i=0;i<r.length;++i)if(r[i].__isFold&&r[i].find().from.line==n)return!0}function i(e){if(typeof e=="string"){var t=document.createElement("div");return t.className=e,t}return e.cloneNode(!0)}function s(t,n,s){var o=t.state.foldGutter.options,u=n;t.eachLine(n,s,function(n){var s=null;if(r(t,u))s=i(o.indicatorFolded);else{var a=e(u,0),f=o.rangeFinder||t.getHelper(a,"fold"),l=f&&f(t,a);l&&l.from.line+1<l.to.line&&(s=i(o.indicatorOpen))}t.setGutterMarker(n,o.gutter,s),++u})}function o(e){var t=e.getViewport(),n=e.state.foldGutter;if(!n)return;e.operation(function(){s(e,t.from,t.to)}),n.from=t.from,n.to=t.to}function u(t,n,r){var i=t.state.foldGutter.options;if(r!=i.gutter)return;t.foldCode(e(n,0),i.rangeFinder)}function a(e){var t=e.state.foldGutter;t.from=t.to=0,clearTimeout(t.changeUpdate),t.changeUpdate=setTimeout(function(){o(e)},600)}function f(e){var t=e.state.foldGutter;clearTimeout(t.changeUpdate),t.changeUpdate=setTimeout(function(){var n=e.getViewport();t.from==t.to||n.from-t.to>20||t.from-n.to>20?o(e):e.operation(function(){n.from<t.from&&(s(e,n.from,t.from),t.from=n.from),n.to>t.to&&(s(e,t.to,n.to),t.to=n.to)})},400)}function l(e,t){var n=e.state.foldGutter,r=t.line;r>=n.from&&r<n.to&&s(e,r,r+1)}CodeMirror.defineOption("foldGutter",!1,function(e,r,i){i&&i!=CodeMirror.Init&&(e.clearGutter(e.state.foldGutter.options.gutter),e.state.foldGutter=null,e.off("gutterClick",u),e.off("change",a),e.off("viewportChange",f),e.off("fold",l),e.off("unfold",l)),r&&(e.state.foldGutter=new t(n(r)),o(e),e.on("gutterClick",u),e.on("change",a),e.on("viewportChange",f),e.on("fold",l),e.on("unfold",l))});var e=CodeMirror.Pos})();