@aperture-browser/session-element 0.0.0-nightly.123.a02294dfd68b → 0.0.0-nightly.126.c57737aef730

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.
@@ -22,8 +22,8 @@ Error generating stack: `+e.message+`
22
22
  `);n=jv(e)??Ev(Z_(e.ast),e);break;default:n=Sv(e);break}return t?`${n}\n at ${t}`:n}function jv(e){if(e._tag===`Pointer`)return;if(e._tag===`Encoding`)return jv(e.issue);let t=(e._tag===`Filter`?e.filter.annotations:`annotations`in e?e.annotations:e.ast.annotations)?.[e._tag===`MissingKey`?`messageMissingKey`:e._tag===`UnexpectedKey`?`messageUnexpectedKey`:`message`];if(typeof t==`string`)return t}function Mv(e){let t;for(let n of e.reasons){if(!yd(n)||!av(n.error))return;t??=n.error}return t}function Nv(e,t){let n=Mv(e);if(n===void 0)throw Error(t,{cause:e});return n}var Pv=e=>Object.assign(Object.create(v),e);function Fv(e){return Hv((t,n)=>I(e(t,n)))}function Iv(e){return Fv((t,n)=>{let r={message:e(t)};return ur(t)?new gv(r,t.value,n):new gv(r)})}var Lv=Pv({_tag:`Passthrough`});function Rv(){return Lv}function zv(e){return Pv({_tag:`Transform`,transform:e})}function Bv(e){return Pv({_tag:`TransformEffect`,transform:e})}function Vv(e){return Pv({_tag:`TransformOptional`,transform:e})}function Hv(e){return Pv({_tag:`TransformOptionalEffect`,transform:e})}function Uv(){return Vv(()=>sr())}function Wv(e){return Hv(t=>{let n=gr(t,pe);return ur(n)?P(n):Tp(e,cr)})}function Gv(){return zv(globalThis.String)}function Kv(){return zv(globalThis.Number)}function qv(e){return Bv((t,n)=>vf({try:()=>JSON.parse(t,e?.reviver),catch:()=>new hv({expected:`a valid JSON string`},t,n)}))}function Jv(e){return Bv((t,n)=>vf({try:()=>{let n=JSON.stringify(t,e?.replacer,e?.space);if(n===void 0)throw TypeError(`Value cannot be represented as JSON`);return n},catch:()=>new hv({expected:`a JSON-serializable value`},t,n)}))}var Yv=class extends y{_tag=`Middleware`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new Yv(this.encode,this.decode)}},Xv=`~effect/SchemaTransformation/Transformation`,Zv=class extends y{[Xv]=Xv;_tag=`Transformation`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new Zv(this.encode,this.decode)}};function Qv(e){return D(e,Xv)&&e[Xv]===Xv}var $v=e=>Qv(e)?e:new Zv(e.decode,e.encode);function ey(e){return new Zv(zv(e.decode),zv(e.encode))}var ty=new Zv(Rv(),Rv());function ny(){return ty}var ry=new Zv(Kv(),Gv()),iy=e=>ge(e)&&typeof e.message==`string`,ay=e=>{let t=Object.hasOwn(e,`cause`)?Error(e.message,{cause:ly(e.cause)}):Error(e.message);return typeof e.name==`string`&&e.name!==`Error`&&(t.name=e.name),typeof e.stack==`string`&&(t.stack=e.stack),t},oy=e=>{try{let t=ht(e);return t===void 0?ct(e):JSON.parse(t)}catch{return ct(e)}},sy=(e,t,n)=>{let r={name:e.name,message:typeof e.message==`string`?e.message:``};return t?.includeStack&&typeof e.stack==`string`&&(r.stack=e.stack),!t?.excludeCause&&e.cause!==void 0&&(r.cause=n(e.cause)),r},cy=e=>{let t=new WeakSet,n=r=>{if(ye(r)){if(t.has(r))return`[Circular]`;t.add(r);let i=sy(r,e,n);return t.delete(r),i}return oy(r)};return n},ly=e=>iy(e)?ay(e):e,uy=e=>ey({decode:ly,encode:cy(e)});function dy(e){return new Zv(qv(e??{}),Jv(e))}function fy(e){return t=>t._tag===e}var py=fy(`Declaration`),my=fy(`Never`),hy=fy(`Literal`),gy=fy(`UniqueSymbol`),_y=fy(`Arrays`),vy=fy(`Objects`),yy=fy(`Suspend`),by=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},xy={},Sy=class{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,n=void 0,r=void 0){this.isOptional=e,this.isMutable=t,this.constructorDefault=n,this.annotations=r}},Cy=`~effect/Schema`,wy=class{[Cy]=Cy;annotations;checks;encoding;context;constructor(e=void 0,t=void 0,n=void 0,r=void 0){this.annotations=e,this.checks=t,this.encoding=n,this.context=r}toString(){return`<${this._tag}>`}},Ty=class extends wy{_tag=`Declaration`;typeParameters;run;encodingChecks;encodingRun;constructor(e,t,n,r,i,a,o,s){super(n,r,i,a),this.typeParameters=e,this.run=t,this.encodingChecks=o,this.encodingRun=s}getParser(){let e;return(t,n)=>t===Q_?ev:(e??=this.run(this.typeParameters))(t,this,n)}_rebuild(e,t,n,r,i){let a=qb(this.typeParameters,e);return a===this.typeParameters&&t===this.checks&&n===this.encodingChecks&&r===this.run&&i===this.encodingRun?this:new Ty(a,r,this.annotations,t,void 0,this.context,n,i)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks,this.run,this.encodingRun)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks,this.encodingRun??this.run,this.run)}getExpected(){let e=this.annotations?.expected;return typeof e==`string`?e:`<Declaration>`}},Ey=new class extends wy{_tag=`Null`;getParser(){return dx(this,null)}getExpected(){return`null`}},Dy=class extends wy{_tag=`Undefined`;getParser(){return dx(this,void 0)}toCodecJson(){return Fb(this,[Oy])}getExpected(){return`undefined`}},Oy=new by(Ey,new Zv(zv(()=>void 0),zv(()=>null))),ky=new Dy,Ay=new class extends wy{_tag=`Unknown`;getParser(){return fx(this,he)}getExpected(){return`unknown`}},jy=class extends wy{_tag=`Literal`;literal;constructor(e,t,n,r,i){if(super(t,n,r,i),typeof e==`number`&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${ct(e)}`);this.literal=e}getParser(){return dx(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==`bigint`?My(this):this}toCodecStringTree(){return typeof this.literal==`string`?this:My(this)}getExpected(){return typeof this.literal==`string`?JSON.stringify(this.literal):globalThis.String(this.literal)}};function My(e){let t=globalThis.String(e.literal);return Fb(e,[new by(new jy(t),new Zv(zv(()=>e.literal),zv(()=>t)))])}var Ny=new class extends wy{_tag=`String`;getParser(){return fx(this,ce)}matchPart(e,t){let n=this.checks;return n&&!t.disableChecks&&xx(n,e,void 0,this,t)?void 0:e}getExpected(){return`string`}},Py=class extends wy{_tag=`Number`;getParser(){return fx(this,le)}matchKey(e,t){return this._match(gx,e,t)}matchPart(e,t){return this._match(hx,e,t)}_match(e,t,n){if(!e.test(t))return;let r=globalThis.Number(t);return n.disableChecks||!this.checks?r:xx(this.checks,r,void 0,this,n)?void 0:r}toCodecJson(){return this.checks&&(Fy(this.checks,`effect/schema/isFinite`)||Fy(this.checks,`effect/schema/isInt`))?this:Fb(this,[Ab])}toCodecStringTree(){return this.toCodecJson()===this?Fb(this,[yx]):Fb(this,[bx])}getExpected(){return`number`}};function Fy(e,t){return e.some(e=>e.annotations?.representation?.id===t||e._tag===`FilterGroup`&&Fy(e.checks,t))}var Iy=new Py,Ly=new class extends wy{_tag=`Boolean`;getParser(){return fx(this,E)}getExpected(){return`boolean`}},Ry=class extends wy{_tag=`Arrays`;isMutable;elements;rest;encodingChecks;constructor(e,t,n,r,i,a,o,s){super(r,i,a,o),this.isMutable=e,this.elements=t,this.rest=n,this.encodingChecks=s;let c=!1;for(let e=0;e<t.length;e++)if(nx(t[e]))c=!0;else if(c)throw Error(`A required element cannot follow an optional element. ts(1257)`);if(c&&n.length>1)throw Error(`A required element cannot follow an optional element. ts(1257)`);for(let e=1;e<n.length;e++)if(nx(n[e]))throw Error(`An optional element cannot follow a rest element. ts(1266)`)}getParser(e,t=e){let n=this,r,i,a=n.elements.length,o=Math.max(0,n.rest.length-1);function s(e,t){return t<a?r[t]:t>=e?i[t-e+1]:i[0]}let c=e=>{let{input:t,len:r,options:i}=e;if(n.rest.length===0&&r>a)for(let o=a;o<r;o++){let r=new fv(n,t[o],i),a=new uv([o],r);if(i.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return I(new pv(n,[a],t,i))}return e.issues?I(new pv(n,e.issues,t,i)):$_(e.output)},l=(e,t)=>{let r=e.length,i={ast:n,getParser:s,input:e,len:r,tailThreshold:Math.max(a,r-o),output:new globalThis.Array(r),issues:void 0,options:t},u=n.rest.length===0?a:Math.max(r,a+o),d=t.concurrency===void 0?1:bl(t.concurrency),f=d===1?Vy(i,e,0,u):Hy(i,e,{concurrency:d,end:u});if(!f)return c(i);if(js(f))return Op(f,()=>c(i));let p=!0;return uf(()=>p?(p=!1,L(f,()=>c(i))):l(e,t))};return(e,a)=>{if(e===Q_)return ev;try{return Array.isArray(e)?(r||(r=n.elements.map(e=>({ast:e,parser:t(e)})),i=n.rest.map(e=>({ast:e,parser:t(e)}))),l(e,a)):I(new mv(n,e,a))}catch(e){return _f(e)}}}_rebuild(e,t,n){let r=qb(this.elements,e),i=qb(this.rest,e);return r===this.elements&&i===this.rest&&t===this.checks&&n===this.encodingChecks?this:new Ry(this.isMutable,r,i,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){return`array`}};function zy(e,t,n,r){if(n._tag===`Failure`)return Uy(e,e.ast,r,n);let i=n===tv?t:n[O];if(i!==Q_)e.output[r]=i;else{let t=e.getParser(e.tailThreshold,r);if(nx(t.ast))return;let n=new uv([r],new dv(t.ast.context?.annotations));if(e.options.errors===`all`)e.issues?e.issues.push(n):e.issues=[n];else return ku(new pv(e.ast,[n],e.input,e.options))}}var By={onItem(e,t,n){let r=n<e.len?t:Q_;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step:zy},Vy=xl()(By),Hy=Cl()(By),Uy=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let i=Mv(r.cause);if(i===void 0)return Ou(Cd(r.cause,r=>new pv(t,[new uv([n],r)],e.input,e.options)));let a=new uv([n],i);if(e.options.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return ku(new pv(t,[a],e.input,e.options))},Wy=`[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?`;function Gy(e,t,n=xy){let r,i;function a(t){switch(t._tag){case`String`:case`TemplateLiteral`:return(r??=Object.keys(e)).filter(e=>t.matchPart(e,n)!==void 0);case`Number`:return(r??=Object.keys(e)).filter(e=>t.matchKey(e,n)!==void 0);case`Symbol`:return(i??=Object.getOwnPropertySymbols(e)).filter(r=>Object.prototype.propertyIsEnumerable.call(e,r)&&t.matchKey(r,n)!==void 0);case`Union`:return[...new Set(t.types.flatMap(a))];default:return[]}}return a(px(sx(t)))}var Ky=class{name;type;constructor(e,t){this.name=e,this.type=t}};function qy(e){switch(e._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return e.types.every(qy);default:return!1}}function Jy(e){let t=Lb(e);switch(t._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return t.types.every(Jy);default:return!1}}function Yy(e){return qy(e)&&Jy(e)}var Xy=class{parameter;type;constructor(e,t){if(!Yy(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,nx(t)&&!ux(t))throw Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}},Zy=class extends wy{_tag=`Objects`;propertySignatures;indexSignatures;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=o}getParser(e,t=e){let n=this,r=n.propertySignatures.length,i=n.indexSignatures.length;if(!r&&!i)return fx(n,me);let a,o,s=()=>(a||(a=n.propertySignatures.map(e=>({parser:t(e.type),name:e.name,type:e.type})),o=i?n.indexSignatures.map(n=>({is:n,parserKey:e(px(n.parameter)),parserValue:t(n.type)})):void 0),a),c=()=>{let e=new Set(n.propertySignatures.map(e=>typeof e.name==`number`?globalThis.String(e.name):e.name)),t=(t,i,a,o,s)=>{if(s._tag===`Failure`)return Uy(t,n,i,s)??Au;let c=s===tv?o:s[O];if(a!==Q_&&c!==Q_){if(r&&(e.has(i)||e.has(typeof a==`number`?globalThis.String(a):a)))return Au;Et(t.out,a,c)}return Au},c=(e,r,i,a)=>{if(!a){let t=i.parserKey(r,e.options);if(!js(t))return L(wf(t),t=>c(e,r,i,t));a=t}if(a._tag===`Failure`)return Uy(e,n,r,a)??Au;let o=a===tv?r:a[O],s=e.input[r],l=i.parserValue(s,e.options);return js(l)?t(e,r,o,s,l):L(wf(l),n=>t(e,r,o,s,n))},l=(e,n,r)=>{let i=e.input[n],a=r.parserValue(i,e.options);return js(a)?t(e,n,n,i,a):L(wf(a),r=>t(e,n,n,i,r))},u=i?Cl()({onItem:(e,[t,n])=>n.is.parameter===Ny?l(e,t,n):c(e,t,n),step:(e,t,n)=>n._tag===`Failure`?n:void 0}):void 0;return kp(function*(t,d){if(t===Q_)return Q_;if(!(typeof t==`object`&&t&&!Array.isArray(t)))return yield*I(new mv(n,t,d));s();let f=t,p={},m={ast:n,input:f,out:p,issues:void 0,options:d},h=d.errors===`all`,g=d.onExcessProperty===`error`,_=d.concurrency===void 0?1:bl(d.concurrency),v=i&&g?n.indexSignatures.map(e=>Gy(f,e.parameter,d)):void 0;if(g){let r=v?new Set(e):e;if(v)for(let e of v)for(let t of e)r.add(t);let i=Reflect.ownKeys(f);for(let e=0;e<i.length;e++){let a=i[e];if(!r.has(a)&&Object.prototype.propertyIsEnumerable.call(f,a)){let e=new fv(n,f[a],d),r=new uv([a],e);if(h){m.issues?m.issues.push(r):m.issues=[r];continue}else return yield*I(new pv(n,[r],t,d))}}}if(r){let e=_===1?eb(m,a):tb(m,a,{concurrency:_});e&&(yield*e)}if(i&&_===1)for(let e=0;e<i;e++){let t=o[e],n=t.is.parameter===Ny?l:c,r=v?.[e]??(t.is.parameter===Ny?Object.keys(f):Gy(f,t.is.parameter,d));for(let e=0;e<r.length;e++){let i=n(m,r[e],t);if(!js(i))yield*i;else if(i._tag===`Failure`)return yield*i}}else if(u){let e=ua();for(let t=0;t<i;t++){let n=o[t],r=v?.[t]??(n.is.parameter===Ny?Object.keys(f):Gy(f,n.is.parameter,d));for(let t=0;t<r.length;t++)e.push([r[t],n])}let t=u(m,e,{concurrency:_});t&&(yield*t)}return m.issues?yield*I(new pv(n,m.issues,t,d)):p})};if(i)return c();let l,u=(e,t,n)=>{let r=a[t];return L(wf(n),n=>{let i=Qy(e,r,n);if(i)return i;let o=()=>$_(e.out),s=eb(e,a.slice(t+1));return s?Op(s,o):o()})};return(e,t)=>{if(e===Q_)return ev;if(t.errors===`all`||t.onExcessProperty!==void 0||t.concurrency!==void 0&&bl(t.concurrency)!==1)return(l??=c())(e,t);if(!(typeof e==`object`&&e&&!Array.isArray(e)))return I(new mv(n,e,t));let r=s(),i=e,a={},o={ast:n,input:i,out:a,issues:void 0,options:t};try{for(let e=0;e<r.length;e++){let n=r[e],s=n.name,c=mb(i,s),l=c?i[s]:Q_,d=n.parser(l,t);if(!js(d))return u(o,e,d);if(d===tv){c&&Et(a,s,l);continue}let f=Qy(o,n,d);if(f)return f}}catch(e){return _f(e)}return $_(a)}}_rebuild(e,t,n,r){let i=qb(this.propertySignatures,t=>{let n=e(t.type);return n===t.type?t:new Ky(t.name,n)}),a=qb(this.indexSignatures,n=>{let r=t(n.parameter),i=e(n.type);return r===n.parameter&&i===n.type?n:new Xy(r,i)});return i===this.propertySignatures&&a===this.indexSignatures&&n===this.checks&&r===this.encodingChecks?this:new Zy(i,a,this.annotations,n,void 0,this.context,r)}flip(e){return this._rebuild(e,e,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,this.checks,this.encodingChecks)}getExpected(){return this.propertySignatures.length===0&&this.indexSignatures.length===0?`object | array`:`object`}};function Qy(e,t,n){if(n._tag===`Failure`)return Uy(e,e.ast,t.name,n);if(n===tv)return;let r=n[O];if(r!==Q_){Et(e.out,t.name,r);return}if(delete e.out[t.name],!nx(t.type)){let n=new uv([t.name],new dv(t.type.context?.annotations));if(e.options.errors===`all`){e.issues?e.issues.push(n):e.issues=[n];return}else return ku(new pv(e.ast,[n],e.input,e.options))}}var $y={onItem(e,t){if(!mb(e.input,t.name))return t.parser(Q_,e.options);let n=e.input[t.name];return Et(e.out,t.name,n),t.parser(n,e.options)},step:Qy},eb=xl()($y),tb=Cl()($y);function nb(e,t){return e?t?[...e,...t]:e:t}function rb(e,t,n){return new Zy(Reflect.ownKeys(e).map(t=>new Ky(t,e[t].ast)),[],n,t)}function ib(e){return e.ast}function ab(e,t=void 0){return new Ry(!1,e.map(e=>e.ast),[],void 0,t)}function ob(e,t,n){return new gb(e.map(ib),t,void 0,n)}function sb(e){if(e.encoding)throw Error(`mutable does not support encodings`);return new Ry(!0,e.elements,e.rest,e.annotations,e.checks,void 0,e.context,e.encodingChecks)}var cb=T(e=>{for(;;){if(yy(e))return Ay;let t=e.encoding;if(!t)return e.recur?.(cb,x)??e;if(t.some(e=>e.transformation._tag===`Middleware`&&e.transformation.decode!==x))return Ay;e=t[t.length-1].to}});function lb(e){switch(e._tag){case`Null`:return[`null`];case`Undefined`:return[`undefined`];case`String`:case`TemplateLiteral`:return[`string`];case`Number`:return[`number`];case`Boolean`:return[`boolean`];case`Symbol`:case`UniqueSymbol`:return[`symbol`];case`BigInt`:return[`bigint`];case`Arrays`:return[`array`];case`ObjectKeyword`:return[`object`,`array`,`function`];case`Objects`:return e.propertySignatures.length||e.indexSignatures.length?[`object`]:[`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`];case`Enum`:return Array.from(new Set(e.enums.map(([,e])=>typeof e)));case`Literal`:return[typeof e.literal];case`Union`:return Array.from(new Set(e.types.flatMap(lb)));default:return[`null`,`undefined`,`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`]}}function ub(e){switch(e._tag){default:return[];case`Declaration`:{let t=e.annotations?.[Y_];return Array.isArray(t)?t:[]}case`Objects`:return e.propertySignatures.flatMap(e=>{let t=e.type;if(!nx(t)){if(hy(t))return[{key:e.name,literal:t.literal}];if(gy(t))return[{key:e.name,literal:t.symbol}]}return[]});case`Arrays`:return e.elements.flatMap((e,t)=>{if(!nx(e)){if(hy(e))return[{key:t,literal:e.literal}];if(gy(e))return[{key:t,literal:e.symbol}]}return[]});case`Union`:{if(e.types.length===0)return[];let t=e.types.map(e=>ub(cb(e)));return t[0].filter(e=>t.every(t=>t.some(t=>t.key===e.key&&t.literal===e.literal)))}case`Suspend`:return ub(e.thunk())}}var db=new WeakMap,fb=Object.freeze([]),pb=e=>e===null?`null`:Array.isArray(e)?`array`:typeof e,mb=(e,t)=>t===`__proto__`?Object.hasOwn(e,t):t in e;function hb(e){let t=db.get(e);if(t)return t;let n,r=0,i,a,o=!0,s=[];for(let t=0;t<e.length;t++){let c=e[t],l=cb(c);if(my(l))continue;if(hy(l)||gy(l)){a??=new Map;let e=hy(l)?l.literal:l.symbol;s[t]=e;let n=a.get(e);n||a.set(e,n=[]),n.push(t)}else o=!1;let u=ub(l);if(u.length){n??=new Map,r++;for(let{key:e,literal:r}of u){let i=n.get(e);i||n.set(e,i=[new Map,new Set]),i[1].add(t);let a=i[0].get(r);a||i[0].set(r,a=new Set),a.add(t)}}else{i??={};let e=lb(l);for(let n of e)(i[n]??=[]).push(t)}}let c={},l=e=>c[e]??=Object.freeze(i?.[e]??fb);if(o&&a)a.forEach(Object.freeze),t=e=>a.get(e)??fb;else if(n?.size===1&&!i){let[r,[i]]=n.entries().next().value,a=new Map;for(let[e,t]of i)a.set(e,Object.freeze(Array.from(t)));let o=Object.freeze(e.map((e,t)=>t));t=(e,t)=>{if(_e(e)){let n=mb(e,r)?e[r]:void 0;if(n!==void 0)return a.get(n)??fb;if(t)return o}return fb}}else if(n){let e;for(let t of n)(!e||t[1][0].size>e[1][0].size)&&t[1][1].size===r&&(e=t);t=(t,r)=>{let a=pb(t);if(!_e(t))return l(a);let o=new Set(i?.[a]),s;if(e){let[n,[i]]=e,c=mb(t,n),u=c?t[n]:void 0;if(c&&(!r||u!==void 0)){let e=i.get(u);if(!e)return l(a);for(let t of e)o.add(t);s=n}}if(s===void 0)for(let[e,[i,a]]of n){let n=mb(t,e),s=n?t[e]:void 0;if(n&&(!r||s!==void 0)){let e=i.get(s);if(e)for(let t of e)o.add(t)}else if(r)for(let e of a)o.add(e)}for(let[e,[i,a]]of n){if(e===s)continue;let n=mb(t,e),c=n?t[e]:void 0;if(n&&(!r||c!==void 0)){let e=i.get(c);for(let t of o)a.has(t)&&!e?.has(t)&&o.delete(t)}}return Array.from(o).sort((e,t)=>e-t)}}else t=e=>{let t=l(pb(e));return a?t.filter(t=>s[t]===void 0||s[t]===e):t};return db.set(e,t),t}var gb=class extends wy{_tag=`Union`;types;options;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.types=e,this.options=t,this.encodingChecks=o}getParser(e,t){let n=this,r=t!==void 0,i=[],a=t=>i[t]??=e(n.types[t]),o;return(e,t)=>{if(e===Q_)return ev;let i=(o??=hb(n.types))(e,r);if(i.length===0)return I(new _v(n,[],e,t));if(i.length===1){let r=a(i[0])(e,t);return r._tag===`Success`?r:js(r)?_b(n,r.cause,e,t):vb(n,r,e,t)}return yb(n,a,i,e,t)}}_rebuild(e,t,n){let r=qb(this.types,e);return r===this.types&&t===this.checks&&n===this.encodingChecks?this:new gb(r,this.options,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}matchPart(e,t){for(let n of this.types){let r=n.matchPart(e,t);if(r!==void 0)return r}}getExpected(e){let t=this.annotations?.expected;if(typeof t==`string`)return t;if(this.types.length===0)return`never`;let n=this.types.map(t=>{let n=sx(t);switch(n._tag){case`Arrays`:{let t=n.elements.filter(hy);if(t.length>0)return`${Cb(n.isMutable)}[ ${t.map(t=>e(t)+wb(t.context?.isOptional)).join(`, `)}, ... ]`;break}case`Objects`:{let t=n.propertySignatures.filter(e=>hy(e.type));if(t.length>0)return`{ ${t.map(t=>`${Cb(t.type.context?.isMutable)}${ut(t.name)}${wb(t.type.context?.isOptional)}: ${e(t.type)}`).join(`, `)}, ... }`;break}}return e(n)});return Array.from(new Set(n)).join(` | `)}};function _b(e,t,n,r){let i=Mv(t);return i?ku(new _v(e,[i],n,r)):Ou(t)}function vb(e,t,n,r){return Nf(t,t=>_b(e,t,n,r))}function yb(e,t,n,r,i){let a={ast:e,parser:t,input:r,out:void 0,successes:e.options?.mode===`oneOf`?[]:void 0,issues:void 0,options:i},o=xb(a,n);return o?bb(o,a):a.out?a.out:I(new _v(e,a.issues??[],r,i))}function bb(e,t){return Op(e,e=>t.out===tv?P(t.input):t.out?t.out:I(new _v(t.ast,t.issues??[],t.input,t.options)))}var xb=xl()({onItem(e,t){return e.parser(t)(e.input,e.options)},step(e,t,n){if(n._tag===`Failure`){let t=Mv(n.cause);if(t===void 0)return n;e.issues?e.issues.push(t):e.issues=[t]}else{if(e.out&&e.successes)return e.successes.push(e.ast.types[t]),ku(new vv(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(e.ast.types[t]);else return Au}}}),Sb=new gb([new jy(`Infinity`),new jy(`-Infinity`),new jy(`NaN`)]);function Cb(e){return e?``:`readonly `}function wb(e){return e?`?`:``}var Tb=class extends wy{_tag=`Suspend`;thunk;constructor(e,t,n,r,i){if(n)throw Error(`Cannot add checks to Suspend`);super(t,void 0,r,i);let a;this.thunk=()=>a??=e()}getParser(e){let t;return(n,r)=>(t??=e(this.thunk()))(n,r)}recur(e){return new Tb(()=>e(this.thunk()),this.annotations,void 0,void 0,this.context)}getExpected(e){return e(this.thunk())}},Eb=class extends y{_tag=`Filter`;run;annotations;aborted;constructor(e,t=void 0,n=!1){super(),this.run=e,this.annotations=t,this.aborted=n}annotate(e){return new Eb(this.run,{...this.annotations,...e},this.aborted)}abort(){return new Eb(this.run,this.annotations,!0)}and(e,t){return new Db([this,e],t)}},Db=class extends y{_tag=`FilterGroup`;checks;annotations;constructor(e,t=void 0){super(),this.checks=e,this.annotations=t}annotate(e){return new Db(this.checks,{...this.annotations,...e})}and(e,t){return new Db([this,e],t)}};function Ob(e,t,n=!1){return new Eb((t,n,r)=>xv(n,e(t,n,r),t,r),t,n)}function kb(e){return Ob(e=>globalThis.Number.isFinite(e),{expected:`a finite number`,representation:{id:`effect/schema/isFinite`,payload:null},toJsonSchema:()=>({type:`number`}),toCode:()=>({runtime:`Schema.isFinite()`}),arbitraryConstraint:{number:`finite`},...e})}var Ab=new by(new gb([Bb(Iy,[kb()]),Sb]),new Zv(Kv(),zv(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function jb(e,t){let n=new globalThis.RegExp(e),r={source:n.source,flags:n.flags};return Ob(e=>(n.lastIndex=0,n.test(e)),{expected:`a string matching the RegExp ${r.source}`,representation:{id:`effect/schema/isPattern`,payload:r},toJsonSchema:()=>[{},!0],arbitraryConstraint:{patterns:[r]},...t})}var Mb=new WeakMap;function Nb(e,t){let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,t);return Reflect.ownKeys(t).every(e=>e===`context`||e===`encoding`)&&Mb.set(n,Pb(e)),n}function Pb(e){let t=Mb.get(e);if(t!==void 0)return t;if(e.encoding===void 0)return e;let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,{encoding:void 0});return Mb.set(e,n),n}function Fb(e,t){return e.encoding===t?e:Nb(e,{encoding:t})}function Ib(e,t){if(e.context===t)return e;let n=Pb(e);return n.context===t&&n.encoding===e.encoding?n:Nb(e,{context:t})}function Lb(e){return e.encoding?Lb(e.encoding[e.encoding.length-1].to):e}function Rb(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return zb(e,$i(e.checks.slice(0,-1),n.annotate(t)))}return Nb(e,{annotations:{...e.annotations,...t}})}function zb(e,t){if(e._tag===`Suspend`&&t)throw Error(`Cannot add checks to Suspend`);return e.checks===t?e:Nb(e,{checks:t})}function Bb(e,t){return zb(e,nb(e.checks,t))}function Vb(e,t){let n=t(e.to);return n===e.to?e:new by(n,e.transformation)}function Hb(e,t){let n=e,r=n[n.length-1],i=Vb(r,t);return i===r?e:$i(e.slice(0,e.length-1),i)}function Ub(e){return t=>t.encoding?Fb(t,Hb(t.encoding,e)):t}function Wb(e,t){return Ub(e=>Ib(e,t))(e)}function Gb(e,t){function n(r){if(r.encoding){let e=r.encoding[r.encoding.length-1];return t?.stopAt?.(e)?r:Fb(r,Hb(r.encoding,n))}return e(r)}return T(n)}function Kb(e,t,n){let r=new by(e,t);return Fb(n,n.encoding?[...n.encoding,r]:[r])}function qb(e,t){let n;for(let r=0;r<e.length;r++){let i=e[r],a=t(i);if(n)n[r]=a;else if(a!==i){n=Array(e.length);for(let t=0;t<r;t++)n[t]=e[t];n[r]=a}}return n??e}function Jb(e,t){return Ib(e,e.context?new Sy(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new Sy(!1,!1,void 0,t))}var Yb=T(e=>Xb(Ib(e,e.context?e.context.isOptional===!1?new Sy(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new Sy(!0,!1)))),Xb=Ub(Yb),Zb=w(e=>Yb(new gb([e,ky])));function Qb(e,t){return Ib(e,e.context?new Sy(e.context.isOptional,e.context.isMutable,t,e.context.annotations):new Sy(!1,!1,t))}function $b(e,t,n){return Kb(e,n,t)}function ex(e){let t=[],n=[];function r(e){switch(e._tag){case`Literal`:de(e.literal)&&!t.includes(e.literal)&&t.push(e.literal);return;case`UniqueSymbol`:t.includes(e.symbol)||t.push(e.symbol);return;case`Never`:return;case`Union`:for(let t=0;t<e.types.length;t++)r(e.types[t]);return;default:n.push(e)}}return r(e),{literals:t,parameters:n}}function tx(e,t){let{literals:n,parameters:r}=ex(e);return new Zy(n.map(e=>new Ky(e,t)),r.map(e=>new Xy(e,t)))}function nx(e){return e.context?.isOptional??!1}function rx(e){return e.annotations?.[`~structural`]===!0||e._tag===`FilterGroup`&&e.checks.every(rx)}function ix(e){function t(e){return rx(e)?[e]:e._tag===`FilterGroup`?e.checks.flatMap(t):[]}let n=e.flatMap(t);return ea(n)?n:void 0}function ax(e){let t=!0;function n(e){return t=t&&!e.encoding&&!yy(e),t&&`recur`in e&&e.recur(n),e}return`recur`in e&&e.recur(n),t}var ox=T(e=>{let t=Pb(e);if(t!==e){let n=ox(t);return n===t&&e.encoding===void 0?e:Ib(n,e.context)}let n=`recur`in e?e.recur(ox):e;if(`encodingChecks`in n&&n.encodingChecks){let t=ax(e)?n.encodingChecks:_y(n)||vy(n)||py(n)&&n.typeParameters.length>0?ix(n.encodingChecks):void 0;return Nb(n,{encodingChecks:void 0,checks:nb(n.checks,t)})}return n}),sx=T(e=>ox(lx(e)));function cx(e,t){let n=t,r=n.length,i=n[r-1],a=[new by(lx(Fb(e,void 0)),n[0].transformation.flip())];for(let e=1;e<r;e++)a.unshift(new by(lx(n[e-1].to),n[e].transformation.flip()));let o=lx(i.to);return o.encoding?Fb(o,[...o.encoding,...a]):Fb(o,a)}var lx=w(e=>{if(e.encoding)return cx(e,e.encoding);let t=Pb(e);if(t!==e){let n=lx(t);return n===t?e:Ib(n,e.context)}return`flip`in e?e.flip(lx):`recur`in e?e.recur(lx):e});function ux(e){switch(e._tag){case`Undefined`:return!0;case`Union`:return e.types.some(ux);default:return!1}}function dx(e,t){let n=t===0?tv:$_(t);return(r,i)=>r===Q_?ev:r===t?n:I(new mv(e,r,i))}function fx(e,t){return(n,r)=>n===Q_?ev:t(n)?tv:I(new mv(e,n,r))}var px=Gb(e=>{switch(e._tag){default:return e;case`Number`:return e.toCodecStringTree();case`Union`:return e.recur(px)}}),mx=Gb(e=>{switch(e._tag){default:return e;case`Symbol`:case`UniqueSymbol`:return e.toCodecStringTree();case`Union`:return e.recur(mx)}}),hx=new globalThis.RegExp(`^${Wy}$`),gx=new globalThis.RegExp(`^(?:${Wy}|Infinity|-Infinity|NaN)$`);function _x(e){return jb(hx,{expected:`a string representing a finite number`,representation:{id:`effect/schema/isStringFinite`,payload:null},toJsonSchema:()=>({pattern:hx.source}),...e})}var vx=Bb(Ny,[_x()]),yx=new by(vx,ry),bx=new by(new gb([vx,Sb]),ry);function xx(e,t,n,r,i){for(let a=0;a<e.length;a++){let o=e[a];if(o._tag===`FilterGroup`){if(n=xx(o.checks,t,n,r,i),n&&(i.errors!==`all`||n[n.length-1].filter.aborted))return n}else{let e=o.run(t,r,i);if(e){let r=new cv(o,e,t,i);if(n?n.push(r):n=[r],i.errors!==`all`||o.aborted)return n}}}return n}function Sx(e){if(!py(e))return;let t=e.annotations?.[X_];return fe(t)?t(e.typeParameters):void 0}function Cx(e){return e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&globalThis.Number.isFinite(e)}function wx(e){return e===void 0||typeof e==`string`}function Tx(e,t){let n=new WeakMap,r=[];outer:for(;;){if(typeof e!=`object`||!e){if(!t(e))return!1}else{let t=e,i=n.get(t);if(i===!1)return!1;if(i===void 0){let e=Array.isArray(t);if(!e){let e=Object.getPrototypeOf(t);if(e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null)return!1}n.set(t,!1),r.push({value:t,keys:e?t.length:Object.keys(t),index:0})}}for(;r.length>0;){let t=r[r.length-1],i=t.keys;if(typeof i==`number`){if(t.index<i){e=t.value[t.index++];continue outer}}else if(t.index<i.length){e=t.value[i[t.index++]];continue outer}n.set(t.value,!0),r.pop()}return!0}}function Ex(e){return Tx(e,Cx)}var Dx=new Ty([],()=>(e,t,n)=>Ex(e)?tv:I(new mv(t,e,n)),{representation:{id:`effect/schema/Json`,payload:null},expected:`JSON value`,toCodecJson:()=>void 0,toCodecStringTree:()=>jx}),Ox=new by(Dx,ny()),kx=new by(new gb([new Ry(!1,[],[Dx]),new Zy([],[new Xy(Ny,Dx)])]),ny());function Ax(e){return Tx(e,wx)}var jx=new by(new Ty([],()=>(e,t,n)=>Ax(e)?tv:I(new mv(t,e,n)),{expected:`StringTree`,toCodecStringTree:()=>void 0}),ny()),Mx=(e,t,n)=>e===tv?n(t):Op(e,n);function Nx(e){if(e._tag===`Middleware`)return(t,n,r)=>Px(t===tv?e.decode($_(nv(n)),r):e.decode(Tp(t,nv),r));let t=e.decode;switch(t._tag){case`Passthrough`:return(e,t)=>e===tv?$_(t):e;case`Transform`:{let e=e=>e===Q_?ev:$_(t.transform(e));return(t,n)=>Mx(t,n,e)}case`TransformOptional`:{let e=e=>rv(t.transform(nv(e)));return(t,n)=>Mx(t,n,e)}case`TransformEffect`:return(e,n,r)=>Mx(e,n,e=>e===Q_?ev:t.transform(e,r));case`TransformOptionalEffect`:return(e,n,r)=>Mx(e,n,e=>Px(t.transform(nv(e),r)))}}var Px=e=>Op(e,rv),Fx=(e,t,n,r)=>Nf(r,r=>gf(()=>Cd(r,r=>new lv(e,r,t,n))));function Ix(e,t){let n=Nx(e.link.transformation),r;return(i,a)=>{if(i===Q_)return ev;if(e.isConstructed(i))return tv;let o=(r??=t(e.link.to))(i,a);return n(o,i,a)}}function Lx(e,t){let n=e.context.constructorDefault;return(r,i)=>{if(r!==Q_&&r!==void 0)return t(r,i);let a=n;if(js(a)&&a._tag===`Success`){let e=t(a[O],i);return e===tv?a:e}return Op(Fx(e,r,i,a),e=>{let n=t(e,i);return n===tv?$_(e):n})}}function Rx(e,t){let n=t(e);return e.context?.constructorDefault===void 0?n:Lx(e,n)}function zx(e,t,n,r,i){if(e._tag===`Declaration`)for(let n of e.typeParameters)t(n);let a=n?Sx(e):void 0,o=a?Ix(a,t):r??e.getParser(t,n),s=e.checks,c=e.encoding,l=c?.map(e=>Nx(e.transformation)),u=e.encodingChecks;if(!c&&!s&&!u)return o;let d,f=(t,n)=>{let r=o(t,n);if(u&&!n.disableChecks)if(js(r)){if(r._tag===`Success`){let i=r===tv?t:r[O];if(t!==Q_&&i!==Q_){let i=xx(u,t,void 0,e,n);i&&(r=I(new pv(e,i,t,n)))}}}else r=L(r,r=>{if(t!==Q_&&r!==Q_){let r=xx(u,t,void 0,e,n);if(r)return I(new pv(e,r,t,n))}return P(r)});if(s&&!n.disableChecks)if(js(r)){if(r._tag===`Success`){let i=r===tv?t:r[O];if(i===Q_)return r;let a=xx(s,i,void 0,e,n);a&&(r=I(new pv(e,a,i,n)))}}else r=L(r,t=>{if(t!==Q_){let r=xx(s,t,void 0,e,n);if(r)return I(new pv(e,r,t,n))}return P(t)});return r},p=i===void 0?f:i(f);return c?(n,r)=>{let i=d??=c.map(e=>t(e.to)),a=n,o=i[i.length-1](n,r);for(let e=c.length-1;e>=0;e--)if(o=l[e](o,a,r),e!==0){let t=i[e-1];o._tag===`Success`?(a=o[O],o=t(a,r)):o=Op(o,e=>{let n=t(e,r);return n===tv?$_(e):n})}if(o._tag===`Success`){let e=o[O],t=p(e,r);return t===tv?o:t}return o=Fx(e,n,r,o),Op(o,e=>{let t=p(e,r);return t===tv?$_(e):t})}:p}var Bx=Symbol(),Vx=new WeakMap,Hx,Ux=e=>Xx(e).parser,Wx=e=>Xx(e).makeEffect,Gx=e=>Rx(e,Wx),Kx=class{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=zx(this.ast,Ux)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=zx(this.ast,Wx,Gx)}},qx=class extends Kx{compiled;resolve;constructor(e,t,n){super(e),this.compiled=t,this.resolve=n}save(e,t){return Object.defineProperty(this,e,{value:t}),t}operation(e){let t=this.compiled;return typeof t==`function`?t(this.ast,this.resolve,e):t?.[e]}get is(){return this.save(`is`,this.operation(`is`))}get decode(){return this.save(`decode`,this.operation(`decode`))}get make(){return this.save(`make`,this.operation(`make`))}get decodeEffect(){return this.save(`decodeEffect`,this.operation(`decodeEffect`)??zx(this.ast,e=>Yx(this.resolve,e,`parser`)))}get parser(){let e=this.decode;return e===void 0?this.decodeEffect:this.save(`parser`,Jx(e,()=>this.decodeEffect))}get makeEffect(){let e=this.operation(`makeEffect`);if(e!==void 0)return this.save(`makeEffect`,e);let t=e=>Yx(this.resolve,e,`makeEffect`);return this.save(`makeEffect`,zx(this.ast,t,e=>Rx(e,t)))}};function Jx(e,t){let n;return(r,i)=>{if(r!==Q_)try{let t=e(r,i);if(t!==Bx)return t===r?tv:$_(t)}catch(e){return _f(e)}return(n??=t())(r,i)}}function Yx(e,t,n){let r=e(t);if(r.compiled===void 0||Object.hasOwn(r,n))return r[n];let i;return(e,t)=>(i??=r[n])(e,t)}function Xx(e){let t=Vx.get(e);if(t!==void 0)return t;let n=Hx===void 0?new Kx(e):new qx(e,Hx(e,Xx),Xx);return Vx.set(e,n),n}function Zx(e){let t=e.ast,n;return(e,r)=>(n??=cS(hS,ox(t)))(e,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function Qx(e){let t=Zx(e);return(e,n)=>{let r=Sp(t(e,n));return ju(r)?cr(r.value):(Nv(r.cause,`Option adapter can only return none for schema issues`),sr())}}function $x(e){return pS(ox(e.ast))}function eS(e,t){let n=oS(e.ast);return t===void 0?n:(e,r)=>n(e,iS(t,r))}function tS(e,t){return uS(eS(e,t))}function nS(e,t){return dS(eS(e,t))}function rS(e,t){let n=oS(lx(e.ast));return t===void 0?n:(e,r)=>n(e,iS(t,r))}var iS=(e,t)=>t?{...e,...t}:e,aS=e=>e===Q_?I(new hv):P(e);function oS(e){return cS(mS,e)}function sS(e,t){return e===tv?P(t):js(e)?e[O]===Q_?aS(Q_):e:Op(e,aS)}function cS(e,t){let n;return(r,i)=>{let a=(n??=e(t))(r,i??xy);return a===tv?P(r):js(a)?a[O]===Q_?aS(Q_):a:Op(a,aS)}}function lS(e){return(t,n)=>Sp(e(t,n))}function uS(e){let t=lS(e);return(e,n)=>{let r=t(e,n);return ju(r)?cr(r.value):(Nv(r.cause,`Option adapter can only return none for schema issues`),sr())}}function dS(e){let t=lS(e);return(e,n)=>{let r=t(e,n);return ju(r)?Pi(r.value):Fi(Nv(r.cause,`Result adapter can only return schema issues`))}}function fS(e,t){let n=Sp(e);if(ju(n))return n.value;let r=Nv(n.cause,t);throw Error(`Schema validation failed`,{cause:r})}function pS(e){let t,n;return(r,i)=>{t??=Xx(e);let a=i?.disableChecks?i.parseOptions?{...i.parseOptions,disableChecks:!0}:{disableChecks:!0}:i?.parseOptions??xy,o=t.make;if(o!==void 0&&r!==Q_){let e;try{e=o(r,a)}catch(e){throw Nv(xd(e),`Constructor adapter can only throw schema issues`),e}if(e!==Bx&&e!==Q_)return e}return fS(sS((n??=t.makeEffect)(r,a),r),`Constructor adapter can only throw schema issues`)}}var mS=e=>Xx(e).parser,hS=e=>Xx(e).makeEffect,gS=`~effect/Schema/Schema`,_S=Symbol(),vS={[gS]:gS,get make(){let e=$x(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=Zx(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=Qx(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return _(this,arguments)},annotate(e){return this.rebuild(Rb(this.ast,e))},annotateKey(e){return this.rebuild(Jb(this.ast,e))},check(...e){return this.rebuild(Bb(this.ast,e))},rebuild(e){return yS(e,this[_S])}};function yS(e,t){function n(){}let r=Object.setPrototypeOf(n,vS);return t&&(Object.hasOwn(t,`name`)||Object.hasOwn(t,`length`)||Object.hasOwn(t,`__proto__`))?Object.defineProperties(r,Object.getOwnPropertyDescriptors({...t})):Object.assign(r,t),r[_S]=t,r.ast=e,r}function bS(e){return yS(xS(e.ast),{schema:e})}var xS=Gb(e=>{let t=ES(e,xS),n=e.context;return t===e||n===void 0?t:Wb(t,SS(n))});function SS(e){return e.constructorDefault===void 0?e:new Sy(e.isOptional,e.isMutable,void 0,e.annotations)}function CS(e){if(e.propertySignatures.some(e=>typeof e.name!=`string`))throw new globalThis.Error(`Objects property names must be strings`,{cause:e})}function wS(e){return t=>{let n=[...t].sort((t,n)=>e(sx(t))-e(sx(n)));return n.some((e,n)=>e!==t[n])?n:t}}var TS=wS(e=>{switch(e._tag){case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function ES(e,t){switch(e._tag){case`Declaration`:{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!fe(n))return Fb(e,[Ox]);let r=n(e.typeParameters.map(e=>yS(sx(e))));return r===void 0?e:Fb(e,[Vb(r,t)])}case`Unknown`:return Fb(e,[Ox]);case`ObjectKeyword`:return Fb(e,[kx]);case`Undefined`:case`Void`:case`Literal`:case`Number`:return e.toCodecJson();case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return CS(e),e.recur(t,mx);case`Union`:{let n=TS(e.types);return n===e.types?e.recur(t):new gb(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t)}case`Arrays`:case`Suspend`:return e.recur(t)}return e}var DS=e=>e,OS=`~effect/Schema/SchemaError`;function kS(e){return D(e,`~effect/Schema/SchemaError`)&&e[`~effect/Schema/SchemaError`]===`~effect/Schema/SchemaError`}var AS=gS;function jS(){return(e,t,n)=>qS(new Ty(e.map(ib),e=>t(e.map(e=>qS(e))),n))}function MS(e,t){return jS()([],()=>(t,n,r)=>e(t)?P(t):I(new mv(n,t,r)),t)}var NS=class extends Da(`SchemaError`){[OS]=OS;constructor(e){let t=St();Ct(0);try{super({issue:e})}finally{Ct(t)}}get message(){return kv(this.issue)}toString(){return`SchemaError(${this.message})`}};function PS(e){return kS(e)}function FS(e){return js(e)?IS(e):Nf(e,e=>gf(()=>Cd(e,e=>new NS(e))))}function IS(e){return ju(e)?e:Ou(Cd(e.cause,e=>new NS(e)))}function LS(e,t){let n;for(let r of e.reasons){if(!yd(r)||!PS(r.error))throw new globalThis.Error(t,{cause:e});n??=r.error}if(n===void 0)throw new globalThis.Error(t,{cause:e});return n}function RS(e){let t=Sp(e);if(ju(t))return t.value;throw LS(t.cause,`Sync adapter can only throw schema errors`)}function zS(e,t){let n=eS(e,t);return(e,t)=>FS(n(e,t))}var BS=zS,VS=tS;function HS(e,t){let n=nS(e,t);return(e,t)=>zi(n(e,t),e=>new NS(e))}function US(e,t){let n=zS(e,t);return(e,t)=>RS(n(e,t))}function WS(e,t){let n=rS(e,t);return(e,t)=>FS(n(e,t))}function GS(e,t){let n=WS(e,t);return(e,t)=>RS(n(e,t))}var KS=GS,qS=yS;function JS(e){return D(e,AS)&&e[AS]===AS}var z=DS(e=>qS(Yb(e.ast),{schema:e})),YS=DS(e=>{let t=sC(e);return qS(Zb(e.ast),{schema:t})}),XS=DS(e=>qS(ox(e.ast),{schema:e})),ZS=DS(e=>qS(sx(e.ast),{schema:e}));function B(e){let t=qS(new jy(e),{literal:e,transform(n){return t.pipe(lC(B(n),{decode:zv(()=>n),encode:zv(()=>e)}))}});return t}var QS=qS(Ay),$S=qS(Ey),eC=qS(ky),V=qS(Ny),H=qS(Iy),U=qS(Ly);function tC(e,t){return qS(e,{fields:t,mapFields(e,t){let n=e(this.fields);return tC(rb(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function W(e){return tC(rb(e,void 0),e)}function nC(e,t){return qS(tx(e.ast,t.ast),{key:e,value:t})}function rC(e,t){return qS(e,{elements:t,mapElements(e,t){let n=e(this.elements);return rC(ab(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}var G=DS(e=>qS(new Ry(!1,[],[e.ast]),{value:e})),iC=DS(e=>qS(sb(e.ast),{schema:e}));function aC(e,t){return qS(e,{members:t,mapMembers(e,t){let n=e(this.members);return aC(ob(n,this.ast.options,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function K(e,t){return aC(ob(e,t,void 0),e)}function q(e){let t=e.map(B);return qS(ob(t,void 0,void 0),{literals:e,members:t,mapMembers(e){return K(e(this.members))},pick(e){return q(e)},transform(e){return K(t.map((t,n)=>t.transform(e[n])))}})}var oC=DS(e=>K([e,$S])),sC=DS(e=>K([e,eC]));function cC(e){return qS(new Tb(()=>e().ast))}function lC(e,t){return n=>qS($b(n.ast,e.ast,t?$v(t):ny()),{from:n,to:e})}function uC(e){return t=>qS(Qb(t.ast,e),{schema:t})}function dC(e){return Nf(e,e=>gf(()=>Cd(e,e=>e.issue)))}function fC(e,t){let n=t?.encodingStrategy===`omit`?Uv():Rv();return t=>z(ZS(t)).pipe(lC(t,{decode:Wv(dC(e)),encode:n}))}function pC(e){return B(e).pipe(uC(P(e)))}function mC(e,t){return W({_tag:pC(e),...t})}function hC(e,t){return MS(t=>t instanceof e,t)}function gC(){return(e,t)=>new by(e.ast,$v(t))}var _C=Ob;function vC(e,t){let n=e.source,r=e.flags,i=/^[dg]*uy?$/.test(r),a=r===``?`new RegExp(${ct(n)})`:`new RegExp(${ct(n)}, ${ct(r)})`;return jb(e,{toJsonSchema:()=>i?{pattern:r.endsWith(`y`)?`^(?:${n})`:n}:[{},!0],toCode:()=>({runtime:`Schema.isPattern(${a})`}),...t})}var yC=kb;function bC(e){let t=ir(e.order),n=e.formatter??ct;return(r,i)=>_C(e=>t(e,r),{expected:`a value greater than ${n(r)}`,arbitraryConstraint:{order:e.order,minimum:r,exclusiveMinimum:!0},...e.annotate?.(r),...i})}function xC(e){let t=or(e.order),n=e.formatter??ct;return(r,i)=>_C(e=>t(e,r),{expected:`a value greater than or equal to ${n(r)}`,arbitraryConstraint:{order:e.order,minimum:r},...e.annotate?.(r),...i})}function SC(e){let t=ar(e.order),n=e.formatter??ct;return(r,i)=>_C(e=>t(e,r),{expected:`a value less than or equal to ${n(r)}`,arbitraryConstraint:{order:e.order,maximum:r},...e.annotate?.(r),...i})}function CC(e){let t=or(e.order),n=ir(e.order),r=ar(e.order),i=rr(e.order),a=e.formatter??ct;return(o,s)=>{let c=o.exclusiveMinimum?n:t,l=o.exclusiveMaximum?i:r;return _C(e=>c(e,o.minimum)&&l(e,o.maximum),{expected:`a value between ${a(o.minimum)}${o.exclusiveMinimum?` (excluded)`:``} and ${a(o.maximum)}${o.exclusiveMaximum?` (excluded)`:``}`,arbitraryConstraint:{order:e.order,minimum:o.minimum,maximum:o.maximum,...o.exclusiveMinimum&&{exclusiveMinimum:!0},...o.exclusiveMaximum&&{exclusiveMaximum:!0}},...e.annotate?.(o),...s})}}function wC(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${ct(e)}`);return e}var TC=bC({order:tr,annotate:e=>({representation:{id:`effect/schema/isGreaterThan`,payload:{exclusiveMinimum:wC(e)}},toJsonSchema:()=>({exclusiveMinimum:e}),toCode:()=>({runtime:`Schema.isGreaterThan(${ct(e)})`})})}),J=xC({order:tr,annotate:e=>({representation:{id:`effect/schema/isGreaterThanOrEqualTo`,payload:{minimum:wC(e)}},toJsonSchema:()=>({minimum:e}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualTo(${ct(e)})`})})}),EC=SC({order:tr,annotate:e=>({representation:{id:`effect/schema/isLessThanOrEqualTo`,payload:{maximum:wC(e)}},toJsonSchema:()=>({maximum:e}),toCode:()=>({runtime:`Schema.isLessThanOrEqualTo(${ct(e)})`})})}),DC=CC({order:tr,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:`effect/schema/isBetween`,payload:{minimum:wC(e.minimum),maximum:wC(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({[t?`exclusiveMinimum`:`minimum`]:e.minimum,[n?`exclusiveMaximum`:`maximum`]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${ct(e.minimum)}, maximum: ${ct(e.maximum)}, exclusiveMinimum: ${ct(t)}, exclusiveMaximum: ${ct(n)} })`})}}});function Y(e){return _C(e=>globalThis.Number.isSafeInteger(e),{expected:`an integer`,representation:{id:`effect/schema/isInt`,payload:null},toJsonSchema:()=>[{type:`integer`},!0],toCode:()=>({runtime:`Schema.isInt()`}),arbitraryConstraint:{number:`integer`},...e})}function OC(e,t){return e=NC(e),kC(e,Math.ceil(e/2),t)}function kC(e,t,n){return _C(t=>t.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:`effect/schema/isMinLength`,payload:{minLength:e}},toJsonSchema:({type:n})=>n===`string`?e<=1?{minLength:t}:[{minLength:t},!0]:n===`array`?{minItems:e}:n===void 0?[{minLength:t,minItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMinLength(${e})`}),[J_]:!0,arbitraryConstraint:{minLength:e},...n})}function AC(e,t){return e=NC(e),_C(t=>t.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:`effect/schema/isMaxLength`,payload:{maxLength:e}},toJsonSchema:({type:t})=>t===`string`?e===0?{maxLength:e}:[{maxLength:e},!0]:t===`array`?{maxItems:e}:t===void 0?[{maxLength:e,maxItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMaxLength(${e})`}),[J_]:!0,arbitraryConstraint:{maxLength:e},...t})}function jC(e,t){return e=NC(e),_C(t=>MC(t,e+1)<=e,{expected:`a string with at most ${e} code points`,representation:{id:`effect/schema/isMaxCodePoints`,payload:{maxCodePoints:e}},toJsonSchema:()=>({maxLength:e}),toCode:()=>({runtime:`Schema.isMaxCodePoints(${e})`}),arbitraryConstraint:{maxCodePoints:e},...t})}function MC(e,t){if(t===0)return 0;let n=0;for(let r of e)if(++n>=t)break;return n}function NC(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${e}`);return Math.max(0,Math.floor(e))}function PC(e){return _C(e=>ma(e).length===e.length,{expected:`an array with unique items`,representation:{id:`effect/schema/isUnique`,payload:null},toJsonSchema:()=>({uniqueItems:!0}),toCode:()=>({runtime:`Schema.isUnique()`}),arbitraryConstraint:{uniqueBy:x},...e})}var FC=e=>e?.includeStack===!0|(e?.excludeCause===!0?2:0),IC=e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},LC=[];function RC(e){let t=FC(e),n=LC[t];if(n!==void 0)return n;let r=$C.pipe(lC(QS,uy(IC(t))));return LC[t]=r,r}globalThis.RegExp,globalThis.URL;var zC=V.annotate({expected:`a string that will be decoded as JSON`,contentMediaType:`application/json`});function BC(e,t){return zC.pipe(lC(e,dy(t)))}globalThis.File,globalThis.FormData,globalThis.URLSearchParams,globalThis.Uint8Array;function VC(e,t){let n=typeof t?.label==`string`?t.label:void 0,r=t?.disallowJsonEncode===!0,i=n===void 0?r?{disallowJsonEncode:!0}:void 0:r?{label:n,disallowJsonEncode:!0}:{label:n},a=n===void 0?void 0:eS(B(n));return qS(jS()([e],([e])=>(t,n,r)=>v_(t)?Op(a===void 0?df:Ep(a(t.label,r),e=>new uv([`label`],e)),()=>Dp(eS(e)(x_(t),r),{onSuccess:e=>y_(e,{label:t.label}),onFailure:()=>new pv(n,[new uv([`value`],new hv(void 0,t,r))],t,r)})):I(new mv(n,t,r)),{representation:{id:`effect/schema/Redacted`,payload:i??null},toCode:({typeParameters:e})=>({runtime:i===void 0?`Schema.Redacted(${e[0].runtime})`:`Schema.Redacted(${e[0].runtime}, ${ct(i)})`,Type:`Redacted.Redacted<${e[0].Type}>`,importDeclarations:[`import * as Redacted from "effect/Redacted"`]}),expected:`Redacted`,toCodecJson:([e])=>gC()(e,{decode:zv(e=>y_(e,{label:n})),encode:r?Iv(e=>`Cannot serialize Redacted`+(ur(e)&&typeof e.value.label==`string`?` with label: "${e.value.label}"`:``)):zv(x_)}),toEquivalence:([e])=>S_(e)}).ast,{value:e})}function HC(e,t){return lC(VC(XS(e),{label:t?.label,disallowJsonEncode:t?.disallowEncode}),{decode:zv(e=>y_(e,{label:t?.label})),encode:t?.disallowEncode?Iv(e=>`Cannot encode Redacted`+(ur(e)&&typeof e.value.label==`string`?` with label: "${e.value.label}"`:``)):zv(x_)})(e)}var UC=globalThis.Symbol.for(`immer-draftable`),WC={};function GC(e,t,n,r,i){let a=JC(n,t,r),o=qC(t),s=class extends e{constructor(...[e,t]){let r=t?.[`~payload`],i=r?.token===WC?r.value:n.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:WC,value:i}})}static[AS]=AS;get[o](){return o}static[UC]=!0;static identifier=t;static fields=n.fields;static get ast(){return a(this).ast}static pipe(){return _(this,arguments)}static rebuild(e){return a(this).rebuild(e)}static make(e,t){return $x(a(this))(e??{},t)}static makeOption(e,t){return Qx(a(this))(e??{},t)}static makeEffect(e,t){return a(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(Rb(this.ast,e))}static annotateKey(e){return this.rebuild(Jb(this.ast,e))}static check(...e){return this.rebuild(Bb(this.ast,e))}static extend(e){return(t,r)=>{let a=YC(t)?t:W(t),o={...n.fields,...a.fields},s=rb(o,n.ast.checks,{identifier:e});return GC(this,e,tC(Bb(s,a.ast.checks),o),r,i)}}static mapFields(e,t){return n.mapFields(e,t)}};return i!==void 0&&Object.assign(s.prototype,i(t)),s}function KC(e){return new Zv(zv(t=>new e(t,{"~payload":{token:WC,value:t}})),Rv())}function qC(e){return`~effect/Schema/Class/${e}`}function JC(e,t,n){let r;return i=>{if(r!==void 0)return r;let a=qC(t),o=e=>e instanceof i||D(e,a),s=KC(i);return r=lC(qS(new Ty([e.ast],()=>(e,t,n)=>o(e)?P(e):I(new mv(t,e,n)),{identifier:t,[X_]:([e])=>({isConstructed:o,link:new by(e,s)}),toCodec:([e])=>new by(e.ast,s),toEquivalence:([e])=>e,toFormatter:([e])=>t=>`${i.identifier}(${e(t)})`,[Y_]:ub(e.ast),...n})),s)(e)}}function YC(e){return JS(e)}var XC=e=>(t,n)=>GC(_n,e,YC(t)?t:W(t),n,e=>({name:e})),ZC=e=>(t,n,r)=>{let i=YC(n)?n.mapFields(e=>({_tag:pC(t),...e}),{unsafePreserveChecks:!0}):mC(t,n);return XC(e??t)(i,r)},QC=bS,$C=qS(Rb(Dx,{toCode:()=>({runtime:`Schema.Json`,Type:`Schema.Json`})})),ew=`~effect/http/HttpBody`;Da(`HttpBodyError`);var tw=class{[ew];constructor(){this[ew]=ew}[gt](){return this.toJSON()}toString(){return ct(this,{ignoreToString:!0})}},nw=new class extends tw{_tag=`Empty`;toJSON(){return{_id:`effect/HttpBody`,_tag:`Empty`}}},rw=class extends tw{_tag=`Uint8Array`;contentType;contentLength;text;_body;constructor(e,t,n,r){super(),this._body=e,this.text=r,this.contentType=t,this.contentLength=n}get body(){return this._body??=ow(this.text)}toJSON(){return{_id:`effect/HttpBody`,_tag:`Uint8Array`,body:this.contentType.startsWith(`text/`)||this.contentType.endsWith(`json`)?new TextDecoder().decode(this.body):`Uint8Array(${this.body.length})`,contentType:this.contentType,contentLength:this.contentLength}}},iw=new TextEncoder,aw=globalThis.Buffer,ow=aw===void 0?e=>iw.encode(e):e=>aw.from(e,`utf8`),sw=(e,t)=>{if(typeof e!=`string`&&(e=e===void 0?``:String(e)),aw!==void 0)return new rw(void 0,t??`text/plain`,aw.byteLength(e,`utf8`),e);let n=iw.encode(e);return new rw(n,t??`text/plain`,n.length,e)},cw=(e,t)=>sw(JSON.stringify(e),t??`application/json`),lw=class extends tw{_tag=`FormData`;contentType=void 0;contentLength=void 0;formData;constructor(e){super(),this.formData=e}toJSON(){return{_id:`effect/HttpBody`,_tag:`FormData`,formData:this.formData}}},uw=e=>new lw(e),dw=(e,t,n)=>{if(n!=null){if(typeof n==`object`){e.append(t,n);return}e.append(t,String(n))}},fw=e=>{let t=new globalThis.FormData;for(let[n,r]of Object.entries(e))if(Array.isArray(r))for(let e of r)dw(t,n,e);else dw(t,n,r);return uw(t)},pw=class extends tw{_tag=`Stream`;stream;contentType;contentLength;constructor(e,t,n){super(),this.stream=e,this.contentType=t,this.contentLength=n}toJSON(){return{_id:`effect/HttpBody`,_tag:`Stream`,contentType:this.contentType,contentLength:this.contentLength}}},mw=(e,t,n)=>new pw(e,t??`application/octet-stream`,n),hw=`~effect/http/HttpClientError`,gw=class extends Da(`HttpClientError`){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[hw]=hw;get request(){return this.reason.request}get response(){return`response`in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},_w=e=>e.endsWith(`Error`)?e.slice(0,-5):e,vw=(e,t,n)=>t?`${e}: ${t} (${n})`:`${e} error (${n})`,yw=class extends Da(`TransportError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return vw(_w(this._tag),this.description,this.methodAndUrl)}};Da(`EncodeError`);var bw=class extends Da(`InvalidUrlError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return vw(_w(this._tag),this.description,this.methodAndUrl)}},xw=class extends Da(`StatusCodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return vw(_w(this._tag),this.description,e)}},Sw=class extends Da(`DecodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return vw(_w(this._tag),this.description,e)}},Cw=class extends Da(`EmptyBodyError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return vw(_w(this._tag),this.description,e)}};XC(hw)({_tag:pC(`HttpError`),kind:q([`EncodeError`,`DecodeError`,`TransportError`,`InvalidUrlError`,`StatusCodeError`,`EmptyBodyError`]),cause:YS(RC())});var ww=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`],[`QUERY`,`query`]],Tw=(e,t)=>t._tag===`Empty`||t._tag===`FormData`?N_(N_(e,`content-type`),`content-length`):(e=t.contentType===void 0?N_(e,`content-type`):A_(e,`content-type`,t.contentType),t.contentLength===void 0?N_(e,`content-length`):A_(e,`content-length`,t.contentLength.toString())),Ew=class extends Da(`UrlError`){},Dw=(e,t,n)=>Ii({try:()=>{let r=new URL(e,Ow());for(let e=0;e<t.params.length;e++){let[n,i]=t.params[e];i!==void 0&&r.searchParams.append(n,i)}return n!==void 0&&(r.hash=n),r},catch:e=>new Ew({cause:e})}),Ow=()=>{if(`location`in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0)return location.origin+location.pathname},kw=`~effect/http/HttpClientRequest`,Aw={[kw]:kw,...yt,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:rt(this.headers),body:this.body.toJSON()}},pipe(){return _(this,arguments)}};function jw(e,t,n,r,i,a){let o=Object.create(Aw);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var Mw=jw(`GET`,``,G_,sr(),D_,nw),Nw=e=>(t,n)=>zw(Mw,{method:e,url:t,...n??void 0}),Pw=Nw(`GET`),Fw=Nw(`POST`),Iw=Nw(`PATCH`),Lw=Nw(`PUT`),Rw=Nw(`DELETE`),zw=b(2,(e,t)=>{let n=e;return t.method&&(n=Bw(n,t.method)),t.url&&(n=qw(n,t.url)),t.headers&&(n=X(n,t.headers)),t.urlParams&&(n=Xw(n,t.urlParams)),t.hash&&(n=Zw(n,t.hash)),t.body&&(n=Qw(n,t.body)),t.accept&&(n=Gw(n,t.accept)),t.acceptJson&&(n=Kw(n)),n}),Bw=b(2,(e,t)=>jw(t,e.url,e.urlParams,e.hash,e.headers,e.body)),Vw=b(3,(e,t,n)=>jw(e.method,e.url,e.urlParams,e.hash,A_(e.headers,t,n),e.body)),X=b(2,(e,t)=>jw(e.method,e.url,e.urlParams,e.hash,j_(e.headers,t),e.body)),Hw=b(2,(e,t)=>jw(e.method,e.url,e.urlParams,e.hash,t(e.headers),e.body)),Uw=b(2,(e,t)=>Hw(e,N_(t))),Ww=b(2,(e,t)=>Vw(e,`Authorization`,`Bearer ${g_(t)}`)),Gw=b(2,(e,t)=>Vw(e,`Accept`,t)),Kw=Gw(`application/json`),qw=b(2,(e,t)=>{if(typeof t==`string`)return jw(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=V_(n.searchParams),i=pr(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,jw(e.method,n.toString(),r,i,e.headers,e.body)}),Jw=b(2,(e,t)=>t===``?e:jw(e.method,Yw(t,e.url),e.urlParams,e.hash,e.headers,e.body)),Yw=(e,t)=>{let n=e.endsWith(`/`),r=t.startsWith(`/`);return n&&r?e+t.slice(1):!n&&!r?e+`/`+t:e+t},Xw=b(2,(e,t)=>jw(e.method,e.url,K_(e.urlParams,t),e.hash,e.headers,e.body)),Zw=b(2,(e,t)=>jw(e.method,e.url,e.urlParams,cr(t),e.headers,e.body)),Qw=b(2,(e,t)=>jw(e.method,e.url,e.urlParams,e.hash,Tw(e.headers,t),t)),$w=b(2,(e,t)=>Qw(e,cw(t))),eT=b(2,(e,t)=>Qw(e,fw(t)));function tT(e){let t=Dw(e.url,e.urlParams,mr(e.hash));return Ri(t)?cr(t.success):sr()}var nT=`~effect/http/HttpIncomingMessage`,rT=(e,t)=>{let n=BS(QC(e)),r=t?.reviver===void 0?void 0:BS(BC(QC(e),t));return e=>r===void 0?L(e.json,e=>n(e,t)):L(e.text,i=>i===``?L(e.json,e=>n(e,t)):r(i,t))},iT=(e,t)=>{let n=e.headers[`content-type`]??``,r;if(n.includes(`application/json`))try{r=bp(e.json)}catch{}else if(n.includes(`text/`)||n.includes(`urlencoded`))try{r=bp(e.text)}catch{}let i={...t,headers:rt(e.headers),remoteAddress:e.remoteAddress};return r!==void 0&&(i.body=r),i},aT=`~effect/http/HttpClientResponse`,oT=(e,t)=>new cT(e,t),Z=b(2,(e,t)=>{let n=e.status;return t[n]?t[n](e):n>=200&&n<300&&t[`2xx`]?t[`2xx`](e):n>=300&&n<400&&t[`3xx`]?t[`3xx`](e):n>=400&&n<500&&t[`4xx`]?t[`4xx`](e):n>=500&&n<600&&t[`5xx`]?t[`5xx`](e):t.orElse(e)}),sT=e=>e.status>=200&&e.status<300?P(e):I(new gw({reason:new xw({response:e,request:e.request,description:`non 2xx status code`})})),cT=class extends bt{[nT];[aT];request;source;constructor(e,t){super(),this.request=e,this.source=t,this[nT]=nT,this[aT]=aT}toJSON(){return iT(this,{_id:`HttpClientResponse`,request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get url(){if(this.source.url)return this.source.url.split(`#`)[0];let e=tT(this.request);return lr(e)?``:(e.value.hash=``,e.value.href)}get headers(){return O_(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=l_(this.source.headers.getSetCookie())}get remoteAddress(){return sr()}get stream(){return this.source.body?lg({evaluate:()=>this.source.body,onError:e=>new gw({reason:new Sw({request:this.request,response:this,cause:e})})}):ag(new gw({reason:new Cw({request:this.request,response:this,description:`can not create stream from empty body`})}))}get json(){return L(this.text,e=>vf({try:()=>e===``?null:JSON.parse(e),catch:e=>new gw({reason:new Sw({request:this.request,response:this,cause:e})})}))}textBody;get text(){return this.textBody??=Tf(this.arrayBuffer,e=>new TextDecoder().decode(e))}get urlParamsBody(){return L(this.text,e=>vf({try:()=>V_(new URLSearchParams(e)),catch:e=>new gw({reason:new Sw({request:this.request,response:this,cause:e})})}))}formDataBody;get formData(){return this.formDataBody??=lf({try:()=>this.source.formData(),catch:e=>new gw({reason:new Sw({request:this.request,response:this,cause:e})})}).pipe(tp,bp)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody||=lf({try:()=>this.source.arrayBuffer(),catch:e=>new gw({reason:new Sw({request:this.request,response:this,cause:e})})}).pipe(tp,bp),this.arrayBufferBody}pipe(){return _(this,arguments)}},lT=e=>k_({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${dr(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?`01`:`00`}`}),uT=`~effect/http/HttpClient`,dT=vr(`effect/HttpClient`),fT=b(2,(e,t)=>mT(n=>t(e.postprocess(n)),e.preprocess)),pT=fT(L(sT)),mT=(e,t)=>{let n=Object.create(hT);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},hT={[uT]:uT,pipe(){return _(this,arguments)},...yt,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(ww.map(([e,t])=>[t,function(t,n){return this.execute(Nw(e)(t,n))}]))},gT=e=>mT(t=>L(t,t=>bf(n=>{let r=TT.get(t),i=r??new AbortController,a=Dw(t.url,t.urlParams,mr(t.hash));if(Li(a))return I(new gw({reason:new bw({request:t,cause:a.failure})}));let o=a.success;if(n.getRef(Ia)||n.getRef(yT)(t)){let a=e(t,o,i.signal,n);return r?a:ap(e=>Hf(e(a),{onSuccess(e){return wT.register(e,i),P(new ET(e,i))},onFailure(e){return Ed(e)&&i.abort(),hf(e)}}))}return cp(n.getRef(ST)(t),{kind:`client`},a=>{a.attribute(`http.request.method`,t.method),a.attribute(`server.address`,o.origin),o.port!==``&&a.attribute(`server.port`,+o.port),a.attribute(`url.full`,o.toString()),a.attribute(`url.path`,o.pathname),a.attribute(`url.scheme`,o.protocol.slice(0,-1));let s=o.search.slice(1);s!==``&&a.attribute(`url.query`,s);let c=n.getRef(I_),l=n.getRef(bT);for(let e in t.headers)l(e,`request`)&&a.attribute(`http.request.header.${e}`,F_(e,c)?`<redacted>`:t.headers[e]);return t=n.getRef(xT)?X(t,lT(a)):t,ap(s=>s(e(t,o,i.signal,n)).pipe(lp(a,{captureStackTrace:!1}),Hf({onSuccess:e=>{a.attribute(`http.response.status_code`,e.status);for(let t in e.headers)l(t,`response`)&&a.attribute(`http.response.header.${t}`,F_(t,c)?`<redacted>`:e.headers[t]);return r?P(e):(wT.register(e,i),P(new ET(e,i)))},onFailure(e){return!r&&Ed(e)&&i.abort(),hf(e)}})))})})),P),_T=b(2,(e,t)=>mT(e.postprocess,n=>Tf(e.preprocess(n),t))),vT=b(2,(e,t)=>mT(e.postprocess,n=>L(e.preprocess(n),t))),yT=Xr(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>C}),bT=Xr(`effect/http/HttpClient/TracerHeaderFilter`,{defaultValue:()=>S}),xT=Xr(`effect/http/HttpClient/TracerPropagationEnabled`,{defaultValue:S}),ST=Xr(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>`http.client ${e.method}`}),CT=e=>dd(dT)(Wf(t=>Tf(e,e=>fT(e,Kf(e=>Jr(t,e)))))),wT=(()=>{if(`FinalizationRegistry`in globalThis&&globalThis.FinalizationRegistry){let e=new FinalizationRegistry(e=>{e.abort()});return{register(t,n){e.register(t,n,t)},unregister(t){e.unregister(t)}}}let e=new Map;return{register(t,n){e.set(t,setTimeout(()=>n.abort(),5e3))},unregister(t){let n=e.get(t);n!==void 0&&(clearTimeout(n),e.delete(t))}}})(),TT=new WeakMap,ET=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[aT]=aT;[nT]=nT;applyInterrupt(e){return uf(()=>(wT.unregister(this.original),rp(e,()=>F(()=>{this.controller.abort()}))))}get request(){return this.original.request}get url(){return this.original.url}get status(){return this.original.status}get headers(){return this.original.headers}get cookies(){return this.original.cookies}get remoteAddress(){return this.original.remoteAddress}get formData(){return this.applyInterrupt(this.original.formData)}get text(){return this.applyInterrupt(this.original.text)}get json(){return this.applyInterrupt(this.original.json)}get urlParamsBody(){return this.applyInterrupt(this.original.urlParamsBody)}get arrayBuffer(){return this.applyInterrupt(this.original.arrayBuffer)}get stream(){return ig(()=>(wT.unregister(this.original),bg(this.original.stream,F(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[gt](){return this.original[gt]()}pipe(){return _(this,arguments)}},DT=W({status:B(`ok`).annotate({description:"Process health. A successful response currently reports `ok`."}),color:q([`blue`,`green`]).annotate({description:`Deployment color of the process that handled the request.`}),role:q([`active`,`inactive`]).annotate({description:`Whether this deployment color currently serves active traffic.`}),version:V.annotate({description:`Build or release version embedded in the running binary.`,examples:[`1.4.0`]}),activeColor:q([`blue`,`green`]).annotate({description:`Deployment color currently selected as active.`})}).annotate({description:`Local deployment health and blue-green role information.`,examples:[{status:`ok`,color:`blue`,role:`active`,version:`1.4.0`,activeColor:`blue`}],identifier:`Health`}),Q=V.annotate({description:`Time-ordered UUID version 7 generated by Aperture.`,examples:[`019f6cf0-0000-7000-8000-000000000001`],format:`uuid`,identifier:`UUIDv7`}),OT=q([`api_token`,`user`,`system`]).annotate({description:`Stable category of the authenticated or audited actor.`,examples:[`api_token`],identifier:`PrincipalType`}),kT=q([`system_admin`,`tenant`]).annotate({description:"Authorization boundary. `system_admin` principals may administer the deployment and select tenants. `tenant` principals act within one effective tenant.\n",examples:[`tenant`],identifier:`AuthorityType`}),AT=q([`system:admin`,`sessions:read`,`sessions:write`,`snapshots:read`,`snapshots:write`,`tenant:write`,`tenants:write`]).annotate({description:"Permission granted to a principal. `system:admin` implies every scope. Tenant credentials and memberships cannot receive `system:admin` or `tenants:write`.\n",examples:[`sessions:write`],identifier:`Scope`}),jT=q([`all`,`allowlist`]).annotate({description:`Whether a tenant API token can access every tenant resource or only explicit grants.`,default:`all`,examples:[`allowlist`],identifier:`ResourceMode`}),MT=q([`session`,`snapshot`]).annotate({description:`Tenant resource category accepted by API token allowlists.`,examples:[`session`],identifier:`ResourceType`}),NT=W({code:V.annotate({description:`Stable code enumerated by each operation response.`,examples:[`insufficient_scope`]}),message:V.annotate({description:`Human-readable explanation. It may include resource or validation context.`,examples:[`insufficient scope`]})}).annotate({description:`Stable machine-readable error code with a human-readable explanation.`,identifier:`ErrorDetail`}),PT=W({name:V.annotate({description:`Configured browser channel name.`,examples:[`chromium`]})}).annotate({description:`Browser runtime selectable when creating a session.`,identifier:`BrowserChannel`}),FT=W({limit:H.annotate({description:`Effective page size after applying the default and maximum.`,examples:[50]}).check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})).check(EC(100).annotate({expected:`a value less than or equal to 100`})),nextCursor:z(V.annotate({description:`Opaque cursor for the next page. Omitted when there is no next page.`,examples:[`eyJjcmVhdGVkQXQiOiIyMDI2LTA3LTE3VDEyOjAwOjAwWiIsImlkIjoiMDE5ZjZjZjAtMDAwMC03MDAwLTgwMDAtMDAwMDAwMDAwMDAwIn0`]})),hasMore:U.annotate({description:`Whether another page is available.`,examples:[!0]})}).annotate({description:`Cursor pagination metadata for a newest-first result page.`,identifier:`PageMeta`});W({displayName:V.annotate({description:`Human-readable tenant name. Leading and trailing whitespace is removed and whitespace-only values are rejected.`,examples:[`Example engineering`]}).check(OC(1).annotate({expected:`a value with a length of at least 1`})).check(vC(RegExp(`.*\\S.*`,`u`)).annotate({expected:`a string matching the RegExp .*\\S.*`}))}).annotate({description:`Tenant fields accepted by create and update operations.`,identifier:`TenantInput`}),W({email:z(K([V,$S]).annotate({description:`Optional normalized login and contact email.`,format:`email`})),displayName:V.check(OC(1).annotate({expected:`a value with a length of at least 1`})).check(vC(RegExp(`.*\\S.*`,`u`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),isSystemAdmin:U.annotate({description:`Grants deployment-wide administration independently of tenant memberships.`}),createPersonalTenant:z(K([U,$S]).annotate({description:"Also create a tenant owned by the user with every tenant scope. `null` or omitted uses the server default `auto_create_personal_tenant`."}))}).annotate({description:`User profile and authority for a new user. Same fields as UserInput plus the personal tenant choice.`,identifier:`CreateUserInput`}),W({email:z(K([V,$S]).annotate({description:`Optional normalized login and contact email.`,format:`email`})),displayName:V.check(OC(1).annotate({expected:`a value with a length of at least 1`})).check(vC(RegExp(`.*\\S.*`,`u`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),isSystemAdmin:U.annotate({description:`Grants deployment-wide administration independently of tenant memberships.`})}).annotate({identifier:`UserInput`});var IT=W({token:V.annotate({description:`Raw setup token. Store and transmit it as a secret.`}),expiresAt:V.annotate({format:`date-time`})}).annotate({description:`One-time account setup secret returned only when created.`,identifier:`UserInvitation`}),LT=q([`sessions:read`,`sessions:write`,`snapshots:read`,`snapshots:write`,`tenant:write`]).annotate({description:`Scope allowed on a tenant-bound API token.`,examples:[`sessions:write`],identifier:`TenantScope`}),RT=HC(V).annotate({identifier:`SensitiveString`}),zT=q([`creating`,`running`,`suspended`,`deleted`,`expired`,`failed`]).annotate({description:"Session lifecycle state:\n\n- `creating`: browser startup is in progress; the CDP endpoint does not answer yet.\n- `running`: browser and routing are available and the CDP endpoint answers.\n- `suspended`: browser is intentionally stopped while retained state remains available.\n- `deleted`: deletion cleanup is pending; legacy retained soft-deleted sessions may still be reopenable until their retention deadline.\n- `expired`: retention elapsed or permanent deletion completed; the session can no longer be used.\n- `failed`: startup or reopen failed; retained state may still be reopenable.\n",examples:[`running`],identifier:`SessionStatus`}),BT=nC(V,V).annotate({description:`Arbitrary string key-value metadata. Tag-writing operations additionally reject blank keys and blank values.`,examples:[{environment:`production`,region:`eu-west-1`}],identifier:`StringMap`}),VT=W({url:V.annotate({examples:[`socks5://user:xxxxx@proxy.example.com:1080`]})}).annotate({description:`A named upstream as stored. The secret is never returned and proxy URL passwords are masked.`,identifier:`SessionProxyUpstream`}),HT=W({match:V.annotate({description:"`host` or `host:port`, where the host is exact, `*.suffix` for subdomains, or `*` for any host. `*` never matches `localhost`, which only a rule naming it routes. Loopback IPs never reach the proxy, so local services are matched as `localhost`.",examples:[`*.example.test`]}),via:V.annotate({description:"`direct` dials from the session host, `refuse` fails the connection, `local` uses the attached local tunnel and fails while none is attached. Anything else names an upstream, or is an inline proxy URL without a secret.",examples:[`operator`]})}).annotate({description:`Routes the browser connections its match covers.`,identifier:`ProxyRule`}),UT=W({channel:V.annotate({description:"Channel returned by `GET /api/browser/channels`.",examples:[`chromium`]}).check(OC(1).annotate({expected:`a value with a length of at least 1`})).check(vC(RegExp(`.*\\S.*`,`u`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),args:z(G(V).annotate({description:`Additional Chromium command-line arguments. Aperture rejects arguments that conflict with supervisor-owned behavior or deployment policy.`,examples:[[`--lang=en-US`]]}))}).annotate({description:`Browser runtime configuration used to create or reopen the session.`,identifier:`BrowserConfig`}),WT=W({x:H.check(yC().annotate({expected:`a finite number`})),y:H.check(yC().annotate({expected:`a finite number`}))}).annotate({identifier:`InitialBrowserScrollPosition`}),GT=W({tag:V.check(vC(RegExp(`^[a-z][a-z0-9-]*$`,`u`)).annotate({expected:`a string matching the RegExp ^[a-z][a-z0-9-]*$`})),index:H.check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))}).annotate({identifier:`InitialBrowserElementPathStep`}),KT=W({start:H.check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})),end:H.check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})),direction:q([`forward`,`backward`,`none`])}).annotate({identifier:`InitialBrowserControlSelection`}),qT=q([`Strict`,`Lax`,`None`]).annotate({identifier:`BrowserCookieSameSite`}),JT=W({topLevelSite:V.annotate({format:`uri`}).check(vC(RegExp(`^https?:\\/\\/[^/]+$`,`u`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/[^/]+$`})),hasCrossSiteAncestor:z(U)}).annotate({identifier:`InitialBrowserCookiePartitionKey`}),YT=W({kind:q([`none`,`string`,`array`]),value:z(G(V))}).annotate({description:`Object-store key path. String paths contain one value; array paths contain at least one.`,identifier:`InitialIndexedDBKeyPath`}),XT=W({kind:q([`string`,`array`]),value:G(V).check(OC(1).annotate({expected:`a value with a length of at least 1`}))}).annotate({description:`Index key path. String paths contain one value; array paths contain at least one.`,identifier:`InitialIndexedDBIndexKeyPath`}),ZT=W({visible:U.annotate({description:`Whether to include the remote cursor in live streams and recordings.`})}).annotate({description:`Whether the remote browser cursor is composited into session media.`,identifier:`CursorVisibility`});W({origins:K([B(`open-tabs`),G(V.check(OC(1).annotate({expected:`a value with a length of at least 1`})).check(jC(2048).annotate({expected:`a string with at most 2048 code points`}))).check(OC(1).annotate({expected:`a value with a length of at least 1`})).check(AC(100).annotate({expected:`a value with a length of at most 100`}))],{mode:`oneOf`}).annotate({description:`Exact origins and/or * patterns, or open-tabs to select current pages and frames.`})}).annotate({examples:[{origins:[`*`]},{origins:[`https://example.com`,`https://*.example.org`]},{origins:`open-tabs`}],identifier:`ExportSessionStorageStateInput`});var QT=W({code:q([`ffmpeg_unavailable`,`open_failed`,`nothing_kept`,`analysis_failed`,`plan_failed`,`render_failed`,`timeout`,`cancelled`,`timeline_failed`]),message:V}).annotate({description:`Why a recording has no edit although one was due or a timeline could not be written. The raw video is published regardless.`,identifier:`RecordingEditError`}),$T=W({targetId:V.annotate({description:`Identifier of the ready top-level target to record.`}).check(OC(1).annotate({expected:`a value with a length of at least 1`})),fps:z(H.annotate({description:`Requested frames per second. Omit or use a non-positive value for the instance default.`,examples:[60]}).check(Y().annotate({expected:`an integer`}))),bitrateKbps:z(H.annotate({description:`Requested video bitrate in kilobits per second. Omit or use a non-positive value for the instance default.`,examples:[6e3]}).check(Y().annotate({expected:`an integer`}))),codec:z(q([`vp8`,`h264-va`]).annotate({description:`Video codec. Omit for the instance default.`,examples:[`vp8`]})),capture:z(q([`continuous`,`bursts`]).annotate({description:"With `bursts`, the edited video keeps only the stretches around browser tool calls, from `burst.leadMs` before a call to `burst.tailMs` after it, longer until the screen has stood still for `burst.settleMs` but at most `burst.maxTailMs`, and the recording follows the tab the automation acts on. The raw video is always the whole capture. Defaults to `continuous`. Cannot be combined with `idle`. Needs `recording_ffmpeg_executable` on the instance."})),pace:z(q([`instant`,`fast`,`slow`]).annotate({description:"How browser automation acts while the recording runs. `instant` moves the pointer straight to each action; `fast` (default) and `slow` glide it there in a time that grows with the distance and shrinks with the target's size (Fitts's law), `slow` taking twice as long and resting longer before a click. The slowest pace of the running recordings applies. Needs nothing of the instance."})),motion:z(K([q([`linear`,`natural`]),W({type:B(`natural`),seed:z(H.check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})).check(EC(9007199254740991).annotate({expected:`a value less than or equal to 9007199254740991`})))})],{mode:`oneOf`}).annotate({description:"The pointer's path at pace `fast` or `slow`; ignored at `instant`. `linear` (default) is a straight eased path; `natural` is a curved eased path that now and then overshoots a little and corrects. A natural motion without a seed gets one, reported as the recording's `motionSeed`; the same seed replays the same paths."})),idle:z(q([`cut`,`speed`]).annotate({description:"Remove (`cut`) or fast-forward (`speed`) the stretches of a continuous recording in which neither the picture nor the automation changes, in the edited video. Needs `recording_ffmpeg_executable` on the instance."})),ripple:z(U.annotate({description:"Mark clicks with a ripple in the edited video. Needs `recording_ffmpeg_executable` on the instance."})),burst:z(W({preset:z(q([`tight`,`default`,`relaxed`]).annotate({description:"The sizes the fields default to: `tight` (lead 200, tail 400, settle 200, max tail 1500), `default` (500, 800, 400, 3000) or `relaxed` (800, 1200, 600, 4000). Defaults to `default`."})),leadMs:z(H.annotate({description:`Kept before a tool call. Overrides the preset.`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})).check(EC(6e4).annotate({expected:`a value less than or equal to 60000`}))),tailMs:z(H.annotate({description:`Kept after a tool call. Overrides the preset.`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})).check(EC(6e4).annotate({expected:`a value less than or equal to 60000`}))),settleMs:z(H.annotate({description:`How long the screen must stand still to count as settled. Overrides the preset.`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})).check(EC(6e4).annotate({expected:`a value less than or equal to 60000`}))),maxTailMs:z(H.annotate({description:`Longest wait for the screen to settle after a call. Overrides the preset.`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})).check(EC(6e4).annotate({expected:`a value less than or equal to 60000`})))}).annotate({description:"Burst sizes in milliseconds for `capture` `bursts`; rejected without it. Omitted or zero fields take the preset's values. `tailMs` must not exceed `maxTailMs`."}))}).annotate({description:`Top-level target and optional recording settings.`,identifier:`CreateSessionRecordingInput`});W({targetId:V.annotate({description:`Identifier of the ready destination top-level target.`}).check(OC(1).annotate({expected:`a value with a length of at least 1`}))}).annotate({description:`Destination for a running tab recording.`,identifier:`RetargetSessionRecordingInput`}),W({text:V.annotate({description:`Caption text. Whitespace is trimmed.`}).check(OC(1).annotate({expected:`a value with a length of at least 1`})).check(jC(200).annotate({expected:`a string with at most 200 code points`})),durationMs:z(H.annotate({description:`Display duration in milliseconds. Zero or omitted means 3000; other values must be at least 200.`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})).check(EC(3e4).annotate({expected:`a value less than or equal to 30000`})))}).annotate({identifier:`RecordingCaptionInput`});var eE=W({x:H.annotate({description:`Left edge in viewport CSS pixels.`}).check(yC().annotate({expected:`a finite number`})),y:H.annotate({description:`Top edge in viewport CSS pixels.`}).check(yC().annotate({expected:`a finite number`})),width:H.check(yC().annotate({expected:`a finite number`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})),height:H.check(yC().annotate({expected:`a finite number`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))}).annotate({identifier:`RecordingRect`}),tE=W({x:H.annotate({description:`Horizontal position in viewport CSS pixels.`}).check(yC().annotate({expected:`a finite number`})),y:H.annotate({description:`Vertical position in viewport CSS pixels.`}).check(yC().annotate({expected:`a finite number`}))}).annotate({identifier:`RecordingPoint`}),nE=W({type:B(`file`),name:V.annotate({description:`File name without directory components.`,examples:[`screencast-20260801T120000Z.webm`]}),relativePath:V.annotate({description:"Path below the session files root. Browser downloads are under `downloads/`, recordings under `recordings/`, uploads under `uploads/`, and Playwright MCP output under `outputs/`. Pass it to `browser_file_upload` or to create a signed download URL.",examples:[`recordings/screencast-20260801T120000Z.webm`]}),size:H.annotate({description:`File size in bytes.`,examples:[1048576],format:`int64`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})),modifiedAt:V.annotate({description:`Last file modification time.`,examples:[`2026-08-01T12:05:00Z`],format:`date-time`}),mimeType:V.annotate({description:`Detected media type.`,examples:[`video/webm`]}),sandboxPath:z(V.annotate({description:"Path of the file inside the session's browser sandbox, under the fixed `/session/files` root, for CDP `DOM.setFileInputFiles`. It is readable by the browser while the session runs. Absent for files of sessions created before session files moved under one root that are still in their old location.",examples:[`/session/files/recordings/screencast-20260801T120000Z.webm`]}))}).annotate({description:`Regular file retained with a browser session.`,identifier:`SessionFile`}),rE=W({type:B(`directory`),name:V.annotate({description:`Directory name without parent components.`,examples:[`invoices`]}),relativePath:V.annotate({description:`Path below the session files root.`,examples:[`uploads/invoices`]}),modifiedAt:V.annotate({format:`date-time`})}).annotate({description:`Directory below the session files root.`,identifier:`SessionDirectory`}),iE=hC(globalThis.Blob,{expected:`File | Blob`});W({from:V.annotate({description:"Current path from a `SessionFileEntry` result.",examples:[`downloads/invoice.pdf`]}).check(OC(1).annotate({expected:`a value with a length of at least 1`})),to:V.annotate({description:`New path below the session files root. Missing directories are created.`,examples:[`uploads/invoices/2026-08.pdf`]}).check(OC(1).annotate({expected:`a value with a length of at least 1`}))}).annotate({description:`Current and new path of a session file.`,identifier:`MoveSessionFileInput`}),W({relativePath:V.annotate({description:`Path below the session files root. Missing parents are created.`,examples:[`uploads/invoices`]}).check(OC(1).annotate({expected:`a value with a length of at least 1`}))}).annotate({description:`Directory to create.`,identifier:`CreateSessionDirectoryInput`}),W({relativePath:V.annotate({description:"Path from a `SessionFile` result.",examples:[`recordings/screencast-20260801T120000Z.webm`]}).check(OC(1).annotate({expected:`a value with a length of at least 1`})),ttlSeconds:z(H.annotate({description:"Requested lifetime in seconds. Omit it to use `signed_file_url_ttl`; values above `signed_file_url_max_ttl` are rejected.",examples:[900]}).check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`}))),disposition:z(q([`attachment`,`inline`]).annotate({description:"How the URL presents the file. `inline` lets browsers display it, for example as an `<img>` source. Either way it is served with its detected `Content-Type`, `X-Content-Type-Options: nosniff`, and byte-range support. Content that can run scripts, such as HTML or SVG, also gets `Content-Security-Policy: sandbox`; images, audio, video, PDFs, and plain text do not, so browser viewers keep working.",default:`attachment`}))}).annotate({description:`Session file path and requested signed URL lifetime.`,identifier:`SessionFileDownloadURLInput`});var aE=W({url:V.annotate({description:"URL containing a path-bound `apf_` token.",examples:[`https://aperture.example.com/sessions/019f6cf0-0000-7000-8000-000000000010/files/recordings/screencast-20260801T120000Z.webm?token=apf_REDACTED`],format:`uri`}),expiresAt:V.annotate({description:`Time after which the URL is rejected.`,examples:[`2026-08-01T12:20:00Z`],format:`date-time`})}).annotate({description:`Signed URL for one session file.`,identifier:`SessionFileDownloadURL`});W({description:z(K([V,$S]).annotate({description:"New description. Send `null` to clear it; an empty string is stored as an empty description.",examples:[`Updated signed-in state`]}))}).annotate({description:`Replacement snapshot description.`,identifier:`UpdateSnapshotInput`});var oE=W({error:V.annotate({examples:[`file exceeds upload limit`]})}).annotate({description:`Error raised inside a running session. It carries a message but no stable code.`,identifier:`LiveSessionErrorBody`});W({targetId:V.annotate({description:`Identifier of the top-level target to resize.`}).check(OC(1).annotate({expected:`a value with a length of at least 1`})),width:H.annotate({description:`Logical width in CSS pixels. Widths below 500 are raised to 500.`,examples:[1280]}).check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})).check(EC(16384).annotate({expected:`a value less than or equal to 16384`})),height:H.annotate({description:`Logical height in CSS pixels.`,examples:[720]}).check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})).check(EC(16384).annotate({expected:`a value less than or equal to 16384`})),deviceScaleFactor:z(H.annotate({description:`Device pixel ratio, rounded to 1/120. Omit or use a non-positive value for 1. The scaled content size may not exceed 16384 pixels.`,examples:[1]}).check(yC().annotate({expected:`a finite number`})))}).annotate({description:`Requested logical viewport of one top-level target.`,identifier:`SetViewportInput`});var sE=W({width:H.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),height:H.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),contentWidth:H.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),contentHeight:H.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),canvasWidth:H.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),canvasHeight:H.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),deviceScaleFactor:H.annotate({description:`Effective device pixel ratio.`}).check(yC().annotate({expected:`a finite number`}))}).annotate({description:`Logical size, DPR-scaled content rectangle, and 64x64-bucketed media canvas of a target.`,identifier:`Viewport`}),cE=W({id:cC(()=>Q).annotate({description:`Tenant identifier.`}),displayName:V.annotate({description:`Human-readable tenant name.`,examples:[`Example engineering`]}),createdAt:V.annotate({description:`Time the tenant was created.`,examples:[`2026-07-17T12:00:00Z`],format:`date-time`}),deletedAt:z(K([V,$S]).annotate({description:"Soft-deactivation time, or `null` for an active tenant.",examples:[null],format:`date-time`})),ownerUserId:z(K([Q,$S],{mode:`oneOf`}).annotate({description:"Owner of a personal tenant, or `null` for a shared tenant.",examples:[null]}))}).annotate({description:`Tenant account. Deletion is a reversible soft deactivation.`,identifier:`Tenant`}),lE=W({id:Q,email:z(K([V,$S]).annotate({format:`email`})),displayName:V,isSystemAdmin:U,createdAt:V.annotate({format:`date-time`}),updatedAt:V.annotate({format:`date-time`}),disabledAt:z(K([V,$S]).annotate({format:`date-time`})),hasPersonalTenant:z(U.annotate({description:`Whether the user owns an active personal tenant. Included by the get-user operation; the tenant itself stays hidden from administrators.`})),passwordSetupStatus:z(q([`available`,`configured`,`email_required`,`user_disabled`,`login_disabled`]).annotate({description:`Password setup state included by the get-user operation.`}))}).annotate({identifier:`User`}),uE=W({id:Q,name:K([V,$S]).annotate({description:"Display name (a session's label), or `null` when it has none or no longer exists."})}).annotate({description:`Something a resource refers to, by id and display name.`,identifier:`Reference`});W({ids:G(Q).annotate({description:`Up to 100 unique UUIDv7 values. An empty array is valid.`,examples:[[`019f6cf0-0000-7000-8000-000000000010`,`019f6cf0-0000-7000-8000-000000000011`]]}).check(AC(100).annotate({expected:`a value with a length of at most 100`})).check(PC().annotate({expected:`an array with unique items`}))}).annotate({description:`Ordered session IDs for a tenant-scoped bulk lookup. Missing, foreign, and deleted IDs are omitted from the result.`,identifier:`SessionBulkInput`});var dE=W({id:cC(()=>Q).annotate({description:`Event identifier.`}),tenantId:cC(()=>Q).annotate({description:`Tenant that owns the event.`}),resourceType:V.annotate({description:`Resource category associated with the event. Currently session events are the primary source; new categories may be added.`,examples:[`session`]}),resourceId:V.annotate({description:"Identifier of the associated resource. Its format depends on `resourceType`.",examples:[`019f6cf0-0000-7000-8000-000000000010`]}),type:V.annotate({description:`Extensible event type used for programmatic handling.`,examples:[`session.token_rotated`]}),message:V.annotate({description:`Human-readable event summary.`,examples:[`session token rotated`]}),data:nC(V,$C.annotate({expected:`JSON value`})).annotate({description:`Event-specific JSON payload, such as error details or upload metadata.`,examples:[{reason:`manual rotation`}]}),createdAt:V.annotate({description:`Time the event was recorded.`,examples:[`2026-07-17T12:30:00Z`],format:`date-time`})}).annotate({description:`Immutable tenant-scoped audit or lifecycle event.`,identifier:`Event`}),fE=W({id:Q,actorType:OT,actorId:z(K([V,$S])),tenantId:z(K([Q,$S],{mode:`oneOf`})),action:V.annotate({examples:[`tenant_membership.upserted`]}),resourceType:V.annotate({examples:[`tenant_membership`]}),resourceId:z(K([V,$S])),data:nC(V,$C.annotate({expected:`JSON value`})),createdAt:V.annotate({format:`date-time`})}).annotate({identifier:`AuditEvent`}),pE=W({type:OT,id:K([Q,$S],{mode:`oneOf`}).annotate({description:"User or API token id, or `null` for the trusted local system."}),name:K([V,$S]).annotate({description:"User display name or token name, or `null` for the local system or when it no longer exists."})}).annotate({description:`The user or API token behind an action, or the trusted local system.`,identifier:`PrincipalReference`}),mE=W({resourceType:MT,resourceId:Q,label:z(K([V,$S]).annotate({description:`Session label or snapshot name, included on token responses when the resource has one. Ignored on input.`,readOnly:!0}))}).annotate({description:`Access to one existing tenant session or snapshot by its stable UUIDv7 identifier.`,identifier:`ResourceGrant`}),hE=W({error:NT}).annotate({description:`Standard error envelope returned by REST API operations.`,identifier:`Error`}),gE=W({channels:G(PT)}).annotate({description:`Browser channels enabled on this deployment.`,examples:[{channels:[{name:`chromium`}]}],identifier:`BrowserChannels`}),_E=W({tenantId:Q,userId:Q,scopes:G(LT).check(OC(1).annotate({expected:`a value with a length of at least 1`})).check(PC().annotate({expected:`an array with unique items`})),createdAt:V.annotate({format:`date-time`}),updatedAt:V.annotate({format:`date-time`})}).annotate({identifier:`TenantMembership`});W({scopes:G(LT).check(OC(1).annotate({expected:`a value with a length of at least 1`})).check(PC().annotate({expected:`an array with unique items`}))}).annotate({identifier:`TenantMembershipInput`});var vE=W({urls:G(V).annotate({description:`STUN or TURN server URLs.`,examples:[[`turn:turn.example.com:3478?transport=udp`]]}),username:z(V.annotate({description:`TURN username. Omitted when the server does not require authentication.`,examples:[`aperture-session`]})),credential:z(cC(()=>RT).annotate({description:`TURN credential. Treat it as a secret and do not persist it in logs.`,examples:[`REDACTED`]}))}).annotate({description:`ICE server configuration supplied to WebRTC consumers.`,identifier:`IceServer`}),yE=W({editorToken:cC(()=>RT).annotate({examples:[`ape_019f6cf0000070008000000000000010_REDACTED`]}),viewerToken:cC(()=>RT).annotate({examples:[`apv_019f6cf0000070008000000000000010_REDACTED`]})}).annotate({description:`Owner-visible role-scoped secrets used to build collaboration links.`,identifier:`SessionCollaborationCapabilities`}),bE=W({url:cC(()=>RT).annotate({description:`Thumbnail of the tab most recently shown to a live-session client.`,format:`uri`}),targetUrlTemplate:cC(()=>RT).annotate({description:"Tab thumbnail URL with a literal `{targetId}` placeholder for a top-level target ID."}),expiresAt:V.annotate({format:`date-time`})}).annotate({description:`Signed thumbnail URLs for image elements. They need no other credentials and expire after the
23
23
  configured signed URL lifetime; every session response returns fresh ones. Present while the
24
24
  session is running, or while suspended when thumbnails were saved.
25
- `,identifier:`SessionThumbnail`}),xE=W({name:V,value:cC(()=>RT).annotate({description:`Browser storage value. Never log this field.`})}).annotate({identifier:`BrowserStorageEntry`}),SE=W({key:cC(()=>RT).annotate({description:`JSON-encoded structured-clone key.`}),value:cC(()=>RT).annotate({description:`JSON-encoded structured-clone value.`})}).annotate({identifier:`InitialIndexedDBRecord`}),CE=W({path:V.check(OC(1).annotate({expected:`a value with a length of at least 1`})),body:cC(()=>RT).annotate({contentEncoding:`base64`})}).annotate({identifier:`InitialOPFSFile`}),wE=W({url:V.annotate({description:"A generic proxy URL (`http`, `https`, `socks`, `socks5`, `socks5h`) or a compound tunnel URL (`ws+yamux+socks5://`, `wss+yamux+socks5://`). Proxy credentials go in the userinfo (`socks5://user:pass@host:1080`) and are sent as Basic `Proxy-Authorization` for `http`/`https` or RFC 1929 username/password for the socks schemes. An omitted port defaults to 1080 (socks), 80 (http) or 443 (https).",examples:[`wss+yamux+socks5://tunnel.example.com/t/019f6cf0-0000-7000-8000-000000000010`]}),auth:z(cC(()=>RT).annotate({description:`Bearer secret for a tunnel URL's handshake. Required for a tunnel URL and invalid for a proxy URL. Write-only; never returned.`,examples:[`REDACTED`]}))}).annotate({description:`A named upstream that proxy rules route through.`,identifier:`ProxyUpstream`}),TE=W({url:z(V.annotate({description:"Compound tunnel URL (`ws+yamux+socks5://` or `wss+yamux+socks5://`).",examples:[`wss+yamux+socks5://tunnel.example.com/t/019f6cf0-0000-7000-8000-000000000010`]})),auth:z(cC(()=>RT).annotate({description:`Bearer secret for the tunnel handshake. Write-only; never returned.`,examples:[`REDACTED`]}))}).annotate({description:"Legacy tunnel endpoint for `upstream` `tunnel`; both fields are required with it. Use a tunnel URL in `upstreams`.",identifier:`ProxyTunnelConfig`}),EE=W({url:V.annotate({format:`uri`}),requestHeaders:BT,responseHeaders:BT,responseStatus:H.check(Y().annotate({expected:`an integer`})).check(J(100).annotate({expected:`a value greater than or equal to 100`})).check(EC(599).annotate({expected:`a value less than or equal to 599`})),responseStatusText:V,responseBody:cC(()=>RT).annotate({contentEncoding:`base64`})}).annotate({identifier:`InitialCacheStorageEntry`});W({tags:cC(()=>BT).annotate({description:`Complete tag map. Keys and values must contain non-whitespace characters.`})}).annotate({description:`Complete replacement tag set. The map may be empty to clear all tags.`,examples:[{tags:{environment:`production`,region:`eu-west-1`}}],identifier:`ReplaceTagsInput`}),W({name:V.annotate({description:`Tenant-unique snapshot name. Leading and trailing whitespace is removed.`,examples:[`signed-in-base`]}).check(OC(1).annotate({expected:`a value with a length of at least 1`})).check(vC(RegExp(`.*\\S.*`,`u`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),description:z(K([V,$S]).annotate({description:"Optional snapshot description. `null` creates the snapshot without a description.",examples:[`Signed-in storefront state for checkout tests`]})),force:z(U.annotate({description:"Deleted snapshot names are reused automatically. Set `true` to replace an active snapshot, which is renamed to its tombstone name and retained for the configured snapshot retention period.",default:!1})),tags:z(cC(()=>BT).annotate({description:`Initial complete tag map for the new snapshot.`}))}).annotate({description:`Snapshot metadata created from a stopped, retained session.`,examples:[{name:`signed-in-base`,description:`Signed-in storefront state for checkout tests`,force:!1,tags:{application:`storefront`,environment:`staging`}}],identifier:`PromoteSessionInput`});var DE=W({upstreams:nC(V,VT),rules:G(HT),upstream:q([`direct`,`proxy`,`tunnel`]).annotate({description:"Legacy single-upstream view of `rules`; read `upstreams` and `rules` instead. Exact when the rules are optional leading `direct` rules followed by one final `*` rule via an upstream proxy or tunnel, with no other upstreams, and `direct` when there are no rules. Otherwise it approximates the route of the last `*` rule (`local` reads as `tunnel`, `refuse` as `direct`), or `direct` without one, and `url`, `tunnel` and `bypass` are omitted.",examples:[`tunnel`]}),url:z(V.annotate({description:"Legacy upstream proxy URL with its password masked. Only present when `upstream` is exactly `proxy`.",examples:[`socks5://user:xxxxx@proxy.example.com:1080`]})),tunnel:z(W({url:z(V.annotate({examples:[`wss+yamux+socks5://tunnel.example.com/t/019f6cf0-0000-7000-8000-000000000010`]}))}).annotate({description:"Legacy tunnel endpoint. Only present when `upstream` is exactly `tunnel`. The secret is never returned."})),bypass:z(V.annotate({description:"Legacy `;`-separated matches of the leading `direct` rules. Only present with an exact `proxy` or `tunnel` value.",examples:[`*.internal.example.com`]}))}).annotate({description:`Stored session egress proxy configuration. Secrets are write-only, so this value cannot be replayed as a write.`,identifier:`SessionProxy`}),OE=W({tag:V.check(vC(RegExp(`^[a-z][a-z0-9-]*$`,`u`)).annotate({expected:`a string matching the RegExp ^[a-z][a-z0-9-]*$`})),id:z(V),name:z(V),inputType:z(V),autocomplete:z(V),ariaLabel:z(V),placeholder:z(V),path:G(GT).check(AC(256).annotate({expected:`a value with a length of at most 256`}))}).annotate({description:`Semantic element identity with a structural fallback. It is not a CSS selector.`,identifier:`InitialBrowserElementLocator`}),kE=W({name:V.check(OC(1).annotate({expected:`a value with a length of at least 1`})),value:cC(()=>RT).annotate({description:`Cookie value. Never log this field.`}),domain:V.annotate({examples:[`.example.com`]}).check(OC(1).annotate({expected:`a value with a length of at least 1`})),hostOnly:z(U.annotate({description:"Scope the cookie to exactly `domain`, without subdomains. `domain` must then be a plain hostname.",default:!1})),path:V.annotate({examples:[`/`]}).check(vC(RegExp(`^\\/`,`u`)).annotate({expected:`a string matching the RegExp ^\\/`})),expires:z(H.annotate({description:`Unix timestamp in seconds. Omit for a session cookie.`}).check(yC().annotate({expected:`a finite number`})).check(TC(0).annotate({expected:`a value greater than 0`}))),httpOnly:z(U.annotate({default:!1})),secure:z(U.annotate({default:!1})),sameSite:z(qT),partitionKey:z(JT)}).annotate({description:`Cookie imported into the new browser profile.`,identifier:`InitialBrowserCookie`}),AE=W({name:V,keyPath:XT,unique:U,multiEntry:U}).annotate({identifier:`InitialIndexedDBIndex`}),jE=W({recordingId:V.annotate({description:`Stable recording identifier retained across target changes.`,format:`uuid`}),mode:q([`tab`,`viewer`]).annotate({description:`Tab recordings stay on their specified top-level target; viewer recordings follow a live session client's selected top-level target and cannot be explicitly retargeted.`}),targetId:V.annotate({description:`Identifier of the top-level target currently recorded.`}),captureGeneration:H.annotate({description:`Assignment generation for the current top-level target.`,format:`int64`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})),status:q([`starting`,`running`,`stopped`,`failed`]),stopReason:z(V.annotate({description:`Lifecycle reason recorded after the recording stops or fails.`})),relativePath:V.annotate({description:`Session file path below the session files root; host paths are never exposed.`,examples:[`recordings/recording-550e8400-e29b-41d4-a716-446655440000.webm`]}),startedAt:V.annotate({format:`date-time`}),stoppedAt:z(V.annotate({format:`date-time`})),sizeBytes:z(H.annotate({format:`int64`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),fps:H.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),bitrateKbps:H.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),codec:q([`vp8`,`h264-va`]),motionSeed:z(H.annotate({description:"Seed of the recording's natural motion. Start a recording with a `motion` of type `natural` and this `seed` to replay its pointer paths."}).check(Y().annotate({expected:`an integer`}))),editing:U.annotate({description:"Whether the edit a requested stop makes is still running. The raw video is already published; `editedRelativePath`, `timelineRelativePath` and `editError` are filled once this is false."}),editedRelativePath:z(V.annotate({description:"The edited H.264 video, published next to the raw one as `<name>.edited.mp4`, once a stop made it."})),timelineRelativePath:z(V.annotate({description:"What the recording's automation did and when, in the raw and edited video's time, published as `<name>.timeline.json`."})),editError:z(QT)}).annotate({description:`One logical recording of a top-level target.`,identifier:`Recording`}),ME=W({rect:z(eE),selector:z(V.annotate({description:`CSS selector of an element in the top-level document; the zoom follows it.`}).check(OC(1).annotate({expected:`a value with a length of at least 1`}))),pointer:z(U.annotate({description:`Follow the pointer, so clicks and hovers stay in view.`}))}).annotate({description:`What a focus zooms on. Name exactly one of rect, selector and pointer.`,identifier:`RecordingFocusTarget`});W({point:z(tE),selector:z(V.annotate({description:`CSS selector in the top-level document; pass instead of point.`}).check(OC(1).annotate({expected:`a value with a length of at least 1`}))),radius:z(H.annotate({description:`Circle radius in CSS pixels. Zero or omitted means 40; other values must be at least 8.`}).check(yC().annotate({expected:`a finite number`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})).check(EC(300).annotate({expected:`a value less than or equal to 300`}))),loops:z(H.annotate({description:`Number of circles. Zero or omitted means 2.`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})).check(EC(5).annotate({expected:`a value less than or equal to 5`}))),durationMs:z(H.annotate({description:`Circle duration in milliseconds. Zero or omitted means 1200; other values must be at least 300.`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})).check(EC(5e3).annotate({expected:`a value less than or equal to 5000`})))}).annotate({identifier:`RecordingAttentionInput`});var NE=K([nE,rE],{mode:`oneOf`}).annotate({description:"A session file or directory, told apart by `type`.",identifier:`SessionFileEntry`}),PE=W({targetId:V,generation:H.annotate({description:`Assignment generation of the target's media output.`,format:`int64`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})),viewport:sE}).annotate({description:`Viewport applied to a top-level target.`,identifier:`TargetViewport`}),FE=W({tenant:K([cE,$S],{mode:`oneOf`}).annotate({description:"Active personal tenant, or `null` when the user has none."})}).annotate({description:`State of the signed-in user's personal tenant.`,identifier:`PersonalTenantStatus`}),IE=W({data:G(cE),meta:FT}).annotate({description:`Cursor-paginated tenants.`,identifier:`TenantPage`}),LE=W({data:G(lE),meta:FT}).annotate({identifier:`UserPage`}),RE=W({id:cC(()=>Q).annotate({description:`Snapshot identifier.`}),name:V.annotate({description:`Human-selected tenant-unique snapshot name.`,examples:[`signed-in-base`]}),tenantId:cC(()=>Q).annotate({description:`Tenant that owns the snapshot.`}),description:z(K([V,$S]).annotate({description:"Operator-provided description, or `null` when none is set.",examples:[`Signed-in storefront state for checkout tests`]})),parentSnapshotId:z(cC(()=>Q).annotate({description:"Deprecated, use `parentSnapshot`. Base snapshot from which the source session was created. Omitted for snapshots without a parent."})),parentSnapshot:z(cC(()=>uE).annotate({description:`Base snapshot from which the source session was created. Omitted for snapshots without a parent.`,readOnly:!0})),promotedFromSessionId:z(cC(()=>Q).annotate({description:"Deprecated, use `promotedFromSession`. Session whose retained overlay produced this snapshot. Omitted when lineage is unavailable."})),promotedFromSession:z(cC(()=>uE).annotate({description:`Session whose retained overlay produced this snapshot, named by its label. Omitted when lineage is unavailable.`,readOnly:!0})),createdAt:V.annotate({description:`Time the snapshot was created.`,examples:[`2026-07-17T12:45:00Z`],format:`date-time`}),deletedAt:z(K([V,$S]).annotate({description:"Soft-deletion time, or `null` for an active snapshot.",examples:[null],format:`date-time`})),expiresAt:z(V.annotate({description:`Purge eligibility time for a deleted snapshot. Omitted for active snapshots.`,examples:[`2026-08-16T12:45:00Z`],format:`date-time`})),tags:z(cC(()=>BT).annotate({description:`Snapshot metadata tags. Omitted when no tags are set.`}))}).annotate({description:`Reusable retained browser filesystem state. Deletion is soft until the retention deadline.`,identifier:`Snapshot`}),zE=W({data:G(dE),meta:FT}).annotate({description:`Cursor-paginated tenant events.`,identifier:`EventPage`}),BE=W({data:G(fE),meta:FT}).annotate({identifier:`AuditEventPage`}),VE=W({type:OT,id:V.annotate({description:`Stable identifier of the authenticated subject.`}),authMethod:q([`api_token`,`oauth`,`oidc`,`passkey`,`password`]).annotate({description:`Authentication mechanism used for this request.`}),tokenId:K([Q,$S],{mode:`oneOf`}).annotate({description:"Identifier of the API token used for authentication, or `null` for account-backed sessions."}),userId:z(K([Q,$S],{mode:`oneOf`}).annotate({description:"User identifier for account-backed authentication, or `null` for API tokens."})),name:V.annotate({description:`Display name of the authenticated credential or user.`,examples:[`deployment automation`]}),authorityType:kT,tenantId:z(K([Q,$S],{mode:`oneOf`}).annotate({description:"Effective tenant for tenant authority, or `null` when no tenant is selected."})),scopes:G(AT).annotate({description:`Scopes granted to the authenticated principal.`}).check(PC().annotate({expected:`an array with unique items`})),resourceMode:jT,resourceGrants:G(mE).annotate({description:"Explicit grants when `resourceMode` is `allowlist`; empty when it is `all`."}).check(PC().annotate({expected:`an array with unique items`}))}).annotate({description:`Authenticated subject identity and authorization context.`,identifier:`Principal`}),HE=W({id:cC(()=>Q).annotate({description:`Token identifier. This is not the bearer secret.`}),authorityType:kT,tenantId:z(K([Q,$S],{mode:`oneOf`}).annotate({description:"Deprecated, use `tenant`. Bound tenant for a tenant token, or `null` for a system administrator token."})),tenant:K([uE,$S],{mode:`oneOf`}).annotate({description:"Bound tenant for a tenant token, or `null` for a system administrator token.",readOnly:!0}),name:V.annotate({description:`Operator-assigned token name, unique within its authority and tenant context.`,examples:[`ci automation`]}),scopes:G(AT).annotate({description:`Unique scopes granted to the token.`}).check(OC(1).annotate({expected:`a value with a length of at least 1`})).check(PC().annotate({expected:`an array with unique items`})),createdAt:V.annotate({description:`Time the token was created.`,examples:[`2026-07-17T12:00:00Z`],format:`date-time`}),createdByType:cC(()=>OT).annotate({description:"Deprecated, use `createdBy.type`. Principal category that created the token."}),createdById:K([Q,$S],{mode:`oneOf`}).annotate({description:"Deprecated, use `createdBy.id`. User or API token identifier that created the token, or `null` for trusted local system actions."}),createdBy:cC(()=>pE).annotate({description:`User or API token that created the token, or the trusted local system.`,readOnly:!0}),parentTokenId:K([Q,$S],{mode:`oneOf`}).annotate({description:"Deprecated, use `parentToken`. API token used to delegate this token, or `null` when a user or trusted local system created it."}),parentToken:K([uE,$S],{mode:`oneOf`}).annotate({description:"API token used to delegate this token, or `null` when a user or trusted local system created it.",readOnly:!0}),resourceMode:jT,resourceGrants:G(mE).annotate({description:"Explicit session and snapshot grants when `resourceMode` is `allowlist`."}).check(PC().annotate({expected:`an array with unique items`})),expiresAt:z(K([V,$S]).annotate({description:"Authentication expiry time, or `null` when the token does not expire automatically.",examples:[`2026-08-17T12:00:00Z`],format:`date-time`})),revokedAt:z(K([V,$S]).annotate({description:"Revocation time, or `null` while the token is active.",examples:[null],format:`date-time`}))}).annotate({description:`API token metadata. The raw bearer secret is never included in this schema.`,identifier:`Token`});K([W({name:V.annotate({description:`Operator-assigned name. Leading and trailing whitespace is removed.`,examples:[`platform admin`]}).check(OC(1).annotate({expected:`a value with a length of at least 1`})).check(vC(RegExp(`.*\\S.*`,`u`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),authorityType:B(`system_admin`),scopes:G(AT).annotate({description:"Must include `system:admin`.",examples:[[`system:admin`]]}).check(OC(1).annotate({expected:`a value with a length of at least 1`})).check(PC().annotate({expected:`an array with unique items`})),expiresAt:z(K([V,$S]).annotate({description:"Optional RFC3339 timestamp. Omit or send `null` for no automatic expiry.",examples:[`2026-08-17T12:00:00Z`],format:`date-time`})),resourceMode:z(B(`all`).annotate({description:`System administrator tokens cannot use resource allowlists.`,default:`all`})),resourceGrants:z(G(mE).annotate({description:`Must be empty for a system administrator token.`}).check(AC(0).annotate({expected:`a value with a length of at most 0`})))}),W({name:V.annotate({description:`Operator-assigned name. Leading and trailing whitespace is removed.`,examples:[`tenant automation`]}).check(OC(1).annotate({expected:`a value with a length of at least 1`})).check(vC(RegExp(`.*\\S.*`,`u`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),authorityType:B(`tenant`),tenantId:cC(()=>Q).annotate({description:`Active tenant to bind permanently to the token.`}),scopes:G(LT).annotate({description:"Tenant-compatible scopes. `system:admin` and `tenants:write` are rejected.",examples:[[`sessions:read`,`sessions:write`]]}).check(OC(1).annotate({expected:`a value with a length of at least 1`})).check(PC().annotate({expected:`an array with unique items`})),expiresAt:z(K([V,$S]).annotate({description:"Optional RFC3339 timestamp. Omit or send `null` for no automatic expiry.",examples:[`2026-08-17T12:00:00Z`],format:`date-time`})),resourceMode:z(jT),resourceGrants:z(G(mE).annotate({description:"Existing tenant resources granted when `resourceMode` is `allowlist`; must be empty for `all`."}).check(PC().annotate({expected:`an array with unique items`})))})],{mode:`oneOf`}).annotate({description:`Token definition accepted by the system administrator token endpoint.`,identifier:`CreateAdminTokenInput`}),W({name:V.annotate({description:`Operator-assigned name. Leading and trailing whitespace is removed.`,examples:[`browser worker`]}).check(OC(1).annotate({expected:`a value with a length of at least 1`})).check(vC(RegExp(`.*\\S.*`,`u`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),scopes:G(LT).annotate({description:"Tenant-compatible scopes. `system:admin` and `tenants:write` are rejected.",examples:[[`sessions:read`,`sessions:write`]]}).check(OC(1).annotate({expected:`a value with a length of at least 1`})).check(PC().annotate({expected:`an array with unique items`})),expiresAt:z(K([V,$S]).annotate({description:"Optional RFC3339 timestamp. Omit or send `null` for no automatic expiry.",examples:[`2026-08-17T12:00:00Z`],format:`date-time`})),resourceMode:z(jT),resourceGrants:z(G(mE).annotate({description:"Existing tenant resources granted when `resourceMode` is `allowlist`; must be empty for `all`."}).check(PC().annotate({expected:`an array with unique items`})))}).annotate({description:`Token definition automatically bound to the authenticated tenant.`,identifier:`CreateTenantTokenInput`}),K([hE,oE],{mode:`oneOf`}).annotate({description:`Failure of a live-session route.`,identifier:`LiveSessionFailure`});var UE=W({mode:q([`auto`,`cdp`]).annotate({description:"Configured media mode. `auto` enables deployment-selected media support; `cdp` exposes Chrome DevTools access only.",examples:[`auto`]}),webrtcProducer:U.annotate({description:`Whether the compositor WebRTC producer is available for this session.`,examples:[!0]}),iceServers:z(G(vE).annotate({description:`ICE configuration for WebRTC setup. Omitted when WebRTC is unavailable or does not need configured ICE servers.`}))}).annotate({description:`Media capabilities currently available for the session.`,identifier:`SessionMedia`}),WE=W({origin:V.annotate({format:`uri`}).check(vC(RegExp(`^https?:\\/\\/[^/]+$`,`u`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/[^/]+$`})),entries:G(xE)}).annotate({identifier:`InitialTargetStorageOrigin`}),GE=W({upstreams:z(nC(V,wE).annotate({description:"Upstreams by name. Names use lowercase letters, digits and dashes; `direct`, `refuse` and `local` are reserved."})),rules:z(G(HT).check(AC(256).annotate({expected:`a value with a length of at most 256`}))),upstream:z(q([`direct`,`proxy`,`tunnel`]).annotate({description:"Legacy single-upstream shape; use `upstreams` and `rules`. Cannot be combined with them. `proxy` becomes a final `*` rule via `url`, `tunnel` a `tunnel` upstream and a final `*` rule via it, each preceded by `direct` rules for the `bypass` entries. `direct` or omitted means no rules.",examples:[`tunnel`]})),url:z(V.annotate({description:"Legacy upstream proxy URL, required with `upstream` `proxy`. Use `upstreams` and `rules`.",examples:[`socks5://user:pass@proxy.example.com:1080`]})),tunnel:z(TE),bypass:z(V.annotate({description:"Legacy hosts to send direct, separated by `;` or `,`. Each entry must be a valid rule `match`; a leading `.` means any subdomain. CIDR ranges, `<local>` and scheme prefixes are rejected. Use `upstreams` and `rules`.",examples:[`*.internal.example.com`]}))}).annotate({description:"Session egress proxy configuration. Rules are checked in order and the first match routes the connection; unmatched connections go direct, and unmatched `localhost` stays on the session host. Omitted for direct egress.",identifier:`ProxyConfig`}),KE=W({upstreams:z(nC(V,wE)),rules:z(G(HT).check(AC(256).annotate({expected:`a value with a length of at most 256`}))),upstream:z(q([`direct`,`proxy`,`tunnel`]).annotate({description:"Legacy single-upstream shape; use `upstreams` and `rules`."})),url:z(V.annotate({description:"Legacy upstream proxy URL; use `upstreams` and `rules`."})),tunnel:z(TE),bypass:z(V.annotate({description:"Legacy hosts to send direct; use `upstreams` and `rules`."})),drain:z(U.annotate({description:`Reset live tunnel streams instead of letting them drain. New connections use the new rules either way.`,examples:[!1]}))}).annotate({description:"Replacement session egress proxy configuration. Fields other than `drain` are as in `ProxyConfig`.",identifier:`UpdateProxyConfig`}),qE=W({name:V,entries:G(EE)}).annotate({identifier:`InitialCacheStorageCache`}),JE=W({locator:OE,value:RT,checked:z(U),selectedIndices:z(G(H.check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})))),selection:z(KT)}).annotate({identifier:`InitialBrowserControlState`}),YE=W({locator:OE,html:RT}).annotate({identifier:`InitialBrowserContentEditableState`}),XE=W({locator:OE,x:H.check(yC().annotate({expected:`a finite number`})),y:H.check(yC().annotate({expected:`a finite number`}))}).annotate({identifier:`InitialBrowserElementScrollPosition`}),ZE=W({locator:OE,nodePath:G(H.check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))).check(AC(256).annotate({expected:`a value with a length of at most 256`})),offset:H.check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))}).annotate({identifier:`InitialBrowserSelectionEndpoint`}),QE=W({name:V,keyPath:YT,autoIncrement:U,indexes:G(AE),records:G(SE)}).annotate({identifier:`InitialIndexedDBObjectStore`});W({target:ME,zoom:H.check(yC().annotate({expected:`a finite number`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})).check(EC(4).annotate({expected:`a value less than or equal to 4`})),durationMs:z(H.annotate({description:`Zoom out after this many milliseconds; at least 200. Zero or omitted keeps the focus until reset-focus.`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})).check(EC(1e4).annotate({expected:`a value less than or equal to 10000`})))}).annotate({identifier:`RecordingFocusInput`});var $E=W({snapshot:RE}).annotate({description:`Snapshot returned after a mutation.`,identifier:`SnapshotMutation`}),eD=W({data:G(RE),meta:FT}).annotate({description:`Cursor-paginated snapshots.`,identifier:`SnapshotPage`}),tD=W({principal:VE,personalTenant:K([FE,$S],{mode:`oneOf`}).annotate({description:"The signed-in user's personal tenant, or `null` when they cannot manage one (API tokens, OAuth clients, and users without one while `allow_personal_tenants` is off)."}),selectedTenant:K([cE,$S],{mode:`oneOf`}).annotate({description:"Effective tenant, or `null` when the principal has not selected one."}),availableTenants:G(cE).annotate({description:`Active tenant memberships available to an account-backed principal. API-token principals return an empty array.`}),settings:W({allowPersonalTenants:U.annotate({description:"Whether personal tenants can be created (`allow_personal_tenants`)."}),autoCreatePersonalTenant:U.annotate({description:"Whether new users get a personal tenant by default (`auto_create_personal_tenant`)."})}).annotate({description:`Server settings relevant to the signed-in principal.`})}).annotate({description:`Current principal and its effective tenant selection.`,identifier:`AuthMe`}),nD=W({data:G(HE),meta:FT}).annotate({description:`Cursor-paginated API token metadata without bearer secrets.`,identifier:`TokenPage`}),rD=W({token:HE,rawToken:cC(()=>RT).annotate({description:`One-time Aperture API bearer token. Store it immediately; later reads return only token metadata.`,examples:[`apt_019f6cf0000070008000000000000002_REDACTED`]})}).annotate({description:`Created token metadata and its one-time bearer secret.`,identifier:`CreateTokenResponse`}),iD=W({id:cC(()=>Q).annotate({description:`Session identifier.`}),tenantId:cC(()=>Q).annotate({description:`Tenant that owns the session.`}),baseSnapshotName:z(V.annotate({description:`Snapshot name used as the session base. Omitted for a blank session.`,examples:[`signed-in-base`]})),label:z(V.annotate({description:`Optional operator-facing session label.`,examples:[`checkout smoke test`]})),status:zT,browserChannel:z(V.annotate({description:`Browser channel used to create and reopen the session.`,examples:[`chromium`]})),media:UE,createdAt:V.annotate({description:`Time the session record was created.`,examples:[`2026-07-17T12:00:00Z`],format:`date-time`}),startedAt:z(V.annotate({description:`Most recent successful browser start time. Omitted before startup succeeds.`,examples:[`2026-07-17T12:00:03Z`],format:`date-time`})),stoppedAt:z(V.annotate({description:`Most recent browser stop time. Omitted while no stop has occurred.`,examples:[`2026-07-17T13:00:00Z`],format:`date-time`})),deletedAt:z(K([V,$S]).annotate({description:"Soft-deletion time, or `null` for a session that has not been deleted.",examples:[null],format:`date-time`})),expiresAt:V.annotate({description:`Retention deadline after which the session and its overlay may be purged. This is not token expiry.`,examples:[`2026-07-24T12:00:00Z`],format:`date-time`}),lastConnectedAt:z(V.annotate({description:`Most recent routed client activity time. Omitted until a client connects.`,examples:[`2026-07-17T12:30:00Z`],format:`date-time`})),suspendedAt:z(V.annotate({description:`Most recent suspension time. Omitted unless the session is suspended.`,examples:[`2026-07-17T13:00:00Z`],format:`date-time`})),tags:z(cC(()=>BT).annotate({description:`Session metadata tags. Omitted when no tags are set.`})),cdpUrl:z(V.annotate({description:"Authenticated Chrome DevTools endpoint. Omitted when the session is not currently routable. Use it with `sessionToken`.",examples:[`https://aperture.example.com/cdp/019f6cf0-0000-7000-8000-000000000010`],format:`uri`})),sessionToken:z(cC(()=>RT).annotate({description:`Session access secret returned when live access credentials are available. Rotation invalidates the previous token immediately.`,examples:[`aps_019f6cf0000070008000000000000010_REDACTED`]})),collaboration:z(yE),thumbnail:z(bE),proxy:z(DE)}).annotate({description:`Browser session state, retention metadata, tags, and currently available access credentials.`,identifier:`Session`}),aD=W({anchor:ZE,focus:ZE}).annotate({identifier:`InitialBrowserDocumentSelection`}),oD=W({name:V,version:H.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),objectStores:G(QE)}).annotate({identifier:`InitialIndexedDBDatabase`}),sD=W({data:G(iD),meta:FT}).annotate({description:`Cursor-paginated browser sessions.`,identifier:`SessionPage`}),cD=W({session:iD,cdpUrl:V.annotate({description:`Authenticated Chrome DevTools endpoint for the new session.`,examples:[`https://aperture.example.com/cdp/019f6cf0-0000-7000-8000-000000000010`],format:`uri`}),sessionToken:cC(()=>RT).annotate({description:`Initial session access secret. Store it immediately.`,examples:[`aps_019f6cf0000070008000000000000010_REDACTED`]})}).annotate({description:`Newly created session and its one-time initial access credentials.`,identifier:`CreateSessionResult`}),lD=W({sessions:G(iD)}).annotate({description:`Sessions found for the requested IDs, preserving request order.`,identifier:`SessionBulkResponse`}),uD=W({session:iD,cdpUrl:z(V.annotate({description:`Current Chrome DevTools endpoint. Omitted by operations that do not expose live access.`,examples:[`https://aperture.example.com/cdp/019f6cf0-0000-7000-8000-000000000010`],format:`uri`})),sessionToken:z(cC(()=>RT).annotate({description:`Current raw session access secret. Omitted by operations that do not expose or replace credentials.`,examples:[`aps_019f6cf0000070008000000000000010_REDACTED`]}))}).annotate({description:`Updated session and operation-specific live access credentials when available.`,identifier:`SessionMutation`}),dD=W({version:B(1),windowName:z(RT),historyState:z(cC(()=>RT).annotate({description:`JSON-encoded structured-clone history state.`})),controls:G(JE).check(AC(1e4).annotate({expected:`a value with a length of at most 10000`})),contentEditables:G(YE).check(AC(1e4).annotate({expected:`a value with a length of at most 10000`})),scrollPositions:G(XE).check(AC(1e4).annotate({expected:`a value with a length of at most 10000`})),focus:z(OE),selection:z(aD)}).annotate({description:`Sensitive top-document state replayed during initial navigation.`,identifier:`InitialBrowserDocumentState`}),fD=W({origin:V.annotate({examples:[`https://example.com`],format:`uri`}).check(vC(RegExp(`^https?:\\/\\/[^/]+$`,`u`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/[^/]+$`})),ancestorOrigins:z(G(V.annotate({format:`uri`}).check(vC(RegExp(`^https?:\\/\\/[^/]+$`,`u`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/[^/]+$`}))).annotate({description:`Top-down HTTP origin chain for partitioned storage. Omitted for a top-level origin.`}).check(AC(32).annotate({expected:`a value with a length of at most 32`}))),localStorage:G(xE),indexedDB:z(G(oD)),cacheStorage:z(G(qE)),opfs:z(G(CE))}).annotate({description:`Profile-scoped browser storage imported for one exact HTTP origin and ancestor partition.`,identifier:`InitialStorageOrigin`}),pD=W({url:V.annotate({description:`Absolute HTTP or HTTPS URL without embedded credentials.`,examples:[`https://example.com/account`],format:`uri`}).check(vC(RegExp(`^https?:\\/\\/`,`u`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/`})),sessionStorage:z(G(WE).annotate({description:`Per-origin session storage installed in target frames before page scripts execute.`})),scroll:z(WT),documentState:z(dD),openerTargetIndex:z(H.annotate({description:`Index of another initial target that opened this target.`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),active:z(U.annotate({description:`Select this target for the first connected session client. At most one target may be active.`,default:!1}))}).annotate({description:`HTTP page and target-scoped state opened during session creation.`,identifier:`InitialBrowserTarget`}),mD=W({cookies:G(kE).check(AC(1e4).annotate({expected:`a value with a length of at most 10000`})),origins:G(fD).check(AC(100).annotate({expected:`a value with a length of at most 100`}))}).annotate({description:`Profile-scoped browser storage imported before initial browser targets are opened.`,identifier:`InitialBrowserStorageState`}),hD=W({baseSnapshotName:z(K([V,$S]).annotate({description:"Active snapshot used as the browser filesystem base. Omit, send `null`, or send an empty value for a blank session.",examples:[`signed-in-base`]})),label:z(K([V,$S]).annotate({description:`Optional operator-facing label for the session.`,examples:[`checkout smoke test`]})),browser:UT,initialTargets:z(G(pD).annotate({description:`Browser targets that replace the browser's startup page after storage import. Result order follows input order; opener dependencies may be created first.`}).check(AC(50).annotate({expected:`a value with a length of at most 50`}))),storageState:z(mD),tags:z(cC(()=>BT).annotate({description:`Initial session tags.`})),proxy:z(GE)}).annotate({description:`Configuration for a new retained browser session.`,examples:[{baseSnapshotName:`signed-in-base`,label:`checkout smoke test`,browser:{channel:`chromium`,args:[`--lang=en-US`]},initialTargets:[{url:`https://example.com/account`}],storageState:{cookies:[],origins:[{origin:`https://example.com`,localStorage:[{name:`access-token`,value:`REDACTED`}]}]},tags:{environment:`staging`,suite:`checkout`}}],identifier:`CreateSessionInput`}),gD=DT;W({"X-Aperture-Tenant-Id":z(Q)});var _D=tD,vD=cE,yD=cE,bD=gE;W({limit:z(H.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:z(V),deleted:z(q([`active`,`deleted`,`all`]).annotate({default:`active`})),includeDeleted:z(U.annotate({default:!1})),query:z(V)});var xD=IE,SD=cE,CD=cE,wD=cE,TD=cE;W({limit:z(H.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:z(V),query:z(V),disabled:z(q([`active`,`disabled`,`all`]).annotate({default:`active`}))});var ED=LE,DD=lE,OD=lE,kD=lE,AD=lE,jD=lE,MD=hE,ND=hE,PD=IT,FD=G(_E),ID=G(_E),LD=_E,RD=hE;W({limit:z(H.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:z(V),tenantId:z(Q),actorType:z(OT),actorId:z(V),action:z(V),resourceType:z(V),resourceId:z(V)});var zD=BE;W({limit:z(H.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:z(V),authorityType:z(kT),tenantId:z(Q),name:z(V),scope:z(AT),revoked:z(q([`active`,`revoked`,`all`]).annotate({default:`all`}))});var BD=nD,VD=rD,HD=hE,UD=cE,WD=cE;W({limit:z(H.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:z(V),name:z(V),scope:z(AT),revoked:z(q([`active`,`revoked`,`all`]).annotate({default:`all`}))});var GD=nD,KD=rD,qD=hE;W({"X-Aperture-Tenant-Id":z(Q),limit:z(H.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:z(V),includeDeleted:z(U.annotate({default:!1})),status:z(zT),query:z(V),tagKey:z(G(V.check(OC(1).annotate({expected:`a value with a length of at least 1`})))),tagValue:z(G(V.check(OC(1).annotate({expected:`a value with a length of at least 1`})))),tagOperator:z(G(q([`eq`,`neq`,`in`,`not_in`])))});var JD=sD;W({"X-Aperture-Tenant-Id":z(Q),waitForReady:z(U.annotate({default:!0}))});var YD=hD,XD=cD;W({"X-Aperture-Tenant-Id":z(Q)});var ZD=lD;W({"X-Aperture-Tenant-Id":z(Q)});var QD=iD;W({"X-Aperture-Tenant-Id":z(Q)});var $D=uD;W({"X-Aperture-Tenant-Id":z(Q)});var eO=uD;W({"X-Aperture-Tenant-Id":z(Q)});var tO=KE,nO=uD;W({"X-Aperture-Tenant-Id":z(Q)});var rO=uD;W({"X-Aperture-Tenant-Id":z(Q)});var iO=uD;W({"X-Aperture-Tenant-Id":z(Q)});var aO=uD;W({"X-Aperture-Tenant-Id":z(Q)});var oO=uD;W({"X-Aperture-Tenant-Id":z(Q)});var sO=ZT;W({"X-Aperture-Tenant-Id":z(Q)});var cO=ZT;W({"X-Aperture-Tenant-Id":z(Q)});var lO=hE;W({"X-Aperture-Tenant-Id":z(Q)});var uO=hE;W({"X-Aperture-Tenant-Id":z(Q)});var dO=mD;W({"X-Aperture-Tenant-Id":z(Q)});var fO=G(jE);W({"X-Aperture-Tenant-Id":z(Q)});var pO=jE;W({"X-Aperture-Tenant-Id":z(Q)});var mO=jE;W({"X-Aperture-Tenant-Id":z(Q)});var hO=jE;W({"X-Aperture-Tenant-Id":z(Q)});var gO=hE;W({"X-Aperture-Tenant-Id":z(Q)});var _O=hE;W({"X-Aperture-Tenant-Id":z(Q)});var vO=hE;W({"X-Aperture-Tenant-Id":z(Q)});var yO=hE;W({"X-Aperture-Tenant-Id":z(Q)});var bO=jE;W({"X-Aperture-Tenant-Id":z(Q)});var xO=G(NE);W({"X-Aperture-Tenant-Id":z(Q),directory:z(V.annotate({default:`uploads`}))}),W({files:z(G(iE))});var SO=W({files:G(nE)}).annotate({description:`Files stored by this request, in request order.`});W({"X-Aperture-Tenant-Id":z(Q),relativePath:V.check(OC(1).annotate({expected:`a value with a length of at least 1`})),recursive:z(U.annotate({default:!1}))});var CO=hE;W({"X-Aperture-Tenant-Id":z(Q)});var wO=NE;W({"X-Aperture-Tenant-Id":z(Q)});var TO=rE;W({"X-Aperture-Tenant-Id":z(Q)});var EO=aE;W({"X-Aperture-Tenant-Id":z(Q)});var DO=$E;W({"X-Aperture-Tenant-Id":z(Q),limit:z(H.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:z(V),name:z(V),deleted:z(q([`active`,`deleted`,`all`]).annotate({default:`active`})),includeDeleted:z(U.annotate({default:!1})),tagKey:z(G(V.check(OC(1).annotate({expected:`a value with a length of at least 1`})))),tagValue:z(G(V.check(OC(1).annotate({expected:`a value with a length of at least 1`})))),tagOperator:z(G(q([`eq`,`neq`,`in`,`not_in`])))});var OO=eD;W({"X-Aperture-Tenant-Id":z(Q)});var kO=$E;W({"X-Aperture-Tenant-Id":z(Q)});var AO=$E;W({"X-Aperture-Tenant-Id":z(Q)});var jO=$E;W({"X-Aperture-Tenant-Id":z(Q)});var MO=$E;W({"X-Aperture-Tenant-Id":z(Q),limit:z(H.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:z(V),resourceType:z(V),resourceId:z(V)});var NO=zE;W({"X-Aperture-Tenant-Id":z(Q)}),W({files:z(G(iE))});var PO=W({files:G(nE)}).annotate({description:`Files stored by this request, in request order.`});W({"X-Aperture-Tenant-Id":z(Q)});var FO=PE,IO=(e,t={})=>{let n=e=>L(If(e.json,()=>`Unexpected status code`),t=>I(new gw({reason:new xw({request:e.request,response:e,description:typeof t==`string`?t:JSON.stringify(t)})}))),r=n=>r=>{let i=n?.includeResponse?e=>Tf(r(e),t=>[t,e]):e=>r(e);return t?.transformClient?n=>L(L(t.transformClient(e),e=>e.execute(n)),i):t=>L(e.execute(t),i)},i=encodeURIComponent,a=(e,t,n)=>uf(()=>{let r=(t,n)=>I(new gw({reason:new bw({request:e(``),cause:n,description:t})}));if(t.some(e=>e===``||/^(?:\.|%2e){1,2}$/i.test(e)))return r(`Path parameters must be non-empty and cannot be dot segments`);let i;try{i=n()}catch(e){return r(`Failed to encode path parameter`,e)}return i.split(`/`).some(e=>/^(?:\.|%2e){1,2}$/i.test(e))?r(`Request paths cannot contain dot segments`):P(e(i))}),o=n=>uf(()=>t.transformClient?L(t.transformClient(e),e=>pT(e).execute(n)):pT(e).execute(n)),s=e=>Tf(e.arrayBuffer,e=>new Uint8Array(e)),c=e=>o(e).pipe(Tf(e=>e.stream),dg),l=e=>t=>rT(e)(t);return{httpClient:e,getHealth:e=>Pw(`/api/health`).pipe(r(e?.config)(Z({"2xx":l(gD),orElse:n}))),getCurrentPrincipal:e=>Pw(`/api/auth/me`).pipe(X({"X-Aperture-Tenant-Id":e?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(e?.config)(Z({"2xx":l(_D),orElse:n}))),createOwnPersonalTenant:e=>Fw(`/api/auth/personal-tenant`).pipe(r(e?.config)(Z({"2xx":l(vD),orElse:n}))),deleteOwnPersonalTenant:e=>Rw(`/api/auth/personal-tenant`).pipe(r(e?.config)(Z({"2xx":l(yD),orElse:n}))),listBrowserChannels:e=>Pw(`/api/browser/channels`).pipe(r(e?.config)(Z({"2xx":l(bD),orElse:n}))),listTenants:e=>Pw(`/api/admin/tenants`).pipe(Xw({limit:e?.params?.limit,cursor:e?.params?.cursor,deleted:e?.params?.deleted,includeDeleted:e?.params?.includeDeleted,query:e?.params?.query}),r(e?.config)(Z({"2xx":l(xD),orElse:n}))),createTenant:e=>Fw(`/api/admin/tenants`).pipe($w(e.payload),r(e.config)(Z({"2xx":l(SD),orElse:n}))),deleteTenant:(e,t)=>a(Rw,[e],()=>`/api/admin/tenants/`+i(e)).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(CD),orElse:n}))))),updateTenant:(e,t)=>a(Iw,[e],()=>`/api/admin/tenants/`+i(e)).pipe(L(e=>e.pipe($w(t.payload),r(t.config)(Z({"2xx":l(wD),orElse:n}))))),restoreTenant:(e,t)=>a(Fw,[e],()=>`/api/admin/tenants/`+i(e)+`/restore`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(TD),orElse:n}))))),listUsers:e=>Pw(`/api/admin/users`).pipe(Xw({limit:e?.params?.limit,cursor:e?.params?.cursor,query:e?.params?.query,disabled:e?.params?.disabled}),r(e?.config)(Z({"2xx":l(ED),orElse:n}))),createUser:e=>Fw(`/api/admin/users`).pipe($w(e.payload),r(e.config)(Z({"2xx":l(DD),orElse:n}))),getUser:(e,t)=>a(Pw,[e],()=>`/api/admin/users/`+i(e)).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(OD),orElse:n}))))),disableUser:(e,t)=>a(Rw,[e],()=>`/api/admin/users/`+i(e)).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(kD),orElse:n}))))),updateUser:(e,t)=>a(Iw,[e],()=>`/api/admin/users/`+i(e)).pipe(L(e=>e.pipe($w(t.payload),r(t.config)(Z({"2xx":l(AD),orElse:n}))))),restoreUser:(e,t)=>a(Fw,[e],()=>`/api/admin/users/`+i(e)+`/restore`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(jD),orElse:n}))))),createPersonalTenant:(e,t)=>a(Fw,[e],()=>`/api/admin/users/`+i(e)+`/personal-tenant`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(MD),204:()=>df,orElse:n}))))),deletePersonalTenant:(e,t)=>a(Rw,[e],()=>`/api/admin/users/`+i(e)+`/personal-tenant`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(ND),204:()=>df,orElse:n}))))),createUserInvitation:(e,t)=>a(Fw,[e],()=>`/api/admin/users/`+i(e)+`/invitation`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(PD),orElse:n}))))),listUserMemberships:(e,t)=>a(Pw,[e],()=>`/api/admin/users/`+i(e)+`/memberships`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(FD),orElse:n}))))),listTenantMemberships:(e,t)=>a(Pw,[e],()=>`/api/admin/tenants/`+i(e)+`/memberships`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(ID),orElse:n}))))),upsertTenantMembership:(e,t,o)=>a(Lw,[e,t],()=>`/api/admin/tenants/`+i(e)+`/memberships/`+i(t)).pipe(L(e=>e.pipe($w(o.payload),r(o.config)(Z({"2xx":l(LD),orElse:n}))))),deleteTenantMembership:(e,t,o)=>a(Rw,[e,t],()=>`/api/admin/tenants/`+i(e)+`/memberships/`+i(t)).pipe(L(e=>e.pipe(r(o?.config)(Z({"2xx":l(RD),204:()=>df,orElse:n}))))),listAuditEvents:e=>Pw(`/api/admin/audit-events`).pipe(Xw({limit:e?.params?.limit,cursor:e?.params?.cursor,tenantId:e?.params?.tenantId,actorType:e?.params?.actorType,actorId:e?.params?.actorId,action:e?.params?.action,resourceType:e?.params?.resourceType,resourceId:e?.params?.resourceId}),r(e?.config)(Z({"2xx":l(zD),orElse:n}))),listAdminTokens:e=>Pw(`/api/admin/tokens`).pipe(Xw({limit:e?.params?.limit,cursor:e?.params?.cursor,authorityType:e?.params?.authorityType,tenantId:e?.params?.tenantId,name:e?.params?.name,scope:e?.params?.scope,revoked:e?.params?.revoked}),r(e?.config)(Z({"2xx":l(BD),orElse:n}))),createAdminToken:e=>Fw(`/api/admin/tokens`).pipe($w(e.payload),r(e.config)(Z({"2xx":l(VD),orElse:n}))),revokeAdminToken:(e,t)=>a(Fw,[e],()=>`/api/admin/tokens/`+i(e)+`/revoke`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(HD),204:()=>df,orElse:n}))))),getTenant:e=>Pw(`/api/tenant`).pipe(r(e?.config)(Z({"2xx":l(UD),orElse:n}))),updateSelectedTenant:e=>Iw(`/api/tenant`).pipe($w(e.payload),r(e.config)(Z({"2xx":l(WD),orElse:n}))),listTenantTokens:e=>Pw(`/api/tenant/tokens`).pipe(Xw({limit:e?.params?.limit,cursor:e?.params?.cursor,name:e?.params?.name,scope:e?.params?.scope,revoked:e?.params?.revoked}),r(e?.config)(Z({"2xx":l(GD),orElse:n}))),createTenantToken:e=>Fw(`/api/tenant/tokens`).pipe($w(e.payload),r(e.config)(Z({"2xx":l(KD),orElse:n}))),revokeTenantToken:(e,t)=>a(Fw,[e],()=>`/api/tenant/tokens/`+i(e)+`/revoke`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(qD),204:()=>df,orElse:n}))))),listSessions:e=>Pw(`/api/sessions`).pipe(Xw({limit:e?.params?.limit,cursor:e?.params?.cursor,includeDeleted:e?.params?.includeDeleted,status:e?.params?.status,query:e?.params?.query,tagKey:e?.params?.tagKey,tagValue:e?.params?.tagValue,tagOperator:e?.params?.tagOperator}),X({"X-Aperture-Tenant-Id":e?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(e?.config)(Z({"2xx":l(JD),orElse:n}))),createSession:e=>Fw(`/api/sessions`).pipe(Xw({waitForReady:e.params?.waitForReady}),X({"X-Aperture-Tenant-Id":e.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(e.payload),r(e.config)(Z({"2xx":l(XD),orElse:n}))),getSessionsBulk:e=>Fw(`/api/sessions/bulk`).pipe(X({"X-Aperture-Tenant-Id":e.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(e.payload),r(e.config)(Z({"2xx":l(ZD),orElse:n}))),getSession:(e,t)=>a(Pw,[e],()=>`/api/sessions/`+i(e)).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(QD),orElse:n}))))),deleteSession:(e,t)=>a(Rw,[e],()=>`/api/sessions/`+i(e)).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l($D),orElse:n}))))),replaceSessionTags:(e,t)=>a(Lw,[e],()=>`/api/sessions/`+i(e)+`/tags`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(t.payload),r(t.config)(Z({"2xx":l(eO),orElse:n}))))),updateSessionProxy:(e,t)=>a(Lw,[e],()=>`/api/sessions/`+i(e)+`/proxy`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(t.payload),r(t.config)(Z({"2xx":l(nO),orElse:n}))))),suspendSession:(e,t)=>a(Fw,[e],()=>`/api/sessions/`+i(e)+`/suspend`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(rO),orElse:n}))))),reopenSession:(e,t)=>a(Fw,[e],()=>`/api/sessions/`+i(e)+`/reopen`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(iO),orElse:n}))))),rotateSessionToken:(e,t)=>a(Fw,[e],()=>`/api/sessions/`+i(e)+`/session-token/rotate`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(aO),orElse:n}))))),rotateCollaborationCapability:(e,t,o)=>a(Fw,[e,t],()=>`/api/sessions/`+i(e)+`/collaboration-capabilities/`+i(t)+`/rotate`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(o?.config)(Z({"2xx":l(oO),orElse:n}))))),getSessionCursor:(e,t)=>a(Pw,[e],()=>`/api/sessions/`+i(e)+`/cursor`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(sO),orElse:n}))))),setSessionCursor:(e,t)=>a(Lw,[e],()=>`/api/sessions/`+i(e)+`/cursor`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(t.payload),r(t.config)(Z({"2xx":l(cO),orElse:n}))))),getSessionThumbnail:(e,t)=>a(Pw,[e],()=>`/api/sessions/`+i(e)+`/thumbnail`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(lO),200:s,orElse:n}))))),getSessionThumbnailStream:(e,t)=>dg(a(Pw,[e],()=>`/api/sessions/`+i(e)+`/thumbnail`).pipe(Tf(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),c)))),getSessionTargetThumbnail:(e,t,o)=>a(Pw,[e,t],()=>`/api/sessions/`+i(e)+`/targets/`+i(t)+`/thumbnail`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(o?.config)(Z({"2xx":l(uO),200:s,orElse:n}))))),getSessionTargetThumbnailStream:(e,t,n)=>dg(a(Pw,[e,t],()=>`/api/sessions/`+i(e)+`/targets/`+i(t)+`/thumbnail`).pipe(Tf(e=>e.pipe(X({"X-Aperture-Tenant-Id":n?.params?.[`X-Aperture-Tenant-Id`]??void 0}),c)))),exportSessionStorageState:(e,t)=>a(Fw,[e],()=>`/api/sessions/`+i(e)+`/storage-state`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(t.payload),r(t.config)(Z({"2xx":l(dO),orElse:n}))))),listSessionRecordings:(e,t)=>a(Pw,[e],()=>`/api/sessions/`+i(e)+`/recordings`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(fO),orElse:n}))))),createSessionRecording:(e,t)=>a(Fw,[e],()=>`/api/sessions/`+i(e)+`/recordings`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(t.payload),r(t.config)(Z({"2xx":l(pO),orElse:n}))))),getSessionRecording:(e,t,o)=>a(Pw,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(o?.config)(Z({"2xx":l(mO),orElse:n}))))),retargetSessionRecording:(e,t,o)=>a(Fw,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)+`/retarget`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(o.payload),r(o.config)(Z({"2xx":l(hO),orElse:n}))))),captionSessionRecording:(e,t,o)=>a(Fw,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)+`/caption`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(o.payload),r(o.config)(Z({"2xx":l(gO),204:()=>df,orElse:n}))))),focusSessionRecording:(e,t,o)=>a(Fw,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)+`/focus`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(o.payload),r(o.config)(Z({"2xx":l(_O),204:()=>df,orElse:n}))))),resetFocusSessionRecording:(e,t,o)=>a(Fw,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)+`/reset-focus`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(o?.config)(Z({"2xx":l(vO),204:()=>df,orElse:n}))))),attentionSessionRecording:(e,t,o)=>a(Fw,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)+`/attention`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(o.payload),r(o.config)(Z({"2xx":l(yO),204:()=>df,orElse:n}))))),stopSessionRecording:(e,t,o)=>a(Fw,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)+`/stop`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(o?.config)(Z({"2xx":l(bO),orElse:n}))))),listSessionFiles:(e,t)=>a(Pw,[e],()=>`/api/sessions/`+i(e)+`/files`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(xO),orElse:n}))))),uploadSessionFiles:(e,t)=>a(Fw,[e],()=>`/api/sessions/`+i(e)+`/files`).pipe(L(e=>e.pipe(Xw({directory:t.params?.directory}),X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),eT(t.payload),r(t.config)(Z({"2xx":l(SO),orElse:n}))))),deleteSessionFile:(e,t)=>a(Rw,[e],()=>`/api/sessions/`+i(e)+`/files`).pipe(L(e=>e.pipe(Xw({relativePath:t.params.relativePath,recursive:t.params.recursive}),X({"X-Aperture-Tenant-Id":t.params[`X-Aperture-Tenant-Id`]??void 0}),r(t.config)(Z({"2xx":l(CO),204:()=>df,orElse:n}))))),moveSessionFile:(e,t)=>a(Fw,[e],()=>`/api/sessions/`+i(e)+`/files/move`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(t.payload),r(t.config)(Z({"2xx":l(wO),orElse:n}))))),createSessionDirectory:(e,t)=>a(Fw,[e],()=>`/api/sessions/`+i(e)+`/files/directories`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(t.payload),r(t.config)(Z({"2xx":l(TO),orElse:n}))))),createSessionFileDownloadURL:(e,t)=>a(Fw,[e],()=>`/api/sessions/`+i(e)+`/files/download-url`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(t.payload),r(t.config)(Z({"2xx":l(EO),orElse:n}))))),promoteSession:(e,t)=>a(Fw,[e],()=>`/api/sessions/`+i(e)+`/promote`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(t.payload),r(t.config)(Z({"2xx":l(DO),orElse:n}))))),listSnapshots:e=>Pw(`/api/snapshots`).pipe(Xw({limit:e?.params?.limit,cursor:e?.params?.cursor,name:e?.params?.name,deleted:e?.params?.deleted,includeDeleted:e?.params?.includeDeleted,tagKey:e?.params?.tagKey,tagValue:e?.params?.tagValue,tagOperator:e?.params?.tagOperator}),X({"X-Aperture-Tenant-Id":e?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(e?.config)(Z({"2xx":l(OO),orElse:n}))),deleteSnapshot:(e,t)=>a(Rw,[e],()=>`/api/snapshots/`+i(e)).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(kO),orElse:n}))))),updateSnapshot:(e,t)=>a(Iw,[e],()=>`/api/snapshots/`+i(e)).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(t.payload),r(t.config)(Z({"2xx":l(AO),orElse:n}))))),replaceSnapshotTags:(e,t)=>a(Lw,[e],()=>`/api/snapshots/`+i(e)+`/tags`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(t.payload),r(t.config)(Z({"2xx":l(jO),orElse:n}))))),restoreSnapshot:(e,t)=>a(Fw,[e],()=>`/api/snapshots/`+i(e)+`/restore`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(MO),orElse:n}))))),listEvents:e=>Pw(`/api/events`).pipe(Xw({limit:e?.params?.limit,cursor:e?.params?.cursor,resourceType:e?.params?.resourceType,resourceId:e?.params?.resourceId}),X({"X-Aperture-Tenant-Id":e?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(e?.config)(Z({"2xx":l(NO),orElse:n}))),uploadLiveSessionFiles:(e,t)=>a(Fw,[e],()=>`/sessions/`+i(e)+`/uploads`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),eT(t.payload),r(t.config)(Z({"2xx":l(PO),orElse:n}))))),setSessionViewport:(e,t)=>a(Fw,[e],()=>`/sessions/`+i(e)+`/browser/viewport`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(t.payload),r(t.config)(Z({"2xx":l(FO),orElse:n})))))}},LO=`X-Aperture-Tenant-Id`,RO={kind:`session`,authorityType:null,tenantId:null,selectedTenantId:null};function zO(e,t){if(t!==`none`){if(t===`optional`)return e.selectedTenantId??void 0;if(e.authorityType===`tenant`)return e.kind===`bearer`?e.selectedTenantId??void 0:e.tenantId??void 0;if(e.authorityType===`system_admin`)return e.selectedTenantId??void 0}}var BO={anonymous:{},webSession:{credentials:RO},of:e=>({credentials:e}),tenantScoped:e=>({credentials:e,tenantHeader:`tenant-scoped`})},VO=class extends vr()(`@aperture-browser/api-client/ApiAuthorization`){},HO=q([`ble`,`cable`,`hybrid`,`internal`,`nfc`,`smart-card`,`usb`]),UO=W({id:V,type:B(`public-key`),transports:z(iC(G(HO)))}),WO=z(W({appid:z(V),credProps:z(U),hmacCreateSecret:z(U),minPinLength:z(U)})),GO=q([`hybrid`,`security-key`,`client-device`]),KO=q([`discouraged`,`preferred`,`required`]),qO=W({methods:G(K([W({type:B(`password`)}),W({type:B(`api_token`)}),W({type:B(`passkey`)}),W({type:B(`oidc`),id:V,name:V,loginUrl:V})]))}),JO=W({publicKey:W({challenge:V,timeout:z(H),rpId:z(V),allowCredentials:z(iC(G(UO))),userVerification:z(KO),hints:z(iC(G(GO))),extensions:WO})}),YO=W({publicKey:W({rp:W({id:z(V),name:V}),user:W({id:V,name:V,displayName:V}),challenge:V,pubKeyCredParams:iC(G(W({alg:q([-7,-8,-35,-36,-37,-38,-39,-257,-258,-259]),type:B(`public-key`)}))),timeout:z(H),excludeCredentials:z(iC(G(UO))),authenticatorSelection:z(W({authenticatorAttachment:z(q([`platform`,`cross-platform`])),requireResidentKey:z(U),residentKey:z(q([`discouraged`,`preferred`,`required`])),userVerification:z(KO)})),hints:z(iC(G(GO))),attestation:z(q([`direct`,`enterprise`,`indirect`,`none`])),attestationFormats:z(iC(G(q([`fido-u2f`,`packed`,`android-safetynet`,`android-key`,`tpm`,`apple`,`none`])))),extensions:WO})}),XO=W({id:V,name:V,createdAt:V,lastUsedAt:oC(V)}),ZO=W({passkeys:G(XO)}),QO=W({passkey:XO}),$O=W({mfaRequired:U}),ek=W({hasPassword:U,totpEnabled:U,recoveryCodesRemaining:H.check(Y(),J(0))}),tk=W({secret:V,otpauthUrl:V,qrCodeDataUrl:V}),nk=W({recoveryCodes:G(V)}),rk=W({id:V,name:V,uri:oC(V),logoUri:oC(V),kind:q([`registered`,`metadata_document`])}),ik=W({client:rk,redirectUri:V,requestedScopes:G(V),user:W({id:V,displayName:V,isSystemAdmin:U}),tenants:G(W({id:V,displayName:V,scopes:G(LT)})),availableScopes:G(LT),canGrantSystemAdmin:U}),ak=W({redirectUrl:V}),ok=W({grants:G(W({id:V,client:rk,authorityType:kT,tenants:G(W({id:V,displayName:V})),scopes:G(V),resourceMode:jT,resourceGrants:G(W({resourceType:MT,resourceId:V})),createdAt:V,lastUsedAt:oC(V)}))}),sk=class extends vr()(`@aperture-browser/api-client/AuthApi`){},ck=e=>({body:cw(e)}),lk=dd(sk,mf(function*(){let e=yield*dT,{authorize:t}=yield*VO,n=pT(e),r=IO(e),i=t(BO.anonymous),a=t(BO.webSession),o=R(`AuthApi.listLoginMethods`)(function*(){return yield*n.get(`/auth/login-methods`).pipe(L(rT(qO)),i)}),s=R(`AuthApi.loginWithPassword`)(function*(e,t){return yield*n.post(`/auth/password/login`,ck({email:e,password:t})).pipe(L(rT($O)),i)}),c=R(`AuthApi.completePasswordMFA`)(function*(e){yield*n.post(`/auth/password/login/mfa`,ck({code:e})).pipe(i)}),l=R(`AuthApi.loginWithAPIToken`)(function*(e){yield*n.post(`/auth/token/login`,ck({token:e})).pipe(i)}),u=R(`AuthApi.beginPasskeyLogin`)(function*(){return yield*n.post(`/auth/passkeys/login/options`).pipe(L(rT(JO)),i)}),d=R(`AuthApi.finishPasskeyLogin`)(function*(e){yield*n.post(`/auth/passkeys/login/finish`,ck(e)).pipe(i)}),f=R(`AuthApi.acceptUserInvitation`)(function*(e,t){yield*n.post(`/auth/invitations/accept`,ck({token:e,password:t})).pipe(i)}),p=R(`AuthApi.logoutWebSession`)(function*(){yield*n.post(`/auth/logout`).pipe(a)}),m=R(`AuthApi.getAuthMe`)(function*(e=null,n=RO){return yield*r.getCurrentPrincipal(void 0).pipe(t({credentials:{...n,selectedTenantId:e},tenantHeader:`optional`}))}),h=R(`AuthApi.getSecurityStatus`)(function*(){return yield*n.get(`/auth/security`).pipe(L(rT(ek)),a)}),g=R(`AuthApi.getTenantContext`)(function*(e=null){return yield*n.get(`/auth/tenant-context`).pipe(L(rT(tD)),t({credentials:{...RO,selectedTenantId:e},tenantHeader:`optional`}))}),_=R(`AuthApi.resolveSessionTenant`)(function*(e){return yield*n.get(`/auth/sessions/${encodeURIComponent(e)}/tenant`).pipe(L(rT(cE)),a)}),v=R(`AuthApi.setPassword`)(function*(e,t){yield*n.put(`/auth/password`,ck({currentPassword:e,newPassword:t})).pipe(a)}),y=R(`AuthApi.listPasskeys`)(function*(){return yield*n.get(`/auth/passkeys`).pipe(L(rT(ZO)),a)}),b=R(`AuthApi.beginPasskeyRegistration`)(function*(e){return yield*n.post(`/auth/passkeys/registration/options`,ck({name:e})).pipe(L(rT(YO)),a)}),x=R(`AuthApi.finishPasskeyRegistration`)(function*(e){return yield*n.post(`/auth/passkeys/registration/finish`,ck(e)).pipe(L(rT(QO)),a)}),ee=R(`AuthApi.renamePasskey`)(function*(e,t){return yield*n.patch(`/auth/passkeys/${encodeURIComponent(e)}`,ck({name:t})).pipe(L(rT(QO)),a)}),S=R(`AuthApi.deletePasskey`)(function*(e){yield*n.del(`/auth/passkeys/${encodeURIComponent(e)}`).pipe(a)}),C=R(`AuthApi.beginTOTPEnrollment`)(function*(){return yield*n.post(`/auth/totp/enrollment/options`).pipe(L(rT(tk)),a)}),te=R(`AuthApi.completeTOTPEnrollment`)(function*(e){return yield*n.post(`/auth/totp/enrollment/finish`,ck({code:e})).pipe(L(rT(nk)),a)}),ne=R(`AuthApi.regenerateRecoveryCodes`)(function*(e){return yield*n.post(`/auth/totp/recovery-codes`,ck({code:e})).pipe(L(rT(nk)),a)}),w=R(`AuthApi.disableTOTP`)(function*(e){yield*n.post(`/auth/totp/disable`,ck({code:e})).pipe(a)}),T=R(`AuthApi.getOAuthAuthorization`)(function*(e){return yield*n.get(`/auth/oauth/authorization?${e}`).pipe(L(rT(ik)),a)}),re=R(`AuthApi.approveOAuthAuthorization`)(function*(e){return yield*n.post(`/auth/oauth/authorization/approve`,ck(e)).pipe(L(rT(ak)),a)}),ie=R(`AuthApi.denyOAuthAuthorization`)(function*(e){return yield*n.post(`/auth/oauth/authorization/deny`,ck({query:e})).pipe(L(rT(ak)),a)}),ae=R(`AuthApi.listOAuthGrants`)(function*(){return yield*n.get(`/auth/oauth/grants`).pipe(L(rT(ok)),a)}),oe=R(`AuthApi.createOwnPersonalTenant`)(function*(){return yield*r.createOwnPersonalTenant(void 0).pipe(a)}),se=R(`AuthApi.deleteOwnPersonalTenant`)(function*(){return yield*r.deleteOwnPersonalTenant(void 0).pipe(a)}),ce=R(`AuthApi.revokeOAuthGrant`)(function*(e){yield*n.del(`/auth/oauth/grants/${encodeURIComponent(e)}`).pipe(a)});return sk.of({listLoginMethods:o,loginWithPassword:s,completePasswordMFA:c,loginWithAPIToken:l,beginPasskeyLogin:u,finishPasskeyLogin:d,acceptUserInvitation:f,logoutWebSession:p,getAuthMe:m,getTenantContext:g,resolveSessionTenant:_,createOwnPersonalTenant:oe,deleteOwnPersonalTenant:se,getSecurityStatus:h,setPassword:v,listPasskeys:y,beginPasskeyRegistration:b,finishPasskeyRegistration:x,renamePasskey:ee,deletePasskey:S,beginTOTPEnrollment:C,completeTOTPEnrollment:te,regenerateRecoveryCodes:ne,disableTOTP:w,getOAuthAuthorization:T,approveOAuthAuthorization:re,denyOAuthAuthorization:ie,listOAuthGrants:ae,revokeOAuthGrant:ce})})),uk=K([W({error:W({code:V,message:V})}),W({error:V})]),dk=class extends ZC()(`ApiRequestError`,{code:V,message:V,status:H,cause:YS(K([hC(gw),hC(NS)]))}){},fk=(e,t)=>new dk({code:`internal_error`,message:`Invalid response`,status:e,cause:t}),pk=e=>e.pipe(Mf(`HttpClientError`,{StatusCodeError:({response:e},t)=>rT(uk)(e).pipe(Tf(({error:t})=>typeof t==`string`?new dk({code:`live_session_error`,message:t,status:e.status}):new dk({...t,status:e.status})),If(()=>new dk({code:`internal_error`,message:`Request failed`,status:e.status,cause:t})),L(I)),DecodeError:({response:e},t)=>I(fk(e.status,t))}),jf({HttpClientError:e=>I(new dk({code:`network_error`,message:`The server could not be reached`,status:0,cause:e})),SchemaError:e=>I(fk(0,e))})),mk=Xr(`@aperture-browser/api-client/CurrentAuthorization`,{defaultValue:()=>({})}),hk=e=>mk.useSync(({credentials:t,bearerToken:n,tenantHeader:r=`none`})=>{let i=n??(t?.kind===`bearer`?t.token:void 0),a=i===void 0?void 0:x_(i).trim(),o=t?zO(t,r):void 0;return e.pipe(Kw,a?Ww(a):x,o?Vw(LO,o):Uw(LO))}),gk=new Set([`authentication_required`,`invalid_authentication_token`,`authentication_token_expired`,`authentication_token_revoked`,`user_disabled`]),_k=dd(dT,Tf(dT,vT(hk))),vk=dd(VO,mf(function*(){let e=yield*nm();return VO.of({authorize:t=>n=>n.pipe(pk,Pf(n=>t.credentials?.kind===`session`&&gk.has(n.code)?im(e,void 0):df),qf(mk,t)),sessionAuthenticationFailures:cg(e)})})),yk=class extends vr()(`@aperture-browser/api-client/EventsApi`){},bk=class extends vr()(`@aperture-browser/api-client/HealthApi`){};function xk(e){return e.meta.hasMore?e.meta.nextCursor:void 0}function Sk(e){let t=(t,n)=>ug(void 0,r=>e(t,n===void 0?{cursor:r}:{...n,cursor:r}).pipe(Tf(e=>{let t=xk(e);return[e.data,t===void 0?sr():cr(t)]})));return{list:e,stream:t,listAll:(e,n)=>xg(t(e,n))}}var Ck=e=>({tagKey:e?.map(e=>e.key),tagOperator:e?.map(e=>e.operator),tagValue:e?.map(e=>e.values.join(`,`))}),wk=e=>Object.fromEntries(Object.entries(e).flatMap(([e,t])=>{if(t==null||t===``)return[];if(!Array.isArray(t))return[[e,t]];let n=t.filter(e=>e!==``);return n.length>0?[[e,n]]:[]})),Tk=dd(yk,mf(function*(){let e=yield*dT,{authorize:t}=yield*VO,n=IO(e),r=R(`EventsApi.listEvents`)(function*(e,r={}){return yield*n.listEvents({params:wk({limit:r.limit,cursor:r.cursor,resourceType:r.resourceType,resourceId:r.resourceId})}).pipe(t(BO.tenantScoped(e)))}),i=R(`EventsApi.listAuditEvents`)(function*(e,r={}){return yield*n.listAuditEvents({params:wk({limit:r.limit,cursor:r.cursor,tenantId:r.tenantId,actorType:r.actorType,actorId:r.actorId,action:r.action,resourceType:r.resourceType,resourceId:r.resourceId})}).pipe(t(BO.of(e)))}),a=Sk(r),o=Sk(i);return yk.of({listEvents:r,streamEvents:a.stream,listAllEvents:a.listAll,listAuditEvents:i,streamAuditEvents:o.stream,listAllAuditEvents:o.listAll})})),Ek=dd(bk,mf(function*(){let e=yield*dT,{authorize:t}=yield*VO,n=IO(e),r=R(`HealthApi.getHealth`)(function*(){return yield*n.getHealth(void 0).pipe(t(BO.anonymous))});return bk.of({getHealth:r})})),Dk=H.check(Y(),TC(0)),Ok=P([]),kk=W({capture:$T.fields.capture,pace:$T.fields.pace,motion:$T.fields.motion,idle:$T.fields.idle,ripple:$T.fields.ripple,burst:$T.fields.burst}),Ak={sessionId:V,cdpUrl:V,media:UE,thumbnailAvailable:U,pages:G(W({targetId:V,state:q([`pending`,`ready`,`unavailable`,`closed`]),title:V,url:V,viewport:z(W({width:Dk,height:Dk,deviceScaleFactor:H.check(TC(0)),contentWidth:Dk,contentHeight:Dk,canvasWidth:Dk,canvasHeight:Dk})),thumbnailAvailable:U})).pipe(fC(Ok))},jk={...Ak,capturedAt:V,representativeTargetId:z(V)},Mk=K([W({...jk,status:B(`running`),source:B(`live`)}),W({...jk,status:B(`suspended`),source:B(`persisted`)}),W({...Ak,status:B(`suspended`),source:B(`unavailable`)})]),Nk={recordingId:V,mode:q([`tab`,`viewer`]),targetId:V,captureGeneration:Dk,status:q([`starting`,`running`,`stopped`,`failed`]),stopReason:z(V),sandboxPath:z(V),path:z(V),startedAt:V,stoppedAt:z(V),sizeBytes:z(H.check(Y(),J(0))),fps:Dk,bitrateKbps:Dk,codec:V,motionSeed:z(H.check(Y())),editing:U,editedRelativePath:z(V),timelineRelativePath:z(V),editError:z(QT)},Pk=W({...Nk,relativePath:z(V)}).pipe(lC(W({...Nk,relativePath:V}),ey({decode:({relativePath:e,...t})=>({...t,relativePath:e??t.path??``}),encode:e=>e}))),Fk=class extends vr()(`@aperture-browser/api-client/SessionsApi`){},Ik=Fd,Lk=e=>bf(t=>P(e(t.getRef(Ik)))),Rk=(e,t,n)=>{let r=n?.halfOpen===!0?0:1;return Lk(n=>{let i=Math.ceil(e),a=Math.floor(t);return Math.floor(n.nextDoubleUnsafe()*(a-i+r))+i})},zk=new TextEncoder,Bk=e=>e.replaceAll(`"`,`%22`).replaceAll(`\r`,`%0D`).replaceAll(`
26
- `,`%0A`),Vk=e=>e instanceof Blob?lg({evaluate:()=>e.stream(),onError:e=>e}):e instanceof Uint8Array?rg(e):e,Hk=R(`SessionsApi.streamedMultipart`)(function*(e){let t=`aperture-upload-${(yield*Rk(0,2**53-1)).toString(36)}`;return mw(og(e.map(e=>{let n=`--${t}\r\nContent-Disposition: form-data; name="files"; filename="${Bk(e.name)}"\r\nContent-Type: application/octet-stream\r
25
+ `,identifier:`SessionThumbnail`}),xE=W({name:V,value:cC(()=>RT).annotate({description:`Browser storage value. Never log this field.`})}).annotate({identifier:`BrowserStorageEntry`}),SE=W({key:cC(()=>RT).annotate({description:`JSON-encoded structured-clone key.`}),value:cC(()=>RT).annotate({description:`JSON-encoded structured-clone value.`})}).annotate({identifier:`InitialIndexedDBRecord`}),CE=W({path:V.check(OC(1).annotate({expected:`a value with a length of at least 1`})),body:cC(()=>RT).annotate({contentEncoding:`base64`})}).annotate({identifier:`InitialOPFSFile`}),wE=W({url:V.annotate({description:"A generic proxy URL (`http`, `https`, `socks`, `socks5`, `socks5h`) or a compound tunnel URL (`ws+yamux+socks5://`, `wss+yamux+socks5://`). Proxy credentials go in the userinfo (`socks5://user:pass@host:1080`) and are sent as Basic `Proxy-Authorization` for `http`/`https` or RFC 1929 username/password for the socks schemes. An omitted port defaults to 1080 (socks), 80 (http) or 443 (https).",examples:[`wss+yamux+socks5://tunnel.example.com/t/019f6cf0-0000-7000-8000-000000000010`]}),auth:z(cC(()=>RT).annotate({description:`Bearer secret for a tunnel URL's handshake. Required for a tunnel URL and invalid for a proxy URL. Write-only; never returned.`,examples:[`REDACTED`]}))}).annotate({description:`A named upstream that proxy rules route through.`,identifier:`ProxyUpstream`}),TE=W({url:z(V.annotate({description:"Compound tunnel URL (`ws+yamux+socks5://` or `wss+yamux+socks5://`).",examples:[`wss+yamux+socks5://tunnel.example.com/t/019f6cf0-0000-7000-8000-000000000010`]})),auth:z(cC(()=>RT).annotate({description:`Bearer secret for the tunnel handshake. Write-only; never returned.`,examples:[`REDACTED`]}))}).annotate({description:"Legacy tunnel endpoint for `upstream` `tunnel`; both fields are required with it. Use a tunnel URL in `upstreams`.",identifier:`ProxyTunnelConfig`}),EE=W({url:V.annotate({format:`uri`}),requestHeaders:BT,responseHeaders:BT,responseStatus:H.check(Y().annotate({expected:`an integer`})).check(J(100).annotate({expected:`a value greater than or equal to 100`})).check(EC(599).annotate({expected:`a value less than or equal to 599`})),responseStatusText:V,responseBody:cC(()=>RT).annotate({contentEncoding:`base64`})}).annotate({identifier:`InitialCacheStorageEntry`});W({tags:cC(()=>BT).annotate({description:`Complete tag map. Keys and values must contain non-whitespace characters.`})}).annotate({description:`Complete replacement tag set. The map may be empty to clear all tags.`,examples:[{tags:{environment:`production`,region:`eu-west-1`}}],identifier:`ReplaceTagsInput`}),W({name:V.annotate({description:`Tenant-unique snapshot name. Leading and trailing whitespace is removed.`,examples:[`signed-in-base`]}).check(OC(1).annotate({expected:`a value with a length of at least 1`})).check(vC(RegExp(`.*\\S.*`,`u`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),description:z(K([V,$S]).annotate({description:"Optional snapshot description. `null` creates the snapshot without a description.",examples:[`Signed-in storefront state for checkout tests`]})),force:z(U.annotate({description:"Deleted snapshot names are reused automatically. Set `true` to replace an active snapshot, which is renamed to its tombstone name and retained for the configured snapshot retention period.",default:!1})),tags:z(cC(()=>BT).annotate({description:`Initial complete tag map for the new snapshot.`}))}).annotate({description:`Snapshot metadata created from a stopped, retained session.`,examples:[{name:`signed-in-base`,description:`Signed-in storefront state for checkout tests`,force:!1,tags:{application:`storefront`,environment:`staging`}}],identifier:`PromoteSessionInput`});var DE=W({upstreams:nC(V,VT),rules:G(HT),upstream:q([`direct`,`proxy`,`tunnel`]).annotate({description:"Legacy single-upstream view of `rules`; read `upstreams` and `rules` instead. Exact when the rules are optional leading `direct` rules followed by one final `*` rule via an upstream proxy or tunnel, with no other upstreams, and `direct` when there are no rules. Otherwise it approximates the route of the last `*` rule (`local` reads as `tunnel`, `refuse` as `direct`), or `direct` without one, and `url`, `tunnel` and `bypass` are omitted.",examples:[`tunnel`]}),url:z(V.annotate({description:"Legacy upstream proxy URL with its password masked. Only present when `upstream` is exactly `proxy`.",examples:[`socks5://user:xxxxx@proxy.example.com:1080`]})),tunnel:z(W({url:z(V.annotate({examples:[`wss+yamux+socks5://tunnel.example.com/t/019f6cf0-0000-7000-8000-000000000010`]}))}).annotate({description:"Legacy tunnel endpoint. Only present when `upstream` is exactly `tunnel`. The secret is never returned."})),bypass:z(V.annotate({description:"Legacy `;`-separated matches of the leading `direct` rules. Only present with an exact `proxy` or `tunnel` value.",examples:[`*.internal.example.com`]}))}).annotate({description:`Stored session egress proxy configuration. Secrets are write-only, so this value cannot be replayed as a write.`,identifier:`SessionProxy`}),OE=W({tag:V.check(vC(RegExp(`^[a-z][a-z0-9-]*$`,`u`)).annotate({expected:`a string matching the RegExp ^[a-z][a-z0-9-]*$`})),id:z(V),name:z(V),inputType:z(V),autocomplete:z(V),ariaLabel:z(V),placeholder:z(V),path:G(GT).check(AC(256).annotate({expected:`a value with a length of at most 256`}))}).annotate({description:`Semantic element identity with a structural fallback. It is not a CSS selector.`,identifier:`InitialBrowserElementLocator`}),kE=W({name:V.check(OC(1).annotate({expected:`a value with a length of at least 1`})),value:cC(()=>RT).annotate({description:`Cookie value. Never log this field.`}),domain:V.annotate({examples:[`.example.com`]}).check(OC(1).annotate({expected:`a value with a length of at least 1`})),hostOnly:z(U.annotate({description:"Scope the cookie to exactly `domain`, without subdomains. `domain` must then be a plain hostname.",default:!1})),path:V.annotate({examples:[`/`]}).check(vC(RegExp(`^\\/`,`u`)).annotate({expected:`a string matching the RegExp ^\\/`})),expires:z(H.annotate({description:`Unix timestamp in seconds. Omit for a session cookie.`}).check(yC().annotate({expected:`a finite number`})).check(TC(0).annotate({expected:`a value greater than 0`}))),httpOnly:z(U.annotate({default:!1})),secure:z(U.annotate({default:!1})),sameSite:z(qT),partitionKey:z(JT)}).annotate({description:`Cookie imported into the new browser profile.`,identifier:`InitialBrowserCookie`}),AE=W({name:V,keyPath:XT,unique:U,multiEntry:U}).annotate({identifier:`InitialIndexedDBIndex`}),jE=W({recordingId:V.annotate({description:`Stable recording identifier retained across target changes.`,format:`uuid`}),mode:q([`tab`,`viewer`]).annotate({description:`Tab recordings stay on their specified top-level target; viewer recordings follow a live session client's selected top-level target and cannot be explicitly retargeted.`}),targetId:V.annotate({description:`Identifier of the top-level target currently recorded.`}),captureGeneration:H.annotate({description:`Assignment generation for the current top-level target.`,format:`int64`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})),status:q([`starting`,`running`,`stopped`,`failed`]),stopReason:z(V.annotate({description:`Lifecycle reason recorded after the recording stops or fails.`})),relativePath:V.annotate({description:`Session file path below the session files root; host paths are never exposed.`,examples:[`recordings/recording-550e8400-e29b-41d4-a716-446655440000.webm`]}),startedAt:V.annotate({format:`date-time`}),stoppedAt:z(V.annotate({format:`date-time`})),sizeBytes:z(H.annotate({format:`int64`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),fps:H.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),bitrateKbps:H.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),codec:q([`vp8`,`h264-va`]),motionSeed:z(H.annotate({description:"Seed of the recording's natural motion. Start a recording with a `motion` of type `natural` and this `seed` to replay its pointer paths."}).check(Y().annotate({expected:`an integer`}))),editing:U.annotate({description:"Whether the edit a requested stop makes is still running. The raw video is already published; `editedRelativePath`, `timelineRelativePath` and `editError` are filled once this is false."}),editedRelativePath:z(V.annotate({description:"The edited H.264 video, published next to the raw one as `<name>.edited.mp4`, once a stop made it."})),timelineRelativePath:z(V.annotate({description:"What the recording's automation did and when, in the raw and edited video's time, published as `<name>.timeline.json`."})),editError:z(QT)}).annotate({description:`One logical recording of a top-level target.`,identifier:`Recording`}),ME=W({rect:z(eE),selector:z(V.annotate({description:`CSS selector of an element in the top-level document; the zoom follows it.`}).check(OC(1).annotate({expected:`a value with a length of at least 1`}))),pointer:z(U.annotate({description:`Follow the pointer, so clicks and hovers stay in view.`}))}).annotate({description:`What a focus zooms on. Name exactly one of rect, selector and pointer.`,identifier:`RecordingFocusTarget`});W({point:z(tE),selector:z(V.annotate({description:`CSS selector in the top-level document; pass instead of point.`}).check(OC(1).annotate({expected:`a value with a length of at least 1`}))),radius:z(H.annotate({description:`Circle radius in CSS pixels. Zero or omitted means 40; other values must be at least 8.`}).check(yC().annotate({expected:`a finite number`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})).check(EC(300).annotate({expected:`a value less than or equal to 300`}))),loops:z(H.annotate({description:`Number of circles. Zero or omitted means 2.`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})).check(EC(5).annotate({expected:`a value less than or equal to 5`}))),durationMs:z(H.annotate({description:`Circle duration in milliseconds. Zero or omitted means 1200; other values must be at least 300.`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})).check(EC(5e3).annotate({expected:`a value less than or equal to 5000`})))}).annotate({identifier:`RecordingAttentionInput`});var NE=K([nE,rE],{mode:`oneOf`}).annotate({description:"A session file or directory, told apart by `type`.",identifier:`SessionFileEntry`}),PE=W({targetId:V,generation:H.annotate({description:`Assignment generation of the target's media output.`,format:`int64`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})),viewport:sE}).annotate({description:`Viewport applied to a top-level target.`,identifier:`TargetViewport`}),FE=W({targetId:V.annotate({description:`Target ID taken by the per-tab thumbnail routes and the live session. It changes when the browser restarts.`}),title:V,url:V,state:q([`pending`,`ready`,`unavailable`,`closed`]).annotate({description:`Whether the live session can show the page.`}),viewport:z(cC(()=>sE).annotate({description:`The page's viewport, when the compositor has one for it.`})),thumbnailAvailable:U.annotate({description:`Whether the per-tab thumbnail route can serve this page.`})}).annotate({description:`One top-level browser page.`,identifier:`BrowserPage`}),IE=W({tenant:K([cE,$S],{mode:`oneOf`}).annotate({description:"Active personal tenant, or `null` when the user has none."})}).annotate({description:`State of the signed-in user's personal tenant.`,identifier:`PersonalTenantStatus`}),LE=W({data:G(cE),meta:FT}).annotate({description:`Cursor-paginated tenants.`,identifier:`TenantPage`}),RE=W({data:G(lE),meta:FT}).annotate({identifier:`UserPage`}),zE=W({id:cC(()=>Q).annotate({description:`Snapshot identifier.`}),name:V.annotate({description:`Human-selected tenant-unique snapshot name.`,examples:[`signed-in-base`]}),tenantId:cC(()=>Q).annotate({description:`Tenant that owns the snapshot.`}),description:z(K([V,$S]).annotate({description:"Operator-provided description, or `null` when none is set.",examples:[`Signed-in storefront state for checkout tests`]})),parentSnapshotId:z(cC(()=>Q).annotate({description:"Deprecated, use `parentSnapshot`. Base snapshot from which the source session was created. Omitted for snapshots without a parent."})),parentSnapshot:z(cC(()=>uE).annotate({description:`Base snapshot from which the source session was created. Omitted for snapshots without a parent.`,readOnly:!0})),promotedFromSessionId:z(cC(()=>Q).annotate({description:"Deprecated, use `promotedFromSession`. Session whose retained overlay produced this snapshot. Omitted when lineage is unavailable."})),promotedFromSession:z(cC(()=>uE).annotate({description:`Session whose retained overlay produced this snapshot, named by its label. Omitted when lineage is unavailable.`,readOnly:!0})),createdAt:V.annotate({description:`Time the snapshot was created.`,examples:[`2026-07-17T12:45:00Z`],format:`date-time`}),deletedAt:z(K([V,$S]).annotate({description:"Soft-deletion time, or `null` for an active snapshot.",examples:[null],format:`date-time`})),expiresAt:z(V.annotate({description:`Purge eligibility time for a deleted snapshot. Omitted for active snapshots.`,examples:[`2026-08-16T12:45:00Z`],format:`date-time`})),tags:z(cC(()=>BT).annotate({description:`Snapshot metadata tags. Omitted when no tags are set.`}))}).annotate({description:`Reusable retained browser filesystem state. Deletion is soft until the retention deadline.`,identifier:`Snapshot`}),BE=W({data:G(dE),meta:FT}).annotate({description:`Cursor-paginated tenant events.`,identifier:`EventPage`}),VE=W({data:G(fE),meta:FT}).annotate({identifier:`AuditEventPage`}),HE=W({type:OT,id:V.annotate({description:`Stable identifier of the authenticated subject.`}),authMethod:q([`api_token`,`oauth`,`oidc`,`passkey`,`password`]).annotate({description:`Authentication mechanism used for this request.`}),tokenId:K([Q,$S],{mode:`oneOf`}).annotate({description:"Identifier of the API token used for authentication, or `null` for account-backed sessions."}),userId:z(K([Q,$S],{mode:`oneOf`}).annotate({description:"User identifier for account-backed authentication, or `null` for API tokens."})),name:V.annotate({description:`Display name of the authenticated credential or user.`,examples:[`deployment automation`]}),authorityType:kT,tenantId:z(K([Q,$S],{mode:`oneOf`}).annotate({description:"Effective tenant for tenant authority, or `null` when no tenant is selected."})),scopes:G(AT).annotate({description:`Scopes granted to the authenticated principal.`}).check(PC().annotate({expected:`an array with unique items`})),resourceMode:jT,resourceGrants:G(mE).annotate({description:"Explicit grants when `resourceMode` is `allowlist`; empty when it is `all`."}).check(PC().annotate({expected:`an array with unique items`}))}).annotate({description:`Authenticated subject identity and authorization context.`,identifier:`Principal`}),UE=W({id:cC(()=>Q).annotate({description:`Token identifier. This is not the bearer secret.`}),authorityType:kT,tenantId:z(K([Q,$S],{mode:`oneOf`}).annotate({description:"Deprecated, use `tenant`. Bound tenant for a tenant token, or `null` for a system administrator token."})),tenant:K([uE,$S],{mode:`oneOf`}).annotate({description:"Bound tenant for a tenant token, or `null` for a system administrator token.",readOnly:!0}),name:V.annotate({description:`Operator-assigned token name, unique within its authority and tenant context.`,examples:[`ci automation`]}),scopes:G(AT).annotate({description:`Unique scopes granted to the token.`}).check(OC(1).annotate({expected:`a value with a length of at least 1`})).check(PC().annotate({expected:`an array with unique items`})),createdAt:V.annotate({description:`Time the token was created.`,examples:[`2026-07-17T12:00:00Z`],format:`date-time`}),createdByType:cC(()=>OT).annotate({description:"Deprecated, use `createdBy.type`. Principal category that created the token."}),createdById:K([Q,$S],{mode:`oneOf`}).annotate({description:"Deprecated, use `createdBy.id`. User or API token identifier that created the token, or `null` for trusted local system actions."}),createdBy:cC(()=>pE).annotate({description:`User or API token that created the token, or the trusted local system.`,readOnly:!0}),parentTokenId:K([Q,$S],{mode:`oneOf`}).annotate({description:"Deprecated, use `parentToken`. API token used to delegate this token, or `null` when a user or trusted local system created it."}),parentToken:K([uE,$S],{mode:`oneOf`}).annotate({description:"API token used to delegate this token, or `null` when a user or trusted local system created it.",readOnly:!0}),resourceMode:jT,resourceGrants:G(mE).annotate({description:"Explicit session and snapshot grants when `resourceMode` is `allowlist`."}).check(PC().annotate({expected:`an array with unique items`})),expiresAt:z(K([V,$S]).annotate({description:"Authentication expiry time, or `null` when the token does not expire automatically.",examples:[`2026-08-17T12:00:00Z`],format:`date-time`})),revokedAt:z(K([V,$S]).annotate({description:"Revocation time, or `null` while the token is active.",examples:[null],format:`date-time`}))}).annotate({description:`API token metadata. The raw bearer secret is never included in this schema.`,identifier:`Token`});K([W({name:V.annotate({description:`Operator-assigned name. Leading and trailing whitespace is removed.`,examples:[`platform admin`]}).check(OC(1).annotate({expected:`a value with a length of at least 1`})).check(vC(RegExp(`.*\\S.*`,`u`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),authorityType:B(`system_admin`),scopes:G(AT).annotate({description:"Must include `system:admin`.",examples:[[`system:admin`]]}).check(OC(1).annotate({expected:`a value with a length of at least 1`})).check(PC().annotate({expected:`an array with unique items`})),expiresAt:z(K([V,$S]).annotate({description:"Optional RFC3339 timestamp. Omit or send `null` for no automatic expiry.",examples:[`2026-08-17T12:00:00Z`],format:`date-time`})),resourceMode:z(B(`all`).annotate({description:`System administrator tokens cannot use resource allowlists.`,default:`all`})),resourceGrants:z(G(mE).annotate({description:`Must be empty for a system administrator token.`}).check(AC(0).annotate({expected:`a value with a length of at most 0`})))}),W({name:V.annotate({description:`Operator-assigned name. Leading and trailing whitespace is removed.`,examples:[`tenant automation`]}).check(OC(1).annotate({expected:`a value with a length of at least 1`})).check(vC(RegExp(`.*\\S.*`,`u`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),authorityType:B(`tenant`),tenantId:cC(()=>Q).annotate({description:`Active tenant to bind permanently to the token.`}),scopes:G(LT).annotate({description:"Tenant-compatible scopes. `system:admin` and `tenants:write` are rejected.",examples:[[`sessions:read`,`sessions:write`]]}).check(OC(1).annotate({expected:`a value with a length of at least 1`})).check(PC().annotate({expected:`an array with unique items`})),expiresAt:z(K([V,$S]).annotate({description:"Optional RFC3339 timestamp. Omit or send `null` for no automatic expiry.",examples:[`2026-08-17T12:00:00Z`],format:`date-time`})),resourceMode:z(jT),resourceGrants:z(G(mE).annotate({description:"Existing tenant resources granted when `resourceMode` is `allowlist`; must be empty for `all`."}).check(PC().annotate({expected:`an array with unique items`})))})],{mode:`oneOf`}).annotate({description:`Token definition accepted by the system administrator token endpoint.`,identifier:`CreateAdminTokenInput`}),W({name:V.annotate({description:`Operator-assigned name. Leading and trailing whitespace is removed.`,examples:[`browser worker`]}).check(OC(1).annotate({expected:`a value with a length of at least 1`})).check(vC(RegExp(`.*\\S.*`,`u`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),scopes:G(LT).annotate({description:"Tenant-compatible scopes. `system:admin` and `tenants:write` are rejected.",examples:[[`sessions:read`,`sessions:write`]]}).check(OC(1).annotate({expected:`a value with a length of at least 1`})).check(PC().annotate({expected:`an array with unique items`})),expiresAt:z(K([V,$S]).annotate({description:"Optional RFC3339 timestamp. Omit or send `null` for no automatic expiry.",examples:[`2026-08-17T12:00:00Z`],format:`date-time`})),resourceMode:z(jT),resourceGrants:z(G(mE).annotate({description:"Existing tenant resources granted when `resourceMode` is `allowlist`; must be empty for `all`."}).check(PC().annotate({expected:`an array with unique items`})))}).annotate({description:`Token definition automatically bound to the authenticated tenant.`,identifier:`CreateTenantTokenInput`}),K([hE,oE],{mode:`oneOf`}).annotate({description:`Failure of a live-session route.`,identifier:`LiveSessionFailure`});var WE=W({mode:q([`auto`,`cdp`]).annotate({description:"Configured media mode. `auto` enables deployment-selected media support; `cdp` exposes Chrome DevTools access only.",examples:[`auto`]}),webrtcProducer:U.annotate({description:`Whether the compositor WebRTC producer is available for this session.`,examples:[!0]}),iceServers:z(G(vE).annotate({description:`ICE configuration for WebRTC setup. Omitted when WebRTC is unavailable or does not need configured ICE servers.`}))}).annotate({description:`Media capabilities currently available for the session.`,identifier:`SessionMedia`}),GE=W({origin:V.annotate({format:`uri`}).check(vC(RegExp(`^https?:\\/\\/[^/]+$`,`u`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/[^/]+$`})),entries:G(xE)}).annotate({identifier:`InitialTargetStorageOrigin`}),KE=W({upstreams:z(nC(V,wE).annotate({description:"Upstreams by name. Names use lowercase letters, digits and dashes; `direct`, `refuse` and `local` are reserved."})),rules:z(G(HT).check(AC(256).annotate({expected:`a value with a length of at most 256`}))),upstream:z(q([`direct`,`proxy`,`tunnel`]).annotate({description:"Legacy single-upstream shape; use `upstreams` and `rules`. Cannot be combined with them. `proxy` becomes a final `*` rule via `url`, `tunnel` a `tunnel` upstream and a final `*` rule via it, each preceded by `direct` rules for the `bypass` entries. `direct` or omitted means no rules.",examples:[`tunnel`]})),url:z(V.annotate({description:"Legacy upstream proxy URL, required with `upstream` `proxy`. Use `upstreams` and `rules`.",examples:[`socks5://user:pass@proxy.example.com:1080`]})),tunnel:z(TE),bypass:z(V.annotate({description:"Legacy hosts to send direct, separated by `;` or `,`. Each entry must be a valid rule `match`; a leading `.` means any subdomain. CIDR ranges, `<local>` and scheme prefixes are rejected. Use `upstreams` and `rules`.",examples:[`*.internal.example.com`]}))}).annotate({description:"Session egress proxy configuration. Rules are checked in order and the first match routes the connection; unmatched connections go direct, and unmatched `localhost` stays on the session host. Omitted for direct egress.",identifier:`ProxyConfig`}),qE=W({upstreams:z(nC(V,wE)),rules:z(G(HT).check(AC(256).annotate({expected:`a value with a length of at most 256`}))),upstream:z(q([`direct`,`proxy`,`tunnel`]).annotate({description:"Legacy single-upstream shape; use `upstreams` and `rules`."})),url:z(V.annotate({description:"Legacy upstream proxy URL; use `upstreams` and `rules`."})),tunnel:z(TE),bypass:z(V.annotate({description:"Legacy hosts to send direct; use `upstreams` and `rules`."})),drain:z(U.annotate({description:`Reset live tunnel streams instead of letting them drain. New connections use the new rules either way.`,examples:[!1]}))}).annotate({description:"Replacement session egress proxy configuration. Fields other than `drain` are as in `ProxyConfig`.",identifier:`UpdateProxyConfig`}),JE=W({name:V,entries:G(EE)}).annotate({identifier:`InitialCacheStorageCache`}),YE=W({locator:OE,value:RT,checked:z(U),selectedIndices:z(G(H.check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})))),selection:z(KT)}).annotate({identifier:`InitialBrowserControlState`}),XE=W({locator:OE,html:RT}).annotate({identifier:`InitialBrowserContentEditableState`}),ZE=W({locator:OE,x:H.check(yC().annotate({expected:`a finite number`})),y:H.check(yC().annotate({expected:`a finite number`}))}).annotate({identifier:`InitialBrowserElementScrollPosition`}),QE=W({locator:OE,nodePath:G(H.check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))).check(AC(256).annotate({expected:`a value with a length of at most 256`})),offset:H.check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))}).annotate({identifier:`InitialBrowserSelectionEndpoint`}),$E=W({name:V,keyPath:YT,autoIncrement:U,indexes:G(AE),records:G(SE)}).annotate({identifier:`InitialIndexedDBObjectStore`});W({target:ME,zoom:H.check(yC().annotate({expected:`a finite number`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})).check(EC(4).annotate({expected:`a value less than or equal to 4`})),durationMs:z(H.annotate({description:`Zoom out after this many milliseconds; at least 200. Zero or omitted keeps the focus until reset-focus.`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})).check(EC(1e4).annotate({expected:`a value less than or equal to 10000`})))}).annotate({identifier:`RecordingFocusInput`});var eD=W({snapshot:zE}).annotate({description:`Snapshot returned after a mutation.`,identifier:`SnapshotMutation`}),tD=W({data:G(zE),meta:FT}).annotate({description:`Cursor-paginated snapshots.`,identifier:`SnapshotPage`}),nD=W({principal:HE,personalTenant:K([IE,$S],{mode:`oneOf`}).annotate({description:"The signed-in user's personal tenant, or `null` when they cannot manage one (API tokens, OAuth clients, and users without one while `allow_personal_tenants` is off)."}),selectedTenant:K([cE,$S],{mode:`oneOf`}).annotate({description:"Effective tenant, or `null` when the principal has not selected one."}),availableTenants:G(cE).annotate({description:`Active tenant memberships available to an account-backed principal. API-token principals return an empty array.`}),settings:W({allowPersonalTenants:U.annotate({description:"Whether personal tenants can be created (`allow_personal_tenants`)."}),autoCreatePersonalTenant:U.annotate({description:"Whether new users get a personal tenant by default (`auto_create_personal_tenant`)."})}).annotate({description:`Server settings relevant to the signed-in principal.`})}).annotate({description:`Current principal and its effective tenant selection.`,identifier:`AuthMe`}),rD=W({data:G(UE),meta:FT}).annotate({description:`Cursor-paginated API token metadata without bearer secrets.`,identifier:`TokenPage`}),iD=W({token:UE,rawToken:cC(()=>RT).annotate({description:`One-time Aperture API bearer token. Store it immediately; later reads return only token metadata.`,examples:[`apt_019f6cf0000070008000000000000002_REDACTED`]})}).annotate({description:`Created token metadata and its one-time bearer secret.`,identifier:`CreateTokenResponse`}),aD=W({id:cC(()=>Q).annotate({description:`Session identifier.`}),tenantId:cC(()=>Q).annotate({description:`Tenant that owns the session.`}),baseSnapshotName:z(V.annotate({description:`Snapshot name used as the session base. Omitted for a blank session.`,examples:[`signed-in-base`]})),label:z(V.annotate({description:`Optional operator-facing session label.`,examples:[`checkout smoke test`]})),status:zT,browserChannel:z(V.annotate({description:`Browser channel used to create and reopen the session.`,examples:[`chromium`]})),media:WE,createdAt:V.annotate({description:`Time the session record was created.`,examples:[`2026-07-17T12:00:00Z`],format:`date-time`}),startedAt:z(V.annotate({description:`Most recent successful browser start time. Omitted before startup succeeds.`,examples:[`2026-07-17T12:00:03Z`],format:`date-time`})),stoppedAt:z(V.annotate({description:`Most recent browser stop time. Omitted while no stop has occurred.`,examples:[`2026-07-17T13:00:00Z`],format:`date-time`})),deletedAt:z(K([V,$S]).annotate({description:"Soft-deletion time, or `null` for a session that has not been deleted.",examples:[null],format:`date-time`})),expiresAt:V.annotate({description:`Retention deadline after which the session and its overlay may be purged. This is not token expiry.`,examples:[`2026-07-24T12:00:00Z`],format:`date-time`}),lastConnectedAt:z(V.annotate({description:`Most recent routed client activity time. Omitted until a client connects.`,examples:[`2026-07-17T12:30:00Z`],format:`date-time`})),suspendedAt:z(V.annotate({description:`Most recent suspension time. Omitted unless the session is suspended.`,examples:[`2026-07-17T13:00:00Z`],format:`date-time`})),tags:z(cC(()=>BT).annotate({description:`Session metadata tags. Omitted when no tags are set.`})),cdpUrl:z(V.annotate({description:"Authenticated Chrome DevTools endpoint. Omitted when the session is not currently routable. Use it with `sessionToken`.",examples:[`https://aperture.example.com/cdp/019f6cf0-0000-7000-8000-000000000010`],format:`uri`})),sessionToken:z(cC(()=>RT).annotate({description:`Session access secret returned when live access credentials are available. Rotation invalidates the previous token immediately.`,examples:[`aps_019f6cf0000070008000000000000010_REDACTED`]})),collaboration:z(yE),thumbnail:z(bE),proxy:z(DE)}).annotate({description:`Browser session state, retention metadata, tags, and currently available access credentials.`,identifier:`Session`}),oD=W({sessionId:Q,status:q([`running`,`suspended`]).annotate({description:`Session lifecycle state.`}),source:q([`live`,`persisted`,`unavailable`]).annotate({description:"- `live`: the running browser's current pages.\n- `persisted`: the pages saved when the session suspended.\n- `unavailable`: a suspended session with no saved pages for its last run.\n"}),capturedAt:z(V.annotate({description:"When the page list was read or saved. Absent when `source` is `unavailable`.",format:`date-time`})),representativeTargetId:z(V.annotate({description:`The page the session thumbnail shows, the one most recently shown to a live-session client while it is ready, else the first selectable page. Absent when there is none.`})),pages:G(FE).annotate({description:`Top-level pages in the order the live session shows them.`}),thumbnailAvailable:U.annotate({description:`Whether the session thumbnail route can serve an image.`}),cdpUrl:V.annotate({description:`The session's CDP endpoint base URL, without the session token.`}),media:WE}).annotate({description:`Passive page metadata of a running or suspended session.`,identifier:`SessionBrowserStatus`}),sD=W({anchor:QE,focus:QE}).annotate({identifier:`InitialBrowserDocumentSelection`}),cD=W({name:V,version:H.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),objectStores:G($E)}).annotate({identifier:`InitialIndexedDBDatabase`}),lD=W({data:G(aD),meta:FT}).annotate({description:`Cursor-paginated browser sessions.`,identifier:`SessionPage`}),uD=W({session:aD,cdpUrl:V.annotate({description:`Authenticated Chrome DevTools endpoint for the new session.`,examples:[`https://aperture.example.com/cdp/019f6cf0-0000-7000-8000-000000000010`],format:`uri`}),sessionToken:cC(()=>RT).annotate({description:`Initial session access secret. Store it immediately.`,examples:[`aps_019f6cf0000070008000000000000010_REDACTED`]})}).annotate({description:`Newly created session and its one-time initial access credentials.`,identifier:`CreateSessionResult`}),dD=W({sessions:G(aD)}).annotate({description:`Sessions found for the requested IDs, preserving request order.`,identifier:`SessionBulkResponse`}),fD=W({session:aD,cdpUrl:z(V.annotate({description:`Current Chrome DevTools endpoint. Omitted by operations that do not expose live access.`,examples:[`https://aperture.example.com/cdp/019f6cf0-0000-7000-8000-000000000010`],format:`uri`})),sessionToken:z(cC(()=>RT).annotate({description:`Current raw session access secret. Omitted by operations that do not expose or replace credentials.`,examples:[`aps_019f6cf0000070008000000000000010_REDACTED`]}))}).annotate({description:`Updated session and operation-specific live access credentials when available.`,identifier:`SessionMutation`}),pD=W({version:B(1),windowName:z(RT),historyState:z(cC(()=>RT).annotate({description:`JSON-encoded structured-clone history state.`})),controls:G(YE).check(AC(1e4).annotate({expected:`a value with a length of at most 10000`})),contentEditables:G(XE).check(AC(1e4).annotate({expected:`a value with a length of at most 10000`})),scrollPositions:G(ZE).check(AC(1e4).annotate({expected:`a value with a length of at most 10000`})),focus:z(OE),selection:z(sD)}).annotate({description:`Sensitive top-document state replayed during initial navigation.`,identifier:`InitialBrowserDocumentState`}),mD=W({origin:V.annotate({examples:[`https://example.com`],format:`uri`}).check(vC(RegExp(`^https?:\\/\\/[^/]+$`,`u`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/[^/]+$`})),ancestorOrigins:z(G(V.annotate({format:`uri`}).check(vC(RegExp(`^https?:\\/\\/[^/]+$`,`u`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/[^/]+$`}))).annotate({description:`Top-down HTTP origin chain for partitioned storage. Omitted for a top-level origin.`}).check(AC(32).annotate({expected:`a value with a length of at most 32`}))),localStorage:G(xE),indexedDB:z(G(cD)),cacheStorage:z(G(JE)),opfs:z(G(CE))}).annotate({description:`Profile-scoped browser storage imported for one exact HTTP origin and ancestor partition.`,identifier:`InitialStorageOrigin`}),hD=W({url:V.annotate({description:`Absolute HTTP or HTTPS URL without embedded credentials.`,examples:[`https://example.com/account`],format:`uri`}).check(vC(RegExp(`^https?:\\/\\/`,`u`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/`})),sessionStorage:z(G(GE).annotate({description:`Per-origin session storage installed in target frames before page scripts execute.`})),scroll:z(WT),documentState:z(pD),openerTargetIndex:z(H.annotate({description:`Index of another initial target that opened this target.`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),active:z(U.annotate({description:`Select this target for the first connected session client. At most one target may be active.`,default:!1}))}).annotate({description:`HTTP page and target-scoped state opened during session creation.`,identifier:`InitialBrowserTarget`}),gD=W({cookies:G(kE).check(AC(1e4).annotate({expected:`a value with a length of at most 10000`})),origins:G(mD).check(AC(100).annotate({expected:`a value with a length of at most 100`}))}).annotate({description:`Profile-scoped browser storage imported before initial browser targets are opened.`,identifier:`InitialBrowserStorageState`}),_D=W({baseSnapshotName:z(K([V,$S]).annotate({description:"Active snapshot used as the browser filesystem base. Omit, send `null`, or send an empty value for a blank session.",examples:[`signed-in-base`]})),label:z(K([V,$S]).annotate({description:`Optional operator-facing label for the session.`,examples:[`checkout smoke test`]})),browser:UT,initialTargets:z(G(hD).annotate({description:`Browser targets that replace the browser's startup page after storage import. Result order follows input order; opener dependencies may be created first.`}).check(AC(50).annotate({expected:`a value with a length of at most 50`}))),storageState:z(gD),tags:z(cC(()=>BT).annotate({description:`Initial session tags.`})),proxy:z(KE)}).annotate({description:`Configuration for a new retained browser session.`,examples:[{baseSnapshotName:`signed-in-base`,label:`checkout smoke test`,browser:{channel:`chromium`,args:[`--lang=en-US`]},initialTargets:[{url:`https://example.com/account`}],storageState:{cookies:[],origins:[{origin:`https://example.com`,localStorage:[{name:`access-token`,value:`REDACTED`}]}]},tags:{environment:`staging`,suite:`checkout`}}],identifier:`CreateSessionInput`}),vD=DT;W({"X-Aperture-Tenant-Id":z(Q)});var yD=nD,bD=cE,xD=cE,SD=gE;W({limit:z(H.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:z(V),deleted:z(q([`active`,`deleted`,`all`]).annotate({default:`active`})),includeDeleted:z(U.annotate({default:!1})),query:z(V)});var CD=LE,wD=cE,TD=cE,ED=cE,DD=cE;W({limit:z(H.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:z(V),query:z(V),disabled:z(q([`active`,`disabled`,`all`]).annotate({default:`active`}))});var OD=RE,kD=lE,AD=lE,jD=lE,MD=lE,ND=lE,PD=hE,FD=hE,ID=IT,LD=G(_E),RD=G(_E),zD=_E,BD=hE;W({limit:z(H.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:z(V),tenantId:z(Q),actorType:z(OT),actorId:z(V),action:z(V),resourceType:z(V),resourceId:z(V)});var VD=VE;W({limit:z(H.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:z(V),authorityType:z(kT),tenantId:z(Q),name:z(V),scope:z(AT),revoked:z(q([`active`,`revoked`,`all`]).annotate({default:`all`}))});var HD=rD,UD=iD,WD=hE,GD=cE,KD=cE;W({limit:z(H.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:z(V),name:z(V),scope:z(AT),revoked:z(q([`active`,`revoked`,`all`]).annotate({default:`all`}))});var qD=rD,JD=iD,YD=hE;W({"X-Aperture-Tenant-Id":z(Q),limit:z(H.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:z(V),includeDeleted:z(U.annotate({default:!1})),status:z(zT),query:z(V),tagKey:z(G(V.check(OC(1).annotate({expected:`a value with a length of at least 1`})))),tagValue:z(G(V.check(OC(1).annotate({expected:`a value with a length of at least 1`})))),tagOperator:z(G(q([`eq`,`neq`,`in`,`not_in`])))});var XD=lD;W({"X-Aperture-Tenant-Id":z(Q),waitForReady:z(U.annotate({default:!0}))});var ZD=_D,QD=uD;W({"X-Aperture-Tenant-Id":z(Q)});var $D=dD;W({"X-Aperture-Tenant-Id":z(Q)});var eO=aD;W({"X-Aperture-Tenant-Id":z(Q)});var tO=fD;W({"X-Aperture-Tenant-Id":z(Q)});var nO=fD;W({"X-Aperture-Tenant-Id":z(Q)});var rO=qE,iO=fD;W({"X-Aperture-Tenant-Id":z(Q)});var aO=fD;W({"X-Aperture-Tenant-Id":z(Q)});var oO=fD;W({"X-Aperture-Tenant-Id":z(Q)});var sO=fD;W({"X-Aperture-Tenant-Id":z(Q)});var cO=fD;W({"X-Aperture-Tenant-Id":z(Q)});var lO=ZT;W({"X-Aperture-Tenant-Id":z(Q)});var uO=ZT;W({"X-Aperture-Tenant-Id":z(Q)});var dO=hE;W({"X-Aperture-Tenant-Id":z(Q)});var fO=hE;W({"X-Aperture-Tenant-Id":z(Q)});var pO=gD;W({"X-Aperture-Tenant-Id":z(Q)});var mO=G(jE);W({"X-Aperture-Tenant-Id":z(Q)});var hO=jE;W({"X-Aperture-Tenant-Id":z(Q)});var gO=jE;W({"X-Aperture-Tenant-Id":z(Q)});var _O=jE;W({"X-Aperture-Tenant-Id":z(Q)});var vO=hE;W({"X-Aperture-Tenant-Id":z(Q)});var yO=hE;W({"X-Aperture-Tenant-Id":z(Q)});var bO=hE;W({"X-Aperture-Tenant-Id":z(Q)});var xO=hE;W({"X-Aperture-Tenant-Id":z(Q)});var SO=jE;W({"X-Aperture-Tenant-Id":z(Q)});var CO=G(NE);W({"X-Aperture-Tenant-Id":z(Q),directory:z(V.annotate({default:`uploads`}))}),W({files:z(G(iE))});var wO=W({files:G(nE)}).annotate({description:`Files stored by this request, in request order.`});W({"X-Aperture-Tenant-Id":z(Q),relativePath:V.check(OC(1).annotate({expected:`a value with a length of at least 1`})),recursive:z(U.annotate({default:!1}))});var TO=hE;W({"X-Aperture-Tenant-Id":z(Q)});var EO=NE;W({"X-Aperture-Tenant-Id":z(Q)});var DO=rE;W({"X-Aperture-Tenant-Id":z(Q)});var OO=aE;W({"X-Aperture-Tenant-Id":z(Q)});var kO=eD;W({"X-Aperture-Tenant-Id":z(Q),limit:z(H.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:z(V),name:z(V),deleted:z(q([`active`,`deleted`,`all`]).annotate({default:`active`})),includeDeleted:z(U.annotate({default:!1})),tagKey:z(G(V.check(OC(1).annotate({expected:`a value with a length of at least 1`})))),tagValue:z(G(V.check(OC(1).annotate({expected:`a value with a length of at least 1`})))),tagOperator:z(G(q([`eq`,`neq`,`in`,`not_in`])))});var AO=tD;W({"X-Aperture-Tenant-Id":z(Q)});var jO=eD;W({"X-Aperture-Tenant-Id":z(Q)});var MO=eD;W({"X-Aperture-Tenant-Id":z(Q)});var NO=eD;W({"X-Aperture-Tenant-Id":z(Q)});var PO=eD;W({"X-Aperture-Tenant-Id":z(Q),limit:z(H.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:z(V),resourceType:z(V),resourceId:z(V)});var FO=BE;W({"X-Aperture-Tenant-Id":z(Q)}),W({files:z(G(iE))});var IO=W({files:G(nE)}).annotate({description:`Files stored by this request, in request order.`});W({"X-Aperture-Tenant-Id":z(Q)});var LO=PE;W({"X-Aperture-Tenant-Id":z(Q)});var RO=oD,zO=(e,t={})=>{let n=e=>L(If(e.json,()=>`Unexpected status code`),t=>I(new gw({reason:new xw({request:e.request,response:e,description:typeof t==`string`?t:JSON.stringify(t)})}))),r=n=>r=>{let i=n?.includeResponse?e=>Tf(r(e),t=>[t,e]):e=>r(e);return t?.transformClient?n=>L(L(t.transformClient(e),e=>e.execute(n)),i):t=>L(e.execute(t),i)},i=encodeURIComponent,a=(e,t,n)=>uf(()=>{let r=(t,n)=>I(new gw({reason:new bw({request:e(``),cause:n,description:t})}));if(t.some(e=>e===``||/^(?:\.|%2e){1,2}$/i.test(e)))return r(`Path parameters must be non-empty and cannot be dot segments`);let i;try{i=n()}catch(e){return r(`Failed to encode path parameter`,e)}return i.split(`/`).some(e=>/^(?:\.|%2e){1,2}$/i.test(e))?r(`Request paths cannot contain dot segments`):P(e(i))}),o=n=>uf(()=>t.transformClient?L(t.transformClient(e),e=>pT(e).execute(n)):pT(e).execute(n)),s=e=>Tf(e.arrayBuffer,e=>new Uint8Array(e)),c=e=>o(e).pipe(Tf(e=>e.stream),dg),l=e=>t=>rT(e)(t);return{httpClient:e,getHealth:e=>Pw(`/api/health`).pipe(r(e?.config)(Z({"2xx":l(vD),orElse:n}))),getCurrentPrincipal:e=>Pw(`/api/auth/me`).pipe(X({"X-Aperture-Tenant-Id":e?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(e?.config)(Z({"2xx":l(yD),orElse:n}))),createOwnPersonalTenant:e=>Fw(`/api/auth/personal-tenant`).pipe(r(e?.config)(Z({"2xx":l(bD),orElse:n}))),deleteOwnPersonalTenant:e=>Rw(`/api/auth/personal-tenant`).pipe(r(e?.config)(Z({"2xx":l(xD),orElse:n}))),listBrowserChannels:e=>Pw(`/api/browser/channels`).pipe(r(e?.config)(Z({"2xx":l(SD),orElse:n}))),listTenants:e=>Pw(`/api/admin/tenants`).pipe(Xw({limit:e?.params?.limit,cursor:e?.params?.cursor,deleted:e?.params?.deleted,includeDeleted:e?.params?.includeDeleted,query:e?.params?.query}),r(e?.config)(Z({"2xx":l(CD),orElse:n}))),createTenant:e=>Fw(`/api/admin/tenants`).pipe($w(e.payload),r(e.config)(Z({"2xx":l(wD),orElse:n}))),deleteTenant:(e,t)=>a(Rw,[e],()=>`/api/admin/tenants/`+i(e)).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(TD),orElse:n}))))),updateTenant:(e,t)=>a(Iw,[e],()=>`/api/admin/tenants/`+i(e)).pipe(L(e=>e.pipe($w(t.payload),r(t.config)(Z({"2xx":l(ED),orElse:n}))))),restoreTenant:(e,t)=>a(Fw,[e],()=>`/api/admin/tenants/`+i(e)+`/restore`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(DD),orElse:n}))))),listUsers:e=>Pw(`/api/admin/users`).pipe(Xw({limit:e?.params?.limit,cursor:e?.params?.cursor,query:e?.params?.query,disabled:e?.params?.disabled}),r(e?.config)(Z({"2xx":l(OD),orElse:n}))),createUser:e=>Fw(`/api/admin/users`).pipe($w(e.payload),r(e.config)(Z({"2xx":l(kD),orElse:n}))),getUser:(e,t)=>a(Pw,[e],()=>`/api/admin/users/`+i(e)).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(AD),orElse:n}))))),disableUser:(e,t)=>a(Rw,[e],()=>`/api/admin/users/`+i(e)).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(jD),orElse:n}))))),updateUser:(e,t)=>a(Iw,[e],()=>`/api/admin/users/`+i(e)).pipe(L(e=>e.pipe($w(t.payload),r(t.config)(Z({"2xx":l(MD),orElse:n}))))),restoreUser:(e,t)=>a(Fw,[e],()=>`/api/admin/users/`+i(e)+`/restore`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(ND),orElse:n}))))),createPersonalTenant:(e,t)=>a(Fw,[e],()=>`/api/admin/users/`+i(e)+`/personal-tenant`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(PD),204:()=>df,orElse:n}))))),deletePersonalTenant:(e,t)=>a(Rw,[e],()=>`/api/admin/users/`+i(e)+`/personal-tenant`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(FD),204:()=>df,orElse:n}))))),createUserInvitation:(e,t)=>a(Fw,[e],()=>`/api/admin/users/`+i(e)+`/invitation`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(ID),orElse:n}))))),listUserMemberships:(e,t)=>a(Pw,[e],()=>`/api/admin/users/`+i(e)+`/memberships`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(LD),orElse:n}))))),listTenantMemberships:(e,t)=>a(Pw,[e],()=>`/api/admin/tenants/`+i(e)+`/memberships`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(RD),orElse:n}))))),upsertTenantMembership:(e,t,o)=>a(Lw,[e,t],()=>`/api/admin/tenants/`+i(e)+`/memberships/`+i(t)).pipe(L(e=>e.pipe($w(o.payload),r(o.config)(Z({"2xx":l(zD),orElse:n}))))),deleteTenantMembership:(e,t,o)=>a(Rw,[e,t],()=>`/api/admin/tenants/`+i(e)+`/memberships/`+i(t)).pipe(L(e=>e.pipe(r(o?.config)(Z({"2xx":l(BD),204:()=>df,orElse:n}))))),listAuditEvents:e=>Pw(`/api/admin/audit-events`).pipe(Xw({limit:e?.params?.limit,cursor:e?.params?.cursor,tenantId:e?.params?.tenantId,actorType:e?.params?.actorType,actorId:e?.params?.actorId,action:e?.params?.action,resourceType:e?.params?.resourceType,resourceId:e?.params?.resourceId}),r(e?.config)(Z({"2xx":l(VD),orElse:n}))),listAdminTokens:e=>Pw(`/api/admin/tokens`).pipe(Xw({limit:e?.params?.limit,cursor:e?.params?.cursor,authorityType:e?.params?.authorityType,tenantId:e?.params?.tenantId,name:e?.params?.name,scope:e?.params?.scope,revoked:e?.params?.revoked}),r(e?.config)(Z({"2xx":l(HD),orElse:n}))),createAdminToken:e=>Fw(`/api/admin/tokens`).pipe($w(e.payload),r(e.config)(Z({"2xx":l(UD),orElse:n}))),revokeAdminToken:(e,t)=>a(Fw,[e],()=>`/api/admin/tokens/`+i(e)+`/revoke`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(WD),204:()=>df,orElse:n}))))),getTenant:e=>Pw(`/api/tenant`).pipe(r(e?.config)(Z({"2xx":l(GD),orElse:n}))),updateSelectedTenant:e=>Iw(`/api/tenant`).pipe($w(e.payload),r(e.config)(Z({"2xx":l(KD),orElse:n}))),listTenantTokens:e=>Pw(`/api/tenant/tokens`).pipe(Xw({limit:e?.params?.limit,cursor:e?.params?.cursor,name:e?.params?.name,scope:e?.params?.scope,revoked:e?.params?.revoked}),r(e?.config)(Z({"2xx":l(qD),orElse:n}))),createTenantToken:e=>Fw(`/api/tenant/tokens`).pipe($w(e.payload),r(e.config)(Z({"2xx":l(JD),orElse:n}))),revokeTenantToken:(e,t)=>a(Fw,[e],()=>`/api/tenant/tokens/`+i(e)+`/revoke`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(YD),204:()=>df,orElse:n}))))),listSessions:e=>Pw(`/api/sessions`).pipe(Xw({limit:e?.params?.limit,cursor:e?.params?.cursor,includeDeleted:e?.params?.includeDeleted,status:e?.params?.status,query:e?.params?.query,tagKey:e?.params?.tagKey,tagValue:e?.params?.tagValue,tagOperator:e?.params?.tagOperator}),X({"X-Aperture-Tenant-Id":e?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(e?.config)(Z({"2xx":l(XD),orElse:n}))),createSession:e=>Fw(`/api/sessions`).pipe(Xw({waitForReady:e.params?.waitForReady}),X({"X-Aperture-Tenant-Id":e.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(e.payload),r(e.config)(Z({"2xx":l(QD),orElse:n}))),getSessionsBulk:e=>Fw(`/api/sessions/bulk`).pipe(X({"X-Aperture-Tenant-Id":e.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(e.payload),r(e.config)(Z({"2xx":l($D),orElse:n}))),getSession:(e,t)=>a(Pw,[e],()=>`/api/sessions/`+i(e)).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(eO),orElse:n}))))),deleteSession:(e,t)=>a(Rw,[e],()=>`/api/sessions/`+i(e)).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(tO),orElse:n}))))),replaceSessionTags:(e,t)=>a(Lw,[e],()=>`/api/sessions/`+i(e)+`/tags`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(t.payload),r(t.config)(Z({"2xx":l(nO),orElse:n}))))),updateSessionProxy:(e,t)=>a(Lw,[e],()=>`/api/sessions/`+i(e)+`/proxy`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(t.payload),r(t.config)(Z({"2xx":l(iO),orElse:n}))))),suspendSession:(e,t)=>a(Fw,[e],()=>`/api/sessions/`+i(e)+`/suspend`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(aO),orElse:n}))))),reopenSession:(e,t)=>a(Fw,[e],()=>`/api/sessions/`+i(e)+`/reopen`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(oO),orElse:n}))))),rotateSessionToken:(e,t)=>a(Fw,[e],()=>`/api/sessions/`+i(e)+`/session-token/rotate`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(sO),orElse:n}))))),rotateCollaborationCapability:(e,t,o)=>a(Fw,[e,t],()=>`/api/sessions/`+i(e)+`/collaboration-capabilities/`+i(t)+`/rotate`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(o?.config)(Z({"2xx":l(cO),orElse:n}))))),getSessionCursor:(e,t)=>a(Pw,[e],()=>`/api/sessions/`+i(e)+`/cursor`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(lO),orElse:n}))))),setSessionCursor:(e,t)=>a(Lw,[e],()=>`/api/sessions/`+i(e)+`/cursor`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(t.payload),r(t.config)(Z({"2xx":l(uO),orElse:n}))))),getSessionThumbnail:(e,t)=>a(Pw,[e],()=>`/api/sessions/`+i(e)+`/thumbnail`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(dO),200:s,orElse:n}))))),getSessionThumbnailStream:(e,t)=>dg(a(Pw,[e],()=>`/api/sessions/`+i(e)+`/thumbnail`).pipe(Tf(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),c)))),getSessionTargetThumbnail:(e,t,o)=>a(Pw,[e,t],()=>`/api/sessions/`+i(e)+`/targets/`+i(t)+`/thumbnail`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(o?.config)(Z({"2xx":l(fO),200:s,orElse:n}))))),getSessionTargetThumbnailStream:(e,t,n)=>dg(a(Pw,[e,t],()=>`/api/sessions/`+i(e)+`/targets/`+i(t)+`/thumbnail`).pipe(Tf(e=>e.pipe(X({"X-Aperture-Tenant-Id":n?.params?.[`X-Aperture-Tenant-Id`]??void 0}),c)))),exportSessionStorageState:(e,t)=>a(Fw,[e],()=>`/api/sessions/`+i(e)+`/storage-state`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(t.payload),r(t.config)(Z({"2xx":l(pO),orElse:n}))))),listSessionRecordings:(e,t)=>a(Pw,[e],()=>`/api/sessions/`+i(e)+`/recordings`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(mO),orElse:n}))))),createSessionRecording:(e,t)=>a(Fw,[e],()=>`/api/sessions/`+i(e)+`/recordings`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(t.payload),r(t.config)(Z({"2xx":l(hO),orElse:n}))))),getSessionRecording:(e,t,o)=>a(Pw,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(o?.config)(Z({"2xx":l(gO),orElse:n}))))),retargetSessionRecording:(e,t,o)=>a(Fw,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)+`/retarget`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(o.payload),r(o.config)(Z({"2xx":l(_O),orElse:n}))))),captionSessionRecording:(e,t,o)=>a(Fw,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)+`/caption`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(o.payload),r(o.config)(Z({"2xx":l(vO),204:()=>df,orElse:n}))))),focusSessionRecording:(e,t,o)=>a(Fw,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)+`/focus`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(o.payload),r(o.config)(Z({"2xx":l(yO),204:()=>df,orElse:n}))))),resetFocusSessionRecording:(e,t,o)=>a(Fw,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)+`/reset-focus`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(o?.config)(Z({"2xx":l(bO),204:()=>df,orElse:n}))))),attentionSessionRecording:(e,t,o)=>a(Fw,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)+`/attention`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(o.payload),r(o.config)(Z({"2xx":l(xO),204:()=>df,orElse:n}))))),stopSessionRecording:(e,t,o)=>a(Fw,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)+`/stop`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(o?.config)(Z({"2xx":l(SO),orElse:n}))))),listSessionFiles:(e,t)=>a(Pw,[e],()=>`/api/sessions/`+i(e)+`/files`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(CO),orElse:n}))))),uploadSessionFiles:(e,t)=>a(Fw,[e],()=>`/api/sessions/`+i(e)+`/files`).pipe(L(e=>e.pipe(Xw({directory:t.params?.directory}),X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),eT(t.payload),r(t.config)(Z({"2xx":l(wO),orElse:n}))))),deleteSessionFile:(e,t)=>a(Rw,[e],()=>`/api/sessions/`+i(e)+`/files`).pipe(L(e=>e.pipe(Xw({relativePath:t.params.relativePath,recursive:t.params.recursive}),X({"X-Aperture-Tenant-Id":t.params[`X-Aperture-Tenant-Id`]??void 0}),r(t.config)(Z({"2xx":l(TO),204:()=>df,orElse:n}))))),moveSessionFile:(e,t)=>a(Fw,[e],()=>`/api/sessions/`+i(e)+`/files/move`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(t.payload),r(t.config)(Z({"2xx":l(EO),orElse:n}))))),createSessionDirectory:(e,t)=>a(Fw,[e],()=>`/api/sessions/`+i(e)+`/files/directories`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(t.payload),r(t.config)(Z({"2xx":l(DO),orElse:n}))))),createSessionFileDownloadURL:(e,t)=>a(Fw,[e],()=>`/api/sessions/`+i(e)+`/files/download-url`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(t.payload),r(t.config)(Z({"2xx":l(OO),orElse:n}))))),promoteSession:(e,t)=>a(Fw,[e],()=>`/api/sessions/`+i(e)+`/promote`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(t.payload),r(t.config)(Z({"2xx":l(kO),orElse:n}))))),listSnapshots:e=>Pw(`/api/snapshots`).pipe(Xw({limit:e?.params?.limit,cursor:e?.params?.cursor,name:e?.params?.name,deleted:e?.params?.deleted,includeDeleted:e?.params?.includeDeleted,tagKey:e?.params?.tagKey,tagValue:e?.params?.tagValue,tagOperator:e?.params?.tagOperator}),X({"X-Aperture-Tenant-Id":e?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(e?.config)(Z({"2xx":l(AO),orElse:n}))),deleteSnapshot:(e,t)=>a(Rw,[e],()=>`/api/snapshots/`+i(e)).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(jO),orElse:n}))))),updateSnapshot:(e,t)=>a(Iw,[e],()=>`/api/snapshots/`+i(e)).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(t.payload),r(t.config)(Z({"2xx":l(MO),orElse:n}))))),replaceSnapshotTags:(e,t)=>a(Lw,[e],()=>`/api/snapshots/`+i(e)+`/tags`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(t.payload),r(t.config)(Z({"2xx":l(NO),orElse:n}))))),restoreSnapshot:(e,t)=>a(Fw,[e],()=>`/api/snapshots/`+i(e)+`/restore`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(PO),orElse:n}))))),listEvents:e=>Pw(`/api/events`).pipe(Xw({limit:e?.params?.limit,cursor:e?.params?.cursor,resourceType:e?.params?.resourceType,resourceId:e?.params?.resourceId}),X({"X-Aperture-Tenant-Id":e?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(e?.config)(Z({"2xx":l(FO),orElse:n}))),uploadLiveSessionFiles:(e,t)=>a(Fw,[e],()=>`/sessions/`+i(e)+`/uploads`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),eT(t.payload),r(t.config)(Z({"2xx":l(IO),orElse:n}))))),setSessionViewport:(e,t)=>a(Fw,[e],()=>`/sessions/`+i(e)+`/browser/viewport`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),$w(t.payload),r(t.config)(Z({"2xx":l(LO),orElse:n}))))),getSessionBrowserStatus:(e,t)=>a(Pw,[e],()=>`/sessions/`+i(e)+`/browser/status`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(RO),orElse:n})))))}},BO=`X-Aperture-Tenant-Id`,VO={kind:`session`,authorityType:null,tenantId:null,selectedTenantId:null};function HO(e,t){if(t!==`none`){if(t===`optional`)return e.selectedTenantId??void 0;if(e.authorityType===`tenant`)return e.kind===`bearer`?e.selectedTenantId??void 0:e.tenantId??void 0;if(e.authorityType===`system_admin`)return e.selectedTenantId??void 0}}var UO={anonymous:{},webSession:{credentials:VO},of:e=>({credentials:e}),tenantScoped:e=>({credentials:e,tenantHeader:`tenant-scoped`})},WO=class extends vr()(`@aperture-browser/api-client/ApiAuthorization`){},GO=q([`ble`,`cable`,`hybrid`,`internal`,`nfc`,`smart-card`,`usb`]),KO=W({id:V,type:B(`public-key`),transports:z(iC(G(GO)))}),qO=z(W({appid:z(V),credProps:z(U),hmacCreateSecret:z(U),minPinLength:z(U)})),JO=q([`hybrid`,`security-key`,`client-device`]),YO=q([`discouraged`,`preferred`,`required`]),XO=W({methods:G(K([W({type:B(`password`)}),W({type:B(`api_token`)}),W({type:B(`passkey`)}),W({type:B(`oidc`),id:V,name:V,loginUrl:V})]))}),ZO=W({publicKey:W({challenge:V,timeout:z(H),rpId:z(V),allowCredentials:z(iC(G(KO))),userVerification:z(YO),hints:z(iC(G(JO))),extensions:qO})}),QO=W({publicKey:W({rp:W({id:z(V),name:V}),user:W({id:V,name:V,displayName:V}),challenge:V,pubKeyCredParams:iC(G(W({alg:q([-7,-8,-35,-36,-37,-38,-39,-257,-258,-259]),type:B(`public-key`)}))),timeout:z(H),excludeCredentials:z(iC(G(KO))),authenticatorSelection:z(W({authenticatorAttachment:z(q([`platform`,`cross-platform`])),requireResidentKey:z(U),residentKey:z(q([`discouraged`,`preferred`,`required`])),userVerification:z(YO)})),hints:z(iC(G(JO))),attestation:z(q([`direct`,`enterprise`,`indirect`,`none`])),attestationFormats:z(iC(G(q([`fido-u2f`,`packed`,`android-safetynet`,`android-key`,`tpm`,`apple`,`none`])))),extensions:qO})}),$O=W({id:V,name:V,createdAt:V,lastUsedAt:oC(V)}),ek=W({passkeys:G($O)}),tk=W({passkey:$O}),nk=W({mfaRequired:U}),rk=W({hasPassword:U,totpEnabled:U,recoveryCodesRemaining:H.check(Y(),J(0))}),ik=W({secret:V,otpauthUrl:V,qrCodeDataUrl:V}),ak=W({recoveryCodes:G(V)}),ok=W({id:V,name:V,uri:oC(V),logoUri:oC(V),kind:q([`registered`,`metadata_document`])}),sk=W({client:ok,redirectUri:V,requestedScopes:G(V),user:W({id:V,displayName:V,isSystemAdmin:U}),tenants:G(W({id:V,displayName:V,scopes:G(LT)})),availableScopes:G(LT),canGrantSystemAdmin:U}),ck=W({redirectUrl:V}),lk=W({grants:G(W({id:V,client:ok,authorityType:kT,tenants:G(W({id:V,displayName:V})),scopes:G(V),resourceMode:jT,resourceGrants:G(W({resourceType:MT,resourceId:V})),createdAt:V,lastUsedAt:oC(V)}))}),uk=class extends vr()(`@aperture-browser/api-client/AuthApi`){},dk=e=>({body:cw(e)}),fk=dd(uk,mf(function*(){let e=yield*dT,{authorize:t}=yield*WO,n=pT(e),r=zO(e),i=t(UO.anonymous),a=t(UO.webSession),o=R(`AuthApi.listLoginMethods`)(function*(){return yield*n.get(`/auth/login-methods`).pipe(L(rT(XO)),i)}),s=R(`AuthApi.loginWithPassword`)(function*(e,t){return yield*n.post(`/auth/password/login`,dk({email:e,password:t})).pipe(L(rT(nk)),i)}),c=R(`AuthApi.completePasswordMFA`)(function*(e){yield*n.post(`/auth/password/login/mfa`,dk({code:e})).pipe(i)}),l=R(`AuthApi.loginWithAPIToken`)(function*(e){yield*n.post(`/auth/token/login`,dk({token:e})).pipe(i)}),u=R(`AuthApi.beginPasskeyLogin`)(function*(){return yield*n.post(`/auth/passkeys/login/options`).pipe(L(rT(ZO)),i)}),d=R(`AuthApi.finishPasskeyLogin`)(function*(e){yield*n.post(`/auth/passkeys/login/finish`,dk(e)).pipe(i)}),f=R(`AuthApi.acceptUserInvitation`)(function*(e,t){yield*n.post(`/auth/invitations/accept`,dk({token:e,password:t})).pipe(i)}),p=R(`AuthApi.logoutWebSession`)(function*(){yield*n.post(`/auth/logout`).pipe(a)}),m=R(`AuthApi.getAuthMe`)(function*(e=null,n=VO){return yield*r.getCurrentPrincipal(void 0).pipe(t({credentials:{...n,selectedTenantId:e},tenantHeader:`optional`}))}),h=R(`AuthApi.getSecurityStatus`)(function*(){return yield*n.get(`/auth/security`).pipe(L(rT(rk)),a)}),g=R(`AuthApi.getTenantContext`)(function*(e=null){return yield*n.get(`/auth/tenant-context`).pipe(L(rT(nD)),t({credentials:{...VO,selectedTenantId:e},tenantHeader:`optional`}))}),_=R(`AuthApi.resolveSessionTenant`)(function*(e){return yield*n.get(`/auth/sessions/${encodeURIComponent(e)}/tenant`).pipe(L(rT(cE)),a)}),v=R(`AuthApi.setPassword`)(function*(e,t){yield*n.put(`/auth/password`,dk({currentPassword:e,newPassword:t})).pipe(a)}),y=R(`AuthApi.listPasskeys`)(function*(){return yield*n.get(`/auth/passkeys`).pipe(L(rT(ek)),a)}),b=R(`AuthApi.beginPasskeyRegistration`)(function*(e){return yield*n.post(`/auth/passkeys/registration/options`,dk({name:e})).pipe(L(rT(QO)),a)}),x=R(`AuthApi.finishPasskeyRegistration`)(function*(e){return yield*n.post(`/auth/passkeys/registration/finish`,dk(e)).pipe(L(rT(tk)),a)}),ee=R(`AuthApi.renamePasskey`)(function*(e,t){return yield*n.patch(`/auth/passkeys/${encodeURIComponent(e)}`,dk({name:t})).pipe(L(rT(tk)),a)}),S=R(`AuthApi.deletePasskey`)(function*(e){yield*n.del(`/auth/passkeys/${encodeURIComponent(e)}`).pipe(a)}),C=R(`AuthApi.beginTOTPEnrollment`)(function*(){return yield*n.post(`/auth/totp/enrollment/options`).pipe(L(rT(ik)),a)}),te=R(`AuthApi.completeTOTPEnrollment`)(function*(e){return yield*n.post(`/auth/totp/enrollment/finish`,dk({code:e})).pipe(L(rT(ak)),a)}),ne=R(`AuthApi.regenerateRecoveryCodes`)(function*(e){return yield*n.post(`/auth/totp/recovery-codes`,dk({code:e})).pipe(L(rT(ak)),a)}),w=R(`AuthApi.disableTOTP`)(function*(e){yield*n.post(`/auth/totp/disable`,dk({code:e})).pipe(a)}),T=R(`AuthApi.getOAuthAuthorization`)(function*(e){return yield*n.get(`/auth/oauth/authorization?${e}`).pipe(L(rT(sk)),a)}),re=R(`AuthApi.approveOAuthAuthorization`)(function*(e){return yield*n.post(`/auth/oauth/authorization/approve`,dk(e)).pipe(L(rT(ck)),a)}),ie=R(`AuthApi.denyOAuthAuthorization`)(function*(e){return yield*n.post(`/auth/oauth/authorization/deny`,dk({query:e})).pipe(L(rT(ck)),a)}),ae=R(`AuthApi.listOAuthGrants`)(function*(){return yield*n.get(`/auth/oauth/grants`).pipe(L(rT(lk)),a)}),oe=R(`AuthApi.createOwnPersonalTenant`)(function*(){return yield*r.createOwnPersonalTenant(void 0).pipe(a)}),se=R(`AuthApi.deleteOwnPersonalTenant`)(function*(){return yield*r.deleteOwnPersonalTenant(void 0).pipe(a)}),ce=R(`AuthApi.revokeOAuthGrant`)(function*(e){yield*n.del(`/auth/oauth/grants/${encodeURIComponent(e)}`).pipe(a)});return uk.of({listLoginMethods:o,loginWithPassword:s,completePasswordMFA:c,loginWithAPIToken:l,beginPasskeyLogin:u,finishPasskeyLogin:d,acceptUserInvitation:f,logoutWebSession:p,getAuthMe:m,getTenantContext:g,resolveSessionTenant:_,createOwnPersonalTenant:oe,deleteOwnPersonalTenant:se,getSecurityStatus:h,setPassword:v,listPasskeys:y,beginPasskeyRegistration:b,finishPasskeyRegistration:x,renamePasskey:ee,deletePasskey:S,beginTOTPEnrollment:C,completeTOTPEnrollment:te,regenerateRecoveryCodes:ne,disableTOTP:w,getOAuthAuthorization:T,approveOAuthAuthorization:re,denyOAuthAuthorization:ie,listOAuthGrants:ae,revokeOAuthGrant:ce})})),pk=K([W({error:W({code:V,message:V})}),W({error:V})]),mk=class extends ZC()(`ApiRequestError`,{code:V,message:V,status:H,cause:YS(K([hC(gw),hC(NS)]))}){},hk=(e,t)=>new mk({code:`internal_error`,message:`Invalid response`,status:e,cause:t}),gk=e=>e.pipe(Mf(`HttpClientError`,{StatusCodeError:({response:e},t)=>rT(pk)(e).pipe(Tf(({error:t})=>typeof t==`string`?new mk({code:`live_session_error`,message:t,status:e.status}):new mk({...t,status:e.status})),If(()=>new mk({code:`internal_error`,message:`Request failed`,status:e.status,cause:t})),L(I)),DecodeError:({response:e},t)=>I(hk(e.status,t))}),jf({HttpClientError:e=>I(new mk({code:`network_error`,message:`The server could not be reached`,status:0,cause:e})),SchemaError:e=>I(hk(0,e))})),_k=Xr(`@aperture-browser/api-client/CurrentAuthorization`,{defaultValue:()=>({})}),vk=e=>_k.useSync(({credentials:t,bearerToken:n,tenantHeader:r=`none`})=>{let i=n??(t?.kind===`bearer`?t.token:void 0),a=i===void 0?void 0:x_(i).trim(),o=t?HO(t,r):void 0;return e.pipe(Kw,a?Ww(a):x,o?Vw(BO,o):Uw(BO))}),yk=new Set([`authentication_required`,`invalid_authentication_token`,`authentication_token_expired`,`authentication_token_revoked`,`user_disabled`]),bk=dd(dT,Tf(dT,vT(vk))),xk=dd(WO,mf(function*(){let e=yield*nm();return WO.of({authorize:t=>n=>n.pipe(gk,Pf(n=>t.credentials?.kind===`session`&&yk.has(n.code)?im(e,void 0):df),qf(_k,t)),sessionAuthenticationFailures:cg(e)})})),Sk=class extends vr()(`@aperture-browser/api-client/EventsApi`){},Ck=class extends vr()(`@aperture-browser/api-client/HealthApi`){};function wk(e){return e.meta.hasMore?e.meta.nextCursor:void 0}function Tk(e){let t=(t,n)=>ug(void 0,r=>e(t,n===void 0?{cursor:r}:{...n,cursor:r}).pipe(Tf(e=>{let t=wk(e);return[e.data,t===void 0?sr():cr(t)]})));return{list:e,stream:t,listAll:(e,n)=>xg(t(e,n))}}var Ek=e=>({tagKey:e?.map(e=>e.key),tagOperator:e?.map(e=>e.operator),tagValue:e?.map(e=>e.values.join(`,`))}),Dk=e=>Object.fromEntries(Object.entries(e).flatMap(([e,t])=>{if(t==null||t===``)return[];if(!Array.isArray(t))return[[e,t]];let n=t.filter(e=>e!==``);return n.length>0?[[e,n]]:[]})),Ok=dd(Sk,mf(function*(){let e=yield*dT,{authorize:t}=yield*WO,n=zO(e),r=R(`EventsApi.listEvents`)(function*(e,r={}){return yield*n.listEvents({params:Dk({limit:r.limit,cursor:r.cursor,resourceType:r.resourceType,resourceId:r.resourceId})}).pipe(t(UO.tenantScoped(e)))}),i=R(`EventsApi.listAuditEvents`)(function*(e,r={}){return yield*n.listAuditEvents({params:Dk({limit:r.limit,cursor:r.cursor,tenantId:r.tenantId,actorType:r.actorType,actorId:r.actorId,action:r.action,resourceType:r.resourceType,resourceId:r.resourceId})}).pipe(t(UO.of(e)))}),a=Tk(r),o=Tk(i);return Sk.of({listEvents:r,streamEvents:a.stream,listAllEvents:a.listAll,listAuditEvents:i,streamAuditEvents:o.stream,listAllAuditEvents:o.listAll})})),kk=dd(Ck,mf(function*(){let e=yield*dT,{authorize:t}=yield*WO,n=zO(e),r=R(`HealthApi.getHealth`)(function*(){return yield*n.getHealth(void 0).pipe(t(UO.anonymous))});return Ck.of({getHealth:r})})),Ak=H.check(Y(),TC(0)),jk=P([]),Mk=W({capture:$T.fields.capture,pace:$T.fields.pace,motion:$T.fields.motion,idle:$T.fields.idle,ripple:$T.fields.ripple,burst:$T.fields.burst}),Nk={sessionId:V,cdpUrl:V,media:WE,thumbnailAvailable:U,pages:G(W({targetId:V,state:q([`pending`,`ready`,`unavailable`,`closed`]),title:V,url:V,viewport:z(W({width:Ak,height:Ak,deviceScaleFactor:H.check(TC(0)),contentWidth:Ak,contentHeight:Ak,canvasWidth:Ak,canvasHeight:Ak})),thumbnailAvailable:U})).pipe(fC(jk))},Pk={...Nk,capturedAt:V,representativeTargetId:z(V)},Fk=K([W({...Pk,status:B(`running`),source:B(`live`)}),W({...Pk,status:B(`suspended`),source:B(`persisted`)}),W({...Nk,status:B(`suspended`),source:B(`unavailable`)})]),Ik={recordingId:V,mode:q([`tab`,`viewer`]),targetId:V,captureGeneration:Ak,status:q([`starting`,`running`,`stopped`,`failed`]),stopReason:z(V),sandboxPath:z(V),path:z(V),startedAt:V,stoppedAt:z(V),sizeBytes:z(H.check(Y(),J(0))),fps:Ak,bitrateKbps:Ak,codec:V,motionSeed:z(H.check(Y())),editing:U,editedRelativePath:z(V),timelineRelativePath:z(V),editError:z(QT)},Lk=W({...Ik,relativePath:z(V)}).pipe(lC(W({...Ik,relativePath:V}),ey({decode:({relativePath:e,...t})=>({...t,relativePath:e??t.path??``}),encode:e=>e}))),Rk=class extends vr()(`@aperture-browser/api-client/SessionsApi`){},zk=Fd,Bk=e=>bf(t=>P(e(t.getRef(zk)))),Vk=(e,t,n)=>{let r=n?.halfOpen===!0?0:1;return Bk(n=>{let i=Math.ceil(e),a=Math.floor(t);return Math.floor(n.nextDoubleUnsafe()*(a-i+r))+i})},Hk=new TextEncoder,Uk=e=>e.replaceAll(`"`,`%22`).replaceAll(`\r`,`%0D`).replaceAll(`
26
+ `,`%0A`),Wk=e=>e instanceof Blob?lg({evaluate:()=>e.stream(),onError:e=>e}):e instanceof Uint8Array?rg(e):e,Gk=R(`SessionsApi.streamedMultipart`)(function*(e){let t=`aperture-upload-${(yield*Vk(0,2**53-1)).toString(36)}`;return mw(og(e.map(e=>{let n=`--${t}\r\nContent-Disposition: form-data; name="files"; filename="${Uk(e.name)}"\r\nContent-Type: application/octet-stream\r
27
27
  \r
28
- `;return rg(zk.encode(n)).pipe(mg(Vk(e.content)),mg(rg(zk.encode(`\r
29
- `))))})).pipe(pg(),mg(rg(zk.encode(`--${t}--\r\n`)))),`multipart/form-data; boundary=${t}`)}),Uk=R(`SessionsApi.uploadBody`)(function*(e){let t=new FormData;for(let n of e)if(n.content instanceof Blob)t.append(`files`,n.content,n.name);else if(n.content instanceof Uint8Array)t.append(`files`,new Blob([new Uint8Array(n.content)]),n.name);else return yield*Hk(e);return uw(t)}),Wk=e=>e?.match(/filename="([^"]+)"/)?.[1]??null,Gk=(e,t)=>`/sessions/${encodeURIComponent(e)}/recordings/${encodeURIComponent(t)}/content`,Kk=100,qk=dd(Fk,mf(function*(){let e=yield*dT,{authorize:t}=yield*VO,n=pT(e),r=IO(e),i=e=>t(BO.tenantScoped(e)),a=R(`SessionsApi.listSessions`)(function*(e,t={}){return yield*r.listSessions({params:wk({limit:t.limit,cursor:t.cursor,includeDeleted:t.includeDeleted||void 0,status:t.status,query:t.query,...Ck(t.tags)})}).pipe(i(e))}),o=Sk(a),s=R(`SessionsApi.exportSessionStorageState`)(function*(e,t,n){return yield*r.exportSessionStorageState(t,{payload:n}).pipe(i(e))}),c=R(`SessionsApi.getSession`)(function*(e,t){return yield*r.getSession(t,void 0).pipe(i(e))}),l=R(`SessionsApi.getSessionsBulk`)(function*(e,t){return{sessions:(yield*of(ca(t,Kk),t=>r.getSessionsBulk({payload:{ids:t}}).pipe(i(e)))).flatMap(e=>e.sessions)}}),u=R(`SessionsApi.createSession`)(function*(e,t,n={}){return yield*r.createSession({params:wk({waitForReady:n.waitForReady}),payload:KS(YD)({baseSnapshotName:t.baseSnapshotName??null,label:t.label??null,browser:{channel:t.browser.channel,args:t.browser.args??[]},initialTargets:t.initialTargets??[],...t.storageState===void 0?{}:{storageState:t.storageState},tags:t.tags??{},...t.proxy===void 0?{}:{proxy:t.proxy}})}).pipe(i(e))}),d=R(`SessionsApi.deleteSession`)(function*(e,t){return yield*r.deleteSession(t,void 0).pipe(i(e))}),f=R(`SessionsApi.reopenSession`)(function*(e,t){return yield*r.reopenSession(t,void 0).pipe(i(e))}),p=R(`SessionsApi.suspendSession`)(function*(e,t){return yield*r.suspendSession(t,void 0).pipe(i(e))}),m=R(`SessionsApi.rotateSessionToken`)(function*(e,t){return yield*r.rotateSessionToken(t,void 0).pipe(i(e))}),h=R(`SessionsApi.rotateCollaborationCapability`)(function*(e,t,n){return yield*r.rotateCollaborationCapability(t,n,void 0).pipe(i(e))}),g=R(`SessionsApi.replaceSessionTags`)(function*(e,t,n){return yield*r.replaceSessionTags(t,{payload:{tags:n}}).pipe(i(e))}),_=R(`SessionsApi.updateSessionProxy`)(function*(e,t,n){return yield*r.updateSessionProxy(t,{payload:KS(tO)(n)}).pipe(i(e))}),v=R(`SessionsApi.promoteSession`)(function*(e,t,n){return yield*r.promoteSession(t,{payload:{name:n.name,description:n.description??null,force:n.force??!1,tags:n.tags??{}}}).pipe(i(e))}),y=R(`SessionsApi.getSessionCursor`)(function*(e,t){return yield*r.getSessionCursor(t,void 0).pipe(i(e))}),b=R(`SessionsApi.setSessionCursor`)(function*(e,t,n){return yield*r.setSessionCursor(t,{payload:{visible:n}}).pipe(i(e))}),x=R(`SessionsApi.listSessionRecordings`)(function*(e,t){return yield*r.listSessionRecordings(t,void 0).pipe(i(e))}),ee=R(`SessionsApi.createSessionRecording`)(function*(e,t,n){return yield*r.createSessionRecording(t,{payload:n}).pipe(i(e))}),S=R(`SessionsApi.getSessionRecording`)(function*(e,t,n){return yield*r.getSessionRecording(t,n,void 0).pipe(i(e))}),C=R(`SessionsApi.retargetSessionRecording`)(function*(e,t,n,a){return yield*r.retargetSessionRecording(t,n,{payload:{targetId:a}}).pipe(i(e))}),te=R(`SessionsApi.stopSessionRecording`)(function*(e,t,n){return yield*r.stopSessionRecording(t,n,void 0).pipe(i(e))}),ne=R(`SessionsApi.listSessionFiles`)(function*(e,t){return yield*r.listSessionFiles(t,void 0).pipe(i(e))}),w=R(`SessionsApi.captionSessionRecording`)(function*(e,t,n,a){yield*r.captionSessionRecording(t,n,{payload:a}).pipe(i(e))}),T=R(`SessionsApi.focusSessionRecording`)(function*(e,t,n,a){yield*r.focusSessionRecording(t,n,{payload:a}).pipe(i(e))}),re=R(`SessionsApi.resetFocusSessionRecording`)(function*(e,t,n){yield*r.resetFocusSessionRecording(t,n,void 0).pipe(i(e))}),ie=R(`SessionsApi.attentionSessionRecording`)(function*(e,t,n,a){yield*r.attentionSessionRecording(t,n,{payload:a}).pipe(i(e))}),ae=R(`SessionsApi.createSessionFileDownloadURL`)(function*(e,t,n){return yield*r.createSessionFileDownloadURL(t,{payload:n}).pipe(i(e))}),oe=R(`SessionsApi.getBrowserChannels`)(function*(e){return yield*r.listBrowserChannels(void 0).pipe(i(e))}),se=R(`SessionsApi.getBrowserStatus`)(function*(e,r,i){return yield*n.get(`/sessions/${encodeURIComponent(r)}/browser/status`).pipe(L(rT(Mk)),t({credentials:e,bearerToken:i,tenantHeader:`tenant-scoped`}))}),ce=R(`SessionsApi.downloadSessionRecording`)(function*(e,r,i,a){return yield*n.get(Gk(r,i)).pipe(L(e=>Tf(e.arrayBuffer,t=>({blob:new Blob([t],{type:e.headers[`content-type`]??``}),filename:Wk(e.headers[`content-disposition`])}))),t({credentials:e,bearerToken:a,tenantHeader:`tenant-scoped`}))}),le=R(`SessionsApi.getSessionThumbnail`)(function*(e,r,i){let a=`/api/sessions/${encodeURIComponent(r)}`,o=i===void 0?`${a}/thumbnail`:`${a}/targets/${encodeURIComponent(i)}/thumbnail`;return yield*n.get(o).pipe(L(e=>Tf(e.arrayBuffer,e=>new Blob([e],{type:`image/jpeg`}))),t({credentials:e,tenantHeader:`tenant-scoped`}))}),E=(e,r,i,a)=>n.get(Gk(r,i)).pipe(t({credentials:e,bearerToken:a,tenantHeader:`tenant-scoped`}),Tf(e=>e.stream.pipe(yg(`HttpClientError`,e=>$h(pk(I(e)))))),dg),ue=R(`SessionsApi.uploadSessionFiles`)(function*(e,t,r,a={}){let o=yield*Uk(r);return(yield*n.post(`/api/sessions/${encodeURIComponent(t)}/files`,{body:o,urlParams:wk({directory:a.directory})}).pipe(L(rT(SO)),i(e))).files}),de=R(`SessionsApi.deleteSessionFile`)(function*(e,t,n,a={}){yield*r.deleteSessionFile(t,{params:wk({relativePath:n,recursive:a.recursive})}).pipe(i(e))}),fe=R(`SessionsApi.createSessionDirectory`)(function*(e,t,n){return yield*r.createSessionDirectory(t,{payload:{relativePath:n}}).pipe(i(e))}),pe=R(`SessionsApi.moveSessionFile`)(function*(e,t,n){return yield*r.moveSessionFile(t,{payload:n}).pipe(i(e))}),me=R(`SessionsApi.uploadLiveSessionFiles`)(function*(e,r,i,a){let o=yield*Uk(i);return(yield*n.post(`/sessions/${encodeURIComponent(r)}/uploads`,{body:o}).pipe(L(rT(PO)),t({credentials:e,bearerToken:a,tenantHeader:`tenant-scoped`}))).files}),he=R(`SessionsApi.setSessionViewport`)(function*(e,n,i,a){return yield*r.setSessionViewport(n,{payload:i}).pipe(t({credentials:e,bearerToken:a,tenantHeader:`tenant-scoped`}))});return Fk.of({listSessions:a,streamSessions:o.stream,listAllSessions:o.listAll,getSession:c,exportSessionStorageState:s,getSessionsBulk:l,createSession:u,deleteSession:d,reopenSession:f,suspendSession:p,rotateSessionToken:m,rotateCollaborationCapability:h,replaceSessionTags:g,updateSessionProxy:_,promoteSession:v,getSessionCursor:y,setSessionCursor:b,listSessionRecordings:x,createSessionRecording:ee,getSessionRecording:S,retargetSessionRecording:C,stopSessionRecording:te,captionSessionRecording:w,focusSessionRecording:T,resetFocusSessionRecording:re,attentionSessionRecording:ie,listSessionFiles:ne,createSessionFileDownloadURL:ae,getBrowserChannels:oe,getBrowserStatus:se,downloadSessionRecording:ce,getSessionThumbnail:le,streamSessionRecording:E,uploadSessionFiles:ue,uploadLiveSessionFiles:me,deleteSessionFile:de,moveSessionFile:pe,createSessionDirectory:fe,setSessionViewport:he})})),Jk=class extends vr()(`@aperture-browser/api-client/SnapshotsApi`){},Yk=dd(Jk,mf(function*(){let e=yield*dT,{authorize:t}=yield*VO,n=IO(e),r=e=>t(BO.tenantScoped(e)),i=R(`SnapshotsApi.listSnapshots`)(function*(e,t={}){return yield*n.listSnapshots({params:wk({limit:t.limit,cursor:t.cursor,includeDeleted:t.includeDeleted||void 0,deleted:t.deleted,name:t.name,...Ck(t.tags)})}).pipe(r(e))}),a=Sk(i),o=R(`SnapshotsApi.getSnapshotByName`)(function*(e,t){return yield*a.stream(e,{name:t,limit:100}).pipe(_g(e=>e.name===t),Sg)}),s=R(`SnapshotsApi.updateSnapshot`)(function*(e,t,i){return yield*n.updateSnapshot(t,{payload:i}).pipe(r(e))}),c=R(`SnapshotsApi.replaceSnapshotTags`)(function*(e,t,i){return yield*n.replaceSnapshotTags(t,{payload:{tags:i}}).pipe(r(e))}),l=R(`SnapshotsApi.deleteSnapshot`)(function*(e,t){return yield*n.deleteSnapshot(t,void 0).pipe(r(e))}),u=R(`SnapshotsApi.restoreSnapshot`)(function*(e,t){return yield*n.restoreSnapshot(t,void 0).pipe(r(e))});return Jk.of({listSnapshots:i,streamSnapshots:a.stream,listAllSnapshots:a.listAll,getSnapshotByName:o,updateSnapshot:s,replaceSnapshotTags:c,deleteSnapshot:l,restoreSnapshot:u})})),Xk=class extends vr()(`@aperture-browser/api-client/TenantsApi`){},Zk=dd(Xk,mf(function*(){let e=yield*dT,{authorize:t}=yield*VO,n=IO(e),r=R(`TenantsApi.listTenants`)(function*(e,r={}){return yield*n.listTenants({params:wk({limit:r.limit,cursor:r.cursor,includeDeleted:r.includeDeleted||void 0,deleted:r.deleted,query:r.query})}).pipe(t(BO.of(e)))}),i=Sk(r),a=R(`TenantsApi.getCurrentTenant`)(function*(e){return yield*n.getTenant(void 0).pipe(t(BO.tenantScoped(e)))}),o=R(`TenantsApi.updateCurrentTenant`)(function*(e,r){return yield*n.updateSelectedTenant({payload:r}).pipe(t(BO.tenantScoped(e)))}),s=R(`TenantsApi.createTenant`)(function*(e,r){return yield*n.createTenant({payload:r}).pipe(t(BO.of(e)))}),c=R(`TenantsApi.updateTenant`)(function*(e,r,i){return yield*n.updateTenant(r,{payload:i}).pipe(t(BO.of(e)))}),l=R(`TenantsApi.deleteTenant`)(function*(e,r){return yield*n.deleteTenant(r,void 0).pipe(t(BO.of(e)))}),u=R(`TenantsApi.restoreTenant`)(function*(e,r){return yield*n.restoreTenant(r,void 0).pipe(t(BO.of(e)))});return Xk.of({listTenants:r,streamTenants:i.stream,listAllTenants:i.listAll,createTenant:s,updateTenant:c,deleteTenant:l,restoreTenant:u,getCurrentTenant:a,updateCurrentTenant:o})})),Qk=class extends vr()(`@aperture-browser/api-client/TokensApi`){},$k=dd(Qk,mf(function*(){let e=yield*dT,{authorize:t}=yield*VO,n=IO(e),r=R(`TokensApi.listAdminTokens`)(function*(e,r={}){return yield*n.listAdminTokens({params:wk({limit:r.limit,cursor:r.cursor,tenantId:r.tenantId,name:r.name,authorityType:r.authorityType,revoked:r.revoked,scope:r.scope})}).pipe(t(BO.of(e)))}),i=Sk(r),a=R(`TokensApi.createAdminToken`)(function*(e,r){let i=r.authorityType===`system_admin`;return yield*n.createAdminToken({payload:{name:r.name,authorityType:r.authorityType,tenantId:r.tenantId??null,scopes:r.scopes,resourceMode:i?`all`:r.resourceMode,resourceGrants:i?[]:r.resourceGrants,expiresAt:r.expiresAt??null}}).pipe(t(BO.of(e)))}),o=R(`TokensApi.revokeAdminToken`)(function*(e,r){yield*n.revokeAdminToken(r,void 0).pipe(t(BO.of(e)))}),s=R(`TokensApi.listTenantTokens`)(function*(e,r={}){return yield*n.listTenantTokens({params:wk({limit:r.limit,cursor:r.cursor,name:r.name,revoked:r.revoked,scope:r.scope})}).pipe(t(BO.tenantScoped(e)))}),c=Sk(s),l=R(`TokensApi.createTenantToken`)(function*(e,r){return yield*n.createTenantToken({payload:{name:r.name,scopes:r.scopes,resourceMode:r.resourceMode,resourceGrants:r.resourceGrants,expiresAt:r.expiresAt??null}}).pipe(t(BO.tenantScoped(e)))}),u=R(`TokensApi.revokeTenantToken`)(function*(e,r){yield*n.revokeTenantToken(r,void 0).pipe(t(BO.tenantScoped(e)))});return Qk.of({listAdminTokens:r,streamAdminTokens:i.stream,listAllAdminTokens:i.listAll,createAdminToken:a,revokeAdminToken:o,listTenantTokens:s,streamTenantTokens:c.stream,listAllTenantTokens:c.listAll,createTenantToken:l,revokeTenantToken:u})})),eA=class extends vr()(`@aperture-browser/api-client/UsersApi`){},tA=hd(lk,Zk,dd(eA,mf(function*(){let e=yield*dT,{authorize:t}=yield*VO,n=IO(e),r=R(`UsersApi.listUsers`)(function*(e,r={}){return yield*n.listUsers({params:wk({limit:r.limit,cursor:r.cursor,query:r.query,disabled:r.disabled})}).pipe(t(BO.of(e)))}),i=Sk(r),a=R(`UsersApi.createUser`)(function*(e,r){return yield*n.createUser({payload:r}).pipe(t(BO.of(e)))}),o=R(`UsersApi.createPersonalTenant`)(function*(e,r){yield*n.createPersonalTenant(r,void 0).pipe(t(BO.of(e)))}),s=R(`UsersApi.deletePersonalTenant`)(function*(e,r){yield*n.deletePersonalTenant(r,void 0).pipe(t(BO.of(e)))}),c=R(`UsersApi.getUser`)(function*(e,r){return yield*n.getUser(r,void 0).pipe(t(BO.of(e)))}),l=R(`UsersApi.updateUser`)(function*(e,r,i){return yield*n.updateUser(r,{payload:i}).pipe(t(BO.of(e)))}),u=R(`UsersApi.createUserInvitation`)(function*(e,r){return yield*n.createUserInvitation(r,void 0).pipe(t(BO.of(e)))}),d=R(`UsersApi.disableUser`)(function*(e,r){return yield*n.disableUser(r,void 0).pipe(t(BO.of(e)))}),f=R(`UsersApi.restoreUser`)(function*(e,r){return yield*n.restoreUser(r,void 0).pipe(t(BO.of(e)))}),p=R(`UsersApi.listUserMemberships`)(function*(e,r){return yield*n.listUserMemberships(r,void 0).pipe(t(BO.of(e)))}),m=R(`UsersApi.listTenantMemberships`)(function*(e,r){return yield*n.listTenantMemberships(r,void 0).pipe(t(BO.of(e)))}),h=R(`UsersApi.upsertTenantMembership`)(function*(e,r,i,a){let o={scopes:a};return yield*n.upsertTenantMembership(r,i,{payload:o}).pipe(t(BO.of(e)))}),g=R(`UsersApi.deleteTenantMembership`)(function*(e,r,i){yield*n.deleteTenantMembership(r,i,void 0).pipe(t(BO.of(e)))});return eA.of({listUsers:r,streamUsers:i.stream,listAllUsers:i.listAll,createUser:a,getUser:c,updateUser:l,createUserInvitation:u,disableUser:d,restoreUser:f,createPersonalTenant:o,deletePersonalTenant:s,listUserMemberships:p,listTenantMemberships:m,upsertTenantMembership:h,deleteTenantMembership:g})})),qk,Yk,$k,Tk,Ek).pipe(_d(_k),vd(vk)),nA=e=>dd(dT,Tf(dT,_T(Jw(e)))),rA=`aperture-session.v1`,iA={onExcessProperty:`error`},aA=H.check(Y()),oA=H.check(TC(0)),sA=aA.check(TC(0)),cA=H.check(DC({minimum:0,maximum:1})),lA=P([]);function uA(e){return G(e).pipe(fC(lA))}var dA=q([`implicit`,`explicit`]),fA=W({profile:V,fps:aA.check(DC({minimum:1,maximum:120})),bitrateKbps:aA.check(J(100)),keyframeInterval:sA}),pA=W({id:V,label:V,codec:V,mimeType:V,sdpFmtpLine:V}),mA=W({quality:z(fA),profiles:G(pA),cursorVisible:U}),hA=W({id:V,type:V,title:V,url:V,loading:U,canGoBack:z(U),canGoForward:z(U),viewport:z(W({width:oA,height:oA,contentWidth:oA,contentHeight:oA,canvasWidth:oA,canvasHeight:oA,deviceScaleFactor:oA}))}),gA=W({clientId:V,name:V,avatarHash:V,role:q([`owner`,`editor`,`viewer`,`automation`]),activeTargetId:z(V),followingClientId:z(V),holdingInput:U,leaseMode:z(dA),recovering:z(U)}),_A=HS(BC(K([W({type:B(`session.snapshot`),clientId:V,resumeSecret:V,role:q([`owner`,`editor`,`viewer`]),transport:q([`webrtc`,`websocket`]),holderClientId:z(V),mode:z(dA),activeTargetId:z(V),targets:uA(hA),participants:uA(gA),recordings:uA(Pk),presentation:mA,viewportOwnerClientId:z(V),autoSize:z(U)}),W({type:B(`presence.state`),participants:uA(gA)}),W({type:B(`input.state`),holderClientId:z(V),mode:z(dA)}),W({type:B(`viewport.state`),viewportOwnerClientId:z(V),autoSize:U}),W({type:B(`presence.cursor`),clientId:V,targetId:V,x:cA,y:cA,realtimeCounter:sA}),W({type:B(`presence.cursor.clear`),clientId:V,realtimeCounter:sA}),W({type:B(`paint.point`),clientId:V,targetId:V,strokeId:V,color:V.check(vC(/^#[0-9a-fA-F]{6}$/)),width:H.check(DC({minimum:1,maximum:16})),phase:q([`start`,`move`,`end`]),x:cA,y:cA,realtimeCounter:z(sA)}),W({type:B(`targets.state`),activeTargetId:z(V),targets:uA(hA)}),W({type:B(`recordings.state`),recordings:uA(Pk)}),W({type:B(`presentation.state`),presentation:mA}),W({type:B(`error`),code:V,message:V}),W({type:q([`target.select.result`,`target.create.result`,`target.close.result`,`page.navigate.result`,`page.history-back.result`,`page.history-forward.result`,`page.reload.result`,`page.stop-loading.result`,`viewport.set.result`,`viewport.auto-size.set.result`,`viewport.owner.claim.result`,`presentation.quality.set.result`,`presentation.cursor.set.result`,`automation.pacing.set.result`,`recording.start.result`,`recording.stop.result`,`recording.cancel.result`]),requestId:V,ok:U,code:z(V),message:z(V),targetId:z(V),recording:z(Pk),presentation:z(mA)})])),iA),vA=W({type:B(`presentation.frame`),targetId:V,width:oA,height:oA}),yA=[SA(1280,720,1),SA(1440,900,1),SA(1920,1080,1),SA(2560,1440,1),SA(768,1024,1),SA(390,844,1)],bA=yA[0],xA=[1,1.5,2,3];function SA(e,t,n){return{id:`${e}x${t}@${CA(n)}`,label:`${e}×${t}`,width:e,height:t,deviceScaleFactor:n}}function CA(e){return Number.isInteger(e)?String(e):String(e).replace(/0+$/,``).replace(/\.$/,``)}function wA(e,t,n,r){if(n<=0||r<=0||e<=0||t<=0)return{scale:1,offsetX:0,offsetY:0,renderedWidth:e,renderedHeight:t};let i=Math.min(e/n,t/r),a=n*i,o=r*i;return{scale:i,offsetX:(e-a)/2,offsetY:(t-o)/2,renderedWidth:a,renderedHeight:o}}var TA=`~effect/FiberSet`,EA=e=>D(e,TA),DA={[TA]:TA,[Symbol.iterator](){return this.state._tag===`Closed`?Wi():this.state.backing[Symbol.iterator]()},...Lt,toJSON(){return{_id:`FiberSet`,state:this.state}}},OA=(e,t)=>{let n=Object.create(DA);return n.state={_tag:`Open`,backing:e},n.deferred=t,n},kA=()=>Yf(F(()=>OA(new Set,Fu())),e=>uf(()=>{let t=e.state;if(t._tag===`Closed`)return df;e.state={_tag:`Closed`};let n=t.backing;return Np(n).pipe(Vu(e.deferred))})),AA=()=>L(kA(),e=>FA(e)()),jA=-1,MA=ha(_a(Dd,ga(jA))),NA=b(e=>EA(e[0]),(e,t,n)=>{if(e.state._tag===`Closed`){t.interruptUnsafe(jA);return}else if(e.state.backing.has(t))return;e.state.backing.add(t),t.addObserver(r=>{e.state._tag!==`Closed`&&(e.state.backing.delete(t),Mu(r)&&(n?.propagateInterruption===!0?!MA(r.cause):!Sd(r.cause))&&Bu(e.deferred,r))})}),PA=function(){let e;return()=>(e===void 0&&(e=fp(np)),e)}(),FA=e=>()=>Tf(Uf(),t=>{let n=pp(t);return(t,r)=>{if(e.state._tag===`Closed`)return PA();let i=n(t,r);return NA(e,i,r),i}}),IA=Xr(`effect/http/FetchHttpClient/Fetch`,{defaultValue:()=>globalThis.fetch}),LA=class extends vr()(`effect/http/FetchHttpClient/RequestInit`){},RA=CT(P(gT((e,t,n,r)=>{let i=r.getRef(IA),a=Vr(r.context,LA)??{},o=a.headers?M_(O_(a.headers),e.headers):e.headers;o[`content-length`]&&(o=N_(o,`content-length`));let s=r=>Tf(lf({try:()=>i(t,{...a,method:e.method,headers:o,body:r,duplex:typeof ReadableStream<`u`&&r instanceof ReadableStream?`half`:void 0,signal:n}),catch:t=>new gw({reason:new yw({request:e,cause:t})})}),t=>oT(e,t));switch(e.body._tag){case`Raw`:case`Uint8Array`:return s(e.body.body);case`FormData`:return s(e.body.formData);case`Stream`:return L(Eg(e.body.stream),s)}return s(void 0)})));function zA(e,t){let n=new URL(e.baseUrl??`/`,window.location.href);if(n.protocol!==`http:`&&n.protocol!==`https:`)throw Error(`session base URL must use HTTP or HTTPS`);if(e.kind===`relay`&&n.origin!==window.location.origin)throw Error(`session relay must use the page's origin`);return n.pathname=`${n.pathname.replace(/\/$/,``)}/${t}`,n.search=``,n.hash=``,n}function BA(e,t){return zA(e,`sessions/${encodeURIComponent(e.sessionId)}/${t}`)}function VA(e,t){let n=BA(e,t);return n.protocol=n.protocol===`https:`?`wss:`:`ws:`,n.toString()}function HA(e){if(e.kind!==`direct`)return{token:void 0,tenantId:void 0};let{credentials:t}=e;return{token:t.kind===`bearer`?x_(t.token):void 0,tenantId:zO(t,`tenant-scoped`)}}function UA(e){let{token:t,tenantId:n}=HA(e),r=[rA];return t!==void 0&&r.push(`authorization.bearer.${t}`),n!==void 0&&r.push(`x-aperture-tenant-id.${n}`),r}function WA(e,t){let{token:n,tenantId:r}=HA(e),i={};return n!==void 0&&(i.Authorization=`Bearer ${n}`),r!==void 0&&(i[`X-Aperture-Tenant-Id`]=r),L(dT,e=>pT(e).get(t.toString(),{headers:i})).pipe(qf(LA,{credentials:n===void 0?`same-origin`:`omit`,redirect:`error`,cache:`no-store`}))}var GA=R(`getSessionStatus`)(function*(e){return yield*WA(e,BA(e,`browser/status`)).pipe(L(rT(Mk)),pk)}),KA=R(`downloadSessionRecording`)(function*(e,t){return yield*WA(e,BA(e,`recordings/${encodeURIComponent(t)}/content`)).pipe(L(e=>Tf(e.arrayBuffer,t=>({blob:new Blob([t],{type:e.headers[`content-type`]??``}),filename:Wk(e.headers[`content-disposition`])}))),pk)}),qA=R(`getTargetThumbnail`)(function*(e,t){let n=`targets/${encodeURIComponent(t)}/thumbnail`,r=HA(e).token;return yield*WA(e,e.kind===`relay`||r!==void 0&&(r.startsWith(`aps_`)||r.startsWith(`ape_`)||r.startsWith(`apv_`))?BA(e,n):zA(e,`api/sessions/${encodeURIComponent(e.sessionId)}/${n}`)).pipe(L(e=>Tf(e.arrayBuffer,e=>new Blob([e],{type:`image/jpeg`}))),pk)}),JA=class extends Da(`LiveSessionError`){},YA=VS(BC(K([W({version:B(1),type:B(`answer`),sdp:V}),W({version:B(1),type:B(`ice-candidate`),candidate:W({candidate:V,sdpMid:z(oC(V)),sdpMLineIndex:z(oC(H.check(Y()))),usernameFragment:z(oC(V))})}),W({version:B(1),type:B(`error`),error:W({code:V,message:V})})])),iA),XA=VS(BC(vA),iA),ZA=5e3,QA=500,$A=15e3,ej=wp(function*(e){let{callbacks:t}=e,n=yield*AA(),r=e=>n(e),i=(e,t)=>r(Rf(e).pipe(Sf(F(t)))),a=null,o=null,s=null,c=e.webrtcSupported?`webrtc`:`websocket`,l=null,u=!1,d=null,f=null,p=1e3,m=0,h=0,g=0,_=[],v=null,y=new Map,b={hello:()=>({type:`session.hello`,...s??e.identity,...e.autoSize===void 0?{}:{autoSize:e.autoSize()}}),message:(e,t)=>oe(e,t),ready:e=>re(e),failed:(e,t)=>ae(e,t),frame:(e,n)=>{a===e?t.onFrame(n):o===e&&(v=n)}},x=()=>{o?.close(),o=null,_=[],v=null},ee=()=>{f?.interruptUnsafe(),f=null},S=e=>{let t=new JA({message:e});for(let e of y.values())Bu(e,I(t));y.clear()},C=e=>{if(!l)return;let t=l;l=null,Bu(t.deferred,I(new JA({message:e})))},te=()=>{c===`webrtc`&&e.webrtcSupported?ne():w()},ne=()=>{if(u||d!==null||o)return;let t;try{t=new rj({access:e.access,iceServers:e.iceServers,callbacks:b,fork:r})}catch(e){le(`webrtc`,tj(e,`WebRTC setup failed`));return}o=t,_=[],v=null,t.connect(),i(ZA,()=>{o===t&&(x(),le(`webrtc`,new JA({message:`WebRTC presentation timed out`})))})},w=()=>{if(u||d!==null||o)return;let t;try{t=new nj({access:e.access,callbacks:b,fork:r})}catch(e){le(`websocket`,tj(e,`WebSocket setup failed`));return}o=t,_=[],v=null,t.connect()},T=e=>i(e,()=>{!u&&a===null&&o===null&&w()}),re=n=>{if(u||o!==n){n.close();return}let r=a,i=_,s=v;if(r&&r!==n&&S(`live session transport replaced`),o=null,_=[],v=null,a=n,h=0,g=0,p=1e3,t.onPhase(`connected`),t.onTransport(n.kind),l?.kind===n.kind){let e=l;l=null,Bu(e.deferred,df)}n instanceof rj?(t.onFrame(null),t.onStream(n.mediaStream())):(t.onStream(null),s&&t.onFrame(s));for(let e of i)se(e);n.kind===`websocket`&&c===`webrtc`&&e.webrtcSupported&&ce(),r&&r!==n&&r.close()},ie=e=>{ee(),x(),a?.close(),a=null,C(e),S(e),t.onFrame(null),t.onStream(null),t.onTransport(null)},ae=(e,n)=>{if(!u){if(n.terminalReason!==void 0&&(o===e||a===e)){d=n,ie(n.message),t.onPhase(`error`),t.onError(n.message);return}if(o===e){x(),le(e.kind,n);return}a===e&&(a=null,e.close(),S(`live session transport was lost`),t.onPhase(`disconnected`),t.onError(n.message),t.onFrame(null),t.onStream(null),t.onTransport(null),T(e.kind===`webrtc`?0:QA))}},oe=(e,t)=>{if(t.type===`error`&&t.code===`resume_rejected`&&o===e&&a===null&&(s=null),t.type===`session.snapshot`&&(s={clientId:t.clientId,resumeSecret:t.resumeSecret}),a!==e){if(o!==e)return;_.push(t),t.type===`session.snapshot`&&e.kind===`websocket`&&re(e);return}se(t)},se=e=>{if(`realtimeCounter`in e&&e.realtimeCounter!==void 0){if(e.realtimeCounter<=g)return;g=e.realtimeCounter}if(`requestId`in e){let t=y.get(e.requestId);t&&(y.delete(e.requestId),Bu(t,e.ok?P(e):I(new JA({message:e.message??`live session command failed`}))))}t.onMessage(e)},ce=()=>{if(u||c!==`webrtc`||!e.webrtcSupported||a?.kind===`webrtc`||f!==null)return;let t=p;p=Math.min($A,p*2),f=i(t,()=>{f=null,ne()})},le=(e,n)=>{if(l?.kind===e&&(C(n.message),a&&(c=a.kind)),a){a.kind===`websocket`&&ce();return}if(e===`webrtc`){w();return}t.onPhase(`disconnected`),t.onError(n.message),T(QA)},E=e=>a?.sendReliable(e)??!1,ue=e=>(h+=1,a?.sendRealtime({realtimeCounter:h,...e})??!1),de=()=>{u=!0,ie(`live session connection closed`)};return yield*Zf(()=>F(de)),t.onPhase(`connecting`),te(),{reconnect:F(()=>{d=null,ee(),x(),a?.close(),a=null,C(`live session transport replaced`),S(`live session transport replaced`),t.onPhase(`connecting`),w()}),selectTransport:t=>uf(()=>{if(d!==null)return I(d);if(t===`webrtc`&&!e.webrtcSupported)return I(new JA({message:`WebRTC presentation is unavailable`}));if(c=t,ee(),o&&o.kind!==t&&x(),C(`presentation selection was replaced`),a?.kind===t)return df;let n=Fu();return l={kind:t,deferred:n},o===null&&(t===`webrtc`?ne():w()),Iu(n)}),sendReliable:E,sendRealtime:ue,command:(e,t={})=>uf(()=>{m+=1;let n=`request-${m}`,r=Fu();return y.set(n,r),E({type:e,requestId:n,...t})?Iu(r).pipe(rp(()=>F(()=>y.delete(n)))):(y.delete(n),I(new JA({message:`live session transport is unavailable`})))})}});function tj(e,t){return new JA({message:e instanceof Error&&e.message?e.message:t})}var nj=class{kind=`websocket`;socket;callbacks;fork;pendingRealtime=new Map;pendingRasterPacket=null;rasterDecoder=null;decodingRaster=!1;realtimeFrame=null;closed=!1;constructor(e){this.callbacks=e.callbacks,this.fork=e.fork,this.socket=new WebSocket(VA(e.access,`session`),UA(e.access)),this.socket.binaryType=`blob`}connect(){this.socket.addEventListener(`open`,()=>{this.sendReliable(this.callbacks.hello())}),this.socket.addEventListener(`message`,e=>{if(typeof e.data==`string`){let t=_A(e.data);if(Li(t)){this.callbacks.failed(this,aj(t.failure));return}this.callbacks.message(this,t.success);return}e.data instanceof Blob&&(this.pendingRasterPacket=e.data,this.decodingRaster||(this.decodingRaster=!0,this.rasterDecoder=this.fork(this.decodeRasterPackets())))}),this.socket.addEventListener(`close`,e=>{this.closed||this.callbacks.failed(this,ij(`WebSocket session transport closed`,e.code))}),this.socket.addEventListener(`error`,()=>{this.closed||this.callbacks.failed(this,new JA({message:`WebSocket session transport failed`}))})}sendReliable(e){return this.flushRealtime(),this.sendNow(e)}sendRealtime(e){return this.socket.readyState===WebSocket.OPEN?(this.pendingRealtime.delete(e.type),this.pendingRealtime.set(e.type,e),this.realtimeFrame===null&&(this.realtimeFrame=window.requestAnimationFrame(()=>{this.realtimeFrame=null,this.flushRealtime()})),!0):!1}close(){this.closed=!0,this.pendingRasterPacket=null,this.rasterDecoder?.interruptUnsafe(),this.rasterDecoder=null,this.realtimeFrame!==null&&(window.cancelAnimationFrame(this.realtimeFrame),this.realtimeFrame=null),this.pendingRealtime.clear(),this.socket.close()}decodeRasterPackets(){return mf({self:this},function*(){for(;;){let e=this.pendingRasterPacket;if(e===null||this.closed){this.decodingRaster=!1;return}this.pendingRasterPacket=null;let t=yield*oj(e);ur(t)&&!this.closed&&this.callbacks.frame(this,t.value)}})}flushRealtime(){this.realtimeFrame!==null&&(window.cancelAnimationFrame(this.realtimeFrame),this.realtimeFrame=null);for(let e of this.pendingRealtime.values())this.sendNow(e);this.pendingRealtime.clear()}sendNow(e){return this.socket.readyState===WebSocket.OPEN?(this.socket.send(JSON.stringify(e)),!0):!1}},rj=class{kind=`webrtc`;connection;reliable;realtime;signal;callbacks;fork;pendingCandidates=[];reliableOpen=!1;realtimeOpen=!1;helloSent=!1;snapshotReceived=!1;stream=null;streamReady=!1;closed=!1;constructor(e){this.callbacks=e.callbacks,this.fork=e.fork,this.connection=new RTCPeerConnection({iceServers:e.iceServers.map(e=>({urls:[...e.urls],username:e.username,credential:e.credential===void 0?void 0:x_(e.credential)}))}),this.reliable=this.connection.createDataChannel(`application`,{ordered:!0}),this.realtime=this.connection.createDataChannel(`application-realtime`,{ordered:!1,maxRetransmits:0}),this.connection.addTransceiver(`video`,{direction:`recvonly`}),this.signal=new WebSocket(VA(e.access,`webrtc/signal`),UA(e.access))}connect(){this.reliable.addEventListener(`open`,()=>{this.reliableOpen=!0,this.sendHello()}),this.realtime.addEventListener(`open`,()=>{this.realtimeOpen=!0,this.sendHello()}),this.reliable.addEventListener(`message`,e=>this.handleApplicationMessage(e)),this.realtime.addEventListener(`message`,e=>this.handleApplicationMessage(e));for(let e of[this.reliable,this.realtime])e.addEventListener(`close`,()=>this.fail(`WebRTC session channel closed`)),e.addEventListener(`error`,()=>this.fail(`WebRTC session channel failed`));this.connection.addEventListener(`track`,e=>{this.stream=e.streams[0]??new MediaStream([e.track]);let t=()=>{this.stream&&(this.streamReady=!0,this.maybeReady())};e.track.muted?e.track.addEventListener(`unmute`,t,{once:!0}):t()}),this.connection.addEventListener(`icecandidate`,e=>{e.candidate&&this.signal.readyState===WebSocket.OPEN&&this.signal.send(JSON.stringify({version:1,type:`ice-candidate`,candidate:e.candidate.toJSON()}))}),this.connection.addEventListener(`connectionstatechange`,()=>{(this.connection.connectionState===`failed`||this.connection.connectionState===`closed`)&&this.fail(`WebRTC ${this.connection.connectionState}`)}),this.signal.addEventListener(`open`,()=>{this.fork(this.sendOffer().pipe(Af(`LiveSessionError`,e=>F(()=>this.fail(e.message)))))}),this.signal.addEventListener(`message`,e=>this.handleSignal(e)),this.signal.addEventListener(`close`,e=>this.fail(`WebRTC signaling closed`,e.code)),this.signal.addEventListener(`error`,()=>this.fail(`WebRTC signaling failed`))}sendReliable(e){return this.reliable.readyState===`open`?(this.reliable.send(JSON.stringify(e)),!0):!1}sendRealtime(e){return this.realtime.readyState===`open`?(this.realtime.send(JSON.stringify(e)),!0):!1}close(){this.closed=!0,this.reliable.close(),this.realtime.close(),this.connection.close(),this.signal.close()}mediaStream(){return this.stream}sendHello(){this.helloSent||!this.reliableOpen||!this.realtimeOpen||(this.helloSent=this.sendReliable(this.callbacks.hello()))}handleApplicationMessage(e){if(typeof e.data!=`string`)return;let t=_A(e.data);if(Li(t)){this.closed||this.callbacks.failed(this,aj(t.failure));return}this.callbacks.message(this,t.success),t.success.type===`session.snapshot`&&(this.snapshotReceived=!0,this.maybeReady())}handleSignal(e){let t=typeof e.data==`string`?YA(e.data):sr();if(lr(t)){this.fail(`WebRTC signaling message is invalid`);return}let n=t.value;if(n.type===`error`){this.fail(n.error.message);return}if(n.type===`answer`){this.fork(lf(()=>this.connection.setRemoteDescription({type:`answer`,sdp:n.sdp})).pipe(Sf(uf(()=>of(this.pendingCandidates.splice(0),e=>lf(()=>this.connection.addIceCandidate(e)),{discard:!0}))),kf(()=>F(()=>this.fail(`WebRTC answer is invalid`)))));return}if(!this.connection.remoteDescription){this.pendingCandidates.push(n.candidate);return}this.fork(lf(()=>this.connection.addIceCandidate(n.candidate)).pipe(kf(()=>F(()=>this.fail(`WebRTC ICE candidate is invalid`)))))}sendOffer(){return mf({self:this},function*(){let e=e=>tj(e,`WebRTC negotiation failed`),t=yield*lf({try:()=>this.connection.createOffer(),catch:e});yield*lf({try:()=>this.connection.setLocalDescription(t),catch:e});let n=this.connection.localDescription?.sdp;if(!n)return yield*new JA({message:`WebRTC offer is unavailable`});this.signal.send(JSON.stringify({version:1,type:`offer`,sdp:n}))})}maybeReady(){this.snapshotReceived&&this.stream&&this.streamReady&&this.callbacks.ready(this)}fail(e,t=0){this.closed||this.callbacks.failed(this,ij(e,t))}};function ij(e,t){return t===4401||t===4403?new JA({message:`Session access denied. Sign in or request access before reconnecting.`,terminalReason:`access_denied`}):t===4404||t===4410?new JA({message:`Session is no longer available.`,terminalReason:`session_unavailable`}):new JA({message:e})}function aj(e){return new JA({message:`The server sent a live session message this client cannot read: ${e.message}`,terminalReason:`protocol_mismatch`})}function oj(e){return mf(function*(){if(e.size<4)return sr();let t=yield*lf(()=>e.slice(0,4).arrayBuffer()),n=new DataView(t).getUint32(0);return n===0||n>e.size-4?sr():hr(XA(yield*lf(()=>e.slice(4,4+n).text())),t=>({targetId:t.targetId,data:e.slice(4+n,e.size,`image/jpeg`),width:t.width,height:t.height}))}).pipe(If(()=>sr()))}var $=c(f(),1),sj=`~effect/SubscriptionRef`,cj={...Lt,[sj]:{_A:x},toJSON(){return{_id:`SubscriptionRef`,value:this.value}}},lj=e=>Tf(nm({replay:1}),t=>{let n=Object.create(cj);return n.semaphore=th(1),n.value=e,n.pubsub=t,am(n.pubsub,e),n}),uj=e=>cg(e.pubsub),dj=(e,t)=>{e.value=t,am(e.pubsub,t)},fj=b(2,(e,t)=>e.semaphore.withPermit(F(()=>dj(e,t)))),pj=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),mj=o(((e,t)=>{t.exports=pj()})),hj=mj(),gj=(0,$.createContext)(null),_j=class extends Da(`RuntimeProviderMissingError`){message=`useRuntime must be used inside RuntimeProvider`};function vj({runtime:e,baseUrl:t,children:n}){let r=(0,$.useMemo)(()=>({runtime:e,baseUrl:t}),[e,t]);return(0,hj.jsx)(gj.Provider,{value:r,children:n})}function yj(){let e=(0,$.useContext)(gj);if(!e)throw new _j;return e}function bj(){return yj().runtime}function xj(e,t){let n=bj();(0,$.useEffect)(()=>{let t=e();if(!t)return;let r=n.runFork(t);return()=>r.interruptUnsafe()},[n,...t])}function Sj(e,t){let n=bj(),r=(0,$.useRef)(new Set);return(0,$.useEffect)(()=>{let e=r.current;return()=>{for(let t of e)t.interruptUnsafe();e.clear()}},[]),(0,$.useCallback)((...t)=>{let i=n.runFork(e(...t));i.pollUnsafe()||(r.current.add(i),i.addObserver(()=>r.current.delete(i)))},[n,...t])}var Cj=2e3,wj=()=>new JA({message:`live session transport is unavailable`}),Tj=40,Ej=7e3,Dj={left:272,right:273,middle:274};function Oj({access:e,displayName:t=null,enabled:n,webrtcSupported:r,iceServers:i,autoSize:a}){let o=(0,$.useMemo)(()=>Aj(t),[t]),[s,c]=(0,$.useState)(`viewer`),l=bj(),u=(0,$.useMemo)(()=>l.runSync(lj(null)),[l]),d=(0,$.useMemo)(()=>l.runSync(nm()),[l]),f=(0,$.useMemo)(()=>uj(u),[u]),p=(0,$.useMemo)(()=>cg(d),[d]),m=(0,$.useCallback)(e=>l.runSync(fj(u,e)),[u,l]),h=(0,$.useCallback)(e=>am(d,e),[d]),g=(0,$.useRef)(null),_=(0,$.useRef)(null),v=(0,$.useRef)(``),y=(0,$.useRef)(!1),b=(0,$.useRef)(!1),x=(0,$.useRef)(!1),ee=(0,$.useRef)(0),S=(0,$.useRef)([]),C=(0,$.useRef)(null),te=(0,$.useRef)(null),ne=(0,$.useRef)(null),w=(0,$.useRef)(null),T=(0,$.useRef)(!1),[re,ie]=(0,$.useState)(`idle`),[ae,oe]=(0,$.useState)([]),[se,ce]=(0,$.useState)(null),[le,E]=(0,$.useState)(null),[ue,de]=(0,$.useState)(null),[fe,pe]=(0,$.useState)(null),[me,he]=(0,$.useState)(!1),[ge,_e]=(0,$.useState)(!1),[D,ve]=(0,$.useState)(null),[ye,be]=(0,$.useState)([]),[xe,Se]=(0,$.useState)(null),[Ce,we]=(0,$.useState)(``),[Te,Ee]=(0,$.useState)(null),[De,Oe]=(0,$.useState)(null),[ke,Ae]=(0,$.useState)([]),[je,Me]=(0,$.useState)(()=>new Map),[Ne,Pe]=(0,$.useState)(null);te.current=ue,ne.current=fe,w.current=D;let Fe=(0,$.useCallback)(e=>{switch(e.type){case`session.snapshot`:c(e.role),v.current=e.clientId,we(e.clientId),_.current=e.holderClientId??null,Ee(e.holderClientId??null),Oe(e.mode??null),S.current=e.participants,Ae(e.participants),C.current=e.participants.find(t=>t.clientId===e.clientId)?.followingClientId??null,oe(e.targets),ce(e.activeTargetId??null),de(Nj(e.targets,e.activeTargetId)),be(e.recordings),ve(e.presentation??null),Se(e.autoSize===void 0?null:{ownerClientId:e.viewportOwnerClientId??null,autoSize:e.autoSize}),Pe(null);return;case`targets.state`:oe(e.targets),ce(e.activeTargetId??null),de(Nj(e.targets,e.activeTargetId)),he(!1);return;case`presence.state`:S.current=e.participants,Ae(e.participants),C.current=e.participants.find(e=>e.clientId===v.current)?.followingClientId??null,Me(e=>{let t=C.current;if(!t)return e.size===0?e:new Map;let n=e.get(t);return n?new Map([[t,n]]):new Map});return;case`input.state`:_.current=e.holderClientId??null,Ee(e.holderClientId??null),Oe(e.mode??null),y.current=!1,b.current=!1,Pe(e=>e?.code===`input_busy`||e?.code===`input_not_owned`?null:e);return;case`viewport.state`:Se({ownerClientId:e.viewportOwnerClientId??null,autoSize:e.autoSize});return;case`presence.cursor`:if(e.clientId!==C.current)return;Me(t=>new Map(t).set(e.clientId,e));return;case`presence.cursor.clear`:Me(t=>{if(!t.has(e.clientId))return t;let n=new Map(t);return n.delete(e.clientId),n});return;case`paint.point`:S.current.some(t=>t.clientId===e.clientId)&&h({type:`point`,message:e});return;case`recordings.state`:be(e.recordings);return;case`presentation.state`:ve(e.presentation);return;case`error`:y.current=!1,b.current=!1,Pe({code:e.code,message:e.message});return;default:e.presentation&&ve(e.presentation),e.ok||Pe({code:e.code??`request_rejected`,message:e.message??`Live session command failed.`})}},[h]);xj(()=>{if(!n||e===null){g.current=null,ie(`idle`),c(`viewer`),oe([]),ce(null),E(null),de(null),pe(null),ve(null),he(!1),_e(!1),Ae([]),Me(new Map),be([]),Se(null),m(null),h({type:`clear`});return}return c(`viewer`),mf(function*(){let t=yield*ej({access:e,identity:o,autoSize:a,iceServers:i,webrtcSupported:r,callbacks:{onPhase:ie,onMessage:Fe,onFrame:m,onStream:E,onTransport:pe,onError:e=>Pe({code:`connection_failed`,message:e})}});return g.current=t,yield*Zf(()=>F(()=>{g.current===t&&(g.current=null)})),yield*pf}).pipe(Jf,Qf(F(()=>{m(null),h({type:`clear`})})))},[a,e,n,Fe,i,o,m,h,r]);let Ie=(0,$.useCallback)(e=>g.current?.sendReliable(e)??!1,[]),Le=(0,$.useCallback)(e=>g.current?.sendRealtime(e)??!1,[]),Re=Sj((e,t,n)=>e.command(t,n).pipe(kf(e=>F(()=>{he(!1),Pe({code:`request_rejected`,message:e.message})}))),[]),ze=(0,$.useCallback)((e,t={})=>{let n=g.current;return n?(Re(n,e,t),!0):!1},[Re]),Be=(0,$.useCallback)((e,t={})=>uf(()=>g.current?g.current.command(e,t):I(wj())),[]),Ve=Sj((e,t)=>e.command(`target.select`,{targetId:t}).pipe(Vf({onSuccess:()=>ce(t),onFailure:e=>Pe({code:`request_rejected`,message:e.message})}),Qf(F(()=>he(!1)))),[]),He=(0,$.useCallback)(e=>uf(()=>{let t=g.current;return t?(he(!0),t.command(`target.select`,{targetId:e}).pipe(Cf(()=>F(()=>ce(e))),Pf(e=>F(()=>Pe({code:`request_rejected`,message:e.message}))),Qf(F(()=>he(!1))),Of)):I(wj())}),[]),Ue=(0,$.useCallback)(e=>{let t=g.current;return t?(he(!0),Ve(t,e),!0):!1},[Ve]),We=(0,$.useCallback)(e=>uf(()=>{let t=g.current;return t?T.current?I(new JA({message:`another presentation update is already in progress`})):(T.current=!0,_e(!0),mf(function*(){switch(e.kind){case`jpeg`:return yield*t.selectTransport(`websocket`);case`webrtc-retry`:return yield*t.selectTransport(`webrtc`);case`webrtc`:{let n=te.current;if(!n)return yield*new JA({message:`presentation size is unavailable`});let r=w.current?.quality?.profile!==e.quality.profile&&ne.current===`webrtc`;r&&(yield*t.selectTransport(`websocket`));let i=yield*t.command(`presentation.quality.set`,{profile:e.quality.profile,width:n.canvasWidth,height:n.canvasHeight,fps:e.quality.fps,bitrateKbps:e.quality.bitrateKbps}).pipe(Pf(()=>r?Ff(t.selectTransport(`webrtc`)):df));return i.presentation&&ve(i.presentation),yield*t.selectTransport(`webrtc`)}default:return e}}).pipe(Pf(e=>F(()=>Pe({code:`presentation_update_failed`,message:e.message}))),Qf(F(()=>{T.current=!1,_e(!1)})))):I(wj())}),[]),Ge=(0,$.useCallback)((e,t)=>s===`viewer`||!Ie({type:`input.claim`,targetId:e,mode:t})?!1:(y.current=!0,b.current=!1,!0),[s,Ie]),Ke=(0,$.useCallback)(()=>b.current||_.current!==v.current||!Ie({type:`input.release`})?!1:(b.current=!0,y.current=!1,!0),[Ie]),qe=(0,$.useCallback)(e=>e?Ue(e):!1,[Ue]),Je=(0,$.useCallback)(e=>Ie({type:`follow.set`,followingClientId:e??``}),[Ie]),Ye=(0,$.useCallback)((e,t,n,r)=>{let i=performance.now();if(i-ee.current<Tj)return!1;ee.current=i;let a=Le({type:`presence.cursor`,targetId:e,x:Pj(t,r.width),y:Pj(n,r.height)});return a&&(x.current=!0),a},[Le]),Xe=(0,$.useCallback)(e=>e.phase===`move`?Le({type:`paint.point`,...e}):Ie({type:`paint.point`,...e}),[Le,Ie]),Ze=(0,$.useCallback)(()=>!x.current||!Ie({type:`presence.cursor.clear`})?!1:(x.current=!1,!0),[Ie]),Qe=(0,$.useCallback)((e,t=!1)=>t?Le(e):Ie(e),[Le,Ie]),$e=(0,$.useCallback)((e,t)=>{if(s===`viewer`||_.current!==v.current&&!y.current)return!1;switch(e.type){case`input.mouse`:{let n=Pj(e.x,t.width),r=Pj(e.y,t.height);if(e.action===`move`)return Qe({type:`input.pointer.motion.absolute`,targetId:e.targetId,x:n,y:r,width:t.width,height:t.height,modifiers:e.modifiers??0},!0);if(e.button===`none`)return!0;let i=Dj[e.button??`left`],a=(a,o)=>Qe({type:`input.pointer.button`,targetId:e.targetId,x:n,y:r,width:t.width,height:t.height,buttonCode:i,pressed:a,clickCount:o,modifiers:e.modifiers??0});if(e.action===`down`||e.action===`up`)return a(e.action===`down`,e.clickCount??1);let o=e.action===`doubleClick`?2:1;for(let t=0;t<o;t+=1){let n=e.action===`doubleClick`?t+1:1;a(!0,n),a(!1,n)}return!0}case`input.wheel`:{let n=Pj(e.x,t.width),r=Pj(e.y,t.height);return Qe({type:`input.pointer.scroll`,targetId:e.targetId,x:n,y:r,width:t.width,height:t.height,horizontal:e.deltaX,vertical:e.deltaY,stopHorizontal:!1,stopVertical:!1,modifiers:e.modifiers??0}),Qe({type:`input.pointer.scroll`,targetId:e.targetId,x:n,y:r,width:t.width,height:t.height,horizontal:0,vertical:0,stopHorizontal:e.deltaX!==0,stopVertical:e.deltaY!==0,modifiers:e.modifiers??0})}case`input.key`:{if(e.action===`char`)return e.text?Qe({type:`input.keyboard.text`,targetId:e.targetId,text:e.text}):!1;let t=Dg[e.code??``];if(!t)return!1;let n=e.windowsVirtualKeyCode??Fg(e.code,e.key);return Qe({type:`input.keyboard.key`,targetId:e.targetId,keycode:t,pressed:e.action===`down`,key:e.key,code:e.code,text:e.text,unmodifiedText:e.unmodifiedText,modifiers:e.modifiers??0,windowsVirtualKeyCode:n,nativeVirtualKeyCode:e.nativeVirtualKeyCode??n,location:e.location??0,autoRepeat:e.autoRepeat??!1,isKeypad:e.isKeypad??!1})}case`clipboard.copy`:return Fj(Qe,e.targetId,`KeyC`);case`clipboard.cut`:return Fj(Qe,e.targetId,`KeyX`);case`clipboard.paste`:{let t=e.items.find(e=>e.mimeType===`text/plain`);return t?Qe({type:`input.keyboard.text`,targetId:e.targetId,text:t.data}):!1}default:return e}},[s,Qe]),et=Te===Ce&&Ce!==``,tt=ke.find(e=>e.clientId===Ce)?.followingClientId??null;return xj(()=>et?Rf(Cj).pipe(Sf(F(()=>{_.current===v.current&&Ie({type:`input.heartbeat`})})),op):void 0,[et,Ie]),{phase:re,targets:ae,activeTargetId:se,frames:f,mediaStream:le,mediaSize:ue,transport:fe,presentation:D,mediaSwitching:me||ge,recordings:ye,viewportOwnership:xe,sendBrowserInput:$e,selectTarget:Ue,requestSelectTarget:He,command:ze,request:Be,selectPresentation:We,reconnect:()=>{let e=g.current;e&&l.runSync(e.reconnect)},collaboration:{phase:re===`error`?`disconnected`:re,role:s,clientId:Ce,holderClientId:Te,leaseMode:De,hasControl:et,canRequestControl:s!==`viewer`&&re===`connected`,lastError:Ne,participants:ke,cursors:je,paintEvents:p,followingClientId:tt,claim:Ge,release:Ke,setActiveTarget:qe,follow:Je,sendCursor:Ye,sendPaintPoint:Xe,clearCursor:Ze,sendInput:$e}}}var kj=VS(BC(W({name:V.check(OC(1),AC(48)),avatarHash:V.check(vC(/^[0-9a-f]{32}$/))})),iA);function Aj(e){let t=jj();return e?.trim()?{...t,name:Array.from(e.trim()).slice(0,48).join(``)}:t}function jj(){let e=`aperture.collaboration.identity`;try{let t=window.localStorage.getItem(e);if(t){let e=kj(t);if(ur(e))return e.value}let n=Mj();return window.localStorage.setItem(e,JSON.stringify(n)),n}catch{return Mj()}}function Mj(){let e=[`Amber`,`Brisk`,`Calm`,`Clever`,`Misty`,`Quiet`,`Swift`,`Warm`],t=[`Badger`,`Falcon`,`Fox`,`Koala`,`Otter`,`Panda`,`Raven`,`Tiger`],n=new Uint8Array(18);return crypto.getRandomValues(n),{name:`${e[(n.at(0)??0)%e.length]??`Quiet`} ${t[(n.at(1)??0)%t.length]??`Otter`}`,avatarHash:Array.from(n.slice(2),e=>e.toString(16).padStart(2,`0`)).join(``)}}function Nj(e,t){let n=e.find(e=>e.id===t)?.viewport;return n?{width:n.width,height:n.height,canvasWidth:n.canvasWidth,canvasHeight:n.canvasHeight,deviceScaleFactor:n.deviceScaleFactor}:null}function Pj(e,t){return t<=1?0:Math.min(1,Math.max(0,e/t))}function Fj(e,t,n){let r=Dg.ControlLeft,i=Dg[n];if(!r||!i)return!1;let a=Fg(`ControlLeft`,`Control`),o=n===`KeyC`?`c`:`x`,s=Fg(n,o);return e({type:`input.keyboard.key`,targetId:t,keycode:r,pressed:!0,key:`Control`,code:`ControlLeft`,windowsVirtualKeyCode:a,nativeVirtualKeyCode:a,modifiers:2}),e({type:`input.keyboard.key`,targetId:t,keycode:i,pressed:!0,key:o,code:n,windowsVirtualKeyCode:s,nativeVirtualKeyCode:s,modifiers:2}),e({type:`input.keyboard.key`,targetId:t,keycode:i,pressed:!1,key:o,code:n,windowsVirtualKeyCode:s,nativeVirtualKeyCode:s,modifiers:2}),e({type:`input.keyboard.key`,targetId:t,keycode:r,pressed:!1,key:`Control`,code:`ControlLeft`,windowsVirtualKeyCode:a,nativeVirtualKeyCode:a,modifiers:0})}var Ij=[`#f43f5e`,`#f97316`,`#eab308`,`#22c55e`,`#06b6d4`,`#8b5cf6`],Lj=4,Rj=24,zj=2048,Bj=512;function Vj({collaboration:e,targetId:t,enabled:n,visible:r,left:i,top:a,width:o,height:s}){let c=(0,$.useRef)(null),l=(0,$.useRef)(null),u=(0,$.useRef)(null),d=(0,$.useRef)(0),f=(0,$.useRef)(new Map),p=Wj(e.clientId);xj(()=>{let n=c.current;if(!n)return;let r=window.devicePixelRatio||1;n.width=Math.max(1,Math.round(o*r)),n.height=Math.max(1,Math.round(s*r));let i=n.getContext(`2d`);if(!i)return;let a=null,l=new Set(e.participants.map(e=>e.clientId)),u=Date.now();for(let[e,t]of f.current)!t.ended&&!l.has(t.clientId)&&f.current.set(e,{...t,updatedAt:u,ended:!0});let d=()=>{a=null,i.setTransform(r,0,0,r,0,0),i.clearRect(0,0,o,s);let e=Date.now(),n=0;for(let[r,a]of f.current){let c=e-a.updatedAt;if(a.ended&&c>=7e3){f.current.delete(r);continue}if(a.ended&&(n+=1),a.targetId!==t||a.points.length===0)continue;let l=a.ended?1-c/Ej:1;i.globalAlpha=l,i.strokeStyle=a.color,i.fillStyle=a.color,i.lineWidth=a.width,i.lineCap=`round`,i.lineJoin=`round`;let u=a.points[0];if(!u)continue;if(a.points.length===1){i.beginPath(),i.arc(u.x*o,u.y*s,a.width/2,0,Math.PI*2),i.fill();continue}i.beginPath(),i.moveTo(u.x*o,u.y*s);for(let e=1;e<a.points.length-1;e+=1){let t=a.points[e],n=a.points[e+1];!t||!n||i.quadraticCurveTo(t.x*o,t.y*s,(t.x+n.x)/2*o,(t.y+n.y)/2*s)}let d=a.points[a.points.length-1];d&&i.lineTo(d.x*o,d.y*s),i.stroke()}i.globalAlpha=1,n>0&&(a=window.requestAnimationFrame(d))},p=()=>{a===null&&(a=window.requestAnimationFrame(d))},m=e=>{if(e.type===`clear`){f.current.clear(),p();return}let t=e.message,n=`${t.clientId}:${t.targetId}:${t.strokeId}`,r=f.current.get(n);if(t.phase!==`start`&&!r||r?.ended&&t.phase!==`start`)return;let i=Date.now();if(t.phase===`start`)for(let[e,n]of f.current)!n.ended&&n.clientId===t.clientId&&f.current.set(e,{...n,updatedAt:i,ended:!0});let a=t.phase===`start`||!r?[{x:t.x,y:t.y}]:[...r.points,{x:t.x,y:t.y}];if(a.length>zj&&(a=a.filter((e,t)=>t%2==0)),!r&&f.current.size>=Bj){let e=null,t=1/0;for(let[n,r]of f.current)r.ended&&r.updatedAt<t&&(e=n,t=r.updatedAt);e&&f.current.delete(e)}f.current.set(n,{clientId:t.clientId,targetId:t.targetId,color:t.color,width:t.width,points:a,updatedAt:i,ended:t.phase===`end`}),p()};return d(),Cg(e.paintEvents,e=>F(()=>m(e))).pipe(Qf(F(()=>{a!==null&&window.cancelAnimationFrame(a)})))},[e.paintEvents,e.participants,s,t,o]),(0,$.useEffect)(()=>{l.current=null,u.current=null},[n,t]);function m(n,r){let i=l.current,a=Hj(n);!i||!a||e.sendPaintPoint({targetId:t,strokeId:i,color:p,width:Lj,phase:r,x:a.x,y:a.y})}function h(n){if(Uj(n),!n.isPrimary||n.button!==0||u.current!==null)return;n.currentTarget.focus(),l.current=crypto.randomUUID(),u.current=n.pointerId,d.current=performance.now();try{n.currentTarget.setPointerCapture(n.pointerId)}catch{}let r=Hj(n);r&&e.sendCursor(t,r.x*o,r.y*s,{width:o,height:s}),m(n,`start`)}function g(n){if(Uj(n),u.current!==null&&n.pointerId!==u.current)return;let r=Hj(n);r&&e.sendCursor(t,r.x*o,r.y*s,{width:o,height:s}),!(!l.current||performance.now()-d.current<Rj)&&(d.current=performance.now(),m(n,`move`))}function _(e){Uj(e),!(!l.current||u.current!==e.pointerId)&&(m(e,`end`),l.current=null,u.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))}return(0,hj.jsx)(`canvas`,{ref:c,tabIndex:-1,style:{position:`absolute`,zIndex:20,touchAction:`none`,cursor:n?`crosshair`:void 0,pointerEvents:n?void 0:`none`,visibility:r?void 0:`hidden`,left:i,top:a,width:o,height:s},"aria-label":`Shared drawing overlay`,onPointerDown:h,onPointerMove:g,onPointerUp:_,onPointerCancel:_,onWheel:Uj,onContextMenu:Uj})}function Hj(e){let t=e.currentTarget.getBoundingClientRect();return t.width===0||t.height===0?null:{x:Math.max(0,Math.min(1,(e.clientX-t.left)/t.width)),y:Math.max(0,Math.min(1,(e.clientY-t.top)/t.height))}}function Uj(e){e.preventDefault(),e.stopPropagation()}function Wj(e){let t=0;for(let n of e)t=t*31+n.charCodeAt(0)>>>0;return Ij[t%Ij.length]??`#f43f5e`}var Gj=500,Kj=5;function qj({control:e,viewport:t=e.viewport,localCursorEnabled:n=!0,paintingEnabled:r=!1,onPaintingEnabledChange:i,onNotice:a,className:o,style:s,renderOverlay:c}){let l=(0,$.useRef)(null),u=(0,$.useRef)(null),d=(0,$.useRef)(null),f=(0,$.useRef)({decodingFrame:null,generation:0,pending:null}),p=(0,$.useRef)(null),m=(0,$.useRef)(new Map),h=(0,$.useRef)(new Set),g=(0,$.useRef)(null),_=(0,$.useRef)(null),v=(0,$.useRef)(!1),y=(0,$.useRef)(null),b=(0,$.useRef)(null),[x,ee]=(0,$.useState)(null),[S,C]=(0,$.useState)(null),[te,ne]=(0,$.useState)(null),w=e.mediaPath===`webrtc-live`&&e.mediaPhase===`live`&&!!e.mediaStream&&!!e.activeTargetId,T=w&&(e.mediaSwitching||e.mediaTargetId!==e.activeTargetId||te?.stream!==e.mediaStream||te?.targetId!==e.activeTargetId),re=r&&(w||S!==null)&&e.collaboration.phase===`connected`&&!e.mediaSwitching&&!T,ie=r||e.mediaSwitching||T||e.collaboration.phase!==`connected`||e.collaboration.role===`viewer`,ae=T&&te?te.size:e.mediaSize,oe=w?ae?.width??t.width:S?.width??t.width,se=w?ae?.height??t.height:S?.height??t.height,ce=w?oe:t.width,le=w?se:t.height,E=w?Math.min(ae?.canvasWidth??oe,Math.round(oe*(ae?.deviceScaleFactor??1))):oe,ue=w?Math.min(ae?.canvasHeight??se,Math.round(se*(ae?.deviceScaleFactor??1))):se,de=wA(e.browserViewportSize?.width??oe,e.browserViewportSize?.height??se,oe,se),fe=Jj(e.phase),pe=Yj(e.collaboration),me=fe??pe,he=me?y.current??x:null,ge=e.collaboration.followingClientId?e.collaboration.participants.find(t=>t.clientId===e.collaboration.followingClientId):null,_e=ge?e.collaboration.cursors.get(ge.clientId):null,D=_e?.targetId===e.activeTargetId?{x:de.offsetX+_e.x*de.renderedWidth,y:de.offsetY+_e.y*de.renderedHeight}:null;(0,$.useEffect)(()=>{e.setInputDimensions({width:ce,height:le})},[e.setInputDimensions,le,ce]);let ve=(0,$.useCallback)(()=>{let t=[...m.current.entries()].reverse();m.current.clear();for(let[n,r]of t)e.sendInput({type:`input.key`,targetId:r.targetId,action:`up`,...r.input,text:void 0,modifiers:0,autoRepeat:!1})&&h.current.add(n)},[e.sendInput]);xj(()=>{let t=t=>{if(!t){u.current?eM(u.current,f.current):tM(f.current),p.current!==null&&(p.current=null,C(null));return}if(t.targetId!==e.activeTargetId)return;u.current&&!w?Zj(u.current,f.current,t):f.current.pending=t;let n=p.current;if(n?.width!==t.width||n?.height!==t.height){let e={width:t.width,height:t.height};p.current=e,C(e)}};return Cg(e.frames,e=>F(()=>t(e))).pipe(Qf(F(()=>{u.current?eM(u.current,f.current):tM(f.current)})))},[e.activeTargetId,e.frames,w]),(0,$.useLayoutEffect)(()=>{let t=f.current,n=e.activeTargetId,r=t.pending?.targetId===n?t.pending:t.decodingFrame?.targetId===n?t.decodingFrame:null,i=u.current;if(i?eM(i,t):tM(t),r){t.pending=r;let e={width:r.width,height:r.height};p.current=e,C(e),i&&Qj(i,t)}else p.current!==null&&(p.current=null,C(null))},[e.activeTargetId]),(0,$.useEffect)(()=>{let e=u.current;w||!e||Qj(e,f.current)},[S,w]),(0,$.useEffect)(()=>{d.current&&(d.current.srcObject=w?e.mediaStream:null)},[e.mediaStream,w]),(0,$.useEffect)(()=>{let t=d.current,n=e.mediaStream,r=e.activeTargetId,i=e.mediaSize;if(!w||!t||!n||!r||!i||e.mediaSwitching||e.mediaTargetId!==r||te?.stream===n&&te.targetId===r)return;let a=t.requestVideoFrameCallback(()=>{ne({stream:n,targetId:r,size:i})});return()=>t.cancelVideoFrameCallback(a)},[e.activeTargetId,e.mediaSize,e.mediaStream,e.mediaSwitching,e.mediaTargetId,te,w]),(0,$.useEffect)(()=>{let t=l.current;if(!t)return;let n=(t,n)=>{e.setBrowserViewportSize({width:t,height:n})},r=t.getBoundingClientRect();n(r.width,r.height);let i=new ResizeObserver(e=>{let t=e[0];t&&n(t.contentRect.width,t.contentRect.height)});return i.observe(t),()=>i.disconnect()},[e.setBrowserViewportSize]),(0,$.useEffect)(()=>()=>{_.current?.(),ve()},[ve]),(0,$.useEffect)(()=>{let e=()=>{ve(),Se()},t=()=>{document.visibilityState===`hidden`&&(ve(),Se())};return window.addEventListener(`blur`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`blur`,e),document.removeEventListener(`visibilitychange`,t)}},[ve,e.collaboration]),(0,$.useEffect)(()=>{ie&&(_.current?.(),ve(),Se())},[ie,ve]),(0,$.useEffect)(()=>{r&&(e.setCaptured(!1),v.current=!1),e.collaboration.hasControl&&e.collaboration.leaseMode===`implicit`&&!v.current&&e.collaboration.release()},[e.collaboration.hasControl,e.collaboration.leaseMode,e.collaboration.release,e.setCaptured,r]);function ye(e,t){let n=l.current?.getBoundingClientRect();if(!n)return null;let r=wA(n.width,n.height,oe,se),i=e.clientX-n.left-r.offsetX,a=e.clientY-n.top-r.offsetY;if(!t&&(i<0||a<0||i>r.renderedWidth||a>r.renderedHeight))return null;let o=i/r.scale*(ce/oe),s=a/r.scale*(le/se);return t?{x:Math.round(sM(o,0,Math.max(ce-1,0))),y:Math.round(sM(s,0,Math.max(le-1,0)))}:{x:Math.round(o),y:Math.round(s)}}function be(){return e.phase!==`connected`||!e.activeTargetId||ie?null:(e.captured||e.setCaptured(!0),xe(e.activeTargetId),l.current?.focus(),e.activeTargetId)}function xe(t){v.current=!0,e.collaboration.hasControl||e.collaboration.claim(t,`implicit`)}function Se(){v.current=!1,e.collaboration.hasControl&&e.collaboration.leaseMode===`implicit`&&e.collaboration.release()}function Ce(e){e.preventDefault(),e.stopPropagation()}function we(e){e.cancelable&&e.preventDefault(),e.stopPropagation()}function Te(){e.phase!==`connected`||ie||(e.setCaptured(!0),e.activeTargetId&&xe(e.activeTargetId),l.current?.focus())}function Ee(t){Re(t),!(ie||!e.activeTargetId)&&(e.setCaptured(!0),xe(e.activeTargetId))}function De(){y.current=null,ee(null),e.collaboration.clearCursor(),g.current||(ve(),Se(),e.setCaptured(!1))}function Oe(){e.captured||Te()}function ke(t){Re(t);let n=ye(t,!1);if(e.activeTargetId&&n?e.collaboration.sendCursor(e.activeTargetId,n.x,n.y,{width:ce,height:le}):n||e.collaboration.clearCursor(),ie||g.current?.pointerId===t.pointerId)return;let r=e.captured&&t.buttons===0?e.activeTargetId:null;r&&n&&(Ce(t),e.sendInput({type:`input.mouse`,targetId:r,action:`move`,x:n.x,y:n.y,button:`none`,buttons:0,clickCount:0,modifiers:jg(t.nativeEvent)}))}function Ae(t){Re(t);let n=be();if(!n)return;let r=ye(t,!1);if(!r)return;let i=l.current;if(!i)return;let a=iM(t.button),o=Date.now(),s=aM(n,a,r,o,b.current);b.current={targetId:n,button:a,point:r,time:o,clickCount:s},Ce(t),g.current={pointerId:t.pointerId,targetId:n,button:a,clickCount:s},_.current?.();try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}Ne({pointerId:t.pointerId,targetId:n,button:a,clickCount:s,element:i}),e.sendInput({type:`input.mouse`,targetId:n,action:`down`,x:r.x,y:r.y,button:a,buttons:t.buttons,clickCount:s,modifiers:jg(t.nativeEvent)})}function je(t){if(ie)return;let n=g.current,r=n?.pointerId===t.pointerId?n.targetId:e.activeTargetId;if(!r)return;let i=ye(t,n?.pointerId===t.pointerId);i&&(Ce(t),e.sendInput({type:`input.mouse`,targetId:r,action:`up`,x:i.x,y:i.y,button:n?.button??iM(t.button),buttons:t.buttons,clickCount:n?.clickCount??1,modifiers:jg(t.nativeEvent)}),n?.pointerId===t.pointerId&&(g.current=null,t.currentTarget.hasPointerCapture(t.pointerId)&&t.currentTarget.releasePointerCapture(t.pointerId)))}function Me(t){let n=g.current;if(n?.pointerId!==t.pointerId)return;let r=ye(t,!0);g.current=null,t.currentTarget.hasPointerCapture(t.pointerId)&&t.currentTarget.releasePointerCapture(t.pointerId),!(!r||ie)&&(Ce(t),e.sendInput({type:`input.mouse`,targetId:n.targetId,action:`up`,x:r.x,y:r.y,button:n.button,buttons:0,clickCount:n.clickCount,modifiers:jg(t.nativeEvent)}))}function Ne({pointerId:t,targetId:n,button:r,clickCount:i,element:a}){let o=a=>{if(a.pointerId!==t)return;let o=ye(a,!0);we(a),o&&(e.collaboration.sendCursor(n,o.x,o.y,{width:ce,height:le}),e.sendInput({type:`input.mouse`,targetId:n,action:`move`,x:o.x,y:o.y,button:r,buttons:a.buttons||oM(r),clickCount:i,modifiers:jg(a)}))},s=(a,o)=>{if(a.pointerId!==t)return;let s=ye(a,!0);ye(a,!1)||e.collaboration.clearCursor(),we(a),s&&(e.sendInput({type:`input.mouse`,targetId:n,action:`up`,x:s.x,y:s.y,button:r,buttons:0,clickCount:i,modifiers:jg(a)}),o||(b.current={targetId:n,button:r,point:s,time:Date.now(),clickCount:i})),u()},c=e=>s(e,!1),l=e=>s(e,!0),u=()=>{window.removeEventListener(`pointermove`,o,!0),window.removeEventListener(`pointerup`,c,!0),window.removeEventListener(`pointercancel`,l,!0);try{a.hasPointerCapture(t)&&a.releasePointerCapture(t)}catch{}g.current?.pointerId===t&&(g.current=null),_.current===u&&(_.current=null)};_.current=u,window.addEventListener(`pointermove`,o,!0),window.addEventListener(`pointerup`,c,!0),window.addEventListener(`pointercancel`,l,!0)}function Pe(t){let n=be();if(!n)return;let r=ye(t,!1);if(!r)return;Ce(t);let i=cM(t.deltaMode,le);e.sendInput({type:`input.wheel`,targetId:n,x:r.x,y:r.y,deltaX:t.deltaX*i,deltaY:t.deltaY*i,modifiers:jg(t.nativeEvent)})}function Fe(t){if(t.key===`Escape`&&r){t.preventDefault(),t.stopPropagation(),i?.(!1);return}if(t.key===`Escape`){e.captured&&(t.preventDefault(),t.stopPropagation(),e.setCaptured(!1),Se());return}let n=t.code||t.key;if(t.repeat&&h.current.has(n)){t.preventDefault(),t.stopPropagation();return}let o=e.activeTargetId;if(ie||!o||!e.captured&&dM(l.current)!==l.current&&!l.current?.contains(t.target))return;t.preventDefault(),t.stopPropagation();let s=rM(t.nativeEvent);if(s===`copy`){e.sendInput({type:`clipboard.copy`,targetId:o});return}if(s===`cut`){e.sendInput({type:`clipboard.cut`,targetId:o});return}if(s===`paste`){lM(e,a);return}if(!Pg(t.nativeEvent))return;let c=Ng(t.nativeEvent,`down`);e.sendInput({type:`input.key`,targetId:o,action:`down`,...c})&&(h.current.delete(n),m.current.set(n,{targetId:o,input:c}))}function Ie(t){let n=t.code||t.key;if(h.current.delete(n)){t.preventDefault(),t.stopPropagation();return}let r=m.current.get(n),i=r?.targetId??e.activeTargetId,a=!ie&&(e.captured||dM(l.current)===l.current||!!l.current?.contains(t.target));!i||!r&&!a||t.key!==`Escape`&&(t.preventDefault(),t.stopPropagation(),!(!r&&rM(t.nativeEvent))&&(!r&&!Pg(t.nativeEvent)||e.sendInput({type:`input.key`,targetId:i,action:`up`,...Ng(t.nativeEvent,`up`)})&&m.current.delete(n)))}function Le(t){t.relatedTarget instanceof Node&&t.currentTarget.contains(t.relatedTarget)||(ve(),Se(),e.setCaptured(!1))}function Re(e){let t=l.current?.getBoundingClientRect();if(!t)return;let n={x:e.clientX-t.left,y:e.clientY-t.top};y.current=n,me&&ee(n)}let ze=uM(e.phase,S!==null,e.mediaPhase,e.mediaPath,w),Be=nM(e.phase,e.mediaPhase,e.mediaSwitching),Ve=pe||Xj(e.collaboration.lastError)?null:e.collaboration.lastError;return(0,hj.jsxs)(`div`,{ref:l,tabIndex:0,onKeyDown:Fe,onKeyUp:Ie,onBlur:Le,onClick:Oe,onPointerMove:ke,onFocus:()=>{!ie&&e.activeTargetId&&xe(e.activeTargetId)},onPointerEnter:Ee,onPointerLeave:De,onPointerDown:Ae,onPointerUp:je,onPointerCancel:Me,onWheel:Pe,onContextMenu:t=>{e.captured&&t.preventDefault()},"aria-busy":T,"aria-disabled":ie,className:o,style:{position:`relative`,display:`flex`,flex:`1 1 0%`,minHeight:0,alignItems:`center`,justifyContent:`center`,overflow:`hidden`,outline:`none`,touchAction:`none`,cursor:n?void 0:`none`,...s},children:[w?(0,hj.jsx)(`div`,{style:{position:`relative`,overflow:`hidden`,background:`black`,transition:`opacity 150ms`,opacity:T?.75:1,width:de.renderedWidth,height:de.renderedHeight},children:(0,hj.jsx)(`video`,{ref:d,autoPlay:!0,muted:!0,playsInline:!0,"data-viewport-width":oe,"data-viewport-height":se,style:{position:`absolute`,top:0,left:0,maxWidth:`none`,objectFit:`fill`,width:de.renderedWidth*((ae?.canvasWidth??E)/E),height:de.renderedHeight*((ae?.canvasHeight??ue)/ue)}})}):S?(0,hj.jsx)(`div`,{style:{position:`relative`,overflow:`hidden`,background:`black`,width:de.renderedWidth,height:de.renderedHeight},children:(0,hj.jsx)(`img`,{ref:u,alt:``,draggable:!1,style:{position:`absolute`,inset:0,width:`100%`,height:`100%`,objectFit:`contain`}})}):null,e.activeTargetId?(0,hj.jsx)(Vj,{collaboration:e.collaboration,targetId:e.activeTargetId,enabled:re,visible:!e.mediaSwitching&&!T&&(w||S!==null),left:de.offsetX,top:de.offsetY,width:de.renderedWidth,height:de.renderedHeight}):null,c?.({status:ze,placeholder:w||S?null:Be,cursorHint:me&&he?{text:me,...he}:null,followedCursor:D&&ge?{name:ge.name,...D}:null,collaborationError:Ve?.message??null})]})}function Jj(e){return e===`disconnected`||e===`error`?`Session disconnected`:null}function Yj(e){return e.holderClientId!==null&&e.holderClientId!==e.clientId?`Input in use`:e.hasControl?null:e.lastError?.code===`input_busy`||e.lastError?.code===`input_not_owned`?`Input in use`:e.lastError?.code===`input_unavailable`?`Input unavailable`:null}function Xj(e){return e?.code===`input_busy`||e?.code===`input_not_owned`}function Zj(e,t,n){t.pending=n,Qj(e,t)}function Qj(e,t){if(t.decodingFrame!==null||t.pending===null)return;let n=t.pending,r=t.generation;t.pending=null,t.decodingFrame=n,$j(e,n).then(()=>{t.generation===r&&(t.decodingFrame=null,Qj(e,t))})}async function $j(e,t){let n=e.src,r=URL.createObjectURL(t.data);e.src=r;try{await e.decode()}catch{}finally{n.startsWith(`blob:`)&&URL.revokeObjectURL(n),e.src!==r&&URL.revokeObjectURL(r)}}function eM(e,t){tM(t);let n=e.src;e.removeAttribute(`src`),n.startsWith(`blob:`)&&URL.revokeObjectURL(n)}function tM(e){e.generation+=1,e.decodingFrame=null,e.pending=null}function nM(e,t,n){return e===`connecting`?`connecting`:e===`connected`&&t===`connecting`?`connecting-media`:e===`connected`&&n?`switching`:e===`disconnected`||e===`error`?`disconnected`:`waiting`}function rM(e){if(!(e.metaKey||e.ctrlKey)||e.altKey)return null;switch(e.code){case`KeyC`:return`copy`;case`KeyX`:return`cut`;case`KeyV`:return`paste`;default:return null}}function iM(e){return e===0?`left`:e===1?`middle`:e===2?`right`:`none`}function aM(e,t,n,r,i){return i&&i.targetId===e&&i.button===t&&r-i.time<=Gj&&Math.abs(i.point.x-n.x)<=Kj&&Math.abs(i.point.y-n.y)<=Kj?Math.min(i.clickCount+1,3):1}function oM(e){switch(e){case`left`:return 1;case`right`:return 2;case`middle`:return 4;case`none`:return 0;default:return e}}function sM(e,t,n){return Math.min(Math.max(e,t),n)}function cM(e,t){return e===WheelEvent.DOM_DELTA_LINE?16:e===WheelEvent.DOM_DELTA_PAGE?t:1}async function lM(e,t){if(!e.activeTargetId)return;let n=``;try{n=await navigator.clipboard.readText()}catch(e){console.warn(`Clipboard read failed`,e),t?.({level:`error`,message:`Clipboard read failed`});return}n&&e.sendInput({type:`clipboard.paste`,targetId:e.activeTargetId,items:[{mimeType:`text/plain`,data:n}]})}function uM(e,t,n,r,i){return e===`connected`?n===`live`&&i?`webrtc`:t?r===`websocket-live`?`websocket`:`webrtc`:`offline`:`offline`}function dM(e){let t=e?.getRootNode();return t instanceof Document||t instanceof ShadowRoot?t.activeElement:null}var fM=[],pM=`aperture.viewport.auto-size-default`;function mM({access:e,displayName:t,enabled:n=!0,webrtcProducerSupported:r=!1,webrtcIceServers:i=fM,onNotice:a}){let o=bj(),s=(0,$.useRef)(a);s.current=a;let c=(e,t)=>F(()=>s.current?.({level:e,message:t})),[l,u]=(0,$.useState)(gM),[d,f]=(0,$.useState)(()=>l),p=(0,$.useRef)(d);p.current=d;let m=(0,$.useCallback)(()=>p.current,[]),h=Oj({access:e,displayName:t,enabled:n&&e!==null,webrtcSupported:r,iceServers:i,autoSize:m}),g=h.collaboration.role,[_,v]=(0,$.useState)([]),y=(0,$.useMemo)(()=>hM(_,h.targets),[h.targets,_]),b=(0,$.useRef)(h.targets);b.current=h.targets;let x=(0,$.useRef)(h.phase);x.current=h.phase;let[ee,S]=(0,$.useState)(bA),[C,te]=(0,$.useState)(null),[ne,w]=(0,$.useState)(!1),[T,re]=(0,$.useState)(!1),ie=g===`owner`||g===`editor`,ae=(0,$.useMemo)(()=>e===null?null:t=>qA(e,t),[e]),oe=(0,$.useRef)(null),se=(0,$.useRef)(ee),ce=(0,$.useRef)(bA),le=(0,$.useRef)(null);oe.current=h.activeTargetId,se.current=ee,le.current=C,(0,$.useEffect)(()=>{h.phase!==`connected`&&w(!1)},[h.phase]),(0,$.useEffect)(()=>{if(!h.mediaSize)return;let e=se.current;e.width===h.mediaSize.width&&e.height===h.mediaSize.height&&e.deviceScaleFactor===h.mediaSize.deviceScaleFactor||S(_M(h.mediaSize,h.mediaSize.deviceScaleFactor))},[h.mediaSize]);let E=(0,$.useCallback)(t=>!n||e===null?!1:h.sendBrowserInput(t,ce.current),[e,n,h]),ue=(0,$.useCallback)(e=>{h.selectTarget(e)},[h]),de=(0,$.useCallback)((e,t,n)=>{e!==t&&v(r=>{let i=hM(r,b.current).map(e=>e.id),a=i.indexOf(e),o=i.indexOf(t),s=i[a];if(a===-1||o===-1||!s)return r;let c=[...i];c.splice(a,1);let l=n===`after`?o+1:o,u=a<l?l-1:l;return u===a?r:(c.splice(u,0,s),c)})},[]),fe=(0,$.useCallback)(e=>o.runPromise(h.request(`target.create`,{url:e}).pipe(Tf(e=>e.targetId??null),kf(e=>c(`error`,yM(e,`Tab could not be created`)).pipe(Ef(null))))),[h,o]),pe=(0,$.useCallback)((e=`about:blank`)=>{fe(e)},[fe]),me=(0,$.useCallback)(e=>{fe(e.url||`about:blank`).then(t=>{t&&de(t,e.id,`after`)})},[fe,de]),he=(0,$.useCallback)(e=>{h.command(`target.close`,{targetId:e})},[h]),ge=(0,$.useCallback)(e=>{let t=oe.current;t&&h.command(`page.navigate`,{targetId:t,url:e})},[h]),_e=(0,$.useCallback)(e=>{h.command(`page.reload`,{targetId:e})},[h]),D=(0,$.useCallback)(()=>{let e=oe.current;e&&h.command(`page.stop-loading`,{targetId:e})},[h]),ve=(0,$.useCallback)(()=>{let e=oe.current;e&&h.command(`page.history-back`,{targetId:e})},[h]),ye=(0,$.useCallback)(()=>{let e=oe.current;e&&h.command(`page.history-forward`,{targetId:e})},[h]),be=h.viewportOwnership,xe=(0,$.useRef)(be);xe.current=be;let Se=d&&(be===null||be.ownerClientId===h.collaboration.clientId),Ce=(0,$.useRef)(Se);Ce.current=Se,(0,$.useEffect)(()=>{be!==null&&(p.current=be.autoSize,f(be.autoSize))},[be]);let we=Sj(e=>h.request(`viewport.set`,e).pipe(Ff),[h.request]),Te=(0,$.useCallback)((e,t)=>{S(e);let n=oe.current;if(n===null)return;let r={targetId:n,width:e.width,height:e.height,deviceScaleFactor:e.deviceScaleFactor};t&&xe.current!==null?we({...r,autoSize:!0}):h.command(`viewport.set`,r)},[h.command,we]),Ee=(0,$.useCallback)(e=>{p.current!==e&&(p.current=e,f(e),xe.current!==null&&h.command(`viewport.auto-size.set`,{enabled:e}))},[h.command]);(0,$.useEffect)(()=>{let e=le.current;Se&&h.phase===`connected`&&h.activeTargetId!==null&&e!==null&&Te(_M(e,se.current.deviceScaleFactor),!0)},[Te,h.activeTargetId,h.phase,Se]);let De=(0,$.useCallback)(e=>{Ee(!1),Te(e,!1)},[Te,Ee]),Oe=(0,$.useCallback)(e=>{let t={width:Math.round(e.width),height:Math.round(e.height)};if(t.width<1||t.height<1)return;let n=le.current;n?.width===t.width&&n.height===t.height||(le.current=t,te(t),Ce.current&&Te(_M(t,se.current.deviceScaleFactor),!0))},[Te]),ke=(0,$.useCallback)(()=>{let e=le.current;e&&(Ee(!1),Te(_M(e,se.current.deviceScaleFactor),!1))},[Te,Ee]),Ae=(0,$.useCallback)(()=>{p.current=!0,f(!0),h.command(`viewport.owner.claim`)},[h.command]),je=(0,$.useCallback)(e=>{u(e);try{window.localStorage.setItem(pM,String(e))}catch{}},[]),Me=(e,t)=>e.pipe(kf(e=>c(`error`,yM(e,t))),Qf(F(()=>re(!1)))),Ne=Sj((e,t,n)=>Me(h.request(`recording.start`,{mode:e,targetId:t,...n}),`Recording failed to start`),[h]),Pe=(0,$.useCallback)((e,t)=>{let n=oe.current;!n||!ie||T||(re(!0),Ne(e,n,t))},[ie,T,Ne]),Fe=Sj((e,t)=>Me(h.request(`recording.stop`,{recordingId:t}).pipe(Sf(KA(e,t)),L(({blob:n,filename:r})=>{let i=h.recordings.find(e=>e.recordingId===t);return vM(n,r??`${e.sessionId}-${i?.targetId??`target`}-${t}.webm`)}),Sf(c(`success`,`Recording saved`))),`Recording failed to stop`),[h]),Ie=(0,$.useCallback)(t=>{e===null||T||(re(!0),Fe(e,t))},[e,T,Fe]),Le=Sj(e=>Me(h.request(`recording.cancel`,{recordingId:e}).pipe(Sf(c(`success`,`Recording stopped`))),`Recording failed to stop`),[h]),Re=(0,$.useCallback)(e=>{T||(re(!0),Le(e))},[T,Le]),ze=Sj(e=>h.request(`presentation.cursor.set`,{visible:e}).pipe(kf(e=>c(`error`,yM(e,`Remote cursor could not be updated`)))),[h]),Be=(0,$.useCallback)(t=>{e!==null&&ze(t)},[e,ze]),[Ve,He]=(0,$.useState)(!1),Ue=(0,$.useRef)(h.command);Ue.current=h.command,(0,$.useEffect)(()=>{h.phase===`connected`&&ie&&Ue.current(`automation.pacing.set`,{pacing:Ve?`watchable`:`normal`})},[h.phase,ie,Ve]);let We=Sj(e=>h.selectPresentation(e).pipe(kf(e=>c(`error`,yM(e,`Presentation could not be updated`)))),[h]),Ge=(0,$.useCallback)(t=>!n||e===null||h.mediaSwitching?!1:(We(t),!0),[e,n,h.mediaSwitching,We]),Ke=(0,$.useCallback)(e=>Ge({kind:`webrtc`,quality:e}),[Ge]),qe=(0,$.useMemo)(()=>{let e=e=>uf(()=>x.current===`connected`?e:I(new JA({message:`the session is not connected`}))),t=(t,n)=>e(h.request(t,n)),n=(t,n={})=>e(uf(()=>{let e=oe.current;return e?h.request(t,{targetId:e,...n}):I(new JA({message:`no tab is active`}))})).pipe(Of);return{navigate:e=>n(`page.navigate`,{url:e}),historyBack:()=>n(`page.history-back`),historyForward:()=>n(`page.history-forward`),reload:e=>e?t(`page.reload`,{targetId:e}).pipe(Of):n(`page.reload`),stopLoading:()=>n(`page.stop-loading`),createTarget:(e=`about:blank`)=>t(`target.create`,{url:e}).pipe(Tf(e=>e.targetId??null)),closeTarget:e=>t(`target.close`,{targetId:e}).pipe(Of),activateTarget:t=>e(h.requestSelectTarget(t))}},[h.request,h.requestSelectTarget]),Je=(0,$.useMemo)(()=>y.find(e=>e.id===h.activeTargetId)??null,[h.activeTargetId,y]),Ye=h.transport===`webrtc`?`webrtc-live`:`websocket-live`,Xe=h.phase===`connected`?`live`:h.phase===`connecting`?`connecting`:h.phase===`error`?`failed`:`idle`;return{phase:h.phase,targets:y,activeTargetId:h.activeTargetId,activeTarget:Je,frames:h.frames,mediaPhase:Xe,mediaStream:h.mediaStream,mediaStreamSettings:h.presentation?.quality??null,mediaVideoProfiles:h.presentation?.profiles??[],mediaSize:h.mediaSize,mediaPath:Ye,mediaTargetId:h.activeTargetId,mediaSwitching:h.mediaSwitching,viewport:ee,browserViewportSize:C,viewportAutoSync:d,viewportAutoSizeActive:Se,viewportOwnership:be,viewportAutoSizeDefault:l,captured:ne,recordings:h.recordings,canRecord:ie,loadTargetThumbnail:ae,recordingBusy:T,remoteCursorEnabled:h.presentation?.cursorVisible??!0,watchableAutomation:Ve,collaboration:h.collaboration,commands:qe,setCaptured:w,setInputDimensions:e=>{ce.current=e},setViewport:De,setBrowserViewportSize:Oe,setViewportAutoSync:Ee,setViewportToBrowserSize:ke,setViewportAutoSizeDefault:je,takeOverViewport:Ae,setWebRTCStreamSettings:Ke,selectMediaStream:Ge,sendInput:E,activateTarget:ue,reorderTargets:de,createTarget:pe,duplicateTarget:me,closeTarget:he,navigate:ge,reload:_e,stopLoading:D,historyBack:ve,historyForward:ye,startRecording:Pe,stopRecording:Ie,cancelRecording:Re,setRemoteCursorEnabled:Be,setWatchableAutomation:He,reconnect:h.reconnect}}function hM(e,t){let n=new Map(t.map(e=>[e.id,e])),r=new Set,i=[];for(let t of e){let e=n.get(t);e&&(i.push(e),r.add(e.id))}for(let e of t)r.has(e.id)||i.push(e);return i}function gM(){try{return window.localStorage.getItem(pM)===`true`}catch{return!1}}function _M(e,t){return SA(e.width,e.height,t)}var vM=(e,t)=>Xf(F(()=>URL.createObjectURL(e)),e=>F(()=>{let n=document.createElement(`a`);n.href=e,n.download=t,n.click()}),e=>F(()=>URL.revokeObjectURL(e)).pipe(Lf(0)));function yM(e,t){return e instanceof Error&&e.message?e.message:t}var bM=`~effect/ManagedRuntime`,xM=(e,t)=>{let n=t?.memoMap??id(),r=Uu(`sequential`),i=qu(r,`sequential`),a={onFiberStart:Pp(qu(r,`parallel`))},o=e=>e?{...e,onFiberStart:e.onFiberStart?t=>{a.onFiberStart(t),e.onFiberStart(t)}:a.onFiberStart}:a,s,c=bf(t=>(s||=fp(Cf(sd(e,n,i),e=>F(()=>{l.cachedContext=e})),{...a,scheduler:t.cache.scheduler}),xf(Ap(s)))),l={[bM]:bM,memoMap:n,scope:r,contextEffect:c,cachedContext:void 0,context(){return l.cachedContext===void 0?gp(l.contextEffect):Promise.resolve(l.cachedContext)},dispose(){return gp(l.disposeEffect)},[Symbol.asyncDispose](){return l.dispose()},disposeEffect:uf(()=>(l.contextEffect=_f(`ManagedRuntime disposed`),l.cachedContext=void 0,Ju(l.scope,Au))),runFork(e,t){return l.cachedContext===void 0?fp(SM(l,e),o(t)):pp(l.cachedContext)(e,o(t))},runCallback(e,t){return l.cachedContext===void 0?hp(SM(l,e),o(t)):mp(l.cachedContext)(e,o(t))},runSyncExit(e){return l.cachedContext===void 0?Sp(SM(l,e)):Cp(l.cachedContext)(e)},runSync(e){return l.cachedContext===void 0?bp(SM(l,e)):xp(l.cachedContext)(e)},runPromiseExit(e,t){return l.cachedContext===void 0?vp(SM(l,e),o(t)):yp(l.cachedContext)(e,o(t))},runPromise(e,t){return l.cachedContext===void 0?gp(SM(l,e),o(t)):_p(l.cachedContext)(e,o(t))}};return l};function SM(e,t){return L(e.contextEffect,e=>Gf(t,e))}var CM=(e={})=>xM(hd(RA,tA.pipe(_d(e.baseUrl?nA(e.baseUrl):ud),_d(RA)),cd(xT,!1)));function wM({baseUrl:e,children:t}){let[n,r]=(0,$.useState)(null);return(0,$.useEffect)(()=>{let t=CM({baseUrl:e});return r(t),()=>{r(null),t.dispose()}},[e]),n?(0,hj.jsx)(vj,{runtime:n,baseUrl:e,children:t}):null}function TM(e,t){let n=e.slice(4,40);return!(e.startsWith(`ape_`)||e.startsWith(`apv_`))||e[40]!==`_`||e.length<=41?null:{kind:`direct`,baseUrl:t,sessionId:n,credentials:{kind:`bearer`,token:y_(e),authorityType:null,tenantId:null,selectedTenantId:null}}}var EM=[];function DM(e){return e===401||e===403?`denied`:e===410?`expired`:`unavailable`}function OM({access:e,displayName:t,onNotice:n}){let[r,i]=(0,$.useState)({access:null,status:`loading`,browser:null});xj(()=>{if(e!==null)return i({access:e,status:`loading`,browser:null}),GA(e).pipe(Vf({onFailure:t=>i({access:e,status:DM(t.status),browser:null}),onSuccess:t=>i(e.kind===`direct`&&t.sessionId!==e.sessionId?{access:e,status:`unavailable`,browser:null}:{access:e,status:`ready`,browser:t})}))},[e]);let a=r.access===e?r.browser:null,o=mM({access:a===null?null:e,displayName:t,webrtcProducerSupported:a?.media.mode===`auto`&&a.media.webrtcProducer,webrtcIceServers:a?.media.iceServers??EM,onNotice:n});return{status:e===null?`invalid`:r.access===e?r.status:`loading`,browser:a,control:o}}function kM(){let e=null;return t=>{let n=t.getAttribute(`token`),r=t.getAttribute(`base-url`);return(e===null||e.token!==n||e.baseUrl!==r)&&(e={token:n,baseUrl:r,access:n===null?null:TM(n,r??void 0)}),e.access}}export{lf as A,mf as C,Jf as D,gp as E,g as F,m as I,f as L,Qd as M,Da as N,uf as O,ur as P,o as R,I as S,sp as T,BC as _,Sj as a,Af as b,JA as c,SA as d,CA as f,KS as g,US as h,qj as i,df as j,F as k,xA as l,VS as m,OM as n,xj as o,kk as p,wM as r,mj as s,kM as t,yA as u,Zf as v,pf as w,kf as x,Sf as y,c as z};
28
+ `;return rg(Hk.encode(n)).pipe(mg(Wk(e.content)),mg(rg(Hk.encode(`\r
29
+ `))))})).pipe(pg(),mg(rg(Hk.encode(`--${t}--\r\n`)))),`multipart/form-data; boundary=${t}`)}),Kk=R(`SessionsApi.uploadBody`)(function*(e){let t=new FormData;for(let n of e)if(n.content instanceof Blob)t.append(`files`,n.content,n.name);else if(n.content instanceof Uint8Array)t.append(`files`,new Blob([new Uint8Array(n.content)]),n.name);else return yield*Gk(e);return uw(t)}),qk=e=>e?.match(/filename="([^"]+)"/)?.[1]??null,Jk=(e,t)=>`/sessions/${encodeURIComponent(e)}/recordings/${encodeURIComponent(t)}/content`,Yk=100,Xk=dd(Rk,mf(function*(){let e=yield*dT,{authorize:t}=yield*WO,n=pT(e),r=zO(e),i=e=>t(UO.tenantScoped(e)),a=R(`SessionsApi.listSessions`)(function*(e,t={}){return yield*r.listSessions({params:Dk({limit:t.limit,cursor:t.cursor,includeDeleted:t.includeDeleted||void 0,status:t.status,query:t.query,...Ek(t.tags)})}).pipe(i(e))}),o=Tk(a),s=R(`SessionsApi.exportSessionStorageState`)(function*(e,t,n){return yield*r.exportSessionStorageState(t,{payload:n}).pipe(i(e))}),c=R(`SessionsApi.getSession`)(function*(e,t){return yield*r.getSession(t,void 0).pipe(i(e))}),l=R(`SessionsApi.getSessionsBulk`)(function*(e,t){return{sessions:(yield*of(ca(t,Yk),t=>r.getSessionsBulk({payload:{ids:t}}).pipe(i(e)))).flatMap(e=>e.sessions)}}),u=R(`SessionsApi.createSession`)(function*(e,t,n={}){return yield*r.createSession({params:Dk({waitForReady:n.waitForReady}),payload:KS(ZD)({baseSnapshotName:t.baseSnapshotName??null,label:t.label??null,browser:{channel:t.browser.channel,args:t.browser.args??[]},initialTargets:t.initialTargets??[],...t.storageState===void 0?{}:{storageState:t.storageState},tags:t.tags??{},...t.proxy===void 0?{}:{proxy:t.proxy}})}).pipe(i(e))}),d=R(`SessionsApi.deleteSession`)(function*(e,t){return yield*r.deleteSession(t,void 0).pipe(i(e))}),f=R(`SessionsApi.reopenSession`)(function*(e,t){return yield*r.reopenSession(t,void 0).pipe(i(e))}),p=R(`SessionsApi.suspendSession`)(function*(e,t){return yield*r.suspendSession(t,void 0).pipe(i(e))}),m=R(`SessionsApi.rotateSessionToken`)(function*(e,t){return yield*r.rotateSessionToken(t,void 0).pipe(i(e))}),h=R(`SessionsApi.rotateCollaborationCapability`)(function*(e,t,n){return yield*r.rotateCollaborationCapability(t,n,void 0).pipe(i(e))}),g=R(`SessionsApi.replaceSessionTags`)(function*(e,t,n){return yield*r.replaceSessionTags(t,{payload:{tags:n}}).pipe(i(e))}),_=R(`SessionsApi.updateSessionProxy`)(function*(e,t,n){return yield*r.updateSessionProxy(t,{payload:KS(rO)(n)}).pipe(i(e))}),v=R(`SessionsApi.promoteSession`)(function*(e,t,n){return yield*r.promoteSession(t,{payload:{name:n.name,description:n.description??null,force:n.force??!1,tags:n.tags??{}}}).pipe(i(e))}),y=R(`SessionsApi.getSessionCursor`)(function*(e,t){return yield*r.getSessionCursor(t,void 0).pipe(i(e))}),b=R(`SessionsApi.setSessionCursor`)(function*(e,t,n){return yield*r.setSessionCursor(t,{payload:{visible:n}}).pipe(i(e))}),x=R(`SessionsApi.listSessionRecordings`)(function*(e,t){return yield*r.listSessionRecordings(t,void 0).pipe(i(e))}),ee=R(`SessionsApi.createSessionRecording`)(function*(e,t,n){return yield*r.createSessionRecording(t,{payload:n}).pipe(i(e))}),S=R(`SessionsApi.getSessionRecording`)(function*(e,t,n){return yield*r.getSessionRecording(t,n,void 0).pipe(i(e))}),C=R(`SessionsApi.retargetSessionRecording`)(function*(e,t,n,a){return yield*r.retargetSessionRecording(t,n,{payload:{targetId:a}}).pipe(i(e))}),te=R(`SessionsApi.stopSessionRecording`)(function*(e,t,n){return yield*r.stopSessionRecording(t,n,void 0).pipe(i(e))}),ne=R(`SessionsApi.listSessionFiles`)(function*(e,t){return yield*r.listSessionFiles(t,void 0).pipe(i(e))}),w=R(`SessionsApi.captionSessionRecording`)(function*(e,t,n,a){yield*r.captionSessionRecording(t,n,{payload:a}).pipe(i(e))}),T=R(`SessionsApi.focusSessionRecording`)(function*(e,t,n,a){yield*r.focusSessionRecording(t,n,{payload:a}).pipe(i(e))}),re=R(`SessionsApi.resetFocusSessionRecording`)(function*(e,t,n){yield*r.resetFocusSessionRecording(t,n,void 0).pipe(i(e))}),ie=R(`SessionsApi.attentionSessionRecording`)(function*(e,t,n,a){yield*r.attentionSessionRecording(t,n,{payload:a}).pipe(i(e))}),ae=R(`SessionsApi.createSessionFileDownloadURL`)(function*(e,t,n){return yield*r.createSessionFileDownloadURL(t,{payload:n}).pipe(i(e))}),oe=R(`SessionsApi.getBrowserChannels`)(function*(e){return yield*r.listBrowserChannels(void 0).pipe(i(e))}),se=R(`SessionsApi.getBrowserStatus`)(function*(e,r,i){return yield*n.get(`/sessions/${encodeURIComponent(r)}/browser/status`).pipe(L(rT(Fk)),t({credentials:e,bearerToken:i,tenantHeader:`tenant-scoped`}))}),ce=R(`SessionsApi.downloadSessionRecording`)(function*(e,r,i,a){return yield*n.get(Jk(r,i)).pipe(L(e=>Tf(e.arrayBuffer,t=>({blob:new Blob([t],{type:e.headers[`content-type`]??``}),filename:qk(e.headers[`content-disposition`])}))),t({credentials:e,bearerToken:a,tenantHeader:`tenant-scoped`}))}),le=R(`SessionsApi.getSessionThumbnail`)(function*(e,r,i){let a=`/api/sessions/${encodeURIComponent(r)}`,o=i===void 0?`${a}/thumbnail`:`${a}/targets/${encodeURIComponent(i)}/thumbnail`;return yield*n.get(o).pipe(L(e=>Tf(e.arrayBuffer,e=>new Blob([e],{type:`image/jpeg`}))),t({credentials:e,tenantHeader:`tenant-scoped`}))}),E=(e,r,i,a)=>n.get(Jk(r,i)).pipe(t({credentials:e,bearerToken:a,tenantHeader:`tenant-scoped`}),Tf(e=>e.stream.pipe(yg(`HttpClientError`,e=>$h(gk(I(e)))))),dg),ue=R(`SessionsApi.uploadSessionFiles`)(function*(e,t,r,a={}){let o=yield*Kk(r);return(yield*n.post(`/api/sessions/${encodeURIComponent(t)}/files`,{body:o,urlParams:Dk({directory:a.directory})}).pipe(L(rT(wO)),i(e))).files}),de=R(`SessionsApi.deleteSessionFile`)(function*(e,t,n,a={}){yield*r.deleteSessionFile(t,{params:Dk({relativePath:n,recursive:a.recursive})}).pipe(i(e))}),fe=R(`SessionsApi.createSessionDirectory`)(function*(e,t,n){return yield*r.createSessionDirectory(t,{payload:{relativePath:n}}).pipe(i(e))}),pe=R(`SessionsApi.moveSessionFile`)(function*(e,t,n){return yield*r.moveSessionFile(t,{payload:n}).pipe(i(e))}),me=R(`SessionsApi.uploadLiveSessionFiles`)(function*(e,r,i,a){let o=yield*Kk(i);return(yield*n.post(`/sessions/${encodeURIComponent(r)}/uploads`,{body:o}).pipe(L(rT(IO)),t({credentials:e,bearerToken:a,tenantHeader:`tenant-scoped`}))).files}),he=R(`SessionsApi.setSessionViewport`)(function*(e,n,i,a){return yield*r.setSessionViewport(n,{payload:i}).pipe(t({credentials:e,bearerToken:a,tenantHeader:`tenant-scoped`}))});return Rk.of({listSessions:a,streamSessions:o.stream,listAllSessions:o.listAll,getSession:c,exportSessionStorageState:s,getSessionsBulk:l,createSession:u,deleteSession:d,reopenSession:f,suspendSession:p,rotateSessionToken:m,rotateCollaborationCapability:h,replaceSessionTags:g,updateSessionProxy:_,promoteSession:v,getSessionCursor:y,setSessionCursor:b,listSessionRecordings:x,createSessionRecording:ee,getSessionRecording:S,retargetSessionRecording:C,stopSessionRecording:te,captionSessionRecording:w,focusSessionRecording:T,resetFocusSessionRecording:re,attentionSessionRecording:ie,listSessionFiles:ne,createSessionFileDownloadURL:ae,getBrowserChannels:oe,getBrowserStatus:se,downloadSessionRecording:ce,getSessionThumbnail:le,streamSessionRecording:E,uploadSessionFiles:ue,uploadLiveSessionFiles:me,deleteSessionFile:de,moveSessionFile:pe,createSessionDirectory:fe,setSessionViewport:he})})),Zk=class extends vr()(`@aperture-browser/api-client/SnapshotsApi`){},Qk=dd(Zk,mf(function*(){let e=yield*dT,{authorize:t}=yield*WO,n=zO(e),r=e=>t(UO.tenantScoped(e)),i=R(`SnapshotsApi.listSnapshots`)(function*(e,t={}){return yield*n.listSnapshots({params:Dk({limit:t.limit,cursor:t.cursor,includeDeleted:t.includeDeleted||void 0,deleted:t.deleted,name:t.name,...Ek(t.tags)})}).pipe(r(e))}),a=Tk(i),o=R(`SnapshotsApi.getSnapshotByName`)(function*(e,t){return yield*a.stream(e,{name:t,limit:100}).pipe(_g(e=>e.name===t),Sg)}),s=R(`SnapshotsApi.updateSnapshot`)(function*(e,t,i){return yield*n.updateSnapshot(t,{payload:i}).pipe(r(e))}),c=R(`SnapshotsApi.replaceSnapshotTags`)(function*(e,t,i){return yield*n.replaceSnapshotTags(t,{payload:{tags:i}}).pipe(r(e))}),l=R(`SnapshotsApi.deleteSnapshot`)(function*(e,t){return yield*n.deleteSnapshot(t,void 0).pipe(r(e))}),u=R(`SnapshotsApi.restoreSnapshot`)(function*(e,t){return yield*n.restoreSnapshot(t,void 0).pipe(r(e))});return Zk.of({listSnapshots:i,streamSnapshots:a.stream,listAllSnapshots:a.listAll,getSnapshotByName:o,updateSnapshot:s,replaceSnapshotTags:c,deleteSnapshot:l,restoreSnapshot:u})})),$k=class extends vr()(`@aperture-browser/api-client/TenantsApi`){},eA=dd($k,mf(function*(){let e=yield*dT,{authorize:t}=yield*WO,n=zO(e),r=R(`TenantsApi.listTenants`)(function*(e,r={}){return yield*n.listTenants({params:Dk({limit:r.limit,cursor:r.cursor,includeDeleted:r.includeDeleted||void 0,deleted:r.deleted,query:r.query})}).pipe(t(UO.of(e)))}),i=Tk(r),a=R(`TenantsApi.getCurrentTenant`)(function*(e){return yield*n.getTenant(void 0).pipe(t(UO.tenantScoped(e)))}),o=R(`TenantsApi.updateCurrentTenant`)(function*(e,r){return yield*n.updateSelectedTenant({payload:r}).pipe(t(UO.tenantScoped(e)))}),s=R(`TenantsApi.createTenant`)(function*(e,r){return yield*n.createTenant({payload:r}).pipe(t(UO.of(e)))}),c=R(`TenantsApi.updateTenant`)(function*(e,r,i){return yield*n.updateTenant(r,{payload:i}).pipe(t(UO.of(e)))}),l=R(`TenantsApi.deleteTenant`)(function*(e,r){return yield*n.deleteTenant(r,void 0).pipe(t(UO.of(e)))}),u=R(`TenantsApi.restoreTenant`)(function*(e,r){return yield*n.restoreTenant(r,void 0).pipe(t(UO.of(e)))});return $k.of({listTenants:r,streamTenants:i.stream,listAllTenants:i.listAll,createTenant:s,updateTenant:c,deleteTenant:l,restoreTenant:u,getCurrentTenant:a,updateCurrentTenant:o})})),tA=class extends vr()(`@aperture-browser/api-client/TokensApi`){},nA=dd(tA,mf(function*(){let e=yield*dT,{authorize:t}=yield*WO,n=zO(e),r=R(`TokensApi.listAdminTokens`)(function*(e,r={}){return yield*n.listAdminTokens({params:Dk({limit:r.limit,cursor:r.cursor,tenantId:r.tenantId,name:r.name,authorityType:r.authorityType,revoked:r.revoked,scope:r.scope})}).pipe(t(UO.of(e)))}),i=Tk(r),a=R(`TokensApi.createAdminToken`)(function*(e,r){let i=r.authorityType===`system_admin`;return yield*n.createAdminToken({payload:{name:r.name,authorityType:r.authorityType,tenantId:r.tenantId??null,scopes:r.scopes,resourceMode:i?`all`:r.resourceMode,resourceGrants:i?[]:r.resourceGrants,expiresAt:r.expiresAt??null}}).pipe(t(UO.of(e)))}),o=R(`TokensApi.revokeAdminToken`)(function*(e,r){yield*n.revokeAdminToken(r,void 0).pipe(t(UO.of(e)))}),s=R(`TokensApi.listTenantTokens`)(function*(e,r={}){return yield*n.listTenantTokens({params:Dk({limit:r.limit,cursor:r.cursor,name:r.name,revoked:r.revoked,scope:r.scope})}).pipe(t(UO.tenantScoped(e)))}),c=Tk(s),l=R(`TokensApi.createTenantToken`)(function*(e,r){return yield*n.createTenantToken({payload:{name:r.name,scopes:r.scopes,resourceMode:r.resourceMode,resourceGrants:r.resourceGrants,expiresAt:r.expiresAt??null}}).pipe(t(UO.tenantScoped(e)))}),u=R(`TokensApi.revokeTenantToken`)(function*(e,r){yield*n.revokeTenantToken(r,void 0).pipe(t(UO.tenantScoped(e)))});return tA.of({listAdminTokens:r,streamAdminTokens:i.stream,listAllAdminTokens:i.listAll,createAdminToken:a,revokeAdminToken:o,listTenantTokens:s,streamTenantTokens:c.stream,listAllTenantTokens:c.listAll,createTenantToken:l,revokeTenantToken:u})})),rA=class extends vr()(`@aperture-browser/api-client/UsersApi`){},iA=hd(fk,eA,dd(rA,mf(function*(){let e=yield*dT,{authorize:t}=yield*WO,n=zO(e),r=R(`UsersApi.listUsers`)(function*(e,r={}){return yield*n.listUsers({params:Dk({limit:r.limit,cursor:r.cursor,query:r.query,disabled:r.disabled})}).pipe(t(UO.of(e)))}),i=Tk(r),a=R(`UsersApi.createUser`)(function*(e,r){return yield*n.createUser({payload:r}).pipe(t(UO.of(e)))}),o=R(`UsersApi.createPersonalTenant`)(function*(e,r){yield*n.createPersonalTenant(r,void 0).pipe(t(UO.of(e)))}),s=R(`UsersApi.deletePersonalTenant`)(function*(e,r){yield*n.deletePersonalTenant(r,void 0).pipe(t(UO.of(e)))}),c=R(`UsersApi.getUser`)(function*(e,r){return yield*n.getUser(r,void 0).pipe(t(UO.of(e)))}),l=R(`UsersApi.updateUser`)(function*(e,r,i){return yield*n.updateUser(r,{payload:i}).pipe(t(UO.of(e)))}),u=R(`UsersApi.createUserInvitation`)(function*(e,r){return yield*n.createUserInvitation(r,void 0).pipe(t(UO.of(e)))}),d=R(`UsersApi.disableUser`)(function*(e,r){return yield*n.disableUser(r,void 0).pipe(t(UO.of(e)))}),f=R(`UsersApi.restoreUser`)(function*(e,r){return yield*n.restoreUser(r,void 0).pipe(t(UO.of(e)))}),p=R(`UsersApi.listUserMemberships`)(function*(e,r){return yield*n.listUserMemberships(r,void 0).pipe(t(UO.of(e)))}),m=R(`UsersApi.listTenantMemberships`)(function*(e,r){return yield*n.listTenantMemberships(r,void 0).pipe(t(UO.of(e)))}),h=R(`UsersApi.upsertTenantMembership`)(function*(e,r,i,a){let o={scopes:a};return yield*n.upsertTenantMembership(r,i,{payload:o}).pipe(t(UO.of(e)))}),g=R(`UsersApi.deleteTenantMembership`)(function*(e,r,i){yield*n.deleteTenantMembership(r,i,void 0).pipe(t(UO.of(e)))});return rA.of({listUsers:r,streamUsers:i.stream,listAllUsers:i.listAll,createUser:a,getUser:c,updateUser:l,createUserInvitation:u,disableUser:d,restoreUser:f,createPersonalTenant:o,deletePersonalTenant:s,listUserMemberships:p,listTenantMemberships:m,upsertTenantMembership:h,deleteTenantMembership:g})})),Xk,Qk,nA,Ok,kk).pipe(_d(bk),vd(xk)),aA=e=>dd(dT,Tf(dT,_T(Jw(e)))),oA=`aperture-session.v1`,sA={onExcessProperty:`error`},cA=H.check(Y()),lA=H.check(TC(0)),uA=cA.check(TC(0)),dA=H.check(DC({minimum:0,maximum:1})),fA=P([]);function pA(e){return G(e).pipe(fC(fA))}var mA=q([`implicit`,`explicit`]),hA=W({profile:V,fps:cA.check(DC({minimum:1,maximum:120})),bitrateKbps:cA.check(J(100)),keyframeInterval:uA}),gA=W({id:V,label:V,codec:V,mimeType:V,sdpFmtpLine:V}),_A=W({quality:z(hA),profiles:G(gA),cursorVisible:U}),vA=W({id:V,type:V,title:V,url:V,loading:U,canGoBack:z(U),canGoForward:z(U),viewport:z(W({width:lA,height:lA,contentWidth:lA,contentHeight:lA,canvasWidth:lA,canvasHeight:lA,deviceScaleFactor:lA}))}),yA=W({clientId:V,name:V,avatarHash:V,role:q([`owner`,`editor`,`viewer`,`automation`]),activeTargetId:z(V),followingClientId:z(V),holdingInput:U,leaseMode:z(mA),recovering:z(U)}),bA=HS(BC(K([W({type:B(`session.snapshot`),clientId:V,resumeSecret:V,role:q([`owner`,`editor`,`viewer`]),transport:q([`webrtc`,`websocket`]),holderClientId:z(V),mode:z(mA),activeTargetId:z(V),targets:pA(vA),participants:pA(yA),recordings:pA(Lk),presentation:_A,viewportOwnerClientId:z(V),autoSize:z(U)}),W({type:B(`presence.state`),participants:pA(yA)}),W({type:B(`input.state`),holderClientId:z(V),mode:z(mA)}),W({type:B(`viewport.state`),viewportOwnerClientId:z(V),autoSize:U}),W({type:B(`presence.cursor`),clientId:V,targetId:V,x:dA,y:dA,realtimeCounter:uA}),W({type:B(`presence.cursor.clear`),clientId:V,realtimeCounter:uA}),W({type:B(`paint.point`),clientId:V,targetId:V,strokeId:V,color:V.check(vC(/^#[0-9a-fA-F]{6}$/)),width:H.check(DC({minimum:1,maximum:16})),phase:q([`start`,`move`,`end`]),x:dA,y:dA,realtimeCounter:z(uA)}),W({type:B(`targets.state`),activeTargetId:z(V),targets:pA(vA)}),W({type:B(`recordings.state`),recordings:pA(Lk)}),W({type:B(`presentation.state`),presentation:_A}),W({type:B(`error`),code:V,message:V}),W({type:q([`target.select.result`,`target.create.result`,`target.close.result`,`page.navigate.result`,`page.history-back.result`,`page.history-forward.result`,`page.reload.result`,`page.stop-loading.result`,`viewport.set.result`,`viewport.auto-size.set.result`,`viewport.owner.claim.result`,`presentation.quality.set.result`,`presentation.cursor.set.result`,`automation.pacing.set.result`,`recording.start.result`,`recording.stop.result`,`recording.cancel.result`]),requestId:V,ok:U,code:z(V),message:z(V),targetId:z(V),recording:z(Lk),presentation:z(_A)})])),sA),xA=W({type:B(`presentation.frame`),targetId:V,width:lA,height:lA}),SA=[TA(1280,720,1),TA(1440,900,1),TA(1920,1080,1),TA(2560,1440,1),TA(768,1024,1),TA(390,844,1)],CA=SA[0],wA=[1,1.5,2,3];function TA(e,t,n){return{id:`${e}x${t}@${EA(n)}`,label:`${e}×${t}`,width:e,height:t,deviceScaleFactor:n}}function EA(e){return Number.isInteger(e)?String(e):String(e).replace(/0+$/,``).replace(/\.$/,``)}function DA(e,t,n,r){if(n<=0||r<=0||e<=0||t<=0)return{scale:1,offsetX:0,offsetY:0,renderedWidth:e,renderedHeight:t};let i=Math.min(e/n,t/r),a=n*i,o=r*i;return{scale:i,offsetX:(e-a)/2,offsetY:(t-o)/2,renderedWidth:a,renderedHeight:o}}var OA=`~effect/FiberSet`,kA=e=>D(e,OA),AA={[OA]:OA,[Symbol.iterator](){return this.state._tag===`Closed`?Wi():this.state.backing[Symbol.iterator]()},...Lt,toJSON(){return{_id:`FiberSet`,state:this.state}}},jA=(e,t)=>{let n=Object.create(AA);return n.state={_tag:`Open`,backing:e},n.deferred=t,n},MA=()=>Yf(F(()=>jA(new Set,Fu())),e=>uf(()=>{let t=e.state;if(t._tag===`Closed`)return df;e.state={_tag:`Closed`};let n=t.backing;return Np(n).pipe(Vu(e.deferred))})),NA=()=>L(MA(),e=>RA(e)()),PA=-1,FA=ha(_a(Dd,ga(PA))),IA=b(e=>kA(e[0]),(e,t,n)=>{if(e.state._tag===`Closed`){t.interruptUnsafe(PA);return}else if(e.state.backing.has(t))return;e.state.backing.add(t),t.addObserver(r=>{e.state._tag!==`Closed`&&(e.state.backing.delete(t),Mu(r)&&(n?.propagateInterruption===!0?!FA(r.cause):!Sd(r.cause))&&Bu(e.deferred,r))})}),LA=function(){let e;return()=>(e===void 0&&(e=fp(np)),e)}(),RA=e=>()=>Tf(Uf(),t=>{let n=pp(t);return(t,r)=>{if(e.state._tag===`Closed`)return LA();let i=n(t,r);return IA(e,i,r),i}}),zA=Xr(`effect/http/FetchHttpClient/Fetch`,{defaultValue:()=>globalThis.fetch}),BA=class extends vr()(`effect/http/FetchHttpClient/RequestInit`){},VA=CT(P(gT((e,t,n,r)=>{let i=r.getRef(zA),a=Vr(r.context,BA)??{},o=a.headers?M_(O_(a.headers),e.headers):e.headers;o[`content-length`]&&(o=N_(o,`content-length`));let s=r=>Tf(lf({try:()=>i(t,{...a,method:e.method,headers:o,body:r,duplex:typeof ReadableStream<`u`&&r instanceof ReadableStream?`half`:void 0,signal:n}),catch:t=>new gw({reason:new yw({request:e,cause:t})})}),t=>oT(e,t));switch(e.body._tag){case`Raw`:case`Uint8Array`:return s(e.body.body);case`FormData`:return s(e.body.formData);case`Stream`:return L(Eg(e.body.stream),s)}return s(void 0)})));function HA(e,t){let n=new URL(e.baseUrl??`/`,window.location.href);if(n.protocol!==`http:`&&n.protocol!==`https:`)throw Error(`session base URL must use HTTP or HTTPS`);if(e.kind===`relay`&&n.origin!==window.location.origin)throw Error(`session relay must use the page's origin`);return n.pathname=`${n.pathname.replace(/\/$/,``)}/${t}`,n.search=``,n.hash=``,n}function UA(e,t){return HA(e,`sessions/${encodeURIComponent(e.sessionId)}/${t}`)}function WA(e,t){let n=UA(e,t);return n.protocol=n.protocol===`https:`?`wss:`:`ws:`,n.toString()}function GA(e){if(e.kind!==`direct`)return{token:void 0,tenantId:void 0};let{credentials:t}=e;return{token:t.kind===`bearer`?x_(t.token):void 0,tenantId:HO(t,`tenant-scoped`)}}function KA(e){let{token:t,tenantId:n}=GA(e),r=[oA];return t!==void 0&&r.push(`authorization.bearer.${t}`),n!==void 0&&r.push(`x-aperture-tenant-id.${n}`),r}function qA(e,t){let{token:n,tenantId:r}=GA(e),i={};return n!==void 0&&(i.Authorization=`Bearer ${n}`),r!==void 0&&(i[`X-Aperture-Tenant-Id`]=r),L(dT,e=>pT(e).get(t.toString(),{headers:i})).pipe(qf(BA,{credentials:n===void 0?`same-origin`:`omit`,redirect:`error`,cache:`no-store`}))}var JA=R(`getSessionStatus`)(function*(e){return yield*qA(e,UA(e,`browser/status`)).pipe(L(rT(Fk)),gk)}),YA=R(`downloadSessionRecording`)(function*(e,t){return yield*qA(e,UA(e,`recordings/${encodeURIComponent(t)}/content`)).pipe(L(e=>Tf(e.arrayBuffer,t=>({blob:new Blob([t],{type:e.headers[`content-type`]??``}),filename:qk(e.headers[`content-disposition`])}))),gk)}),XA=R(`getTargetThumbnail`)(function*(e,t){let n=`targets/${encodeURIComponent(t)}/thumbnail`,r=GA(e).token;return yield*qA(e,e.kind===`relay`||r!==void 0&&(r.startsWith(`aps_`)||r.startsWith(`ape_`)||r.startsWith(`apv_`))?UA(e,n):HA(e,`api/sessions/${encodeURIComponent(e.sessionId)}/${n}`)).pipe(L(e=>Tf(e.arrayBuffer,e=>new Blob([e],{type:`image/jpeg`}))),gk)}),ZA=class extends Da(`LiveSessionError`){},QA=VS(BC(K([W({version:B(1),type:B(`answer`),sdp:V}),W({version:B(1),type:B(`ice-candidate`),candidate:W({candidate:V,sdpMid:z(oC(V)),sdpMLineIndex:z(oC(H.check(Y()))),usernameFragment:z(oC(V))})}),W({version:B(1),type:B(`error`),error:W({code:V,message:V})})])),sA),$A=VS(BC(xA),sA),ej=5e3,tj=500,nj=15e3,rj=wp(function*(e){let{callbacks:t}=e,n=yield*NA(),r=e=>n(e),i=(e,t)=>r(Rf(e).pipe(Sf(F(t)))),a=null,o=null,s=null,c=e.webrtcSupported?`webrtc`:`websocket`,l=null,u=!1,d=null,f=null,p=1e3,m=0,h=0,g=0,_=[],v=null,y=new Map,b={hello:()=>({type:`session.hello`,...s??e.identity,...e.autoSize===void 0?{}:{autoSize:e.autoSize()}}),message:(e,t)=>oe(e,t),ready:e=>re(e),failed:(e,t)=>ae(e,t),frame:(e,n)=>{a===e?t.onFrame(n):o===e&&(v=n)}},x=()=>{o?.close(),o=null,_=[],v=null},ee=()=>{f?.interruptUnsafe(),f=null},S=e=>{let t=new ZA({message:e});for(let e of y.values())Bu(e,I(t));y.clear()},C=e=>{if(!l)return;let t=l;l=null,Bu(t.deferred,I(new ZA({message:e})))},te=()=>{c===`webrtc`&&e.webrtcSupported?ne():w()},ne=()=>{if(u||d!==null||o)return;let t;try{t=new oj({access:e.access,iceServers:e.iceServers,callbacks:b,fork:r})}catch(e){le(`webrtc`,ij(e,`WebRTC setup failed`));return}o=t,_=[],v=null,t.connect(),i(ej,()=>{o===t&&(x(),le(`webrtc`,new ZA({message:`WebRTC presentation timed out`})))})},w=()=>{if(u||d!==null||o)return;let t;try{t=new aj({access:e.access,callbacks:b,fork:r})}catch(e){le(`websocket`,ij(e,`WebSocket setup failed`));return}o=t,_=[],v=null,t.connect()},T=e=>i(e,()=>{!u&&a===null&&o===null&&w()}),re=n=>{if(u||o!==n){n.close();return}let r=a,i=_,s=v;if(r&&r!==n&&S(`live session transport replaced`),o=null,_=[],v=null,a=n,h=0,g=0,p=1e3,t.onPhase(`connected`),t.onTransport(n.kind),l?.kind===n.kind){let e=l;l=null,Bu(e.deferred,df)}n instanceof oj?(t.onFrame(null),t.onStream(n.mediaStream())):(t.onStream(null),s&&t.onFrame(s));for(let e of i)se(e);n.kind===`websocket`&&c===`webrtc`&&e.webrtcSupported&&ce(),r&&r!==n&&r.close()},ie=e=>{ee(),x(),a?.close(),a=null,C(e),S(e),t.onFrame(null),t.onStream(null),t.onTransport(null)},ae=(e,n)=>{if(!u){if(n.terminalReason!==void 0&&(o===e||a===e)){d=n,ie(n.message),t.onPhase(`error`),t.onError(n.message);return}if(o===e){x(),le(e.kind,n);return}a===e&&(a=null,e.close(),S(`live session transport was lost`),t.onPhase(`disconnected`),t.onError(n.message),t.onFrame(null),t.onStream(null),t.onTransport(null),T(e.kind===`webrtc`?0:tj))}},oe=(e,t)=>{if(t.type===`error`&&t.code===`resume_rejected`&&o===e&&a===null&&(s=null),t.type===`session.snapshot`&&(s={clientId:t.clientId,resumeSecret:t.resumeSecret}),a!==e){if(o!==e)return;_.push(t),t.type===`session.snapshot`&&e.kind===`websocket`&&re(e);return}se(t)},se=e=>{if(`realtimeCounter`in e&&e.realtimeCounter!==void 0){if(e.realtimeCounter<=g)return;g=e.realtimeCounter}if(`requestId`in e){let t=y.get(e.requestId);t&&(y.delete(e.requestId),Bu(t,e.ok?P(e):I(new ZA({message:e.message??`live session command failed`}))))}t.onMessage(e)},ce=()=>{if(u||c!==`webrtc`||!e.webrtcSupported||a?.kind===`webrtc`||f!==null)return;let t=p;p=Math.min(nj,p*2),f=i(t,()=>{f=null,ne()})},le=(e,n)=>{if(l?.kind===e&&(C(n.message),a&&(c=a.kind)),a){a.kind===`websocket`&&ce();return}if(e===`webrtc`){w();return}t.onPhase(`disconnected`),t.onError(n.message),T(tj)},E=e=>a?.sendReliable(e)??!1,ue=e=>(h+=1,a?.sendRealtime({realtimeCounter:h,...e})??!1),de=()=>{u=!0,ie(`live session connection closed`)};return yield*Zf(()=>F(de)),t.onPhase(`connecting`),te(),{reconnect:F(()=>{d=null,ee(),x(),a?.close(),a=null,C(`live session transport replaced`),S(`live session transport replaced`),t.onPhase(`connecting`),w()}),selectTransport:t=>uf(()=>{if(d!==null)return I(d);if(t===`webrtc`&&!e.webrtcSupported)return I(new ZA({message:`WebRTC presentation is unavailable`}));if(c=t,ee(),o&&o.kind!==t&&x(),C(`presentation selection was replaced`),a?.kind===t)return df;let n=Fu();return l={kind:t,deferred:n},o===null&&(t===`webrtc`?ne():w()),Iu(n)}),sendReliable:E,sendRealtime:ue,command:(e,t={})=>uf(()=>{m+=1;let n=`request-${m}`,r=Fu();return y.set(n,r),E({type:e,requestId:n,...t})?Iu(r).pipe(rp(()=>F(()=>y.delete(n)))):(y.delete(n),I(new ZA({message:`live session transport is unavailable`})))})}});function ij(e,t){return new ZA({message:e instanceof Error&&e.message?e.message:t})}var aj=class{kind=`websocket`;socket;callbacks;fork;pendingRealtime=new Map;pendingRasterPacket=null;rasterDecoder=null;decodingRaster=!1;realtimeFrame=null;closed=!1;constructor(e){this.callbacks=e.callbacks,this.fork=e.fork,this.socket=new WebSocket(WA(e.access,`session`),KA(e.access)),this.socket.binaryType=`blob`}connect(){this.socket.addEventListener(`open`,()=>{this.sendReliable(this.callbacks.hello())}),this.socket.addEventListener(`message`,e=>{if(typeof e.data==`string`){let t=bA(e.data);if(Li(t)){this.callbacks.failed(this,cj(t.failure));return}this.callbacks.message(this,t.success);return}e.data instanceof Blob&&(this.pendingRasterPacket=e.data,this.decodingRaster||(this.decodingRaster=!0,this.rasterDecoder=this.fork(this.decodeRasterPackets())))}),this.socket.addEventListener(`close`,e=>{this.closed||this.callbacks.failed(this,sj(`WebSocket session transport closed`,e.code))}),this.socket.addEventListener(`error`,()=>{this.closed||this.callbacks.failed(this,new ZA({message:`WebSocket session transport failed`}))})}sendReliable(e){return this.flushRealtime(),this.sendNow(e)}sendRealtime(e){return this.socket.readyState===WebSocket.OPEN?(this.pendingRealtime.delete(e.type),this.pendingRealtime.set(e.type,e),this.realtimeFrame===null&&(this.realtimeFrame=window.requestAnimationFrame(()=>{this.realtimeFrame=null,this.flushRealtime()})),!0):!1}close(){this.closed=!0,this.pendingRasterPacket=null,this.rasterDecoder?.interruptUnsafe(),this.rasterDecoder=null,this.realtimeFrame!==null&&(window.cancelAnimationFrame(this.realtimeFrame),this.realtimeFrame=null),this.pendingRealtime.clear(),this.socket.close()}decodeRasterPackets(){return mf({self:this},function*(){for(;;){let e=this.pendingRasterPacket;if(e===null||this.closed){this.decodingRaster=!1;return}this.pendingRasterPacket=null;let t=yield*lj(e);ur(t)&&!this.closed&&this.callbacks.frame(this,t.value)}})}flushRealtime(){this.realtimeFrame!==null&&(window.cancelAnimationFrame(this.realtimeFrame),this.realtimeFrame=null);for(let e of this.pendingRealtime.values())this.sendNow(e);this.pendingRealtime.clear()}sendNow(e){return this.socket.readyState===WebSocket.OPEN?(this.socket.send(JSON.stringify(e)),!0):!1}},oj=class{kind=`webrtc`;connection;reliable;realtime;signal;callbacks;fork;pendingCandidates=[];reliableOpen=!1;realtimeOpen=!1;helloSent=!1;snapshotReceived=!1;stream=null;streamReady=!1;closed=!1;constructor(e){this.callbacks=e.callbacks,this.fork=e.fork,this.connection=new RTCPeerConnection({iceServers:e.iceServers.map(e=>({urls:[...e.urls],username:e.username,credential:e.credential===void 0?void 0:x_(e.credential)}))}),this.reliable=this.connection.createDataChannel(`application`,{ordered:!0}),this.realtime=this.connection.createDataChannel(`application-realtime`,{ordered:!1,maxRetransmits:0}),this.connection.addTransceiver(`video`,{direction:`recvonly`}),this.signal=new WebSocket(WA(e.access,`webrtc/signal`),KA(e.access))}connect(){this.reliable.addEventListener(`open`,()=>{this.reliableOpen=!0,this.sendHello()}),this.realtime.addEventListener(`open`,()=>{this.realtimeOpen=!0,this.sendHello()}),this.reliable.addEventListener(`message`,e=>this.handleApplicationMessage(e)),this.realtime.addEventListener(`message`,e=>this.handleApplicationMessage(e));for(let e of[this.reliable,this.realtime])e.addEventListener(`close`,()=>this.fail(`WebRTC session channel closed`)),e.addEventListener(`error`,()=>this.fail(`WebRTC session channel failed`));this.connection.addEventListener(`track`,e=>{this.stream=e.streams[0]??new MediaStream([e.track]);let t=()=>{this.stream&&(this.streamReady=!0,this.maybeReady())};e.track.muted?e.track.addEventListener(`unmute`,t,{once:!0}):t()}),this.connection.addEventListener(`icecandidate`,e=>{e.candidate&&this.signal.readyState===WebSocket.OPEN&&this.signal.send(JSON.stringify({version:1,type:`ice-candidate`,candidate:e.candidate.toJSON()}))}),this.connection.addEventListener(`connectionstatechange`,()=>{(this.connection.connectionState===`failed`||this.connection.connectionState===`closed`)&&this.fail(`WebRTC ${this.connection.connectionState}`)}),this.signal.addEventListener(`open`,()=>{this.fork(this.sendOffer().pipe(Af(`LiveSessionError`,e=>F(()=>this.fail(e.message)))))}),this.signal.addEventListener(`message`,e=>this.handleSignal(e)),this.signal.addEventListener(`close`,e=>this.fail(`WebRTC signaling closed`,e.code)),this.signal.addEventListener(`error`,()=>this.fail(`WebRTC signaling failed`))}sendReliable(e){return this.reliable.readyState===`open`?(this.reliable.send(JSON.stringify(e)),!0):!1}sendRealtime(e){return this.realtime.readyState===`open`?(this.realtime.send(JSON.stringify(e)),!0):!1}close(){this.closed=!0,this.reliable.close(),this.realtime.close(),this.connection.close(),this.signal.close()}mediaStream(){return this.stream}sendHello(){this.helloSent||!this.reliableOpen||!this.realtimeOpen||(this.helloSent=this.sendReliable(this.callbacks.hello()))}handleApplicationMessage(e){if(typeof e.data!=`string`)return;let t=bA(e.data);if(Li(t)){this.closed||this.callbacks.failed(this,cj(t.failure));return}this.callbacks.message(this,t.success),t.success.type===`session.snapshot`&&(this.snapshotReceived=!0,this.maybeReady())}handleSignal(e){let t=typeof e.data==`string`?QA(e.data):sr();if(lr(t)){this.fail(`WebRTC signaling message is invalid`);return}let n=t.value;if(n.type===`error`){this.fail(n.error.message);return}if(n.type===`answer`){this.fork(lf(()=>this.connection.setRemoteDescription({type:`answer`,sdp:n.sdp})).pipe(Sf(uf(()=>of(this.pendingCandidates.splice(0),e=>lf(()=>this.connection.addIceCandidate(e)),{discard:!0}))),kf(()=>F(()=>this.fail(`WebRTC answer is invalid`)))));return}if(!this.connection.remoteDescription){this.pendingCandidates.push(n.candidate);return}this.fork(lf(()=>this.connection.addIceCandidate(n.candidate)).pipe(kf(()=>F(()=>this.fail(`WebRTC ICE candidate is invalid`)))))}sendOffer(){return mf({self:this},function*(){let e=e=>ij(e,`WebRTC negotiation failed`),t=yield*lf({try:()=>this.connection.createOffer(),catch:e});yield*lf({try:()=>this.connection.setLocalDescription(t),catch:e});let n=this.connection.localDescription?.sdp;if(!n)return yield*new ZA({message:`WebRTC offer is unavailable`});this.signal.send(JSON.stringify({version:1,type:`offer`,sdp:n}))})}maybeReady(){this.snapshotReceived&&this.stream&&this.streamReady&&this.callbacks.ready(this)}fail(e,t=0){this.closed||this.callbacks.failed(this,sj(e,t))}};function sj(e,t){return t===4401||t===4403?new ZA({message:`Session access denied. Sign in or request access before reconnecting.`,terminalReason:`access_denied`}):t===4404||t===4410?new ZA({message:`Session is no longer available.`,terminalReason:`session_unavailable`}):new ZA({message:e})}function cj(e){return new ZA({message:`The server sent a live session message this client cannot read: ${e.message}`,terminalReason:`protocol_mismatch`})}function lj(e){return mf(function*(){if(e.size<4)return sr();let t=yield*lf(()=>e.slice(0,4).arrayBuffer()),n=new DataView(t).getUint32(0);return n===0||n>e.size-4?sr():hr($A(yield*lf(()=>e.slice(4,4+n).text())),t=>({targetId:t.targetId,data:e.slice(4+n,e.size,`image/jpeg`),width:t.width,height:t.height}))}).pipe(If(()=>sr()))}var $=c(f(),1),uj=`~effect/SubscriptionRef`,dj={...Lt,[uj]:{_A:x},toJSON(){return{_id:`SubscriptionRef`,value:this.value}}},fj=e=>Tf(nm({replay:1}),t=>{let n=Object.create(dj);return n.semaphore=th(1),n.value=e,n.pubsub=t,am(n.pubsub,e),n}),pj=e=>cg(e.pubsub),mj=(e,t)=>{e.value=t,am(e.pubsub,t)},hj=b(2,(e,t)=>e.semaphore.withPermit(F(()=>mj(e,t)))),gj=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),_j=o(((e,t)=>{t.exports=gj()})),vj=_j(),yj=(0,$.createContext)(null),bj=class extends Da(`RuntimeProviderMissingError`){message=`useRuntime must be used inside RuntimeProvider`};function xj({runtime:e,baseUrl:t,children:n}){let r=(0,$.useMemo)(()=>({runtime:e,baseUrl:t}),[e,t]);return(0,vj.jsx)(yj.Provider,{value:r,children:n})}function Sj(){let e=(0,$.useContext)(yj);if(!e)throw new bj;return e}function Cj(){return Sj().runtime}function wj(e,t){let n=Cj();(0,$.useEffect)(()=>{let t=e();if(!t)return;let r=n.runFork(t);return()=>r.interruptUnsafe()},[n,...t])}function Tj(e,t){let n=Cj(),r=(0,$.useRef)(new Set);return(0,$.useEffect)(()=>{let e=r.current;return()=>{for(let t of e)t.interruptUnsafe();e.clear()}},[]),(0,$.useCallback)((...t)=>{let i=n.runFork(e(...t));i.pollUnsafe()||(r.current.add(i),i.addObserver(()=>r.current.delete(i)))},[n,...t])}var Ej=2e3,Dj=()=>new ZA({message:`live session transport is unavailable`}),Oj=40,kj=7e3,Aj={left:272,right:273,middle:274};function jj({access:e,displayName:t=null,enabled:n,webrtcSupported:r,iceServers:i,autoSize:a}){let o=(0,$.useMemo)(()=>Nj(t),[t]),[s,c]=(0,$.useState)(`viewer`),l=Cj(),u=(0,$.useMemo)(()=>l.runSync(fj(null)),[l]),d=(0,$.useMemo)(()=>l.runSync(nm()),[l]),f=(0,$.useMemo)(()=>pj(u),[u]),p=(0,$.useMemo)(()=>cg(d),[d]),m=(0,$.useCallback)(e=>l.runSync(hj(u,e)),[u,l]),h=(0,$.useCallback)(e=>am(d,e),[d]),g=(0,$.useRef)(null),_=(0,$.useRef)(null),v=(0,$.useRef)(``),y=(0,$.useRef)(!1),b=(0,$.useRef)(!1),x=(0,$.useRef)(!1),ee=(0,$.useRef)(0),S=(0,$.useRef)([]),C=(0,$.useRef)(null),te=(0,$.useRef)(null),ne=(0,$.useRef)(null),w=(0,$.useRef)(null),T=(0,$.useRef)(!1),[re,ie]=(0,$.useState)(`idle`),[ae,oe]=(0,$.useState)([]),[se,ce]=(0,$.useState)(null),[le,E]=(0,$.useState)(null),[ue,de]=(0,$.useState)(null),[fe,pe]=(0,$.useState)(null),[me,he]=(0,$.useState)(!1),[ge,_e]=(0,$.useState)(!1),[D,ve]=(0,$.useState)(null),[ye,be]=(0,$.useState)([]),[xe,Se]=(0,$.useState)(null),[Ce,we]=(0,$.useState)(``),[Te,Ee]=(0,$.useState)(null),[De,Oe]=(0,$.useState)(null),[ke,Ae]=(0,$.useState)([]),[je,Me]=(0,$.useState)(()=>new Map),[Ne,Pe]=(0,$.useState)(null);te.current=ue,ne.current=fe,w.current=D;let Fe=(0,$.useCallback)(e=>{switch(e.type){case`session.snapshot`:c(e.role),v.current=e.clientId,we(e.clientId),_.current=e.holderClientId??null,Ee(e.holderClientId??null),Oe(e.mode??null),S.current=e.participants,Ae(e.participants),C.current=e.participants.find(t=>t.clientId===e.clientId)?.followingClientId??null,oe(e.targets),ce(e.activeTargetId??null),de(Ij(e.targets,e.activeTargetId)),be(e.recordings),ve(e.presentation??null),Se(e.autoSize===void 0?null:{ownerClientId:e.viewportOwnerClientId??null,autoSize:e.autoSize}),Pe(null);return;case`targets.state`:oe(e.targets),ce(e.activeTargetId??null),de(Ij(e.targets,e.activeTargetId)),he(!1);return;case`presence.state`:S.current=e.participants,Ae(e.participants),C.current=e.participants.find(e=>e.clientId===v.current)?.followingClientId??null,Me(e=>{let t=C.current;if(!t)return e.size===0?e:new Map;let n=e.get(t);return n?new Map([[t,n]]):new Map});return;case`input.state`:_.current=e.holderClientId??null,Ee(e.holderClientId??null),Oe(e.mode??null),y.current=!1,b.current=!1,Pe(e=>e?.code===`input_busy`||e?.code===`input_not_owned`?null:e);return;case`viewport.state`:Se({ownerClientId:e.viewportOwnerClientId??null,autoSize:e.autoSize});return;case`presence.cursor`:if(e.clientId!==C.current)return;Me(t=>new Map(t).set(e.clientId,e));return;case`presence.cursor.clear`:Me(t=>{if(!t.has(e.clientId))return t;let n=new Map(t);return n.delete(e.clientId),n});return;case`paint.point`:S.current.some(t=>t.clientId===e.clientId)&&h({type:`point`,message:e});return;case`recordings.state`:be(e.recordings);return;case`presentation.state`:ve(e.presentation);return;case`error`:y.current=!1,b.current=!1,Pe({code:e.code,message:e.message});return;default:e.presentation&&ve(e.presentation),e.ok||Pe({code:e.code??`request_rejected`,message:e.message??`Live session command failed.`})}},[h]);wj(()=>{if(!n||e===null){g.current=null,ie(`idle`),c(`viewer`),oe([]),ce(null),E(null),de(null),pe(null),ve(null),he(!1),_e(!1),Ae([]),Me(new Map),be([]),Se(null),m(null),h({type:`clear`});return}return c(`viewer`),mf(function*(){let t=yield*rj({access:e,identity:o,autoSize:a,iceServers:i,webrtcSupported:r,callbacks:{onPhase:ie,onMessage:Fe,onFrame:m,onStream:E,onTransport:pe,onError:e=>Pe({code:`connection_failed`,message:e})}});return g.current=t,yield*Zf(()=>F(()=>{g.current===t&&(g.current=null)})),yield*pf}).pipe(Jf,Qf(F(()=>{m(null),h({type:`clear`})})))},[a,e,n,Fe,i,o,m,h,r]);let Ie=(0,$.useCallback)(e=>g.current?.sendReliable(e)??!1,[]),Le=(0,$.useCallback)(e=>g.current?.sendRealtime(e)??!1,[]),Re=Tj((e,t,n)=>e.command(t,n).pipe(kf(e=>F(()=>{he(!1),Pe({code:`request_rejected`,message:e.message})}))),[]),ze=(0,$.useCallback)((e,t={})=>{let n=g.current;return n?(Re(n,e,t),!0):!1},[Re]),Be=(0,$.useCallback)((e,t={})=>uf(()=>g.current?g.current.command(e,t):I(Dj())),[]),Ve=Tj((e,t)=>e.command(`target.select`,{targetId:t}).pipe(Vf({onSuccess:()=>ce(t),onFailure:e=>Pe({code:`request_rejected`,message:e.message})}),Qf(F(()=>he(!1)))),[]),He=(0,$.useCallback)(e=>uf(()=>{let t=g.current;return t?(he(!0),t.command(`target.select`,{targetId:e}).pipe(Cf(()=>F(()=>ce(e))),Pf(e=>F(()=>Pe({code:`request_rejected`,message:e.message}))),Qf(F(()=>he(!1))),Of)):I(Dj())}),[]),Ue=(0,$.useCallback)(e=>{let t=g.current;return t?(he(!0),Ve(t,e),!0):!1},[Ve]),We=(0,$.useCallback)(e=>uf(()=>{let t=g.current;return t?T.current?I(new ZA({message:`another presentation update is already in progress`})):(T.current=!0,_e(!0),mf(function*(){switch(e.kind){case`jpeg`:return yield*t.selectTransport(`websocket`);case`webrtc-retry`:return yield*t.selectTransport(`webrtc`);case`webrtc`:{let n=te.current;if(!n)return yield*new ZA({message:`presentation size is unavailable`});let r=w.current?.quality?.profile!==e.quality.profile&&ne.current===`webrtc`;r&&(yield*t.selectTransport(`websocket`));let i=yield*t.command(`presentation.quality.set`,{profile:e.quality.profile,width:n.canvasWidth,height:n.canvasHeight,fps:e.quality.fps,bitrateKbps:e.quality.bitrateKbps}).pipe(Pf(()=>r?Ff(t.selectTransport(`webrtc`)):df));return i.presentation&&ve(i.presentation),yield*t.selectTransport(`webrtc`)}default:return e}}).pipe(Pf(e=>F(()=>Pe({code:`presentation_update_failed`,message:e.message}))),Qf(F(()=>{T.current=!1,_e(!1)})))):I(Dj())}),[]),Ge=(0,$.useCallback)((e,t)=>s===`viewer`||!Ie({type:`input.claim`,targetId:e,mode:t})?!1:(y.current=!0,b.current=!1,!0),[s,Ie]),Ke=(0,$.useCallback)(()=>b.current||_.current!==v.current||!Ie({type:`input.release`})?!1:(b.current=!0,y.current=!1,!0),[Ie]),qe=(0,$.useCallback)(e=>e?Ue(e):!1,[Ue]),Je=(0,$.useCallback)(e=>Ie({type:`follow.set`,followingClientId:e??``}),[Ie]),Ye=(0,$.useCallback)((e,t,n,r)=>{let i=performance.now();if(i-ee.current<Oj)return!1;ee.current=i;let a=Le({type:`presence.cursor`,targetId:e,x:Lj(t,r.width),y:Lj(n,r.height)});return a&&(x.current=!0),a},[Le]),Xe=(0,$.useCallback)(e=>e.phase===`move`?Le({type:`paint.point`,...e}):Ie({type:`paint.point`,...e}),[Le,Ie]),Ze=(0,$.useCallback)(()=>!x.current||!Ie({type:`presence.cursor.clear`})?!1:(x.current=!1,!0),[Ie]),Qe=(0,$.useCallback)((e,t=!1)=>t?Le(e):Ie(e),[Le,Ie]),$e=(0,$.useCallback)((e,t)=>{if(s===`viewer`||_.current!==v.current&&!y.current)return!1;switch(e.type){case`input.mouse`:{let n=Lj(e.x,t.width),r=Lj(e.y,t.height);if(e.action===`move`)return Qe({type:`input.pointer.motion.absolute`,targetId:e.targetId,x:n,y:r,width:t.width,height:t.height,modifiers:e.modifiers??0},!0);if(e.button===`none`)return!0;let i=Aj[e.button??`left`],a=(a,o)=>Qe({type:`input.pointer.button`,targetId:e.targetId,x:n,y:r,width:t.width,height:t.height,buttonCode:i,pressed:a,clickCount:o,modifiers:e.modifiers??0});if(e.action===`down`||e.action===`up`)return a(e.action===`down`,e.clickCount??1);let o=e.action===`doubleClick`?2:1;for(let t=0;t<o;t+=1){let n=e.action===`doubleClick`?t+1:1;a(!0,n),a(!1,n)}return!0}case`input.wheel`:{let n=Lj(e.x,t.width),r=Lj(e.y,t.height);return Qe({type:`input.pointer.scroll`,targetId:e.targetId,x:n,y:r,width:t.width,height:t.height,horizontal:e.deltaX,vertical:e.deltaY,stopHorizontal:!1,stopVertical:!1,modifiers:e.modifiers??0}),Qe({type:`input.pointer.scroll`,targetId:e.targetId,x:n,y:r,width:t.width,height:t.height,horizontal:0,vertical:0,stopHorizontal:e.deltaX!==0,stopVertical:e.deltaY!==0,modifiers:e.modifiers??0})}case`input.key`:{if(e.action===`char`)return e.text?Qe({type:`input.keyboard.text`,targetId:e.targetId,text:e.text}):!1;let t=Dg[e.code??``];if(!t)return!1;let n=e.windowsVirtualKeyCode??Fg(e.code,e.key);return Qe({type:`input.keyboard.key`,targetId:e.targetId,keycode:t,pressed:e.action===`down`,key:e.key,code:e.code,text:e.text,unmodifiedText:e.unmodifiedText,modifiers:e.modifiers??0,windowsVirtualKeyCode:n,nativeVirtualKeyCode:e.nativeVirtualKeyCode??n,location:e.location??0,autoRepeat:e.autoRepeat??!1,isKeypad:e.isKeypad??!1})}case`clipboard.copy`:return Rj(Qe,e.targetId,`KeyC`);case`clipboard.cut`:return Rj(Qe,e.targetId,`KeyX`);case`clipboard.paste`:{let t=e.items.find(e=>e.mimeType===`text/plain`);return t?Qe({type:`input.keyboard.text`,targetId:e.targetId,text:t.data}):!1}default:return e}},[s,Qe]),et=Te===Ce&&Ce!==``,tt=ke.find(e=>e.clientId===Ce)?.followingClientId??null;return wj(()=>et?Rf(Ej).pipe(Sf(F(()=>{_.current===v.current&&Ie({type:`input.heartbeat`})})),op):void 0,[et,Ie]),{phase:re,targets:ae,activeTargetId:se,frames:f,mediaStream:le,mediaSize:ue,transport:fe,presentation:D,mediaSwitching:me||ge,recordings:ye,viewportOwnership:xe,sendBrowserInput:$e,selectTarget:Ue,requestSelectTarget:He,command:ze,request:Be,selectPresentation:We,reconnect:()=>{let e=g.current;e&&l.runSync(e.reconnect)},collaboration:{phase:re===`error`?`disconnected`:re,role:s,clientId:Ce,holderClientId:Te,leaseMode:De,hasControl:et,canRequestControl:s!==`viewer`&&re===`connected`,lastError:Ne,participants:ke,cursors:je,paintEvents:p,followingClientId:tt,claim:Ge,release:Ke,setActiveTarget:qe,follow:Je,sendCursor:Ye,sendPaintPoint:Xe,clearCursor:Ze,sendInput:$e}}}var Mj=VS(BC(W({name:V.check(OC(1),AC(48)),avatarHash:V.check(vC(/^[0-9a-f]{32}$/))})),sA);function Nj(e){let t=Pj();return e?.trim()?{...t,name:Array.from(e.trim()).slice(0,48).join(``)}:t}function Pj(){let e=`aperture.collaboration.identity`;try{let t=window.localStorage.getItem(e);if(t){let e=Mj(t);if(ur(e))return e.value}let n=Fj();return window.localStorage.setItem(e,JSON.stringify(n)),n}catch{return Fj()}}function Fj(){let e=[`Amber`,`Brisk`,`Calm`,`Clever`,`Misty`,`Quiet`,`Swift`,`Warm`],t=[`Badger`,`Falcon`,`Fox`,`Koala`,`Otter`,`Panda`,`Raven`,`Tiger`],n=new Uint8Array(18);return crypto.getRandomValues(n),{name:`${e[(n.at(0)??0)%e.length]??`Quiet`} ${t[(n.at(1)??0)%t.length]??`Otter`}`,avatarHash:Array.from(n.slice(2),e=>e.toString(16).padStart(2,`0`)).join(``)}}function Ij(e,t){let n=e.find(e=>e.id===t)?.viewport;return n?{width:n.width,height:n.height,canvasWidth:n.canvasWidth,canvasHeight:n.canvasHeight,deviceScaleFactor:n.deviceScaleFactor}:null}function Lj(e,t){return t<=1?0:Math.min(1,Math.max(0,e/t))}function Rj(e,t,n){let r=Dg.ControlLeft,i=Dg[n];if(!r||!i)return!1;let a=Fg(`ControlLeft`,`Control`),o=n===`KeyC`?`c`:`x`,s=Fg(n,o);return e({type:`input.keyboard.key`,targetId:t,keycode:r,pressed:!0,key:`Control`,code:`ControlLeft`,windowsVirtualKeyCode:a,nativeVirtualKeyCode:a,modifiers:2}),e({type:`input.keyboard.key`,targetId:t,keycode:i,pressed:!0,key:o,code:n,windowsVirtualKeyCode:s,nativeVirtualKeyCode:s,modifiers:2}),e({type:`input.keyboard.key`,targetId:t,keycode:i,pressed:!1,key:o,code:n,windowsVirtualKeyCode:s,nativeVirtualKeyCode:s,modifiers:2}),e({type:`input.keyboard.key`,targetId:t,keycode:r,pressed:!1,key:`Control`,code:`ControlLeft`,windowsVirtualKeyCode:a,nativeVirtualKeyCode:a,modifiers:0})}var zj=[`#f43f5e`,`#f97316`,`#eab308`,`#22c55e`,`#06b6d4`,`#8b5cf6`],Bj=4,Vj=24,Hj=2048,Uj=512;function Wj({collaboration:e,targetId:t,enabled:n,visible:r,left:i,top:a,width:o,height:s}){let c=(0,$.useRef)(null),l=(0,$.useRef)(null),u=(0,$.useRef)(null),d=(0,$.useRef)(0),f=(0,$.useRef)(new Map),p=qj(e.clientId);wj(()=>{let n=c.current;if(!n)return;let r=window.devicePixelRatio||1;n.width=Math.max(1,Math.round(o*r)),n.height=Math.max(1,Math.round(s*r));let i=n.getContext(`2d`);if(!i)return;let a=null,l=new Set(e.participants.map(e=>e.clientId)),u=Date.now();for(let[e,t]of f.current)!t.ended&&!l.has(t.clientId)&&f.current.set(e,{...t,updatedAt:u,ended:!0});let d=()=>{a=null,i.setTransform(r,0,0,r,0,0),i.clearRect(0,0,o,s);let e=Date.now(),n=0;for(let[r,a]of f.current){let c=e-a.updatedAt;if(a.ended&&c>=7e3){f.current.delete(r);continue}if(a.ended&&(n+=1),a.targetId!==t||a.points.length===0)continue;let l=a.ended?1-c/kj:1;i.globalAlpha=l,i.strokeStyle=a.color,i.fillStyle=a.color,i.lineWidth=a.width,i.lineCap=`round`,i.lineJoin=`round`;let u=a.points[0];if(!u)continue;if(a.points.length===1){i.beginPath(),i.arc(u.x*o,u.y*s,a.width/2,0,Math.PI*2),i.fill();continue}i.beginPath(),i.moveTo(u.x*o,u.y*s);for(let e=1;e<a.points.length-1;e+=1){let t=a.points[e],n=a.points[e+1];!t||!n||i.quadraticCurveTo(t.x*o,t.y*s,(t.x+n.x)/2*o,(t.y+n.y)/2*s)}let d=a.points[a.points.length-1];d&&i.lineTo(d.x*o,d.y*s),i.stroke()}i.globalAlpha=1,n>0&&(a=window.requestAnimationFrame(d))},p=()=>{a===null&&(a=window.requestAnimationFrame(d))},m=e=>{if(e.type===`clear`){f.current.clear(),p();return}let t=e.message,n=`${t.clientId}:${t.targetId}:${t.strokeId}`,r=f.current.get(n);if(t.phase!==`start`&&!r||r?.ended&&t.phase!==`start`)return;let i=Date.now();if(t.phase===`start`)for(let[e,n]of f.current)!n.ended&&n.clientId===t.clientId&&f.current.set(e,{...n,updatedAt:i,ended:!0});let a=t.phase===`start`||!r?[{x:t.x,y:t.y}]:[...r.points,{x:t.x,y:t.y}];if(a.length>Hj&&(a=a.filter((e,t)=>t%2==0)),!r&&f.current.size>=Uj){let e=null,t=1/0;for(let[n,r]of f.current)r.ended&&r.updatedAt<t&&(e=n,t=r.updatedAt);e&&f.current.delete(e)}f.current.set(n,{clientId:t.clientId,targetId:t.targetId,color:t.color,width:t.width,points:a,updatedAt:i,ended:t.phase===`end`}),p()};return d(),Cg(e.paintEvents,e=>F(()=>m(e))).pipe(Qf(F(()=>{a!==null&&window.cancelAnimationFrame(a)})))},[e.paintEvents,e.participants,s,t,o]),(0,$.useEffect)(()=>{l.current=null,u.current=null},[n,t]);function m(n,r){let i=l.current,a=Gj(n);!i||!a||e.sendPaintPoint({targetId:t,strokeId:i,color:p,width:Bj,phase:r,x:a.x,y:a.y})}function h(n){if(Kj(n),!n.isPrimary||n.button!==0||u.current!==null)return;n.currentTarget.focus(),l.current=crypto.randomUUID(),u.current=n.pointerId,d.current=performance.now();try{n.currentTarget.setPointerCapture(n.pointerId)}catch{}let r=Gj(n);r&&e.sendCursor(t,r.x*o,r.y*s,{width:o,height:s}),m(n,`start`)}function g(n){if(Kj(n),u.current!==null&&n.pointerId!==u.current)return;let r=Gj(n);r&&e.sendCursor(t,r.x*o,r.y*s,{width:o,height:s}),!(!l.current||performance.now()-d.current<Vj)&&(d.current=performance.now(),m(n,`move`))}function _(e){Kj(e),!(!l.current||u.current!==e.pointerId)&&(m(e,`end`),l.current=null,u.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))}return(0,vj.jsx)(`canvas`,{ref:c,tabIndex:-1,style:{position:`absolute`,zIndex:20,touchAction:`none`,cursor:n?`crosshair`:void 0,pointerEvents:n?void 0:`none`,visibility:r?void 0:`hidden`,left:i,top:a,width:o,height:s},"aria-label":`Shared drawing overlay`,onPointerDown:h,onPointerMove:g,onPointerUp:_,onPointerCancel:_,onWheel:Kj,onContextMenu:Kj})}function Gj(e){let t=e.currentTarget.getBoundingClientRect();return t.width===0||t.height===0?null:{x:Math.max(0,Math.min(1,(e.clientX-t.left)/t.width)),y:Math.max(0,Math.min(1,(e.clientY-t.top)/t.height))}}function Kj(e){e.preventDefault(),e.stopPropagation()}function qj(e){let t=0;for(let n of e)t=t*31+n.charCodeAt(0)>>>0;return zj[t%zj.length]??`#f43f5e`}var Jj=500,Yj=5;function Xj({control:e,viewport:t=e.viewport,localCursorEnabled:n=!0,paintingEnabled:r=!1,onPaintingEnabledChange:i,onNotice:a,className:o,style:s,renderOverlay:c}){let l=(0,$.useRef)(null),u=(0,$.useRef)(null),d=(0,$.useRef)(null),f=(0,$.useRef)({decodingFrame:null,generation:0,pending:null}),p=(0,$.useRef)(null),m=(0,$.useRef)(new Map),h=(0,$.useRef)(new Set),g=(0,$.useRef)(null),_=(0,$.useRef)(null),v=(0,$.useRef)(!1),y=(0,$.useRef)(null),b=(0,$.useRef)(null),[x,ee]=(0,$.useState)(null),[S,C]=(0,$.useState)(null),[te,ne]=(0,$.useState)(null),w=e.mediaPath===`webrtc-live`&&e.mediaPhase===`live`&&!!e.mediaStream&&!!e.activeTargetId,T=w&&(e.mediaSwitching||e.mediaTargetId!==e.activeTargetId||te?.stream!==e.mediaStream||te?.targetId!==e.activeTargetId),re=r&&(w||S!==null)&&e.collaboration.phase===`connected`&&!e.mediaSwitching&&!T,ie=r||e.mediaSwitching||T||e.collaboration.phase!==`connected`||e.collaboration.role===`viewer`,ae=T&&te?te.size:e.mediaSize,oe=w?ae?.width??t.width:S?.width??t.width,se=w?ae?.height??t.height:S?.height??t.height,ce=w?oe:t.width,le=w?se:t.height,E=w?Math.min(ae?.canvasWidth??oe,Math.round(oe*(ae?.deviceScaleFactor??1))):oe,ue=w?Math.min(ae?.canvasHeight??se,Math.round(se*(ae?.deviceScaleFactor??1))):se,de=DA(e.browserViewportSize?.width??oe,e.browserViewportSize?.height??se,oe,se),fe=Zj(e.phase),pe=Qj(e.collaboration),me=fe??pe,he=me?y.current??x:null,ge=e.collaboration.followingClientId?e.collaboration.participants.find(t=>t.clientId===e.collaboration.followingClientId):null,_e=ge?e.collaboration.cursors.get(ge.clientId):null,D=_e?.targetId===e.activeTargetId?{x:de.offsetX+_e.x*de.renderedWidth,y:de.offsetY+_e.y*de.renderedHeight}:null;(0,$.useEffect)(()=>{e.setInputDimensions({width:ce,height:le})},[e.setInputDimensions,le,ce]);let ve=(0,$.useCallback)(()=>{let t=[...m.current.entries()].reverse();m.current.clear();for(let[n,r]of t)e.sendInput({type:`input.key`,targetId:r.targetId,action:`up`,...r.input,text:void 0,modifiers:0,autoRepeat:!1})&&h.current.add(n)},[e.sendInput]);wj(()=>{let t=t=>{if(!t){u.current?rM(u.current,f.current):iM(f.current),p.current!==null&&(p.current=null,C(null));return}if(t.targetId!==e.activeTargetId)return;u.current&&!w?eM(u.current,f.current,t):f.current.pending=t;let n=p.current;if(n?.width!==t.width||n?.height!==t.height){let e={width:t.width,height:t.height};p.current=e,C(e)}};return Cg(e.frames,e=>F(()=>t(e))).pipe(Qf(F(()=>{u.current?rM(u.current,f.current):iM(f.current)})))},[e.activeTargetId,e.frames,w]),(0,$.useLayoutEffect)(()=>{let t=f.current,n=e.activeTargetId,r=t.pending?.targetId===n?t.pending:t.decodingFrame?.targetId===n?t.decodingFrame:null,i=u.current;if(i?rM(i,t):iM(t),r){t.pending=r;let e={width:r.width,height:r.height};p.current=e,C(e),i&&tM(i,t)}else p.current!==null&&(p.current=null,C(null))},[e.activeTargetId]),(0,$.useEffect)(()=>{let e=u.current;w||!e||tM(e,f.current)},[S,w]),(0,$.useEffect)(()=>{d.current&&(d.current.srcObject=w?e.mediaStream:null)},[e.mediaStream,w]),(0,$.useEffect)(()=>{let t=d.current,n=e.mediaStream,r=e.activeTargetId,i=e.mediaSize;if(!w||!t||!n||!r||!i||e.mediaSwitching||e.mediaTargetId!==r||te?.stream===n&&te.targetId===r)return;let a=t.requestVideoFrameCallback(()=>{ne({stream:n,targetId:r,size:i})});return()=>t.cancelVideoFrameCallback(a)},[e.activeTargetId,e.mediaSize,e.mediaStream,e.mediaSwitching,e.mediaTargetId,te,w]),(0,$.useEffect)(()=>{let t=l.current;if(!t)return;let n=(t,n)=>{e.setBrowserViewportSize({width:t,height:n})},r=t.getBoundingClientRect();n(r.width,r.height);let i=new ResizeObserver(e=>{let t=e[0];t&&n(t.contentRect.width,t.contentRect.height)});return i.observe(t),()=>i.disconnect()},[e.setBrowserViewportSize]),(0,$.useEffect)(()=>()=>{_.current?.(),ve()},[ve]),(0,$.useEffect)(()=>{let e=()=>{ve(),Se()},t=()=>{document.visibilityState===`hidden`&&(ve(),Se())};return window.addEventListener(`blur`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`blur`,e),document.removeEventListener(`visibilitychange`,t)}},[ve,e.collaboration]),(0,$.useEffect)(()=>{ie&&(_.current?.(),ve(),Se())},[ie,ve]),(0,$.useEffect)(()=>{r&&(e.setCaptured(!1),v.current=!1),e.collaboration.hasControl&&e.collaboration.leaseMode===`implicit`&&!v.current&&e.collaboration.release()},[e.collaboration.hasControl,e.collaboration.leaseMode,e.collaboration.release,e.setCaptured,r]);function ye(e,t){let n=l.current?.getBoundingClientRect();if(!n)return null;let r=DA(n.width,n.height,oe,se),i=e.clientX-n.left-r.offsetX,a=e.clientY-n.top-r.offsetY;if(!t&&(i<0||a<0||i>r.renderedWidth||a>r.renderedHeight))return null;let o=i/r.scale*(ce/oe),s=a/r.scale*(le/se);return t?{x:Math.round(uM(o,0,Math.max(ce-1,0))),y:Math.round(uM(s,0,Math.max(le-1,0)))}:{x:Math.round(o),y:Math.round(s)}}function be(){return e.phase!==`connected`||!e.activeTargetId||ie?null:(e.captured||e.setCaptured(!0),xe(e.activeTargetId),l.current?.focus(),e.activeTargetId)}function xe(t){v.current=!0,e.collaboration.hasControl||e.collaboration.claim(t,`implicit`)}function Se(){v.current=!1,e.collaboration.hasControl&&e.collaboration.leaseMode===`implicit`&&e.collaboration.release()}function Ce(e){e.preventDefault(),e.stopPropagation()}function we(e){e.cancelable&&e.preventDefault(),e.stopPropagation()}function Te(){e.phase!==`connected`||ie||(e.setCaptured(!0),e.activeTargetId&&xe(e.activeTargetId),l.current?.focus())}function Ee(t){Re(t),!(ie||!e.activeTargetId)&&(e.setCaptured(!0),xe(e.activeTargetId))}function De(){y.current=null,ee(null),e.collaboration.clearCursor(),g.current||(ve(),Se(),e.setCaptured(!1))}function Oe(){e.captured||Te()}function ke(t){Re(t);let n=ye(t,!1);if(e.activeTargetId&&n?e.collaboration.sendCursor(e.activeTargetId,n.x,n.y,{width:ce,height:le}):n||e.collaboration.clearCursor(),ie||g.current?.pointerId===t.pointerId)return;let r=e.captured&&t.buttons===0?e.activeTargetId:null;r&&n&&(Ce(t),e.sendInput({type:`input.mouse`,targetId:r,action:`move`,x:n.x,y:n.y,button:`none`,buttons:0,clickCount:0,modifiers:jg(t.nativeEvent)}))}function Ae(t){Re(t);let n=be();if(!n)return;let r=ye(t,!1);if(!r)return;let i=l.current;if(!i)return;let a=sM(t.button),o=Date.now(),s=cM(n,a,r,o,b.current);b.current={targetId:n,button:a,point:r,time:o,clickCount:s},Ce(t),g.current={pointerId:t.pointerId,targetId:n,button:a,clickCount:s},_.current?.();try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}Ne({pointerId:t.pointerId,targetId:n,button:a,clickCount:s,element:i}),e.sendInput({type:`input.mouse`,targetId:n,action:`down`,x:r.x,y:r.y,button:a,buttons:t.buttons,clickCount:s,modifiers:jg(t.nativeEvent)})}function je(t){if(ie)return;let n=g.current,r=n?.pointerId===t.pointerId?n.targetId:e.activeTargetId;if(!r)return;let i=ye(t,n?.pointerId===t.pointerId);i&&(Ce(t),e.sendInput({type:`input.mouse`,targetId:r,action:`up`,x:i.x,y:i.y,button:n?.button??sM(t.button),buttons:t.buttons,clickCount:n?.clickCount??1,modifiers:jg(t.nativeEvent)}),n?.pointerId===t.pointerId&&(g.current=null,t.currentTarget.hasPointerCapture(t.pointerId)&&t.currentTarget.releasePointerCapture(t.pointerId)))}function Me(t){let n=g.current;if(n?.pointerId!==t.pointerId)return;let r=ye(t,!0);g.current=null,t.currentTarget.hasPointerCapture(t.pointerId)&&t.currentTarget.releasePointerCapture(t.pointerId),!(!r||ie)&&(Ce(t),e.sendInput({type:`input.mouse`,targetId:n.targetId,action:`up`,x:r.x,y:r.y,button:n.button,buttons:0,clickCount:n.clickCount,modifiers:jg(t.nativeEvent)}))}function Ne({pointerId:t,targetId:n,button:r,clickCount:i,element:a}){let o=a=>{if(a.pointerId!==t)return;let o=ye(a,!0);we(a),o&&(e.collaboration.sendCursor(n,o.x,o.y,{width:ce,height:le}),e.sendInput({type:`input.mouse`,targetId:n,action:`move`,x:o.x,y:o.y,button:r,buttons:a.buttons||lM(r),clickCount:i,modifiers:jg(a)}))},s=(a,o)=>{if(a.pointerId!==t)return;let s=ye(a,!0);ye(a,!1)||e.collaboration.clearCursor(),we(a),s&&(e.sendInput({type:`input.mouse`,targetId:n,action:`up`,x:s.x,y:s.y,button:r,buttons:0,clickCount:i,modifiers:jg(a)}),o||(b.current={targetId:n,button:r,point:s,time:Date.now(),clickCount:i})),u()},c=e=>s(e,!1),l=e=>s(e,!0),u=()=>{window.removeEventListener(`pointermove`,o,!0),window.removeEventListener(`pointerup`,c,!0),window.removeEventListener(`pointercancel`,l,!0);try{a.hasPointerCapture(t)&&a.releasePointerCapture(t)}catch{}g.current?.pointerId===t&&(g.current=null),_.current===u&&(_.current=null)};_.current=u,window.addEventListener(`pointermove`,o,!0),window.addEventListener(`pointerup`,c,!0),window.addEventListener(`pointercancel`,l,!0)}function Pe(t){let n=be();if(!n)return;let r=ye(t,!1);if(!r)return;Ce(t);let i=dM(t.deltaMode,le);e.sendInput({type:`input.wheel`,targetId:n,x:r.x,y:r.y,deltaX:t.deltaX*i,deltaY:t.deltaY*i,modifiers:jg(t.nativeEvent)})}function Fe(t){if(t.key===`Escape`&&r){t.preventDefault(),t.stopPropagation(),i?.(!1);return}if(t.key===`Escape`){e.captured&&(t.preventDefault(),t.stopPropagation(),e.setCaptured(!1),Se());return}let n=t.code||t.key;if(t.repeat&&h.current.has(n)){t.preventDefault(),t.stopPropagation();return}let o=e.activeTargetId;if(ie||!o||!e.captured&&mM(l.current)!==l.current&&!l.current?.contains(t.target))return;t.preventDefault(),t.stopPropagation();let s=oM(t.nativeEvent);if(s===`copy`){e.sendInput({type:`clipboard.copy`,targetId:o});return}if(s===`cut`){e.sendInput({type:`clipboard.cut`,targetId:o});return}if(s===`paste`){fM(e,a);return}if(!Pg(t.nativeEvent))return;let c=Ng(t.nativeEvent,`down`);e.sendInput({type:`input.key`,targetId:o,action:`down`,...c})&&(h.current.delete(n),m.current.set(n,{targetId:o,input:c}))}function Ie(t){let n=t.code||t.key;if(h.current.delete(n)){t.preventDefault(),t.stopPropagation();return}let r=m.current.get(n),i=r?.targetId??e.activeTargetId,a=!ie&&(e.captured||mM(l.current)===l.current||!!l.current?.contains(t.target));!i||!r&&!a||t.key!==`Escape`&&(t.preventDefault(),t.stopPropagation(),!(!r&&oM(t.nativeEvent))&&(!r&&!Pg(t.nativeEvent)||e.sendInput({type:`input.key`,targetId:i,action:`up`,...Ng(t.nativeEvent,`up`)})&&m.current.delete(n)))}function Le(t){t.relatedTarget instanceof Node&&t.currentTarget.contains(t.relatedTarget)||(ve(),Se(),e.setCaptured(!1))}function Re(e){let t=l.current?.getBoundingClientRect();if(!t)return;let n={x:e.clientX-t.left,y:e.clientY-t.top};y.current=n,me&&ee(n)}let ze=pM(e.phase,S!==null,e.mediaPhase,e.mediaPath,w),Be=aM(e.phase,e.mediaPhase,e.mediaSwitching),Ve=pe||$j(e.collaboration.lastError)?null:e.collaboration.lastError;return(0,vj.jsxs)(`div`,{ref:l,tabIndex:0,onKeyDown:Fe,onKeyUp:Ie,onBlur:Le,onClick:Oe,onPointerMove:ke,onFocus:()=>{!ie&&e.activeTargetId&&xe(e.activeTargetId)},onPointerEnter:Ee,onPointerLeave:De,onPointerDown:Ae,onPointerUp:je,onPointerCancel:Me,onWheel:Pe,onContextMenu:t=>{e.captured&&t.preventDefault()},"aria-busy":T,"aria-disabled":ie,className:o,style:{position:`relative`,display:`flex`,flex:`1 1 0%`,minHeight:0,alignItems:`center`,justifyContent:`center`,overflow:`hidden`,outline:`none`,touchAction:`none`,cursor:n?void 0:`none`,...s},children:[w?(0,vj.jsx)(`div`,{style:{position:`relative`,overflow:`hidden`,background:`black`,transition:`opacity 150ms`,opacity:T?.75:1,width:de.renderedWidth,height:de.renderedHeight},children:(0,vj.jsx)(`video`,{ref:d,autoPlay:!0,muted:!0,playsInline:!0,"data-viewport-width":oe,"data-viewport-height":se,style:{position:`absolute`,top:0,left:0,maxWidth:`none`,objectFit:`fill`,width:de.renderedWidth*((ae?.canvasWidth??E)/E),height:de.renderedHeight*((ae?.canvasHeight??ue)/ue)}})}):S?(0,vj.jsx)(`div`,{style:{position:`relative`,overflow:`hidden`,background:`black`,width:de.renderedWidth,height:de.renderedHeight},children:(0,vj.jsx)(`img`,{ref:u,alt:``,draggable:!1,style:{position:`absolute`,inset:0,width:`100%`,height:`100%`,objectFit:`contain`}})}):null,e.activeTargetId?(0,vj.jsx)(Wj,{collaboration:e.collaboration,targetId:e.activeTargetId,enabled:re,visible:!e.mediaSwitching&&!T&&(w||S!==null),left:de.offsetX,top:de.offsetY,width:de.renderedWidth,height:de.renderedHeight}):null,c?.({status:ze,placeholder:w||S?null:Be,cursorHint:me&&he?{text:me,...he}:null,followedCursor:D&&ge?{name:ge.name,...D}:null,collaborationError:Ve?.message??null})]})}function Zj(e){return e===`disconnected`||e===`error`?`Session disconnected`:null}function Qj(e){return e.holderClientId!==null&&e.holderClientId!==e.clientId?`Input in use`:e.hasControl?null:e.lastError?.code===`input_busy`||e.lastError?.code===`input_not_owned`?`Input in use`:e.lastError?.code===`input_unavailable`?`Input unavailable`:null}function $j(e){return e?.code===`input_busy`||e?.code===`input_not_owned`}function eM(e,t,n){t.pending=n,tM(e,t)}function tM(e,t){if(t.decodingFrame!==null||t.pending===null)return;let n=t.pending,r=t.generation;t.pending=null,t.decodingFrame=n,nM(e,n).then(()=>{t.generation===r&&(t.decodingFrame=null,tM(e,t))})}async function nM(e,t){let n=e.src,r=URL.createObjectURL(t.data);e.src=r;try{await e.decode()}catch{}finally{n.startsWith(`blob:`)&&URL.revokeObjectURL(n),e.src!==r&&URL.revokeObjectURL(r)}}function rM(e,t){iM(t);let n=e.src;e.removeAttribute(`src`),n.startsWith(`blob:`)&&URL.revokeObjectURL(n)}function iM(e){e.generation+=1,e.decodingFrame=null,e.pending=null}function aM(e,t,n){return e===`connecting`?`connecting`:e===`connected`&&t===`connecting`?`connecting-media`:e===`connected`&&n?`switching`:e===`disconnected`||e===`error`?`disconnected`:`waiting`}function oM(e){if(!(e.metaKey||e.ctrlKey)||e.altKey)return null;switch(e.code){case`KeyC`:return`copy`;case`KeyX`:return`cut`;case`KeyV`:return`paste`;default:return null}}function sM(e){return e===0?`left`:e===1?`middle`:e===2?`right`:`none`}function cM(e,t,n,r,i){return i&&i.targetId===e&&i.button===t&&r-i.time<=Jj&&Math.abs(i.point.x-n.x)<=Yj&&Math.abs(i.point.y-n.y)<=Yj?Math.min(i.clickCount+1,3):1}function lM(e){switch(e){case`left`:return 1;case`right`:return 2;case`middle`:return 4;case`none`:return 0;default:return e}}function uM(e,t,n){return Math.min(Math.max(e,t),n)}function dM(e,t){return e===WheelEvent.DOM_DELTA_LINE?16:e===WheelEvent.DOM_DELTA_PAGE?t:1}async function fM(e,t){if(!e.activeTargetId)return;let n=``;try{n=await navigator.clipboard.readText()}catch(e){console.warn(`Clipboard read failed`,e),t?.({level:`error`,message:`Clipboard read failed`});return}n&&e.sendInput({type:`clipboard.paste`,targetId:e.activeTargetId,items:[{mimeType:`text/plain`,data:n}]})}function pM(e,t,n,r,i){return e===`connected`?n===`live`&&i?`webrtc`:t?r===`websocket-live`?`websocket`:`webrtc`:`offline`:`offline`}function mM(e){let t=e?.getRootNode();return t instanceof Document||t instanceof ShadowRoot?t.activeElement:null}var hM=[],gM=`aperture.viewport.auto-size-default`;function _M({access:e,displayName:t,enabled:n=!0,webrtcProducerSupported:r=!1,webrtcIceServers:i=hM,onNotice:a}){let o=Cj(),s=(0,$.useRef)(a);s.current=a;let c=(e,t)=>F(()=>s.current?.({level:e,message:t})),[l,u]=(0,$.useState)(yM),[d,f]=(0,$.useState)(()=>l),p=(0,$.useRef)(d);p.current=d;let m=(0,$.useCallback)(()=>p.current,[]),h=jj({access:e,displayName:t,enabled:n&&e!==null,webrtcSupported:r,iceServers:i,autoSize:m}),g=h.collaboration.role,[_,v]=(0,$.useState)([]),y=(0,$.useMemo)(()=>vM(_,h.targets),[h.targets,_]),b=(0,$.useRef)(h.targets);b.current=h.targets;let x=(0,$.useRef)(h.phase);x.current=h.phase;let[ee,S]=(0,$.useState)(CA),[C,te]=(0,$.useState)(null),[ne,w]=(0,$.useState)(!1),[T,re]=(0,$.useState)(!1),ie=g===`owner`||g===`editor`,ae=(0,$.useMemo)(()=>e===null?null:t=>XA(e,t),[e]),oe=(0,$.useRef)(null),se=(0,$.useRef)(ee),ce=(0,$.useRef)(CA),le=(0,$.useRef)(null);oe.current=h.activeTargetId,se.current=ee,le.current=C,(0,$.useEffect)(()=>{h.phase!==`connected`&&w(!1)},[h.phase]),(0,$.useEffect)(()=>{if(!h.mediaSize)return;let e=se.current;e.width===h.mediaSize.width&&e.height===h.mediaSize.height&&e.deviceScaleFactor===h.mediaSize.deviceScaleFactor||S(bM(h.mediaSize,h.mediaSize.deviceScaleFactor))},[h.mediaSize]);let E=(0,$.useCallback)(t=>!n||e===null?!1:h.sendBrowserInput(t,ce.current),[e,n,h]),ue=(0,$.useCallback)(e=>{h.selectTarget(e)},[h]),de=(0,$.useCallback)((e,t,n)=>{e!==t&&v(r=>{let i=vM(r,b.current).map(e=>e.id),a=i.indexOf(e),o=i.indexOf(t),s=i[a];if(a===-1||o===-1||!s)return r;let c=[...i];c.splice(a,1);let l=n===`after`?o+1:o,u=a<l?l-1:l;return u===a?r:(c.splice(u,0,s),c)})},[]),fe=(0,$.useCallback)(e=>o.runPromise(h.request(`target.create`,{url:e}).pipe(Tf(e=>e.targetId??null),kf(e=>c(`error`,SM(e,`Tab could not be created`)).pipe(Ef(null))))),[h,o]),pe=(0,$.useCallback)((e=`about:blank`)=>{fe(e)},[fe]),me=(0,$.useCallback)(e=>{fe(e.url||`about:blank`).then(t=>{t&&de(t,e.id,`after`)})},[fe,de]),he=(0,$.useCallback)(e=>{h.command(`target.close`,{targetId:e})},[h]),ge=(0,$.useCallback)(e=>{let t=oe.current;t&&h.command(`page.navigate`,{targetId:t,url:e})},[h]),_e=(0,$.useCallback)(e=>{h.command(`page.reload`,{targetId:e})},[h]),D=(0,$.useCallback)(()=>{let e=oe.current;e&&h.command(`page.stop-loading`,{targetId:e})},[h]),ve=(0,$.useCallback)(()=>{let e=oe.current;e&&h.command(`page.history-back`,{targetId:e})},[h]),ye=(0,$.useCallback)(()=>{let e=oe.current;e&&h.command(`page.history-forward`,{targetId:e})},[h]),be=h.viewportOwnership,xe=(0,$.useRef)(be);xe.current=be;let Se=d&&(be===null||be.ownerClientId===h.collaboration.clientId),Ce=(0,$.useRef)(Se);Ce.current=Se,(0,$.useEffect)(()=>{be!==null&&(p.current=be.autoSize,f(be.autoSize))},[be]);let we=Tj(e=>h.request(`viewport.set`,e).pipe(Ff),[h.request]),Te=(0,$.useCallback)((e,t)=>{S(e);let n=oe.current;if(n===null)return;let r={targetId:n,width:e.width,height:e.height,deviceScaleFactor:e.deviceScaleFactor};t&&xe.current!==null?we({...r,autoSize:!0}):h.command(`viewport.set`,r)},[h.command,we]),Ee=(0,$.useCallback)(e=>{p.current!==e&&(p.current=e,f(e),xe.current!==null&&h.command(`viewport.auto-size.set`,{enabled:e}))},[h.command]);(0,$.useEffect)(()=>{let e=le.current;Se&&h.phase===`connected`&&h.activeTargetId!==null&&e!==null&&Te(bM(e,se.current.deviceScaleFactor),!0)},[Te,h.activeTargetId,h.phase,Se]);let De=(0,$.useCallback)(e=>{Ee(!1),Te(e,!1)},[Te,Ee]),Oe=(0,$.useCallback)(e=>{let t={width:Math.round(e.width),height:Math.round(e.height)};if(t.width<1||t.height<1)return;let n=le.current;n?.width===t.width&&n.height===t.height||(le.current=t,te(t),Ce.current&&Te(bM(t,se.current.deviceScaleFactor),!0))},[Te]),ke=(0,$.useCallback)(()=>{let e=le.current;e&&(Ee(!1),Te(bM(e,se.current.deviceScaleFactor),!1))},[Te,Ee]),Ae=(0,$.useCallback)(()=>{p.current=!0,f(!0),h.command(`viewport.owner.claim`)},[h.command]),je=(0,$.useCallback)(e=>{u(e);try{window.localStorage.setItem(gM,String(e))}catch{}},[]),Me=(e,t)=>e.pipe(kf(e=>c(`error`,SM(e,t))),Qf(F(()=>re(!1)))),Ne=Tj((e,t,n)=>Me(h.request(`recording.start`,{mode:e,targetId:t,...n}),`Recording failed to start`),[h]),Pe=(0,$.useCallback)((e,t)=>{let n=oe.current;!n||!ie||T||(re(!0),Ne(e,n,t))},[ie,T,Ne]),Fe=Tj((e,t)=>Me(h.request(`recording.stop`,{recordingId:t}).pipe(Sf(YA(e,t)),L(({blob:n,filename:r})=>{let i=h.recordings.find(e=>e.recordingId===t);return xM(n,r??`${e.sessionId}-${i?.targetId??`target`}-${t}.webm`)}),Sf(c(`success`,`Recording saved`))),`Recording failed to stop`),[h]),Ie=(0,$.useCallback)(t=>{e===null||T||(re(!0),Fe(e,t))},[e,T,Fe]),Le=Tj(e=>Me(h.request(`recording.cancel`,{recordingId:e}).pipe(Sf(c(`success`,`Recording stopped`))),`Recording failed to stop`),[h]),Re=(0,$.useCallback)(e=>{T||(re(!0),Le(e))},[T,Le]),ze=Tj(e=>h.request(`presentation.cursor.set`,{visible:e}).pipe(kf(e=>c(`error`,SM(e,`Remote cursor could not be updated`)))),[h]),Be=(0,$.useCallback)(t=>{e!==null&&ze(t)},[e,ze]),[Ve,He]=(0,$.useState)(!1),Ue=(0,$.useRef)(h.command);Ue.current=h.command,(0,$.useEffect)(()=>{h.phase===`connected`&&ie&&Ue.current(`automation.pacing.set`,{pacing:Ve?`watchable`:`normal`})},[h.phase,ie,Ve]);let We=Tj(e=>h.selectPresentation(e).pipe(kf(e=>c(`error`,SM(e,`Presentation could not be updated`)))),[h]),Ge=(0,$.useCallback)(t=>!n||e===null||h.mediaSwitching?!1:(We(t),!0),[e,n,h.mediaSwitching,We]),Ke=(0,$.useCallback)(e=>Ge({kind:`webrtc`,quality:e}),[Ge]),qe=(0,$.useMemo)(()=>{let e=e=>uf(()=>x.current===`connected`?e:I(new ZA({message:`the session is not connected`}))),t=(t,n)=>e(h.request(t,n)),n=(t,n={})=>e(uf(()=>{let e=oe.current;return e?h.request(t,{targetId:e,...n}):I(new ZA({message:`no tab is active`}))})).pipe(Of);return{navigate:e=>n(`page.navigate`,{url:e}),historyBack:()=>n(`page.history-back`),historyForward:()=>n(`page.history-forward`),reload:e=>e?t(`page.reload`,{targetId:e}).pipe(Of):n(`page.reload`),stopLoading:()=>n(`page.stop-loading`),createTarget:(e=`about:blank`)=>t(`target.create`,{url:e}).pipe(Tf(e=>e.targetId??null)),closeTarget:e=>t(`target.close`,{targetId:e}).pipe(Of),activateTarget:t=>e(h.requestSelectTarget(t))}},[h.request,h.requestSelectTarget]),Je=(0,$.useMemo)(()=>y.find(e=>e.id===h.activeTargetId)??null,[h.activeTargetId,y]),Ye=h.transport===`webrtc`?`webrtc-live`:`websocket-live`,Xe=h.phase===`connected`?`live`:h.phase===`connecting`?`connecting`:h.phase===`error`?`failed`:`idle`;return{phase:h.phase,targets:y,activeTargetId:h.activeTargetId,activeTarget:Je,frames:h.frames,mediaPhase:Xe,mediaStream:h.mediaStream,mediaStreamSettings:h.presentation?.quality??null,mediaVideoProfiles:h.presentation?.profiles??[],mediaSize:h.mediaSize,mediaPath:Ye,mediaTargetId:h.activeTargetId,mediaSwitching:h.mediaSwitching,viewport:ee,browserViewportSize:C,viewportAutoSync:d,viewportAutoSizeActive:Se,viewportOwnership:be,viewportAutoSizeDefault:l,captured:ne,recordings:h.recordings,canRecord:ie,loadTargetThumbnail:ae,recordingBusy:T,remoteCursorEnabled:h.presentation?.cursorVisible??!0,watchableAutomation:Ve,collaboration:h.collaboration,commands:qe,setCaptured:w,setInputDimensions:e=>{ce.current=e},setViewport:De,setBrowserViewportSize:Oe,setViewportAutoSync:Ee,setViewportToBrowserSize:ke,setViewportAutoSizeDefault:je,takeOverViewport:Ae,setWebRTCStreamSettings:Ke,selectMediaStream:Ge,sendInput:E,activateTarget:ue,reorderTargets:de,createTarget:pe,duplicateTarget:me,closeTarget:he,navigate:ge,reload:_e,stopLoading:D,historyBack:ve,historyForward:ye,startRecording:Pe,stopRecording:Ie,cancelRecording:Re,setRemoteCursorEnabled:Be,setWatchableAutomation:He,reconnect:h.reconnect}}function vM(e,t){let n=new Map(t.map(e=>[e.id,e])),r=new Set,i=[];for(let t of e){let e=n.get(t);e&&(i.push(e),r.add(e.id))}for(let e of t)r.has(e.id)||i.push(e);return i}function yM(){try{return window.localStorage.getItem(gM)===`true`}catch{return!1}}function bM(e,t){return TA(e.width,e.height,t)}var xM=(e,t)=>Xf(F(()=>URL.createObjectURL(e)),e=>F(()=>{let n=document.createElement(`a`);n.href=e,n.download=t,n.click()}),e=>F(()=>URL.revokeObjectURL(e)).pipe(Lf(0)));function SM(e,t){return e instanceof Error&&e.message?e.message:t}var CM=`~effect/ManagedRuntime`,wM=(e,t)=>{let n=t?.memoMap??id(),r=Uu(`sequential`),i=qu(r,`sequential`),a={onFiberStart:Pp(qu(r,`parallel`))},o=e=>e?{...e,onFiberStart:e.onFiberStart?t=>{a.onFiberStart(t),e.onFiberStart(t)}:a.onFiberStart}:a,s,c=bf(t=>(s||=fp(Cf(sd(e,n,i),e=>F(()=>{l.cachedContext=e})),{...a,scheduler:t.cache.scheduler}),xf(Ap(s)))),l={[CM]:CM,memoMap:n,scope:r,contextEffect:c,cachedContext:void 0,context(){return l.cachedContext===void 0?gp(l.contextEffect):Promise.resolve(l.cachedContext)},dispose(){return gp(l.disposeEffect)},[Symbol.asyncDispose](){return l.dispose()},disposeEffect:uf(()=>(l.contextEffect=_f(`ManagedRuntime disposed`),l.cachedContext=void 0,Ju(l.scope,Au))),runFork(e,t){return l.cachedContext===void 0?fp(TM(l,e),o(t)):pp(l.cachedContext)(e,o(t))},runCallback(e,t){return l.cachedContext===void 0?hp(TM(l,e),o(t)):mp(l.cachedContext)(e,o(t))},runSyncExit(e){return l.cachedContext===void 0?Sp(TM(l,e)):Cp(l.cachedContext)(e)},runSync(e){return l.cachedContext===void 0?bp(TM(l,e)):xp(l.cachedContext)(e)},runPromiseExit(e,t){return l.cachedContext===void 0?vp(TM(l,e),o(t)):yp(l.cachedContext)(e,o(t))},runPromise(e,t){return l.cachedContext===void 0?gp(TM(l,e),o(t)):_p(l.cachedContext)(e,o(t))}};return l};function TM(e,t){return L(e.contextEffect,e=>Gf(t,e))}var EM=(e={})=>wM(hd(VA,iA.pipe(_d(e.baseUrl?aA(e.baseUrl):ud),_d(VA)),cd(xT,!1)));function DM({baseUrl:e,children:t}){let[n,r]=(0,$.useState)(null);return(0,$.useEffect)(()=>{let t=EM({baseUrl:e});return r(t),()=>{r(null),t.dispose()}},[e]),n?(0,vj.jsx)(xj,{runtime:n,baseUrl:e,children:t}):null}function OM(e,t){let n=e.slice(4,40);return!(e.startsWith(`ape_`)||e.startsWith(`apv_`))||e[40]!==`_`||e.length<=41?null:{kind:`direct`,baseUrl:t,sessionId:n,credentials:{kind:`bearer`,token:y_(e),authorityType:null,tenantId:null,selectedTenantId:null}}}var kM=[];function AM(e){return e===401||e===403?`denied`:e===410?`expired`:`unavailable`}function jM({access:e,displayName:t,onNotice:n}){let[r,i]=(0,$.useState)({access:null,status:`loading`,browser:null});wj(()=>{if(e!==null)return i({access:e,status:`loading`,browser:null}),JA(e).pipe(Vf({onFailure:t=>i({access:e,status:AM(t.status),browser:null}),onSuccess:t=>i(e.kind===`direct`&&t.sessionId!==e.sessionId?{access:e,status:`unavailable`,browser:null}:{access:e,status:`ready`,browser:t})}))},[e]);let a=r.access===e?r.browser:null,o=_M({access:a===null?null:e,displayName:t,webrtcProducerSupported:a?.media.mode===`auto`&&a.media.webrtcProducer,webrtcIceServers:a?.media.iceServers??kM,onNotice:n});return{status:e===null?`invalid`:r.access===e?r.status:`loading`,browser:a,control:o}}function MM(){let e=null;return t=>{let n=t.getAttribute(`token`),r=t.getAttribute(`base-url`);return(e===null||e.token!==n||e.baseUrl!==r)&&(e={token:n,baseUrl:r,access:n===null?null:OM(n,r??void 0)}),e.access}}export{lf as A,mf as C,Jf as D,gp as E,g as F,m as I,f as L,Qd as M,Da as N,uf as O,ur as P,o as R,I as S,sp as T,BC as _,Tj as a,Af as b,ZA as c,TA as d,EA as f,KS as g,US as h,Xj as i,df as j,F as k,wA as l,VS as m,jM as n,wj as o,Mk as p,DM as r,_j as s,MM as t,SA as u,Zf as v,pf as w,kf as x,Sf as y,c as z};