1(globalThis.webpackChunkwebsite||=[]).push([[977],{6798(e,t,s){"use strict";s.d(t,{Y:()=>n});const i=!0;class n{#e=new Uint8Array(4096);#t;#s=new TextEncoder;#i=0;constructor(){this.#t=new DataView(this.#e.buffer)}get length(){return this.#i}get buffer(){return this.#e.slice(0,this.#i)}bufferView(e,t){return new Uint8Array(this.#e.buffer,e,t)}int8(e){return this.#n(1),this.#t.setInt8(this.#i,e),this.#i+=1,this}uint8(e){return this.#n(1),this.#t.setUint8(this.#i,e),this.#i+=1,this}int16(e){return this.#n(2),this.#t.setInt16(this.#i,e,i),this.#i+=2,this}uint16(e){return this.#n(2),this.#t.setUint16(this.#i,e,i),this.#i+=2,this}int32(e){return this.#n(4),this.#t.setInt32(this.#i,e,i),this.#i+=4,this}uint32(e){return this.#n(4),this.#t.setUint32(this.#i,e,i),this.#i+=4,this}int64(e){return this.#n(8),this.#t.setBigInt64(this.#i,e,i),this.#i+=8,this}uint64(e){return this.#n(8),this.#t.setBigUint64(this.#i,e,i),this.#i+=8,this}string(e){const t=this.#s.encode(e);return this.#n(t.byteLength+4),this.uint32(t.length),this.#e.set(t,this.#i),this.#i+=t.length,this}bytes(e){return this.#n(e.byteLength),this.#e.set(e,this.#i),this.#i+=e.length,this}tupleArray(e,t,s){const i=this.#i;this.uint32(0);for(const[a,o]of s)e.call(this,a),t.call(this,o);const n=this.#i;this.#i=i;const r=n-i-4;return this.uint32(r),this.#i=n,this}seek(e){return this.#r(e),this.#i=e,this}reset(){return this.#i=0,this}#n(e){this.#r(this.#i+e)}#r(e){if(e>this.#e.byteLength){const t=Math.max(1.5*this.#e.byteLength,e),s=new Uint8Array(t);s.set(this.#e),this.#e=s,this.#t=new DataView(this.#e.buffer)}}}},6589(e,t,s){"use strict";s.d(t,{l:()=>i});class i{#a;#o=new Map;#d;#c=0;#h;constructor(e,t){this.#a=e,this.#d=t}async size(){return null==this.#h&&(this.#h=await this.#a.size()),this.#h}async read(e,t,s){const i=Number(t),n=this.#o.get(e);if(null!=n&&n.byteLength>=i)return n.byteLength===i?n:n.subarray(0,i);const r=await this.#a.read(e,t,s);if(this.#c+r.byteLength<=this.#d){const t=new Uint8Array(r);return this.#o.set(e,t),this.#c+=t.byteLength,t}return r}}},7419(e,t,s){"use strict";s.d(t,{v:()=>n});var i=s(9552);class n{#u=new i.w;#f;#l=0;messageStartTime=0n;messageEndTime=0n;constructor({useMessageIndex:e=!0}){e&&(this.#f=new Map)}get numMessages(){return this.#l}get buffer(){return this.#u.buffer}get byteLength(){return this.#u.length}get indices(){return this.#f?this.#f.values():[]}addSchema(e){this.#u.writeSchema(e)}addChannel(e){this.#f&&!this.#f.has(e.id)&&this.#f.set(e.id,{channelId:e.id,records:[]}),this.#u.writeChannel(e)}addMessage(e){if((0===this.#l||e.logTime<this.messageStartTime)&&(this.messageStartTime=e.logTime),(0===this.#l||e.logTime>this.messageEndTime)&&(this.messageEndTime=e.logTime),this.#f){let t=this.#f.get(e.channelId);t||(t={channelId:e.channelId,records:[]},this.#f.set(e.channelId,t)),t.records.push([e.logTime,BigInt(this.#u.length)])}this.#l+=1,this.#u.writeMessage(e)}reset(){this.messageStartTime=0n,this.messageEndTime=0n,this.#l=0,this.#f?.clear(),this.#u.reset()}}},1448(e,t,s){"use strict";s.d(t,{I:()=>o});var i=s(4951),n=s(1952),r=s(3389),a=s(4356);class o{#m;#g;#p;#b;#w;#y;#C=0;constructor(e){if(this.chunkIndex=e.chunkIndex,this.#m=e.relevantChannels,this.#g=e.startTime,this.#p=e.endTime,this.#b=e.reverse,this.#w=e.readFullMessageIndexRange??!1,0n===this.chunkIndex.messageIndexLength&&(0n!==this.chunkIndex.messageStartTime||0n!==this.chunkIndex.messageEndTime))throw new Error("Encountered a chunk index without message indexes and non-zero start and end times")}compare(e){if(this.#b!==e.#b)throw new Error("Cannot compare a reversed ChunkCursor to a non-reversed ChunkCursor");let t=Number(this.#v()-e.#v());return 0===t&&(t=Number(this.chunkIndex.chunkStartOffset-e.chunkIndex.chunkStartOffset)),this.#b?-t:t}hasMoreMessages(){if(null==this.#y)throw new Error("loadMessageIndexes() must be called before hasMore()");return this.#C<this.#y.length}popMessage(){if(null==this.#y)throw new Error("loadMessageIndexes() must be called before popMessage()");if(this.#C>=this.#y.length)throw new Error(`Unexpected popMessage() call when no more messages are available, in chunk at offset ${this.chunkIndex.chunkStartOffset}`);return this.#y[this.#C++]}hasMessageIndexes(){return null!=this.#y}async loadMessageIndexes(e,t){const s=this.#b;let o,d;const c=this.#w;for(const[i,n]of this.chunkIndex.messageIndexOffsets)(null==o||n<o)&&(o=n),(c||!this.#m||this.#m.has(i))&&(null==d||n<d)&&(d=n);if(null==o||null==d)return void(this.#y=[]);const h=o+this.chunkIndex.messageIndexLength,u=await e.read(d,h-d,t),f=new DataView(u.buffer,u.byteOffset,u.byteLength),l=new i.A(f),m=[];let g;for(;g=(0,n.H)(l,!0);)"MessageIndex"===g.type&&(0===g.records.length||this.#m&&!this.#m.has(g.channelId)||m.push(g.records));if(0!==l.bytesRemaining())throw new Error(`${l.bytesRemaining()} bytes remaining in message index section`);if(this.#y=m.flat().sort(([e,t],[s,i])=>{let n=Number(e-s);return 0===n&&(n=Number(t-i)),n}),s&&this.#y.reverse(),0===this.#y.length)return;const[p]=this.#y[0];if(p<this.chunkIndex.messageStartTime)throw new Error(`Chunk at offset ${this.chunkIndex.chunkStartOffset} contains a message with logTime (${p}) earlier than chunk messageStartTime (${this.chunkIndex.messageStartTime})`);const[b]=this.#y[this.#y.length-1];if(b>this.chunkIndex.messageEndTime)throw new Error(`Chunk at offset ${this.chunkIndex.chunkStartOffset} contains a message with logTime (${b}) later than chunk messageEndTime (${this.chunkIndex.messageEndTime})`);const w=s?this.#p:this.#g,y=s?this.#g:this.#p,C=s?e=>-e:e=>e;let v,S;null!=w&&(v=(0,r.n)(this.#y,w,C)),null!=y&&(S=(0,a.p)(this.#y,y,C)),null==v&&null==S||(this.#y=this.#y.slice(v,S))}#v(){return null!=this.#y&&this.#y.length>0&&this.#C<this.#y.length?this.#y[this.#C][0]:this.#b?this.chunkIndex.messageEndTime:this.chunkIndex.messageStartTime}}},4951(e,t,s){"use strict";s.d(t,{A:()=>r});var i=s(5255);const n=new TextDecoder;class r{#t;#S;constructor(e,t=0){this.#t=e,this.#S=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),this.offset=t}reset(e,t=0){this.#t=e,this.#S=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),this.offset=t}bytesRemaining(){return this.#S.length-this.offset}uint8(){const e=this.#t.getUint8(this.offset);return this.offset+=1,e}uint16(){const e=this.#t.getUint16(this.offset,!0);return this.offset+=2,e}uint32(){const e=this.#t.getUint32(this.offset,!0);return this.offset+=4,e}uint64(){const e=i.b.call(this.#t,this.offset,!0);return this.offset+=8,e}string(){const e=this.uint32();if(0===e)return"";if(e>this.bytesRemaining())throw new Error(`String length ${e}
1 exceeds bounds of buffer`);return n.decode(this.u8ArrayBorrow(e))}keyValuePairs(e,t){const s=this.uint32();if(this.offset+s>this.#t.byteLength)throw new Error(`Key-value pairs length ${s} exceeds bounds of buffer`);const i=[],n=this.offset+s;try{for(;this.offset<n;)i.push([e(this),t(this)])}catch(r){throw new Error(`Error reading key-value pairs: ${r.message}`)}if(this.offset!==n)throw new Error(`Key-value pairs length (${this.offset-n+s}) greater than expected (${s})`);return i}map(e,t){const s=this.uint32();if(this.offset+s>this.#t.byteLength)throw new Error(`Map length ${s} exceeds bounds of buffer`);const i=new Map,n=this.offset+s;try{for(;this.offset<n;){const s=e(this),n=t(this),r=i.get(s);if(null!=r)throw new Error(`Duplicate key ${String(s)} (${String(r)} vs ${String(n)})`);i.set(s,n)}}catch(r){throw new Error(`Error reading map: ${r.message}`)}if(this.offset!==n)throw new Error(`Map length (${this.offset-n+s}) greater than expected (${s})`);return i}u8ArrayBorrow(e){if(!(e>=0&&e<=this.bytesRemaining()))throw new Error(`Byte array length ${e} exceeds bounds of buffer`);const t=this.#S.subarray(this.offset,this.offset+e);return this.offset+=e,t}u8ArrayCopy(e){if(!(e>=0&&e<=this.bytesRemaining()))throw new Error(`Byte array length ${e} exceeds bounds of buffer`);const t=this.#S.slice(this.offset,this.offset+e);return this.offset+=e,t}}},8446(e,t,s){"use strict";s.d(t,{k:()=>h});var i=s(6796),n=s(8917),r=s(6589),a=s(1448),o=s(4951),d=s(8094),c=s(1952);class h{metadataIndexes=[];#a;#I;#x;#E;#k;#T;#M;constructor(e){this.#a=e.readable,this.chunkIndexes=e.chunkIndexes,this.attachmentIndexes=e.attachmentIndexes,this.metadataIndexes=e.metadataIndexes,this.statistics=e.statistics,this.#x=e.decompressHandlers,this.channelsById=e.channelsById,this.schemasById=e.schemasById,this.summaryOffsetsByOpcode=e.summaryOffsetsByOpcode,this.header=e.header,this.footer=e.footer,this.dataEndOffset=e.dataEndOffset,this.dataSectionCrc=e.dataSectionCrc;const t=e.messageIndexCacheSizeBytes??0;this.#I=t>0?new r.l(this.#a,t):this.#a;for(const s of e.chunkIndexes)(null==this.#E||s.messageStartTime<this.#E)&&(this.#E=s.messageStartTime),(null==this.#k||s.messageEndTime>this.#k)&&(this.#k=s.messageEndTime);for(const s of e.attachmentIndexes)(null==this.#T||s.logTime<this.#T)&&(this.#T=s.logTime),(null==this.#M||s.logTime>this.#M)&&(this.#M=s.logTime)}#A(e){return new Error(`${e} [library=${this.header.library}]`)}static async Initialize({readable:e,decompressHandlers:t,messageIndexCacheSizeBytes:s,readOptions:n}){const r=await e.size();let a,u,f,l,m;{const t=await e.read(0n,BigInt(d.ue.length+1+8),n),s=new DataView(t.buffer,t.byteOffset,t.byteLength);(0,c.Z)(new o.A(s));const i=9n+s.getBigUint64(d.ue.length+1,!0),r=await e.read(BigInt(d.ue.length),i,n);u=BigInt(d.ue.length)+i;const h=new o.A(new DataView(r.buffer,r.byteOffset,r.byteLength)),f=(0,c.H)(h,!0);if("Header"!==f?.type)throw new Error(`Unable to read header at beginning of file; found ${f?.type??"nothing"}`);if(0!==h.bytesRemaining())throw new Error(`${h.bytesRemaining()} bytes remaining after parsing header`);a=f}function g(e){return new Error(`${e} [library=${a.library}]`)}{const t=BigInt(d.ue.length+1+8+4+4),s=BigInt(29+d.ue.length);if(r<t+s)throw g(`File size (${r}) is too small to be valid MCAP`);f=r-s;const i=await e.read(f,s,n);l=new DataView(i.buffer,i.byteOffset,i.byteLength)}try{(0,c.Z)(new o.A(l,l.byteLength-d.ue.length))}catch(O){throw g(O.message)}{const e=new o.A(l),t=(0,c.H)(e,!0);if("Footer"!==t?.type)throw g(`Unable to read footer from end of file (offset ${f}); found ${t?.type??"nothing"}`);if(e.bytesRemaining()!==d.ue.length)throw g(e.bytesRemaining()-d.ue.length+" b
1ytes remaining after parsing footer");m=t}if(0n===m.summaryStart)throw g("File is not indexed");const p=new Uint8Array(25);p.set(new Uint8Array(l.buffer,l.byteOffset,p.byteLength));const b=m.summaryStart-13n;if(b<u)throw g(`Expected DataEnd position (summary start ${m.summaryStart} - 13 = ${b}) to be after Header end offset (${u})`);const w=await e.read(b,f-b,n);if(0!==m.summaryCrc){let e=(0,i.oU)();if(e=(0,i.B_)(e,w.subarray(Number(13n))),e=(0,i.B_)(e,p),e=(0,i.kh)(e),e!==m.summaryCrc)throw g(`Incorrect summary CRC ${e} (expected ${m.summaryCrc})`)}const y=new DataView(w.buffer,w.byteOffset,w.byteLength),C=new o.A(y),v=new Map,S=new Map,I=[],x=[],E=[],k=new Map;let T,M,A,B=!0;for(;A=(0,c.H)(C,!0);){if(B&&"DataEnd"!==A.type)throw g(`Expected DataEnd record to precede summary section, but found ${A.type}`);switch(B=!1,A.type){case"Schema":S.set(A.id,A);break;case"Channel":v.set(A.id,A);break;case"ChunkIndex":I.push(A);break;case"AttachmentIndex":x.push(A);break;case"MetadataIndex":E.push(A);break;case"Statistics":if(T)throw g("Duplicate Statistics record");T=A;break;case"SummaryOffset":k.set(A.groupOpcode,A);break;case"DataEnd":M=0===A.dataSectionCrc?void 0:A.dataSectionCrc;break;case"Header":case"Footer":case"Message":case"Chunk":case"MessageIndex":case"Attachment":case"Metadata":throw g(`${A.type} record not allowed in index section`)}}if(0!==C.bytesRemaining())throw g(`${C.bytesRemaining()} bytes remaining in index section`);return new h({readable:e,chunkIndexes:I,attachmentIndexes:x,metadataIndexes:E,statistics:T,decompressHandlers:t,channelsById:v,schemasById:S,summaryOffsetsByOpcode:k,header:a,footer:m,dataEndOffset:b,dataSectionCrc:M,messageIndexCacheSizeBytes:s})}async*readMessages(e={}){const{topics:t,startTime:s=this.#E,endTime:i=this.#k,reverse:r=!1,validateCrcs:d,readOptions:h}=e;if(null==s||null==i)return;let u;if(t){u=new Set;for(const e of this.channelsById.values())t.includes(e.topic)&&u.add(e.id)}const f=new n.rs((e,t)=>e.compare(t));let l,m=!0;const g=this.#I!==this.#a;for(const n of this.chunkIndexes)n.messageStartTime<=i&&n.messageEndTime>=s&&(f.push(new a.I({chunkIndex:n,relevantChannels:u,startTime:s,endTime:i,reverse:r,readFullMessageIndexRange:g})),m&&null!=l&&(m=n.messageStartTime>=l),l=n.messageEndTime);const p=new Map,b=new o.A(new DataView(new ArrayBuffer(0)));for(let n;n=f.peek();){if(!n.hasMessageIndexes()){await n.loadMessageIndexes(this.#I,h),n.hasMoreMessages()?f.replace(n):f.pop();continue}let e=p.get(n.chunkIndex.chunkStartOffset);e||(e=await this.#B(n.chunkIndex,{validateCrcs:d??!0,readOptions:h}),p.set(n.chunkIndex.chunkStartOffset,e));const[t,s]=n.popMessage();if(s>=BigInt(e.byteLength))throw this.#A(`Message offset beyond chunk bounds (log time ${t}, offset ${s}, chunk data length ${e.byteLength}) in chunk at offset ${n.chunkIndex.chunkStartOffset}`);b.reset(e,Number(s));const i=(0,c.H)(b,d??!0);if(!i)throw this.#A(`Unable to parse record at offset ${s} in chunk at offset ${n.chunkIndex.chunkStartOffset}`);if("Message"!==i.type)throw this.#A(`Unexpected record type ${i.type} in message index (time ${t}, offset ${s} in chunk at offset ${n.chunkIndex.chunkStartOffset})`);if(i.logTime!==t)throw this.#A(`Message log time ${i.logTime} did not match message index entry (${t} at offset ${s} in chunk at offset ${n.chunkIndex.chunkStartOffset})`);yield i,n.hasMoreMessages()?m||f.replace(n):(f.pop(),p.delete(n.chunkIndex.chunkStartOffset))}}async*readMetadata(e={}){const{name:t,readOptions:s}=e;for(const i of this.metadataIndexes){if(null!=t&&i.name!==t)continue;const e=await this.#a.read(i.offset,i.length,s),n=new o.A(new DataView(e.buffer,e.byteOffset,e.byteLength)),r=(0,c.H)(n,!1);if("Metadata"!==r?.type)throw this.#A(`Metadata data at offset ${i.offset} does not point to metadata record (found ${String(r?.type)})`);yield r}}async*readAttachments(e={}){const{name:t,mediaType:s,startTime:i=this.#T,endTime:n=this.#M,validateCrcs:r,readOptions:a}=e;if(null!=i&&null!=n)for(const d of this.attachmentIndexes){if(null!=t&&d.name!==t)continue;if(null!=s&&d.mediaType!==s)continue;if(d.logTime>n||d.logTime<i)continue;const e=await this.#a.read(d.offset,d.length,a),h=new o.A(new DataView(e.buffer,e.byteOffset,e.byteLength)),u=(0,c.H)(h,r??!0);if("Attachment"!==u?.type)throw this.#A(`Attachment data at offset ${d.offset} does not point to attachment record (found ${String(u?.type)})`);yield u}}async#B(e,t){const s=await this.#a.read(e.chunkStartOffset,e.chunkLength,t?.readOptions),n=new o.A(new DataView(s.buffer,s.byteOffset,s.byteLength)),r=(0,c.H)(n,t?.validateCrcs??!0);if("Chunk"!==r?.type)throw this.#A(`Chunk start offset ${e.chunkStartOffset} does not point to chunk record (found ${String(r?.type)})`);const a=r;let d=a.records;if(""!==a.compression&&d.byteLength>0){const e=this.#x?.[a.compression];if(!e)throw this.#A(`Unsupported compression ${a.compression}`);d=e(d,a.uncompressedSize)}if(0!==a.uncompressedCrc&&!1!==t?.validateCrcs){const e=(0,i.QR)(d);if(e!==a.uncompressedCrc)throw this.#A(`Incorrect chunk CRC ${e} (expected ${a.uncompressedCrc})`)}return new DataView(d.buffer,d.byteOffset,d.byteLength)}}},9552(e,t,s){"use strict";s.d(t,{w:()=>a});var i=s(6796),n=s(6798),r=s(8094);class a{#O=new n.Y;
1constructor(e){this.options=e}get length(){return this.#O.length}get buffer(){return this.#O.buffer}reset(){this.#O.reset()}writeMagic(){this.#O.bytes(new Uint8Array(r.ue))}writeHeader(e){this.#O.uint8(r.pz.HEADER);const t=this.#O.length;this.#O.uint64(0n).string(e.profile).string(e.library),!0===this.options?.padRecords&&this.#O.uint8(1).uint8(255).uint8(255);const s=this.#O.length;return this.#O.seek(t).uint64(BigInt(s-t-8)).seek(s),BigInt(s-t+1)}writeFooter(e){return this.#O.uint8(r.pz.FOOTER).uint64(20n).uint64(e.summaryStart).uint64(e.summaryOffsetStart).uint32(e.summaryCrc),20n}writeSchema(e){this.#O.uint8(r.pz.SCHEMA);const t=this.#O.length;this.#O.uint64(0n).uint16(e.id).string(e.name).string(e.encoding).uint32(e.data.byteLength).bytes(e.data),!0===this.options?.padRecords&&this.#O.uint8(1).uint8(255).uint8(255);const s=this.#O.length;return this.#O.seek(t).uint64(BigInt(s-t-8)).seek(s),BigInt(s-t+1)}writeChannel(e){this.#O.uint8(r.pz.CHANNEL);const t=this.#O.length;this.#O.uint64(0n).uint16(e.id).uint16(e.schemaId).string(e.topic).string(e.messageEncoding).tupleArray(e=>this.#O.string(e),e=>this.#O.string(e),e.metadata),!0===this.options?.padRecords&&this.#O.uint8(1).uint8(255).uint8(255);const s=this.#O.length;return this.#O.seek(t).uint64(BigInt(s-t-8)).seek(s),BigInt(s-t+1)}writeMessage(e){this.#O.uint8(r.pz.MESSAGE);const t=this.#O.length;this.#O.uint64(0n).uint16(e.channelId).uint32(e.sequence).uint64(e.logTime).uint64(e.publishTime).bytes(e.data);const s=this.#O.length;this.#O.seek(t).uint64(BigInt(s-t-8)).seek(s)}writeAttachment(e){this.#O.uint8(r.pz.ATTACHMENT);const t=this.#O.length;this.#O.uint64(0n);const s=this.#O.length;this.#O.uint64(e.logTime).uint64(e.createTime).string(e.name).string(e.mediaType).uint64(BigInt(e.data.byteLength)).bytes(e.data),this.#O.uint32((0,i.QR)(this.#O.bufferView(s,this.#O.length-s))),!0===this.options?.padRecords&&this.#O.uint8(1).uint8(255).uint8(255);const n=this.#O.length;return this.#O.seek(t).uint64(BigInt(n-t-8)).seek(n),BigInt(n-t+1)}writeAttachmentIndex(e){this.#O.uint8(r.pz.ATTACHMENT_INDEX);const t=this.#O.length;this.#O.uint64(0n).uint64(e.offset).uint64(e.length).uint64(e.logTime).uint64(e.createTime).uint64(e.dataSize).string(e.name).string(e.mediaType),!0===this.options?.padRecords&&this.#O.uint8(1).uint8(255).uint8(255);const s=this.#O.length;return this.#O.seek(t).uint64(BigInt(s-t-8)).seek(s),BigInt(s-t+1)}writeChunk(e){this.#O.uint8(r.pz.CHUNK);const t=this.#O.length;this.#O.uint64(0n).uint64(e.messageStartTime).uint64(e.messageEndTime).uint64(e.uncompressedSize).uint32(e.uncompressedCrc).string(e.compression).uint64(BigInt(e.records.byteLength)).bytes(e.records);const s=this.#O.length;return this.#O.seek(t).uint64(BigInt(s-t-8)).seek(s),BigInt(s-t+1)}writeChunkIndex(e){this.#O.uint8(r.pz.CHUNK_INDEX);const t=this.#O.length;this.#O.uint64(0n).uint64(e.messageStartTime).uint64(e.messageEndTime).uint64(e.chunkStartOffset).uint64(e.chunkLength).uint32(10*e.messageIndexOffsets.size);for(const[i,n]of e.messageIndexOffsets)this.#O.uint16(i).uint64(n);this.#O.uint64(e.messageIndexLength).string(e.compression).uint64(e.compressedSize).uint64(e.uncompressedSize),!0===this.options?.padRecords&&this.#O.uint8(1).uint8(255).uint8(255);const s=this.#O.length;return this.#O.seek(t).uint64(BigInt(s-t-8)).seek(s),BigInt(s-t+1)}writeMessageIndex(e){this.#O.uint8(r.pz.MESSAGE_INDEX);const t=this.#O.length,s=16*e.records.length;this.#O.uint64(0n).uint16(e.channelId).uint32(s);for(const n of e.records)this.#O.uint64(n[0]).uint64(n[1]);!0===this.options?.padRecords&&this.#O.uint8(1).uint8(255).uint8(255);const i=this.#O.length;return this.#O.seek(t).uint64(BigInt(i-t-8)).seek(i),BigInt(i-t+1)}writeMetadata(e){this.#O.uint8(r.pz.METADATA);const t=this.#O.length;this.#O.uint64(0n).string(e.name).tupleArray(e=>this.#O.string(e),e=>this.#O.string(e),e.metadata),!0===this.options?.padRecords&&this.#O.uint8(1).uint8(255).uint8(255);const s=this.#O.length;return this.#O.seek(t).uint64(BigInt(s-t-8)).seek(s),BigInt(s-t+1)}writeMetadataIndex(e){this.#O.uint8(r.pz.METADATA_INDEX);const t=this.#O.length;this.#O.uint64(0n).uint64(e.offset).uint64(e.length).string(e.name),!0===this.options?.padRecords&&this.#O.uint8(1).uint8(255).uint8(255);const s=this.#O.length;return this.#O.seek(t).uint64(BigInt(s-t-8)).seek(s),BigInt(s-t+1)}writeSummaryOffset(e){this.#O.uint8(r.pz.SUMMARY_OFFSET);const t=this.#O.length;this.#O.uint64(0n).uint8(e.groupOpcode).uint64(e.groupStart).uint64(e.groupLength),!0===this.options?.padRecords&&this.#O.uint8(1).uint8(255).uint8(255);const s=this.#O.length;return this.#O.seek(t).uint64(BigInt(s-t-8)).seek(s),BigInt(s-t+1)}writeStatistics(e){this.#O.uint8(r.pz.STATISTICS);const t=this.#O.length;this.#O.uint64(0n).uint64(e.messageCount).uint16(e.schemaCount).uint32(e.channelCount).uint32(e.attachmentCount).uint32(e.metadataCount).uint32(e.chunkCount).uint64(e.messageStartTime).uint64(e.messageEndTime).tupleArray(e=>this.#O.uint16(e),e=>this.#O.uint64(e),e.channelMessageCounts),!0===this.options?.padRecords&&this.#O.uint8(1).uint8(255).uint8(255);const s=this.#O.length;return this.#O.seek(t).uint64(BigInt(s-t-8)).seek(s),BigInt(s-t+1)}writeDataEnd(e){return this.#O.uint8(r.pz.DATA_END).uint64(4n).uint32(e.dataSectionCrc),4n}}},6721(e,t,s){"use strict";s(6796),s(4951),s(8094),s(1952)},4593(e,t,s){"use strict";s.d(t,{z:()=>c});var i=s(6796),n=s(7419),r=s(8446),a=s(9552),o=s(8094),d=s(3091);class c{#D=0;#j=1;#N;#u=new a.w;#R=new Map;#W=new Map;#L=new Set;#z=new Set;#F;#_;#$;#U;#V;#H;#P;#q=!1;#X;#K;#Y;constructor(e){const{writable:t,useStatistics:s=!0,useSummaryOffsets:i=!0,useChunks:r=!0,repeatSchemas:a=!0,repeatChannels:o=!0,useAttachmentIndex:d=!0,useMetadataIndex:c=!0,useMessageIndex:h=!0,useChunkIndex:u=!0,startChannelId:f=0,chunkSize:l=1048576,compressChunk:m}=e;this.#N=t,this.#V=i,s&&(this.statistics={messageCount:0n,schemaCount:0,channelCount:0,attachmentCount:0,metadataCount:0,chunkCount:0,messageStartTime:0n,messageEndTime:0n,channelMessageCounts:new Map}),r&&(this.#F=new n.v({useMessageIndex:h})),this.#H=a,this.#P=o,d&&(this.#K=[]),c&&(this.#Y=[]),u&&(this.#X=[]),this.#D=f,this.#$=l,this.#_=m}static async InitializeForAppending(e,t){const{readOptions:s,...n}=t,a=await r.k.Initialize({readable:e,readOptions:s});await e.seek(a.dataEndOffset),await e.truncate();const o=new c({...n,writable:e});o.#q=!0,o.#U=null!=a.dataSectionCrc?(0,i.kh)(a.dataSectionCrc):void 0,o.#X=[...a.chunkIndexes],o.#K=[...a.attachmentIndexes],o.#Y=[...a.metadataIndexes],o.statistics&&(a.statistics?o.statistics=a.statistics:o.statistics=void 0),o.#R=new Map(a.schemasById),o.#L=new Set(a.schemasById.keys());for(const i of a.schemasById.values())o.#j=Math.max(o.#j,i.id+1);o.#W=new Map(a.channelsById),o.#z=new Set(a.channelsById.keys());for(const i of a.channelsById.values())o.#D=Math.max(o.#D,i.id+1);return o}async start(e={profile:"",library:d.k}){if(this.#q)throw new Error("Cannot call start() when writer is in append mode");this.#U=(0,i.oU)(),this.#u.writeMagic(),this.#u.writeHeader(e),this.#U=(0,i.B_)(this.#U,this.#u.buffer),await this.#N.write(this.#u.buffer),this.#u.reset()}async end(){await this.#G(),null!=this.#U&&(this.#U=(0,i.B_)(this.#U,this.#u.buffer)),await this.#N.write(this.#u.buffer),this.#u.reset(),this.#u.writeDataEnd({dataSectionCrc:null==this.#U?0:(0,i.kh)(this.#U)}),await this.#N.write(this.#u.buffer),this.#u.reset();const e=[],t=this.#N.position();let s=(0,i.oU)();if(this.#H){const t=this.#N.position();let s=0n;for(const e of this.#R.values())s+=this.#u.writeSchema(e);e.push({groupOpcode:o.pz.SCHEMA,groupStart:t,groupLength:s})}if(this.#P){s=(0,i.B_)(s,this.#u.buffer),await this.#N.write(this.#u.buffer),this.#u.reset();const t=this.#N.position();let n=0n;for(const e of this.#W.values())n+=this.#u.writeChannel(e);e.push({groupOpcode:o.pz.CHANNEL,groupStart:t,groupLength:n})}if(this.statistics){s=(0,i.B_)(s,this.#u.buffer),await this.#N.write(this.#u.buffer),this.#u.reset();const t=this.#N.position(),n=this.#u.writeStatistics(this.statistics);e.push({groupOpcode:o.pz.STATISTICS,groupStart:t,groupLength:n})}if(s=(0,i.B_)(s,this.#u.buffer),await this.#N.write(this.#u.buffer),this.#u.reset(),this.#Y){s=(0,i.B_)(s,this.#u.buffer),await this.#N.write(this.#u.buffer),this.#u.reset();const t=this.#N.position();let n=0n;for(const e of this.#Y)n+=this.#u.writeMetadataIndex(e);e.push({groupOpcode:o.pz.METADATA_INDEX,groupStart:t,groupLength:n})}if(this.#K){s=(0,i.B_)(s,this.#u.buffer),await this.#N.write(this.#u.buffer),this.#u.reset();const t=this.#N.position();let n=0n;for(const e of this.#K)n+=this.#u.writeAttachmentIndex(e);e.push({groupOpcode:o.pz.ATTACHMENT_INDEX,groupStart:t,groupLength:n})}if(this.#X){s=(0,i.B_)(s,this.#u.buffer),await this.#N.write(this.#u.buffer),this.#u.reset();const t=this.#N.position();let n=0n;for(const e of this.#X)n+=this.#u.writeChunkIndex(e);e.push({groupOpcode:o.pz.CHUNK_INDEX,groupStart:t,groupLength:n})}s=(0,i.B_)(s,this.#u.buffer),await this.#N.write(this.#u.buffer),this.#u.reset();const n=this.#N.position(),r=n-t;if(this.#V)for(const i of e)0n!==i.groupLength&&this.#u.writeSummaryOffset(i);s=(0,i.B_)(s,this.#u.buffer);const a={summaryStart:0n===r?0n:t,summaryOffsetStart:this.#V?n:0n,summaryCrc:0},d=new DataView(new ArrayBuffer(25));d.setUint8(0,o.pz.FOOTER),d.setBigUint64(1,20n,!0),d.setBigUint64(9,a.summaryStart,!0),d.setBigUint64(17,a.summaryOffsetStart,!0),s=(0,i.B_)(s,d),a.summaryCrc=(0,i.kh)(s),this.#u.writeFooter(a),this.#u.writeMagic(),await this.#N.write(this.#u.buffer),this.#u.reset()}async registerSchema(e){const t=this.#j++;return this.#R.set(t,{...e,id:t}),this.statistics&&++this.statistics.schemaCount,t}async registerChannel(e){const t=this.#D++;return this.#W.set(t,{...e,id:t}),this.statistics&&++this.statistics.channelCount,t}async addMessage(e){if(this.statistics&&(0n===this.statistics.messageCount?(this.statistics.messageStartTime=e.logTime,this.statistics.messageEndTime=e.logTime):(e.logTime<this.statistics.messageStartTime&&(this.statistics.messageStartTime=e.logTime),e.logTime>this.statistics.messageEndTime&&(this.statistics.messageEndTime=e.logTime)),this.statistics.channelMessageCounts.set(e.channelId,(this.statistics.channelMessageCounts.get(e.channelId)??0n)+1n),++this.statistics.messageCount),!this.#z.has(e.channelId)){const t=this.#W.get(e.channelId);if(!t)throw new Error(`McapWriter#addMessage failed: missing channel for id ${e.channelId}`);if(0!==t.schemaId&&!this.#L.has(t.schemaId)){const e=this.#R.get(t.schemaId);if(!e)throw new Error(`McapWriter#addMessage failed: missing schema for id ${t.schemaId}`);this.#F?this.#F.addSchema(e):this.#u.writeSchema(e),this.#L.add(t.schemaId)}this.#F?this.#F.addChannel(t):this.#u.writeChannel(t),this.#z.add(e.channelId)}this.#F?this.#F.addMessage(e):this.#u.writeMessage(e),this.#F&&this.#F.byteLength>this.#$&&await this.#G()}async addAttachment(e){const t=this.#u.writeAttachment(e);
1if(this.statistics&&++this.statistics.attachmentCount,this.#K){const s=this.#N.position();this.#K.push({logTime:e.logTime,createTime:e.createTime,name:e.name,mediaType:e.mediaType,offset:s,dataSize:BigInt(e.data.byteLength),length:t})}null!=this.#U&&(this.#U=(0,i.B_)(this.#U,this.#u.buffer)),await this.#N.write(this.#u.buffer),this.#u.reset()}async addMetadata(e){const t=this.#u.writeMetadata(e);if(this.statistics&&++this.statistics.metadataCount,this.#Y){const s=this.#N.position();this.#Y.push({name:e.name,offset:s,length:t})}null!=this.#U&&(this.#U=(0,i.B_)(this.#U,this.#u.buffer)),await this.#N.write(this.#u.buffer),this.#u.reset()}async#G(){if(!this.#F||0===this.#F.numMessages)return;this.statistics&&++this.statistics.chunkCount;const e=this.#F.buffer,t=BigInt(e.length),s=(0,i.QR)(e);let n="",r=e;this.#_&&({compression:n,compressedData:r}=this.#_(e));const a={messageStartTime:this.#F.messageStartTime,messageEndTime:this.#F.messageEndTime,uncompressedSize:t,uncompressedCrc:s,compression:n,records:r},o=this.#N.position(),d=this.#u.writeChunk(a),c=this.#X?new Map:void 0;null!=this.#U&&(this.#U=(0,i.B_)(this.#U,this.#u.buffer)),await this.#N.write(this.#u.buffer),this.#u.reset();const h=this.#N.position();let u=0n;for(const i of this.#F.indices)c?.set(i.channelId,h+u),u+=this.#u.writeMessageIndex(i);this.#X&&this.#X.push({messageStartTime:a.messageStartTime,messageEndTime:a.messageEndTime,chunkStartOffset:o,chunkLength:d,messageIndexOffsets:c,messageIndexLength:u,compression:a.compression,compressedSize:BigInt(a.records.byteLength),uncompressedSize:a.uncompressedSize}),this.#F.reset(),null!=this.#U&&(this.#U=(0,i.B_)(this.#U,this.#u.buffer)),await this.#N.write(this.#u.buffer),this.#u.reset()}}},8094(e,t,s){"use strict";s.d(t,{pz:()=>n});const i=Object.freeze([137,77,67,65,80,48,13,10]);let n=function(e){return e[e.MIN=1]="MIN",e[e.HEADER=1]="HEADER",e[e.FOOTER=2]="FOOTER",e[e.SCHEMA=3]="SCHEMA",e[e.CHANNEL=4]="CHANNEL",e[e.MESSAGE=5]="MESSAGE",e[e.CHUNK=6]="CHUNK",e[e.MESSAGE_INDEX=7]="MESSAGE_INDEX",e[e.CHUNK_INDEX=8]="CHUNK_INDEX",e[e.ATTACHMENT=9]="ATTACHMENT",e[e.ATTACHMENT_INDEX=10]="ATTACHMENT_INDEX",e[e.STATISTICS=11]="STATISTICS",e[e.METADATA=12]="METADATA",e[e.METADATA_INDEX=13]="METADATA_INDEX",e[e.SUMMARY_OFFSET=14]="SUMMARY_OFFSET",e[e.DATA_END=15]="DATA_END",e[e.MAX=15]="MAX",e}({});s.d(t,["ue",0,i])},5255(e,t,s){"use strict";const i="function"==typeof DataView.prototype.getBigUint64?DataView.prototype.getBigUint64:function(e,t){const s=!0===t?this.getUint32(e,t):this.getUint32(e+4,t),i=!0===t?this.getUint32(e+4,t):this.getUint32(e,t);return BigInt(i)<<32n|BigInt(s)};s.d(t,["b",0,i])},5258(e,t,s){"use strict";s(8094)},4355(e,t,s){"use strict";s.d(t,{zc:()=>i.z});s(8446),s(6721),s(4951);var i=s(4593);s(9552),s(7419),s(8094),s(5258),s(1952)},1952(e,t,s){"use strict";s.d(t,{H:()=>a,Z:()=>r});var i=s(6796),n=s(8094);function r(e){if(e.bytesRemaining()<n.ue.length)return;const t=e.u8ArrayBorrow(n.ue.length);if(!n.ue.every((e,s)=>e===t[s]))throw new Error(`Expected MCAP magic '${n.ue.map(e=>e.toString(16).padStart(2,"0")).join(" ")}', found '${Array.from(t,(e,s)=>t[s].toString(16).padStart(2,"0")).join(" ")}'`);return{specVersion:"0"}}function a(e,t=!1){if(e.bytesRemaining()<9)return;const s=e.offset,r=e.uint8(),a=e.uint64();if(a>Number.MAX_SAFE_INTEGER)throw new Error(`Record content length ${a} is too large`);const o=Number(a);if(e.bytesRemaining()<o)return void(e.offset=s);let d;switch(r){case n.pz.HEADER:d=function(e,t){const s=e.offset,i=e.string(),n=e.string();return e.offset=s+t,{type:"Header",profile:i,library:n}}(e,o);break;case n.pz.FOOTER:d=function(e,t){const s=e.offset,i=e.uint64(),n=e.uint64(),r=e.uint32();return e.offset=s+t,{type:"Footer",summaryStart:i,summaryOffsetStart:n,summaryCrc:r}}(e,o);break;case n.pz.SCHEMA:d=function(e,t){const s=e.offset,i=e.uint16(),n=e.string(),r=e.string(),a=e.uint32(),o=e.offset;if(t-(o-s)<a)throw new Error(`Schema data length ${a} exceeds bounds of record`);const d=e.u8ArrayCopy(a);return e.offset=s+t,{type:"Schema",id:i,encoding:r,name:n,data:d}}(e,o);break;case n.pz.CHANNEL:d=function(e,t){const s=e.offset,i=e.uint16(),n=e.uint16(),r=e.string(),a=e.string(),o=e.map(e=>e.string(),e=>e.string());return e.offset=s+t,{type:"Channel",id:i,schemaId:n,topic:r,messageEncoding:a,metadata:o}}(e,o);break;case n.pz.MESSAGE:d=function(e,t){const s=22;if(t<s)throw new Error(`Message record length ${t} is less than ${s} bytes`);const i=e.uint16(),n=e.uint32(),r=e.uint64(),a=e.uint64(),o=e.u8ArrayCopy(t-s);return{type:"Message",channelId:i,sequence:n,logTime:r,publishTime:a,data:o}}(e,o);break;case n.pz.CHUNK:d=function(e,t){const s=e.offset,i=e.uint64(),n=e.uint64(),r=e.uint64(),a=e.uint32(),o=e.string(),d=Number(e.uint64()),c=e.offset,h=c-s;if(d+h>t)throw new Error("Chunk records length exceeds remaining record size");const u=e.u8ArrayCopy(d);return e.offset=s+t,{type:"Chunk",messageStartTime:i,messageEndTime:n,compression:o,uncompressedSize:r,uncompressedCrc:a,records:u}}(e,o);break;case n.pz.MESSAGE_INDEX:d=function(e,t){const s=e.offset,i=e.uint16(),n=e.keyValuePairs(e=>e.uint64(),e=>e.uint64());return e.offset=s+t,{type:"MessageIndex",channelId:i,records:n}}(e,o);break;case n.pz.CHUNK_INDEX:d=function(e,t){const s=e.offset,i=e.uint64(),n=e.uint64(),r=e.uint64(),a=e.uint64(),o=e.map(e=>e.uint16(),e=>e.uint64()),d=e.uint64(),c=e.string(),h=e.uint64(),u=e.uint64();return e.offset=s+t,{type:"ChunkIndex",messageStartTime:i,messageEndTime:n,chunkStartOffset:r,chunkLength:a,messageIndexOffsets:o,messageIndexLength:d,compression:c,
1compressedSize:h,uncompressedSize:u}}(e,o);break;case n.pz.ATTACHMENT:d=function(e,t,s){const n=e.offset,r=e.uint64(),a=e.uint64(),o=e.string(),d=e.string(),c=e.uint64();if(BigInt(e.offset)+c>Number.MAX_SAFE_INTEGER)throw new Error(`Attachment too large: ${c}`);if(e.offset+Number(c)+4>n+t)throw new Error(`Attachment data length ${c} exceeds bounds of record`);const h=e.u8ArrayCopy(Number(c)),u=e.offset-n,f=e.uint32();if(s&&0!==f){e.offset=n;const t=e.u8ArrayBorrow(u),s=(0,i.QR)(t);if(e.offset=n+u+4,s!==f)throw new Error(`Attachment CRC32 mismatch: expected ${f}, actual ${s}`)}return e.offset=n+t,{type:"Attachment",logTime:r,createTime:a,name:o,mediaType:d,data:h}}(e,o,t);break;case n.pz.ATTACHMENT_INDEX:d=function(e,t){const s=e.offset,i=e.uint64(),n=e.uint64(),r=e.uint64(),a=e.uint64(),o=e.uint64(),d=e.string(),c=e.string();return e.offset=s+t,{type:"AttachmentIndex",offset:i,length:n,logTime:r,createTime:a,dataSize:o,name:d,mediaType:c}}(e,o);break;case n.pz.STATISTICS:d=function(e,t){const s=e.offset,i=e.uint64(),n=e.uint16(),r=e.uint32(),a=e.uint32(),o=e.uint32(),d=e.uint32(),c=e.uint64(),h=e.uint64(),u=e.map(e=>e.uint16(),e=>e.uint64());return e.offset=s+t,{type:"Statistics",messageCount:i,schemaCount:n,channelCount:r,attachmentCount:a,metadataCount:o,chunkCount:d,messageStartTime:c,messageEndTime:h,channelMessageCounts:u}}(e,o);break;case n.pz.METADATA:d=function(e,t){const s=e.offset,i=e.string(),n=e.map(e=>e.string(),e=>e.string());return e.offset=s+t,{type:"Metadata",metadata:n,name:i}}(e,o);break;case n.pz.METADATA_INDEX:d=function(e,t){const s=e.offset,i=e.uint64(),n=e.uint64(),r=e.string();return e.offset=s+t,{type:"MetadataIndex",offset:i,length:n,name:r}}(e,o);break;case n.pz.SUMMARY_OFFSET:d=function(e,t){const s=e.offset,i=e.uint8(),n=e.uint64(),r=e.uint64();return e.offset=s+t,{type:"SummaryOffset",groupOpcode:i,groupStart:n,groupLength:r}}(e,o);break;case n.pz.DATA_END:d=function(e,t){const s=e.offset,i=e.uint32();return e.offset=s+t,{type:"DataEnd",dataSectionCrc:i}}(e,o);break;default:d=function(e,t,s){const i=e.u8ArrayBorrow(t);return{type:"Unknown",opcode:s,data:i}}(e,o,r)}return e.offset=s+9+o,d}},3389(e,t,s){"use strict";function i(e,t,s){let i=0,n=e.length;if(0===n)return 0;const r=s(t);for(;i<n;){const t=i+n>>>1;s(e[t][0])<r?i=t+1:n=t}return n}s.d(t,{n:()=>i})},4356(e,t,s){"use strict";function i(e,t,s){let i=0,n=e.length;if(0===n)return 0;const r=s(t);for(;i<n;){const t=i+n>>>1;s(e[t][0])<=r?i=t+1:n=t}return n}s.d(t,{p:()=>i})},3091(e,t,s){"use strict";s.d(t,["k",0,"mcap-typescript/2.3.0"])},7578(e,t,s){"use strict";s.r(t),s.d(t,{McapRecordingDemo:()=>ke});var i=s(3587),n=s(4452),r=s.n(n),a=s(3696);const o="container_vkss",d="column_JsKD",c="subhead_wuZj",h="sensors_P1RV",u="sensorsGrid_uQrl",f="sensorCategory_dXCd",l="recordingControls_SF0O",m="recordingDot_YQcP",g="recordingDotActive_WTOj",p="recordingControlsColumn_JxEU",b="downloadButton_W8ox",w="recordingStatsSection_vndR",y="statsCounters_nXOW",C="statCounter_APVx",v="mediaRow_Gv8q",S="mediaContainer_JYty",I="audioWaveform_CDKo",x="mediaErrorContainer_vudR",E="mediaPlaceholderText_Ogts",k="mediaLoadingIndicator_kZlo",T="error_wAS5",M="downloadInfo_h8Zf",A="h264Warning_GAAF",B="downloadInfoCloseButton_v6le",O="videoFormatGroup_aJv5",D="deviceSelector_wVUl",j="deviceLabel_HG6W",N="deviceSelect_KmvH";var R=s(5828),W=s(9915),L=s(113),z=s(3739),F=s.n(z),_=s(4355),$=s(3868),U=s(3628),V=s.n(U),H=s(2457),P=s.n(H),q=s(4827),X=s.n(q);async function K(e,t,s){const i=`foxglove.${s.name}`,n=new(P().Root);n.addJSON(P().common.get("google/protobuf/timestamp.proto").nested),n.addJSON(P().common.get("google/protobuf/duration.proto").nested),function e(t){const s=Object.values(L.foxgloveEnumSchemas).filter(e=>e.parentSchemaName===t.name),i=(0,L.generateProto)(t,s),r=P().parse(i,{keepCase:!0}),a=`foxglove/${t.name}.proto`;r.root.nestedArray[0].filename=a,n.add(r.root.nestedArray[0]);for(const n of t.fields)"nested"===n.type.type&&e(n.type.schema)}(s);const r=n.lookupType(i),a=n.toDescriptor("proto3");for(const d of a.file){if(null==d.name||0===d.name.length)throw new Error(`Missing filename for ${d.package??"(unknown package)"}`);"google_protobuf.proto"!==d.name&&(d.dependency=["google_protobuf.proto"])}const o=await e.registerSchema({name:i,encoding:"protobuf",data:X().FileDescriptorSet.encode(a).finish()});return{rootType:r,id:await e.registerChannel({topic:t,messageEncoding:"protobuf",schemaId:o,metadata:new Map})}}function Y({sec:e,nsec:t}){return{seconds:e,nanos:t}}const G={type:"object",properties:{clientX:{type:"number"},clientY:{type:"number"}}};class J extends $.b{#s=new TextEncoder;#J;#Q=new(V())(1);#Z;#ee=0;#te;#se=0;#ie;#ne=0;#re;#ae=0;#oe;#de=0;#ce;#he=0;#ue;#fe=0;#le;#me=0;#ge=[];bytesWritten=0n;messageCount=0n;chunkCount=0;constructor(){super(),this.#pe()}#pe(){this.#Q.add(async()=>{await F().isLoaded,this.#ge=[],this.bytesWritten=0n,this.messageCount=0n,this.chunkCount=0,this.#J=new _.zc({chunkSize:5120,compressChunk:e=>({compression:"zstd",compressedData:new Uint8Array(F().compress(e))}),writable:{position:()=>this.bytesWritten,write:async e=>{this.#ge.push(new Uint8Array(e)),this.bytesWritten+=BigInt(e.byteLength),this.#be()}}}),await this.#J.start({library:"MCAP web demo",profile:""}),this.#be()}),this.#Z=void 0,this.#ee=0,this.#te=void 0,this.#se=0,this.#ie=void 0,this.#ne=0,this.#re=void 0,this.#ae=0,this.#oe=void 0,this.#de=0,this.#ce=void 0,this.#he=0,this.#ue=void 0,this.#fe=0}#we(){const e=+new Date;return 1000000n*BigInt(e)}#be(){this.chunkCount=this.#J?.statistics?.chunkCount??0,this.messageCount=this.#J?.statistics?.messageCount??0n,this.emit
1("update")}async addMouseEvent(e){this.#Q.add(async()=>{if(!this.#J)return;if(null==this.#ce){const e=await this.#J.registerSchema({name:"MouseEvent",encoding:"jsonschema",data:this.#s.encode(JSON.stringify(G))});this.#ce=await this.#J.registerChannel({topic:"mouse",messageEncoding:"json",schemaId:e,metadata:new Map})}const t=this.#we();await this.#J.addMessage({sequence:this.#he++,channelId:this.#ce,logTime:t,publishTime:t,data:this.#s.encode(JSON.stringify(e))}),this.messageCount++,this.#be()})}async addPose(e){this.#Q.add(async()=>{if(!this.#J)return;this.#ue||(this.#ue=await K(this.#J,"pose",L.foxgloveMessageSchemas.PoseInFrame));const t=this.#we(),{id:s,rootType:i}=this.#ue;await this.#J.addMessage({sequence:this.#fe++,channelId:s,logTime:t,publishTime:t,data:i.encode(e).finish()}),this.messageCount++,this.#be()})}async addJpegFrame(e){this.#Q.add(async()=>{if(!this.#J)return;this.#oe||(this.#oe=await K(this.#J,"camera_jpeg",L.foxgloveMessageSchemas.CompressedImage));const{id:t,rootType:s}=this.#oe,i=this.#we(),n={timestamp:Y((0,R.fromNanoSec)(i)),frame_id:"camera",data:new Uint8Array(await e.arrayBuffer()),format:"jpeg"};await this.#J.addMessage({sequence:this.#de++,channelId:t,logTime:i,publishTime:i,data:s.encode(n).finish()}),this.messageCount++,this.#be()})}async addVideoFrame(e){this.#Q.add(async()=>{if(!this.#J)return;let t,s;switch(e.format){case"h264":t=this.#ie??=await K(this.#J,"camera_h264",L.foxgloveMessageSchemas.CompressedVideo),s=this.#ne++;break;case"h265":t=this.#re??=await K(this.#J,"camera_h265",L.foxgloveMessageSchemas.CompressedVideo),s=this.#ae++;break;case"vp9":t=this.#le??=await K(this.#J,"camera_vp9",L.foxgloveMessageSchemas.CompressedVideo),s=this.#me++;break;case"av1":t=this.#te??=await K(this.#J,"camera_av1",L.foxgloveMessageSchemas.CompressedVideo),s=this.#se++}const{id:i,rootType:n}=t,r=this.#we(),a={timestamp:Y((0,R.fromNanoSec)(r)),frame_id:"camera",data:e.data,format:e.format},o=n.encode(a).finish();e.release(),await this.#J.addMessage({sequence:s,channelId:i,logTime:r,publishTime:r,data:o}),this.messageCount++,this.#be()})}async addAudioData(e){this.#Q.add(async()=>{if(!this.#J)return;const t=this.#Z??=await K(this.#J,"microphone",L.foxgloveMessageSchemas.RawAudio),s=this.#ee++,{id:i,rootType:n}=t,r={timestamp:Y(e.timestamp),data:e.data,format:e.format,sample_rate:e.sample_rate,number_of_channels:e.number_of_channels},a=n.encode(r).finish(),o=this.#we();await this.#J.addMessage({sequence:s,channelId:i,logTime:o,publishTime:o,data:a}),this.messageCount++,this.#be()})}async closeAndRestart(){return await this.#Q.add(async()=>{await(this.#J?.end());const e=new Blob(this.#ge);return this.#pe(),e})}}const Q=Math.PI/180;function Z(e){const t=["B","kiB","MiB","GiB","TiB"];let s=e,i=0;for(;i+1<t.length&&s>=1024;)s/=1024,i++;return`${s.toFixed(0===i?0:1)} ${t[i]}`}const ee=(0,W.vt)(e=>{const t=new J;return t.addListener("update",()=>{e({bytesWritten:t.bytesWritten,messageCount:t.messageCount,chunkCount:t.chunkCount})}),{bytesWritten:t.bytesWritten,messageCount:t.messageCount,chunkCount:t.chunkCount,latestMouse:void 0,latestOrientation:void 0,recording:!1,orientationPermissionError:!1,showDownloadInfo:!1,enabledVideoFormats:new Set,recordAudio:!1,recordMouse:!0,recordOrientation:!0,selectedCameraDeviceId:"",selectedAudioDeviceId:"",videoStarted:!1,videoError:void 0,audioError:void 0,audioStream:void 0,actions:{addMouseEventMessage(s){t.addMouseEvent(s),e({latestMouse:s})},addPoseMessage(s){t.addPose(function(e){const t=(e.alpha??0)*Q,s=(e.beta??0)*Q,i=(e.gamma??0)*Q,n=Math.cos(s/2),r=Math.cos(i/2),a=Math.cos(t/2),o=Math.sin(s/2),d=Math.sin(i/2),c=Math.sin(t/2),h=o*r*a-n*d*c,u=n*d*a+o*r*c,f=n*r*c+o*d*a,l=n*r*a-o*d*c;return{timestamp:Y((0,R.fromMillis)(e.timeStamp)),frame_id:"device",pose:{position:{x:0,y:0,z:0},orientation:{x:h,y:u,z:f,w:l}}}}(s)),e({latestOrientation:s})},addJpegFrame(e){t.addJpegFrame(e)},addVideoFrame(e){t.addVideoFrame(e)},addAudioData(e){t.addAudioData(e)},closeAndRestart:async()=>await t.closeAndRestart(),setRecording:({isRecording:t})=>{e({recording:t})},setOrientationPermissionError:({hasError:t})=>{e({orientationPermissionError:t})},setShowDownloadInfo:({shouldShow:t})=>{e({showDownloadInfo:t})},setVideoFormat:({format:t,enabled:s})=>{e(e=>{const i=new Set(e.enabledVideoFormats);return s?i.add(t):i.delete(t),{enabledVideoFormats:i}})},setRecordAudio:({shouldRecord:t})=>{e({recordAudio:t})},setRecordMouse:({shouldRecord:t})=>{e({recordMouse:t})},setRecordOrientation:({shouldRecord:t})=>{e({recordOrientation:t})},setSelectedCameraDeviceId:t=>{e({selectedCameraDeviceId:t})},setSelectedAudioDeviceId:t=>{e({selectedAudioDeviceId:t})},setVideoStarted:({isStarted:t})=>{e({videoStarted:t})},setVideoError:t=>{e({videoError:t})},setAudioError:t=>{e({audioError:t})},setAudioStream:t=>{e({audioStream:t})}}}});var te=s(2540);function se({audioWaveformRef:e}){const t=ee(),{audioError:s,recordAudio:i,actions:n}=t,a=i,o=()=>{a||n.setRecordAudio({shouldRecord:!0})};return s?(0,te.jsx)("div",{className:r()(T,x),children:s.toString()}):a?(0,te.jsx)("canvas",{ref:e,className:I}):(0,te.jsx)("span",{className:E,onClick:o,role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||o()},children:"Enable \u201cMicrophone\u201d to record audio"})}function ie(){const e=ee(),{actions:t,recordAudio:s,enabledVideoFormats:i,selectedCameraDeviceId:n,selectedAudioDeviceId:r,videoStarted:o,audioStream:d}=e,[c,h]=(0,a.useState)([]),u=i.size>0,f=s;(0,a.useEffect)(()=>{const e=async()=>{try{const e=await navigator.mediaDevices.enumerateDevices();h(e);const t=ee.getState(),s=n,i=t.selectedAudioDeviceId,r=t.actions,a=e.filter(e=>"videoinput"===e.kind),o=e.filter(e=>"audioinput"===e.kind);if(a.length>0){const e=a.some(e=>e.deviceId===s);s&&e||r.setSelectedCameraDeviceId(a[0].deviceId)}else s&&r.setSelectedCameraDeviceId("");if(o.length>0){const e=o.some(e=>e.deviceId===i);i&&e||r.setSelectedAudioDeviceId(o[0].deviceId)}else i&&r.setSelectedAudioDeviceId("")}catch(e){console.error("Error getting devices:",e)}};e();const t=()=>{e()};return navigator.mediaDevices.addEventListener("devicechange",t),()=>{navigator.mediaDevices.removeEventListener("devicechange",t)}},[o,d,n]);const l=c.filter(e=>"videoinput"===e.kind),m=c.filter(e=>"audioinput"===e.kind);return u||f?(0,te.jsxs)("div",{className:D,children:[u&&l.length>0&&(0,te.jsxs)(te.Fragment,{children:[(0,te.jsx)("label",{className:j,children:"Camera"}),(0,te.jsx)("select",{className:N,value:n,onChange:e=>{var s;s=e.target.value,t.setSelectedCameraDeviceId(s),u&&t.setVideoError(void 0)},children:l.map(e=>(0,te.jsx)("option",{value:e.deviceId,children:e.label||`Camera ${e.deviceId.slice(0,8)}...`},e.deviceId))})]}),f&&m.length>0&&(0,te.jsxs)(te.Fragment,{children:[(0,te.jsx)("label",{className:j,children:"Microphone"}),(0,te.jsx)("select",{className:N,value:r,onChange:e=>{var s;s=e.target.value,t.setSelectedAudioDeviceId(s),f&&t.setAudioError(void 0)},children:m.map(e=>(0,te.jsx)("option",{value:e.deviceId,children:e.label||`Microphone ${e.deviceId.slice(0,8)}...`},e.deviceId))})]})]}):(0,te.jsx)(te.Fragment,{})}var ne=s(7989);const re=()=>"AudioContext"in window||"webkitAudioContext"in window,ae=async()=>!!re();function oe(e){const t=new AbortController;return async function(e,t){const{video:s,enableH264:i,enableH265:n,enableVP9:r,enableAV1:a,enableJpeg:o,onJpegFrame:d,onVideoFrame:c,onError:h,frameDurationSec:u}=e;if(!(a||r||n||i||o))throw new Error("At least one of AV1, VP9, H.265, H.264, or JPEG encoding must be enabled");const f=document.createElement("canvas");f.width=s.videoWidth,f.height=s.videoHeight;const l=f.getContext("2d"),m=[],g=[];if(i){const e=await we({outputFormat:"h264",baseConfig:de,frameDurationSec:u,framePool:g,onError:h,onVideoFrame:c,signal:t,video:s});e&&m.push(e)}if(n){const e=await we({outputFormat:"h265",baseConfig:ce,frameDurationSec:u,framePool:g,onError:h,onVideoFrame:c,signal:t,video:s});e&&m.push(e)}if(r){const e=await we({outputFormat:"vp9",baseConfig:he,frameDurationSec:u,framePool:g,onError:h,onVideoFrame:c,signal:t,video:s});e&&m.push(e)}if(a){const e=await we({outputFormat:"av1",baseConfig:ue,frameDurationSec:u,framePool:g,onError:h,onVideoFrame:c,signal:t,video:s});e&&m.push(e)}const p=2e3;let b,w=0;const y=performance.now(),C=setInterval(()=>{if(!(w>0)){if(m.length>0){const e=performance.now(),t=new VideoFrame(s,{timestamp:1e3*(e-y),duration:1e6*u}),i={keyFrame:!1};(null==b||e-b>=p)&&(i.keyFrame=!0,b=e);for(const s of m)++w,s.addEventListener("dequeue",()=>{--w},{once:!0}),s.encode(t,i);t.close()}o&&(++w,l?.drawImage(s,0,0),f.toBlob(e=>{--w,e&&d(e)},"image/jpeg",.8))}},1e3*u),v=()=>{clearInterval(C);for(const e of m)e.close()};t.aborted?v():t.addEventListener("abort",v)}(e,t.signal),()=>{t.abort()}}const de={codec:"avc1.42001f",avc:{format:"annexb"}},ce={codec:"hvc1.1.6.L93.B0",avc:{format:"annexb"},hevc:{format:"annexb"}},he={codec:"vp09.00.31.08"},ue={codec:"av01.0.05M.08"};async function fe(){const e=await pe({baseConfig:{...de,width:640,height:480},frameDurationSec:1/30});return{supported:null!=e,mayUseLotsOfKeyframes:e?.mayUseLotsOfKeyframes??!1}}async function le(){const e=await pe({baseConfig:{...ce,width:640,height:480},frameDurationSec:1/30});return{supported:null!=e,mayUseLotsOfKeyframes:e?.mayUseLotsOfKeyframes??!1}}async function me(){const e=await pe({baseConfig:{...he,width:640,height:480},frameDurationSec:1/30});return{supported:null!=e,mayUseLotsOfKeyframes:e?.mayUseLotsOfKeyframes??!1}}async function ge(){const e=await pe({baseConfig:{...ue,width:640,height:480},frameDurationSec:1/30});return{supported:null!=e,mayUseLotsOfKeyframes:e?.mayUseLotsOfKeyframes??!1}}async function pe({baseConfig:e,frameDurationSec:t}){const s={...e,latencyMode:"realtime",framerate:1/t,bitrate:1e6};try{if("function"!=typeof VideoEncoder)return void console.error("VideoEncoder is not supported, falling back to JPEG encoding");let t=await be(s);
1if(t.supported)return{config:s,mayUseLotsOfKeyframes:t.mayUseLotsOfKeyframes};if(console.warn(`latencyMode realtime encoding not supported for ${e.codec}, attempting fallback to quality`),s.latencyMode="quality",t=await be(s),t.supported)return{config:s,mayUseLotsOfKeyframes:t.mayUseLotsOfKeyframes}}catch(i){console.warn("VideoEncoder error during compatibility detection:",s,i)}console.warn(`No supported config found for ${e.codec}`)}async function be(e){try{const t=await VideoEncoder.isConfigSupported(e);if(!0!==t.supported)return{supported:!1};console.info(`Found supported config for ${e.codec}:`,t.config);let s=0,i=0,n=!1,r=!0;const a=new VideoEncoder({output(t){"key"===t.type&&s++,i++;const n=new Uint8Array(t.byteLength);if(t.copyTo(n),"annexb"===e.avc?.format||"annexb"===e.hevc?.format){0===n[0]&&0===n[1]&&(1===n[2]||0===n[2]&&1===n[3])||(r=!1)}},error(t){n=!0,console.error("VideoEncoder error during compatibility detection:",e,t)}});a.configure(e);const o=await createImageBitmap(new ImageData(e.width,e.height)),d=1/(e.framerate??30)*1e6;for(let e=0;e<2;e++){const t=new VideoFrame(o,{timestamp:e*d,duration:d});a.encode(t,{keyFrame:0===e}),t.close()}return o.close(),await a.flush(),a.close(),{supported:2===i&&!n&&r,mayUseLotsOfKeyframes:s>1}}catch(t){return console.error("VideoEncoder error during compatibility detection:",e,t),{supported:!1}}}async function we(e){const{baseConfig:t,frameDurationSec:s,framePool:i,onError:n,onVideoFrame:r,outputFormat:a,signal:o,video:d}=e;let c;try{const e=await pe({baseConfig:{...t,width:d.videoWidth,height:d.videoHeight},frameDurationSec:s});return e?(c=new VideoEncoder({output:e=>{let t=i.pop();(!t||t.byteLength<e.byteLength)&&(t=new ArrayBuffer(e.byteLength)),e.copyTo(t),r({format:a,data:new Uint8Array(t,0,e.byteLength),release(){i.push(this.data.buffer)}})},error:e=>{o.aborted||n(e)}}),c.configure(e.config),c):void n(new Error(`Unable to find a supported configuration for ${a} encoding`))}catch(h){return void n(h)}}const ye=window.matchMedia("(hover: hover)").matches;function Ce(){const e=ee(),{actions:t,recordAudio:s,recordMouse:i,recordOrientation:n}=e,{data:r}=(0,ne.Yb)(fe),{data:a}=(0,ne.Yb)(le),{data:o}=(0,ne.Yb)(me),{data:d}=(0,ne.Yb)(ge),{data:c}=(0,ne.Yb)(ae);return(0,te.jsx)("div",{className:h,children:(0,te.jsxs)("div",{className:u,children:[(0,te.jsx)("div",{className:f,children:"Camera"}),(0,te.jsx)("div",{children:(0,te.jsxs)("div",{className:O,children:[!0===d?.supported&&(0,te.jsxs)("label",{children:[(0,te.jsx)("input",{type:"checkbox",checked:e.enabledVideoFormats.has("av1"),onChange:e=>{t.setVideoFormat({format:"av1",enabled:e.target.checked})}}),"AV1"]}),!0===o?.supported&&(0,te.jsxs)("label",{children:[(0,te.jsx)("input",{type:"checkbox",checked:e.enabledVideoFormats.has("vp9"),onChange:e=>{t.setVideoFormat({format:"vp9",enabled:e.target.checked})}}),"VP9"]}),!0===a?.supported&&(0,te.jsxs)("label",{children:[(0,te.jsx)("input",{type:"checkbox",checked:e.enabledVideoFormats.has("h265"),onChange:e=>{t.setVideoFormat({format:"h265",enabled:e.target.checked})}}),"H.265"]}),!0===r?.supported&&(0,te.jsxs)("label",{children:[(0,te.jsx)("input",{type:"checkbox",checked:e.enabledVideoFormats.has("h264"),onChange:e=>{t.setVideoFormat({format:"h264",enabled:e.target.checked})}}),"H.264"]}),(0,te.jsxs)("label",{children:[(0,te.jsx)("input",{type:"checkbox",checked:e.enabledVideoFormats.has("jpeg"),onChange:e=>{t.setVideoFormat({format:"jpeg",enabled:e.target.checked})}}),"JPEG"]})]})}),(0,te.jsx)("div",{className:f,children:"Audio"}),(0,te.jsx)("div",{children:!0===c&&(0,te.jsxs)("label",{children:[(0,te.jsx)("input",{type:"checkbox",checked:s,onChange:e=>{t.setRecordAudio({shouldRecord:e.target.checked})}}),"Microphone"]})}),(0,te.jsx)("div",{className:f,children:"Controls"}),(0,te.jsxs)("div",{children:[(0,te.jsxs)("label",{children:[(0,te.jsx)("input",{type:"checkbox",checked:i,onChange:e=>{t.setRecordMouse({shouldRecord:e.target.checked})}}),"Mouse position"]}),!ye&&(0,te.jsxs)("label",{children:[(0,te.jsx)("input",{type:"checkbox",checked:n,onChange:e=>{t.setRecordOrientation({shouldRecord:e.target.checked})}}),"Orientation"]})]})]})})}function ve(){const{recordMouse:e,latestMouse:t,recordOrientation:s,latestOrientation:i}=ee();return e||s?(0,te.jsxs)("div",{className:p,children:[e&&t&&(0,te.jsxs)(te.Fragment,{children:[(0,te.jsxs)("div",{className:w,children:[(0,te.jsx)("h4",{children:"Mouse position"}),(0,te.jsxs)("div",{children:[(0,te.jsx)("var",{children:"X"}),": ",t.clientX.toFixed(1)]}),(0,te.jsxs)("div",{children:[(0,te.jsx)("var",{children:"Y"}),": ",t.clientY.toFixed(1)]})]}),(0,te.jsx)("hr",{})]}),s&&i&&(0,te.jsxs)(te.Fragment,{children:[(0,te.jsxs)("div",{className:w,children:[(0,te.jsx)("h4",{children:"Device orientation"}),(0,te.jsxs)("div",{children:[(0,te.jsx)("var",{children:"Roll"}),": ",(i.gamma??0).toFixed(),"\xb0"]}),(0,te.jsxs)("div",{children:[(0,te.jsx)("var",{children:"Pitch"}),": ",(i.beta??0).toFixed(),"\xb0"]}),(0,te.jsxs)("div",{children:[(0,te.jsx)("var",{children:"Yaw"}),": ",(i.alpha??0).toFixed(),"\xb0"]})]}),(0,te.jsx)("hr",{})]})]}):null}function Se(){const e=ee(),{videoError:t,enabledVideoFormats:s,videoStarted:i,actions:n}=e,a=s.size>0,{data:o}=(0,ne.Yb)(fe),{data:d}=(0,ne.Yb)(le),{data:c}=(0,ne.Yb)(ge);return t?(0,te.jsx)("div",{className:r()(T,x),children:t.toString()}):a?(0,te.jsxs)(te.Fragment,{children:[!i&&(0,te.jsx)("progress",{className:k}),s.has("h264")&&!0===o?.mayUseLotsOfKeyframes&&(0,te.jsx)("div",{className:A,children:"Note: This browser may have a bug that causes H.264 encoding to be less efficie
1nt."})]}):(0,te.jsx)("span",{className:E,onClick:()=>{!0===c?.supported?n.setVideoFormat({format:"av1",enabled:!0}):!0===d?.supported?n.setVideoFormat({format:"h265",enabled:!0}):!0===o?.supported?n.setVideoFormat({format:"h264",enabled:!0}):n.setVideoFormat({format:"jpeg",enabled:!0})},children:"Choose a video format to enable video."})}function Ie(e){const{actions:t,recording:s,videoStarted:i,enabledVideoFormats:n,selectedCameraDeviceId:r}=ee(),o=n.size>0;(0,a.useEffect)(()=>{if(!s)return;const e=setTimeout(()=>{t.setRecording({isRecording:!1})},3e4);return()=>{clearTimeout(e)}},[s,t]),(0,a.useEffect)(()=>{const s=e.current;if(!s||!o)return;const i=s.querySelector("video");i&&i.remove();const n=document.createElement("video");n.muted=!0,n.playsInline=!0,s.appendChild(n);const a=function(e){let t,s=!1;if("object"!=typeof navigator.mediaDevices)e.onError(new Error("navigator.mediaDevices is not defined"));else{const i={video:!e.deviceId||{deviceId:{exact:e.deviceId}}};navigator.mediaDevices.getUserMedia(i).then(async i=>{s||(t=i,e.video.srcObject=i,await e.video.play(),s||e.onStart())}).catch(t=>{s||e.onError(new Error(`${t.toString()}. Ensure camera permissions are enabled.`))})}return()=>{if(s=!0,t)for(const e of t.getTracks())e.stop()}}({video:n,deviceId:r,onStart:()=>{t.setVideoStarted({isStarted:!0})},onError:e=>{t.setVideoError(e),console.error(e)}});return()=>{a(),n.remove(),t.setVideoStarted({isStarted:!1}),t.setVideoError(void 0)}},[o,r,t,e]),(0,a.useEffect)(()=>{const r=e.current;if(!s||!r||!i)return;if(!o)return;const a=r.querySelector("video");if(!a)return;const d=oe({video:a,enableAV1:n.has("av1"),enableVP9:n.has("vp9"),enableH265:n.has("h265"),enableH264:n.has("h264"),enableJpeg:n.has("jpeg"),frameDurationSec:1/30,onJpegFrame:e=>{t.addJpegFrame(e)},onVideoFrame:e=>{t.addVideoFrame(e)},onError:e=>{t.setVideoError(e),console.error(e)}});return()=>{d()}},[o,s,i,n,t,e])}function xe(e){const{actions:t,recording:s,recordAudio:i,audioStream:n,selectedAudioDeviceId:r}=ee(),o=i;(0,a.useEffect)(()=>{if(!o)return;const s=e.current;if(!s)return;const i=s.getBoundingClientRect();s.width=i.width*window.devicePixelRatio,s.height=i.height*window.devicePixelRatio,s.style.width=`${i.width}px`,s.style.height=`${i.height}px`;const n=function({canvas:e,onAudioStream:t,onError:s,deviceId:i}){let n,r=!1,a=0;if("object"!=typeof navigator.mediaDevices)s(new Error("navigator.mediaDevices is not defined"));else{const o=t=>{r||(a=requestAnimationFrame(()=>{const s=new Uint8Array(t.frequencyBinCount);t.getByteTimeDomainData(s);const i=e.getContext("2d");if(i){const t=e.width,n=e.height;i.fillStyle="rgba(0, 0, 0, 0.3)",i.fillRect(0,0,t,n);const r=n/2,a=t/s.length,o=n/256;i.beginPath(),i.moveTo(0,r);for(let e=0;e<s.length;e++){const t=e*a,n=r+((s[e]??128)-128)*o;i.lineTo(t,n)}i.strokeStyle="#00ffff",i.lineWidth=2,i.stroke()}o(t)}))},d=new AudioContext;d.resume();const c={audio:!i||{deviceId:{exact:i}}};navigator.mediaDevices.getUserMedia(c).then(e=>{if(r)return;n=e,t(n);const s=d.createMediaStreamSource(n),i=d.createAnalyser();i.fftSize=2048,s.connect(i),o(i)}).catch(e=>{r||s(new Error(`${e.toString()}. Ensure microphone permissions are enabled.`))})}return()=>{r=!0,cancelAnimationFrame(a);for(const e of n?.getTracks()??[])e.stop()}}({canvas:s,deviceId:r,onAudioStream:e=>{t.setAudioStream(e)},onError:e=>{t.setAudioError(e),console.error(e)}});return()=>{n(),t.setAudioStream(void 0),t.setAudioError(void 0)}},[o,r,t,e]),(0,a.useEffect)(()=>{if(!o||!s||!n)return;const r=e.current;if(r){const e=r.getBoundingClientRect();r.width=e.width*window.devicePixelRatio,r.height=e.height*window.devicePixelRatio,r.style.width=`${e.width}px`,r.style.height=`${e.height}px`}const a=function({enablePCM:e,stream:t,onAudioData:s,onError:i}){if(!e)return void i(new Error("Invariant: expected PCM encoding to be enabled"));if(!re())return void i(new Error("Audio capture not supported: Web Audio API not supported in browser"));if(!t.getAudioTracks()[0])return void i(new Error("Invariant: expected audio track from stream"));let n=!1;const r=new AudioContext({sampleRate:44100}),a=new Blob(["\n class PCMProcessor extends AudioWorkletProcessor {\n constructor() {\n super();\n this.buffer = new Float32Array(1024);\n this.bufferIndex = 0;\n }\n\n process(inputs, outputs, parameters) {\n const input = inputs[0];\n if (input.length > 0) {\n const channelData = input[0];\n\n // Copy samples into our buffer\n for (let i = 0; i < channelData.length;
1 i++) {\n this.buffer[this.bufferIndex++] = channelData[i];\n\n // If we've filled our buffer, send it and reset\n if (this.bufferIndex >= 1024) {\n this.port.postMessage(this.buffer);\n this.buffer = new Float32Array(1024);\n this.bufferIndex = 0;\n }\n }\n }\n return true;\n }\n }\n registerProcessor('pcm-processor', PCMProcessor);\n "],{type:"application/javascript"}),o=URL.createObjectURL(a),d=r.createMediaStreamSource(t);let c;return r.audioWorklet.addModule(o).then(()=>{n||(c=new AudioWorkletNode(r,"pcm-processor",{numberOfInputs:1,numberOfOutputs:1,outputChannelCount:[1]}),c.port.onmessage=e=>{if(n)return;const t=e.data,i=new Int16Array(t.length);for(let s=0;s<t.length;s++)i[s]=32767*Math.max(-1,Math.min(1,t[s]??0));s({format:"pcm-s16",timestamp:(0,R.fromMillis)(Date.now()),data:new Uint8Array(i.buffer),sample_rate:44100,number_of_channels:1})},d.connect(c),c.connect(r.destination))}).catch(i),()=>{n=!0,c&&c.disconnect(),d.disconnect(),r.close(),URL.revokeObjectURL(o);for(const e of t.getTracks())e.stop()}}({enablePCM:i,stream:n,onAudioData:e=>{t.addAudioData(e)},onError:e=>{t.setAudioError(e)}}),d=e.current;return()=>{if(a?.(),d){const e=d.getContext("2d");e&&e.clearRect(0,0,d.width,d.height)}}},[o,n,s,i,t,e])}const Ee=window.matchMedia("(hover: hover)").matches;function ke(){const e=ee(),t=(0,a.useRef)(null),s=(0,a.useRef)(null),{actions:n,audioError:h,orientationPermissionError:u,recordAudio:f,recording:w,recordMouse:I,recordOrientation:x,showDownloadInfo:E,videoError:k,enabledVideoFormats:A}=e,O=I||!Ee&&x||A.size>0&&!k||f&&!h;!function(){const{actions:e,recording:t,recordMouse:s}=ee();(0,a.useEffect)(()=>{if(!t||!s)return;const i=t=>{e.addMouseEventMessage({clientX:t.clientX,clientY:t.clientY})};return window.addEventListener("pointerdown",i),window.addEventListener("pointermove",i),()=>{window.removeEventListener("pointerdown",i),window.removeEventListener("pointermove",i)}},[e,t,s])}(),function(){const{actions:e,recording:t,recordOrientation:s}=ee();(0,a.useEffect)(()=>{if(!t||!s)return;const i=t=>{e.addPoseMessage(t)};return window.addEventListener("deviceorientation",i),()=>{window.removeEventListener("deviceorientation",i)}},[e,t,s])}(),Ie(t),xe(s);const D=function(){const{actions:e,recording:t,recordOrientation:s}=ee();return(0,a.useCallback)(i=>{i.preventDefault(),t?e.setRecording({isRecording:!1}):(e.setRecording({isRecording:!0}),e.setOrientationPermissionError({hasError:!1}),s&&"undefined"!=typeof DeviceOrientationEvent&&"requestPermission"in DeviceOrientationEvent&&"function"==typeof DeviceOrientationEvent.requestPermission&&Promise.resolve(DeviceOrientationEvent.requestPermission()).then(t=>{"granted"!==t&&e.setOrientationPermissionError({hasError:!0})}).catch(console.error))},[s,t,e])}(),j=function(){const{actions:e}=ee();return(0,a.useCallback)(t=>{t.preventDefault(),(async()=>{const t=await e.closeAndRestart(),s=URL.createObjectURL(t),i=document.createElement("a");i.href=s;const n=new Date,r=new Date(n.getTime()-6e4*n.getTimezoneOffset()).toISOString().replace(/\..+$/,"").replace("T","_").replaceAll(":","-");i.download=`demo_${r}.mcap`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(s),e.setShowDownloadInfo({shouldShow:!0})})()},[e])}();return(0,te.jsx)("section",{className:o,children:(0,te.jsxs)("div",{className:d,children:[(0,te.jsxs)("header",{children:[(0,te.jsx)("h2",{children:"Try it out now"}),(0,te.jsx)("p",{className:c,children:"Select sensor data to record to an MCAP file. All data is recorded and saved locally."})]}),(0,te.jsx)(Ce,{}),(0,te.jsx)(ie,{}),u&&(0,te.jsx)("div",{className:T,children:"Allow permission to use device orientation"}),(0,te.jsx)("hr",{}),E&&(0,te.jsxs)("div",{className:M,children:[(0,te.jsx)("button",{"aria-label":"Close",className:r()("clean-btn",B),type:"button",onClick:()=>{n.setShowDownloadInfo({shouldShow:!1})},children:(0,te.jsx)("span",{"aria-hidden":"true",children:"\xd7"})}),"Try inspecting the file with the"," ",(0,te.jsx)(i.A,{to:"/guides/cli",children:"MCAP CLI"}),", or open it in"," ",(0,te.jsx)(i.A,{to:"https://app.foxglove.dev/",children:"Foxglove"}),"."]}),(0,te.jsxs)("div",{className:y,children:[(0,te.jsxs)("div",{className:C,children:[(0,te.jsx)("var",{children:"Messages"})," ",e.messageCount.toString()]}),(0,te.jsxs)("div",{className:C,children:[(0,te.jsx)("var",{children:"Chunks"})," ",e.chunkCount]})]}),(0,te.jsxs)("div",{className:v,children:[(0,te.jsx)("div",{className:S,ref:t,children:(0,te.jsx)(Se,{})}),(0,te.jsx)("div",{className:S,children:(0,te.jsx)(se,{audioWaveformRef:s})})]}),(0,te.jsxs)("div",{className:l,children:[(0,te.jsxs)("div",{className:p,children:[(0,te.jsxs)(i.A,{href:"#",className:r()("button","button--danger",{"button--outline":!w,disabled:!w&&!O}),onClick:D,children:[(0,te.jsx)("div",{className:r()(m,{[g]:w})}),w?"Stop recording":"Start recording"]}),e.messageCount>0&&(0,te.jsxs)(i.A,{href:"#",className:r()("button","button--success",b),onClick:j,children:["Download recording (",Z(Number(e.bytesWritten)),")"]})]}),(0,te.jsx)(ve,{})]})]})})}},9964(){},1874(){},9154(){}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.