@dstorage-tech/dstorage-sdk 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +24 -4
  2. package/dist/browser.d.mts +2 -189
  3. package/dist/browser.mjs +1774 -2130
  4. package/dist/errors.d.mts +0 -3
  5. package/dist/errors.d.ts +0 -3
  6. package/dist/errors.js +0 -5
  7. package/dist/errors.mjs +0 -5
  8. package/dist/index.d.mts +2 -189
  9. package/dist/index.d.ts +2 -189
  10. package/dist/index.js +1844 -2199
  11. package/dist/index.mjs +1823 -2175
  12. package/package.json +2 -1
  13. package/dist/KeypairEncryptionAdapter-AE75YC4W-AOWNSH2M.mjs +0 -9
  14. package/dist/KeypairEncryptionAdapter-AE75YC4W-BAVHRNNJ.mjs +0 -1
  15. package/dist/KeypairEncryptionAdapter-AE75YC4W-BEYO4RUO.mjs +0 -1
  16. package/dist/KeypairEncryptionAdapter-AE75YC4W-VAOH6AAL.mjs +0 -9
  17. package/dist/KeypairEncryptionAdapter-XUKCLRFU-6ERIZN2M.mjs +0 -1
  18. package/dist/MnemonicEncryptionAdapter-J6IE5OKA-6DFVUVD6.mjs +0 -1
  19. package/dist/MnemonicEncryptionAdapter-J6IE5OKA-O5AJPX42.mjs +0 -1
  20. package/dist/MnemonicEncryptionAdapter-J6IE5OKA-SI6TBLTQ.mjs +0 -9
  21. package/dist/MnemonicEncryptionAdapter-J6IE5OKA-WEPFOTSJ.mjs +0 -9
  22. package/dist/MnemonicEncryptionAdapter-RCHUETBP-ELAMJMMO.mjs +0 -1
  23. package/dist/PasswordEncryptionAdapter-CWOXUGR4-2YZ64B4A.mjs +0 -1
  24. package/dist/PasswordEncryptionAdapter-CWOXUGR4-DCEGC2NX.mjs +0 -1
  25. package/dist/PasswordEncryptionAdapter-CWOXUGR4-QEGGYPFJ.mjs +0 -13
  26. package/dist/PasswordEncryptionAdapter-CWOXUGR4-ZYUBUYUI.mjs +0 -13
  27. package/dist/PasswordEncryptionAdapter-ECHND672-XVBPHPPT.mjs +0 -1
  28. package/dist/chunk-4YMF57VY.mjs +0 -1
  29. package/dist/chunk-5MZ7FPPY.mjs +0 -1
  30. package/dist/chunk-5P4EW2YL.mjs +0 -1
  31. package/dist/chunk-5RW7SGA7.mjs +0 -1
  32. package/dist/chunk-62RSKZ6T.mjs +0 -118
  33. package/dist/chunk-BBJCQFWP.mjs +0 -275
  34. package/dist/chunk-EYF3263P.mjs +0 -2049
  35. package/dist/chunk-GUYENY5N.mjs +0 -1
  36. package/dist/chunk-L5QD6GHB.mjs +0 -101
  37. package/dist/chunk-PKHRAYFD.mjs +0 -1
  38. package/dist/chunk-PLAOCKSS.mjs +0 -101
  39. package/dist/chunk-QKA2DCR6.mjs +0 -118
  40. package/dist/chunk-RPSRFFXN.mjs +0 -275
  41. package/dist/chunk-TESUOXRJ.mjs +0 -1
  42. package/dist/chunk-TMLXCRJU.mjs +0 -1
  43. package/dist/chunk-TNRKN4LB.mjs +0 -1
  44. package/dist/chunk-TSZ37JDY.mjs +0 -2596
  45. package/dist/chunk-U3MS6KMF.mjs +0 -1
  46. package/dist/chunk-UBALMYIY.mjs +0 -2049
  47. package/dist/chunk-UOOF4V2Y.mjs +0 -1
  48. package/dist/chunk-Z2TH6U4C.mjs +0 -3
  49. package/dist/chunk-ZEPZ4QDD.mjs +0 -1
  50. package/dist/chunk-ZGUY5EIR.mjs +0 -1
  51. package/dist/contract-api-AO4RGPLT-4HRCMSCE.mjs +0 -279
  52. package/dist/contract-api-AO4RGPLT-ADH6ZDKC.mjs +0 -279
  53. package/dist/contract-api-AO4RGPLT-PAMIPEI3.mjs +0 -1
  54. package/dist/contract-api-AO4RGPLT-W3RSVP5A.mjs +0 -1
  55. package/dist/contract-api-AO4RGPLT-WENYDV6I.mjs +0 -1
  56. package/dist/contract-api-TJ7JPHZA-ZWP3EH7D.mjs +0 -279
  57. package/dist/dataregistry-simulator-E6RTGGWT-QGCYR3VF.mjs +0 -1
  58. package/dist/dist-655VYUPJ.mjs +0 -1
  59. package/dist/dist-MEZZWKP4.mjs +0 -1
  60. package/dist/dist-UD4WRMYJ.mjs +0 -65
  61. package/dist/esm5-AGBDHMNS.mjs +0 -1
  62. package/dist/in-memory-private-state-NGOP37V7-XFJFNFCQ.mjs +0 -1
