export class Segment{constructor(begin,end,data){if(begin>end){throw new Error('Invalid segment');} this.begin=begin;this.end=end;this.data=data;} intersects(that){return this.begina.begin-b.begin);let endIndex=startIndex;let merged=null;if(startIndex>0){const precedingSegment=this._segments[startIndex-1];merged=this._tryMerge(precedingSegment,newSegment);if(merged){--startIndex;newSegment=merged;}else if(this._segments[startIndex-1].end>=newSegment.begin){if(newSegment.endthis.append(segment));} segments(){return this._segments;} _tryMerge(first,second){const merged=this._mergeCallback&&this._mergeCallback(first,second);if(!merged){return null;} merged.begin=first.begin;merged.end=Math.max(first.end,second.end);return merged;}} self.Common=self.Common||{};Common=Common||{};Common.Segment=Segment;Common.SegmentedRange=SegmentedRange;