var StructuredJSON=function(e){"use strict";const r="object"==typeof self?self:globalThis,t=(e,t)=>{switch(e){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+e)}return new r[e](t)},s=e=>((e,r)=>{const s=(r,t)=>(e.set(t,r),r),n=c=>{if(e.has(c))return e.get(c);const[a,o]=r[c];switch(a){case 0:case-1:return s(o,c);case 1:{const e=s([],c);for(const r of o)e.push(n(r));return e}case 2:{const e=s({},c);for(const[r,t]of o)e[n(r)]=n(t);return e}case 3:return s(new Date(o),c);case 4:{const{source:e,flags:r}=o;return s(new RegExp(e,r),c)}case 5:{const e=s(new Map,c);for(const[r,t]of o)e.set(n(r),n(t));return e}case 6:{const e=s(new Set,c);for(const r of o)e.add(n(r));return e}case 7:{const{name:e,message:r}=o;return s(t(e,r),c)}case 8:return s(BigInt(o),c);case"BigInt":return s(Object(BigInt(o)),c);case"ArrayBuffer":return s(new Uint8Array(o).buffer,o);case"DataView":{const{buffer:e}=new Uint8Array(o);return s(new DataView(e),o)}}return s(t(a,o),c)};return n})(new Map,e)(0),n="",{toString:c}={},{keys:a}=Object,o=e=>{const r=typeof e;if("object"!==r||!e)return[0,r];const t=c.call(e).slice(8,-1);switch(t){case"Array":return[1,n];case"Object":return[2,n];case"Date":return[3,n];case"RegExp":return[4,n];case"Map":return[5,n];case"Set":return[6,n];case"DataView":return[1,t]}return t.includes("Array")?[1,t]:t.includes("Error")?[7,t]:[2,t]},u=([e,r])=>0===e&&("function"===r||"symbol"===r),i=(e,{json:r,lossy:t}={})=>{const s=[];return((e,r,t,s)=>{const c=(e,r)=>{const n=s.push(e)-1;return t.set(r,n),n},i=s=>{if(t.has(s))return t.get(s);let[f,l]=o(s);switch(f){case 0:{let r=s;switch(l){case"bigint":f=8,r=s.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+l);r=null;break;case"undefined":return c([-1],s)}return c([f,r],s)}case 1:{if(l){let e=s;return"DataView"===l?e=new Uint8Array(s.buffer):"ArrayBuffer"===l&&(e=new Uint8Array(s)),c([l,[...e]],s)}const e=[],r=c([f,e],s);for(const r of s)e.push(i(r));return r}case 2:{if(l)switch(l){case"BigInt":return c([l,s.toString()],s);case"Boolean":case"Number":case"String":return c([l,s.valueOf()],s)}if(r&&"toJSON"in s)return i(s.toJSON());const t=[],n=c([f,t],s);for(const r of a(s))!e&&u(o(s[r]))||t.push([i(r),i(s[r])]);return n}case 3:return c([f,isNaN(s.getTime())?n:s.toISOString()],s);case 4:{const{source:e,flags:r}=s;return c([f,{source:e,flags:r}],s)}case 5:{const r=[],t=c([f,r],s);for(const[t,n]of s)(e||!u(o(t))&&!u(o(n)))&&r.push([i(t),i(n)]);return t}case 6:{const r=[],t=c([f,r],s);for(const t of s)!e&&u(o(t))||r.push(i(t));return t}}const{message:w}=s;return c([f,{name:l,message:w}],s)};return i})(!(r||t),!!r,new Map,s)(e),s},{parse:f,stringify:l}=JSON,w={json:!0,lossy:!0};return e.parse=e=>s(f(e)),e.stringify=e=>l(i(e,w)),e}({});
