/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../../../chunks/_rollupPluginBabelHelpers","../../../../../core/maybe"],(function(t,e,n){"use strict";let a=function(){function t(e){if(!Array.isArray(e))return void(this.data=e);this.data=e[0];let n=this;for(let a=1;a<e.length;a++)n.next=new t([e[a]]),n=n.next}var n=t.prototype;return n.values=function*(){let t=this;for(;t;)yield t.data,t=t.next},n.forEach=function(t){let e=this;for(;e;)t(e.data),e=e.next},n.find=function(t){var e;return t(this.data)?this:null==(e=this.next)?void 0:e.find(t)},n.max=function(t,e=this){const n=t(this.data)>t(e.data)?this:e;return this.next?this.next.max(t,n):n},n.remove=function(t,e=null){return this===t?e?(e.next=this.next,e):this.next:this.next.remove(t,this)},e._createClass(t,[{key:"last",get:function(){return this.next?this.next.last:this}}]),t}(),i=function(){function t(t){this._head=null,n.isNone(t)||(this._head=new a(t))}var i=t.prototype;return i.maxAvailableSpace=function(){if(n.isNone(this._head))return 0;const t=this._head.max((t=>t.end-t.start));return t.data.end-t.data.start},i.firstFit=function(t){if(n.isNone(this._head))return null;let e=null,a=this._head;for(;a;){const n=a.data.end-a.data.start;if(n===t)return e?e.next=a.next:this._head=a.next,a.data.start;if(n>t){const e=a.data.start;return a.data.start+=t,e}e=a,a=a.next}return null},i.free=function(t,e){const i=t+e;if(n.isNone(this._head)){const e=new a({start:t,end:i});return void(this._head=e)}if(i<=this._head.data.start){if(i===this._head.data.start)return void(this._head.data.start-=e);const n=new a({start:t,end:i});return n.next=this._head,void(this._head=n)}let r=this._head,s=r.next;for(;s;){if(s.data.start>=i){if(r.data.end===t){if(r.data.end+=e,r.data.end===s.data.start){const t=s.data.end-s.data.start;return r.data.end+=t,void(r.next=s.next)}return}if(s.data.start===i)return void(s.data.start-=e);const n=new a({start:t,end:i});return n.next=r.next,void(r.next=n)}r=s,s=s.next}if(t===r.data.end)return void(r.data.end+=e);const d=new a({start:t,end:i});r.next=d},e._createClass(t,[{key:"head",get:function(){return this._head}}]),t}();t.FreeList=i,t.List=a,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