@@ -1 +0,0 @@
1
- import{a as m}from"./chunk-PKHRAYFD.mjs";import{A as c,B as p,a as o,y as s}from"./chunk-UBALMYIY.mjs";var h=class n{constructor(e,t,r,i){this.publicKey=e,this.secretKey=t,this.context=r,this.variant=i,this.name=i}static fromPublicKey(e,t,r="mlkem768"){return new n(e,void 0,t,r)}static fromKeypair(e,t,r,i="mlkem768"){return new n(e,t,r,i)}static generateKeypair(e,t="mlkem768"){let{pk:r,sk:i}=s(t);return{adapter:new n(r,i,e,t),publicKey:r,secretKey:i}}static async fromMnemonic(e,t,r="mlkem768"){let{MnemonicEncryptionAdapter:i}=await import("./MnemonicEncryptionAdapter-J6IE5OKA-6DFVUVD6.mjs");return new i(e).intoKeypairEncryptionAdapter(t,r)}static async fromPassword(e,t,r,i="mlkem768",a){let{PasswordEncryptionAdapter:y}=await import("./PasswordEncryptionAdapter-CWOXUGR4-DCEGC2NX.mjs");return new y({password:e,salt:t,...a?{params:a}:{}}).intoKeypairEncryptionAdapter(r,i)}destroy(){this.secretKey?.fill(0),this.secretKey=void 0}async wrapDek(e){return c(e,this.publicKey,this.context,this.variant)}async unwrapDek(e){if(!this.secretKey)throw new o(m.KEYPAIR_MISSING_SECRET_KEY,`[dStorage] KeypairEncryptionAdapter(${this.variant}): cannot unwrapDek \u2014 no Secret Key is available. Use fromKeypair() or fromPassword() to create an adapter with a SK.`);return p(e,this.secretKey,this.context)}};export{h as a};
@@ -1,3 +0,0 @@
1
- var ct=function(r,t){return ct=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,o){e.__proto__=o}||function(e,o){for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])},ct(r,t)};function E(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");ct(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function Zt(r,t,e,o){function n(i){return i instanceof e?i:new e(function(u){u(i)})}return new(e||(e=Promise))(function(i,u){function f(l){try{c(o.next(l))}catch(s){u(s)}}function a(l){try{c(o.throw(l))}catch(s){u(s)}}function c(l){l.done?i(l.value):n(l.value).then(f,a)}c((o=o.apply(r,t||[])).next())})}function br(r,t){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,n,i,u=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return u.next=f(0),u.throw=f(1),u.return=f(2),typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function f(c){return function(l){return a([c,l])}}function a(c){if(o)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(e=0)),e;)try{if(o=1,n&&(i=c[0]&2?n.return:c[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,c[1])).done)return i;switch(n=0,i&&(c=[c[0]&2,i.value]),c[0]){case 0:case 1:i=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,n=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(i=e.trys,!(i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){e.label=c[1];break}if(c[0]===6&&e.label<i[1]){e.label=i[1],i=c;break}if(i&&e.label<i[2]){e.label=i[2],e.ops.push(c);break}i[2]&&e.ops.pop(),e.trys.pop();continue}c=t.call(r,e)}catch(l){c=[6,l],n=0}finally{o=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function P(r){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&r[t],o=0;if(e)return e.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&o>=r.length&&(r=void 0),{value:r&&r[o++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function A(r,t){var e=typeof Symbol=="function"&&r[Symbol.iterator];if(!e)return r;var o=e.call(r),n,i=[],u;try{for(;(t===void 0||t-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(f){u={error:f}}finally{try{n&&!n.done&&(e=o.return)&&e.call(o)}finally{if(u)throw u.error}}return i}function _(r,t,e){if(e||arguments.length===2)for(var o=0,n=t.length,i;o<n;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return r.concat(i||Array.prototype.slice.call(t))}function fr(r){return this instanceof fr?(this.v=r,this):new fr(r)}function Ht(r,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=e.apply(r,t||[]),n,i=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),f("next"),f("throw"),f("return",u),n[Symbol.asyncIterator]=function(){return this},n;function u(d){return function(x){return Promise.resolve(x).then(d,s)}}function f(d,x){o[d]&&(n[d]=function(b){return new Promise(function(g,S){i.push([d,b,g,S])>1||a(d,b)})},x&&(n[d]=x(n[d])))}function a(d,x){try{c(o[d](x))}catch(b){h(i[0][3],b)}}function c(d){d.value instanceof fr?Promise.resolve(d.value.v).then(l,s):h(i[0][2],d)}function l(d){a("next",d)}function s(d){a("throw",d)}function h(d,x){d(x),i.shift(),i.length&&a(i[0][0],i[0][1])}}function Xt(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=r[Symbol.asyncIterator],e;return t?t.call(r):(r=typeof P=="function"?P(r):r[Symbol.iterator](),e={},o("next"),o("throw"),o("return"),e[Symbol.asyncIterator]=function(){return this},e);function o(i){e[i]=r[i]&&function(u){return new Promise(function(f,a){u=r[i](u),n(f,a,u.done,u.value)})}}function n(i,u,f,a){Promise.resolve(a).then(function(c){i({value:c,done:f})},u)}}function y(r){return typeof r=="function"}function U(r){var t=function(o){Error.call(o),o.stack=new Error().stack},e=r(t);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var Or=U(function(r){return function(e){r(this),this.message=e?e.length+` errors occurred during unsubscription:
2
- `+e.map(function(o,n){return n+1+") "+o.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=e}});function L(r,t){if(r){var e=r.indexOf(t);0<=e&&r.splice(e,1)}}var j=(function(){function r(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return r.prototype.unsubscribe=function(){var t,e,o,n,i;if(!this.closed){this.closed=!0;var u=this._parentage;if(u)if(this._parentage=null,Array.isArray(u))try{for(var f=P(u),a=f.next();!a.done;a=f.next()){var c=a.value;c.remove(this)}}catch(b){t={error:b}}finally{try{a&&!a.done&&(e=f.return)&&e.call(f)}finally{if(t)throw t.error}}else u.remove(this);var l=this.initialTeardown;if(y(l))try{l()}catch(b){i=b instanceof Or?b.errors:[b]}var s=this._finalizers;if(s){this._finalizers=null;try{for(var h=P(s),d=h.next();!d.done;d=h.next()){var x=d.value;try{re(x)}catch(b){i=i??[],b instanceof Or?i=_(_([],A(i)),A(b.errors)):i.push(b)}}}catch(b){o={error:b}}finally{try{d&&!d.done&&(n=h.return)&&n.call(h)}finally{if(o)throw o.error}}}if(i)throw new Or(i)}},r.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)re(t);else{if(t instanceof r){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},r.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},r.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},r.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&L(e,t)},r.prototype.remove=function(t){var e=this._finalizers;e&&L(e,t),t instanceof r&&t._removeParent(this)},r.EMPTY=(function(){var t=new r;return t.closed=!0,t})(),r})();var mt=j.EMPTY;function Ur(r){return r instanceof j||r&&"closed"in r&&y(r.remove)&&y(r.add)&&y(r.unsubscribe)}function re(r){y(r)?r():r.unsubscribe()}var G={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var yr={setTimeout:function(r,t){for(var e=[],o=2;o<arguments.length;o++)e[o-2]=arguments[o];var n=yr.delegate;return n?.setTimeout?n.setTimeout.apply(n,_([r,t],A(e))):setTimeout.apply(void 0,_([r,t],A(e)))},clearTimeout:function(r){var t=yr.delegate;return(t?.clearTimeout||clearTimeout)(r)},delegate:void 0};function qr(r){yr.setTimeout(function(){var t=G.onUnhandledError;if(t)t(r);else throw r})}function O(){}var te=(function(){return pt("C",void 0,void 0)})();function ee(r){return pt("E",void 0,r)}function oe(r){return pt("N",r,void 0)}function pt(r,t,e){return{kind:r,value:t,error:e}}var ar=null;function gr(r){if(G.useDeprecatedSynchronousErrorHandling){var t=!ar;if(t&&(ar={errorThrown:!1,error:null}),r(),t){var e=ar,o=e.errorThrown,n=e.error;if(ar=null,o)throw n}}else r()}function ne(r){G.useDeprecatedSynchronousErrorHandling&&ar&&(ar.errorThrown=!0,ar.error=r)}var wr=(function(r){E(t,r);function t(e){var o=r.call(this)||this;return o.isStopped=!1,e?(o.destination=e,Ur(e)&&e.add(o)):o.destination=qe,o}return t.create=function(e,o,n){return new Z(e,o,n)},t.prototype.next=function(e){this.isStopped?st(oe(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?st(ee(e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?st(te,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})(j);var Ne=Function.prototype.bind;function lt(r,t){return Ne.call(r,t)}var We=(function(){function r(t){this.partialObserver=t}return r.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(o){Dr(o)}},r.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(o){Dr(o)}else Dr(t)},r.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){Dr(e)}},r})(),Z=(function(r){E(t,r);function t(e,o,n){var i=r.call(this)||this,u;if(y(e)||!e)u={next:e??void 0,error:o??void 0,complete:n??void 0};else{var f;i&&G.useDeprecatedNextContext?(f=Object.create(e),f.unsubscribe=function(){return i.unsubscribe()},u={next:e.next&&lt(e.next,f),error:e.error&&lt(e.error,f),complete:e.complete&&lt(e.complete,f)}):u=e}return i.destination=new We(u),i}return t})(wr);function Dr(r){G.useDeprecatedSynchronousErrorHandling?ne(r):qr(r)}function Ue(r){throw r}function st(r,t){var e=G.onStoppedNotification;e&&yr.setTimeout(function(){return e(r,t)})}var qe={closed:!0,next:O,error:Ue,complete:O};var cr=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function F(r){return r}function Ir(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return vt(r)}function vt(r){return r.length===0?F:r.length===1?r[0]:function(e){return r.reduce(function(o,n){return n(o)},e)}}var w=(function(){function r(t){t&&(this._subscribe=t)}return r.prototype.lift=function(t){var e=new r;return e.source=this,e.operator=t,e},r.prototype.subscribe=function(t,e,o){var n=this,i=Ye(t)?t:new Z(t,e,o);return gr(function(){var u=n,f=u.operator,a=u.source;i.add(f?f.call(i,a):a?n._subscribe(i):n._trySubscribe(i))}),i},r.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},r.prototype.forEach=function(t,e){var o=this;return e=ie(e),new e(function(n,i){var u=new Z({next:function(f){try{t(f)}catch(a){i(a),u.unsubscribe()}},error:i,complete:n});o.subscribe(u)})},r.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},r.prototype[cr]=function(){return this},r.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return vt(t)(this)},r.prototype.toPromise=function(t){var e=this;return t=ie(t),new t(function(o,n){var i;e.subscribe(function(u){return i=u},function(u){return n(u)},function(){return o(i)})})},r.create=function(t){return new r(t)},r})();function ie(r){var t;return(t=r??G.Promise)!==null&&t!==void 0?t:Promise}function De(r){return r&&y(r.next)&&y(r.error)&&y(r.complete)}function Ye(r){return r&&r instanceof wr||De(r)&&Ur(r)}function dt(r){return y(r?.lift)}function m(r){return function(t){if(dt(t))return t.lift(function(e){try{return r(e,this)}catch(o){this.error(o)}});throw new TypeError("Unable to lift unknown Observable type")}}function p(r,t,e,o,n){return new Fr(r,t,e,o,n)}var Fr=(function(r){E(t,r);function t(e,o,n,i,u,f){var a=r.call(this,e)||this;return a.onFinalize=u,a.shouldUnsubscribe=f,a._next=o?function(c){try{o(c)}catch(l){e.error(l)}}:r.prototype._next,a._error=i?function(c){try{i(c)}catch(l){e.error(l)}finally{this.unsubscribe()}}:r.prototype._error,a._complete=n?function(){try{n()}catch(c){e.error(c)}finally{this.unsubscribe()}}:r.prototype._complete,a}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var o=this.closed;r.prototype.unsubscribe.call(this),!o&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t})(wr);function ht(){return m(function(r,t){var e=null;r._refCount++;var o=p(t,void 0,void 0,void 0,function(){if(!r||r._refCount<=0||0<--r._refCount){e=null;return}var n=r._connection,i=e;e=null,n&&(!i||n===i)&&n.unsubscribe(),t.unsubscribe()});r.subscribe(o),o.closed||(e=r.connect())})}var mr=(function(r){E(t,r);function t(e,o){var n=r.call(this)||this;return n.source=e,n.subjectFactory=o,n._subject=null,n._refCount=0,n._connection=null,dt(e)&&(n.lift=e.lift),n}return t.prototype._subscribe=function(e){return this.getSubject().subscribe(e)},t.prototype.getSubject=function(){var e=this._subject;return(!e||e.isStopped)&&(this._subject=this.subjectFactory()),this._subject},t.prototype._teardown=function(){this._refCount=0;var e=this._connection;this._subject=this._connection=null,e?.unsubscribe()},t.prototype.connect=function(){var e=this,o=this._connection;if(!o){o=this._connection=new j;var n=this.getSubject();o.add(this.source.subscribe(p(n,void 0,function(){e._teardown(),n.complete()},function(i){e._teardown(),n.error(i)},function(){return e._teardown()}))),o.closed&&(this._connection=null,o=j.EMPTY)}return o},t.prototype.refCount=function(){return ht()(this)},t})(w);var xt={now:function(){return(xt.delegate||performance).now()},delegate:void 0};var H={schedule:function(r){var t=requestAnimationFrame,e=cancelAnimationFrame,o=H.delegate;o&&(t=o.requestAnimationFrame,e=o.cancelAnimationFrame);var n=t(function(i){e=void 0,r(i)});return new j(function(){return e?.(n)})},requestAnimationFrame:function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=H.delegate;return(e?.requestAnimationFrame||requestAnimationFrame).apply(void 0,_([],A(r)))},cancelAnimationFrame:function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=H.delegate;return(e?.cancelAnimationFrame||cancelAnimationFrame).apply(void 0,_([],A(r)))},delegate:void 0};function ze(r){return r?ue(r):Ge}function ue(r){return new w(function(t){var e=r||xt,o=e.now(),n=0,i=function(){t.closed||(n=H.requestAnimationFrame(function(u){n=0;var f=e.now();t.next({timestamp:r?f:u,elapsed:f-o}),i()}))};return i(),function(){n&&H.cancelAnimationFrame(n)}})}var Ge=ue();var bt=U(function(r){return function(){r(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}});var I=(function(r){E(t,r);function t(){var e=r.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return t.prototype.lift=function(e){var o=new fe(this,this);return o.operator=e,o},t.prototype._throwIfClosed=function(){if(this.closed)throw new bt},t.prototype.next=function(e){var o=this;gr(function(){var n,i;if(o._throwIfClosed(),!o.isStopped){o.currentObservers||(o.currentObservers=Array.from(o.observers));try{for(var u=P(o.currentObservers),f=u.next();!f.done;f=u.next()){var a=f.value;a.next(e)}}catch(c){n={error:c}}finally{try{f&&!f.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}}})},t.prototype.error=function(e){var o=this;gr(function(){if(o._throwIfClosed(),!o.isStopped){o.hasError=o.isStopped=!0,o.thrownError=e;for(var n=o.observers;n.length;)n.shift().error(e)}})},t.prototype.complete=function(){var e=this;gr(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var o=e.observers;o.length;)o.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(e){return this._throwIfClosed(),r.prototype._trySubscribe.call(this,e)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var o=this,n=this,i=n.hasError,u=n.isStopped,f=n.observers;return i||u?mt:(this.currentObservers=null,f.push(e),new j(function(){o.currentObservers=null,L(f,e)}))},t.prototype._checkFinalizedStatuses=function(e){var o=this,n=o.hasError,i=o.thrownError,u=o.isStopped;n?e.error(i):u&&e.complete()},t.prototype.asObservable=function(){var e=new w;return e.source=this,e},t.create=function(e,o){return new fe(e,o)},t})(w);var fe=(function(r){E(t,r);function t(e,o){var n=r.call(this)||this;return n.destination=e,n.source=o,n}return t.prototype.next=function(e){var o,n;(n=(o=this.destination)===null||o===void 0?void 0:o.next)===null||n===void 0||n.call(o,e)},t.prototype.error=function(e){var o,n;(n=(o=this.destination)===null||o===void 0?void 0:o.error)===null||n===void 0||n.call(o,e)},t.prototype.complete=function(){var e,o;(o=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||o===void 0||o.call(e)},t.prototype._subscribe=function(e){var o,n;return(n=(o=this.source)===null||o===void 0?void 0:o.subscribe(e))!==null&&n!==void 0?n:mt},t})(I);var yt=(function(r){E(t,r);function t(e){var o=r.call(this)||this;return o._value=e,o}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(e){var o=r.prototype._subscribe.call(this,e);return!o.closed&&e.next(this._value),o},t.prototype.getValue=function(){var e=this,o=e.hasError,n=e.thrownError,i=e._value;if(o)throw n;return this._throwIfClosed(),i},t.prototype.next=function(e){r.prototype.next.call(this,this._value=e)},t})(I);var pr={now:function(){return(pr.delegate||Date).now()},delegate:void 0};var Tr=(function(r){E(t,r);function t(e,o,n){e===void 0&&(e=1/0),o===void 0&&(o=1/0),n===void 0&&(n=pr);var i=r.call(this)||this;return i._bufferSize=e,i._windowTime=o,i._timestampProvider=n,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=o===1/0,i._bufferSize=Math.max(1,e),i._windowTime=Math.max(1,o),i}return t.prototype.next=function(e){var o=this,n=o.isStopped,i=o._buffer,u=o._infiniteTimeWindow,f=o._timestampProvider,a=o._windowTime;n||(i.push(e),!u&&i.push(f.now()+a)),this._trimBuffer(),r.prototype.next.call(this,e)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var o=this._innerSubscribe(e),n=this,i=n._infiniteTimeWindow,u=n._buffer,f=u.slice(),a=0;a<f.length&&!e.closed;a+=i?1:2)e.next(f[a]);return this._checkFinalizedStatuses(e),o},t.prototype._trimBuffer=function(){var e=this,o=e._bufferSize,n=e._timestampProvider,i=e._buffer,u=e._infiniteTimeWindow,f=(u?1:2)*o;if(o<1/0&&f<i.length&&i.splice(0,i.length-f),!u){for(var a=n.now(),c=0,l=1;l<i.length&&i[l]<=a;l+=2)c=l;c&&i.splice(0,c+1)}},t})(I);var jr=(function(r){E(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e._value=null,e._hasValue=!1,e._isComplete=!1,e}return t.prototype._checkFinalizedStatuses=function(e){var o=this,n=o.hasError,i=o._hasValue,u=o._value,f=o.thrownError,a=o.isStopped,c=o._isComplete;n?e.error(f):(a||c)&&(i&&e.next(u),e.complete())},t.prototype.next=function(e){this.isStopped||(this._value=e,this._hasValue=!0)},t.prototype.complete=function(){var e=this,o=e._hasValue,n=e._value,i=e._isComplete;i||(this._isComplete=!0,o&&r.prototype.next.call(this,n),r.prototype.complete.call(this))},t})(I);var ae=(function(r){E(t,r);function t(e,o){return r.call(this)||this}return t.prototype.schedule=function(e,o){return o===void 0&&(o=0),this},t})(j);var Pr={setInterval:function(r,t){for(var e=[],o=2;o<arguments.length;o++)e[o-2]=arguments[o];var n=Pr.delegate;return n?.setInterval?n.setInterval.apply(n,_([r,t],A(e))):setInterval.apply(void 0,_([r,t],A(e)))},clearInterval:function(r){var t=Pr.delegate;return(t?.clearInterval||clearInterval)(r)},delegate:void 0};var Q=(function(r){E(t,r);function t(e,o){var n=r.call(this,e,o)||this;return n.scheduler=e,n.work=o,n.pending=!1,n}return t.prototype.schedule=function(e,o){var n;if(o===void 0&&(o=0),this.closed)return this;this.state=e;var i=this.id,u=this.scheduler;return i!=null&&(this.id=this.recycleAsyncId(u,i,o)),this.pending=!0,this.delay=o,this.id=(n=this.id)!==null&&n!==void 0?n:this.requestAsyncId(u,this.id,o),this},t.prototype.requestAsyncId=function(e,o,n){return n===void 0&&(n=0),Pr.setInterval(e.flush.bind(e,this),n)},t.prototype.recycleAsyncId=function(e,o,n){if(n===void 0&&(n=0),n!=null&&this.delay===n&&this.pending===!1)return o;o!=null&&Pr.clearInterval(o)},t.prototype.execute=function(e,o){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var n=this._execute(e,o);if(n)return n;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,o){var n=!1,i;try{this.work(e)}catch(u){n=!0,i=u||new Error("Scheduled action threw falsy error")}if(n)return this.unsubscribe(),i},t.prototype.unsubscribe=function(){if(!this.closed){var e=this,o=e.id,n=e.scheduler,i=n.actions;this.work=this.state=this.scheduler=null,this.pending=!1,L(i,this),o!=null&&(this.id=this.recycleAsyncId(n,o,null)),this.delay=null,r.prototype.unsubscribe.call(this)}},t})(ae);var Ke=1,gt,wt={};function ce(r){return r in wt?(delete wt[r],!0):!1}var St={setImmediate:function(r){var t=Ke++;return wt[t]=!0,gt||(gt=Promise.resolve()),gt.then(function(){return ce(t)&&r()}),t},clearImmediate:function(r){ce(r)}};var Qe=St.setImmediate,Be=St.clearImmediate,Cr={setImmediate:function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=Cr.delegate;return(e?.setImmediate||Qe).apply(void 0,_([],A(r)))},clearImmediate:function(r){var t=Cr.delegate;return(t?.clearImmediate||Be)(r)},delegate:void 0};var me=(function(r){E(t,r);function t(e,o){var n=r.call(this,e,o)||this;return n.scheduler=e,n.work=o,n}return t.prototype.requestAsyncId=function(e,o,n){return n===void 0&&(n=0),n!==null&&n>0?r.prototype.requestAsyncId.call(this,e,o,n):(e.actions.push(this),e._scheduled||(e._scheduled=Cr.setImmediate(e.flush.bind(e,void 0))))},t.prototype.recycleAsyncId=function(e,o,n){var i;if(n===void 0&&(n=0),n!=null?n>0:this.delay>0)return r.prototype.recycleAsyncId.call(this,e,o,n);var u=e.actions;o!=null&&((i=u[u.length-1])===null||i===void 0?void 0:i.id)!==o&&(Cr.clearImmediate(o),e._scheduled===o&&(e._scheduled=void 0))},t})(Q);var Yr=(function(){function r(t,e){e===void 0&&(e=r.now),this.schedulerActionCtor=t,this.now=e}return r.prototype.schedule=function(t,e,o){return e===void 0&&(e=0),new this.schedulerActionCtor(this,t).schedule(o,e)},r.now=pr.now,r})();var B=(function(r){E(t,r);function t(e,o){o===void 0&&(o=Yr.now);var n=r.call(this,e,o)||this;return n.actions=[],n._active=!1,n}return t.prototype.flush=function(e){var o=this.actions;if(this._active){o.push(e);return}var n;this._active=!0;do if(n=e.execute(e.state,e.delay))break;while(e=o.shift());if(this._active=!1,n){for(;e=o.shift();)e.unsubscribe();throw n}},t})(Yr);var pe=(function(r){E(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t.prototype.flush=function(e){this._active=!0;var o=this._scheduled;this._scheduled=void 0;var n=this.actions,i;e=e||n.shift();do if(i=e.execute(e.state,e.delay))break;while((e=n[0])&&e.id===o&&n.shift());if(this._active=!1,i){for(;(e=n[0])&&e.id===o&&n.shift();)e.unsubscribe();throw i}},t})(B);var le=new pe(me),$e=le;var C=new B(Q),Rr=C;var se=(function(r){E(t,r);function t(e,o){var n=r.call(this,e,o)||this;return n.scheduler=e,n.work=o,n}return t.prototype.schedule=function(e,o){return o===void 0&&(o=0),o>0?r.prototype.schedule.call(this,e,o):(this.delay=o,this.state=e,this.scheduler.flush(this),this)},t.prototype.execute=function(e,o){return o>0||this.closed?r.prototype.execute.call(this,e,o):this._execute(e,o)},t.prototype.requestAsyncId=function(e,o,n){return n===void 0&&(n=0),n!=null&&n>0||n==null&&this.delay>0?r.prototype.requestAsyncId.call(this,e,o,n):(e.flush(this),0)},t})(Q);var ve=(function(r){E(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t})(B);var de=new ve(se),Je=de;var he=(function(r){E(t,r);function t(e,o){var n=r.call(this,e,o)||this;return n.scheduler=e,n.work=o,n}return t.prototype.requestAsyncId=function(e,o,n){return n===void 0&&(n=0),n!==null&&n>0?r.prototype.requestAsyncId.call(this,e,o,n):(e.actions.push(this),e._scheduled||(e._scheduled=H.requestAnimationFrame(function(){return e.flush(void 0)})))},t.prototype.recycleAsyncId=function(e,o,n){var i;if(n===void 0&&(n=0),n!=null?n>0:this.delay>0)return r.prototype.recycleAsyncId.call(this,e,o,n);var u=e.actions;o!=null&&o===e._scheduled&&((i=u[u.length-1])===null||i===void 0?void 0:i.id)!==o&&(H.cancelAnimationFrame(o),e._scheduled=void 0)},t})(Q);var xe=(function(r){E(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t.prototype.flush=function(e){this._active=!0;var o;e?o=e.id:(o=this._scheduled,this._scheduled=void 0);var n=this.actions,i;e=e||n.shift();do if(i=e.execute(e.state,e.delay))break;while((e=n[0])&&e.id===o&&n.shift());if(this._active=!1,i){for(;(e=n[0])&&e.id===o&&n.shift();)e.unsubscribe();throw i}},t})(B);var be=new xe(he),Ze=be;var He=(function(r){E(t,r);function t(e,o){e===void 0&&(e=ye),o===void 0&&(o=1/0);var n=r.call(this,e,function(){return n.frame})||this;return n.maxFrames=o,n.frame=0,n.index=-1,n}return t.prototype.flush=function(){for(var e=this,o=e.actions,n=e.maxFrames,i,u;(u=o[0])&&u.delay<=n&&(o.shift(),this.frame=u.delay,!(i=u.execute(u.state,u.delay))););if(i){for(;u=o.shift();)u.unsubscribe();throw i}},t.frameTimeFactor=10,t})(B);var ye=(function(r){E(t,r);function t(e,o,n){n===void 0&&(n=e.index+=1);var i=r.call(this,e,o)||this;return i.scheduler=e,i.work=o,i.index=n,i.active=!0,i.index=e.index=n,i}return t.prototype.schedule=function(e,o){if(o===void 0&&(o=0),Number.isFinite(o)){if(!this.id)return r.prototype.schedule.call(this,e,o);this.active=!1;var n=new t(this.scheduler,this.work);return this.add(n),n.schedule(e,o)}else return j.EMPTY},t.prototype.requestAsyncId=function(e,o,n){n===void 0&&(n=0),this.delay=e.frame+n;var i=e.actions;return i.push(this),i.sort(t.sortActions),1},t.prototype.recycleAsyncId=function(e,o,n){n===void 0&&(n=0)},t.prototype._execute=function(e,o){if(this.active===!0)return r.prototype._execute.call(this,e,o)},t.sortActions=function(e,o){return e.delay===o.delay?e.index===o.index?0:e.index>o.index?1:-1:e.delay>o.delay?1:-1},t})(Q);var M=new w(function(r){return r.complete()});function Xe(r){return r?ro(r):M}function ro(r){return new w(function(t){return r.schedule(function(){return t.complete()})})}function tr(r){return r&&y(r.schedule)}function At(r){return r[r.length-1]}function $(r){return y(At(r))?r.pop():void 0}function k(r){return tr(At(r))?r.pop():void 0}function zr(r,t){return typeof At(r)=="number"?r.pop():t}var Sr=(function(r){return r&&typeof r.length=="number"&&typeof r!="function"});function Gr(r){return y(r?.then)}function Kr(r){return y(r[cr])}function Qr(r){return Symbol.asyncIterator&&y(r?.[Symbol.asyncIterator])}function Br(r){return new TypeError("You provided "+(r!==null&&typeof r=="object"?"an invalid object":"'"+r+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function to(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var $r=to();function Jr(r){return y(r?.[$r])}function Zr(r){return Ht(this,arguments,function(){var e,o,n,i;return br(this,function(u){switch(u.label){case 0:e=r.getReader(),u.label=1;case 1:u.trys.push([1,,9,10]),u.label=2;case 2:return[4,fr(e.read())];case 3:return o=u.sent(),n=o.value,i=o.done,i?[4,fr(void 0)]:[3,5];case 4:return[2,u.sent()];case 5:return[4,fr(n)];case 6:return[4,u.sent()];case 7:return u.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function Hr(r){return y(r?.getReader)}function v(r){if(r instanceof w)return r;if(r!=null){if(Kr(r))return eo(r);if(Sr(r))return oo(r);if(Gr(r))return no(r);if(Qr(r))return ge(r);if(Jr(r))return io(r);if(Hr(r))return uo(r)}throw Br(r)}function eo(r){return new w(function(t){var e=r[cr]();if(y(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function oo(r){return new w(function(t){for(var e=0;e<r.length&&!t.closed;e++)t.next(r[e]);t.complete()})}function no(r){return new w(function(t){r.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,qr)})}function io(r){return new w(function(t){var e,o;try{for(var n=P(r),i=n.next();!i.done;i=n.next()){var u=i.value;if(t.next(u),t.closed)return}}catch(f){e={error:f}}finally{try{i&&!i.done&&(o=n.return)&&o.call(n)}finally{if(e)throw e.error}}t.complete()})}function ge(r){return new w(function(t){fo(r,t).catch(function(e){return t.error(e)})})}function uo(r){return ge(Zr(r))}function fo(r,t){var e,o,n,i;return Zt(this,void 0,void 0,function(){var u,f;return br(this,function(a){switch(a.label){case 0:a.trys.push([0,5,6,11]),e=Xt(r),a.label=1;case 1:return[4,e.next()];case 2:if(o=a.sent(),!!o.done)return[3,4];if(u=o.value,t.next(u),t.closed)return[2];a.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return f=a.sent(),n={error:f},[3,11];case 6:return a.trys.push([6,,9,10]),o&&!o.done&&(i=e.return)?[4,i.call(e)]:[3,8];case 7:a.sent(),a.label=8;case 8:return[3,10];case 9:if(n)throw n.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function R(r,t,e,o,n){o===void 0&&(o=0),n===void 0&&(n=!1);var i=t.schedule(function(){e(),n?r.add(this.schedule(null,o)):this.unsubscribe()},o);if(r.add(i),!n)return i}function lr(r,t){return t===void 0&&(t=0),m(function(e,o){e.subscribe(p(o,function(n){return R(o,r,function(){return o.next(n)},t)},function(){return R(o,r,function(){return o.complete()},t)},function(n){return R(o,r,function(){return o.error(n)},t)}))})}function sr(r,t){return t===void 0&&(t=0),m(function(e,o){o.add(r.schedule(function(){return e.subscribe(o)},t))})}function we(r,t){return v(r).pipe(sr(t),lr(t))}function Se(r,t){return v(r).pipe(sr(t),lr(t))}function Ae(r,t){return new w(function(e){var o=0;return t.schedule(function(){o===r.length?e.complete():(e.next(r[o++]),e.closed||this.schedule())})})}function Xr(r,t){return new w(function(e){var o;return R(e,t,function(){o=r[$r](),R(e,t,function(){var n,i,u;try{n=o.next(),i=n.value,u=n.done}catch(f){e.error(f);return}u?e.complete():e.next(i)},0,!0)}),function(){return y(o?.return)&&o.return()}})}function rt(r,t){if(!r)throw new Error("Iterable cannot be null");return new w(function(e){R(e,t,function(){var o=r[Symbol.asyncIterator]();R(e,t,function(){o.next().then(function(n){n.done?e.complete():e.next(n.value)})},0,!0)})})}function _e(r,t){return rt(Zr(r),t)}function _t(r,t){if(r!=null){if(Kr(r))return we(r,t);if(Sr(r))return Ae(r,t);if(Gr(r))return Se(r,t);if(Qr(r))return rt(r,t);if(Jr(r))return Xr(r,t);if(Hr(r))return _e(r,t)}throw Br(r)}function N(r,t){return t?_t(r,t):v(r)}function Mr(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=k(r);return N(r,e)}function Et(r,t){var e=y(r)?r:function(){return r},o=function(n){return n.error(e())};return new w(t?function(n){return t.schedule(o,0,n)}:o)}var Ot;(function(r){r.NEXT="N",r.ERROR="E",r.COMPLETE="C"})(Ot||(Ot={}));var kr=(function(){function r(t,e,o){this.kind=t,this.value=e,this.error=o,this.hasValue=t==="N"}return r.prototype.observe=function(t){return It(this,t)},r.prototype.do=function(t,e,o){var n=this,i=n.kind,u=n.value,f=n.error;return i==="N"?t?.(u):i==="E"?e?.(f):o?.()},r.prototype.accept=function(t,e,o){var n;return y((n=t)===null||n===void 0?void 0:n.next)?this.observe(t):this.do(t,e,o)},r.prototype.toObservable=function(){var t=this,e=t.kind,o=t.value,n=t.error,i=e==="N"?Mr(o):e==="E"?Et(function(){return n}):e==="C"?M:0;if(!i)throw new TypeError("Unexpected notification kind "+e);return i},r.createNext=function(t){return new r("N",t)},r.createError=function(t){return new r("E",void 0,t)},r.createComplete=function(){return r.completeNotification},r.completeNotification=new r("C"),r})();function It(r,t){var e,o,n,i=r,u=i.kind,f=i.value,a=i.error;if(typeof u!="string")throw new TypeError('Invalid notification, missing "kind"');u==="N"?(e=t.next)===null||e===void 0||e.call(t,f):u==="E"?(o=t.error)===null||o===void 0||o.call(t,a):(n=t.complete)===null||n===void 0||n.call(t)}function ao(r){return!!r&&(r instanceof w||y(r.lift)&&y(r.subscribe))}var D=U(function(r){return function(){r(this),this.name="EmptyError",this.message="no elements in sequence"}});function co(r,t){var e=typeof t=="object";return new Promise(function(o,n){var i=!1,u;r.subscribe({next:function(f){u=f,i=!0},error:n,complete:function(){i?o(u):e?o(t.defaultValue):n(new D)}})})}function mo(r,t){var e=typeof t=="object";return new Promise(function(o,n){var i=new Z({next:function(u){o(u),i.unsubscribe()},error:n,complete:function(){e?o(t.defaultValue):n(new D)}});r.subscribe(i)})}var tt=U(function(r){return function(){r(this),this.name="ArgumentOutOfRangeError",this.message="argument out of range"}});var Ft=U(function(r){return function(e){r(this),this.name="NotFoundError",this.message=e}});var Tt=U(function(r){return function(e){r(this),this.name="SequenceError",this.message=e}});function Ar(r){return r instanceof Date&&!isNaN(r)}var Ee=U(function(r){return function(e){e===void 0&&(e=null),r(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=e}});function jt(r,t){var e=Ar(r)?{first:r}:typeof r=="number"?{each:r}:r,o=e.first,n=e.each,i=e.with,u=i===void 0?po:i,f=e.scheduler,a=f===void 0?t??C:f,c=e.meta,l=c===void 0?null:c;if(o==null&&n==null)throw new TypeError("No timeout provided.");return m(function(s,h){var d,x,b=null,g=0,S=function(T){x=R(h,a,function(){try{d.unsubscribe(),v(u({meta:l,lastValue:b,seen:g})).subscribe(h)}catch(W){h.error(W)}},T)};d=s.subscribe(p(h,function(T){x?.unsubscribe(),g++,h.next(b=T),n>0&&S(n)},void 0,void 0,function(){x?.closed||x?.unsubscribe(),b=null})),!g&&S(o!=null?typeof o=="number"?o:+o-a.now():n)})}function po(r){throw new Ee(r)}function Y(r,t){return m(function(e,o){var n=0;e.subscribe(p(o,function(i){o.next(r.call(t,i,n++))}))})}var lo=Array.isArray;function so(r,t){return lo(t)?r.apply(void 0,_([],A(t))):r(t)}function q(r){return Y(function(t){return so(r,t)})}function _r(r,t,e,o){if(e)if(tr(e))o=e;else return function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];return _r(r,t,o).apply(this,n).pipe(q(e))};return o?function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];return _r(r,t).apply(this,n).pipe(sr(o),lr(o))}:function(){for(var n=this,i=[],u=0;u<arguments.length;u++)i[u]=arguments[u];var f=new jr,a=!0;return new w(function(c){var l=f.subscribe(c);if(a){a=!1;var s=!1,h=!1;t.apply(n,_(_([],A(i)),[function(){for(var d=[],x=0;x<arguments.length;x++)d[x]=arguments[x];if(r){var b=d.shift();if(b!=null){f.error(b);return}}f.next(1<d.length?d:d[0]),h=!0,s&&f.complete()}])),h&&f.complete(),s=!0}return l})}}function vo(r,t,e){return _r(!1,r,t,e)}function ho(r,t,e){return _r(!0,r,t,e)}var xo=Array.isArray,bo=Object.getPrototypeOf,yo=Object.prototype,go=Object.keys;function et(r){if(r.length===1){var t=r[0];if(xo(t))return{args:t,keys:null};if(wo(t)){var e=go(t);return{args:e.map(function(o){return t[o]}),keys:e}}}return{args:r,keys:null}}function wo(r){return r&&typeof r=="object"&&bo(r)===yo}function ot(r,t){return r.reduce(function(e,o,n){return e[o]=t[n],e},{})}function Pt(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=k(r),o=$(r),n=et(r),i=n.args,u=n.keys;if(i.length===0)return N([],e);var f=new w(Ct(i,e,u?function(a){return ot(u,a)}:F));return o?f.pipe(q(o)):f}function Ct(r,t,e){return e===void 0&&(e=F),function(o){Oe(t,function(){for(var n=r.length,i=new Array(n),u=n,f=n,a=function(l){Oe(t,function(){var s=N(r[l],t),h=!1;s.subscribe(p(o,function(d){i[l]=d,h||(h=!0,f--),f||o.next(e(i.slice()))},function(){--u||o.complete()}))},o)},c=0;c<n;c++)a(c)},o)}}function Oe(r,t,e){r?R(e,r,t):t()}function Er(r,t,e,o,n,i,u,f){var a=[],c=0,l=0,s=!1,h=function(){s&&!a.length&&!c&&t.complete()},d=function(b){return c<o?x(b):a.push(b)},x=function(b){i&&t.next(b),c++;var g=!1;v(e(b,l++)).subscribe(p(t,function(S){n?.(S),i?d(S):t.next(S)},function(){g=!0},void 0,function(){if(g)try{c--;for(var S=function(){var T=a.shift();u?R(t,u,function(){return x(T)}):x(T)};a.length&&c<o;)S();h()}catch(T){t.error(T)}}))};return r.subscribe(p(t,d,function(){s=!0,h()})),function(){f?.()}}function V(r,t,e){return e===void 0&&(e=1/0),y(t)?V(function(o,n){return Y(function(i,u){return t(o,i,n,u)})(v(r(o,n)))},e):(typeof t=="number"&&(e=t),m(function(o,n){return Er(o,n,r,e)}))}function vr(r){return r===void 0&&(r=1/0),V(F,r)}function Vr(){return vr(1)}function er(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return Vr()(N(r,k(r)))}function dr(r){return new w(function(t){v(r()).subscribe(t)})}var So={connector:function(){return new I},resetOnDisconnect:!0};function Ao(r,t){t===void 0&&(t=So);var e=null,o=t.connector,n=t.resetOnDisconnect,i=n===void 0?!0:n,u=o(),f=new w(function(a){return u.subscribe(a)});return f.connect=function(){return(!e||e.closed)&&(e=dr(function(){return r}).subscribe(u),i&&e.add(function(){return u=o()})),e},f}function _o(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=$(r),o=et(r),n=o.args,i=o.keys,u=new w(function(f){var a=n.length;if(!a){f.complete();return}for(var c=new Array(a),l=a,s=a,h=function(x){var b=!1;v(n[x]).subscribe(p(f,function(g){b||(b=!0,s--),c[x]=g},function(){return l--},void 0,function(){(!l||!b)&&(s||f.next(i?ot(i,c):c),f.complete())}))},d=0;d<a;d++)h(d)});return e?u.pipe(q(e)):u}var Eo=["addListener","removeListener"],Oo=["addEventListener","removeEventListener"],Io=["on","off"];function Rt(r,t,e,o){if(y(e)&&(o=e,e=void 0),o)return Rt(r,t,e).pipe(q(o));var n=A(jo(r)?Oo.map(function(f){return function(a){return r[f](t,a,e)}}):Fo(r)?Eo.map(Ie(r,t)):To(r)?Io.map(Ie(r,t)):[],2),i=n[0],u=n[1];if(!i&&Sr(r))return V(function(f){return Rt(f,t,e)})(v(r));if(!i)throw new TypeError("Invalid event target");return new w(function(f){var a=function(){for(var c=[],l=0;l<arguments.length;l++)c[l]=arguments[l];return f.next(1<c.length?c:c[0])};return i(a),function(){return u(a)}})}function Ie(r,t){return function(e){return function(o){return r[e](t,o)}}}function Fo(r){return y(r.addListener)&&y(r.removeListener)}function To(r){return y(r.on)&&y(r.off)}function jo(r){return y(r.addEventListener)&&y(r.removeEventListener)}function Fe(r,t,e){return e?Fe(r,t).pipe(q(e)):new w(function(o){var n=function(){for(var u=[],f=0;f<arguments.length;f++)u[f]=arguments[f];return o.next(u.length===1?u[0]:u)},i=r(n);return y(t)?function(){return t(n,i)}:void 0})}function Po(r,t,e,o,n){var i,u,f,a;arguments.length===1?(i=r,a=i.initialState,t=i.condition,e=i.iterate,u=i.resultSelector,f=u===void 0?F:u,n=i.scheduler):(a=r,!o||tr(o)?(f=F,n=o):f=o);function c(){var l;return br(this,function(s){switch(s.label){case 0:l=a,s.label=1;case 1:return!t||t(l)?[4,f(l)]:[3,4];case 2:s.sent(),s.label=3;case 3:return l=e(l),[3,1];case 4:return[2]}})}return dr(n?function(){return Xr(c(),n)}:c)}function Co(r,t,e){return dr(function(){return r()?t:e})}function z(r,t,e){r===void 0&&(r=0),e===void 0&&(e=Rr);var o=-1;return t!=null&&(tr(t)?e=t:o=t),new w(function(n){var i=Ar(r)?+r-e.now():r;i<0&&(i=0);var u=0;return e.schedule(function(){n.closed||(n.next(u++),0<=o?this.schedule(void 0,o):n.complete())},i)})}function Mt(r,t){return r===void 0&&(r=0),t===void 0&&(t=C),r<0&&(r=0),z(r,r,t)}function Ro(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=k(r),o=zr(r,1/0),n=r;return n.length?n.length===1?v(n[0]):vr(o)(N(n,e)):M}var Te=new w(O);function Mo(){return Te}var ko=Array.isArray;function J(r){return r.length===1&&ko(r[0])?r[0]:r}function kt(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=J(r);return new w(function(o){var n=0,i=function(){if(n<e.length){var u=void 0;try{u=v(e[n++])}catch{i();return}var f=new Fr(o,void 0,O,O);u.subscribe(f),f.add(i)}else o.complete()};i()})}function Vo(r,t){return N(Object.entries(r),t)}function je(r,t){return function(e,o){return!r.call(t,e,o)}}function K(r,t){return m(function(e,o){var n=0;e.subscribe(p(o,function(i){return r.call(t,i,n++)&&o.next(i)}))})}function Lo(r,t,e){return[K(t,e)(v(r)),K(je(t,e))(v(r))]}function No(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return r=J(r),r.length===1?v(r[0]):new w(Vt(r))}function Vt(r){return function(t){for(var e=[],o=function(i){e.push(v(r[i]).subscribe(p(t,function(u){if(e){for(var f=0;f<e.length;f++)f!==i&&e[f].unsubscribe();e=null}t.next(u)})))},n=0;e&&!t.closed&&n<r.length;n++)o(n)}}function Wo(r,t,e){if(t==null&&(t=r,r=0),t<=0)return M;var o=t+r;return new w(e?function(n){var i=r;return e.schedule(function(){i<o?(n.next(i++),this.schedule()):n.complete()})}:function(n){for(var i=r;i<o&&!n.closed;)n.next(i++);n.complete()})}function Uo(r,t){return new w(function(e){var o=r(),n=t(o),i=n?v(n):M;return i.subscribe(e),function(){o&&o.unsubscribe()}})}function Lr(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=$(r),o=J(r);return o.length?new w(function(n){var i=o.map(function(){return[]}),u=o.map(function(){return!1});n.add(function(){i=u=null});for(var f=function(c){v(o[c]).subscribe(p(n,function(l){if(i[c].push(l),i.every(function(h){return h.length})){var s=i.map(function(h){return h.shift()});n.next(e?e.apply(void 0,_([],A(s))):s),i.some(function(h,d){return!h.length&&u[d]})&&n.complete()}},function(){u[c]=!0,!i[c].length&&n.complete()}))},a=0;!n.closed&&a<o.length;a++)f(a);return function(){i=u=null}}):M}function Lt(r){return m(function(t,e){var o=!1,n=null,i=null,u=!1,f=function(){if(i?.unsubscribe(),i=null,o){o=!1;var c=n;n=null,e.next(c)}u&&e.complete()},a=function(){i=null,u&&e.complete()};t.subscribe(p(e,function(c){o=!0,n=c,i||v(r(c)).subscribe(i=p(e,f,a))},function(){u=!0,(!o||!i||i.closed)&&e.complete()}))})}function qo(r,t){return t===void 0&&(t=C),Lt(function(){return z(r,t)})}function Do(r){return m(function(t,e){var o=[];return t.subscribe(p(e,function(n){return o.push(n)},function(){e.next(o),e.complete()})),v(r).subscribe(p(e,function(){var n=o;o=[],e.next(n)},O)),function(){o=null}})}function Yo(r,t){return t===void 0&&(t=null),t=t??r,m(function(e,o){var n=[],i=0;e.subscribe(p(o,function(u){var f,a,c,l,s=null;i++%t===0&&n.push([]);try{for(var h=P(n),d=h.next();!d.done;d=h.next()){var x=d.value;x.push(u),r<=x.length&&(s=s??[],s.push(x))}}catch(S){f={error:S}}finally{try{d&&!d.done&&(a=h.return)&&a.call(h)}finally{if(f)throw f.error}}if(s)try{for(var b=P(s),g=b.next();!g.done;g=b.next()){var x=g.value;L(n,x),o.next(x)}}catch(S){c={error:S}}finally{try{g&&!g.done&&(l=b.return)&&l.call(b)}finally{if(c)throw c.error}}},function(){var u,f;try{for(var a=P(n),c=a.next();!c.done;c=a.next()){var l=c.value;o.next(l)}}catch(s){u={error:s}}finally{try{c&&!c.done&&(f=a.return)&&f.call(a)}finally{if(u)throw u.error}}o.complete()},void 0,function(){n=null}))})}function zo(r){for(var t,e,o=[],n=1;n<arguments.length;n++)o[n-1]=arguments[n];var i=(t=k(o))!==null&&t!==void 0?t:C,u=(e=o[0])!==null&&e!==void 0?e:null,f=o[1]||1/0;return m(function(a,c){var l=[],s=!1,h=function(b){var g=b.buffer,S=b.subs;S.unsubscribe(),L(l,b),c.next(g),s&&d()},d=function(){if(l){var b=new j;c.add(b);var g=[],S={buffer:g,subs:b};l.push(S),R(b,i,function(){return h(S)},r)}};u!==null&&u>=0?R(c,i,d,u,!0):s=!0,d();var x=p(c,function(b){var g,S,T=l.slice();try{for(var W=P(T),rr=W.next();!rr.done;rr=W.next()){var ir=rr.value,ur=ir.buffer;ur.push(b),f<=ur.length&&h(ir)}}catch(Le){g={error:Le}}finally{try{rr&&!rr.done&&(S=W.return)&&S.call(W)}finally{if(g)throw g.error}}},function(){for(;l?.length;)c.next(l.shift().buffer);x?.unsubscribe(),c.complete(),c.unsubscribe()},void 0,function(){return l=null});a.subscribe(x)})}function Go(r,t){return m(function(e,o){var n=[];v(r).subscribe(p(o,function(i){var u=[];n.push(u);var f=new j,a=function(){L(n,u),o.next(u),f.unsubscribe()};f.add(v(t(i)).subscribe(p(o,a,O)))},O)),e.subscribe(p(o,function(i){var u,f;try{for(var a=P(n),c=a.next();!c.done;c=a.next()){var l=c.value;l.push(i)}}catch(s){u={error:s}}finally{try{c&&!c.done&&(f=a.return)&&f.call(a)}finally{if(u)throw u.error}}},function(){for(;n.length>0;)o.next(n.shift());o.complete()}))})}function Ko(r){return m(function(t,e){var o=null,n=null,i=function(){n?.unsubscribe();var u=o;o=[],u&&e.next(u),v(r()).subscribe(n=p(e,i,O))};i(),t.subscribe(p(e,function(u){return o?.push(u)},function(){o&&e.next(o),e.complete()},void 0,function(){return o=n=null}))})}function Pe(r){return m(function(t,e){var o=null,n=!1,i;o=t.subscribe(p(e,void 0,void 0,function(u){i=v(r(u,Pe(r)(t))),o?(o.unsubscribe(),o=null,i.subscribe(e)):n=!0})),n&&(o.unsubscribe(),o=null,i.subscribe(e))})}function nt(r,t,e,o,n){return function(i,u){var f=e,a=t,c=0;i.subscribe(p(u,function(l){var s=c++;a=f?r(a,l,s):(f=!0,l),o&&u.next(a)},n&&(function(){f&&u.next(a),u.complete()})))}}function X(r,t){return m(nt(r,t,arguments.length>=2,!1,!0))}var Qo=function(r,t){return r.push(t),r};function Nt(){return m(function(r,t){X(Qo,[])(r).subscribe(t)})}function it(r,t){return Ir(Nt(),V(function(e){return r(e)}),t?q(t):F)}function Wt(r){return it(Pt,r)}var Bo=Wt;function Ut(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=$(r);return e?Ir(Ut.apply(void 0,_([],A(r))),q(e)):m(function(o,n){Ct(_([o],A(J(r))))(n)})}function $o(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return Ut.apply(void 0,_([],A(r)))}function ut(r,t){return y(t)?V(r,t,1):V(r,1)}function Jo(r,t){return y(t)?ut(function(){return r},t):ut(function(){return r})}function Ce(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=k(r);return m(function(o,n){Vr()(N(_([o],A(r)),e)).subscribe(n)})}function Zo(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return Ce.apply(void 0,_([],A(r)))}function Re(r){return new w(function(t){return r.subscribe(t)})}var Ho={connector:function(){return new I}};function Nr(r,t){t===void 0&&(t=Ho);var e=t.connector;return m(function(o,n){var i=e();v(r(Re(i))).subscribe(n),n.add(o.subscribe(i))})}function Xo(r){return X(function(t,e,o){return!r||r(e,o)?t+1:t},0)}function rn(r){return m(function(t,e){var o=!1,n=null,i=null,u=function(){if(i?.unsubscribe(),i=null,o){o=!1;var f=n;n=null,e.next(f)}};t.subscribe(p(e,function(f){i?.unsubscribe(),o=!0,n=f,i=p(e,u,O),v(r(f)).subscribe(i)},function(){u(),e.complete()},void 0,function(){n=i=null}))})}function tn(r,t){return t===void 0&&(t=C),m(function(e,o){var n=null,i=null,u=null,f=function(){if(n){n.unsubscribe(),n=null;var c=i;i=null,o.next(c)}};function a(){var c=u+r,l=t.now();if(l<c){n=this.schedule(void 0,c-l),o.add(n);return}f()}e.subscribe(p(o,function(c){i=c,u=t.now(),n||(n=t.schedule(a,r),o.add(n))},function(){f(),o.complete()},void 0,function(){i=n=null}))})}function hr(r){return m(function(t,e){var o=!1;t.subscribe(p(e,function(n){o=!0,e.next(n)},function(){o||e.next(r),e.complete()}))})}function or(r){return r<=0?function(){return M}:m(function(t,e){var o=0;t.subscribe(p(e,function(n){++o<=r&&(e.next(n),r<=o&&e.complete())}))})}function qt(){return m(function(r,t){r.subscribe(p(t,O))})}function Dt(r){return Y(function(){return r})}function ft(r,t){return t?function(e){return er(t.pipe(or(1),qt()),e.pipe(ft(r)))}:V(function(e,o){return v(r(e,o)).pipe(or(1),Dt(e))})}function en(r,t){t===void 0&&(t=C);var e=z(r,t);return ft(function(){return e})}function on(){return m(function(r,t){r.subscribe(p(t,function(e){return It(e,t)}))})}function nn(r,t){return m(function(e,o){var n=new Set;e.subscribe(p(o,function(i){var u=r?r(i):i;n.has(u)||(n.add(u),o.next(i))})),t&&v(t).subscribe(p(o,function(){return n.clear()},O))})}function Yt(r,t){return t===void 0&&(t=F),r=r??un,m(function(e,o){var n,i=!0;e.subscribe(p(o,function(u){var f=t(u);(i||!r(n,f))&&(i=!1,n=f,o.next(u))}))})}function un(r,t){return r===t}function fn(r,t){return Yt(function(e,o){return t?t(e[r],o[r]):e[r]===o[r]})}function xr(r){return r===void 0&&(r=an),m(function(t,e){var o=!1;t.subscribe(p(e,function(n){o=!0,e.next(n)},function(){return o?e.complete():e.error(r())}))})}function an(){return new D}function cn(r,t){if(r<0)throw new tt;var e=arguments.length>=2;return function(o){return o.pipe(K(function(n,i){return i===r}),or(1),e?hr(t):xr(function(){return new tt}))}}function mn(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return function(e){return er(e,Mr.apply(void 0,_([],A(r))))}}function pn(r,t){return m(function(e,o){var n=0;e.subscribe(p(o,function(i){r.call(t,i,n++,e)||(o.next(!1),o.complete())},function(){o.next(!0),o.complete()}))})}function at(r,t){return t?function(e){return e.pipe(at(function(o,n){return v(r(o,n)).pipe(Y(function(i,u){return t(o,i,n,u)}))}))}:m(function(e,o){var n=0,i=null,u=!1;e.subscribe(p(o,function(f){i||(i=p(o,void 0,function(){i=null,u&&o.complete()}),v(r(f,n++)).subscribe(i))},function(){u=!0,!i&&o.complete()}))})}function zt(){return at(F)}var ln=zt;function sn(r,t,e){return t===void 0&&(t=1/0),t=(t||0)<1?1/0:t,m(function(o,n){return Er(o,n,r,t,void 0,!0,e)})}function vn(r){return m(function(t,e){try{t.subscribe(e)}finally{e.add(r)}})}function dn(r,t){return m(Gt(r,t,"value"))}function Gt(r,t,e){var o=e==="index";return function(n,i){var u=0;n.subscribe(p(i,function(f){var a=u++;r.call(t,f,a,n)&&(i.next(o?a:f),i.complete())},function(){i.next(o?-1:void 0),i.complete()}))}}function hn(r,t){return m(Gt(r,t,"index"))}function xn(r,t){var e=arguments.length>=2;return function(o){return o.pipe(r?K(function(n,i){return r(n,i,o)}):F,or(1),e?hr(t):xr(function(){return new D}))}}function bn(r,t,e,o){return m(function(n,i){var u;!t||typeof t=="function"?u=t:(e=t.duration,u=t.element,o=t.connector);var f=new Map,a=function(x){f.forEach(x),x(i)},c=function(x){return a(function(b){return b.error(x)})},l=0,s=!1,h=new Fr(i,function(x){try{var b=r(x),g=f.get(b);if(!g){f.set(b,g=o?o():new I);var S=d(b,g);if(i.next(S),e){var T=p(g,function(){g.complete(),T?.unsubscribe()},void 0,void 0,function(){return f.delete(b)});h.add(v(e(S)).subscribe(T))}}g.next(u?u(x):x)}catch(W){c(W)}},function(){return a(function(x){return x.complete()})},c,function(){return f.clear()},function(){return s=!0,l===0});n.subscribe(h);function d(x,b){var g=new w(function(S){l++;var T=b.subscribe(S);return function(){T.unsubscribe(),--l===0&&s&&h.unsubscribe()}});return g.key=x,g}})}function yn(){return m(function(r,t){r.subscribe(p(t,function(){t.next(!1),t.complete()},function(){t.next(!0),t.complete()}))})}function Kt(r){return r<=0?function(){return M}:m(function(t,e){var o=[];t.subscribe(p(e,function(n){o.push(n),r<o.length&&o.shift()},function(){var n,i;try{for(var u=P(o),f=u.next();!f.done;f=u.next()){var a=f.value;e.next(a)}}catch(c){n={error:c}}finally{try{f&&!f.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}e.complete()},void 0,function(){o=null}))})}function gn(r,t){var e=arguments.length>=2;return function(o){return o.pipe(r?K(function(n,i){return r(n,i,o)}):F,Kt(1),e?hr(t):xr(function(){return new D}))}}function wn(){return m(function(r,t){r.subscribe(p(t,function(e){t.next(kr.createNext(e))},function(){t.next(kr.createComplete()),t.complete()},function(e){t.next(kr.createError(e)),t.complete()}))})}function Sn(r){return X(y(r)?function(t,e){return r(t,e)>0?t:e}:function(t,e){return t>e?t:e})}var An=V;function _n(r,t,e){return e===void 0&&(e=1/0),y(t)?V(function(){return r},t,e):(typeof t=="number"&&(e=t),V(function(){return r},e))}function En(r,t,e){return e===void 0&&(e=1/0),m(function(o,n){var i=t;return Er(o,n,function(u,f){return r(i,u,f)},e,function(u){i=u},!1,void 0,function(){return i=null})})}function Me(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=k(r),o=zr(r,1/0);return m(function(n,i){vr(o)(N(_([n],A(r)),e)).subscribe(i)})}function On(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return Me.apply(void 0,_([],A(r)))}function In(r){return X(y(r)?function(t,e){return r(t,e)<0?t:e}:function(t,e){return t<e?t:e})}function Wr(r,t){var e=y(r)?r:function(){return r};return y(t)?Nr(t,{connector:e}):function(o){return new mr(o,e)}}function Fn(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=J(r);return function(o){return kt.apply(void 0,_([o],A(e)))}}function Tn(){return m(function(r,t){var e,o=!1;r.subscribe(p(t,function(n){var i=e;e=n,o&&t.next([i,n]),o=!0}))})}function jn(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=r.length;if(e===0)throw new Error("list of properties cannot be empty.");return Y(function(o){for(var n=o,i=0;i<e;i++){var u=n?.[r[i]];if(typeof u<"u")n=u;else return}return n})}function Pn(r){return r?function(t){return Nr(r)(t)}:function(t){return Wr(new I)(t)}}function Cn(r){return function(t){var e=new yt(r);return new mr(t,function(){return e})}}function Rn(){return function(r){var t=new jr;return new mr(r,function(){return t})}}function Mn(r,t,e,o){e&&!y(e)&&(o=e);var n=y(e)?e:void 0;return function(i){return Wr(new Tr(r,t,o),n)(i)}}function kn(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return r.length?m(function(e,o){Vt(_([e],A(r)))(o)}):F}function Vn(r){var t,e=1/0,o;return r!=null&&(typeof r=="object"?(t=r.count,e=t===void 0?1/0:t,o=r.delay):e=r),e<=0?function(){return M}:m(function(n,i){var u=0,f,a=function(){if(f?.unsubscribe(),f=null,o!=null){var l=typeof o=="number"?z(o):v(o(u)),s=p(i,function(){s.unsubscribe(),c()});l.subscribe(s)}else c()},c=function(){var l=!1;f=n.subscribe(p(i,void 0,function(){++u<e?f?a():l=!0:i.complete()})),l&&a()};c()})}function Ln(r){return m(function(t,e){var o,n=!1,i,u=!1,f=!1,a=function(){return f&&u&&(e.complete(),!0)},c=function(){return i||(i=new I,v(r(i)).subscribe(p(e,function(){o?l():n=!0},function(){u=!0,a()}))),i},l=function(){f=!1,o=t.subscribe(p(e,void 0,function(){f=!0,!a()&&c().next()})),n&&(o.unsubscribe(),o=null,n=!1,l())};l()})}function Nn(r){r===void 0&&(r=1/0);var t;r&&typeof r=="object"?t=r:t={count:r};var e=t.count,o=e===void 0?1/0:e,n=t.delay,i=t.resetOnSuccess,u=i===void 0?!1:i;return o<=0?F:m(function(f,a){var c=0,l,s=function(){var h=!1;l=f.subscribe(p(a,function(d){u&&(c=0),a.next(d)},void 0,function(d){if(c++<o){var x=function(){l?(l.unsubscribe(),l=null,s()):h=!0};if(n!=null){var b=typeof n=="number"?z(n):v(n(d,c)),g=p(a,function(){g.unsubscribe(),x()},function(){a.complete()});b.subscribe(g)}else x()}else a.error(d)})),h&&(l.unsubscribe(),l=null,s())};s()})}function Wn(r){return m(function(t,e){var o,n=!1,i,u=function(){o=t.subscribe(p(e,void 0,void 0,function(f){i||(i=new I,v(r(i)).subscribe(p(e,function(){return o?u():n=!0}))),i&&i.next(f)})),n&&(o.unsubscribe(),o=null,n=!1,u())};u()})}function Qt(r){return m(function(t,e){var o=!1,n=null;t.subscribe(p(e,function(i){o=!0,n=i})),v(r).subscribe(p(e,function(){if(o){o=!1;var i=n;n=null,e.next(i)}},O))})}function Un(r,t){return t===void 0&&(t=C),Qt(Mt(r,t))}function qn(r,t){return m(nt(r,t,arguments.length>=2,!0))}function Dn(r,t){return t===void 0&&(t=function(e,o){return e===o}),m(function(e,o){var n=ke(),i=ke(),u=function(a){o.next(a),o.complete()},f=function(a,c){var l=p(o,function(s){var h=c.buffer,d=c.complete;h.length===0?d?u(!1):a.buffer.push(s):!t(s,h.shift())&&u(!1)},function(){a.complete=!0;var s=c.complete,h=c.buffer;s&&u(h.length===0),l?.unsubscribe()});return l};e.subscribe(f(n,i)),v(r).subscribe(f(i,n))})}function ke(){return{buffer:[],complete:!1}}function $t(r){r===void 0&&(r={});var t=r.connector,e=t===void 0?function(){return new I}:t,o=r.resetOnError,n=o===void 0?!0:o,i=r.resetOnComplete,u=i===void 0?!0:i,f=r.resetOnRefCountZero,a=f===void 0?!0:f;return function(c){var l,s,h,d=0,x=!1,b=!1,g=function(){s?.unsubscribe(),s=void 0},S=function(){g(),l=h=void 0,x=b=!1},T=function(){var W=l;S(),W?.unsubscribe()};return m(function(W,rr){d++,!b&&!x&&g();var ir=h=h??e();rr.add(function(){d--,d===0&&!b&&!x&&(s=Bt(T,a))}),ir.subscribe(rr),!l&&d>0&&(l=new Z({next:function(ur){return ir.next(ur)},error:function(ur){b=!0,g(),s=Bt(S,n,ur),ir.error(ur)},complete:function(){x=!0,g(),s=Bt(S,u),ir.complete()}}),v(W).subscribe(l))})(c)}}function Bt(r,t){for(var e=[],o=2;o<arguments.length;o++)e[o-2]=arguments[o];if(t===!0){r();return}if(t!==!1){var n=new Z({next:function(){n.unsubscribe(),r()}});return v(t.apply(void 0,_([],A(e)))).subscribe(n)}}function Yn(r,t,e){var o,n,i,u,f=!1;return r&&typeof r=="object"?(o=r.bufferSize,u=o===void 0?1/0:o,n=r.windowTime,t=n===void 0?1/0:n,i=r.refCount,f=i===void 0?!1:i,e=r.scheduler):u=r??1/0,$t({connector:function(){return new Tr(u,t,e)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:f})}function zn(r){return m(function(t,e){var o=!1,n,i=!1,u=0;t.subscribe(p(e,function(f){i=!0,(!r||r(f,u++,t))&&(o&&e.error(new Tt("Too many matching values")),o=!0,n=f)},function(){o?(e.next(n),e.complete()):e.error(i?new Ft("No matching values"):new D)}))})}function Gn(r){return K(function(t,e){return r<=e})}function Kn(r){return r<=0?F:m(function(t,e){var o=new Array(r),n=0;return t.subscribe(p(e,function(i){var u=n++;if(u<r)o[u]=i;else{var f=u%r,a=o[f];o[f]=i,e.next(a)}})),function(){o=null}})}function Qn(r){return m(function(t,e){var o=!1,n=p(e,function(){n?.unsubscribe(),o=!0},O);v(r).subscribe(n),t.subscribe(p(e,function(i){return o&&e.next(i)}))})}function Bn(r){return m(function(t,e){var o=!1,n=0;t.subscribe(p(e,function(i){return(o||(o=!r(i,n++)))&&e.next(i)}))})}function $n(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=k(r);return m(function(o,n){(e?er(r,o,e):er(r,o)).subscribe(n)})}function nr(r,t){return m(function(e,o){var n=null,i=0,u=!1,f=function(){return u&&!n&&o.complete()};e.subscribe(p(o,function(a){n?.unsubscribe();var c=0,l=i++;v(r(a,l)).subscribe(n=p(o,function(s){return o.next(t?t(a,s,l,c++):s)},function(){n=null,f()}))},function(){u=!0,f()}))})}function Jn(){return nr(F)}function Zn(r,t){return y(t)?nr(function(){return r},t):nr(function(){return r})}function Hn(r,t){return m(function(e,o){var n=t;return nr(function(i,u){return r(n,i,u)},function(i,u){return n=u,u})(e).subscribe(o),function(){n=null}})}function Xn(r){return m(function(t,e){v(r).subscribe(p(e,function(){return e.complete()},O)),!e.closed&&t.subscribe(e)})}function ri(r,t){return t===void 0&&(t=!1),m(function(e,o){var n=0;e.subscribe(p(o,function(i){var u=r(i,n++);(u||t)&&o.next(i),!u&&o.complete()}))})}function ti(r,t,e){var o=y(r)||t||e?{next:r,error:t,complete:e}:r;return o?m(function(n,i){var u;(u=o.subscribe)===null||u===void 0||u.call(o);var f=!0;n.subscribe(p(i,function(a){var c;(c=o.next)===null||c===void 0||c.call(o,a),i.next(a)},function(){var a;f=!1,(a=o.complete)===null||a===void 0||a.call(o),i.complete()},function(a){var c;f=!1,(c=o.error)===null||c===void 0||c.call(o,a),i.error(a)},function(){var a,c;f&&((a=o.unsubscribe)===null||a===void 0||a.call(o)),(c=o.finalize)===null||c===void 0||c.call(o)}))}):F}function Jt(r,t){return m(function(e,o){var n=t??{},i=n.leading,u=i===void 0?!0:i,f=n.trailing,a=f===void 0?!1:f,c=!1,l=null,s=null,h=!1,d=function(){s?.unsubscribe(),s=null,a&&(g(),h&&o.complete())},x=function(){s=null,h&&o.complete()},b=function(S){return s=v(r(S)).subscribe(p(o,d,x))},g=function(){if(c){c=!1;var S=l;l=null,o.next(S),!h&&b(S)}};e.subscribe(p(o,function(S){c=!0,l=S,!(s&&!s.closed)&&(u?g():b(S))},function(){h=!0,!(a&&c&&s&&!s.closed)&&o.complete()}))})}function ei(r,t,e){t===void 0&&(t=C);var o=z(r,t);return Jt(function(){return o},e)}function oi(r){return r===void 0&&(r=C),m(function(t,e){var o=r.now();t.subscribe(p(e,function(n){var i=r.now(),u=i-o;o=i,e.next(new ni(n,u))}))})}var ni=(function(){function r(t,e){this.value=t,this.interval=e}return r})();function ii(r,t,e){var o,n,i;if(e=e??Rr,Ar(r)?o=r:typeof r=="number"&&(n=r),t)i=function(){return t};else throw new TypeError("No observable provided to switch to");if(o==null&&n==null)throw new TypeError("No timeout provided.");return jt({first:o,each:n,scheduler:e,with:i})}function ui(r){return r===void 0&&(r=pr),Y(function(t){return{value:t,timestamp:r.now()}})}function fi(r){return m(function(t,e){var o=new I;e.next(o.asObservable());var n=function(i){o.error(i),e.error(i)};return t.subscribe(p(e,function(i){return o?.next(i)},function(){o.complete(),e.complete()},n)),v(r).subscribe(p(e,function(){o.complete(),e.next(o=new I)},O,n)),function(){o?.unsubscribe(),o=null}})}function ai(r,t){t===void 0&&(t=0);var e=t>0?t:r;return m(function(o,n){var i=[new I],u=[],f=0;n.next(i[0].asObservable()),o.subscribe(p(n,function(a){var c,l;try{for(var s=P(i),h=s.next();!h.done;h=s.next()){var d=h.value;d.next(a)}}catch(g){c={error:g}}finally{try{h&&!h.done&&(l=s.return)&&l.call(s)}finally{if(c)throw c.error}}var x=f-r+1;if(x>=0&&x%e===0&&i.shift().complete(),++f%e===0){var b=new I;i.push(b),n.next(b.asObservable())}},function(){for(;i.length>0;)i.shift().complete();n.complete()},function(a){for(;i.length>0;)i.shift().error(a);n.error(a)},function(){u=null,i=null}))})}function ci(r){for(var t,e,o=[],n=1;n<arguments.length;n++)o[n-1]=arguments[n];var i=(t=k(o))!==null&&t!==void 0?t:C,u=(e=o[0])!==null&&e!==void 0?e:null,f=o[1]||1/0;return m(function(a,c){var l=[],s=!1,h=function(g){var S=g.window,T=g.subs;S.complete(),T.unsubscribe(),L(l,g),s&&d()},d=function(){if(l){var g=new j;c.add(g);var S=new I,T={window:S,subs:g,seen:0};l.push(T),c.next(S.asObservable()),R(g,i,function(){return h(T)},r)}};u!==null&&u>=0?R(c,i,d,u,!0):s=!0,d();var x=function(g){return l.slice().forEach(g)},b=function(g){x(function(S){var T=S.window;return g(T)}),g(c),c.unsubscribe()};return a.subscribe(p(c,function(g){x(function(S){S.window.next(g),f<=++S.seen&&h(S)})},function(){return b(function(g){return g.complete()})},function(g){return b(function(S){return S.error(g)})})),function(){l=null}})}function mi(r,t){return m(function(e,o){var n=[],i=function(u){for(;0<n.length;)n.shift().error(u);o.error(u)};v(r).subscribe(p(o,function(u){var f=new I;n.push(f);var a=new j,c=function(){L(n,f),f.complete(),a.unsubscribe()},l;try{l=v(t(u))}catch(s){i(s);return}o.next(f.asObservable()),a.add(l.subscribe(p(o,c,O,i)))},O)),e.subscribe(p(o,function(u){var f,a,c=n.slice();try{for(var l=P(c),s=l.next();!s.done;s=l.next()){var h=s.value;h.next(u)}}catch(d){f={error:d}}finally{try{s&&!s.done&&(a=l.return)&&a.call(l)}finally{if(f)throw f.error}}},function(){for(;0<n.length;)n.shift().complete();o.complete()},i,function(){for(;0<n.length;)n.shift().unsubscribe()}))})}function pi(r){return m(function(t,e){var o,n,i=function(f){o.error(f),e.error(f)},u=function(){n?.unsubscribe(),o?.complete(),o=new I,e.next(o.asObservable());var f;try{f=v(r())}catch(a){i(a);return}f.subscribe(n=p(e,u,u,i))};u(),t.subscribe(p(e,function(f){return o.next(f)},function(){o.complete(),e.complete()},i,function(){n?.unsubscribe(),o=null}))})}function li(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=$(r);return m(function(o,n){for(var i=r.length,u=new Array(i),f=r.map(function(){return!1}),a=!1,c=function(s){v(r[s]).subscribe(p(n,function(h){u[s]=h,!a&&!f[s]&&(f[s]=!0,(a=f.every(F))&&(f=null))},O))},l=0;l<i;l++)c(l);o.subscribe(p(n,function(s){if(a){var h=_([s],A(u));n.next(e?e.apply(void 0,_([],A(h))):h)}}))})}function si(r){return it(Lr,r)}function Ve(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return m(function(e,o){Lr.apply(void 0,_([e],A(r))).subscribe(o)})}function vi(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return Ve.apply(void 0,_([],A(r)))}export{Or as a,j as b,G as c,O as d,wr as e,cr as f,F as g,Ir as h,w as i,ht as j,mr as k,ze as l,bt as m,I as n,yt as o,Tr as p,jr as q,Yr as r,le as s,$e as t,C as u,Rr as v,de as w,Je as x,be as y,Ze as z,He as A,ye as B,M as C,Xe as D,lr as E,sr as F,_t as G,N as H,Mr as I,Et as J,Ot as K,kr as L,ao as M,D as N,co as O,mo as P,tt as Q,Ft as R,Tt as S,Ee as T,jt as U,Y as V,vo as W,ho as X,Pt as Y,V as Z,vr as _,Vr as $,er as aa,dr as ba,Ao as ca,_o as da,Rt as ea,Fe as fa,Po as ga,Co as ha,z as ia,Mt as ja,Ro as ka,Te as la,Mo as ma,kt as na,Vo as oa,K as pa,Lo as qa,No as ra,Wo as sa,Uo as ta,Lr as ua,Lt as va,qo as wa,Do as xa,Yo as ya,zo as za,Go as Aa,Ko as Ba,Pe as Ca,X as Da,Nt as Ea,Wt as Fa,Bo as Ga,$o as Ha,ut as Ia,Jo as Ja,Zo as Ka,Nr as La,Xo as Ma,rn as Na,tn as Oa,hr as Pa,or as Qa,qt as Ra,Dt as Sa,ft as Ta,en as Ua,on as Va,nn as Wa,Yt as Xa,fn as Ya,xr as Za,cn as _a,mn as $a,pn as ab,at as bb,zt as cb,ln as db,sn as eb,vn as fb,dn as gb,hn as hb,xn as ib,bn as jb,yn as kb,Kt as lb,gn as mb,wn as nb,Sn as ob,An as pb,_n as qb,En as rb,On as sb,In as tb,Wr as ub,Fn as vb,Tn as wb,jn as xb,Pn as yb,Cn as zb,Rn as Ab,Mn as Bb,kn as Cb,Vn as Db,Ln as Eb,Nn as Fb,Wn as Gb,Qt as Hb,Un as Ib,qn as Jb,Dn as Kb,$t as Lb,Yn as Mb,zn as Nb,Gn as Ob,Kn as Pb,Qn as Qb,Bn as Rb,$n as Sb,nr as Tb,Jn as Ub,Zn as Vb,Hn as Wb,Xn as Xb,ri as Yb,ti as Zb,Jt as _b,ei as $b,oi as ac,ii as bc,ui as cc,fi as dc,ai as ec,ci as fc,mi as gc,pi as hc,li as ic,si as jc,vi as kc};
@@ -1 +0,0 @@
1
- import{a as m}from"./chunk-PKHRAYFD.mjs";import{A as c,B as p,a as o,y as s}from"./chunk-EYF3263P.mjs";var h=class n{constructor(e,t,r,i){this.publicKey=e,this.secretKey=t,this.context=r,this.variant=i,this.name=i}static fromPublicKey(e,t,r="mlkem768"){return new n(e,void 0,t,r)}static fromKeypair(e,t,r,i="mlkem768"){return new n(e,t,r,i)}static generateKeypair(e,t="mlkem768"){let{pk:r,sk:i}=s(t);return{adapter:new n(r,i,e,t),publicKey:r,secretKey:i}}static async fromMnemonic(e,t,r="mlkem768"){let{MnemonicEncryptionAdapter:i}=await import("./MnemonicEncryptionAdapter-J6IE5OKA-O5AJPX42.mjs");return new i(e).intoKeypairEncryptionAdapter(t,r)}static async fromPassword(e,t,r,i="mlkem768",a){let{PasswordEncryptionAdapter:y}=await import("./PasswordEncryptionAdapter-CWOXUGR4-2YZ64B4A.mjs");return new y({password:e,salt:t,...a?{params:a}:{}}).intoKeypairEncryptionAdapter(r,i)}destroy(){this.secretKey?.fill(0),this.secretKey=void 0}async wrapDek(e){return c(e,this.publicKey,this.context,this.variant)}async unwrapDek(e){if(!this.secretKey)throw new o(m.KEYPAIR_MISSING_SECRET_KEY,`[dStorage] KeypairEncryptionAdapter(${this.variant}): cannot unwrapDek \u2014 no Secret Key is available. Use fromKeypair() or fromPassword() to create an adapter with a SK.`);return p(e,this.secretKey,this.context)}};export{h as a};
@@ -1 +0,0 @@
1
- var a=Object.defineProperty,i=(e,r,t)=>r in e?a(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,l=(e,r,t)=>i(e,typeof r!="symbol"?r+"":r,t);export{l as a};
@@ -1,279 +0,0 @@
1
- import {
2
- ChainErrorCode
3
- } from "./chunk-4X5K43JF.mjs";
4
- import {
5
- DStorageError
6
- } from "./chunk-TSZ37JDY.mjs";
7
- import {
8
- CompiledDataRegistryContract,
9
- createDataRegistryPrivateState,
10
- ledger
11
- } from "./chunk-VDZ7F7MP.mjs";
12
- import "./chunk-5QOKJEH3.mjs";
13
- import {
14
- require_cjs
15
- } from "./chunk-25I6ZXUC.mjs";
16
- import {
17
- __toESM
18
- } from "./chunk-UJCSKKID.mjs";
19
-
20
- // ../chain/dist/contract-api-AO4RGPLT.mjs
21
- var import_rxjs = __toESM(require_cjs(), 1);
22
- import {
23
- deployContract,
24
- findDeployedContract,
25
- withContractScopedTransaction
26
- } from "@midnight-ntwrk/midnight-js-contracts";
27
- import { toHex } from "@midnight-ntwrk/midnight-js-utils";
28
- var dataRegistryPrivateStateKey = "DataRegistryPrivateState";
29
- var SUPPORTED_CONTRACT_VERSION = 0n;
30
- function validateContractVersion(version, contractAddress) {
31
- if (version !== SUPPORTED_CONTRACT_VERSION) {
32
- throw new DStorageError(
33
- ChainErrorCode.CONTRACT_UNSUPPORTED_VERSION,
34
- `[dStorage/midnight] Unsupported contract version ${version} at ${contractAddress}. This SDK supports version ${SUPPORTED_CONTRACT_VERSION} only. Deploy a compatible DataRegistry contract or upgrade the SDK.`
35
- );
36
- }
37
- }
38
- var DataRegistryAPI = class _DataRegistryAPI {
39
- /** @internal */
40
- constructor(deployedContract, providers, logger) {
41
- this.deployedContract = deployedContract;
42
- this.providers = providers;
43
- this.logger = logger;
44
- this.deployedContractAddress = deployedContract.deployTxData.public.contractAddress;
45
- this.state$ = (0, import_rxjs.combineLatest)(
46
- [
47
- // Combine public (ledger) state with...
48
- providers.publicDataProvider.contractStateObservable(this.deployedContractAddress, {
49
- type: "latest"
50
- }).pipe(
51
- (0, import_rxjs.map)((contractState) => ledger(contractState.data)),
52
- (0, import_rxjs.tap)(
53
- (ledgerState) => logger?.debug?.(
54
- "dStorage/midnight",
55
- `ledger state changed: refCounter=${ledgerState.refCounter}`
56
- )
57
- )
58
- ),
59
- // ...private state...
60
- // since the private state of the DataRegistry application never changes, we can query the
61
- // private state once and always use the same value with `combineLatest`. In applications
62
- // where the private state is expected to change, we would need to make this an `Observable`.
63
- (0, import_rxjs.from)(
64
- providers.privateStateProvider.get(
65
- dataRegistryPrivateStateKey
66
- )
67
- )
68
- ],
69
- // ...and combine them to produce the required derived state.
70
- // isOurs is set to false here — ownership is determined by the core SDK
71
- // (dStorage.ts) by attempting to unwrap the DEK from the keyEnvelope using
72
- // the available KEKs. This avoids coupling the chain layer to key material.
73
- (ledgerState, _privateState) => {
74
- const references = /* @__PURE__ */ new Map();
75
- for (const [id, refEntry] of ledgerState.references) {
76
- const refId = toHex(id);
77
- references.set(refId, refEntry);
78
- }
79
- return {
80
- references,
81
- refCounter: ledgerState.refCounter,
82
- contractVersion: ledgerState.contractVersion
83
- };
84
- }
85
- ).pipe(
86
- // Keep one live subscription to the indexer WebSocket for the lifetime of
87
- // this API instance. Without shareReplay, each firstValueFrom(state$) call
88
- // creates a new subscription — the indexer does not replay the last emitted
89
- // state to new subscribers, so callers would receive stale data until the
90
- // next on-chain change arrives. shareReplay(1) ensures:
91
- // 1. The indexer connection is established once and kept alive.
92
- // 2. Every new subscriber (e.g. listReferences, readReference) immediately
93
- // receives the most recently emitted state.
94
- // 3. Future indexer pushes (after upload/remove txs) still update the cache.
95
- (0, import_rxjs.shareReplay)({ bufferSize: 1, refCount: false })
96
- );
97
- }
98
- async storeReference(storageId, encryptionScheme, storageProvider, metadata, writtenAt, keyEnvelope, contentHash, ownerSecret) {
99
- this.logger?.log(
100
- "dStorage/midnight",
101
- `storing reference: storageId=${storageId}`
102
- );
103
- await this.providers.privateStateProvider.set(dataRegistryPrivateStateKey, {
104
- ownerSecret: new Uint8Array(ownerSecret)
105
- });
106
- try {
107
- const txData = await withContractScopedTransaction(
108
- this.providers,
109
- async (txCtx) => {
110
- await this.deployedContract.callTx.storeReference(
111
- txCtx,
112
- storageId,
113
- encryptionScheme,
114
- storageProvider,
115
- metadata,
116
- writtenAt,
117
- keyEnvelope,
118
- contentHash
119
- );
120
- },
121
- { scopeName: "storeReference" }
122
- );
123
- const txHash = txData.public.txHash ?? txData.public.txId ?? "";
124
- const blockHeight = Number(txData.public.blockHeight ?? 0);
125
- const circuitResult = txData.private.result;
126
- if (!(circuitResult instanceof Uint8Array)) {
127
- throw new DStorageError(
128
- ChainErrorCode.CONTRACT_CIRCUIT_RESULT_MISSING,
129
- `[dStorage/midnight] storeReference succeeded on-chain (txHash=${txHash}) but the runtime did not return the circuit refId at txData.private.result (got ${typeof circuitResult}). This is likely a compact-runtime version mismatch. Upgrade @midnight-ntwrk/compact-runtime or report this as a bug.`
130
- );
131
- }
132
- this.logger?.debug?.(
133
- "dStorage/midnight",
134
- `transaction: circuit=storeReference txHash=${txHash} blockHeight=${blockHeight}`
135
- );
136
- return { refId: circuitResult, txHash, blockHeight };
137
- } finally {
138
- await this.providers.privateStateProvider.set(
139
- dataRegistryPrivateStateKey,
140
- {}
141
- );
142
- }
143
- }
144
- async removeReference(refId, ownerSecret) {
145
- this.logger?.log(
146
- "dStorage/midnight",
147
- `removing reference: ${toHex(refId)}`
148
- );
149
- await this.providers.privateStateProvider.set(dataRegistryPrivateStateKey, {
150
- ownerSecret: new Uint8Array(ownerSecret)
151
- });
152
- try {
153
- const txData = await withContractScopedTransaction(
154
- this.providers,
155
- async (txCtx) => {
156
- await this.deployedContract.callTx.removeReference(txCtx, refId);
157
- },
158
- { scopeName: "removeReference" }
159
- );
160
- const txHash = txData.public.txHash ?? txData.public.txId ?? "";
161
- const blockHeight = Number(txData.public.blockHeight ?? 0);
162
- this.logger?.debug?.(
163
- "dStorage/midnight",
164
- `transaction: circuit=removeReference txHash=${txHash} blockHeight=${blockHeight}`
165
- );
166
- return { txHash, blockHeight };
167
- } finally {
168
- await this.providers.privateStateProvider.set(
169
- dataRegistryPrivateStateKey,
170
- {}
171
- );
172
- }
173
- }
174
- async updateReference(refId, storageId, encryptionScheme, storageProvider, metadata, writtenAt, keyEnvelope, contentHash, ownerSecret, newOwnerSecret) {
175
- this.logger?.log(
176
- "dStorage/midnight",
177
- `updating reference: ${toHex(refId)}`
178
- );
179
- await this.providers.privateStateProvider.set(dataRegistryPrivateStateKey, {
180
- ownerSecret: new Uint8Array(ownerSecret),
181
- // When no new secret is provided, pass the old one so the circuit recomputes the same
182
- // commitment and the stored value is preserved unchanged.
183
- newOwnerSecret: new Uint8Array(newOwnerSecret ?? ownerSecret)
184
- });
185
- try {
186
- const txData = await withContractScopedTransaction(
187
- this.providers,
188
- async (txCtx) => {
189
- await this.deployedContract.callTx.updateReference(
190
- txCtx,
191
- refId,
192
- storageId,
193
- encryptionScheme,
194
- storageProvider,
195
- metadata,
196
- writtenAt,
197
- keyEnvelope,
198
- contentHash
199
- );
200
- },
201
- { scopeName: "updateReference" }
202
- );
203
- const txHash = txData.public.txHash ?? txData.public.txId ?? "";
204
- const blockHeight = Number(txData.public.blockHeight ?? 0);
205
- this.logger?.debug?.(
206
- "dStorage/midnight",
207
- `transaction: circuit=updateReference txHash=${txHash} blockHeight=${blockHeight}`
208
- );
209
- return { txHash, blockHeight };
210
- } finally {
211
- await this.providers.privateStateProvider.set(
212
- dataRegistryPrivateStateKey,
213
- {}
214
- );
215
- }
216
- }
217
- /**
218
- * Deploys a new DataRegistry contract to the network.
219
- *
220
- * @param providers The DataRegistry providers.
221
- * @param logger An optional 'pino' logger to use for logging.
222
- * @returns A `Promise` that resolves with a {@link DataRegistryAPI} instance that manages the newly deployed
223
- * {@link DeployedDataRegistryContract}; or rejects with a deployment error.
224
- */
225
- static async deploy(providers, logger) {
226
- logger?.log("dStorage/midnight", "deploying DataRegistry contract...");
227
- const deployedDataRegistryContract = await deployContract(providers, {
228
- compiledContract: CompiledDataRegistryContract,
229
- privateStateId: dataRegistryPrivateStateKey,
230
- initialPrivateState: createDataRegistryPrivateState()
231
- });
232
- return new _DataRegistryAPI(deployedDataRegistryContract, providers, logger);
233
- }
234
- /**
235
- * Finds an already deployed DataRegistry contract on the network, and joins it.
236
- *
237
- * @param providers The DataRegistry providers.
238
- * @param contractAddress The contract address of the deployed DataRegistry contract to search for and join.
239
- * @param logger An optional 'pino' logger to use for logging.
240
- * @returns A `Promise` that resolves with a {@link DataRegistryAPI} instance that manages the joined
241
- * {@link DeployedDataRegistryContract}; or rejects with an error.
242
- */
243
- static async join(providers, contractAddress, logger) {
244
- logger?.log(
245
- "dStorage/midnight",
246
- `joining DataRegistry contract at: ${contractAddress}`
247
- );
248
- providers.privateStateProvider.setContractAddress(contractAddress);
249
- const deployedDataRegistryContract = await findDeployedContract(providers, {
250
- contractAddress,
251
- compiledContract: CompiledDataRegistryContract,
252
- privateStateId: dataRegistryPrivateStateKey,
253
- initialPrivateState: await _DataRegistryAPI.getPrivateState(providers)
254
- });
255
- const contractVersion = await (0, import_rxjs.firstValueFrom)(
256
- providers.publicDataProvider.contractStateObservable(contractAddress, { type: "latest" }).pipe((0, import_rxjs.map)((s) => ledger(s.data).contractVersion))
257
- );
258
- validateContractVersion(contractVersion, contractAddress);
259
- return new _DataRegistryAPI(deployedDataRegistryContract, providers, logger);
260
- }
261
- static async getPrivateState(providers) {
262
- const existingPrivateState = await providers.privateStateProvider.get(
263
- dataRegistryPrivateStateKey
264
- );
265
- return existingPrivateState ?? createDataRegistryPrivateState();
266
- }
267
- };
268
- var randomBytes = (length) => {
269
- const bytes = new Uint8Array(length);
270
- crypto.getRandomValues(bytes);
271
- return bytes;
272
- };
273
- export {
274
- DataRegistryAPI,
275
- SUPPORTED_CONTRACT_VERSION,
276
- dataRegistryPrivateStateKey,
277
- randomBytes,
278
- validateContractVersion
279
- };