(function(mod){if(typeof exports=="object"&&typeof module=="object") mod(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd) define(["../../lib/codemirror"],mod);else mod(CodeMirror);})(function(CodeMirror){"use strict";function doFold(cm,pos,options,force){if(options&&options.call){var finder=options;options=null;}else{var finder=getOption(cm,options,"rangeFinder");} if(typeof pos=="number")pos=CodeMirror.Pos(pos,0);var minSize=getOption(cm,options,"minFoldSize");function getRange(allowFolded){var range=finder(cm,pos);if(!range||range.to.line-range.from.linecm.firstLine()){pos=CodeMirror.Pos(pos.line-1,0);range=getRange(false);} if(!range||range.cleared||force==="unfold")return;var myWidget=makeWidget(cm,options);CodeMirror.on(myWidget,"mousedown",function(e){myRange.clear();CodeMirror.e_preventDefault(e);});var myRange=cm.markText(range.from,range.to,{replacedWith:myWidget,clearOnEnter:getOption(cm,options,"clearOnEnter"),__isFold:true});myRange.on("clear",function(from,to){CodeMirror.signal(cm,"unfold",cm,from,to);});CodeMirror.signal(cm,"fold",cm,range.from,range.to);} function makeWidget(cm,options){var widget=getOption(cm,options,"widget");if(typeof widget=="string"){var text=document.createTextNode(widget);widget=document.createElement("span");widget.appendChild(text);widget.className="CodeMirror-foldmarker";}else if(widget){widget=widget.cloneNode(true)} return widget;} CodeMirror.newFoldFunction=function(rangeFinder,widget){return function(cm,pos){doFold(cm,pos,{rangeFinder:rangeFinder,widget:widget});};};CodeMirror.defineExtension("foldCode",function(pos,options,force){doFold(this,pos,options,force);});CodeMirror.defineExtension("isFolded",function(pos){var marks=this.findMarksAt(pos);for(var i=0;i