@junobuild/core-standalone 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.js +9 -9
- package/dist/browser/index.js.map +3 -3
- package/dist/declarations/satellite/satellite.did.d.ts +8 -5
- package/dist/declarations/satellite/satellite.factory.did.js +11 -8
- package/dist/declarations/satellite/satellite.factory.did.mjs +11 -8
- package/dist/node/index.mjs +1 -1
- package/dist/node/index.mjs.map +3 -3
- package/package.json +1 -1
|
@@ -28,7 +28,9 @@ export interface AuthenticationConfig {
|
|
|
28
28
|
}
|
|
29
29
|
export interface AuthenticationConfigInternetIdentity {
|
|
30
30
|
derivation_origin: [] | [string];
|
|
31
|
+
external_alternative_origins: [] | [Array<string>];
|
|
31
32
|
}
|
|
33
|
+
export type CollectionType = {Db: null} | {Storage: null};
|
|
32
34
|
export interface CommitBatch {
|
|
33
35
|
batch_id: bigint;
|
|
34
36
|
headers: Array<[string, string]>;
|
|
@@ -161,8 +163,8 @@ export interface Rule {
|
|
|
161
163
|
mutable_permissions: [] | [boolean];
|
|
162
164
|
rate_config: [] | [RateConfig];
|
|
163
165
|
write: Permission;
|
|
166
|
+
max_changes_per_user: [] | [number];
|
|
164
167
|
}
|
|
165
|
-
export type RulesType = {Db: null} | {Storage: null};
|
|
166
168
|
export interface SetController {
|
|
167
169
|
metadata: Array<[string, string]>;
|
|
168
170
|
scope: ControllerScope;
|
|
@@ -186,6 +188,7 @@ export interface SetRule {
|
|
|
186
188
|
mutable_permissions: [] | [boolean];
|
|
187
189
|
rate_config: [] | [RateConfig];
|
|
188
190
|
write: Permission;
|
|
191
|
+
max_changes_per_user: [] | [number];
|
|
189
192
|
}
|
|
190
193
|
export interface StorageConfig {
|
|
191
194
|
iframe: [] | [StorageConfigIFrame];
|
|
@@ -250,7 +253,7 @@ export interface _SERVICE {
|
|
|
250
253
|
del_filtered_docs: ActorMethod<[string, ListParams], undefined>;
|
|
251
254
|
del_many_assets: ActorMethod<[Array<[string, string]>], undefined>;
|
|
252
255
|
del_many_docs: ActorMethod<[Array<[string, string, DelDoc]>], undefined>;
|
|
253
|
-
del_rule: ActorMethod<[
|
|
256
|
+
del_rule: ActorMethod<[CollectionType, string, DelRule], undefined>;
|
|
254
257
|
deposit_cycles: ActorMethod<[DepositCyclesArgs], undefined>;
|
|
255
258
|
get_asset: ActorMethod<[string, string], [] | [AssetNoContent]>;
|
|
256
259
|
get_auth_config: ActorMethod<[], [] | [AuthenticationConfig]>;
|
|
@@ -259,7 +262,7 @@ export interface _SERVICE {
|
|
|
259
262
|
get_doc: ActorMethod<[string, string], [] | [Doc]>;
|
|
260
263
|
get_many_assets: ActorMethod<[Array<[string, string]>], Array<[string, [] | [AssetNoContent]]>>;
|
|
261
264
|
get_many_docs: ActorMethod<[Array<[string, string]>], Array<[string, [] | [Doc]]>>;
|
|
262
|
-
get_rule: ActorMethod<[
|
|
265
|
+
get_rule: ActorMethod<[CollectionType, string], [] | [Rule]>;
|
|
263
266
|
get_storage_config: ActorMethod<[], StorageConfig>;
|
|
264
267
|
http_request: ActorMethod<[HttpRequest], HttpResponse>;
|
|
265
268
|
http_request_streaming_callback: ActorMethod<
|
|
@@ -271,7 +274,7 @@ export interface _SERVICE {
|
|
|
271
274
|
list_controllers: ActorMethod<[], Array<[Principal, Controller]>>;
|
|
272
275
|
list_custom_domains: ActorMethod<[], Array<[string, CustomDomain]>>;
|
|
273
276
|
list_docs: ActorMethod<[string, ListParams], ListResults_1>;
|
|
274
|
-
list_rules: ActorMethod<[
|
|
277
|
+
list_rules: ActorMethod<[CollectionType], Array<[string, Rule]>>;
|
|
275
278
|
memory_size: ActorMethod<[], MemorySize>;
|
|
276
279
|
set_auth_config: ActorMethod<[AuthenticationConfig], undefined>;
|
|
277
280
|
set_controllers: ActorMethod<[SetControllersArgs], Array<[Principal, Controller]>>;
|
|
@@ -279,7 +282,7 @@ export interface _SERVICE {
|
|
|
279
282
|
set_db_config: ActorMethod<[DbConfig], undefined>;
|
|
280
283
|
set_doc: ActorMethod<[string, string, SetDoc], Doc>;
|
|
281
284
|
set_many_docs: ActorMethod<[Array<[string, string, SetDoc]>], Array<[string, Doc]>>;
|
|
282
|
-
set_rule: ActorMethod<[
|
|
285
|
+
set_rule: ActorMethod<[CollectionType, string, SetRule], Rule>;
|
|
283
286
|
set_storage_config: ActorMethod<[StorageConfig], undefined>;
|
|
284
287
|
upload_asset_chunk: ActorMethod<[UploadChunk], UploadChunkResult>;
|
|
285
288
|
version: ActorMethod<[], string>;
|
|
@@ -48,7 +48,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
48
48
|
expires_at: IDL.Opt(IDL.Nat64)
|
|
49
49
|
});
|
|
50
50
|
const DelDoc = IDL.Record({version: IDL.Opt(IDL.Nat64)});
|
|
51
|
-
const
|
|
51
|
+
const CollectionType = IDL.Variant({Db: IDL.Null, Storage: IDL.Null});
|
|
52
52
|
const DelRule = IDL.Record({version: IDL.Opt(IDL.Nat64)});
|
|
53
53
|
const DepositCyclesArgs = IDL.Record({
|
|
54
54
|
cycles: IDL.Nat,
|
|
@@ -76,7 +76,8 @@ export const idlFactory = ({IDL}) => {
|
|
|
76
76
|
version: IDL.Opt(IDL.Nat64)
|
|
77
77
|
});
|
|
78
78
|
const AuthenticationConfigInternetIdentity = IDL.Record({
|
|
79
|
-
derivation_origin: IDL.Opt(IDL.Text)
|
|
79
|
+
derivation_origin: IDL.Opt(IDL.Text),
|
|
80
|
+
external_alternative_origins: IDL.Opt(IDL.Vec(IDL.Text))
|
|
80
81
|
});
|
|
81
82
|
const AuthenticationConfig = IDL.Record({
|
|
82
83
|
internet_identity: IDL.Opt(AuthenticationConfigInternetIdentity)
|
|
@@ -143,7 +144,8 @@ export const idlFactory = ({IDL}) => {
|
|
|
143
144
|
version: IDL.Opt(IDL.Nat64),
|
|
144
145
|
mutable_permissions: IDL.Opt(IDL.Bool),
|
|
145
146
|
rate_config: IDL.Opt(RateConfig),
|
|
146
|
-
write: Permission
|
|
147
|
+
write: Permission,
|
|
148
|
+
max_changes_per_user: IDL.Opt(IDL.Nat32)
|
|
147
149
|
});
|
|
148
150
|
const HttpRequest = IDL.Record({
|
|
149
151
|
url: IDL.Text,
|
|
@@ -229,7 +231,8 @@ export const idlFactory = ({IDL}) => {
|
|
|
229
231
|
version: IDL.Opt(IDL.Nat64),
|
|
230
232
|
mutable_permissions: IDL.Opt(IDL.Bool),
|
|
231
233
|
rate_config: IDL.Opt(RateConfig),
|
|
232
|
-
write: Permission
|
|
234
|
+
write: Permission,
|
|
235
|
+
max_changes_per_user: IDL.Opt(IDL.Nat32)
|
|
233
236
|
});
|
|
234
237
|
const UploadChunk = IDL.Record({
|
|
235
238
|
content: IDL.Vec(IDL.Nat8),
|
|
@@ -258,7 +261,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
258
261
|
del_filtered_docs: IDL.Func([IDL.Text, ListParams], [], []),
|
|
259
262
|
del_many_assets: IDL.Func([IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))], [], []),
|
|
260
263
|
del_many_docs: IDL.Func([IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text, DelDoc))], [], []),
|
|
261
|
-
del_rule: IDL.Func([
|
|
264
|
+
del_rule: IDL.Func([CollectionType, IDL.Text, DelRule], [], []),
|
|
262
265
|
deposit_cycles: IDL.Func([DepositCyclesArgs], [], []),
|
|
263
266
|
get_asset: IDL.Func([IDL.Text, IDL.Text], [IDL.Opt(AssetNoContent)], ['query']),
|
|
264
267
|
get_auth_config: IDL.Func([], [IDL.Opt(AuthenticationConfig)], ['query']),
|
|
@@ -275,7 +278,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
275
278
|
[IDL.Vec(IDL.Tuple(IDL.Text, IDL.Opt(Doc)))],
|
|
276
279
|
['query']
|
|
277
280
|
),
|
|
278
|
-
get_rule: IDL.Func([
|
|
281
|
+
get_rule: IDL.Func([CollectionType, IDL.Text], [IDL.Opt(Rule)], ['query']),
|
|
279
282
|
get_storage_config: IDL.Func([], [StorageConfig], ['query']),
|
|
280
283
|
http_request: IDL.Func([HttpRequest], [HttpResponse], ['query']),
|
|
281
284
|
http_request_streaming_callback: IDL.Func(
|
|
@@ -288,7 +291,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
288
291
|
list_controllers: IDL.Func([], [IDL.Vec(IDL.Tuple(IDL.Principal, Controller))], ['query']),
|
|
289
292
|
list_custom_domains: IDL.Func([], [IDL.Vec(IDL.Tuple(IDL.Text, CustomDomain))], ['query']),
|
|
290
293
|
list_docs: IDL.Func([IDL.Text, ListParams], [ListResults_1], ['query']),
|
|
291
|
-
list_rules: IDL.Func([
|
|
294
|
+
list_rules: IDL.Func([CollectionType], [IDL.Vec(IDL.Tuple(IDL.Text, Rule))], ['query']),
|
|
292
295
|
memory_size: IDL.Func([], [MemorySize], ['query']),
|
|
293
296
|
set_auth_config: IDL.Func([AuthenticationConfig], [], []),
|
|
294
297
|
set_controllers: IDL.Func(
|
|
@@ -304,7 +307,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
304
307
|
[IDL.Vec(IDL.Tuple(IDL.Text, Doc))],
|
|
305
308
|
[]
|
|
306
309
|
),
|
|
307
|
-
set_rule: IDL.Func([
|
|
310
|
+
set_rule: IDL.Func([CollectionType, IDL.Text, SetRule], [Rule], []),
|
|
308
311
|
set_storage_config: IDL.Func([StorageConfig], [], []),
|
|
309
312
|
upload_asset_chunk: IDL.Func([UploadChunk], [UploadChunkResult], []),
|
|
310
313
|
version: IDL.Func([], [IDL.Text], ['query'])
|
|
@@ -48,7 +48,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
48
48
|
expires_at: IDL.Opt(IDL.Nat64)
|
|
49
49
|
});
|
|
50
50
|
const DelDoc = IDL.Record({version: IDL.Opt(IDL.Nat64)});
|
|
51
|
-
const
|
|
51
|
+
const CollectionType = IDL.Variant({Db: IDL.Null, Storage: IDL.Null});
|
|
52
52
|
const DelRule = IDL.Record({version: IDL.Opt(IDL.Nat64)});
|
|
53
53
|
const DepositCyclesArgs = IDL.Record({
|
|
54
54
|
cycles: IDL.Nat,
|
|
@@ -76,7 +76,8 @@ export const idlFactory = ({IDL}) => {
|
|
|
76
76
|
version: IDL.Opt(IDL.Nat64)
|
|
77
77
|
});
|
|
78
78
|
const AuthenticationConfigInternetIdentity = IDL.Record({
|
|
79
|
-
derivation_origin: IDL.Opt(IDL.Text)
|
|
79
|
+
derivation_origin: IDL.Opt(IDL.Text),
|
|
80
|
+
external_alternative_origins: IDL.Opt(IDL.Vec(IDL.Text))
|
|
80
81
|
});
|
|
81
82
|
const AuthenticationConfig = IDL.Record({
|
|
82
83
|
internet_identity: IDL.Opt(AuthenticationConfigInternetIdentity)
|
|
@@ -143,7 +144,8 @@ export const idlFactory = ({IDL}) => {
|
|
|
143
144
|
version: IDL.Opt(IDL.Nat64),
|
|
144
145
|
mutable_permissions: IDL.Opt(IDL.Bool),
|
|
145
146
|
rate_config: IDL.Opt(RateConfig),
|
|
146
|
-
write: Permission
|
|
147
|
+
write: Permission,
|
|
148
|
+
max_changes_per_user: IDL.Opt(IDL.Nat32)
|
|
147
149
|
});
|
|
148
150
|
const HttpRequest = IDL.Record({
|
|
149
151
|
url: IDL.Text,
|
|
@@ -229,7 +231,8 @@ export const idlFactory = ({IDL}) => {
|
|
|
229
231
|
version: IDL.Opt(IDL.Nat64),
|
|
230
232
|
mutable_permissions: IDL.Opt(IDL.Bool),
|
|
231
233
|
rate_config: IDL.Opt(RateConfig),
|
|
232
|
-
write: Permission
|
|
234
|
+
write: Permission,
|
|
235
|
+
max_changes_per_user: IDL.Opt(IDL.Nat32)
|
|
233
236
|
});
|
|
234
237
|
const UploadChunk = IDL.Record({
|
|
235
238
|
content: IDL.Vec(IDL.Nat8),
|
|
@@ -258,7 +261,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
258
261
|
del_filtered_docs: IDL.Func([IDL.Text, ListParams], [], []),
|
|
259
262
|
del_many_assets: IDL.Func([IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))], [], []),
|
|
260
263
|
del_many_docs: IDL.Func([IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text, DelDoc))], [], []),
|
|
261
|
-
del_rule: IDL.Func([
|
|
264
|
+
del_rule: IDL.Func([CollectionType, IDL.Text, DelRule], [], []),
|
|
262
265
|
deposit_cycles: IDL.Func([DepositCyclesArgs], [], []),
|
|
263
266
|
get_asset: IDL.Func([IDL.Text, IDL.Text], [IDL.Opt(AssetNoContent)], ['query']),
|
|
264
267
|
get_auth_config: IDL.Func([], [IDL.Opt(AuthenticationConfig)], ['query']),
|
|
@@ -275,7 +278,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
275
278
|
[IDL.Vec(IDL.Tuple(IDL.Text, IDL.Opt(Doc)))],
|
|
276
279
|
['query']
|
|
277
280
|
),
|
|
278
|
-
get_rule: IDL.Func([
|
|
281
|
+
get_rule: IDL.Func([CollectionType, IDL.Text], [IDL.Opt(Rule)], ['query']),
|
|
279
282
|
get_storage_config: IDL.Func([], [StorageConfig], ['query']),
|
|
280
283
|
http_request: IDL.Func([HttpRequest], [HttpResponse], ['query']),
|
|
281
284
|
http_request_streaming_callback: IDL.Func(
|
|
@@ -288,7 +291,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
288
291
|
list_controllers: IDL.Func([], [IDL.Vec(IDL.Tuple(IDL.Principal, Controller))], ['query']),
|
|
289
292
|
list_custom_domains: IDL.Func([], [IDL.Vec(IDL.Tuple(IDL.Text, CustomDomain))], ['query']),
|
|
290
293
|
list_docs: IDL.Func([IDL.Text, ListParams], [ListResults_1], ['query']),
|
|
291
|
-
list_rules: IDL.Func([
|
|
294
|
+
list_rules: IDL.Func([CollectionType], [IDL.Vec(IDL.Tuple(IDL.Text, Rule))], ['query']),
|
|
292
295
|
memory_size: IDL.Func([], [MemorySize], ['query']),
|
|
293
296
|
set_auth_config: IDL.Func([AuthenticationConfig], [], []),
|
|
294
297
|
set_controllers: IDL.Func(
|
|
@@ -304,7 +307,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
304
307
|
[IDL.Vec(IDL.Tuple(IDL.Text, Doc))],
|
|
305
308
|
[]
|
|
306
309
|
),
|
|
307
|
-
set_rule: IDL.Func([
|
|
310
|
+
set_rule: IDL.Func([CollectionType, IDL.Text, SetRule], [Rule], []),
|
|
308
311
|
set_storage_config: IDL.Func([StorageConfig], [], []),
|
|
309
312
|
upload_asset_chunk: IDL.Func([UploadChunk], [UploadChunkResult], []),
|
|
310
313
|
version: IDL.Func([], [IDL.Text], ['query'])
|
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 fE=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 dE=bd(),Xl=Ss(),Ql=yi(),Cs=xi(),Zp=Ya(),cr=Ut(),hE=Vt(),Hi=Oi(),pE=fE(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,hE.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]=yE(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,dE.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 yE(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(pE.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 gE=$i&&$i.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty($i,"__esModule",{value:!0});$i.createAssetCanisterActor=void 0;var mE=za(),bE=gE(Xp());function _E(t){return mE.Actor.createActor(bE.default,t)}$i.createAssetCanisterActor=_E});var Lp=ee($r=>{"use strict";var wE=$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]}),EE=$r&&$r.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),xE=$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)&&wE(e,t,r);return EE(e,t),e};Object.defineProperty($r,"__esModule",{value:!0});$r.fetchCandid=void 0;var vE=Ut(),TE=xE(Bs()),AE=zl(),SE=za();async function BE(t,e){e||(e=await AE.HttpAgent.create());let n=(await TE.request({agent:e,canisterId:vE.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 SE.Actor.createActor(i,{agent:e,canisterId:t}).__get_candid_interface_tmp_hack()}$r.fetchCandid=BE});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]}),OE=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 OE(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((i3,yy)=>{"use strict";var cf=Object.defineProperty,NE=Object.getOwnPropertyDescriptor,RE=Object.getOwnPropertyNames,PE=Object.prototype.hasOwnProperty,IE=(t,e)=>{for(var r in e)cf(t,r,{get:e[r],enumerable:!0})},UE=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of RE(e))!PE.call(t,i)&&i!==r&&cf(t,i,{get:()=>e[i],enumerable:!(n=NE(e,i))||n.enumerable});return t},FE=t=>UE(cf({},"__esModule",{value:!0}),t),iy={};IE(iy,{AgentManager:()=>KE,Canister:()=>VE,FromStringToTokenError:()=>sy,ICPToken:()=>jE,InvalidPercentageError:()=>fy,NullishError:()=>dy,TokenAmount:()=>kE,TokenAmountV2:()=>HE,arrayBufferToUint8Array:()=>JE,arrayOfNumberToUint8Array:()=>QE,asNonNullish:()=>YE,asciiStringToByteArray:()=>LE,assertNonNullish:()=>Ks,assertPercentageNumber:()=>WE,bigEndianCrc32:()=>ax,bigIntToUint8Array:()=>DE,candidNumberArrayToBigInt:()=>rx,convertStringToE8s:()=>oy,createAgent:()=>uy,createServices:()=>GE,debounce:()=>dx,decodeBase32:()=>ix,defaultAgent:()=>cy,encodeBase32:()=>nx,fromDefinedNullable:()=>px,fromNullable:()=>uf,fromNullishNullable:()=>yx,hexStringToUint8Array:()=>ex,isEmptyString:()=>$E,isNullish:()=>Da,jsonReplacer:()=>gx,jsonReviver:()=>mx,nonNullish:()=>Kr,notEmptyString:()=>ay,nowInBigIntNanoSeconds:()=>fx,numberToUint8Array:()=>ZE,principalToSubAccount:()=>bx,secondsToDuration:()=>ux,smallerVersion:()=>_x,toNullable:()=>hx,uint8ArrayToArrayOfNumber:()=>XE,uint8ArrayToBigInt:()=>zE,uint8ArrayToHexString:()=>tx});yy.exports=FE(iy);var sy=(t=>(t[t.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",t[t.InvalidFormat=1]="InvalidFormat",t[t.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",t))(sy||{}),ME=BigInt(1e8),CE=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)*ME}catch{return 1}if(i){if(i.length>8)return 0;try{s+=BigInt(i.padEnd(8,"0"))}catch{return 1}}return s},qE=({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},jE={symbol:"ICP",name:"Internet Computer",decimals:8},kE=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}},HE=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=qE({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(CE,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)}},VE=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!=="",$E=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}),KE=class ly{constructor(e){this.config=e,this.agents=void 0}static create(e){return new ly(e)}async getAgent({identity:e}){let r=e.getPrincipal().toText();if(Da(this.agents)||Da(this.agents[r])){let n=await uy({identity:e,fetchRootKey:this.config.fetchRootKey,host:this.config.host,verifyQuerySignatures:!0});return this.agents={...this.agents??{},[r]:n},n}return this.agents[r]}clearAgents(){this.agents=null}},GE=({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)},YE=(t,e)=>(Ks(t,e),t),WE=t=>{if(t<0||t>100)throw new fy(`${t} is not a valid percentage number.`)},zE=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}},DE=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)},ZE=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)},JE=t=>new Uint8Array(t),XE=t=>Array.from(t),QE=t=>new Uint8Array(t),LE=t=>Array.from(t).map(e=>e.charCodeAt(0)),ex=t=>{let e=t.match(/.{1,2}/g);return Ks(e,"Invalid hex string."),Uint8Array.from(e.map(r=>parseInt(r,16)))},tx=t=>(t instanceof Uint8Array||(t=Uint8Array.from(t)),t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")),rx=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 nx=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 ix(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 sx=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]),ox=t=>{let e=-1;for(let r=0;r<t.length;r++){let n=(t[r]^e)&255;e=sx[n]^e>>>8}return(e^-1)>>>0},ax=t=>{let e=new ArrayBuffer(4);return new DataView(e).setUint32(0,ox(t),!1),new Uint8Array(e)},cx={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"},ux=({seconds:t,i18n:e=cx})=>{let r=t/BigInt(60),n=r/BigInt(60);r-=n*BigInt(60);let i=n/BigInt(24);n-=i*BigInt(24);let s=lx(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(", ")},lx=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)}),fx=()=>BigInt(Date.now())*BigInt(1e6),dx=(t,e)=>{let r;return(...n)=>{let i=()=>t(...n);r&&clearTimeout(r),r=setTimeout(i,e!==void 0&&e>0?e:300)}},hx=t=>Kr(t)?[t]:[],uf=t=>t?.[0],px=t=>{let e=uf(t);return Ks(e),e},yx=t=>uf(t??[]),py=Ut(),sf="__bigint__",of="__principal__",af="__uint8array__",gx=(t,e)=>typeof e=="bigint"?{[sf]:`${e}`}:Kr(e)&&e instanceof py.Principal?{[of]:e.toText()}:Kr(e)&&e instanceof Uint8Array?{[af]:Array.from(e)}:e,mx=(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?py.Principal.fromText(r(of)):Kr(e)&&typeof e=="object"&&af in e?Uint8Array.from(r(af)):e},bx=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)},_x=({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 my=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 wx=Qt(),Lt=Qt(),Gs=kl();function gy(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(gy(e)){let r=e;if(gy(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,wx.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 _y=ee(ni=>{"use strict";Object.defineProperty(ni,"__esModule",{value:!0});ni.ECDSAKeyIdentity=ni.CryptoError=void 0;var Ex=Qt(),La=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};ni.CryptoError=La;function by(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 Ex.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=by(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=by(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 xx=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 vx=Ut(),df=class{constructor(e){In.set(this,void 0),xx(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 vx.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 wy=ee(De=>{"use strict";var Tx=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]}),Ax=De&&De.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Sx=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)&&Tx(e,t,r);return Ax(e,t),e},Bx=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},Ox=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)},Nx=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=Sx(ps()),Rx=hf(),Px=new TextEncoder().encode("ic-request-auth-delegation"),Ix=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 Ux(t,e,r,n){let i=new zs(e.toDer(),BigInt(+r)*BigInt(1e6),n),s=new Uint8Array([...Px,...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 Ux(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=Nx(e,["body"]),i=await(0,Fn.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...Ix,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};De.DelegationIdentity=mf;var bf=class t extends Rx.PartialIdentity{constructor(e,r){super(e),tc.set(this,void 0),Bx(this,tc,r,"f")}get delegation(){return Ox(this,tc,"f")}static fromDelegation(e,r){return new t(e,r)}};De.PartialDelegationIdentity=bf;tc=new WeakMap;function Fx(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=Fx});var Ey=ee(Mn=>{"use strict";var Mx=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=Mx(Vo()),Cx=kn(),qx=xi();function jx(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=jx(e)}toDer(){return this._encodedKey}getCose(){return this._cose}};Mn.CosePublicKey=rc;function Hx(t="<ic0.app>"){return typeof t=="string"?Uint8Array.from(t,e=>e.charCodeAt(0)):t}async function Vx(t){let e=await navigator.credentials.create(t??{publicKey:{authenticatorSelection:{userVerification:"preferred"},attestation:"direct",challenge:Hx(),pubKeyCredParams:[{type:"public-key",alg:wf.ECDSA_WITH_SHA256}],rp:{name:"Internet Identity Service"},user:{id:(0,Cx.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,qx.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 Vx(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 vy=ee(We=>{"use strict";var $x=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)&&$x(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 xy=my();Object.defineProperty(We,"Ed25519KeyIdentity",{enumerable:!0,get:function(){return xy.Ed25519KeyIdentity}});Object.defineProperty(We,"Ed25519PublicKey",{enumerable:!0,get:function(){return xy.Ed25519PublicKey}});vf(_y(),We);vf(wy(),We);vf(hf(),We);var Kx=Ey();Object.defineProperty(We,"WebAuthnIdentity",{enumerable:!0,get:function(){return Kx.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 Ty=["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),Ty.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);Ty.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 Yx(){return Ay||(Ay=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Wx(){return Sy||(Sy=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}function zx(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&&By.set(r,t)}).catch(()=>{}),Nf.set(e,t),e}function Dx(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 Ny(t){Of=t(Of)}function Zx(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(Ds(this),e,...r);return Oy.set(n,e.sort?e.sort():[e]),ur(n)}:Wx().includes(t)?function(...e){return t.apply(Ds(this),e),ur(By.get(this))}:function(...e){return ur(t.apply(Ds(this),e))}}function Jx(t){return typeof t=="function"?Zx(t):(t instanceof IDBTransaction&&Dx(t),Gx(t,Yx())?new Proxy(t,Of):t)}function ur(t){if(t instanceof IDBRequest)return zx(t);if(Sf.has(t))return Sf.get(t);let e=Jx(t);return e!==t&&(Sf.set(t,e),Nf.set(e,t)),e}var Gx,Ay,Sy,By,Bf,Oy,Sf,Nf,Of,Ds,Rf=Xf(()=>{Gx=(t,e)=>e.some(r=>t instanceof r);By=new WeakMap,Bf=new WeakMap,Oy=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||Oy.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 Py={};Lg(Py,{deleteDB:()=>Qx,openDB:()=>Xx,unwrap:()=>Ds,wrap:()=>ur});function Xx(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 Qx(t,{blocked:e}={}){let r=indexedDB.deleteDatabase(t);return e&&r.addEventListener("blocked",n=>e(n.oldVersion,n)),ur(r).then(()=>{})}function Ry(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=e8.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||Lx.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 Lx,e8,Pf,Iy=Xf(()=>{Rf();Rf();Lx=["get","getKey","getAll","getAllKeys","count"],e8=["put","add","delete","clear"],Pf=new Map;Ny(t=>({...t,get:(e,r,n)=>Ry(e,r)||t.get(e,r,n),has:(e,r)=>!!Ry(e,r)||t.has(e,r)}))});var Uf=ee(sc=>{"use strict";Object.defineProperty(sc,"__esModule",{value:!0});sc.IdbKeyVal=void 0;var t8=(Iy(),em(Py)),Zs=oc(),Uy="auth-client-db",Fy="ic-keyval",r8=async(t=Uy,e=Fy,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,t8.openDB)(t,r,{upgrade:n=>{n.objectStoreNames.contains(e)&&n.clear(e),n.createObjectStore(e)}}));async function n8(t,e,r){return await t.get(e,r)}async function i8(t,e,r,n){return await t.put(e,n,r)}async function s8(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=Uy,storeName:n=Fy,version:i=Zs.DB_VERSION}=e??{},s=await r8(r,n,i);return new t(s,n)}async set(e,r){return await i8(this._db,this._storeName,e,r)}async get(e){var r;return(r=await n8(this._db,this._storeName,e))!==null&&r!==void 0?r:null}async remove(e){return await s8(this._db,this._storeName,e)}};sc.IdbKeyVal=If});var oc=ee(nt=>{"use strict";var o8=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},a8=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 c8=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),o8(this,ac,e??{},"f")}get _db(){return new Promise(e=>{if(this.initializedDb){e(this.initializedDb);return}c8.IdbKeyVal.create(a8(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 u8=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]}),l8=Le&&Le.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&u8(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 My=Qt(),er=vy(),Cy=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 f8=Uf();Object.defineProperty(Le,"IdbKeyVal",{enumerable:!0,get:function(){return f8.IdbKeyVal}});var d8="https://identity.ic0.app",h8="#authorize",Cf="ECDSA",qf="Ed25519",p8=500;Le.ERROR_USER_INTERRUPT="UserInterrupt";l8(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 My.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=Cy.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=Cy.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())||d8);a.hash=h8,(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,p8))};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 My.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 Ug=Ze(mt(),1);var mg=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 yg=Ze(Hf(),1),gg=Ze(mt(),1);var qy=BigInt(144e11),jy=!1,ky={width:576,height:576},Hy={width:505,height:705},Vy="internetcomputer.org";var Js=Ze(mt(),1);var zi="http://127.0.0.1:5987",$y="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),Ky=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??Vy}`;let i=Yr.getInstance().get(),s=(0,Js.nonNullish)(i)&&(0,Js.nonNullish)(i?.internetIdentityId)?i.internetIdentityId:$y,{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(ky)},identityProvider:r()}}},Gy=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(Hy)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#e)}&applicationLogo=${encodeURI(this.#t)}`}}};var Wy=Ze(Qt(),1),hc=Ze(mt(),1);var Yy=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 Yy.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 Wy.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 zy=Ze(Hf(),1),_c=()=>zy.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 Dy=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 Ky(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 Jy=Ze(Ut(),1),it=Ze(mt(),1);var Zy=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:Zy(t.createdAt),updated_at:Zy(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"?Jy.Principal.fromText(n):n)});var Ly=Ze(mt(),1);var Xy=({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)}),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}),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}),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 Qy=({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=>tg({idlFactory:Xy,buildType:"stock",...t}),eg=({idlFactory:t,...e})=>tg({idlFactory:t,buildType:"extended",...e}),tg=async({satelliteId:t,container:e,...r})=>{let{satelliteId:n}=zf({satelliteId:t});(0,Ly.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 rg=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})},ng=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},ig=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})},sg=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},og=async({collection:t,doc:e,satellite:r})=>{let{del_doc:n}=await lt(r),{key:i}=e;return n(t,i,Wf(e))},ag=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)},cg=async({collection:t,filter:e,satellite:r})=>{let{del_filtered_docs:n}=await lt(r);return n(t,Cn(e))},ug=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 Dy({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)}},lg=async({collection:t,filter:e,satellite:r})=>{let{count_docs:n}=await lt(r);return n(t,Cn(e))};var fg=Ze(Qt(),1);var et=t=>t!==void 0?t:Ec()??new fg.AnonymousIdentity;var dg=async({satellite:t,...e})=>{let r=et(t?.identity);return await rg({...e,satellite:{...t,identity:r}})},M6=async({satellite:t,...e})=>{let r=et(t?.identity);return await ng({...e,satellite:{...t,identity:r}})},hg=async({satellite:t,...e})=>{let r=et(t?.identity);return await ig({...e,satellite:{...t,identity:r}})},C6=async({satellite:t,...e})=>{let r=et(t?.identity);return await sg({...e,satellite:{...t,identity:r}})},q6=async({satellite:t,...e})=>{let r=et(t?.identity);return await og({...e,satellite:{...t,identity:r}})},j6=async({satellite:t,...e})=>{let r=et(t?.identity);return await ag({...e,satellite:{...t,identity:r}})},k6=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await cg({...r,filter:e??{},satellite:{...t,identity:n}})},H6=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await ug({...r,filter:e??{},satellite:{...t,identity:n}})},V6=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await lg({...r,filter:e??{},satellite:{...t,identity:n}})};var pg=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=()=>dg({collection:"#user",key:r}),i=await n();if((0,Qs.nonNullish)(i))return i;try{return await y8({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}},y8=({userId:t,...e})=>hg({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 pg(t);on.getInstance().set(r)},g8=t=>new Promise(async(e,r)=>{if((0,gg.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===yg.ERROR_USER_INTERRUPT){r(new gc(i));return}r(new pc(i))},maxTimeToLive:t?.maxTimeToLive??qy,allowPinAuthentication:t?.allowPin??jy,...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(),m8=async()=>(Wr??await _c()).getIdentity();var bg=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,mg.isNullish)(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var _g=()=>{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()},wg=()=>{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 fT=async({idlFactory:t,satellite:e})=>{let r=et(e?.identity);return await eg({idlFactory:t,...e,identity:r})};var to=Ze(mt(),1);var eo=Ze(mt(),1);var Ls=Ze(mt(),1);var Eg=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 b8({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*b8({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=>_8(i)))}}var _8=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 xg=async({satellite:t,...e})=>{let r=await lt(t);await Eg({actor:r,asset:e,init_asset_upload:async i=>await r.init_asset_upload(i)})},vg=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)}},Tg=async({collection:t,satellite:e,filter:r})=>{let{count_assets:n}=await lt(e);return n(t,Cn(r))},Ag=async({collection:t,fullPath:e,satellite:r})=>(await lt(r)).del_asset(t,e),Sg=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)},Bg=async({collection:t,satellite:e,filter:r})=>{let{del_filtered_assets:n}=await lt(e);return n(t,Cn(r))},Og=async({collection:t,fullPath:e,satellite:r})=>{let{get_asset:n}=await lt(r);return(0,eo.fromNullable)(await n(t,e))},Ng=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 Rg=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var TT=t=>Pg(t),AT=t=>Pg({filename:t.data.name,...t}),Pg=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 xg({data:e,filename:d,collection:r,token:s,headers:n,fullPath:h,encoding:a,satellite:m,description:c}),{downloadUrl:Ig({satellite:m,assetKey:{fullPath:h,token:s}}),fullPath:h,name:d}},ST=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)},{items:i,...s}=await vg({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:Ig({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:Rg(K),total_length:E}}),{}),owner:d.toText(),created_at:u,updated_at:O}});return{items:o,assets:o,...s}},BT=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)};return await Tg({collection:t,satellite:n,filter:r??{}})},OT=({collection:t,fullPath:e,satellite:r})=>Ag({collection:t,fullPath:e,satellite:{...r,identity:et(r?.identity)}}),NT=({assets:t,satellite:e})=>Sg({assets:t,satellite:{...e,identity:et(e?.identity)}}),RT=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)};return await Bg({collection:t,satellite:n,filter:r??{}})},PT=async({satellite:t,...e})=>{let r=et(t?.identity);return await Og({...e,satellite:{...t,identity:r}})},IT=async({satellite:t,...e})=>{let r=et(t?.identity);return await Ng({...e,satellite:{...t,identity:r}})},Ig=({assetKey:{fullPath:t,token:e},satellite:r})=>{let n={...r,identity:et(r?.identity)};return`${Qy(n)}${t}${(0,to.nonNullish)(e)?`?token=${e}`:""}`};var w8=t=>{let e=t?.satelliteId??_g();(0,Ug.assertNonNullish)(e,"Satellite ID is not configured. Juno cannot be initialized.");let r=t?.container??wg();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:r}},kT=t=>E8(t),E8=async t=>{let e=w8(t);Yr.getInstance().set(e),await Zf();let r=e.workers?.auth!==void 0?bg(e.workers.auth):void 0;return[...r?[r]:[]]},HT=t=>on.getInstance().subscribe(t);export{mc as InitError,dc as InternetIdentityProvider,bc as ListError,Gy as NFIDProvider,pc as SignInError,yc as SignInInitError,gc as SignInUserInterruptError,HT as authSubscribe,BT as countAssets,V6 as countDocs,OT as deleteAsset,q6 as deleteDoc,RT as deleteFilteredAssets,k6 as deleteFilteredDocs,NT as deleteManyAssets,j6 as deleteManyDocs,Ig as downloadUrl,PT as getAsset,dg as getDoc,IT as getManyAssets,M6 as getManyDocs,fT as getSatelliteExtendedActor,kT as initJuno,E8 as initSatellite,ST as listAssets,H6 as listDocs,hg as setDoc,C6 as setManyDocs,g8 as signIn,Jf as signOut,m8 as unsafeIdentity,TT as uploadBlob,AT 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 Ux(t,e,r,n){let i=new zs(e.toDer(),BigInt(+r)*BigInt(1e6),n),s=new Uint8Array([...Px,...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 Ux(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=Nx(e,["body"]),i=await(0,Fn.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...Ix,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};De.DelegationIdentity=mf;var bf=class t extends Rx.PartialIdentity{constructor(e,r){super(e),tc.set(this,void 0),Bx(this,tc,r,"f")}get delegation(){return Ox(this,tc,"f")}static fromDelegation(e,r){return new t(e,r)}};De.PartialDelegationIdentity=bf;tc=new WeakMap;function Fx(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=Fx});var Ey=ee(Mn=>{"use strict";var Mx=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=Mx(Vo()),Cx=kn(),qx=xi();function jx(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=jx(e)}toDer(){return this._encodedKey}getCose(){return this._cose}};Mn.CosePublicKey=rc;function Hx(t="<ic0.app>"){return typeof t=="string"?Uint8Array.from(t,e=>e.charCodeAt(0)):t}async function Vx(t){let e=await navigator.credentials.create(t??{publicKey:{authenticatorSelection:{userVerification:"preferred"},attestation:"direct",challenge:Hx(),pubKeyCredParams:[{type:"public-key",alg:wf.ECDSA_WITH_SHA256}],rp:{name:"Internet Identity Service"},user:{id:(0,Cx.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,qx.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 Vx(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 vy=ee(We=>{"use strict";var $x=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)&&$x(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 xy=my();Object.defineProperty(We,"Ed25519KeyIdentity",{enumerable:!0,get:function(){return xy.Ed25519KeyIdentity}});Object.defineProperty(We,"Ed25519PublicKey",{enumerable:!0,get:function(){return xy.Ed25519PublicKey}});vf(_y(),We);vf(wy(),We);vf(hf(),We);var Kx=Ey();Object.defineProperty(We,"WebAuthnIdentity",{enumerable:!0,get:function(){return Kx.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 Ty=["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),Ty.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);Ty.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 Yx(){return Ay||(Ay=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Wx(){return Sy||(Sy=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}function zx(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&&By.set(r,t)}).catch(()=>{}),Nf.set(e,t),e}function Dx(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 Ny(t){Of=t(Of)}function Zx(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(Ds(this),e,...r);return Oy.set(n,e.sort?e.sort():[e]),ur(n)}:Wx().includes(t)?function(...e){return t.apply(Ds(this),e),ur(By.get(this))}:function(...e){return ur(t.apply(Ds(this),e))}}function Jx(t){return typeof t=="function"?Zx(t):(t instanceof IDBTransaction&&Dx(t),Gx(t,Yx())?new Proxy(t,Of):t)}function ur(t){if(t instanceof IDBRequest)return zx(t);if(Sf.has(t))return Sf.get(t);let e=Jx(t);return e!==t&&(Sf.set(t,e),Nf.set(e,t)),e}var Gx,Ay,Sy,By,Bf,Oy,Sf,Nf,Of,Ds,Rf=Xf(()=>{Gx=(t,e)=>e.some(r=>t instanceof r);By=new WeakMap,Bf=new WeakMap,Oy=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||Oy.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 Py={};Lg(Py,{deleteDB:()=>Qx,openDB:()=>Xx,unwrap:()=>Ds,wrap:()=>ur});function Xx(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 Qx(t,{blocked:e}={}){let r=indexedDB.deleteDatabase(t);return e&&r.addEventListener("blocked",n=>e(n.oldVersion,n)),ur(r).then(()=>{})}function Ry(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=e8.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||Lx.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 Lx,e8,Pf,Iy=Xf(()=>{Rf();Rf();Lx=["get","getKey","getAll","getAllKeys","count"],e8=["put","add","delete","clear"],Pf=new Map;Ny(t=>({...t,get:(e,r,n)=>Ry(e,r)||t.get(e,r,n),has:(e,r)=>!!Ry(e,r)||t.has(e,r)}))});var Uf=ee(sc=>{"use strict";Object.defineProperty(sc,"__esModule",{value:!0});sc.IdbKeyVal=void 0;var t8=(Iy(),em(Py)),Zs=oc(),Uy="auth-client-db",Fy="ic-keyval",r8=async(t=Uy,e=Fy,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,t8.openDB)(t,r,{upgrade:n=>{n.objectStoreNames.contains(e)&&n.clear(e),n.createObjectStore(e)}}));async function n8(t,e,r){return await t.get(e,r)}async function i8(t,e,r,n){return await t.put(e,n,r)}async function s8(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=Uy,storeName:n=Fy,version:i=Zs.DB_VERSION}=e??{},s=await r8(r,n,i);return new t(s,n)}async set(e,r){return await i8(this._db,this._storeName,e,r)}async get(e){var r;return(r=await n8(this._db,this._storeName,e))!==null&&r!==void 0?r:null}async remove(e){return await s8(this._db,this._storeName,e)}};sc.IdbKeyVal=If});var oc=ee(nt=>{"use strict";var o8=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},a8=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 c8=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),o8(this,ac,e??{},"f")}get _db(){return new Promise(e=>{if(this.initializedDb){e(this.initializedDb);return}c8.IdbKeyVal.create(a8(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 u8=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]}),l8=Le&&Le.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&u8(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 My=Qt(),er=vy(),Cy=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 f8=Uf();Object.defineProperty(Le,"IdbKeyVal",{enumerable:!0,get:function(){return f8.IdbKeyVal}});var d8="https://identity.ic0.app",h8="#authorize",Cf="ECDSA",qf="Ed25519",p8=500;Le.ERROR_USER_INTERRUPT="UserInterrupt";l8(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 My.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=Cy.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=Cy.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())||d8);a.hash=h8,(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,p8))};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 My.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 Ug=Ze(mt(),1);var mg=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 yg=Ze(Hf(),1),gg=Ze(mt(),1);var qy=BigInt(144e11),jy=!1,ky={width:576,height:576},Hy={width:505,height:705},Vy="internetcomputer.org";var Js=Ze(mt(),1);var zi="http://127.0.0.1:5987",$y="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),Ky=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??Vy}`;let i=Yr.getInstance().get(),s=(0,Js.nonNullish)(i)&&(0,Js.nonNullish)(i?.internetIdentityId)?i.internetIdentityId:$y,{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(ky)},identityProvider:r()}}},Gy=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(Hy)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#e)}&applicationLogo=${encodeURI(this.#t)}`}}};var Wy=Ze(Qt(),1),hc=Ze(mt(),1);var Yy=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 Yy.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 Wy.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 zy=Ze(Hf(),1),_c=()=>zy.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 Dy=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 Ky(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 Jy=Ze(Ut(),1),it=Ze(mt(),1);var Zy=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:Zy(t.createdAt),updated_at:Zy(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"?Jy.Principal.fromText(n):n)});var Ly=Ze(mt(),1);var Xy=({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 Qy=({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=>tg({idlFactory:Xy,buildType:"stock",...t}),eg=({idlFactory:t,...e})=>tg({idlFactory:t,buildType:"extended",...e}),tg=async({satelliteId:t,container:e,...r})=>{let{satelliteId:n}=zf({satelliteId:t});(0,Ly.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 rg=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})},ng=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},ig=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})},sg=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},og=async({collection:t,doc:e,satellite:r})=>{let{del_doc:n}=await lt(r),{key:i}=e;return n(t,i,Wf(e))},ag=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)},cg=async({collection:t,filter:e,satellite:r})=>{let{del_filtered_docs:n}=await lt(r);return n(t,Cn(e))},ug=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 Dy({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)}},lg=async({collection:t,filter:e,satellite:r})=>{let{count_docs:n}=await lt(r);return n(t,Cn(e))};var fg=Ze(Qt(),1);var et=t=>t!==void 0?t:Ec()??new fg.AnonymousIdentity;var dg=async({satellite:t,...e})=>{let r=et(t?.identity);return await rg({...e,satellite:{...t,identity:r}})},q6=async({satellite:t,...e})=>{let r=et(t?.identity);return await ng({...e,satellite:{...t,identity:r}})},hg=async({satellite:t,...e})=>{let r=et(t?.identity);return await ig({...e,satellite:{...t,identity:r}})},j6=async({satellite:t,...e})=>{let r=et(t?.identity);return await sg({...e,satellite:{...t,identity:r}})},k6=async({satellite:t,...e})=>{let r=et(t?.identity);return await og({...e,satellite:{...t,identity:r}})},H6=async({satellite:t,...e})=>{let r=et(t?.identity);return await ag({...e,satellite:{...t,identity:r}})},V6=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await cg({...r,filter:e??{},satellite:{...t,identity:n}})},$6=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await ug({...r,filter:e??{},satellite:{...t,identity:n}})},K6=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await lg({...r,filter:e??{},satellite:{...t,identity:n}})};var pg=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=()=>dg({collection:"#user",key:r}),i=await n();if((0,Qs.nonNullish)(i))return i;try{return await y8({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}},y8=({userId:t,...e})=>hg({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 pg(t);on.getInstance().set(r)},g8=t=>new Promise(async(e,r)=>{if((0,gg.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===yg.ERROR_USER_INTERRUPT){r(new gc(i));return}r(new pc(i))},maxTimeToLive:t?.maxTimeToLive??qy,allowPinAuthentication:t?.allowPin??jy,...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(),m8=async()=>(Wr??await _c()).getIdentity();var bg=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,mg.isNullish)(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var _g=()=>{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()},wg=()=>{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 hT=async({idlFactory:t,satellite:e})=>{let r=et(e?.identity);return await eg({idlFactory:t,...e,identity:r})};var to=Ze(mt(),1);var eo=Ze(mt(),1);var Ls=Ze(mt(),1);var Eg=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 b8({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*b8({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=>_8(i)))}}var _8=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 xg=async({satellite:t,...e})=>{let r=await lt(t);await Eg({actor:r,asset:e,init_asset_upload:async i=>await r.init_asset_upload(i)})},vg=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)}},Tg=async({collection:t,satellite:e,filter:r})=>{let{count_assets:n}=await lt(e);return n(t,Cn(r))},Ag=async({collection:t,fullPath:e,satellite:r})=>(await lt(r)).del_asset(t,e),Sg=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)},Bg=async({collection:t,satellite:e,filter:r})=>{let{del_filtered_assets:n}=await lt(e);return n(t,Cn(r))},Og=async({collection:t,fullPath:e,satellite:r})=>{let{get_asset:n}=await lt(r);return(0,eo.fromNullable)(await n(t,e))},Ng=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 Rg=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var ST=t=>Pg(t),BT=t=>Pg({filename:t.data.name,...t}),Pg=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 xg({data:e,filename:d,collection:r,token:s,headers:n,fullPath:h,encoding:a,satellite:m,description:c}),{downloadUrl:Ig({satellite:m,assetKey:{fullPath:h,token:s}}),fullPath:h,name:d}},OT=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)},{items:i,...s}=await vg({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:Ig({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:Rg(K),total_length:E}}),{}),owner:d.toText(),created_at:u,updated_at:O}});return{items:o,assets:o,...s}},NT=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)};return await Tg({collection:t,satellite:n,filter:r??{}})},RT=({collection:t,fullPath:e,satellite:r})=>Ag({collection:t,fullPath:e,satellite:{...r,identity:et(r?.identity)}}),PT=({assets:t,satellite:e})=>Sg({assets:t,satellite:{...e,identity:et(e?.identity)}}),IT=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)};return await Bg({collection:t,satellite:n,filter:r??{}})},UT=async({satellite:t,...e})=>{let r=et(t?.identity);return await Og({...e,satellite:{...t,identity:r}})},FT=async({satellite:t,...e})=>{let r=et(t?.identity);return await Ng({...e,satellite:{...t,identity:r}})},Ig=({assetKey:{fullPath:t,token:e},satellite:r})=>{let n={...r,identity:et(r?.identity)};return`${Qy(n)}${t}${(0,to.nonNullish)(e)?`?token=${e}`:""}`};var w8=t=>{let e=t?.satelliteId??_g();(0,Ug.assertNonNullish)(e,"Satellite ID is not configured. Juno cannot be initialized.");let r=t?.container??wg();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:r}},VT=t=>E8(t),E8=async t=>{let e=w8(t);Yr.getInstance().set(e),await Zf();let r=e.workers?.auth!==void 0?bg(e.workers.auth):void 0;return[...r?[r]:[]]},$T=t=>on.getInstance().subscribe(t);export{mc as InitError,dc as InternetIdentityProvider,bc as ListError,Gy as NFIDProvider,pc as SignInError,yc as SignInInitError,gc as SignInUserInterruptError,$T as authSubscribe,NT as countAssets,K6 as countDocs,RT as deleteAsset,k6 as deleteDoc,IT as deleteFilteredAssets,V6 as deleteFilteredDocs,PT as deleteManyAssets,H6 as deleteManyDocs,Ig as downloadUrl,UT as getAsset,dg as getDoc,FT as getManyAssets,q6 as getManyDocs,hT as getSatelliteExtendedActor,VT as initJuno,E8 as initSatellite,OT as listAssets,$6 as listDocs,hg as setDoc,j6 as setManyDocs,g8 as signIn,Jf as signOut,m8 as unsafeIdentity,ST as uploadBlob,BT as uploadFile};
|
|
58
58
|
/*! Bundled license information:
|
|
59
59
|
|
|
60
60
|
ieee754/index.js:
|