node-seal
Version:
Homomorphic Encryption for TypeScript or JavaScript using Microsoft SEAL
1 lines • 56.4 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).SEAL=t()}(this,(function(){"use strict";var e="undefined"!=typeof document?document.currentScript:null,t=async function(t={}){var r,n,a,o,i=t,c=new Promise(((e,t)=>{r=e,n=t})),s="./this.program",u="undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:e&&"SCRIPT"===e.tagName.toUpperCase()&&e.src||new URL("throws_wasm_cf_worker_umd.js",document.baseURI).href,l="";try{l=new URL(".",u).href}catch{}o=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)},a=async e=>{if((e=await fetch(e,{credentials:"same-origin"})).ok)return e.arrayBuffer();throw Error(e.status+" : "+e.url)};var d,f,y,h,p,m,v,w,g,T,b,C,A,P=console.error.bind(console),x=!1;function I(){var e=f.buffer;h=new Int8Array(e),m=new Int16Array(e),p=new Uint8Array(e),v=new Uint16Array(e),w=new Int32Array(e),g=new Uint32Array(e),T=new Float32Array(e),A=new Float64Array(e),b=new BigInt64Array(e),C=new BigUint64Array(e)}var S,E=0,V=null;function M(e){throw i.onAbort?.(e),P(e="Aborted("+e+")"),x=!0,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),n(e),e}async function j(e,t){try{var r=await async function(e){if(!d)try{var t=await a(e);return new Uint8Array(t)}catch{}if(e==S&&d)e=new Uint8Array(d);else{if(!o)throw"both async and sync fetching of the wasm failed";e=o(e)}return e}(e);return await WebAssembly.instantiate(r,t)}catch(e){P(`failed to asynchronously prepare wasm: ${e}`),M(e)}}class ${name="ExitStatus";constructor(e){this.message=`Program terminated with exit(${e})`,this.status=e}}var W=e=>{for(;0<e.length;)e.shift()(i)},F=[],z=[],U=()=>{var e=i.preRun.shift();z.push(e)},R=!0;class B{constructor(e){this.X=e-24}}var K,k=e=>{for(var t="";p[e>>>0];)t+=K[p[e++>>>0]];return t},N={},_={},D={},O=class extends Error{constructor(e){super(e),this.name="BindingError"}};function L(e,t,r={}){return function(e,t,r={}){var n=t.name;if(!e)throw new O(`type "${n}" must have a positive integer typeid pointer`);if(_.hasOwnProperty(e)){if(r.va)return;throw new O(`Cannot register type '${n}' twice`)}_[e]=t,delete D[e],N.hasOwnProperty(e)&&(t=N[e],delete N[e],t.forEach((e=>e())))}(e,t,r)}var Z=(e,t,r)=>{switch(t){case 1:return r?e=>h[e>>>0]:e=>p[e>>>0];case 2:return r?e=>m[e>>>1>>>0]:e=>v[e>>>1>>>0];case 4:return r?e=>w[e>>>2>>>0]:e=>g[e>>>2>>>0];case 8:return r?e=>b[e>>>3>>>0]:e=>C[e>>>3>>>0];default:throw new TypeError(`invalid integer width (${t}): ${e}`)}},X=e=>{throw new O(e.V.Y.W.name+" instance already deleted")},H=!1,Y=()=>{},G=e=>"undefined"==typeof FinalizationRegistry?(G=e=>e,e):(H=new FinalizationRegistry((e=>{--(e=e.V).count.value,0===e.count.value&&(e.$?e.ba.fa(e.$):e.Y.W.fa(e.X))})),Y=e=>{H.unregister(e)},(G=e=>{var t=e.V;return t.$&&H.register(e,{V:t},e),e})(e));function q(){}var Q=(e,t)=>Object.defineProperty(t,"name",{value:e}),J={},ee=(e,t,r)=>{if(void 0===e[t].Z){var n=e[t];e[t]=function(...n){if(!e[t].Z.hasOwnProperty(n.length))throw new O(`Function '${r}' called with an invalid number of arguments (${n.length}) - expects one of (${e[t].Z})!`);return e[t].Z[n.length].apply(this,n)},e[t].Z=[],e[t].Z[n.ga]=n}},te=(e,t,r)=>{if(i.hasOwnProperty(e)){if(void 0===r||void 0!==i[e].Z&&void 0!==i[e].Z[r])throw new O(`Cannot register public name '${e}' twice`);if(ee(i,e,e),i[e].Z.hasOwnProperty(r))throw new O(`Cannot register multiple overloads of a function with the same number of arguments (${r})!`);i[e].Z[r]=t}else i[e]=t,i[e].ga=r};function re(e,t,r,n,a,o,i,c){this.name=e,this.constructor=t,this.ea=r,this.fa=n,this.aa=a,this.ta=o,this.ka=i,this.sa=c,this.xa=[]}var ne=(e,t,r)=>{for(;t!==r;){if(!t.ka)throw new O(`Expected null or instance of ${r.name}, got an instance of ${t.name}`);e=t.ka(e),t=t.aa}return e},ae=e=>{if(null===e)return"null";var t=typeof e;return"object"===t||"array"===t||"function"===t?e.toString():""+e};function oe(e,t){if(null===t){if(this.oa)throw new O(`null is not a valid ${this.name}`);return 0}if(!t.V)throw new O(`Cannot pass "${ae(t)}" as a ${this.name}`);if(!t.V.X)throw new O(`Cannot pass deleted object as a pointer of type ${this.name}`);return ne(t.V.X,t.V.Y.W,this.W)}function ie(e,t){if(null===t){if(this.oa)throw new O(`null is not a valid ${this.name}`);if(this.na){var r=this.ya();return null!==e&&e.push(this.fa,r),r}return 0}if(!t||!t.V)throw new O(`Cannot pass "${ae(t)}" as a ${this.name}`);if(!t.V.X)throw new O(`Cannot pass deleted object as a pointer of type ${this.name}`);if(!this.ma&&t.V.Y.ma)throw new O(`Cannot convert argument of type ${t.V.ba?t.V.ba.name:t.V.Y.name} to parameter type ${this.name}`);if(r=ne(t.V.X,t.V.Y.W,this.W),this.na){if(void 0===t.V.$)throw new O("Passing raw pointer to smart pointer is illegal");switch(this.Aa){case 0:if(t.V.ba!==this)throw new O(`Cannot convert argument of type ${t.V.ba?t.V.ba.name:t.V.Y.name} to parameter type ${this.name}`);r=t.V.$;break;case 1:r=t.V.$;break;case 2:if(t.V.ba===this)r=t.V.$;else{var n=t.clone();r=this.za(r,Fe((()=>n.delete()))),null!==e&&e.push(this.fa,r)}break;default:throw new O("Unsupporting sharing policy")}}return r}function ce(e,t){if(null===t){if(this.oa)throw new O(`null is not a valid ${this.name}`);return 0}if(!t.V)throw new O(`Cannot pass "${ae(t)}" as a ${this.name}`);if(!t.V.X)throw new O(`Cannot pass deleted object as a pointer of type ${this.name}`);if(t.V.Y.ma)throw new O(`Cannot convert argument of type ${t.V.Y.name} to parameter type ${this.name}`);return ne(t.V.X,t.V.Y.W,this.W)}function se(e){return this.fromWireType(g[e>>>2>>>0])}var ue=(e,t,r)=>t===r?e:void 0===r.aa||null===(e=ue(e,t,r.aa))?null:r.sa(e),le={},de=class extends Error{constructor(e){super(e),this.name="InternalError"}},fe=(e,t)=>{if(!t.Y||!t.X)throw new de("makeClassHandle requires ptr and ptrType");if(!!t.ba!=!!t.$)throw new de("Both smartPtrType and smartPtr must be specified");return t.count={value:1},G(Object.create(e,{V:{value:t,writable:!0}}))};function ye(e,t,r,n,a,o,i,c,s,u,l){this.name=e,this.W=t,this.oa=r,this.ma=n,this.na=a,this.wa=o,this.Aa=i,this.qa=c,this.ya=s,this.za=u,this.fa=l,a||void 0!==t.aa?this.toWireType=ie:(this.toWireType=n?oe:ce,this.da=null)}var he,pe=(e,t,r)=>{if(!i.hasOwnProperty(e))throw new de("Replacing nonexistent public symbol");void 0!==i[e].Z&&void 0!==r?i[e].Z[r]=t:(i[e]=t,i[e].ga=r)},me=[],ve=e=>{var t=me[e];return t||(me[e]=t=he.get(e)),t},we=(e,t)=>(...r)=>((e,t,r=[])=>(t=ve(t)(...r),"p"==e[0]?t>>>0:t))(e,t,r),ge=(e,t)=>{var r=(e=k(e)).includes("p")?we(e,t):ve(t);if("function"!=typeof r)throw new O(`unknown function pointer with signature ${e}: ${t}`);return r};class Te extends Error{}var be=e=>{e=ht(e);var t=k(e);return vt(e),t},Ce=(e,t)=>{var r=[],n={};throw t.forEach((function e(t){n[t]||_[t]||(D[t]?D[t].forEach(e):(r.push(t),n[t]=!0))})),new Te(`${e}: `+r.map(be).join([", "]))},Ae=(e,t,r)=>{function n(t){if((t=r(t)).length!==e.length)throw new de("Mismatched type converter count");for(var n=0;n<e.length;++n)L(e[n],t[n])}e.forEach((e=>D[e]=t));var a=Array(t.length),o=[],i=0;t.forEach(((e,t)=>{_.hasOwnProperty(e)?a[t]=_[e]:(o.push(e),N.hasOwnProperty(e)||(N[e]=[]),N[e].push((()=>{a[t]=_[e],++i===o.length&&n(a)})))})),0===o.length&&n(a)},Pe=e=>{for(;e.length;){var t=e.pop();e.pop()(t)}};function xe(e,t,r,n,a){var o=t.length;if(2>o)throw new O("argTypes array size mismatch! Must at least get return value and 'this' types!");var i=null!==t[1]&&null!==r,c=function(e){for(var t=1;t<e.length;++t)if(null!==e[t]&&void 0===e[t].da)return!0;return!1}(t),s="void"!==t[0].name,u=o-2,l=Array(u),d=[],f=[];return Q(e,(function(...e){if(f.length=0,d.length=i?2:1,d[0]=a,i){var r=t[1].toWireType(f,this);d[1]=r}for(var o=0;o<u;++o)l[o]=t[o+2].toWireType(f,e[o]),d.push(l[o]);if(e=n(...d),c)Pe(f);else for(o=i?1:2;o<t.length;o++){var y=1===o?r:l[o-2];null!==t[o].da&&t[o].da(y)}return r=s?t[0].fromWireType(e):void 0}))}var Ie=(e,t)=>{for(var r=[],n=0;n<e;n++)r.push(g[t+4*n>>>2>>>0]);return r},Se=e=>{const t=(e=e.trim()).indexOf("(");return-1===t?e:e.slice(0,t)},Ee=(e,t,r)=>{if(!(e instanceof Object))throw new O(`${r} with invalid "this": ${e}`);if(!(e instanceof t.W.constructor))throw new O(`${r} incompatible with "this" of type ${e.constructor.name}`);if(!e.V.X)throw new O(`cannot call emscripten binding method ${r} on deleted object`);return ne(e.V.X,e.V.Y.W,t.W)},Ve=[],Me=[0,1,,1,null,1,!0,1,!1,1];function je(e){9<(e>>>=0)&&0==--Me[e+1]&&(Me[e]=void 0,Ve.push(e))}for(var $e,We=e=>{if(!e)throw new O(`Cannot use deleted val. handle = ${e}`);return Me[e]},Fe=e=>{switch(e){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:const t=Ve.pop()||Me.length;return Me[t]=e,Me[t+1]=1,t}},ze={name:"emscripten::val",fromWireType:e=>{var t=We(e);return je(e),t},toWireType:(e,t)=>Fe(t),ca:8,readValueFromPointer:se,da:null},Ue=(e,t,r)=>{switch(t){case 1:return r?function(e){return this.fromWireType(h[e>>>0])}:function(e){return this.fromWireType(p[e>>>0])};case 2:return r?function(e){return this.fromWireType(m[e>>>1>>>0])}:function(e){return this.fromWireType(v[e>>>1>>>0])};case 4:return r?function(e){return this.fromWireType(w[e>>>2>>>0])}:function(e){return this.fromWireType(g[e>>>2>>>0])};default:throw new TypeError(`invalid integer width (${t}): ${e}`)}},Re=(e,t)=>{var r=_[e];if(void 0===r)throw e=`${t} has unknown type ${be(e)}`,new O(e);return r},Be=(e,t)=>{switch(t){case 4:return function(e){return this.fromWireType(T[e>>>2>>>0])};case 8:return function(e){return this.fromWireType(A[e>>>3>>>0])};default:throw new TypeError(`invalid float width (${t}): ${e}`)}},Ke=Object.assign({optional:!0},ze),ke=(e,t,r)=>{var n=p;if(!(0<r))return 0;var a=t>>>=0;r=t+r-1;for(var o=0;o<e.length;++o){var i=e.charCodeAt(o);if(55296<=i&&57343>=i&&(i=65536+((1023&i)<<10)|1023&e.charCodeAt(++o)),127>=i){if(t>=r)break;n[t++>>>0]=i}else{if(2047>=i){if(t+1>=r)break;n[t++>>>0]=192|i>>6}else{if(65535>=i){if(t+2>=r)break;n[t++>>>0]=224|i>>12}else{if(t+3>=r)break;n[t++>>>0]=240|i>>18,n[t++>>>0]=128|i>>12&63}n[t++>>>0]=128|i>>6&63}n[t++>>>0]=128|63&i}}return n[t>>>0]=0,t-a},Ne=e=>{for(var t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);127>=n?t++:2047>=n?t+=2:55296<=n&&57343>=n?(t+=4,++r):t+=3}return t},_e="undefined"!=typeof TextDecoder?new TextDecoder:void 0,De=(e=0,t=NaN)=>{var r=p,n=(e>>>=0)+t;for(t=e;r[t]&&!(t>=n);)++t;if(16<t-e&&r.buffer&&_e)return _e.decode(r.subarray(e,t));for(n="";e<t;){var a=r[e++];if(128&a){var o=63&r[e++];if(192==(224&a))n+=String.fromCharCode((31&a)<<6|o);else{var i=63&r[e++];65536>(a=224==(240&a)?(15&a)<<12|o<<6|i:(7&a)<<18|o<<12|i<<6|63&r[e++])?n+=String.fromCharCode(a):(a-=65536,n+=String.fromCharCode(55296|a>>10,56320|1023&a))}}else n+=String.fromCharCode(a)}return n},Oe="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,Le=(e,t)=>{t=(e>>>=1)+t/2;for(var r=e;!(r>=t)&&v[r>>>0];)++r;if(16<r-e&&Oe)return Oe.decode(v.subarray(e>>>0,r>>>0));for(r="";!(e>=t);++e){var n=v[e>>>0];if(0==n)break;r+=String.fromCharCode(n)}return r},Ze=(e,t,r)=>{if(r??=2147483647,2>r)return 0;var n=t;r=(r-=2)<2*e.length?r/2:e.length;for(var a=0;a<r;++a)m[t>>>1>>>0]=e.charCodeAt(a),t+=2;return m[t>>>1>>>0]=0,t-n},Xe=e=>2*e.length,He=(e,t)=>{for(var r=0,n="";!(r>=t/4);){var a=w[e+4*r>>>2>>>0];if(0==a)break;++r,65536<=a?(a-=65536,n+=String.fromCharCode(55296|a>>10,56320|1023&a)):n+=String.fromCharCode(a)}return n},Ye=(e,t,r)=>{if(t>>>=0,r??=2147483647,4>r)return 0;var n=t;r=n+r-4;for(var a=0;a<e.length;++a){var o=e.charCodeAt(a);if(55296<=o&&57343>=o&&(o=65536+((1023&o)<<10)|1023&e.charCodeAt(++a)),w[t>>>2>>>0]=o,(t+=4)+4>r)break}return w[t>>>2>>>0]=0,t-n},Ge=e=>{for(var t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);55296<=n&&57343>=n&&++r,t+=4}return t},qe=0,Qe=(e,t,r)=>{var n=[];return e=e.toWireType(n,r),n.length&&(g[t>>>2>>>0]=Fe(n)),e},Je={},et=e=>{var t=Je[e];return void 0===t?k(e):t},tt=[],rt=Reflect.construct,nt={},at=e=>{if(!(e instanceof $||"unwind"==e))throw e},ot=e=>{throw y=e,R||0<qe||(i.onExit?.(e),x=!0),new $(e)},it={},ct=()=>{if(!$e){var e,t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:s||"./this.program"};for(e in it)void 0===it[e]?delete t[e]:t[e]=it[e];var r=[];for(e in t)r.push(`${e}=${t[e]}`);$e=r}return $e},st=e=>{(st=e=>crypto.getRandomValues(e))(e)},ut=Array(256),lt=0;256>lt;++lt)ut[lt]=String.fromCharCode(lt);K=ut,(()=>{let e=q.prototype;Object.assign(e,{isAliasOf:function(e){if(!(this instanceof q&&e instanceof q))return!1;var t=this.V.Y.W,r=this.V.X;e.V=e.V;var n=e.V.Y.W;for(e=e.V.X;t.aa;)r=t.ka(r),t=t.aa;for(;n.aa;)e=n.ka(e),n=n.aa;return t===n&&r===e},clone:function(){if(this.V.X||X(this),this.V.ja)return this.V.count.value+=1,this;var e=G,t=Object,r=t.create,n=Object.getPrototypeOf(this),a=this.V;return(e=e(r.call(t,n,{V:{value:{count:a.count,ia:a.ia,ja:a.ja,X:a.X,Y:a.Y,$:a.$,ba:a.ba}}}))).V.count.value+=1,e.V.ia=!1,e},delete(){if(this.V.X||X(this),this.V.ia&&!this.V.ja)throw new O("Object already scheduled for deletion");Y(this);var e=this.V;--e.count.value,0===e.count.value&&(e.$?e.ba.fa(e.$):e.Y.W.fa(e.X)),this.V.ja||(this.V.$=void 0,this.V.X=void 0)},isDeleted:function(){return!this.V.X},deleteLater:function(){if(this.V.X||X(this),this.V.ia&&!this.V.ja)throw new O("Object already scheduled for deletion");return this.V.ia=!0,this}});const t=Symbol.dispose;t&&(e[t]=e.delete)})(),Object.assign(ye.prototype,{ua(e){return this.qa&&(e=this.qa(e)),e},pa(e){this.fa?.(e)},ca:8,readValueFromPointer:se,fromWireType:function(e){function t(){return this.na?fe(this.W.ea,{Y:this.wa,X:r,ba:this,$:e}):fe(this.W.ea,{Y:this,X:e})}var r=this.ua(e);if(!r)return this.pa(e),null;var n=((e,t)=>{if(void 0===t)throw new O("ptr should not be undefined");for(;e.aa;)t=e.ka(t),e=e.aa;return le[t]})(this.W,r);if(void 0!==n)return 0===n.V.count.value?(n.V.X=r,n.V.$=e,n.clone()):(n=n.clone(),this.pa(e),n);if(n=this.W.ta(r),!(n=J[n]))return t.call(this);n=this.ma?n.ra:n.pointerType;var a=ue(r,this.W,n.W);return null===a?t.call(this):this.na?fe(n.W.ea,{Y:n,X:a,ba:this,$:e}):fe(n.W.ea,{Y:n,X:a})}}),i.noExitRuntime&&(R=i.noExitRuntime),i.printErr&&(P=i.printErr),i.wasmBinary&&(d=i.wasmBinary),i.thisProgram&&(s=i.thisProgram);var dt={a:function(e,t,r){var n=new B(e>>>=0);throw g[n.X+16>>>2>>>0]=0,g[n.X+4>>>2>>>0]=t>>>0,g[n.X+8>>>2>>>0]=r>>>0,e},M:()=>M(""),x:function(e,t,r,n,a){e>>>=0,r>>>=0,t=k(t>>>0);let o=e=>e;if(n=0n===n){const e=8*r;o=t=>BigInt.asUintN(e,t),a=o(a)}L(e,{name:t,fromWireType:o,toWireType:(e,t)=>("number"==typeof t&&(t=BigInt(t)),t),ca:8,readValueFromPointer:Z(t,r,!n),da:null})},J:function(e,t,r,n){L(e>>>0,{name:t=k(t>>>0),fromWireType:function(e){return!!e},toWireType:function(e,t){return t?r:n},ca:8,readValueFromPointer:function(e){return this.fromWireType(p[e>>>0])},da:null})},e:function(e,t,r,n,a,o,i,c,s,u,l,d,f){e>>>=0,t>>>=0,r>>>=0,n>>>=0,o>>>=0,i>>>=0,c>>>=0,s>>>=0,u>>>=0,d>>>=0,f>>>=0,l=k(l>>>=0),o=ge(a>>>0,o),c&&=ge(i,c),u&&=ge(s,u),f=ge(d,f);var y=(e=>{var t=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return 48<=t&&57>=t?`_${e}`:e})(l);te(y,(function(){Ce(`Cannot construct ${l} due to unbound types`,[n])})),Ae([e,t,r],n?[n]:[],(t=>{if(t=t[0],n)var r=t.W,a=r.ea;else a=q.prototype;t=Q(l,(function(...e){if(Object.getPrototypeOf(this)!==i)throw new O(`Use 'new' to construct ${l}`);if(void 0===d.ha)throw new O(`${l} has no accessible constructor`);var t=d.ha[e.length];if(void 0===t)throw new O(`Tried to invoke ctor of ${l} with invalid number of parameters (${e.length}) - expected (${Object.keys(d.ha).toString()}) parameters instead!`);return t.apply(this,e)}));var i=Object.create(a,{constructor:{value:t}});t.prototype=i;var s,d=new re(l,t,i,f,r,o,c,u);return d.aa&&((s=d.aa).la??(s.la=[]),d.aa.la.push(d)),r=new ye(l,d,!0,!1,!1),s=new ye(l+"*",d,!1,!1,!1),a=new ye(l+" const*",d,!1,!0,!1),J[e]={pointerType:s,ra:a},pe(y,t),[r,s,a]}))},s:function(e,t,r,n,a,o,i){e>>>=0,t>>>=0,a>>>=0,o>>>=0,i>>>=0;var c=Ie(r,n>>>0);t=k(t),t=Se(t),o=ge(a,o),Ae([],[e],(e=>{function n(){Ce(`Cannot call ${a} due to unbound types`,c)}var a=`${(e=e[0]).name}.${t}`;t.startsWith("@@")&&(t=Symbol[t.substring(2)]);var s=e.W.constructor;return void 0===s[t]?(n.ga=r-1,s[t]=n):(ee(s,t,a),s[t].Z[r-1]=n),Ae([],c,(n=>{if(n=xe(a,[n[0],null].concat(n.slice(1)),null,o,i),void 0===s[t].Z?(n.ga=r-1,s[t]=n):s[t].Z[r-1]=n,e.W.la)for(const r of e.W.la)r.constructor.hasOwnProperty(t)||(r.constructor[t]=n);return[]})),[]}))},y:function(e,t,r,n,a,o,i,c){e>>>=0,r>>>=0,n>>>=0,o>>>=0,i>>>=0,c>>>=0,t=k(t>>>=0),o=ge(a>>>0,o),Ae([],[e],(e=>{var a=`${(e=e[0]).name}.${t}`,s={get(){Ce(`Cannot access ${a} due to unbound types`,[r])},enumerable:!0,configurable:!0};return s.set=c?()=>{Ce(`Cannot access ${a} due to unbound types`,[r])}:()=>{throw new O(`${a} is a read-only property`)},Object.defineProperty(e.W.constructor,t,s),Ae([],[r],(r=>{r=r[0];var a={get:()=>r.fromWireType(o(n)),enumerable:!0};return c&&(c=ge(i,c),a.set=e=>{var t=[];c(n,r.toWireType(t,e)),Pe(t)}),Object.defineProperty(e.W.constructor,t,a),[]})),[]}))},f:function(e,t,r,n,a,o){e>>>=0,n>>>=0,a>>>=0,o>>>=0;var i=Ie(t,r>>>0);a=ge(n,a),Ae([],[e],(e=>{var r=`constructor ${(e=e[0]).name}`;if(void 0===e.W.ha&&(e.W.ha=[]),void 0!==e.W.ha[t-1])throw new O(`Cannot register multiple constructors with identical number of parameters (${t-1}) for class '${e.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return e.W.ha[t-1]=()=>{Ce(`Cannot construct ${e.name} due to unbound types`,i)},Ae([],i,(n=>(n.splice(1,0,null),e.W.ha[t-1]=xe(r,n,null,a,o),[]))),[]}))},b:function(e,t,r,n,a,o,i,c){e>>>=0,t>>>=0,a>>>=0,o>>>=0,i>>>=0;var s=Ie(r,n>>>0);t=k(t),t=Se(t),o=ge(a,o),Ae([],[e],(e=>{function n(){Ce(`Cannot call ${a} due to unbound types`,s)}var a=`${(e=e[0]).name}.${t}`;t.startsWith("@@")&&(t=Symbol[t.substring(2)]),c&&e.W.xa.push(t);var u=e.W.ea,l=u[t];return void 0===l||void 0===l.Z&&l.className!==e.name&&l.ga===r-2?(n.ga=r-2,n.className=e.name,u[t]=n):(ee(u,t,a),u[t].Z[r-2]=n),Ae([],s,(n=>(n=xe(a,n,e,o,i),void 0===u[t].Z?(n.ga=r-2,u[t]=n):u[t].Z[r-2]=n,[]))),[]}))},t:function(e,t,r,n,a,o,i,c,s,u){e>>>=0,r>>>=0,a>>>=0,o>>>=0,i>>>=0,c>>>=0,s>>>=0,u>>>=0,t=k(t>>>=0),a=ge(n>>>0,a),Ae([],[e],(e=>{var n=`${(e=e[0]).name}.${t}`,l={get(){Ce(`Cannot access ${n} due to unbound types`,[r,i])},enumerable:!0,configurable:!0};return l.set=s?()=>Ce(`Cannot access ${n} due to unbound types`,[r,i]):()=>{throw new O(n+" is a read-only property")},Object.defineProperty(e.W.ea,t,l),Ae([],s?[r,i]:[r],(r=>{var i=r[0],l={get(){var t=Ee(this,e,n+" getter");return i.fromWireType(a(o,t))},enumerable:!0};if(s){s=ge(c,s);var d=r[1];l.set=function(t){var r=Ee(this,e,n+" setter"),a=[];s(u,r,d.toWireType(a,t)),Pe(a)}}return Object.defineProperty(e.W.ea,t,l),[]})),[]}))},H:function(e){return L(e>>>0,ze)},v:function(e,t,r,n){function a(){}t=k(t>>>0),a.values={},L(e>>>0,{name:t,constructor:a,fromWireType:function(e){return this.constructor.values[e]},toWireType:(e,t)=>t.value,ca:8,readValueFromPointer:Ue(t,r>>>0,n),da:null}),te(t,a)},p:function(e,t,r){t>>>=0;var n=Re(e>>>0,"enum");t=k(t),e=n.constructor,n=Object.create(n.constructor.prototype,{value:{value:r},constructor:{value:Q(`${n.name}_${t}`,(function(){}))}}),e.values[r]=n,e[t]=n},w:function(e,t,r){L(e>>>0,{name:t=k(t>>>0),fromWireType:e=>e,toWireType:(e,t)=>t,ca:8,readValueFromPointer:Be(t,r>>>0),da:null})},o:function(e,t,r,n,a,o){e>>>=0,n>>>=0,a>>>=0,o>>>=0;var i=Ie(t,r>>>0);e=k(e),e=Se(e),a=ge(n,a),te(e,(function(){Ce(`Cannot call ${e} due to unbound types`,i)}),t-1),Ae([],i,(r=>(pe(e,xe(e,[r[0],null].concat(r.slice(1)),null,a,o),t-1),[])))},r:function(e,t,r,n,a){e>>>=0,r>>>=0,t=k(t>>>0);let o=e=>e;if(0===n){var i=32-8*r;o=e=>e<<i>>>i,a=o(a)}L(e,{name:t,fromWireType:o,toWireType:(e,t)=>t,ca:8,readValueFromPointer:Z(t,r,0!==n),da:null})},k:function(e,t,r){function n(e){return new a(h.buffer,g[e+4>>>2>>>0],g[e>>>2>>>0])}var a=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array][t];L(e>>>0,{name:r=k(r>>>0),fromWireType:n,ca:8,readValueFromPointer:n},{va:!0})},q:function(e){L(e>>>0,Ke)},I:function(e,t){L(e>>>0,{name:t=k(t>>>0),fromWireType:function(e){for(var t,r=g[e>>>2>>>0],n=e+4,a=n,o=0;o<=r;++o){var i=n+o;if(o==r||0==p[i>>>0]){var c=a;a=(c>>>=0)?De(c,i-a):"",void 0===t?t=a:(t+=String.fromCharCode(0),t+=a),a=i+1}}return vt(e),t},toWireType:function(e,t){t instanceof ArrayBuffer&&(t=new Uint8Array(t));var r="string"==typeof t;if(!(r||ArrayBuffer.isView(t)&&1==t.BYTES_PER_ELEMENT))throw new O("Cannot pass non-string to std::string");var n=r?Ne(t):t.length,a=mt(4+n+1),o=a+4;return g[a>>>2>>>0]=n,r?ke(t,o,n+1):p.set(t,o>>>0),null!==e&&e.push(vt,a),a},ca:8,readValueFromPointer:se,da(e){vt(e)}})},u:function(e,t,r){if(t>>>=0,r=k(r>>>=0),2===t)var n=Le,a=Ze,o=Xe,i=e=>v[e>>>1>>>0];else 4===t&&(n=He,a=Ye,o=Ge,i=e=>g[e>>>2>>>0]);L(e>>>0,{name:r,fromWireType:e=>{for(var r,a=g[e>>>2>>>0],o=e+4,c=0;c<=a;++c){var s=e+4+c*t;c!=a&&0!=i(s)||(o=n(o,s-o),void 0===r?r=o:(r+=String.fromCharCode(0),r+=o),o=s+t)}return vt(e),r},toWireType:(e,n)=>{if("string"!=typeof n)throw new O(`Cannot pass non-string to C++ string type ${r}`);var i=o(n),c=mt(4+i+t);return g[c>>>2>>>0]=i/t,a(n,c+4,i+t),null!==e&&e.push(vt,c),c},ca:8,readValueFromPointer:se,da(e){vt(e)}})},K:function(e,t){L(e>>>0,{Ba:!0,name:t=k(t>>>0),ca:0,fromWireType:()=>{},toWireType:()=>{}})},D:()=>{R=!1,qe=0},h:function(e,t,r){return t>>>=0,r>>>=0,e=We(e>>>0),t=Re(t,"emval::as"),Qe(t,r,e)},m:function(e,t,r,n,a){return r>>>=0,n>>>=0,a>>>=0,(e=tt[e>>>0])(t=We(t>>>0),t[r=et(r)],n,a)},c:je,l:function(e,t,r){var n=((e,t)=>{for(var r=Array(e),n=0;n<e;++n)r[n]=Re(g[t+4*n>>>2>>>0],`parameter ${n}`);return r})(e,t>>>0),a=n.shift();e--;var o=Array(e);return t=`methodCaller<(${n.map((e=>e.name)).join(", ")}) => ${a.name}>`,(e=>{var t=tt.length;return tt.push(e),t})(Q(t,((t,i,c,s)=>{for(var u=0,l=0;l<e;++l)o[l]=n[l].readValueFromPointer(s+u),u+=n[l].ca;return t=1===r?rt(i,o):i.apply(t,o),Qe(a,c,t)})))},i:function(e,t){return t>>>=0,e=We(e>>>0),t=We(t),Fe(e[t])},n:function(e){9<(e>>>=0)&&(Me[e+1]+=1)},F:function(){return Fe([])},j:function(e){return Fe(et(e>>>0))},d:function(e){var t=We(e>>>=0);Pe(t),je(e)},g:function(e,t){return t>>>=0,e=(e=Re(e>>>0,"_emval_take_value")).readValueFromPointer(t),Fe(e)},E:(e,t)=>{if(nt[e]&&(clearTimeout(nt[e].id),delete nt[e]),!t)return 0;var r=setTimeout((()=>{delete nt[e],(e=>{if(!x)try{if(e(),!(R||0<qe))try{y=e=y,ot(e)}catch(e){at(e)}}catch(e){at(e)}})((()=>pt(e,performance.now())))}),t);return nt[e]={id:r,Ca:t},0},A:function(e,t,r,n){r>>>=0,n>>>=0;var a=(new Date).getFullYear(),o=new Date(a,0,1).getTimezoneOffset();a=new Date(a,6,1).getTimezoneOffset(),g[e>>>0>>>2>>>0]=60*Math.max(o,a),w[t>>>0>>>2>>>0]=Number(o!=a),e=(t=e=>{var t=Math.abs(e);return`UTC${0<=e?"-":"+"}${String(Math.floor(t/60)).padStart(2,"0")}${String(t%60).padStart(2,"0")}`})(o),t=t(a),a<o?(ke(e,r,17),ke(t,n,17)):(ke(e,n,17),ke(t,r,17))},L:function(e){e>>>=0;var t=p.length;if(4294901760<e)return!1;for(var r=1;4>=r;r*=2){var n=t*(1+.2/r);n=Math.min(n,e+100663296);e:{n=(Math.min(4294901760,65536*Math.ceil(Math.max(e,n)/65536))-f.buffer.byteLength+65535)/65536|0;try{f.grow(n),I();var a=1;break e}catch(e){}a=void 0}if(a)return!0}return!1},B:function(e,t){e>>>=0,t>>>=0;var r,n=0,a=0;for(r of ct()){var o=t+n;g[e+a>>>2>>>0]=o,n+=ke(r,o,1/0)+1,a+=4}return 0},G:function(e,t){e>>>=0,t>>>=0;var r=ct();for(var n of(g[e>>>2>>>0]=r.length,e=0,r))e+=Ne(n)+1;return g[t>>>2>>>0]=e,0},C:ot,z:function(e,t){return e>>>=0,st(p.subarray(e>>>0,e+(t>>>0)>>>0)),0}},ft=await async function(){function t(e){return ft=e.exports,ft=function(){var e=ft;e=Object.assign({},e);var t=e=>t=>e(t)>>>0;return e.Q=t(e.Q),e.S=t(e.S),e._emscripten_stack_alloc=t(e._emscripten_stack_alloc),e.emscripten_stack_get_current=(e=>()=>e()>>>0)(e.emscripten_stack_get_current),e}(),f=ft.N,I(),he=ft.U,E--,i.monitorRunDependencies?.(E),0==E&&V&&(e=V,V=null,e()),ft}E++,i.monitorRunDependencies?.(E);var r={a:dt};if(i.instantiateWasm)return new Promise((e=>{i.instantiateWasm(r,((r,n)=>{e(t(r))}))}));S??=i.locateFile?i.locateFile?i.locateFile("seal_throws_wasm_cf_worker.wasm",l):l+"seal_throws_wasm_cf_worker.wasm":new URL("seal_throws_wasm_cf_worker.wasm","undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:e&&"SCRIPT"===e.tagName.toUpperCase()&&e.src||new URL("throws_wasm_cf_worker_umd.js",document.baseURI).href).href;try{var a=await async function(e){var t=S;if(!d&&"function"==typeof WebAssembly.instantiateStreaming)try{var r=fetch(t,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(r,e)}catch(e){P(`wasm streaming compile failed: ${e}`),P("falling back to ArrayBuffer instantiation")}return j(t,e)}(r);return t(a.instance)}catch(e){return n(e),Promise.reject(e)}}(),yt=i._main=ft.P,ht=ft.Q,pt=ft.R,mt=ft.S,vt=ft.T;if(i.preInit)for("function"==typeof i.preInit&&(i.preInit=[i.preInit]);0<i.preInit.length;)i.preInit.shift()();return function e(){function t(){if(i.calledRun=!0,!x){if(ft.O(),r(i),i.onRuntimeInitialized?.(),!i.noInitialRun)try{var e=yt(0,0);y=e,ot(e)}catch(e){at(e)}if(i.postRun)for("function"==typeof i.postRun&&(i.postRun=[i.postRun]);i.postRun.length;)e=i.postRun.shift(),F.push(e);W(F)}}if(0<E)V=e;else{if(i.preRun)for("function"==typeof i.preRun&&(i.preRun=[i.preRun]);i.preRun.length;)U();W(z),0<E?V=e:i.setStatus?(i.setStatus("Running..."),setTimeout((()=>{setTimeout((()=>i.setStatus("")),1),t()}),1)):t()}}(),c};const r="Unsupported vector type",n=({loader:e})=>(e=>({Exception:t,MemoryPoolHandle:r,PlainText:n,Vector:a})=>o=>{const i=e.BatchEncoder;let c;try{c=new i(o.instance)}catch(e){throw t.safe(e)}return{get instance(){return c},unsafeInject(e){c&&(c.delete(),c=void 0),c=e},delete(){c&&(c.delete(),c=void 0)},encode(e,r){try{if(e.constructor===Int32Array){if(r)return void c.encode(e,r.instance,"INT32");const t=n();return c.encode(e,t.instance,"INT32"),t}if(e.constructor===Uint32Array){if(r)return void c.encode(e,r.instance,"UINT32");const t=n();return c.encode(e,t.instance,"UINT32"),t}if(e.constructor===BigInt64Array){const t=e.toString().split(",");if(r)return void c.encode(t,r.instance,"INT64");const a=n();return c.encode(t,a.instance,"INT64"),a}if(e.constructor===BigUint64Array){const t=e.toString().split(",");if(r)return void c.encode(t,r.instance,"UINT64");const a=n();return c.encode(t,a.instance,"UINT64"),a}throw new Error("Unsupported array type! `array` must be of type Int32Array, Uint32Array, BigInt64Array, or BigUint64Array.")}catch(e){throw t.safe(e)}},decode(e,n=!0,o=r.global){try{if(n){const t=a(),r=c.decodeInt32(e.instance,o);t.unsafeInject(r),t.setType("Int32Array");const n=t.toArray();return t.delete(),n}const t=a(),r=c.decodeUint32(e.instance,o);t.unsafeInject(r),t.setType("Uint32Array");const i=t.toArray();return t.delete(),i}catch(e){throw t.safe(e)}},decodeBigInt(e,n=!0,a=r.global){try{if(n){const t=c.decodeBigInt(e.instance,!0,a);return BigInt64Array.from(t)}const t=c.decodeBigInt(e.instance,!1,a);return BigUint64Array.from(t)}catch(e){throw t.safe(e)}},get slotCount(){return c.slotCount()}}})(e.library),a=e=>({Exception:t,ComprModeType:r,ParmsIdType:n,MemoryPoolHandle:o,Vector:i})=>({context:c,parmsId:s,sizeCapacity:u,pool:l=o.global}={})=>{const d=e.Ciphertext;let f=function({context:e,parmsId:r,sizeCapacity:n,pool:a=o.global}={}){try{if(e||r||void 0!==n){if(e&&!r&&void 0===n)return new d(e.instance,a);if(e&&r&&void 0===n)return new d(e.instance,r.instance,a);if(e&&r&&void 0!==n)return new d(e.instance,r.instance,n,a);throw new Error("Must specify a (context), (context, parmsId), or (context, parmsId, sizeCapacity)")}return new d(a)}catch(e){throw t.safe(e)}}({context:c,parmsId:s,sizeCapacity:u,pool:l});return{get instance(){return f},unsafeInject(e){f&&(f.delete(),f=void 0),f=e},delete(){f&&(f.delete(),f=void 0)},reserve(e,r){try{return f.reserve(e.instance,r)}catch(e){throw t.safe(e)}},resize(e){try{return f.resize(e)}catch(e){throw t.safe(e)}},release(){f.release()},get coeffModulusSize(){return f.coeffModulusSize()},get polyModulusDegree(){return f.polyModulusDegree()},get size(){return f.size()},get sizeCapacity(){return f.sizeCapacity()},get isTransparent(){return f.isTransparent()},get isNttForm(){return f.isNttForm()},get parmsId(){const e=n();return e.inject(f.parmsId()),e},get scale(){return f.scale()},setScale(e){f.setScale(e)},get pool(){return f.pool()},save:(e=r.zstd)=>f.saveToString(e),saveArray(e=r.zstd){const t=i(),n=f.saveToArray(e);t.unsafeInject(n),t.setType("Uint8Array");const a=t.toArray();return t.delete(),a},load(e,r){try{f.loadFromString(e.instance,r)}catch(e){throw t.safe(e)}},loadArray(e,r){try{f.loadFromArray(e.instance,r)}catch(e){throw t.safe(e)}},copy(e){try{f.copy(e.instance)}catch(e){throw t.safe(e)}},clone(){try{const c=f.clone(),s=a(e)({Exception:t,ComprModeType:r,ParmsIdType:n,MemoryPoolHandle:o,Vector:i})();return s.unsafeInject(c),s}catch(e){throw t.safe(e)}},move(e){try{f.move(e.instance),e.delete()}catch(e){throw t.safe(e)}}}},o=({loader:e})=>{const t=e.library;return a(t)},i=({loader:e})=>(e=>({Exception:t,MemoryPoolHandle:r,PlainText:n,Vector:a})=>o=>{const i=e.CKKSEncoder;let c;try{c=new i(o.instance)}catch(e){throw t.safe(e)}return{get instance(){return c},unsafeInject(e){c&&(c.delete(),c=void 0),c=e},delete(){c&&(c.delete(),c=void 0)},encode(e,a,o,i=r.global){try{if(e.constructor===Float64Array){if(o)return void c.encode(e,a,o.instance,i);const t=n();return c.encode(e,a,t.instance,i),t}throw new Error("Unsupported array type! `array` must be of type Float64Array.")}catch(e){throw t.safe(e)}},decode(e,n=r.global){try{const t=a(),r=c.decodeDouble(e.instance,n);t.unsafeInject(r),t.setType("Float64Array");const o=t.toArray();return t.delete(),o}catch(e){throw t.safe(e)}},get slotCount(){return c.slotCount()}}})(e.library),c=({loader:e})=>(e=>({Exception:t,SecurityLevel:r,Vector:n})=>()=>{const a=e.CoeffModulus.MaxBitCount,o=e.CoeffModulus.BFVDefault,i=e.CoeffModulus.CreateFromArray;return{MaxBitCount:(e,t=r.tc128)=>a(e,t),BFVDefault(e,a=r.tc128){try{const t=n(),r=o(e,a);return t.unsafeInject(r),t.setType("Modulus"),t}catch(e){throw t.safe(e)}},Create(e,r){try{if(r.constructor!==Int32Array)throw new Error("Unsupported argument type! `bitSizes` must be an Int32Array");const t=n(),a=i(e,r);return t.unsafeInject(a),t.setType("Modulus"),t}catch(e){throw t.safe(e)}}}})(e.library),s=({loader:e})=>(e=>()=>()=>{const t=e.ComprModeType.none,r=e.ComprModeType.zlib,n=e.ComprModeType.zstd;return{get none(){return t},get zlib(){return r},get zstd(){return n}}})(e.library),u=({loader:e})=>(e=>({ParmsIdType:t,ContextData:r,SecurityLevel:n})=>(a,o=!0,i=n.tc128)=>{let c=new(0,e.SEALContext)(a.instance,o,i);return{get instance(){return c},unsafeInject(e){c&&(c.delete(),c=void 0),c=e},delete(){c&&(c.delete(),c=void 0)},toHuman:()=>c.toHuman(),getContextData(e){const t=c.getContextData(e.instance),n=r();return n.unsafeInject(t),n},get keyContextData(){const e=c.keyContextData(),t=r();return t.unsafeInject(e),t},get firstContextData(){const e=c.firstContextData(),t=r();return t.unsafeInject(e),t},get lastContextData(){const e=c.lastContextData(),t=r();return t.unsafeInject(e),t},parametersSet:()=>c.parametersSet(),get keyParmsId(){const e=c.keyParmsId(),r=t();return r.inject(e),r},get firstParmsId(){const e=c.firstParmsId(),r=t();return r.inject(e),r},get lastParmsId(){const e=c.lastParmsId(),r=t();return r.inject(e),r},get usingKeyswitching(){return c.usingKeyswitching()}}})(e.library),l=e=>({Exception:e,EncryptionParameters:t,ParmsIdType:r,EncryptionParameterQualifiers:n})=>()=>{let a;return{get instance(){return a},unsafeInject(e){a&&(a.delete(),a=void 0),a=e},delete(){a&&(a.delete(),a=void 0)},get parms(){const e=a.parms(),r=t();return r.unsafeInject(e),r},get parmsId(){const e=r();return e.inject(a.parmsId()),e},get qualifiers(){const e=n();return e.unsafeInject(a.qualifiers()),e},get totalCoeffModulusBitCount(){return a.totalCoeffModulusBitCount()},get prevContextData(){const o=l()({Exception:e,EncryptionParameters:t,ParmsIdType:r,EncryptionParameterQualifiers:n})();return o.unsafeInject(a.prevContextData()),o},get nextContextData(){const o=l()({Exception:e,EncryptionParameters:t,ParmsIdType:r,EncryptionParameterQualifiers:n})();return o.unsafeInject(a.nextContextData()),o},get chainIndex(){return a.chainIndex()}}},d=({loader:e})=>(e.library,l()),f=({loader:e})=>(e=>({Exception:t,PlainText:r})=>(n,a)=>{const o=e.Decryptor;let i;try{i=new o(n.instance,a.instance)}catch(e){throw t.safe(e)}return{get instance(){return i},unsafeInject(e){i&&(i.delete(),i=void 0),i=e},delete(){i&&(i.delete(),i=void 0)},decrypt(e,n){try{if(n)return void i.decrypt(e.instance,n.instance);const t=r();return i.decrypt(e.instance,t.instance),t}catch(e){throw t.safe(e)}},invariantNoiseBudget(e){try{return i.invariantNoiseBudget(e.instance)}catch(e){throw t.safe(e)}}}})(e.library),y=({loader:e})=>(e=>({Exception:t,ComprModeType:r,Modulus:n,SchemeType:a,ParmsIdType:o,Vector:i})=>(c=a.none)=>{let s=new(0,e.EncryptionParameters)(c);return{get instance(){return s},unsafeInject(e){s&&(s.delete(),s=void 0),s=e},delete(){s&&(s.delete(),s=void 0)},setPolyModulusDegree(e){try{s.setPolyModulusDegree(e)}catch(e){throw t.safe(e)}},setCoeffModulus(e){try{s.setCoeffModulus(e.instance)}catch(e){throw t.safe(e)}},setPlainModulus(e){try{s.setPlainModulus(e.instance)}catch(e){throw t.safe(e)}},get scheme(){return s.scheme()},get polyModulusDegree(){return s.polyModulusDegree()},get coeffModulus(){const e=i(),t=s.coeffModulus();e.unsafeInject(t),e.setType("Modulus");const r=e.toArray();return e.delete(),r},get plainModulus(){const e=s.plainModulus(),t=n(BigInt(0));return t.inject(e),t},get parmsId(){const e=o();return e.inject(s.parmsId()),e},save:(e=r.zstd)=>s.saveToString(e),saveArray(e=r.zstd){const t=i(),n=s.saveToArray(e);t.unsafeInject(n),t.setType("Uint8Array");const a=t.toArray();return t.delete(),a},load(e){try{s.loadFromString(e)}catch(e){throw t.safe(e)}},loadArray(e){try{s.loadFromArray(e)}catch(e){throw t.safe(e)}}}})(e.library),h=({loader:e})=>(e=>({Exception:t,MemoryPoolHandle:r,CipherText:n,Serializable:a})=>(o,i,c)=>{const s=e.Encryptor;let u=function(e,r,n){try{return n?new s(e.instance,r.instance,n.instance):new s(e.instance,r.instance)}catch(e){throw t.safe(e)}}(o,i,c);return{get instance(){return u},unsafeInject(e){u&&(u.delete(),u=void 0),u=e},delete(){u&&(u.delete(),u=void 0)},encrypt(e,a,o=r.global){try{if(a)return void u.encrypt(e.instance,a.instance,o);const t=n();return u.encrypt(e.instance,t.instance,o),t}catch(e){throw t.safe(e)}},encryptSerializable(e,n=r.global){try{const t=a(),r=u.encryptSerializable(e.instance,n);return t.unsafeInject(r),t}catch(e){throw t.safe(e)}},encryptSymmetric(e,a,o=r.global){try{if(a)return void u.encryptSymmetric(e.instance,a.instance,o);const t=n();return u.encryptSymmetric(e.instance,t.instance,o),t}catch(e){throw t.safe(e)}},encryptSymmetricSerializable(e,n=r.global){try{const t=a(),r=u.encryptSymmetricSerializable(e.instance,n);return t.unsafeInject(r),t}catch(e){throw t.safe(e)}},encryptZero(e,a=r.global){try{if(e)return void u.encryptZero(e.instance,a);const t=n();return u.encryptZero(t.instance,a),t}catch(e){throw t.safe(e)}},encryptZeroSerializable(e=r.global){try{const t=a(),r=u.encryptZeroSerializable(e);return t.unsafeInject(r),t}catch(e){throw t.safe(e)}}}})(e.library),p=({loader:e})=>(e=>({Exception:t,MemoryPoolHandle:r,CipherText:n,PlainText:a})=>o=>{const i=e.Evaluator;let c;try{c=new i(o.instance)}catch(e){throw t.safe(e)}return{get instance(){return c},unsafeInject(e){c&&(c.delete(),c=void 0),c=e},delete(){c&&(c.delete(),c=void 0)},negate(e,r){try{if(r)return void c.negate(e.instance,r.instance);const t=n();return c.negate(e.instance,t.instance),t}catch(e){throw t.safe(e)}},add(e,r,a){try{if(a)return void c.add(e.instance,r.instance,a.instance);const t=n();return c.add(e.instance,r.instance,t.instance),t}catch(e){throw t.safe(e)}},sub(e,r,a){try{if(a)return void c.sub(e.instance,r.instance,a.instance);const t=n();return c.sub(e.instance,r.instance,t.instance),t}catch(e){throw t.safe(e)}},multiply(e,a,o,i=r.global){try{if(o)return void c.multiply(e.instance,a.instance,o.instance,i);const t=n();return c.multiply(e.instance,a.instance,t.instance,i),t}catch(e){throw t.safe(e)}},square(e,a,o=r.global){try{if(a)return void c.square(e.instance,a.instance,o);const t=n();return c.square(e.instance,t.instance,o),t}catch(e){throw t.safe(e)}},relinearize(e,a,o,i=r.global){try{if(o)return void c.relinearize(e.instance,a.instance,o.instance,i);const t=n();return c.relinearize(e.instance,a.instance,t.instance,i),t}catch(e){throw t.safe(e)}},cipherModSwitchToNext(e,a,o=r.global){try{if(a)return void c.cipherModSwitchToNext(e.instance,a.instance,o);const t=n();return c.cipherModSwitchToNext(e.instance,t.instance,o),t}catch(e){throw t.safe(e)}},cipherModSwitchTo(e,a,o,i=r.global){try{if(o)return void c.cipherModSwitchTo(e.instance,a.instance,o.instance,i);const t=n();return c.cipherModSwitchTo(e.instance,a.instance,t.instance,i),t}catch(e){throw t.safe(e)}},plainModSwitchToNext(e,r){try{if(r)return void c.plainModSwitchToNext(e.instance,r.instance);const t=a();return c.plainModSwitchToNext(e.instance,t.instance),t}catch(e){throw t.safe(e)}},plainModSwitchTo(e,r,n){try{if(n)return void c.plainModSwitchTo(e.instance,r.instance,n.instance);const t=a();return c.plainModSwitchTo(e.instance,r.instance,t.instance),t}catch(e){throw t.safe(e)}},rescaleToNext(e,a,o=r.global){try{if(a)return void c.rescaleToNext(e.instance,a.instance,o);const t=n();return c.rescaleToNext(e.instance,t.instance,o),t}catch(e){throw t.safe(e)}},rescaleTo(e,a,o,i=r.global){try{if(o)return void c.rescaleTo(e.instance,a.instance,o.instance,i);const t=n();return c.rescaleTo(e.instance,a.instance,t.instance,i),t}catch(e){throw t.safe(e)}},modReduceToNext(e,a,o=r.global){try{if(a)return void c.modReduceToNext(e.instance,a.instance,o);const t=n();return c.modReduceToNext(e.instance,t.instance,o),t}catch(e){throw t.safe(e)}},modReduceTo(e,a,o,i=r.global){try{if(o)return void c.modReduceTo(e.instance,a.instance,o.instance,i);const t=n();return c.modReduceTo(e.instance,a.instance,t.instance,i),t}catch(e){throw t.safe(e)}},exponentiate(e,a,o,i,s=r.global){try{if(i)return void c.exponentiate(e.instance,a,o.instance,i.instance,s);const t=n();return c.exponentiate(e.instance,a,o.instance,t.instance,s),t}catch(e){throw t.safe(e)}},addPlain(e,a,o,i=r.global){try{if(o)return void c.addPlain(e.instance,a.instance,o.instance,i);const t=n();return c.addPlain(e.instance,a.instance,t.instance,i),t}catch(e){throw t.safe(e)}},subPlain(e,a,o,i=r.global){try{if(o)return void c.subPlain(e.instance,a.instance,o.instance,i);const t=n();return c.subPlain(e.instance,a.instance,t.instance,i),t}catch(e){throw t.safe(e)}},multiplyPlain(e,a,o,i=r.global){try{if(o)return void c.multiplyPlain(e.instance,a.instance,o.instance,i);const t=n();return c.multiplyPlain(e.instance,a.instance,t.instance,i),t}catch(e){throw t.safe(e)}},plainTransformToNtt(e,n,o,i=r.global){try{if(o)return void c.plainTransformToNtt(e.instance,n.instance,o.instance,i);const t=a();return c.plainTransformToNtt(e.instance,n.instance,t.instance,i),t}catch(e){throw t.safe(e)}},cipherTransformToNtt(e,r){try{if(r)return void c.cipherTransformToNtt(e.instance,r.instance);const t=n();return c.cipherTransformToNtt(e.instance,t.instance),t}catch(e){throw t.safe(e)}},cipherTransformFromNtt(e,r){try{if(r)return void c.cipherTransformFromNtt(e.instance,r.instance);const t=n();return c.cipherTransformFromNtt(e.instance,t.instance),t}catch(e){throw t.safe(e)}},applyGalois(e,a,o,i,s=r.global){try{if(i)return void c.applyGalois(e.instance,a,o.instance,i.instance,s);const t=n();return c.applyGalois(e.instance,a,o.instance,t.instance,s),t}catch(e){throw t.safe(e)}},rotateRows(e,a,o,i,s=r.global){try{if(i)return void c.rotateRows(e.instance,a,o.instance,i.instance,s);const t=n();return c.rotateRows(e.instance,a,o.instance,t.instance,s),t}catch(e){throw t.safe(e)}},rotateColumns(e,a,o,i=r.global){try{if(o)return void c.rotateColumns(e.instance,a.instance,o.instance,i);const t=n();return c.rotateColumns(e.instance,a.instance,t.instance,i),t}catch(e){throw t.safe(e)}},rotateVector(e,a,o,i,s=r.global){try{if(i)return void c.rotateVector(e.instance,a,o.instance,i.instance,s);const t=n();return c.rotateVector(e.instance,a,o.instance,t.instance,s),t}catch(e){throw t.safe(e)}},complexConjugate(e,a,o,i=r.global){try{if(o)return void c.complexConjugate(e.instance,a.instance,o.instance,i);const t=n();return c.complexConjugate(e.instance,a.instance,t.instance,i),t}catch(e){throw t.safe(e)}},sumElements(e,a,o,i,s=r.global){try{if(i)return void c.sumElements(e.instance,a.instance,o,i.instance,s);const t=n();return c.sumElements(e.instance,a.instance,o,t.instance,s),t}catch(e){throw t.safe(e)}},dotProduct(e,a,o,i,s,u,l=r.global){try{if(u)return c.multiply(e.instance,a.instance,u.instance,l),c.relinearize(u.instance,o.instance,u.instance,l),void c.sumElements(u.instance,i.instance,s,u.instance,l);const t=n();return c.multiply(e.instance,a.instance,t.instance,l),c.relinearize(t.instance,o.instance,t.instance,l),c.sumElements(t.instance,i.instance,s,t.instance,l),t}catch(e){throw t.safe(e)}},dotProductPlain(e,a,o,i,s,u=r.global){try{if(s)return c.multiplyPlain(e.instance,a.instance,s.instance,u),void c.sumElements(s.instance,o.instance,i,s.instance,u);const t=n();return c.multiplyPlain(e.instance,a.instance,t.instance,u),c.sumElements(t.instance,o.instance,i,t.instance,u),t}catch(e){throw t.safe(e)}}}})(e.library),m=({loader:e})=>(e=>()=>()=>{const t=e.getException;return{safe:e=>"number"==typeof e?new Error(t(e)):e instanceof Error?e:new Error(e||"Unknown Error!")}})(e.library),v=e=>({Exception:t,ComprModeType:r,Vector:n})=>()=>{const a=e.GaloisKeys;let o=new a;return{get instance(){return o},inject(e){o&&(o.delete(),o=void 0),o=new a(e),e.delete()},delete(){o&&(o.delete(),o=void 0)},get size(){return o.size()},getIndex(e){try{return o.getIndex(e)}catch(e){throw t.safe(e)}},hasKey(e){try{return o.hasKey(e)}catch(e){throw t.safe(e)}},save(e=r.zstd){try{return o.saveToString(e)}catch(e){throw t.safe(e)}},saveArray(e=r.zstd){const t=n(),a=o.saveToArray(e);t.unsafeInject(a),t.setType("Uint8Array");const i=t.toArray();return t.delete(),i},load(e,r){try{o.loadFromString(e.instance,r)}catch(e){throw t.safe(e)}},loadArray(e,r){try{o.loadFromArray(e.instance,r)}catch(e){throw t.safe(e)}},copy(e){try{o.copy(e.instance)}catch(e){throw t.safe(e)}},clone(){try{const a=o.clone(),i=v(e)({Exception:t,ComprModeType:r,Vector:n})();return i.inject(a),i}catch(e){throw t.safe(e)}},move(e){try{o.move(e.instance),e.delete()}catch(e){throw t.safe(e)}}}},w=({loader:e})=>{const t=e.library;return v(t)},g=({loader:e})=>(e=>({Exception:t,PublicKey:r,SecretKey:n,RelinKeys:a,GaloisKeys:o,Serializable:i})=>(c,s)=>{const u=e.KeyGenerator;let l=function(e,r){try{return r?new u(e.instance,r.instance):new u(e.instance)}catch(e){throw t.safe(e)}}(c,s);return{get instance(){return l},unsafeInject(e){l&&(l.delete(),l=void 0),l=e},delete(){l&&(l.delete(),l=void 0)},secretKey(){try{const e=n(),t=l.secretKey();return e.inject(t),e}catch(e){throw t.safe(e)}},createPublicKey(){try{const e=r();return l.createPublicKey(e.instance),e}catch(e){throw t.safe(e)}},createPublicKeySerializable(){try{const e=i(),t=l.createPublicKeySerializable();return e.unsafeInject(t),e}catch(e){throw t.safe(e)}},createRelinKeys(){try{const e=a();return l.createRelinKeys(e.instance),e}catch(e){throw t.safe(e)}},createRelinKeysSerializable(){try{const e=i(),t=l.createRelinKeysSerializable();return e.unsafeInject(t),e}catch(e){throw t.safe(e)}},createGaloisKeys(e=Int32Array.from([])){try{const t=o();return l.createGaloisKeys(e,t.instance),t}catch(e){throw t.safe(e)}},createGaloisKeysSerializable(e=Int32Array.from([])){try{const t=i(),r=l.createGaloisKeysSerializable(e);return t.unsafeInject(r),t}catch(e){throw t.safe(e)}}}})(e.library),T=({loader:e})=>(e=>()=>()=>{const t=e.MemoryPoolHandle.MemoryPoolHandleGlobal,r=e.MemoryPoolHandle.MemoryPoolHandleThreadLocal;return{get global(){return t()},get threadLocal(){return r()}}})(e.library),b=({loader:e})=>(e=>({Exception:t,ComprModeType:r,Vector:n})=>a=>{const o=e.Modulus;let i=function(e){try{const t=new o;return t.setValue(e.toString()),t}catch(e){throw t.safe(e)}}(a);return{get instance(){return i},inject(e){i&&(i.delete(),i=void 0),i=new o(e),e.delete()},delete(){i&&(i.delete(),i=void 0)},setValue(e){try{i.setValue(e.toString())}catch(e){throw t.safe(e)}},get value(){return BigInt(i.value())},get bitCount(){return i.bitCount()},get isZero(){return i.isZero()},get isPrime(){return i.isPrime()},save:(e=r.zstd)=>i.saveToString(e),saveArray(e=r.zstd){const t=n(),a=i.saveToArray(e);t.unsafeInject(a),t.setType("Uint8Array");const o=t.toArray();return t.delete(),o},load(e){try{i.loadFromString(e)}catch(e){throw t.safe(e)}},loadArray(e){try{i.loadFromArray(e)}catch(e){throw t.safe(e)}}}})(e.library),C=({loader:e})=>(e=>({Exception:t})=>()=>{const r=e.ParmsIdType;let n;return{get instance(){return n},inject(e){n&&(n.delete(),n=void 0),n=new r(e),e.delete()},delete(){n&&(n.delete(),n=void 0)},get values(){try{const e=n.values();return BigUint64Array.from(e)}catch(e){throw t.safe(e)}}}})(e.library),A=({loader:e})=>(e=>({Exception:t,Modulus:r,Vector:n})=>()=>{const a=e.PlainModulus.Batching,o=e.PlainModulus.BatchingVector;return{Batching(e,n){try{const t=r(BigInt(0));return t.inject(a(e,n)),t}catch(e){throw t.safe(e)}},BatchingVector(e,r){try{const t=n();t.from(r);const a=o(e,t.instance);return t.delete(),a}catch(e){throw t.safe(e)}}}})(e.library),P=e=>({Exception:t,ComprModeType:r,ParmsIdType:n,MemoryPoolHandle:a,Vector:o})=>({capacity:i,coeffCount:c,pool:s=a.global}={})=>{const u=e.Plaintext;let l=function({capacity:e,coeffCount:r,pool:n=a.global}={}){try{if(void 0===e&&void 0===r)return new u(n);if(void 0===e&&void 0!==r)return new u(r,n);if(void 0!==e&&void 0!==r)return new u(e,r,n);throw new Error("Must specify a (coeffCount), (coeffCount, capacity)")}catch(e){throw t.safe(e)}}({capacity:i,coeffCount:c,pool:s});return{get instance(){return l},unsafeInject(e){l&&(l.delete(),l=void 0),l=e},delete(){l&&(l.delete(),l=void 0)},reserve(e){try{return l.reserve(e)}catch(e){throw t.safe(e)}},shrinkToFit(){l.shrinkToFit()},release(){l.release()},resize(e){try{l.resize(e)}catch(e){throw t.safe(e)}},setZero(){l.setZero()},get isZero(){return l.isZero()},get capacity(){return l.capacity()},get coeffCount(){return l.coeffCount()},get significantCoeffCount(){return l.significantCoeffCount()},get nonzeroCoeffCount(){return l.nonzeroCoeffCount()},toPolynomial(){try{return l.toPolynomial()}catch(e){throw t.safe(e)}},get isNttForm(){return l.isNttForm()},get parmsId(){const e=n();return e.inject(l.parmsId()),e},get scale(){return l.scale()},setScale(e){l.setScale(e)},get pool(){return l.pool()},save:(e=r.zstd)=>l.saveToString(e),saveArray(e=r.zstd){const t=o(),n=l.saveToArray(e);t.unsafeInject(n),t.setType("Uint8Array");const a=t.toArray();return t.delete(),a},load(e,r){try{l.loadFromString(e.instance,r)}catch(e){throw t.safe(e)}},loadArray(e,r){try{l.loadFromArray(e.instance,r)}catch(e){throw t.safe(e)}},copy(e){try{l.copy(e.instance)}catch(e){throw t.safe(e)}},clone(){try{const i=l.clone(),c=P(e)({Exception:t,ComprModeType:r,ParmsIdType:n,MemoryPoolHandle:a,Vector:o})();return c.unsafeInject(i),c}catch(e){throw t.safe(e)}},move(e){try{l.move(e.instance),e.delete()}catch(e){throw t.safe(e)}}}},x=({loader:e})=>{const t=e.library;return P(t)},I=e=>({Exception:t,ComprModeType:r,Vector:n})=>()=>{const a=e.PublicKey;let o=new a;return{get instance(){return o},inject(e){o&&(o.delete(),o=void 0),o=new a(e),e.delete()},delete(){o&&(o.delete(),o=void 0)},save(e=r.zstd){try{return o.saveToString(e)}catch(e){throw t.safe(e)}},saveArray(e=r.zstd){const t=n(),a=o.saveToArray(e);t.unsafeInject(a),t.setType("Uint8Array");const i=t.toArray();return t.delete(),i},load(e,r){try{o.loadFromString(e.instance,r)}catch(e){throw t.safe(e)}},loadArray(e,r){try{o.loadFromArray(e.instance,r)}catch(e){throw t.safe(e)}},copy(e){try{o.copy(e.instance)}catch(e){throw t.safe(e)}},clone(){try{const a=o.clone(),i=I(e)({Exception:t,ComprModeType:r,Vector:n})();return i.inject(a),i}catch(e){throw t.safe(e)}},move(e){try{o.move(e.instance),e.delete()}catch(e){throw t.safe(e)}}}},S=({loader:e})=>{const t=e.library;return I(t)},E=e=>({Exception:t,ComprModeType:r,Vector:n})=>()=>{const a=e.RelinKeys;let o=new a;return{get instance(){return o},inject(e){o&&(o.delete(),o=void 0),o=new a(e),e.delete()},delete(){o&&(o.delete(),o=void 0)},get size(){return o.size()},getIndex(e){try{return o.getIndex(e)}catch(e){throw t.safe(e)}},hasKey(e){try{return o.hasKey(e)}catch(e){throw t.safe(e)}},save(e=r.zstd){try{return o.saveToString(e)}catch(e){throw t.safe(e)}},saveArray(e=r.zstd){const t=n(),a=o.saveToArray(e);t.unsafeInject(a),t.setType("Uint8Array");const i=t.toArray();return t.delete(),i},load(e,r){try{o.loadFromString(e.instance,r)}catch(e){throw t.safe(e)}},loadArray(e,r){try{o.loadFromArray(e.instance,r)}catch(e){throw t.safe(e)}},copy(e){try{o.copy(e.instance)}catch(e){throw t.safe(e)}},clone(){try{const a=o.clone(),i=E(e)({Exception:t,ComprModeType:r,Vector:n})();return i.inject(a),i}catch(e){throw t.safe(e)}},move(e){try{o.move(e.instance),e.delete()}catch(e){throw t.safe(e)}}}},V=({loader:e})=>{const t=e.library;return E(t)},M=({loader:e})=>(e=>()=>()=>{const t=e.SchemeType.none,r=e.SchemeType.bfv,n=e.SchemeType.ckks,a=e.SchemeType.bgv;return{get none(){return