@handofclient/embed-js 0.0.0-stage → 0.1.0
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/channel.d.ts +34 -0
- package/dist/channel.js +82 -0
- package/dist/embed.global.js +3 -0
- package/dist/host/defaultUi.d.ts +8 -0
- package/dist/host/defaultUi.js +109 -0
- package/dist/host/global.d.ts +15 -0
- package/dist/host/global.js +7 -0
- package/dist/host/index.d.ts +48 -0
- package/dist/host/index.js +133 -0
- package/dist/host/packageIdEncoding.d.ts +7 -0
- package/dist/host/packageIdEncoding.js +13 -0
- package/dist/host/watchdog.d.ts +12 -0
- package/dist/host/watchdog.js +19 -0
- package/dist/plugin/index.d.ts +87 -0
- package/dist/plugin/index.js +131 -0
- package/dist/plugin/resize.d.ts +7 -0
- package/dist/plugin/resize.js +26 -0
- package/dist/plugin/tokenProvider.d.ts +23 -0
- package/dist/plugin/tokenProvider.js +62 -0
- package/dist/protocol.d.ts +128 -0
- package/dist/protocol.js +36 -0
- package/package.json +37 -4
- package/README.md +0 -3
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface ChannelTarget {
|
|
2
|
+
window: Window;
|
|
3
|
+
/** The postMessage targetOrigin. "*" is only ever correct for the plugin side's very first
|
|
4
|
+
* hoc:hello, before it has learned (and pinned) the host's real origin - see
|
|
5
|
+
* docs/postmessage-protocol.md section 3. Every other message on either side targets a specific,
|
|
6
|
+
* known origin. */
|
|
7
|
+
origin: string;
|
|
8
|
+
}
|
|
9
|
+
type NotificationHandler<T> = (payload: T, event: MessageEvent) => void;
|
|
10
|
+
type RequestHandler<TReq, TRes> = (payload: TReq, event: MessageEvent) => TRes | Promise<TRes>;
|
|
11
|
+
/**
|
|
12
|
+
* Shared request/reply/notification plumbing for both halves of the protocol. Origin validation is
|
|
13
|
+
* intentionally injected rather than hard-coded here: the host side checks against one fixed embed
|
|
14
|
+
* origin, while the plugin side pins to whichever origin delivered its first valid hoc:init (see
|
|
15
|
+
* docs/postmessage-protocol.md section 3) - two different policies over the same wire mechanics.
|
|
16
|
+
*/
|
|
17
|
+
export declare class PostMessageChannel {
|
|
18
|
+
private readonly getTarget;
|
|
19
|
+
private readonly validateIncoming;
|
|
20
|
+
private readonly pending;
|
|
21
|
+
private readonly notificationHandlers;
|
|
22
|
+
private readonly requestHandlers;
|
|
23
|
+
private readonly listener;
|
|
24
|
+
constructor(getTarget: () => ChannelTarget | null, validateIncoming: (event: MessageEvent) => boolean);
|
|
25
|
+
send<T>(type: string, payload: T, replyTo?: string): void;
|
|
26
|
+
request<TReq, TRes>(type: string, payload: TReq, timeoutMs?: number): Promise<TRes>;
|
|
27
|
+
onNotification<T>(type: string, handler: NotificationHandler<T>): void;
|
|
28
|
+
/** Registers a handler for an incoming request; its return value (or resolved value) is
|
|
29
|
+
* automatically posted back as the reply envelope. */
|
|
30
|
+
onRequest<TReq, TRes>(type: string, handler: RequestHandler<TReq, TRes>): void;
|
|
31
|
+
dispose(): void;
|
|
32
|
+
private handleMessage;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
package/dist/channel.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { isEnvelope, makeEnvelope } from "./protocol.js";
|
|
2
|
+
const DEFAULT_REQUEST_TIMEOUT_MS = 10_000;
|
|
3
|
+
/**
|
|
4
|
+
* Shared request/reply/notification plumbing for both halves of the protocol. Origin validation is
|
|
5
|
+
* intentionally injected rather than hard-coded here: the host side checks against one fixed embed
|
|
6
|
+
* origin, while the plugin side pins to whichever origin delivered its first valid hoc:init (see
|
|
7
|
+
* docs/postmessage-protocol.md section 3) - two different policies over the same wire mechanics.
|
|
8
|
+
*/
|
|
9
|
+
export class PostMessageChannel {
|
|
10
|
+
getTarget;
|
|
11
|
+
validateIncoming;
|
|
12
|
+
pending = new Map();
|
|
13
|
+
notificationHandlers = new Map();
|
|
14
|
+
requestHandlers = new Map();
|
|
15
|
+
listener;
|
|
16
|
+
constructor(getTarget, validateIncoming) {
|
|
17
|
+
this.getTarget = getTarget;
|
|
18
|
+
this.validateIncoming = validateIncoming;
|
|
19
|
+
this.listener = (event) => this.handleMessage(event);
|
|
20
|
+
window.addEventListener("message", this.listener);
|
|
21
|
+
}
|
|
22
|
+
send(type, payload, replyTo) {
|
|
23
|
+
const target = this.getTarget();
|
|
24
|
+
if (!target)
|
|
25
|
+
return;
|
|
26
|
+
target.window.postMessage(makeEnvelope(type, payload, replyTo), target.origin);
|
|
27
|
+
}
|
|
28
|
+
request(type, payload, timeoutMs = DEFAULT_REQUEST_TIMEOUT_MS) {
|
|
29
|
+
const target = this.getTarget();
|
|
30
|
+
if (!target)
|
|
31
|
+
return Promise.reject(new Error(`No message target available for request "${type}"`));
|
|
32
|
+
const envelope = makeEnvelope(type, payload);
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
const timer = setTimeout(() => {
|
|
35
|
+
this.pending.delete(envelope.msgId);
|
|
36
|
+
reject(new Error(`Request "${type}" timed out after ${timeoutMs}ms`));
|
|
37
|
+
}, timeoutMs);
|
|
38
|
+
this.pending.set(envelope.msgId, { resolve: resolve, reject, timer });
|
|
39
|
+
target.window.postMessage(envelope, target.origin);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
onNotification(type, handler) {
|
|
43
|
+
this.notificationHandlers.set(type, handler);
|
|
44
|
+
}
|
|
45
|
+
/** Registers a handler for an incoming request; its return value (or resolved value) is
|
|
46
|
+
* automatically posted back as the reply envelope. */
|
|
47
|
+
onRequest(type, handler) {
|
|
48
|
+
this.requestHandlers.set(type, handler);
|
|
49
|
+
}
|
|
50
|
+
dispose() {
|
|
51
|
+
window.removeEventListener("message", this.listener);
|
|
52
|
+
for (const { timer, reject } of this.pending.values()) {
|
|
53
|
+
clearTimeout(timer);
|
|
54
|
+
reject(new Error("Channel disposed"));
|
|
55
|
+
}
|
|
56
|
+
this.pending.clear();
|
|
57
|
+
}
|
|
58
|
+
async handleMessage(event) {
|
|
59
|
+
if (!this.validateIncoming(event))
|
|
60
|
+
return;
|
|
61
|
+
if (!isEnvelope(event.data))
|
|
62
|
+
return;
|
|
63
|
+
const envelope = event.data;
|
|
64
|
+
if (envelope.replyTo) {
|
|
65
|
+
const pending = this.pending.get(envelope.replyTo);
|
|
66
|
+
if (!pending)
|
|
67
|
+
return; // reply to a request we no longer care about (timed out, disposed)
|
|
68
|
+
clearTimeout(pending.timer);
|
|
69
|
+
this.pending.delete(envelope.replyTo);
|
|
70
|
+
pending.resolve(envelope.payload);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const requestHandler = this.requestHandlers.get(envelope.type);
|
|
74
|
+
if (requestHandler) {
|
|
75
|
+
const result = await requestHandler(envelope.payload, event);
|
|
76
|
+
this.send(envelope.type, result, envelope.msgId);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const notificationHandler = this.notificationHandlers.get(envelope.type);
|
|
80
|
+
notificationHandler?.(envelope.payload, event);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";(()=>{var w;(function(t){t[t.Canceled=1]="Canceled",t[t.Unknown=2]="Unknown",t[t.InvalidArgument=3]="InvalidArgument",t[t.DeadlineExceeded=4]="DeadlineExceeded",t[t.NotFound=5]="NotFound",t[t.AlreadyExists=6]="AlreadyExists",t[t.PermissionDenied=7]="PermissionDenied",t[t.ResourceExhausted=8]="ResourceExhausted",t[t.FailedPrecondition=9]="FailedPrecondition",t[t.Aborted=10]="Aborted",t[t.OutOfRange=11]="OutOfRange",t[t.Unimplemented=12]="Unimplemented",t[t.Internal=13]="Internal",t[t.Unavailable=14]="Unavailable",t[t.DataLoss=15]="DataLoss",t[t.Unauthenticated=16]="Unauthenticated"})(w||(w={}));function cn(t){let e=w[t];return typeof e!="string"?t.toString():e[0].toLowerCase()+e.substring(1).replace(/[A-Z]/g,n=>"_"+n.toLowerCase())}var v=class t extends Error{constructor(e,n=w.Unknown,i,r,s){super(ai(e,n)),this.name="ConnectError",Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=e,this.code=n,this.metadata=new Headers(i??{}),this.details=r??[],this.cause=s}static from(e,n=w.Unknown){return e instanceof t?e:e instanceof Error?e.name=="AbortError"?new t(e.message,w.Canceled):new t(e.message,n,void 0,void 0,e):new t(String(e),n,void 0,void 0,e)}static[Symbol.hasInstance](e){return e instanceof Error?Object.getPrototypeOf(e)===t.prototype?!0:e.name==="ConnectError"&&"code"in e&&typeof e.code=="number"&&"metadata"in e&&"details"in e&&Array.isArray(e.details)&&"rawMessage"in e&&typeof e.rawMessage=="string"&&"cause"in e:!1}findDetails(e){let n="typeName"in e?{findMessage:r=>r===e.typeName?e:void 0}:e,i=[];for(let r of this.details){if("getType"in r){n.findMessage(r.getType().typeName)&&i.push(r);continue}let s=n.findMessage(r.type);if(s)try{i.push(s.fromBinary(r.value))}catch{}}return i}};function ai(t,e){return t.length?`[${cn(e)}] ${t}`:`[${cn(e)}]`}function I(t,e){if(!t)throw new Error(e)}var ci=34028234663852886e22,ui=-34028234663852886e22,li=4294967295,fi=2147483647,mi=-2147483648;function Y(t){if(typeof t!="number")throw new Error("invalid int 32: "+typeof t);if(!Number.isInteger(t)||t>fi||t<mi)throw new Error("invalid int 32: "+t)}function re(t){if(typeof t!="number")throw new Error("invalid uint 32: "+typeof t);if(!Number.isInteger(t)||t>li||t<0)throw new Error("invalid uint 32: "+t)}function we(t){if(typeof t!="number")throw new Error("invalid float 32: "+typeof t);if(Number.isFinite(t)&&(t>ci||t<ui))throw new Error("invalid float 32: "+t)}var zn=Symbol("@bufbuild/protobuf/enum-type");function Wn(t){let e=t[zn];return I(e,"missing enum type on enum object"),e}function un(t,e,n,i){t[zn]=ln(e,n.map(r=>({no:r.no,name:r.name,localName:t[r.no]})),i)}function ln(t,e,n){let i=Object.create(null),r=Object.create(null),s=[];for(let a of e){let c=Kn(a);s.push(c),i[a.name]=c,r[a.no]=c}return{typeName:t,values:s,findName(a){return i[a]},findNumber(a){return r[a]}}}function Xn(t,e,n){let i={};for(let r of e){let s=Kn(r);i[s.localName]=s.no,i[s.no]=s.localName}return un(i,t,e,n),i}function Kn(t){return"localName"in t?t:Object.assign(Object.assign({},t),{localName:t.name})}var m=class{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,n){let i=this.getType(),r=i.runtime.bin,s=r.makeReadOptions(n);return r.readMessage(this,s.readerFactory(e),e.byteLength,s),this}fromJson(e,n){let i=this.getType(),r=i.runtime.json,s=r.makeReadOptions(n);return r.readMessage(i,e,s,this),this}fromJsonString(e,n){let i;try{i=JSON.parse(e)}catch(r){throw new Error(`cannot decode ${this.getType().typeName} from JSON: ${r instanceof Error?r.message:String(r)}`)}return this.fromJson(i,n)}toBinary(e){let n=this.getType(),i=n.runtime.bin,r=i.makeWriteOptions(e),s=r.writerFactory();return i.writeMessage(this,s,r),s.finish()}toJson(e){let n=this.getType(),i=n.runtime.json,r=i.makeWriteOptions(e);return i.writeMessage(this,r)}toJsonString(e){var n;let i=this.toJson(e);return JSON.stringify(i,null,(n=e?.prettySpaces)!==null&&n!==void 0?n:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}};function Zn(t,e,n,i){var r;let s=(r=i?.localName)!==null&&r!==void 0?r:e.substring(e.lastIndexOf(".")+1),a={[s]:function(c){t.util.initFields(this),t.util.initPartial(c,this)}}[s];return Object.setPrototypeOf(a.prototype,new m),Object.assign(a,{runtime:t,typeName:e,fields:t.util.newFieldList(n),fromBinary(c,u){return new a().fromBinary(c,u)},fromJson(c,u){return new a().fromJson(c,u)},fromJsonString(c,u){return new a().fromJsonString(c,u)},equals(c,u){return t.util.equals(a,c,u)}}),a}function Qn(){let t=0,e=0;for(let i=0;i<28;i+=7){let r=this.buf[this.pos++];if(t|=(r&127)<<i,(r&128)==0)return this.assertBounds(),[t,e]}let n=this.buf[this.pos++];if(t|=(n&15)<<28,e=(n&112)>>4,(n&128)==0)return this.assertBounds(),[t,e];for(let i=3;i<=31;i+=7){let r=this.buf[this.pos++];if(e|=(r&127)<<i,(r&128)==0)return this.assertBounds(),[t,e]}throw new Error("invalid varint")}function ke(t,e,n){for(let s=0;s<28;s=s+7){let a=t>>>s,c=!(!(a>>>7)&&e==0),u=(c?a|128:a)&255;if(n.push(u),!c)return}let i=t>>>28&15|(e&7)<<4,r=e>>3!=0;if(n.push((r?i|128:i)&255),!!r){for(let s=3;s<31;s=s+7){let a=e>>>s,c=!!(a>>>7),u=(c?a|128:a)&255;if(n.push(u),!c)return}n.push(e>>>31&1)}}var Te=4294967296;function fn(t){let e=t[0]==="-";e&&(t=t.slice(1));let n=1e6,i=0,r=0;function s(a,c){let u=Number(t.slice(a,c));r*=n,i=i*n+u,i>=Te&&(r=r+(i/Te|0),i=i%Te)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),e?er(i,r):dn(i,r)}function _n(t,e){let n=dn(t,e),i=n.hi&2147483648;i&&(n=er(n.lo,n.hi));let r=mn(n.lo,n.hi);return i?"-"+r:r}function mn(t,e){if({lo:t,hi:e}=di(t,e),e<=2097151)return String(Te*e+t);let n=t&16777215,i=(t>>>24|e<<8)&16777215,r=e>>16&65535,s=n+i*6777216+r*6710656,a=i+r*8147497,c=r*2,u=1e7;return s>=u&&(a+=Math.floor(s/u),s%=u),a>=u&&(c+=Math.floor(a/u),a%=u),c.toString()+Yn(a)+Yn(s)}function di(t,e){return{lo:t>>>0,hi:e>>>0}}function dn(t,e){return{lo:t|0,hi:e|0}}function er(t,e){return e=~e,t?t=~t+1:e+=1,dn(t,e)}var Yn=t=>{let e=String(t);return"0000000".slice(e.length)+e};function pn(t,e){if(t>=0){for(;t>127;)e.push(t&127|128),t=t>>>7;e.push(t)}else{for(let n=0;n<9;n++)e.push(t&127|128),t=t>>7;e.push(1)}}function tr(){let t=this.buf[this.pos++],e=t&127;if((t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<7,(t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<14,(t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<21,(t&128)==0)return this.assertBounds(),e;t=this.buf[this.pos++],e|=(t&15)<<28;for(let n=5;(t&128)!==0&&n<10;n++)t=this.buf[this.pos++];if((t&128)!=0)throw new Error("invalid varint");return this.assertBounds(),e>>>0}function pi(){let t=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof t.getBigInt64=="function"&&typeof t.getBigUint64=="function"&&typeof t.setBigInt64=="function"&&typeof t.setBigUint64=="function"&&(typeof process!="object"||typeof process.env!="object"||process.env.BUF_BIGINT_DISABLE!=="1")){let r=BigInt("-9223372036854775808"),s=BigInt("9223372036854775807"),a=BigInt("0"),c=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(u){let f=typeof u=="bigint"?u:BigInt(u);if(f>s||f<r)throw new Error(`int64 invalid: ${u}`);return f},uParse(u){let f=typeof u=="bigint"?u:BigInt(u);if(f>c||f<a)throw new Error(`uint64 invalid: ${u}`);return f},enc(u){return t.setBigInt64(0,this.parse(u),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},uEnc(u){return t.setBigInt64(0,this.uParse(u),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},dec(u,f){return t.setInt32(0,u,!0),t.setInt32(4,f,!0),t.getBigInt64(0,!0)},uDec(u,f){return t.setInt32(0,u,!0),t.setInt32(4,f,!0),t.getBigUint64(0,!0)}}}let n=r=>I(/^-?[0-9]+$/.test(r),`int64 invalid: ${r}`),i=r=>I(/^[0-9]+$/.test(r),`uint64 invalid: ${r}`);return{zero:"0",supported:!1,parse(r){return typeof r!="string"&&(r=r.toString()),n(r),r},uParse(r){return typeof r!="string"&&(r=r.toString()),i(r),r},enc(r){return typeof r!="string"&&(r=r.toString()),n(r),fn(r)},uEnc(r){return typeof r!="string"&&(r=r.toString()),i(r),fn(r)},dec(r,s){return _n(r,s)},uDec(r,s){return mn(r,s)}}}var S=pi();var l;(function(t){t[t.DOUBLE=1]="DOUBLE",t[t.FLOAT=2]="FLOAT",t[t.INT64=3]="INT64",t[t.UINT64=4]="UINT64",t[t.INT32=5]="INT32",t[t.FIXED64=6]="FIXED64",t[t.FIXED32=7]="FIXED32",t[t.BOOL=8]="BOOL",t[t.STRING=9]="STRING",t[t.BYTES=12]="BYTES",t[t.UINT32=13]="UINT32",t[t.SFIXED32=15]="SFIXED32",t[t.SFIXED64=16]="SFIXED64",t[t.SINT32=17]="SINT32",t[t.SINT64=18]="SINT64"})(l||(l={}));var A;(function(t){t[t.BIGINT=0]="BIGINT",t[t.STRING=1]="STRING"})(A||(A={}));function D(t,e,n){if(e===n)return!0;if(t==l.BYTES){if(!(e instanceof Uint8Array)||!(n instanceof Uint8Array)||e.length!==n.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!==n[i])return!1;return!0}switch(t){case l.UINT64:case l.FIXED64:case l.INT64:case l.SFIXED64:case l.SINT64:return e==n}return!1}function q(t,e){switch(t){case l.BOOL:return!1;case l.UINT64:case l.FIXED64:case l.INT64:case l.SFIXED64:case l.SINT64:return e==0?S.zero:"0";case l.DOUBLE:case l.FLOAT:return 0;case l.BYTES:return new Uint8Array(0);case l.STRING:return"";default:return 0}}function xe(t,e){switch(t){case l.BOOL:return e===!1;case l.STRING:return e==="";case l.BYTES:return e instanceof Uint8Array&&!e.byteLength;default:return e==0}}var N;(function(t){t[t.Varint=0]="Varint",t[t.Bit64=1]="Bit64",t[t.LengthDelimited=2]="LengthDelimited",t[t.StartGroup=3]="StartGroup",t[t.EndGroup=4]="EndGroup",t[t.Bit32=5]="Bit32"})(N||(N={}));var be=class{constructor(e){this.stack=[],this.textEncoder=e??new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let r=0;r<this.chunks.length;r++)e+=this.chunks[r].length;let n=new Uint8Array(e),i=0;for(let r=0;r<this.chunks.length;r++)n.set(this.chunks[r],i),i+=this.chunks[r].length;return this.chunks=[],n}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),n=this.stack.pop();if(!n)throw new Error("invalid state, fork stack empty");return this.chunks=n.chunks,this.buf=n.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,n){return this.uint32((e<<3|n)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(re(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return Y(e),pn(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let n=this.textEncoder.encode(e);return this.uint32(n.byteLength),this.raw(n)}float(e){we(e);let n=new Uint8Array(4);return new DataView(n.buffer).setFloat32(0,e,!0),this.raw(n)}double(e){let n=new Uint8Array(8);return new DataView(n.buffer).setFloat64(0,e,!0),this.raw(n)}fixed32(e){re(e);let n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,e,!0),this.raw(n)}sfixed32(e){Y(e);let n=new Uint8Array(4);return new DataView(n.buffer).setInt32(0,e,!0),this.raw(n)}sint32(e){return Y(e),e=(e<<1^e>>31)>>>0,pn(e,this.buf),this}sfixed64(e){let n=new Uint8Array(8),i=new DataView(n.buffer),r=S.enc(e);return i.setInt32(0,r.lo,!0),i.setInt32(4,r.hi,!0),this.raw(n)}fixed64(e){let n=new Uint8Array(8),i=new DataView(n.buffer),r=S.uEnc(e);return i.setInt32(0,r.lo,!0),i.setInt32(4,r.hi,!0),this.raw(n)}int64(e){let n=S.enc(e);return ke(n.lo,n.hi,this.buf),this}sint64(e){let n=S.enc(e),i=n.hi>>31,r=n.lo<<1^i,s=(n.hi<<1|n.lo>>>31)^i;return ke(r,s,this.buf),this}uint64(e){let n=S.uEnc(e);return ke(n.lo,n.hi,this.buf),this}},ve=class{constructor(e,n){this.varint64=Qn,this.uint32=tr,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=n??new TextDecoder}tag(){let e=this.uint32(),n=e>>>3,i=e&7;if(n<=0||i<0||i>5)throw new Error("illegal tag: field no "+n+" wire type "+i);return[n,i]}skip(e,n){let i=this.pos;switch(e){case N.Varint:for(;this.buf[this.pos++]&128;);break;case N.Bit64:this.pos+=4;case N.Bit32:this.pos+=4;break;case N.LengthDelimited:let r=this.uint32();this.pos+=r;break;case N.StartGroup:for(;;){let[s,a]=this.tag();if(a===N.EndGroup){if(n!==void 0&&s!==n)throw new Error("invalid end group tag");break}this.skip(a,s)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(i,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return S.dec(...this.varint64())}uint64(){return S.uDec(...this.varint64())}sint64(){let[e,n]=this.varint64(),i=-(e&1);return e=(e>>>1|(n&1)<<31)^i,n=n>>>1^i,S.dec(e,n)}bool(){let[e,n]=this.varint64();return e!==0||n!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return S.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return S.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),n=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(n,n+e)}string(){return this.textDecoder.decode(this.bytes())}};function nr(t,e,n,i){let r;return{typeName:e,extendee:n,get field(){if(!r){let s=typeof i=="function"?i():i;s.name=e.split(".").pop(),s.jsonName=`[${e}]`,r=t.util.newFieldList([s]).list()[0]}return r},runtime:t}}function Ie(t){let e=t.field.localName,n=Object.create(null);return n[e]=hi(t),[n,()=>n[e]]}function hi(t){let e=t.field;if(e.repeated)return[];if(e.default!==void 0)return e.default;switch(e.kind){case"enum":return e.T.values[0].no;case"scalar":return q(e.T,e.L);case"message":let n=e.T,i=new n;return n.fieldWrapper?n.fieldWrapper.unwrapField(i):i;case"map":throw"map fields are not allowed to be extensions"}}function rr(t,e){if(!e.repeated&&(e.kind=="enum"||e.kind=="scalar")){for(let n=t.length-1;n>=0;--n)if(t[n].no==e.no)return[t[n]];return[]}return t.filter(n=>n.no===e.no)}var M="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Se=[];for(let t=0;t<M.length;t++)Se[M[t].charCodeAt(0)]=t;Se[45]=M.indexOf("+");Se[95]=M.indexOf("/");var Q={dec(t){let e=t.length*3/4;t[t.length-2]=="="?e-=2:t[t.length-1]=="="&&(e-=1);let n=new Uint8Array(e),i=0,r=0,s,a=0;for(let c=0;c<t.length;c++){if(s=Se[t.charCodeAt(c)],s===void 0)switch(t[c]){case"=":r=0;case`
|
|
2
|
+
`:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(r){case 0:a=s,r=1;break;case 1:n[i++]=a<<2|(s&48)>>4,a=s,r=2;break;case 2:n[i++]=(a&15)<<4|(s&60)>>2,a=s,r=3;break;case 3:n[i++]=(a&3)<<6|s,r=0;break}}if(r==1)throw Error("invalid base64 string.");return n.subarray(0,i)},enc(t){let e="",n=0,i,r=0;for(let s=0;s<t.length;s++)switch(i=t[s],n){case 0:e+=M[i>>2],r=(i&3)<<4,n=1;break;case 1:e+=M[r|i>>4],r=(i&15)<<2,n=2;break;case 2:e+=M[r|i>>6],e+=M[i&63],n=0;break}return n&&(e+=M[r],e+="=",n==1&&(e+="=")),e}};function ir(t,e,n){sr(e,t);let i=e.runtime.bin.makeReadOptions(n),r=rr(t.getType().runtime.bin.listUnknownFields(t),e.field),[s,a]=Ie(e);for(let c of r)e.runtime.bin.readField(s,i.readerFactory(c.data),e.field,c.wireType,i);return a()}function or(t,e,n,i){sr(e,t);let r=e.runtime.bin.makeReadOptions(i),s=e.runtime.bin.makeWriteOptions(i);if(hn(t,e)){let f=t.getType().runtime.bin.listUnknownFields(t).filter(p=>p.no!=e.field.no);t.getType().runtime.bin.discardUnknownFields(t);for(let p of f)t.getType().runtime.bin.onUnknownField(t,p.no,p.wireType,p.data)}let a=s.writerFactory(),c=e.field;!c.opt&&!c.repeated&&(c.kind=="enum"||c.kind=="scalar")&&(c=Object.assign(Object.assign({},e.field),{opt:!0})),e.runtime.bin.writeField(c,n,a,s);let u=r.readerFactory(a.finish());for(;u.pos<u.len;){let[f,p]=u.tag(),h=u.skip(p,f);t.getType().runtime.bin.onUnknownField(t,f,p,h)}}function hn(t,e){let n=t.getType();return e.extendee.typeName===n.typeName&&!!n.runtime.bin.listUnknownFields(t).find(i=>i.no==e.field.no)}function sr(t,e){I(t.extendee.typeName==e.getType().typeName,`extension ${t.typeName} can only be applied to message ${t.extendee.typeName}`)}function Ee(t,e){let n=t.localName;if(t.repeated)return e[n].length>0;if(t.oneof)return e[t.oneof.localName].case===n;switch(t.kind){case"enum":case"scalar":return t.opt||t.req?e[n]!==void 0:t.kind=="enum"?e[n]!==t.T.values[0].no:!xe(t.T,e[n]);case"message":return e[n]!==void 0;case"map":return Object.keys(e[n]).length>0}}function yn(t,e){let n=t.localName,i=!t.opt&&!t.req;if(t.repeated)e[n]=[];else if(t.oneof)e[t.oneof.localName]={case:void 0};else switch(t.kind){case"map":e[n]={};break;case"enum":e[n]=i?t.T.values[0].no:void 0;break;case"scalar":e[n]=i?q(t.T,t.L):void 0;break;case"message":e[n]=void 0;break}}function U(t,e){if(t===null||typeof t!="object"||!Object.getOwnPropertyNames(m.prototype).every(i=>i in t&&typeof t[i]=="function"))return!1;let n=t.getType();return n===null||typeof n!="function"||!("typeName"in n)||typeof n.typeName!="string"?!1:e===void 0?!0:n.typeName==e.typeName}function Ne(t,e){return U(e)||!t.fieldWrapper?e:t.fieldWrapper.wrapField(e)}var Bo={"google.protobuf.DoubleValue":l.DOUBLE,"google.protobuf.FloatValue":l.FLOAT,"google.protobuf.Int64Value":l.INT64,"google.protobuf.UInt64Value":l.UINT64,"google.protobuf.Int32Value":l.INT32,"google.protobuf.UInt32Value":l.UINT32,"google.protobuf.BoolValue":l.BOOL,"google.protobuf.StringValue":l.STRING,"google.protobuf.BytesValue":l.BYTES};var ar={ignoreUnknownFields:!1},cr={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function yi(t){return t?Object.assign(Object.assign({},ar),t):ar}function gi(t){return t?Object.assign(Object.assign({},cr),t):cr}var Fe=Symbol(),Je=Symbol();function fr(){return{makeReadOptions:yi,makeWriteOptions:gi,readMessage(t,e,n,i){if(e==null||Array.isArray(e)||typeof e!="object")throw new Error(`cannot decode message ${t.typeName} from JSON: ${C(e)}`);i=i??new t;let r=new Map,s=n.typeRegistry;for(let[a,c]of Object.entries(e)){let u=t.fields.findJsonName(a);if(u){if(u.oneof){if(c===null&&u.kind=="scalar")continue;let f=r.get(u.oneof);if(f!==void 0)throw new Error(`cannot decode message ${t.typeName} from JSON: multiple keys for oneof "${u.oneof.name}" present: "${f}", "${a}"`);r.set(u.oneof,a)}ur(i,c,u,n,t)}else{let f=!1;if(s?.findExtension&&a.startsWith("[")&&a.endsWith("]")){let p=s.findExtension(a.substring(1,a.length-1));if(p&&p.extendee.typeName==t.typeName){f=!0;let[h,y]=Ie(p);ur(h,c,p.field,n,p),or(i,p,y(),n)}}if(!f&&!n.ignoreUnknownFields)throw new Error(`cannot decode message ${t.typeName} from JSON: key "${a}" is unknown`)}}return i},writeMessage(t,e){let n=t.getType(),i={},r;try{for(r of n.fields.byNumber()){if(!Ee(r,t)){if(r.req)throw"required field not set";if(!e.emitDefaultValues||!Ti(r))continue}let a=r.oneof?t[r.oneof.localName].value:t[r.localName],c=lr(r,a,e);c!==void 0&&(i[e.useProtoFieldName?r.name:r.jsonName]=c)}let s=e.typeRegistry;if(s?.findExtensionFor)for(let a of n.runtime.bin.listUnknownFields(t)){let c=s.findExtensionFor(n.typeName,a.no);if(c&&hn(t,c)){let u=ir(t,c,e),f=lr(c.field,u,e);f!==void 0&&(i[c.field.jsonName]=f)}}}catch(s){let a=r?`cannot encode field ${n.typeName}.${r.name} to JSON`:`cannot encode message ${n.typeName} to JSON`,c=s instanceof Error?s.message:String(s);throw new Error(a+(c.length>0?`: ${c}`:""))}return i},readScalar(t,e,n){return ie(t,e,n??A.BIGINT,!0)},writeScalar(t,e,n){if(e!==void 0&&(n||xe(t,e)))return Pe(t,e)},debug:C}}function C(t){if(t===null)return"null";switch(typeof t){case"object":return Array.isArray(t)?"array":"object";case"string":return t.length>100?"string":`"${t.split('"').join('\\"')}"`;default:return String(t)}}function ur(t,e,n,i,r){let s=n.localName;if(n.repeated){if(I(n.kind!="map"),e===null)return;if(!Array.isArray(e))throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${C(e)}`);let a=t[s];for(let c of e){if(c===null)throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${C(c)}`);switch(n.kind){case"message":a.push(n.T.fromJson(c,i));break;case"enum":let u=gn(n.T,c,i.ignoreUnknownFields,!0);u!==Je&&a.push(u);break;case"scalar":try{a.push(ie(n.T,c,n.L,!0))}catch(f){let p=`cannot decode field ${r.typeName}.${n.name} from JSON: ${C(c)}`;throw f instanceof Error&&f.message.length>0&&(p+=`: ${f.message}`),new Error(p)}break}}}else if(n.kind=="map"){if(e===null)return;if(typeof e!="object"||Array.isArray(e))throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${C(e)}`);let a=t[s];for(let[c,u]of Object.entries(e)){if(u===null)throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: map value null`);let f;try{f=wi(n.K,c)}catch(p){let h=`cannot decode map key for field ${r.typeName}.${n.name} from JSON: ${C(e)}`;throw p instanceof Error&&p.message.length>0&&(h+=`: ${p.message}`),new Error(h)}switch(n.V.kind){case"message":a[f]=n.V.T.fromJson(u,i);break;case"enum":let p=gn(n.V.T,u,i.ignoreUnknownFields,!0);p!==Je&&(a[f]=p);break;case"scalar":try{a[f]=ie(n.V.T,u,A.BIGINT,!0)}catch(h){let y=`cannot decode map value for field ${r.typeName}.${n.name} from JSON: ${C(e)}`;throw h instanceof Error&&h.message.length>0&&(y+=`: ${h.message}`),new Error(y)}break}}}else switch(n.oneof&&(t=t[n.oneof.localName]={case:s},s="value"),n.kind){case"message":let a=n.T;if(e===null&&a.typeName!="google.protobuf.Value")return;let c=t[s];U(c)?c.fromJson(e,i):(t[s]=c=a.fromJson(e,i),a.fieldWrapper&&!n.oneof&&(t[s]=a.fieldWrapper.unwrapField(c)));break;case"enum":let u=gn(n.T,e,i.ignoreUnknownFields,!1);switch(u){case Fe:yn(n,t);break;case Je:break;default:t[s]=u;break}break;case"scalar":try{let f=ie(n.T,e,n.L,!1);f===Fe?yn(n,t):t[s]=f}catch(f){let p=`cannot decode field ${r.typeName}.${n.name} from JSON: ${C(e)}`;throw f instanceof Error&&f.message.length>0&&(p+=`: ${f.message}`),new Error(p)}break}}function wi(t,e){if(t===l.BOOL)switch(e){case"true":e=!0;break;case"false":e=!1;break}return ie(t,e,A.BIGINT,!0).toString()}function ie(t,e,n,i){if(e===null)return i?q(t,n):Fe;switch(t){case l.DOUBLE:case l.FLOAT:if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""||typeof e=="string"&&e.trim().length!==e.length||typeof e!="string"&&typeof e!="number")break;let r=Number(e);if(Number.isNaN(r)||!Number.isFinite(r))break;return t==l.FLOAT&&we(r),r;case l.INT32:case l.FIXED32:case l.SFIXED32:case l.SINT32:case l.UINT32:let s;if(typeof e=="number"?s=e:typeof e=="string"&&e.length>0&&e.trim().length===e.length&&(s=Number(e)),s===void 0)break;return t==l.UINT32||t==l.FIXED32?re(s):Y(s),s;case l.INT64:case l.SFIXED64:case l.SINT64:if(typeof e!="number"&&typeof e!="string")break;let a=S.parse(e);return n?a.toString():a;case l.FIXED64:case l.UINT64:if(typeof e!="number"&&typeof e!="string")break;let c=S.uParse(e);return n?c.toString():c;case l.BOOL:if(typeof e!="boolean")break;return e;case l.STRING:if(typeof e!="string")break;try{encodeURIComponent(e)}catch{throw new Error("invalid UTF8")}return e;case l.BYTES:if(e==="")return new Uint8Array(0);if(typeof e!="string")break;return Q.dec(e)}throw new Error}function gn(t,e,n,i){if(e===null)return t.typeName=="google.protobuf.NullValue"?0:i?t.values[0].no:Fe;switch(typeof e){case"number":if(Number.isInteger(e))return e;break;case"string":let r=t.findName(e);if(r!==void 0)return r.no;if(n)return Je;break}throw new Error(`cannot decode enum ${t.typeName} from JSON: ${C(e)}`)}function Ti(t){return t.repeated||t.kind=="map"?!0:!(t.oneof||t.kind=="message"||t.opt||t.req)}function lr(t,e,n){if(t.kind=="map"){I(typeof e=="object"&&e!=null);let i={},r=Object.entries(e);switch(t.V.kind){case"scalar":for(let[a,c]of r)i[a.toString()]=Pe(t.V.T,c);break;case"message":for(let[a,c]of r)i[a.toString()]=c.toJson(n);break;case"enum":let s=t.V.T;for(let[a,c]of r)i[a.toString()]=wn(s,c,n.enumAsInteger);break}return n.emitDefaultValues||r.length>0?i:void 0}if(t.repeated){I(Array.isArray(e));let i=[];switch(t.kind){case"scalar":for(let r=0;r<e.length;r++)i.push(Pe(t.T,e[r]));break;case"enum":for(let r=0;r<e.length;r++)i.push(wn(t.T,e[r],n.enumAsInteger));break;case"message":for(let r=0;r<e.length;r++)i.push(e[r].toJson(n));break}return n.emitDefaultValues||i.length>0?i:void 0}switch(t.kind){case"scalar":return Pe(t.T,e);case"enum":return wn(t.T,e,n.enumAsInteger);case"message":return Ne(t.T,e).toJson(n)}}function wn(t,e,n){var i;if(I(typeof e=="number"),t.typeName=="google.protobuf.NullValue")return null;if(n)return e;let r=t.findNumber(e);return(i=r?.name)!==null&&i!==void 0?i:e}function Pe(t,e){switch(t){case l.INT32:case l.SFIXED32:case l.SINT32:case l.FIXED32:case l.UINT32:return I(typeof e=="number"),e;case l.FLOAT:case l.DOUBLE:return I(typeof e=="number"),Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":e;case l.STRING:return I(typeof e=="string"),e;case l.BOOL:return I(typeof e=="boolean"),e;case l.UINT64:case l.FIXED64:case l.INT64:case l.SFIXED64:case l.SINT64:return I(typeof e=="bigint"||typeof e=="string"||typeof e=="number"),e.toString();case l.BYTES:return I(e instanceof Uint8Array),Q.enc(e)}}var _=Symbol("@bufbuild/protobuf/unknown-fields"),mr={readUnknownFields:!0,readerFactory:t=>new ve(t)},dr={writeUnknownFields:!0,writerFactory:()=>new be};function ki(t){return t?Object.assign(Object.assign({},mr),t):mr}function xi(t){return t?Object.assign(Object.assign({},dr),t):dr}function gr(){return{makeReadOptions:ki,makeWriteOptions:xi,listUnknownFields(t){var e;return(e=t[_])!==null&&e!==void 0?e:[]},discardUnknownFields(t){delete t[_]},writeUnknownFields(t,e){let i=t[_];if(i)for(let r of i)e.tag(r.no,r.wireType).raw(r.data)},onUnknownField(t,e,n,i){let r=t;Array.isArray(r[_])||(r[_]=[]),r[_].push({no:e,wireType:n,data:i})},readMessage(t,e,n,i,r){let s=t.getType(),a=r?e.len:e.pos+n,c,u;for(;e.pos<a&&([c,u]=e.tag(),!(r===!0&&u==N.EndGroup));){let f=s.fields.find(c);if(!f){let p=e.skip(u,c);i.readUnknownFields&&this.onUnknownField(t,c,u,p);continue}pr(t,e,f,u,i)}if(r&&(u!=N.EndGroup||c!==n))throw new Error("invalid end group tag")},readField:pr,writeMessage(t,e,n){let i=t.getType();for(let r of i.fields.byNumber()){if(!Ee(r,t)){if(r.req)throw new Error(`cannot encode field ${i.typeName}.${r.name} to binary: required field not set`);continue}let s=r.oneof?t[r.oneof.localName].value:t[r.localName];hr(r,s,e,n)}return n.writeUnknownFields&&this.writeUnknownFields(t,e),e},writeField(t,e,n,i){e!==void 0&&hr(t,e,n,i)}}}function pr(t,e,n,i,r){let{repeated:s,localName:a}=n;switch(n.oneof&&(t=t[n.oneof.localName],t.case!=a&&delete t.value,t.case=a,a="value"),n.kind){case"scalar":case"enum":let c=n.kind=="enum"?l.INT32:n.T,u=Ue;if(n.kind=="scalar"&&n.L>0&&(u=vi),s){let y=t[a];if(i==N.LengthDelimited&&c!=l.STRING&&c!=l.BYTES){let g=e.uint32()+e.pos;for(;e.pos<g;)y.push(u(e,c))}else y.push(u(e,c))}else t[a]=u(e,c);break;case"message":let f=n.T;s?t[a].push(Be(e,new f,r,n)):U(t[a])?Be(e,t[a],r,n):(t[a]=Be(e,new f,r,n),f.fieldWrapper&&!n.oneof&&!n.repeated&&(t[a]=f.fieldWrapper.unwrapField(t[a])));break;case"map":let[p,h]=bi(n,e,r);t[a][p]=h;break}}function Be(t,e,n,i){let r=e.getType().runtime.bin,s=i?.delimited;return r.readMessage(e,t,s?i.no:t.uint32(),n,s),e}function bi(t,e,n){let i=e.uint32(),r=e.pos+i,s,a;for(;e.pos<r;){let[c]=e.tag();switch(c){case 1:s=Ue(e,t.K);break;case 2:switch(t.V.kind){case"scalar":a=Ue(e,t.V.T);break;case"enum":a=e.int32();break;case"message":a=Be(e,new t.V.T,n,void 0);break}break}}if(s===void 0&&(s=q(t.K,A.BIGINT)),typeof s!="string"&&typeof s!="number"&&(s=s.toString()),a===void 0)switch(t.V.kind){case"scalar":a=q(t.V.T,A.BIGINT);break;case"enum":a=t.V.T.values[0].no;break;case"message":a=new t.V.T;break}return[s,a]}function vi(t,e){let n=Ue(t,e);return typeof n=="bigint"?n.toString():n}function Ue(t,e){switch(e){case l.STRING:return t.string();case l.BOOL:return t.bool();case l.DOUBLE:return t.double();case l.FLOAT:return t.float();case l.INT32:return t.int32();case l.INT64:return t.int64();case l.UINT64:return t.uint64();case l.FIXED64:return t.fixed64();case l.BYTES:return t.bytes();case l.FIXED32:return t.fixed32();case l.SFIXED32:return t.sfixed32();case l.SFIXED64:return t.sfixed64();case l.SINT64:return t.sint64();case l.UINT32:return t.uint32();case l.SINT32:return t.sint32()}}function hr(t,e,n,i){I(e!==void 0);let r=t.repeated;switch(t.kind){case"scalar":case"enum":let s=t.kind=="enum"?l.INT32:t.T;if(r)if(I(Array.isArray(e)),t.packed)Si(n,s,t.no,e);else for(let a of e)oe(n,s,t.no,a);else oe(n,s,t.no,e);break;case"message":if(r){I(Array.isArray(e));for(let a of e)yr(n,i,t,a)}else yr(n,i,t,e);break;case"map":I(typeof e=="object"&&e!=null);for(let[a,c]of Object.entries(e))Ii(n,i,t,a,c);break}}function Ii(t,e,n,i,r){t.tag(n.no,N.LengthDelimited),t.fork();let s=i;switch(n.K){case l.INT32:case l.FIXED32:case l.UINT32:case l.SFIXED32:case l.SINT32:s=Number.parseInt(i);break;case l.BOOL:I(i=="true"||i=="false"),s=i=="true";break}switch(oe(t,n.K,1,s),n.V.kind){case"scalar":oe(t,n.V.T,2,r);break;case"enum":oe(t,l.INT32,2,r);break;case"message":I(r!==void 0),t.tag(2,N.LengthDelimited).bytes(r.toBinary(e));break}t.join()}function yr(t,e,n,i){let r=Ne(n.T,i);n.delimited?t.tag(n.no,N.StartGroup).raw(r.toBinary(e)).tag(n.no,N.EndGroup):t.tag(n.no,N.LengthDelimited).bytes(r.toBinary(e))}function oe(t,e,n,i){I(i!==void 0);let[r,s]=wr(e);t.tag(n,r)[s](i)}function Si(t,e,n,i){if(!i.length)return;t.tag(n,N.LengthDelimited).fork();let[,r]=wr(e);for(let s=0;s<i.length;s++)t[r](i[s]);t.join()}function wr(t){let e=N.Varint;switch(t){case l.BYTES:case l.STRING:e=N.LengthDelimited;break;case l.DOUBLE:case l.FIXED64:case l.SFIXED64:e=N.Bit64;break;case l.FIXED32:case l.SFIXED32:case l.FLOAT:e=N.Bit32;break}let n=l[t].toLowerCase();return[e,n]}function Tr(){return{setEnumType:un,initPartial(t,e){if(t===void 0)return;let n=e.getType();for(let i of n.fields.byMember()){let r=i.localName,s=e,a=t;if(a[r]!=null)switch(i.kind){case"oneof":let c=a[r].case;if(c===void 0)continue;let u=i.findField(c),f=a[r].value;u&&u.kind=="message"&&!U(f,u.T)?f=new u.T(f):u&&u.kind==="scalar"&&u.T===l.BYTES&&(f=se(f)),s[r]={case:c,value:f};break;case"scalar":case"enum":let p=a[r];i.T===l.BYTES&&(p=i.repeated?p.map(se):se(p)),s[r]=p;break;case"map":switch(i.V.kind){case"scalar":case"enum":if(i.V.T===l.BYTES)for(let[d,g]of Object.entries(a[r]))s[r][d]=se(g);else Object.assign(s[r],a[r]);break;case"message":let y=i.V.T;for(let d of Object.keys(a[r])){let g=a[r][d];y.fieldWrapper||(g=new y(g)),s[r][d]=g}break}break;case"message":let h=i.T;if(i.repeated)s[r]=a[r].map(y=>U(y,h)?y:new h(y));else{let y=a[r];h.fieldWrapper?h.typeName==="google.protobuf.BytesValue"?s[r]=se(y):s[r]=y:s[r]=U(y,h)?y:new h(y)}break}}},equals(t,e,n){return e===n?!0:!e||!n?!1:t.fields.byMember().every(i=>{let r=e[i.localName],s=n[i.localName];if(i.repeated){if(r.length!==s.length)return!1;switch(i.kind){case"message":return r.every((a,c)=>i.T.equals(a,s[c]));case"scalar":return r.every((a,c)=>D(i.T,a,s[c]));case"enum":return r.every((a,c)=>D(l.INT32,a,s[c]))}throw new Error(`repeated cannot contain ${i.kind}`)}switch(i.kind){case"message":let a=r,c=s;return i.T.fieldWrapper&&(a!==void 0&&!U(a)&&(a=i.T.fieldWrapper.wrapField(a)),c!==void 0&&!U(c)&&(c=i.T.fieldWrapper.wrapField(c))),i.T.equals(a,c);case"enum":return D(l.INT32,r,s);case"scalar":return D(i.T,r,s);case"oneof":if(r.case!==s.case)return!1;let u=i.findField(r.case);if(u===void 0)return!0;switch(u.kind){case"message":return u.T.equals(r.value,s.value);case"enum":return D(l.INT32,r.value,s.value);case"scalar":return D(u.T,r.value,s.value)}throw new Error(`oneof cannot contain ${u.kind}`);case"map":let f=Object.keys(r).concat(Object.keys(s));switch(i.V.kind){case"message":let p=i.V.T;return f.every(y=>p.equals(r[y],s[y]));case"enum":return f.every(y=>D(l.INT32,r[y],s[y]));case"scalar":let h=i.V.T;return f.every(y=>D(h,r[y],s[y]))}break}})},clone(t){let e=t.getType(),n=new e,i=n;for(let r of e.fields.byMember()){let s=t[r.localName],a;if(r.repeated)a=s.map(Re);else if(r.kind=="map"){a=i[r.localName];for(let[c,u]of Object.entries(s))a[c]=Re(u)}else r.kind=="oneof"?a=r.findField(s.case)?{case:s.case,value:Re(s.value)}:{case:void 0}:a=Re(s);i[r.localName]=a}for(let r of e.runtime.bin.listUnknownFields(t))e.runtime.bin.onUnknownField(i,r.no,r.wireType,r.data);return n}}}function Re(t){if(t===void 0)return t;if(U(t))return t.clone();if(t instanceof Uint8Array){let e=new Uint8Array(t.byteLength);return e.set(t),e}return t}function se(t){return t instanceof Uint8Array?t:new Uint8Array(t)}function kr(t,e,n){return{syntax:t,json:fr(),bin:gr(),util:Object.assign(Object.assign({},Tr()),{newFieldList:e,initFields:n}),makeMessageType(i,r,s){return Zn(this,i,r,s)},makeEnum:Xn,makeEnumType:ln,getEnumType:Wn,makeExtension(i,r,s){return nr(this,i,r,s)}}}var Oe=class{constructor(e,n){this._fields=e,this._normalizer=n}findJsonName(e){if(!this.jsonNames){let n={};for(let i of this.list())n[i.jsonName]=n[i.name]=i;this.jsonNames=n}return this.jsonNames[e]}find(e){if(!this.numbers){let n={};for(let i of this.list())n[i.no]=i;this.numbers=n}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort((e,n)=>e.no-n.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];let e=this.members,n;for(let i of this.list())i.oneof?i.oneof!==n&&(n=i.oneof,e.push(n)):e.push(i)}return this.members}};function Tn(t,e){let n=vr(t);return e?n:Pi(Ji(n))}function xr(t){return Tn(t,!1)}var br=vr;function vr(t){let e=!1,n=[];for(let i=0;i<t.length;i++){let r=t.charAt(i);switch(r){case"_":e=!0;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":n.push(r),e=!1;break;default:e&&(e=!1,r=r.toUpperCase()),n.push(r);break}}return n.join("")}var Ei=new Set(["constructor","toString","toJSON","valueOf"]),Ni=new Set(["getType","clone","equals","fromBinary","fromJson","fromJsonString","toBinary","toJson","toJsonString","toObject"]),Ir=t=>`${t}$`,Ji=t=>Ni.has(t)?Ir(t):t,Pi=t=>Ei.has(t)?Ir(t):t;var Ae=class{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=xr(e)}addField(e){I(e.oneof===this,`field ${e.name} not one of ${this.name}`),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let n=0;n<this.fields.length;n++)this._lookup[this.fields[n].localName]=this.fields[n]}return this._lookup[e]}};function Sr(t,e){var n,i,r,s,a,c;let u=[],f;for(let p of typeof t=="function"?t():t){let h=p;if(h.localName=Tn(p.name,p.oneof!==void 0),h.jsonName=(n=p.jsonName)!==null&&n!==void 0?n:br(p.name),h.repeated=(i=p.repeated)!==null&&i!==void 0?i:!1,p.kind=="scalar"&&(h.L=(r=p.L)!==null&&r!==void 0?r:A.BIGINT),h.delimited=(s=p.delimited)!==null&&s!==void 0?s:!1,h.req=(a=p.req)!==null&&a!==void 0?a:!1,h.opt=(c=p.opt)!==null&&c!==void 0?c:!1,p.packed===void 0&&(e?h.packed=p.kind=="enum"||p.kind=="scalar"&&p.T!=l.BYTES&&p.T!=l.STRING:h.packed=!1),p.oneof!==void 0){let y=typeof p.oneof=="string"?p.oneof:p.oneof.name;(!f||f.name!=y)&&(f=new Ae(y)),h.oneof=f,f.addField(h)}u.push(h)}return u}var o=kr("proto3",t=>new Oe(t,e=>Sr(e,!0)),t=>{for(let e of t.getType().fields.byMember()){if(e.opt)continue;let n=e.localName,i=t;if(e.repeated){i[n]=[];continue}switch(e.kind){case"oneof":i[n]={case:void 0};break;case"enum":i[n]=0;break;case"map":i[n]={};break;case"scalar":i[n]=q(e.T,e.L);break;case"message":break}}});var T;(function(t){t[t.Unary=0]="Unary",t[t.ServerStreaming=1]="ServerStreaming",t[t.ClientStreaming=2]="ClientStreaming",t[t.BiDiStreaming=3]="BiDiStreaming"})(T||(T={}));var kn;(function(t){t[t.NoSideEffects=1]="NoSideEffects",t[t.Idempotent=2]="Idempotent"})(kn||(kn={}));var F=class t extends m{constructor(e){super(),this.seconds=S.zero,this.nanos=0,o.util.initPartial(e,this)}fromJson(e,n){if(typeof e!="string")throw new Error(`cannot decode google.protobuf.Timestamp from JSON: ${o.json.debug(e)}`);let i=e.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);if(!i)throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");let r=Date.parse(i[1]+"-"+i[2]+"-"+i[3]+"T"+i[4]+":"+i[5]+":"+i[6]+(i[8]?i[8]:"Z"));if(Number.isNaN(r))throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");if(r<Date.parse("0001-01-01T00:00:00Z")||r>Date.parse("9999-12-31T23:59:59Z"))throw new Error("cannot decode message google.protobuf.Timestamp from JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive");return this.seconds=S.parse(r/1e3),this.nanos=0,i[7]&&(this.nanos=parseInt("1"+i[7]+"0".repeat(9-i[7].length))-1e9),this}toJson(e){let n=Number(this.seconds)*1e3;if(n<Date.parse("0001-01-01T00:00:00Z")||n>Date.parse("9999-12-31T23:59:59Z"))throw new Error("cannot encode google.protobuf.Timestamp to JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive");if(this.nanos<0)throw new Error("cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative");let i="Z";if(this.nanos>0){let r=(this.nanos+1e9).toString().substring(1);r.substring(3)==="000000"?i="."+r.substring(0,3)+"Z":r.substring(6)==="000"?i="."+r.substring(0,6)+"Z":i="."+r+"Z"}return new Date(n).toISOString().replace(".000Z",i)}toDate(){return new Date(Number(this.seconds)*1e3+Math.ceil(this.nanos/1e6))}static now(){return t.fromDate(new Date)}static fromDate(e){let n=e.getTime();return new t({seconds:S.parse(Math.floor(n/1e3)),nanos:n%1e3*1e6})}static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}};F.runtime=o;F.typeName="google.protobuf.Timestamp";F.fields=o.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);var z=class t extends m{constructor(e){super(),this.typeUrl="",this.value=new Uint8Array(0),o.util.initPartial(e,this)}toJson(e){var n;if(this.typeUrl==="")return{};let i=this.typeUrlToName(this.typeUrl),r=(n=e?.typeRegistry)===null||n===void 0?void 0:n.findMessage(i);if(!r)throw new Error(`cannot encode message google.protobuf.Any to JSON: "${this.typeUrl}" is not in the type registry`);let a=r.fromBinary(this.value).toJson(e);return(i.startsWith("google.protobuf.")||a===null||Array.isArray(a)||typeof a!="object")&&(a={value:a}),a["@type"]=this.typeUrl,a}fromJson(e,n){var i;if(e===null||Array.isArray(e)||typeof e!="object")throw new Error(`cannot decode message google.protobuf.Any from JSON: expected object but got ${e===null?"null":Array.isArray(e)?"array":typeof e}`);if(Object.keys(e).length==0)return this;let r=e["@type"];if(typeof r!="string"||r=="")throw new Error('cannot decode message google.protobuf.Any from JSON: "@type" is empty');let s=this.typeUrlToName(r),a=(i=n?.typeRegistry)===null||i===void 0?void 0:i.findMessage(s);if(!a)throw new Error(`cannot decode message google.protobuf.Any from JSON: ${r} is not in the type registry`);let c;if(s.startsWith("google.protobuf.")&&Object.prototype.hasOwnProperty.call(e,"value"))c=a.fromJson(e.value,n);else{let u=Object.assign({},e);delete u["@type"],c=a.fromJson(u,n)}return this.packFrom(c),this}packFrom(e){this.value=e.toBinary(),this.typeUrl=this.typeNameToUrl(e.getType().typeName)}unpackTo(e){return this.is(e.getType())?(e.fromBinary(this.value),!0):!1}unpack(e){if(this.typeUrl==="")return;let n=e.findMessage(this.typeUrlToName(this.typeUrl));if(n)return n.fromBinary(this.value)}is(e){if(this.typeUrl==="")return!1;let n=this.typeUrlToName(this.typeUrl),i="";return typeof e=="string"?i=e:i=e.typeName,n===i}typeNameToUrl(e){return`type.googleapis.com/${e}`}typeUrlToName(e){if(!e.length)throw new Error(`invalid type url: ${e}`);let n=e.lastIndexOf("/"),i=n>=0?e.substring(n+1):e;if(!i.length)throw new Error(`invalid type url: ${e}`);return i}static pack(e){let n=new t;return n.packFrom(e),n}static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}};z.runtime=o;z.typeName="google.protobuf.Any";z.fields=o.util.newFieldList(()=>[{no:1,name:"type_url",kind:"scalar",T:9},{no:2,name:"value",kind:"scalar",T:12}]);function Er(t,e,n){try{let i=Q.dec(t);return e?e.fromBinary(i,n):i}catch(i){throw v.from(i,w.DataLoss)}}function Nr(t,e){let n={};for(let[i,r]of Object.entries(t.methods)){let s=e(Object.assign(Object.assign({},r),{localName:i,service:t}));s!=null&&(n[i]=s)}return n}var qe=1;function Le(t){let e,n=new Uint8Array(0);function i(r){let s=new Uint8Array(n.length+r.length);s.set(n),s.set(r,n.length),n=s}return new ReadableStream({start(){e=t.getReader()},async pull(r){let s;for(;;){if(s===void 0&&n.byteLength>=5){let u=0;for(let f=1;f<5;f++)u=(u<<8)+n[f];s={flags:n[0],length:u}}if(s!==void 0&&n.byteLength>=s.length+5)break;let c=await e.read();if(c.done)break;i(c.value)}if(s===void 0){if(n.byteLength==0){r.close();return}r.error(new v("premature end of stream",w.DataLoss));return}let a=n.subarray(5,5+s.length);n=n.subarray(5+s.length),r.enqueue({flags:s.flags,data:a})}})}function Ce(t,e){let n=new Uint8Array(e.length+5);n.set(e,5);let i=new DataView(n.buffer,n.byteOffset,n.byteLength);return i.setUint8(0,t),i.setUint32(1,e.length),n}var Fi=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),n={},i("next"),i("throw"),i("return"),n[Symbol.asyncIterator]=function(){return this},n);function i(s){n[s]=t[s]&&function(a){return new Promise(function(c,u){a=t[s](a),r(c,u,a.done,a.value)})}}function r(s,a,c,u){Promise.resolve(u).then(function(f){s({value:f,done:c})},a)}},ae=function(t){return this instanceof ae?(this.v=t,this):new ae(t)},Bi=function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=n.apply(t,e||[]),r,s=[];return r={},c("next"),c("throw"),c("return",a),r[Symbol.asyncIterator]=function(){return this},r;function a(d){return function(g){return Promise.resolve(g).then(d,h)}}function c(d,g){i[d]&&(r[d]=function(b){return new Promise(function(k,J){s.push([d,b,k,J])>1||u(d,b)})},g&&(r[d]=g(r[d])))}function u(d,g){try{f(i[d](g))}catch(b){y(s[0][3],b)}}function f(d){d.value instanceof ae?Promise.resolve(d.value.v).then(p,h):y(s[0][2],d)}function p(d){u("next",d)}function h(d){u("throw",d)}function y(d,g){d(g),s.shift(),s.length&&u(s[0][0],s[0][1])}},Ui=function(t){var e,n;return e={},i("next"),i("throw",function(r){throw r}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(r,s){e[r]=t[r]?function(a){return(n=!n)?{value:ae(t[r](a)),done:!1}:s?s(a):a}:s}};function Jr(t){return Bi(this,arguments,function*(){yield ae(yield*Ui(Fi(t)))})}var Pr=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),n={},i("next"),i("throw"),i("return"),n[Symbol.asyncIterator]=function(){return this},n);function i(s){n[s]=t[s]&&function(a){return new Promise(function(c,u){a=t[s](a),r(c,u,a.done,a.value)})}}function r(s,a,c,u){Promise.resolve(u).then(function(f){s({value:f,done:c})},a)}},ee=function(t){return this instanceof ee?(this.v=t,this):new ee(t)},Ri=function(t){var e,n;return e={},i("next"),i("throw",function(r){throw r}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(r,s){e[r]=t[r]?function(a){return(n=!n)?{value:ee(t[r](a)),done:!1}:s?s(a):a}:s}},Oi=function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=n.apply(t,e||[]),r,s=[];return r={},c("next"),c("throw"),c("return",a),r[Symbol.asyncIterator]=function(){return this},r;function a(d){return function(g){return Promise.resolve(g).then(d,h)}}function c(d,g){i[d]&&(r[d]=function(b){return new Promise(function(k,J){s.push([d,b,k,J])>1||u(d,b)})},g&&(r[d]=g(r[d])))}function u(d,g){try{f(i[d](g))}catch(b){y(s[0][3],b)}}function f(d){d.value instanceof ee?Promise.resolve(d.value.v).then(p,h):y(s[0][2],d)}function p(d){u("next",d)}function h(d){u("throw",d)}function y(d,g){d(g),s.shift(),s.length&&u(s[0][0],s[0][1])}};function G(t,e){return Nr(t,n=>{switch(n.kind){case T.Unary:return Ai(e,t,n);case T.ServerStreaming:return qi(e,t,n);case T.ClientStreaming:return Li(e,t,n);case T.BiDiStreaming:return Ci(e,t,n);default:return null}})}function Ai(t,e,n){return async function(i,r){var s,a;let c=await t.unary(e,n,r?.signal,r?.timeoutMs,r?.headers,i,r?.contextValues);return(s=r?.onHeader)===null||s===void 0||s.call(r,c.header),(a=r?.onTrailer)===null||a===void 0||a.call(r,c.trailer),c.message}}function qi(t,e,n){return function(i,r){return Fr(t.stream(e,n,r?.signal,r?.timeoutMs,r?.headers,Jr([i]),r?.contextValues),r)}}function Li(t,e,n){return async function(i,r){var s,a,c,u,f,p;let h=await t.stream(e,n,r?.signal,r?.timeoutMs,r?.headers,i,r?.contextValues);(f=r?.onHeader)===null||f===void 0||f.call(r,h.header);let y,d=0;try{for(var g=!0,b=Pr(h.message),k;k=await b.next(),s=k.done,!s;g=!0)u=k.value,g=!1,y=u,d++}catch(J){a={error:J}}finally{try{!g&&!s&&(c=b.return)&&await c.call(b)}finally{if(a)throw a.error}}if(!y)throw new v("protocol error: missing response message",w.Unimplemented);if(d>1)throw new v("protocol error: received extra messages for client streaming method",w.Unimplemented);return(p=r?.onTrailer)===null||p===void 0||p.call(r,h.trailer),y}}function Ci(t,e,n){return function(i,r){return Fr(t.stream(e,n,r?.signal,r?.timeoutMs,r?.headers,i,r?.contextValues),r)}}function Fr(t,e){let n=(function(){return Oi(this,arguments,function*(){var i,r;let s=yield ee(t);(i=e?.onHeader)===null||i===void 0||i.call(e,s.header),yield ee(yield*Ri(Pr(s.message))),(r=e?.onTrailer)===null||r===void 0||r.call(e,s.trailer)})})()[Symbol.asyncIterator]();return{[Symbol.asyncIterator]:()=>({next:()=>n.next()})}}function Br(...t){let e=new AbortController,n=t.filter(r=>r!==void 0).concat(e.signal);for(let r of n){if(r.aborted){i.apply(r);break}r.addEventListener("abort",i)}function i(){e.signal.aborted||e.abort(xn(this));for(let r of n)r.removeEventListener("abort",i)}return e}function Ur(t){let e=new AbortController,n=()=>{e.abort(new v("the operation timed out",w.DeadlineExceeded))},i;return t!==void 0&&(t<=0?n():i=setTimeout(n,t)),{signal:e.signal,cleanup:()=>clearTimeout(i)}}function xn(t){if(!t.aborted)return;if(t.reason!==void 0)return t.reason;let e=new Error("This operation was aborted");return e.name="AbortError",e}function De(){return{get(t){return t.id in this?this[t.id]:t.defaultValue},set(t,e){return this[t.id]=e,this},delete(t){return delete this[t.id],this}}}function Me(t){let e=new Headers,n=new TextDecoder().decode(t).split(`\r
|
|
3
|
+
`);for(let i of n){if(i==="")continue;let r=i.indexOf(":");if(r>0){let s=i.substring(0,r).trim(),a=i.substring(r+1).trim();e.append(s,a)}}return e}var bn="Content-Type";var vn="Grpc-Timeout",L="Grpc-Status",ce="Grpc-Message",In="Grpc-Status-Details-Bin";var He="User-Agent";var Sn="X-User-Agent",Or="X-Grpc-Web";var Ar="application/grpc-web+proto",qr="application/grpc-web+json";var W=class t extends m{constructor(e){super(),this.code=0,this.message="",this.details=[],o.util.initPartial(e,this)}static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}};W.runtime=o;W.typeName="google.rpc.Status";W.fields=o.util.newFieldList(()=>[{no:1,name:"code",kind:"scalar",T:5},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"details",kind:"message",T:z,repeated:!0}]);var Lr="0";function Ve(t){var e;let n=t.get(In);if(n!=null){let r=Er(n,W);if(r.code==0)return;let s=new v(r.message,r.code,t);return s.details=r.details.map(a=>({type:a.typeUrl.substring(a.typeUrl.lastIndexOf("/")+1),value:a.value})),s}let i=t.get(L);if(i!=null){if(i===Lr)return;let r=parseInt(i,10);return r in w?new v(decodeURIComponent((e=t.get(ce))!==null&&e!==void 0?e:""),r,t):new v(`invalid grpc-status: ${i}`,w.Internal,t)}}function $e(t,e,n){let i=typeof e=="string"?e:e.typeName,r=typeof n=="string"?n:n.name;return t.toString().replace(/\/?$/,`/${i}/${r}`)}function En(t,e){return e instanceof t?e:new t(e)}function Cr(t,e){function n(i){return i.done===!0?i:{done:i.done,value:En(t,i.value)}}return{[Symbol.asyncIterator](){let i=e[Symbol.asyncIterator](),r={next:()=>i.next().then(n)};return i.throw!==void 0&&(r.throw=s=>i.throw(s).then(n)),i.return!==void 0&&(r.return=s=>i.return(s).then(n)),r}}}function Nn(t,e){var n;return(n=e?.concat().reverse().reduce((i,r)=>r(i),t))!==null&&n!==void 0?n:t}function Hr(t){var e;let n=Object.assign({},t);return(e=n.ignoreUnknownFields)!==null&&e!==void 0||(n.ignoreUnknownFields=!0),n}function Ge(t,e,n,i){let r=e?Dr(t.I,i):Mr(t.I,n);return{parse:(e?Dr(t.O,i):Mr(t.O,n)).parse,serialize:r.serialize}}function Dr(t,e){return{parse(n){try{return t.fromBinary(n,e)}catch(i){let r=i instanceof Error?i.message:String(i);throw new v(`parse binary: ${r}`,w.Internal)}},serialize(n){try{return n.toBinary(e)}catch(i){let r=i instanceof Error?i.message:String(i);throw new v(`serialize binary: ${r}`,w.Internal)}}}}function Mr(t,e){var n,i;let r=(n=e?.textEncoder)!==null&&n!==void 0?n:new TextEncoder,s=(i=e?.textDecoder)!==null&&i!==void 0?i:new TextDecoder,a=Hr(e);return{parse(c){try{let u=s.decode(c);return t.fromJsonString(u,a)}catch(u){throw v.from(u,w.InvalidArgument)}},serialize(c){try{let u=c.toJsonString(a);return r.encode(u)}catch(u){throw v.from(u,w.Internal)}}}}function Jn(t){let e=Nn(t.next,t.interceptors),[n,i,r]=Vr(t),s=Object.assign(Object.assign({},t.req),{message:En(t.req.method.I,t.req.message),signal:n});return e(s).then(a=>(r(),a),i)}function Pn(t){let e=Nn(t.next,t.interceptors),[n,i,r]=Vr(t),s=Object.assign(Object.assign({},t.req),{message:Cr(t.req.method.I,t.req.message),signal:n}),a=!1;return n.addEventListener("abort",function(){var c,u;let f=t.req.message[Symbol.asyncIterator]();a||(c=f.throw)===null||c===void 0||c.call(f,this.reason).catch(()=>{}),(u=f.return)===null||u===void 0||u.call(f).catch(()=>{})}),e(s).then(c=>Object.assign(Object.assign({},c),{message:{[Symbol.asyncIterator](){let u=c.message[Symbol.asyncIterator]();return{next(){return u.next().then(f=>(f.done==!0&&(a=!0,r()),f),i)}}}}}),i)}function Vr(t){let{signal:e,cleanup:n}=Ur(t.timeoutMs),i=Br(t.signal,e);return[i.signal,function(s){let a=v.from(e.aborted?xn(e):s);return i.abort(a),n(),Promise.reject(a)},function(){n(),i.abort()}]}function $r(){try{new Headers}catch{throw new Error("connect-web requires the fetch API. Are you running on an old version of Node.js? Node.js is not supported in Connect for Web - please stay tuned for Connect for Node.")}}function ue(t,e){let n=Ve(t);if(n)throw e.forEach((i,r)=>{n.metadata.append(r,i)}),n;if(!e.has(L)&&!t.has(L))throw new v("protocol error: missing status",w.Internal)}function je(t,e,n,i){var r,s;let a=new Headers(n??{});a.set(bn,t?Ar:qr),a.set(Or,"1");let c=(s=(r=a.get(He))!==null&&r!==void 0?r:a.get(Sn))!==null&&s!==void 0?s:"connect-es/1.7.0";return a.set(Sn,c),i&&a.set(He,c),e!==void 0&&a.set(vn,`${e}m`),a}function Gr(t){switch(t){case 400:return w.Internal;case 401:return w.Unauthenticated;case 403:return w.PermissionDenied;case 404:return w.Unimplemented;case 429:return w.Unavailable;case 502:return w.Unavailable;case 503:return w.Unavailable;case 504:return w.Unavailable;default:return w.Unknown}}function ze(t,e){var n;if(t>=200&&t<300)return{foundStatus:e.has(L),headerError:Ve(e)};throw new v(decodeURIComponent((n=e.get(ce))!==null&&n!==void 0?n:`HTTP ${t}`),Gr(t),e)}var X=function(t){return this instanceof X?(this.v=t,this):new X(t)},Mi=function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=n.apply(t,e||[]),r,s=[];return r={},c("next"),c("throw"),c("return",a),r[Symbol.asyncIterator]=function(){return this},r;function a(d){return function(g){return Promise.resolve(g).then(d,h)}}function c(d,g){i[d]&&(r[d]=function(b){return new Promise(function(k,J){s.push([d,b,k,J])>1||u(d,b)})},g&&(r[d]=g(r[d])))}function u(d,g){try{f(i[d](g))}catch(b){y(s[0][3],b)}}function f(d){d.value instanceof X?Promise.resolve(d.value.v).then(p,h):y(s[0][2],d)}function p(d){u("next",d)}function h(d){u("throw",d)}function y(d,g){d(g),s.shift(),s.length&&u(s[0][0],s[0][1])}};function Fn(t){var e;$r();let n=(e=t.useBinaryFormat)!==null&&e!==void 0?e:!0;return{async unary(i,r,s,a,c,u,f){var p;let{serialize:h,parse:y}=Ge(r,n,t.jsonOptions,t.binaryOptions);return a=a===void 0?t.defaultTimeoutMs:a<=0?void 0:a,await Jn({interceptors:t.interceptors,signal:s,timeoutMs:a,req:{stream:!1,service:i,method:r,url:$e(t.baseUrl,i,r),init:{method:"POST",credentials:(p=t.credentials)!==null&&p!==void 0?p:"same-origin",redirect:"error",mode:"cors"},header:je(n,a,c,!1),contextValues:f??De(),message:u},next:async d=>{var g;let k=await((g=t.fetch)!==null&&g!==void 0?g:globalThis.fetch)(d.url,Object.assign(Object.assign({},d.init),{headers:d.header,signal:d.signal,body:Ce(0,h(d.message))})),{headerError:J}=ze(k.status,k.headers);if(!k.body)throw J!==void 0?J:"missing response body";let R=Le(k.body).getReader(),x,P;for(;;){let B=await R.read();if(B.done)break;let{flags:$,data:ne}=B.value;if(($&qe)===qe)throw new v("protocol error: received unsupported compressed output",w.Internal);if($===128){if(x!==void 0)throw"extra trailer";x=Me(ne);continue}if(P!==void 0)throw new v("extra message",w.Unimplemented);P=y(ne)}if(x===void 0)throw J!==void 0?J:new v("missing trailer",k.headers.has(L)?w.Unimplemented:w.Unknown);if(ue(x,k.headers),P===void 0)throw new v("missing message",x.has(L)?w.Unimplemented:w.Unknown);return{stream:!1,service:i,method:r,header:k.headers,message:P,trailer:x}}})},async stream(i,r,s,a,c,u,f){var p;let{serialize:h,parse:y}=Ge(r,n,t.jsonOptions,t.binaryOptions);function d(b,k,J,R,x){return Mi(this,arguments,function*(){let B=Le(b).getReader();if(k){if(!(yield X(B.read())).done)throw"extra data for trailers-only";return yield X(void 0)}let $=!1;for(;;){let ne=yield X(B.read());if(ne.done)break;let{flags:ii,data:Gn}=ne.value;if((ii&128)===128){if($)throw"extra trailer";$=!0;let jn=Me(Gn);ue(jn,R),jn.forEach((oi,si)=>J.set(si,oi));continue}if($)throw"extra message";yield yield X(y(Gn))}if("throwIfAborted"in x&&x.throwIfAborted(),!$)throw"missing trailer"})}async function g(b){if(r.kind!=T.ServerStreaming)throw"The fetch API does not support streaming request bodies";let k=await b[Symbol.asyncIterator]().next();if(k.done==!0)throw"missing request message";return Ce(0,h(k.value))}return a=a===void 0?t.defaultTimeoutMs:a<=0?void 0:a,Pn({interceptors:t.interceptors,signal:s,timeoutMs:a,req:{stream:!0,service:i,method:r,url:$e(t.baseUrl,i,r),init:{method:"POST",credentials:(p=t.credentials)!==null&&p!==void 0?p:"same-origin",redirect:"error",mode:"cors"},header:je(n,a,c,!1),contextValues:f??De(),message:u},next:async b=>{var k;let R=await((k=t.fetch)!==null&&k!==void 0?k:globalThis.fetch)(b.url,Object.assign(Object.assign({},b.init),{headers:b.header,signal:b.signal,body:await g(b.message)})),{foundStatus:x,headerError:P}=ze(R.status,R.headers);if(P!=null)throw P;if(!R.body)throw"missing response body";let B=new Headers;return Object.assign(Object.assign({},b),{header:R.headers,trailer:B,message:d(R.body,x,B,R.headers,b.signal)})}})}}}var E=class t extends m{hostId="";tenantId="";packageId="";constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.TenantScope";static fields=o.util.newFieldList(()=>[{no:1,name:"host_id",kind:"scalar",T:9},{no:2,name:"tenant_id",kind:"scalar",T:9},{no:3,name:"package_id",kind:"scalar",T:9}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},H=class t extends m{pageSize=0;pageToken="";constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.PageRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"page_size",kind:"scalar",T:5},{no:2,name:"page_token",kind:"scalar",T:9}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},V=class t extends m{nextPageToken="";constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.PageResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"next_page_token",kind:"scalar",T:9}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}};var K;(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.API_CALL=1]="API_CALL",t[t.EGRESS_CALL=2]="EGRESS_CALL",t[t.TOKEN_ISSUED=3]="TOKEN_ISSUED",t[t.ACTIVATION_CHANGE=4]="ACTIVATION_CHANGE"})(K||(K={}));o.util.setEnumType(K,"handofclient.v1.AuditKind",[{no:0,name:"AUDIT_KIND_UNSPECIFIED"},{no:1,name:"AUDIT_KIND_API_CALL"},{no:2,name:"AUDIT_KIND_EGRESS_CALL"},{no:3,name:"AUDIT_KIND_TOKEN_ISSUED"},{no:4,name:"AUDIT_KIND_ACTIVATION_CHANGE"}]);var Bn=class t extends m{entryId="";scope;kind=K.UNSPECIFIED;actor="";summary="";detailJson="";occurredAt;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.AuditEntry";static fields=o.util.newFieldList(()=>[{no:1,name:"entry_id",kind:"scalar",T:9},{no:2,name:"scope",kind:"message",T:E},{no:3,name:"kind",kind:"enum",T:o.getEnumType(K)},{no:4,name:"actor",kind:"scalar",T:9},{no:5,name:"summary",kind:"scalar",T:9},{no:6,name:"detail_json",kind:"scalar",T:9},{no:7,name:"occurred_at",kind:"message",T:F}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Xe=class t extends m{hostId="";tenantId="";packageId="";startTime;endTime;kind=K.UNSPECIFIED;page;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.QueryRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"host_id",kind:"scalar",T:9},{no:2,name:"tenant_id",kind:"scalar",T:9},{no:3,name:"package_id",kind:"scalar",T:9},{no:4,name:"start_time",kind:"message",T:F},{no:5,name:"end_time",kind:"message",T:F},{no:6,name:"kind",kind:"enum",T:o.getEnumType(K)},{no:7,name:"page",kind:"message",T:H}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Ke=class t extends m{entries=[];page;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.QueryResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"entries",kind:"message",T:Bn,repeated:!0},{no:2,name:"page",kind:"message",T:V}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}};var jr={typeName:"handofclient.v1.AuditLog",methods:{query:{name:"Query",I:Xe,O:Ke,kind:T.Unary}}};var le;(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.GET=1]="GET",t[t.POST=2]="POST",t[t.PUT=3]="PUT",t[t.PATCH=4]="PATCH",t[t.DELETE=5]="DELETE",t[t.HEAD=6]="HEAD"})(le||(le={}));o.util.setEnumType(le,"handofclient.v1.HttpMethod",[{no:0,name:"HTTP_METHOD_UNSPECIFIED"},{no:1,name:"HTTP_METHOD_GET"},{no:2,name:"HTTP_METHOD_POST"},{no:3,name:"HTTP_METHOD_PUT"},{no:4,name:"HTTP_METHOD_PATCH"},{no:5,name:"HTTP_METHOD_DELETE"},{no:6,name:"HTTP_METHOD_HEAD"}]);var Ze=class t extends m{name="";value="";constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.HttpHeader";static fields=o.util.newFieldList(()=>[{no:1,name:"name",kind:"scalar",T:9},{no:2,name:"value",kind:"scalar",T:9}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Ye=class t extends m{scope;method=le.UNSPECIFIED;url="";headers=[];body=new Uint8Array(0);timeoutMs=0;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.SendRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"scope",kind:"message",T:E},{no:2,name:"method",kind:"enum",T:o.getEnumType(le)},{no:3,name:"url",kind:"scalar",T:9},{no:4,name:"headers",kind:"message",T:Ze,repeated:!0},{no:5,name:"body",kind:"scalar",T:12},{no:6,name:"timeout_ms",kind:"scalar",T:5}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Qe=class t extends m{statusCode=0;headers=[];body=new Uint8Array(0);constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.SendResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"status_code",kind:"scalar",T:5},{no:2,name:"headers",kind:"message",T:Ze,repeated:!0},{no:3,name:"body",kind:"scalar",T:12}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}};var zr={typeName:"handofclient.v1.EgressProxy",methods:{send:{name:"Send",I:Ye,O:Qe,kind:T.Unary}}};var _e=class t extends m{scope;requiredFeatures=[];constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.CheckFeaturesRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"scope",kind:"message",T:E},{no:2,name:"required_features",kind:"scalar",T:9,repeated:!0}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},et=class t extends m{allowed=!1;missingFeatures=[];constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.CheckFeaturesResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"allowed",kind:"scalar",T:8},{no:2,name:"missing_features",kind:"scalar",T:9,repeated:!0}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Un=class t extends m{metric="";quantity=0;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.UsageRecord";static fields=o.util.newFieldList(()=>[{no:1,name:"metric",kind:"scalar",T:9},{no:2,name:"quantity",kind:"scalar",T:1}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},tt=class t extends m{scope;records=[];constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.ReportUsageRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"scope",kind:"message",T:E},{no:2,name:"records",kind:"message",T:Un,repeated:!0}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},nt=class t extends m{constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.ReportUsageResponse";static fields=o.util.newFieldList(()=>[]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},rt=class t extends m{hostId="";tenantId="";grantedFeatures=[];constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.SetTenantFeaturesRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"host_id",kind:"scalar",T:9},{no:2,name:"tenant_id",kind:"scalar",T:9},{no:3,name:"granted_features",kind:"scalar",T:9,repeated:!0}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},it=class t extends m{grantedFeatures=[];constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.SetTenantFeaturesResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"granted_features",kind:"scalar",T:9,repeated:!0}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},ot=class t extends m{hostId="";tenantId="";constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.GetTenantFeaturesRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"host_id",kind:"scalar",T:9},{no:2,name:"tenant_id",kind:"scalar",T:9}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},st=class t extends m{grantedFeatures=[];constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.GetTenantFeaturesResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"granted_features",kind:"scalar",T:9,repeated:!0}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}};var Wr={typeName:"handofclient.v1.Entitlement",methods:{checkFeatures:{name:"CheckFeatures",I:_e,O:et,kind:T.Unary},reportUsage:{name:"ReportUsage",I:tt,O:nt,kind:T.Unary},setTenantFeatures:{name:"SetTenantFeatures",I:rt,O:it,kind:T.Unary},getTenantFeatures:{name:"GetTenantFeatures",I:ot,O:st,kind:T.Unary}}};var fe;(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.PAGE=1]="PAGE",t[t.OVERRIDE=2]="OVERRIDE",t[t.PANEL=3]="PANEL"})(fe||(fe={}));o.util.setEnumType(fe,"handofclient.v1.SlotKind",[{no:0,name:"SLOT_KIND_UNSPECIFIED"},{no:1,name:"SLOT_KIND_PAGE"},{no:2,name:"SLOT_KIND_OVERRIDE"},{no:3,name:"SLOT_KIND_PANEL"}]);var me;(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.PINNED=1]="PINNED",t[t.CHANNEL=2]="CHANNEL"})(me||(me={}));o.util.setEnumType(me,"handofclient.v1.UpdatePolicyKind",[{no:0,name:"UPDATE_POLICY_KIND_UNSPECIFIED"},{no:1,name:"UPDATE_POLICY_KIND_PINNED"},{no:2,name:"UPDATE_POLICY_KIND_CHANNEL"}]);var de;(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.STABLE=1]="STABLE",t[t.BETA=2]="BETA"})(de||(de={}));o.util.setEnumType(de,"handofclient.v1.Channel",[{no:0,name:"CHANNEL_UNSPECIFIED"},{no:1,name:"CHANNEL_STABLE"},{no:2,name:"CHANNEL_BETA"}]);var pe;(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.ACTION=1]="ACTION",t[t.FILTER=2]="FILTER"})(pe||(pe={}));o.util.setEnumType(pe,"handofclient.v1.HookKind",[{no:0,name:"HOOK_KIND_UNSPECIFIED"},{no:1,name:"HOOK_KIND_ACTION"},{no:2,name:"HOOK_KIND_FILTER"}]);var he;(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.APPEND=1]="APPEND",t[t.PREPEND=2]="PREPEND",t[t.REPLACE=3]="REPLACE",t[t.CONST=4]="CONST"})(he||(he={}));o.util.setEnumType(he,"handofclient.v1.FilterTransformKind",[{no:0,name:"FILTER_TRANSFORM_KIND_UNSPECIFIED"},{no:1,name:"FILTER_TRANSFORM_KIND_APPEND"},{no:2,name:"FILTER_TRANSFORM_KIND_PREPEND"},{no:3,name:"FILTER_TRANSFORM_KIND_REPLACE"},{no:4,name:"FILTER_TRANSFORM_KIND_CONST"}]);var ye;(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.PUBLISHED=1]="PUBLISHED",t[t.YANKED=2]="YANKED"})(ye||(ye={}));o.util.setEnumType(ye,"handofclient.v1.VersionState",[{no:0,name:"VERSION_STATE_UNSPECIFIED"},{no:1,name:"VERSION_STATE_PUBLISHED"},{no:2,name:"VERSION_STATE_YANKED"}]);var at=class t extends m{slotId="";kind=fe.UNSPECIFIED;title="";showInNav=!1;defaultEnabled=!1;targetPath="";matchPath="";aliasGroupKey="";hostPanelId="";constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.SlotDecl";static fields=o.util.newFieldList(()=>[{no:1,name:"slot_id",kind:"scalar",T:9},{no:2,name:"kind",kind:"enum",T:o.getEnumType(fe)},{no:3,name:"title",kind:"scalar",T:9},{no:4,name:"show_in_nav",kind:"scalar",T:8},{no:5,name:"default_enabled",kind:"scalar",T:8},{no:6,name:"target_path",kind:"scalar",T:9},{no:7,name:"match_path",kind:"scalar",T:9},{no:8,name:"alias_group_key",kind:"scalar",T:9},{no:9,name:"host_panel_id",kind:"scalar",T:9}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Rn=class t extends m{entryPoints={};bundleHash="";fileIntegrity={};constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.BundleRef";static fields=o.util.newFieldList(()=>[{no:1,name:"entry_points",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:2,name:"bundle_hash",kind:"scalar",T:9},{no:3,name:"file_integrity",kind:"map",K:9,V:{kind:"scalar",T:9}}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},On=class t extends m{scopes=[];egressHosts=[];constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.Permissions";static fields=o.util.newFieldList(()=>[{no:1,name:"scopes",kind:"scalar",T:9,repeated:!0},{no:2,name:"egress_hosts",kind:"scalar",T:9,repeated:!0}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},An=class t extends m{requiredFeatures=[];constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.EntitlementRequirement";static fields=o.util.newFieldList(()=>[{no:1,name:"required_features",kind:"scalar",T:9,repeated:!0}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},qn=class t extends m{kind=me.UNSPECIFIED;channel=de.UNSPECIFIED;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.UpdatePolicy";static fields=o.util.newFieldList(()=>[{no:1,name:"kind",kind:"enum",T:o.getEnumType(me)},{no:2,name:"channel",kind:"enum",T:o.getEnumType(de)}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Ln=class t extends m{kind=he.UNSPECIFIED;text="";replacements={};constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.FilterTransform";static fields=o.util.newFieldList(()=>[{no:1,name:"kind",kind:"enum",T:o.getEnumType(he)},{no:2,name:"text",kind:"scalar",T:9},{no:3,name:"replacements",kind:"map",K:9,V:{kind:"scalar",T:9}}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Cn=class t extends m{hook="";kind=pe.UNSPECIFIED;priority=0;acceptedArgs=0;webhookUrl="";argIndexes=[];transform;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.HookDecl";static fields=o.util.newFieldList(()=>[{no:1,name:"hook",kind:"scalar",T:9},{no:2,name:"kind",kind:"enum",T:o.getEnumType(pe)},{no:3,name:"priority",kind:"scalar",T:5},{no:4,name:"accepted_args",kind:"scalar",T:5},{no:5,name:"webhook_url",kind:"scalar",T:9},{no:6,name:"arg_indexes",kind:"scalar",T:5,repeated:!0},{no:7,name:"transform",kind:"message",T:Ln}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},ct=class t extends m{manifestVersion=0;packageId="";publisher="";name="";description="";version="";hostId="";tenantKey="";bundle;slots=[];permissions;entitlement;updatePolicy;hooks=[];strictCsp=!1;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.Manifest";static fields=o.util.newFieldList(()=>[{no:1,name:"manifest_version",kind:"scalar",T:5},{no:2,name:"package_id",kind:"scalar",T:9},{no:3,name:"publisher",kind:"scalar",T:9},{no:4,name:"name",kind:"scalar",T:9},{no:5,name:"description",kind:"scalar",T:9},{no:6,name:"version",kind:"scalar",T:9},{no:7,name:"host_id",kind:"scalar",T:9},{no:8,name:"tenant_key",kind:"scalar",T:9},{no:9,name:"bundle",kind:"message",T:Rn},{no:10,name:"slots",kind:"message",T:at,repeated:!0},{no:11,name:"permissions",kind:"message",T:On},{no:12,name:"entitlement",kind:"message",T:An},{no:13,name:"update_policy",kind:"message",T:qn},{no:14,name:"hooks",kind:"message",T:Cn,repeated:!0},{no:15,name:"strict_csp",kind:"scalar",T:8}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},ge=class t extends m{packageId="";version="";manifest;state=ye.UNSPECIFIED;publishedBy="";publishedAt;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.PackageVersion";static fields=o.util.newFieldList(()=>[{no:1,name:"package_id",kind:"scalar",T:9},{no:2,name:"version",kind:"scalar",T:9},{no:3,name:"manifest",kind:"message",T:ct},{no:4,name:"state",kind:"enum",T:o.getEnumType(ye)},{no:5,name:"published_by",kind:"scalar",T:9},{no:6,name:"published_at",kind:"message",T:F}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Dn=class t extends m{packageId="";publisher="";name="";description="";hostId="";createdAt;strictCsp=!1;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.Package";static fields=o.util.newFieldList(()=>[{no:1,name:"package_id",kind:"scalar",T:9},{no:2,name:"publisher",kind:"scalar",T:9},{no:3,name:"name",kind:"scalar",T:9},{no:4,name:"description",kind:"scalar",T:9},{no:5,name:"host_id",kind:"scalar",T:9},{no:6,name:"created_at",kind:"message",T:F},{no:7,name:"strict_csp",kind:"scalar",T:8}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},te=class t extends m{scope;slotId="";activeVersion="";pinned=!1;enabled=!1;activatedAt;activatedBy="";constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.Activation";static fields=o.util.newFieldList(()=>[{no:1,name:"scope",kind:"message",T:E},{no:2,name:"slot_id",kind:"scalar",T:9},{no:3,name:"active_version",kind:"scalar",T:9},{no:4,name:"pinned",kind:"scalar",T:8},{no:5,name:"enabled",kind:"scalar",T:8},{no:6,name:"activated_at",kind:"message",T:F},{no:7,name:"activated_by",kind:"scalar",T:9}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},j=class t extends m{hostId="";displayName="";registeredOrigins=[];webhookUrl="";createdAt;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.Host";static fields=o.util.newFieldList(()=>[{no:1,name:"host_id",kind:"scalar",T:9},{no:2,name:"display_name",kind:"scalar",T:9},{no:3,name:"registered_origins",kind:"scalar",T:9,repeated:!0},{no:4,name:"webhook_url",kind:"scalar",T:9},{no:5,name:"created_at",kind:"message",T:F}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},ut=class t extends m{manifest;bundleUploadRef="";constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.PublishVersionRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"manifest",kind:"message",T:ct},{no:2,name:"bundle_upload_ref",kind:"scalar",T:9}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},lt=class t extends m{version;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.PublishVersionResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"version",kind:"message",T:ge}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},ft=class t extends m{hostId="";publisher="";page;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.ListPackagesRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"host_id",kind:"scalar",T:9},{no:2,name:"publisher",kind:"scalar",T:9},{no:3,name:"page",kind:"message",T:H}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},mt=class t extends m{packages=[];page;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.ListPackagesResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"packages",kind:"message",T:Dn,repeated:!0},{no:2,name:"page",kind:"message",T:V}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},dt=class t extends m{packageId="";page;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.ListVersionsRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"package_id",kind:"scalar",T:9},{no:2,name:"page",kind:"message",T:H}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},pt=class t extends m{versions=[];page;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.ListVersionsResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"versions",kind:"message",T:ge,repeated:!0},{no:2,name:"page",kind:"message",T:V}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},ht=class t extends m{scope;slotId="";constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.GetActiveVersionRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"scope",kind:"message",T:E},{no:2,name:"slot_id",kind:"scalar",T:9}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},yt=class t extends m{version;slot;enabled=!1;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.GetActiveVersionResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"version",kind:"message",T:ge},{no:2,name:"slot",kind:"message",T:at},{no:3,name:"enabled",kind:"scalar",T:8}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},gt=class t extends m{scope;slotId="";version="";constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.ActivateRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"scope",kind:"message",T:E},{no:2,name:"slot_id",kind:"scalar",T:9},{no:3,name:"version",kind:"scalar",T:9}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},wt=class t extends m{activation;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.ActivateResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"activation",kind:"message",T:te}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Tt=class t extends m{scope;slotId="";pinned=!1;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.PinRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"scope",kind:"message",T:E},{no:2,name:"slot_id",kind:"scalar",T:9},{no:3,name:"pinned",kind:"scalar",T:8}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},kt=class t extends m{activation;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.PinResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"activation",kind:"message",T:te}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},xt=class t extends m{scope;slotId="";targetVersion="";constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.RollbackRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"scope",kind:"message",T:E},{no:2,name:"slot_id",kind:"scalar",T:9},{no:3,name:"target_version",kind:"scalar",T:9}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},bt=class t extends m{activation;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.RollbackResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"activation",kind:"message",T:te}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},vt=class t extends m{scope;slotId="";enabled=!1;applyToAliasGroup=!1;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.SetSlotEnabledRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"scope",kind:"message",T:E},{no:2,name:"slot_id",kind:"scalar",T:9},{no:3,name:"enabled",kind:"scalar",T:8},{no:4,name:"apply_to_alias_group",kind:"scalar",T:8}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},It=class t extends m{affectedSlotIds=[];constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.SetSlotEnabledResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"affected_slot_ids",kind:"scalar",T:9,repeated:!0}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},St=class t extends m{host;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.RegisterHostRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"host",kind:"message",T:j}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Et=class t extends m{host;apiKey="";webhookSecret="";constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.RegisterHostResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"host",kind:"message",T:j},{no:2,name:"api_key",kind:"scalar",T:9},{no:3,name:"webhook_secret",kind:"scalar",T:9}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Nt=class t extends m{hostId="";tenantId="";allowedHosts=[];constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.SetTenantEgressAllowlistRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"host_id",kind:"scalar",T:9},{no:2,name:"tenant_id",kind:"scalar",T:9},{no:3,name:"allowed_hosts",kind:"scalar",T:9,repeated:!0}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Jt=class t extends m{allowedHosts=[];constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.SetTenantEgressAllowlistResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"allowed_hosts",kind:"scalar",T:9,repeated:!0}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Pt=class t extends m{hostId="";origins=[];constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.AddHostOriginsRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"host_id",kind:"scalar",T:9},{no:2,name:"origins",kind:"scalar",T:9,repeated:!0}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Ft=class t extends m{host;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.AddHostOriginsResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"host",kind:"message",T:j}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Bt=class t extends m{hostId="";constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.RotateApiKeyRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"host_id",kind:"scalar",T:9}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Ut=class t extends m{host;apiKey="";constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.RotateApiKeyResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"host",kind:"message",T:j},{no:2,name:"api_key",kind:"scalar",T:9}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Rt=class t extends m{hostId="";tenantId="";constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.GetTenantEgressAllowlistRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"host_id",kind:"scalar",T:9},{no:2,name:"tenant_id",kind:"scalar",T:9}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Ot=class t extends m{allowedHosts=[];constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.GetTenantEgressAllowlistResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"allowed_hosts",kind:"scalar",T:9,repeated:!0}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},At=class t extends m{page;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.ListHostsRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"page",kind:"message",T:H}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},qt=class t extends m{hosts=[];page;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.ListHostsResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"hosts",kind:"message",T:j,repeated:!0},{no:2,name:"page",kind:"message",T:V}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Lt=class t extends m{tenantId="";packageId="";slotId="";page;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.ListActivationsRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"tenant_id",kind:"scalar",T:9},{no:2,name:"package_id",kind:"scalar",T:9},{no:3,name:"slot_id",kind:"scalar",T:9},{no:4,name:"page",kind:"message",T:H}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Ct=class t extends m{activations=[];page;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.ListActivationsResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"activations",kind:"message",T:te,repeated:!0},{no:2,name:"page",kind:"message",T:V}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Dt=class t extends m{constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.WhoAmIRequest";static fields=o.util.newFieldList(()=>[]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Mt=class t extends m{host;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.WhoAmIResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"host",kind:"message",T:j}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}};var Xr={typeName:"handofclient.v1.PackageRegistry",methods:{publishVersion:{name:"PublishVersion",I:ut,O:lt,kind:T.Unary},listPackages:{name:"ListPackages",I:ft,O:mt,kind:T.Unary},listVersions:{name:"ListVersions",I:dt,O:pt,kind:T.Unary},getActiveVersion:{name:"GetActiveVersion",I:ht,O:yt,kind:T.Unary},activate:{name:"Activate",I:gt,O:wt,kind:T.Unary},pin:{name:"Pin",I:Tt,O:kt,kind:T.Unary},rollback:{name:"Rollback",I:xt,O:bt,kind:T.Unary},setSlotEnabled:{name:"SetSlotEnabled",I:vt,O:It,kind:T.Unary},registerHost:{name:"RegisterHost",I:St,O:Et,kind:T.Unary},addHostOrigins:{name:"AddHostOrigins",I:Pt,O:Ft,kind:T.Unary},rotateApiKey:{name:"RotateApiKey",I:Bt,O:Ut,kind:T.Unary},setTenantEgressAllowlist:{name:"SetTenantEgressAllowlist",I:Nt,O:Jt,kind:T.Unary},getTenantEgressAllowlist:{name:"GetTenantEgressAllowlist",I:Rt,O:Ot,kind:T.Unary},listHosts:{name:"ListHosts",I:At,O:qt,kind:T.Unary},listActivations:{name:"ListActivations",I:Lt,O:Ct,kind:T.Unary},whoAmI:{name:"WhoAmI",I:Dt,O:Mt,kind:T.Unary}}};var Ht=class t extends m{scope;key="";constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.GetRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"scope",kind:"message",T:E},{no:2,name:"key",kind:"scalar",T:9}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Vt=class t extends m{value=new Uint8Array(0);found=!1;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.GetResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:12},{no:2,name:"found",kind:"scalar",T:8}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},$t=class t extends m{scope;key="";value=new Uint8Array(0);ifMatchEtag="";constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.SetRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"scope",kind:"message",T:E},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"value",kind:"scalar",T:12},{no:4,name:"if_match_etag",kind:"scalar",T:9}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Gt=class t extends m{etag="";constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.SetResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"etag",kind:"scalar",T:9}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},jt=class t extends m{scope;key="";constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.DeleteRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"scope",kind:"message",T:E},{no:2,name:"key",kind:"scalar",T:9}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},zt=class t extends m{constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.DeleteResponse";static fields=o.util.newFieldList(()=>[]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Wt=class t extends m{scope;path="";constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.FileExistsRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"scope",kind:"message",T:E},{no:2,name:"path",kind:"scalar",T:9}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Xt=class t extends m{exists=!1;sizeBytes=S.zero;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.FileExistsResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"exists",kind:"scalar",T:8},{no:2,name:"size_bytes",kind:"scalar",T:3}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Kt=class t extends m{scope;path="";constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.ReadFileRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"scope",kind:"message",T:E},{no:2,name:"path",kind:"scalar",T:9}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Zt=class t extends m{data=new Uint8Array(0);constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.ReadFileResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"data",kind:"scalar",T:12}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Yt=class t extends m{scope;path="";data=new Uint8Array(0);constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.WriteFileRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"scope",kind:"message",T:E},{no:2,name:"path",kind:"scalar",T:9},{no:3,name:"data",kind:"scalar",T:12}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},Qt=class t extends m{bytesWritten=S.zero;etag="";constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.WriteFileResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"bytes_written",kind:"scalar",T:3},{no:2,name:"etag",kind:"scalar",T:9}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}};var Kr={typeName:"handofclient.v1.TenantStorage",methods:{get:{name:"Get",I:Ht,O:Vt,kind:T.Unary},set:{name:"Set",I:$t,O:Gt,kind:T.Unary},delete:{name:"Delete",I:jt,O:zt,kind:T.Unary},fileExists:{name:"FileExists",I:Wt,O:Xt,kind:T.Unary},readFile:{name:"ReadFile",I:Kt,O:Zt,kind:T.ServerStreaming},writeFile:{name:"WriteFile",I:Yt,O:Qt,kind:T.ClientStreaming}}};var _t=class t extends m{hostApiKey="";tenantId="";userId="";slotId="";packageId="";launchParams={};constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.IssueEmbedTokenRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"host_api_key",kind:"scalar",T:9},{no:2,name:"tenant_id",kind:"scalar",T:9},{no:3,name:"user_id",kind:"scalar",T:9},{no:4,name:"slot_id",kind:"scalar",T:9},{no:5,name:"package_id",kind:"scalar",T:9},{no:6,name:"launch_params",kind:"map",K:9,V:{kind:"scalar",T:9}}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},en=class t extends m{token="";expiresAt;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.IssueEmbedTokenResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"token",kind:"scalar",T:9},{no:2,name:"expires_at",kind:"message",T:F}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},tn=class t extends m{token="";constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.RefreshEmbedTokenRequest";static fields=o.util.newFieldList(()=>[{no:1,name:"token",kind:"scalar",T:9}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},nn=class t extends m{token="";expiresAt;constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.RefreshEmbedTokenResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"token",kind:"scalar",T:9},{no:2,name:"expires_at",kind:"message",T:F}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},rn=class t extends m{constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.GetJwksRequest";static fields=o.util.newFieldList(()=>[]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}},on=class t extends m{jwksJson="";constructor(e){super(),o.util.initPartial(e,this)}static runtime=o;static typeName="handofclient.v1.GetJwksResponse";static fields=o.util.newFieldList(()=>[{no:1,name:"jwks_json",kind:"scalar",T:9}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return o.util.equals(t,e,n)}};var Zr={typeName:"handofclient.v1.TokenService",methods:{issueEmbedToken:{name:"IssueEmbedToken",I:_t,O:en,kind:T.Unary},refreshEmbedToken:{name:"RefreshEmbedToken",I:tn,O:nn,kind:T.Unary},getJwks:{name:"GetJwks",I:rn,O:on,kind:T.Unary}}};function Mn(t){return e=>async n=>{if(t.apiKey&&n.header.set("x-api-key",t.apiKey),!t.tokenProvider)return e(n);let i=t.tokenProvider,r=await i.getToken();n.header.set("Authorization",`Bearer ${r}`);try{return await e(n)}catch(s){if(n.stream||!(s instanceof v)||s.code!==w.Unauthenticated)throw s;let a=await i.refreshToken();return n.header.set("Authorization",`Bearer ${a}`),await e(n)}}}function Hn(t){let e=Fn({baseUrl:t.baseUrl,fetch:t.fetch,interceptors:[Mn({tokenProvider:t.tokenProvider,apiKey:t.apiKey})]});return{packageRegistry:G(Xr,e),tokenService:G(Zr,e),entitlement:G(Wr,e),tenantStorage:G(Kr,e),egressProxy:G(zr,e),auditLog:G(jr,e)}}var O={Hello:"hoc:hello",Init:"hoc:init",Ready:"hoc:ready",Error:"hoc:error",Resize:"hoc:resize",Navigate:"hoc:navigate",TokenRefresh:"hoc:token-refresh",ContextChanged:"hoc:context-changed",Telemetry:"hoc:telemetry",Ui:"hoc:ui"};function Qr(t){if(typeof t!="object"||t===null)return!1;let e=t;return e.v===1&&typeof e.type=="string"&&typeof e.msgId=="string"&&typeof e.payload=="object"&&e.payload!==null}function Yr(){return crypto.randomUUID()}function Vn(t,e,n){return n===void 0?{v:1,type:t,msgId:Yr(),payload:e}:{v:1,type:t,msgId:Yr(),replyTo:n,payload:e}}var Hi=1e4,sn=class{constructor(e,n){this.getTarget=e;this.validateIncoming=n;this.listener=i=>this.handleMessage(i),window.addEventListener("message",this.listener)}getTarget;validateIncoming;pending=new Map;notificationHandlers=new Map;requestHandlers=new Map;listener;send(e,n,i){let r=this.getTarget();r&&r.window.postMessage(Vn(e,n,i),r.origin)}request(e,n,i=Hi){let r=this.getTarget();if(!r)return Promise.reject(new Error(`No message target available for request "${e}"`));let s=Vn(e,n);return new Promise((a,c)=>{let u=setTimeout(()=>{this.pending.delete(s.msgId),c(new Error(`Request "${e}" timed out after ${i}ms`))},i);this.pending.set(s.msgId,{resolve:a,reject:c,timer:u}),r.window.postMessage(s,r.origin)})}onNotification(e,n){this.notificationHandlers.set(e,n)}onRequest(e,n){this.requestHandlers.set(e,n)}dispose(){window.removeEventListener("message",this.listener);for(let{timer:e,reject:n}of this.pending.values())clearTimeout(e),n(new Error("Channel disposed"));this.pending.clear()}async handleMessage(e){if(!this.validateIncoming(e)||!Qr(e.data))return;let n=e.data;if(n.replyTo){let s=this.pending.get(n.replyTo);if(!s)return;clearTimeout(s.timer),this.pending.delete(n.replyTo),s.resolve(n.payload);return}let i=this.requestHandlers.get(n.type);if(i){let s=await i(n.payload,e);this.send(n.type,s,n.msgId);return}this.notificationHandlers.get(n.type)?.(n.payload,e)}};async function _r(t){switch(t.kind){case"modal":return Vi(t.options.title,t.options.body);case"toast":return $i(t.options.message,t.options.durationMs??4e3);case"confirm":return Gi(t.options.title,t.options.message)}}function ei(){return{position:"fixed",inset:"0",display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0, 0, 0, 0.4)",zIndex:"2147483647",fontFamily:"system-ui, sans-serif"}}function Vi(t,e){return new Promise(n=>{let i=document.createElement("div");Object.assign(i.style,ei());let r=document.createElement("div");if(Object.assign(r.style,{background:"white",color:"#111",borderRadius:"8px",padding:"20px 24px",maxWidth:"420px",boxShadow:"0 8px 30px rgba(0,0,0,0.25)"}),t){let c=document.createElement("h3");c.textContent=t,c.style.marginTop="0",r.appendChild(c)}let s=document.createElement("p");s.textContent=e,r.appendChild(s);let a=document.createElement("button");a.textContent="Close",Object.assign(a.style,{marginTop:"12px"}),a.onclick=()=>{i.remove(),n({closed:!0})},r.appendChild(a),i.appendChild(r),document.body.appendChild(i)})}function $i(t,e){let n=document.createElement("div");return n.textContent=t,Object.assign(n.style,{position:"fixed",bottom:"24px",left:"50%",transform:"translateX(-50%)",background:"#1f2937",color:"white",padding:"10px 16px",borderRadius:"6px",fontFamily:"system-ui, sans-serif",fontSize:"14px",zIndex:"2147483647",boxShadow:"0 4px 14px rgba(0,0,0,0.3)"}),document.body.appendChild(n),setTimeout(()=>n.remove(),e),Promise.resolve({shown:!0})}function Gi(t,e){return new Promise(n=>{let i=document.createElement("div");Object.assign(i.style,ei());let r=document.createElement("div");if(Object.assign(r.style,{background:"white",color:"#111",borderRadius:"8px",padding:"20px 24px",maxWidth:"420px",boxShadow:"0 8px 30px rgba(0,0,0,0.25)"}),t){let f=document.createElement("h3");f.textContent=t,f.style.marginTop="0",r.appendChild(f)}let s=document.createElement("p");s.textContent=e,r.appendChild(s);let a=document.createElement("div");Object.assign(a.style,{display:"flex",gap:"8px",justifyContent:"flex-end"});let c=document.createElement("button");c.textContent="Cancel",c.onclick=()=>{i.remove(),n({confirmed:!1})};let u=document.createElement("button");u.textContent="OK",u.onclick=()=>{i.remove(),n({confirmed:!0})},a.append(c,u),r.appendChild(a),i.appendChild(r),document.body.appendChild(i)})}function ti(t){let e=new TextEncoder().encode(t),n="";for(let i of e)n+=String.fromCharCode(i);return btoa(n).replace(/=+$/,"").replace(/\+/g,"-").replace(/\//g,"_")}var an=class{timer;constructor(e,n){this.timer=setTimeout(n,e)}cancel(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null)}};var Z=class extends Error{constructor(n,i){super(i);this.reason=n;this.name="HocMountError"}reason},$n=null;function ni(t){$n=t}function ji(){if(!$n)throw new Error("HandOfClient.configure({ apiBaseUrl, embedOrigin }) must be called before mount().");return $n}var zi=15e3;async function ri(t,e){let{apiBaseUrl:n,embedOrigin:i}=ji(),r;try{let y=await fetch(e.tokenUrl,{credentials:"same-origin"});if(!y.ok)throw new Error(`tokenUrl responded ${y.status}`);r=await y.json()}catch(y){throw new Z("token-fetch-failed",`Failed to fetch embed token: ${y.message}`)}let s=Hn({baseUrl:n}).packageRegistry,a={hostId:e.hostId,tenantId:e.tenantId,packageId:e.packageId},c;try{c=await s.getActiveVersion({scope:a,slotId:e.slotId})}catch(y){throw new Z("no-active-version",`No active version for this tenant/slot: ${y.message}`)}let u=c.version.version,f=c.version.manifest.bundle.entryPoints[e.slotId]??"index.html",p=ti(e.packageId),h=document.createElement("iframe");return h.title=c.slot?.title||e.slotId,h.sandbox.add("allow-scripts","allow-same-origin","allow-forms","allow-popups"),h.style.border="none",h.style.width="100%",h.src=`${i}/embed/${p}/${u}/${f}`,new Promise((y,d)=>{let g=!1,b=null,k=new sn(()=>h.contentWindow?{window:h.contentWindow,origin:i}:null,x=>x.source===h.contentWindow&&x.origin===i),J=(x,P)=>{if(g)return;g=!0,b?.cancel(),k.dispose(),h.remove();let B=new Z(x,P);e.onError?.(B),d(B)},R=()=>{g||(g=!0,b?.cancel(),y({unmount:()=>{k.dispose(),h.remove()},setContext:x=>k.send(O.ContextChanged,x),navigate:(x,P)=>k.send(O.Navigate,{path:x,state:P})}))};k.onNotification(O.Hello,(x,P)=>{let B={token:r.token,tokenExpiresAt:r.expiresAt,tenantContext:{hostId:e.hostId,tenantId:e.tenantId,packageId:e.packageId,slotId:e.slotId,version:u},user:{userId:r.userId,displayName:r.displayName},theme:e.theme,locale:e.locale,launchParams:e.launchParams??{},apiBaseUrl:n};k.send(O.Init,B,P.data.msgId),b=new an(e.readyTimeoutMs??zi,()=>J("timeout","Plugin did not signal ready/error in time"))}),k.onNotification(O.Ready,R),k.onNotification(O.Error,x=>{J("plugin-error",x.message)}),k.onNotification(O.Resize,x=>{h.style.height=`${x.height}px`}),k.onNotification(O.Navigate,x=>{e.onNavigate?.(x.path,x.replace??!1)}),k.onNotification(O.Telemetry,x=>{e.onTelemetry?.(x)}),k.onRequest(O.Ui,x=>(e.onUi??_r)(x)),k.onRequest(O.TokenRefresh,async()=>{try{let x=await fetch(e.tokenUrl,{credentials:"same-origin"});if(!x.ok)throw new Error(`tokenUrl responded ${x.status}`);let P=await x.json();return{token:P.token,expiresAt:P.expiresAt}}catch(x){return{error:`Host session refresh failed: ${x.message}`}}}),h.onerror=()=>J("iframe-load-failed","The plugin iframe failed to load"),t.appendChild(h)})}window.HandOfClient={configure:ni,mount:ri,MountError:Z};})();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { UiReplyPayload, UiRequestPayload } from "../protocol.js";
|
|
2
|
+
/**
|
|
3
|
+
* Minimal, dependency-free modal/toast/confirm renderer, used when a host does not pass its own
|
|
4
|
+
* `onUi` handler to `mount()`. This is what keeps hoc:ui off the mandatory host-integration-cost list
|
|
5
|
+
* (mount + tokenUrl endpoint + optional webhooks) per docs/postmessage-protocol.md section 5.10 - a
|
|
6
|
+
* host gets a working, if plain, UI for free.
|
|
7
|
+
*/
|
|
8
|
+
export declare function defaultUiHandler(request: UiRequestPayload): Promise<UiReplyPayload>;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal, dependency-free modal/toast/confirm renderer, used when a host does not pass its own
|
|
3
|
+
* `onUi` handler to `mount()`. This is what keeps hoc:ui off the mandatory host-integration-cost list
|
|
4
|
+
* (mount + tokenUrl endpoint + optional webhooks) per docs/postmessage-protocol.md section 5.10 - a
|
|
5
|
+
* host gets a working, if plain, UI for free.
|
|
6
|
+
*/
|
|
7
|
+
export async function defaultUiHandler(request) {
|
|
8
|
+
switch (request.kind) {
|
|
9
|
+
case "modal":
|
|
10
|
+
return showModal(request.options.title, request.options.body);
|
|
11
|
+
case "toast":
|
|
12
|
+
return showToast(request.options.message, request.options.durationMs ?? 4000);
|
|
13
|
+
case "confirm":
|
|
14
|
+
return showConfirm(request.options.title, request.options.message);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function baseOverlayStyle() {
|
|
18
|
+
return {
|
|
19
|
+
position: "fixed",
|
|
20
|
+
inset: "0",
|
|
21
|
+
display: "flex",
|
|
22
|
+
alignItems: "center",
|
|
23
|
+
justifyContent: "center",
|
|
24
|
+
background: "rgba(0, 0, 0, 0.4)",
|
|
25
|
+
zIndex: "2147483647",
|
|
26
|
+
fontFamily: "system-ui, sans-serif",
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function showModal(title, body) {
|
|
30
|
+
return new Promise((resolve) => {
|
|
31
|
+
const overlay = document.createElement("div");
|
|
32
|
+
Object.assign(overlay.style, baseOverlayStyle());
|
|
33
|
+
const box = document.createElement("div");
|
|
34
|
+
Object.assign(box.style, {
|
|
35
|
+
background: "white", color: "#111", borderRadius: "8px", padding: "20px 24px",
|
|
36
|
+
maxWidth: "420px", boxShadow: "0 8px 30px rgba(0,0,0,0.25)",
|
|
37
|
+
});
|
|
38
|
+
if (title) {
|
|
39
|
+
const heading = document.createElement("h3");
|
|
40
|
+
heading.textContent = title;
|
|
41
|
+
heading.style.marginTop = "0";
|
|
42
|
+
box.appendChild(heading);
|
|
43
|
+
}
|
|
44
|
+
const message = document.createElement("p");
|
|
45
|
+
message.textContent = body;
|
|
46
|
+
box.appendChild(message);
|
|
47
|
+
const closeButton = document.createElement("button");
|
|
48
|
+
closeButton.textContent = "Close";
|
|
49
|
+
Object.assign(closeButton.style, { marginTop: "12px" });
|
|
50
|
+
closeButton.onclick = () => {
|
|
51
|
+
overlay.remove();
|
|
52
|
+
resolve({ closed: true });
|
|
53
|
+
};
|
|
54
|
+
box.appendChild(closeButton);
|
|
55
|
+
overlay.appendChild(box);
|
|
56
|
+
document.body.appendChild(overlay);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function showToast(message, durationMs) {
|
|
60
|
+
const toast = document.createElement("div");
|
|
61
|
+
toast.textContent = message;
|
|
62
|
+
Object.assign(toast.style, {
|
|
63
|
+
position: "fixed", bottom: "24px", left: "50%", transform: "translateX(-50%)",
|
|
64
|
+
background: "#1f2937", color: "white", padding: "10px 16px", borderRadius: "6px",
|
|
65
|
+
fontFamily: "system-ui, sans-serif", fontSize: "14px", zIndex: "2147483647",
|
|
66
|
+
boxShadow: "0 4px 14px rgba(0,0,0,0.3)",
|
|
67
|
+
});
|
|
68
|
+
document.body.appendChild(toast);
|
|
69
|
+
setTimeout(() => toast.remove(), durationMs);
|
|
70
|
+
return Promise.resolve({ shown: true });
|
|
71
|
+
}
|
|
72
|
+
function showConfirm(title, message) {
|
|
73
|
+
return new Promise((resolve) => {
|
|
74
|
+
const overlay = document.createElement("div");
|
|
75
|
+
Object.assign(overlay.style, baseOverlayStyle());
|
|
76
|
+
const box = document.createElement("div");
|
|
77
|
+
Object.assign(box.style, {
|
|
78
|
+
background: "white", color: "#111", borderRadius: "8px", padding: "20px 24px",
|
|
79
|
+
maxWidth: "420px", boxShadow: "0 8px 30px rgba(0,0,0,0.25)",
|
|
80
|
+
});
|
|
81
|
+
if (title) {
|
|
82
|
+
const heading = document.createElement("h3");
|
|
83
|
+
heading.textContent = title;
|
|
84
|
+
heading.style.marginTop = "0";
|
|
85
|
+
box.appendChild(heading);
|
|
86
|
+
}
|
|
87
|
+
const text = document.createElement("p");
|
|
88
|
+
text.textContent = message;
|
|
89
|
+
box.appendChild(text);
|
|
90
|
+
const buttonRow = document.createElement("div");
|
|
91
|
+
Object.assign(buttonRow.style, { display: "flex", gap: "8px", justifyContent: "flex-end" });
|
|
92
|
+
const cancelButton = document.createElement("button");
|
|
93
|
+
cancelButton.textContent = "Cancel";
|
|
94
|
+
cancelButton.onclick = () => {
|
|
95
|
+
overlay.remove();
|
|
96
|
+
resolve({ confirmed: false });
|
|
97
|
+
};
|
|
98
|
+
const confirmButton = document.createElement("button");
|
|
99
|
+
confirmButton.textContent = "OK";
|
|
100
|
+
confirmButton.onclick = () => {
|
|
101
|
+
overlay.remove();
|
|
102
|
+
resolve({ confirmed: true });
|
|
103
|
+
};
|
|
104
|
+
buttonRow.append(cancelButton, confirmButton);
|
|
105
|
+
box.appendChild(buttonRow);
|
|
106
|
+
overlay.appendChild(box);
|
|
107
|
+
document.body.appendChild(overlay);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entry point for the drop-in `<script>` build (dist/embed.global.js, bundled by build.mjs) - attaches
|
|
3
|
+
* `window.HandOfClient` for hosts with no JS bundler of their own. A host using a bundler should import
|
|
4
|
+
* from "@handofclient/embed-js/host" directly instead of loading this file.
|
|
5
|
+
*/
|
|
6
|
+
import { configure, mount, HocMountError } from "./index.js";
|
|
7
|
+
declare global {
|
|
8
|
+
interface Window {
|
|
9
|
+
HandOfClient: {
|
|
10
|
+
configure: typeof configure;
|
|
11
|
+
mount: typeof mount;
|
|
12
|
+
MountError: typeof HocMountError;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entry point for the drop-in `<script>` build (dist/embed.global.js, bundled by build.mjs) - attaches
|
|
3
|
+
* `window.HandOfClient` for hosts with no JS bundler of their own. A host using a bundler should import
|
|
4
|
+
* from "@handofclient/embed-js/host" directly instead of loading this file.
|
|
5
|
+
*/
|
|
6
|
+
import { configure, mount, HocMountError } from "./index.js";
|
|
7
|
+
window.HandOfClient = { configure, mount, MountError: HocMountError };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type ContextChangedPayload, type TelemetryPayload, type ThemeTokens, type UiReplyPayload, type UiRequestPayload } from "../protocol.js";
|
|
2
|
+
export type MountErrorReason = "token-fetch-failed" | "no-active-version" | "iframe-load-failed" | "timeout" | "plugin-error";
|
|
3
|
+
export declare class HocMountError extends Error {
|
|
4
|
+
readonly reason: MountErrorReason;
|
|
5
|
+
constructor(reason: MountErrorReason, message: string);
|
|
6
|
+
}
|
|
7
|
+
/** Contract for a host's own tokenUrl backend endpoint - see docs/postmessage-protocol.md section 4
|
|
8
|
+
* step 1. The host mints this by calling TokenService.IssueEmbedToken server-to-server; embed.js only
|
|
9
|
+
* ever talks to the host's own endpoint over same-origin fetch, never to the Platform API directly for
|
|
10
|
+
* token issuance. */
|
|
11
|
+
export interface TokenEndpointResponse {
|
|
12
|
+
token: string;
|
|
13
|
+
expiresAt: string;
|
|
14
|
+
userId: string;
|
|
15
|
+
displayName?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface HandOfClientConfig {
|
|
18
|
+
/** Platform API base URL, e.g. https://api.handofclient.com - used only for the anonymous, Public
|
|
19
|
+
* GetActiveVersion call (see AuthPolicy.Methods); never for token issuance. */
|
|
20
|
+
apiBaseUrl: string;
|
|
21
|
+
/** Origin serving embed bundles, e.g. https://embed.handofclient.com. */
|
|
22
|
+
embedOrigin: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function configure(next: HandOfClientConfig): void;
|
|
25
|
+
export interface MountOptions {
|
|
26
|
+
hostId: string;
|
|
27
|
+
tenantId: string;
|
|
28
|
+
packageId: string;
|
|
29
|
+
slotId: string;
|
|
30
|
+
/** Same-origin endpoint on the host's own backend that mints an embed token - see
|
|
31
|
+
* TokenEndpointResponse. */
|
|
32
|
+
tokenUrl: string;
|
|
33
|
+
theme: ThemeTokens;
|
|
34
|
+
locale: string;
|
|
35
|
+
launchParams?: Record<string, string>;
|
|
36
|
+
/** Default 15000ms - see docs/postmessage-protocol.md section 4's explicit non-heuristic rule. */
|
|
37
|
+
readyTimeoutMs?: number;
|
|
38
|
+
onError?: (error: HocMountError) => void;
|
|
39
|
+
onNavigate?: (path: string, replace: boolean) => void;
|
|
40
|
+
onTelemetry?: (event: TelemetryPayload) => void;
|
|
41
|
+
onUi?: (request: UiRequestPayload) => Promise<UiReplyPayload>;
|
|
42
|
+
}
|
|
43
|
+
export interface Mounted {
|
|
44
|
+
unmount(): void;
|
|
45
|
+
setContext(update: ContextChangedPayload): void;
|
|
46
|
+
navigate(path: string, state?: unknown): void;
|
|
47
|
+
}
|
|
48
|
+
export declare function mount(container: HTMLElement, options: MountOptions): Promise<Mounted>;
|