import{ManagedFloat64Array,setMemoryManager,useFinalizationRegistry}from"../memory.js";export const BYTES_PER_FLOAT64=8;const memory=new WebAssembly.Memory({initial:0});const freeList={};let view=new Float64Array(memory.buffer);let next=0;export const memoryManager={get buffer(){return memory.buffer},get view(){return view},create:function(size){if(freeList[size]){const offset=freeList[size]-1;freeList[size]=view[offset];return offset*BYTES_PER_FLOAT64}if(next+size>view.length){memory.grow(1);view=new Float64Array(memory.buffer)}const offset=next;next+=size;return offset*BYTES_PER_FLOAT64},free:function(byteOffset,size){const offset=Math.ceil(byteOffset/BYTES_PER_FLOAT64);if(offset+size>view.length){return}view[offset]=freeList[size]||0;freeList[size]=offset+1}};setMemoryManager(memoryManager);export{ManagedFloat64Array,setMemoryManager,useFinalizationRegistry}; //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJNYW5hZ2VkRmxvYXQ2NEFycmF5Iiwic2V0TWVtb3J5TWFuYWdlciIsInVzZUZpbmFsaXphdGlvblJlZ2lzdHJ5IiwiQllURVNfUEVSX0ZMT0FUNjQiLCJtZW1vcnkiLCJXZWJBc3NlbWJseSIsIk1lbW9yeSIsImluaXRpYWwiLCJmcmVlTGlzdCIsInZpZXciLCJGbG9hdDY0QXJyYXkiLCJidWZmZXIiLCJuZXh0IiwibWVtb3J5TWFuYWdlciIsImNyZWF0ZSIsInNpemUiLCJvZmZzZXQiLCJsZW5ndGgiLCJncm93IiwiZnJlZSIsImJ5dGVPZmZzZXQiLCJNYXRoIiwiY2VpbCJdLCJzb3VyY2VzIjpbIi4uLy4uL2pzL2pzL21lbW9yeS50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBNYW5hZ2VkRmxvYXQ2NEFycmF5LCBNZW1vcnlNYW5hZ2VyLCBzZXRNZW1vcnlNYW5hZ2VyLCB1c2VGaW5hbGl6YXRpb25SZWdpc3RyeSB9IGZyb20gJy4uL21lbW9yeS50cyc7XG5cbmV4cG9yd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