define(function(a,b,c){"use strict";var d=function(a,b){return a.row-b.row||a.column-b.column},e=function(a,b,c,d){this.start={row:a,column:b},this.end={row:c,column:d}};(function(){this.isEqual=function(a){return this.start.row===a.start.row&&this.end.row===a.end.row&&this.start.column===a.start.column&&this.end.column===a.end.column},this.toString=function(){return"Range: ["+this.start.row+"/"+this.start.column+"] -> ["+this.end.row+"/"+this.end.column+"]"},this.contains=function(a,b){return 0==this.compare(a,b)},this.compareRange=function(a){var b,c=a.end,d=a.start;return b=this.compare(c.row,c.column),1==b?(b=this.compare(d.row,d.column),1==b?2:0==b?1:0):b==-1?-2:(b=this.compare(d.row,d.column),b==-1?-1:1==b?42:0)},this.comparePoint=function(a){return this.compare(a.row,a.column)},this.containsRange=function(a){return 0==this.comparePoint(a.start)&&0==this.comparePoint(a.end)},this.intersects=function(a){var b=this.compareRange(a);return b==-1||0==b||1==b},this.isEnd=function(a,b){return this.end.row==a&&this.end.column==b},this.isStart=function(a,b){return this.start.row==a&&this.start.column==b},this.setStart=function(a,b){"object"==typeof a?(this.start.column=a.column,this.start.row=a.row):(this.start.row=a,this.start.column=b)},this.setEnd=function(a,b){"object"==typeof a?(this.end.column=a.column,this.end.row=a.row):(this.end.row=a,this.end.column=b)},this.inside=function(a,b){return 0==this.compare(a,b)&&(!this.isEnd(a,b)&&!this.isStart(a,b))},this.insideStart=function(a,b){return 0==this.compare(a,b)&&!this.isEnd(a,b)},this.insideEnd=function(a,b){return 0==this.compare(a,b)&&!this.isStart(a,b)},this.compare=function(a,b){return this.isMultiLine()||a!==this.start.row?a<this.start.row?-1:a>this.end.row?1:this.start.row===a?b>=this.start.column?0:-1:this.end.row===a?b<=this.end.column?0:1:0:b<this.start.column?-1:b>this.end.column?1:0},this.compareStart=function(a,b){return this.start.row==a&&this.start.column==b?-1:this.compare(a,b)},this.compareEnd=function(a,b){return this.end.row==a&&this.end.column==b?1:this.compare(a,b)},this.compareInside=function(a,b){return this.end.row==a&&this.end.column==b?1:this.start.row==a&&this.start.column==b?-1:this.compare(a,b)},this.clipRows=function(a,b){if(this.end.row>b)var c={row:b+1,column:0};else if(this.end.row<a)var c={row:a,column:0};if(this.start.row>b)var d={row:b+1,column:0};else if(this.start.row<a)var d={row:a,column:0};return e.fromPoints(d||this.start,c||this.end)},this.extend=function(a,b){var c=this.compare(a,b);if(0==c)return this;if(c==-1)var d={row:a,column:b};else var f={row:a,column:b};return e.fromPoints(d||this.start,f||this.end)},this.isEmpty=function(){return this.start.row===this.end.row&&this.start.column===this.end.column},this.isMultiLine=function(){return this.start.row!==this.end.row},this.clone=function(){return e.fromPoints(this.start,this.end)},this.collapseRows=function(){return 0==this.end.column?new e(this.start.row,0,Math.max(this.start.row,this.end.row-1),0):new e(this.start.row,0,this.end.row,0)},this.toScreenRange=function(a){var b=a.documentToScreenPosition(this.start),c=a.documentToScreenPosition(this.end);return new e(b.row,b.column,c.row,c.column)},this.moveBy=function(a,b){this.start.row+=a,this.start.column+=b,this.end.row+=a,this.end.column+=b}}).call(e.prototype),e.fromPoints=function(a,b){return new e(a.row,a.column,b.row,b.column)},e.comparePoints=d,e.comparePoints=function(a,b){return a.row-b.row||a.column-b.column},b.Range=e});