var t=require("msgpackr"),i=require("@bokuweb/zstd-wasm"),e=0;function r(t){return"__private_"+e+++"_"+t}function n(t,i){if(!Object.prototype.hasOwnProperty.call(t,i))throw new TypeError("attempted to use private field on non-instance");return t}var o={doc:0,heading1:1,heading2:2,heading3:3,heading4:4,heading5:5,heading6:6,text:7,paragraph:8,image:9,taskList:10,taskItem:11,table:12,tableRow:13,tableCell:14,codeBlock:15,bulletList:16,orderedList:17,hardBreak:18,horizontalRule:19,blockQuote:20,emoji:21,hashTag:22,mention:23,listItem:24},a={bold:0,italic:1,code:2,highlight:3,link:4,strike:5,subscript:6,superscript:7,textstyle:8,underline:9},s={optimize:!0,zstd:!0},h=new t.Packr({});function u(t){var i=Array.isArray(t)?[]:{};for(var e in t){var r=t[e];i[e]=r&&"object"==typeof r?u(r):r}return i}var d=r("options"),c=r("optimizeNode"),f=function(){function t(t){var e=this;Object.defineProperty(this,c,{value:l}),this.zstdFinished=void 0,Object.defineProperty(this,d,{writable:!0,value:void 0}),n(this,d)[d]=Object.assign({},s,t),n(this,d)[d].zstd?(this.zstdFinished=i.init(),this.zstdFinished.then(function(){e.zstdFinished=!0})):this.zstdFinished=!0}return t.prototype.Compress=function(t){try{var e=this,r=function(){var r=h.pack(n(e,d)[d].optimize?n(e,c)[c](t):t);return n(e,d)[d].zstd?i.compress(r):r};n(e,d)[d].deepCopy&&(t=u(t));var o=function(){if(n(e,d)[d].zstd&&!0!==e.zstdFinished)return Promise.resolve(e.zstdFinished).then(function(){})}();return Promise.resolve(o&&o.then?o.then(r):r())}catch(t){return Promise.reject(t)}},t}();function l(t){var i,e={a:0,d:t.marks,e:t.attrs,b:t.text};if("heading"===t.type&&null!=(i=t.attrs)&&i.level)e.a=o["heading"+t.attrs.level],e.e.level=void 0;else{if(void 0===o[t.type])throw new Error("No type enum for element with type "+t.type+". Please add this the custom element type dictionary, or file an issue if you think "+t.type+" should be included in the default dictionary");e.a=o[t.type]}for(var r in t.marks){if(void 0===a[t.marks[r].type])throw new Error("No type enum for mark with type "+t.marks[r].type+". Please add this the custom mark type dictionary, or file an issue if you think "+t.marks[r].type+" should be included in the default dictionary");e.d[r].type=a[t.marks[r].type]}if(t.content)for(var s in e.c=[],t.content)e.c[s]=n(this,c)[c](t.content[s]);return e}var v=new t.Packr({}),m=r("options"),p=r("optimizeNode"),y=function(){function t(t){var e=this;for(var r in Object.defineProperty(this,p,{value:b}),this.zstdFinished=void 0,Object.defineProperty(this,m,{writable:!0,value:void 0}),this.typeNumbers=void 0,this.markNumbers=void 0,n(this,m)[m]=Object.assign({},s,t),this.typeNumbers=[],this.markNumbers=[],o)this.typeNumbers[o[r]]=r;for(var h in a)this.markNumbers[a[h]]=h;n(this,m)[m].zstd?(this.zstdFinished=i.init(),this.zstdFinished.then(function(){e.zstdFinished=!0})):this.zstdFinished=!0}return t.prototype.Decompress=function(t){try{var e=this,r=function(){var r=n(e,m)[m].zstd?v.unpack(new Uint8Array(i.decompress(t))):v.unpack(t);return n(e,m)[m].optimize?n(e,p)[p](r):r},o=function(){if(n(e,m)[m].zstd&&!0!==e.zstdFinished)return Promise.resolve(e.zstdFinished).then(function(){})}();return Promise.resolve(o&&o.then?o.then(r):r())}catch(t){return Promise.reject(t)}},t}();function b(t){var i={type:""};if(t.d&&(i.marks=t.d),t.e&&(i.attrs=t.e),t.b&&(i.text=t.b),void 0===this.typeNumbers[t.a])throw new Error("No type enum for element with type "+t.a+". Please add this the custom element type dictionary, or file an issue if you think "+t.a+" should be included in the default dictionary");if(i.type=this.typeNumbers[t.a],i.type.startsWith("heading")&&(i.attrs.level=parseInt(i.type.split("g").pop()),i.type="heading"),t.c)for(var e in i.content=t.c,t.c)i.content[e]=n(this,p)[p](t.c[e]);for(var r in t.d){if(void 0===this.markNumbers[t.d[r].type])throw new Error("No type enum for mark with type "+t.d[r].type+". Please add this the custom mark type dictionary, or file an issue if you think "+t.d[r].type+" should be included in the default dictionary");i.marks[r].type=this.markNumbers[t.d[r].type]}return i}exports.Compress=f,exports.Decompress=y; //# sourceMappingURL=index.cjs.map