"use strict";const o=require("../../../../../../_virtual/OpIterator.js");require("./Op.js");const f=require("../../../../../../_virtual/Op.js");Object.defineProperty(o.__exports,"__esModule",{value:!0});const n=f.__exports;class u{constructor(e){this.ops=e,this.index=0,this.offset=0}hasNext(){return this.peekLength()<1/0}next(e){e||(e=1/0);const t=this.ops[this.index];if(t){const i=this.offset,r=n.default.length(t);if(e>=r-i?(e=r-i,this.index+=1,this.offset=0):this.offset+=e,typeof t.delete=="number")return{delete:e};{const s={};return t.attributes&&(s.attributes=t.attributes),typeof t.retain=="number"?s.retain=e:typeof t.retain=="object"&&t.retain!==null?s.retain=t.retain:typeof t.insert=="string"?s.insert=t.insert.substr(i,e):s.insert=t.insert,s}}else return{retain:1/0}}peek(){return this.ops[this.index]}peekLength(){return this.ops[this.index]?n.default.length(this.ops[this.index])-this.offset:1/0}peekType(){const e=this.ops[this.index];return e?typeof e.delete=="number"?"delete":typeof e.retain=="number"||typeof e.retain=="object"&&e.retain!==null?"retain":"insert":"retain"}rest(){if(this.hasNext()){if(this.offset===0)return this.ops.slice(this.index);{const e=this.offset,t=this.index,i=this.next(),r=this.ops.slice(this.index);return this.offset=e,this.index=t,[i].concat(r)}}else return[]}}o.__exports.default=u;
