@junobuild/admin 0.0.61 → 0.1.1
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.
- package/dist/browser/index.js +1 -13
- package/dist/browser/index.js.map +4 -4
- package/dist/declarations/mission_control/mission_control.did.d.ts +101 -37
- package/dist/declarations/mission_control/mission_control.factory.did.js +101 -56
- package/dist/node/index.mjs +1 -13
- package/dist/node/index.mjs.map +4 -4
- package/package.json +3 -2
package/dist/node/index.mjs
CHANGED
|
@@ -1,16 +1,4 @@
|
|
|
1
1
|
import { createRequire as topLevelCreateRequire } from 'module';
|
|
2
2
|
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
-
var Sn=Object.create;var Ot=Object.defineProperty;var Rn=Object.getOwnPropertyDescriptor;var An=Object.getOwnPropertyNames;var Vn=Object.getPrototypeOf,On=Object.prototype.hasOwnProperty;var Ft=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Q=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Fn=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of An(t))!On.call(e,o)&&o!==r&&Ot(e,o,{get:()=>t[o],enumerable:!(n=Rn(t,o))||n.enumerable});return e};var Et=(e,t,r)=>(r=e!=null?Sn(Vn(e)):{},Fn(t||!e||!e.__esModule?Ot(r,"default",{value:e,enumerable:!0}):r,e));var Ve=Q(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.bufFromBufLike=B.uint8ToBuf=B.PipeArrayBuffer=B.fromHexString=B.toHexString=B.concat=void 0;function ro(...e){let t=new Uint8Array(e.reduce((n,o)=>n+o.byteLength,0)),r=0;for(let n of e)t.set(new Uint8Array(n),r),r+=n.byteLength;return t}B.concat=ro;function no(e){return new Uint8Array(e).reduce((t,r)=>t+r.toString(16).padStart(2,"0"),"")}B.toHexString=no;function oo(e){var t;return new Uint8Array(((t=e.match(/.{1,2}/g))!==null&&t!==void 0?t:[]).map(r=>parseInt(r,16)))}B.fromHexString=oo;var ot=class{constructor(t,r=t?.byteLength||0){this._buffer=Ae(t||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return Ae(this._view.slice())}get byteLength(){return this._view.byteLength}read(t){let r=this._view.subarray(0,t);return this._view=this._view.subarray(t),r.slice().buffer}readUint8(){let t=this._view[0];return this._view=this._view.subarray(1),t}write(t){let r=new Uint8Array(t),n=this._view.byteLength;this._view.byteOffset+this._view.byteLength+r.byteLength>=this._buffer.byteLength?this.alloc(r.byteLength):this._view=new Uint8Array(this._buffer,this._view.byteOffset,this._view.byteLength+r.byteLength),this._view.set(r,n)}get end(){return this._view.byteLength===0}alloc(t){let r=new ArrayBuffer((this._buffer.byteLength+t)*1.2|0),n=new Uint8Array(r,0,this._view.byteLength+t);n.set(this._view),this._buffer=r,this._view=n}};B.PipeArrayBuffer=ot;function Re(e){return new DataView(e.buffer,e.byteOffset,e.byteLength).buffer}B.uint8ToBuf=Re;function Ae(e){return e instanceof Uint8Array?Re(e):e instanceof ArrayBuffer?e:Array.isArray(e)?Re(new Uint8Array(e)):"buffer"in e?Ae(e.buffer):Re(new Uint8Array(e))}B.bufFromBufLike=Ae});var it=Q(Oe=>{"use strict";Object.defineProperty(Oe,"__esModule",{value:!0});Oe.idlLabelToId=void 0;function io(e){let r=new TextEncoder().encode(e),n=0;for(let o of r)n=(n*223+o)%2**32;return n}function so(e){if(/^_\d+_$/.test(e)||/^_0x[0-9a-fA-F]+_$/.test(e)){let t=+e.slice(1,-1);if(Number.isSafeInteger(t)&&t>=0&&t<2**32)return t}return io(e)}Oe.idlLabelToId=so});var at=Q(P=>{"use strict";Object.defineProperty(P,"__esModule",{value:!0});P.readIntLE=P.readUIntLE=P.writeIntLE=P.writeUIntLE=P.slebDecode=P.slebEncode=P.lebDecode=P.lebEncode=P.safeReadUint8=P.safeRead=void 0;var st=Ve();function dr(){throw new Error("unexpected end of buffer")}function pr(e,t){return e.byteLength<t&&dr(),e.read(t)}P.safeRead=pr;function Fe(e){let t=e.readUint8();return t===void 0&&dr(),t}P.safeReadUint8=Fe;function ao(e){if(typeof e=="number"&&(e=BigInt(e)),e<BigInt(0))throw new Error("Cannot leb encode negative values.");let t=(e===BigInt(0)?0:Math.ceil(Math.log2(Number(e))))+1,r=new st.PipeArrayBuffer(new ArrayBuffer(t),0);for(;;){let n=Number(e&BigInt(127));if(e/=BigInt(128),e===BigInt(0)){r.write(new Uint8Array([n]));break}else r.write(new Uint8Array([n|128]))}return r.buffer}P.lebEncode=ao;function mr(e){let t=BigInt(1),r=BigInt(0),n;do n=Fe(e),r+=BigInt(n&127).valueOf()*t,t*=BigInt(128);while(n>=128);return r}P.lebDecode=mr;function co(e){typeof e=="number"&&(e=BigInt(e));let t=e<BigInt(0);t&&(e=-e-BigInt(1));let r=(e===BigInt(0)?0:Math.ceil(Math.log2(Number(e))))+1,n=new st.PipeArrayBuffer(new ArrayBuffer(r),0);for(;;){let i=o(e);if(e/=BigInt(128),t&&e===BigInt(0)&&i&64||!t&&e===BigInt(0)&&!(i&64)){n.write(new Uint8Array([i]));break}else n.write(new Uint8Array([i|128]))}function o(i){let a=i%BigInt(128);return Number(t?BigInt(128)-a-BigInt(1):a)}return n.buffer}P.slebEncode=co;function lo(e){let t=new Uint8Array(e.buffer),r=0;for(;r<t.byteLength;r++)if(t[r]<128){if(!(t[r]&64))return mr(e);break}let n=new Uint8Array(pr(e,r+1)),o=BigInt(0);for(let i=n.byteLength-1;i>=0;i--)o=o*BigInt(128)+BigInt(128-(n[i]&127)-1);return-o-BigInt(1)}P.slebDecode=lo;function uo(e,t){if(BigInt(e)<BigInt(0))throw new Error("Cannot write negative values.");return fr(e,t)}P.writeUIntLE=uo;function fr(e,t){e=BigInt(e);let r=new st.PipeArrayBuffer(new ArrayBuffer(Math.min(1,t)),0),n=0,o=BigInt(256),i=BigInt(0),a=Number(e%o);for(r.write(new Uint8Array([a]));++n<t;)e<0&&i===BigInt(0)&&a!==0&&(i=BigInt(1)),a=Number((e/o-i)%BigInt(256)),r.write(new Uint8Array([a])),o*=BigInt(256);return r.buffer}P.writeIntLE=fr;function hr(e,t){let r=BigInt(Fe(e)),n=BigInt(1),o=0;for(;++o<t;){n*=BigInt(256);let i=BigInt(Fe(e));r=r+n*i}return r}P.readUIntLE=hr;function po(e,t){let r=hr(e,t),n=BigInt(2)**(BigInt(8)*BigInt(t-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}P.readIntLE=po});var yr=Q(se=>{"use strict";Object.defineProperty(se,"__esModule",{value:!0});se.iexp2=se.ilog2=void 0;function mo(e){let t=BigInt(e);if(e<=0)throw new RangeError("Input must be positive");return t.toString(2).length-1}se.ilog2=mo;function fo(e){let t=BigInt(e);if(e<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<t}se.iexp2=fo});var pt=Q(s=>{"use strict";Object.defineProperty(s,"__esModule",{value:!0});s.Variant=s.Record=s.Opt=s.Vec=s.Tuple=s.Principal=s.Nat64=s.Nat32=s.Nat16=s.Nat8=s.Int64=s.Int32=s.Int16=s.Int8=s.Float64=s.Float32=s.Nat=s.Int=s.Text=s.Null=s.Bool=s.Unknown=s.Reserved=s.Empty=s.decode=s.encode=s.ServiceClass=s.FuncClass=s.PrincipalClass=s.RecClass=s.VariantClass=s.TupleClass=s.RecordClass=s.OptClass=s.VecClass=s.FixedNatClass=s.FixedIntClass=s.FloatClass=s.NatClass=s.IntClass=s.TextClass=s.ReservedClass=s.NullClass=s.BoolClass=s.UnknownClass=s.EmptyClass=s.ConstructType=s.PrimitiveType=s.Type=s.Visitor=void 0;s.Service=s.Func=s.Rec=void 0;var ho=Ft("@dfinity/principal"),_=Ve(),K=it(),c=at(),ct=yr(),Ee="DIDL",_r=400;function ye(e,t,r){return e.map((n,o)=>r(n,t[o]))}var lt=class{constructor(){this._typs=[],this._idx=new Map}has(t){return this._idx.has(t.name)}add(t,r){let n=this._typs.length;this._idx.set(t.name,n),this._typs.push(r)}merge(t,r){let n=this._idx.get(t.name),o=this._idx.get(r);if(n===void 0)throw new Error("Missing type index for "+t);if(o===void 0)throw new Error("Missing type index for "+r);this._typs[n]=this._typs[o],this._typs.splice(o,1),this._idx.delete(r)}encode(){let t=(0,c.lebEncode)(this._typs.length),r=(0,_.concat)(...this._typs);return(0,_.concat)(t,r)}indexOf(t){if(!this._idx.has(t))throw new Error("Missing type index for "+t);return(0,c.slebEncode)(this._idx.get(t)||0)}},ut=class{visitType(t,r){throw new Error("Not implemented")}visitPrimitive(t,r){return this.visitType(t,r)}visitEmpty(t,r){return this.visitPrimitive(t,r)}visitBool(t,r){return this.visitPrimitive(t,r)}visitNull(t,r){return this.visitPrimitive(t,r)}visitReserved(t,r){return this.visitPrimitive(t,r)}visitText(t,r){return this.visitPrimitive(t,r)}visitNumber(t,r){return this.visitPrimitive(t,r)}visitInt(t,r){return this.visitNumber(t,r)}visitNat(t,r){return this.visitNumber(t,r)}visitFloat(t,r){return this.visitPrimitive(t,r)}visitFixedInt(t,r){return this.visitNumber(t,r)}visitFixedNat(t,r){return this.visitNumber(t,r)}visitPrincipal(t,r){return this.visitPrimitive(t,r)}visitConstruct(t,r){return this.visitType(t,r)}visitVec(t,r,n){return this.visitConstruct(t,n)}visitOpt(t,r,n){return this.visitConstruct(t,n)}visitRecord(t,r,n){return this.visitConstruct(t,n)}visitTuple(t,r,n){let o=r.map((i,a)=>[`_${a}_`,i]);return this.visitRecord(t,o,n)}visitVariant(t,r,n){return this.visitConstruct(t,n)}visitRec(t,r,n){return this.visitConstruct(r,n)}visitFunc(t,r){return this.visitConstruct(t,r)}visitService(t,r){return this.visitConstruct(t,r)}};s.Visitor=ut;var ae=class{display(){return this.name}valueToString(t){return S(t)}buildTypeTable(t){t.has(this)||this._buildTypeTableImpl(t)}};s.Type=ae;var U=class extends ae{checkType(t){if(this.name!==t.name)throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`);return t}_buildTypeTableImpl(t){}};s.PrimitiveType=U;var G=class extends ae{checkType(t){if(t instanceof L){let r=t.getType();if(typeof r>"u")throw new Error("type mismatch with uninitialized type");return r}throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`)}encodeType(t){return t.indexOf(this.name)}};s.ConstructType=G;var ke=class extends U{accept(t,r){return t.visitEmpty(this,r)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${S(t)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return(0,c.slebEncode)(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}};s.EmptyClass=ke;var Me=class extends ae{checkType(t){throw new Error("Method not implemented for unknown.")}accept(t,r){throw t.visitType(this,r)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${S(t)}`)}encodeValue(){throw new Error("Unknown cannot appear as a function argument")}valueToString(){throw new Error("Unknown cannot appear as a value")}encodeType(){throw new Error("Unknown cannot be serialized")}decodeValue(t,r){let n=r.decodeValue(t,r);Object(n)!==n&&(n=Object(n));let o;return r instanceof L?o=()=>r.getType():o=()=>r,Object.defineProperty(n,"type",{value:o,writable:!0,enumerable:!1,configurable:!0}),n}_buildTypeTableImpl(){throw new Error("Unknown cannot be serialized")}get name(){return"Unknown"}};s.UnknownClass=Me;var Be=class extends U{accept(t,r){return t.visitBool(this,r)}covariant(t){if(typeof t=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${S(t)}`)}encodeValue(t){return new Uint8Array([t?1:0])}encodeType(){return(0,c.slebEncode)(-2)}decodeValue(t,r){switch(this.checkType(r),(0,c.safeReadUint8)(t)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}};s.BoolClass=Be;var Ue=class extends U{accept(t,r){return t.visitNull(this,r)}covariant(t){if(t===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${S(t)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,c.slebEncode)(-1)}decodeValue(t,r){return this.checkType(r),null}get name(){return"null"}};s.NullClass=Ue;var ce=class extends U{accept(t,r){return t.visitReserved(this,r)}covariant(t){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,c.slebEncode)(-16)}decodeValue(t,r){return r.name!==this.name&&r.decodeValue(t,r),null}get name(){return"reserved"}};s.ReservedClass=ce;var $e=class extends U{accept(t,r){return t.visitText(this,r)}covariant(t){if(typeof t=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${S(t)}`)}encodeValue(t){let r=new TextEncoder().encode(t),n=(0,c.lebEncode)(r.byteLength);return(0,_.concat)(n,r)}encodeType(){return(0,c.slebEncode)(-15)}decodeValue(t,r){this.checkType(r);let n=(0,c.lebDecode)(t),o=(0,c.safeRead)(t,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(o)}get name(){return"text"}valueToString(t){return'"'+t+'"'}};s.TextClass=$e;var qe=class extends U{accept(t,r){return t.visitInt(this,r)}covariant(t){if(typeof t=="bigint"||Number.isInteger(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${S(t)}`)}encodeValue(t){return(0,c.slebEncode)(t)}encodeType(){return(0,c.slebEncode)(-4)}decodeValue(t,r){return this.checkType(r),(0,c.slebDecode)(t)}get name(){return"int"}valueToString(t){return t.toString()}};s.IntClass=qe;var je=class extends U{accept(t,r){return t.visitNat(this,r)}covariant(t){if(typeof t=="bigint"&&t>=BigInt(0)||Number.isInteger(t)&&t>=0)return!0;throw new Error(`Invalid ${this.display()} argument: ${S(t)}`)}encodeValue(t){return(0,c.lebEncode)(t)}encodeType(){return(0,c.slebEncode)(-3)}decodeValue(t,r){return this.checkType(r),(0,c.lebDecode)(t)}get name(){return"nat"}valueToString(t){return t.toString()}};s.NatClass=je;var _e=class extends U{constructor(t){if(super(),this._bits=t,t!==32&&t!==64)throw new Error("not a valid float type")}accept(t,r){return t.visitFloat(this,r)}covariant(t){if(typeof t=="number"||t instanceof Number)return!0;throw new Error(`Invalid ${this.display()} argument: ${S(t)}`)}encodeValue(t){let r=new ArrayBuffer(this._bits/8),n=new DataView(r);return this._bits===32?n.setFloat32(0,t,!0):n.setFloat64(0,t,!0),r}encodeType(){let t=this._bits===32?-13:-14;return(0,c.slebEncode)(t)}decodeValue(t,r){this.checkType(r);let n=(0,c.safeRead)(t,this._bits/8),o=new DataView(n);return this._bits===32?o.getFloat32(0,!0):o.getFloat64(0,!0)}get name(){return"float"+this._bits}valueToString(t){return t.toString()}};s.FloatClass=_e;var D=class extends U{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedInt(this,r)}covariant(t){let r=(0,ct.iexp2)(this._bits-1)*BigInt(-1),n=(0,ct.iexp2)(this._bits-1)-BigInt(1),o=!1;if(typeof t=="bigint")o=t>=r&&t<=n;else if(Number.isInteger(t)){let i=BigInt(t);o=i>=r&&i<=n}else o=!1;if(o)return!0;throw new Error(`Invalid ${this.display()} argument: ${S(t)}`)}encodeValue(t){return(0,c.writeIntLE)(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return(0,c.slebEncode)(-9-t)}decodeValue(t,r){this.checkType(r);let n=(0,c.readIntLE)(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(t){return t.toString()}};s.FixedIntClass=D;var W=class extends U{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedNat(this,r)}covariant(t){let r=(0,ct.iexp2)(this._bits),n=!1;if(typeof t=="bigint"&&t>=BigInt(0)?n=t<r:Number.isInteger(t)&&t>=0?n=BigInt(t)<r:n=!1,n)return!0;throw new Error(`Invalid ${this.display()} argument: ${S(t)}`)}encodeValue(t){return(0,c.writeUIntLE)(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return(0,c.slebEncode)(-5-t)}decodeValue(t,r){this.checkType(r);let n=(0,c.readUIntLE)(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(t){return t.toString()}};s.FixedNatClass=W;var ze=class e extends G{constructor(t){super(),this._type=t,this._blobOptimization=!1,t instanceof W&&t._bits===8&&(this._blobOptimization=!0)}accept(t,r){return t.visitVec(this,this._type,r)}covariant(t){let r=this._type instanceof W?this._type._bits:this._type instanceof D?this._type._bits:0;if(ArrayBuffer.isView(t)&&r==t.BYTES_PER_ELEMENT*8||Array.isArray(t)&&t.every((n,o)=>{try{return this._type.covariant(n)}catch(i){throw new Error(`Invalid ${this.display()} argument:
|
|
4
|
-
|
|
5
|
-
index ${o} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${S(t)}`)}encodeValue(t){let r=(0,c.lebEncode)(t.length);if(this._blobOptimization)return(0,_.concat)(r,new Uint8Array(t));if(ArrayBuffer.isView(t))return(0,_.concat)(r,new Uint8Array(t.buffer));let n=new _.PipeArrayBuffer(new ArrayBuffer(r.byteLength+t.length),0);n.write(r);for(let o of t){let i=this._type.encodeValue(o);n.write(new Uint8Array(i))}return n.buffer}_buildTypeTableImpl(t){this._type.buildTypeTable(t);let r=(0,c.slebEncode)(-19),n=this._type.encodeType(t);t.add(this,(0,_.concat)(r,n))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a vector type");let o=Number((0,c.lebDecode)(t));if(this._type instanceof W){if(this._type._bits==8)return new Uint8Array(t.read(o));if(this._type._bits==16)return new Uint16Array(t.read(o*2));if(this._type._bits==32)return new Uint32Array(t.read(o*4));if(this._type._bits==64)return new BigUint64Array(t.read(o*8))}if(this._type instanceof D){if(this._type._bits==8)return new Int8Array(t.read(o));if(this._type._bits==16)return new Int16Array(t.read(o*2));if(this._type._bits==32)return new Int32Array(t.read(o*4));if(this._type._bits==64)return new BigInt64Array(t.read(o*8))}let i=[];for(let a=0;a<o;a++)i.push(this._type.decodeValue(t,n._type));return i}get name(){return`vec ${this._type.name}`}display(){return`vec ${this._type.display()}`}valueToString(t){return"vec {"+t.map(n=>this._type.valueToString(n)).join("; ")+"}"}};s.VecClass=ze;var le=class e extends G{constructor(t){super(),this._type=t}accept(t,r){return t.visitOpt(this,this._type,r)}covariant(t){try{if(Array.isArray(t)&&(t.length===0||t.length===1&&this._type.covariant(t[0])))return!0}catch(r){throw new Error(`Invalid ${this.display()} argument: ${S(t)}
|
|
6
|
-
|
|
7
|
-
-> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${S(t)}`)}encodeValue(t){return t.length===0?new Uint8Array([0]):(0,_.concat)(new Uint8Array([1]),this._type.encodeValue(t[0]))}_buildTypeTableImpl(t){this._type.buildTypeTable(t);let r=(0,c.slebEncode)(-18),n=this._type.encodeType(t);t.add(this,(0,_.concat)(r,n))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not an option type");switch((0,c.safeReadUint8)(t)){case 0:return[];case 1:return[this._type.decodeValue(t,n._type)];default:throw new Error("Not an option value")}}get name(){return`opt ${this._type.name}`}display(){return`opt ${this._type.display()}`}valueToString(t){return t.length===0?"null":`opt ${this._type.valueToString(t[0])}`}};s.OptClass=le;var ge=class e extends G{constructor(t={}){super(),this._fields=Object.entries(t).sort((r,n)=>(0,K.idlLabelToId)(r[0])-(0,K.idlLabelToId)(n[0]))}accept(t,r){return t.visitRecord(this,this._fields,r)}tryAsTuple(){let t=[];for(let r=0;r<this._fields.length;r++){let[n,o]=this._fields[r];if(n!==`_${r}_`)return null;t.push(o)}return t}covariant(t){if(typeof t=="object"&&this._fields.every(([r,n])=>{if(!t.hasOwnProperty(r))throw new Error(`Record is missing key "${r}".`);try{return n.covariant(t[r])}catch(o){throw new Error(`Invalid ${this.display()} argument:
|
|
8
|
-
|
|
9
|
-
field ${r} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${S(t)}`)}encodeValue(t){let r=this._fields.map(([o])=>t[o]),n=ye(this._fields,r,([,o],i)=>o.encodeValue(i));return(0,_.concat)(...n)}_buildTypeTableImpl(t){this._fields.forEach(([i,a])=>a.buildTypeTable(t));let r=(0,c.slebEncode)(-20),n=(0,c.lebEncode)(this._fields.length),o=this._fields.map(([i,a])=>(0,_.concat)((0,c.lebEncode)((0,K.idlLabelToId)(i)),a.encodeType(t)));t.add(this,(0,_.concat)(r,n,(0,_.concat)(...o)))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a record type");let o={},i=0,a=0;for(;a<n._fields.length;){let[l,p]=n._fields[a];if(i>=this._fields.length){p.decodeValue(t,p),a++;continue}let[d,g]=this._fields[i],y=(0,K.idlLabelToId)(this._fields[i][0]),h=(0,K.idlLabelToId)(l);if(y===h)o[d]=g.decodeValue(t,p),i++,a++;else if(h>y)if(g instanceof le||g instanceof ce)o[d]=[],i++;else throw new Error("Cannot find required field "+d);else p.decodeValue(t,p),a++}for(let[l,p]of this._fields.slice(i))if(p instanceof le||p instanceof ce)o[l]=[];else throw new Error("Cannot find required field "+l);return o}get name(){return`record {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`record {${this._fields.map(([r,n])=>r+":"+n.display()).join("; ")}}`}valueToString(t){let r=this._fields.map(([o])=>t[o]);return`record {${ye(this._fields,r,([o,i],a)=>o+"="+i.valueToString(a)).join("; ")}}`}};s.RecordClass=ge;var He=class e extends ge{constructor(t){let r={};t.forEach((n,o)=>r["_"+o+"_"]=n),super(r),this._components=t}accept(t,r){return t.visitTuple(this,this._components,r)}covariant(t){if(Array.isArray(t)&&t.length>=this._fields.length&&this._components.every((r,n)=>{try{return r.covariant(t[n])}catch(o){throw new Error(`Invalid ${this.display()} argument:
|
|
10
|
-
|
|
11
|
-
index ${n} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${S(t)}`)}encodeValue(t){let r=ye(this._components,t,(n,o)=>n.encodeValue(o));return(0,_.concat)(...r)}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("not a tuple type");if(n._components.length<this._components.length)throw new Error("tuple mismatch");let o=[];for(let[i,a]of n._components.entries())i>=this._components.length?a.decodeValue(t,a):o.push(this._components[i].decodeValue(t,a));return o}display(){return`record {${this._components.map(r=>r.display()).join("; ")}}`}valueToString(t){return`record {${ye(this._components,t,(n,o)=>n.valueToString(o)).join("; ")}}`}};s.TupleClass=He;var Ke=class e extends G{constructor(t={}){super(),this._fields=Object.entries(t).sort((r,n)=>(0,K.idlLabelToId)(r[0])-(0,K.idlLabelToId)(n[0]))}accept(t,r){return t.visitVariant(this,this._fields,r)}covariant(t){if(typeof t=="object"&&Object.entries(t).length===1&&this._fields.every(([r,n])=>{try{return!t.hasOwnProperty(r)||n.covariant(t[r])}catch(o){throw new Error(`Invalid ${this.display()} argument:
|
|
12
|
-
|
|
13
|
-
variant ${r} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${S(t)}`)}encodeValue(t){for(let r=0;r<this._fields.length;r++){let[n,o]=this._fields[r];if(t.hasOwnProperty(n)){let i=(0,c.lebEncode)(r),a=o.encodeValue(t[n]);return(0,_.concat)(i,a)}}throw Error("Variant has no data: "+t)}_buildTypeTableImpl(t){this._fields.forEach(([,i])=>{i.buildTypeTable(t)});let r=(0,c.slebEncode)(-21),n=(0,c.lebEncode)(this._fields.length),o=this._fields.map(([i,a])=>(0,_.concat)((0,c.lebEncode)((0,K.idlLabelToId)(i)),a.encodeType(t)));t.add(this,(0,_.concat)(r,n,...o))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a variant type");let o=Number((0,c.lebDecode)(t));if(o>=n._fields.length)throw Error("Invalid variant index: "+o);let[i,a]=n._fields[o];for(let[l,p]of this._fields)if((0,K.idlLabelToId)(i)===(0,K.idlLabelToId)(l)){let d=p.decodeValue(t,a);return{[l]:d}}throw new Error("Cannot find field hash "+i)}get name(){return`variant {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`variant {${this._fields.map(([r,n])=>r+(n.name==="null"?"":`:${n.display()}`)).join("; ")}}`}valueToString(t){for(let[r,n]of this._fields)if(t.hasOwnProperty(r)){let o=n.valueToString(t[r]);return o==="null"?`variant {${r}}`:`variant {${r}=${o}}`}throw new Error("Variant has no data: "+t)}};s.VariantClass=Ke;var L=class e extends G{constructor(){super(...arguments),this._id=e._counter++,this._type=void 0}accept(t,r){if(!this._type)throw Error("Recursive type uninitialized.");return t.visitRec(this,this._type,r)}fill(t){this._type=t}getType(){return this._type}covariant(t){if(this._type&&this._type.covariant(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${S(t)}`)}encodeValue(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(t)}_buildTypeTableImpl(t){if(!this._type)throw Error("Recursive type uninitialized.");t.add(this,new Uint8Array([])),this._type.buildTypeTable(t),t.merge(this,this._type.name)}decodeValue(t,r){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(t,r)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(t)}};s.RecClass=L;L._counter=0;function dt(e){if((0,c.safeReadUint8)(e)!==1)throw new Error("Cannot decode principal");let r=Number((0,c.lebDecode)(e));return ho.Principal.fromUint8Array(new Uint8Array((0,c.safeRead)(e,r)))}var We=class extends U{accept(t,r){return t.visitPrincipal(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${S(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=(0,c.lebEncode)(r.byteLength);return(0,_.concat)(new Uint8Array([1]),n,r)}encodeType(){return(0,c.slebEncode)(-24)}decodeValue(t,r){return this.checkType(r),dt(t)}get name(){return"principal"}valueToString(t){return`${this.name} "${t.toText()}"`}};s.PrincipalClass=We;var Te=class extends G{constructor(t,r,n=[]){super(),this.argTypes=t,this.retTypes=r,this.annotations=n}static argsToString(t,r){if(t.length!==r.length)throw new Error("arity mismatch");return"("+t.map((n,o)=>n.valueToString(r[o])).join(", ")+")"}accept(t,r){return t.visitFunc(this,r)}covariant(t){if(Array.isArray(t)&&t.length===2&&t[0]&&t[0]._isPrincipal&&typeof t[1]=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${S(t)}`)}encodeValue([t,r]){let n=t.toUint8Array(),o=(0,c.lebEncode)(n.byteLength),i=(0,_.concat)(new Uint8Array([1]),o,n),a=new TextEncoder().encode(r),l=(0,c.lebEncode)(a.byteLength);return(0,_.concat)(new Uint8Array([1]),i,l,a)}_buildTypeTableImpl(t){this.argTypes.forEach(d=>d.buildTypeTable(t)),this.retTypes.forEach(d=>d.buildTypeTable(t));let r=(0,c.slebEncode)(-22),n=(0,c.lebEncode)(this.argTypes.length),o=(0,_.concat)(...this.argTypes.map(d=>d.encodeType(t))),i=(0,c.lebEncode)(this.retTypes.length),a=(0,_.concat)(...this.retTypes.map(d=>d.encodeType(t))),l=(0,c.lebEncode)(this.annotations.length),p=(0,_.concat)(...this.annotations.map(d=>this.encodeAnnotation(d)));t.add(this,(0,_.concat)(r,n,o,i,a,l,p))}decodeValue(t){if((0,c.safeReadUint8)(t)!==1)throw new Error("Cannot decode function reference");let n=dt(t),o=Number((0,c.lebDecode)(t)),i=(0,c.safeRead)(t,o),l=new TextDecoder("utf8",{fatal:!0}).decode(i);return[n,l]}get name(){let t=this.argTypes.map(o=>o.name).join(", "),r=this.retTypes.map(o=>o.name).join(", "),n=" "+this.annotations.join(" ");return`(${t}) -> (${r})${n}`}valueToString([t,r]){return`func "${t.toText()}".${r}`}display(){let t=this.argTypes.map(o=>o.display()).join(", "),r=this.retTypes.map(o=>o.display()).join(", "),n=" "+this.annotations.join(" ");return`(${t}) \u2192 (${r})${n}`}encodeAnnotation(t){if(t==="query")return new Uint8Array([1]);if(t==="oneway")return new Uint8Array([2]);if(t==="composite_query")return new Uint8Array([3]);throw new Error("Illegal function annotation")}};s.FuncClass=Te;var Ge=class extends G{constructor(t){super(),this._fields=Object.entries(t).sort((r,n)=>r[0]<n[0]?-1:r[0]>n[0]?1:0)}accept(t,r){return t.visitService(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${S(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=(0,c.lebEncode)(r.length);return(0,_.concat)(new Uint8Array([1]),n,r)}_buildTypeTableImpl(t){this._fields.forEach(([i,a])=>a.buildTypeTable(t));let r=(0,c.slebEncode)(-23),n=(0,c.lebEncode)(this._fields.length),o=this._fields.map(([i,a])=>{let l=new TextEncoder().encode(i),p=(0,c.lebEncode)(l.length);return(0,_.concat)(p,l,a.encodeType(t))});t.add(this,(0,_.concat)(r,n,...o))}decodeValue(t){return dt(t)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(t){return`service "${t.toText()}"`}};s.ServiceClass=Ge;function S(e){let t=JSON.stringify(e,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return t&&t.length>_r?t.substring(0,_r-3)+"...":t}function yo(e,t){if(t.length<e.length)throw Error("Wrong number of message arguments");let r=new lt;e.forEach(p=>p.buildTypeTable(r));let n=new TextEncoder().encode(Ee),o=r.encode(),i=(0,c.lebEncode)(t.length),a=(0,_.concat)(...e.map(p=>p.encodeType(r))),l=(0,_.concat)(...ye(e,t,(p,d)=>{try{p.covariant(d)}catch(g){throw new Error(g.message+`
|
|
14
|
-
|
|
15
|
-
`)}return p.encodeValue(d)}));return(0,_.concat)(n,o,i,a,l)}s.encode=yo;function _o(e,t){let r=new _.PipeArrayBuffer(t);if(t.byteLength<Ee.length)throw new Error("Message length smaller than magic number");let n=(0,c.safeRead)(r,Ee.length),o=new TextDecoder().decode(n);if(o!==Ee)throw new Error("Wrong magic number: "+JSON.stringify(o));function i(u){let m=[],T=Number((0,c.lebDecode)(u));for(let b=0;b<T;b++){let C=Number((0,c.slebDecode)(u));switch(C){case-18:case-19:{let x=Number((0,c.slebDecode)(u));m.push([C,x]);break}case-20:case-21:{let x=[],N=Number((0,c.lebDecode)(u)),R;for(;N--;){let A=Number((0,c.lebDecode)(u));if(A>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof R=="number"&&R>=A)throw new Error("field id collision or not sorted");R=A;let V=Number((0,c.slebDecode)(u));x.push([A,V])}m.push([C,x]);break}case-22:{let x=[],N=Number((0,c.lebDecode)(u));for(;N--;)x.push(Number((0,c.slebDecode)(u)));let R=[],A=Number((0,c.lebDecode)(u));for(;A--;)R.push(Number((0,c.slebDecode)(u)));let V=[],M=Number((0,c.lebDecode)(u));for(;M--;)switch(Number((0,c.lebDecode)(u))){case 1:{V.push("query");break}case 2:{V.push("oneway");break}case 3:{V.push("composite_query");break}default:throw new Error("unknown annotation")}m.push([C,[x,R,V]]);break}case-23:{let x=Number((0,c.lebDecode)(u)),N=[];for(;x--;){let R=Number((0,c.lebDecode)(u)),A=new TextDecoder().decode((0,c.safeRead)(u,R)),V=(0,c.slebDecode)(u);N.push([A,V])}m.push([C,N]);break}default:throw new Error("Illegal op_code: "+C)}}let v=[],w=Number((0,c.lebDecode)(u));for(let b=0;b<w;b++)v.push(Number((0,c.slebDecode)(u)));return[m,v]}let[a,l]=i(r);if(l.length<e.length)throw new Error("Wrong number of return values");let p=a.map(u=>Pr());function d(u){if(u<-24)throw new Error("future value not supported");if(u<0)switch(u){case-1:return s.Null;case-2:return s.Bool;case-3:return s.Nat;case-4:return s.Int;case-5:return s.Nat8;case-6:return s.Nat16;case-7:return s.Nat32;case-8:return s.Nat64;case-9:return s.Int8;case-10:return s.Int16;case-11:return s.Int32;case-12:return s.Int64;case-13:return s.Float32;case-14:return s.Float64;case-15:return s.Text;case-16:return s.Reserved;case-17:return s.Empty;case-24:return s.Principal;default:throw new Error("Illegal op_code: "+u)}if(u>=a.length)throw new Error("type index out of range");return p[u]}function g(u){switch(u[0]){case-19:{let m=d(u[1]);return Tr(m)}case-18:{let m=d(u[1]);return br(m)}case-20:{let m={};for(let[w,b]of u[1]){let C=`_${w}_`;m[C]=d(b)}let T=xr(m),v=T.tryAsTuple();return Array.isArray(v)?gr(...v):T}case-21:{let m={};for(let[T,v]of u[1]){let w=`_${T}_`;m[w]=d(v)}return wr(m)}case-22:{let[m,T,v]=u[1];return vr(m.map(w=>d(w)),T.map(w=>d(w)),v)}case-23:{let m={},T=u[1];for(let[v,w]of T){let b=d(w);if(b instanceof L&&(b=b.getType()),!(b instanceof Te))throw new Error("Illegal service definition: services can only contain functions");m[v]=b}return Cr(m)}default:throw new Error("Illegal op_code: "+u[0])}}a.forEach((u,m)=>{if(u[0]===-22){let T=g(u);p[m].fill(T)}}),a.forEach((u,m)=>{if(u[0]!==-22){let T=g(u);p[m].fill(T)}});let y=l.map(u=>d(u)),h=e.map((u,m)=>u.decodeValue(r,y[m]));for(let u=e.length;u<y.length;u++)y[u].decodeValue(r,y[u]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return h}s.decode=_o;s.Empty=new ke;s.Reserved=new ce;s.Unknown=new Me;s.Bool=new Be;s.Null=new Ue;s.Text=new $e;s.Int=new qe;s.Nat=new je;s.Float32=new _e(32);s.Float64=new _e(64);s.Int8=new D(8);s.Int16=new D(16);s.Int32=new D(32);s.Int64=new D(64);s.Nat8=new W(8);s.Nat16=new W(16);s.Nat32=new W(32);s.Nat64=new W(64);s.Principal=new We;function gr(...e){return new He(e)}s.Tuple=gr;function Tr(e){return new ze(e)}s.Vec=Tr;function br(e){return new le(e)}s.Opt=br;function xr(e){return new ge(e)}s.Record=xr;function wr(e){return new Ke(e)}s.Variant=wr;function Pr(){return new L}s.Rec=Pr;function vr(e,t,r=[]){return new Te(e,t,r)}s.Func=vr;function Cr(e){return new Ge(e)}s.Service=Cr});var Tt=Q(E=>{"use strict";Object.defineProperty(E,"__esModule",{value:!0});E.VecForm=E.OptionForm=E.VariantForm=E.TupleForm=E.RecordForm=E.InputForm=E.InputBox=void 0;var mt=class{constructor(t,r){this.idl=t,this.ui=r,this.label=null,this.value=void 0;let n=document.createElement("span");n.className="status",this.status=n,r.input&&(r.input.addEventListener("blur",()=>{r.input.value!==""&&this.parse()}),r.input.addEventListener("input",()=>{n.style.display="none",r.input.classList.remove("reject")}))}isRejected(){return this.value===void 0}parse(t={}){if(this.ui.form){let r=this.ui.form.parse(t);return this.value=r,r}if(this.ui.input){let r=this.ui.input;try{let n=this.ui.parse(this.idl,t,r.value);if(!this.idl.covariant(n))throw new Error(`${r.value} is not of type ${this.idl.display()}`);return this.status.style.display="none",this.value=n,n}catch(n){r.classList.add("reject"),this.status.style.display="block",this.status.innerHTML="InputError: "+n.message,this.value=void 0;return}}return null}render(t){let r=document.createElement("span");if(this.label){let n=document.createElement("label");n.innerText=this.label,r.appendChild(n)}this.ui.input&&(r.appendChild(this.ui.input),r.appendChild(this.status)),this.ui.form&&this.ui.form.render(r),t.appendChild(r)}};E.InputBox=mt;var ee=class{constructor(t){this.ui=t,this.form=[]}renderForm(t){this.ui.container?(this.form.forEach(r=>r.render(this.ui.container)),t.appendChild(this.ui.container)):this.form.forEach(r=>r.render(t))}render(t){if(this.ui.open&&this.ui.event){t.appendChild(this.ui.open);let r=this;r.ui.open.addEventListener(r.ui.event,()=>{if(r.ui.container)r.ui.container.innerHTML="";else{let n=r.ui.open.nextElementSibling;n&&n.parentNode.removeChild(n)}r.generateForm(),r.renderForm(t)})}else this.generateForm(),this.renderForm(t)}};E.InputForm=ee;var ft=class extends ee{constructor(t,r){super(r),this.fields=t,this.ui=r}generateForm(){this.form=this.fields.map(([t,r])=>{let n=this.ui.render(r);return this.ui.labelMap&&this.ui.labelMap.hasOwnProperty(t)?n.label=this.ui.labelMap[t]+" ":n.label=t+" ",n})}parse(t){let r={};if(this.fields.forEach(([n,o],i)=>{let a=this.form[i].parse(t);r[n]=a}),!this.form.some(n=>n.isRejected()))return r}};E.RecordForm=ft;var ht=class extends ee{constructor(t,r){super(r),this.components=t,this.ui=r}generateForm(){this.form=this.components.map(t=>this.ui.render(t))}parse(t){let r=[];if(this.components.forEach((n,o)=>{let i=this.form[o].parse(t);r.push(i)}),!this.form.some(n=>n.isRejected()))return r}};E.TupleForm=ht;var yt=class extends ee{constructor(t,r){super(r),this.fields=t,this.ui=r}generateForm(){let t=this.ui.open.selectedIndex,[r,n]=this.fields[t],o=this.ui.render(n);this.form=[o]}parse(t){let r=this.ui.open,n=r.options[r.selectedIndex].value,o=this.form[0].parse(t);if(o===void 0)return;let i={};return i[n]=o,i}};E.VariantForm=yt;var _t=class extends ee{constructor(t,r){super(r),this.ty=t,this.ui=r}generateForm(){if(this.ui.open.checked){let t=this.ui.render(this.ty);this.form=[t]}else this.form=[]}parse(t){if(this.form.length===0)return[];{let r=this.form[0].parse(t);return r===void 0?void 0:[r]}}};E.OptionForm=_t;var gt=class extends ee{constructor(t,r){super(r),this.ty=t,this.ui=r}generateForm(){let t=+this.ui.open.value;this.form=[];for(let r=0;r<t;r++){let n=this.ui.render(this.ty);this.form.push(n)}}parse(t){let r=this.form.map(n=>n.parse(t));if(!this.form.some(n=>n.isRejected()))return r}};E.VecForm=gt});var Sr=Q(f=>{"use strict";var go=f&&f.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),To=f&&f.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Nr=f&&f.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&go(t,e,r);return To(t,e),t};Object.defineProperty(f,"__esModule",{value:!0});f.renderValue=f.renderInput=f.Render=f.vecForm=f.optForm=f.variantForm=f.tupleForm=f.recordForm=f.inputBox=void 0;var Ze=Nr(pt()),bt=Ft("@dfinity/principal"),ue=Nr(Tt()),bo={parse:So},be={render:vt},xo=(e,t)=>new ue.InputBox(e,Object.assign(Object.assign({},bo),t));f.inputBox=xo;var wo=(e,t)=>new ue.RecordForm(e,Object.assign(Object.assign({},be),t));f.recordForm=wo;var Po=(e,t)=>new ue.TupleForm(e,Object.assign(Object.assign({},be),t));f.tupleForm=Po;var vo=(e,t)=>new ue.VariantForm(e,Object.assign(Object.assign({},be),t));f.variantForm=vo;var Co=(e,t)=>new ue.OptionForm(e,Object.assign(Object.assign({},be),t));f.optForm=Co;var No=(e,t)=>new ue.VecForm(e,Object.assign(Object.assign({},be),t));f.vecForm=No;var Xe=class extends Ze.Visitor{visitType(t,r){let n=document.createElement("input");return n.classList.add("argument"),n.placeholder=t.display(),(0,f.inputBox)(t,{input:n})}visitNull(t,r){return(0,f.inputBox)(t,{})}visitRecord(t,r,n){let o={};if(r.length>1){let a=document.createElement("div");a.classList.add("popup-form"),o={container:a}}let i=(0,f.recordForm)(r,o);return(0,f.inputBox)(t,{form:i})}visitTuple(t,r,n){let o={};if(r.length>1){let a=document.createElement("div");a.classList.add("popup-form"),o={container:a}}let i=(0,f.tupleForm)(r,o);return(0,f.inputBox)(t,{form:i})}visitVariant(t,r,n){let o=document.createElement("select");for(let[l,p]of r){let d=new Option(l);o.add(d)}o.selectedIndex=-1,o.classList.add("open");let i={open:o,event:"change"},a=(0,f.variantForm)(r,i);return(0,f.inputBox)(t,{form:a})}visitOpt(t,r,n){let o=document.createElement("input");o.type="checkbox",o.classList.add("open");let i=(0,f.optForm)(r,{open:o,event:"change"});return(0,f.inputBox)(t,{form:i})}visitVec(t,r,n){let o=document.createElement("input");o.type="number",o.min="0",o.max="100",o.style.width="8rem",o.placeholder="len",o.classList.add("open");let i=document.createElement("div");i.classList.add("popup-form");let a=(0,f.vecForm)(r,{open:o,event:"change",container:i});return(0,f.inputBox)(t,{form:a})}visitRec(t,r,n){return vt(r)}};f.Render=Xe;var xt=class extends Ze.Visitor{visitNull(t,r){return null}visitBool(t,r){if(r==="true")return!0;if(r==="false")return!1;throw new Error(`Cannot parse ${r} as boolean`)}visitText(t,r){return r}visitFloat(t,r){return parseFloat(r)}visitFixedInt(t,r){return t._bits<=32?parseInt(r,10):BigInt(r)}visitFixedNat(t,r){return t._bits<=32?parseInt(r,10):BigInt(r)}visitNumber(t,r){return BigInt(r)}visitPrincipal(t,r){return bt.Principal.fromText(r)}visitService(t,r){return bt.Principal.fromText(r)}visitFunc(t,r){let n=r.split(".",2);return[bt.Principal.fromText(n[0]),n[1]]}},wt=class extends Ze.Visitor{visitNull(t,r){return null}visitBool(t,r){return Math.random()<.5}visitText(t,r){return Math.random().toString(36).substring(6)}visitFloat(t,r){return Math.random()}visitInt(t,r){return BigInt(this.generateNumber(!0))}visitNat(t,r){return BigInt(this.generateNumber(!1))}visitFixedInt(t,r){let n=this.generateNumber(!0);return t._bits<=32?n:BigInt(r)}visitFixedNat(t,r){let n=this.generateNumber(!1);return t._bits<=32?n:BigInt(r)}generateNumber(t){let r=Math.floor(Math.random()*100);return t&&Math.random()<.5?-r:r}};function So(e,t,r){return t.random&&r===""?e.accept(new wt,r):e.accept(new xt,r)}function vt(e){return e.accept(new Xe,null)}f.renderInput=vt;function oe(e,t,r){return e.accept(new Pt,{input:t,value:r})}f.renderValue=oe;var Pt=class extends Ze.Visitor{visitType(t,r){r.input.ui.input.value=t.valueToString(r.value)}visitNull(t,r){}visitText(t,r){r.input.ui.input.value=r.value}visitRec(t,r,n){oe(r,n.input,n.value)}visitOpt(t,r,n){if(n.value.length!==0){let o=n.input.ui.form,i=o.ui.open;i.checked=!0,i.dispatchEvent(new Event(o.ui.event)),oe(r,o.form[0],n.value[0])}}visitRecord(t,r,n){let o=n.input.ui.form;r.forEach(([i,a],l)=>{oe(a,o.form[l],n.value[i])})}visitTuple(t,r,n){let o=n.input.ui.form;r.forEach((i,a)=>{oe(i,o.form[a],n.value[a])})}visitVariant(t,r,n){let o=n.input.ui.form,i=Object.entries(n.value)[0];r.forEach(([a,l],p)=>{if(a===i[0]){let d=o.ui.open;d.selectedIndex=p,d.dispatchEvent(new Event(o.ui.event)),oe(l,o.form[0],i[1])}})}visitVec(t,r,n){let o=n.input.ui.form,i=n.value.length,a=o.ui.open;a.value=i,a.dispatchEvent(new Event(o.ui.event)),n.value.forEach((l,p)=>{oe(r,o.form[p],l)})}}});var Ar=Q(Rr=>{"use strict";Object.defineProperty(Rr,"__esModule",{value:!0})});var Ct=Q(F=>{"use strict";var Vr=F&&F.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),Ro=F&&F.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),de=F&&F.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Vr(t,e,r)},Ao=F&&F.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&Vr(t,e,r);return Ro(t,e),t};Object.defineProperty(F,"__esModule",{value:!0});F.IDL=void 0;de(Sr(),F);de(Tt(),F);F.IDL=Ao(pt());de(it(),F);de(at(),F);de(Ve(),F);de(Ar(),F)});var Pe=class extends Error{constructor(){super("The Wasm code for the upgrade is identical to the code currently installed. No upgrade is necessary.")}};import{isNullish as Bn}from"@junobuild/utils";var kt=({IDL:e})=>{let t=e.Record({updated_at:e.Nat64,orbiter_id:e.Principal,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),r=e.Record({subnet_id:e.Opt(e.Principal),name:e.Opt(e.Text)}),n=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,satellite_id:e.Principal}),o=e.Record({cycles:e.Nat,destination_id:e.Principal}),i=e.Record({e8s:e.Nat64}),a=e.Record({timestamp_nanos:e.Nat64}),l=e.Record({to:e.Vec(e.Nat8),fee:i,memo:e.Nat64,from_subaccount:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(a),amount:i}),p=e.Variant({TxTooOld:e.Record({allowed_window_nanos:e.Nat64}),BadFee:e.Record({expected_fee:i}),TxDuplicate:e.Record({duplicate_of:e.Nat64}),TxCreatedInFuture:e.Null,InsufficientFunds:e.Record({balance:i})}),d=e.Variant({Ok:e.Nat64,Err:p}),g=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),y=e.Record({to:g,fee:e.Opt(e.Nat),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat}),h=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,BadBurn:e.Record({min_burn_amount:e.Nat}),Duplicate:e.Record({duplicate_of:e.Nat}),BadFee:e.Record({expected_fee:e.Nat}),CreatedInFuture:e.Record({ledger_time:e.Nat64}),TooOld:e.Null,InsufficientFunds:e.Record({balance:e.Nat})}),u=e.Variant({Ok:e.Nat,Err:h}),m=e.Variant({Write:e.Null,Admin:e.Null}),T=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:m,expires_at:e.Opt(e.Nat64)}),v=e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),w=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),memory_allocation:e.Nat,compute_allocation:e.Nat}),b=e.Record({status:v,memory_size:e.Nat,cycles:e.Nat,settings:w,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8))}),C=e.Record({id:e.Principal,status:b,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),status_at:e.Nat64}),x=e.Variant({Ok:C,Err:e.Text}),N=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:m,expires_at:e.Opt(e.Nat64)}),R=e.Record({enabled:e.Bool,cycles_threshold:e.Opt(e.Nat64)}),A=e.Record({mission_control_cycles_threshold:e.Opt(e.Nat64),orbiters:e.Vec(e.Tuple(e.Principal,R)),satellites:e.Vec(e.Tuple(e.Principal,R)),cycles_threshold:e.Opt(e.Nat64)}),V=e.Record({orbiters:e.Opt(e.Vec(x)),satellites:e.Opt(e.Vec(x)),mission_control:x});return e.Service({add_mission_control_controllers:e.Func([e.Vec(e.Principal)],[],[]),add_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),create_orbiter:e.Func([e.Opt(e.Text)],[t],[]),create_orbiter_with_config:e.Func([r],[t],[]),create_satellite:e.Func([e.Text],[n],[]),create_satellite_with_config:e.Func([r],[n],[]),del_mission_control_controllers:e.Func([e.Vec(e.Principal)],[],[]),del_orbiter:e.Func([e.Principal,e.Nat],[],[]),del_orbiters_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),del_satellite:e.Func([e.Principal,e.Nat],[],[]),del_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),deposit_cycles:e.Func([o],[],[]),get_user:e.Func([],[e.Principal],["query"]),icp_transfer:e.Func([l],[d],[]),icrc_transfer:e.Func([e.Principal,y],[u],[]),list_mission_control_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,T))],["query"]),list_mission_control_statuses:e.Func([],[e.Vec(e.Tuple(e.Nat64,x))],["query"]),list_orbiter_statuses:e.Func([e.Principal],[e.Opt(e.Vec(e.Tuple(e.Nat64,x)))],["query"]),list_orbiters:e.Func([],[e.Vec(e.Tuple(e.Principal,t))],["query"]),list_satellite_statuses:e.Func([e.Principal],[e.Opt(e.Vec(e.Tuple(e.Nat64,x)))],["query"]),list_satellites:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["query"]),remove_mission_control_controllers:e.Func([e.Vec(e.Principal)],[],[]),remove_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),set_metadata:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[],[]),set_mission_control_controllers:e.Func([e.Vec(e.Principal),N],[],[]),set_orbiter:e.Func([e.Principal,e.Opt(e.Text)],[t],[]),set_orbiter_metadata:e.Func([e.Principal,e.Vec(e.Tuple(e.Text,e.Text))],[t],[]),set_orbiters_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal),N],[],[]),set_satellite:e.Func([e.Principal,e.Opt(e.Text)],[n],[]),set_satellite_metadata:e.Func([e.Principal,e.Vec(e.Tuple(e.Text,e.Text))],[n],[]),set_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal),N],[],[]),status:e.Func([A],[V],[]),top_up:e.Func([e.Principal,i],[],[]),unset_orbiter:e.Func([e.Principal],[],[]),unset_satellite:e.Func([e.Principal],[],[]),version:e.Func([],[e.Text],["query"])})};var Mt=({IDL:e})=>{let t=e.Record({controllers:e.Vec(e.Principal)}),r=e.Variant({Write:e.Null,Admin:e.Null}),n=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:r,expires_at:e.Opt(e.Nat64)}),o=e.Record({version:e.Opt(e.Nat64)}),i=e.Record({cycles:e.Nat,destination_id:e.Principal}),a=e.Record({to:e.Opt(e.Nat64),from:e.Opt(e.Nat64),satellite_id:e.Opt(e.Principal)}),l=e.Record({key:e.Text,collected_at:e.Nat64}),p=e.Record({inner_height:e.Nat16,inner_width:e.Nat16}),d=e.Record({title:e.Text,updated_at:e.Nat64,referrer:e.Opt(e.Text),time_zone:e.Text,session_id:e.Text,href:e.Text,created_at:e.Nat64,satellite_id:e.Principal,device:p,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),g=e.Record({safari:e.Float64,opera:e.Float64,others:e.Float64,firefox:e.Float64,chrome:e.Float64}),y=e.Record({desktop:e.Float64,others:e.Float64,mobile:e.Float64}),h=e.Record({browsers:g,devices:y}),u=e.Record({day:e.Nat8,month:e.Nat8,year:e.Int32}),m=e.Record({bounce_rate:e.Float64,average_page_views_per_session:e.Float64,daily_total_page_views:e.Vec(e.Tuple(u,e.Nat32)),total_page_views:e.Nat32,unique_page_views:e.Nat64,unique_sessions:e.Nat64}),T=e.Record({referrers:e.Vec(e.Tuple(e.Text,e.Nat32)),pages:e.Vec(e.Tuple(e.Text,e.Nat32))}),v=e.Variant({Navigate:e.Null,Restore:e.Null,Reload:e.Null,BackForward:e.Null,BackForwardCache:e.Null,Prerender:e.Null}),w=e.Record({id:e.Text,value:e.Float64,navigation_type:e.Opt(v),delta:e.Float64}),b=e.Variant({WebVitalsMetric:w}),C=e.Variant({CLS:e.Null,FCP:e.Null,INP:e.Null,LCP:e.Null,TTFB:e.Null}),x=e.Record({updated_at:e.Nat64,session_id:e.Text,data:b,href:e.Text,metric_name:C,created_at:e.Nat64,satellite_id:e.Principal,version:e.Opt(e.Nat64)}),N=e.Record({cls:e.Opt(e.Float64),fcp:e.Opt(e.Float64),inp:e.Opt(e.Float64),lcp:e.Opt(e.Float64),ttfb:e.Opt(e.Float64)}),R=e.Record({overall:N,pages:e.Vec(e.Tuple(e.Text,N))}),A=e.Record({updated_at:e.Nat64,session_id:e.Text,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),name:e.Text,created_at:e.Nat64,satellite_id:e.Principal,version:e.Opt(e.Nat64)}),V=e.Record({total:e.Vec(e.Tuple(e.Text,e.Nat32))}),M=e.Record({performance_metrics:e.Bool,track_events:e.Bool,page_views:e.Bool}),k=e.Record({updated_at:e.Nat64,features:e.Opt(M),created_at:e.Nat64,version:e.Opt(e.Nat64)}),q=e.Record({stable:e.Nat64,heap:e.Nat64}),X=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:r,expires_at:e.Opt(e.Nat64)}),j=e.Record({controller:X,controllers:e.Vec(e.Principal)}),Z=e.Record({title:e.Text,updated_at:e.Opt(e.Nat64),referrer:e.Opt(e.Text),time_zone:e.Text,session_id:e.Text,href:e.Text,satellite_id:e.Principal,device:p,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),J=e.Variant({Ok:d,Err:e.Text}),Y=e.Variant({Ok:e.Null,Err:e.Vec(e.Tuple(l,e.Text))}),z=e.Record({session_id:e.Text,data:b,href:e.Text,metric_name:C,satellite_id:e.Principal,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),et=e.Variant({Ok:x,Err:e.Text}),tt=e.Record({features:e.Opt(M),version:e.Opt(e.Nat64)}),we=e.Record({updated_at:e.Opt(e.Nat64),session_id:e.Text,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),name:e.Text,satellite_id:e.Principal,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),rt=e.Variant({Ok:A,Err:e.Text});return e.Service({del_controllers:e.Func([t],[e.Vec(e.Tuple(e.Principal,n))],[]),del_satellite_config:e.Func([e.Principal,o],[],[]),deposit_cycles:e.Func([i],[],[]),get_page_views:e.Func([a],[e.Vec(e.Tuple(l,d))],["query"]),get_page_views_analytics_clients:e.Func([a],[h],["query"]),get_page_views_analytics_metrics:e.Func([a],[m],["query"]),get_page_views_analytics_top_10:e.Func([a],[T],["query"]),get_performance_metrics:e.Func([a],[e.Vec(e.Tuple(l,x))],["query"]),get_performance_metrics_analytics_web_vitals:e.Func([a],[R],["query"]),get_track_events:e.Func([a],[e.Vec(e.Tuple(l,A))],["query"]),get_track_events_analytics:e.Func([a],[V],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["query"]),list_satellite_configs:e.Func([],[e.Vec(e.Tuple(e.Principal,k))],["query"]),memory_size:e.Func([],[q],["query"]),set_controllers:e.Func([j],[e.Vec(e.Tuple(e.Principal,n))],[]),set_page_view:e.Func([l,Z],[J],[]),set_page_views:e.Func([e.Vec(e.Tuple(l,Z))],[Y],[]),set_performance_metric:e.Func([l,z],[et],[]),set_performance_metrics:e.Func([e.Vec(e.Tuple(l,z))],[Y],[]),set_satellite_configs:e.Func([e.Vec(e.Tuple(e.Principal,tt))],[e.Vec(e.Tuple(e.Principal,k))],[]),set_track_event:e.Func([l,we],[rt],[]),set_track_events:e.Func([e.Vec(e.Tuple(l,we))],[Y],[]),version:e.Func([],[e.Text],["query"])})};var Bt=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Record({controllers:e.Vec(e.Principal)}),n=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,expires_at:e.Opt(e.Nat64)}),o=e.Record({updated_at:e.Opt(e.Nat64)}),i=e.Record({headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text))))}),a=e.Record({storage:i}),l=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),created_at:e.Nat64}),p=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text))}),d=e.Record({token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),g=e.Variant({Callback:e.Record({token:d,callback:e.Func([],[],[])})}),y=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(g),status_code:e.Nat16}),h=e.Record({token:e.Opt(d),body:e.Vec(e.Nat8)}),u=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,encoding_type:e.Opt(e.Text),full_path:e.Text}),m=e.Record({batch_id:e.Nat}),T=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),v=e.Record({field:T,desc:e.Bool}),w=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),b=e.Record({order:e.Opt(v),owner:e.Opt(e.Principal),matcher:e.Opt(e.Text),paginate:e.Opt(w)}),C=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),x=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),N=e.Record({key:C,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,x)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),R=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,N))}),A=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Opt(e.Text)}),V=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,l))}),M=e.Variant({Db:e.Null,Storage:e.Null}),k=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),q=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:k,created_at:e.Nat64,write:k}),X=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),expires_at:e.Opt(e.Nat64)}),j=e.Record({controller:X,controllers:e.Vec(e.Principal)}),Z=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),J=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:k,write:k}),Y=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),z=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([t],[],[]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Opt(e.Text)],[],[]),del_controllers:e.Func([r],[e.Vec(e.Tuple(e.Principal,n))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,o],[],[]),get_config:e.Func([],[a],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(l)],["query"]),http_request:e.Func([p],[y],["query"]),http_request_streaming_callback:e.Func([d],[h],["query"]),init_asset_upload:e.Func([u],[m],[]),list_assets:e.Func([e.Opt(e.Text),b],[R],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,A))],["query"]),list_docs:e.Func([e.Text,b],[V],["query"]),list_rules:e.Func([M],[e.Vec(e.Tuple(e.Text,q))],["query"]),set_config:e.Func([a],[],[]),set_controllers:e.Func([j],[e.Vec(e.Tuple(e.Principal,n))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_doc:e.Func([e.Text,e.Text,Z],[l],[]),set_rule:e.Func([M,e.Text,J],[],[]),upload_asset_chunk:e.Func([Y],[z],[]),version:e.Func([],[e.Text],["query"])})};var Ut=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Record({controllers:e.Vec(e.Principal)}),n=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,expires_at:e.Opt(e.Nat64)}),o=e.Record({updated_at:e.Opt(e.Nat64)}),i=e.Record({headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text))))}),a=e.Record({storage:i}),l=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),created_at:e.Nat64}),p=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text))}),d=e.Record({token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),g=e.Variant({Callback:e.Record({token:d,callback:e.Func([],[],[])})}),y=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(g),status_code:e.Nat16}),h=e.Record({token:e.Opt(d),body:e.Vec(e.Nat8)}),u=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,encoding_type:e.Opt(e.Text),full_path:e.Text}),m=e.Record({batch_id:e.Nat}),T=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),v=e.Record({field:T,desc:e.Bool}),w=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),b=e.Record({order:e.Opt(v),matcher:e.Opt(e.Text),paginate:e.Opt(w)}),C=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),x=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),N=e.Record({key:C,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,x)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),R=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,N))}),A=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Opt(e.Text)}),V=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,l))}),M=e.Variant({Db:e.Null,Storage:e.Null}),k=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),q=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:k,created_at:e.Nat64,write:k}),X=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),expires_at:e.Opt(e.Nat64)}),j=e.Record({controller:X,controllers:e.Vec(e.Principal)}),Z=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),J=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:k,write:k}),Y=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),z=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([t],[],[]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Opt(e.Text)],[],[]),del_controllers:e.Func([r],[e.Vec(e.Tuple(e.Principal,n))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,o],[],[]),get_config:e.Func([],[a],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(l)],["query"]),http_request:e.Func([p],[y],["query"]),http_request_streaming_callback:e.Func([d],[h],["query"]),init_asset_upload:e.Func([u],[m],[]),list_assets:e.Func([e.Opt(e.Text),b],[R],["query"]),list_controllers:e.Func([],[e.Vec(e.Principal)],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,A))],["query"]),list_docs:e.Func([e.Text,b],[V],["query"]),list_rules:e.Func([M],[e.Vec(e.Tuple(e.Text,q))],["query"]),set_config:e.Func([a],[],[]),set_controllers:e.Func([j],[e.Vec(e.Tuple(e.Principal,n))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_doc:e.Func([e.Text,e.Text,Z],[l],[]),set_rule:e.Func([M,e.Text,J],[],[]),upload_asset_chunk:e.Func([Y],[z],[]),version:e.Func([],[e.Text],["query"])})};var $t=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),n=e.Record({field:r,desc:e.Bool}),o=e.Variant({Equal:e.Nat64,Between:e.Tuple(e.Nat64,e.Nat64),GreaterThan:e.Nat64,LessThan:e.Nat64}),i=e.Record({key:e.Opt(e.Text),updated_at:e.Opt(o),description:e.Opt(e.Text),created_at:e.Opt(o)}),a=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),l=e.Record({order:e.Opt(n),owner:e.Opt(e.Principal),matcher:e.Opt(i),paginate:e.Opt(a)}),p=e.Record({controllers:e.Vec(e.Principal)}),d=e.Variant({Write:e.Null,Admin:e.Null}),g=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:d,expires_at:e.Opt(e.Nat64)}),y=e.Record({version:e.Opt(e.Nat64)}),h=e.Variant({Db:e.Null,Storage:e.Null}),u=e.Record({version:e.Opt(e.Nat64)}),m=e.Record({cycles:e.Nat,destination_id:e.Principal}),T=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,description:e.Opt(e.Text),full_path:e.Text}),v=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),w=e.Record({key:T,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,v)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),b=e.Record({derivation_origin:e.Opt(e.Text)}),C=e.Record({internet_identity:e.Opt(b)}),x=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),N=e.Record({max_memory_size:e.Opt(x)}),R=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),A=e.Variant({Deny:e.Null,Allow:e.Null}),V=e.Record({status_code:e.Nat16,location:e.Text}),M=e.Record({iframe:e.Opt(R),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),max_memory_size:e.Opt(x),raw_access:e.Opt(A),redirects:e.Opt(e.Vec(e.Tuple(e.Text,V)))}),k=e.Record({db:e.Opt(N),authentication:e.Opt(C),storage:M}),q=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),description:e.Opt(e.Text),created_at:e.Nat64,version:e.Opt(e.Nat64)}),X=e.Variant({Heap:e.Null,Stable:e.Null}),j=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),Z=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),J=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(X),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:j,created_at:e.Nat64,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(Z),write:j}),Y=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),certificate_version:e.Opt(e.Nat16)}),z=e.Record({memory:X,token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),et=e.Variant({Callback:e.Record({token:z,callback:e.Func([],[],["query"])})}),tt=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(et),status_code:e.Nat16}),we=e.Record({token:e.Opt(z),body:e.Vec(e.Nat8)}),rt=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,description:e.Opt(e.Text),encoding_type:e.Opt(e.Text),full_path:e.Text}),_n=e.Record({batch_id:e.Nat}),gn=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,w)),items_length:e.Nat64}),Tn=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),bn=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,q)),items_length:e.Nat64}),xn=e.Record({stable:e.Nat64,heap:e.Nat64}),wn=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:d,expires_at:e.Opt(e.Nat64)}),Pn=e.Record({controller:wn,controllers:e.Vec(e.Principal)}),Vt=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),vn=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(X),max_size:e.Opt(e.Nat),read:j,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(Z),write:j}),Cn=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),Nn=e.Record({chunk_id:e.Nat});return e.Service({build_version:e.Func([],[e.Text],["query"]),commit_asset_upload:e.Func([t],[],[]),count_assets:e.Func([e.Text,l],[e.Nat64],["query"]),count_collection_assets:e.Func([e.Text],[e.Nat64],["query"]),count_collection_docs:e.Func([e.Text],[e.Nat64],["query"]),count_docs:e.Func([e.Text,l],[e.Nat64],["query"]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Text],[],[]),del_controllers:e.Func([p],[e.Vec(e.Tuple(e.Principal,g))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,y],[],[]),del_docs:e.Func([e.Text],[],[]),del_filtered_assets:e.Func([e.Text,l],[],[]),del_filtered_docs:e.Func([e.Text,l],[],[]),del_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[],[]),del_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,y))],[],[]),del_rule:e.Func([h,e.Text,u],[],[]),deposit_cycles:e.Func([m],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(w)],["query"]),get_auth_config:e.Func([],[e.Opt(C)],["query"]),get_config:e.Func([],[k],[]),get_db_config:e.Func([],[e.Opt(N)],["query"]),get_doc:e.Func([e.Text,e.Text],[e.Opt(q)],["query"]),get_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(w)))],["query"]),get_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(q)))],["query"]),get_rule:e.Func([h,e.Text],[e.Opt(J)],["query"]),get_storage_config:e.Func([],[M],["query"]),http_request:e.Func([Y],[tt],["query"]),http_request_streaming_callback:e.Func([z],[we],["query"]),init_asset_upload:e.Func([rt],[_n],[]),list_assets:e.Func([e.Text,l],[gn],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,g))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,Tn))],["query"]),list_docs:e.Func([e.Text,l],[bn],["query"]),list_rules:e.Func([h],[e.Vec(e.Tuple(e.Text,J))],["query"]),memory_size:e.Func([],[xn],["query"]),set_auth_config:e.Func([C],[],[]),set_controllers:e.Func([Pn],[e.Vec(e.Tuple(e.Principal,g))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_db_config:e.Func([N],[],[]),set_doc:e.Func([e.Text,e.Text,Vt],[q],[]),set_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,Vt))],[e.Vec(e.Tuple(e.Text,q))],[]),set_rule:e.Func([h,e.Text,vn],[J],[]),set_storage_config:e.Func([M],[],[]),upload_asset_chunk:e.Func([Cn],[Nn],[]),version:e.Func([],[e.Text],["query"])})};import{Actor as En,HttpAgent as kn}from"@dfinity/agent";import{nonNullish as qt}from"@junobuild/utils";var jt=async({canisterId:e,idlFactory:t,config:r,...n})=>{let o=await $(n);return En.createActor(t,{agent:o,canisterId:e,...r??{}})},$=async({agent:e,...t})=>e??await Mn(t),Mn=async({identity:e,fetch:t,container:r})=>{let n=qt(r)&&r!==!1,o=n?r===!0?"http://127.0.0.1:5987":r:"https://icp-api.io";return await kn.create({identity:e,host:o,retryTimes:10,...qt(t)&&{fetch:t},shouldFetchRootKey:n})};var zt=({satelliteId:e,...t})=>me({canisterId:e,...t,idlFactory:Ut}),O=({satelliteId:e,...t})=>me({canisterId:e,...t,idlFactory:$t}),Ht=({satelliteId:e,...t})=>me({canisterId:e,...t,idlFactory:Bt}),ie=({missionControlId:e,...t})=>me({canisterId:e,...t,idlFactory:kt}),ve=({orbiterId:e,...t})=>me({canisterId:e,...t,idlFactory:Mt}),me=({canisterId:e,idlFactory:t,...r})=>{if(Bn(e))throw new Error("No canister ID provided.");return jt({canisterId:e,idlFactory:t,...r})};var Kt=async({missionControl:e})=>(await ie(e)).version(),Wt=async({missionControl:e})=>(await ie(e)).get_user(),Gt=async({missionControl:e})=>(await ie(e)).list_mission_control_controllers(),Xt=async({missionControl:e,satelliteIds:t,controllerIds:r,controller:n})=>(await ie(e)).set_satellites_controllers(t,r,n),Zt=async({missionControl:e,controllerIds:t,controller:r})=>(await ie(e)).set_mission_control_controllers(t,r);import{Principal as Un}from"@dfinity/principal";import{nonNullish as $n,toNullable as qn}from"@junobuild/utils";var nt=({controllerId:e,profile:t})=>({controllerIds:[Un.fromText(e)],controller:jn(t)}),jn=e=>({metadata:$n(e)&&e!==""?[["profile",e]]:[],expires_at:qn(void 0),scope:{Admin:null}});var ui=({controllerId:e,profile:t,...r})=>Xt({...r,...nt({controllerId:e,profile:t})}),di=({controllerId:e,profile:t,...r})=>Zt({...r,...nt({controllerId:e,profile:t})}),pi=e=>Gt(e);import{Principal as Vo}from"@dfinity/principal";var fe={reinstall:null},ne={upgrade:[{skip_pre_upgrade:[!1],wasm_memory_persistence:[{replace:null}]}]};import{fromNullable as In,isNullish as Dn}from"@junobuild/utils";import{CanisterStatus as zn}from"@dfinity/agent";import{ICManagementCanister as H}from"@dfinity/ic-management";import{Principal as Hn}from"@dfinity/principal";import{assertNonNullish as Kn}from"@junobuild/utils";var Jt=async({canisterId:e,actor:t})=>{let r=await $(t),{stopCanister:n}=H.create({agent:r});await n(e)},Yt=async({canisterId:e,actor:t})=>{let r=await $(t),{startCanister:n}=H.create({agent:r});await n(e)},Qt=async({actor:e,code:t})=>{let r=await $(e),{installCode:n}=H.create({agent:r});return n(t)},It=async({actor:e,canisterId:t})=>{let r=await $(e),{storedChunks:n}=H.create({agent:r});return n({canisterId:t})},Ce=async({actor:e,canisterId:t})=>{let r=await $(e),{clearChunkStore:n}=H.create({agent:r});return n({canisterId:t})},Dt=async({actor:e,chunk:t})=>{let r=await $(e),{uploadChunk:n}=H.create({agent:r});return n(t)},Lt=async({actor:e,code:t})=>{let r=await $(e),{installChunkedCode:n}=H.create({agent:r});return n(t)},er=async({actor:e,canisterId:t})=>{let r=await $(e),{canisterStatus:n}=H.create({agent:r});return n(t)},tr=async({canisterId:e,path:t,...r})=>{Kn(e,"A canister ID must be provided to request its status.");let n=await $(r);return(await zn.request({canisterId:Hn.from(e),agent:n,paths:[{kind:"metadata",key:t,path:t,decodeStrategy:"utf-8"}]})).get(t)},rr=async({actor:e,canisterId:t})=>{let r=await $(e),{listCanisterSnapshots:n}=H.create({agent:r});return n({canisterId:t})},nr=async({actor:e,...t})=>{let r=await $(e),{takeCanisterSnapshot:n}=H.create({agent:r});return n(t)};var or=(i=>(i[i.AssertingExistingCode=0]="AssertingExistingCode",i[i.StoppingCanister=1]="StoppingCanister",i[i.TakingSnapshot=2]="TakingSnapshot",i[i.UpgradingCode=3]="UpgradingCode",i[i.RestartingCanister=4]="RestartingCanister",i))(or||{});var Ne=e=>(e instanceof Uint8Array||(e=Uint8Array.from(e)),e.reduce((t,r)=>t+r.toString(16).padStart(2,"0"),""));var ir=e=>crypto.subtle.digest("SHA-256",e),sr=e=>Array.from(new Uint8Array(e)).map(r=>r.toString(16).padStart(2,"0")).join(""),ar=async e=>{let t=await ir(await e.arrayBuffer());return sr(t)},Se=async e=>{let t=await ir(e);return sr(t)};import{isNullish as Gn,nonNullish as cr}from"@junobuild/utils";var lr=async({actor:e,canisterId:t,missionControlId:r,wasmModule:n,preClearChunks:o,...i})=>{o&&await Ce({actor:e,canisterId:t});let a=await Xn({wasmModule:n}),{uploadChunks:l,storedChunks:p,preClearChunks:d,postClearChunks:g}=await Zn({actor:e,wasmChunks:a,canisterId:t,missionControlId:r});d&&await Ce({actor:e,canisterId:t});let y=[];for await(let h of Jn({uploadChunks:l,actor:e,canisterId:t,missionControlId:r}))y=[...y,...h];await Lt({actor:e,code:{...i,chunkHashesList:[...y,...p].sort(({orderId:h},{orderId:u})=>h-u).map(({chunkHash:h})=>h),targetCanisterId:t,storeCanisterId:r,wasmModuleHash:await Se(n)}}),g&&await Ce({actor:e,canisterId:t})},Xn=async({wasmModule:e})=>{let t=new Blob([e]),r=[],n=1e6,o=0;for(let i=0;i<t.size;i+=n){let a=t.slice(i,i+n);r.push({chunk:a,orderId:o,sha256:await ar(a)}),o++}return r},Zn=async({canisterId:e,missionControlId:t,actor:r,wasmChunks:n})=>{let o=await It({actor:r,canisterId:t??e}),i=o.map(({hash:p})=>({chunkHash:{hash:p},sha256:Ne(p)})),{storedChunks:a,uploadChunks:l}=n.reduce(({uploadChunks:p,storedChunks:d},{sha256:g,...y})=>{let h=i.find(({sha256:u})=>u===g);return{uploadChunks:[...p,...cr(h)?[]:[{sha256:g,...y}]],storedChunks:[...d,...cr(h)?[{...y,...h}]:[]]}},{uploadChunks:[],storedChunks:[]});return{uploadChunks:l,storedChunks:a,preClearChunks:o.length>0&&a.length===0,postClearChunks:Gn(t)}};async function*Jn({uploadChunks:e,limit:t=12,...r}){for(let n=0;n<e.length;n=n+t){let o=e.slice(n,n+t);yield await Promise.all(o.map(a=>Yn({uploadChunk:a,...r})))}}var Yn=async({actor:e,canisterId:t,missionControlId:r,uploadChunk:{chunk:n,...o}})=>({chunkHash:await Dt({actor:e,chunk:{canisterId:r??t,chunk:new Uint8Array(await n.arrayBuffer())}}),...o});var ur=async({actor:e,...t})=>{await Qt({actor:e,code:t})};var I=async({wasmModule:e,canisterId:t,actor:r,onProgress:n,takeSnapshot:o=!0,...i})=>{await he({fn:async()=>await Ln({wasmModule:e,canisterId:t,actor:r,...i}),onProgress:n,step:0}),await he({fn:async()=>await Jt({canisterId:t,actor:r}),onProgress:n,step:1});try{await he({fn:async()=>o?await to({canisterId:t,actor:r}):Promise.resolve(),onProgress:n,step:2}),await he({fn:async()=>await eo({wasmModule:e,canisterId:t,actor:r,...i}),onProgress:n,step:3})}finally{await he({fn:async()=>await Yt({canisterId:t,actor:r}),onProgress:n,step:4})}},he=async({fn:e,step:t,onProgress:r})=>{r?.({step:t,state:"in_progress"});try{await e(),r?.({step:t,state:"success"})}catch(n){throw r?.({step:t,state:"error"}),n}},Ln=async({actor:e,canisterId:t,wasmModule:r,reset:n})=>{if(n===!0)return;let{module_hash:o}=await er({actor:e,canisterId:t}),i=In(o);if(Dn(i))return;let a=await Se(r),l=Ne(i);if(a===l)throw new Pe},eo=async({wasmModule:e,canisterId:t,actor:r,...n})=>{await((new Blob([e]).size>2e6?"chunked":"single")==="chunked"?lr:ur)({wasmModule:e,canisterId:t,actor:r,...n})},to=async e=>{let t=await rr(e);await nr({...e,snapshotId:t?.[0]?.id})};var te=Et(Ct(),1),Or=e=>te.IDL.encode([te.IDL.Record({user:te.IDL.Principal})],[{user:e}]),Je=e=>te.IDL.encode([te.IDL.Record({controllers:te.IDL.Vec(te.IDL.Principal)})],[{controllers:e.map(([t,r])=>t)}]);var as=async({missionControl:e,...t})=>{let r=await Wt({missionControl:e}),{missionControlId:n,...o}=e;if(!n)throw new Error("No mission control principal defined.");let i=Or(r);await I({actor:o,canisterId:Vo.fromText(n),arg:new Uint8Array(i),mode:ne,...t})};var us=e=>Kt(e);var ms=async e=>{await I(e)};var Fr=async({orbiter:e})=>(await ve(e)).version(),Ye=async({orbiter:e})=>(await ve(e)).list_controllers(),Er=async({orbiter:e})=>{let{memory_size:t}=await ve(e);return t()};var gs=e=>Ye(e);var xs=e=>Er(e);import{Principal as Oo}from"@dfinity/principal";var Rs=async({orbiter:e,reset:t=!1,...r})=>{let{orbiterId:n,...o}=e;if(!n)throw new Error("No orbiter principal defined.");let i=await Ye({orbiter:e}),a=Je(i);await I({actor:o,canisterId:Oo.fromText(n),arg:new Uint8Array(a),mode:t?fe:ne,reset:t,...r})};var Os=e=>Fr(e);import{major as kr,minor as Mr,patch as Br}from"semver";var ks=({currentVersion:e,selectedVersion:t})=>{let r=kr(e),n=kr(t),o=Mr(e),i=Mr(t),a=Br(e),l=Br(t);return r<n-1||o<i-1||a<l-1?{canUpgrade:!1}:{canUpgrade:!0}};import{toNullable as Fo}from"@junobuild/utils";var Ur=async({config:e,satellite:t})=>{let{set_storage_config:r}=await O(t);return r(e)},$r=async({config:e,satellite:t})=>{let{set_db_config:r}=await O(t);return r(e)},qr=async({config:e,satellite:t})=>{let{set_auth_config:r}=await O(t);return r(e)};var jr=async({satellite:e})=>{let{get_auth_config:t}=await O(e);return t()},zr=async({satellite:e,type:t})=>(await O(e)).list_rules(t),Hr=async({type:e,collection:t,rule:r,satellite:n})=>{let{set_rule:o}=await O(n);return o(e,t,r)},Kr=async({satellite:e})=>{let{version:t}=await O(e);return t()},Wr=async({satellite:e})=>{let{build_version:t}=await O(e);return t()},Gr=async({satellite:e})=>(await zt(e)).list_controllers(),Qe=async({satellite:e})=>(await Ht(e)).list_controllers(),Ie=async({satellite:e})=>(await O(e)).list_controllers(),Xr=async({satellite:e})=>{let{list_custom_domains:t}=await O(e);return t()},Zr=async({satellite:e,domainName:t,boundaryNodesId:r})=>{let{set_custom_domain:n}=await O(e);await n(t,Fo(r))},Jr=async({satellite:e})=>{let{memory_size:t}=await O(e);return t()},Yr=async({collection:e,satellite:t})=>{let{count_collection_docs:r}=await O(t);return r(e)},Qr=async({collection:e,satellite:t})=>{let{count_collection_assets:r}=await O(t);return r(e)},Ir=async({collection:e,satellite:t})=>{let{del_docs:r}=await O(t);return r(e)},Dr=async({collection:e,satellite:t})=>{let{del_assets:r}=await O(t);return r(e)},Lr=async({args:e,satellite:t})=>{let{set_controllers:r}=await O(t);return r(e)};var js=e=>Qr(e),zs=e=>Dr(e);import{fromNullable as De,isNullish as tn,nonNullish as en}from"@junobuild/utils";import{nonNullish as Eo,toNullable as Nt}from"@junobuild/utils";var St=e=>Nt(Eo(e)?{heap:Nt(e.heap),stable:Nt(e.stable)}:void 0);var Js=async({config:{headers:e,rewrites:t,redirects:r,iframe:n,rawAccess:o,maxMemorySize:i},satellite:a})=>{let l=(e??[]).map(({source:h,headers:u})=>[h,u]),p=(t??[]).map(({source:h,destination:u})=>[h,u]),d=(r??[]).map(({source:h,location:u,code:m})=>[h,{status_code:m,location:u}]);return await Ur({satellite:a,config:{headers:l,rewrites:p,redirects:[d],iframe:[n==="same-origin"?{SameOrigin:null}:n==="allow-any"?{AllowAny:null}:{Deny:null}],raw_access:[o===!0?{Allow:null}:{Deny:null}],max_memory_size:St(i)}})},Ys=async({config:{maxMemorySize:e},...t})=>{await $r({config:{max_memory_size:St(e)},...t})},Qs=async({config:{internetIdentity:e},...t})=>{await qr({config:{internet_identity:tn(e?.derivationOrigin)?[]:[{derivation_origin:[e.derivationOrigin]}]},...t})},Is=async({satellite:e})=>{let t=De(await jr({satellite:e}));if(tn(t))return;let r=De(t.internet_identity??[]);return{...en(r)&&{internetIdentity:{...en(De(r.derivation_origin))&&{derivationOrigin:De(r.derivation_origin)}}}}};var ea=({deprecatedNoScope:e,...t})=>(e===!0?Qe:Ie)(t),ta=e=>Lr(e);var oa=e=>Yr(e),ia=e=>Ir(e);import{fromNullable as rn,nonNullish as ko}from"@junobuild/utils";var la=async({satellite:e})=>(await Xr({satellite:e})).map(([r,n])=>{let o=rn(n.version);return{domain:r,bn_id:rn(n.bn_id),created_at:n.created_at,updated_at:n.updated_at,...ko(o)&&{version:o}}}),ua=({satellite:e,domains:t})=>Promise.all(t.map(({domain:r,bn_id:n})=>Zr({satellite:e,domainName:r,boundaryNodesId:n})));var ma=e=>Jr(e);import{fromNullable as pe,nonNullish as re,toNullable as Le}from"@junobuild/utils";var nn={Db:null},on={Storage:null},sn={Public:null},an={Private:null},cn={Managed:null},ln={Controllers:null},Rt={Heap:null},un={Stable:null},dn=600000000n;var At=e=>e==="storage"?on:nn,fn=({read:e,write:t,memory:r,maxSize:n,maxCapacity:o,version:i,mutablePermissions:a,maxTokens:l})=>({read:mn(e),write:mn(t),memory:re(r)?[Mo(r)]:[],version:Le(i),max_size:Le(re(n)&&n>0?BigInt(n):void 0),max_capacity:Le(re(o)&&o>0?o:void 0),mutable_permissions:Le(a),rate_config:re(l)?[{max_tokens:BigInt(l),time_per_token_ns:dn}]:[]}),hn=([e,t])=>{let{read:r,write:n,updated_at:o,created_at:i,max_size:a,max_capacity:l,memory:p,mutable_permissions:d,version:g,rate_config:y}=t,h=a?.[0]??0n>0n?Number(pe(a)):void 0,u=l?.[0]??!1?pe(l):void 0,m=pe(g),T=y?.[0]?.max_tokens??0n>0n?pe(y)?.max_tokens:void 0;return{collection:e,read:pn(r),write:pn(n),memory:Bo(pe(p)??Rt),updatedAt:o,createdAt:i,...re(m)&&{version:m},...re(h)&&{maxSize:h},...re(u)&&{maxCapacity:u},mutablePermissions:pe(d)??!0,...re(T)&&{maxTokens:Number(T)}}},pn=e=>"Public"in e?"public":"Private"in e?"private":"Managed"in e?"managed":"controllers",mn=e=>{switch(e){case"public":return sn;case"private":return an;case"managed":return cn;default:return ln}},Mo=e=>{switch(e.toLowerCase()){case"heap":return Rt;default:return un}},Bo=e=>"Heap"in e?"heap":"stable";var xa=async({type:e,satellite:t})=>(await zr({satellite:t,type:At(e)})).map(n=>hn(n)),wa=async({rule:{collection:e,...t},type:r,satellite:n})=>{await Hr({type:At(r),rule:fn(t),satellite:n,collection:e})};var xe=Et(Ct(),1);import{Principal as yn}from"@dfinity/principal";import{isNullish as Uo}from"@junobuild/utils";var Va=async({satellite:e,deprecated:t,deprecatedNoScope:r,reset:n=!1,...o})=>{let{satelliteId:i,...a}=e;if(Uo(i))throw new Error("No satellite principal defined.");if(t){let g=await Gr({satellite:e}),y=xe.IDL.encode([xe.IDL.Record({controllers:xe.IDL.Vec(xe.IDL.Principal)})],[{controllers:g}]);await I({actor:a,canisterId:yn.fromText(i),arg:new Uint8Array(y),mode:n?fe:ne,reset:n,...o});return}let p=await(r?Qe:Ie)({satellite:e}),d=Je(p);await I({actor:a,canisterId:yn.fromText(i),arg:new Uint8Array(d),mode:n?fe:ne,reset:n,...o})};import{nonNullish as $o}from"@junobuild/utils";var Ma=e=>Kr(e),Ba=e=>Wr(e),Ua=async({satellite:{satelliteId:e,...t}})=>{let r=await tr({...t,canisterId:e,path:"juno:build"});return $o(r)&&["stock","extended"].includes(r)?r:void 0};export{or as UpgradeCodeProgressStep,Pe as UpgradeCodeUnchangedError,ar as blobSha256,ks as checkUpgradeVersion,js as countAssets,oa as countDocs,zs as deleteAssets,ia as deleteDocs,Is as getAuthConfig,la as listCustomDomains,pi as listMissionControlControllers,gs as listOrbiterControllers,xa as listRules,ea as listSatelliteControllers,us as missionControlVersion,xs as orbiterMemorySize,Os as orbiterVersion,Ua as satelliteBuildType,Ba as satelliteBuildVersion,ma as satelliteMemorySize,Ma as satelliteVersion,Qs as setAuthConfig,ua as setCustomDomains,Ys as setDatastoreConfig,di as setMissionControlController,wa as setRule,ta as setSatelliteControllers,ui as setSatellitesController,Js as setStorageConfig,Se as uint8ArraySha256,as as upgradeMissionControl,ms as upgradeModule,Rs as upgradeOrbiter,Va as upgradeSatellite};
|
|
3
|
+
var $=class extends Error{constructor(){super("The Wasm code for the upgrade is identical to the code currently installed. No upgrade is necessary.")}};import{isNullish as Ge}from"@junobuild/utils";var gt=({IDL:t})=>{let e=t.Record({fund_cycles:t.Nat,min_cycles:t.Nat}),r=t.Variant({BelowThreshold:e}),o=t.Record({strategy:t.Opt(r),enabled:t.Bool}),a=t.Record({cycles:t.Opt(o)}),s=t.Record({monitoring:t.Opt(a)}),n=t.Record({updated_at:t.Nat64,orbiter_id:t.Principal,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,settings:t.Opt(s)}),i=t.Record({subnet_id:t.Opt(t.Principal),name:t.Opt(t.Text)}),l=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,satellite_id:t.Principal,settings:t.Opt(s)}),p=t.Record({cycles:t.Nat,destination_id:t.Principal}),m=t.Record({to:t.Opt(t.Text),enabled:t.Bool}),u=t.Record({notification:t.Opt(m),default_strategy:t.Opt(r)}),c=t.Record({cycles:t.Opt(u)}),d=t.Record({monitoring:t.Opt(c)}),g=t.Record({to:t.Opt(t.Nat64),from:t.Opt(t.Nat64),segment_id:t.Principal}),C=t.Record({segment_id:t.Principal,created_at:t.Nat64,nonce:t.Int32}),M=t.Record({timestamp:t.Nat64,amount:t.Nat}),F=t.Record({deposited_cycles:t.Opt(M),cycles:M}),N=t.Record({cycles:t.Opt(F)}),h=t.Record({monitored_ids:t.Vec(t.Principal),running:t.Bool}),V=t.Record({cycles:t.Opt(h)}),S=t.Record({updated_at:t.Nat64,created_at:t.Nat64,monitoring:t.Opt(a)}),U=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),user:t.Opt(t.Principal),created_at:t.Nat64,config:t.Opt(d)}),x=t.Record({e8s:t.Nat64}),q=t.Record({timestamp_nanos:t.Nat64}),f=t.Record({to:t.Vec(t.Nat8),fee:x,memo:t.Nat64,from_subaccount:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(q),amount:x}),y=t.Variant({TxTooOld:t.Record({allowed_window_nanos:t.Nat64}),BadFee:t.Record({expected_fee:x}),TxDuplicate:t.Record({duplicate_of:t.Nat64}),TxCreatedInFuture:t.Null,InsufficientFunds:t.Record({balance:x})}),T=t.Variant({Ok:t.Nat64,Err:y}),b=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),R=t.Record({to:b,fee:t.Opt(t.Nat),memo:t.Opt(t.Vec(t.Nat8)),from_subaccount:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat}),k=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,BadBurn:t.Record({min_burn_amount:t.Nat}),Duplicate:t.Record({duplicate_of:t.Nat}),BadFee:t.Record({expected_fee:t.Nat}),CreatedInFuture:t.Record({ledger_time:t.Nat64}),TooOld:t.Null,InsufficientFunds:t.Record({balance:t.Nat})}),w=t.Variant({Ok:t.Nat,Err:k}),O=t.Variant({Write:t.Null,Admin:t.Null}),A=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:O,expires_at:t.Opt(t.Nat64)}),z=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:O,expires_at:t.Opt(t.Nat64)}),W=t.Record({ids:t.Vec(t.Principal),strategy:r}),G=t.Record({orbiters_strategy:t.Opt(W),mission_control_strategy:t.Opt(r),satellites_strategy:t.Opt(W)}),Z=t.Record({cycles_config:t.Opt(G)}),ct=t.Record({satellite_ids:t.Opt(t.Vec(t.Principal)),try_mission_control:t.Opt(t.Bool),orbiter_ids:t.Opt(t.Vec(t.Principal))}),lt=t.Record({cycles_config:t.Opt(ct)});return t.Service({add_mission_control_controllers:t.Func([t.Vec(t.Principal)],[],[]),add_satellites_controllers:t.Func([t.Vec(t.Principal),t.Vec(t.Principal)],[],[]),create_orbiter:t.Func([t.Opt(t.Text)],[n],[]),create_orbiter_with_config:t.Func([i],[n],[]),create_satellite:t.Func([t.Text],[l],[]),create_satellite_with_config:t.Func([i],[l],[]),del_mission_control_controllers:t.Func([t.Vec(t.Principal)],[],[]),del_orbiter:t.Func([t.Principal,t.Nat],[],[]),del_orbiters_controllers:t.Func([t.Vec(t.Principal),t.Vec(t.Principal)],[],[]),del_satellite:t.Func([t.Principal,t.Nat],[],[]),del_satellites_controllers:t.Func([t.Vec(t.Principal),t.Vec(t.Principal)],[],[]),deposit_cycles:t.Func([p],[],[]),get_config:t.Func([],[t.Opt(d)],["query"]),get_metadata:t.Func([],[t.Vec(t.Tuple(t.Text,t.Text))],["query"]),get_monitoring_history:t.Func([g],[t.Vec(t.Tuple(C,N))],["query"]),get_monitoring_status:t.Func([],[V],["query"]),get_settings:t.Func([],[t.Opt(S)],["query"]),get_user:t.Func([],[t.Principal],["query"]),get_user_data:t.Func([],[U],["query"]),icp_transfer:t.Func([f],[T],[]),icrc_transfer:t.Func([t.Principal,R],[w],[]),list_mission_control_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,A))],["query"]),list_orbiters:t.Func([],[t.Vec(t.Tuple(t.Principal,n))],["query"]),list_satellites:t.Func([],[t.Vec(t.Tuple(t.Principal,l))],["query"]),remove_mission_control_controllers:t.Func([t.Vec(t.Principal)],[],[]),remove_satellites_controllers:t.Func([t.Vec(t.Principal),t.Vec(t.Principal)],[],[]),set_config:t.Func([t.Opt(d)],[],[]),set_metadata:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[],[]),set_mission_control_controllers:t.Func([t.Vec(t.Principal),z],[],[]),set_orbiter:t.Func([t.Principal,t.Opt(t.Text)],[n],[]),set_orbiter_metadata:t.Func([t.Principal,t.Vec(t.Tuple(t.Text,t.Text))],[n],[]),set_orbiters_controllers:t.Func([t.Vec(t.Principal),t.Vec(t.Principal),z],[],[]),set_satellite:t.Func([t.Principal,t.Opt(t.Text)],[l],[]),set_satellite_metadata:t.Func([t.Principal,t.Vec(t.Tuple(t.Text,t.Text))],[l],[]),set_satellites_controllers:t.Func([t.Vec(t.Principal),t.Vec(t.Principal),z],[],[]),start_monitoring:t.Func([],[],[]),stop_monitoring:t.Func([],[],[]),top_up:t.Func([t.Principal,x],[],[]),unset_orbiter:t.Func([t.Principal],[],[]),unset_satellite:t.Func([t.Principal],[],[]),update_and_start_monitoring:t.Func([Z],[],[]),update_and_stop_monitoring:t.Func([lt],[],[]),version:t.Func([],[t.Text],["query"])})};var xt=({IDL:t})=>{let e=t.Record({controllers:t.Vec(t.Principal)}),r=t.Variant({Write:t.Null,Admin:t.Null}),o=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:r,expires_at:t.Opt(t.Nat64)}),a=t.Record({version:t.Opt(t.Nat64)}),s=t.Record({cycles:t.Nat,destination_id:t.Principal}),n=t.Record({to:t.Opt(t.Nat64),from:t.Opt(t.Nat64),satellite_id:t.Opt(t.Principal)}),i=t.Record({key:t.Text,collected_at:t.Nat64}),l=t.Record({inner_height:t.Nat16,inner_width:t.Nat16}),p=t.Record({title:t.Text,updated_at:t.Nat64,referrer:t.Opt(t.Text),time_zone:t.Text,session_id:t.Text,href:t.Text,created_at:t.Nat64,satellite_id:t.Principal,device:l,version:t.Opt(t.Nat64),user_agent:t.Opt(t.Text)}),m=t.Record({safari:t.Float64,opera:t.Float64,others:t.Float64,firefox:t.Float64,chrome:t.Float64}),u=t.Record({desktop:t.Float64,others:t.Float64,mobile:t.Float64}),c=t.Record({browsers:m,devices:u}),d=t.Record({day:t.Nat8,month:t.Nat8,year:t.Int32}),g=t.Record({bounce_rate:t.Float64,average_page_views_per_session:t.Float64,daily_total_page_views:t.Vec(t.Tuple(d,t.Nat32)),total_page_views:t.Nat32,unique_page_views:t.Nat64,unique_sessions:t.Nat64}),C=t.Record({referrers:t.Vec(t.Tuple(t.Text,t.Nat32)),pages:t.Vec(t.Tuple(t.Text,t.Nat32))}),M=t.Variant({Navigate:t.Null,Restore:t.Null,Reload:t.Null,BackForward:t.Null,BackForwardCache:t.Null,Prerender:t.Null}),F=t.Record({id:t.Text,value:t.Float64,navigation_type:t.Opt(M),delta:t.Float64}),N=t.Variant({WebVitalsMetric:F}),h=t.Variant({CLS:t.Null,FCP:t.Null,INP:t.Null,LCP:t.Null,TTFB:t.Null}),V=t.Record({updated_at:t.Nat64,session_id:t.Text,data:N,href:t.Text,metric_name:h,created_at:t.Nat64,satellite_id:t.Principal,version:t.Opt(t.Nat64)}),S=t.Record({cls:t.Opt(t.Float64),fcp:t.Opt(t.Float64),inp:t.Opt(t.Float64),lcp:t.Opt(t.Float64),ttfb:t.Opt(t.Float64)}),U=t.Record({overall:S,pages:t.Vec(t.Tuple(t.Text,S))}),x=t.Record({updated_at:t.Nat64,session_id:t.Text,metadata:t.Opt(t.Vec(t.Tuple(t.Text,t.Text))),name:t.Text,created_at:t.Nat64,satellite_id:t.Principal,version:t.Opt(t.Nat64)}),q=t.Record({total:t.Vec(t.Tuple(t.Text,t.Nat32))}),f=t.Record({performance_metrics:t.Bool,track_events:t.Bool,page_views:t.Bool}),y=t.Record({updated_at:t.Nat64,features:t.Opt(f),created_at:t.Nat64,version:t.Opt(t.Nat64)}),T=t.Record({stable:t.Nat64,heap:t.Nat64}),b=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:r,expires_at:t.Opt(t.Nat64)}),R=t.Record({controller:b,controllers:t.Vec(t.Principal)}),k=t.Record({title:t.Text,updated_at:t.Opt(t.Nat64),referrer:t.Opt(t.Text),time_zone:t.Text,session_id:t.Text,href:t.Text,satellite_id:t.Principal,device:l,version:t.Opt(t.Nat64),user_agent:t.Opt(t.Text)}),w=t.Variant({Ok:p,Err:t.Text}),O=t.Variant({Ok:t.Null,Err:t.Vec(t.Tuple(i,t.Text))}),A=t.Record({session_id:t.Text,data:N,href:t.Text,metric_name:h,satellite_id:t.Principal,version:t.Opt(t.Nat64),user_agent:t.Opt(t.Text)}),z=t.Variant({Ok:V,Err:t.Text}),W=t.Record({features:t.Opt(f),version:t.Opt(t.Nat64)}),G=t.Record({updated_at:t.Opt(t.Nat64),session_id:t.Text,metadata:t.Opt(t.Vec(t.Tuple(t.Text,t.Text))),name:t.Text,satellite_id:t.Principal,version:t.Opt(t.Nat64),user_agent:t.Opt(t.Text)}),Z=t.Variant({Ok:x,Err:t.Text});return t.Service({del_controllers:t.Func([e],[t.Vec(t.Tuple(t.Principal,o))],[]),del_satellite_config:t.Func([t.Principal,a],[],[]),deposit_cycles:t.Func([s],[],[]),get_page_views:t.Func([n],[t.Vec(t.Tuple(i,p))],["query"]),get_page_views_analytics_clients:t.Func([n],[c],["query"]),get_page_views_analytics_metrics:t.Func([n],[g],["query"]),get_page_views_analytics_top_10:t.Func([n],[C],["query"]),get_performance_metrics:t.Func([n],[t.Vec(t.Tuple(i,V))],["query"]),get_performance_metrics_analytics_web_vitals:t.Func([n],[U],["query"]),get_track_events:t.Func([n],[t.Vec(t.Tuple(i,x))],["query"]),get_track_events_analytics:t.Func([n],[q],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,o))],["query"]),list_satellite_configs:t.Func([],[t.Vec(t.Tuple(t.Principal,y))],["query"]),memory_size:t.Func([],[T],["query"]),set_controllers:t.Func([R],[t.Vec(t.Tuple(t.Principal,o))],[]),set_page_view:t.Func([i,k],[w],[]),set_page_views:t.Func([t.Vec(t.Tuple(i,k))],[O],[]),set_performance_metric:t.Func([i,A],[z],[]),set_performance_metrics:t.Func([t.Vec(t.Tuple(i,A))],[O],[]),set_satellite_configs:t.Func([t.Vec(t.Tuple(t.Principal,W))],[t.Vec(t.Tuple(t.Principal,y))],[]),set_track_event:t.Func([i,G],[Z],[]),set_track_events:t.Func([t.Vec(t.Tuple(i,G))],[O],[]),version:t.Func([],[t.Text],["query"])})};var ft=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),r=t.Record({controllers:t.Vec(t.Principal)}),o=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,expires_at:t.Opt(t.Nat64)}),a=t.Record({updated_at:t.Opt(t.Nat64)}),s=t.Record({headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text))))}),n=t.Record({storage:s}),i=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),created_at:t.Nat64}),l=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text))}),p=t.Record({token:t.Opt(t.Text),sha256:t.Opt(t.Vec(t.Nat8)),headers:t.Vec(t.Tuple(t.Text,t.Text)),index:t.Nat64,encoding_type:t.Text,full_path:t.Text}),m=t.Variant({Callback:t.Record({token:p,callback:t.Func([],[],[])})}),u=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(m),status_code:t.Nat16}),c=t.Record({token:t.Opt(p),body:t.Vec(t.Nat8)}),d=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,encoding_type:t.Opt(t.Text),full_path:t.Text}),g=t.Record({batch_id:t.Nat}),C=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),M=t.Record({field:C,desc:t.Bool}),F=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),N=t.Record({order:t.Opt(M),owner:t.Opt(t.Principal),matcher:t.Opt(t.Text),paginate:t.Opt(F)}),h=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,full_path:t.Text}),V=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),S=t.Record({key:h,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,V)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64}),U=t.Record({matches_length:t.Nat64,length:t.Nat64,items:t.Vec(t.Tuple(t.Text,S))}),x=t.Record({updated_at:t.Nat64,created_at:t.Nat64,bn_id:t.Opt(t.Text)}),q=t.Record({matches_length:t.Nat64,length:t.Nat64,items:t.Vec(t.Tuple(t.Text,i))}),f=t.Variant({Db:t.Null,Storage:t.Null}),y=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),T=t.Record({updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:y,created_at:t.Nat64,write:y}),b=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),expires_at:t.Opt(t.Nat64)}),R=t.Record({controller:b,controllers:t.Vec(t.Principal)}),k=t.Record({updated_at:t.Opt(t.Nat64),data:t.Vec(t.Nat8)}),w=t.Record({updated_at:t.Opt(t.Nat64),max_size:t.Opt(t.Nat),read:y,write:y}),O=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat}),A=t.Record({chunk_id:t.Nat});return t.Service({commit_asset_upload:t.Func([e],[],[]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Opt(t.Text)],[],[]),del_controllers:t.Func([r],[t.Vec(t.Tuple(t.Principal,o))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,a],[],[]),get_config:t.Func([],[n],[]),get_doc:t.Func([t.Text,t.Text],[t.Opt(i)],["query"]),http_request:t.Func([l],[u],["query"]),http_request_streaming_callback:t.Func([p],[c],["query"]),init_asset_upload:t.Func([d],[g],[]),list_assets:t.Func([t.Opt(t.Text),N],[U],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,o))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,x))],["query"]),list_docs:t.Func([t.Text,N],[q],["query"]),list_rules:t.Func([f],[t.Vec(t.Tuple(t.Text,T))],["query"]),set_config:t.Func([n],[],[]),set_controllers:t.Func([R],[t.Vec(t.Tuple(t.Principal,o))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_doc:t.Func([t.Text,t.Text,k],[i],[]),set_rule:t.Func([f,t.Text,w],[],[]),upload_asset_chunk:t.Func([O],[A],[]),version:t.Func([],[t.Text],["query"])})};var Tt=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),r=t.Record({controllers:t.Vec(t.Principal)}),o=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,expires_at:t.Opt(t.Nat64)}),a=t.Record({updated_at:t.Opt(t.Nat64)}),s=t.Record({headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text))))}),n=t.Record({storage:s}),i=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),created_at:t.Nat64}),l=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text))}),p=t.Record({token:t.Opt(t.Text),sha256:t.Opt(t.Vec(t.Nat8)),headers:t.Vec(t.Tuple(t.Text,t.Text)),index:t.Nat64,encoding_type:t.Text,full_path:t.Text}),m=t.Variant({Callback:t.Record({token:p,callback:t.Func([],[],[])})}),u=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(m),status_code:t.Nat16}),c=t.Record({token:t.Opt(p),body:t.Vec(t.Nat8)}),d=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,encoding_type:t.Opt(t.Text),full_path:t.Text}),g=t.Record({batch_id:t.Nat}),C=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),M=t.Record({field:C,desc:t.Bool}),F=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),N=t.Record({order:t.Opt(M),matcher:t.Opt(t.Text),paginate:t.Opt(F)}),h=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,full_path:t.Text}),V=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),S=t.Record({key:h,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,V)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64}),U=t.Record({matches_length:t.Nat64,length:t.Nat64,items:t.Vec(t.Tuple(t.Text,S))}),x=t.Record({updated_at:t.Nat64,created_at:t.Nat64,bn_id:t.Opt(t.Text)}),q=t.Record({matches_length:t.Nat64,length:t.Nat64,items:t.Vec(t.Tuple(t.Text,i))}),f=t.Variant({Db:t.Null,Storage:t.Null}),y=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),T=t.Record({updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:y,created_at:t.Nat64,write:y}),b=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),expires_at:t.Opt(t.Nat64)}),R=t.Record({controller:b,controllers:t.Vec(t.Principal)}),k=t.Record({updated_at:t.Opt(t.Nat64),data:t.Vec(t.Nat8)}),w=t.Record({updated_at:t.Opt(t.Nat64),max_size:t.Opt(t.Nat),read:y,write:y}),O=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat}),A=t.Record({chunk_id:t.Nat});return t.Service({commit_asset_upload:t.Func([e],[],[]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Opt(t.Text)],[],[]),del_controllers:t.Func([r],[t.Vec(t.Tuple(t.Principal,o))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,a],[],[]),get_config:t.Func([],[n],[]),get_doc:t.Func([t.Text,t.Text],[t.Opt(i)],["query"]),http_request:t.Func([l],[u],["query"]),http_request_streaming_callback:t.Func([p],[c],["query"]),init_asset_upload:t.Func([d],[g],[]),list_assets:t.Func([t.Opt(t.Text),N],[U],["query"]),list_controllers:t.Func([],[t.Vec(t.Principal)],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,x))],["query"]),list_docs:t.Func([t.Text,N],[q],["query"]),list_rules:t.Func([f],[t.Vec(t.Tuple(t.Text,T))],["query"]),set_config:t.Func([n],[],[]),set_controllers:t.Func([R],[t.Vec(t.Tuple(t.Principal,o))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_doc:t.Func([t.Text,t.Text,k],[i],[]),set_rule:t.Func([f,t.Text,w],[],[]),upload_asset_chunk:t.Func([O],[A],[]),version:t.Func([],[t.Text],["query"])})};var Pt=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),r=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),o=t.Record({field:r,desc:t.Bool}),a=t.Variant({Equal:t.Nat64,Between:t.Tuple(t.Nat64,t.Nat64),GreaterThan:t.Nat64,LessThan:t.Nat64}),s=t.Record({key:t.Opt(t.Text),updated_at:t.Opt(a),description:t.Opt(t.Text),created_at:t.Opt(a)}),n=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),i=t.Record({order:t.Opt(o),owner:t.Opt(t.Principal),matcher:t.Opt(s),paginate:t.Opt(n)}),l=t.Record({controllers:t.Vec(t.Principal)}),p=t.Variant({Write:t.Null,Admin:t.Null}),m=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:p,expires_at:t.Opt(t.Nat64)}),u=t.Record({version:t.Opt(t.Nat64)}),c=t.Variant({Db:t.Null,Storage:t.Null}),d=t.Record({version:t.Opt(t.Nat64)}),g=t.Record({cycles:t.Nat,destination_id:t.Principal}),C=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,description:t.Opt(t.Text),full_path:t.Text}),M=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),F=t.Record({key:C,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,M)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),N=t.Record({derivation_origin:t.Opt(t.Text)}),h=t.Record({internet_identity:t.Opt(N)}),V=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),S=t.Record({max_memory_size:t.Opt(V)}),U=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),x=t.Variant({Deny:t.Null,Allow:t.Null}),q=t.Record({status_code:t.Nat16,location:t.Text}),f=t.Record({iframe:t.Opt(U),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),max_memory_size:t.Opt(V),raw_access:t.Opt(x),redirects:t.Opt(t.Vec(t.Tuple(t.Text,q)))}),y=t.Record({db:t.Opt(S),authentication:t.Opt(h),storage:f}),T=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),description:t.Opt(t.Text),created_at:t.Nat64,version:t.Opt(t.Nat64)}),b=t.Variant({Heap:t.Null,Stable:t.Null}),R=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),k=t.Record({max_tokens:t.Nat64,time_per_token_ns:t.Nat64}),w=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(b),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:R,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(k),write:R}),O=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),certificate_version:t.Opt(t.Nat16)}),A=t.Record({memory:b,token:t.Opt(t.Text),sha256:t.Opt(t.Vec(t.Nat8)),headers:t.Vec(t.Tuple(t.Text,t.Text)),index:t.Nat64,encoding_type:t.Text,full_path:t.Text}),z=t.Variant({Callback:t.Record({token:A,callback:t.Func([],[],["query"])})}),W=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(z),status_code:t.Nat16}),G=t.Record({token:t.Opt(A),body:t.Vec(t.Nat8)}),Z=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,description:t.Opt(t.Text),encoding_type:t.Opt(t.Text),full_path:t.Text}),ct=t.Record({batch_id:t.Nat}),lt=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,F)),items_length:t.Nat64}),we=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),Me=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,T)),items_length:t.Nat64}),ve=t.Record({stable:t.Nat64,heap:t.Nat64}),Ue=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:p,expires_at:t.Opt(t.Nat64)}),qe=t.Record({controller:Ue,controllers:t.Vec(t.Principal)}),yt=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),Ee=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(b),max_size:t.Opt(t.Nat),read:R,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(k),write:R}),Be=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),ze=t.Record({chunk_id:t.Nat});return t.Service({build_version:t.Func([],[t.Text],["query"]),commit_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text,i],[t.Nat64],["query"]),count_collection_assets:t.Func([t.Text],[t.Nat64],["query"]),count_collection_docs:t.Func([t.Text],[t.Nat64],["query"]),count_docs:t.Func([t.Text,i],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([l],[t.Vec(t.Tuple(t.Principal,m))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,u],[],[]),del_docs:t.Func([t.Text],[],[]),del_filtered_assets:t.Func([t.Text,i],[],[]),del_filtered_docs:t.Func([t.Text,i],[],[]),del_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[],[]),del_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,u))],[],[]),del_rule:t.Func([c,t.Text,d],[],[]),deposit_cycles:t.Func([g],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(F)],["query"]),get_auth_config:t.Func([],[t.Opt(h)],["query"]),get_config:t.Func([],[y],[]),get_db_config:t.Func([],[t.Opt(S)],["query"]),get_doc:t.Func([t.Text,t.Text],[t.Opt(T)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(F)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(T)))],["query"]),get_rule:t.Func([c,t.Text],[t.Opt(w)],["query"]),get_storage_config:t.Func([],[f],["query"]),http_request:t.Func([O],[W],["query"]),http_request_streaming_callback:t.Func([A],[G],["query"]),init_asset_upload:t.Func([Z],[ct],[]),list_assets:t.Func([t.Text,i],[lt],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,m))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,we))],["query"]),list_docs:t.Func([t.Text,i],[Me],["query"]),list_rules:t.Func([c],[t.Vec(t.Tuple(t.Text,w))],["query"]),memory_size:t.Func([],[ve],["query"]),set_auth_config:t.Func([h],[],[]),set_controllers:t.Func([qe],[t.Vec(t.Tuple(t.Principal,m))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([S],[],[]),set_doc:t.Func([t.Text,t.Text,yt],[T],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,yt))],[t.Vec(t.Tuple(t.Text,T))],[]),set_rule:t.Func([c,t.Text,Ee],[w],[]),set_storage_config:t.Func([f],[],[]),upload_asset_chunk:t.Func([Be],[ze],[]),version:t.Func([],[t.Text],["query"])})};import{Actor as He,HttpAgent as Ke}from"@dfinity/agent";import{nonNullish as Ct}from"@junobuild/utils";var Nt=async({canisterId:t,idlFactory:e,config:r,...o})=>{let a=await P(o);return He.createActor(e,{agent:a,canisterId:t,...r??{}})},P=async({agent:t,...e})=>t??await We(e),We=async({identity:t,fetch:e,container:r})=>{let o=Ct(r)&&r!==!1,a=o?r===!0?"http://127.0.0.1:5987":r:"https://icp-api.io";return await Ke.create({identity:t,host:a,retryTimes:10,...Ct(e)&&{fetch:e},shouldFetchRootKey:o})};var ht=({satelliteId:t,...e})=>J({canisterId:t,...e,idlFactory:Tt}),_=({satelliteId:t,...e})=>J({canisterId:t,...e,idlFactory:Pt}),St=({satelliteId:t,...e})=>J({canisterId:t,...e,idlFactory:ft}),j=({missionControlId:t,...e})=>J({canisterId:t,...e,idlFactory:gt}),D=({orbiterId:t,...e})=>J({canisterId:t,...e,idlFactory:xt}),J=({canisterId:t,idlFactory:e,...r})=>{if(Ge(t))throw new Error("No canister ID provided.");return Nt({canisterId:t,idlFactory:e,...r})};var Rt=async({missionControl:t})=>(await j(t)).version(),Ot=async({missionControl:t})=>(await j(t)).get_user(),At=async({missionControl:t})=>(await j(t)).list_mission_control_controllers(),Ft=async({missionControl:t,satelliteIds:e,controllerIds:r,controller:o})=>(await j(t)).set_satellites_controllers(e,r,o),Vt=async({missionControl:t,controllerIds:e,controller:r})=>(await j(t)).set_mission_control_controllers(e,r);import{Principal as je}from"@dfinity/principal";import{nonNullish as Xe,toNullable as Ze}from"@junobuild/utils";var pt=({controllerId:t,profile:e})=>({controllerIds:[je.fromText(t)],controller:Je(e)}),Je=t=>({metadata:Xe(t)&&t!==""?[["profile",t]]:[],expires_at:Ze(void 0),scope:{Admin:null}});var Wr=({controllerId:t,profile:e,...r})=>Ft({...r,...pt({controllerId:t,profile:e})}),Gr=({controllerId:t,profile:e,...r})=>Vt({...r,...pt({controllerId:t,profile:e})}),jr=t=>At(t);import{Principal as lr}from"@dfinity/principal";var Q={reinstall:null},H={upgrade:[{skip_pre_upgrade:[!1],wasm_memory_persistence:[{replace:null}]}]};import{fromNullable as ar,isNullish as sr}from"@junobuild/utils";import{CanisterStatus as Qe}from"@dfinity/agent";import{ICManagementCanister as v}from"@dfinity/ic-management";import{Principal as Ye}from"@dfinity/principal";import{assertNonNullish as $e}from"@junobuild/utils";var bt=async({canisterId:t,actor:e})=>{let r=await P(e),{stopCanister:o}=v.create({agent:r});await o(t)},kt=async({canisterId:t,actor:e})=>{let r=await P(e),{startCanister:o}=v.create({agent:r});await o(t)},wt=async({actor:t,code:e})=>{let r=await P(t),{installCode:o}=v.create({agent:r});return o(e)},Mt=async({actor:t,canisterId:e})=>{let r=await P(t),{storedChunks:o}=v.create({agent:r});return o({canisterId:e})},I=async({actor:t,canisterId:e})=>{let r=await P(t),{clearChunkStore:o}=v.create({agent:r});return o({canisterId:e})},vt=async({actor:t,chunk:e})=>{let r=await P(t),{uploadChunk:o}=v.create({agent:r});return o(e)},Ut=async({actor:t,code:e})=>{let r=await P(t),{installChunkedCode:o}=v.create({agent:r});return o(e)},qt=async({actor:t,canisterId:e})=>{let r=await P(t),{canisterStatus:o}=v.create({agent:r});return o(e)},Et=async({canisterId:t,path:e,...r})=>{$e(t,"A canister ID must be provided to request its status.");let o=await P(r);return(await Qe.request({canisterId:Ye.from(t),agent:o,paths:[{kind:"metadata",key:e,path:e,decodeStrategy:"utf-8"}]})).get(e)},Bt=async({actor:t,canisterId:e})=>{let r=await P(t),{listCanisterSnapshots:o}=v.create({agent:r});return o({canisterId:e})},zt=async({actor:t,...e})=>{let r=await P(t),{takeCanisterSnapshot:o}=v.create({agent:r});return o(e)};var Ht=(s=>(s[s.AssertingExistingCode=0]="AssertingExistingCode",s[s.StoppingCanister=1]="StoppingCanister",s[s.TakingSnapshot=2]="TakingSnapshot",s[s.UpgradingCode=3]="UpgradingCode",s[s.RestartingCanister=4]="RestartingCanister",s))(Ht||{});var L=t=>(t instanceof Uint8Array||(t=Uint8Array.from(t)),t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),""));var Kt=t=>crypto.subtle.digest("SHA-256",t),Wt=t=>Array.from(new Uint8Array(t)).map(r=>r.toString(16).padStart(2,"0")).join(""),Gt=async t=>{let e=await Kt(await t.arrayBuffer());return Wt(e)},tt=async t=>{let e=await Kt(t);return Wt(e)};import{isNullish as Ie,nonNullish as jt}from"@junobuild/utils";var Xt=async({actor:t,canisterId:e,missionControlId:r,wasmModule:o,preClearChunks:a,...s})=>{a&&await I({actor:t,canisterId:e});let n=await Le({wasmModule:o}),{uploadChunks:i,storedChunks:l,preClearChunks:p,postClearChunks:m}=await tr({actor:t,wasmChunks:n,canisterId:e,missionControlId:r});p&&await I({actor:t,canisterId:e});let u=[];for await(let c of er({uploadChunks:i,actor:t,canisterId:e,missionControlId:r}))u=[...u,...c];await Ut({actor:t,code:{...s,chunkHashesList:[...u,...l].sort(({orderId:c},{orderId:d})=>c-d).map(({chunkHash:c})=>c),targetCanisterId:e,storeCanisterId:r,wasmModuleHash:await tt(o)}}),m&&await I({actor:t,canisterId:e})},Le=async({wasmModule:t})=>{let e=new Blob([t]),r=[],o=1e6,a=0;for(let s=0;s<e.size;s+=o){let n=e.slice(s,s+o);r.push({chunk:n,orderId:a,sha256:await Gt(n)}),a++}return r},tr=async({canisterId:t,missionControlId:e,actor:r,wasmChunks:o})=>{let a=await Mt({actor:r,canisterId:e??t}),s=a.map(({hash:l})=>({chunkHash:{hash:l},sha256:L(l)})),{storedChunks:n,uploadChunks:i}=o.reduce(({uploadChunks:l,storedChunks:p},{sha256:m,...u})=>{let c=s.find(({sha256:d})=>d===m);return{uploadChunks:[...l,...jt(c)?[]:[{sha256:m,...u}]],storedChunks:[...p,...jt(c)?[{...u,...c}]:[]]}},{uploadChunks:[],storedChunks:[]});return{uploadChunks:i,storedChunks:n,preClearChunks:a.length>0&&n.length===0,postClearChunks:Ie(e)}};async function*er({uploadChunks:t,limit:e=12,...r}){for(let o=0;o<t.length;o=o+e){let a=t.slice(o,o+e);yield await Promise.all(a.map(n=>rr({uploadChunk:n,...r})))}}var rr=async({actor:t,canisterId:e,missionControlId:r,uploadChunk:{chunk:o,...a}})=>({chunkHash:await vt({actor:t,chunk:{canisterId:r??e,chunk:new Uint8Array(await o.arrayBuffer())}}),...a});var Zt=async({actor:t,...e})=>{await wt({actor:t,code:e})};var E=async({wasmModule:t,canisterId:e,actor:r,onProgress:o,takeSnapshot:a=!0,...s})=>{await Y({fn:async()=>await nr({wasmModule:t,canisterId:e,actor:r,...s}),onProgress:o,step:0}),await Y({fn:async()=>await bt({canisterId:e,actor:r}),onProgress:o,step:1});try{await Y({fn:async()=>a?await cr({canisterId:e,actor:r}):Promise.resolve(),onProgress:o,step:2}),await Y({fn:async()=>await ir({wasmModule:t,canisterId:e,actor:r,...s}),onProgress:o,step:3})}finally{await Y({fn:async()=>await kt({canisterId:e,actor:r}),onProgress:o,step:4})}},Y=async({fn:t,step:e,onProgress:r})=>{r?.({step:e,state:"in_progress"});try{await t(),r?.({step:e,state:"success"})}catch(o){throw r?.({step:e,state:"error"}),o}},nr=async({actor:t,canisterId:e,wasmModule:r,reset:o})=>{if(o===!0)return;let{module_hash:a}=await qt({actor:t,canisterId:e}),s=ar(a);if(sr(s))return;let n=await tt(r),i=L(s);if(n===i)throw new $},ir=async({wasmModule:t,canisterId:e,actor:r,...o})=>{await((new Blob([t]).size>2e6?"chunked":"single")==="chunked"?Xt:Zt)({wasmModule:t,canisterId:e,actor:r,...o})},cr=async t=>{let e=await Bt(t);await zt({...t,snapshotId:e?.[0]?.id})};import{IDL as K}from"@dfinity/candid";var Jt=t=>K.encode([K.Record({user:K.Principal})],[{user:t}]),et=t=>K.encode([K.Record({controllers:K.Vec(K.Principal)})],[{controllers:t.map(([e,r])=>e)}]);var wo=async({missionControl:t,...e})=>{let r=await Ot({missionControl:t}),{missionControlId:o,...a}=t;if(!o)throw new Error("No mission control principal defined.");let s=Jt(r);await E({actor:a,canisterId:lr.fromText(o),arg:new Uint8Array(s),mode:H,...e})};var Uo=t=>Rt(t);var Bo=async t=>{await E(t)};var Qt=async({orbiter:t})=>(await D(t)).version(),rt=async({orbiter:t})=>(await D(t)).list_controllers(),Yt=async({orbiter:t})=>{let{memory_size:e}=await D(t);return e()};var Go=t=>rt(t);var Zo=t=>Yt(t);import{Principal as pr}from"@dfinity/principal";var Lo=async({orbiter:t,reset:e=!1,...r})=>{let{orbiterId:o,...a}=t;if(!o)throw new Error("No orbiter principal defined.");let s=await rt({orbiter:t}),n=et(s);await E({actor:a,canisterId:pr.fromText(o),arg:new Uint8Array(n),mode:e?Q:H,reset:e,...r})};var ra=t=>Qt(t);import{major as $t,minor as Dt,patch as It}from"semver";var sa=({currentVersion:t,selectedVersion:e})=>{let r=$t(t),o=$t(e),a=Dt(t),s=Dt(e),n=It(t),i=It(e);return r<o-1||a<s-1||n<i-1?{canUpgrade:!1}:{canUpgrade:!0}};import{toNullable as dr}from"@junobuild/utils";var Lt=async({config:t,satellite:e})=>{let{set_storage_config:r}=await _(e);return r(t)},te=async({config:t,satellite:e})=>{let{set_db_config:r}=await _(e);return r(t)},ee=async({config:t,satellite:e})=>{let{set_auth_config:r}=await _(e);return r(t)};var re=async({satellite:t})=>{let{get_auth_config:e}=await _(t);return e()},oe=async({satellite:t,type:e})=>(await _(t)).list_rules(e),ae=async({type:t,collection:e,rule:r,satellite:o})=>{let{set_rule:a}=await _(o);return a(t,e,r)},se=async({satellite:t})=>{let{version:e}=await _(t);return e()},ne=async({satellite:t})=>{let{build_version:e}=await _(t);return e()},ie=async({satellite:t})=>(await ht(t)).list_controllers(),ot=async({satellite:t})=>(await St(t)).list_controllers(),at=async({satellite:t})=>(await _(t)).list_controllers(),ce=async({satellite:t})=>{let{list_custom_domains:e}=await _(t);return e()},le=async({satellite:t,domainName:e,boundaryNodesId:r})=>{let{set_custom_domain:o}=await _(t);await o(e,dr(r))},pe=async({satellite:t})=>{let{memory_size:e}=await _(t);return e()},de=async({collection:t,satellite:e})=>{let{count_collection_docs:r}=await _(e);return r(t)},ue=async({collection:t,satellite:e})=>{let{count_collection_assets:r}=await _(e);return r(t)},me=async({collection:t,satellite:e})=>{let{del_docs:r}=await _(e);return r(t)},_e=async({collection:t,satellite:e})=>{let{del_assets:r}=await _(e);return r(t)},ye=async({args:t,satellite:e})=>{let{set_controllers:r}=await _(e);return r(t)};var da=t=>ue(t),ua=t=>_e(t);import{fromNullable as st,isNullish as xe,nonNullish as ge}from"@junobuild/utils";import{nonNullish as ur,toNullable as dt}from"@junobuild/utils";var ut=t=>dt(ur(t)?{heap:dt(t.heap),stable:dt(t.stable)}:void 0);var Ta=async({config:{headers:t,rewrites:e,redirects:r,iframe:o,rawAccess:a,maxMemorySize:s},satellite:n})=>{let i=(t??[]).map(({source:c,headers:d})=>[c,d]),l=(e??[]).map(({source:c,destination:d})=>[c,d]),p=(r??[]).map(({source:c,location:d,code:g})=>[c,{status_code:g,location:d}]);return await Lt({satellite:n,config:{headers:i,rewrites:l,redirects:[p],iframe:[o==="same-origin"?{SameOrigin:null}:o==="allow-any"?{AllowAny:null}:{Deny:null}],raw_access:[a===!0?{Allow:null}:{Deny:null}],max_memory_size:ut(s)}})},Pa=async({config:{maxMemorySize:t},...e})=>{await te({config:{max_memory_size:ut(t)},...e})},Ca=async({config:{internetIdentity:t},...e})=>{await ee({config:{internet_identity:xe(t?.derivationOrigin)?[]:[{derivation_origin:[t.derivationOrigin]}]},...e})},Na=async({satellite:t})=>{let e=st(await re({satellite:t}));if(xe(e))return;let r=st(e.internet_identity??[]);return{...ge(r)&&{internetIdentity:{...ge(st(r.derivation_origin))&&{derivationOrigin:st(r.derivation_origin)}}}}};var Ra=({deprecatedNoScope:t,...e})=>(t===!0?ot:at)(e),Oa=t=>ye(t);var Va=t=>de(t),ba=t=>me(t);import{fromNullable as fe,nonNullish as mr}from"@junobuild/utils";var va=async({satellite:t})=>(await ce({satellite:t})).map(([r,o])=>{let a=fe(o.version);return{domain:r,bn_id:fe(o.bn_id),created_at:o.created_at,updated_at:o.updated_at,...mr(a)&&{version:a}}}),Ua=({satellite:t,domains:e})=>Promise.all(e.map(({domain:r,bn_id:o})=>le({satellite:t,domainName:r,boundaryNodesId:o})));var Ba=t=>pe(t);import{fromNullable as X,nonNullish as B,toNullable as nt}from"@junobuild/utils";var Te={Db:null},Pe={Storage:null},Ce={Public:null},Ne={Private:null},he={Managed:null},Se={Controllers:null},mt={Heap:null},Re={Stable:null},Oe=600000000n;var _t=t=>t==="storage"?Pe:Te,Ve=({read:t,write:e,memory:r,maxSize:o,maxCapacity:a,version:s,mutablePermissions:n,maxTokens:i})=>({read:Fe(t),write:Fe(e),memory:B(r)?[_r(r)]:[],version:nt(s),max_size:nt(B(o)&&o>0?BigInt(o):void 0),max_capacity:nt(B(a)&&a>0?a:void 0),mutable_permissions:nt(n),rate_config:B(i)?[{max_tokens:BigInt(i),time_per_token_ns:Oe}]:[]}),be=([t,e])=>{let{read:r,write:o,updated_at:a,created_at:s,max_size:n,max_capacity:i,memory:l,mutable_permissions:p,version:m,rate_config:u}=e,c=n?.[0]??0n>0n?Number(X(n)):void 0,d=i?.[0]??!1?X(i):void 0,g=X(m),C=u?.[0]?.max_tokens??0n>0n?X(u)?.max_tokens:void 0;return{collection:t,read:Ae(r),write:Ae(o),memory:yr(X(l)??mt),updatedAt:a,createdAt:s,...B(g)&&{version:g},...B(c)&&{maxSize:c},...B(d)&&{maxCapacity:d},mutablePermissions:X(p)??!0,...B(C)&&{maxTokens:Number(C)}}},Ae=t=>"Public"in t?"public":"Private"in t?"private":"Managed"in t?"managed":"controllers",Fe=t=>{switch(t){case"public":return Ce;case"private":return Ne;case"managed":return he;default:return Se}},_r=t=>{switch(t.toLowerCase()){case"heap":return mt;default:return Re}},yr=t=>"Heap"in t?"heap":"stable";var Za=async({type:t,satellite:e})=>(await oe({satellite:e,type:_t(t)})).map(o=>be(o)),Ja=async({rule:{collection:t,...e},type:r,satellite:o})=>{await ae({type:_t(r),rule:Ve(e),satellite:o,collection:t})};import{IDL as it}from"@dfinity/candid";import{Principal as ke}from"@dfinity/principal";import{isNullish as gr}from"@junobuild/utils";var rs=async({satellite:t,deprecated:e,deprecatedNoScope:r,reset:o=!1,...a})=>{let{satelliteId:s,...n}=t;if(gr(s))throw new Error("No satellite principal defined.");if(e){let m=await ie({satellite:t}),u=it.encode([it.Record({controllers:it.Vec(it.Principal)})],[{controllers:m}]);await E({actor:n,canisterId:ke.fromText(s),arg:new Uint8Array(u),mode:o?Q:H,reset:o,...a});return}let l=await(r?ot:at)({satellite:t}),p=et(l);await E({actor:n,canisterId:ke.fromText(s),arg:new Uint8Array(p),mode:o?Q:H,reset:o,...a})};import{nonNullish as xr}from"@junobuild/utils";var is=t=>se(t),cs=t=>ne(t),ls=async({satellite:{satelliteId:t,...e}})=>{let r=await Et({...e,canisterId:t,path:"juno:build"});return xr(r)&&["stock","extended"].includes(r)?r:void 0};export{Ht as UpgradeCodeProgressStep,$ as UpgradeCodeUnchangedError,Gt as blobSha256,sa as checkUpgradeVersion,da as countAssets,Va as countDocs,ua as deleteAssets,ba as deleteDocs,Na as getAuthConfig,va as listCustomDomains,jr as listMissionControlControllers,Go as listOrbiterControllers,Za as listRules,Ra as listSatelliteControllers,Uo as missionControlVersion,Zo as orbiterMemorySize,ra as orbiterVersion,ls as satelliteBuildType,cs as satelliteBuildVersion,Ba as satelliteMemorySize,is as satelliteVersion,Ca as setAuthConfig,Ua as setCustomDomains,Pa as setDatastoreConfig,Gr as setMissionControlController,Ja as setRule,Oa as setSatelliteControllers,Wr as setSatellitesController,Ta as setStorageConfig,tt as uint8ArraySha256,wo as upgradeMissionControl,Bo as upgradeModule,Lo as upgradeOrbiter,rs as upgradeSatellite};
|
|
16
4
|
//# sourceMappingURL=index.mjs.map
|