@junobuild/core-peer 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{assertNonNullish as Pr}from"@dfinity/utils";import{isNullish as Rr}from"@dfinity/utils";var q=class{callbacks=[];populate(a){this.callbacks.forEach(({callback:r})=>r(a))}subscribe(a){let r=Symbol();return this.callbacks.push({id:r,callback:a}),()=>this.callbacks=this.callbacks.filter(({id:o})=>o!==r)}};var R=class e extends q{static instance;authUser=null;constructor(){super()}static getInstance(){return e.instance||(e.instance=new e),e.instance}set(a){this.authUser=a,this.populate(a)}get(){return this.authUser}subscribe(a){let r=super.subscribe(a);return a(this.authUser),r}reset(){this.authUser=null,this.populate(this.authUser)}};var Be=({message:e,detail:a})=>{let r=new CustomEvent(e,{detail:a,bubbles:!0});document.dispatchEvent(r)};import{ERROR_USER_INTERRUPT as Tr}from"@dfinity/auth-client";import{isNullish as Ca}from"@dfinity/utils";var aa=BigInt(144e11),ra=!1,oa={width:576,height:576},ca={width:505,height:705},ia="internetcomputer.org";import{isNullish as ar,nonNullish as la}from"@dfinity/utils";var M="http://127.0.0.1:5987",na="rdmx6-jaaaa-aaaaa-aaadq-cai";var y=class e extends q{static instance;env;constructor(){super()}static getInstance(){return e.instance||(e.instance=new e),e.instance}set(a){this.env=a,this.populate(a)}get(){return this.env}reset(){this.env=null}subscribe(a){let r=super.subscribe(a);return a(this.env),r}};import{isNullish as ta}from"@dfinity/utils";import{jsonReplacer as Za,jsonReviver as er}from"@dfinity/utils";var sa=async e=>{let a=new Blob([JSON.stringify(e,Za)],{type:"application/json; charset=utf-8"});return new Uint8Array(await a.arrayBuffer())},ce=async e=>{let a=new Blob([e instanceof Uint8Array?e:new Uint8Array(e)],{type:"application/json; charset=utf-8"});return JSON.parse(await a.text(),er)},ie=()=>typeof window<"u";var Je=({width:e,height:a})=>{if(!ie()||ta(window)||ta(window.top))return;let{top:{innerWidth:r,innerHeight:o}}=window,c=o/2+screenY-a/2,i=r/2+screenX-e/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${e}, height=${a}, top=${c}, left=${i}`};var ne=class{#e;constructor({domain:a}){this.#e=a}get id(){return"internet_identity"}signInOptions({windowed:a}){let r=()=>{let o=y.getInstance().get()?.container;if(ar(o)||o===!1)return`https://identity.${this.#e??ia}`;let c=y.getInstance().get(),i=la(c)&&la(c?.internetIdentityId)?c.internetIdentityId:na,{host:n,protocol:s}=new URL(o===!0?M:o);return/apple/i.test(navigator?.vendor)?`${s}//${n}?canisterId=${i}`:`${s}//${i}.${n.replace("127.0.0.1","localhost")}`};return{...a!==!1&&{windowOpenerFeatures:Je(oa)},identityProvider:r()}}},pa=class{#e;#a;constructor({appName:a,logoUrl:r}){this.#e=a,this.#a=r}get id(){return"nfid"}signInOptions({windowed:a}){return{...a!==!1&&{windowOpenerFeatures:Je(ca)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#e)}&applicationLogo=${encodeURI(this.#a)}`}}};import{Actor as or}from"@dfinity/agent";import{isNullish as Ke}from"@dfinity/utils";import{isNullish as ze}from"@dfinity/utils";import{HttpAgent as rr}from"@dfinity/agent";import{nonNullish as da}from"@dfinity/utils";var _a=async({identity:e,container:a})=>{let o=da(a)&&a!==!1?a===!0?M:a:"https://icp-api.io",c=da(a);return await rr.create({identity:e,shouldFetchRootKey:c,host:o})};var j=class e{static instance;#e=void 0;constructor(){}static getInstance(){return ze(e.instance)&&(e.instance=new e),e.instance}async getAgent({identity:a,...r}){let o=a.getPrincipal().toText();if(ze(this.#e)||ze(this.#e[o])){let c=await _a({identity:a,...r});return this.#e={...this.#e??{},[o]:c},c}return this.#e[o]}reset(){this.#e=null}};var B=class e{static instance;#e=void 0;constructor(){}static getInstance(){return Ke(e.instance)&&(e.instance=new e),e.instance}async getActor({satelliteId:a,identity:r,actorKey:o,...c}){let i=`${o}#${r.getPrincipal().toText()}#${a};`;if(Ke(this.#e)||Ke(this.#e[i])){let n=await this.createActor({satelliteId:a,identity:r,...c});return this.#e={...this.#e??{},[i]:n},n}return this.#e[i]}reset(){this.#e=null}async createActor({idlFactory:a,satelliteId:r,...o}){let c=await j.getInstance().getAgent(o);return or.createActor(a,{agent:c,canisterId:r})}};var se=class extends Error{},te=class extends Error{},le=class extends Error{},pe=class extends Error{},de=class extends Error{};import{AuthClient as cr}from"@dfinity/auth-client";var _e=()=>cr.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});import{isNullish as _r,nonNullish as wa}from"@dfinity/utils";var Ge=({error:e,type:a})=>typeof e=="string"?e.includes(a):e instanceof Error?e.message.includes(a):!1;var ua="juno.datastore.error.user.cannot_update";import{fromNullable as z,isNullish as tr,nonNullish as lr}from"@dfinity/utils";var Ta=async({data:e})=>{try{return await ce(e)}catch(a){console.error("The data parsing has failed, mapping to undefined as a fallback.",a);return}};import{fromNullable as Na,toNullable as He}from"@dfinity/utils";var We=async e=>{let{data:a,version:r,description:o}=e;return{description:He(o),data:await sa(a),version:He(r)}},$e=e=>{let{version:a}=e;return{version:He(a)}},re=async({doc:e,key:a})=>{let{owner:r,version:o,description:c,data:i,...n}=e;return{key:a,description:Na(c),owner:r.toText(),data:await ce(i),version:Na(o),...n}};import{Principal as ir}from"@dfinity/principal";import{isNullish as J,toNullable as N}from"@dfinity/utils";var ma=e=>{if(J(e))return N();switch(e.matcher){case"equal":return N({Equal:e.timestamp});case"greaterThan":return N({GreaterThan:e.timestamp});case"lessThan":return N({LessThan:e.timestamp});case"between":return N({Between:[e.timestamps.start,e.timestamps.end]});default:throw new de("Invalid list matcher for timestamp",e)}},A=({matcher:e,paginate:a,order:r,owner:o})=>({matcher:J(e)?[]:[{key:N(e.key),description:N(e.description),created_at:ma(e.createdAt),updated_at:ma(e.updatedAt)}],paginate:N(J(a)?void 0:{start_after:N(a.startAfter),limit:N(J(a.limit)?void 0:BigInt(a.limit))}),order:N(J(r)?void 0:{desc:r.desc,field:r.field==="created_at"?{CreatedAt:null}:r.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:N(J(o)?void 0:typeof o=="string"?ir.fromText(o):o)});import{assertNonNullish as sr}from"@dfinity/utils";import{Actor as Fo}from"@dfinity/agent";import"@dfinity/agent";import"@dfinity/agent";import"@dfinity/principal";import{HttpAgent as Io}from"@dfinity/agent";import{Principal as ko}from"@dfinity/principal";var nr=(e=>(e[e.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",e[e.InvalidFormat=1]="InvalidFormat",e[e.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",e))(nr||{}),bo=BigInt(1e8);var Oa="abcdefghijklmnopqrstuvwxyz234567",oe=Object.create(null);for(let e=0;e<Oa.length;e++)oe[Oa[e]]=e;oe[0]=oe.o;oe[1]=oe.i;var Do=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]);var xa=({IDL:e})=>{let a=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Record({sha256:e.Vec(e.Nat8),proposal_id:e.Nat}),o=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),c=e.Record({field:o,desc:e.Bool}),i=e.Variant({Equal:e.Nat64,Between:e.Tuple(e.Nat64,e.Nat64),GreaterThan:e.Nat64,LessThan:e.Nat64}),n=e.Record({key:e.Opt(e.Text),updated_at:e.Opt(i),description:e.Opt(e.Text),created_at:e.Opt(i)}),s=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),t=e.Record({order:e.Opt(c),owner:e.Opt(e.Principal),matcher:e.Opt(n),paginate:e.Opt(s)}),O=e.Record({controllers:e.Vec(e.Principal)}),d=e.Variant({Write:e.Null,Admin:e.Null,Submit:e.Null}),_=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:d,expires_at:e.Opt(e.Nat64)}),T=e.Record({version:e.Opt(e.Nat64)}),u=e.Variant({Db:e.Null,Storage:e.Null}),E=e.Record({version:e.Opt(e.Nat64)}),v=e.Record({proposal_ids:e.Vec(e.Nat)}),b=e.Record({cycles:e.Nat,destination_id:e.Principal}),L=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,description:e.Opt(e.Text),full_path:e.Text}),K=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),F=e.Record({key:L,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,K)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),D=e.Record({derivation_origin:e.Opt(e.Text),external_alternative_origins:e.Opt(e.Vec(e.Text))}),S=e.Record({allowed_callers:e.Vec(e.Principal)}),f=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),internet_identity:e.Opt(D),rules:e.Opt(S)}),h=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),I=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(h)}),G=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),H=e.Variant({Deny:e.Null,Allow:e.Null}),W=e.Record({status_code:e.Nat16,location:e.Text}),w=e.Record({iframe:e.Opt(G),updated_at:e.Opt(e.Nat64),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(h),raw_access:e.Opt(H),redirects:e.Opt(e.Vec(e.Tuple(e.Text,W)))}),me=e.Record({db:e.Opt(I),authentication:e.Opt(f),storage:w}),x=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),description:e.Opt(e.Text),created_at:e.Nat64,version:e.Opt(e.Nat64)}),Oe=e.Variant({Initialized:e.Null,Failed:e.Null,Open:e.Null,Rejected:e.Null,Executed:e.Null,Accepted:e.Null}),xe=e.Record({clear_existing_assets:e.Opt(e.Bool)}),Re=e.Record({orbiter:e.Opt(e.Text),mission_control_version:e.Opt(e.Text),satellite_version:e.Opt(e.Text)}),$=e.Variant({AssetsUpgrade:xe,SegmentsDeployment:Re}),V=e.Record({status:Oe,updated_at:e.Nat64,sha256:e.Opt(e.Vec(e.Nat8)),executed_at:e.Opt(e.Nat64),owner:e.Principal,created_at:e.Nat64,version:e.Opt(e.Nat64),proposal_type:$}),k=e.Variant({Heap:e.Null,Stable:e.Null}),P=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),Y=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),C=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(k),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:P,created_at:e.Nat64,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(Y),write:P,max_changes_per_user:e.Opt(e.Nat32)}),ye=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),certificate_version:e.Opt(e.Nat16)}),U=e.Record({memory:k,token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),ge=e.Variant({Callback:e.Record({token:U,callback:e.Func([],[],["query"])})}),Fe=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(ge),status_code:e.Nat16}),fe=e.Record({token:e.Opt(U),body:e.Vec(e.Nat8)}),X=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,description:e.Opt(e.Text),encoding_type:e.Opt(e.Text),full_path:e.Text}),Q=e.Record({batch_id:e.Nat}),he=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,F)),items_length:e.Nat64}),Ve=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),Pe=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,x)),items_length:e.Nat64}),Ae=e.Record({desc:e.Bool}),Ee=e.Record({start_after:e.Opt(e.Nat),limit:e.Opt(e.Nat)}),ve=e.Record({order:e.Opt(Ae),paginate:e.Opt(Ee)}),be=e.Record({proposal_id:e.Nat}),De=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(be,V)),items_length:e.Nat64}),Se=e.Record({include_system:e.Bool}),Ie=e.Record({matcher:e.Opt(Se)}),we=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(e.Text,C)),items_length:e.Nat64}),ke=e.Record({stable:e.Nat64,heap:e.Nat64}),Ce=e.Record({version:e.Opt(e.Nat64),internet_identity:e.Opt(D),rules:e.Opt(S)}),Ue=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:d,expires_at:e.Opt(e.Nat64)}),Le=e.Record({controller:Ue,controllers:e.Vec(e.Principal)}),qe=e.Record({version:e.Opt(e.Nat64),max_memory_size:e.Opt(h)}),Z=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),Me=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(k),max_size:e.Opt(e.Nat),read:P,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(Y),write:P,max_changes_per_user:e.Opt(e.Nat32)}),je=e.Record({iframe:e.Opt(G),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),version:e.Opt(e.Nat64),max_memory_size:e.Opt(h),raw_access:e.Opt(H),redirects:e.Opt(e.Vec(e.Tuple(e.Text,W)))}),ee=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),ae=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([a],[],[]),commit_proposal:e.Func([r],[e.Null],[]),commit_proposal_asset_upload:e.Func([a],[],[]),count_assets:e.Func([e.Text,t],[e.Nat64],["query"]),count_collection_assets:e.Func([e.Text],[e.Nat64],["query"]),count_collection_docs:e.Func([e.Text],[e.Nat64],["query"]),count_docs:e.Func([e.Text,t],[e.Nat64],["query"]),count_proposals:e.Func([],[e.Nat64],["query"]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Text],[],[]),del_controllers:e.Func([O],[e.Vec(e.Tuple(e.Principal,_))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,T],[],[]),del_docs:e.Func([e.Text],[],[]),del_filtered_assets:e.Func([e.Text,t],[],[]),del_filtered_docs:e.Func([e.Text,t],[],[]),del_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[],[]),del_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,T))],[],[]),del_rule:e.Func([u,e.Text,E],[],[]),delete_proposal_assets:e.Func([v],[],[]),deposit_cycles:e.Func([b],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(F)],["query"]),get_auth_config:e.Func([],[e.Opt(f)],["query"]),get_config:e.Func([],[me],[]),get_db_config:e.Func([],[e.Opt(I)],["query"]),get_doc:e.Func([e.Text,e.Text],[e.Opt(x)],["query"]),get_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(F)))],["query"]),get_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(x)))],["query"]),get_proposal:e.Func([e.Nat],[e.Opt(V)],["query"]),get_rule:e.Func([u,e.Text],[e.Opt(C)],["query"]),get_storage_config:e.Func([],[w],["query"]),http_request:e.Func([ye],[Fe],["query"]),http_request_streaming_callback:e.Func([U],[fe],["query"]),init_asset_upload:e.Func([X],[Q],[]),init_proposal:e.Func([$],[e.Nat,V],[]),init_proposal_asset_upload:e.Func([X,e.Nat],[Q],[]),list_assets:e.Func([e.Text,t],[he],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,_))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,Ve))],["query"]),list_docs:e.Func([e.Text,t],[Pe],["query"]),list_proposals:e.Func([ve],[De],["query"]),list_rules:e.Func([u,Ie],[we],["query"]),memory_size:e.Func([],[ke],["query"]),reject_proposal:e.Func([r],[e.Null],[]),set_auth_config:e.Func([Ce],[f],[]),set_controllers:e.Func([Le],[e.Vec(e.Tuple(e.Principal,_))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_db_config:e.Func([qe],[I],[]),set_doc:e.Func([e.Text,e.Text,Z],[x],[]),set_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,Z))],[e.Vec(e.Tuple(e.Text,x))],[]),set_rule:e.Func([u,e.Text,Me],[C],[]),set_storage_config:e.Func([je],[w],[]),submit_proposal:e.Func([e.Nat],[e.Nat,V],[]),upload_asset_chunk:e.Func([ee],[ae],[]),upload_proposal_asset_chunk:e.Func([ee],[ae],[])})},Ra=({IDL:e})=>{let a=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Record({sha256:e.Vec(e.Nat8),proposal_id:e.Nat}),o=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),c=e.Record({field:o,desc:e.Bool}),i=e.Variant({Equal:e.Nat64,Between:e.Tuple(e.Nat64,e.Nat64),GreaterThan:e.Nat64,LessThan:e.Nat64}),n=e.Record({key:e.Opt(e.Text),updated_at:e.Opt(i),description:e.Opt(e.Text),created_at:e.Opt(i)}),s=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),t=e.Record({order:e.Opt(c),owner:e.Opt(e.Principal),matcher:e.Opt(n),paginate:e.Opt(s)}),O=e.Record({controllers:e.Vec(e.Principal)}),d=e.Variant({Write:e.Null,Admin:e.Null,Submit:e.Null}),_=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:d,expires_at:e.Opt(e.Nat64)}),T=e.Record({version:e.Opt(e.Nat64)}),u=e.Variant({Db:e.Null,Storage:e.Null}),E=e.Record({version:e.Opt(e.Nat64)}),v=e.Record({proposal_ids:e.Vec(e.Nat)}),b=e.Record({cycles:e.Nat,destination_id:e.Principal}),L=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,description:e.Opt(e.Text),full_path:e.Text}),K=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),F=e.Record({key:L,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,K)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),D=e.Record({derivation_origin:e.Opt(e.Text),external_alternative_origins:e.Opt(e.Vec(e.Text))}),S=e.Record({allowed_callers:e.Vec(e.Principal)}),f=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),internet_identity:e.Opt(D),rules:e.Opt(S)}),h=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),I=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(h)}),G=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),H=e.Variant({Deny:e.Null,Allow:e.Null}),W=e.Record({status_code:e.Nat16,location:e.Text}),w=e.Record({iframe:e.Opt(G),updated_at:e.Opt(e.Nat64),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(h),raw_access:e.Opt(H),redirects:e.Opt(e.Vec(e.Tuple(e.Text,W)))}),me=e.Record({db:e.Opt(I),authentication:e.Opt(f),storage:w}),x=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),description:e.Opt(e.Text),created_at:e.Nat64,version:e.Opt(e.Nat64)}),Oe=e.Variant({Initialized:e.Null,Failed:e.Null,Open:e.Null,Rejected:e.Null,Executed:e.Null,Accepted:e.Null}),xe=e.Record({clear_existing_assets:e.Opt(e.Bool)}),Re=e.Record({orbiter:e.Opt(e.Text),mission_control_version:e.Opt(e.Text),satellite_version:e.Opt(e.Text)}),$=e.Variant({AssetsUpgrade:xe,SegmentsDeployment:Re}),V=e.Record({status:Oe,updated_at:e.Nat64,sha256:e.Opt(e.Vec(e.Nat8)),executed_at:e.Opt(e.Nat64),owner:e.Principal,created_at:e.Nat64,version:e.Opt(e.Nat64),proposal_type:$}),k=e.Variant({Heap:e.Null,Stable:e.Null}),P=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),Y=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),C=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(k),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:P,created_at:e.Nat64,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(Y),write:P,max_changes_per_user:e.Opt(e.Nat32)}),ye=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),certificate_version:e.Opt(e.Nat16)}),U=e.Record({memory:k,token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),ge=e.Variant({Callback:e.Record({token:U,callback:e.Func([],[],[])})}),Fe=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(ge),status_code:e.Nat16}),fe=e.Record({token:e.Opt(U),body:e.Vec(e.Nat8)}),X=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,description:e.Opt(e.Text),encoding_type:e.Opt(e.Text),full_path:e.Text}),Q=e.Record({batch_id:e.Nat}),he=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,F)),items_length:e.Nat64}),Ve=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),Pe=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,x)),items_length:e.Nat64}),Ae=e.Record({desc:e.Bool}),Ee=e.Record({start_after:e.Opt(e.Nat),limit:e.Opt(e.Nat)}),ve=e.Record({order:e.Opt(Ae),paginate:e.Opt(Ee)}),be=e.Record({proposal_id:e.Nat}),De=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(be,V)),items_length:e.Nat64}),Se=e.Record({include_system:e.Bool}),Ie=e.Record({matcher:e.Opt(Se)}),we=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(e.Text,C)),items_length:e.Nat64}),ke=e.Record({stable:e.Nat64,heap:e.Nat64}),Ce=e.Record({version:e.Opt(e.Nat64),internet_identity:e.Opt(D),rules:e.Opt(S)}),Ue=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:d,expires_at:e.Opt(e.Nat64)}),Le=e.Record({controller:Ue,controllers:e.Vec(e.Principal)}),qe=e.Record({version:e.Opt(e.Nat64),max_memory_size:e.Opt(h)}),Z=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),Me=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(k),max_size:e.Opt(e.Nat),read:P,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(Y),write:P,max_changes_per_user:e.Opt(e.Nat32)}),je=e.Record({iframe:e.Opt(G),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),version:e.Opt(e.Nat64),max_memory_size:e.Opt(h),raw_access:e.Opt(H),redirects:e.Opt(e.Vec(e.Tuple(e.Text,W)))}),ee=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),ae=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([a],[],[]),commit_proposal:e.Func([r],[e.Null],[]),commit_proposal_asset_upload:e.Func([a],[],[]),count_assets:e.Func([e.Text,t],[e.Nat64],[]),count_collection_assets:e.Func([e.Text],[e.Nat64],[]),count_collection_docs:e.Func([e.Text],[e.Nat64],[]),count_docs:e.Func([e.Text,t],[e.Nat64],[]),count_proposals:e.Func([],[e.Nat64],[]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Text],[],[]),del_controllers:e.Func([O],[e.Vec(e.Tuple(e.Principal,_))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,T],[],[]),del_docs:e.Func([e.Text],[],[]),del_filtered_assets:e.Func([e.Text,t],[],[]),del_filtered_docs:e.Func([e.Text,t],[],[]),del_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[],[]),del_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,T))],[],[]),del_rule:e.Func([u,e.Text,E],[],[]),delete_proposal_assets:e.Func([v],[],[]),deposit_cycles:e.Func([b],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(F)],[]),get_auth_config:e.Func([],[e.Opt(f)],[]),get_config:e.Func([],[me],[]),get_db_config:e.Func([],[e.Opt(I)],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(x)],[]),get_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(F)))],[]),get_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(x)))],[]),get_proposal:e.Func([e.Nat],[e.Opt(V)],[]),get_rule:e.Func([u,e.Text],[e.Opt(C)],[]),get_storage_config:e.Func([],[w],[]),http_request:e.Func([ye],[Fe],[]),http_request_streaming_callback:e.Func([U],[fe],[]),init_asset_upload:e.Func([X],[Q],[]),init_proposal:e.Func([$],[e.Nat,V],[]),init_proposal_asset_upload:e.Func([X,e.Nat],[Q],[]),list_assets:e.Func([e.Text,t],[he],[]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,_))],[]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,Ve))],[]),list_docs:e.Func([e.Text,t],[Pe],[]),list_proposals:e.Func([ve],[De],[]),list_rules:e.Func([u,Ie],[we],[]),memory_size:e.Func([],[ke],[]),reject_proposal:e.Func([r],[e.Null],[]),set_auth_config:e.Func([Ce],[f],[]),set_controllers:e.Func([Le],[e.Vec(e.Tuple(e.Principal,_))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_db_config:e.Func([qe],[I],[]),set_doc:e.Func([e.Text,e.Text,Z],[x],[]),set_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,Z))],[e.Vec(e.Tuple(e.Text,x))],[]),set_rule:e.Func([u,e.Text,Me],[C],[]),set_storage_config:e.Func([je],[w],[]),submit_proposal:e.Func([e.Nat],[e.Nat,V],[]),upload_asset_chunk:e.Func([ee],[ae],[]),upload_proposal_asset_chunk:e.Func([ee],[ae],[])})};import{nonNullish as Ye}from"@dfinity/utils";var ya=({satelliteId:e,container:a})=>{let{satelliteId:r}=Xe({satelliteId:e}),{container:o}=Qe({container:a});if(Ye(o)&&o!==!1){let{host:c,protocol:i}=new URL(o===!0?M:o);return`${i}//${r??"unknown"}.${c.replace("127.0.0.1","localhost")}`}return`https://${r??"unknown"}.icp0.io`},Xe=({satelliteId:e})=>Ye(e)?{satelliteId:e}:y.getInstance().get()??{satelliteId:void 0},Qe=({container:e})=>Ye(e)?{container:e}:y.getInstance().get()??{container:void 0};var p=({satellite:e,options:{certified:a}})=>Fa({idlFactory:a?Ra:xa,actorKey:`stock#${a?"update":"query"}`,...e}),ga=({idlFactory:e,...a})=>Fa({idlFactory:e,actorKey:"extended#query",...a}),Fa=async({satelliteId:e,container:a,...r})=>{let{satelliteId:o}=Xe({satelliteId:e});sr(o,"No satellite ID defined. Did you initialize Juno?");let{container:c}=Qe({container:a});return await B.getInstance().getActor({satelliteId:o,container:c,...r})};var fa=async({collection:e,key:a,...r})=>{let{get_doc:o}=await p(r),c=z(await o(e,a));if(!tr(c))return re({doc:c,key:a})},ha=async({docs:e,...a})=>{let{get_many_docs:r}=await p(a),o=e.map(({collection:n,key:s})=>[n,s]),c=await r(o),i=[];for(let[n,s]of c){let t=z(s);i.push(lr(t)?await re({key:n,doc:t}):void 0)}return i},Va=async({collection:e,doc:a,...r})=>{let{set_doc:o}=await p(r),{key:c}=a,i=await We(a),n=await o(e,c,i);return await re({key:c,doc:n})},Pa=async({docs:e,...a})=>{let{set_many_docs:r}=await p(a),o=[];for(let{collection:n,doc:s}of e){let{key:t}=s;o.push([n,t,await We(s)])}let c=await r(o),i=[];for(let[n,s]of c)i.push(await re({key:n,doc:s}));return i},Aa=async({collection:e,doc:a,...r})=>{let{del_doc:o}=await p(r),{key:c}=a;return o(e,c,$e(a))},Ea=async({docs:e,...a})=>{let{del_many_docs:r}=await p(a),o=e.map(({collection:c,doc:i})=>[c,i.key,$e(i)]);await r(o)},va=async({collection:e,filter:a,...r})=>{let{del_filtered_docs:o}=await p(r);return o(e,A(a))},ba=async({collection:e,filter:a,...r})=>{let{list_docs:o}=await p(r),{items:c,items_page:i,items_length:n,matches_length:s,matches_pages:t}=await o(e,A(a)),O=[];for(let[d,_]of c){let{data:T,owner:u,description:E,version:v,...b}=_;O.push({key:d,description:z(E),owner:u.toText(),data:await Ta({data:T}),version:z(v),...b})}return{items:O,items_length:n,items_page:z(i),matches_length:s,matches_pages:z(t)}},Da=async({collection:e,filter:a,...r})=>{let{count_docs:o}=await p(r);return o(e,A(a))};var g={certified:!1};import{AnonymousIdentity as pr}from"@dfinity/agent";import{nonNullish as dr}from"@dfinity/utils";var l=e=>dr(e)?e:ue()??new pr;var Sa=async({satellite:e,options:a,...r})=>{let o=l(e?.identity);return await fa({...r,satellite:{...e,identity:o},options:a??g})},nc=async({satellite:e,options:a,...r})=>{let o=l(e?.identity);return await ha({...r,satellite:{...e,identity:o},options:a??g})},Ia=async({satellite:e,...a})=>{let r=l(e?.identity);return await Va({...a,satellite:{...e,identity:r},options:{certified:!0}})},sc=async({satellite:e,...a})=>{let r=l(e?.identity);return await Pa({...a,satellite:{...e,identity:r},options:{certified:!0}})},tc=async({satellite:e,...a})=>{let r=l(e?.identity);return await Aa({...a,satellite:{...e,identity:r},options:{certified:!0}})},lc=async({satellite:e,...a})=>{let r=l(e?.identity);return await Ea({...a,satellite:{...e,identity:r},options:{certified:!0}})},pc=async({satellite:e,filter:a,...r})=>{let o=l(e?.identity);return await va({...r,filter:a??{},satellite:{...e,identity:o},options:{certified:!0}})},dc=async({satellite:e,options:a,filter:r,...o})=>{let c=l(e?.identity);return await ba({...o,filter:r??{},satellite:{...e,identity:c},options:a??g})},_c=async({satellite:e,options:a,filter:r,...o})=>{let c=l(e?.identity);return await Da({...o,filter:r??{},satellite:{...e,identity:c},options:a??g})};var ka=async e=>{let a=ue();if(_r(a))throw new pe("No identity to initialize the user. Have you initialized Juno?");let r=a.getPrincipal().toText(),o=()=>Sa({collection:"#user",key:r}),c=await o();if(wa(c))return c;try{return await ur({userId:r,provider:e})}catch(i){if(Ge({error:i,type:ua})){let n=await o();if(wa(n))return n}throw i}},ur=({userId:e,...a})=>Ia({collection:"#user",doc:{key:e,data:a}});var m,Ze=async e=>{if(m=m??await _e(),!(await m?.isAuthenticated()??!1))return;let r=await ka(e);R.getInstance().set(r)},Nr=e=>new Promise(async(a,r)=>{if(Ca(m)){r(new te("No client is ready to perform a sign-in. Have you initialized the Satellite?"));return}let o=e?.provider??new ne({});await m.login({onSuccess:async()=>{await Ze(o.id),a()},onError:c=>{if(c===Tr){r(new le(c));return}r(new se(c))},maxTimeToLive:e?.maxTimeToLive??aa,allowPinAuthentication:e?.allowPin??ra,...e?.derivationOrigin!==void 0&&{derivationOrigin:e.derivationOrigin},...o.signInOptions({windowed:e?.windowed})})}),ea=async()=>{await mr(),m=await _e()},mr=async()=>{await m?.logout(),m=null,R.getInstance().reset(),B.getInstance().reset(),j.getInstance().reset()},ue=()=>m?.getIdentity(),Or=async()=>(m??await _e()).getIdentity(),xr=async()=>{let e=R.getInstance().get();return Ca(e)||!(await m?.isAuthenticated()??!1)?null:m?.getIdentity()??null};var Ua=e=>{let a=e===!0?"./workers/auth.worker.js":e,r=new Worker(a),o=async()=>{Be({message:"junoSignOutAuthTimer"}),await ea()};return r.onmessage=async({data:c})=>{let{msg:i,data:n}=c;switch(i){case"junoSignOutAuthTimer":await o();return;case"junoDelegationRemainingTime":Be({message:"junoDelegationRemainingTime",detail:n?.authRemainingTime});return}},R.getInstance().subscribe(c=>{if(Rr(c)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var La=()=>{let e=()=>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??e():e()},qa=()=>{let e=()=>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??e():e()};var qc=async({idlFactory:e,satellite:a})=>{let r=l(a?.identity);return await ga({idlFactory:e,...a,identity:r})};import{fromNullable as Ya,nonNullish as Vr}from"@dfinity/utils";import{fromNullable as Ne}from"@dfinity/utils";import{toNullable as Te}from"@dfinity/utils";var Ma=async({asset:{data:e,headers:a,...r},actor:o})=>{let{init_asset_upload:c,upload_asset_chunk:i,commit_asset_upload:n}=o,{batch_id:s}=await c(yr(r)),{chunkIds:t}=await Fr({data:e,uploadFn:i,batchId:s});await gr({commitFn:n,batchId:s,data:e,headers:a,chunkIds:t})};var yr=({filename:e,collection:a,token:r,fullPath:o,encoding:c,description:i})=>({collection:a,full_path:o,name:e,token:Te(r),encoding_type:Te(c),description:Te(i)}),gr=async({commitFn:e,batchId:a,chunkIds:r,headers:o,data:c})=>{let i=o.find(([n,s])=>n.toLowerCase()==="content-type")===void 0&&c.type!==void 0&&c.type!==""?[["Content-Type",c.type]]:void 0;await e({batch_id:a,chunk_ids:r.map(({chunk_id:n})=>n),headers:[...o,...i??[]]})},Fr=async({data:e,uploadFn:a,batchId:r})=>{let o=[],c=ie()?new Blob([await e.arrayBuffer()]):e,i=0n;for(let s=0;s<c.size;s+=19e5){let t=c.slice(s,s+19e5);o.push({batchId:r,chunk:t,uploadFn:a,orderId:i}),i++}let n=[];for await(let s of fr({uploadChunks:o}))n=[...n,...s];return{chunkIds:n}};async function*fr({uploadChunks:e,limit:a=12}){for(let r=0;r<e.length;r=r+a){let o=e.slice(r,r+a);yield await Promise.all(o.map(c=>hr(c)))}}var hr=async({batchId:e,chunk:a,uploadFn:r,orderId:o})=>r({batch_id:e,content:new Uint8Array(await a.arrayBuffer()),order_id:Te(o)});var ja=async({asset:e,...a})=>{let r=await p(a);await Ma({actor:r,asset:e})},Ba=async({collection:e,filter:a,...r})=>{let{list_assets:o}=await p(r),{items:c,items_length:i,items_page:n,matches_length:s,matches_pages:t}=await o(e,A(a));return{items:c.map(([O,d])=>d),items_length:i,items_page:Ne(n),matches_length:s,matches_pages:Ne(t)}},Ja=async({collection:e,filter:a,...r})=>{let{count_assets:o}=await p(r);return o(e,A(a))},za=async({collection:e,fullPath:a,...r})=>(await p(r)).del_asset(e,a),Ka=async({assets:e,satellite:a})=>{let{del_many_assets:r}=await p({satellite:a,options:{certified:!0}}),o=e.map(({collection:c,fullPath:i})=>[c,i]);await r(o)},Ga=async({collection:e,filter:a,...r})=>{let{del_filtered_assets:o}=await p(r);return o(e,A(a))},Ha=async({collection:e,fullPath:a,...r})=>{let{get_asset:o}=await p(r);return Ne(await o(e,a))},Wa=async({assets:e,...a})=>{let{get_many_assets:r}=await p(a),o=e.map(({collection:i,fullPath:n})=>[i,n]);return(await r(o)).map(([i,n])=>Ne(n))};var $a=e=>btoa([...e].map(a=>String.fromCharCode(a)).join(""));var ri=e=>Xa(e),oi=e=>Xa({filename:e.data.name,...e}),Xa=async({filename:e,data:a,collection:r,headers:o=[],fullPath:c,token:i,satellite:n,encoding:s,description:t})=>{let O=l(n?.identity),d=decodeURI(e),_=c??`/${r}/${d}`,T={...n,identity:O};return await ja({asset:{data:a,filename:d,collection:r,token:i,headers:o,fullPath:_,encoding:s,description:t},satellite:T,options:{certified:!0}}),{downloadUrl:Qa({satellite:T,assetKey:{fullPath:_,token:i}}),fullPath:_,name:d}},ci=async({collection:e,filter:a,satellite:r,options:o})=>{let c={...r,identity:l(r?.identity)},{items:i,...n}=await Ba({collection:e,filter:a??{},satellite:c,options:o??g}),s=i.map(({key:{full_path:t,token:O,name:d,owner:_,description:T},headers:u,encodings:E,created_at:v,updated_at:b})=>{let L=Ya(O);return{fullPath:t,description:Ya(T),name:d,downloadUrl:Qa({satellite:c,assetKey:{fullPath:t,token:L}}),token:L,headers:u,encodings:E.reduce((K,[F,{modified:D,sha256:S,total_length:f}])=>({...K,[F]:{modified:D,sha256:$a(S),total_length:f}}),{}),owner:_.toText(),created_at:v,updated_at:b}});return{items:s,assets:s,...n}},ii=async({collection:e,filter:a,satellite:r,options:o})=>{let c={...r,identity:l(r?.identity)};return await Ja({collection:e,satellite:c,filter:a??{},options:o??g})},ni=({collection:e,fullPath:a,satellite:r})=>za({collection:e,fullPath:a,satellite:{...r,identity:l(r?.identity)},options:{certified:!0}}),si=({assets:e,satellite:a})=>Ka({assets:e,satellite:{...a,identity:l(a?.identity)},options:{certified:!0}}),ti=async({collection:e,satellite:a,filter:r})=>{let o={...a,identity:l(a?.identity)};return await Ga({collection:e,satellite:o,filter:r??{},options:{certified:!0}})},li=async({satellite:e,options:a,...r})=>{let o=l(e?.identity);return await Ha({...r,satellite:{...e,identity:o},options:a??g})},pi=async({satellite:e,options:a,...r})=>{let o=l(e?.identity);return await Wa({...r,satellite:{...e,identity:o},options:a??g})},Qa=({assetKey:{fullPath:e,token:a},satellite:r})=>{let o={...r,identity:l(r?.identity)};return`${ya(o)}${e}${Vr(a)?`?token=${a}`:""}`};var Ar=e=>{let a=e?.satelliteId??La();Pr(a,"Satellite ID is not configured. Juno cannot be initialized.");let r=e?.container??qa();return{satelliteId:a,internetIdentityId:e?.internetIdentityId,workers:e?.workers,container:r}},xi=e=>Er(e),Er=async e=>{let a=Ar(e);y.getInstance().set(a),await Ze();let r=a.workers?.auth!==void 0?Ua(a.workers.auth):void 0;return[...r?[r]:[]]},Ri=e=>R.getInstance().subscribe(e);export{pe as InitError,ne as InternetIdentityProvider,de as ListError,pa as NFIDProvider,se as SignInError,te as SignInInitError,le as SignInUserInterruptError,Ri as authSubscribe,ii as countAssets,_c as countDocs,ni as deleteAsset,tc as deleteDoc,ti as deleteFilteredAssets,pc as deleteFilteredDocs,si as deleteManyAssets,lc as deleteManyDocs,Qa as downloadUrl,li as getAsset,Sa as getDoc,xr as getIdentityOnce,pi as getManyAssets,nc as getManyDocs,qc as getSatelliteExtendedActor,xi as initJuno,Er as initSatellite,ci as listAssets,dc as listDocs,Ia as setDoc,sc as setManyDocs,Nr as signIn,ea as signOut,Or as unsafeIdentity,ri as uploadBlob,oi as uploadFile};
|
|
1
|
+
import{assertNonNullish as Ar}from"@dfinity/utils";import{isNullish as Rr}from"@dfinity/utils";var M=class{callbacks=[];populate(a){this.callbacks.forEach(({callback:r})=>r(a))}subscribe(a){let r=Symbol();return this.callbacks.push({id:r,callback:a}),()=>this.callbacks=this.callbacks.filter(({id:o})=>o!==r)}};var R=class e extends M{static instance;authUser=null;constructor(){super()}static getInstance(){return e.instance||(e.instance=new e),e.instance}set(a){this.authUser=a,this.populate(a)}get(){return this.authUser}subscribe(a){let r=super.subscribe(a);return a(this.authUser),r}reset(){this.authUser=null,this.populate(this.authUser)}};var je=({message:e,detail:a})=>{let r=new CustomEvent(e,{detail:a,bubbles:!0});document.dispatchEvent(r)};import{ERROR_USER_INTERRUPT as Tr}from"@dfinity/auth-client";import{isNullish as Ca}from"@dfinity/utils";var aa=BigInt(144e11),ra=!1,oa={width:576,height:576},ca={width:505,height:705},na="internetcomputer.org";import{isNullish as ar,nonNullish as la}from"@dfinity/utils";var j="http://127.0.0.1:5987",ia="rdmx6-jaaaa-aaaaa-aaadq-cai";var y=class e extends M{static instance;env;constructor(){super()}static getInstance(){return e.instance||(e.instance=new e),e.instance}set(a){this.env=a,this.populate(a)}get(){return this.env}reset(){this.env=null}subscribe(a){let r=super.subscribe(a);return a(this.env),r}};import{isNullish as ta}from"@dfinity/utils";import{jsonReplacer as Za,jsonReviver as er}from"@dfinity/utils";var sa=async e=>{let a=new Blob([JSON.stringify(e,Za)],{type:"application/json; charset=utf-8"});return new Uint8Array(await a.arrayBuffer())},ce=async e=>{let a=new Blob([e instanceof Uint8Array?e:new Uint8Array(e)],{type:"application/json; charset=utf-8"});return JSON.parse(await a.text(),er)},ne=()=>typeof window<"u";var Je=({width:e,height:a})=>{if(!ne()||ta(window)||ta(window.top))return;let{top:{innerWidth:r,innerHeight:o}}=window,c=o/2+screenY-a/2,n=r/2+screenX-e/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${e}, height=${a}, top=${c}, left=${n}`};var ie=class{#e;constructor({domain:a}){this.#e=a}get id(){return"internet_identity"}signInOptions({windowed:a}){let r=()=>{let o=y.getInstance().get()?.container;if(ar(o)||o===!1)return`https://identity.${this.#e??na}`;let c=y.getInstance().get(),n=la(c)&&la(c?.internetIdentityId)?c.internetIdentityId:ia,{host:i,protocol:s}=new URL(o===!0?j:o);return/apple/i.test(navigator?.vendor)?`${s}//${i}?canisterId=${n}`:`${s}//${n}.${i.replace("127.0.0.1","localhost")}`};return{...a!==!1&&{windowOpenerFeatures:Je(oa)},identityProvider:r()}}},pa=class{#e;#a;constructor({appName:a,logoUrl:r}){this.#e=a,this.#a=r}get id(){return"nfid"}signInOptions({windowed:a}){return{...a!==!1&&{windowOpenerFeatures:Je(ca)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#e)}&applicationLogo=${encodeURI(this.#a)}`}}};import{Actor as or}from"@dfinity/agent";import{isNullish as Ke}from"@dfinity/utils";import{isNullish as ze}from"@dfinity/utils";import{HttpAgent as rr}from"@dfinity/agent";import{nonNullish as da}from"@dfinity/utils";var _a=async({identity:e,container:a})=>{let o=da(a)&&a!==!1?a===!0?j:a:"https://icp-api.io",c=da(a);return await rr.create({identity:e,shouldFetchRootKey:c,host:o})};var J=class e{static instance;#e=void 0;constructor(){}static getInstance(){return ze(e.instance)&&(e.instance=new e),e.instance}async getAgent({identity:a,...r}){let o=a.getPrincipal().toText();if(ze(this.#e)||ze(this.#e[o])){let c=await _a({identity:a,...r});return this.#e={...this.#e??{},[o]:c},c}return this.#e[o]}reset(){this.#e=null}};var z=class e{static instance;#e=void 0;constructor(){}static getInstance(){return Ke(e.instance)&&(e.instance=new e),e.instance}async getActor({satelliteId:a,identity:r,actorKey:o,...c}){let n=`${o}#${r.getPrincipal().toText()}#${a};`;if(Ke(this.#e)||Ke(this.#e[n])){let i=await this.createActor({satelliteId:a,identity:r,...c});return this.#e={...this.#e??{},[n]:i},i}return this.#e[n]}reset(){this.#e=null}async createActor({idlFactory:a,satelliteId:r,...o}){let c=await J.getInstance().getAgent(o);return or.createActor(a,{agent:c,canisterId:r})}};var se=class extends Error{},te=class extends Error{},le=class extends Error{},pe=class extends Error{},de=class extends Error{};import{AuthClient as cr}from"@dfinity/auth-client";var _e=()=>cr.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});import{isNullish as _r,nonNullish as wa}from"@dfinity/utils";var Ge=({error:e,type:a})=>typeof e=="string"?e.includes(a):e instanceof Error?e.message.includes(a):!1;var ua="juno.datastore.error.user.cannot_update";import{fromNullable as G,isNullish as tr,nonNullish as lr}from"@dfinity/utils";var Ta=async({data:e})=>{try{return await ce(e)}catch(a){console.error("The data parsing has failed, mapping to undefined as a fallback.",a);return}};import{fromNullable as Na,toNullable as He}from"@dfinity/utils";var We=async e=>{let{data:a,version:r,description:o}=e;return{description:He(o),data:await sa(a),version:He(r)}},$e=e=>{let{version:a}=e;return{version:He(a)}},re=async({doc:e,key:a})=>{let{owner:r,version:o,description:c,data:n,...i}=e;return{key:a,description:Na(c),owner:r.toText(),data:await ce(n),version:Na(o),...i}};import{Principal as nr}from"@dfinity/principal";import{isNullish as K,toNullable as m}from"@dfinity/utils";var ma=e=>{if(K(e))return m();switch(e.matcher){case"equal":return m({Equal:e.timestamp});case"greaterThan":return m({GreaterThan:e.timestamp});case"lessThan":return m({LessThan:e.timestamp});case"between":return m({Between:[e.timestamps.start,e.timestamps.end]});default:throw new de("Invalid list matcher for timestamp",e)}},A=({matcher:e,paginate:a,order:r,owner:o})=>({matcher:K(e)?[]:[{key:m(e.key),description:m(e.description),created_at:ma(e.createdAt),updated_at:ma(e.updatedAt)}],paginate:m(K(a)?void 0:{start_after:m(a.startAfter),limit:m(K(a.limit)?void 0:BigInt(a.limit))}),order:m(K(r)?void 0:{desc:r.desc,field:r.field==="created_at"?{CreatedAt:null}:r.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:m(K(o)?void 0:typeof o=="string"?nr.fromText(o):o)});import{assertNonNullish as sr}from"@dfinity/utils";import{Actor as fo}from"@dfinity/agent";import"@dfinity/agent";import"@dfinity/agent";import"@dfinity/principal";import{HttpAgent as wo}from"@dfinity/agent";import{Principal as Co}from"@dfinity/principal";var ir=(e=>(e[e.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",e[e.InvalidFormat=1]="InvalidFormat",e[e.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",e))(ir||{}),Do=BigInt(1e8);var Oa="abcdefghijklmnopqrstuvwxyz234567",oe=Object.create(null);for(let e=0;e<Oa.length;e++)oe[Oa[e]]=e;oe[0]=oe.o;oe[1]=oe.i;var Io=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]);var xa=({IDL:e})=>{let a=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Record({sha256:e.Vec(e.Nat8),proposal_id:e.Nat}),o=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),c=e.Record({field:o,desc:e.Bool}),n=e.Variant({Equal:e.Nat64,Between:e.Tuple(e.Nat64,e.Nat64),GreaterThan:e.Nat64,LessThan:e.Nat64}),i=e.Record({key:e.Opt(e.Text),updated_at:e.Opt(n),description:e.Opt(e.Text),created_at:e.Opt(n)}),s=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),t=e.Record({order:e.Opt(c),owner:e.Opt(e.Principal),matcher:e.Opt(i),paginate:e.Opt(s)}),u=e.Record({controllers:e.Vec(e.Principal)}),d=e.Variant({Write:e.Null,Admin:e.Null,Submit:e.Null}),_=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:d,expires_at:e.Opt(e.Nat64)}),N=e.Record({version:e.Opt(e.Nat64)}),T=e.Variant({Db:e.Null,Storage:e.Null}),E=e.Record({version:e.Opt(e.Nat64)}),v=e.Record({proposal_ids:e.Vec(e.Nat)}),b=e.Record({cycles:e.Nat,destination_id:e.Principal}),B=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,description:e.Opt(e.Text),full_path:e.Text}),H=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),F=e.Record({key:B,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,H)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),D=e.Record({derivation_origin:e.Opt(e.Text),external_alternative_origins:e.Opt(e.Vec(e.Text))}),I=e.Record({allowed_callers:e.Vec(e.Principal)}),f=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),internet_identity:e.Opt(D),rules:e.Opt(I)}),h=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),S=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(h)}),W=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),$=e.Variant({Deny:e.Null,Allow:e.Null}),Y=e.Record({status_code:e.Nat16,location:e.Text}),w=e.Record({iframe:e.Opt(W),updated_at:e.Opt(e.Nat64),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(h),raw_access:e.Opt($),redirects:e.Opt(e.Vec(e.Tuple(e.Text,Y)))}),me=e.Record({db:e.Opt(S),authentication:e.Opt(f),storage:w}),x=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),description:e.Opt(e.Text),created_at:e.Nat64,version:e.Opt(e.Nat64)}),Oe=e.Variant({Initialized:e.Null,Failed:e.Null,Open:e.Null,Rejected:e.Null,Executed:e.Null,Accepted:e.Null}),xe=e.Record({clear_existing_assets:e.Opt(e.Bool)}),Re=e.Record({orbiter:e.Opt(e.Text),mission_control_version:e.Opt(e.Text),satellite_version:e.Opt(e.Text)}),X=e.Variant({AssetsUpgrade:xe,SegmentsDeployment:Re}),V=e.Record({status:Oe,updated_at:e.Nat64,sha256:e.Opt(e.Vec(e.Nat8)),executed_at:e.Opt(e.Nat64),owner:e.Principal,created_at:e.Nat64,version:e.Opt(e.Nat64),proposal_type:X}),k=e.Variant({Heap:e.Null,Stable:e.Null}),P=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),Q=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),C=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(k),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:P,created_at:e.Nat64,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(Q),write:P,max_changes_per_user:e.Opt(e.Nat32)}),ye=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),certificate_version:e.Opt(e.Nat16)}),U=e.Record({memory:k,token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),ge=e.Variant({Callback:e.Record({token:U,callback:e.Func([],[],["query"])})}),Fe=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(ge),status_code:e.Nat16}),fe=e.Record({token:e.Opt(U),body:e.Vec(e.Nat8)}),L=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,description:e.Opt(e.Text),encoding_type:e.Opt(e.Text),full_path:e.Text}),q=e.Record({batch_id:e.Nat}),he=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,F)),items_length:e.Nat64}),Ve=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),Pe=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,x)),items_length:e.Nat64}),Ae=e.Record({desc:e.Bool}),Ee=e.Record({start_after:e.Opt(e.Nat),limit:e.Opt(e.Nat)}),ve=e.Record({order:e.Opt(Ae),paginate:e.Opt(Ee)}),be=e.Record({proposal_id:e.Nat}),De=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(be,V)),items_length:e.Nat64}),Ie=e.Record({include_system:e.Bool}),Se=e.Record({matcher:e.Opt(Ie)}),we=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(e.Text,C)),items_length:e.Nat64}),ke=e.Record({stable:e.Nat64,heap:e.Nat64}),Ce=e.Record({version:e.Opt(e.Nat64),internet_identity:e.Opt(D),rules:e.Opt(I)}),Ue=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:d,expires_at:e.Opt(e.Nat64)}),Le=e.Record({controller:Ue,controllers:e.Vec(e.Principal)}),qe=e.Record({version:e.Opt(e.Nat64),max_memory_size:e.Opt(h)}),Z=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),Be=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(k),max_size:e.Opt(e.Nat),read:P,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(Q),write:P,max_changes_per_user:e.Opt(e.Nat32)}),Me=e.Record({iframe:e.Opt(W),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),version:e.Opt(e.Nat64),max_memory_size:e.Opt(h),raw_access:e.Opt($),redirects:e.Opt(e.Vec(e.Tuple(e.Text,Y)))}),ee=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),ae=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([a],[],[]),commit_proposal:e.Func([r],[e.Null],[]),commit_proposal_asset_upload:e.Func([a],[],[]),commit_proposal_many_assets_upload:e.Func([e.Vec(a)],[],[]),count_assets:e.Func([e.Text,t],[e.Nat64],["query"]),count_collection_assets:e.Func([e.Text],[e.Nat64],["query"]),count_collection_docs:e.Func([e.Text],[e.Nat64],["query"]),count_docs:e.Func([e.Text,t],[e.Nat64],["query"]),count_proposals:e.Func([],[e.Nat64],["query"]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Text],[],[]),del_controllers:e.Func([u],[e.Vec(e.Tuple(e.Principal,_))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,N],[],[]),del_docs:e.Func([e.Text],[],[]),del_filtered_assets:e.Func([e.Text,t],[],[]),del_filtered_docs:e.Func([e.Text,t],[],[]),del_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[],[]),del_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,N))],[],[]),del_rule:e.Func([T,e.Text,E],[],[]),delete_proposal_assets:e.Func([v],[],[]),deposit_cycles:e.Func([b],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(F)],["query"]),get_auth_config:e.Func([],[e.Opt(f)],["query"]),get_config:e.Func([],[me],[]),get_db_config:e.Func([],[e.Opt(S)],["query"]),get_doc:e.Func([e.Text,e.Text],[e.Opt(x)],["query"]),get_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(F)))],["query"]),get_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(x)))],["query"]),get_proposal:e.Func([e.Nat],[e.Opt(V)],["query"]),get_rule:e.Func([T,e.Text],[e.Opt(C)],["query"]),get_storage_config:e.Func([],[w],["query"]),http_request:e.Func([ye],[Fe],["query"]),http_request_streaming_callback:e.Func([U],[fe],["query"]),init_asset_upload:e.Func([L],[q],[]),init_proposal:e.Func([X],[e.Nat,V],[]),init_proposal_asset_upload:e.Func([L,e.Nat],[q],[]),init_proposal_many_assets_upload:e.Func([e.Vec(L),e.Nat],[e.Vec(e.Tuple(e.Text,q))],[]),list_assets:e.Func([e.Text,t],[he],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,_))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,Ve))],["query"]),list_docs:e.Func([e.Text,t],[Pe],["query"]),list_proposals:e.Func([ve],[De],["query"]),list_rules:e.Func([T,Se],[we],["query"]),memory_size:e.Func([],[ke],["query"]),reject_proposal:e.Func([r],[e.Null],[]),set_auth_config:e.Func([Ce],[f],[]),set_controllers:e.Func([Le],[e.Vec(e.Tuple(e.Principal,_))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_db_config:e.Func([qe],[S],[]),set_doc:e.Func([e.Text,e.Text,Z],[x],[]),set_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,Z))],[e.Vec(e.Tuple(e.Text,x))],[]),set_rule:e.Func([T,e.Text,Be],[C],[]),set_storage_config:e.Func([Me],[w],[]),submit_proposal:e.Func([e.Nat],[e.Nat,V],[]),upload_asset_chunk:e.Func([ee],[ae],[]),upload_proposal_asset_chunk:e.Func([ee],[ae],[])})},Ra=({IDL:e})=>{let a=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Record({sha256:e.Vec(e.Nat8),proposal_id:e.Nat}),o=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),c=e.Record({field:o,desc:e.Bool}),n=e.Variant({Equal:e.Nat64,Between:e.Tuple(e.Nat64,e.Nat64),GreaterThan:e.Nat64,LessThan:e.Nat64}),i=e.Record({key:e.Opt(e.Text),updated_at:e.Opt(n),description:e.Opt(e.Text),created_at:e.Opt(n)}),s=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),t=e.Record({order:e.Opt(c),owner:e.Opt(e.Principal),matcher:e.Opt(i),paginate:e.Opt(s)}),u=e.Record({controllers:e.Vec(e.Principal)}),d=e.Variant({Write:e.Null,Admin:e.Null,Submit:e.Null}),_=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:d,expires_at:e.Opt(e.Nat64)}),N=e.Record({version:e.Opt(e.Nat64)}),T=e.Variant({Db:e.Null,Storage:e.Null}),E=e.Record({version:e.Opt(e.Nat64)}),v=e.Record({proposal_ids:e.Vec(e.Nat)}),b=e.Record({cycles:e.Nat,destination_id:e.Principal}),B=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,description:e.Opt(e.Text),full_path:e.Text}),H=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),F=e.Record({key:B,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,H)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),D=e.Record({derivation_origin:e.Opt(e.Text),external_alternative_origins:e.Opt(e.Vec(e.Text))}),I=e.Record({allowed_callers:e.Vec(e.Principal)}),f=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),internet_identity:e.Opt(D),rules:e.Opt(I)}),h=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),S=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(h)}),W=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),$=e.Variant({Deny:e.Null,Allow:e.Null}),Y=e.Record({status_code:e.Nat16,location:e.Text}),w=e.Record({iframe:e.Opt(W),updated_at:e.Opt(e.Nat64),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(h),raw_access:e.Opt($),redirects:e.Opt(e.Vec(e.Tuple(e.Text,Y)))}),me=e.Record({db:e.Opt(S),authentication:e.Opt(f),storage:w}),x=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),description:e.Opt(e.Text),created_at:e.Nat64,version:e.Opt(e.Nat64)}),Oe=e.Variant({Initialized:e.Null,Failed:e.Null,Open:e.Null,Rejected:e.Null,Executed:e.Null,Accepted:e.Null}),xe=e.Record({clear_existing_assets:e.Opt(e.Bool)}),Re=e.Record({orbiter:e.Opt(e.Text),mission_control_version:e.Opt(e.Text),satellite_version:e.Opt(e.Text)}),X=e.Variant({AssetsUpgrade:xe,SegmentsDeployment:Re}),V=e.Record({status:Oe,updated_at:e.Nat64,sha256:e.Opt(e.Vec(e.Nat8)),executed_at:e.Opt(e.Nat64),owner:e.Principal,created_at:e.Nat64,version:e.Opt(e.Nat64),proposal_type:X}),k=e.Variant({Heap:e.Null,Stable:e.Null}),P=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),Q=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),C=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(k),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:P,created_at:e.Nat64,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(Q),write:P,max_changes_per_user:e.Opt(e.Nat32)}),ye=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),certificate_version:e.Opt(e.Nat16)}),U=e.Record({memory:k,token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),ge=e.Variant({Callback:e.Record({token:U,callback:e.Func([],[],[])})}),Fe=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(ge),status_code:e.Nat16}),fe=e.Record({token:e.Opt(U),body:e.Vec(e.Nat8)}),L=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,description:e.Opt(e.Text),encoding_type:e.Opt(e.Text),full_path:e.Text}),q=e.Record({batch_id:e.Nat}),he=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,F)),items_length:e.Nat64}),Ve=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),Pe=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,x)),items_length:e.Nat64}),Ae=e.Record({desc:e.Bool}),Ee=e.Record({start_after:e.Opt(e.Nat),limit:e.Opt(e.Nat)}),ve=e.Record({order:e.Opt(Ae),paginate:e.Opt(Ee)}),be=e.Record({proposal_id:e.Nat}),De=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(be,V)),items_length:e.Nat64}),Ie=e.Record({include_system:e.Bool}),Se=e.Record({matcher:e.Opt(Ie)}),we=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(e.Text,C)),items_length:e.Nat64}),ke=e.Record({stable:e.Nat64,heap:e.Nat64}),Ce=e.Record({version:e.Opt(e.Nat64),internet_identity:e.Opt(D),rules:e.Opt(I)}),Ue=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:d,expires_at:e.Opt(e.Nat64)}),Le=e.Record({controller:Ue,controllers:e.Vec(e.Principal)}),qe=e.Record({version:e.Opt(e.Nat64),max_memory_size:e.Opt(h)}),Z=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),Be=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(k),max_size:e.Opt(e.Nat),read:P,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(Q),write:P,max_changes_per_user:e.Opt(e.Nat32)}),Me=e.Record({iframe:e.Opt(W),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),version:e.Opt(e.Nat64),max_memory_size:e.Opt(h),raw_access:e.Opt($),redirects:e.Opt(e.Vec(e.Tuple(e.Text,Y)))}),ee=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),ae=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([a],[],[]),commit_proposal:e.Func([r],[e.Null],[]),commit_proposal_asset_upload:e.Func([a],[],[]),commit_proposal_many_assets_upload:e.Func([e.Vec(a)],[],[]),count_assets:e.Func([e.Text,t],[e.Nat64],[]),count_collection_assets:e.Func([e.Text],[e.Nat64],[]),count_collection_docs:e.Func([e.Text],[e.Nat64],[]),count_docs:e.Func([e.Text,t],[e.Nat64],[]),count_proposals:e.Func([],[e.Nat64],[]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Text],[],[]),del_controllers:e.Func([u],[e.Vec(e.Tuple(e.Principal,_))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,N],[],[]),del_docs:e.Func([e.Text],[],[]),del_filtered_assets:e.Func([e.Text,t],[],[]),del_filtered_docs:e.Func([e.Text,t],[],[]),del_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[],[]),del_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,N))],[],[]),del_rule:e.Func([T,e.Text,E],[],[]),delete_proposal_assets:e.Func([v],[],[]),deposit_cycles:e.Func([b],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(F)],[]),get_auth_config:e.Func([],[e.Opt(f)],[]),get_config:e.Func([],[me],[]),get_db_config:e.Func([],[e.Opt(S)],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(x)],[]),get_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(F)))],[]),get_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(x)))],[]),get_proposal:e.Func([e.Nat],[e.Opt(V)],[]),get_rule:e.Func([T,e.Text],[e.Opt(C)],[]),get_storage_config:e.Func([],[w],[]),http_request:e.Func([ye],[Fe],[]),http_request_streaming_callback:e.Func([U],[fe],[]),init_asset_upload:e.Func([L],[q],[]),init_proposal:e.Func([X],[e.Nat,V],[]),init_proposal_asset_upload:e.Func([L,e.Nat],[q],[]),init_proposal_many_assets_upload:e.Func([e.Vec(L),e.Nat],[e.Vec(e.Tuple(e.Text,q))],[]),list_assets:e.Func([e.Text,t],[he],[]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,_))],[]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,Ve))],[]),list_docs:e.Func([e.Text,t],[Pe],[]),list_proposals:e.Func([ve],[De],[]),list_rules:e.Func([T,Se],[we],[]),memory_size:e.Func([],[ke],[]),reject_proposal:e.Func([r],[e.Null],[]),set_auth_config:e.Func([Ce],[f],[]),set_controllers:e.Func([Le],[e.Vec(e.Tuple(e.Principal,_))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_db_config:e.Func([qe],[S],[]),set_doc:e.Func([e.Text,e.Text,Z],[x],[]),set_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,Z))],[e.Vec(e.Tuple(e.Text,x))],[]),set_rule:e.Func([T,e.Text,Be],[C],[]),set_storage_config:e.Func([Me],[w],[]),submit_proposal:e.Func([e.Nat],[e.Nat,V],[]),upload_asset_chunk:e.Func([ee],[ae],[]),upload_proposal_asset_chunk:e.Func([ee],[ae],[])})};import{nonNullish as Ye}from"@dfinity/utils";var ya=({satelliteId:e,container:a})=>{let{satelliteId:r}=Xe({satelliteId:e}),{container:o}=Qe({container:a});if(Ye(o)&&o!==!1){let{host:c,protocol:n}=new URL(o===!0?j:o);return`${n}//${r??"unknown"}.${c.replace("127.0.0.1","localhost")}`}return`https://${r??"unknown"}.icp0.io`},Xe=({satelliteId:e})=>Ye(e)?{satelliteId:e}:y.getInstance().get()??{satelliteId:void 0},Qe=({container:e})=>Ye(e)?{container:e}:y.getInstance().get()??{container:void 0};var p=({satellite:e,options:{certified:a}})=>Fa({idlFactory:a?Ra:xa,actorKey:`stock#${a?"update":"query"}`,...e}),ga=({idlFactory:e,...a})=>Fa({idlFactory:e,actorKey:"extended#query",...a}),Fa=async({satelliteId:e,container:a,...r})=>{let{satelliteId:o}=Xe({satelliteId:e});sr(o,"No satellite ID defined. Did you initialize Juno?");let{container:c}=Qe({container:a});return await z.getInstance().getActor({satelliteId:o,container:c,...r})};var fa=async({collection:e,key:a,...r})=>{let{get_doc:o}=await p(r),c=G(await o(e,a));if(!tr(c))return re({doc:c,key:a})},ha=async({docs:e,...a})=>{let{get_many_docs:r}=await p(a),o=e.map(({collection:i,key:s})=>[i,s]),c=await r(o),n=[];for(let[i,s]of c){let t=G(s);n.push(lr(t)?await re({key:i,doc:t}):void 0)}return n},Va=async({collection:e,doc:a,...r})=>{let{set_doc:o}=await p(r),{key:c}=a,n=await We(a),i=await o(e,c,n);return await re({key:c,doc:i})},Pa=async({docs:e,...a})=>{let{set_many_docs:r}=await p(a),o=[];for(let{collection:i,doc:s}of e){let{key:t}=s;o.push([i,t,await We(s)])}let c=await r(o),n=[];for(let[i,s]of c)n.push(await re({key:i,doc:s}));return n},Aa=async({collection:e,doc:a,...r})=>{let{del_doc:o}=await p(r),{key:c}=a;return o(e,c,$e(a))},Ea=async({docs:e,...a})=>{let{del_many_docs:r}=await p(a),o=e.map(({collection:c,doc:n})=>[c,n.key,$e(n)]);await r(o)},va=async({collection:e,filter:a,...r})=>{let{del_filtered_docs:o}=await p(r);return o(e,A(a))},ba=async({collection:e,filter:a,...r})=>{let{list_docs:o}=await p(r),{items:c,items_page:n,items_length:i,matches_length:s,matches_pages:t}=await o(e,A(a)),u=[];for(let[d,_]of c){let{data:N,owner:T,description:E,version:v,...b}=_;u.push({key:d,description:G(E),owner:T.toText(),data:await Ta({data:N}),version:G(v),...b})}return{items:u,items_length:i,items_page:G(n),matches_length:s,matches_pages:G(t)}},Da=async({collection:e,filter:a,...r})=>{let{count_docs:o}=await p(r);return o(e,A(a))};var g={certified:!1};import{AnonymousIdentity as pr}from"@dfinity/agent";import{nonNullish as dr}from"@dfinity/utils";var l=e=>dr(e)?e:ue()??new pr;var Ia=async({satellite:e,options:a,...r})=>{let o=l(e?.identity);return await fa({...r,satellite:{...e,identity:o},options:a??g})},sc=async({satellite:e,options:a,...r})=>{let o=l(e?.identity);return await ha({...r,satellite:{...e,identity:o},options:a??g})},Sa=async({satellite:e,...a})=>{let r=l(e?.identity);return await Va({...a,satellite:{...e,identity:r},options:{certified:!0}})},tc=async({satellite:e,...a})=>{let r=l(e?.identity);return await Pa({...a,satellite:{...e,identity:r},options:{certified:!0}})},lc=async({satellite:e,...a})=>{let r=l(e?.identity);return await Aa({...a,satellite:{...e,identity:r},options:{certified:!0}})},pc=async({satellite:e,...a})=>{let r=l(e?.identity);return await Ea({...a,satellite:{...e,identity:r},options:{certified:!0}})},dc=async({satellite:e,filter:a,...r})=>{let o=l(e?.identity);return await va({...r,filter:a??{},satellite:{...e,identity:o},options:{certified:!0}})},_c=async({satellite:e,options:a,filter:r,...o})=>{let c=l(e?.identity);return await ba({...o,filter:r??{},satellite:{...e,identity:c},options:a??g})},uc=async({satellite:e,options:a,filter:r,...o})=>{let c=l(e?.identity);return await Da({...o,filter:r??{},satellite:{...e,identity:c},options:a??g})};var ka=async e=>{let a=ue();if(_r(a))throw new pe("No identity to initialize the user. Have you initialized Juno?");let r=a.getPrincipal().toText(),o=()=>Ia({collection:"#user",key:r}),c=await o();if(wa(c))return c;try{return await ur({userId:r,provider:e})}catch(n){if(Ge({error:n,type:ua})){let i=await o();if(wa(i))return i}throw n}},ur=({userId:e,...a})=>Sa({collection:"#user",doc:{key:e,data:a}});var O,Ze=async e=>{if(O=O??await _e(),!(await O?.isAuthenticated()??!1))return;let r=await ka(e);R.getInstance().set(r)},Nr=e=>new Promise(async(a,r)=>{if(Ca(O)){r(new te("No client is ready to perform a sign-in. Have you initialized the Satellite?"));return}let o=e?.provider??new ie({});await O.login({onSuccess:async()=>{await Ze(o.id),a()},onError:c=>{if(c===Tr){r(new le(c));return}r(new se(c))},maxTimeToLive:e?.maxTimeToLive??aa,allowPinAuthentication:e?.allowPin??ra,...e?.derivationOrigin!==void 0&&{derivationOrigin:e.derivationOrigin},...o.signInOptions({windowed:e?.windowed})})}),ea=async()=>{await mr(),O=await _e()},mr=async()=>{await O?.logout(),O=null,R.getInstance().reset(),z.getInstance().reset(),J.getInstance().reset()},ue=()=>O?.getIdentity(),Or=async()=>(O??await _e()).getIdentity(),xr=async()=>{let e=R.getInstance().get();return Ca(e)||!(await O?.isAuthenticated()??!1)?null:O?.getIdentity()??null};var Ua=e=>{let a=e===!0?"./workers/auth.worker.js":e,r=new Worker(a),o=async()=>{je({message:"junoSignOutAuthTimer"}),await ea()};return r.onmessage=async({data:c})=>{let{msg:n,data:i}=c;switch(n){case"junoSignOutAuthTimer":await o();return;case"junoDelegationRemainingTime":je({message:"junoDelegationRemainingTime",detail:i?.authRemainingTime});return}},R.getInstance().subscribe(c=>{if(Rr(c)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var La=()=>{let e=()=>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??e():e()},qa=()=>{let e=()=>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??e():e()};var Bc=async({idlFactory:e,satellite:a})=>{let r=l(a?.identity);return await ga({idlFactory:e,...a,identity:r})};import{fromNullable as Ya,nonNullish as Pr}from"@dfinity/utils";import{fromNullable as Ne}from"@dfinity/utils";import{assertNonNullish as Jc,toNullable as Te}from"@dfinity/utils";var Ba=async({asset:{data:e,headers:a,...r},actor:o,progress:c})=>{let{init_asset_upload:n,upload_asset_chunk:i,commit_asset_upload:s}=o,{batch_id:t}=await n(yr(r));c?.onInitiatedBatch();let{chunkIds:u}=await fr({data:e,uploadFn:i,batchId:t});c?.onUploadedFileChunks(r.fullPath),await Fr({commitFn:s,batchId:t,data:e,headers:a,chunkIds:u}),c?.onCommittedBatch()};var yr=({filename:e,collection:a,token:r,fullPath:o,encoding:c,description:n})=>({collection:a,full_path:o,name:e,token:Te(r),encoding_type:Te(c),description:Te(n)}),gr=({batchId:e,chunkIds:a,headers:r,data:o})=>{let c=r.find(([n,i])=>n.toLowerCase()==="content-type")===void 0&&o.type!==void 0&&o.type!==""?[["Content-Type",o.type]]:void 0;return{batch_id:e,chunk_ids:a.map(({chunk_id:n})=>n),headers:[...r,...c??[]]}},Fr=async({commitFn:e,...a})=>{let r=gr(a);await e(r)},fr=async({data:e,uploadFn:a,batchId:r})=>{let o=[],c=ne()?new Blob([await e.arrayBuffer()]):e,n=0n;for(let s=0;s<c.size;s+=19e5){let t=c.slice(s,s+19e5);o.push({batchId:r,chunk:t,uploadFn:a,orderId:n}),n++}let i=[];for await(let s of hr({uploadChunks:o}))i=[...i,...s];return{chunkIds:i}};async function*hr({uploadChunks:e,limit:a=12}){for(let r=0;r<e.length;r=r+a){let o=e.slice(r,r+a);yield await Promise.all(o.map(c=>Vr(c)))}}var Vr=async({batchId:e,chunk:a,uploadFn:r,orderId:o})=>r({batch_id:e,content:new Uint8Array(await a.arrayBuffer()),order_id:Te(o)});var Ma=async({asset:e,...a})=>{let r=await p(a);await Ba({actor:r,asset:e})},ja=async({collection:e,filter:a,...r})=>{let{list_assets:o}=await p(r),{items:c,items_length:n,items_page:i,matches_length:s,matches_pages:t}=await o(e,A(a));return{items:c.map(([u,d])=>d),items_length:n,items_page:Ne(i),matches_length:s,matches_pages:Ne(t)}},Ja=async({collection:e,filter:a,...r})=>{let{count_assets:o}=await p(r);return o(e,A(a))},za=async({collection:e,fullPath:a,...r})=>(await p(r)).del_asset(e,a),Ka=async({assets:e,satellite:a})=>{let{del_many_assets:r}=await p({satellite:a,options:{certified:!0}}),o=e.map(({collection:c,fullPath:n})=>[c,n]);await r(o)},Ga=async({collection:e,filter:a,...r})=>{let{del_filtered_assets:o}=await p(r);return o(e,A(a))},Ha=async({collection:e,fullPath:a,...r})=>{let{get_asset:o}=await p(r);return Ne(await o(e,a))},Wa=async({assets:e,...a})=>{let{get_many_assets:r}=await p(a),o=e.map(({collection:n,fullPath:i})=>[n,i]);return(await r(o)).map(([n,i])=>Ne(i))};var $a=e=>btoa([...e].map(a=>String.fromCharCode(a)).join(""));var cn=e=>Xa(e),nn=e=>Xa({filename:e.data.name,...e}),Xa=async({filename:e,data:a,collection:r,headers:o=[],fullPath:c,token:n,satellite:i,encoding:s,description:t})=>{let u=l(i?.identity),d=decodeURI(e),_=c??`/${r}/${d}`,N={...i,identity:u};return await Ma({asset:{data:a,filename:d,collection:r,token:n,headers:o,fullPath:_,encoding:s,description:t},satellite:N,options:{certified:!0}}),{downloadUrl:Qa({satellite:N,assetKey:{fullPath:_,token:n}}),fullPath:_,name:d}},sn=async({collection:e,filter:a,satellite:r,options:o})=>{let c={...r,identity:l(r?.identity)},{items:n,...i}=await ja({collection:e,filter:a??{},satellite:c,options:o??g}),s=n.map(({key:{full_path:t,token:u,name:d,owner:_,description:N},headers:T,encodings:E,created_at:v,updated_at:b})=>{let B=Ya(u);return{fullPath:t,description:Ya(N),name:d,downloadUrl:Qa({satellite:c,assetKey:{fullPath:t,token:B}}),token:B,headers:T,encodings:E.reduce((H,[F,{modified:D,sha256:I,total_length:f}])=>({...H,[F]:{modified:D,sha256:$a(I),total_length:f}}),{}),owner:_.toText(),created_at:v,updated_at:b}});return{items:s,assets:s,...i}},tn=async({collection:e,filter:a,satellite:r,options:o})=>{let c={...r,identity:l(r?.identity)};return await Ja({collection:e,satellite:c,filter:a??{},options:o??g})},ln=({collection:e,fullPath:a,satellite:r})=>za({collection:e,fullPath:a,satellite:{...r,identity:l(r?.identity)},options:{certified:!0}}),pn=({assets:e,satellite:a})=>Ka({assets:e,satellite:{...a,identity:l(a?.identity)},options:{certified:!0}}),dn=async({collection:e,satellite:a,filter:r})=>{let o={...a,identity:l(a?.identity)};return await Ga({collection:e,satellite:o,filter:r??{},options:{certified:!0}})},_n=async({satellite:e,options:a,...r})=>{let o=l(e?.identity);return await Ha({...r,satellite:{...e,identity:o},options:a??g})},un=async({satellite:e,options:a,...r})=>{let o=l(e?.identity);return await Wa({...r,satellite:{...e,identity:o},options:a??g})},Qa=({assetKey:{fullPath:e,token:a},satellite:r})=>{let o={...r,identity:l(r?.identity)};return`${ya(o)}${e}${Pr(a)?`?token=${a}`:""}`};var Er=e=>{let a=e?.satelliteId??La();Ar(a,"Satellite ID is not configured. Juno cannot be initialized.");let r=e?.container??qa();return{satelliteId:a,internetIdentityId:e?.internetIdentityId,workers:e?.workers,container:r}},gn=e=>vr(e),vr=async e=>{let a=Er(e);y.getInstance().set(a),await Ze();let r=a.workers?.auth!==void 0?Ua(a.workers.auth):void 0;return[...r?[r]:[]]},Fn=e=>R.getInstance().subscribe(e);export{pe as InitError,ie as InternetIdentityProvider,de as ListError,pa as NFIDProvider,se as SignInError,te as SignInInitError,le as SignInUserInterruptError,Fn as authSubscribe,tn as countAssets,uc as countDocs,ln as deleteAsset,lc as deleteDoc,dn as deleteFilteredAssets,dc as deleteFilteredDocs,pn as deleteManyAssets,pc as deleteManyDocs,Qa as downloadUrl,_n as getAsset,Ia as getDoc,xr as getIdentityOnce,un as getManyAssets,sc as getManyDocs,Bc as getSatelliteExtendedActor,gn as initJuno,vr as initSatellite,sn as listAssets,_c as listDocs,Sa as setDoc,tc as setManyDocs,Nr as signIn,ea as signOut,Or as unsafeIdentity,cn as uploadBlob,nn as uploadFile};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|