var s=200,o=function(){};o.prototype.append=function(e){return e.length?(e=o.from(e),!this.length&&e||e.length<s&&this.leafAppend(e)||this.length<s&&e.leafPrepend(this)||this.appendInner(e)):this};o.prototype.prepend=function(e){return e.length?o.from(e).append(this):this};o.prototype.appendInner=function(e){return new a(this,e)};o.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?o.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};o.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};o.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};o.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var n=[];return this.forEach(function(i,f){return n.push(e(i,f))},t,r),n};o.from=function(e){return e instanceof o?e:e&&e.length?new l(e):o.empty};var l=(function(e){function t(n){e.call(this),this.values=n}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(n,i){return n==0&&i==this.length?this:new t(this.values.slice(n,i))},t.prototype.getInner=function(n){return this.values[n]},t.prototype.forEachInner=function(n,i,f,h){for(var p=i;p<f;p++)if(n(this.values[p],h+p)===!1)return!1},t.prototype.forEachInvertedInner=function(n,i,f,h){for(var p=i-1;p>=f;p--)if(n(this.values[p],h+p)===!1)return!1},t.prototype.leafAppend=function(n){if(this.length+n.length<=s)return new t(this.values.concat(n.flatten()))},t.prototype.leafPrepend=function(n){if(this.length+n.length<=s)return new t(n.flatten().concat(this.values))},r.length.get=function(){return this.values.length},r.depth.get=function(){return 0},Object.defineProperties(t.prototype,r),t})(o);o.empty=new l([]);var a=(function(e){function t(r,n){e.call(this),this.left=r,this.right=n,this.length=r.length+n.length,this.depth=Math.max(r.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},t.prototype.forEachInner=function(r,n,i,f){var h=this.left.length;if(n<h&&this.left.forEachInner(r,n,Math.min(i,h),f)===!1||i>h&&this.right.forEachInner(r,Math.max(n-h,0),Math.min(this.length,i)-h,f+h)===!1)return!1},t.prototype.forEachInvertedInner=function(r,n,i,f){var h=this.left.length;if(n>h&&this.right.forEachInvertedInner(r,n-h,Math.max(i,h)-h,f+h)===!1||i<h&&this.left.forEachInvertedInner(r,Math.min(n,h),i,f)===!1)return!1},t.prototype.sliceInner=function(r,n){if(r==0&&n==this.length)return this;var i=this.left.length;return n<=i?this.left.slice(r,n):r>=i?this.right.slice(r-i,n-i):this.left.slice(r,i).append(this.right.slice(0,n-i))},t.prototype.leafAppend=function(r){var n=this.right.leafAppend(r);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(r){var n=this.left.leafPrepend(r);if(n)return new t(n,this.right)},t.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new t(this.left,new t(this.right,r)):new t(this,r)},t})(o);export{o as p};
