@junobuild/core-standalone 0.1.11 → 0.1.12
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/canisterStatus-OWQH6ZT5.js +2 -0
- package/dist/browser/{chunk-REWHDUNS.js → chunk-DCSQJUQP.js} +2 -18
- package/dist/browser/index.js +2 -2
- package/dist/browser/index.js.map +2 -2
- package/dist/declarations/satellite/satellite.did.d.ts +0 -2
- package/dist/declarations/satellite/satellite.factory.certified.did.js +1 -3
- package/dist/declarations/satellite/satellite.factory.did.js +1 -3
- package/dist/declarations/satellite/satellite.factory.did.mjs +1 -3
- package/dist/declarations/sputnik/sputnik.did.d.ts +0 -2
- package/dist/declarations/sputnik/sputnik.factory.certified.did.js +1 -3
- package/dist/declarations/sputnik/sputnik.factory.did.js +1 -3
- package/dist/node/index.mjs +1 -19
- package/dist/node/index.mjs.map +2 -2
- package/dist/workers/auth.worker.js +1 -16
- package/package.json +1 -1
- package/dist/browser/canisterStatus-TKCY5NA5.js +0 -2
- /package/dist/browser/{canisterStatus-TKCY5NA5.js.map → canisterStatus-OWQH6ZT5.js.map} +0 -0
- /package/dist/browser/{chunk-REWHDUNS.js.map → chunk-DCSQJUQP.js.map} +0 -0
|
@@ -237,7 +237,6 @@ export interface UploadChunkResult {
|
|
|
237
237
|
chunk_id: bigint;
|
|
238
238
|
}
|
|
239
239
|
export interface _SERVICE {
|
|
240
|
-
build_version: ActorMethod<[], string>;
|
|
241
240
|
commit_asset_upload: ActorMethod<[CommitBatch], undefined>;
|
|
242
241
|
count_assets: ActorMethod<[string, ListParams], bigint>;
|
|
243
242
|
count_collection_assets: ActorMethod<[string], bigint>;
|
|
@@ -285,7 +284,6 @@ export interface _SERVICE {
|
|
|
285
284
|
set_rule: ActorMethod<[CollectionType, string, SetRule], Rule>;
|
|
286
285
|
set_storage_config: ActorMethod<[StorageConfig], undefined>;
|
|
287
286
|
upload_asset_chunk: ActorMethod<[UploadChunk], UploadChunkResult>;
|
|
288
|
-
version: ActorMethod<[], string>;
|
|
289
287
|
}
|
|
290
288
|
export declare const idlFactory: IDL.InterfaceFactory;
|
|
291
289
|
export declare const init: (args: {IDL: typeof IDL}) => IDL.Type[];
|
|
@@ -241,7 +241,6 @@ export const idlFactory = ({IDL}) => {
|
|
|
241
241
|
});
|
|
242
242
|
const UploadChunkResult = IDL.Record({chunk_id: IDL.Nat});
|
|
243
243
|
return IDL.Service({
|
|
244
|
-
build_version: IDL.Func([], [IDL.Text], []),
|
|
245
244
|
commit_asset_upload: IDL.Func([CommitBatch], [], []),
|
|
246
245
|
count_assets: IDL.Func([IDL.Text, ListParams], [IDL.Nat64], []),
|
|
247
246
|
count_collection_assets: IDL.Func([IDL.Text], [IDL.Nat64], []),
|
|
@@ -309,8 +308,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
309
308
|
),
|
|
310
309
|
set_rule: IDL.Func([CollectionType, IDL.Text, SetRule], [Rule], []),
|
|
311
310
|
set_storage_config: IDL.Func([StorageConfig], [], []),
|
|
312
|
-
upload_asset_chunk: IDL.Func([UploadChunk], [UploadChunkResult], [])
|
|
313
|
-
version: IDL.Func([], [IDL.Text], [])
|
|
311
|
+
upload_asset_chunk: IDL.Func([UploadChunk], [UploadChunkResult], [])
|
|
314
312
|
});
|
|
315
313
|
};
|
|
316
314
|
// @ts-ignore
|
|
@@ -241,7 +241,6 @@ export const idlFactory = ({IDL}) => {
|
|
|
241
241
|
});
|
|
242
242
|
const UploadChunkResult = IDL.Record({chunk_id: IDL.Nat});
|
|
243
243
|
return IDL.Service({
|
|
244
|
-
build_version: IDL.Func([], [IDL.Text], ['query']),
|
|
245
244
|
commit_asset_upload: IDL.Func([CommitBatch], [], []),
|
|
246
245
|
count_assets: IDL.Func([IDL.Text, ListParams], [IDL.Nat64], ['query']),
|
|
247
246
|
count_collection_assets: IDL.Func([IDL.Text], [IDL.Nat64], ['query']),
|
|
@@ -309,8 +308,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
309
308
|
),
|
|
310
309
|
set_rule: IDL.Func([CollectionType, IDL.Text, SetRule], [Rule], []),
|
|
311
310
|
set_storage_config: IDL.Func([StorageConfig], [], []),
|
|
312
|
-
upload_asset_chunk: IDL.Func([UploadChunk], [UploadChunkResult], [])
|
|
313
|
-
version: IDL.Func([], [IDL.Text], ['query'])
|
|
311
|
+
upload_asset_chunk: IDL.Func([UploadChunk], [UploadChunkResult], [])
|
|
314
312
|
});
|
|
315
313
|
};
|
|
316
314
|
// @ts-ignore
|
|
@@ -241,7 +241,6 @@ export const idlFactory = ({IDL}) => {
|
|
|
241
241
|
});
|
|
242
242
|
const UploadChunkResult = IDL.Record({chunk_id: IDL.Nat});
|
|
243
243
|
return IDL.Service({
|
|
244
|
-
build_version: IDL.Func([], [IDL.Text], ['query']),
|
|
245
244
|
commit_asset_upload: IDL.Func([CommitBatch], [], []),
|
|
246
245
|
count_assets: IDL.Func([IDL.Text, ListParams], [IDL.Nat64], ['query']),
|
|
247
246
|
count_collection_assets: IDL.Func([IDL.Text], [IDL.Nat64], ['query']),
|
|
@@ -309,8 +308,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
309
308
|
),
|
|
310
309
|
set_rule: IDL.Func([CollectionType, IDL.Text, SetRule], [Rule], []),
|
|
311
310
|
set_storage_config: IDL.Func([StorageConfig], [], []),
|
|
312
|
-
upload_asset_chunk: IDL.Func([UploadChunk], [UploadChunkResult], [])
|
|
313
|
-
version: IDL.Func([], [IDL.Text], ['query'])
|
|
311
|
+
upload_asset_chunk: IDL.Func([UploadChunk], [UploadChunkResult], [])
|
|
314
312
|
});
|
|
315
313
|
};
|
|
316
314
|
// @ts-ignore
|
|
@@ -237,7 +237,6 @@ export interface UploadChunkResult {
|
|
|
237
237
|
chunk_id: bigint;
|
|
238
238
|
}
|
|
239
239
|
export interface _SERVICE {
|
|
240
|
-
build_version: ActorMethod<[], string>;
|
|
241
240
|
commit_asset_upload: ActorMethod<[CommitBatch], undefined>;
|
|
242
241
|
count_assets: ActorMethod<[string, ListParams], bigint>;
|
|
243
242
|
count_collection_assets: ActorMethod<[string], bigint>;
|
|
@@ -285,7 +284,6 @@ export interface _SERVICE {
|
|
|
285
284
|
set_rule: ActorMethod<[CollectionType, string, SetRule], Rule>;
|
|
286
285
|
set_storage_config: ActorMethod<[StorageConfig], undefined>;
|
|
287
286
|
upload_asset_chunk: ActorMethod<[UploadChunk], UploadChunkResult>;
|
|
288
|
-
version: ActorMethod<[], string>;
|
|
289
287
|
}
|
|
290
288
|
export declare const idlFactory: IDL.InterfaceFactory;
|
|
291
289
|
export declare const init: (args: {IDL: typeof IDL}) => IDL.Type[];
|
|
@@ -241,7 +241,6 @@ export const idlFactory = ({IDL}) => {
|
|
|
241
241
|
});
|
|
242
242
|
const UploadChunkResult = IDL.Record({chunk_id: IDL.Nat});
|
|
243
243
|
return IDL.Service({
|
|
244
|
-
build_version: IDL.Func([], [IDL.Text], []),
|
|
245
244
|
commit_asset_upload: IDL.Func([CommitBatch], [], []),
|
|
246
245
|
count_assets: IDL.Func([IDL.Text, ListParams], [IDL.Nat64], []),
|
|
247
246
|
count_collection_assets: IDL.Func([IDL.Text], [IDL.Nat64], []),
|
|
@@ -309,8 +308,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
309
308
|
),
|
|
310
309
|
set_rule: IDL.Func([CollectionType, IDL.Text, SetRule], [Rule], []),
|
|
311
310
|
set_storage_config: IDL.Func([StorageConfig], [], []),
|
|
312
|
-
upload_asset_chunk: IDL.Func([UploadChunk], [UploadChunkResult], [])
|
|
313
|
-
version: IDL.Func([], [IDL.Text], [])
|
|
311
|
+
upload_asset_chunk: IDL.Func([UploadChunk], [UploadChunkResult], [])
|
|
314
312
|
});
|
|
315
313
|
};
|
|
316
314
|
// @ts-ignore
|
|
@@ -241,7 +241,6 @@ export const idlFactory = ({IDL}) => {
|
|
|
241
241
|
});
|
|
242
242
|
const UploadChunkResult = IDL.Record({chunk_id: IDL.Nat});
|
|
243
243
|
return IDL.Service({
|
|
244
|
-
build_version: IDL.Func([], [IDL.Text], ['query']),
|
|
245
244
|
commit_asset_upload: IDL.Func([CommitBatch], [], []),
|
|
246
245
|
count_assets: IDL.Func([IDL.Text, ListParams], [IDL.Nat64], ['query']),
|
|
247
246
|
count_collection_assets: IDL.Func([IDL.Text], [IDL.Nat64], ['query']),
|
|
@@ -309,8 +308,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
309
308
|
),
|
|
310
309
|
set_rule: IDL.Func([CollectionType, IDL.Text, SetRule], [Rule], []),
|
|
311
310
|
set_storage_config: IDL.Func([StorageConfig], [], []),
|
|
312
|
-
upload_asset_chunk: IDL.Func([UploadChunk], [UploadChunkResult], [])
|
|
313
|
-
version: IDL.Func([], [IDL.Text], ['query'])
|
|
311
|
+
upload_asset_chunk: IDL.Func([UploadChunk], [UploadChunkResult], [])
|
|
314
312
|
});
|
|
315
313
|
};
|
|
316
314
|
// @ts-ignore
|
package/dist/node/index.mjs
CHANGED
|
@@ -54,7 +54,7 @@ ${e(i)}
|
|
|
54
54
|
Request ID: ${(0,Wp.toHex)(r)}
|
|
55
55
|
`)}throw new Error("unreachable")}Wt.pollForResponse=zp});var Dp=ee(Jl=>{"use strict";Object.defineProperty(Jl,"__esModule",{value:!0});Jl.default=({IDL:t})=>{let e=t.Variant({mainnet:t.Null,testnet:t.Null}),r=t.Text,n=t.Record({network:e,address:r,min_confirmations:t.Opt(t.Nat32)}),i=t.Nat64,s=i,o=t.Nat32,a=t.Record({start_height:o,end_height:t.Opt(o),network:e}),c=t.Vec(t.Nat8),f=t.Record({tip_height:o,block_headers:t.Vec(c)}),d=t.Record({network:e}),h=t.Nat64,m=t.Vec(h),_=t.Record({network:e,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:r}),u=t.Vec(t.Nat8),O=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),T=t.Record({height:t.Nat32,value:i,outpoint:O}),P=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:o,tip_block_hash:u,utxos:t.Vec(T)}),F=t.Record({transaction:t.Vec(t.Nat8),network:e}),A=t.Principal,K=t.Record({canister_id:A,num_requested_changes:t.Opt(t.Nat64)}),E=t.Variant({from_user:t.Record({user_id:t.Principal}),from_canister:t.Record({canister_version:t.Opt(t.Nat64),canister_id:t.Principal})}),j=t.Vec(t.Nat8),G=t.Variant({creation:t.Record({controllers:t.Vec(t.Principal)}),code_deployment:t.Record({mode:t.Variant({reinstall:t.Null,upgrade:t.Null,install:t.Null}),module_hash:t.Vec(t.Nat8)}),load_snapshot:t.Record({canister_version:t.Nat64,taken_at_timestamp:t.Nat64,snapshot_id:j}),controllers_change:t.Record({controllers:t.Vec(t.Principal)}),code_uninstall:t.Null}),z=t.Record({timestamp_nanos:t.Nat64,canister_version:t.Nat64,origin:E,details:G}),q=t.Record({controllers:t.Vec(t.Principal),module_hash:t.Opt(t.Vec(t.Nat8)),recent_changes:t.Vec(z),total_num_changes:t.Nat64}),oe=t.Record({canister_id:A}),Q=t.Variant({controllers:t.Null,public:t.Null,allowed_viewers:t.Vec(t.Principal)}),ie=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:Q,wasm_memory_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),w=t.Record({status:t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),memory_size:t.Nat,cycles:t.Nat,settings:ie,query_stats:t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),b=t.Record({canister_id:A}),N=t.Record({freezing_threshold:t.Opt(t.Nat),controllers:t.Opt(t.Vec(t.Principal)),reserved_cycles_limit:t.Opt(t.Nat),log_visibility:t.Opt(Q),wasm_memory_limit:t.Opt(t.Nat),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),B=t.Record({settings:t.Opt(N),sender_canister_version:t.Opt(t.Nat64)}),R=t.Record({canister_id:A}),V=t.Record({canister_id:A}),Z=t.Record({canister_id:A,snapshot_id:j}),ce=t.Record({canister_id:A}),ae=t.Variant({secp256k1:t.Null}),D=t.Record({key_id:t.Record({name:t.Text,curve:ae}),canister_id:t.Opt(A),derivation_path:t.Vec(t.Vec(t.Nat8))}),M=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),y=t.Record({canister_id:A}),L=t.Record({idx:t.Nat64,timestamp_nanos:t.Nat64,content:t.Vec(t.Nat8)}),re=t.Record({canister_log_records:t.Vec(L)}),le=t.Record({value:t.Text,name:t.Text}),X=t.Record({status:t.Nat,body:t.Vec(t.Nat8),headers:t.Vec(le)}),l=t.Record({url:t.Text,method:t.Variant({get:t.Null,head:t.Null,post:t.Null}),max_response_bytes:t.Opt(t.Nat64),body:t.Opt(t.Vec(t.Nat8)),transform:t.Opt(t.Record({function:t.Func([t.Record({context:t.Vec(t.Nat8),response:X})],[X],["query"]),context:t.Vec(t.Nat8)})),headers:t.Vec(le)}),p=t.Variant({reinstall:t.Null,upgrade:t.Opt(t.Record({wasm_memory_persistence:t.Opt(t.Variant({keep:t.Null,replace:t.Null})),skip_pre_upgrade:t.Opt(t.Bool)})),install:t.Null}),g=t.Record({hash:t.Vec(t.Nat8)}),I=t.Record({arg:t.Vec(t.Nat8),wasm_module_hash:t.Vec(t.Nat8),mode:p,chunk_hashes_list:t.Vec(g),target_canister:A,store_canister:t.Opt(A),sender_canister_version:t.Opt(t.Nat64)}),S=t.Vec(t.Nat8),U=t.Record({arg:t.Vec(t.Nat8),wasm_module:S,mode:p,canister_id:A,sender_canister_version:t.Opt(t.Nat64)}),H=t.Record({canister_id:A}),x=t.Record({id:j,total_size:t.Nat64,taken_at_timestamp:t.Nat64}),C=t.Vec(x),$=t.Record({canister_id:A,sender_canister_version:t.Opt(t.Nat64),snapshot_id:j}),k=t.Record({start_at_timestamp_nanos:t.Nat64,subnet_id:t.Principal}),J=t.Record({num_block_failures_total:t.Nat64,node_id:t.Principal,num_blocks_proposed_total:t.Nat64}),te=t.Vec(t.Record({timestamp_nanos:t.Nat64,node_metrics:t.Vec(J)})),de=t.Record({settings:t.Opt(N),specified_id:t.Opt(A),amount:t.Opt(t.Nat),sender_canister_version:t.Opt(t.Nat64)}),_e=t.Record({canister_id:A}),Me=t.Record({canister_id:A,amount:t.Nat}),Ve=t.Vec(t.Nat8),me=t.Variant({ed25519:t.Null,bip340secp256k1:t.Null}),he=t.Record({key_id:t.Record({algorithm:me,name:t.Text}),canister_id:t.Opt(A),derivation_path:t.Vec(t.Vec(t.Nat8))}),Je=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),vr=t.Record({key_id:t.Record({name:t.Text,curve:ae}),derivation_path:t.Vec(t.Vec(t.Nat8)),message_hash:t.Vec(t.Nat8)}),zr=t.Record({signature:t.Vec(t.Nat8)}),Dr=t.Variant({bip341:t.Record({merkle_root_hash:t.Vec(t.Nat8)})}),kt=t.Record({aux:t.Opt(Dr),key_id:t.Record({algorithm:me,name:t.Text}),derivation_path:t.Vec(t.Vec(t.Nat8)),message:t.Vec(t.Nat8)}),Ne=t.Record({signature:t.Vec(t.Nat8)}),Tt=t.Record({canister_id:A}),st=t.Record({canister_id:A}),$e=t.Record({canister_id:A}),xc=t.Vec(g),vc=t.Record({subnet_id:t.Principal}),Ke=t.Record({replica_version:t.Text}),Tc=t.Record({replace_snapshot:t.Opt(j),canister_id:A}),Ac=x,Sc=t.Record({canister_id:A,sender_canister_version:t.Opt(t.Nat64)}),Bc=t.Record({canister_id:t.Principal,settings:N,sender_canister_version:t.Opt(t.Nat64)}),Oc=t.Record({chunk:t.Vec(t.Nat8),canister_id:t.Principal}),an=g;return t.Service({bitcoin_get_balance:t.Func([n],[s],[]),bitcoin_get_block_headers:t.Func([a],[f],[]),bitcoin_get_current_fee_percentiles:t.Func([d],[m],[]),bitcoin_get_utxos:t.Func([_],[P],[]),bitcoin_send_transaction:t.Func([F],[],[]),canister_info:t.Func([K],[q],[]),canister_status:t.Func([oe],[w],[]),clear_chunk_store:t.Func([b],[],[]),create_canister:t.Func([B],[R],[]),delete_canister:t.Func([V],[],[]),delete_canister_snapshot:t.Func([Z],[],[]),deposit_cycles:t.Func([ce],[],[]),ecdsa_public_key:t.Func([D],[M],[]),fetch_canister_logs:t.Func([y],[re],["query"]),http_request:t.Func([l],[X],[]),install_chunked_code:t.Func([I],[],[]),install_code:t.Func([U],[],[]),list_canister_snapshots:t.Func([H],[C],[]),load_canister_snapshot:t.Func([$],[],[]),node_metrics_history:t.Func([k],[te],[]),provisional_create_canister_with_cycles:t.Func([de],[_e],[]),provisional_top_up_canister:t.Func([Me],[],[]),raw_rand:t.Func([],[Ve],[]),schnorr_public_key:t.Func([he],[Je],[]),sign_with_ecdsa:t.Func([vr],[zr],[]),sign_with_schnorr:t.Func([kt],[Ne],[]),start_canister:t.Func([Tt],[],[]),stop_canister:t.Func([st],[],[]),stored_chunks:t.Func([$e],[xc],[]),subnet_info:t.Func([vc],[Ke],[]),take_canister_snapshot:t.Func([Tc],[Ac],[]),uninstall_code:t.Func([Sc],[],[]),update_settings:t.Func([Bc],[],[]),upload_chunk:t.Func([Oc],[an],[])})}});var za=ee(Ye=>{"use strict";var dE=Ye&&Ye.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Ye,"__esModule",{value:!0});Ye.AdvancedActor=Ye.getManagementCanister=Ye.ACTOR_METHOD_WITH_CERTIFICATE=Ye.ACTOR_METHOD_WITH_HTTP_DETAILS=Ye.Actor=Ye.UpdateCallRejectedError=Ye.QueryCallRejectedError=Ye.ActorCallError=void 0;var hE=bd(),Xl=Ss(),Ql=yi(),Cs=xi(),Zp=Ya(),cr=Ut(),pE=Vt(),Hi=Oi(),yE=dE(Dp()),qs=class extends Ql.AgentError{constructor(e,r,n,i){super(["Call failed:",` Canister: ${e.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(s=>` "${s}": ${JSON.stringify(i[s])}`)].join(`
|
|
56
56
|
`)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i}};Ye.ActorCallError=qs;var Wa=class extends qs{constructor(e,r,n){var i;super(e,r,"query",{Status:n.status,Code:(i=Xl.ReplicaRejectCode[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}};Ye.QueryCallRejectedError=Wa;var js=class extends qs{constructor(e,r,n,i,s,o,a){super(e,r,"update",Object.assign({"Request ID":(0,pE.toHex)(n)},i.body?Object.assign(Object.assign({},a?{"Error code":a}:{}),{"Reject code":String(s),"Reject message":o}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i,this.reject_code=s,this.reject_message=o,this.error_code=a}};Ye.UpdateCallRejectedError=js;var ar=Symbol.for("ic-agent-metadata"),ks=class t{constructor(e){this[ar]=Object.freeze(e)}static agentOf(e){return e[ar].config.agent}static interfaceOf(e){return e[ar].service}static canisterIdOf(e){return cr.Principal.from(e[ar].config.canisterId)}static async install(e,r){let n=e.mode===void 0?{install:null}:e.mode,i=e.arg?[...new Uint8Array(e.arg)]:[],s=[...new Uint8Array(e.module)],o=typeof r.canisterId=="string"?cr.Principal.fromText(r.canisterId):r.canisterId;await Ll(r).install_code({mode:n,arg:i,wasm_module:s,canister_id:o,sender_canister_version:[]})}static async createCanister(e,r){function n(s){return[{controllers:s.controllers?[s.controllers]:[],compute_allocation:s.compute_allocation?[s.compute_allocation]:[],freezing_threshold:s.freezing_threshold?[s.freezing_threshold]:[],memory_allocation:s.memory_allocation?[s.memory_allocation]:[],reserved_cycles_limit:[],log_visibility:[],wasm_memory_limit:[]}]}let{canister_id:i}=await Ll(e||{}).provisional_create_canister_with_cycles({amount:[],settings:n(r||{}),specified_id:[],sender_canister_version:[]});return i}static async createAndInstallCanister(e,r,n){let i=await this.createCanister(n);return await this.install(Object.assign({},r),Object.assign(Object.assign({},n),{canisterId:i})),this.createActor(e,Object.assign(Object.assign({},n),{canisterId:i}))}static createActorClass(e,r){let n=e({IDL:Cs.IDL});class i extends t{constructor(o){if(!o.canisterId)throw new Ql.AgentError(`Canister ID is required, but received ${typeof o.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);let a=typeof o.canisterId=="string"?cr.Principal.fromText(o.canisterId):o.canisterId;super({config:Object.assign(Object.assign(Object.assign({},Jp),o),{canisterId:a}),service:n});for(let[c,f]of n._fields)r?.httpDetails&&f.annotations.push(Ye.ACTOR_METHOD_WITH_HTTP_DETAILS),r?.certificate&&f.annotations.push(Ye.ACTOR_METHOD_WITH_CERTIFICATE),this[c]=gE(this,c,f,o.blsVerify)}}return i}static createActor(e,r){if(!r.canisterId)throw new Ql.AgentError(`Canister ID is required, but received ${typeof r.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);return new(this.createActorClass(e))(r)}static createActorWithHttpDetails(e,r){return new(this.createActorClass(e,{httpDetails:!0}))(r)}static createActorWithExtendedDetails(e,r,n={httpDetails:!0,certificate:!0}){return new(this.createActorClass(e,n))(r)}};Ye.Actor=ks;function Vi(t,e){let r=Cs.IDL.decode(t,hE.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var Jp={pollingStrategyFactory:Zp.strategy.defaultStrategy};Ye.ACTOR_METHOD_WITH_HTTP_DETAILS="http-details";Ye.ACTOR_METHOD_WITH_CERTIFICATE="certificate";function gE(t,e,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(o,...a)=>{var c,f;o=Object.assign(Object.assign({},o),(f=(c=t[ar].config).queryTransform)===null||f===void 0?void 0:f.call(c,e,a,Object.assign(Object.assign({},t[ar].config),o)));let d=o.agent||t[ar].config.agent||(0,Xl.getDefaultAgent)(),h=cr.Principal.from(o.canisterId||t[ar].config.canisterId),m=Cs.IDL.encode(r.argTypes,a),_=await d.query(h,{methodName:e,arg:m,effectiveCanisterId:o.effectiveCanisterId}),u=Object.assign(Object.assign({},_.httpDetails),{requestDetails:_.requestDetails});switch(_.status){case"rejected":throw new Wa(h,e,_);case"replied":return r.annotations.includes(Ye.ACTOR_METHOD_WITH_HTTP_DETAILS)?{httpDetails:u,result:Vi(r.retTypes,_.reply.arg)}:Vi(r.retTypes,_.reply.arg)}}:i=async(o,...a)=>{var c,f;o=Object.assign(Object.assign({},o),(f=(c=t[ar].config).callTransform)===null||f===void 0?void 0:f.call(c,e,a,Object.assign(Object.assign({},t[ar].config),o)));let d=o.agent||t[ar].config.agent||(0,Xl.getDefaultAgent)(),{canisterId:h,effectiveCanisterId:m,pollingStrategyFactory:_}=Object.assign(Object.assign(Object.assign({},Jp),t[ar].config),o),u=cr.Principal.from(h),O=m!==void 0?cr.Principal.from(m):u,T=Cs.IDL.encode(r.argTypes,a),{requestId:P,response:F,requestDetails:A}=await d.call(u,{methodName:e,arg:T,effectiveCanisterId:O}),K,E;if(F.body&&F.body.certificate){if(d.rootKey==null)throw new Error("Agent is missing root key");let q=F.body.certificate;E=await Hi.Certificate.create({certificate:(0,Cs.bufFromBufLike)(q),rootKey:d.rootKey,canisterId:cr.Principal.from(h),blsVerify:n});let oe=[new TextEncoder().encode("request_status"),P];switch(new TextDecoder().decode((0,Hi.lookupResultToBuffer)(E.lookup([...oe,"status"])))){case"replied":K=(0,Hi.lookupResultToBuffer)(E.lookup([...oe,"reply"]));break;case"rejected":{let ie=new Uint8Array((0,Hi.lookupResultToBuffer)(E.lookup([...oe,"reject_code"])))[0],w=new TextDecoder().decode((0,Hi.lookupResultToBuffer)(E.lookup([...oe,"reject_message"]))),b=(0,Hi.lookupResultToBuffer)(E.lookup([...oe,"error_code"])),N=b?new TextDecoder().decode(b):void 0;throw new js(u,e,P,F,ie,w,N)}}}else if(F.body&&"reject_message"in F.body){let{reject_code:q,reject_message:oe,error_code:Q}=F.body;throw new js(u,e,P,F,q,oe,Q)}if(F.status===202){let q=_(),oe=await(0,Zp.pollForResponse)(d,O,P,q,n);E=oe.certificate,K=oe.reply}let j=r.annotations.includes(Ye.ACTOR_METHOD_WITH_HTTP_DETAILS),G=r.annotations.includes(Ye.ACTOR_METHOD_WITH_CERTIFICATE),z=Object.assign(Object.assign({},F),{requestDetails:A});if(K!==void 0)return j&&G?{httpDetails:z,certificate:E,result:Vi(r.retTypes,K)}:G?{certificate:E,result:Vi(r.retTypes,K)}:j?{httpDetails:z,result:Vi(r.retTypes,K)}:Vi(r.retTypes,K);if(r.retTypes.length===0)return j?{httpDetails:F,result:void 0}:void 0;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let s=(...o)=>i({},...o);return s.withOptions=o=>(...a)=>i(o,...a),s}function Ll(t){function e(r,n){if(t.effectiveCanisterId)return{effectiveCanisterId:cr.Principal.from(t.effectiveCanisterId)};let i=n[0],s=cr.Principal.fromHex("");return i&&typeof i=="object"&&i.target_canister&&r==="install_chunked_code"&&(s=cr.Principal.from(i.target_canister)),i&&typeof i=="object"&&i.canister_id&&(s=cr.Principal.from(i.canister_id)),{effectiveCanisterId:s}}return ks.createActor(yE.default,Object.assign(Object.assign(Object.assign({},t),{canisterId:cr.Principal.fromHex("")}),{callTransform:e,queryTransform:e}))}Ye.getManagementCanister=Ll;var ef=class extends ks{constructor(e){super(e)}};Ye.AdvancedActor=ef});var Xp=ee(tf=>{"use strict";Object.defineProperty(tf,"__esModule",{value:!0});tf.default=({IDL:t})=>t.Service({retrieve:t.Func([t.Text],[t.Vec(t.Nat8)],["query"]),store:t.Func([t.Text,t.Vec(t.Nat8)],[],[])})});var Qp=ee($i=>{"use strict";var mE=$i&&$i.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty($i,"__esModule",{value:!0});$i.createAssetCanisterActor=void 0;var bE=za(),_E=mE(Xp());function wE(t){return bE.Actor.createActor(_E.default,t)}$i.createAssetCanisterActor=wE});var Lp=ee($r=>{"use strict";var EE=$r&&$r.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),xE=$r&&$r.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),vE=$r&&$r.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&EE(e,t,r);return xE(e,t),e};Object.defineProperty($r,"__esModule",{value:!0});$r.fetchCandid=void 0;var TE=Ut(),AE=vE(Bs()),SE=zl(),BE=za();async function OE(t,e){e||(e=await SE.HttpAgent.create());let n=(await AE.request({agent:e,canisterId:TE.Principal.fromText(t),paths:["candid"]})).get("candid");if(n)return n;let i=({IDL:o})=>o.Service({__get_candid_interface_tmp_hack:o.Func([],[o.Text],["query"])});return await BE.Actor.createActor(i,{agent:e,canisterId:t}).__get_candid_interface_tmp_hack()}$r.fetchCandid=OE});var Qt=ee(Re=>{"use strict";var ey=Re&&Re.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),NE=Re&&Re.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),It=Re&&Re.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&ey(e,t,r)},rf=Re&&Re.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&ey(e,t,r);return NE(e,t),e};Object.defineProperty(Re,"__esModule",{value:!0});Re.Cbor=Re.CanisterStatus=Re.polling=void 0;It(za(),Re);It(Ss(),Re);It(Xo(),Re);It(gs(),Re);It(Hu(),Re);It(Qp(),Re);It(Oi(),Re);It(Vl(),Re);It(Lp(),Re);It(Gl(),Re);It($l(),Re);It(ds(),Re);It(wl(),Re);It(Vt(),Re);It(Zu(),Re);Re.polling=rf(Ya());Re.CanisterStatus=rf(Bs());Re.Cbor=rf(ys());It(Ya(),Re)});var mt=ee((c3,gy)=>{"use strict";var cf=Object.defineProperty,RE=Object.getOwnPropertyDescriptor,PE=Object.getOwnPropertyNames,IE=Object.prototype.hasOwnProperty,UE=(t,e)=>{for(var r in e)cf(t,r,{get:e[r],enumerable:!0})},FE=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of PE(e))!IE.call(t,i)&&i!==r&&cf(t,i,{get:()=>e[i],enumerable:!(n=RE(e,i))||n.enumerable});return t},ME=t=>FE(cf({},"__esModule",{value:!0}),t),iy={};UE(iy,{AgentManager:()=>GE,Canister:()=>$E,FromStringToTokenError:()=>sy,ICPToken:()=>kE,InvalidPercentageError:()=>fy,NullishError:()=>dy,TokenAmount:()=>HE,TokenAmountV2:()=>VE,arrayBufferToUint8Array:()=>XE,arrayOfNumberToUint8Array:()=>LE,asNonNullish:()=>WE,asciiStringToByteArray:()=>ex,assertNonNullish:()=>Ks,assertPercentageNumber:()=>zE,base64ToUint8Array:()=>ax,bigEndianCrc32:()=>lx,bigIntToUint8Array:()=>ZE,candidNumberArrayToBigInt:()=>nx,convertStringToE8s:()=>oy,createAgent:()=>uy,createServices:()=>YE,debounce:()=>gx,decodeBase32:()=>sx,defaultAgent:()=>cy,encodeBase32:()=>ix,fromDefinedNullable:()=>bx,fromNullable:()=>uf,fromNullishNullable:()=>_x,hexStringToUint8Array:()=>tx,isEmptyString:()=>KE,isNullish:()=>Da,jsonReplacer:()=>wx,jsonReviver:()=>Ex,nonNullish:()=>Kr,notEmptyString:()=>ay,nowInBigIntNanoSeconds:()=>px,numberToUint8Array:()=>JE,principalToSubAccount:()=>xx,secondsToDuration:()=>dx,smallerVersion:()=>vx,toBigIntNanoSeconds:()=>yx,toNullable:()=>mx,uint8ArrayToArrayOfNumber:()=>QE,uint8ArrayToBase64:()=>ox,uint8ArrayToBigInt:()=>DE,uint8ArrayToHexString:()=>rx});gy.exports=ME(iy);var sy=(t=>(t[t.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",t[t.InvalidFormat=1]="InvalidFormat",t[t.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",t))(sy||{}),CE=BigInt(1e8),qE=8,oy=t=>{let e=t.includes("e")?Number(t).toLocaleString("en",{useGrouping:!1,maximumFractionDigits:20}):t;e=e.trim().replace(/[,']/g,"");let r=e.match(/\d*(\.\d*)?/);if(!r||r[0]!==e)return 1;let[n,i]=e.split("."),s=BigInt(0);if(n)try{s+=BigInt(n)*CE}catch{return 1}if(i){if(i.length>8)return 0;try{s+=BigInt(i.padEnd(8,"0"))}catch{return 1}}return s},jE=({amount:t,decimals:e})=>{t=t.trim().replace(/[,']/g,"");let r=t.match(/\d*(\.\d*)?/);if(!r||r[0]!==t)return 1;let[n,i]=t.split("."),s=0n,o=10n**BigInt(e);if(n)try{s+=BigInt(n)*o}catch{return 1}if(i){if(i.length>e)return 2;try{s+=BigInt(i.padEnd(e,"0"))}catch{return 1}}return s},kE={symbol:"ICP",name:"Internet Computer",decimals:8},HE=class Vs{constructor(e,r){if(this.e8s=e,this.token=r,r.decimals!==8)throw new Error("Use TokenAmountV2 for number of decimals other than 8")}static fromE8s({amount:e,token:r}){return new Vs(e,r)}static fromString({amount:e,token:r}){if(r.decimals!==8)throw new Error("Use TokenAmountV2 for number of decimals other than 8");let n=oy(e);return typeof n=="bigint"?new Vs(n,r):n}static fromNumber({amount:e,token:r}){let n=Vs.fromString({amount:e.toString(),token:r});if(n instanceof Vs)return n;throw n===0?new Error(`Number ${e} has more than 8 decimals`):new Error(`Invalid number ${e}`)}toE8s(){return this.e8s}},VE=class $s{constructor(e,r){this.ulps=e,this.token=r}static fromUlps({amount:e,token:r}){return new $s(e,r)}static fromString({amount:e,token:r}){let n=jE({amount:e,decimals:r.decimals});return typeof n=="bigint"?new $s(n,r):n}static fromNumber({amount:e,token:r}){let n=$s.fromString({amount:e.toFixed(Math.min(qE,r.decimals)),token:r});if(n instanceof $s)return n;throw n===2?new Error(`Number ${e} has more than ${r.decimals} decimals`):new Error(`Invalid number ${e}`)}toUlps(){return this.ulps}toE8s(){return this.token.decimals<8?this.ulps*10n**BigInt(8-this.token.decimals):this.token.decimals===8?this.ulps:this.ulps/10n**BigInt(this.token.decimals-8)}},$E=class{constructor(t,e,r){this.id=t,this.service=e,this.certifiedService=r,this.caller=({certified:n=!0})=>n?this.certifiedService:this.service}get canisterId(){return this.id}},ty=Qt(),nf=Qt(),Da=t=>t==null,Kr=t=>!Da(t),ay=t=>Kr(t)&&t!=="",KE=t=>!ay(t),cy=()=>nf.HttpAgent.createSync({host:"https://icp-api.io",identity:new nf.AnonymousIdentity}),uy=async({identity:t,host:e,fetchRootKey:r=!1,verifyQuerySignatures:n=!1,retryTimes:i})=>await nf.HttpAgent.create({identity:t,...Kr(e)&&{host:e},verifyQuerySignatures:n,...Kr(i)&&{retryTimes:i},shouldFetchRootKey:r}),GE=class ly{constructor(e){this.config=e,this.agents=void 0,this.getAgent=async({identity:r})=>{let n=r.getPrincipal().toText();if(Da(this.agents)||Da(this.agents[n])){let i=await uy({identity:r,fetchRootKey:this.config.fetchRootKey,host:this.config.host,verifyQuerySignatures:!0});return this.agents={...this.agents??{},[n]:i},i}return this.agents[n]},this.clearAgents=()=>{this.agents=null}}static create(e){return new ly(e)}},YE=({options:{canisterId:t,serviceOverride:e,certifiedServiceOverride:r,agent:n,callTransform:i,queryTransform:s},idlFactory:o,certifiedIdlFactory:a})=>{let c=n??cy(),f=e??ty.Actor.createActor(o,{agent:c,canisterId:t,callTransform:i,queryTransform:s}),d=r??ty.Actor.createActor(a,{agent:c,canisterId:t,callTransform:i,queryTransform:s});return{service:f,certifiedService:d,agent:c,canisterId:t}},fy=class extends Error{},dy=class extends Error{},Ks=(t,e)=>{if(t==null)throw new dy(e)},WE=(t,e)=>(Ks(t,e),t),zE=t=>{if(t<0||t>100)throw new fy(`${t} is not a valid percentage number.`)},DE=t=>{let e=new DataView(t.buffer,t.byteOffset,t.byteLength);if(typeof e.getBigUint64=="function")return e.getBigUint64(0);{let r=BigInt(e.getUint32(0)),n=BigInt(e.getUint32(4));return(r<<BigInt(32))+n}},ZE=t=>{let e=new ArrayBuffer(8),r=new DataView(e);if(typeof r.setBigUint64=="function")r.setBigUint64(0,t);else{let n=Number(t>>BigInt(32)),i=Number(t&BigInt(4294967295));r.setUint32(0,n),r.setUint32(4,i)}return new Uint8Array(e)},JE=t=>{let e=new DataView(new ArrayBuffer(8));for(let r=7;r>=0;--r)e.setUint8(r,t%256),t=t>>8;return new Uint8Array(e.buffer)},XE=t=>new Uint8Array(t),QE=t=>Array.from(t),LE=t=>new Uint8Array(t),ex=t=>Array.from(t).map(e=>e.charCodeAt(0)),tx=t=>{let e=t.match(/.{1,2}/g);return Ks(e,"Invalid hex string."),Uint8Array.from(e.map(r=>parseInt(r,16)))},rx=t=>(t instanceof Uint8Array||(t=Uint8Array.from(t)),t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")),nx=t=>{let e=0n;for(let r=t.length-1;r>=0;r--)e=(e<<32n)+BigInt(t[r]);return e},Za="abcdefghijklmnopqrstuvwxyz234567",Ki=Object.create(null);for(let t=0;t<Za.length;t++)Ki[Za[t]]=t;Ki[0]=Ki.o;Ki[1]=Ki.i;var ix=t=>{let e=0,r=0,n="";function i(s){return e<0?r|=s>>-e:r=s<<e&248,e>3?(e-=8,1):(e<4&&(n+=Za[r>>3],e+=5),0)}for(let s=0;s<t.length;)s+=i(t[s]);return n+(e<0?Za[r>>3]:"")};function sx(t){let e=0,r=0,n=new Uint8Array(t.length*4/3|0),i=0;function s(o){let a=Ki[o.toLowerCase()];Ks(a,`Invalid character: ${JSON.stringify(o)}`),a<<=3,r|=a>>>e,e+=5,e>=8&&(n[i++]=r,e-=8,e>0?r=a<<5-e&255:r=0)}for(let o of t)s(o);return n.slice(0,i)}var ox=t=>btoa(String.fromCharCode(...new Uint8Array(t))),ax=t=>Uint8Array.from(atob(t),e=>e.charCodeAt(0)),cx=new Uint32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]),ux=t=>{let e=-1;for(let r=0;r<t.length;r++){let n=(t[r]^e)&255;e=cx[n]^e>>>8}return(e^-1)>>>0},lx=t=>{let e=new ArrayBuffer(4);return new DataView(e).setUint32(0,ux(t),!1),new Uint8Array(e)},fx={year:"year",year_plural:"years",month:"month",month_plural:"months",day:"day",day_plural:"days",hour:"hour",hour_plural:"hours",minute:"minute",minute_plural:"minutes",second:"second",second_plural:"seconds"},dx=({seconds:t,i18n:e=fx})=>{let r=t/BigInt(60),n=r/BigInt(60);r-=n*BigInt(60);let i=n/BigInt(24);n-=i*BigInt(24);let s=hx(i);return i-=hy(s),[Hs("year",s),Hs("day",i),Hs("hour",n),Hs("minute",r),...t>BigInt(0)&&t<BigInt(60)?[Hs("second",t)]:[]].filter(({amount:o})=>o>0).slice(0,2).map(o=>`${o.amount} ${o.amount===1?e[o.labelKey]:e[`${o.labelKey}_plural`]}`).join(", ")},hx=t=>{let e=t/BigInt(365);for(;hy(e)>t;)e--;return e},hy=t=>{let e=t/BigInt(4);return t*BigInt(365)+e},Hs=(t,e)=>({labelKey:t,amount:Number(e)}),py=1000000n,px=()=>BigInt(Date.now())*py,yx=t=>BigInt(t.getTime())*py,gx=(t,e)=>{let r;return(...n)=>{let i=()=>t(...n);r&&clearTimeout(r),r=setTimeout(i,e!==void 0&&e>0?e:300)}},mx=t=>Kr(t)?[t]:[],uf=t=>t?.[0],bx=t=>{let e=uf(t);return Ks(e),e},_x=t=>uf(t??[]),yy=Ut(),sf="__bigint__",of="__principal__",af="__uint8array__",wx=(t,e)=>typeof e=="bigint"?{[sf]:`${e}`}:Kr(e)&&e instanceof yy.Principal?{[of]:e.toText()}:Kr(e)&&e instanceof Uint8Array?{[af]:Array.from(e)}:e,Ex=(t,e)=>{let r=n=>e[n];return Kr(e)&&typeof e=="object"&&sf in e?BigInt(r(sf)):Kr(e)&&typeof e=="object"&&of in e?yy.Principal.fromText(r(of)):Kr(e)&&typeof e=="object"&&af in e?Uint8Array.from(r(af)):e},xx=t=>{let e=t.toUint8Array(),r=new Uint8Array(32);return r[0]=e.length,r.set(e,1),r},ry=(t,e)=>e>t.length?[...t,...[...Array(e-t.length).keys()].map(()=>0)]:t,ny=t=>{if(!Number.isNaN(Number(t)))return Number(t);let e=t.split("").reduce((r,n)=>Number.isNaN(Number(n))?r:r+n,"");return Number(e)},vx=({minVersion:t,currentVersion:e})=>{let r=ry(t.split(".").map(ny),3).join(".");return ry(e.split(".").map(ny),3).join(".").localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})<0}});var by=ee(Gr=>{"use strict";var Qa=Gr&&Gr.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Pn=Gr&&Gr.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Ja,Xa,Yi,Wi;Object.defineProperty(Gr,"__esModule",{value:!0});Gr.Ed25519KeyIdentity=Gr.Ed25519PublicKey=void 0;var Tx=Qt(),Lt=Qt(),Gs=kl();function my(t){return t!==null&&typeof t=="object"}var ri=class t{constructor(e){if(Ja.set(this,void 0),Xa.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Qa(this,Ja,e,"f"),Qa(this,Xa,t.derEncode(e),"f")}static from(e){if(typeof e=="string"){let r=(0,Lt.fromHex)(e);return this.fromRaw(r)}else if(my(e)){let r=e;if(my(r)&&Object.hasOwnProperty.call(r,"__derEncodedPublicKey__"))return this.fromDer(r);if(ArrayBuffer.isView(r)){let n=r;return this.fromRaw((0,Lt.bufFromBufLike)(n.buffer))}else{if(r instanceof ArrayBuffer)return this.fromRaw(r);if("rawKey"in r)return this.fromRaw(r.rawKey);if("derKey"in r)return this.fromDer(r.derKey);if("toDer"in r)return this.fromDer(r.toDer())}}throw new Error("Cannot construct Ed25519PublicKey from the provided key.")}static fromRaw(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){let r=(0,Lt.wrapDER)(e,Lt.ED25519_OID).buffer;return r.__derEncodedPublicKey__=void 0,r}static derDecode(e){let r=(0,Lt.unwrapDER)(e,Lt.ED25519_OID);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return Pn(this,Ja,"f")}get derKey(){return Pn(this,Xa,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Gr.Ed25519PublicKey=ri;Ja=new WeakMap,Xa=new WeakMap;ri.RAW_KEY_LENGTH=32;var ff=class t extends Lt.SignIdentity{constructor(e,r){super(),Yi.set(this,void 0),Wi.set(this,void 0),Qa(this,Yi,ri.from(e),"f"),Qa(this,Wi,new Uint8Array(r),"f")}static generate(e){if(e&&e.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");e||(e=Gs.ed25519.utils.randomPrivateKey()),(0,Tx.bufEquals)(e,new Uint8Array(new Array(32).fill(0)))&&console.warn("Seed is all zeros. This is not a secure seed. Please provide a seed with sufficient entropy if this is a production environment.");let r=new Uint8Array(32);for(let i=0;i<32;i++)r[i]=new Uint8Array(e)[i];let n=Gs.ed25519.getPublicKey(r);return t.fromKeyPair(n,r)}static fromParsedJson(e){let[r,n]=e;return new t(ri.fromDer((0,Lt.fromHex)(r)),(0,Lt.fromHex)(n))}static fromJSON(e){let r=JSON.parse(e);if(Array.isArray(r)){if(typeof r[0]=="string"&&typeof r[1]=="string")return this.fromParsedJson([r[0],r[1]]);throw new Error("Deserialization error: JSON must have at least 2 items.")}throw new Error(`Deserialization error: Invalid JSON type for string: ${JSON.stringify(e)}`)}static fromKeyPair(e,r){return new t(ri.fromRaw(e),r)}static fromSecretKey(e){let r=Gs.ed25519.getPublicKey(new Uint8Array(e));return t.fromKeyPair(r,e)}toJSON(){return[(0,Lt.toHex)(Pn(this,Yi,"f").toDer()),(0,Lt.toHex)(Pn(this,Wi,"f"))]}getKeyPair(){return{secretKey:Pn(this,Wi,"f"),publicKey:Pn(this,Yi,"f")}}getPublicKey(){return Pn(this,Yi,"f")}async sign(e){let r=new Uint8Array(e),n=(0,Lt.uint8ToBuf)(Gs.ed25519.sign(r,Pn(this,Wi,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(e,r,n){let[i,s,o]=[e,r,n].map(a=>(typeof a=="string"&&(a=(0,Lt.fromHex)(a)),a instanceof Uint8Array&&(a=a.buffer),new Uint8Array(a)));return Gs.ed25519.verify(s,i,o)}};Gr.Ed25519KeyIdentity=ff;Yi=new WeakMap,Wi=new WeakMap});var wy=ee(ni=>{"use strict";Object.defineProperty(ni,"__esModule",{value:!0});ni.ECDSAKeyIdentity=ni.CryptoError=void 0;var Ax=Qt(),La=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};ni.CryptoError=La;function _y(t){if(typeof global<"u"&&global.crypto&&global.crypto.subtle)return global.crypto.subtle;if(t)return t;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new La("Global crypto was not available and none was provided. Please inlcude a SubtleCrypto implementation. See https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto")}var ec=class t extends Ax.SignIdentity{constructor(e,r,n){super(),this._keyPair=e,this._derKey=r,this._subtleCrypto=n}static async generate(e){let{extractable:r=!1,keyUsages:n=["sign","verify"],subtleCrypto:i}=e??{},s=_y(i),o=await s.generateKey({name:"ECDSA",namedCurve:"P-256"},r,n),a=await s.exportKey("spki",o.publicKey);return new this(o,a,s)}static async fromKeyPair(e,r){let n=_y(r),i=await n.exportKey("spki",e.publicKey);return new t(e,i,n)}getKeyPair(){return this._keyPair}getPublicKey(){let e=this._derKey,r=Object.create(this._keyPair.publicKey);return r.toDer=function(){return e},r}async sign(e){let r={name:"ECDSA",hash:{name:"SHA-256"}};return await this._subtleCrypto.sign(r,this._keyPair.privateKey,e)}};ni.ECDSAKeyIdentity=ec;ni.default=ec});var hf=ee(Un=>{"use strict";var Sx=Un&&Un.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Ys=Un&&Un.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},In;Object.defineProperty(Un,"__esModule",{value:!0});Un.PartialIdentity=void 0;var Bx=Ut(),df=class{constructor(e){In.set(this,void 0),Sx(this,In,e,"f")}get rawKey(){return Ys(this,In,"f").rawKey}get derKey(){return Ys(this,In,"f").derKey}toDer(){return Ys(this,In,"f").toDer()}getPublicKey(){return Ys(this,In,"f")}getPrincipal(){return Bx.Principal.from(Ys(this,In,"f").rawKey)}transformRequest(){return Promise.reject("Not implemented. You are attempting to use a partial identity to sign calls, but this identity only has access to the public key.To sign calls, use a DelegationIdentity instead.")}};Un.PartialIdentity=df;In=new WeakMap});var Ey=ee(De=>{"use strict";var Ox=De&&De.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Nx=De&&De.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Rx=De&&De.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Ox(e,t,r);return Nx(e,t),e},Px=De&&De.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Ix=De&&De.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Ux=De&&De.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},tc;Object.defineProperty(De,"__esModule",{value:!0});De.isDelegationValid=De.PartialDelegationIdentity=De.DelegationIdentity=De.DelegationChain=De.Delegation=void 0;var Fn=Qt(),yf=Ut(),Ws=Rx(ps()),Fx=hf(),Mx=new TextEncoder().encode("ic-request-auth-delegation"),Cx=new TextEncoder().encode(`
|
|
57
|
-
ic-request`);function pf(t){if(typeof t!="string"||t.length<64)throw new Error("Invalid public key.");return(0,Fn.fromHex)(t)}var zs=class{constructor(e,r,n){this.pubkey=e,this.expiration=r,this.targets=n}toCBOR(){return Ws.value.map(Object.assign({pubkey:Ws.value.bytes(this.pubkey),expiration:Ws.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:Ws.value.array(this.targets.map(e=>Ws.value.bytes(e.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:(0,Fn.toHex)(this.pubkey)},this.targets&&{targets:this.targets.map(e=>e.toHex())})}};De.Delegation=zs;async function qx(t,e,r,n){let i=new zs(e.toDer(),BigInt(+r)*BigInt(1e6),n),s=new Uint8Array([...Mx,...new Uint8Array((0,Fn.requestIdOf)(Object.assign({},i)))]),o=await t.sign(s);return{delegation:i,signature:o}}var gf=class t{constructor(e,r){this.delegations=e,this.publicKey=r}static async create(e,r,n=new Date(Date.now()+15*60*1e3),i={}){var s,o;let a=await qx(e,r,n,i.targets);return new t([...((s=i.previous)===null||s===void 0?void 0:s.delegations)||[],a],((o=i.previous)===null||o===void 0?void 0:o.publicKey)||e.getPublicKey().toDer())}static fromJSON(e){let{publicKey:r,delegations:n}=typeof e=="string"?JSON.parse(e):e;if(!Array.isArray(n))throw new Error("Invalid delegations.");let i=n.map(s=>{let{delegation:o,signature:a}=s,{pubkey:c,expiration:f,targets:d}=o;if(d!==void 0&&!Array.isArray(d))throw new Error("Invalid targets.");return{delegation:new zs(pf(c),BigInt("0x"+f),d&&d.map(h=>{if(typeof h!="string")throw new Error("Invalid target.");return yf.Principal.fromHex(h)})),signature:pf(a)}});return new this(i,pf(r))}static fromDelegations(e,r){return new this(e,r)}toJSON(){return{delegations:this.delegations.map(e=>{let{delegation:r,signature:n}=e,{targets:i}=r;return{delegation:Object.assign({expiration:r.expiration.toString(16),pubkey:(0,Fn.toHex)(r.pubkey)},i&&{targets:i.map(s=>s.toHex())}),signature:(0,Fn.toHex)(n)}}),publicKey:(0,Fn.toHex)(this.publicKey)}}};De.DelegationChain=gf;var mf=class extends Fn.SignIdentity{constructor(e,r){super(),this._inner=e,this._delegation=r}static fromDelegation(e,r){return new this(e,r)}getDelegation(){return this._delegation}getPublicKey(){return{derKey:this._delegation.publicKey,toDer:()=>this._delegation.publicKey}}sign(e){return this._inner.sign(e)}async transformRequest(e){let{body:r}=e,n=Ux(e,["body"]),i=await(0,Fn.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...Cx,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};De.DelegationIdentity=mf;var bf=class t extends Fx.PartialIdentity{constructor(e,r){super(e),tc.set(this,void 0),Px(this,tc,r,"f")}get delegation(){return Ix(this,tc,"f")}static fromDelegation(e,r){return new t(e,r)}};De.PartialDelegationIdentity=bf;tc=new WeakMap;function jx(t,e){for(let{delegation:i}of t.delegations)if(+new Date(Number(i.expiration/BigInt(1e6)))<=+Date.now())return!1;let r=[],n=e?.scope;n&&(Array.isArray(n)?r.push(...n.map(i=>typeof i=="string"?yf.Principal.fromText(i):i)):r.push(typeof n=="string"?yf.Principal.fromText(n):n));for(let i of r){let s=i.toText();for(let{delegation:o}of t.delegations){if(o.targets===void 0)continue;let a=!0;for(let c of o.targets)if(c.toText()===s){a=!1;break}if(a)return!1}}return!0}De.isDelegationValid=jx});var xy=ee(Mn=>{"use strict";var kx=Mn&&Mn.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Mn,"__esModule",{value:!0});Mn.WebAuthnIdentity=Mn.CosePublicKey=void 0;var ii=Qt(),_f=kx(Vo()),Hx=kn(),Vx=xi();function $x(t){return(0,ii.wrapDER)(t,ii.DER_COSE_OID).buffer}function Kx(t){let e=new DataView(new ArrayBuffer(2)),r=t.slice(53,55);[...new Uint8Array(r)].forEach((i,s)=>e.setUint8(s,i));let n=e.getUint16(0);return t.slice(55+n)}var rc=class{constructor(e){this._cose=e,this._encodedKey=$x(e)}toDer(){return this._encodedKey}getCose(){return this._cose}};Mn.CosePublicKey=rc;function Gx(t="<ic0.app>"){return typeof t=="string"?Uint8Array.from(t,e=>e.charCodeAt(0)):t}async function Yx(t){let e=await navigator.credentials.create(t??{publicKey:{authenticatorSelection:{userVerification:"preferred"},attestation:"direct",challenge:Gx(),pubKeyCredParams:[{type:"public-key",alg:wf.ECDSA_WITH_SHA256}],rp:{name:"Internet Identity Service"},user:{id:(0,Hx.randomBytes)(16),name:"Internet Identity",displayName:"Internet Identity"}}});return e===null?null:{id:e.id,response:e.response,type:e.type,authenticatorAttachment:e.authenticatorAttachment,getClientExtensionResults:e.getClientExtensionResults,rawId:(0,Vx.bufFromBufLike)(e.rawId)}}var wf;(function(t){t[t.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(wf||(wf={}));var Ef=class extends ii.SignIdentity{constructor(e,r,n){super(),this.rawId=e,this.authenticatorAttachment=n,this._publicKey=new rc(r)}static fromJSON(e){let{publicKey:r,rawId:n}=JSON.parse(e);if(typeof r!="string"||typeof n!="string")throw new Error("Invalid JSON string.");return new this((0,ii.fromHex)(n),(0,ii.fromHex)(r),void 0)}static async create(e){var r;let n=await Yx(e);if(!n||n.type!=="public-key")throw new Error("Could not create credentials.");let i=n.response;if(i.attestationObject===void 0)throw new Error("Was expecting an attestation response.");let s=_f.default.decodeFirst(new Uint8Array(i.attestationObject));return new this(n.rawId,Kx(s.authData),(r=n.authenticatorAttachment)!==null&&r!==void 0?r:void 0)}getPublicKey(){return this._publicKey}getAuthenticatorAttachment(){return this.authenticatorAttachment}async sign(e){let r=await navigator.credentials.get({publicKey:{allowCredentials:[{type:"public-key",id:this.rawId}],challenge:e,userVerification:"preferred"}});r.authenticatorAttachment!==null&&(this.authenticatorAttachment=r.authenticatorAttachment);let n=r.response,i=_f.default.encode(new _f.default.Tagged(55799,{authenticator_data:new Uint8Array(n.authenticatorData),client_data_json:new TextDecoder().decode(n.clientDataJSON),signature:new Uint8Array(n.signature)}));if(!i)throw new Error("failed to encode cbor");return i.buffer}toJSON(){return{publicKey:(0,ii.toHex)(this._publicKey.getCose()),rawId:(0,ii.toHex)(this.rawId)}}};Mn.WebAuthnIdentity=Ef});var Ty=ee(We=>{"use strict";var Wx=We&&We.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),vf=We&&We.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Wx(e,t,r)};Object.defineProperty(We,"__esModule",{value:!0});We.Secp256k1KeyIdentity=We.ED25519_OID=We.DER_COSE_OID=We.unwrapDER=We.wrapDER=We.WebAuthnIdentity=We.Ed25519PublicKey=We.Ed25519KeyIdentity=void 0;var vy=by();Object.defineProperty(We,"Ed25519KeyIdentity",{enumerable:!0,get:function(){return vy.Ed25519KeyIdentity}});Object.defineProperty(We,"Ed25519PublicKey",{enumerable:!0,get:function(){return vy.Ed25519PublicKey}});vf(wy(),We);vf(Ey(),We);vf(hf(),We);var zx=xy();Object.defineProperty(We,"WebAuthnIdentity",{enumerable:!0,get:function(){return zx.WebAuthnIdentity}});var nc=Qt();Object.defineProperty(We,"wrapDER",{enumerable:!0,get:function(){return nc.wrapDER}});Object.defineProperty(We,"unwrapDER",{enumerable:!0,get:function(){return nc.unwrapDER}});Object.defineProperty(We,"DER_COSE_OID",{enumerable:!0,get:function(){return nc.DER_COSE_OID}});Object.defineProperty(We,"ED25519_OID",{enumerable:!0,get:function(){return nc.ED25519_OID}});var xf=class{constructor(){throw new Error("Secp256k1KeyIdentity has been moved to a new repo: @dfinity/identity-secp256k1")}};We.Secp256k1KeyIdentity=xf});var Af=ee(ic=>{"use strict";Object.defineProperty(ic,"__esModule",{value:!0});ic.IdleManager=void 0;var Ay=["mousedown","mousemove","keydown","touchstart","wheel"],Tf=class{constructor(e={}){var r;this.callbacks=[],this.idleTimeout=10*60*1e3,this.timeoutID=void 0;let{onIdle:n,idleTimeout:i=10*60*1e3}=e||{};this.callbacks=n?[n]:[],this.idleTimeout=i;let s=this._resetTimer.bind(this);window.addEventListener("load",s,!0),Ay.forEach(function(a){document.addEventListener(a,s,!0)});let o=(a,c)=>{let f;return(...d)=>{let h=this,m=function(){f=void 0,a.apply(h,d)};clearTimeout(f),f=window.setTimeout(m,c)}};if(e?.captureScroll){let a=o(s,(r=e?.scrollDebounce)!==null&&r!==void 0?r:100);window.addEventListener("scroll",a,!0)}s()}static create(e={}){return new this(e)}registerCallback(e){this.callbacks.push(e)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let e=this._resetTimer.bind(this);Ay.forEach(function(r){document.removeEventListener(r,e,!0)}),this.callbacks.forEach(r=>r())}_resetTimer(){let e=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(e,this.idleTimeout)}};ic.IdleManager=Tf});function Zx(){return Sy||(Sy=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Jx(){return By||(By=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}function Xx(t){let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("success",s),t.removeEventListener("error",o)},s=()=>{r(ur(t.result)),i()},o=()=>{n(t.error),i()};t.addEventListener("success",s),t.addEventListener("error",o)});return e.then(r=>{r instanceof IDBCursor&&Oy.set(r,t)}).catch(()=>{}),Nf.set(e,t),e}function Qx(t){if(Bf.has(t))return;let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("complete",s),t.removeEventListener("error",o),t.removeEventListener("abort",o)},s=()=>{r(),i()},o=()=>{n(t.error||new DOMException("AbortError","AbortError")),i()};t.addEventListener("complete",s),t.addEventListener("error",o),t.addEventListener("abort",o)});Bf.set(t,e)}function Ry(t){Of=t(Of)}function Lx(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(Ds(this),e,...r);return Ny.set(n,e.sort?e.sort():[e]),ur(n)}:Jx().includes(t)?function(...e){return t.apply(Ds(this),e),ur(Oy.get(this))}:function(...e){return ur(t.apply(Ds(this),e))}}function e8(t){return typeof t=="function"?Lx(t):(t instanceof IDBTransaction&&Qx(t),Dx(t,Zx())?new Proxy(t,Of):t)}function ur(t){if(t instanceof IDBRequest)return Xx(t);if(Sf.has(t))return Sf.get(t);let e=e8(t);return e!==t&&(Sf.set(t,e),Nf.set(e,t)),e}var Dx,Sy,By,Oy,Bf,Ny,Sf,Nf,Of,Ds,Rf=Xf(()=>{Dx=(t,e)=>e.some(r=>t instanceof r);Oy=new WeakMap,Bf=new WeakMap,Ny=new WeakMap,Sf=new WeakMap,Nf=new WeakMap;Of={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return Bf.get(t);if(e==="objectStoreNames")return t.objectStoreNames||Ny.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return ur(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};Ds=t=>Nf.get(t)});var Iy={};em(Iy,{deleteDB:()=>r8,openDB:()=>t8,unwrap:()=>Ds,wrap:()=>ur});function t8(t,e,{blocked:r,upgrade:n,blocking:i,terminated:s}={}){let o=indexedDB.open(t,e),a=ur(o);return n&&o.addEventListener("upgradeneeded",c=>{n(ur(o.result),c.oldVersion,c.newVersion,ur(o.transaction),c)}),r&&o.addEventListener("blocked",c=>r(c.oldVersion,c.newVersion,c)),a.then(c=>{s&&c.addEventListener("close",()=>s()),i&&c.addEventListener("versionchange",f=>i(f.oldVersion,f.newVersion,f))}).catch(()=>{}),a}function r8(t,{blocked:e}={}){let r=indexedDB.deleteDatabase(t);return e&&r.addEventListener("blocked",n=>e(n.oldVersion,n)),ur(r).then(()=>{})}function Py(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(Pf.get(e))return Pf.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,i=i8.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||n8.includes(r)))return;let s=async function(o,...a){let c=this.transaction(o,i?"readwrite":"readonly"),f=c.store;return n&&(f=f.index(a.shift())),(await Promise.all([f[r](...a),i&&c.done]))[0]};return Pf.set(e,s),s}var n8,i8,Pf,Uy=Xf(()=>{Rf();Rf();n8=["get","getKey","getAll","getAllKeys","count"],i8=["put","add","delete","clear"],Pf=new Map;Ry(t=>({...t,get:(e,r,n)=>Py(e,r)||t.get(e,r,n),has:(e,r)=>!!Py(e,r)||t.has(e,r)}))});var Uf=ee(sc=>{"use strict";Object.defineProperty(sc,"__esModule",{value:!0});sc.IdbKeyVal=void 0;var s8=(Uy(),tm(Iy)),Zs=oc(),Fy="auth-client-db",My="ic-keyval",o8=async(t=Fy,e=My,r)=>(Zs.isBrowser&&(localStorage!=null&&localStorage.getItem(Zs.KEY_STORAGE_DELEGATION))&&(localStorage.removeItem(Zs.KEY_STORAGE_DELEGATION),localStorage.removeItem(Zs.KEY_STORAGE_KEY)),await(0,s8.openDB)(t,r,{upgrade:n=>{n.objectStoreNames.contains(e)&&n.clear(e),n.createObjectStore(e)}}));async function a8(t,e,r){return await t.get(e,r)}async function c8(t,e,r,n){return await t.put(e,n,r)}async function u8(t,e,r){return await t.delete(e,r)}var If=class t{constructor(e,r){this._db=e,this._storeName=r}static async create(e){let{dbName:r=Fy,storeName:n=My,version:i=Zs.DB_VERSION}=e??{},s=await o8(r,n,i);return new t(s,n)}async set(e,r){return await c8(this._db,this._storeName,e,r)}async get(e){var r;return(r=await a8(this._db,this._storeName,e))!==null&&r!==void 0?r:null}async remove(e){return await u8(this._db,this._storeName,e)}};sc.IdbKeyVal=If});var oc=ee(nt=>{"use strict";var l8=nt&&nt.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},f8=nt&&nt.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},ac;Object.defineProperty(nt,"__esModule",{value:!0});nt.IdbStorage=nt.LocalStorage=nt.isBrowser=nt.DB_VERSION=nt.KEY_VECTOR=nt.KEY_STORAGE_DELEGATION=nt.KEY_STORAGE_KEY=void 0;var d8=Uf();nt.KEY_STORAGE_KEY="identity";nt.KEY_STORAGE_DELEGATION="delegation";nt.KEY_VECTOR="iv";nt.DB_VERSION=1;nt.isBrowser=typeof window<"u";var Ff=class{constructor(e="ic-",r){this.prefix=e,this._localStorage=r}get(e){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+e))}set(e,r){return this._getLocalStorage().setItem(this.prefix+e,r),Promise.resolve()}remove(e){return this._getLocalStorage().removeItem(this.prefix+e),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let e=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.localStorage:global.localStorage:window.localStorage;if(!e)throw new Error("Could not find local storage.");return e}};nt.LocalStorage=Ff;var Mf=class{constructor(e){ac.set(this,void 0),l8(this,ac,e??{},"f")}get _db(){return new Promise(e=>{if(this.initializedDb){e(this.initializedDb);return}d8.IdbKeyVal.create(f8(this,ac,"f")).then(r=>{this.initializedDb=r,e(r)})})}async get(e){return await(await this._db).get(e)}async set(e,r){await(await this._db).set(e,r)}async remove(e){await(await this._db).remove(e)}};nt.IdbStorage=Mf;ac=new WeakMap});var Hf=ee(Le=>{"use strict";var h8=Le&&Le.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),p8=Le&&Le.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&h8(e,t,r)};Object.defineProperty(Le,"__esModule",{value:!0});Le.AuthClient=Le.ERROR_USER_INTERRUPT=Le.IdbKeyVal=Le.KEY_STORAGE_KEY=Le.KEY_STORAGE_DELEGATION=Le.LocalStorage=Le.IdbStorage=void 0;var Cy=Qt(),er=Ty(),qy=Af(),vt=oc(),cc=oc();Object.defineProperty(Le,"IdbStorage",{enumerable:!0,get:function(){return cc.IdbStorage}});Object.defineProperty(Le,"LocalStorage",{enumerable:!0,get:function(){return cc.LocalStorage}});Object.defineProperty(Le,"KEY_STORAGE_DELEGATION",{enumerable:!0,get:function(){return cc.KEY_STORAGE_DELEGATION}});Object.defineProperty(Le,"KEY_STORAGE_KEY",{enumerable:!0,get:function(){return cc.KEY_STORAGE_KEY}});var y8=Uf();Object.defineProperty(Le,"IdbKeyVal",{enumerable:!0,get:function(){return y8.IdbKeyVal}});var g8="https://identity.ic0.app",m8="#authorize",Cf="ECDSA",qf="Ed25519",b8=500;Le.ERROR_USER_INTERRUPT="UserInterrupt";p8(Af(),Le);var kf=class{constructor(e,r,n,i,s,o,a,c){this._identity=e,this._key=r,this._chain=n,this._storage=i,this.idleManager=s,this._createOptions=o,this._idpWindow=a,this._eventHandler=c,this._registerDefaultIdleCallback()}static async create(e={}){var r,n,i;let s=(r=e.storage)!==null&&r!==void 0?r:new vt.IdbStorage,o=(n=e.keyType)!==null&&n!==void 0?n:Cf,a=null;if(e.identity)a=e.identity;else{let h=await s.get(vt.KEY_STORAGE_KEY);if(!h&&vt.isBrowser)try{let m=new vt.LocalStorage,_=await m.get(vt.KEY_STORAGE_DELEGATION),u=await m.get(vt.KEY_STORAGE_KEY);_&&u&&o===Cf&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await s.set(vt.KEY_STORAGE_DELEGATION,_),await s.set(vt.KEY_STORAGE_KEY,u),h=_,await m.remove(vt.KEY_STORAGE_DELEGATION),await m.remove(vt.KEY_STORAGE_KEY))}catch(m){console.error("error while attempting to recover localstorage: "+m)}if(h)try{typeof h=="object"?o===qf&&typeof h=="string"?a=await er.Ed25519KeyIdentity.fromJSON(h):a=await er.ECDSAKeyIdentity.fromKeyPair(h):typeof h=="string"&&(a=er.Ed25519KeyIdentity.fromJSON(h))}catch{}}let c=new Cy.AnonymousIdentity,f=null;if(a)try{let h=await s.get(vt.KEY_STORAGE_DELEGATION);if(typeof h=="object"&&h!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");e.identity?c=e.identity:h&&(f=er.DelegationChain.fromJSON(h),(0,er.isDelegationValid)(f)?"toDer"in a?c=er.PartialDelegationIdentity.fromDelegation(a,f):c=er.DelegationIdentity.fromDelegation(a,f):(await jf(s),a=null))}catch(h){console.error(h),await jf(s),a=null}let d;return!((i=e.idleOptions)===null||i===void 0)&&i.disableIdle?d=void 0:(f||e.identity)&&(d=qy.IdleManager.create(e.idleOptions)),a||(o===qf?(a=await er.Ed25519KeyIdentity.generate(),await s.set(vt.KEY_STORAGE_KEY,JSON.stringify(a.toJSON()))):(e.storage&&o===Cf&&console.warn(`You are using a custom storage provider that may not support CryptoKey storage. If you are using a custom storage provider that does not support CryptoKey storage, you should use '${qf}' as the key type, as it can serialize to a string`),a=await er.ECDSAKeyIdentity.generate(),await s.set(vt.KEY_STORAGE_KEY,a.getKeyPair()))),new this(c,a,f,s,d,e)}_registerDefaultIdleCallback(){var e,r;let n=(e=this._createOptions)===null||e===void 0?void 0:e.idleOptions;!n?.onIdle&&!n?.disableDefaultIdleCallback&&((r=this.idleManager)===null||r===void 0||r.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(e,r){var n,i;let s=e.delegations.map(f=>({delegation:new er.Delegation(f.delegation.pubkey,f.delegation.expiration,f.delegation.targets),signature:f.signature.buffer})),o=er.DelegationChain.fromDelegations(s,e.userPublicKey.buffer),a=this._key;if(!a)return;this._chain=o,"toDer"in a?this._identity=er.PartialDelegationIdentity.fromDelegation(a,this._chain):this._identity=er.DelegationIdentity.fromDelegation(a,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let c=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!c?.disableIdle&&(this.idleManager=qy.IdleManager.create(c),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(vt.KEY_STORAGE_DELEGATION,JSON.stringify(this._chain.toJSON())),r?.(e)}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(e){var r,n,i,s;let o=BigInt(8)*BigInt(36e11),a=new URL(((r=e?.identityProvider)===null||r===void 0?void 0:r.toString())||g8);a.hash=m8,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(a,Object.assign({maxTimeToLive:(i=e?.maxTimeToLive)!==null&&i!==void 0?i:o},e)),window.addEventListener("message",this._eventHandler),this._idpWindow=(s=window.open(a.toString(),"idpWindow",e?.windowOpenerFeatures))!==null&&s!==void 0?s:void 0;let c=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(Le.ERROR_USER_INTERRUPT,e?.onError):setTimeout(c,b8))};c()}_getEventHandler(e,r){return async n=>{var i,s,o;if(n.origin!==e.origin)return;let a=n.data;switch(a.kind){case"authorize-ready":{let c=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((i=this._key)===null||i===void 0?void 0:i.getPublicKey().toDer()),maxTimeToLive:r?.maxTimeToLive,allowPinAuthentication:r?.allowPinAuthentication,derivationOrigin:(s=r?.derivationOrigin)===null||s===void 0?void 0:s.toString()},r?.customValues);(o=this._idpWindow)===null||o===void 0||o.postMessage(c,e.origin);break}case"authorize-client-success":try{await this._handleSuccess(a,r?.onSuccess)}catch(c){this._handleFailure(c.message,r?.onError)}break;case"authorize-client-failure":this._handleFailure(a.text,r?.onError);break;default:break}}}_handleFailure(e,r){var n;(n=this._idpWindow)===null||n===void 0||n.close(),r?.(e),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(e={}){if(await jf(this._storage),this._identity=new Cy.AnonymousIdentity,this._chain=null,e.returnTo)try{window.history.pushState({},"",e.returnTo)}catch{window.location.href=e.returnTo}}};Le.AuthClient=kf;async function jf(t){await t.remove(vt.KEY_STORAGE_KEY),await t.remove(vt.KEY_STORAGE_DELEGATION),await t.remove(vt.KEY_VECTOR)}});var Fg=Ze(mt(),1);var bg=Ze(mt(),1);var Gi=class{callbacks=[];populate(e){this.callbacks.forEach(({callback:r})=>r(e))}subscribe(e){let r=Symbol();return this.callbacks.push({id:r,callback:e}),()=>this.callbacks=this.callbacks.filter(({id:n})=>n!==r)}};var on=class t extends Gi{static instance;authUser=null;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.authUser=e,this.populate(e)}get(){return this.authUser}subscribe(e){let r=super.subscribe(e);return e(this.authUser),r}reset(){this.authUser=null,this.populate(this.authUser)}};var lf=({message:t,detail:e})=>{let r=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(r)};var gg=Ze(Hf(),1),mg=Ze(mt(),1);var jy=BigInt(144e11),ky=!1,Hy={width:576,height:576},Vy={width:505,height:705},$y="internetcomputer.org";var Js=Ze(mt(),1);var zi="http://127.0.0.1:5987",Ky="rdmx6-jaaaa-aaaaa-aaadq-cai";var Yr=class t extends Gi{static instance;env;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.env=e,this.populate(e)}get(){return this.env}subscribe(e){let r=super.subscribe(e);return e(this.env),r}};var Vf=Ze(mt(),1);var uc=Ze(mt(),1),Gy=async t=>{let e=new Blob([JSON.stringify(t,uc.jsonReplacer)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},lc=async t=>{let e=new Blob([t instanceof Uint8Array?t:new Uint8Array(t)],{type:"application/json; charset=utf-8"});return JSON.parse(await e.text(),uc.jsonReviver)},fc=()=>typeof window<"u";var $f=({width:t,height:e})=>{if(!fc()||(0,Vf.isNullish)(window)||(0,Vf.isNullish)(window.top))return;let{top:{innerWidth:r,innerHeight:n}}=window,i=n/2+screenY-e/2,s=r/2+screenX-t/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${t}, height=${e}, top=${i}, left=${s}`};var dc=class{#e;constructor({domain:e}){this.#e=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let r=()=>{let n=Yr.getInstance().get()?.container;if((0,Js.isNullish)(n)||n===!1)return`https://identity.${this.#e??$y}`;let i=Yr.getInstance().get(),s=(0,Js.nonNullish)(i)&&(0,Js.nonNullish)(i?.internetIdentityId)?i.internetIdentityId:Ky,{host:o,protocol:a}=new URL(n===!0?zi:n);return/apple/i.test(navigator?.vendor)?`${a}//${o}?canisterId=${s}`:`${a}//${s}.${o.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:$f(Hy)},identityProvider:r()}}},Yy=class{#e;#t;constructor({appName:e,logoUrl:r}){this.#e=e,this.#t=r}get id(){return"nfid"}signInOptions({windowed:e}){return{...e!==!1&&{windowOpenerFeatures:$f(Vy)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#e)}&applicationLogo=${encodeURI(this.#t)}`}}};var zy=Ze(Qt(),1),hc=Ze(mt(),1);var Wy=Ze(Qt(),1),si=Ze(mt(),1);var Di=class t{static instance;#e=void 0;constructor(){}static getInstance(){return(0,si.isNullish)(t.instance)&&(t.instance=new t),t.instance}async getAgent({identity:e,...r}){let n=e.getPrincipal().toText();if((0,si.isNullish)(this.#e)||(0,si.isNullish)(this.#e[n])){let i=await this.createAgent({identity:e,...r});return this.#e={...this.#e??{},[n]:i},i}return this.#e[n]}reset(){this.#e=null}async createAgent({identity:e,fetch:r,container:n}){let s=(0,si.nonNullish)(n)&&n!==!1?n===!0?zi:n:"https://icp-api.io",o=(0,si.nonNullish)(n);return await Wy.HttpAgent.create({identity:e,shouldFetchRootKey:o,host:s,...r&&{fetch:r}})}};var Zi=class t{static instance;#e=void 0;constructor(){}static getInstance(){return(0,hc.isNullish)(t.instance)&&(t.instance=new t),t.instance}async getActor({satelliteId:e,identity:r,buildType:n,...i}){let s=`${n}#${r.getPrincipal().toText()}#${e};`;if((0,hc.isNullish)(this.#e)||(0,hc.isNullish)(this.#e[s])){let o=await this.createActor({satelliteId:e,identity:r,...i});return this.#e={...this.#e??{},[s]:o},o}return this.#e[s]}reset(){this.#e=null}async createActor({idlFactory:e,satelliteId:r,...n}){let i=await Di.getInstance().getAgent(n);return zy.Actor.createActor(e,{agent:i,canisterId:r})}};var pc=class extends Error{},yc=class extends Error{},gc=class extends Error{},mc=class extends Error{},bc=class extends Error{};var Dy=Ze(Hf(),1),_c=()=>Dy.AuthClient.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var Qs=Ze(mt(),1);var Kf="juno.datastore.error.user.cannot_update";var Gf=({error:t,type:e})=>typeof t=="string"?t.includes(e):t instanceof Error?t.message.includes(e):!1;var xr=Ze(mt(),1);var Zy=async({data:t})=>{try{return await lc(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};var oi=Ze(mt(),1);var Yf=async t=>{let{data:e,version:r,description:n}=t;return{description:(0,oi.toNullable)(n),data:await Gy(e),version:(0,oi.toNullable)(r)}},Wf=t=>{let{version:e}=t;return{version:(0,oi.toNullable)(e)}},Xs=async({doc:t,key:e})=>{let{owner:r,version:n,description:i,data:s,...o}=t;return{key:e,description:(0,oi.fromNullable)(i),owner:r.toText(),data:await lc(s),version:(0,oi.fromNullable)(n),...o}};var Xy=Ze(Ut(),1),it=Ze(mt(),1);var Jy=t=>{if((0,it.isNullish)(t))return(0,it.toNullable)();switch(t.matcher){case"equal":return(0,it.toNullable)({Equal:t.timestamp});case"greaterThan":return(0,it.toNullable)({GreaterThan:t.timestamp});case"lessThan":return(0,it.toNullable)({LessThan:t.timestamp});case"between":return(0,it.toNullable)({Between:[t.timestamps.start,t.timestamps.end]});default:throw new bc("Invalid list matcher for timestamp",t)}},Cn=({matcher:t,paginate:e,order:r,owner:n})=>({matcher:(0,it.isNullish)(t)?[]:[{key:(0,it.toNullable)(t.key),description:(0,it.toNullable)(t.description),created_at:Jy(t.createdAt),updated_at:Jy(t.updatedAt)}],paginate:(0,it.toNullable)((0,it.isNullish)(e)?void 0:{start_after:(0,it.toNullable)(e.startAfter),limit:(0,it.toNullable)((0,it.isNullish)(e.limit)?void 0:BigInt(e.limit))}),order:(0,it.toNullable)((0,it.isNullish)(r)?void 0:{desc:r.desc,field:r.field==="created_at"?{CreatedAt:null}:r.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:(0,it.toNullable)((0,it.isNullish)(n)?void 0:typeof n=="string"?Xy.Principal.fromText(n):n)});var eg=Ze(mt(),1);var Qy=({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}),n=t.Record({field:r,desc:t.Bool}),i=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(i),description:t.Opt(t.Text),created_at:t.Opt(i)}),o=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),a=t.Record({order:t.Opt(n),owner:t.Opt(t.Principal),matcher:t.Opt(s),paginate:t.Opt(o)}),c=t.Record({controllers:t.Vec(t.Principal)}),f=t.Variant({Write:t.Null,Admin:t.Null}),d=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:f,expires_at:t.Opt(t.Nat64)}),h=t.Record({version:t.Opt(t.Nat64)}),m=t.Variant({Db:t.Null,Storage:t.Null}),_=t.Record({version:t.Opt(t.Nat64)}),u=t.Record({cycles:t.Nat,destination_id:t.Principal}),O=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}),T=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),P=t.Record({key:O,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,T)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),F=t.Record({derivation_origin:t.Opt(t.Text),external_alternative_origins:t.Opt(t.Vec(t.Text))}),A=t.Record({internet_identity:t.Opt(F)}),K=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),E=t.Record({max_memory_size:t.Opt(K)}),j=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),G=t.Variant({Deny:t.Null,Allow:t.Null}),z=t.Record({status_code:t.Nat16,location:t.Text}),q=t.Record({iframe:t.Opt(j),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(K),raw_access:t.Opt(G),redirects:t.Opt(t.Vec(t.Tuple(t.Text,z)))}),oe=t.Record({db:t.Opt(E),authentication:t.Opt(A),storage:q}),Q=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)}),ie=t.Variant({Heap:t.Null,Stable:t.Null}),w=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),b=t.Record({max_tokens:t.Nat64,time_per_token_ns:t.Nat64}),N=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(ie),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:w,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(b),write:w,max_changes_per_user:t.Opt(t.Nat32)}),B=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)}),R=t.Record({memory:ie,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}),V=t.Variant({Callback:t.Record({token:R,callback:t.Func([],[],["query"])})}),Z=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(V),status_code:t.Nat16}),ce=t.Record({token:t.Opt(R),body:t.Vec(t.Nat8)}),ae=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}),D=t.Record({batch_id:t.Nat}),M=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,P)),items_length:t.Nat64}),y=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),L=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,Q)),items_length:t.Nat64}),re=t.Record({stable:t.Nat64,heap:t.Nat64}),le=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:f,expires_at:t.Opt(t.Nat64)}),X=t.Record({controller:le,controllers:t.Vec(t.Principal)}),l=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),p=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(ie),max_size:t.Opt(t.Nat),read:w,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(b),write:w,max_changes_per_user:t.Opt(t.Nat32)}),g=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),I=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,a],[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,a],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([c],[t.Vec(t.Tuple(t.Principal,d))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,h],[],[]),del_docs:t.Func([t.Text],[],[]),del_filtered_assets:t.Func([t.Text,a],[],[]),del_filtered_docs:t.Func([t.Text,a],[],[]),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,h))],[],[]),del_rule:t.Func([m,t.Text,_],[],[]),deposit_cycles:t.Func([u],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(P)],["query"]),get_auth_config:t.Func([],[t.Opt(A)],["query"]),get_config:t.Func([],[oe],[]),get_db_config:t.Func([],[t.Opt(E)],["query"]),get_doc:t.Func([t.Text,t.Text],[t.Opt(Q)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(P)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(Q)))],["query"]),get_rule:t.Func([m,t.Text],[t.Opt(N)],["query"]),get_storage_config:t.Func([],[q],["query"]),http_request:t.Func([B],[Z],["query"]),http_request_streaming_callback:t.Func([R],[ce],["query"]),init_asset_upload:t.Func([ae],[D],[]),list_assets:t.Func([t.Text,a],[M],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,d))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,y))],["query"]),list_docs:t.Func([t.Text,a],[L],["query"]),list_rules:t.Func([m],[t.Vec(t.Tuple(t.Text,N))],["query"]),memory_size:t.Func([],[re],["query"]),set_auth_config:t.Func([A],[],[]),set_controllers:t.Func([X],[t.Vec(t.Tuple(t.Principal,d))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([E],[],[]),set_doc:t.Func([t.Text,t.Text,l],[Q],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,l))],[t.Vec(t.Tuple(t.Text,Q))],[]),set_rule:t.Func([m,t.Text,p],[N],[]),set_storage_config:t.Func([q],[],[]),upload_asset_chunk:t.Func([g],[I],[]),version:t.Func([],[t.Text],["query"])})};var wc=Ze(mt(),1);var Ly=({satelliteId:t,container:e})=>{let{satelliteId:r}=zf({satelliteId:t}),{container:n}=Df({container:e});if((0,wc.nonNullish)(n)&&n!==!1){let{host:i,protocol:s}=new URL(n===!0?zi:n);return`${s}//${r??"unknown"}.${i.replace("127.0.0.1","localhost")}`}return`https://${r??"unknown"}.icp0.io`},zf=({satelliteId:t})=>(0,wc.nonNullish)(t)?{satelliteId:t}:Yr.getInstance().get()??{satelliteId:void 0},Df=({container:t})=>(0,wc.nonNullish)(t)?{container:t}:Yr.getInstance().get()??{container:void 0};var lt=t=>rg({idlFactory:Qy,buildType:"stock",...t}),tg=({idlFactory:t,...e})=>rg({idlFactory:t,buildType:"extended",...e}),rg=async({satelliteId:t,container:e,...r})=>{let{satelliteId:n}=zf({satelliteId:t});(0,eg.assertNonNullish)(n,"No satellite ID defined. Did you initialize Juno?");let{container:i}=Df({container:e});return await Zi.getInstance().getActor({satelliteId:n,container:i,...r})};var ng=async({collection:t,key:e,satellite:r})=>{let{get_doc:n}=await lt(r),i=(0,xr.fromNullable)(await n(t,e));if(!(0,xr.isNullish)(i))return Xs({doc:i,key:e})},ig=async({docs:t,satellite:e})=>{let{get_many_docs:r}=await lt(e),n=t.map(({collection:o,key:a})=>[o,a]),i=await r(n),s=[];for(let[o,a]of i){let c=(0,xr.fromNullable)(a);s.push((0,xr.nonNullish)(c)?await Xs({key:o,doc:c}):void 0)}return s},sg=async({collection:t,doc:e,satellite:r})=>{let{set_doc:n}=await lt(r),{key:i}=e,s=await Yf(e),o=await n(t,i,s);return await Xs({key:i,doc:o})},og=async({docs:t,satellite:e})=>{let{set_many_docs:r}=await lt(e),n=[];for(let{collection:o,doc:a}of t){let{key:c}=a;n.push([o,c,await Yf(a)])}let i=await r(n),s=[];for(let[o,a]of i)s.push(await Xs({key:o,doc:a}));return s},ag=async({collection:t,doc:e,satellite:r})=>{let{del_doc:n}=await lt(r),{key:i}=e;return n(t,i,Wf(e))},cg=async({docs:t,satellite:e})=>{let{del_many_docs:r}=await lt(e),n=t.map(({collection:i,doc:s})=>[i,s.key,Wf(s)]);await r(n)},ug=async({collection:t,filter:e,satellite:r})=>{let{del_filtered_docs:n}=await lt(r);return n(t,Cn(e))},lg=async({collection:t,filter:e,satellite:r})=>{let{list_docs:n}=await lt(r),{items:i,items_page:s,items_length:o,matches_length:a,matches_pages:c}=await n(t,Cn(e)),f=[];for(let[d,h]of i){let{data:m,owner:_,description:u,version:O,...T}=h;f.push({key:d,description:(0,xr.fromNullable)(u),owner:_.toText(),data:await Zy({data:m}),version:(0,xr.fromNullable)(O),...T})}return{items:f,items_length:o,items_page:(0,xr.fromNullable)(s),matches_length:a,matches_pages:(0,xr.fromNullable)(c)}},fg=async({collection:t,filter:e,satellite:r})=>{let{count_docs:n}=await lt(r);return n(t,Cn(e))};var dg=Ze(Qt(),1);var et=t=>t!==void 0?t:Ec()??new dg.AnonymousIdentity;var hg=async({satellite:t,...e})=>{let r=et(t?.identity);return await ng({...e,satellite:{...t,identity:r}})},V6=async({satellite:t,...e})=>{let r=et(t?.identity);return await ig({...e,satellite:{...t,identity:r}})},pg=async({satellite:t,...e})=>{let r=et(t?.identity);return await sg({...e,satellite:{...t,identity:r}})},$6=async({satellite:t,...e})=>{let r=et(t?.identity);return await og({...e,satellite:{...t,identity:r}})},K6=async({satellite:t,...e})=>{let r=et(t?.identity);return await ag({...e,satellite:{...t,identity:r}})},G6=async({satellite:t,...e})=>{let r=et(t?.identity);return await cg({...e,satellite:{...t,identity:r}})},Y6=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await ug({...r,filter:e??{},satellite:{...t,identity:n}})},W6=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await lg({...r,filter:e??{},satellite:{...t,identity:n}})},z6=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await fg({...r,filter:e??{},satellite:{...t,identity:n}})};var yg=async t=>{let e=Ec();if((0,Qs.isNullish)(e))throw new mc("No identity to initialize the user. Have you initialized Juno?");let r=e.getPrincipal().toText(),n=()=>hg({collection:"#user",key:r}),i=await n();if((0,Qs.nonNullish)(i))return i;try{return await _8({userId:r,provider:t})}catch(s){if(Gf({error:s,type:Kf})){let o=await n();if((0,Qs.nonNullish)(o))return o}throw s}},_8=({userId:t,...e})=>pg({collection:"#user",doc:{key:t,data:e}});var Wr,Zf=async t=>{if(Wr=Wr??await _c(),!(await Wr?.isAuthenticated()??!1))return;let r=await yg(t);on.getInstance().set(r)},w8=t=>new Promise(async(e,r)=>{if((0,mg.isNullish)(Wr)){r(new yc("No client is ready to perform a sign-in. Have you initialized the Satellite?"));return}let n=t?.provider??new dc({});await Wr.login({onSuccess:async()=>{await Zf(n.id),e()},onError:i=>{if(i===gg.ERROR_USER_INTERRUPT){r(new gc(i));return}r(new pc(i))},maxTimeToLive:t?.maxTimeToLive??jy,allowPinAuthentication:t?.allowPin??ky,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...n.signInOptions({windowed:t?.windowed})})}),Jf=async()=>{await Wr?.logout(),Wr=null,on.getInstance().reset(),Zi.getInstance().reset(),Di.getInstance().reset(),Wr=await _c()},Ec=()=>Wr?.getIdentity(),E8=async()=>(Wr??await _c()).getIdentity();var _g=t=>{let e=t===!0?"./workers/auth.worker.js":t,r=new Worker(e),n=async()=>{lf({message:"junoSignOutAuthTimer"}),await Jf()};return r.onmessage=async({data:i})=>{let{msg:s,data:o}=i;switch(s){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":lf({message:"junoDelegationRemainingTime",detail:o?.authRemainingTime});return}},on.getInstance().subscribe(i=>{if((0,bg.isNullish)(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var wg=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_SATELLITE_ID??import.meta.env?.PUBLIC_SATELLITE_ID:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_SATELLITE_ID??t():t()},Eg=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_CONTAINER??import.meta.env?.PUBLIC_CONTAINER:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_CONTAINER??t():t()};var gT=async({idlFactory:t,satellite:e})=>{let r=et(e?.identity);return await tg({idlFactory:t,...e,identity:r})};var to=Ze(mt(),1);var eo=Ze(mt(),1);var Ls=Ze(mt(),1);var xg=async({asset:{data:t,filename:e,collection:r,headers:n,token:i,fullPath:s,encoding:o,description:a},actor:c,init_asset_upload:f})=>{let{batch_id:d}=await f({collection:r,full_path:s,name:e,token:(0,Ls.toNullable)(i),encoding_type:(0,Ls.toNullable)(o),description:(0,Ls.toNullable)(a)}),h=19e5,m=[],_=fc()?new Blob([await t.arrayBuffer()]):t,u=0n;for(let P=0;P<_.size;P+=h){let F=_.slice(P,P+h);m.push({batchId:d,chunk:F,actor:c,orderId:u}),u++}let O=[];for await(let P of x8({uploadChunks:m}))O=[...O,...P];let T=n.find(([P,F])=>P.toLowerCase()==="content-type")===void 0&&t.type!==void 0&&t.type!==""?[["Content-Type",t.type]]:void 0;await c.commit_asset_upload({batch_id:d,chunk_ids:O.map(({chunk_id:P})=>P),headers:[...n,...T??[]]})};async function*x8({uploadChunks:t,limit:e=12}){for(let r=0;r<t.length;r=r+e){let n=t.slice(r,r+e);yield await Promise.all(n.map(i=>v8(i)))}}var v8=async({batchId:t,chunk:e,actor:r,orderId:n})=>r.upload_asset_chunk({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:(0,Ls.toNullable)(n)});var vg=async({satellite:t,...e})=>{let r=await lt(t);await xg({actor:r,asset:e,init_asset_upload:async i=>await r.init_asset_upload(i)})},Tg=async({collection:t,satellite:e,filter:r})=>{let{list_assets:n}=await lt(e),{items:i,items_length:s,items_page:o,matches_length:a,matches_pages:c}=await n(t,Cn(r));return{items:i.map(([f,d])=>d),items_length:s,items_page:(0,eo.fromNullable)(o),matches_length:a,matches_pages:(0,eo.fromNullable)(c)}},Ag=async({collection:t,satellite:e,filter:r})=>{let{count_assets:n}=await lt(e);return n(t,Cn(r))},Sg=async({collection:t,fullPath:e,satellite:r})=>(await lt(r)).del_asset(t,e),Bg=async({assets:t,satellite:e})=>{let{del_many_assets:r}=await lt(e),n=t.map(({collection:i,fullPath:s})=>[i,s]);await r(n)},Og=async({collection:t,satellite:e,filter:r})=>{let{del_filtered_assets:n}=await lt(e);return n(t,Cn(r))},Ng=async({collection:t,fullPath:e,satellite:r})=>{let{get_asset:n}=await lt(r);return(0,eo.fromNullable)(await n(t,e))},Rg=async({assets:t,satellite:e})=>{let{get_many_assets:r}=await lt(e),n=t.map(({collection:s,fullPath:o})=>[s,o]);return(await r(n)).map(([s,o])=>(0,eo.fromNullable)(o))};var Pg=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var NT=t=>Ig(t),RT=t=>Ig({filename:t.data.name,...t}),Ig=async({filename:t,data:e,collection:r,headers:n=[],fullPath:i,token:s,satellite:o,encoding:a,description:c})=>{let f=et(o?.identity),d=decodeURI(t),h=i??`/${r}/${d}`,m={...o,identity:f};return await vg({data:e,filename:d,collection:r,token:s,headers:n,fullPath:h,encoding:a,satellite:m,description:c}),{downloadUrl:Ug({satellite:m,assetKey:{fullPath:h,token:s}}),fullPath:h,name:d}},PT=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)},{items:i,...s}=await Tg({collection:t,satellite:n,filter:r??{}}),o=i.map(({key:{full_path:a,token:c,name:f,owner:d,description:h},headers:m,encodings:_,created_at:u,updated_at:O})=>{let T=(0,to.fromNullable)(c);return{fullPath:a,description:(0,to.fromNullable)(h),name:f,downloadUrl:Ug({satellite:n,assetKey:{fullPath:a,token:T}}),token:T,headers:m,encodings:_.reduce((P,[F,{modified:A,sha256:K,total_length:E}])=>({...P,[F]:{modified:A,sha256:Pg(K),total_length:E}}),{}),owner:d.toText(),created_at:u,updated_at:O}});return{items:o,assets:o,...s}},IT=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)};return await Ag({collection:t,satellite:n,filter:r??{}})},UT=({collection:t,fullPath:e,satellite:r})=>Sg({collection:t,fullPath:e,satellite:{...r,identity:et(r?.identity)}}),FT=({assets:t,satellite:e})=>Bg({assets:t,satellite:{...e,identity:et(e?.identity)}}),MT=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)};return await Og({collection:t,satellite:n,filter:r??{}})},CT=async({satellite:t,...e})=>{let r=et(t?.identity);return await Ng({...e,satellite:{...t,identity:r}})},qT=async({satellite:t,...e})=>{let r=et(t?.identity);return await Rg({...e,satellite:{...t,identity:r}})},Ug=({assetKey:{fullPath:t,token:e},satellite:r})=>{let n={...r,identity:et(r?.identity)};return`${Ly(n)}${t}${(0,to.nonNullish)(e)?`?token=${e}`:""}`};var T8=t=>{let e=t?.satelliteId??wg();(0,Fg.assertNonNullish)(e,"Satellite ID is not configured. Juno cannot be initialized.");let r=t?.container??Eg();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:r}},GT=t=>A8(t),A8=async t=>{let e=T8(t);Yr.getInstance().set(e),await Zf();let r=e.workers?.auth!==void 0?_g(e.workers.auth):void 0;return[...r?[r]:[]]},YT=t=>on.getInstance().subscribe(t);export{mc as InitError,dc as InternetIdentityProvider,bc as ListError,Yy as NFIDProvider,pc as SignInError,yc as SignInInitError,gc as SignInUserInterruptError,YT as authSubscribe,IT as countAssets,z6 as countDocs,UT as deleteAsset,K6 as deleteDoc,MT as deleteFilteredAssets,Y6 as deleteFilteredDocs,FT as deleteManyAssets,G6 as deleteManyDocs,Ug as downloadUrl,CT as getAsset,hg as getDoc,qT as getManyAssets,V6 as getManyDocs,gT as getSatelliteExtendedActor,GT as initJuno,A8 as initSatellite,PT as listAssets,W6 as listDocs,pg as setDoc,$6 as setManyDocs,w8 as signIn,Jf as signOut,E8 as unsafeIdentity,NT as uploadBlob,RT as uploadFile};
|
|
57
|
+
ic-request`);function pf(t){if(typeof t!="string"||t.length<64)throw new Error("Invalid public key.");return(0,Fn.fromHex)(t)}var zs=class{constructor(e,r,n){this.pubkey=e,this.expiration=r,this.targets=n}toCBOR(){return Ws.value.map(Object.assign({pubkey:Ws.value.bytes(this.pubkey),expiration:Ws.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:Ws.value.array(this.targets.map(e=>Ws.value.bytes(e.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:(0,Fn.toHex)(this.pubkey)},this.targets&&{targets:this.targets.map(e=>e.toHex())})}};De.Delegation=zs;async function qx(t,e,r,n){let i=new zs(e.toDer(),BigInt(+r)*BigInt(1e6),n),s=new Uint8Array([...Mx,...new Uint8Array((0,Fn.requestIdOf)(Object.assign({},i)))]),o=await t.sign(s);return{delegation:i,signature:o}}var gf=class t{constructor(e,r){this.delegations=e,this.publicKey=r}static async create(e,r,n=new Date(Date.now()+15*60*1e3),i={}){var s,o;let a=await qx(e,r,n,i.targets);return new t([...((s=i.previous)===null||s===void 0?void 0:s.delegations)||[],a],((o=i.previous)===null||o===void 0?void 0:o.publicKey)||e.getPublicKey().toDer())}static fromJSON(e){let{publicKey:r,delegations:n}=typeof e=="string"?JSON.parse(e):e;if(!Array.isArray(n))throw new Error("Invalid delegations.");let i=n.map(s=>{let{delegation:o,signature:a}=s,{pubkey:c,expiration:f,targets:d}=o;if(d!==void 0&&!Array.isArray(d))throw new Error("Invalid targets.");return{delegation:new zs(pf(c),BigInt("0x"+f),d&&d.map(h=>{if(typeof h!="string")throw new Error("Invalid target.");return yf.Principal.fromHex(h)})),signature:pf(a)}});return new this(i,pf(r))}static fromDelegations(e,r){return new this(e,r)}toJSON(){return{delegations:this.delegations.map(e=>{let{delegation:r,signature:n}=e,{targets:i}=r;return{delegation:Object.assign({expiration:r.expiration.toString(16),pubkey:(0,Fn.toHex)(r.pubkey)},i&&{targets:i.map(s=>s.toHex())}),signature:(0,Fn.toHex)(n)}}),publicKey:(0,Fn.toHex)(this.publicKey)}}};De.DelegationChain=gf;var mf=class extends Fn.SignIdentity{constructor(e,r){super(),this._inner=e,this._delegation=r}static fromDelegation(e,r){return new this(e,r)}getDelegation(){return this._delegation}getPublicKey(){return{derKey:this._delegation.publicKey,toDer:()=>this._delegation.publicKey}}sign(e){return this._inner.sign(e)}async transformRequest(e){let{body:r}=e,n=Ux(e,["body"]),i=await(0,Fn.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...Cx,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};De.DelegationIdentity=mf;var bf=class t extends Fx.PartialIdentity{constructor(e,r){super(e),tc.set(this,void 0),Px(this,tc,r,"f")}get delegation(){return Ix(this,tc,"f")}static fromDelegation(e,r){return new t(e,r)}};De.PartialDelegationIdentity=bf;tc=new WeakMap;function jx(t,e){for(let{delegation:i}of t.delegations)if(+new Date(Number(i.expiration/BigInt(1e6)))<=+Date.now())return!1;let r=[],n=e?.scope;n&&(Array.isArray(n)?r.push(...n.map(i=>typeof i=="string"?yf.Principal.fromText(i):i)):r.push(typeof n=="string"?yf.Principal.fromText(n):n));for(let i of r){let s=i.toText();for(let{delegation:o}of t.delegations){if(o.targets===void 0)continue;let a=!0;for(let c of o.targets)if(c.toText()===s){a=!1;break}if(a)return!1}}return!0}De.isDelegationValid=jx});var xy=ee(Mn=>{"use strict";var kx=Mn&&Mn.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Mn,"__esModule",{value:!0});Mn.WebAuthnIdentity=Mn.CosePublicKey=void 0;var ii=Qt(),_f=kx(Vo()),Hx=kn(),Vx=xi();function $x(t){return(0,ii.wrapDER)(t,ii.DER_COSE_OID).buffer}function Kx(t){let e=new DataView(new ArrayBuffer(2)),r=t.slice(53,55);[...new Uint8Array(r)].forEach((i,s)=>e.setUint8(s,i));let n=e.getUint16(0);return t.slice(55+n)}var rc=class{constructor(e){this._cose=e,this._encodedKey=$x(e)}toDer(){return this._encodedKey}getCose(){return this._cose}};Mn.CosePublicKey=rc;function Gx(t="<ic0.app>"){return typeof t=="string"?Uint8Array.from(t,e=>e.charCodeAt(0)):t}async function Yx(t){let e=await navigator.credentials.create(t??{publicKey:{authenticatorSelection:{userVerification:"preferred"},attestation:"direct",challenge:Gx(),pubKeyCredParams:[{type:"public-key",alg:wf.ECDSA_WITH_SHA256}],rp:{name:"Internet Identity Service"},user:{id:(0,Hx.randomBytes)(16),name:"Internet Identity",displayName:"Internet Identity"}}});return e===null?null:{id:e.id,response:e.response,type:e.type,authenticatorAttachment:e.authenticatorAttachment,getClientExtensionResults:e.getClientExtensionResults,rawId:(0,Vx.bufFromBufLike)(e.rawId)}}var wf;(function(t){t[t.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(wf||(wf={}));var Ef=class extends ii.SignIdentity{constructor(e,r,n){super(),this.rawId=e,this.authenticatorAttachment=n,this._publicKey=new rc(r)}static fromJSON(e){let{publicKey:r,rawId:n}=JSON.parse(e);if(typeof r!="string"||typeof n!="string")throw new Error("Invalid JSON string.");return new this((0,ii.fromHex)(n),(0,ii.fromHex)(r),void 0)}static async create(e){var r;let n=await Yx(e);if(!n||n.type!=="public-key")throw new Error("Could not create credentials.");let i=n.response;if(i.attestationObject===void 0)throw new Error("Was expecting an attestation response.");let s=_f.default.decodeFirst(new Uint8Array(i.attestationObject));return new this(n.rawId,Kx(s.authData),(r=n.authenticatorAttachment)!==null&&r!==void 0?r:void 0)}getPublicKey(){return this._publicKey}getAuthenticatorAttachment(){return this.authenticatorAttachment}async sign(e){let r=await navigator.credentials.get({publicKey:{allowCredentials:[{type:"public-key",id:this.rawId}],challenge:e,userVerification:"preferred"}});r.authenticatorAttachment!==null&&(this.authenticatorAttachment=r.authenticatorAttachment);let n=r.response,i=_f.default.encode(new _f.default.Tagged(55799,{authenticator_data:new Uint8Array(n.authenticatorData),client_data_json:new TextDecoder().decode(n.clientDataJSON),signature:new Uint8Array(n.signature)}));if(!i)throw new Error("failed to encode cbor");return i.buffer}toJSON(){return{publicKey:(0,ii.toHex)(this._publicKey.getCose()),rawId:(0,ii.toHex)(this.rawId)}}};Mn.WebAuthnIdentity=Ef});var Ty=ee(We=>{"use strict";var Wx=We&&We.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),vf=We&&We.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Wx(e,t,r)};Object.defineProperty(We,"__esModule",{value:!0});We.Secp256k1KeyIdentity=We.ED25519_OID=We.DER_COSE_OID=We.unwrapDER=We.wrapDER=We.WebAuthnIdentity=We.Ed25519PublicKey=We.Ed25519KeyIdentity=void 0;var vy=by();Object.defineProperty(We,"Ed25519KeyIdentity",{enumerable:!0,get:function(){return vy.Ed25519KeyIdentity}});Object.defineProperty(We,"Ed25519PublicKey",{enumerable:!0,get:function(){return vy.Ed25519PublicKey}});vf(wy(),We);vf(Ey(),We);vf(hf(),We);var zx=xy();Object.defineProperty(We,"WebAuthnIdentity",{enumerable:!0,get:function(){return zx.WebAuthnIdentity}});var nc=Qt();Object.defineProperty(We,"wrapDER",{enumerable:!0,get:function(){return nc.wrapDER}});Object.defineProperty(We,"unwrapDER",{enumerable:!0,get:function(){return nc.unwrapDER}});Object.defineProperty(We,"DER_COSE_OID",{enumerable:!0,get:function(){return nc.DER_COSE_OID}});Object.defineProperty(We,"ED25519_OID",{enumerable:!0,get:function(){return nc.ED25519_OID}});var xf=class{constructor(){throw new Error("Secp256k1KeyIdentity has been moved to a new repo: @dfinity/identity-secp256k1")}};We.Secp256k1KeyIdentity=xf});var Af=ee(ic=>{"use strict";Object.defineProperty(ic,"__esModule",{value:!0});ic.IdleManager=void 0;var Ay=["mousedown","mousemove","keydown","touchstart","wheel"],Tf=class{constructor(e={}){var r;this.callbacks=[],this.idleTimeout=10*60*1e3,this.timeoutID=void 0;let{onIdle:n,idleTimeout:i=10*60*1e3}=e||{};this.callbacks=n?[n]:[],this.idleTimeout=i;let s=this._resetTimer.bind(this);window.addEventListener("load",s,!0),Ay.forEach(function(a){document.addEventListener(a,s,!0)});let o=(a,c)=>{let f;return(...d)=>{let h=this,m=function(){f=void 0,a.apply(h,d)};clearTimeout(f),f=window.setTimeout(m,c)}};if(e?.captureScroll){let a=o(s,(r=e?.scrollDebounce)!==null&&r!==void 0?r:100);window.addEventListener("scroll",a,!0)}s()}static create(e={}){return new this(e)}registerCallback(e){this.callbacks.push(e)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let e=this._resetTimer.bind(this);Ay.forEach(function(r){document.removeEventListener(r,e,!0)}),this.callbacks.forEach(r=>r())}_resetTimer(){let e=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(e,this.idleTimeout)}};ic.IdleManager=Tf});function Zx(){return Sy||(Sy=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Jx(){return By||(By=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}function Xx(t){let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("success",s),t.removeEventListener("error",o)},s=()=>{r(ur(t.result)),i()},o=()=>{n(t.error),i()};t.addEventListener("success",s),t.addEventListener("error",o)});return e.then(r=>{r instanceof IDBCursor&&Oy.set(r,t)}).catch(()=>{}),Nf.set(e,t),e}function Qx(t){if(Bf.has(t))return;let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("complete",s),t.removeEventListener("error",o),t.removeEventListener("abort",o)},s=()=>{r(),i()},o=()=>{n(t.error||new DOMException("AbortError","AbortError")),i()};t.addEventListener("complete",s),t.addEventListener("error",o),t.addEventListener("abort",o)});Bf.set(t,e)}function Ry(t){Of=t(Of)}function Lx(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(Ds(this),e,...r);return Ny.set(n,e.sort?e.sort():[e]),ur(n)}:Jx().includes(t)?function(...e){return t.apply(Ds(this),e),ur(Oy.get(this))}:function(...e){return ur(t.apply(Ds(this),e))}}function e8(t){return typeof t=="function"?Lx(t):(t instanceof IDBTransaction&&Qx(t),Dx(t,Zx())?new Proxy(t,Of):t)}function ur(t){if(t instanceof IDBRequest)return Xx(t);if(Sf.has(t))return Sf.get(t);let e=e8(t);return e!==t&&(Sf.set(t,e),Nf.set(e,t)),e}var Dx,Sy,By,Oy,Bf,Ny,Sf,Nf,Of,Ds,Rf=Xf(()=>{Dx=(t,e)=>e.some(r=>t instanceof r);Oy=new WeakMap,Bf=new WeakMap,Ny=new WeakMap,Sf=new WeakMap,Nf=new WeakMap;Of={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return Bf.get(t);if(e==="objectStoreNames")return t.objectStoreNames||Ny.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return ur(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};Ds=t=>Nf.get(t)});var Iy={};em(Iy,{deleteDB:()=>r8,openDB:()=>t8,unwrap:()=>Ds,wrap:()=>ur});function t8(t,e,{blocked:r,upgrade:n,blocking:i,terminated:s}={}){let o=indexedDB.open(t,e),a=ur(o);return n&&o.addEventListener("upgradeneeded",c=>{n(ur(o.result),c.oldVersion,c.newVersion,ur(o.transaction),c)}),r&&o.addEventListener("blocked",c=>r(c.oldVersion,c.newVersion,c)),a.then(c=>{s&&c.addEventListener("close",()=>s()),i&&c.addEventListener("versionchange",f=>i(f.oldVersion,f.newVersion,f))}).catch(()=>{}),a}function r8(t,{blocked:e}={}){let r=indexedDB.deleteDatabase(t);return e&&r.addEventListener("blocked",n=>e(n.oldVersion,n)),ur(r).then(()=>{})}function Py(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(Pf.get(e))return Pf.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,i=i8.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||n8.includes(r)))return;let s=async function(o,...a){let c=this.transaction(o,i?"readwrite":"readonly"),f=c.store;return n&&(f=f.index(a.shift())),(await Promise.all([f[r](...a),i&&c.done]))[0]};return Pf.set(e,s),s}var n8,i8,Pf,Uy=Xf(()=>{Rf();Rf();n8=["get","getKey","getAll","getAllKeys","count"],i8=["put","add","delete","clear"],Pf=new Map;Ry(t=>({...t,get:(e,r,n)=>Py(e,r)||t.get(e,r,n),has:(e,r)=>!!Py(e,r)||t.has(e,r)}))});var Uf=ee(sc=>{"use strict";Object.defineProperty(sc,"__esModule",{value:!0});sc.IdbKeyVal=void 0;var s8=(Uy(),tm(Iy)),Zs=oc(),Fy="auth-client-db",My="ic-keyval",o8=async(t=Fy,e=My,r)=>(Zs.isBrowser&&(localStorage!=null&&localStorage.getItem(Zs.KEY_STORAGE_DELEGATION))&&(localStorage.removeItem(Zs.KEY_STORAGE_DELEGATION),localStorage.removeItem(Zs.KEY_STORAGE_KEY)),await(0,s8.openDB)(t,r,{upgrade:n=>{n.objectStoreNames.contains(e)&&n.clear(e),n.createObjectStore(e)}}));async function a8(t,e,r){return await t.get(e,r)}async function c8(t,e,r,n){return await t.put(e,n,r)}async function u8(t,e,r){return await t.delete(e,r)}var If=class t{constructor(e,r){this._db=e,this._storeName=r}static async create(e){let{dbName:r=Fy,storeName:n=My,version:i=Zs.DB_VERSION}=e??{},s=await o8(r,n,i);return new t(s,n)}async set(e,r){return await c8(this._db,this._storeName,e,r)}async get(e){var r;return(r=await a8(this._db,this._storeName,e))!==null&&r!==void 0?r:null}async remove(e){return await u8(this._db,this._storeName,e)}};sc.IdbKeyVal=If});var oc=ee(nt=>{"use strict";var l8=nt&&nt.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},f8=nt&&nt.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},ac;Object.defineProperty(nt,"__esModule",{value:!0});nt.IdbStorage=nt.LocalStorage=nt.isBrowser=nt.DB_VERSION=nt.KEY_VECTOR=nt.KEY_STORAGE_DELEGATION=nt.KEY_STORAGE_KEY=void 0;var d8=Uf();nt.KEY_STORAGE_KEY="identity";nt.KEY_STORAGE_DELEGATION="delegation";nt.KEY_VECTOR="iv";nt.DB_VERSION=1;nt.isBrowser=typeof window<"u";var Ff=class{constructor(e="ic-",r){this.prefix=e,this._localStorage=r}get(e){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+e))}set(e,r){return this._getLocalStorage().setItem(this.prefix+e,r),Promise.resolve()}remove(e){return this._getLocalStorage().removeItem(this.prefix+e),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let e=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.localStorage:global.localStorage:window.localStorage;if(!e)throw new Error("Could not find local storage.");return e}};nt.LocalStorage=Ff;var Mf=class{constructor(e){ac.set(this,void 0),l8(this,ac,e??{},"f")}get _db(){return new Promise(e=>{if(this.initializedDb){e(this.initializedDb);return}d8.IdbKeyVal.create(f8(this,ac,"f")).then(r=>{this.initializedDb=r,e(r)})})}async get(e){return await(await this._db).get(e)}async set(e,r){await(await this._db).set(e,r)}async remove(e){await(await this._db).remove(e)}};nt.IdbStorage=Mf;ac=new WeakMap});var Hf=ee(Le=>{"use strict";var h8=Le&&Le.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),p8=Le&&Le.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&h8(e,t,r)};Object.defineProperty(Le,"__esModule",{value:!0});Le.AuthClient=Le.ERROR_USER_INTERRUPT=Le.IdbKeyVal=Le.KEY_STORAGE_KEY=Le.KEY_STORAGE_DELEGATION=Le.LocalStorage=Le.IdbStorage=void 0;var Cy=Qt(),er=Ty(),qy=Af(),vt=oc(),cc=oc();Object.defineProperty(Le,"IdbStorage",{enumerable:!0,get:function(){return cc.IdbStorage}});Object.defineProperty(Le,"LocalStorage",{enumerable:!0,get:function(){return cc.LocalStorage}});Object.defineProperty(Le,"KEY_STORAGE_DELEGATION",{enumerable:!0,get:function(){return cc.KEY_STORAGE_DELEGATION}});Object.defineProperty(Le,"KEY_STORAGE_KEY",{enumerable:!0,get:function(){return cc.KEY_STORAGE_KEY}});var y8=Uf();Object.defineProperty(Le,"IdbKeyVal",{enumerable:!0,get:function(){return y8.IdbKeyVal}});var g8="https://identity.ic0.app",m8="#authorize",Cf="ECDSA",qf="Ed25519",b8=500;Le.ERROR_USER_INTERRUPT="UserInterrupt";p8(Af(),Le);var kf=class{constructor(e,r,n,i,s,o,a,c){this._identity=e,this._key=r,this._chain=n,this._storage=i,this.idleManager=s,this._createOptions=o,this._idpWindow=a,this._eventHandler=c,this._registerDefaultIdleCallback()}static async create(e={}){var r,n,i;let s=(r=e.storage)!==null&&r!==void 0?r:new vt.IdbStorage,o=(n=e.keyType)!==null&&n!==void 0?n:Cf,a=null;if(e.identity)a=e.identity;else{let h=await s.get(vt.KEY_STORAGE_KEY);if(!h&&vt.isBrowser)try{let m=new vt.LocalStorage,_=await m.get(vt.KEY_STORAGE_DELEGATION),u=await m.get(vt.KEY_STORAGE_KEY);_&&u&&o===Cf&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await s.set(vt.KEY_STORAGE_DELEGATION,_),await s.set(vt.KEY_STORAGE_KEY,u),h=_,await m.remove(vt.KEY_STORAGE_DELEGATION),await m.remove(vt.KEY_STORAGE_KEY))}catch(m){console.error("error while attempting to recover localstorage: "+m)}if(h)try{typeof h=="object"?o===qf&&typeof h=="string"?a=await er.Ed25519KeyIdentity.fromJSON(h):a=await er.ECDSAKeyIdentity.fromKeyPair(h):typeof h=="string"&&(a=er.Ed25519KeyIdentity.fromJSON(h))}catch{}}let c=new Cy.AnonymousIdentity,f=null;if(a)try{let h=await s.get(vt.KEY_STORAGE_DELEGATION);if(typeof h=="object"&&h!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");e.identity?c=e.identity:h&&(f=er.DelegationChain.fromJSON(h),(0,er.isDelegationValid)(f)?"toDer"in a?c=er.PartialDelegationIdentity.fromDelegation(a,f):c=er.DelegationIdentity.fromDelegation(a,f):(await jf(s),a=null))}catch(h){console.error(h),await jf(s),a=null}let d;return!((i=e.idleOptions)===null||i===void 0)&&i.disableIdle?d=void 0:(f||e.identity)&&(d=qy.IdleManager.create(e.idleOptions)),a||(o===qf?(a=await er.Ed25519KeyIdentity.generate(),await s.set(vt.KEY_STORAGE_KEY,JSON.stringify(a.toJSON()))):(e.storage&&o===Cf&&console.warn(`You are using a custom storage provider that may not support CryptoKey storage. If you are using a custom storage provider that does not support CryptoKey storage, you should use '${qf}' as the key type, as it can serialize to a string`),a=await er.ECDSAKeyIdentity.generate(),await s.set(vt.KEY_STORAGE_KEY,a.getKeyPair()))),new this(c,a,f,s,d,e)}_registerDefaultIdleCallback(){var e,r;let n=(e=this._createOptions)===null||e===void 0?void 0:e.idleOptions;!n?.onIdle&&!n?.disableDefaultIdleCallback&&((r=this.idleManager)===null||r===void 0||r.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(e,r){var n,i;let s=e.delegations.map(f=>({delegation:new er.Delegation(f.delegation.pubkey,f.delegation.expiration,f.delegation.targets),signature:f.signature.buffer})),o=er.DelegationChain.fromDelegations(s,e.userPublicKey.buffer),a=this._key;if(!a)return;this._chain=o,"toDer"in a?this._identity=er.PartialDelegationIdentity.fromDelegation(a,this._chain):this._identity=er.DelegationIdentity.fromDelegation(a,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let c=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!c?.disableIdle&&(this.idleManager=qy.IdleManager.create(c),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(vt.KEY_STORAGE_DELEGATION,JSON.stringify(this._chain.toJSON())),r?.(e)}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(e){var r,n,i,s;let o=BigInt(8)*BigInt(36e11),a=new URL(((r=e?.identityProvider)===null||r===void 0?void 0:r.toString())||g8);a.hash=m8,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(a,Object.assign({maxTimeToLive:(i=e?.maxTimeToLive)!==null&&i!==void 0?i:o},e)),window.addEventListener("message",this._eventHandler),this._idpWindow=(s=window.open(a.toString(),"idpWindow",e?.windowOpenerFeatures))!==null&&s!==void 0?s:void 0;let c=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(Le.ERROR_USER_INTERRUPT,e?.onError):setTimeout(c,b8))};c()}_getEventHandler(e,r){return async n=>{var i,s,o;if(n.origin!==e.origin)return;let a=n.data;switch(a.kind){case"authorize-ready":{let c=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((i=this._key)===null||i===void 0?void 0:i.getPublicKey().toDer()),maxTimeToLive:r?.maxTimeToLive,allowPinAuthentication:r?.allowPinAuthentication,derivationOrigin:(s=r?.derivationOrigin)===null||s===void 0?void 0:s.toString()},r?.customValues);(o=this._idpWindow)===null||o===void 0||o.postMessage(c,e.origin);break}case"authorize-client-success":try{await this._handleSuccess(a,r?.onSuccess)}catch(c){this._handleFailure(c.message,r?.onError)}break;case"authorize-client-failure":this._handleFailure(a.text,r?.onError);break;default:break}}}_handleFailure(e,r){var n;(n=this._idpWindow)===null||n===void 0||n.close(),r?.(e),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(e={}){if(await jf(this._storage),this._identity=new Cy.AnonymousIdentity,this._chain=null,e.returnTo)try{window.history.pushState({},"",e.returnTo)}catch{window.location.href=e.returnTo}}};Le.AuthClient=kf;async function jf(t){await t.remove(vt.KEY_STORAGE_KEY),await t.remove(vt.KEY_STORAGE_DELEGATION),await t.remove(vt.KEY_VECTOR)}});var Fg=Ze(mt(),1);var bg=Ze(mt(),1);var Gi=class{callbacks=[];populate(e){this.callbacks.forEach(({callback:r})=>r(e))}subscribe(e){let r=Symbol();return this.callbacks.push({id:r,callback:e}),()=>this.callbacks=this.callbacks.filter(({id:n})=>n!==r)}};var on=class t extends Gi{static instance;authUser=null;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.authUser=e,this.populate(e)}get(){return this.authUser}subscribe(e){let r=super.subscribe(e);return e(this.authUser),r}reset(){this.authUser=null,this.populate(this.authUser)}};var lf=({message:t,detail:e})=>{let r=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(r)};var gg=Ze(Hf(),1),mg=Ze(mt(),1);var jy=BigInt(144e11),ky=!1,Hy={width:576,height:576},Vy={width:505,height:705},$y="internetcomputer.org";var Js=Ze(mt(),1);var zi="http://127.0.0.1:5987",Ky="rdmx6-jaaaa-aaaaa-aaadq-cai";var Yr=class t extends Gi{static instance;env;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.env=e,this.populate(e)}get(){return this.env}subscribe(e){let r=super.subscribe(e);return e(this.env),r}};var Vf=Ze(mt(),1);var uc=Ze(mt(),1),Gy=async t=>{let e=new Blob([JSON.stringify(t,uc.jsonReplacer)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},lc=async t=>{let e=new Blob([t instanceof Uint8Array?t:new Uint8Array(t)],{type:"application/json; charset=utf-8"});return JSON.parse(await e.text(),uc.jsonReviver)},fc=()=>typeof window<"u";var $f=({width:t,height:e})=>{if(!fc()||(0,Vf.isNullish)(window)||(0,Vf.isNullish)(window.top))return;let{top:{innerWidth:r,innerHeight:n}}=window,i=n/2+screenY-e/2,s=r/2+screenX-t/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${t}, height=${e}, top=${i}, left=${s}`};var dc=class{#e;constructor({domain:e}){this.#e=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let r=()=>{let n=Yr.getInstance().get()?.container;if((0,Js.isNullish)(n)||n===!1)return`https://identity.${this.#e??$y}`;let i=Yr.getInstance().get(),s=(0,Js.nonNullish)(i)&&(0,Js.nonNullish)(i?.internetIdentityId)?i.internetIdentityId:Ky,{host:o,protocol:a}=new URL(n===!0?zi:n);return/apple/i.test(navigator?.vendor)?`${a}//${o}?canisterId=${s}`:`${a}//${s}.${o.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:$f(Hy)},identityProvider:r()}}},Yy=class{#e;#t;constructor({appName:e,logoUrl:r}){this.#e=e,this.#t=r}get id(){return"nfid"}signInOptions({windowed:e}){return{...e!==!1&&{windowOpenerFeatures:$f(Vy)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#e)}&applicationLogo=${encodeURI(this.#t)}`}}};var zy=Ze(Qt(),1),hc=Ze(mt(),1);var Wy=Ze(Qt(),1),si=Ze(mt(),1);var Di=class t{static instance;#e=void 0;constructor(){}static getInstance(){return(0,si.isNullish)(t.instance)&&(t.instance=new t),t.instance}async getAgent({identity:e,...r}){let n=e.getPrincipal().toText();if((0,si.isNullish)(this.#e)||(0,si.isNullish)(this.#e[n])){let i=await this.createAgent({identity:e,...r});return this.#e={...this.#e??{},[n]:i},i}return this.#e[n]}reset(){this.#e=null}async createAgent({identity:e,fetch:r,container:n}){let s=(0,si.nonNullish)(n)&&n!==!1?n===!0?zi:n:"https://icp-api.io",o=(0,si.nonNullish)(n);return await Wy.HttpAgent.create({identity:e,shouldFetchRootKey:o,host:s,...r&&{fetch:r}})}};var Zi=class t{static instance;#e=void 0;constructor(){}static getInstance(){return(0,hc.isNullish)(t.instance)&&(t.instance=new t),t.instance}async getActor({satelliteId:e,identity:r,buildType:n,...i}){let s=`${n}#${r.getPrincipal().toText()}#${e};`;if((0,hc.isNullish)(this.#e)||(0,hc.isNullish)(this.#e[s])){let o=await this.createActor({satelliteId:e,identity:r,...i});return this.#e={...this.#e??{},[s]:o},o}return this.#e[s]}reset(){this.#e=null}async createActor({idlFactory:e,satelliteId:r,...n}){let i=await Di.getInstance().getAgent(n);return zy.Actor.createActor(e,{agent:i,canisterId:r})}};var pc=class extends Error{},yc=class extends Error{},gc=class extends Error{},mc=class extends Error{},bc=class extends Error{};var Dy=Ze(Hf(),1),_c=()=>Dy.AuthClient.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var Qs=Ze(mt(),1);var Kf="juno.datastore.error.user.cannot_update";var Gf=({error:t,type:e})=>typeof t=="string"?t.includes(e):t instanceof Error?t.message.includes(e):!1;var xr=Ze(mt(),1);var Zy=async({data:t})=>{try{return await lc(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};var oi=Ze(mt(),1);var Yf=async t=>{let{data:e,version:r,description:n}=t;return{description:(0,oi.toNullable)(n),data:await Gy(e),version:(0,oi.toNullable)(r)}},Wf=t=>{let{version:e}=t;return{version:(0,oi.toNullable)(e)}},Xs=async({doc:t,key:e})=>{let{owner:r,version:n,description:i,data:s,...o}=t;return{key:e,description:(0,oi.fromNullable)(i),owner:r.toText(),data:await lc(s),version:(0,oi.fromNullable)(n),...o}};var Xy=Ze(Ut(),1),it=Ze(mt(),1);var Jy=t=>{if((0,it.isNullish)(t))return(0,it.toNullable)();switch(t.matcher){case"equal":return(0,it.toNullable)({Equal:t.timestamp});case"greaterThan":return(0,it.toNullable)({GreaterThan:t.timestamp});case"lessThan":return(0,it.toNullable)({LessThan:t.timestamp});case"between":return(0,it.toNullable)({Between:[t.timestamps.start,t.timestamps.end]});default:throw new bc("Invalid list matcher for timestamp",t)}},Cn=({matcher:t,paginate:e,order:r,owner:n})=>({matcher:(0,it.isNullish)(t)?[]:[{key:(0,it.toNullable)(t.key),description:(0,it.toNullable)(t.description),created_at:Jy(t.createdAt),updated_at:Jy(t.updatedAt)}],paginate:(0,it.toNullable)((0,it.isNullish)(e)?void 0:{start_after:(0,it.toNullable)(e.startAfter),limit:(0,it.toNullable)((0,it.isNullish)(e.limit)?void 0:BigInt(e.limit))}),order:(0,it.toNullable)((0,it.isNullish)(r)?void 0:{desc:r.desc,field:r.field==="created_at"?{CreatedAt:null}:r.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:(0,it.toNullable)((0,it.isNullish)(n)?void 0:typeof n=="string"?Xy.Principal.fromText(n):n)});var eg=Ze(mt(),1);var Qy=({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}),n=t.Record({field:r,desc:t.Bool}),i=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(i),description:t.Opt(t.Text),created_at:t.Opt(i)}),o=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),a=t.Record({order:t.Opt(n),owner:t.Opt(t.Principal),matcher:t.Opt(s),paginate:t.Opt(o)}),c=t.Record({controllers:t.Vec(t.Principal)}),f=t.Variant({Write:t.Null,Admin:t.Null}),d=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:f,expires_at:t.Opt(t.Nat64)}),h=t.Record({version:t.Opt(t.Nat64)}),m=t.Variant({Db:t.Null,Storage:t.Null}),_=t.Record({version:t.Opt(t.Nat64)}),u=t.Record({cycles:t.Nat,destination_id:t.Principal}),O=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}),T=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),P=t.Record({key:O,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,T)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),F=t.Record({derivation_origin:t.Opt(t.Text),external_alternative_origins:t.Opt(t.Vec(t.Text))}),A=t.Record({internet_identity:t.Opt(F)}),K=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),E=t.Record({max_memory_size:t.Opt(K)}),j=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),G=t.Variant({Deny:t.Null,Allow:t.Null}),z=t.Record({status_code:t.Nat16,location:t.Text}),q=t.Record({iframe:t.Opt(j),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(K),raw_access:t.Opt(G),redirects:t.Opt(t.Vec(t.Tuple(t.Text,z)))}),oe=t.Record({db:t.Opt(E),authentication:t.Opt(A),storage:q}),Q=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)}),ie=t.Variant({Heap:t.Null,Stable:t.Null}),w=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),b=t.Record({max_tokens:t.Nat64,time_per_token_ns:t.Nat64}),N=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(ie),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:w,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(b),write:w,max_changes_per_user:t.Opt(t.Nat32)}),B=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)}),R=t.Record({memory:ie,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}),V=t.Variant({Callback:t.Record({token:R,callback:t.Func([],[],["query"])})}),Z=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(V),status_code:t.Nat16}),ce=t.Record({token:t.Opt(R),body:t.Vec(t.Nat8)}),ae=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}),D=t.Record({batch_id:t.Nat}),M=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,P)),items_length:t.Nat64}),y=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),L=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,Q)),items_length:t.Nat64}),re=t.Record({stable:t.Nat64,heap:t.Nat64}),le=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:f,expires_at:t.Opt(t.Nat64)}),X=t.Record({controller:le,controllers:t.Vec(t.Principal)}),l=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),p=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(ie),max_size:t.Opt(t.Nat),read:w,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(b),write:w,max_changes_per_user:t.Opt(t.Nat32)}),g=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),I=t.Record({chunk_id:t.Nat});return t.Service({commit_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text,a],[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,a],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([c],[t.Vec(t.Tuple(t.Principal,d))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,h],[],[]),del_docs:t.Func([t.Text],[],[]),del_filtered_assets:t.Func([t.Text,a],[],[]),del_filtered_docs:t.Func([t.Text,a],[],[]),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,h))],[],[]),del_rule:t.Func([m,t.Text,_],[],[]),deposit_cycles:t.Func([u],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(P)],["query"]),get_auth_config:t.Func([],[t.Opt(A)],["query"]),get_config:t.Func([],[oe],[]),get_db_config:t.Func([],[t.Opt(E)],["query"]),get_doc:t.Func([t.Text,t.Text],[t.Opt(Q)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(P)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(Q)))],["query"]),get_rule:t.Func([m,t.Text],[t.Opt(N)],["query"]),get_storage_config:t.Func([],[q],["query"]),http_request:t.Func([B],[Z],["query"]),http_request_streaming_callback:t.Func([R],[ce],["query"]),init_asset_upload:t.Func([ae],[D],[]),list_assets:t.Func([t.Text,a],[M],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,d))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,y))],["query"]),list_docs:t.Func([t.Text,a],[L],["query"]),list_rules:t.Func([m],[t.Vec(t.Tuple(t.Text,N))],["query"]),memory_size:t.Func([],[re],["query"]),set_auth_config:t.Func([A],[],[]),set_controllers:t.Func([X],[t.Vec(t.Tuple(t.Principal,d))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([E],[],[]),set_doc:t.Func([t.Text,t.Text,l],[Q],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,l))],[t.Vec(t.Tuple(t.Text,Q))],[]),set_rule:t.Func([m,t.Text,p],[N],[]),set_storage_config:t.Func([q],[],[]),upload_asset_chunk:t.Func([g],[I],[])})};var wc=Ze(mt(),1);var Ly=({satelliteId:t,container:e})=>{let{satelliteId:r}=zf({satelliteId:t}),{container:n}=Df({container:e});if((0,wc.nonNullish)(n)&&n!==!1){let{host:i,protocol:s}=new URL(n===!0?zi:n);return`${s}//${r??"unknown"}.${i.replace("127.0.0.1","localhost")}`}return`https://${r??"unknown"}.icp0.io`},zf=({satelliteId:t})=>(0,wc.nonNullish)(t)?{satelliteId:t}:Yr.getInstance().get()??{satelliteId:void 0},Df=({container:t})=>(0,wc.nonNullish)(t)?{container:t}:Yr.getInstance().get()??{container:void 0};var lt=t=>rg({idlFactory:Qy,buildType:"stock",...t}),tg=({idlFactory:t,...e})=>rg({idlFactory:t,buildType:"extended",...e}),rg=async({satelliteId:t,container:e,...r})=>{let{satelliteId:n}=zf({satelliteId:t});(0,eg.assertNonNullish)(n,"No satellite ID defined. Did you initialize Juno?");let{container:i}=Df({container:e});return await Zi.getInstance().getActor({satelliteId:n,container:i,...r})};var ng=async({collection:t,key:e,satellite:r})=>{let{get_doc:n}=await lt(r),i=(0,xr.fromNullable)(await n(t,e));if(!(0,xr.isNullish)(i))return Xs({doc:i,key:e})},ig=async({docs:t,satellite:e})=>{let{get_many_docs:r}=await lt(e),n=t.map(({collection:o,key:a})=>[o,a]),i=await r(n),s=[];for(let[o,a]of i){let c=(0,xr.fromNullable)(a);s.push((0,xr.nonNullish)(c)?await Xs({key:o,doc:c}):void 0)}return s},sg=async({collection:t,doc:e,satellite:r})=>{let{set_doc:n}=await lt(r),{key:i}=e,s=await Yf(e),o=await n(t,i,s);return await Xs({key:i,doc:o})},og=async({docs:t,satellite:e})=>{let{set_many_docs:r}=await lt(e),n=[];for(let{collection:o,doc:a}of t){let{key:c}=a;n.push([o,c,await Yf(a)])}let i=await r(n),s=[];for(let[o,a]of i)s.push(await Xs({key:o,doc:a}));return s},ag=async({collection:t,doc:e,satellite:r})=>{let{del_doc:n}=await lt(r),{key:i}=e;return n(t,i,Wf(e))},cg=async({docs:t,satellite:e})=>{let{del_many_docs:r}=await lt(e),n=t.map(({collection:i,doc:s})=>[i,s.key,Wf(s)]);await r(n)},ug=async({collection:t,filter:e,satellite:r})=>{let{del_filtered_docs:n}=await lt(r);return n(t,Cn(e))},lg=async({collection:t,filter:e,satellite:r})=>{let{list_docs:n}=await lt(r),{items:i,items_page:s,items_length:o,matches_length:a,matches_pages:c}=await n(t,Cn(e)),f=[];for(let[d,h]of i){let{data:m,owner:_,description:u,version:O,...T}=h;f.push({key:d,description:(0,xr.fromNullable)(u),owner:_.toText(),data:await Zy({data:m}),version:(0,xr.fromNullable)(O),...T})}return{items:f,items_length:o,items_page:(0,xr.fromNullable)(s),matches_length:a,matches_pages:(0,xr.fromNullable)(c)}},fg=async({collection:t,filter:e,satellite:r})=>{let{count_docs:n}=await lt(r);return n(t,Cn(e))};var dg=Ze(Qt(),1);var et=t=>t!==void 0?t:Ec()??new dg.AnonymousIdentity;var hg=async({satellite:t,...e})=>{let r=et(t?.identity);return await ng({...e,satellite:{...t,identity:r}})},V6=async({satellite:t,...e})=>{let r=et(t?.identity);return await ig({...e,satellite:{...t,identity:r}})},pg=async({satellite:t,...e})=>{let r=et(t?.identity);return await sg({...e,satellite:{...t,identity:r}})},$6=async({satellite:t,...e})=>{let r=et(t?.identity);return await og({...e,satellite:{...t,identity:r}})},K6=async({satellite:t,...e})=>{let r=et(t?.identity);return await ag({...e,satellite:{...t,identity:r}})},G6=async({satellite:t,...e})=>{let r=et(t?.identity);return await cg({...e,satellite:{...t,identity:r}})},Y6=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await ug({...r,filter:e??{},satellite:{...t,identity:n}})},W6=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await lg({...r,filter:e??{},satellite:{...t,identity:n}})},z6=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await fg({...r,filter:e??{},satellite:{...t,identity:n}})};var yg=async t=>{let e=Ec();if((0,Qs.isNullish)(e))throw new mc("No identity to initialize the user. Have you initialized Juno?");let r=e.getPrincipal().toText(),n=()=>hg({collection:"#user",key:r}),i=await n();if((0,Qs.nonNullish)(i))return i;try{return await _8({userId:r,provider:t})}catch(s){if(Gf({error:s,type:Kf})){let o=await n();if((0,Qs.nonNullish)(o))return o}throw s}},_8=({userId:t,...e})=>pg({collection:"#user",doc:{key:t,data:e}});var Wr,Zf=async t=>{if(Wr=Wr??await _c(),!(await Wr?.isAuthenticated()??!1))return;let r=await yg(t);on.getInstance().set(r)},w8=t=>new Promise(async(e,r)=>{if((0,mg.isNullish)(Wr)){r(new yc("No client is ready to perform a sign-in. Have you initialized the Satellite?"));return}let n=t?.provider??new dc({});await Wr.login({onSuccess:async()=>{await Zf(n.id),e()},onError:i=>{if(i===gg.ERROR_USER_INTERRUPT){r(new gc(i));return}r(new pc(i))},maxTimeToLive:t?.maxTimeToLive??jy,allowPinAuthentication:t?.allowPin??ky,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...n.signInOptions({windowed:t?.windowed})})}),Jf=async()=>{await Wr?.logout(),Wr=null,on.getInstance().reset(),Zi.getInstance().reset(),Di.getInstance().reset(),Wr=await _c()},Ec=()=>Wr?.getIdentity(),E8=async()=>(Wr??await _c()).getIdentity();var _g=t=>{let e=t===!0?"./workers/auth.worker.js":t,r=new Worker(e),n=async()=>{lf({message:"junoSignOutAuthTimer"}),await Jf()};return r.onmessage=async({data:i})=>{let{msg:s,data:o}=i;switch(s){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":lf({message:"junoDelegationRemainingTime",detail:o?.authRemainingTime});return}},on.getInstance().subscribe(i=>{if((0,bg.isNullish)(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var wg=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_SATELLITE_ID??import.meta.env?.PUBLIC_SATELLITE_ID:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_SATELLITE_ID??t():t()},Eg=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_CONTAINER??import.meta.env?.PUBLIC_CONTAINER:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_CONTAINER??t():t()};var gT=async({idlFactory:t,satellite:e})=>{let r=et(e?.identity);return await tg({idlFactory:t,...e,identity:r})};var to=Ze(mt(),1);var eo=Ze(mt(),1);var Ls=Ze(mt(),1);var xg=async({asset:{data:t,filename:e,collection:r,headers:n,token:i,fullPath:s,encoding:o,description:a},actor:c,init_asset_upload:f})=>{let{batch_id:d}=await f({collection:r,full_path:s,name:e,token:(0,Ls.toNullable)(i),encoding_type:(0,Ls.toNullable)(o),description:(0,Ls.toNullable)(a)}),h=19e5,m=[],_=fc()?new Blob([await t.arrayBuffer()]):t,u=0n;for(let P=0;P<_.size;P+=h){let F=_.slice(P,P+h);m.push({batchId:d,chunk:F,actor:c,orderId:u}),u++}let O=[];for await(let P of x8({uploadChunks:m}))O=[...O,...P];let T=n.find(([P,F])=>P.toLowerCase()==="content-type")===void 0&&t.type!==void 0&&t.type!==""?[["Content-Type",t.type]]:void 0;await c.commit_asset_upload({batch_id:d,chunk_ids:O.map(({chunk_id:P})=>P),headers:[...n,...T??[]]})};async function*x8({uploadChunks:t,limit:e=12}){for(let r=0;r<t.length;r=r+e){let n=t.slice(r,r+e);yield await Promise.all(n.map(i=>v8(i)))}}var v8=async({batchId:t,chunk:e,actor:r,orderId:n})=>r.upload_asset_chunk({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:(0,Ls.toNullable)(n)});var vg=async({satellite:t,...e})=>{let r=await lt(t);await xg({actor:r,asset:e,init_asset_upload:async i=>await r.init_asset_upload(i)})},Tg=async({collection:t,satellite:e,filter:r})=>{let{list_assets:n}=await lt(e),{items:i,items_length:s,items_page:o,matches_length:a,matches_pages:c}=await n(t,Cn(r));return{items:i.map(([f,d])=>d),items_length:s,items_page:(0,eo.fromNullable)(o),matches_length:a,matches_pages:(0,eo.fromNullable)(c)}},Ag=async({collection:t,satellite:e,filter:r})=>{let{count_assets:n}=await lt(e);return n(t,Cn(r))},Sg=async({collection:t,fullPath:e,satellite:r})=>(await lt(r)).del_asset(t,e),Bg=async({assets:t,satellite:e})=>{let{del_many_assets:r}=await lt(e),n=t.map(({collection:i,fullPath:s})=>[i,s]);await r(n)},Og=async({collection:t,satellite:e,filter:r})=>{let{del_filtered_assets:n}=await lt(e);return n(t,Cn(r))},Ng=async({collection:t,fullPath:e,satellite:r})=>{let{get_asset:n}=await lt(r);return(0,eo.fromNullable)(await n(t,e))},Rg=async({assets:t,satellite:e})=>{let{get_many_assets:r}=await lt(e),n=t.map(({collection:s,fullPath:o})=>[s,o]);return(await r(n)).map(([s,o])=>(0,eo.fromNullable)(o))};var Pg=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var NT=t=>Ig(t),RT=t=>Ig({filename:t.data.name,...t}),Ig=async({filename:t,data:e,collection:r,headers:n=[],fullPath:i,token:s,satellite:o,encoding:a,description:c})=>{let f=et(o?.identity),d=decodeURI(t),h=i??`/${r}/${d}`,m={...o,identity:f};return await vg({data:e,filename:d,collection:r,token:s,headers:n,fullPath:h,encoding:a,satellite:m,description:c}),{downloadUrl:Ug({satellite:m,assetKey:{fullPath:h,token:s}}),fullPath:h,name:d}},PT=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)},{items:i,...s}=await Tg({collection:t,satellite:n,filter:r??{}}),o=i.map(({key:{full_path:a,token:c,name:f,owner:d,description:h},headers:m,encodings:_,created_at:u,updated_at:O})=>{let T=(0,to.fromNullable)(c);return{fullPath:a,description:(0,to.fromNullable)(h),name:f,downloadUrl:Ug({satellite:n,assetKey:{fullPath:a,token:T}}),token:T,headers:m,encodings:_.reduce((P,[F,{modified:A,sha256:K,total_length:E}])=>({...P,[F]:{modified:A,sha256:Pg(K),total_length:E}}),{}),owner:d.toText(),created_at:u,updated_at:O}});return{items:o,assets:o,...s}},IT=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)};return await Ag({collection:t,satellite:n,filter:r??{}})},UT=({collection:t,fullPath:e,satellite:r})=>Sg({collection:t,fullPath:e,satellite:{...r,identity:et(r?.identity)}}),FT=({assets:t,satellite:e})=>Bg({assets:t,satellite:{...e,identity:et(e?.identity)}}),MT=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)};return await Og({collection:t,satellite:n,filter:r??{}})},CT=async({satellite:t,...e})=>{let r=et(t?.identity);return await Ng({...e,satellite:{...t,identity:r}})},qT=async({satellite:t,...e})=>{let r=et(t?.identity);return await Rg({...e,satellite:{...t,identity:r}})},Ug=({assetKey:{fullPath:t,token:e},satellite:r})=>{let n={...r,identity:et(r?.identity)};return`${Ly(n)}${t}${(0,to.nonNullish)(e)?`?token=${e}`:""}`};var T8=t=>{let e=t?.satelliteId??wg();(0,Fg.assertNonNullish)(e,"Satellite ID is not configured. Juno cannot be initialized.");let r=t?.container??Eg();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:r}},GT=t=>A8(t),A8=async t=>{let e=T8(t);Yr.getInstance().set(e),await Zf();let r=e.workers?.auth!==void 0?_g(e.workers.auth):void 0;return[...r?[r]:[]]},YT=t=>on.getInstance().subscribe(t);export{mc as InitError,dc as InternetIdentityProvider,bc as ListError,Yy as NFIDProvider,pc as SignInError,yc as SignInInitError,gc as SignInUserInterruptError,YT as authSubscribe,IT as countAssets,z6 as countDocs,UT as deleteAsset,K6 as deleteDoc,MT as deleteFilteredAssets,Y6 as deleteFilteredDocs,FT as deleteManyAssets,G6 as deleteManyDocs,Ug as downloadUrl,CT as getAsset,hg as getDoc,qT as getManyAssets,V6 as getManyDocs,gT as getSatelliteExtendedActor,GT as initJuno,A8 as initSatellite,PT as listAssets,W6 as listDocs,pg as setDoc,$6 as setManyDocs,w8 as signIn,Jf as signOut,E8 as unsafeIdentity,NT as uploadBlob,RT as uploadFile};
|
|
58
58
|
/*! Bundled license information:
|
|
59
59
|
|
|
60
60
|
ieee754/index.js:
|
|
@@ -72,32 +72,14 @@ buffer/index.js:
|
|
|
72
72
|
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
73
73
|
|
|
74
74
|
@noble/curves/abstract/utils.js:
|
|
75
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
76
|
-
|
|
77
75
|
@noble/curves/abstract/modular.js:
|
|
78
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
79
|
-
|
|
80
76
|
@noble/curves/abstract/curve.js:
|
|
81
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
82
|
-
|
|
83
77
|
@noble/curves/abstract/weierstrass.js:
|
|
84
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
85
|
-
|
|
86
78
|
@noble/curves/abstract/bls.js:
|
|
87
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
88
|
-
|
|
89
79
|
@noble/curves/abstract/tower.js:
|
|
90
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
91
|
-
|
|
92
80
|
@noble/curves/bls12-381.js:
|
|
93
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
94
|
-
|
|
95
81
|
@noble/curves/abstract/edwards.js:
|
|
96
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
97
|
-
|
|
98
82
|
@noble/curves/abstract/montgomery.js:
|
|
99
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
100
|
-
|
|
101
83
|
@noble/curves/ed25519.js:
|
|
102
84
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
103
85
|
*/
|