@junobuild/admin 0.0.58-next-2024-11-26.2 → 0.0.58-next-2024-11-27
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,14 +1,14 @@
|
|
|
1
|
-
var en=Object.defineProperty;var tn=(e,t)=>{for(var r in t)en(e,r,{get:t[r],enumerable:!0})};var fe=class extends Error{constructor(){super("The Wasm code for the upgrade is identical to the code currently installed. No upgrade is necessary.")}};import{isNullish as sn}from"@junobuild/utils";var tt=({IDL:e})=>{let t=e.Record({updated_at:e.Nat64,orbiter_id:e.Principal,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),r=e.Record({subnet_id:e.Opt(e.Principal),name:e.Opt(e.Text)}),n=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,satellite_id:e.Principal}),o=e.Record({cycles:e.Nat,destination_id:e.Principal}),i=e.Record({e8s:e.Nat64}),s=e.Record({timestamp_nanos:e.Nat64}),c=e.Record({to:e.Vec(e.Nat8),fee:i,memo:e.Nat64,from_subaccount:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:i}),u=e.Variant({TxTooOld:e.Record({allowed_window_nanos:e.Nat64}),BadFee:e.Record({expected_fee:i}),TxDuplicate:e.Record({duplicate_of:e.Nat64}),TxCreatedInFuture:e.Null,InsufficientFunds:e.Record({balance:i})}),l=e.Variant({Ok:e.Nat64,Err:u}),f=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),m=e.Record({to:f,fee:e.Opt(e.Nat),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat}),d=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,BadBurn:e.Record({min_burn_amount:e.Nat}),Duplicate:e.Record({duplicate_of:e.Nat}),BadFee:e.Record({expected_fee:e.Nat}),CreatedInFuture:e.Record({ledger_time:e.Nat64}),TooOld:e.Null,InsufficientFunds:e.Record({balance:e.Nat})}),a=e.Variant({Ok:e.Nat,Err:d}),p=e.Variant({Write:e.Null,Admin:e.Null}),y=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:p,expires_at:e.Opt(e.Nat64)}),T=e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),x=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),memory_allocation:e.Nat,compute_allocation:e.Nat}),_=e.Record({status:T,memory_size:e.Nat,cycles:e.Nat,settings:x,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8))}),w=e.Record({id:e.Principal,status:_,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),status_at:e.Nat64}),g=e.Variant({Ok:w,Err:e.Text}),b=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:p,expires_at:e.Opt(e.Nat64)}),C=e.Record({enabled:e.Bool,cycles_threshold:e.Opt(e.Nat64)}),S=e.Record({mission_control_cycles_threshold:e.Opt(e.Nat64),orbiters:e.Vec(e.Tuple(e.Principal,C)),satellites:e.Vec(e.Tuple(e.Principal,C)),cycles_threshold:e.Opt(e.Nat64)}),R=e.Record({orbiters:e.Opt(e.Vec(g)),satellites:e.Opt(e.Vec(g)),mission_control:g});return e.Service({add_mission_control_controllers:e.Func([e.Vec(e.Principal)],[],[]),add_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),create_orbiter:e.Func([e.Opt(e.Text)],[t],[]),create_orbiter_with_config:e.Func([r],[t],[]),create_satellite:e.Func([e.Text],[n],[]),create_satellite_with_config:e.Func([r],[n],[]),del_mission_control_controllers:e.Func([e.Vec(e.Principal)],[],[]),del_orbiter:e.Func([e.Principal,e.Nat],[],[]),del_orbiters_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),del_satellite:e.Func([e.Principal,e.Nat],[],[]),del_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),deposit_cycles:e.Func([o],[],[]),get_user:e.Func([],[e.Principal],["query"]),icp_transfer:e.Func([c],[l],[]),icrc_transfer:e.Func([e.Principal,m],[a],[]),list_mission_control_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,y))],["query"]),list_mission_control_statuses:e.Func([],[e.Vec(e.Tuple(e.Nat64,g))],["query"]),list_orbiter_statuses:e.Func([e.Principal],[e.Opt(e.Vec(e.Tuple(e.Nat64,g)))],["query"]),list_orbiters:e.Func([],[e.Vec(e.Tuple(e.Principal,t))],["query"]),list_satellite_statuses:e.Func([e.Principal],[e.Opt(e.Vec(e.Tuple(e.Nat64,g)))],["query"]),list_satellites:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["query"]),remove_mission_control_controllers:e.Func([e.Vec(e.Principal)],[],[]),remove_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),set_metadata:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[],[]),set_mission_control_controllers:e.Func([e.Vec(e.Principal),b],[],[]),set_orbiter:e.Func([e.Principal,e.Opt(e.Text)],[t],[]),set_orbiter_metadata:e.Func([e.Principal,e.Vec(e.Tuple(e.Text,e.Text))],[t],[]),set_orbiters_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal),b],[],[]),set_satellite:e.Func([e.Principal,e.Opt(e.Text)],[n],[]),set_satellite_metadata:e.Func([e.Principal,e.Vec(e.Tuple(e.Text,e.Text))],[n],[]),set_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal),b],[],[]),status:e.Func([S],[R],[]),top_up:e.Func([e.Principal,i],[],[]),unset_orbiter:e.Func([e.Principal],[],[]),unset_satellite:e.Func([e.Principal],[],[]),version:e.Func([],[e.Text],["query"])})};var rt=({IDL:e})=>{let t=e.Record({controllers:e.Vec(e.Principal)}),r=e.Variant({Write:e.Null,Admin:e.Null}),n=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:r,expires_at:e.Opt(e.Nat64)}),o=e.Record({version:e.Opt(e.Nat64)}),i=e.Record({cycles:e.Nat,destination_id:e.Principal}),s=e.Record({to:e.Opt(e.Nat64),from:e.Opt(e.Nat64),satellite_id:e.Opt(e.Principal)}),c=e.Record({key:e.Text,collected_at:e.Nat64}),u=e.Record({inner_height:e.Nat16,inner_width:e.Nat16}),l=e.Record({title:e.Text,updated_at:e.Nat64,referrer:e.Opt(e.Text),time_zone:e.Text,session_id:e.Text,href:e.Text,created_at:e.Nat64,satellite_id:e.Principal,device:u,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),f=e.Record({safari:e.Float64,opera:e.Float64,others:e.Float64,firefox:e.Float64,chrome:e.Float64}),m=e.Record({desktop:e.Float64,others:e.Float64,mobile:e.Float64}),d=e.Record({browsers:f,devices:m}),a=e.Record({day:e.Nat8,month:e.Nat8,year:e.Int32}),p=e.Record({bounce_rate:e.Float64,average_page_views_per_session:e.Float64,daily_total_page_views:e.Vec(e.Tuple(a,e.Nat32)),total_page_views:e.Nat32,unique_page_views:e.Nat64,unique_sessions:e.Nat64}),y=e.Record({referrers:e.Vec(e.Tuple(e.Text,e.Nat32)),pages:e.Vec(e.Tuple(e.Text,e.Nat32))}),T=e.Variant({Navigate:e.Null,Restore:e.Null,Reload:e.Null,BackForward:e.Null,BackForwardCache:e.Null,Prerender:e.Null}),x=e.Record({id:e.Text,value:e.Float64,navigation_type:e.Opt(T),delta:e.Float64}),_=e.Variant({WebVitalsMetric:x}),w=e.Variant({CLS:e.Null,FCP:e.Null,INP:e.Null,LCP:e.Null,TTFB:e.Null}),g=e.Record({updated_at:e.Nat64,session_id:e.Text,data:_,href:e.Text,metric_name:w,created_at:e.Nat64,satellite_id:e.Principal,version:e.Opt(e.Nat64)}),b=e.Record({cls:e.Opt(e.Float64),fcp:e.Opt(e.Float64),inp:e.Opt(e.Float64),lcp:e.Opt(e.Float64),ttfb:e.Opt(e.Float64)}),C=e.Record({overall:b,pages:e.Vec(e.Tuple(e.Text,b))}),S=e.Record({updated_at:e.Nat64,session_id:e.Text,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),name:e.Text,created_at:e.Nat64,satellite_id:e.Principal,version:e.Opt(e.Nat64)}),R=e.Record({total:e.Vec(e.Tuple(e.Text,e.Nat32))}),E=e.Record({performance_metrics:e.Bool,track_events:e.Bool,page_views:e.Bool}),F=e.Record({updated_at:e.Nat64,features:e.Opt(E),created_at:e.Nat64,version:e.Opt(e.Nat64)}),M=e.Record({stable:e.Nat64,heap:e.Nat64}),H=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:r,expires_at:e.Opt(e.Nat64)}),$=e.Record({controller:H,controllers:e.Vec(e.Principal)}),K=e.Record({title:e.Text,updated_at:e.Opt(e.Nat64),referrer:e.Opt(e.Text),time_zone:e.Text,session_id:e.Text,href:e.Text,satellite_id:e.Principal,device:u,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),W=e.Variant({Ok:l,Err:e.Text}),G=e.Variant({Ok:e.Null,Err:e.Vec(e.Tuple(c,e.Text))}),q=e.Record({session_id:e.Text,data:_,href:e.Text,metric_name:w,satellite_id:e.Principal,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),ze=e.Variant({Ok:g,Err:e.Text}),je=e.Record({features:e.Opt(E),version:e.Opt(e.Nat64)}),me=e.Record({updated_at:e.Opt(e.Nat64),session_id:e.Text,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),name:e.Text,satellite_id:e.Principal,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),He=e.Variant({Ok:S,Err:e.Text});return e.Service({del_controllers:e.Func([t],[e.Vec(e.Tuple(e.Principal,n))],[]),del_satellite_config:e.Func([e.Principal,o],[],[]),deposit_cycles:e.Func([i],[],[]),get_page_views:e.Func([s],[e.Vec(e.Tuple(c,l))],["query"]),get_page_views_analytics_clients:e.Func([s],[d],["query"]),get_page_views_analytics_metrics:e.Func([s],[p],["query"]),get_page_views_analytics_top_10:e.Func([s],[y],["query"]),get_performance_metrics:e.Func([s],[e.Vec(e.Tuple(c,g))],["query"]),get_performance_metrics_analytics_web_vitals:e.Func([s],[C],["query"]),get_track_events:e.Func([s],[e.Vec(e.Tuple(c,S))],["query"]),get_track_events_analytics:e.Func([s],[R],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["query"]),list_satellite_configs:e.Func([],[e.Vec(e.Tuple(e.Principal,F))],["query"]),memory_size:e.Func([],[M],["query"]),set_controllers:e.Func([$],[e.Vec(e.Tuple(e.Principal,n))],[]),set_page_view:e.Func([c,K],[W],[]),set_page_views:e.Func([e.Vec(e.Tuple(c,K))],[G],[]),set_performance_metric:e.Func([c,q],[ze],[]),set_performance_metrics:e.Func([e.Vec(e.Tuple(c,q))],[G],[]),set_satellite_configs:e.Func([e.Vec(e.Tuple(e.Principal,je))],[e.Vec(e.Tuple(e.Principal,F))],[]),set_track_event:e.Func([c,me],[He],[]),set_track_events:e.Func([e.Vec(e.Tuple(c,me))],[G],[]),version:e.Func([],[e.Text],["query"])})};var nt=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Record({controllers:e.Vec(e.Principal)}),n=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,expires_at:e.Opt(e.Nat64)}),o=e.Record({updated_at:e.Opt(e.Nat64)}),i=e.Record({headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text))))}),s=e.Record({storage:i}),c=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),created_at:e.Nat64}),u=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text))}),l=e.Record({token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),f=e.Variant({Callback:e.Record({token:l,callback:e.Func([],[],[])})}),m=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(f),status_code:e.Nat16}),d=e.Record({token:e.Opt(l),body:e.Vec(e.Nat8)}),a=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,encoding_type:e.Opt(e.Text),full_path:e.Text}),p=e.Record({batch_id:e.Nat}),y=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),T=e.Record({field:y,desc:e.Bool}),x=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),_=e.Record({order:e.Opt(T),owner:e.Opt(e.Principal),matcher:e.Opt(e.Text),paginate:e.Opt(x)}),w=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),g=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),b=e.Record({key:w,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,g)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),C=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,b))}),S=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Opt(e.Text)}),R=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,c))}),E=e.Variant({Db:e.Null,Storage:e.Null}),F=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),M=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:F,created_at:e.Nat64,write:F}),H=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),expires_at:e.Opt(e.Nat64)}),$=e.Record({controller:H,controllers:e.Vec(e.Principal)}),K=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),W=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:F,write:F}),G=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),q=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([t],[],[]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Opt(e.Text)],[],[]),del_controllers:e.Func([r],[e.Vec(e.Tuple(e.Principal,n))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,o],[],[]),get_config:e.Func([],[s],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(c)],["query"]),http_request:e.Func([u],[m],["query"]),http_request_streaming_callback:e.Func([l],[d],["query"]),init_asset_upload:e.Func([a],[p],[]),list_assets:e.Func([e.Opt(e.Text),_],[C],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,S))],["query"]),list_docs:e.Func([e.Text,_],[R],["query"]),list_rules:e.Func([E],[e.Vec(e.Tuple(e.Text,M))],["query"]),set_config:e.Func([s],[],[]),set_controllers:e.Func([$],[e.Vec(e.Tuple(e.Principal,n))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_doc:e.Func([e.Text,e.Text,K],[c],[]),set_rule:e.Func([E,e.Text,W],[],[]),upload_asset_chunk:e.Func([G],[q],[]),version:e.Func([],[e.Text],["query"])})};var ot=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Record({controllers:e.Vec(e.Principal)}),n=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,expires_at:e.Opt(e.Nat64)}),o=e.Record({updated_at:e.Opt(e.Nat64)}),i=e.Record({headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text))))}),s=e.Record({storage:i}),c=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),created_at:e.Nat64}),u=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text))}),l=e.Record({token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),f=e.Variant({Callback:e.Record({token:l,callback:e.Func([],[],[])})}),m=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(f),status_code:e.Nat16}),d=e.Record({token:e.Opt(l),body:e.Vec(e.Nat8)}),a=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,encoding_type:e.Opt(e.Text),full_path:e.Text}),p=e.Record({batch_id:e.Nat}),y=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),T=e.Record({field:y,desc:e.Bool}),x=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),_=e.Record({order:e.Opt(T),matcher:e.Opt(e.Text),paginate:e.Opt(x)}),w=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),g=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),b=e.Record({key:w,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,g)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),C=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,b))}),S=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Opt(e.Text)}),R=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,c))}),E=e.Variant({Db:e.Null,Storage:e.Null}),F=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),M=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:F,created_at:e.Nat64,write:F}),H=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),expires_at:e.Opt(e.Nat64)}),$=e.Record({controller:H,controllers:e.Vec(e.Principal)}),K=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),W=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:F,write:F}),G=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),q=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([t],[],[]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Opt(e.Text)],[],[]),del_controllers:e.Func([r],[e.Vec(e.Tuple(e.Principal,n))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,o],[],[]),get_config:e.Func([],[s],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(c)],["query"]),http_request:e.Func([u],[m],["query"]),http_request_streaming_callback:e.Func([l],[d],["query"]),init_asset_upload:e.Func([a],[p],[]),list_assets:e.Func([e.Opt(e.Text),_],[C],["query"]),list_controllers:e.Func([],[e.Vec(e.Principal)],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,S))],["query"]),list_docs:e.Func([e.Text,_],[R],["query"]),list_rules:e.Func([E],[e.Vec(e.Tuple(e.Text,M))],["query"]),set_config:e.Func([s],[],[]),set_controllers:e.Func([$],[e.Vec(e.Tuple(e.Principal,n))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_doc:e.Func([e.Text,e.Text,K],[c],[]),set_rule:e.Func([E,e.Text,W],[],[]),upload_asset_chunk:e.Func([G],[q],[]),version:e.Func([],[e.Text],["query"])})};var it=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),n=e.Record({field:r,desc:e.Bool}),o=e.Variant({Equal:e.Nat64,Between:e.Tuple(e.Nat64,e.Nat64),GreaterThan:e.Nat64,LessThan:e.Nat64}),i=e.Record({key:e.Opt(e.Text),updated_at:e.Opt(o),description:e.Opt(e.Text),created_at:e.Opt(o)}),s=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),c=e.Record({order:e.Opt(n),owner:e.Opt(e.Principal),matcher:e.Opt(i),paginate:e.Opt(s)}),u=e.Record({controllers:e.Vec(e.Principal)}),l=e.Variant({Write:e.Null,Admin:e.Null}),f=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:l,expires_at:e.Opt(e.Nat64)}),m=e.Record({version:e.Opt(e.Nat64)}),d=e.Variant({Db:e.Null,Storage:e.Null}),a=e.Record({version:e.Opt(e.Nat64)}),p=e.Record({cycles:e.Nat,destination_id:e.Principal}),y=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}),T=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),x=e.Record({key:y,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,T)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),_=e.Record({derivation_origin:e.Opt(e.Text)}),w=e.Record({internet_identity:e.Opt(_)}),g=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),b=e.Record({max_memory_size:e.Opt(g)}),C=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),S=e.Variant({Deny:e.Null,Allow:e.Null}),R=e.Record({status_code:e.Nat16,location:e.Text}),E=e.Record({iframe:e.Opt(C),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),max_memory_size:e.Opt(g),raw_access:e.Opt(S),redirects:e.Opt(e.Vec(e.Tuple(e.Text,R)))}),F=e.Record({db:e.Opt(b),authentication:e.Opt(w),storage:E}),M=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)}),H=e.Variant({Heap:e.Null,Stable:e.Null}),$=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),K=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),W=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(H),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:$,created_at:e.Nat64,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(K),write:$}),G=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)}),q=e.Record({memory:H,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}),ze=e.Variant({Callback:e.Record({token:q,callback:e.Func([],[],["query"])})}),je=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(ze),status_code:e.Nat16}),me=e.Record({token:e.Opt(q),body:e.Vec(e.Nat8)}),He=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}),Wr=e.Record({batch_id:e.Nat}),Gr=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}),Xr=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),Zr=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,M)),items_length:e.Nat64}),Jr=e.Record({stable:e.Nat64,heap:e.Nat64}),Yr=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:l,expires_at:e.Opt(e.Nat64)}),Qr=e.Record({controller:Yr,controllers:e.Vec(e.Principal)}),et=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),Ir=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(H),max_size:e.Opt(e.Nat),read:$,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(K),write:$}),Dr=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),Lr=e.Record({chunk_id:e.Nat});return e.Service({build_version:e.Func([],[e.Text],["query"]),commit_asset_upload:e.Func([t],[],[]),count_assets:e.Func([e.Text,c],[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,c],[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,f))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,m],[],[]),del_docs:e.Func([e.Text],[],[]),del_filtered_assets:e.Func([e.Text,c],[],[]),del_filtered_docs:e.Func([e.Text,c],[],[]),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,m))],[],[]),del_rule:e.Func([d,e.Text,a],[],[]),deposit_cycles:e.Func([p],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(x)],["query"]),get_auth_config:e.Func([],[e.Opt(w)],["query"]),get_config:e.Func([],[F],[]),get_db_config:e.Func([],[e.Opt(b)],["query"]),get_doc:e.Func([e.Text,e.Text],[e.Opt(M)],["query"]),get_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(x)))],["query"]),get_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(M)))],["query"]),get_rule:e.Func([d,e.Text],[e.Opt(W)],["query"]),get_storage_config:e.Func([],[E],["query"]),http_request:e.Func([G],[je],["query"]),http_request_streaming_callback:e.Func([q],[me],["query"]),init_asset_upload:e.Func([He],[Wr],[]),list_assets:e.Func([e.Text,c],[Gr],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,f))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,Xr))],["query"]),list_docs:e.Func([e.Text,c],[Zr],["query"]),list_rules:e.Func([d],[e.Vec(e.Tuple(e.Text,W))],["query"]),memory_size:e.Func([],[Jr],["query"]),set_auth_config:e.Func([w],[],[]),set_controllers:e.Func([Qr],[e.Vec(e.Tuple(e.Principal,f))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_db_config:e.Func([b],[],[]),set_doc:e.Func([e.Text,e.Text,et],[M],[]),set_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,et))],[e.Vec(e.Tuple(e.Text,M))],[]),set_rule:e.Func([d,e.Text,Ir],[W],[]),set_storage_config:e.Func([E],[],[]),upload_asset_chunk:e.Func([Dr],[Lr],[]),version:e.Func([],[e.Text],["query"])})};import{Actor as rn,HttpAgent as nn}from"@dfinity/agent";import{nonNullish as st}from"@junobuild/utils";var at=async({canisterId:e,idlFactory:t,config:r,...n})=>{let o=await U(n);return rn.createActor(t,{agent:o,canisterId:e,...r??{}})},U=async({agent:e,...t})=>e??await on(t),on=async({identity:e,fetch:t,container:r})=>{let n=st(r)&&r!==!1,o=n?r===!0?"http://127.0.0.1:5987":r:"https://icp-api.io";return await nn.create({identity:e,host:o,retryTimes:10,...st(t)&&{fetch:t},shouldFetchRootKey:n})};var ct=({satelliteId:e,...t})=>ae({canisterId:e,...t,idlFactory:ot}),A=({satelliteId:e,...t})=>ae({canisterId:e,...t,idlFactory:it}),lt=({satelliteId:e,...t})=>ae({canisterId:e,...t,idlFactory:nt}),re=({missionControlId:e,...t})=>ae({canisterId:e,...t,idlFactory:tt}),he=({orbiterId:e,...t})=>ae({canisterId:e,...t,idlFactory:rt}),ae=({canisterId:e,idlFactory:t,...r})=>{if(sn(e))throw new Error("No canister ID provided.");return at({canisterId:e,idlFactory:t,...r})};var ut=async({missionControl:e})=>(await re(e)).version(),pt=async({missionControl:e})=>(await re(e)).get_user(),dt=async({missionControl:e})=>(await re(e)).list_mission_control_controllers(),mt=async({missionControl:e,satelliteIds:t,controllerIds:r,controller:n})=>(await re(e)).set_satellites_controllers(t,r,n),ft=async({missionControl:e,controllerIds:t,controller:r})=>(await re(e)).set_mission_control_controllers(t,r);import{Principal as an}from"@dfinity/principal";import{nonNullish as cn,toNullable as ln}from"@junobuild/utils";var Ke=({controllerId:e,profile:t})=>({controllerIds:[an.fromText(e)],controller:un(t)}),un=e=>({metadata:cn(e)&&e!==""?[["profile",e]]:[],expires_at:ln(void 0),scope:{Admin:null}});var po=({controllerId:e,profile:t,...r})=>mt({...r,...Ke({controllerId:e,profile:t})}),mo=({controllerId:e,profile:t,...r})=>ft({...r,...Ke({controllerId:e,profile:t})}),fo=e=>dt(e);import{Principal as On}from"@dfinity/principal";var ce={reinstall:null},ee={upgrade:[{skip_pre_upgrade:[!1],wasm_memory_persistence:[{replace:null}]}]};import{fromNullable as wn,isNullish as bn}from"@junobuild/utils";import{CanisterStatus as pn}from"@dfinity/agent";import{ICManagementCanister as Y}from"@dfinity/ic-management";import{Principal as dn}from"@dfinity/principal";import{assertNonNullish as mn}from"@junobuild/utils";var ht=async({canisterId:e,actor:t})=>{let r=await U(t),{stopCanister:n}=Y.create({agent:r});await n(e)},yt=async({canisterId:e,actor:t})=>{let r=await U(t),{startCanister:n}=Y.create({agent:r});await n(e)},_t=async({actor:e,code:t})=>{let r=await U(e),{installCode:n}=Y.create({agent:r});return n(t)},gt=async({actor:e,canisterId:t})=>{let r=await U(e),{storedChunks:n}=Y.create({agent:r});return n({canisterId:t})},ye=async({actor:e,canisterId:t})=>{let r=await U(e),{clearChunkStore:n}=Y.create({agent:r});return n({canisterId:t})},xt=async({actor:e,chunk:t})=>{let r=await U(e),{uploadChunk:n}=Y.create({agent:r});return n(t)},Tt=async({actor:e,code:t})=>{let r=await U(e),{installChunkedCode:n}=Y.create({agent:r});return n(t)},wt=async({actor:e,canisterId:t})=>{let r=await U(e),{canisterStatus:n}=Y.create({agent:r});return n(t)},bt=async({canisterId:e,path:t,...r})=>{mn(e,"A canister ID must be provided to request its status.");let n=await U(r);return(await pn.request({canisterId:dn.from(e),agent:n,paths:[{kind:"metadata",key:t,path:t,decodeStrategy:"utf-8"}]})).get(t)};var Pt=(o=>(o[o.AssertingExistingCode=0]="AssertingExistingCode",o[o.StoppingCanister=1]="StoppingCanister",o[o.UpgradingCode=2]="UpgradingCode",o[o.RestartingCanister=3]="RestartingCanister",o))(Pt||{});var _e=e=>(e instanceof Uint8Array||(e=Uint8Array.from(e)),e.reduce((t,r)=>t+r.toString(16).padStart(2,"0"),""));var Nt=e=>crypto.subtle.digest("SHA-256",e),vt=e=>Array.from(new Uint8Array(e)).map(r=>r.toString(16).padStart(2,"0")).join(""),Ct=async e=>{let t=await Nt(await e.arrayBuffer());return vt(t)},ge=async e=>{let t=await Nt(e);return vt(t)};import{isNullish as hn,nonNullish as St}from"@junobuild/utils";var Rt=async({actor:e,canisterId:t,missionControlId:r,wasmModule:n,preClearChunks:o,...i})=>{o&&await ye({actor:e,canisterId:t});let s=await yn({wasmModule:n}),{uploadChunks:c,storedChunks:u,preClearChunks:l,postClearChunks:f}=await _n({actor:e,wasmChunks:s,canisterId:t,missionControlId:r});l&&await ye({actor:e,canisterId:t});let m=[];for await(let d of gn({uploadChunks:c,actor:e,canisterId:t,missionControlId:r}))m=[...m,...d];await Tt({actor:e,code:{...i,chunkHashesList:[...m,...u].sort(({orderId:d},{orderId:a})=>d-a).map(({chunkHash:d})=>d),targetCanisterId:t,storeCanisterId:r,wasmModuleHash:await ge(n)}}),f&&await ye({actor:e,canisterId:t})},yn=async({wasmModule:e})=>{let t=new Blob([e]),r=[],n=1e6,o=0;for(let i=0;i<t.size;i+=n){let s=t.slice(i,i+n);r.push({chunk:s,orderId:o,sha256:await Ct(s)}),o++}return r},_n=async({canisterId:e,missionControlId:t,actor:r,wasmChunks:n})=>{let o=await gt({actor:r,canisterId:t??e}),i=o.map(({hash:u})=>({chunkHash:{hash:u},sha256:_e(u)})),{storedChunks:s,uploadChunks:c}=n.reduce(({uploadChunks:u,storedChunks:l},{sha256:f,...m})=>{let d=i.find(({sha256:a})=>a===f);return{uploadChunks:[...u,...St(d)?[]:[{sha256:f,...m}]],storedChunks:[...l,...St(d)?[{...m,...d}]:[]]}},{uploadChunks:[],storedChunks:[]});return{uploadChunks:c,storedChunks:s,preClearChunks:o.length>0&&s.length===0,postClearChunks:hn(t)}};async function*gn({uploadChunks:e,limit:t=12,...r}){for(let n=0;n<e.length;n=n+t){let o=e.slice(n,n+t);yield await Promise.all(o.map(s=>xn({uploadChunk:s,...r})))}}var xn=async({actor:e,canisterId:t,missionControlId:r,uploadChunk:{chunk:n,...o}})=>({chunkHash:await xt({actor:e,chunk:{canisterId:r??t,chunk:new Uint8Array(await n.arrayBuffer())}}),...o});var te=async({wasmModule:e,canisterId:t,actor:r,onProgress:n,...o})=>{n?.(0),await Pn({wasmModule:e,canisterId:t,actor:r,...o}),n?.(1),await ht({canisterId:t,actor:r});try{n?.(2),await((new Blob([e]).size>2e6?"chunked":"simple")==="chunked"?Rt:Nn)({wasmModule:e,canisterId:t,actor:r,...o})}finally{n?.(3),await yt({canisterId:t,actor:r})}},Pn=async({actor:e,canisterId:t,wasmModule:r})=>{let{module_hash:n}=await wt({actor:e,canisterId:t}),o=wn(n);if(bn(o))return;let i=await ge(r),s=_e(o);if(i===s)throw new fe},Nn=async({actor:e,...t})=>{await _t({actor:e,code:t})};var O={};tn(O,{Bool:()=>Mt,BoolClass:()=>Ne,ConstructType:()=>j,Empty:()=>Et,EmptyClass:()=>be,FixedIntClass:()=>J,FixedNatClass:()=>z,Float32:()=>zt,Float64:()=>jt,FloatClass:()=>ue,Func:()=>nr,FuncClass:()=>de,Int:()=>$t,Int16:()=>Kt,Int32:()=>Wt,Int64:()=>Gt,Int8:()=>Ht,IntClass:()=>Se,Nat:()=>qt,Nat16:()=>Zt,Nat32:()=>Jt,Nat64:()=>Yt,Nat8:()=>Xt,NatClass:()=>Re,Null:()=>Ut,NullClass:()=>ve,Opt:()=>Lt,OptClass:()=>ie,PrimitiveType:()=>k,Principal:()=>Qt,PrincipalClass:()=>Fe,Rec:()=>rr,RecClass:()=>D,Record:()=>er,RecordClass:()=>pe,Reserved:()=>kt,ReservedClass:()=>oe,Service:()=>or,ServiceClass:()=>Ee,Text:()=>Bt,TextClass:()=>Ce,Tuple:()=>It,TupleClass:()=>Ve,Type:()=>ne,Unknown:()=>An,UnknownClass:()=>Pe,Variant:()=>tr,VariantClass:()=>Oe,Vec:()=>Dt,VecClass:()=>Ae,Visitor:()=>we,decode:()=>Rn,encode:()=>Sn});import{Principal as Cn}from"@dfinity/principal";function h(...e){let t=new Uint8Array(e.reduce((n,o)=>n+o.byteLength,0)),r=0;for(let n of e)t.set(new Uint8Array(n),r),r+=n.byteLength;return t}var X=class{constructor(t,r=t?.byteLength||0){this._buffer=Ge(t||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return Ge(this._view.slice())}get byteLength(){return this._view.byteLength}read(t){let r=this._view.subarray(0,t);return this._view=this._view.subarray(t),r.slice().buffer}readUint8(){let t=this._view[0];return this._view=this._view.subarray(1),t}write(t){let r=new Uint8Array(t),n=this._view.byteLength;this._view.byteOffset+this._view.byteLength+r.byteLength>=this._buffer.byteLength?this.alloc(r.byteLength):this._view=new Uint8Array(this._buffer,this._view.byteOffset,this._view.byteLength+r.byteLength),this._view.set(r,n)}get end(){return this._view.byteLength===0}alloc(t){let r=new ArrayBuffer((this._buffer.byteLength+t)*1.2|0),n=new Uint8Array(r,0,this._view.byteLength+t);n.set(this._view),this._buffer=r,this._view=n}};function We(e){return new DataView(e.buffer,e.byteOffset,e.byteLength).buffer}function Ge(e){return e instanceof Uint8Array?We(e):e instanceof ArrayBuffer?e:Array.isArray(e)?We(new Uint8Array(e)):"buffer"in e?Ge(e.buffer):We(new Uint8Array(e))}function vn(e){let r=new TextEncoder().encode(e),n=0;for(let o of r)n=(n*223+o)%2**32;return n}function B(e){if(/^_\d+_$/.test(e)||/^_0x[0-9a-fA-F]+_$/.test(e)){let t=+e.slice(1,-1);if(Number.isSafeInteger(t)&&t>=0&&t<2**32)return t}return vn(e)}function At(){throw new Error("unexpected end of buffer")}function I(e,t){return e.byteLength<t&&At(),e.read(t)}function Q(e){let t=e.readUint8();return t===void 0&&At(),t}function N(e){if(typeof e=="number"&&(e=BigInt(e)),e<BigInt(0))throw new Error("Cannot leb encode negative values.");let t=(e===BigInt(0)?0:Math.ceil(Math.log2(Number(e))))+1,r=new X(new ArrayBuffer(t),0);for(;;){let n=Number(e&BigInt(127));if(e/=BigInt(128),e===BigInt(0)){r.write(new Uint8Array([n]));break}else r.write(new Uint8Array([n|128]))}return r.buffer}function V(e){let t=BigInt(1),r=BigInt(0),n;do n=Q(e),r+=BigInt(n&127).valueOf()*t,t*=BigInt(128);while(n>=128);return r}function v(e){typeof e=="number"&&(e=BigInt(e));let t=e<BigInt(0);t&&(e=-e-BigInt(1));let r=(e===BigInt(0)?0:Math.ceil(Math.log2(Number(e))))+1,n=new X(new ArrayBuffer(r),0);for(;;){let i=o(e);if(e/=BigInt(128),t&&e===BigInt(0)&&i&64||!t&&e===BigInt(0)&&!(i&64)){n.write(new Uint8Array([i]));break}else n.write(new Uint8Array([i|128]))}function o(i){let s=i%BigInt(128);return Number(t?BigInt(128)-s-BigInt(1):s)}return n.buffer}function Z(e){let t=new Uint8Array(e.buffer),r=0;for(;r<t.byteLength;r++)if(t[r]<128){if(!(t[r]&64))return V(e);break}let n=new Uint8Array(I(e,r+1)),o=BigInt(0);for(let i=n.byteLength-1;i>=0;i--)o=o*BigInt(128)+BigInt(128-(n[i]&127)-1);return-o-BigInt(1)}function Vt(e,t){if(BigInt(e)<BigInt(0))throw new Error("Cannot write negative values.");return Xe(e,t)}function Xe(e,t){e=BigInt(e);let r=new X(new ArrayBuffer(Math.min(1,t)),0),n=0,o=BigInt(256),i=BigInt(0),s=Number(e%o);for(r.write(new Uint8Array([s]));++n<t;)e<0&&i===BigInt(0)&&s!==0&&(i=BigInt(1)),s=Number((e/o-i)%BigInt(256)),r.write(new Uint8Array([s])),o*=BigInt(256);return r.buffer}function Ze(e,t){let r=BigInt(Q(e)),n=BigInt(1),o=0;for(;++o<t;){n*=BigInt(256);let i=BigInt(Q(e));r=r+n*i}return r}function Ot(e,t){let r=Ze(e,t),n=BigInt(2)**(BigInt(8)*BigInt(t-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}function xe(e){let t=BigInt(e);if(e<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<t}var Te="DIDL",Ft=400;function le(e,t,r){return e.map((n,o)=>r(n,t[o]))}var Je=class{constructor(){this._typs=[],this._idx=new Map}has(t){return this._idx.has(t.name)}add(t,r){let n=this._typs.length;this._idx.set(t.name,n),this._typs.push(r)}merge(t,r){let n=this._idx.get(t.name),o=this._idx.get(r);if(n===void 0)throw new Error("Missing type index for "+t);if(o===void 0)throw new Error("Missing type index for "+r);this._typs[n]=this._typs[o],this._typs.splice(o,1),this._idx.delete(r)}encode(){let t=N(this._typs.length),r=h(...this._typs);return h(t,r)}indexOf(t){if(!this._idx.has(t))throw new Error("Missing type index for "+t);return v(this._idx.get(t)||0)}},we=class{visitType(t,r){throw new Error("Not implemented")}visitPrimitive(t,r){return this.visitType(t,r)}visitEmpty(t,r){return this.visitPrimitive(t,r)}visitBool(t,r){return this.visitPrimitive(t,r)}visitNull(t,r){return this.visitPrimitive(t,r)}visitReserved(t,r){return this.visitPrimitive(t,r)}visitText(t,r){return this.visitPrimitive(t,r)}visitNumber(t,r){return this.visitPrimitive(t,r)}visitInt(t,r){return this.visitNumber(t,r)}visitNat(t,r){return this.visitNumber(t,r)}visitFloat(t,r){return this.visitPrimitive(t,r)}visitFixedInt(t,r){return this.visitNumber(t,r)}visitFixedNat(t,r){return this.visitNumber(t,r)}visitPrincipal(t,r){return this.visitPrimitive(t,r)}visitConstruct(t,r){return this.visitType(t,r)}visitVec(t,r,n){return this.visitConstruct(t,n)}visitOpt(t,r,n){return this.visitConstruct(t,n)}visitRecord(t,r,n){return this.visitConstruct(t,n)}visitTuple(t,r,n){let o=r.map((i,s)=>[`_${s}_`,i]);return this.visitRecord(t,o,n)}visitVariant(t,r,n){return this.visitConstruct(t,n)}visitRec(t,r,n){return this.visitConstruct(r,n)}visitFunc(t,r){return this.visitConstruct(t,r)}visitService(t,r){return this.visitConstruct(t,r)}},ne=class{display(){return this.name}valueToString(t){return P(t)}buildTypeTable(t){t.has(this)||this._buildTypeTableImpl(t)}},k=class extends ne{checkType(t){if(this.name!==t.name)throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`);return t}_buildTypeTableImpl(t){}},j=class extends ne{checkType(t){if(t instanceof D){let r=t.getType();if(typeof r>"u")throw new Error("type mismatch with uninitialized type");return r}throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`)}encodeType(t){return t.indexOf(this.name)}},be=class extends k{accept(t,r){return t.visitEmpty(this,r)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return v(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}},Pe=class extends ne{checkType(t){throw new Error("Method not implemented for unknown.")}accept(t,r){throw t.visitType(this,r)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(){throw new Error("Unknown cannot appear as a function argument")}valueToString(){throw new Error("Unknown cannot appear as a value")}encodeType(){throw new Error("Unknown cannot be serialized")}decodeValue(t,r){let n=r.decodeValue(t,r);Object(n)!==n&&(n=Object(n));let o;return r instanceof D?o=()=>r.getType():o=()=>r,Object.defineProperty(n,"type",{value:o,writable:!0,enumerable:!1,configurable:!0}),n}_buildTypeTableImpl(){throw new Error("Unknown cannot be serialized")}get name(){return"Unknown"}},Ne=class extends k{accept(t,r){return t.visitBool(this,r)}covariant(t){if(typeof t=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){return new Uint8Array([t?1:0])}encodeType(){return v(-2)}decodeValue(t,r){switch(this.checkType(r),Q(t)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}},ve=class extends k{accept(t,r){return t.visitNull(this,r)}covariant(t){if(t===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return v(-1)}decodeValue(t,r){return this.checkType(r),null}get name(){return"null"}},oe=class extends k{accept(t,r){return t.visitReserved(this,r)}covariant(t){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return v(-16)}decodeValue(t,r){return r.name!==this.name&&r.decodeValue(t,r),null}get name(){return"reserved"}},Ce=class extends k{accept(t,r){return t.visitText(this,r)}covariant(t){if(typeof t=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){let r=new TextEncoder().encode(t),n=N(r.byteLength);return h(n,r)}encodeType(){return v(-15)}decodeValue(t,r){this.checkType(r);let n=V(t),o=I(t,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(o)}get name(){return"text"}valueToString(t){return'"'+t+'"'}},Se=class extends k{accept(t,r){return t.visitInt(this,r)}covariant(t){if(typeof t=="bigint"||Number.isInteger(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){return v(t)}encodeType(){return v(-4)}decodeValue(t,r){return this.checkType(r),Z(t)}get name(){return"int"}valueToString(t){return t.toString()}},Re=class extends k{accept(t,r){return t.visitNat(this,r)}covariant(t){if(typeof t=="bigint"&&t>=BigInt(0)||Number.isInteger(t)&&t>=0)return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){return N(t)}encodeType(){return v(-3)}decodeValue(t,r){return this.checkType(r),V(t)}get name(){return"nat"}valueToString(t){return t.toString()}},ue=class extends k{constructor(t){if(super(),this._bits=t,t!==32&&t!==64)throw new Error("not a valid float type")}accept(t,r){return t.visitFloat(this,r)}covariant(t){if(typeof t=="number"||t instanceof Number)return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){let r=new ArrayBuffer(this._bits/8),n=new DataView(r);return this._bits===32?n.setFloat32(0,t,!0):n.setFloat64(0,t,!0),r}encodeType(){let t=this._bits===32?-13:-14;return v(t)}decodeValue(t,r){this.checkType(r);let n=I(t,this._bits/8),o=new DataView(n);return this._bits===32?o.getFloat32(0,!0):o.getFloat64(0,!0)}get name(){return"float"+this._bits}valueToString(t){return t.toString()}},J=class extends k{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedInt(this,r)}covariant(t){let r=xe(this._bits-1)*BigInt(-1),n=xe(this._bits-1)-BigInt(1),o=!1;if(typeof t=="bigint")o=t>=r&&t<=n;else if(Number.isInteger(t)){let i=BigInt(t);o=i>=r&&i<=n}else o=!1;if(o)return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){return Xe(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return v(-9-t)}decodeValue(t,r){this.checkType(r);let n=Ot(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(t){return t.toString()}},z=class extends k{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedNat(this,r)}covariant(t){let r=xe(this._bits),n=!1;if(typeof t=="bigint"&&t>=BigInt(0)?n=t<r:Number.isInteger(t)&&t>=0?n=BigInt(t)<r:n=!1,n)return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){return Vt(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return v(-5-t)}decodeValue(t,r){this.checkType(r);let n=Ze(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(t){return t.toString()}},Ae=class e extends j{constructor(t){super(),this._type=t,this._blobOptimization=!1,t instanceof z&&t._bits===8&&(this._blobOptimization=!0)}accept(t,r){return t.visitVec(this,this._type,r)}covariant(t){let r=this._type instanceof z?this._type._bits:this._type instanceof J?this._type._bits:0;if(ArrayBuffer.isView(t)&&r==t.BYTES_PER_ELEMENT*8||Array.isArray(t)&&t.every((n,o)=>{try{return this._type.covariant(n)}catch(i){throw new Error(`Invalid ${this.display()} argument:
|
|
1
|
+
var Yr=Object.defineProperty;var Qr=(e,t)=>{for(var r in t)Yr(e,r,{get:t[r],enumerable:!0})};var me=class extends Error{constructor(){super("The Wasm code for the upgrade is identical to the code currently installed. No upgrade is necessary.")}};import{isNullish as en}from"@junobuild/utils";var Le=({IDL:e})=>{let t=e.Record({updated_at:e.Nat64,orbiter_id:e.Principal,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),r=e.Record({subnet_id:e.Opt(e.Principal),name:e.Opt(e.Text)}),n=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,satellite_id:e.Principal}),o=e.Record({cycles:e.Nat,destination_id:e.Principal}),i=e.Record({e8s:e.Nat64}),s=e.Record({timestamp_nanos:e.Nat64}),c=e.Record({to:e.Vec(e.Nat8),fee:i,memo:e.Nat64,from_subaccount:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:i}),u=e.Variant({TxTooOld:e.Record({allowed_window_nanos:e.Nat64}),BadFee:e.Record({expected_fee:i}),TxDuplicate:e.Record({duplicate_of:e.Nat64}),TxCreatedInFuture:e.Null,InsufficientFunds:e.Record({balance:i})}),l=e.Variant({Ok:e.Nat64,Err:u}),_=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),g=e.Record({to:_,fee:e.Opt(e.Nat),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat}),f=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,BadBurn:e.Record({min_burn_amount:e.Nat}),Duplicate:e.Record({duplicate_of:e.Nat}),BadFee:e.Record({expected_fee:e.Nat}),CreatedInFuture:e.Record({ledger_time:e.Nat64}),TooOld:e.Null,InsufficientFunds:e.Record({balance:e.Nat})}),a=e.Variant({Ok:e.Nat,Err:f}),p=e.Variant({Write:e.Null,Admin:e.Null}),m=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:p,expires_at:e.Opt(e.Nat64)}),T=e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),x=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),memory_allocation:e.Nat,compute_allocation:e.Nat}),h=e.Record({status:T,memory_size:e.Nat,cycles:e.Nat,settings:x,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8))}),w=e.Record({id:e.Principal,status:h,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),status_at:e.Nat64}),y=e.Variant({Ok:w,Err:e.Text}),b=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:p,expires_at:e.Opt(e.Nat64)}),C=e.Record({enabled:e.Bool,cycles_threshold:e.Opt(e.Nat64)}),S=e.Record({mission_control_cycles_threshold:e.Opt(e.Nat64),orbiters:e.Vec(e.Tuple(e.Principal,C)),satellites:e.Vec(e.Tuple(e.Principal,C)),cycles_threshold:e.Opt(e.Nat64)}),R=e.Record({orbiters:e.Opt(e.Vec(y)),satellites:e.Opt(e.Vec(y)),mission_control:y});return e.Service({add_mission_control_controllers:e.Func([e.Vec(e.Principal)],[],[]),add_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),create_orbiter:e.Func([e.Opt(e.Text)],[t],[]),create_orbiter_with_config:e.Func([r],[t],[]),create_satellite:e.Func([e.Text],[n],[]),create_satellite_with_config:e.Func([r],[n],[]),del_mission_control_controllers:e.Func([e.Vec(e.Principal)],[],[]),del_orbiter:e.Func([e.Principal,e.Nat],[],[]),del_orbiters_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),del_satellite:e.Func([e.Principal,e.Nat],[],[]),del_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),deposit_cycles:e.Func([o],[],[]),get_user:e.Func([],[e.Principal],["query"]),icp_transfer:e.Func([c],[l],[]),icrc_transfer:e.Func([e.Principal,g],[a],[]),list_mission_control_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,m))],["query"]),list_mission_control_statuses:e.Func([],[e.Vec(e.Tuple(e.Nat64,y))],["query"]),list_orbiter_statuses:e.Func([e.Principal],[e.Opt(e.Vec(e.Tuple(e.Nat64,y)))],["query"]),list_orbiters:e.Func([],[e.Vec(e.Tuple(e.Principal,t))],["query"]),list_satellite_statuses:e.Func([e.Principal],[e.Opt(e.Vec(e.Tuple(e.Nat64,y)))],["query"]),list_satellites:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["query"]),remove_mission_control_controllers:e.Func([e.Vec(e.Principal)],[],[]),remove_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),set_metadata:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[],[]),set_mission_control_controllers:e.Func([e.Vec(e.Principal),b],[],[]),set_orbiter:e.Func([e.Principal,e.Opt(e.Text)],[t],[]),set_orbiter_metadata:e.Func([e.Principal,e.Vec(e.Tuple(e.Text,e.Text))],[t],[]),set_orbiters_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal),b],[],[]),set_satellite:e.Func([e.Principal,e.Opt(e.Text)],[n],[]),set_satellite_metadata:e.Func([e.Principal,e.Vec(e.Tuple(e.Text,e.Text))],[n],[]),set_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal),b],[],[]),status:e.Func([S],[R],[]),top_up:e.Func([e.Principal,i],[],[]),unset_orbiter:e.Func([e.Principal],[],[]),unset_satellite:e.Func([e.Principal],[],[]),version:e.Func([],[e.Text],["query"])})};var et=({IDL:e})=>{let t=e.Record({controllers:e.Vec(e.Principal)}),r=e.Variant({Write:e.Null,Admin:e.Null}),n=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:r,expires_at:e.Opt(e.Nat64)}),o=e.Record({version:e.Opt(e.Nat64)}),i=e.Record({cycles:e.Nat,destination_id:e.Principal}),s=e.Record({to:e.Opt(e.Nat64),from:e.Opt(e.Nat64),satellite_id:e.Opt(e.Principal)}),c=e.Record({key:e.Text,collected_at:e.Nat64}),u=e.Record({inner_height:e.Nat16,inner_width:e.Nat16}),l=e.Record({title:e.Text,updated_at:e.Nat64,referrer:e.Opt(e.Text),time_zone:e.Text,session_id:e.Text,href:e.Text,created_at:e.Nat64,satellite_id:e.Principal,device:u,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),_=e.Record({safari:e.Float64,opera:e.Float64,others:e.Float64,firefox:e.Float64,chrome:e.Float64}),g=e.Record({desktop:e.Float64,others:e.Float64,mobile:e.Float64}),f=e.Record({browsers:_,devices:g}),a=e.Record({day:e.Nat8,month:e.Nat8,year:e.Int32}),p=e.Record({bounce_rate:e.Float64,average_page_views_per_session:e.Float64,daily_total_page_views:e.Vec(e.Tuple(a,e.Nat32)),total_page_views:e.Nat32,unique_page_views:e.Nat64,unique_sessions:e.Nat64}),m=e.Record({referrers:e.Vec(e.Tuple(e.Text,e.Nat32)),pages:e.Vec(e.Tuple(e.Text,e.Nat32))}),T=e.Variant({Navigate:e.Null,Restore:e.Null,Reload:e.Null,BackForward:e.Null,BackForwardCache:e.Null,Prerender:e.Null}),x=e.Record({id:e.Text,value:e.Float64,navigation_type:e.Opt(T),delta:e.Float64}),h=e.Variant({WebVitalsMetric:x}),w=e.Variant({CLS:e.Null,FCP:e.Null,INP:e.Null,LCP:e.Null,TTFB:e.Null}),y=e.Record({updated_at:e.Nat64,session_id:e.Text,data:h,href:e.Text,metric_name:w,created_at:e.Nat64,satellite_id:e.Principal,version:e.Opt(e.Nat64)}),b=e.Record({cls:e.Opt(e.Float64),fcp:e.Opt(e.Float64),inp:e.Opt(e.Float64),lcp:e.Opt(e.Float64),ttfb:e.Opt(e.Float64)}),C=e.Record({overall:b,pages:e.Vec(e.Tuple(e.Text,b))}),S=e.Record({updated_at:e.Nat64,session_id:e.Text,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),name:e.Text,created_at:e.Nat64,satellite_id:e.Principal,version:e.Opt(e.Nat64)}),R=e.Record({total:e.Vec(e.Tuple(e.Text,e.Nat32))}),E=e.Record({performance_metrics:e.Bool,track_events:e.Bool,page_views:e.Bool}),F=e.Record({updated_at:e.Nat64,features:e.Opt(E),created_at:e.Nat64,version:e.Opt(e.Nat64)}),M=e.Record({stable:e.Nat64,heap:e.Nat64}),j=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:r,expires_at:e.Opt(e.Nat64)}),U=e.Record({controller:j,controllers:e.Vec(e.Principal)}),H=e.Record({title:e.Text,updated_at:e.Opt(e.Nat64),referrer:e.Opt(e.Text),time_zone:e.Text,session_id:e.Text,href:e.Text,satellite_id:e.Principal,device:u,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),K=e.Variant({Ok:l,Err:e.Text}),W=e.Variant({Ok:e.Null,Err:e.Vec(e.Tuple(c,e.Text))}),$=e.Record({session_id:e.Text,data:h,href:e.Text,metric_name:w,satellite_id:e.Principal,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),$e=e.Variant({Ok:y,Err:e.Text}),qe=e.Record({features:e.Opt(E),version:e.Opt(e.Nat64)}),de=e.Record({updated_at:e.Opt(e.Nat64),session_id:e.Text,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),name:e.Text,satellite_id:e.Principal,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),ze=e.Variant({Ok:S,Err:e.Text});return e.Service({del_controllers:e.Func([t],[e.Vec(e.Tuple(e.Principal,n))],[]),del_satellite_config:e.Func([e.Principal,o],[],[]),deposit_cycles:e.Func([i],[],[]),get_page_views:e.Func([s],[e.Vec(e.Tuple(c,l))],["query"]),get_page_views_analytics_clients:e.Func([s],[f],["query"]),get_page_views_analytics_metrics:e.Func([s],[p],["query"]),get_page_views_analytics_top_10:e.Func([s],[m],["query"]),get_performance_metrics:e.Func([s],[e.Vec(e.Tuple(c,y))],["query"]),get_performance_metrics_analytics_web_vitals:e.Func([s],[C],["query"]),get_track_events:e.Func([s],[e.Vec(e.Tuple(c,S))],["query"]),get_track_events_analytics:e.Func([s],[R],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["query"]),list_satellite_configs:e.Func([],[e.Vec(e.Tuple(e.Principal,F))],["query"]),memory_size:e.Func([],[M],["query"]),set_controllers:e.Func([U],[e.Vec(e.Tuple(e.Principal,n))],[]),set_page_view:e.Func([c,H],[K],[]),set_page_views:e.Func([e.Vec(e.Tuple(c,H))],[W],[]),set_performance_metric:e.Func([c,$],[$e],[]),set_performance_metrics:e.Func([e.Vec(e.Tuple(c,$))],[W],[]),set_satellite_configs:e.Func([e.Vec(e.Tuple(e.Principal,qe))],[e.Vec(e.Tuple(e.Principal,F))],[]),set_track_event:e.Func([c,de],[ze],[]),set_track_events:e.Func([e.Vec(e.Tuple(c,de))],[W],[]),version:e.Func([],[e.Text],["query"])})};var tt=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Record({controllers:e.Vec(e.Principal)}),n=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,expires_at:e.Opt(e.Nat64)}),o=e.Record({updated_at:e.Opt(e.Nat64)}),i=e.Record({headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text))))}),s=e.Record({storage:i}),c=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),created_at:e.Nat64}),u=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text))}),l=e.Record({token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),_=e.Variant({Callback:e.Record({token:l,callback:e.Func([],[],[])})}),g=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(_),status_code:e.Nat16}),f=e.Record({token:e.Opt(l),body:e.Vec(e.Nat8)}),a=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,encoding_type:e.Opt(e.Text),full_path:e.Text}),p=e.Record({batch_id:e.Nat}),m=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),T=e.Record({field:m,desc:e.Bool}),x=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),h=e.Record({order:e.Opt(T),owner:e.Opt(e.Principal),matcher:e.Opt(e.Text),paginate:e.Opt(x)}),w=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),y=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),b=e.Record({key:w,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,y)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),C=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,b))}),S=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Opt(e.Text)}),R=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,c))}),E=e.Variant({Db:e.Null,Storage:e.Null}),F=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),M=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:F,created_at:e.Nat64,write:F}),j=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),expires_at:e.Opt(e.Nat64)}),U=e.Record({controller:j,controllers:e.Vec(e.Principal)}),H=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),K=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:F,write:F}),W=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),$=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([t],[],[]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Opt(e.Text)],[],[]),del_controllers:e.Func([r],[e.Vec(e.Tuple(e.Principal,n))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,o],[],[]),get_config:e.Func([],[s],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(c)],["query"]),http_request:e.Func([u],[g],["query"]),http_request_streaming_callback:e.Func([l],[f],["query"]),init_asset_upload:e.Func([a],[p],[]),list_assets:e.Func([e.Opt(e.Text),h],[C],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,S))],["query"]),list_docs:e.Func([e.Text,h],[R],["query"]),list_rules:e.Func([E],[e.Vec(e.Tuple(e.Text,M))],["query"]),set_config:e.Func([s],[],[]),set_controllers:e.Func([U],[e.Vec(e.Tuple(e.Principal,n))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_doc:e.Func([e.Text,e.Text,H],[c],[]),set_rule:e.Func([E,e.Text,K],[],[]),upload_asset_chunk:e.Func([W],[$],[]),version:e.Func([],[e.Text],["query"])})};var rt=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Record({controllers:e.Vec(e.Principal)}),n=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,expires_at:e.Opt(e.Nat64)}),o=e.Record({updated_at:e.Opt(e.Nat64)}),i=e.Record({headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text))))}),s=e.Record({storage:i}),c=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),created_at:e.Nat64}),u=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text))}),l=e.Record({token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),_=e.Variant({Callback:e.Record({token:l,callback:e.Func([],[],[])})}),g=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(_),status_code:e.Nat16}),f=e.Record({token:e.Opt(l),body:e.Vec(e.Nat8)}),a=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,encoding_type:e.Opt(e.Text),full_path:e.Text}),p=e.Record({batch_id:e.Nat}),m=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),T=e.Record({field:m,desc:e.Bool}),x=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),h=e.Record({order:e.Opt(T),matcher:e.Opt(e.Text),paginate:e.Opt(x)}),w=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),y=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),b=e.Record({key:w,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,y)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),C=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,b))}),S=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Opt(e.Text)}),R=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,c))}),E=e.Variant({Db:e.Null,Storage:e.Null}),F=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),M=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:F,created_at:e.Nat64,write:F}),j=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),expires_at:e.Opt(e.Nat64)}),U=e.Record({controller:j,controllers:e.Vec(e.Principal)}),H=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),K=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:F,write:F}),W=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),$=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([t],[],[]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Opt(e.Text)],[],[]),del_controllers:e.Func([r],[e.Vec(e.Tuple(e.Principal,n))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,o],[],[]),get_config:e.Func([],[s],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(c)],["query"]),http_request:e.Func([u],[g],["query"]),http_request_streaming_callback:e.Func([l],[f],["query"]),init_asset_upload:e.Func([a],[p],[]),list_assets:e.Func([e.Opt(e.Text),h],[C],["query"]),list_controllers:e.Func([],[e.Vec(e.Principal)],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,S))],["query"]),list_docs:e.Func([e.Text,h],[R],["query"]),list_rules:e.Func([E],[e.Vec(e.Tuple(e.Text,M))],["query"]),set_config:e.Func([s],[],[]),set_controllers:e.Func([U],[e.Vec(e.Tuple(e.Principal,n))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_doc:e.Func([e.Text,e.Text,H],[c],[]),set_rule:e.Func([E,e.Text,K],[],[]),upload_asset_chunk:e.Func([W],[$],[]),version:e.Func([],[e.Text],["query"])})};var nt=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),n=e.Record({field:r,desc:e.Bool}),o=e.Variant({Equal:e.Nat64,Between:e.Tuple(e.Nat64,e.Nat64),GreaterThan:e.Nat64,LessThan:e.Nat64}),i=e.Record({key:e.Opt(e.Text),updated_at:e.Opt(o),description:e.Opt(e.Text),created_at:e.Opt(o)}),s=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),c=e.Record({order:e.Opt(n),owner:e.Opt(e.Principal),matcher:e.Opt(i),paginate:e.Opt(s)}),u=e.Record({controllers:e.Vec(e.Principal)}),l=e.Variant({Write:e.Null,Admin:e.Null}),_=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:l,expires_at:e.Opt(e.Nat64)}),g=e.Record({version:e.Opt(e.Nat64)}),f=e.Variant({Db:e.Null,Storage:e.Null}),a=e.Record({version:e.Opt(e.Nat64)}),p=e.Record({cycles:e.Nat,destination_id:e.Principal}),m=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}),T=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),x=e.Record({key:m,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,T)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),h=e.Record({derivation_origin:e.Opt(e.Text)}),w=e.Record({internet_identity:e.Opt(h)}),y=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),b=e.Record({max_memory_size:e.Opt(y)}),C=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),S=e.Variant({Deny:e.Null,Allow:e.Null}),R=e.Record({status_code:e.Nat16,location:e.Text}),E=e.Record({iframe:e.Opt(C),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),max_memory_size:e.Opt(y),raw_access:e.Opt(S),redirects:e.Opt(e.Vec(e.Tuple(e.Text,R)))}),F=e.Record({db:e.Opt(b),authentication:e.Opt(w),storage:E}),M=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)}),j=e.Variant({Heap:e.Null,Stable:e.Null}),U=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),H=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),K=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(j),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:U,created_at:e.Nat64,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(H),write:U}),W=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)}),$=e.Record({memory:j,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}),$e=e.Variant({Callback:e.Record({token:$,callback:e.Func([],[],["query"])})}),qe=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt($e),status_code:e.Nat16}),de=e.Record({token:e.Opt($),body:e.Vec(e.Nat8)}),ze=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}),qr=e.Record({batch_id:e.Nat}),zr=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}),jr=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),Hr=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,M)),items_length:e.Nat64}),Kr=e.Record({stable:e.Nat64,heap:e.Nat64}),Wr=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:l,expires_at:e.Opt(e.Nat64)}),Gr=e.Record({controller:Wr,controllers:e.Vec(e.Principal)}),De=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),Jr=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(j),max_size:e.Opt(e.Nat),read:U,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(H),write:U}),Xr=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),Zr=e.Record({chunk_id:e.Nat});return e.Service({build_version:e.Func([],[e.Text],["query"]),commit_asset_upload:e.Func([t],[],[]),count_assets:e.Func([e.Text,c],[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,c],[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,g],[],[]),del_docs:e.Func([e.Text],[],[]),del_filtered_assets:e.Func([e.Text,c],[],[]),del_filtered_docs:e.Func([e.Text,c],[],[]),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,g))],[],[]),del_rule:e.Func([f,e.Text,a],[],[]),deposit_cycles:e.Func([p],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(x)],["query"]),get_auth_config:e.Func([],[e.Opt(w)],["query"]),get_config:e.Func([],[F],[]),get_db_config:e.Func([],[e.Opt(b)],["query"]),get_doc:e.Func([e.Text,e.Text],[e.Opt(M)],["query"]),get_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(x)))],["query"]),get_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(M)))],["query"]),get_rule:e.Func([f,e.Text],[e.Opt(K)],["query"]),get_storage_config:e.Func([],[E],["query"]),http_request:e.Func([W],[qe],["query"]),http_request_streaming_callback:e.Func([$],[de],["query"]),init_asset_upload:e.Func([ze],[qr],[]),list_assets:e.Func([e.Text,c],[zr],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,_))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,jr))],["query"]),list_docs:e.Func([e.Text,c],[Hr],["query"]),list_rules:e.Func([f],[e.Vec(e.Tuple(e.Text,K))],["query"]),memory_size:e.Func([],[Kr],["query"]),set_auth_config:e.Func([w],[],[]),set_controllers:e.Func([Gr],[e.Vec(e.Tuple(e.Principal,_))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_db_config:e.Func([b],[],[]),set_doc:e.Func([e.Text,e.Text,De],[M],[]),set_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,De))],[e.Vec(e.Tuple(e.Text,M))],[]),set_rule:e.Func([f,e.Text,Jr],[K],[]),set_storage_config:e.Func([E],[],[]),upload_asset_chunk:e.Func([Xr],[Zr],[]),version:e.Func([],[e.Text],["query"])})};import{Actor as Ir,HttpAgent as Dr}from"@dfinity/agent";import{nonNullish as ot}from"@junobuild/utils";var it=async({canisterId:e,idlFactory:t,config:r,...n})=>{let o=await D(n);return Ir.createActor(t,{agent:o,canisterId:e,...r??{}})},D=async({agent:e,...t})=>e??await Lr(t),Lr=async({identity:e,fetch:t,container:r})=>{let n=ot(r)&&r!==!1,o=n?r===!0?"http://127.0.0.1:5987":r:"https://icp-api.io";return await Dr.create({identity:e,host:o,retryTimes:10,...ot(t)&&{fetch:t},shouldFetchRootKey:n})};var st=({satelliteId:e,...t})=>se({canisterId:e,...t,idlFactory:rt}),A=({satelliteId:e,...t})=>se({canisterId:e,...t,idlFactory:nt}),at=({satelliteId:e,...t})=>se({canisterId:e,...t,idlFactory:tt}),te=({missionControlId:e,...t})=>se({canisterId:e,...t,idlFactory:Le}),fe=({orbiterId:e,...t})=>se({canisterId:e,...t,idlFactory:et}),se=({canisterId:e,idlFactory:t,...r})=>{if(en(e))throw new Error("No canister ID provided.");return it({canisterId:e,idlFactory:t,...r})};var ct=async({missionControl:e})=>(await te(e)).version(),lt=async({missionControl:e})=>(await te(e)).get_user(),ut=async({missionControl:e})=>(await te(e)).list_mission_control_controllers(),pt=async({missionControl:e,satelliteIds:t,controllerIds:r,controller:n})=>(await te(e)).set_satellites_controllers(t,r,n),dt=async({missionControl:e,controllerIds:t,controller:r})=>(await te(e)).set_mission_control_controllers(t,r);import{Principal as tn}from"@dfinity/principal";import{nonNullish as rn,toNullable as nn}from"@junobuild/utils";var je=({controllerId:e,profile:t})=>({controllerIds:[tn.fromText(e)],controller:on(t)}),on=e=>({metadata:rn(e)&&e!==""?[["profile",e]]:[],expires_at:nn(void 0),scope:{Admin:null}});var eo=({controllerId:e,profile:t,...r})=>pt({...r,...je({controllerId:e,profile:t})}),to=({controllerId:e,profile:t,...r})=>dt({...r,...je({controllerId:e,profile:t})}),ro=e=>ut(e);import{Principal as Tn}from"@dfinity/principal";var ae={reinstall:null},L={upgrade:[{skip_pre_upgrade:[!1],wasm_memory_persistence:[{replace:null}]}]};import{fromNullable as un,isNullish as pn}from"@junobuild/utils";import{CanisterStatus as sn}from"@dfinity/agent";import{ICManagementCanister as he}from"@dfinity/ic-management";import{Principal as an}from"@dfinity/principal";import{assertNonNullish as cn}from"@junobuild/utils";var mt=async({canisterId:e,actor:t})=>{let r=await D(t),{stopCanister:n}=he.create({agent:r});await n(e)},ft=async({canisterId:e,actor:t})=>{let r=await D(t),{startCanister:n}=he.create({agent:r});await n(e)},ht=async({actor:e,code:t})=>{let r=await D(e),{installCode:n}=he.create({agent:r});return n(t)};var yt=async({actor:e,canisterId:t})=>{let r=await D(e),{canisterStatus:n}=he.create({agent:r});return n(t)},_t=async({canisterId:e,path:t,...r})=>{cn(e,"A canister ID must be provided to request its status.");let n=await D(r);return(await sn.request({canisterId:an.from(e),agent:n,paths:[{kind:"metadata",key:t,path:t,decodeStrategy:"utf-8"}]})).get(t)};var gt=(o=>(o[o.AssertingExistingCode=0]="AssertingExistingCode",o[o.StoppingCanister=1]="StoppingCanister",o[o.UpgradingCode=2]="UpgradingCode",o[o.RestartingCanister=3]="RestartingCanister",o))(gt||{});var xt=e=>(e instanceof Uint8Array||(e=Uint8Array.from(e)),e.reduce((t,r)=>t+r.toString(16).padStart(2,"0"),""));var Tt=e=>crypto.subtle.digest("SHA-256",e),wt=e=>Array.from(new Uint8Array(e)).map(r=>r.toString(16).padStart(2,"0")).join(""),ho=async e=>{let t=await Tt(await e.arrayBuffer());return wt(t)},bt=async e=>{let t=await Tt(e);return wt(t)};var Pt=async({actor:e,...t})=>{await ht({actor:e,code:t})};var ee=async({wasmModule:e,canisterId:t,actor:r,onProgress:n,...o})=>{await ye({fn:async()=>await dn({wasmModule:e,canisterId:t,actor:r,...o}),onProgress:n,step:0}),await ye({fn:async()=>await mt({canisterId:t,actor:r}),onProgress:n,step:1});try{await ye({fn:async()=>await mn({wasmModule:e,canisterId:t,actor:r,...o}),onProgress:n,step:2})}finally{await ye({fn:async()=>await ft({canisterId:t,actor:r}),onProgress:n,step:3})}},ye=async({fn:e,step:t,onProgress:r})=>{r?.({step:t,state:"in_progress"});try{await e(),r?.({step:t,state:"success"})}catch(n){throw r?.({step:t,state:"error"}),n}},dn=async({actor:e,canisterId:t,wasmModule:r})=>{let{module_hash:n}=await yt({actor:e,canisterId:t}),o=un(n);if(pn(o))return;let i=await bt(r),s=xt(o);if(i===s)throw new me},mn=async({wasmModule:e,canisterId:t,actor:r,...n})=>{let o=()=>new Blob([e]).size>2e6?"chunked":"simple";await Pt({wasmModule:e,canisterId:t,actor:r,...n})};var O={};Qr(O,{Bool:()=>Vt,BoolClass:()=>be,ConstructType:()=>z,Empty:()=>Rt,EmptyClass:()=>Te,FixedIntClass:()=>X,FixedNatClass:()=>q,Float32:()=>Mt,Float64:()=>Bt,FloatClass:()=>le,Func:()=>Dt,FuncClass:()=>pe,Int:()=>Et,Int16:()=>$t,Int32:()=>qt,Int64:()=>zt,Int8:()=>Ut,IntClass:()=>ve,Nat:()=>kt,Nat16:()=>Ht,Nat32:()=>Kt,Nat64:()=>Wt,Nat8:()=>jt,NatClass:()=>Ce,Null:()=>Ot,NullClass:()=>Pe,Opt:()=>Zt,OptClass:()=>oe,PrimitiveType:()=>k,Principal:()=>Gt,PrincipalClass:()=>Ve,Rec:()=>It,RecClass:()=>Q,Record:()=>Yt,RecordClass:()=>ue,Reserved:()=>At,ReservedClass:()=>ne,Service:()=>Lt,ServiceClass:()=>Oe,Text:()=>Ft,TextClass:()=>Ne,Tuple:()=>Jt,TupleClass:()=>Re,Type:()=>re,Unknown:()=>gn,UnknownClass:()=>we,Variant:()=>Qt,VariantClass:()=>Ae,Vec:()=>Xt,VecClass:()=>Se,Visitor:()=>xe,decode:()=>_n,encode:()=>yn});import{Principal as hn}from"@dfinity/principal";function d(...e){let t=new Uint8Array(e.reduce((n,o)=>n+o.byteLength,0)),r=0;for(let n of e)t.set(new Uint8Array(n),r),r+=n.byteLength;return t}var G=class{constructor(t,r=t?.byteLength||0){this._buffer=Ke(t||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return Ke(this._view.slice())}get byteLength(){return this._view.byteLength}read(t){let r=this._view.subarray(0,t);return this._view=this._view.subarray(t),r.slice().buffer}readUint8(){let t=this._view[0];return this._view=this._view.subarray(1),t}write(t){let r=new Uint8Array(t),n=this._view.byteLength;this._view.byteOffset+this._view.byteLength+r.byteLength>=this._buffer.byteLength?this.alloc(r.byteLength):this._view=new Uint8Array(this._buffer,this._view.byteOffset,this._view.byteLength+r.byteLength),this._view.set(r,n)}get end(){return this._view.byteLength===0}alloc(t){let r=new ArrayBuffer((this._buffer.byteLength+t)*1.2|0),n=new Uint8Array(r,0,this._view.byteLength+t);n.set(this._view),this._buffer=r,this._view=n}};function He(e){return new DataView(e.buffer,e.byteOffset,e.byteLength).buffer}function Ke(e){return e instanceof Uint8Array?He(e):e instanceof ArrayBuffer?e:Array.isArray(e)?He(new Uint8Array(e)):"buffer"in e?Ke(e.buffer):He(new Uint8Array(e))}function fn(e){let r=new TextEncoder().encode(e),n=0;for(let o of r)n=(n*223+o)%2**32;return n}function B(e){if(/^_\d+_$/.test(e)||/^_0x[0-9a-fA-F]+_$/.test(e)){let t=+e.slice(1,-1);if(Number.isSafeInteger(t)&&t>=0&&t<2**32)return t}return fn(e)}function Nt(){throw new Error("unexpected end of buffer")}function Y(e,t){return e.byteLength<t&&Nt(),e.read(t)}function Z(e){let t=e.readUint8();return t===void 0&&Nt(),t}function N(e){if(typeof e=="number"&&(e=BigInt(e)),e<BigInt(0))throw new Error("Cannot leb encode negative values.");let t=(e===BigInt(0)?0:Math.ceil(Math.log2(Number(e))))+1,r=new G(new ArrayBuffer(t),0);for(;;){let n=Number(e&BigInt(127));if(e/=BigInt(128),e===BigInt(0)){r.write(new Uint8Array([n]));break}else r.write(new Uint8Array([n|128]))}return r.buffer}function V(e){let t=BigInt(1),r=BigInt(0),n;do n=Z(e),r+=BigInt(n&127).valueOf()*t,t*=BigInt(128);while(n>=128);return r}function v(e){typeof e=="number"&&(e=BigInt(e));let t=e<BigInt(0);t&&(e=-e-BigInt(1));let r=(e===BigInt(0)?0:Math.ceil(Math.log2(Number(e))))+1,n=new G(new ArrayBuffer(r),0);for(;;){let i=o(e);if(e/=BigInt(128),t&&e===BigInt(0)&&i&64||!t&&e===BigInt(0)&&!(i&64)){n.write(new Uint8Array([i]));break}else n.write(new Uint8Array([i|128]))}function o(i){let s=i%BigInt(128);return Number(t?BigInt(128)-s-BigInt(1):s)}return n.buffer}function J(e){let t=new Uint8Array(e.buffer),r=0;for(;r<t.byteLength;r++)if(t[r]<128){if(!(t[r]&64))return V(e);break}let n=new Uint8Array(Y(e,r+1)),o=BigInt(0);for(let i=n.byteLength-1;i>=0;i--)o=o*BigInt(128)+BigInt(128-(n[i]&127)-1);return-o-BigInt(1)}function vt(e,t){if(BigInt(e)<BigInt(0))throw new Error("Cannot write negative values.");return We(e,t)}function We(e,t){e=BigInt(e);let r=new G(new ArrayBuffer(Math.min(1,t)),0),n=0,o=BigInt(256),i=BigInt(0),s=Number(e%o);for(r.write(new Uint8Array([s]));++n<t;)e<0&&i===BigInt(0)&&s!==0&&(i=BigInt(1)),s=Number((e/o-i)%BigInt(256)),r.write(new Uint8Array([s])),o*=BigInt(256);return r.buffer}function Ge(e,t){let r=BigInt(Z(e)),n=BigInt(1),o=0;for(;++o<t;){n*=BigInt(256);let i=BigInt(Z(e));r=r+n*i}return r}function Ct(e,t){let r=Ge(e,t),n=BigInt(2)**(BigInt(8)*BigInt(t-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}function _e(e){let t=BigInt(e);if(e<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<t}var ge="DIDL",St=400;function ce(e,t,r){return e.map((n,o)=>r(n,t[o]))}var Je=class{constructor(){this._typs=[],this._idx=new Map}has(t){return this._idx.has(t.name)}add(t,r){let n=this._typs.length;this._idx.set(t.name,n),this._typs.push(r)}merge(t,r){let n=this._idx.get(t.name),o=this._idx.get(r);if(n===void 0)throw new Error("Missing type index for "+t);if(o===void 0)throw new Error("Missing type index for "+r);this._typs[n]=this._typs[o],this._typs.splice(o,1),this._idx.delete(r)}encode(){let t=N(this._typs.length),r=d(...this._typs);return d(t,r)}indexOf(t){if(!this._idx.has(t))throw new Error("Missing type index for "+t);return v(this._idx.get(t)||0)}},xe=class{visitType(t,r){throw new Error("Not implemented")}visitPrimitive(t,r){return this.visitType(t,r)}visitEmpty(t,r){return this.visitPrimitive(t,r)}visitBool(t,r){return this.visitPrimitive(t,r)}visitNull(t,r){return this.visitPrimitive(t,r)}visitReserved(t,r){return this.visitPrimitive(t,r)}visitText(t,r){return this.visitPrimitive(t,r)}visitNumber(t,r){return this.visitPrimitive(t,r)}visitInt(t,r){return this.visitNumber(t,r)}visitNat(t,r){return this.visitNumber(t,r)}visitFloat(t,r){return this.visitPrimitive(t,r)}visitFixedInt(t,r){return this.visitNumber(t,r)}visitFixedNat(t,r){return this.visitNumber(t,r)}visitPrincipal(t,r){return this.visitPrimitive(t,r)}visitConstruct(t,r){return this.visitType(t,r)}visitVec(t,r,n){return this.visitConstruct(t,n)}visitOpt(t,r,n){return this.visitConstruct(t,n)}visitRecord(t,r,n){return this.visitConstruct(t,n)}visitTuple(t,r,n){let o=r.map((i,s)=>[`_${s}_`,i]);return this.visitRecord(t,o,n)}visitVariant(t,r,n){return this.visitConstruct(t,n)}visitRec(t,r,n){return this.visitConstruct(r,n)}visitFunc(t,r){return this.visitConstruct(t,r)}visitService(t,r){return this.visitConstruct(t,r)}},re=class{display(){return this.name}valueToString(t){return P(t)}buildTypeTable(t){t.has(this)||this._buildTypeTableImpl(t)}},k=class extends re{checkType(t){if(this.name!==t.name)throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`);return t}_buildTypeTableImpl(t){}},z=class extends re{checkType(t){if(t instanceof Q){let r=t.getType();if(typeof r>"u")throw new Error("type mismatch with uninitialized type");return r}throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`)}encodeType(t){return t.indexOf(this.name)}},Te=class extends k{accept(t,r){return t.visitEmpty(this,r)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return v(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}},we=class extends re{checkType(t){throw new Error("Method not implemented for unknown.")}accept(t,r){throw t.visitType(this,r)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(){throw new Error("Unknown cannot appear as a function argument")}valueToString(){throw new Error("Unknown cannot appear as a value")}encodeType(){throw new Error("Unknown cannot be serialized")}decodeValue(t,r){let n=r.decodeValue(t,r);Object(n)!==n&&(n=Object(n));let o;return r instanceof Q?o=()=>r.getType():o=()=>r,Object.defineProperty(n,"type",{value:o,writable:!0,enumerable:!1,configurable:!0}),n}_buildTypeTableImpl(){throw new Error("Unknown cannot be serialized")}get name(){return"Unknown"}},be=class extends k{accept(t,r){return t.visitBool(this,r)}covariant(t){if(typeof t=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){return new Uint8Array([t?1:0])}encodeType(){return v(-2)}decodeValue(t,r){switch(this.checkType(r),Z(t)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}},Pe=class extends k{accept(t,r){return t.visitNull(this,r)}covariant(t){if(t===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return v(-1)}decodeValue(t,r){return this.checkType(r),null}get name(){return"null"}},ne=class extends k{accept(t,r){return t.visitReserved(this,r)}covariant(t){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return v(-16)}decodeValue(t,r){return r.name!==this.name&&r.decodeValue(t,r),null}get name(){return"reserved"}},Ne=class extends k{accept(t,r){return t.visitText(this,r)}covariant(t){if(typeof t=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){let r=new TextEncoder().encode(t),n=N(r.byteLength);return d(n,r)}encodeType(){return v(-15)}decodeValue(t,r){this.checkType(r);let n=V(t),o=Y(t,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(o)}get name(){return"text"}valueToString(t){return'"'+t+'"'}},ve=class extends k{accept(t,r){return t.visitInt(this,r)}covariant(t){if(typeof t=="bigint"||Number.isInteger(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){return v(t)}encodeType(){return v(-4)}decodeValue(t,r){return this.checkType(r),J(t)}get name(){return"int"}valueToString(t){return t.toString()}},Ce=class extends k{accept(t,r){return t.visitNat(this,r)}covariant(t){if(typeof t=="bigint"&&t>=BigInt(0)||Number.isInteger(t)&&t>=0)return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){return N(t)}encodeType(){return v(-3)}decodeValue(t,r){return this.checkType(r),V(t)}get name(){return"nat"}valueToString(t){return t.toString()}},le=class extends k{constructor(t){if(super(),this._bits=t,t!==32&&t!==64)throw new Error("not a valid float type")}accept(t,r){return t.visitFloat(this,r)}covariant(t){if(typeof t=="number"||t instanceof Number)return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){let r=new ArrayBuffer(this._bits/8),n=new DataView(r);return this._bits===32?n.setFloat32(0,t,!0):n.setFloat64(0,t,!0),r}encodeType(){let t=this._bits===32?-13:-14;return v(t)}decodeValue(t,r){this.checkType(r);let n=Y(t,this._bits/8),o=new DataView(n);return this._bits===32?o.getFloat32(0,!0):o.getFloat64(0,!0)}get name(){return"float"+this._bits}valueToString(t){return t.toString()}},X=class extends k{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedInt(this,r)}covariant(t){let r=_e(this._bits-1)*BigInt(-1),n=_e(this._bits-1)-BigInt(1),o=!1;if(typeof t=="bigint")o=t>=r&&t<=n;else if(Number.isInteger(t)){let i=BigInt(t);o=i>=r&&i<=n}else o=!1;if(o)return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){return We(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return v(-9-t)}decodeValue(t,r){this.checkType(r);let n=Ct(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(t){return t.toString()}},q=class extends k{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedNat(this,r)}covariant(t){let r=_e(this._bits),n=!1;if(typeof t=="bigint"&&t>=BigInt(0)?n=t<r:Number.isInteger(t)&&t>=0?n=BigInt(t)<r:n=!1,n)return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){return vt(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return v(-5-t)}decodeValue(t,r){this.checkType(r);let n=Ge(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(t){return t.toString()}},Se=class e extends z{constructor(t){super(),this._type=t,this._blobOptimization=!1,t instanceof q&&t._bits===8&&(this._blobOptimization=!0)}accept(t,r){return t.visitVec(this,this._type,r)}covariant(t){let r=this._type instanceof q?this._type._bits:this._type instanceof X?this._type._bits:0;if(ArrayBuffer.isView(t)&&r==t.BYTES_PER_ELEMENT*8||Array.isArray(t)&&t.every((n,o)=>{try{return this._type.covariant(n)}catch(i){throw new Error(`Invalid ${this.display()} argument:
|
|
2
2
|
|
|
3
|
-
index ${o} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){let r=N(t.length);if(this._blobOptimization)return
|
|
3
|
+
index ${o} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){let r=N(t.length);if(this._blobOptimization)return d(r,new Uint8Array(t));if(ArrayBuffer.isView(t))return d(r,new Uint8Array(t.buffer));let n=new G(new ArrayBuffer(r.byteLength+t.length),0);n.write(r);for(let o of t){let i=this._type.encodeValue(o);n.write(new Uint8Array(i))}return n.buffer}_buildTypeTableImpl(t){this._type.buildTypeTable(t);let r=v(-19),n=this._type.encodeType(t);t.add(this,d(r,n))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a vector type");let o=Number(V(t));if(this._type instanceof q){if(this._type._bits==8)return new Uint8Array(t.read(o));if(this._type._bits==16)return new Uint16Array(t.read(o*2));if(this._type._bits==32)return new Uint32Array(t.read(o*4));if(this._type._bits==64)return new BigUint64Array(t.read(o*8))}if(this._type instanceof X){if(this._type._bits==8)return new Int8Array(t.read(o));if(this._type._bits==16)return new Int16Array(t.read(o*2));if(this._type._bits==32)return new Int32Array(t.read(o*4));if(this._type._bits==64)return new BigInt64Array(t.read(o*8))}let i=[];for(let s=0;s<o;s++)i.push(this._type.decodeValue(t,n._type));return i}get name(){return`vec ${this._type.name}`}display(){return`vec ${this._type.display()}`}valueToString(t){return"vec {"+t.map(n=>this._type.valueToString(n)).join("; ")+"}"}},oe=class e extends z{constructor(t){super(),this._type=t}accept(t,r){return t.visitOpt(this,this._type,r)}covariant(t){try{if(Array.isArray(t)&&(t.length===0||t.length===1&&this._type.covariant(t[0])))return!0}catch(r){throw new Error(`Invalid ${this.display()} argument: ${P(t)}
|
|
4
4
|
|
|
5
|
-
-> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){return t.length===0?new Uint8Array([0]):
|
|
5
|
+
-> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){return t.length===0?new Uint8Array([0]):d(new Uint8Array([1]),this._type.encodeValue(t[0]))}_buildTypeTableImpl(t){this._type.buildTypeTable(t);let r=v(-18),n=this._type.encodeType(t);t.add(this,d(r,n))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not an option type");switch(Z(t)){case 0:return[];case 1:return[this._type.decodeValue(t,n._type)];default:throw new Error("Not an option value")}}get name(){return`opt ${this._type.name}`}display(){return`opt ${this._type.display()}`}valueToString(t){return t.length===0?"null":`opt ${this._type.valueToString(t[0])}`}},ue=class e extends z{constructor(t={}){super(),this._fields=Object.entries(t).sort((r,n)=>B(r[0])-B(n[0]))}accept(t,r){return t.visitRecord(this,this._fields,r)}tryAsTuple(){let t=[];for(let r=0;r<this._fields.length;r++){let[n,o]=this._fields[r];if(n!==`_${r}_`)return null;t.push(o)}return t}covariant(t){if(typeof t=="object"&&this._fields.every(([r,n])=>{if(!t.hasOwnProperty(r))throw new Error(`Record is missing key "${r}".`);try{return n.covariant(t[r])}catch(o){throw new Error(`Invalid ${this.display()} argument:
|
|
6
6
|
|
|
7
|
-
field ${r} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){let r=this._fields.map(([o])=>t[o]),n=
|
|
7
|
+
field ${r} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){let r=this._fields.map(([o])=>t[o]),n=ce(this._fields,r,([,o],i)=>o.encodeValue(i));return d(...n)}_buildTypeTableImpl(t){this._fields.forEach(([i,s])=>s.buildTypeTable(t));let r=v(-20),n=N(this._fields.length),o=this._fields.map(([i,s])=>d(N(B(i)),s.encodeType(t)));t.add(this,d(r,n,d(...o)))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a record type");let o={},i=0,s=0;for(;s<n._fields.length;){let[c,u]=n._fields[s];if(i>=this._fields.length){u.decodeValue(t,u),s++;continue}let[l,_]=this._fields[i],g=B(this._fields[i][0]),f=B(c);if(g===f)o[l]=_.decodeValue(t,u),i++,s++;else if(f>g)if(_ instanceof oe||_ instanceof ne)o[l]=[],i++;else throw new Error("Cannot find required field "+l);else u.decodeValue(t,u),s++}for(let[c,u]of this._fields.slice(i))if(u instanceof oe||u instanceof ne)o[c]=[];else throw new Error("Cannot find required field "+c);return o}get name(){return`record {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`record {${this._fields.map(([r,n])=>r+":"+n.display()).join("; ")}}`}valueToString(t){let r=this._fields.map(([o])=>t[o]);return`record {${ce(this._fields,r,([o,i],s)=>o+"="+i.valueToString(s)).join("; ")}}`}},Re=class e extends ue{constructor(t){let r={};t.forEach((n,o)=>r["_"+o+"_"]=n),super(r),this._components=t}accept(t,r){return t.visitTuple(this,this._components,r)}covariant(t){if(Array.isArray(t)&&t.length>=this._fields.length&&this._components.every((r,n)=>{try{return r.covariant(t[n])}catch(o){throw new Error(`Invalid ${this.display()} argument:
|
|
8
8
|
|
|
9
|
-
index ${n} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){let r=
|
|
9
|
+
index ${n} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){let r=ce(this._components,t,(n,o)=>n.encodeValue(o));return d(...r)}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("not a tuple type");if(n._components.length<this._components.length)throw new Error("tuple mismatch");let o=[];for(let[i,s]of n._components.entries())i>=this._components.length?s.decodeValue(t,s):o.push(this._components[i].decodeValue(t,s));return o}display(){return`record {${this._components.map(r=>r.display()).join("; ")}}`}valueToString(t){return`record {${ce(this._components,t,(n,o)=>n.valueToString(o)).join("; ")}}`}},Ae=class e extends z{constructor(t={}){super(),this._fields=Object.entries(t).sort((r,n)=>B(r[0])-B(n[0]))}accept(t,r){return t.visitVariant(this,this._fields,r)}covariant(t){if(typeof t=="object"&&Object.entries(t).length===1&&this._fields.every(([r,n])=>{try{return!t.hasOwnProperty(r)||n.covariant(t[r])}catch(o){throw new Error(`Invalid ${this.display()} argument:
|
|
10
10
|
|
|
11
|
-
variant ${r} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){for(let r=0;r<this._fields.length;r++){let[n,o]=this._fields[r];if(t.hasOwnProperty(n)){let i=N(r),s=o.encodeValue(t[n]);return
|
|
11
|
+
variant ${r} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){for(let r=0;r<this._fields.length;r++){let[n,o]=this._fields[r];if(t.hasOwnProperty(n)){let i=N(r),s=o.encodeValue(t[n]);return d(i,s)}}throw Error("Variant has no data: "+t)}_buildTypeTableImpl(t){this._fields.forEach(([,i])=>{i.buildTypeTable(t)});let r=v(-21),n=N(this._fields.length),o=this._fields.map(([i,s])=>d(N(B(i)),s.encodeType(t)));t.add(this,d(r,n,...o))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a variant type");let o=Number(V(t));if(o>=n._fields.length)throw Error("Invalid variant index: "+o);let[i,s]=n._fields[o];for(let[c,u]of this._fields)if(B(i)===B(c)){let l=u.decodeValue(t,s);return{[c]:l}}throw new Error("Cannot find field hash "+i)}get name(){return`variant {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`variant {${this._fields.map(([r,n])=>r+(n.name==="null"?"":`:${n.display()}`)).join("; ")}}`}valueToString(t){for(let[r,n]of this._fields)if(t.hasOwnProperty(r)){let o=n.valueToString(t[r]);return o==="null"?`variant {${r}}`:`variant {${r}=${o}}`}throw new Error("Variant has no data: "+t)}},Q=class e extends z{constructor(){super(...arguments),this._id=e._counter++,this._type=void 0}accept(t,r){if(!this._type)throw Error("Recursive type uninitialized.");return t.visitRec(this,this._type,r)}fill(t){this._type=t}getType(){return this._type}covariant(t){if(this._type&&this._type.covariant(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(t)}_buildTypeTableImpl(t){if(!this._type)throw Error("Recursive type uninitialized.");t.add(this,new Uint8Array([])),this._type.buildTypeTable(t),t.merge(this,this._type.name)}decodeValue(t,r){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(t,r)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(t)}};Q._counter=0;function Xe(e){if(Z(e)!==1)throw new Error("Cannot decode principal");let r=Number(V(e));return hn.fromUint8Array(new Uint8Array(Y(e,r)))}var Ve=class extends k{accept(t,r){return t.visitPrincipal(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=N(r.byteLength);return d(new Uint8Array([1]),n,r)}encodeType(){return v(-24)}decodeValue(t,r){return this.checkType(r),Xe(t)}get name(){return"principal"}valueToString(t){return`${this.name} "${t.toText()}"`}},pe=class extends z{constructor(t,r,n=[]){super(),this.argTypes=t,this.retTypes=r,this.annotations=n}static argsToString(t,r){if(t.length!==r.length)throw new Error("arity mismatch");return"("+t.map((n,o)=>n.valueToString(r[o])).join(", ")+")"}accept(t,r){return t.visitFunc(this,r)}covariant(t){if(Array.isArray(t)&&t.length===2&&t[0]&&t[0]._isPrincipal&&typeof t[1]=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue([t,r]){let n=t.toUint8Array(),o=N(n.byteLength),i=d(new Uint8Array([1]),o,n),s=new TextEncoder().encode(r),c=N(s.byteLength);return d(new Uint8Array([1]),i,c,s)}_buildTypeTableImpl(t){this.argTypes.forEach(l=>l.buildTypeTable(t)),this.retTypes.forEach(l=>l.buildTypeTable(t));let r=v(-22),n=N(this.argTypes.length),o=d(...this.argTypes.map(l=>l.encodeType(t))),i=N(this.retTypes.length),s=d(...this.retTypes.map(l=>l.encodeType(t))),c=N(this.annotations.length),u=d(...this.annotations.map(l=>this.encodeAnnotation(l)));t.add(this,d(r,n,o,i,s,c,u))}decodeValue(t){if(Z(t)!==1)throw new Error("Cannot decode function reference");let n=Xe(t),o=Number(V(t)),i=Y(t,o),c=new TextDecoder("utf8",{fatal:!0}).decode(i);return[n,c]}get name(){let t=this.argTypes.map(o=>o.name).join(", "),r=this.retTypes.map(o=>o.name).join(", "),n=" "+this.annotations.join(" ");return`(${t}) -> (${r})${n}`}valueToString([t,r]){return`func "${t.toText()}".${r}`}display(){let t=this.argTypes.map(o=>o.display()).join(", "),r=this.retTypes.map(o=>o.display()).join(", "),n=" "+this.annotations.join(" ");return`(${t}) \u2192 (${r})${n}`}encodeAnnotation(t){if(t==="query")return new Uint8Array([1]);if(t==="oneway")return new Uint8Array([2]);if(t==="composite_query")return new Uint8Array([3]);throw new Error("Illegal function annotation")}},Oe=class extends z{constructor(t){super(),this._fields=Object.entries(t).sort((r,n)=>r[0]<n[0]?-1:r[0]>n[0]?1:0)}accept(t,r){return t.visitService(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=N(r.length);return d(new Uint8Array([1]),n,r)}_buildTypeTableImpl(t){this._fields.forEach(([i,s])=>s.buildTypeTable(t));let r=v(-23),n=N(this._fields.length),o=this._fields.map(([i,s])=>{let c=new TextEncoder().encode(i),u=N(c.length);return d(u,c,s.encodeType(t))});t.add(this,d(r,n,...o))}decodeValue(t){return Xe(t)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(t){return`service "${t.toText()}"`}};function P(e){let t=JSON.stringify(e,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return t&&t.length>St?t.substring(0,St-3)+"...":t}function yn(e,t){if(t.length<e.length)throw Error("Wrong number of message arguments");let r=new Je;e.forEach(u=>u.buildTypeTable(r));let n=new TextEncoder().encode(ge),o=r.encode(),i=N(t.length),s=d(...e.map(u=>u.encodeType(r))),c=d(...ce(e,t,(u,l)=>{try{u.covariant(l)}catch(_){throw new Error(_.message+`
|
|
12
12
|
|
|
13
|
-
`)}return u.encodeValue(l)}));return h(n,o,i,s,c)}function Rn(e,t){let r=new X(t);if(t.byteLength<Te.length)throw new Error("Message length smaller than magic number");let n=I(r,Te.length),o=new TextDecoder().decode(n);if(o!==Te)throw new Error("Wrong magic number: "+JSON.stringify(o));function i(a){let p=[],y=Number(V(a));for(let _=0;_<y;_++){let w=Number(Z(a));switch(w){case-18:case-19:{let g=Number(Z(a));p.push([w,g]);break}case-20:case-21:{let g=[],b=Number(V(a)),C;for(;b--;){let S=Number(V(a));if(S>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof C=="number"&&C>=S)throw new Error("field id collision or not sorted");C=S;let R=Number(Z(a));g.push([S,R])}p.push([w,g]);break}case-22:{let g=[],b=Number(V(a));for(;b--;)g.push(Number(Z(a)));let C=[],S=Number(V(a));for(;S--;)C.push(Number(Z(a)));let R=[],E=Number(V(a));for(;E--;)switch(Number(V(a))){case 1:{R.push("query");break}case 2:{R.push("oneway");break}case 3:{R.push("composite_query");break}default:throw new Error("unknown annotation")}p.push([w,[g,C,R]]);break}case-23:{let g=Number(V(a)),b=[];for(;g--;){let C=Number(V(a)),S=new TextDecoder().decode(I(a,C)),R=Z(a);b.push([S,R])}p.push([w,b]);break}default:throw new Error("Illegal op_code: "+w)}}let T=[],x=Number(V(a));for(let _=0;_<x;_++)T.push(Number(Z(a)));return[p,T]}let[s,c]=i(r);if(c.length<e.length)throw new Error("Wrong number of return values");let u=s.map(a=>rr());function l(a){if(a<-24)throw new Error("future value not supported");if(a<0)switch(a){case-1:return Ut;case-2:return Mt;case-3:return qt;case-4:return $t;case-5:return Xt;case-6:return Zt;case-7:return Jt;case-8:return Yt;case-9:return Ht;case-10:return Kt;case-11:return Wt;case-12:return Gt;case-13:return zt;case-14:return jt;case-15:return Bt;case-16:return kt;case-17:return Et;case-24:return Qt;default:throw new Error("Illegal op_code: "+a)}if(a>=s.length)throw new Error("type index out of range");return u[a]}function f(a){switch(a[0]){case-19:{let p=l(a[1]);return Dt(p)}case-18:{let p=l(a[1]);return Lt(p)}case-20:{let p={};for(let[x,_]of a[1]){let w=`_${x}_`;p[w]=l(_)}let y=er(p),T=y.tryAsTuple();return Array.isArray(T)?It(...T):y}case-21:{let p={};for(let[y,T]of a[1]){let x=`_${y}_`;p[x]=l(T)}return tr(p)}case-22:{let[p,y,T]=a[1];return nr(p.map(x=>l(x)),y.map(x=>l(x)),T)}case-23:{let p={},y=a[1];for(let[T,x]of y){let _=l(x);if(_ instanceof D&&(_=_.getType()),!(_ instanceof de))throw new Error("Illegal service definition: services can only contain functions");p[T]=_}return or(p)}default:throw new Error("Illegal op_code: "+a[0])}}s.forEach((a,p)=>{if(a[0]===-22){let y=f(a);u[p].fill(y)}}),s.forEach((a,p)=>{if(a[0]!==-22){let y=f(a);u[p].fill(y)}});let m=c.map(a=>l(a)),d=e.map((a,p)=>a.decodeValue(r,m[p]));for(let a=e.length;a<m.length;a++)m[a].decodeValue(r,m[a]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return d}var Et=new be,kt=new oe,An=new Pe,Mt=new Ne,Ut=new ve,Bt=new Ce,$t=new Se,qt=new Re,zt=new ue(32),jt=new ue(64),Ht=new J(8),Kt=new J(16),Wt=new J(32),Gt=new J(64),Xt=new z(8),Zt=new z(16),Jt=new z(32),Yt=new z(64),Qt=new Fe;function It(...e){return new Ve(e)}function Dt(e){return new Ae(e)}function Lt(e){return new ie(e)}function er(e){return new pe(e)}function tr(e){return new Oe(e)}function rr(){return new D}function nr(e,t,r=[]){return new de(e,t,r)}function or(e){return new Ee(e)}import{Principal as si}from"@dfinity/principal";var ir=e=>O.encode([O.Record({user:O.Principal})],[{user:e}]),ke=e=>O.encode([O.Record({controllers:O.Vec(O.Principal)})],[{controllers:e.map(([t,r])=>t)}]);var bi=async({missionControl:e,...t})=>{let r=await pt({missionControl:e}),{missionControlId:n,...o}=e;if(!n)throw new Error("No mission control principal defined.");let i=ir(r);await te({actor:o,canisterId:On.fromText(n),arg:new Uint8Array(i),mode:ee,...t})};var vi=e=>ut(e);var sr=async({orbiter:e})=>(await he(e)).version(),Me=async({orbiter:e})=>(await he(e)).list_controllers(),ar=async({orbiter:e})=>{let{memory_size:t}=await he(e);return t()};var Vi=e=>Me(e);var Ei=e=>ar(e);import{Principal as Fn}from"@dfinity/principal";var zi=async({orbiter:e,reset:t=!1,...r})=>{let{orbiterId:n,...o}=e;if(!n)throw new Error("No orbiter principal defined.");let i=await Me({orbiter:e}),s=ke(i);await te({actor:o,canisterId:Fn.fromText(n),arg:new Uint8Array(s),mode:t?ce:ee,...r})};var Ki=e=>sr(e);import{major as cr,minor as lr,patch as ur}from"semver";var Xi=({currentVersion:e,selectedVersion:t})=>{let r=cr(e),n=cr(t),o=lr(e),i=lr(t),s=ur(e),c=ur(t);return r<n-1||o<i-1||s<c-1?{canUpgrade:!1}:{canUpgrade:!0}};import{toNullable as En}from"@junobuild/utils";var pr=async({config:e,satellite:t})=>{let{set_storage_config:r}=await A(t);return r(e)},dr=async({config:e,satellite:t})=>{let{set_db_config:r}=await A(t);return r(e)},mr=async({config:e,satellite:t})=>{let{set_auth_config:r}=await A(t);return r(e)};var fr=async({satellite:e})=>{let{get_auth_config:t}=await A(e);return t()},hr=async({satellite:e,type:t})=>(await A(e)).list_rules(t),yr=async({type:e,collection:t,rule:r,satellite:n})=>{let{set_rule:o}=await A(n);return o(e,t,r)},_r=async({satellite:e})=>{let{version:t}=await A(e);return t()},gr=async({satellite:e})=>{let{build_version:t}=await A(e);return t()},xr=async({satellite:e})=>(await ct(e)).list_controllers(),Ue=async({satellite:e})=>(await lt(e)).list_controllers(),Be=async({satellite:e})=>(await A(e)).list_controllers(),Tr=async({satellite:e})=>{let{list_custom_domains:t}=await A(e);return t()},wr=async({satellite:e,domainName:t,boundaryNodesId:r})=>{let{set_custom_domain:n}=await A(e);await n(t,En(r))},br=async({satellite:e})=>{let{memory_size:t}=await A(e);return t()},Pr=async({collection:e,satellite:t})=>{let{count_collection_docs:r}=await A(t);return r(e)},Nr=async({collection:e,satellite:t})=>{let{count_collection_assets:r}=await A(t);return r(e)},vr=async({collection:e,satellite:t})=>{let{del_docs:r}=await A(t);return r(e)},Cr=async({collection:e,satellite:t})=>{let{del_assets:r}=await A(t);return r(e)},Sr=async({args:e,satellite:t})=>{let{set_controllers:r}=await A(t);return r(e)};var Di=e=>Nr(e),Li=e=>Cr(e);import{fromNullable as $e,isNullish as Ar,nonNullish as Rr}from"@junobuild/utils";import{nonNullish as kn,toNullable as Qe}from"@junobuild/utils";var Ie=e=>Qe(kn(e)?{heap:Qe(e.heap),stable:Qe(e.stable)}:void 0);var ss=async({config:{headers:e,rewrites:t,redirects:r,iframe:n,rawAccess:o,maxMemorySize:i},satellite:s})=>{let c=(e??[]).map(({source:d,headers:a})=>[d,a]),u=(t??[]).map(({source:d,destination:a})=>[d,a]),l=(r??[]).map(({source:d,location:a,code:p})=>[d,{status_code:p,location:a}]);return await pr({satellite:s,config:{headers:c,rewrites:u,redirects:[l],iframe:[n==="same-origin"?{SameOrigin:null}:n==="allow-any"?{AllowAny:null}:{Deny:null}],raw_access:[o===!0?{Allow:null}:{Deny:null}],max_memory_size:Ie(i)}})},as=async({config:{maxMemorySize:e},...t})=>{await dr({config:{max_memory_size:Ie(e)},...t})},cs=async({config:{internetIdentity:e},...t})=>{await mr({config:{internet_identity:Ar(e?.derivationOrigin)?[]:[{derivation_origin:[e.derivationOrigin]}]},...t})},ls=async({satellite:e})=>{let t=$e(await fr({satellite:e}));if(Ar(t))return;let r=$e(t.internet_identity??[]);return{...Rr(r)&&{internetIdentity:{...Rr($e(r.derivation_origin))&&{derivationOrigin:$e(r.derivation_origin)}}}}};var ds=({deprecatedNoScope:e,...t})=>(e===!0?Ue:Be)(t),ms=e=>Sr(e);var ys=e=>Pr(e),_s=e=>vr(e);import{fromNullable as Vr,nonNullish as Mn}from"@junobuild/utils";var ws=async({satellite:e})=>(await Tr({satellite:e})).map(([r,n])=>{let o=Vr(n.version);return{domain:r,bn_id:Vr(n.bn_id),created_at:n.created_at,updated_at:n.updated_at,...Mn(o)&&{version:o}}}),bs=({satellite:e,domains:t})=>Promise.all(t.map(({domain:r,bn_id:n})=>wr({satellite:e,domainName:r,boundaryNodesId:n})));var vs=e=>br(e);import{fromNullable as se,nonNullish as L,toNullable as qe}from"@junobuild/utils";var Or={Db:null},Fr={Storage:null},Er={Public:null},kr={Private:null},Mr={Managed:null},Ur={Controllers:null},De={Heap:null},Br={Stable:null},$r=600000000n;var Le=e=>e==="storage"?Fr:Or,jr=({read:e,write:t,memory:r,maxSize:n,maxCapacity:o,version:i,mutablePermissions:s,maxTokens:c})=>({read:zr(e),write:zr(t),memory:L(r)?[Un(r)]:[],version:qe(i),max_size:qe(L(n)&&n>0?BigInt(n):void 0),max_capacity:qe(L(o)&&o>0?o:void 0),mutable_permissions:qe(s),rate_config:L(c)?[{max_tokens:BigInt(c),time_per_token_ns:$r}]:[]}),Hr=([e,t])=>{let{read:r,write:n,updated_at:o,created_at:i,max_size:s,max_capacity:c,memory:u,mutable_permissions:l,version:f,rate_config:m}=t,d=s?.[0]??0n>0n?Number(se(s)):void 0,a=c?.[0]??!1?se(c):void 0,p=se(f),y=m?.[0]?.max_tokens??0n>0n?se(m)?.max_tokens:void 0;return{collection:e,read:qr(r),write:qr(n),memory:Bn(se(u)??De),updatedAt:o,createdAt:i,...L(p)&&{version:p},...L(d)&&{maxSize:d},...L(a)&&{maxCapacity:a},mutablePermissions:se(l)??!0,...L(y)&&{maxTokens:Number(y)}}},qr=e=>"Public"in e?"public":"Private"in e?"private":"Managed"in e?"managed":"controllers",zr=e=>{switch(e){case"public":return Er;case"private":return kr;case"managed":return Mr;default:return Ur}},Un=e=>{switch(e.toLowerCase()){case"heap":return De;default:return Br}},Bn=e=>"Heap"in e?"heap":"stable";var Es=async({type:e,satellite:t})=>(await hr({satellite:t,type:Le(e)})).map(n=>Hr(n)),ks=async({rule:{collection:e,...t},type:r,satellite:n})=>{await yr({type:Le(r),rule:jr(t),satellite:n,collection:e})};import{Principal as Kr}from"@dfinity/principal";import{isNullish as $n}from"@junobuild/utils";var Ks=async({satellite:e,deprecated:t,deprecatedNoScope:r,reset:n=!1,...o})=>{let{satelliteId:i,...s}=e;if($n(i))throw new Error("No satellite principal defined.");if(t){let f=await xr({satellite:e}),m=O.encode([O.Record({controllers:O.Vec(O.Principal)})],[{controllers:f}]);await te({actor:s,canisterId:Kr.fromText(i),arg:new Uint8Array(m),mode:n?ce:ee,...o});return}let u=await(r?Ue:Be)({satellite:e}),l=ke(u);await te({actor:s,canisterId:Kr.fromText(i),arg:new Uint8Array(l),mode:n?ce:ee,...o})};import{nonNullish as qn}from"@junobuild/utils";var Js=e=>_r(e),Ys=e=>gr(e),Qs=async({satellite:{satelliteId:e,...t}})=>{let r=await bt({...t,canisterId:e,path:"juno:build"});return qn(r)&&["stock","extended"].includes(r)?r:void 0};export{Pt as UpgradeCodeProgress,fe as UpgradeCodeUnchangedError,Ct as blobSha256,Xi as checkUpgradeVersion,Di as countAssets,ys as countDocs,Li as deleteAssets,_s as deleteDocs,ls as getAuthConfig,ws as listCustomDomains,fo as listMissionControlControllers,Vi as listOrbiterControllers,Es as listRules,ds as listSatelliteControllers,vi as missionControlVersion,Ei as orbiterMemorySize,Ki as orbiterVersion,Qs as satelliteBuildType,Ys as satelliteBuildVersion,vs as satelliteMemorySize,Js as satelliteVersion,cs as setAuthConfig,bs as setCustomDomains,as as setDatastoreConfig,mo as setMissionControlController,ks as setRule,ms as setSatelliteControllers,po as setSatellitesController,ss as setStorageConfig,ge as uint8ArraySha256,bi as upgradeMissionControl,zi as upgradeOrbiter,Ks as upgradeSatellite};
|
|
13
|
+
`)}return u.encodeValue(l)}));return d(n,o,i,s,c)}function _n(e,t){let r=new G(t);if(t.byteLength<ge.length)throw new Error("Message length smaller than magic number");let n=Y(r,ge.length),o=new TextDecoder().decode(n);if(o!==ge)throw new Error("Wrong magic number: "+JSON.stringify(o));function i(a){let p=[],m=Number(V(a));for(let h=0;h<m;h++){let w=Number(J(a));switch(w){case-18:case-19:{let y=Number(J(a));p.push([w,y]);break}case-20:case-21:{let y=[],b=Number(V(a)),C;for(;b--;){let S=Number(V(a));if(S>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof C=="number"&&C>=S)throw new Error("field id collision or not sorted");C=S;let R=Number(J(a));y.push([S,R])}p.push([w,y]);break}case-22:{let y=[],b=Number(V(a));for(;b--;)y.push(Number(J(a)));let C=[],S=Number(V(a));for(;S--;)C.push(Number(J(a)));let R=[],E=Number(V(a));for(;E--;)switch(Number(V(a))){case 1:{R.push("query");break}case 2:{R.push("oneway");break}case 3:{R.push("composite_query");break}default:throw new Error("unknown annotation")}p.push([w,[y,C,R]]);break}case-23:{let y=Number(V(a)),b=[];for(;y--;){let C=Number(V(a)),S=new TextDecoder().decode(Y(a,C)),R=J(a);b.push([S,R])}p.push([w,b]);break}default:throw new Error("Illegal op_code: "+w)}}let T=[],x=Number(V(a));for(let h=0;h<x;h++)T.push(Number(J(a)));return[p,T]}let[s,c]=i(r);if(c.length<e.length)throw new Error("Wrong number of return values");let u=s.map(a=>It());function l(a){if(a<-24)throw new Error("future value not supported");if(a<0)switch(a){case-1:return Ot;case-2:return Vt;case-3:return kt;case-4:return Et;case-5:return jt;case-6:return Ht;case-7:return Kt;case-8:return Wt;case-9:return Ut;case-10:return $t;case-11:return qt;case-12:return zt;case-13:return Mt;case-14:return Bt;case-15:return Ft;case-16:return At;case-17:return Rt;case-24:return Gt;default:throw new Error("Illegal op_code: "+a)}if(a>=s.length)throw new Error("type index out of range");return u[a]}function _(a){switch(a[0]){case-19:{let p=l(a[1]);return Xt(p)}case-18:{let p=l(a[1]);return Zt(p)}case-20:{let p={};for(let[x,h]of a[1]){let w=`_${x}_`;p[w]=l(h)}let m=Yt(p),T=m.tryAsTuple();return Array.isArray(T)?Jt(...T):m}case-21:{let p={};for(let[m,T]of a[1]){let x=`_${m}_`;p[x]=l(T)}return Qt(p)}case-22:{let[p,m,T]=a[1];return Dt(p.map(x=>l(x)),m.map(x=>l(x)),T)}case-23:{let p={},m=a[1];for(let[T,x]of m){let h=l(x);if(h instanceof Q&&(h=h.getType()),!(h instanceof pe))throw new Error("Illegal service definition: services can only contain functions");p[T]=h}return Lt(p)}default:throw new Error("Illegal op_code: "+a[0])}}s.forEach((a,p)=>{if(a[0]===-22){let m=_(a);u[p].fill(m)}}),s.forEach((a,p)=>{if(a[0]!==-22){let m=_(a);u[p].fill(m)}});let g=c.map(a=>l(a)),f=e.map((a,p)=>a.decodeValue(r,g[p]));for(let a=e.length;a<g.length;a++)g[a].decodeValue(r,g[a]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return f}var Rt=new Te,At=new ne,gn=new we,Vt=new be,Ot=new Pe,Ft=new Ne,Et=new ve,kt=new Ce,Mt=new le(32),Bt=new le(64),Ut=new X(8),$t=new X(16),qt=new X(32),zt=new X(64),jt=new q(8),Ht=new q(16),Kt=new q(32),Wt=new q(64),Gt=new Ve;function Jt(...e){return new Re(e)}function Xt(e){return new Se(e)}function Zt(e){return new oe(e)}function Yt(e){return new ue(e)}function Qt(e){return new Ae(e)}function It(){return new Q}function Dt(e,t,r=[]){return new pe(e,t,r)}function Lt(e){return new Oe(e)}import{Principal as Jo}from"@dfinity/principal";var er=e=>O.encode([O.Record({user:O.Principal})],[{user:e}]),Fe=e=>O.encode([O.Record({controllers:O.Vec(O.Principal)})],[{controllers:e.map(([t,r])=>t)}]);var ci=async({missionControl:e,...t})=>{let r=await lt({missionControl:e}),{missionControlId:n,...o}=e;if(!n)throw new Error("No mission control principal defined.");let i=er(r);await ee({actor:o,canisterId:Tn.fromText(n),arg:new Uint8Array(i),mode:L,...t})};var pi=e=>ct(e);var tr=async({orbiter:e})=>(await fe(e)).version(),Ee=async({orbiter:e})=>(await fe(e)).list_controllers(),rr=async({orbiter:e})=>{let{memory_size:t}=await fe(e);return t()};var yi=e=>Ee(e);var xi=e=>rr(e);import{Principal as wn}from"@dfinity/principal";var Ci=async({orbiter:e,reset:t=!1,...r})=>{let{orbiterId:n,...o}=e;if(!n)throw new Error("No orbiter principal defined.");let i=await Ee({orbiter:e}),s=Fe(i);await ee({actor:o,canisterId:wn.fromText(n),arg:new Uint8Array(s),mode:t?ae:L,...r})};var Ai=e=>tr(e);import{major as nr,minor as or,patch as ir}from"semver";var Fi=({currentVersion:e,selectedVersion:t})=>{let r=nr(e),n=nr(t),o=or(e),i=or(t),s=ir(e),c=ir(t);return r<n-1||o<i-1||s<c-1?{canUpgrade:!1}:{canUpgrade:!0}};import{toNullable as bn}from"@junobuild/utils";var sr=async({config:e,satellite:t})=>{let{set_storage_config:r}=await A(t);return r(e)},ar=async({config:e,satellite:t})=>{let{set_db_config:r}=await A(t);return r(e)},cr=async({config:e,satellite:t})=>{let{set_auth_config:r}=await A(t);return r(e)};var lr=async({satellite:e})=>{let{get_auth_config:t}=await A(e);return t()},ur=async({satellite:e,type:t})=>(await A(e)).list_rules(t),pr=async({type:e,collection:t,rule:r,satellite:n})=>{let{set_rule:o}=await A(n);return o(e,t,r)},dr=async({satellite:e})=>{let{version:t}=await A(e);return t()},mr=async({satellite:e})=>{let{build_version:t}=await A(e);return t()},fr=async({satellite:e})=>(await st(e)).list_controllers(),ke=async({satellite:e})=>(await at(e)).list_controllers(),Me=async({satellite:e})=>(await A(e)).list_controllers(),hr=async({satellite:e})=>{let{list_custom_domains:t}=await A(e);return t()},yr=async({satellite:e,domainName:t,boundaryNodesId:r})=>{let{set_custom_domain:n}=await A(e);await n(t,bn(r))},_r=async({satellite:e})=>{let{memory_size:t}=await A(e);return t()},gr=async({collection:e,satellite:t})=>{let{count_collection_docs:r}=await A(t);return r(e)},xr=async({collection:e,satellite:t})=>{let{count_collection_assets:r}=await A(t);return r(e)},Tr=async({collection:e,satellite:t})=>{let{del_docs:r}=await A(t);return r(e)},wr=async({collection:e,satellite:t})=>{let{del_assets:r}=await A(t);return r(e)},br=async({args:e,satellite:t})=>{let{set_controllers:r}=await A(t);return r(e)};var $i=e=>xr(e),qi=e=>wr(e);import{fromNullable as Be,isNullish as Nr,nonNullish as Pr}from"@junobuild/utils";import{nonNullish as Pn,toNullable as Ze}from"@junobuild/utils";var Ye=e=>Ze(Pn(e)?{heap:Ze(e.heap),stable:Ze(e.stable)}:void 0);var Ji=async({config:{headers:e,rewrites:t,redirects:r,iframe:n,rawAccess:o,maxMemorySize:i},satellite:s})=>{let c=(e??[]).map(({source:f,headers:a})=>[f,a]),u=(t??[]).map(({source:f,destination:a})=>[f,a]),l=(r??[]).map(({source:f,location:a,code:p})=>[f,{status_code:p,location:a}]);return await sr({satellite:s,config:{headers:c,rewrites:u,redirects:[l],iframe:[n==="same-origin"?{SameOrigin:null}:n==="allow-any"?{AllowAny:null}:{Deny:null}],raw_access:[o===!0?{Allow:null}:{Deny:null}],max_memory_size:Ye(i)}})},Xi=async({config:{maxMemorySize:e},...t})=>{await ar({config:{max_memory_size:Ye(e)},...t})},Zi=async({config:{internetIdentity:e},...t})=>{await cr({config:{internet_identity:Nr(e?.derivationOrigin)?[]:[{derivation_origin:[e.derivationOrigin]}]},...t})},Yi=async({satellite:e})=>{let t=Be(await lr({satellite:e}));if(Nr(t))return;let r=Be(t.internet_identity??[]);return{...Pr(r)&&{internetIdentity:{...Pr(Be(r.derivation_origin))&&{derivationOrigin:Be(r.derivation_origin)}}}}};var Di=({deprecatedNoScope:e,...t})=>(e===!0?ke:Me)(t),Li=e=>br(e);var rs=e=>gr(e),ns=e=>Tr(e);import{fromNullable as vr,nonNullish as Nn}from"@junobuild/utils";var as=async({satellite:e})=>(await hr({satellite:e})).map(([r,n])=>{let o=vr(n.version);return{domain:r,bn_id:vr(n.bn_id),created_at:n.created_at,updated_at:n.updated_at,...Nn(o)&&{version:o}}}),cs=({satellite:e,domains:t})=>Promise.all(t.map(({domain:r,bn_id:n})=>yr({satellite:e,domainName:r,boundaryNodesId:n})));var ps=e=>_r(e);import{fromNullable as ie,nonNullish as I,toNullable as Ue}from"@junobuild/utils";var Cr={Db:null},Sr={Storage:null},Rr={Public:null},Ar={Private:null},Vr={Managed:null},Or={Controllers:null},Qe={Heap:null},Fr={Stable:null},Er=600000000n;var Ie=e=>e==="storage"?Sr:Cr,Br=({read:e,write:t,memory:r,maxSize:n,maxCapacity:o,version:i,mutablePermissions:s,maxTokens:c})=>({read:Mr(e),write:Mr(t),memory:I(r)?[vn(r)]:[],version:Ue(i),max_size:Ue(I(n)&&n>0?BigInt(n):void 0),max_capacity:Ue(I(o)&&o>0?o:void 0),mutable_permissions:Ue(s),rate_config:I(c)?[{max_tokens:BigInt(c),time_per_token_ns:Er}]:[]}),Ur=([e,t])=>{let{read:r,write:n,updated_at:o,created_at:i,max_size:s,max_capacity:c,memory:u,mutable_permissions:l,version:_,rate_config:g}=t,f=s?.[0]??0n>0n?Number(ie(s)):void 0,a=c?.[0]??!1?ie(c):void 0,p=ie(_),m=g?.[0]?.max_tokens??0n>0n?ie(g)?.max_tokens:void 0;return{collection:e,read:kr(r),write:kr(n),memory:Cn(ie(u)??Qe),updatedAt:o,createdAt:i,...I(p)&&{version:p},...I(f)&&{maxSize:f},...I(a)&&{maxCapacity:a},mutablePermissions:ie(l)??!0,...I(m)&&{maxTokens:Number(m)}}},kr=e=>"Public"in e?"public":"Private"in e?"private":"Managed"in e?"managed":"controllers",Mr=e=>{switch(e){case"public":return Rr;case"private":return Ar;case"managed":return Vr;default:return Or}},vn=e=>{switch(e.toLowerCase()){case"heap":return Qe;default:return Fr}},Cn=e=>"Heap"in e?"heap":"stable";var xs=async({type:e,satellite:t})=>(await ur({satellite:t,type:Ie(e)})).map(n=>Ur(n)),Ts=async({rule:{collection:e,...t},type:r,satellite:n})=>{await pr({type:Ie(r),rule:Br(t),satellite:n,collection:e})};import{Principal as $r}from"@dfinity/principal";import{isNullish as Sn}from"@junobuild/utils";var As=async({satellite:e,deprecated:t,deprecatedNoScope:r,reset:n=!1,...o})=>{let{satelliteId:i,...s}=e;if(Sn(i))throw new Error("No satellite principal defined.");if(t){let _=await fr({satellite:e}),g=O.encode([O.Record({controllers:O.Vec(O.Principal)})],[{controllers:_}]);await ee({actor:s,canisterId:$r.fromText(i),arg:new Uint8Array(g),mode:n?ae:L,...o});return}let u=await(r?ke:Me)({satellite:e}),l=Fe(u);await ee({actor:s,canisterId:$r.fromText(i),arg:new Uint8Array(l),mode:n?ae:L,...o})};import{nonNullish as Rn}from"@junobuild/utils";var ks=e=>dr(e),Ms=e=>mr(e),Bs=async({satellite:{satelliteId:e,...t}})=>{let r=await _t({...t,canisterId:e,path:"juno:build"});return Rn(r)&&["stock","extended"].includes(r)?r:void 0};export{gt as UpgradeCodeProgressStep,me as UpgradeCodeUnchangedError,ho as blobSha256,Fi as checkUpgradeVersion,$i as countAssets,rs as countDocs,qi as deleteAssets,ns as deleteDocs,Yi as getAuthConfig,as as listCustomDomains,ro as listMissionControlControllers,yi as listOrbiterControllers,xs as listRules,Di as listSatelliteControllers,pi as missionControlVersion,xi as orbiterMemorySize,Ai as orbiterVersion,Bs as satelliteBuildType,Ms as satelliteBuildVersion,ps as satelliteMemorySize,ks as satelliteVersion,Zi as setAuthConfig,cs as setCustomDomains,Xi as setDatastoreConfig,to as setMissionControlController,Ts as setRule,Li as setSatelliteControllers,eo as setSatellitesController,Ji as setStorageConfig,bt as uint8ArraySha256,ci as upgradeMissionControl,Ci as upgradeOrbiter,As as upgradeSatellite};
|
|
14
14
|
//# sourceMappingURL=index.js.map
|