@apocaliss92/scrypted-reolink-hub
Version:
Reolink (HUBs) Plugin for Scrypted
3 lines • 972 kB
JavaScript
/*! For license information please see main.nodejs.js.LICENSE.txt */
(()=>{var e={39:(e,t,i)=>{"use strict";const{ObjectSetPrototypeOf:n,Symbol:o}=i(3383);e.exports=l;const{ERR_METHOD_NOT_IMPLEMENTED:r}=i(676).codes,s=i(5745),{getHighWaterMark:a}=i(5722);n(l.prototype,s.prototype),n(l,s);const c=o("kCallback");function l(e){if(!(this instanceof l))return new l(e);const t=e?a(this,e,"readableHighWaterMark",!0):null;0===t&&(e={...e,highWaterMark:null,readableHighWaterMark:t,writableHighWaterMark:e.writableHighWaterMark||0}),s.call(this,e),this._readableState.sync=!1,this[c]=null,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",u)}function p(e){"function"!=typeof this._flush||this.destroyed?(this.push(null),e&&e()):this._flush(((t,i)=>{t?e?e(t):this.destroy(t):(null!=i&&this.push(i),this.push(null),e&&e())}))}function u(){this._final!==p&&p.call(this)}l.prototype._final=p,l.prototype._transform=function(e,t,i){throw new r("_transform()")},l.prototype._write=function(e,t,i){const n=this._readableState,o=this._writableState,r=n.length;this._transform(e,t,((e,t)=>{e?i(e):(null!=t&&this.push(t),o.ended||r===n.length||n.length<n.highWaterMark?i():this[c]=i)}))},l.prototype._read=function(){if(this[c]){const e=this[c];this[c]=null,e()}}},111:function(e){(function(){e.exports=function(){function e(e){this.nodes=e}return Object.defineProperty(e.prototype,"length",{get:function(){return this.nodes.length||0}}),e.prototype.clone=function(){return this.nodes=null},e.prototype.item=function(e){return this.nodes[e]||null},e}()}).call(this)},114:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BitStream=t.dumpBuffer=t.BufferChain=t.BitWriter2=t.BitWriter=void 0,t.random16=function(){return o.jspack.Unpack("!H",(0,n.randomBytes)(2))[0]},t.random32=function(){return o.jspack.Unpack("!L",(0,n.randomBytes)(4))[0]},t.bufferXor=function(e,t){if(e.length!==t.length)throw new TypeError("[webrtc-stun] You can not XOR buffers which length are different");const i=e.length,n=Buffer.allocUnsafe(i);for(let o=0;o<i;o++)n[o]=e[o]^t[o];return n},t.bufferArrayXor=function(e){const t=[...e].sort(((e,t)=>e.length-t.length)).reverse()[0].length,i=Buffer.allocUnsafe(t);for(let n=0;n<t;n++)i[n]=0,e.forEach((e=>{i[n]^=e[n]??0}));return i},t.getBit=function(e,t,i=1){let n=e.toString(2).split("");n=[...Array(8-n.length).fill("0"),...n];const o=n.slice(t,t+i).join("");return Number.parseInt(o,2)},t.paddingByte=function(e){const t=e.toString(2).split("");return[...[...Array(8-t.length)].map((()=>"0")),...t].join("")},t.paddingBits=function(e,t){const i=e.toString(2);return[...[...Array(t-i.length)].map((()=>"0")),...i].join("")},t.bufferWriter=function(e,t){return r(e)(t)},t.createBufferWriter=r,t.bufferWriterLE=function(e,t){const i=e.reduce(((e,t)=>e+t),0),n=Buffer.alloc(i);let o=0;return t.forEach(((t,i)=>{const r=e[i];8===r?n.writeBigUInt64LE(t,o):n.writeUIntLE(t,o,r),o+=r})),n},t.bufferReader=function(e,t){let i=0;return t.map((t=>{let n;return n=8===t?e.readBigUInt64BE(i):e.readUIntBE(i,t),i+=t,n}))},t.buffer2ArrayBuffer=function(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)};const n=i(6982),o=i(4724);t.BitWriter=class{constructor(e){this.bitLength=e,this.value=0}set(e,t,i){return i&=(1<<e)-1,this.value|=i<<this.bitLength-e-t,this}get buffer(){const e=Math.ceil(this.bitLength/8),t=Buffer.alloc(e);return t.writeUIntBE(this.value,0,e),t}};function r(e,t){const i=e.reduce(((e,t)=>e+t),0),n=t?Buffer.alloc(i):void 0;return t=>{const o=n||Buffer.alloc(i);let r=0;return t.forEach(((t,i)=>{const n=e[i];8===n?o.writeBigUInt64BE(t,r):o.writeUIntBE(t,r,n),r+=n})),o}}t.BitWriter2=class{constructor(e){if(this.bitLength=e,this._value=0n,this.offset=0n,e>32)throw new Error}set(e,t=1){let i=BigInt(e);const n=BigInt(t);return i&=(1n<<n)-1n,this._value|=i<<BigInt(this.bitLength)-n-this.offset,this.offset+=n,this}get value(){return Number(this._value)}get buffer(){const e=Math.ceil(this.bitLength/8),t=Buffer.alloc(e);return t.writeUIntBE(this.value,0,e),t}};t.BufferChain=class{constructor(e){this.buffer=Buffer.alloc(e)}writeInt16BE(e,t){return this.buffer.writeInt16BE(e,t),this}writeUInt8(e,t){return this.buffer.writeUInt8(e,t),this}};t.dumpBuffer=e=>"0x"+e.toString("hex").replace(/(.)(.)/g,"$1$2 ").split(" ").filter((e=>null!=e&&e.length>0)).join(",0x");t.BitStream=class{constructor(e){this.uint8Array=e,this.position=0,this.bitsPending=0}writeBits(e,t){if(0==e)return this;let i;return t&=4294967295>>>32-e,this.bitsPending>0?this.bitsPending>e?(this.uint8Array[this.position-1]|=t<<this.bitsPending-e,i=e,this.bitsPending-=e):this.bitsPending==e?(this.uint8Array[this.position-1]|=t,i=e,this.bitsPending=0):(this.uint8Array[this.position-1]|=t>>e-this.bitsPending,i=this.bitsPending,this.bitsPending=0):(i=Math.min(8,e),this.bitsPending=8-i,this.uint8Array[this.position++]=t>>e-i<<this.bitsPending),(e-=i)>0&&this.writeBits(e,t),this}readBits(e,t){if("undefined"==typeof t&&(t=0),0==e)return t;let i,n;if(this.bitsPending>0){const t=this.uint8Array[this.position-1]&255>>8-this.bitsPending;n=Math.min(this.bitsPending,e),this.bitsPending-=n,i=t>>this.bitsPending}else n=Math.min(8,e),this.bitsPending=8-n,i=this.uint8Array[this.position++]>>this.bitsPending;return t=t<<n|i,(e-=n)>0?this.readBits(e,t):t}seekTo(e){this.position=e/8|0,this.bitsPending=e%8,this.bitsPending>0&&(this.bitsPending=8-this.bitsPending,this.position++)}}},123:(e,t,i)=>{const n=i(8611),o=i(5692),r=i(6982),s=i(4434),a=i(7016),c=i(9023),l=i(4081).linerase,p=i(4081).parseSOAPString,u=i(1792).parseString,d=i(1792).processors.stripPrefix,h=function(){};var m=function(e,t){s.EventEmitter.call(this),t=t||h,this.useSecure=e.useSecure||!1,this.secureOpts=e.secureOpts||{},this.hostname=e.hostname,this.username=e.username,this.password=e.password,this.port=e.port||(e.useSecure?443:80),this.path=e.path||"/onvif/device_service",this.timeout=e.timeout||12e4,this.agent=e.agent||!1,this.preserveAddress=e.preserveAddress||!1,this.events={},this.on("newListener",function(e){"event"===e&&0===this.listeners(e).length&&setImmediate(function(){this._eventRequest()}.bind(this))}.bind(this)),!1!==e.autoconnect&&setImmediate(function(){this.connect(t)}.bind(this))};c.inherits(m,s.EventEmitter),m.prototype.connect=function(e){this.getSystemDateAndTime(function(t,i,n){if(t)return e.call(this,t,null,n);function o(){var t=[];this.uri&&this.uri.media&&(t.push(this.getProfiles),t.push(this.getVideoSources));var i=t.length,n=!1;if(i>0)t.forEach(function(t){t.call(this,function(t){if(t)e&&!n&&(e.call(this,t),n=!0);else if(! --i&&(this.getActiveSources(),this.emit("connect"),e))return e.call(this,t)}.bind(this))}.bind(this));else if(this.emit("connect"),e)return e.call(this,!1)}this.getServices(!0,function(t){return t?this.getCapabilities(function(t,i,n){return t?e.call(this,t,null,n):o.call(this)}.bind(this)):this.media2Support?void this.getProfiles(function(e){return e&&(this.media2Support=!1),o.call(this)}.bind(this)):o.call(this)}.bind(this))}.bind(this))},m.prototype._request=function(e,t){if("function"!=typeof t)throw new Error("'callback' must be a function");if(void 0===e.body)throw new Error("'options.body' must be a defined");if(void 0===e.action||null===e.action){let i={xmlns:!0,tagNameProcessors:[d]};u(e.body,i,((i,n)=>{if(i)return t(i);for(const t of Object.keys(n.Envelope.Body[0])){const i=n.Envelope.Body[0][t];if(!1===t.startsWith("$")){e.action=i[0].$ns.uri+"/"+i[0].$ns.local;break}}this._requestPart2.call(this,e,t)}))}else this._requestPart2.call(this,e,t)},m.prototype._requestPart2=function(e,t){var i=this,r=!1,s=e.url||{hostname:this.hostname,port:this.port,agent:this.agent,path:e.service?this.uri&&this.uri[e.service]?this.uri[e.service].path:e.service:this.path,timeout:this.timeout};s.headers={"Content-Type":`application/soap+xml;charset=utf-8;action="${e.action}"`,"Content-Length":Buffer.byteLength(e.body,"utf8"),charset:"utf-8"},s.method="POST";var a=this.useSecure?o:n;s=this.useSecure?Object.assign({},this.secureOpts,s):s;var c=a.request(s,(function(e){const n=e.statusCode;var o=[],s=0;e.on("data",(function(e){o.push(e),s+=e.length})),e.on("end",(function(){if(!0!==r){r=!0;var e=Buffer.concat(o,s).toString("utf8");i.emit("rawResponse",e,n),p(e,t,n)}}))}));c.setTimeout(e.replyTimeout?e.replyTimeout:this.timeout,(function(){!0!==r&&(r=!0,t(new Error("Network timeout")),c.abort())})),c.on("error",(function(e){!0!==r&&(r=!0,"ECONNREFUSED"===e.code&&"ECONNREFUSED"===e.errno&&"connect"===e.syscall||"ECONNRESET"===e.code&&"ECONNRESET"===e.errno&&e.syscall,t(e))})),this.emit("rawRequest",e.body),c.write(e.body),c.end()},m.prototype.getSystemDateAndTime=function(e){this._request({body:'<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><GetSystemDateAndTime xmlns="http://www.onvif.org/ver10/device/wsdl"/></s:Body></s:Envelope>'},function(t,i,n,o){if(!t)try{let o,r=i[0].getSystemDateAndTimeResponse[0].systemDateAndTime[0],s=r.UTCDateTime||r.localDateTime;if(void 0===s)o=new Date;else{let e=l(s[0]);o=new Date(Date.UTC(e.date.year,e.date.month-1,e.date.day,e.time.hour,e.time.minute,e.time.second))}this.timeShift||(this.timeShift=o-1e3*process.uptime()),e.call(this,t,o,n)}catch(t){e.call(this,t,null,n)}if(t){let i="";n&&(i=n.toLowerCase()),o&&401===o||n&&(i.includes("sender not authorized")||i.includes("unauthorized")||i.includes("notauthorized"))?this._request({body:this._envelopeHeader()+'<GetSystemDateAndTime xmlns="http://www.onvif.org/ver10/device/wsdl"/>'+this._envelopeFooter()},function(t,i,n){try{let o,r=i[0].getSystemDateAndTimeResponse[0].systemDateAndTime[0],s=r.UTCDateTime||r.localDateTime;if(void 0===s)o=new Date;else{let e=l(s[0]);o=new Date(Date.UTC(e.date.year,e.date.month-1,e.date.day,e.time.hour,e.time.minute,e.time.second))}this.timeShift||(this.timeShift=o-1e3*process.uptime()),e.call(this,t,o,n)}catch(t){e.call(this,t,null,n)}}.bind(this)):e.call(this,t,null,n)}}.bind(this))},m.prototype.setSystemDateAndTime=function(e,t){if(-1===["Manual","NTP"].indexOf(e.dateTimeType))return t(new Error("DateTimeType should be `Manual` or `NTP`"));this._request({body:this._envelopeHeader()+'<SetSystemDateAndTime xmlns="http://www.onvif.org/ver10/device/wsdl"><DateTimeType>'+e.dateTimeType+"</DateTimeType><DaylightSavings>"+!!e.daylightSavings+"</DaylightSavings>"+(void 0!==e.timezone?'<TimeZone><TZ xmlns="http://www.onvif.org/ver10/schema">'+e.timezone+"</TZ></TimeZone>":"")+(void 0!==e.dateTime&&e.dateTime instanceof Date?'<UTCDateTime><Time xmlns="http://www.onvif.org/ver10/schema"><Hour>'+e.dateTime.getUTCHours()+"</Hour><Minute>"+e.dateTime.getUTCMinutes()+"</Minute><Second>"+e.dateTime.getUTCSeconds()+'</Second></Time><Date xmlns="http://www.onvif.org/ver10/schema"><Year>'+e.dateTime.getUTCFullYear()+"</Year><Month>"+(e.dateTime.getUTCMonth()+1)+"</Month><Day>"+e.dateTime.getUTCDate()+"</Day></Date></UTCDateTime>":"")+"</SetSystemDateAndTime>"+this._envelopeFooter()},function(e,i,n){if(e||""!==l(i).setSystemDateAndTimeResponse)return t.call(this,""!==l(i).setSystemDateAndTimeResponse?new Error("Wrong `SetSystemDateAndTime` response"):e,i,n);this.getSystemDateAndTime(t)}.bind(this))},m.prototype.getCapabilities=function(e){this._request({body:this._envelopeHeader()+'<GetCapabilities xmlns="http://www.onvif.org/ver10/device/wsdl"><Category>All</Category></GetCapabilities>'+this._envelopeFooter()},function(t,i,n){if(!t&&(this.capabilities=l(i[0].getCapabilitiesResponse[0].capabilities[0]),this.uri||(this.uri={}),["PTZ","media","imaging","events","device"].forEach(function(e){this.capabilities[e]&&this.capabilities[e].XAddr&&(this.uri[e.toLowerCase()]=this._parseUrl(this.capabilities[e].XAddr))}.bind(this)),this.capabilities.extension&&Object.keys(this.capabilities.extension).forEach(function(e){this.capabilities.extension[e].XAddr&&(this.uri[e]=a.parse(this.capabilities.extension[e].XAddr))}.bind(this)),this.uri.replay&&!this.uri.recording)){var o=this.uri.replay.href.replace("replay","recording");console.warn("WARNING: Adding "+o+" for bad Profile G device"),this.uri.recording=a.parse(o)}e&&e.call(this,t,this.capabilities,n)}.bind(this))},m.prototype.getServiceCapabilities=function(e){this._request({body:this._envelopeHeader()+'<GetServiceCapabilities xmlns="http://www.onvif.org/ver10/device/wsdl" />'+this._envelopeFooter()},function(t,i,n){t||(i=l(i),this.serviceCapabilities={network:i.getServiceCapabilitiesResponse.capabilities.network.$,security:i.getServiceCapabilitiesResponse.capabilities.security.$,system:i.getServiceCapabilitiesResponse.capabilities.system.$},i.getServiceCapabilitiesResponse.capabilities.misc&&(this.serviceCapabilities.auxiliaryCommands=i.getServiceCapabilitiesResponse.capabilities.misc.$.AuxiliaryCommands.split(" "))),e&&e.call(this,t,this.serviceCapabilities,n)}.bind(this))},m.prototype.getActiveSources=function(){this.videoSources.$&&(this.videoSources=[this.videoSources]),this.defaultProfiles=[],this.activeSources=[],this.videoSources.forEach(function(e,t){var i=e.$.token,n=this.profiles.filter((function(e){if(e.videoSourceConfiguration&&e.videoEncoderConfiguration&&(e.videoSourceConfiguration.sourceToken===i||e.videoSourceConfiguration.sourceToken===e.videoSourceConfiguration.name))return!0}));if(0!==n.length){if(0===t&&(this.defaultProfile=n[0]),this.defaultProfiles[t]=n[0],this.activeSources[t]={sourceToken:e.$.token,profileToken:this.defaultProfiles[t].$.token,videoSourceConfigurationToken:this.defaultProfiles[t].videoSourceConfiguration.$.token},this.defaultProfiles[t].videoEncoderConfiguration){var o=this.defaultProfiles[t].videoEncoderConfiguration;this.activeSources[t].encoding=o.encoding,this.activeSources[t].width=o.resolution?o.resolution.width:"",this.activeSources[t].height=o.resolution?o.resolution.height:"",this.activeSources[t].fps=o.rateControl?o.rateControl.frameRateLimit:"",this.activeSources[t].bitrate=o.rateControl?o.rateControl.bitrateLimit:""}0===t&&(this.activeSource=this.activeSources[t]),this.defaultProfiles[t].PTZConfiguration&&(this.activeSources[t].ptz={name:this.defaultProfiles[t].PTZConfiguration.name,token:this.defaultProfiles[t].PTZConfiguration.$.token})}else if(0===t)throw new Error("Unrecognized configuration")}.bind(this)),0===this.activeSources.length&&this.emit("warning","There are no active sources at this device")},m.prototype.getServices=function(e,t){"function"==typeof e&&(t=e,e=!0),this._request({body:this._envelopeHeader()+'<GetServices xmlns="http://www.onvif.org/ver10/device/wsdl"><IncludeCapability>'+e+"</IncludeCapability></GetServices>"+this._envelopeFooter()},function(e,i,n){e||(this.services=l(i).getServicesResponse.service,this.uri||(this.uri={}),this.media2Support=!1,this.services.forEach((e=>{if(Object.prototype.hasOwnProperty.call(e,"namespace")&&Object.prototype.hasOwnProperty.call(e,"XAddr")){let t=a.parse(e.namespace);if("www.onvif.org"===t.hostname){let i=t.path.substring(1).split("/");"media"===i[1]&&"ver20"===i[0]&&(this.media2Support=!0,i[1]="media2"),this.uri[i[1]]=this._parseUrl(e.XAddr)}}}))),t&&t.call(this,e,this.services,n)}.bind(this))},m.prototype.getDeviceInformation=function(e){this._request({body:this._envelopeHeader()+'<GetDeviceInformation xmlns="http://www.onvif.org/ver10/device/wsdl"/>'+this._envelopeFooter()},function(t,i,n){t||(this.deviceInformation=l(i).getDeviceInformationResponse),e&&e.call(this,t,this.deviceInformation,n)}.bind(this))},m.prototype.getHostname=function(e){this._request({body:this._envelopeHeader()+'<GetHostname xmlns="http://www.onvif.org/ver10/device/wsdl"/>'+this._envelopeFooter()},function(t,i,n){e&&e.call(this,t,t?null:l(i).getHostnameResponse.hostnameInformation,n)}.bind(this))},m.prototype.getScopes=function(e){this._request({body:this._envelopeHeader()+'<GetScopes xmlns="http://www.onvif.org/ver10/device/wsdl"/>'+this._envelopeFooter()},function(t,i,n){t||(this.scopes=l(i).getScopesResponse.scopes,void 0===this.scopes?this.scopes=[]:Array.isArray(this.scopes)||(this.scopes=[this.scopes])),e&&e.call(this,t,this.scopes,n)}.bind(this))},m.prototype.setScopes=function(e,t){this._request({body:this._envelopeHeader()+'<SetScopes xmlns="http://www.onvif.org/ver10/device/wsdl">'+e.map((function(e){return"<Scopes>"+e+"</Scopes>"})).join("")+"</SetScopes>"+this._envelopeFooter()},function(e,i,n){if(e||""!==l(i).setScopesResponse)return t(""!==l(i).setScopesResponse?new Error("Wrong `SetScopes` response"):e,i,n);this.getScopes(t)}.bind(this))},m.prototype.systemReboot=function(e){this._request({service:"deviceIO",body:this._envelopeHeader()+'<SystemReboot xmlns="http://www.onvif.org/ver10/device/wsdl"/>'+this._envelopeFooter()},(function(t,i,n){t||(i=i[0].systemRebootResponse[0].message[0]),e.call(this,t,i,n)}))},m.prototype.setSystemFactoryDefault=function(e,t){void 0===t&&(t=e,e=!1);let i=this._envelopeHeader()+'<SetSystemFactoryDefault xmlns="http://www.onvif.org/ver10/device/wsdl"><FactoryDefault>'+(e?"Hard":"Soft")+"</FactoryDefault></SetSystemFactoryDefault>"+this._envelopeFooter();this._request({service:"device",body:i},(function(e,i,n){t&&t.call(this,e,null,n)}))},m.prototype._passwordDigest=function(){let e=new Date(1e3*process.uptime()+(this.timeShift||0)).toISOString(),t=Buffer.allocUnsafe(16);t.writeUIntLE(Math.ceil(4294967296*Math.random()),0,4),t.writeUIntLE(Math.ceil(4294967296*Math.random()),4,4),t.writeUIntLE(Math.ceil(4294967296*Math.random()),8,4),t.writeUIntLE(Math.ceil(4294967296*Math.random()),12,4);let i=r.createHash("sha1");return i.update(Buffer.concat([t,Buffer.from(e,"ascii"),Buffer.from(this.password,"ascii")])),{passdigest:i.digest("base64"),nonce:t.toString("base64"),timestamp:e}},m.prototype._envelopeHeader=function(e){var t='<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"><s:Header>';if(this.username&&this.password){var i=this._passwordDigest();t+='<Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><UsernameToken><Username>'+this.username+'</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">'+i.passdigest+'</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">'+i.nonce+'</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">'+i.timestamp+"</Created></UsernameToken></Security>"}return void 0!==e&&e||(t+='</s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">'),t},m.prototype._envelopeFooter=function(){return"</s:Body></s:Envelope>"},m.prototype._parseUrl=function(e){const t=a.parse(e);return!this.preserveAddress||this.hostname===t.hostname&&this.port===t.port||(t.hostname=this.hostname,t.host=this.hostname+":"+this.port,t.port=this.port,t.href=a.format(t)),t},e.exports={Cam:m},i(7072)(m),i(8539)(m),i(6560)(m),i(3586)(m),i(8974)(m),i(5083)(m),i(7325)(m)},145:function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=i(7260),r=n(i(3861)),s=i(4392),a=i(3540),c=i(5317),l=n(i(9896)),p=n(i(6928)),u=n(i(7016)),d=i(8705),h=i(8406),m=i(2122),f=i(5425),{endpointManager:g}=r.default,v=new RegExp("(.*)([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})(.*)");class y extends s.SettingsMixinDeviceBase{constructor(e,t){super(e),this.plugin=t,this.parsingVideoclips=!1,this.videoErrorCount=new Map,this.ffmpegGenerationTimeout=new Map,this.blacklistedVideos=new Set,this.storageSettings=new a.StorageSettings(this,{ftp:{title:"Fetch from FTP folder",type:"boolean",immediate:!0,defaultValue:!0},ftpFolder:{title:"FTP folder",description:"FTP folder where reolink stores the clips",type:"string"},filenamePrefix:{title:"Filename content (leave empty to let plugin find the clips)",description:"This should contain any relevant text to identify the camera clips. I.e. Videocamera dispensa_00_20250105123640.mp4 -> Videocamera dispensa_00_",type:"string"},maxSpaceInGb:{title:"Dedicated memory in GB",type:"number",defaultValue:20,onPut:async(e,t)=>await this.scanMemoryUsage(t)},occupiedSpaceInGb:{title:"Memory occupancy in GB",type:"number",range:[0,20],readonly:!0,placeholder:"GB"}}),this.plugin.currentMixinsMap[this.id]=this,this.camera=this.plugin.plugin.devices.get(this.nativeId),setTimeout((()=>this.checkFtpScan().catch(this.getLogger()?.log)),3e3)}getLogger(){return(0,d.getBaseLogger)({console:this.console,storage:this.camera.storageSettings})}async release(){this.killed=!0,this.stopVideoclipsParser(),this.stopFtpScan()}async checkFtpScan(){if(!this.killed){const{ftp:e,ftpFolder:t}=this.storageSettings.values,i=this.getLogger();e&&t?(!this.ftpScanTimeout&&i.log("FTP folder scan interval started"),await this.startFtpScan(),!this.parseVideoclipsTimeout&&i.log("FTP videoclips parser started"),await this.startVideoclipsParser()):(this.ftpScanTimeout&&i.log("FTP folder scan interval stopped"),this.stopFtpScan(),this.parseVideoclipsTimeout&&i.log("FTP videoclips parser stopped"),await this.stopVideoclipsParser())}}stopFtpScan(){this.ftpScanTimeout&&clearInterval(this.ftpScanTimeout),this.ftpScanTimeout=void 0}get fileNamePrefix(){const{filenamePrefix:e}=this.storageSettings.values;if(e)return e;let t=String(this.camera.getRtspChannel());return 1===t.length&&(t=`0${t}`),`_${t}_`}handleVideoError(e){const t=(this.videoErrorCount.get(e)||0)+1;return this.videoErrorCount.set(e,t),t>2?(this.blacklistedVideos.add(e),this.getLogger().warn(`Video ${e} blacklisted after ${t} failed attempts`),!0):(this.getLogger().debug(`Video ${e} error count: ${t}/3`),!1)}async startVideoclipsParser(){this.stopVideoclipsParser();const e=this.getLogger(),t=this.getFtpParsedDirectory();await l.default.promises.mkdir(t,{recursive:!0}),this.parseVideoclipsTimeout=setInterval((async()=>{if(!this.parsingVideoclips)try{const{ftpFolder:i}=this.storageSettings.values,n=await this.searchSourceFptFiles(i);if(n.length){const i=n.filter((e=>!this.blacklistedVideos.has(e.fullPath))),r=n.length-i.length;if(r>0&&e.log(`${r} videos are blacklisted and will be skipped`),0===i.length)return void e.log(`No videos to process (${n.length} total, ${r} blacklisted)`);e.log(`${i.length} videoclips will be parsed (${r} blacklisted)`);for(let n=0;n<i.length;n++){const r=i[n],{fullPath:s,filename:a}=r,c=i.length-n-1;try{this.parsingVideoclips=!0;const i=await this.getVideoDurationWithFFmpeg(s);if(i){e.log(`Duration found for video ${s}: ${i}`);let n=await this.findFtpThumbnail(s);if(n||(e.log(`Thumbnail not found for video ${a}, generating`),n=await this.generateThumbnail(s),e.log(`Thumbnail for video ${a} generated`)),n){const o=s.split(".")[0].split("_"),r=o[o.length-1],c=this.convertTimestampToMillis(r),u=`${c}_${Math.round(i)}.mp4`,d=`${c}.jpeg`,h=p.default.join(t,u),m=p.default.join(t,d);await l.default.promises.copyFile(s,h),await l.default.promises.rm(s,{force:!0,maxRetries:10}),await l.default.promises.writeFile(m,n),e.log(`Successfully processed video: ${a} -> ${u} (${i}s)`),e.log(`Successfully processed thumbnail: ${n.length} bytes -> ${d}`),this.videoErrorCount.delete(s)}else{e.warn(`No thumbnail found for video: ${a}`);this.handleVideoError(s)&&e.warn(`Video ${a} will be skipped in future processing`)}}else{e.warn(`Could not extract duration for video: ${a}`);this.handleVideoError(s)&&e.warn(`Video ${a} will be skipped in future processing`)}}catch(t){e.error(`Error during parsing video ${s}:`,t);this.handleVideoError(s)&&e.warn(`Video ${a} will be skipped in future processing`)}finally{e.log(`Remaining videoclips to process: ${c}`),await(0,o.sleep)(2e3)}}}}catch(t){e.log("Error in scanning the ftp folder",t)}finally{this.parsingVideoclips=!1}}),1e4)}async stopVideoclipsParser(){this.parseVideoclipsTimeout&&clearInterval(this.parseVideoclipsTimeout),this.parseVideoclipsTimeout=void 0}async searchSourceFptFiles(e,t=[]){const i=this.fileNamePrefix,n=this.getLogger(),o=[...t],r=await l.default.promises.readdir(e)||[],s=r.filter((e=>(!i||e.includes(i))&&e.endsWith("mp4")));n.debug(`Files found: ${JSON.stringify({files:r,filteredFiles:s})}`);for(const t of s){const r=p.default.join(e,t),s=l.default.statSync(r);if(s.isDirectory())o.push(...await this.searchSourceFptFiles(r,o));else{let a=t;if(i){a=t.split(i)[1]}n.debug(`Parsing filename: ${JSON.stringify({file:t,timestamp:a,videoclippathRegex:v})}`);try{const e=r.split(".")[0].split("_"),i=e[e.length-1],n=this.convertTimestampToMillis(i);o.push({filename:t,fullPath:r,timestamp:n,size:s.size})}catch(i){n.log(`Error parsing file ${t} in path ${e}`)}}}return o}async startFtpScan(){const e=this.getLogger();this.stopFtpScan(),this.ftpScanTimeout=setInterval((async()=>{try{this.storageSettings.values.ftp&&await this.scanMemoryUsage()}catch(t){e.log("Error in scanning the ftp folder",t)}}),36e5),await this.scanMemoryUsage()}async scanMemoryUsage(e){const t=this.getLogger();t.log("FS memory scan initialized");const{ftpFolder:i}=this.storageSettings.values,{maxSpaceInGb:n}=this.storageSettings.values,o=e??n,r=this.fileNamePrefix,{occupiedSpaceInGb:s,occupiedSpaceInGbNumber:a,freeMemory:c}=await(0,h.calculateSize)({currentPath:i,filenamePrefix:r,maxSpaceInGb:o});this.storageSettings.settings.occupiedSpaceInGb.range=[0,o],this.putMixinSetting("occupiedSpaceInGb",s),t.debug(`Occupied space: ${s} GB`);const u=.05*o;if(c<=u){const e=this.getFtpParsedDirectory(),i=(await l.default.promises.readdir(e)).map((i=>{if(i.endsWith(".mp4"))try{const[t]=i.split(".")[0].split("_"),n=Number(t),o=p.default.join(e,i);return{file:i,fullPath:o,thumbnailPath:p.default.join(e,`${t}.jpeg`),timeStart:n}}catch(e){return t.warn(`Error parsing file ${i} for cleanup`),null}return null})).filter(Boolean);i.sort(((e,t)=>e.timeStart-t.timeStart));const n=Math.floor(.1*i.length),o=Math.min(i.length,n);t.log(`Deleting ${o} oldest files... ${JSON.stringify({freeMemory:c,cleanupMemoryThresholderInGb:u})}`);for(let e=0;e<o;e++){const{fullPath:n,file:o,thumbnailPath:r}=i[e];try{await l.default.promises.rm(n,{force:!0,maxRetries:10}),t.log(`Deleted videoclip: ${o}`),l.default.existsSync(r)&&(await l.default.promises.rm(r,{force:!0,maxRetries:10}),t.log(`Deleted thumbnail: ${p.default.basename(r)}`))}catch(e){t.error(`Error deleting files: ${o}`,e)}}}t.log(`FS scan executed: ${JSON.stringify({freeMemory:c,occupiedSpaceInGbNumber:a,maxSpaceInGb:o,cleanupMemoryThresholderInGb:u})}`)}async getClient(){return this.camera.getClient()}async getVideoclipWebhookUrls(e){const t=await g.getCloudEndpoint(void 0,{public:!0}),[i,n]=t.split("?")??"",o={nativeId:this.nativeId,deviceId:this.id,videoclipPath:e};return{videoclipUrl:`${i}videoclip?params=${JSON.stringify(o)}&${n}`,thumbnailUrl:`${i}thumbnail?params=${JSON.stringify(o)}&${n}`}}processDate(e){let t=new Date;return t.setFullYear(e.year),t.setMonth(e.mon-1),t.setDate(e.day),t.setHours(e.hour),t.setMinutes(e.min),t.setSeconds(e.sec),t.getTime()}convertTimestampToMillis(e){const t=parseInt(e.substring(0,4),10),i=parseInt(e.substring(4,6),10),n=parseInt(e.substring(6,8),10),o=parseInt(e.substring(8,10),10),r=parseInt(e.substring(10,12),10),s=parseInt(e.substring(12,14),10);return new Date(t,i-1,n,o,r,s).getTime()}clearFfmpegTimeout(e){const t=this.ffmpegGenerationTimeout.get(e);t&&(clearTimeout(t),this.ffmpegGenerationTimeout.delete(e))}async getVideoDurationWithFFmpeg(e){const t=this.getLogger();return new Promise((async(i,n)=>{try{await l.default.promises.access(e);const o=(0,c.spawn)(this.plugin.ffmpegPath,["-i",e,"-f","null","-"],{stdio:["pipe","pipe","pipe"]});let r="";o.stderr.on("data",(e=>{r+=e.toString()})),o.on("close",(()=>{try{const n=r.match(/Duration: (\d{2}):(\d{2}):(\d{2})\.(\d{2})/);if(n){const o=parseInt(n[1],10),r=parseInt(n[2],10),s=parseInt(n[3],10),a=3600*o+60*r+s+parseInt(n[4],10)/100;t.debug(`Video duration ${e}: ${a}s`),this.clearFfmpegTimeout(e),i(a)}else t.error(`Unable to extract duration from video: ${e}`,r),this.clearFfmpegTimeout(e),i(null)}catch(i){t.error(`Error parsing duration for ${e}:`,i),this.clearFfmpegTimeout(e),n(i)}})),o.on("error",(i=>{t.error(`Error executing FFmpeg for ${e}:`,i),this.clearFfmpegTimeout(e),n(i)}));const s=setTimeout((()=>{o.kill(),t.error(`FFmpeg timeout for ${e}`),this.clearFfmpegTimeout(e),n("timeout")}),15e3);this.ffmpegGenerationTimeout.set(e,s)}catch{t.error(`Videoclip not found: ${e}`),n("not found")}}))}async getVideoClips(e,t="main"){const i=this.getLogger();try{const{ftp:t}=this.storageSettings.values,n=this.getFtpParsedDirectory(),o=[];if(t){const t=(await l.default.promises.readdir(n)||[]).filter((e=>e.endsWith(".mp4")));for(const i of t){const[t,r]=i.split(".")[0].split("_"),s=Number(t),a=p.default.join(n,i),c="motion",{thumbnailUrl:l,videoclipUrl:u}=await this.getVideoclipWebhookUrls(a);s>=e.startTime&&s<=e.endTime&&o.push({id:a,startTime:s,duration:1e3*Number(r),videoId:a,thumbnailId:a,detectionClasses:[c],event:c,description:c,resources:{thumbnail:{href:l},video:{href:u}}})}}else{const t=await this.getClient(),n=(0,m.splitDateRangeByDay)(e.startTime,e.endTime);let r=[];for(const e of n){const i=await t.getVideoClips(this.camera.getRtspChannel(),{startTime:e.start,endTime:e.end});r.push(...i)}for(const e of r){const t=e.name;try{const i=this.processDate(e.StartTime),n=this.processDate(e.EndTime)-i,{detectionClasses:r}=(0,m.parseVideoclipName)(t,this.console)??{},s="motion",{thumbnailUrl:a,videoclipUrl:c}=await this.getVideoclipWebhookUrls(t);o.push({id:t,startTime:i,duration:Math.round(n),videoId:t,thumbnailId:t,detectionClasses:r??[s],event:s,description:f.pluginId,resources:{thumbnail:{href:a},video:{href:c}}})}catch(n){i.log(`error parsing videoclip ${t}: ${JSON.stringify(e)}`,n)}}}return i.info("Videoclips found:",JSON.stringify({videoclips:o})),o}catch(e){i.log("Error during get videoClips",e)}}async getVideoClip(e){this.getLogger().log("Fetching videoId ",e);const{videoclipUrl:t}=await this.getVideoclipWebhookUrls(e);return await r.default.mediaManager.createMediaObject(t,"video/mp4")}async generateThumbnail(e){const t=await r.default.mediaManager.createFFmpegMediaObject({inputArguments:["-ss","00:00:05","-i",e]});return await r.default.mediaManager.convertMediaObjectToBuffer(t,"image/jpeg")}async findFtpThumbnail(e){const t=e.split(".")[0].split("_"),i=Number(t[t.length-1]),n=this.fileNamePrefix,o=p.default.dirname(e),r=this.getLogger();let s;try{const t=l.default.readdirSync(o).filter((e=>{if(!(e.endsWith(".jpg")&&e.includes(n)))return!1;const t=e.split(".")[0].split("_"),o=Number(t[t.length-1]);if(i===o)return s=e,!0;return Math.abs(o-i)<=200})),a=s??t[0];if(a){const t=p.default.join(this.storageSettings.values.ftpFolder,a),i=await l.default.promises.readFile(t);return i.length>0?(r.debug(`Found thumbnail buffer for video ${e}: ${i.length} bytes`),i):(r.warn(`Thumbnail file is empty: ${t}`),null)}return r.debug(`No thumbnail found for video: ${e}`),null}catch(t){return r.error(`Error reading thumbnail for video ${e}:`,t),null}}async getVideoClipThumbnail(e,t){const i=this.getLogger(),{thumbnailUrl:n}=await this.getVideoclipParams(e);i.log(`Fetching thumbnailId ${e} from ${n}`);try{const{ftp:t}=this.storageSettings.values;if(t){const e=u.default.pathToFileURL(n).toString();return await r.default.mediaManager.createMediaObjectFromUrl(e)}if(l.default.existsSync(n)){const e=u.default.pathToFileURL(n).toString();return await r.default.mediaManager.createMediaObjectFromUrl(e)}return i.log(`Thumbnail ${n} not found, adding to generation queue.`),this.plugin.thumbnailsToGenerate.push({thumbnailId:e,deviceId:this.id}),null}catch(t){return i.error(`Error retrieving thumbnail of videoclip ${e}`,t),null}}getFtpParsedDirectory(){const{ftpFolder:e}=this.storageSettings.values;return p.default.join(e,"parsed",this.id)}async getVideoclipParams(e){const{ftp:t,ftpFolder:i}=this.storageSettings.values,{thumbnailFolder:n}=(0,m.getFolderPaths)(this.id,this.camera.plugin.storageSettings.values.downloadFolder);let o,r;if(t){o=e;const t=p.default.join(i,"parsed",this.id);if(e){const[i]=e.split("/").pop().split(".")[0].split("_");r=p.default.join(t,`${i}.jpeg`)}}else{const t=await this.getClient();if(e){const{downloadPathWithHost:i}=await t.getVideoClipUrl(e,this.camera.getRtspChannel());o=i;const s=`${e.split("/").pop().split(".")[0]}`.replaceAll(" ","_");r=p.default.join(n,`${s}.jpeg`)}}return{videoclipUrl:o,thumbnailFolder:n,thumbnailUrl:r}}removeVideoClips(...e){throw new Error("Method not implemented.")}async getMixinSettings(){const e=this.storageSettings.values.ftp;this.storageSettings.settings.filenamePrefix.hide=!e,this.storageSettings.settings.ftpFolder.hide=!e,this.storageSettings.settings.maxSpaceInGb.hide=!e,this.storageSettings.settings.occupiedSpaceInGb.hide=!e;return await this.storageSettings.getSettings()}async putMixinSetting(e,t){this.storage.setItem(e,"string"==typeof t?t:JSON.stringify(t))}}t.default=y},181:e=>{"use strict";e.exports=require("buffer")},320:e=>{e.exports=function(e){var t="function"==typeof setImmediate?setImmediate:"object"==typeof process&&"function"==typeof process.nextTick?process.nextTick:null;t?t(e):setTimeout(e,0)}},336:(e,t,i)=>{"use strict";var n,o,r,s=i(7701),a=i(6928).extname,c=/^\s*([^;\s]*)(?:;|\s|$)/,l=/^text\//i;function p(e){if(!e||"string"!=typeof e)return!1;var t=c.exec(e),i=t&&s[t[1].toLowerCase()];return i&&i.charset?i.charset:!(!t||!l.test(t[1]))&&"UTF-8"}t.charset=p,t.charsets={lookup:p},t.contentType=function(e){if(!e||"string"!=typeof e)return!1;var i=-1===e.indexOf("/")?t.lookup(e):e;if(!i)return!1;if(-1===i.indexOf("charset")){var n=t.charset(i);n&&(i+="; charset="+n.toLowerCase())}return i},t.extension=function(e){if(!e||"string"!=typeof e)return!1;var i=c.exec(e),n=i&&t.extensions[i[1].toLowerCase()];if(!n||!n.length)return!1;return n[0]},t.extensions=Object.create(null),t.lookup=function(e){if(!e||"string"!=typeof e)return!1;var i=a("x."+e).toLowerCase().substr(1);if(!i)return!1;return t.types[i]||!1},t.types=Object.create(null),n=t.extensions,o=t.types,r=["nginx","apache",void 0,"iana"],Object.keys(s).forEach((function(e){var t=s[e],i=t.extensions;if(i&&i.length){n[e]=i;for(var a=0;a<i.length;a++){var c=i[a];if(o[c]){var l=r.indexOf(s[o[c]].source),p=r.indexOf(t.source);if("application/octet-stream"!==o[c]&&(l>p||l===p&&"application/"===o[c].substr(0,12)))continue}o[c]=e}}}))},409:e=>{e.exports=class{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}}},529:function(e){(function(){var t=function(e,t){return function(){return e.apply(t,arguments)}},i={}.hasOwnProperty;e.exports=function(){function e(e){var n,o,r;for(n in this.assertLegalName=t(this.assertLegalName,this),this.assertLegalChar=t(this.assertLegalChar,this),e||(e={}),this.options=e,this.options.version||(this.options.version="1.0"),o=e.stringify||{})i.call(o,n)&&(r=o[n],this[n]=r)}return e.prototype.name=function(e){return this.options.noValidation?e:this.assertLegalName(""+e||"")},e.prototype.text=function(e){return this.options.noValidation?e:this.assertLegalChar(this.textEscape(""+e||""))},e.prototype.cdata=function(e){return this.options.noValidation?e:(e=(e=""+e||"").replace("]]>","]]]]><![CDATA[>"),this.assertLegalChar(e))},e.prototype.comment=function(e){if(this.options.noValidation)return e;if((e=""+e||"").match(/--/))throw new Error("Comment text cannot contain double-hypen: "+e);return this.assertLegalChar(e)},e.prototype.raw=function(e){return this.options.noValidation?e:""+e||""},e.prototype.attValue=function(e){return this.options.noValidation?e:this.assertLegalChar(this.attEscape(e=""+e||""))},e.prototype.insTarget=function(e){return this.options.noValidation?e:this.assertLegalChar(""+e||"")},e.prototype.insValue=function(e){if(this.options.noValidation)return e;if((e=""+e||"").match(/\?>/))throw new Error("Invalid processing instruction value: "+e);return this.assertLegalChar(e)},e.prototype.xmlVersion=function(e){if(this.options.noValidation)return e;if(!(e=""+e||"").match(/1\.[0-9]+/))throw new Error("Invalid version number: "+e);return e},e.prototype.xmlEncoding=function(e){if(this.options.noValidation)return e;if(!(e=""+e||"").match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/))throw new Error("Invalid encoding: "+e);return this.assertLegalChar(e)},e.prototype.xmlStandalone=function(e){return this.options.noValidation?e:e?"yes":"no"},e.prototype.dtdPubID=function(e){return this.options.noValidation?e:this.assertLegalChar(""+e||"")},e.prototype.dtdSysID=function(e){return this.options.noValidation?e:this.assertLegalChar(""+e||"")},e.prototype.dtdElementValue=function(e){return this.options.noValidation?e:this.assertLegalChar(""+e||"")},e.prototype.dtdAttType=function(e){return this.options.noValidation?e:this.assertLegalChar(""+e||"")},e.prototype.dtdAttDefault=function(e){return this.options.noValidation?e:this.assertLegalChar(""+e||"")},e.prototype.dtdEntityValue=function(e){return this.options.noValidation?e:this.assertLegalChar(""+e||"")},e.prototype.dtdNData=function(e){return this.options.noValidation?e:this.assertLegalChar(""+e||"")},e.prototype.convertAttKey="@",e.prototype.convertPIKey="?",e.prototype.convertTextKey="#text",e.prototype.convertCDataKey="#cdata",e.prototype.convertCommentKey="#comment",e.prototype.convertRawKey="#raw",e.prototype.assertLegalChar=function(e){var t,i;if(this.options.noValidation)return e;if(t="","1.0"===this.options.version){if(t=/[\0-\x08\x0B\f\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,i=e.match(t))throw new Error("Invalid character in string: "+e+" at index "+i.index)}else if("1.1"===this.options.version&&(t=/[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,i=e.match(t)))throw new Error("Invalid character in string: "+e+" at index "+i.index);return e},e.prototype.assertLegalName=function(e){var t;if(this.options.noValidation)return e;if(this.assertLegalChar(e),t=/^([:A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])([\x2D\.0-:A-Z_a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*$/,!e.match(t))throw new Error("Invalid character in name");return e},e.prototype.textEscape=function(e){var t;return this.options.noValidation?e:(t=this.options.noDoubleEncoding?/(?!&\S+;)&/g:/&/g,e.replace(t,"&").replace(/</g,"<").replace(/>/g,">").replace(/\r/g,"
"))},e.prototype.attEscape=function(e){var t;return this.options.noValidation?e:(t=this.options.noDoubleEncoding?/(?!&\S+;)&/g:/&/g,e.replace(t,"&").replace(/</g,"<").replace(/"/g,""").replace(/\t/g,"	").replace(/\n/g,"
").replace(/\r/g,"
"))},e}()}).call(this)},541:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=i(1364),o=i(9086);t.default=(e,t)=>{const{options:i}=e,r=i.protocolVersion,s=5===r?t.reasonCode:t.returnCode;if(5===r)e.handleAuth(t,((t,i)=>{if(t)e.emit("error",t);else if(24===s)e.reconnecting=!1,e._sendPacket(i);else{const t=new n.ErrorWithReasonCode(`Connection refused: ${o.ReasonCodes[s]}`,s);e.emit("error",t)}}));else{const t=new n.ErrorWithReasonCode(`Protocol error: Auth packets are only supported in MQTT 5. Your version:${r}`,s);e.emit("error",t)}}},546:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sleep=async function(e){await new Promise((t=>setTimeout(t,e)))}},577:(e,t,i)=>{"use strict";const n=i(7097),{aggregateTwoErrors:o,codes:{ERR_MULTIPLE_CALLBACK:r},AbortError:s}=i(676),{Symbol:a}=i(3383),{kIsDestroyed:c,isDestroyed:l,isFinished:p,isServerRequest:u}=i(6274),d=a("kDestroy"),h=a("kConstruct");function m(e,t,i){e&&(e.stack,t&&!t.errored&&(t.errored=e),i&&!i.errored&&(i.errored=e))}function f(e,t,i){let o=!1;function r(t){if(o)return;o=!0;const r=e._readableState,s=e._writableState;m(t,s,r),s&&(s.closed=!0),r&&(r.closed=!0),"function"==typeof i&&i(t),t?n.nextTick(g,e,t):n.nextTick(v,e)}try{e._destroy(t||null,r)}catch(t){r(t)}}function g(e,t){y(e,t),v(e)}function v(e){const t=e._readableState,i=e._writableState;i&&(i.closeEmitted=!0),t&&(t.closeEmitted=!0),(null!=i&&i.emitClose||null!=t&&t.emitClose)&&e.emit("close")}function y(e,t){const i=e._readableState,n=e._writableState;null!=n&&n.errorEmitted||null!=i&&i.errorEmitted||(n&&(n.errorEmitted=!0),i&&(i.errorEmitted=!0),e.emit("error",t))}function b(e,t,i){const o=e._readableState,r=e._writableState;if(null!=r&&r.destroyed||null!=o&&o.destroyed)return this;null!=o&&o.autoDestroy||null!=r&&r.autoDestroy?e.destroy(t):t&&(t.stack,r&&!r.errored&&(r.errored=t),o&&!o.errored&&(o.errored=t),i?n.nextTick(y,e,t):y(e,t))}function w(e){let t=!1;function i(i){if(t)return void b(e,null!=i?i:new r);t=!0;const o=e._readableState,s=e._writableState,a=s||o;o&&(o.constructed=!0),s&&(s.constructed=!0),a.destroyed?e.emit(d,i):i?b(e,i,!0):n.nextTick(_,e)}try{e._construct((e=>{n.nextTick(i,e)}))}catch(e){n.nextTick(i,e)}}function _(e){e.emit(h)}function S(e){return(null==e?void 0:e.setHeader)&&"function"==typeof e.abort}function x(e){e.emit("close")}function T(e,t){e.emit("error",t),n.nextTick(x,e)}e.exports={construct:function(e,t){if("function"!=typeof e._construct)return;const i=e._readableState,o=e._writableState;i&&(i.constructed=!1),o&&(o.constructed=!1),e.once(h,t),e.listenerCount(h)>1||n.nextTick(w,e)},destroyer:function(e,t){e&&!l(e)&&(t||p(e)||(t=new s),u(e)?(e.socket=null,e.destroy(t)):S(e)?e.abort():S(e.req)?e.req.abort():"function"==typeof e.destroy?e.destroy(t):"function"==typeof e.close?e.close():t?n.nextTick(T,e,t):n.nextTick(x,e),e.destroyed||(e[c]=!0))},destroy:function(e,t){const i=this._readableState,n=this._writableState,r=n||i;return null!=n&&n.destroyed||null!=i&&i.destroyed?("function"==typeof t&&t(),this):(m(e,n,i),n&&(n.destroyed=!0),i&&(i.destroyed=!0),r.constructed?f(this,e,t):this.once(d,(function(i){f(this,o(i,e),t)})),this)},undestroy:function(){const e=this._readableState,t=this._writableState;e&&(e.constructed=!0,e.closed=!1,e.closeEmitted=!1,e.destroyed=!1,e.errored=null,e.errorEmitted=!1,e.reading=!1,e.ended=!1===e.readable,e.endEmitted=!1===e.readable),t&&(t.constructed=!0,t.destroyed=!1,t.closed=!1,t.closeEmitted=!1,t.errored=null,t.errorEmitted=!1,t.finalCalled=!1,t.prefinished=!1,t.ended=!1===t.writable,t.ending=!1===t.writable,t.finished=!1===t.writable)},errorOrDestroy:b}},581:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=i(5825);class o extends n.EventTarget{constructor(){throw super(),new TypeError("AbortSignal cannot be constructed directly")}get aborted(){const e=r.get(this);if("boolean"!=typeof e)throw new TypeError("Expected 'this' to be an 'AbortSignal' object, but got "+(null===this?"null":typeof this));return e}}n.defineEventAttribute(o.prototype,"abort");const r=new WeakMap;Object.defineProperties(o.prototype,{aborted:{enumerable:!0}}),"function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(o.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortSignal"});class s{constructor(){a.set(this,function(){const e=Object.create(o.prototype);return n.EventTarget.call(e),r.set(e,!1),e}())}get signal(){return c(this)}abort(){var e;e=c(this),!1===r.get(e)&&(r.set(e,!0),e.dispatchEvent({type:"abort"}))}}const a=new WeakMap;function c(e){const t=a.get(e);if(null==t)throw new TypeError("Expected 'this' to be an 'AbortController' object, but got "+(null===e?"null":typeof e));return t}Object.defineProperties(s.prototype,{signal:{enumerable:!0},abort:{enumerable:!0}}),"function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(s.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortController"}),t.AbortController=s,t.AbortSignal=o,t.default=s,e.exports=s,e.exports.AbortController=e.exports.default=s,e.exports.AbortSignal=o},614:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createAuthFetch=function(e,t){return async r=>{const s=(0,n.getFetchMethod)(r),a=(0,n.createHeadersArray)(r.headers);r.headers=a,(0,n.setDefaultHttpFetchAccept)(a,r.responseType);const c=await o(r,r.url,s);c&&!(0,n.hasHeader)(a,"Authorization")&&(0,n.setHeader)(a,"Authorization",c);const l=new AbortController;r.signal?.addEventListener("abort",(()=>l.abort(r.signal?.reason)));const p=await e({...r,signal:l.signal,checkStatusCode(e){if(401===e&&r.credential)return!0;if(void 0===r?.checkStatusCode||r?.checkStatusCode){return("function"==typeof r?.checkStatusCode?r.checkStatusCode:n.checkStatus)(e)}return!0},responseType:"readable"});if(401!==p.statusCode)return{...p,body:await t(p.body,r.responseType)};let u=p.headers.get("www-authenticate");if(!u)throw new Error("Did not find WWW-Authenticate header.");"string"==typeof u&&(u=[u]);const{BASIC:d,DIGEST:h,parseWWWAuthenticateHeader:m}=await Promise.resolve().then(i.bind(i,7917)),f=u.map((e=>m(e))),g=f.find((e=>"Digest"===e.type)),v=f.find((e=>"Basic"===e.type)),y=r.credential;if(y.digest=g,y.basic=v,!g&&!v)throw new Error(`Unknown WWW-Authenticate type: ${f[0]?.type}`);const b=await o(r,r.url,s);return b&&(0,n.setHeader)(a,"Authorization",b),e(r)}};const n=i(4426);async function o(e,t,n){if(!e.credential)return;const{BASIC:o,DIGEST:r,parseWWWAuthenticateHeader:s}=await Promise.resolve().then(i.bind(i,7917)),a=e.credential,{digest:c,basic:l}=a;if(c){a.count||=0,++a.count;const o=("00000000"+a.count).slice(-8),r=[...Array(24)].map((()=>Math.floor(16*Math.random()).toString(16))).join(""),s=new URL(t),l=s.pathname+s.search,{DIGEST:p,buildAuthorizationHeader:u}=await Promise.resolve().then(i.bind(i,7917)),d=p.computeHash({username:e.credential.username,password:e.credential.password,method:n,uri:l,nc:o,cnonce:r,algorithm:"MD5",qop:c.data.qop,...c.data});return u(p,{username:e.credential.username,uri:l,nc:o,cnonce:r,algorithm:c.data.algorithm,qop:c.data.qop,response:d,...c.data})}if(l){const{BASIC:t,buildAuthorizationHeader:n}=await Promise.resolve().then(i.bind(i,7917));return n(t,{username:e.credential.username,password:e.credential.password})}}},617:(e,t)=>{"use strict";function i(e){const t=e.split("/");for(let e=0;e<t.length;e++)if("+"!==t[e]){if("#"===t[e])return e===t.length-1;if(-1!==t[e].indexOf("+")||-1!==t[e].indexOf("#"))return!1}return!0}Object.defineProperty(t,"__esModule",{value:!0}),t.validateTopics=t.validateTopic=void 0,t.validateTopic=i,t.validateTopics=function(e){if(0===e.length)return"empty_topic_list";for(let t=0;t<e.length;t++)if(!i(e[t]))return e[t];return null}},661:function(e,t,i){(function(){var t,n={}.hasOwnProperty;t=i(8945),e.exports=function(e){function t(e){t.__super__.constructor.call(this,e)}return function(e,t){for(var i in t)n.call(t,i)&&(e[i]=t[i]);function o(){this.constructor=e}o.prototype=t.prototype,e.prototype=new o,e.__super__=t.prototype}(t,e),t.prototype.document=function(e,t){var i,n,o,r,s;for(t=this.filterOptions(t),r="",n=0,o=(s=e.children).length;n<o;n++)i=s[n],r+=this.writeChildNode(i,t,0);return t.pretty&&r.slice(-t.newline.length)===t.newline&&(r=r.slice(0,-t.newline.length)),r},t}(t)}).call(this)},676:(e,t,i)=>{"use strict";const{format:n,inspect:o,AggregateError:r}=i(3939),s=globalThis.AggregateError||r,a=Symbol("kIsNodeError"),c=["string","function","number","object","Function","Object","boolean","bigint","symbol"],l=/^([A-Z][a-z0-9]*)+$/,p={};function u(e,t){if(!e)throw new p.ERR_INTERNAL_ASSERTION(t)}function d(e){let t="",i=e.length;const n="-"===e[0]?1:0;for(;i>=n+4;i-=3)t=`_${e.slice(i-3,i)}${t}`;return`${e.slice(0,i)}${t}`}function h(e,t,i){i||(i=Error);class o extends i{constructor(...i){super(function(e,t,i){if("function"==typeof t)return u(t.length<=i.length,`Code: ${e}; The provided arguments length (${i.length}) does not match the required ones (${t.length}).`),t(...i);const o=(t.match(/%[dfijoOs]/g)||[]).length;return u(o===i.length,`Code: ${e}; The provided arguments length (${i.length}) does not match the required ones (${o}).`),0===i.length?t:n(t,...i)}(e,t,i))}toString(){return`${this.name} [${e}]: ${this.message}`}}Object.defineProperties(o.prototype,{name:{value:i.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${e}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),o.prototype.code=e,o.prototype[a]=!0,p[e]=o}function m(e){const t="__node_internal_"+e.name;return Object.defineProperty(e,"name",{value:t}),e}class f extends Error{constructor(e="The operation was aborted",t=void 0){if(void 0!==t&&"object"!=typeof t)throw new p.ERR_INVALID_ARG_TYPE("options","Object",t);super(e,t),this.code="ABORT_ERR",this.name="AbortError"}}h("ERR_ASSERTION","%s",Error),h("ERR_INVALID_ARG_TYPE",((e,t,i)=>{u("string"==typeof e,"'name' must be a string"),Array.isArray(t)||(t=[t]);let n="The ";e.endsWith(" argument")?n+=`${e} `:n+=`"${e}" ${e.includes(".")?"property":"argument"} `,n+="must be ";const r=[],s=[],a=[];for(const e of t)u("string"==typeof e,"All expected entries have to be of type string"),c.includes(e)?r.push(e.toLowerCase()):l.test(e)?s.push(e):(u("object"!==e,'The value "object" should be written as "Object"'),a.push(e));if(s.length>0){const e=r.indexOf("object");-1!==e&&(r.splice(r,e,1),s.push("Object"))}if(r.length>0){switch(r.length){case 1:n+=`of type ${r[0]}`;break;case 2:n+=`one of type ${r[0]} or ${r[1]}`;break;default:{const e=r.pop();n+=`one of type ${r.join(", ")}, or ${e}`}}(s.length>0||a.length>0)&&(n+=" or ")}if(s.length>0){switch(s.length){case 1:n+=`an instance of ${s[0]}`;break;case 2:n+=`an instance of ${s[0]} or ${s[1]}`;break;default:{const e=s.pop();n+=`an instance of ${s.join(", ")}, or ${e}`}}a.length>0&&(n+=" or ")}switch(a.length){case 0:break;case 1:a[0].toLowerCase()!==a[0]&&(n+="an "),n+=`${a[0]}`;break;case 2:n+=`one of ${a[0]} or ${a[1]}`;break;default:{const e=a.pop();n+=`one of ${a.join(", ")}, or ${e}`}}if(null==i)n+=`. Received ${i}`;else if("function"==typeof i&&i.name)n+=`. Received function ${i.name}`;else if("object"==typeof i){var p;if(null!==(p=i.constructor)&&void 0!==p&&p.name)n+=`. Received an instance of ${i.constructor.name}`;else{n+=`. Received ${o(i,{depth:-1})}`}}else{let e=o(i,{colors:!1});e.length>25&&(e=`${e.slice(0,25)}...`),n+=`. Received type ${typeof i} (${e})`}return n}),TypeError),h("ERR_INVALID_ARG_VALUE",((e,t,i="is invalid")=>{let n=o(t);n.length>128&&(n=n.slice(0,128)+"...");return`The ${e.includes(".")?"property":"argument"} '${e}' ${i}. Received ${n}`}),TypeError),h("ERR_INVALID_RETURN_VALUE",((e,t,i)=>{var n;return`Expected ${e} to be returned from the "${t}" function but got ${null!=i&&null!==(n=i.constructor)&&void 0!==n&&n.name?`instance of ${i.constructor.name}`:"type "+typeof i}.`}),TypeError),h("ERR_MISSING_ARGS",((...e)=>{let t;u(e.length>0,"At least one arg needs to be specified");const i=e.length;switch(e=(Array.isArray(e)?e:[e]).map((e=>`"${e}"`)).join(" or "),i){case 1:t+=`The ${e[0]} argument`;break;case 2:t+=`The ${e[0]} and ${e[1]} arguments`;break;default:{const i=e.pop();t+=`The ${e.join(", ")}, and ${i} arguments`}}return`${t} must be specified`}),TypeError),h("ERR_OUT_OF_RANGE",((e,t,i)=>{let n;return u(t,'Missing "range" argument'),Number.isInteger(i)&&Math.abs(i)>2**32?n=d(String(i)):"bigint"==typeof i?(n=String(i),(i>2n**32n||i<-(2n**32n))&&(n=d(n)),n+="n"):n=o(i),`The value of "${e}" is out of range. It must be ${t}. Received ${n}`}),RangeError),h("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error),h("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error),h("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error),h("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error),h("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error),h("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),h("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error),h("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error),h("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error),h("ERR_STREAM_WRITE_AFTER_END","write after end",Error),h("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError),e.exports={AbortError:f,aggregateTwoErrors:m((function(e,t){if(e&&t&&e!==t){if(Array.isArray(t.errors))return t.errors.push(e),t;const i=new s([t,e],t.message);return i.code=t.code,i}return e||t})),hideStackFrames:m,codes:p}},770:(e,t,i)=>{const n=i(4298),{EventEmitter:o}=i(4434),r=i(409),s=i(7060),a=i(8766)("mqtt-packet:parser");class c extends o{constructor(){super(),this.parser=this.constructor.parser}static parser(e){return this instanceof c?(this.settings=e||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):(new c).parser(e)}_resetState(){a("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new r,this.error=null,this._list=n(),this._stateCounter=0}parse(e){for(this.error&&this._resetState(),this._list.append(e),a("parse: current state: %s",this._states[this._stateCounter]);(-1!==this.packet.length||this._list.length>0)&&this[this._states[this._stateCounter]]()&&!this.error;)this._stateCounter++,a("parse: state complete. _stateCounter is now: %d",this._stateCounter),a("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return a("parse: exited while loop. packet: %d, buffer list length: %d",this.packet.length,this._list.length),this._list.length}_parseHeader(){const e=this._list.readUInt8(0),t=e>>s.CMD_SHIFT;this.packet.cmd=s.types[t];const i=15&e,n=s.requiredHeaderFlags[t];return null!=n&&i!==n?this._emitError(new Error(s.requiredHeaderFlagsErrors[t])):(this.packet.retain=0!==(e&s.RETAIN_MASK),this.packet.qos=e>>s.QOS_SHIFT&s.QOS_MASK,this.packet.qos>2?this._emitError(new Error("Packet must not have both QoS bits set to 1")):(this.packet.dup=0!==(e&s.DUP_MASK),a("_parseHeader: packet: %o",this.packet),this._list.consume(1),!0))}_parseLength(){const e=this._parseVarByteNum(!0);return e&&(this.packet.length=e.value,this._list.consume(e.bytes)),a("_parseLength %d",e.value),!!e}_parsePayload(){a("_parsePayload: payload %O",this._list);let e=!1;if(0===this.packet.length||this._list.length>=this.packet.length){switch(this._pos=0,this.packet.cmd){case"connect":this._parseConnect();break;case"connack":this._parseConnack();break;case"publish":this._parsePublish();break;case"puback":case"pubrec":case"pubrel":case"pubcomp":this._parseConfirmation();break;case"subscribe":this._parseSubscribe();break;case"suback":this._parseSuback();break;case"unsubscribe":this._parseUnsubscribe();break;case"unsuback":this._parseUnsuback();break;case"pingreq":case"pingresp":break;case"disconnect":this._parseDisconnect();break;case"auth":this._parseAuth();break;default:this._emitError(new Error("Not supported"))}e=!0}return a("_parsePayload complete result: %s",e),e}_parseConnect(){let e,t,i,n;a("_parseConnect");const o={},r=this.packet,c=this._parseString();if(null===c)return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==c&&"MQIsdp"!==c)return this._emitError(new Error("Invalid protocolId"));if(r.protocolId=c,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(r.protocolVersion=this._list.readUInt8(this._pos),r.protocolVersion>=128&&(r.bridgeMode=!0,r.protocolVersion=r.protocolVersion-128),3!==r.protocolVersion&&4!==r.protocolVersion&&5!==r.protocolVersion)return this._emitError(new Error("Invalid protocol version"));if(this._pos++,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(1&this._list.readUInt8(this._pos))return this._emitError(new Error("Connect flag bit 0 must be 0, but got 1"));o.username=this._list.readUInt8(this._pos)&s.USERNAME_MASK,o.password=this._list.readUInt8(this._pos)&s.PASSWORD_MASK,o.will=this._list.readUInt8(this._pos)&s.WILL_FLAG_MASK;const l=!!(this._list.readUInt8(this._pos)&s.WILL_RETAIN_MASK),p=(this._list.readUInt8(this._pos)&s.WILL_QOS_MASK)>>s.WILL_QOS_SHIFT;if(o.will)r.will={},r.will.retain=l,r.will.qos=p;else{if(l)return this._emitError(new Error("Will Retain Flag must be set to zero when Will Flag is set to 0"));if(p)return this._emitError(new Error("Will QoS must be set to zero when Will Flag is set to 0"))}if(r.clean=0!==(this._list.readUInt8(this._pos)&s.CLEAN_SESSION_MASK),this._pos++,r.keepalive=this._parseNum(),-1===r.keepalive)return this._emitError(new Error("Packet too short"));if(5===r.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(r.properties=e)}const u=this._parseString();if(null===u)return this._emitError(new Error("Packet too short"));if(r.clientId=u,a("_parseConnect: packet.clientId: %s",r.clientId),o.will){if(5===r.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(r.will.properties=e)}if(e=this._parseString(),null===e)return this._emitError(new Error("Cannot parse will topic"));if(r.will.topic=e,a("_parseConnect: packet.will.topic: %s",r.will.topic),t=this._parseBuffer(),null===t)return this._emitError(new Error("Cannot parse will payload"));r.will.payload=t,a("_parseConnect: packet.will.paylaod: %s",r.will.payload)}if(o.username){if(n=this._parseString(),null===n)return this._emitError(new Error("Cannot parse username"));r.username=n,a("_parseConnect: packet.username: %s",r.username)}if(o.password){if(i=this._parseBuffer(),null===i)return this._emitError(new Error("Cannot parse password"));r.password=i}return this.settings=r,a("_parseConnect: complete"),r}_parseConnack(){a("_parseConnack");const e=this.packet;if(this._list.length<1)return null;const t=this._list.readUInt8(this._pos++);if(t>1)return this._emitError(new Error("Invalid connack flags, bits 7-1 must be set to 0"));if(e.sessionPresent=!!(t&s.SESSIONPRESENT_MASK),5===this.settings.protocolVersion)this._list.length>=2?e.reasonCode=this._list.readUInt8(this._pos++):e.reasonCode=0;else{if(this._list.length<2)return null;e.returnCode=this._list.readUInt8(this._pos++)}if(-1===e.returnCode||-1===e.reasonCode)return this._emitError(new Error("Cannot parse return code"));if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}a("_parseConnack: complete")}_parsePublish(){a("_parsePublish");const e=this.packet;if(e.topic=this._parseString(),null===e.topic)return this._emitError(new Error("Cannot parse topic"));if(!(e.qos>0)||this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}e.payload=this._list.slice(this._pos,e.length),a("_parsePublish: payload from buffer list: %o",e.payload)}}_parseSubscribe(){a("_parseSubscribe");const e=this.packet;let t,i,n,o,r,c,l;if(e.subscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}if(e.length<=0)return this._emitError(new Error("Malformed subscribe, no payload specified"));for(;this._pos<e.length;){if(t=this._parseString(),null===t)return this._emitError(new Error("Cannot parse topic"));if(this._pos>=e.length)return this._emitError(new Error("Malformed Subscribe Payload"));if(i=this._parseByte(),5===this.settings.protocolVersion){if(192&i)return this._emitError(new Error("Invalid subscribe topic flag bits, bits 7-6 must be 0"))}else if(252&i)return this._emitError(new Error("Invalid subscribe topic flag bits, bits 7-2 must be 0"));if(n=i&s.SUBSCRIBE_OPTIONS_QOS_MASK,n>2)return this._emitError(new Error("Invalid subscribe QoS, must be <= 2"));if(c=0!==(i>>s.SUBSCRIBE_OPTIONS_NL_SHIFT&s.SUBSCRIBE_OPTIONS_NL_MASK),r=0!==(i>>s.SUBSCRIBE_OPTIONS_RAP_SHIFT&s.SUBSCRIBE_OPTIONS_RAP_MASK),o=i>>s.SUBSCRIBE_OPTIONS_RH_SHIFT&s.SUBSCRIBE_OPTIONS_RH_MASK,o>2)return this._emitError(new Error("Invalid retain handling, must be <= 2"));l={topic:t,qos:n},5===this.settings.protocolVersion?(l.nl=c,l.rap=r,l.rh=o):this.settings.bridgeMode&&(l.rh=0,l.rap=!0,l.nl=!0),a("_parseSubscribe: push subscription `%s` to subscription",l),e.subscriptions.push(l)}}}_parseSuback(){a("_parseSuback");const e=this.packet;if(this.packet.granted=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}if(e.length<=0)return this._emitError(new Error("Malformed suback, no payload specified"));for(;this._pos<this.packet.length;){const e=this._list.readUInt8(this._pos++);if(5===this.settings.protocolVersion){if(!s.MQTT5_SUBACK_CODES[e])return this._emitError(new Error("Invalid suback code"))}else if(e>2&&128!==e)return this._emitError(new Error("Invalid suback QoS, must be 0, 1, 2 or 128"));this.packet.granted.push(e)}}}_parseUnsubscribe(){a("_parseUnsubscribe");const e=this.packet;if(e.unsubscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}if(e.length<=0)return this._emitError(new Error("Malformed unsubscribe, no payload specified"));for(;this._pos<e.length;){const t=this._parseString();if(null===t)return this._emitError(new Error("Cannot parse topic"));a("_parseUnsubscribe: push topic `%s` to unsubscriptions",t),e.unsubscriptions.push(t)}}}_parseUnsuback(){a("_parseUnsuback");const e=this.packet;if(!this._parseMessageId())return this._emitError(new Error("Cannot parse messageId"));if((3===this.settings.protocolVersion||4===this.settings.protocolVersion)&&2!==e.length)return this._emitError(new Error("Malformed unsuback, payload length must be 2"));if(e.length<=0)return this._emitError(new Error("Malformed unsuback, no payload specified"));if(5===this.settings.protocolVersion){const t=this._parseProperties();for(Object.getOwnPropertyNames(t).length&&(e.properties=t),e.granted=[];this._pos<this.packet.length;){const e=this._list.readUInt8(this._pos++);if(!s.MQTT5_UNSUBACK_CODES[e])return this._emitError(new Error("Invalid unsuback code"));this.packet.granted.push(e)}}}_parseConfirmation(){a("_parseConfirmation: packet.cmd: `%s`",this.packet.cmd);const e=this.packet;if(this._parseMessageId(),5===this.settings.protocolVersion){if(e.length>2){switch(e.reasonCode=this._parseByte(),this.packet.cmd){case"puback":case"pubrec":if(!s.MQTT5_PUBACK_PUBREC_CODES[e.reasonCode])return this._emitError(new Error("Invalid "+this.packet.cmd+" reason code"));break;case"pubrel":case"pubcomp":if(!s.MQTT5_PUBREL_PUBCOMP_CODES[e.reasonCode])return this._emitError(new Error("Invalid "+this.packet.cmd+" reason code"))}a("_parseConfirmation: packet.reasonCode `%d`",e.reasonCode)}else e.reasonCode=0;if(e.length>3){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}}return!0}_parseDisconnect(){const e=this.packet;if(a("_parseDisconnect"),5===this.settings.protocolVersion){this._list.length>0?(e.reasonCode=this._parseByte(),s.MQTT5_DISCONNECT_CODES[e.reasonCode]||this._emitError(new Error("Invalid disconnect reason code"))):e.reasonCode=0;const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return a("_parseDisconnect result: true"),!0}_parseAuth(){a("_parseAuth");const e=this.packet;if(5!==this.settings.protocolVersion)return this._emitError(new Error("Not supported auth packet for this version MQTT"));if(e.reasonCode=this._parseByte(),!s.MQTT5_AUTH_CODES[e.reasonCode])return this._emitError(new Error("Invalid auth reason code"));const t=this._parseProperties();return Object.getOwnPropertyNames(t).length&&(e.properties=t),a("_parseAuth: result: true"),!0}_parseMessageId(){const e=this.packet;return e.messageId=this._parseNum(),null===e.messageId?(this._emitError(new Error("Cannot parse messageId")),!1):(a("_parseMessageId: packet.messageId %d",e.messageId),!0)}_parseString(e){const t=this._parseNum(),i=t+this._pos;if(-1===t||i>this._list.length||i>this.packet.length)return null;const n=this._list.toString("utf8",this._pos,i);return this._pos+=t,a("_parseString: result: %s",n),n}_parseStringPair(){return a("_parseStringPair"),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){const e=this._parseNum(),t=e+this._pos;if(-1===e||t>this._list.length||t>this.packet.length)return null;const i=this._list.slice(this._pos,t);return this._pos+=e,a("_parseBuffer: result: %o",i),i}_parseNum(){if(this._list.length-this._pos<2)return-1;const e=this._list.readUInt16BE(this._pos);return this._pos+=2,a("_parseNum: result: %s",e),e}_parse4ByteNum(){if(this._list.length-this._pos<4)return-1;const e=this._list.readUInt32BE(this._pos);return this._pos+=4,a("_parse4ByteNum: result: %s",e),e}_parseVarByteNum(e){a("_parseVarByteNum");let t,i=0,n=1,o=0,r=!1;const c=this._pos?this._pos:0;for(;i<4&&c+i<this._list.length;){if(t=this._list.readUInt8(c+i++),o+=n*(t&s.VARBYTEINT_MASK),n*=128,0===(t&s.VARBYTEINT_FIN_MASK)){r=!0;break}if(this._list.length<=i)break}return!r&&4===i&&this._list.length>=i&&this._emitError(new Error("Invalid variable byte integer")),c&&(this._pos+=i),r=!!r&&(e?{bytes:i,value:o}:o),a("_parseVarByteNum: result: %o",r),r}_parseByte(){let e;return this._pos<this._list.length&&(e=this._list.readUInt8(this._pos),this._pos++),a("_parseByte: result: %o",e),e}_parseByType(e){switch(a("_parseByType: type: %s",e),e){case"byte":return 0!==this._parseByte();case"int8":return this._parseByte();case"int16":return this._parseNum();case"int32":return this._parse4ByteNum();case"var":return this._parseVarByteNum();case"string":return this._parseString();case"pair":return this._parseStringPair();case"binary":return this._parseBuffer()}}_parseProperties(){a("_parseProperties");const e=this._parseVarByteNum(),t=this._pos+e,i={};for(;this._pos<t;){const e=this._parseByte();if(!e)return this._emitError(new Error("Cannot parse property code type")),!1;const t=s.propertiesCodes[e];if(!t)return this._emitError(new Error("Unknown property")),!1;if("userProperties"!==t)i[t]?(Array.isArray(i[t])||(i[t]=[i[t]]),i[t].push(this._parseByType(s.propertiesTypes[t]))):i[t]=this._parseByType(s.propertiesTypes[t]);else{i[t]||(i[t]=Object.create(null));const e=this._parseByType(s.propertiesTypes[t]);if(i[t][e.name])if(Array.isArray(i[t][e.name]))i[t][e.name].push(e.value);else{const n=i[t][e.name];i[t][e.name]=[n],i[t][e.name].push(e.value)}else i[t][e.name]=e.value}}return i}_newPacket(){return a("_newPacket"),this.packet&&(this._list.consume(this.packet.length),a("_newPacket: parser emit packet: packet.cmd: %s, packet.payload: %s, packet.length: %d",this.packet.cmd,this.packet.payload,this.packet.length),this.emit("packet",this.packet)),a("_newPacket: new packet"),this.packet=new r,this._pos=0,!0}_emitError(e){a("_emitError",e),this.error=e,this.emit("error",e)}}e.exports=c},838:function(e,t,i){(function(){var t,n,o={}.hasOwnProperty;t=i(5068),n=i(4472),e.exports=function(e){function i(e,n,o){if(i.__super__.constructor.call(this,e),null==n)throw new Error("Missing instruction target. "+this.debugInfo());this.type=t.ProcessingInstruction,this.target=this.stringify.insTarget(n),this.name=this.target,o&&(this.value=this.stringify.insValue(o))}return function(e,t){for(var i in t)o.call(t,i)&&(e[i]=t[i]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(i,e),i.prototype.clone=function(){return Object.create(this)},i.prototype.toString=function(e){return this.options.writer.processingInstruction(this,this.options.writer.filterOptions(e))},i.prototype.isEqualNode=function(e){return!!i.__super__.isEqualNode.apply(this,arguments).isEqualNode(e)&&e.target===this.target},i}(n)}).call(this)},857:e=>{"use strict";e.exports=require("os")},871:function(e,t,i){(function(){var t,n,o={}.hasOwnProperty;n=i(8711),t=i(5068),e.exports=function(e){function i(e){i.__super__.constructor.call(this,e),this.type=t.Dummy}return function(e,t){for(var i in t)o.call(t,i)&&(e[i]=t[i]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(i,e),i.prototype.clone=function(){return Object.create(this)},i.prototype.toString=function(e){return""},i}(n)}).call(this)},890:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Deferred=void 0;class i{constructor(){this.finished=!1,this.promise=new Promise(((e,t)=>{this.resolve=t=>(this.finished=!0,e(t),this),this.reject=e=>(this.finished=!0,t(e),this)}))}[Symbol.dispose](){this.finished||this.reject(new Error("deferred disposed without being resolved"))}async resolvePromise(e){try{this.resolve(await e)}catch(e){this.reject(e)}}}t.Deferred=i},932:e=>{"use strict";e.exports=require("process")},1091:function(e,t,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t},s=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||n(t,e,i)},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ReasonCodes=t.KeepaliveManager=t.UniqueMessageIdProvider=t.DefaultMessageIdProvider=t.Store=t.MqttClient=t.connectAsync=t.connect=t.Client=void 0;const c=a(i(1786));t.MqttClient=c.default;const l=a(i(2574));t.DefaultMessageIdProvider=l.default;const p=a(i(1956));t.UniqueMessageIdProvider=p.default;const u=a(i(6344));t.Store=u.default;const d=r(i(1784));t.connect=d.default,Object.defineProperty(t,"connectAsync",{enumerable:!0,get:function(){return d.connectAsync}});const h=a(i(2444));t.KeepaliveManager=h.default,t.Client=c.default,s(i(1786),t),s(i(1364),t);var m=i(9086);Object.defineProperty(t,"ReasonCodes",{enumerable:!0,get:function(){return m.ReasonCodes}})},1092:function(e,t,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||n(t,e,i)};Object.defineProperty(t,"__esModule",{value:!0}),o(i(114),t),o(i(9150),t),o(i(4770),t),o(i(3417),t),o(i(4563),t),o(i(6465),t),o(i(1743),t),o(i(8726),t)},1172:(e,t,i)=>{"use strict";const{tokenChars:n}=i(3271);e.exports={parse:function(e){const t=new Set;let i=-1,o=-1,r=0;for(;r<e.length;r++){const s=e.charCodeAt(r);if(-1===o&&1===n[s])-1===i&&(i=r);else if(0===r||32!==s&&9!==s){if(44!==s)throw new SyntaxError(`Unexpected character at index ${r}`);{if(-1===i)throw new SyntaxError(`Unexpected character at index ${r}`);-1===o&&(o=r);const n=e.slice(i,o);if(t.has(n))throw new SyntaxError(`The "${n}" subprotocol is duplicated`);t.add(n),i=o=-1}}else-1===o&&-1!==i&&(o=r)}if(-1===i||-1!==o)throw new SyntaxError("Unexpected end of input");const s=e.slice(i,r);if(t.has(s))throw new SyntaxError(`The "${s}" subprotocol is duplicated`);return t.add(s),t}}},1364:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MQTTJS_VERSION=t.nextTick=t.applyMixin=t.ErrorWithReasonCode=void 0;class n extends Error{constructor(e,t){super(e),this.code=t,Object.setPrototypeOf(this,n.prototype),Object.getPrototypeOf(this).name="ErrorWithReasonCode"}}t.ErrorWithReasonCode=n,t.applyMixin=function(e,t,i=!1){var n;const o=[t];for(;;){const e=o[0],t=Object.getPrototypeOf(e);if(!(null==t?void 0:t.prototype))break;o.unshift(t)}for(const t of o)for(const o of Object.getOwnPropertyNames(t.prototype))(i||"constructor"!==o)&&Object.defineProperty(e.prototype,o,null!==(n=Object.getOwnPropertyDescriptor(t.prototype,o))&&void 0!==n?n:Object.create(null))},t.nextTick="function"==typeof(null===process||void 0===process?void 0:process.nextTick)?process.nextTick:e=>{setTimeout(e,0)},t.MQTTJS_VERSION=i(6845).version},1373:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createAsyncQueue=r,t.createAsyncQueueFromGenerator=function(e){const t=r();return(async()=>{try{for await(const i of e)await t.enqueue(i)}catch(e){t.end(e)}t.end()})(),t};const n=i(890);class o extends Error{}function r(){let e;const t=new n.Deferred,i=[],r=[],s=async()=>{if(r.length){const{item:e,dequeued:t}=r.shift();return t?.resolve(),e}if(e)throw e;const t=new n.Deferred;return i.push(t),t.promise},a=(t,o,s)=>{if(e)return!1;if(i.length){const e=i.shift();return o?.resolve(),e.resolve(t),!0}s&&(o||=new n.Deferred);const a={item:t,dequeued:o};if(r.push(a),!s)return!0;const c=()=>{const e=r.indexOf(a);-1!==e&&(r.splice(e,1),o?.reject(new Error("abort")))};return o?.promise.catch((()=>{})).finally((()=>s.removeEventListener("abort",c))),s.addEventListener("abort",c),!0};function c(n){if(e)return!1;for(e=n||new o,t.resolve();i.length;)i.shift().reject(e);return!0}function l(){return async function*(){try{for(;;)try{const e=await s();yield e}catch(e){if(c(e),e instanceof o)return;throw e}}finally{c()}}()}return{[Symbol.dispose](){c(new Error("async queue disposed"))},get ended(){return e},endPromise:t.promise,take:()=>{if(r.length){const{item:e,dequeued:t}=r.shift();return t?.resolve(),e}if(e)throw e},clear:()=>function(e){const t=[],i=r.splice(0,r.length);for(const n of i)e?n.dequeued?.reject(e):n.dequeued?.resolve(void 0),t.push(n.item);return t}(),queued:r,async pipe(e){for await(const t of l())e(t)},submit:(e,t)=>a(e,void 0,t),end:c,async enqueue(e,t){const i=new n.Deferred;return!!a(e,i,t)&&(await i.promise,!0)},dequeue:s,get queue(){return l()}}}},1510:function(e){(function(){e.exports={Disconnected:1,Preceding:2,Following:4,Contains:8,ContainedBy:16,ImplementationSpecific:32}}).call(this)},1516:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{constructor(e){this.aliasToTopic={},this.max=e}put(e,t){return!(0===t||t>this.max)&&(this.aliasToTopic[t]=e,this.length=Object.keys(this.aliasToTopic).length,!0)}getTopicByAlias(e){return this.aliasToTopic[e]}clear(){this.aliasToTopic={}}}},1535:(e,t,i)=>{t.parser=i(770).parser,t.generate=i(6962),t.writeToStream=i(2695)},1543:function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(i(9278)),r=(0,n(i(8766)).default)("mqttjs:tcp");t.default=(e,t)=>{t.port=t.port||1883,t.hostname=t.hostname||t.host||"localhost";const{port:i,path:n}=t,s=t.hostname;return r("port %d and host %s",i,s),o.default.createConnection({port:i,host:s,path:n})}},1564:(e,t,i)=>{"use strict";const{SymbolDispose:n}=i(3383),{AbortError:o,codes:r}=i(676),{isNodeStream:s,isWebStream:a,kControllerErrorFunction:c}=i(6274),l=i(9071),{ERR_INVALID_ARG_TYPE:p}=r;let u;e.exports.addAbortSignal=function(t,i){if(((e,t)=>{if("object"!=typeof e||!("aborted"in e))throw new p(t,"AbortSignal",e)})(t,"signal"),!s(i)&&!a(i))throw new p("stream",["ReadableStream","WritableStream","Stream"],i);return e.exports.addAbortSignalNoValidate(t,i)},e.exports.addAbortSignalNoValidate=function(e,t){if("object"!=typeof e||!("aborted"in e))return t;const r=s(t)?()=>{t.destroy(new o(void 0,{cause:e.reason}))}:()=>{t[c](new o(void 0,{cause:e.reason}))};if(e.aborted)r();else{u=u||i(3939).addAbortListener;const o=u(e,r);l(t,o[n])}return t}},1687:function(e,t,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||n(t,e,i)};Object.defineProperty(t,"__esModule",{value:!0}),t.sdk=t.MixinDeviceBase=t.ScryptedDeviceBase=void 0,o(i(8281),t);const r=i(8281);i(3339);class s extends r.DeviceBase{constructor(e){super(),this.nativeId=e}get storage(){return this._storage||(this._storage=t.sdk.deviceManager.getDeviceStorage(this.nativeId)),this._storage}get log(){return this._log||(this._log=t.sdk.deviceManager.getDeviceLogger(this.nativeId)),this._log}get console(){return this._console||(this._console=t.sdk.deviceManager.getDeviceConsole(this.nativeId)),this._console}async createMediaObject(e,i){return t.sdk.mediaManager.createMediaObject(e,i,{sourceId:this.id})}getMediaObjectConsole(e){return"string"!=typeof e.sourceId?this.console:t.sdk.deviceManager.getMixinConsole(e.sourceId,this.nativeId)}_lazyLoadDeviceState(){this._deviceState||(this.nativeId?this._deviceState=t.sdk.deviceManager.getDeviceState(this.nativeId):this._deviceState=t.sdk.deviceManager.getDeviceState())}onDeviceEvent(e,i){return t.sdk.deviceManager.onDeviceEvent(this.nativeId,e,i)}}t.ScryptedDeviceBase=s;class a extends r.DeviceBase{constructor(e){super(),this._listeners=new Set,this.mixinDevice=e.mixinDevice,this.mixinDeviceInterfaces=e.mixinDeviceInterfaces,this.mixinStorageSuffix=e.mixinStorageSuffix,this._deviceState=e.mixinDeviceState,this.nativeId=t.sdk.systemManager.getDeviceById(this.id).nativeId,this.mixinProviderNativeId=e.mixinProviderNativeId,this._deviceState.__rpcproxy_traps_all_properties&&"string"==typeof this._deviceState.id&&(this._deviceState=t.sdk.deviceManager.createDeviceState(this._deviceState.id,this._deviceState.setState))}get storage(){if(!this._storage){const e=this.mixinStorageSuffix,i=this.id+(e?":"+e:"");this._storage=t.sdk.deviceManager.getMixinStorage(i,this.mixinProviderNativeId)}return this._storage}get console(){return this._console||(t.sdk.deviceManager.getMixinConsole?this._console=t.sdk.deviceManager.getMixinConsole(this.id,this.mixinProviderNativeId):this._console=t.sdk.deviceManager.getDeviceConsole(this.mixinProviderNativeId)),this._console}async createMediaObject(e,i){return t.sdk.mediaManager.createMediaObject(e,i,{sourceId:this.id})}getMediaObjectConsole(e){return"string"!=typeof e.sourceId?this.console:t.sdk.deviceManager.getMixinConsole(e.sourceId,this.mixinProviderNativeId)}onDeviceEvent(e,i){return t.sdk.deviceManager.onMixinEvent(this.id,this,e,i)}_lazyLoadDeviceState(){}manageListener(e){this._listeners.add(e)}release(){for(const e of this._listeners)e.removeListener()}}t.MixinDeviceBase=a,function(){function e(e){return function(){return this._lazyLoadDeviceState(),this._deviceState?.[e]}}function t(e){return function(t){this._lazyLoadDeviceState(),this._deviceState?this._deviceState[e]=t:console.warn("device state is unavailable. the device must be discovered with deviceManager.onDeviceDiscovered or deviceManager.onDevicesChanged before the state can be set.")}}for(const i of Object.values(r.ScryptedInterfaceProperty))i!==r.ScryptedInterfaceProperty.nativeId&&(Object.defineProperty(s.prototype,i,{set:t(i),get:e(i)}),Object.defineProperty(a.prototype,i,{set:t(i),get:e(i)}))}(),t.sdk={};try{let e=!1;try{process.env.SCRYPTED_SDK_ES_MODULE||process.env.SCRYPTED_SDK_MODULE;const n=process.env.SCRYPTED_SDK_CJS_MODULE||process.env.SCRYPTED_SDK_MODULE;if(n)if("undefined"!=typeof require){const i=require(process.env.SCRYPTED_SDK_MODULE);Object.assign(t.sdk,i.getScryptedStatic()),e=!0}else{const o=i(6570)(n);Object.assign(t.sdk,o.getScryptedStatic()),e=!0}}catch(e){throw console.warn("failed to load sdk module",e),e}if(!e){let e;try{e=pluginRuntimeAPI}catch(e){}Object.assign(t.sdk,{log:deviceManager.getDeviceLogger(void 0),deviceManager,endpointManager,mediaManager,systemManager,pluginHostAPI,...e})}try{t.sdk.systemManager.setScryptedInterfaceDescriptors?.(r.TYPES_VERSION,r.ScryptedInterfaceDescriptors)?.catch((()=>{}))}catch(e){}}catch(e){console.error("sdk initialization error, import @scrypted/types or use @scrypted/client instead",e)}t.default=t.sdk},1711:function(e,t,i){(function(){var t,n,o,r,s,a,c,l,p,u,d,h,m,f,g,v,y,b,w,_,S,x,T,E={}.hasOwnProperty;T=i(5502),S=T.isObject,_=T.isFunction,x=T.isPlainObject,w=T.getValue,t=i(5068),h=i(8470),m=i(6859),r=i(5670),s=i(9226),g=i(4565),b=i(9256),f=i(838),u=i(9983),d=i(2189),a=i(2328),l=i(2032),c=i(4423),p=i(4061),o=i(9299),y=i(529),v=i(661),n=i(1926),e.exports=function(){function e(e,i,n){var o;this.name="?xml",this.type=t.Document,e||(e={}),o={},e.writer?x(e.writer)&&(o=e.writer,e.writer=new v):e.writer=new v,this.options=e,this.writer=e.writer,this.writerOptions=this.writer.filterOptions(o),this.stringify=new y(e),this.onDataCallback=i||function(){},this.onEndCallback=n||function(){},this.currentNode=null,this.currentLevel=-1,this.openTags={},this.documentStarted=!1,this.documentCompleted=!1,this.root=null}return e.prototype.createChildNode=function(e){var i,n,o,r,s,a,c,l;switch(e.type){case t.CData:this.cdata(e.value);break;case t.Comment:this.comment(e.value);break;case t.Element:for(n in o={},c=e.attribs)E.call(c,n)&&(i=c[n],o[n]=i.value);this.node(e.name,o);break;case t.Dummy:this.dummy();break;case t.Raw:this.raw(e.value);break;case t.Text:this.text(e.value);break;case t.ProcessingInstruction:this.instruction(e.target,e.value);break;default:throw new Error("This XML node type is not supported in a JS object: "+e.constructor.name)}for(s=0,a=(l=e.children).length;s<a;s++)r=l[s],this.createChildNode(r),r.type===t.Element&&this.up();return this},e.prototype.dummy=function(){return this},e.prototype.node=function(e,t,i){var n;if(null==e)throw new Error("Missing node name.");if(this.root&&-1===this.currentLevel)throw new Error("Document can only have one root node. "+this.debugInfo(e));return this.openCurrent(),e=w(e),null==t&&(t={}),t=w(t),S(t)||(i=(n=[t,i])[0],t=n[1]),this.currentNode=new m(this,e,t),this.currentNode.children=!1,this.currentLevel++,this.openTags[this.currentLevel]=this.currentNode,null!=i&&this.text(i),this},e.prototype.element=function(e,i,n){var o,r,s,a,c,l;if(this.currentNode&&this.currentNode.type===t.DocType)this.dtdElement.apply(this,arguments);else if(Array.isArray(e)||S(e)||_(e))for(a=this.options.noValidation,this.options.noValidation=!0,(l=new h(this.options).element("TEMP_ROOT")).element(e),this.options.noValidation=a,r=0,s=(c=l.children).length;r<s;r++)o=c[r],this.createChildNode(o),o.type===t.Element&&this.up();else this.node(e,i,n);return this},e.prototype.attribute=function(e,t){var i,n;if(!this.currentNode||this.currentNode.children)throw new Error("att() can only be used immediately after an ele() call in callback mode. "+this.debugInfo(e));if(null!=e&&(e=w(e)),S(e))for(i in e)E.call(e,i)&&(n=e[i],this.attribute(i,n));else _(t)&&(t=t.apply()),this.options.keepNullAttributes&&null==t?this.currentNode.attribs[e]=new o(this,e,""):null!=t&&(this.currentNode.attribs[e]=new o(this,e,t));return this},e.prototype.text=function(e){var t;return this.openCurrent(),t=new b(this,e),this.onData(this.writer.text(t,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},e.prototype.cdata=function(e){var t;return this.openCurrent(),t=new r(this,e),this.onData(this.writer.cdata(t,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},e.prototype.comment=function(e){var t;return this.openCurrent(),t=new s(this,e),this.onData(this.writer.comment(t,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},e.prototype.raw=function(e){var t;return this.openCurrent(),t=new g(this,e),this.onData(this.writer.raw(t,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},e.prototype.instruction=function(e,t){var i,n,o,r,s;if(this.openCurrent(),null!=e&&(e=w(e)),null!=t&&(t=w(t)),Array.isArray(e))for(i=0,r=e.length;i<r;i++)n=e[i],this.instruction(n);else if(S(e))for(n in e)E.call(e,n)&&(o=e[n],this.instruction(n,o));else _(t)&&(t=t.apply()),s=new f(this,e,t),this.onData(this.writer.processingInstruction(s,this.writerOptions,this.currentLevel+1),this.currentLevel+1);return this},e.prototype.declaration=function(e,t,i){var n;if(this.openCurrent(),this.documentStarted)throw new Error("declaration() must be the first node.");return n=new u(this,e,t,i),this.onData(this.writer.declaration(n,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},e.prototype.doctype=function(e,t,i){if(this.openCurrent(),null==e)throw new Error("Missing root node name.");if(this.root)throw new Error("dtd() must come before the root node.");return this.currentNode=new d(this,t,i),this.currentNode.rootNodeName=e,this.currentNode.children=!1,this.currentLevel++,this.openTags[this.currentLevel]=this.currentNode,this},e.prototype.dtdElement=function(e,t){var i;return this.openCurrent(),i=new c(this,e,t),this.onData(this.writer.dtdElement(i,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},e.prototype.attList=function(e,t,i,n,o){var r;return this.openCurrent(),r=new a(this,e,t,i,n,o),this.onData(this.writer.dtdAttList(r,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},e.prototype.entity=function(e,t){var i;return this.openCurrent(),i=new l(this,!1,e,t),this.onData(this.writer.dtdEntity(i,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},e.prototype.pEntity=function(e,t){var i;return this.openCurrent(),i=new l(this,!0,e,t),this.onData(this.writer.dtdEntity(i,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},e.prototype.notation=function(e,t){var i;return this.openCurrent(),i=new p(this,e,t),this.onData(this.writer.dtdNotation(i,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},e.prototype.up=function(){if(this.currentLevel<0)throw new Error("The document node has no parent.");return this.currentNode?(this.currentNode.children?this.closeNode(this.currentNode):this.openNode(this.currentNode),this.currentNode=null):this.closeNode(this.openTags[this.currentLevel]),delete this.openTags[this.currentLevel],this.currentLevel--,this},e.prototype.end=function(){for(;this.currentLevel>=0;)this.up();return this.onEnd()},e.prototype.openCurrent=function(){if(this.currentNode)return this.currentNode.children=!0,this.openNode(this.currentNode)},e.prototype.openNode=function(e){var i,o,r,s;if(!e.isOpen){if(this.root||0!==this.currentLevel||e.type!==t.Element||(this.root=e),o="",e.type===t.Element){for(r in this.writerOptions.state=n.OpenTag,o=this.writer.indent(e,this.writerOptions,this.currentLevel)+"<"+e.name,s=e.attribs)E.call(s,r)&&(i=s[r],o+=this.writer.attribute(i,this.writerOptions,this.currentLevel));o+=(e.children?">":"/>")+this.writer.endline(e,this.writerOptions,this.currentLevel),this.writerOptions.state=n.InsideTag}else this.writerOptions.state=n.OpenTag,o=this.writer.indent(e,this.writerOptions,this.currentLevel)+"<!DOCTYPE "+e.rootNodeName,e.pubID&&e.sysID?o+=' PUBLIC "'+e.pubID+'" "'+e.sysID+'"':e.sysID&&(o+=' SYSTEM "'+e.sysID+'"'),e.children?(o+=" [",this.writerOptions.state=n.InsideTag):(this.writerOptions.state=n.CloseTag,o+=">"),o+=this.writer.endline(e,this.writerOptions,this.currentLevel);return this.onData(o,this.currentLevel),e.isOpen=!0}},e.prototype.closeNode=function(e){var i;if(!e.isClosed)return i="",this.writerOptions.state=n.CloseTag,i=e.type===t.Element?this.writer.indent(e,this.writerOptions,this.currentLevel)+"</"+e.name+">"+this.writer.endline(e,this.writerOptions,this.currentLevel):this.writer.indent(e,this.writerOptions,this.currentLevel)+"]>"+this.writer.endline(e,this.writerOptions,this.currentLevel),this.writerOptions.state=n.None,this.onData(i,this.currentLevel),e.isClosed=!0},e.prototype.onData=function(e,t){return this.documentStarted=!0,this.onDataCallback(e,t+1)},e.prototype.onEnd=function(){return this.documentCompleted=!0,this.onEndCallback()},e.prototype.debugInfo=function(e){return null==e?"":"node: <"+e+">"},e.prototype.ele=function(){return this.element.apply(this,arguments)},e.prototype.nod=function(e,t,i){return this.node(e,t,i)},e.prototype.txt=function(e){return this.text(e)},e.prototype.dat=function(e){return this.cdata(e)},e.prototype.com=function(e){return this.comment(e)},e.prototype.ins=function(e,t){return this.instruction(e,t)},e.prototype.dec=function(e,t,i){return this.declaration(e,t,i)},e.prototype.dtd=function(e,t,i){return this.doctype(e,t,i)},e.prototype.e=function(e,t,i){return this.element(e,t,i)},e.prototype.n=function(e,t,i){return this.node(e,t,i)},e.prototype.t=function(e){return this.text(e)},e.prototype.d=function(e){return this.cdata(e)},e.prototype.c=function(e){return this.comment(e)},e.prototype.r=function(e){return this.raw(e)},e.prototype.i=function(e,t){return this.instruction(e,t)},e.prototype.att=function(){return this.currentNode&&this.currentNode.type===t.DocType?this.attList.apply(this,arguments):this.attribute.apply(this,arguments)},e.prototype.a=function(){return this.currentNode&&this.currentNode.type===t.DocType?this.attList.apply(this,arguments):this.attribute.apply(this,arguments)},e.prototype.ent=function(e,t){return this.entity(e,t)},e.prototype.pent=function(e,t){return this.pEntity(e,t)},e.prototype.not=function(e,t){return this.notation(e,t)},e}()}).call(this)},1743:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EventDisposer=t.Event=void 0;t.Event=class{constructor(){this.event={stack:[],promiseStack:[],eventId:0},this.ended=!1,this.onerror=e=>{},this.execute=(...e)=>{if(!this.ended){for(const t of this.event.stack)t.execute(...e);(async()=>{for(const t of this.event.promiseStack)await t.execute(...e)})().catch((e=>{this.onerror(e)}))}},this.complete=()=>{if(!this.ended){for(const e of this.event.stack)e.complete&&e.complete();this.allUnsubscribe(),this.ended=!0,this.onended&&(this.onended(),this.onended=void 0)}},this.error=e=>{if(!this.ended){for(const t of this.event.stack)t.error&&t.error(e);this.allUnsubscribe()}},this.allUnsubscribe=()=>{if(this.ended)throw new Error("event completed");this.event={stack:[],promiseStack:[],eventId:0}},this.subscribe=(e,t,i)=>{const n=this.event.eventId;this.event.stack.push({execute:e,id:n,complete:t,error:i}),this.event.eventId++;const o=()=>{this.event.stack=this.event.stack.filter((e=>e.id!==n&&e))};return{unSubscribe:o,disposer:e=>{e.push(o)}}},this.queuingSubscribe=(e,t,i)=>{if(this.ended)throw new Error("event completed");const n=this.event.eventId;this.event.promiseStack.push({execute:e,id:n,complete:t,error:i}),this.event.eventId++;const o=()=>{this.event.stack=this.event.stack.filter((e=>e.id!==n&&e))};return{unSubscribe:o,disposer:e=>{e.push(o)}}},this.once=(e,t,i)=>{const n=this.subscribe(((...t)=>{n.unSubscribe(),e(...t)}),t,i)},this.watch=(e,t)=>new Promise(((i,n)=>{const o=t&&setTimeout((()=>{n("Event watch timeout")}),t),{unSubscribe:r}=this.subscribe(((...t)=>{e(...t)&&(o&&clearTimeout(o),r(),i(t))}))})),this.asPromise=e=>new Promise(((t,i)=>{const n=e&&setTimeout((()=>{i("Event asPromise timeout")}),e);this.once(((...e)=>{n&&clearTimeout(n),t(e)}),(()=>{n&&clearTimeout(n),t([])}),(e=>{n&&clearTimeout(n),i(e)}))}))}get returnTrigger(){const{execute:e,error:t,complete:i}=this;return{execute:e,error:t,complete:i}}get returnListener(){const{subscribe:e,once:t,asPromise:i}=this;return{subscribe:e,once:t,asPromise:i}}get length(){return this.event.stack.length}};t.EventDisposer=class{constructor(){this._disposer=[]}push(e){this._disposer.push(e)}dispose(){this._disposer.forEach((e=>e())),this._disposer=[]}}},1783:(e,t,i)=>{var n,o,r,s=i(7016),a=s.URL,c=i(8611),l=i(5692),p=i(2203).Writable,u=i(2613),d=i(4376);n="undefined"!=typeof process,o="undefined"!=typeof window&&"undefined"!=typeof document,r=D(Error.captureStackTrace),n||!o&&r||console.warn("The follow-redirects package should be excluded from browser builds.");var h=!1;try{u(new a(""))}catch(e){h="ERR_INVALID_URL"===e.code}var m=["auth","host","hostname","href","path","pathname","port","protocol","query","search","hash"],f=["abort","aborted","connect","error","socket","timeout"],g=Object.create(null);f.forEach((function(e){g[e]=function(t,i,n){this._redirectable.emit(e,t,i,n)}}));var v=I("ERR_INVALID_URL","Invalid URL",TypeError),y=I("ERR_FR_REDIRECTION_FAILURE","Redirected request failed"),b=I("ERR_FR_TOO_MANY_REDIRECTS","Maximum number of redirects exceeded",y),w=I("ERR_FR_MAX_BODY_LENGTH_EXCEEDED","Request body larger than maxBodyLength limit"),_=I("ERR_STREAM_WRITE_AFTER_END","write after end"),S=p.prototype.destroy||E;function x(e,t){p.call(this),this._sanitizeOptions(e),this._options=e,this._ended=!1,this._ending=!1,this._redirectCount=0,this._redirects=[],this._requestBodyLength=0,this._requestBodyBuffers=[],t&&this.on("response",t);var i=this;this._onNativeResponse=function(e){try{i._processResponse(e)}catch(e){i.emit("error",e instanceof y?e:new y({cause:e}))}},this._performRequest()}function T(e){var t={maxRedirects:21,maxBodyLength:10485760},i={};return Object.keys(e).forEach((function(n){var o=n+":",r=i[o]=e[n],s=t[n]=Object.create(r);Object.defineProperties(s,{request:{value:function(e,n,r){var s;return s=e,a&&s instanceof a?e=k(e):R(e)?e=k(C(e)):(r=n,n=P(e),e={protocol:o}),D(n)&&(r=n,n=null),(n=Object.assign({maxRedirects:t.maxRedirects,maxBodyLength:t.maxBodyLength},e,n)).nativeProtocols=i,R(n.host)||R(n.hostname)||(n.hostname="::1"),u.equal(n.protocol,o,"protocol mismatch"),d("options",n),new x(n,r)},configurable:!0,enumerable:!0,writable:!0},get:{value:function(e,t,i){var n=s.request(e,t,i);return n.end(),n},configurable:!0,enumerable:!0,writable:!0}})})),t}function E(){}function C(e){var t;if(h)t=new a(e);else if(!R((t=P(s.parse(e))).protocol))throw new v({input:e});return t}function P(e){if(/^\[/.test(e.hostname)&&!/^\[[:0-9a-f]+\]$/i.test(e.hostname))throw new v({input:e.href||e});if(/^\[/.test(e.host)&&!/^\[[:0-9a-f]+\](:\d+)?$/i.test(e.host))throw new v({input:e.href||e});return e}function k(e,t){var i=t||{};for(var n of m)i[n]=e[n];return i.hostname.startsWith("[")&&(i.hostname=i.hostname.slice(1,-1)),""!==i.port&&(i.port=Number(i.port)),i.path=i.search?i.pathname+i.search:i.pathname,i}function O(e,t){var i;for(var n in t)e.test(n)&&(i=t[n],delete t[n]);return null===i||"undefined"==typeof i?void 0:String(i).trim()}function I(e,t,i){function n(i){D(Error.captureStackTrace)&&Error.captureStackTrace(this,this.constructor),Object.assign(this,i||{}),this.code=e,this.message=this.cause?t+": "+this.cause.message:t}return n.prototype=new(i||Error),Object.defineProperties(n.prototype,{constructor:{value:n,enumerable:!1},name:{value:"Error ["+e+"]",enumerable:!1}}),n}function A(e,t){for(var i of f)e.removeListener(i,g[i]);e.on("error",E),e.destroy(t)}function R(e){return"string"==typeof e||e instanceof String}function D(e){return"function"==typeof e}x.prototype=Object.create(p.prototype),x.prototype.abort=function(){A(this._currentRequest),this._currentRequest.abort(),this.emit("abort")},x.prototype.destroy=function(e){return A(this._currentRequest,e),S.call(this,e),this},x.prototype.write=function(e,t,i){if(this._ending)throw new _;if(!R(e)&&("object"!=typeof(n=e)||!("length"in n)))throw new TypeError("data should be a string, Buffer or Uint8Array");var n;D(t)&&(i=t,t=null),0!==e.length?this._requestBodyLength+e.length<=this._options.maxBodyLength?(this._requestBodyLength+=e.length,this._requestBodyBuffers.push({data:e,encoding:t}),this._currentRequest.write(e,t,i)):(this.emit("error",new w),this.abort()):i&&i()},x.prototype.end=function(e,t,i){if(D(e)?(i=e,e=t=null):D(t)&&(i=t,t=null),e){var n=this,o=this._currentRequest;this.write(e,t,(function(){n._ended=!0,o.end(null,null,i)})),this._ending=!0}else this._ended=this._ending=!0,this._currentRequest.end(null,null,i)},x.prototype.setHeader=function(e,t){this._options.headers[e]=t,this._currentRequest.setHeader(e,t)},x.prototype.removeHeader=function(e){delete this._options.headers[e],this._currentRequest.removeHeader(e)},x.prototype.setTimeout=function(e,t){var i=this;function n(t){t.setTimeout(e),t.removeListener("timeout",t.destroy),t.addListener("timeout",t.destroy)}function o(t){i._timeout&&clearTimeout(i._timeout),i._timeout=setTimeout((function(){i.emit("timeout"),r()}),e),n(t)}function r(){i._timeout&&(clearTimeout(i._timeout),i._timeout=null),i.removeListener("abort",r),i.removeListener("error",r),i.removeListener("response",r),i.removeListener("close",r),t&&i.removeListener("timeout",t),i.socket||i._currentRequest.removeListener("socket",o)}return t&&this.on("timeout",t),this.socket?o(this.socket):this._currentRequest.once("socket",o),this.on("socket",n),this.on("abort",r),this.on("error",r),this.on("response",r),this.on("close",r),this},["flushHeaders","getHeader","setNoDelay","setSocketKeepAlive"].forEach((function(e){x.prototype[e]=function(t,i){return this._currentRequest[e](t,i)}})),["aborted","connection","socket"].forEach((function(e){Object.defineProperty(x.prototype,e,{get:function(){return this._currentRequest[e]}})})),x.prototype._sanitizeOptions=function(e){if(e.headers||(e.headers={}),e.host&&(e.hostname||(e.hostname=e.host),delete e.host),!e.pathname&&e.path){var t=e.path.indexOf("?");t<0?e.pathname=e.path:(e.pathname=e.path.substring(0,t),e.search=e.path.substring(t))}},x.prototype._performRequest=function(){var e=this._options.protocol,t=this._options.nativeProtocols[e];if(!t)throw new TypeError("Unsupported protocol "+e);if(this._options.agents){var i=e.slice(0,-1);this._options.agent=this._options.agents[i]}var n=this._currentRequest=t.request(this._options,this._onNativeResponse);for(var o of(n._redirectable=this,f))n.on(o,g[o]);if(this._currentUrl=/^\//.test(this._options.path)?s.format(this._options):this._options.path,this._isRedirect){var r=0,a=this,c=this._requestBodyBuffers;!function e(t){if(n===a._currentRequest)if(t)a.emit("error",t);else if(r<c.length){var i=c[r++];n.finished||n.write(i.data,i.encoding,e)}else a._ended&&n.end()}()}},x.prototype._processResponse=function(e){var t=e.statusCode;this._options.trackRedirects&&this._redirects.push({url:this._currentUrl,headers:e.headers,statusCode:t});var i,n=e.headers.location;if(!n||!1===this._options.followRedirects||t<300||t>=400)return e.responseUrl=this._currentUrl,e.redirects=this._redirects,this.emit("response",e),void(this._requestBodyBuffers=[]);if(A(this._currentRequest),e.destroy(),++this._redirectCount>this._options.maxRedirects)throw new b;var o=this._options.beforeRedirect;o&&(i=Object.assign({Host:e.req.getHeader("host")},this._options.headers));var r=this._options.method;((301===t||302===t)&&"POST"===this._options.method||303===t&&!/^(?:GET|HEAD)$/.test(this._options.method))&&(this._options.method="GET",this._requestBodyBuffers=[],O(/^content-/i,this._options.headers));var c,l,p=O(/^host$/i,this._options.headers),m=C(this._currentUrl),f=p||m.host,g=/^\w+:/.test(n)?this._currentUrl:s.format(Object.assign(m,{host:f})),v=(c=n,l=g,h?new a(c,l):C(s.resolve(l,c)));if(d("redirecting to",v.href),this._isRedirect=!0,k(v,this._options),(v.protocol!==m.protocol&&"https:"!==v.protocol||v.host!==f&&!function(e,t){u(R(e)&&R(t));var i=e.length-t.length-1;return i>0&&"."===e[i]&&e.endsWith(t)}(v.host,f))&&O(/^(?:(?:proxy-)?authorization|cookie)$/i,this._options.headers),D(o)){var y={headers:e.headers,statusCode:t},w={url:g,method:r,headers:i};o(this._options,y,w),this._sanitizeOptions(this._options)}this._performRequest()},e.exports=T({http:c,https:l}),e.exports.wrap=T},1784:function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.connectAsync=void 0;const o=n(i(8766)),r=n(i(7016)),s=n(i(1786)),a=n(i(8032));"function"!=typeof(null===process||void 0===process?void 0:process.nextTick)&&(process.nextTick=setImmediate);const c=(0,o.default)("mqttjs");let l=null;function p(e,t){var n,o,p,u;if(c("connecting to an MQTT broker..."),"object"!=typeof e||t||(t=e,e=""),t=t||{},e&&"string"==typeof e){const i=r.default.parse(e,!0),o={};if(null!=i.port&&(o.port=Number(i.port)),o.host=i.hostname,o.query=i.query,o.auth=i.auth,o.protocol=i.protocol,o.path=i.path,o.protocol=null===(n=o.protocol)||void 0===n?void 0:n.replace(/:$/,""),!(t=Object.assign(Object.assign({},o),t)).protocol)throw new Error("Missing protocol")}if(t.unixSocket=t.unixSocket||(null===(o=t.protocol)||void 0===o?void 0:o.includes("+unix")),t.unixSocket?t.protocol=t.protocol.replace("+unix",""):(null===(p=t.protocol)||void 0===p?void 0:p.startsWith("ws"))||(null===(u=t.protocol)||void 0===u?void 0:u.startsWith("wx"))||delete t.path,function(e){let t;e.auth&&(t=e.auth.match(/^(.+):(.+)$/),t?(e.username=t[1],e.password=t[2]):e.username=e.auth)}(t),t.query&&"string"==typeof t.query.clientId&&(t.clientId=t.query.clientId),t.cert&&t.key){if(!t.protocol)throw new Error("Missing secure protocol key");if(-1===["mqtts","wss","wxs","alis"].indexOf(t.protocol))switch(t.protocol){case"mqtt":t.protocol="mqtts";break;case"ws":t.protocol="wss";break;case"wx":t.protocol="wxs";break;case"ali":t.protocol="alis";break;default:throw new Error(`Unknown protocol for secure connection: "${t.protocol}"!`)}}if(l||(l={},a.default||t.forceNativeWebSocket?(l.ws=i(6844).browserStreamBuilder,l.wss=i(6844).browserStreamBuilder,l.wx=i(5293).A,l.wxs=i(5293).A,l.ali=i(5208).A,l.alis=i(5208).A):(l.ws=i(6844).streamBuilder,l.wss=i(6844).streamBuilder,l.mqtt=i(1543).default,l.tcp=i(1543).default,l.ssl=i(6141).default,l.tls=l.ssl,l.mqtts=i(6141).default)),!l[t.protocol]){const e=-1!==["mqtts","wss"].indexOf(t.protocol);t.protocol=["mqtt","mqtts","ws","wss","wx","wxs","ali","alis"].filter(((t,i)=>(!e||i%2!=0)&&"function"==typeof l[t]))[0]}if(!1===t.clean&&!t.clientId)throw new Error("Missing clientId for unclean clients");t.protocol&&(t.defaultProtocol=t.protocol);const d=new s.default((function(e){return t.servers&&(e._reconnectCount&&e._reconnectCount!==t.servers.length||(e._reconnectCount=0),t.host=t.servers[e._reconnectCount].host,t.port=t.servers[e._reconnectCount].port,t.protocol=t.servers[e._reconnectCount].protocol?t.servers[e._reconnectCount].protocol:t.defaultProtocol,t.hostname=t.host,e._reconnectCount++),c("calling streambuilder for",t.protocol),l[t.protocol](e,t)}),t);return d.on("error",(()=>{})),d}t.connectAsync=function(e,t,i=!0){return new Promise(((n,o)=>{const r=p(e,t),s={connect:e=>{a(),n(r)},end:()=>{a(),n(r)},error:e=>{a(),r.end(),o(e)}};function a(){Object.keys(s).forEach((e=>{r.off(e,s[e])}))}!1===i&&(s.close=()=>{s.error(new Error("Couldn't connect to server"))}),Object.keys(s).forEach((e=>{r.on(e,s[e])}))}))},t.default=p},1786:function(e,t,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=s(i(1516)),c=s(i(1535)),l=s(i(2574)),p=i(5899),u=s(i(9388)),d=r(i(617)),h=s(i(8766)),m=s(i(6344)),f=s(i(6039)),g=i(1364),v=i(8399),y=s(i(2444)),b=r(i(8032)),w=globalThis.setImmediate||((...e)=>{const t=e.shift();(0,g.nextTick)((()=>{t(...e)}))}),_={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:3e4,clean:!0,resubscribe:!0,writeCache:!0,timerVariant:"auto"};class S extends v.TypedEventEmitter{static defaultId(){return`mqttjs_${Math.random().toString(16).substr(2,8)}`}constructor(e,t){super(),this.options=t||{};for(const e in _)"undefined"==typeof this.options[e]?this.options[e]=_[e]:this.options[e]=t[e];this.log=this.options.log||(0,h.default)("mqttjs:client"),this.noop=this._noop.bind(this),this.log("MqttClient :: version:",S.VERSION),b.isWebWorker?this.log("MqttClient :: environment","webworker"):this.log("MqttClient :: environment",b.default?"browser":"node"),this.log("MqttClient :: options.protocol",t.protocol),this.log("MqttClient :: options.protocolVersion",t.protocolVersion),this.log("MqttClient :: options.username",t.username),this.log("MqttClient :: options.keepalive",t.keepalive),this.log("MqttClient :: options.reconnectPeriod",t.reconnectPeriod),this.log("MqttClient :: options.rejectUnauthorized",t.rejectUnauthorized),this.log("MqttClient :: options.properties.topicAliasMaximum",t.properties?t.properties.topicAliasMaximum:void 0),this.options.clientId="string"==typeof t.clientId?t.clientId:S.defaultId(),this.log("MqttClient :: clientId",this.options.clientId),this.options.customHandleAcks=5===t.protocolVersion&&t.customHandleAcks?t.customHandleAcks:(...e)=>{e[3](null,0)},this.options.writeCache||(c.default.writeToStream.cacheNumbers=!1),this.streamBuilder=e,this.messageIdProvider="undefined"==typeof this.options.messageIdProvider?new l.default:this.options.messageIdProvider,this.outgoingStore=t.outgoingStore||new m.default,this.incomingStore=t.incomingStore||new m.default,this.queueQoSZero=void 0===t.queueQoSZero||t.queueQoSZero,this._resubscribeTopics={},this.messageIdToTopic={},this.keepaliveManager=null,this.connected=!1,this.disconnecting=!1,this.reconnecting=!1,this.queue=[],this.connackTimer=null,this.reconnectTimer=null,this._storeProcessing=!1,this._packetIdsDuringStoreProcessing={},this._storeProcessingQueue=[],this.outgoing={},this._firstConnection=!0,t.properties&&t.properties.topicAliasMaximum>0&&(t.properties.topicAliasMaximum>65535?this.log("MqttClient :: options.properties.topicAliasMaximum is out of range"):this.topicAliasRecv=new a.default(t.properties.topicAliasMaximum)),this.on("connect",(()=>{const{queue:e}=this,t=()=>{const i=e.shift();this.log("deliver :: entry %o",i);let n=null;if(!i)return void this._resubscribe();n=i.packet,this.log("deliver :: call _sendPacket for %o",n);let o=!0;n.messageId&&0!==n.messageId&&(this.messageIdProvider.register(n.messageId)||(o=!1)),o?this._sendPacket(n,(e=>{i.cb&&i.cb(e),t()})):(this.log("messageId: %d has already used. The message is skipped and removed.",n.messageId),t())};this.log("connect :: sending queued packets"),t()})),this.on("close",(()=>{this.log("close :: connected set to `false`"),this.connected=!1,this.log("close :: clearing connackTimer"),clearTimeout(this.connackTimer),this._destroyKeepaliveManager(),this.topicAliasRecv&&this.topicAliasRecv.clear(),this.log("close :: calling _setupReconnect"),this._setupReconnect()})),this.options.manualConnect||(this.log("MqttClient :: setting up stream"),this.connect())}handleAuth(e,t){t()}handleMessage(e,t){t()}_nextId(){return this.messageIdProvider.allocate()}getLastMessageId(){return this.messageIdProvider.getLastAllocated()}connect(){var e;const t=new p.Writable,i=c.default.parser(this.options);let n=null;const o=[];this.log("connect :: calling method to clear reconnect"),this._clearReconnect(),this.disconnected&&!this.reconnecting&&(this.incomingStore=this.options.incomingStore||new m.default,this.outgoingStore=this.options.outgoingStore||new m.default,this.disconnecting=!1,this.disconnected=!1),this.log("connect :: using streamBuilder provided to client to create stream"),this.stream=this.streamBuilder(this),i.on("packet",(e=>{this.log("parser :: on packet push to packets array."),o.push(e)}));const r=()=>{this.log("work :: getting next packet in queue");const e=o.shift();if(e)this.log("work :: packet pulled from queue"),(0,f.default)(this,e,s);else{this.log("work :: no packets in queue");const e=n;n=null,this.log("work :: done flag is %s",!!e),e&&e()}},s=()=>{if(o.length)(0,g.nextTick)(r);else{const e=n;n=null,e()}};t._write=(e,t,o)=>{n=o,this.log("writable stream :: parsing buffer"),i.parse(e),r()};this.log("connect :: pipe stream to writable stream"),this.stream.pipe(t),this.stream.on("error",(e=>{this.log("streamErrorHandler :: error",e.message),e.code?(this.log("streamErrorHandler :: emitting error"),this.emit("error",e)):this.noop(e)})),this.stream.on("close",(()=>{this.log("(%s)stream :: on close",this.options.clientId),this._flushVolatile(),this.log("stream: emit close to MqttClient"),this.emit("close")})),this.log("connect: sending packet `connect`");const a={cmd:"connect",protocolId:this.options.protocolId,protocolVersion:this.options.protocolVersion,clean:this.options.clean,clientId:this.options.clientId,keepalive:this.options.keepalive,username:this.options.username,password:this.options.password,properties:this.options.properties};if(this.options.will&&(a.will=Object.assign(Object.assign({},this.options.will),{payload:null===(e=this.options.will)||void 0===e?void 0:e.payload})),this.topicAliasRecv&&(a.properties||(a.properties={}),this.topicAliasRecv&&(a.properties.topicAliasMaximum=this.topicAliasRecv.max)),this._writePacket(a),i.on("error",this.emit.bind(this,"error")),this.options.properties){if(!this.options.properties.authenticationMethod&&this.options.properties.authenticationData)return this.end((()=>this.emit("error",new Error("Packet has no Authentication Method")))),this;if(this.options.properties.authenticationMethod&&this.options.authPacket&&"object"==typeof this.options.authPacket){const e=Object.assign({cmd:"auth",reasonCode:0},this.options.authPacket);this._writePacket(e)}}return this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout((()=>{this.log("!!connectTimeout hit!! Calling _cleanUp with force `true`"),this.emit("error",new Error("connack timeout")),this._cleanUp(!0)}),this.options.connectTimeout),this}publish(e,t,i,n){this.log("publish :: message `%s` to topic `%s`",t,e);const{options:o}=this;"function"==typeof i&&(n=i,i=null),i=i||{};i=Object.assign(Object.assign({},{qos:0,retain:!1,dup:!1}),i);const{qos:r,retain:s,dup:a,properties:c,cbStorePut:l}=i;if(this._checkDisconnecting(n))return this;const p=()=>{let i=0;if((1===r||2===r)&&(i=this._nextId(),null===i))return this.log("No messageId left"),!1;const p={cmd:"publish",topic:e,payload:t,qos:r,retain:s,messageId:i,dup:a};switch(5===o.protocolVersion&&(p.properties=c),this.log("publish :: qos",r),r){case 1:case 2:this.outgoing[p.messageId]={volatile:!1,cb:n||this.noop},this.log("MqttClient:publish: packet cmd: %s",p.cmd),this._sendPacket(p,void 0,l);break;default:this.log("MqttClient:publish: packet cmd: %s",p.cmd),this._sendPacket(p,n,l)}return!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!p())&&this._storeProcessingQueue.push({invoke:p,cbStorePut:i.cbStorePut,callback:n}),this}publishAsync(e,t,i){return new Promise(((n,o)=>{this.publish(e,t,i,((e,t)=>{e?o(e):n(t)}))}))}subscribe(e,t,i){const n=this.options.protocolVersion;"function"==typeof t&&(i=t),i=i||this.noop;let o=!1,r=[];"string"==typeof e?r=e=[e]:Array.isArray(e)?r=e:"object"==typeof e&&(o=e.resubscribe,delete e.resubscribe,r=Object.keys(e));const s=d.validateTopics(r);if(null!==s)return w(i,new Error(`Invalid topic ${s}`)),this;if(this._checkDisconnecting(i))return this.log("subscribe: discconecting true"),this;const a={qos:0};5===n&&(a.nl=!1,a.rap=!1,a.rh=0);const c=(t=Object.assign(Object.assign({},a),t)).properties,l=[],p=(e,i)=>{if(i=i||t,!Object.prototype.hasOwnProperty.call(this._resubscribeTopics,e)||this._resubscribeTopics[e].qos<i.qos||o){const t={topic:e,qos:i.qos};5===n&&(t.nl=i.nl,t.rap=i.rap,t.rh=i.rh,t.properties=c),this.log("subscribe: pushing topic `%s` and qos `%s` to subs list",t.topic,t.qos),l.push(t)}};if(Array.isArray(e)?e.forEach((e=>{this.log("subscribe: array topic %s",e),p(e)})):Object.keys(e).forEach((t=>{this.log("subscribe: object topic %s, %o",t,e[t]),p(t,e[t])})),!l.length)return i(null,[]),this;const u=()=>{const e=this._nextId();if(null===e)return this.log("No messageId left"),!1;const t={cmd:"subscribe",subscriptions:l,messageId:e};if(c&&(t.properties=c),this.options.resubscribe){this.log("subscribe :: resubscribe true");const e=[];l.forEach((t=>{if(this.options.reconnectPeriod>0){const i={qos:t.qos};5===n&&(i.nl=t.nl||!1,i.rap=t.rap||!1,i.rh=t.rh||0,i.properties=t.properties),this._resubscribeTopics[t.topic]=i,e.push(t.topic)}})),this.messageIdToTopic[t.messageId]=e}return this.outgoing[t.messageId]={volatile:!0,cb(e,t){if(!e){const{granted:e}=t;for(let t=0;t<e.length;t+=1)l[t].qos=e[t]}i(e,l,t)}},this.log("subscribe :: call _sendPacket"),this._sendPacket(t),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!u())&&this._storeProcessingQueue.push({invoke:u,callback:i}),this}subscribeAsync(e,t){return new Promise(((i,n)=>{this.subscribe(e,t,((e,t)=>{e?n(e):i(t)}))}))}unsubscribe(e,t,i){"string"==typeof e&&(e=[e]),"function"==typeof t&&(i=t),i=i||this.noop;const n=d.validateTopics(e);if(null!==n)return w(i,new Error(`Invalid topic ${n}`)),this;if(this._checkDisconnecting(i))return this;const o=()=>{const n=this._nextId();if(null===n)return this.log("No messageId left"),!1;const o={cmd:"unsubscribe",messageId:n,unsubscriptions:[]};return"string"==typeof e?o.unsubscriptions=[e]:Array.isArray(e)&&(o.unsubscriptions=e),this.options.resubscribe&&o.unsubscriptions.forEach((e=>{delete this._resubscribeTopics[e]})),"object"==typeof t&&t.properties&&(o.properties=t.properties),this.outgoing[o.messageId]={volatile:!0,cb:i},this.log("unsubscribe: call _sendPacket"),this._sendPacket(o),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!o())&&this._storeProcessingQueue.push({invoke:o,callback:i}),this}unsubscribeAsync(e,t){return new Promise(((i,n)=>{this.unsubscribe(e,t,((e,t)=>{e?n(e):i(t)}))}))}end(e,t,i){this.log("end :: (%s)",this.options.clientId),null!=e&&"boolean"==typeof e||(i=i||t,t=e,e=!1),"object"!=typeof t&&(i=i||t,t=null),this.log("end :: cb? %s",!!i),i&&"function"==typeof i||(i=this.noop);const n=()=>{this.log("end :: closeStores: closing incoming and outgoing stores"),this.disconnected=!0,this.incomingStore.close((e=>{this.outgoingStore.close((t=>{if(this.log("end :: closeStores: emitting end"),this.emit("end"),i){const n=e||t;this.log("end :: closeStores: invoking callback with args"),i(n)}}))})),this._deferredReconnect?this._deferredReconnect():(0===this.options.reconnectPeriod||this.options.manualConnect)&&(this.disconnecting=!1)},o=()=>{this.log("end :: (%s) :: finish :: calling _cleanUp with force %s",this.options.clientId,e),this._cleanUp(e,(()=>{this.log("end :: finish :: calling process.nextTick on closeStores"),(0,g.nextTick)(n)}),t)};return this.disconnecting?(i(),this):(this._clearReconnect(),this.disconnecting=!0,!e&&Object.keys(this.outgoing).length>0?(this.log("end :: (%s) :: calling finish in 10ms once outgoing is empty",this.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,o,10))):(this.log("end :: (%s) :: immediately calling finish",this.options.clientId),o()),this)}endAsync(e,t){return new Promise(((i,n)=>{this.end(e,t,(e=>{e?n(e):i()}))}))}removeOutgoingMessage(e){if(this.outgoing[e]){const{cb:t}=this.outgoing[e];this._removeOutgoingAndStoreMessage(e,(()=>{t(new Error("Message removed"))}))}return this}reconnect(e){this.log("client reconnect");const t=()=>{e?(this.options.incomingStore=e.incomingStore,this.options.outgoingStore=e.outgoingStore):(this.options.incomingStore=null,this.options.outgoingStore=null),this.incomingStore=this.options.incomingStore||new m.default,this.outgoingStore=this.options.outgoingStore||new m.default,this.disconnecting=!1,this.disconnected=!1,this._deferredReconnect=null,this._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=t:t(),this}_flushVolatile(){this.outgoing&&(this.log("_flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function"),Object.keys(this.outgoing).forEach((e=>{this.outgoing[e].volatile&&"function"==typeof this.outgoing[e].cb&&(this.outgoing[e].cb(new Error("Connection closed")),delete this.outgoing[e])})))}_flush(){this.outgoing&&(this.log("_flush: queue exists? %b",!!this.outgoing),Object.keys(this.outgoing).forEach((e=>{"function"==typeof this.outgoing[e].cb&&(this.outgoing[e].cb(new Error("Connection closed")),delete this.outgoing[e])})))}_removeTopicAliasAndRecoverTopicName(e){let t;e.properties&&(t=e.properties.topicAlias);let i=e.topic.toString();if(this.log("_removeTopicAliasAndRecoverTopicName :: alias %d, topic %o",t,i),0===i.length){if("undefined"==typeof t)return new Error("Unregistered Topic Alias");if(i=this.topicAliasSend.getTopicByAlias(t),"undefined"==typeof i)return new Error("Unregistered Topic Alias");e.topic=i}t&&delete e.properties.topicAlias}_checkDisconnecting(e){return this.disconnecting&&(e&&e!==this.noop?e(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting}_reconnect(){this.log("_reconnect: emitting reconnect to client"),this.emit("reconnect"),this.connected?(this.end((()=>{this.connect()})),this.log("client already connected. disconnecting first.")):(this.log("_reconnect: calling connect"),this.connect())}_setupReconnect(){!this.disconnecting&&!this.reconnectTimer&&this.options.reconnectPeriod>0?(this.reconnecting||(this.log("_setupReconnect :: emit `offline` state"),this.emit("offline"),this.log("_setupReconnect :: set `reconnecting` to `true`"),this.reconnecting=!0),this.log("_setupReconnect :: setting reconnectTimer for %d ms",this.options.reconnectPeriod),this.reconnectTimer=setInterval((()=>{this.log("reconnectTimer :: reconnect triggered!"),this._reconnect()}),this.options.reconnectPeriod)):this.log("_setupReconnect :: doing nothing...")}_clearReconnect(){this.log("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)}_cleanUp(e,t,i={}){if(t&&(this.log("_cleanUp :: done callback provided for on stream close"),this.stream.on("close",t)),this.log("_cleanUp :: forced? %s",e),e)0===this.options.reconnectPeriod&&this.options.clean&&this._flush(),this.log("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{const e=Object.assign({cmd:"disconnect"},i);this.log("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(e,(()=>{this.log("_cleanUp :: (%s) :: destroying stream",this.options.clientId),w((()=>{this.stream.end((()=>{this.log("_cleanUp :: (%s) :: stream destroyed",this.options.clientId)}))}))}))}this.disconnecting||this.reconnecting||(this.log("_cleanUp :: client not disconnecting/reconnecting. Clearing and resetting reconnect."),this._clearReconnect(),this._setupReconnect()),this._destroyKeepaliveManager(),t&&!this.connected&&(this.log("_cleanUp :: (%s) :: removing stream `done` callback `close` listener",this.options.clientId),this.stream.removeListener("close",t),t())}_storeAndSend(e,t,i){this.log("storeAndSend :: store packet with cmd %s to outgoingStore",e.cmd);let n,o=e;if("publish"===o.cmd&&(o=(0,u.default)(e),n=this._removeTopicAliasAndRecoverTopicName(o),n))return t&&t(n);this.outgoingStore.put(o,(n=>{if(n)return t&&t(n);i(),this._writePacket(e,t)}))}_applyTopicAlias(e){if(5===this.options.protocolVersion&&"publish"===e.cmd){let t;e.properties&&(t=e.properties.topicAlias);const i=e.topic.toString();if(this.topicAliasSend)if(t){if(0!==i.length&&(this.log("applyTopicAlias :: register topic: %s - alias: %d",i,t),!this.topicAliasSend.put(i,t)))return this.log("applyTopicAlias :: error out of range. topic: %s - alias: %d",i,t),new Error("Sending Topic Alias out of range")}else 0!==i.length&&(this.options.autoAssignTopicAlias?(t=this.topicAliasSend.getAliasByTopic(i),t?(e.topic="",e.properties=Object.assign(Object.assign({},e.properties),{topicAlias:t}),this.log("applyTopicAlias :: auto assign(use) topic: %s - alias: %d",i,t)):(t=this.topicAliasSend.getLruAlias(),this.topicAliasSend.put(i,t),e.properties=Object.assign(Object.assign({},e.properties),{topicAlias:t}),this.log("applyTopicAlias :: auto assign topic: %s - alias: %d",i,t))):this.options.autoUseTopicAlias&&(t=this.topicAliasSend.getAliasByTopic(i),t&&(e.topic="",e.properties=Object.assign(Object.assign({},e.properties),{topicAlias:t}),this.log("applyTopicAlias :: auto use topic: %s - alias: %d",i,t))));else if(t)return this.log("applyTopicAlias :: error out of range. topic: %s - alias: %d",i,t),new Error("Sending Topic Alias out of range")}}_noop(e){this.log("noop ::",e)}_writePacket(e,t){this.log("_writePacket :: packet: %O",e),this.log("_writePacket :: emitting `packetsend`"),this.emit("packetsend",e),this.log("_writePacket :: writing to stream");const i=c.default.writeToStream(e,this.stream,this.options);this.log("_writePacket :: writeToStream result %s",i),!i&&t&&t!==this.noop?(this.log("_writePacket :: handle events on `drain` once through callback."),this.stream.once("drain",t)):t&&(this.log("_writePacket :: invoking cb"),t())}_sendPacket(e,t,i,n){this.log("_sendPacket :: (%s) :: start",this.options.clientId),i=i||this.noop,t=t||this.noop;const o=this._applyTopicAlias(e);if(o)t(o);else{if(!this.connected)return"auth"===e.cmd?void this._writePacket(e,t):(this.log("_sendPacket :: client not connected. Storing packet offline."),void this._storePacket(e,t,i));if(n)this._writePacket(e,t);else{switch(e.cmd){case"publish":break;case"pubrel":return void this._storeAndSend(e,t,i);default:return void this._writePacket(e,t)}switch(e.qos){case 2:case 1:this._storeAndSend(e,t,i);break;default:this._writePacket(e,t)}this.log("_sendPacket :: (%s) :: end",this.options.clientId)}}}_storePacket(e,t,i){this.log("_storePacket :: packet: %o",e),this.log("_storePacket :: cb? %s",!!t),i=i||this.noop;let n=e;if("publish"===n.cmd){n=(0,u.default)(e);const i=this._removeTopicAliasAndRecoverTopicName(n);if(i)return t&&t(i)}const o=n.qos||0;0===o&&this.queueQoSZero||"publish"!==n.cmd?this.queue.push({packet:n,cb:t}):o>0?(t=this.outgoing[n.messageId]?this.outgoing[n.messageId].cb:null,this.outgoingStore.put(n,(e=>{if(e)return t&&t(e);i()}))):t&&t(new Error("No connection to broker"))}_setupKeepaliveManager(){this.log("_setupKeepaliveManager :: keepalive %d (seconds)",this.options.keepalive),!this.keepaliveManager&&this.options.keepalive&&(this.keepaliveManager=new y.default(this,this.options.timerVariant))}_destroyKeepaliveManager(){this.keepaliveManager&&(this.log("_destroyKeepaliveManager :: destroying keepalive manager"),this.keepaliveManager.destroy(),this.keepaliveManager=null)}reschedulePing(e=!1){this.keepaliveManager&&this.options.keepalive&&(e||this.options.reschedulePings)&&this._reschedulePing()}_reschedulePing(){this.log("_reschedulePing :: rescheduling ping"),this.keepaliveManager.reschedule()}sendPing(){this.log("_sendPing :: sending pingreq"),this._sendPacket({cmd:"pingreq"})}onKeepaliveTimeout(){this.emit("error",new Error("Keepalive timeout")),this.log("onKeepaliveTimeout :: calling _cleanUp with force true"),this._cleanUp(!0)}_resubscribe(){this.log("_resubscribe");const e=Object.keys(this._resubscribeTopics);if(!this._firstConnection&&(this.options.clean||this.options.protocolVersion>=4&&!this.connackPacket.sessionPresent)&&e.length>0)if(this.options.resubscribe)if(5===this.options.protocolVersion){this.log("_resubscribe: protocolVersion 5");for(let t=0;t<e.length;t++){const i={};i[e[t]]=this._resubscribeTopics[e[t]],i.resubscribe=!0,this.subscribe(i,{properties:i[e[t]].properties})}}else this._resubscribeTopics.resubscribe=!0,this.subscribe(this._resubscribeTopics);else this._resubscribeTopics={};this._firstConnection=!1}_onConnect(e){if(this.disconnected)return void this.emit("connect",e);this.connackPacket=e,this.messageIdProvider.clear(),this._setupKeepaliveManager(),this.connected=!0;const t=()=>{let i=this.outgoingStore.createStream();const n=()=>{i.destroy(),i=null,this._flushStoreProcessingQueue(),o()},o=()=>{this._storeProcessing=!1,this._packetIdsDuringStoreProcessing={}};this.once("close",n),i.on("error",(e=>{o(),this._flushStoreProcessingQueue(),this.removeListener("close",n),this.emit("error",e)}));const r=()=>{if(!i)return;const e=i.read(1);let t;e?(this._storeProcessing=!0,this._packetIdsDuringStoreProcessing[e.messageId]?r():this.disconnecting||this.reconnectTimer?i.destroy&&i.destroy():(t=this.outgoing[e.messageId]?this.outgoing[e.messageId].cb:null,this.outgoing[e.messageId]={volatile:!1,cb(e,i){t&&t(e,i),r()}},this._packetIdsDuringStoreProcessing[e.messageId]=!0,this.messageIdProvider.register(e.messageId)?this._sendPacket(e,void 0,void 0,!0):this.log("messageId: %d has already used.",e.messageId))):i.once("readable",r)};i.on("end",(()=>{let i=!0;for(const e in this._packetIdsDuringStoreProcessing)if(!this._packetIdsDuringStoreProcessing[e]){i=!1;break}this.removeListener("close",n),i?(o(),this._invokeAllStoreProcessingQueue(),this.emit("connect",e)):t()})),r()};t()}_invokeStoreProcessingQueue(){if(!this._storeProcessing&&this._storeProcessingQueue.length>0){const e=this._storeProcessingQueue[0];if(e&&e.invoke())return this._storeProcessingQueue.shift(),!0}return!1}_invokeAllStoreProcessingQueue(){for(;this._invokeStoreProcessingQueue(););}_flushStoreProcessingQueue(){for(const e of this._storeProcessingQueue)e.cbStorePut&&e.cbStorePut(new Error("Connection closed")),e.callback&&e.callback(new Error("Connection closed"));this._storeProcessingQueue.splice(0)}_removeOutgoingAndStoreMessage(e,t){delete this.outgoing[e],this.outgoingStore.del({messageId:e},((i,n)=>{t(i,n),this.messageIdProvider.deallocate(e),this._invokeStoreProcessingQueue()}))}}S.VERSION=g.MQTTJS_VERSION,t.default=S},1792:function(e,t,i){(function(){"use strict";var e,n,o,r,s={}.hasOwnProperty;n=i(8732),e=i(4495),o=i(4797),r=i(7443),t.defaults=n.defaults,t.processors=r,t.ValidationError=function(){function e(e){this.message=e}return function(e,t){for(var i in t)s.call(t,i)&&(e[i]=t[i]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(e,Error),e}(),t.Builder=e.Builder,t.Parser=o.Parser,t.parseString=o.parseString,t.parseStringPromise=o.parseStringPromise}).call(this)},1808:(e,t,i)=>{"use strict";const{ArrayIsArray:n,ObjectSetPrototypeOf:o}=i(3383),{EventEmitter:r}=i(4434);function s(e){r.call(this,e)}function a(e,t,i){if("function"==typeof e.prependListener)return e.prependListener(t,i);e._events&&e._events[t]?n(e._events[t])?e._events[t].unshift(i):e._events[t]=[i,e._events[t]]:e.on(t,i)}o(s.prototype,r.prototype),o(s,r),s.prototype.pipe=function(e,t){const i=this;function n(t){e.writable&&!1===e.write(t)&&i.pause&&i.pause()}function o(){i.readable&&i.resume&&i.resume()}i.on("data",n),e.on("drain",o),e._isStdio||t&&!1===t.end||(i.on("end",c),i.on("close",l));let s=!1;function c(){s||(s=!0,e.end())}function l(){s||(s=!0,"function"==typeof e.destroy&&e.destroy())}function p(e){u(),0===r.listenerCount(this,"error")&&this.emit("error",e)}function u(){i.removeListener("data",n),e.removeListener("drain",o),i.removeListener("end",c),i.removeListener("close",l),i.removeListener("error",p),e.removeListener("error",p),i.removeListener("end",u),i.removeListener("close",u),e.removeListener("close",u)}return a(i,"error",p),a(e,"error",p),i.on("end",u),i.on("close",u),e.on("close",u),e.emit("pipe",i),e},e.exports={Stream:s,prependListener:a}},1832:e=>{function t(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}t.keys=()=>[],t.resolve=t,t.id=1832,e.exports=t},1922:(e,t,i)=>{"use strict";const{Buffer:n}=i(181),o=Symbol.for("BufferList");function r(e){if(!(this instanceof r))return new r(e);r._init.call(this,e)}r._init=function(e){Object.defineProperty(this,o,{value:!0}),this._bufs=[],this.length=0,e&&this.append(e)},r.prototype._new=function(e){return new r(e)},r.prototype._offset=function(e){if(0===e)return[0,0];let t=0;for(let i=0;i<this._bufs.length;i++){const n=t+this._bufs[i].length;if(e<n||i===this._bufs.length-1)return[i,e-t];t=n}},r.prototype._reverseOffset=function(e){const t=e[0];let i=e[1];for(let e=0;e<t;e++)i+=this._bufs[e].length;return i},r.prototype.get=function(e){if(e>this.length||e<0)return;const t=this._offset(e);return this._bufs[t[0]][t[1]]},r.prototype.slice=function(e,t){return"number"==typeof e&&e<0&&(e+=this.length),"number"==typeof t&&t<0&&(t+=this.length),this.copy(null,0,e,t)},r.prototype.copy=function(e,t,i,o){if(("number"!=typeof i||i<0)&&(i=0),("number"!=typeof o||o>this.length)&&(o=this.length),i>=this.length)return e||n.alloc(0);if(o<=0)return e||n.alloc(0);const r=!!e,s=this._offset(i),a=o-i;let c=a,l=r&&t||0,p=s[1];if(0===i&&o===this.length){if(!r)return 1===this._bufs.length?this._bufs[0]:n.concat(this._bufs,this.length);for(let t=0;t<this._bufs.length;t++)this._bufs[t].copy(e,l),l+=this._bufs[t].length;return e}if(c<=this._bufs[s[0]].length-p)return r?this._bufs[s[0]].copy(e,t,p,p+c):this._bufs[s[0]].slice(p,p+c);r||(e=n.allocUnsafe(a));for(let t=s[0];t<this._bufs.length;t++){const i=this._bufs[t].length-p;if(!(c>i)){this._bufs[t].copy(e,l,p,p+c),l+=i;break}this._bufs[t].copy(e,l,p),l+=i,c-=i,p&&(p=0)}return e.length>l?e.slice(0,l):e},r.prototype.shallowSlice=function(e,t){if(e=e||0,t="number"!=typeof t?this.length:t,e<0&&(e+=this.length),t<0&&(t+=this.length),e===t)return this._new();const i=this._offset(e),n=this._offset(t),o=this._bufs.slice(i[0],n[0]+1);return 0===n[1]?o.pop():o[o.length-1]=o[o.length-1].slice(0,n[1]),0!==i[1]&&(o[0]=o[0].slice(i[1])),this._new(o)},r.prototype.toString=function(e,t,i){return this.slice(t,i).toString(e)},r.prototype.consume=function(e){if(e=Math.trunc(e),Number.isNaN(e)||e<=0)return this;for(;this._bufs.length;){if(!(e>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},r.prototype.duplicate=function(){const e=this._new();for(let t=0;t<this._bufs.length;t++)e.append(this._bufs[t]);return e},r.prototype.append=function(e){if(null==e)return this;if(e.buffer)this._appendBuffer(n.from(e.buffer,e.byteOffset,e.byteLength));else if(Array.isArray(e))for(let t=0;t<e.length;t++)this.append(e[t]);else if(this._isBufferList(e))for(let t=0;t<e._bufs.length;t++)this.append(e._bufs[t]);else"number"==typeof e&&(e=e.toString()),this._appendBuffer(n.from(e));return this},r.prototype._appendBuffer=function(e){this._bufs.push(e),this.length+=e.length},r.prototype.indexOf=function(e,t,i){if(void 0===i&&"string"==typeof t&&(i=t,t=void 0),"function"==typeof e||Array.isArray(e))throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.');if("number"==typeof e?e=n.from([e]):"string"==typeof e?e=n.from(e,i):this._isBufferList(e)?e=e.slice():Array.isArray(e.buffer)?e=n.from(e.buffer,e.byteOffset,e.byteLength):n.isBuffer(e)||(e=n.from(e)),t=Number(t||0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),0===e.length)return t>this.length?this.length:t;const o=this._offset(t);let r=o[0],s=o[1];for(;r<this._bufs.length;r++){const t=this._bufs[r];for(;s<t.length;){if(t.length-s>=e.length){const i=t.indexOf(e,s);if(-1!==i)return this._reverseOffset([r,i]);s=t.length-e.length+1}else{const t=this._reverseOffset([r,s]);if(this._match(t,e))return t;s++}}s=0}return-1},r.prototype._match=function(e,t){if(this.length-e<t.length)return!1;for(let i=0;i<t.length;i++)if(this.get(e+i)!==t[i])return!1;return!0},function(){const e={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readBigInt64BE:8,readBigInt64LE:8,readBigUInt64BE:8,readBigUInt64LE:8,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1,readIntBE:null,readIntLE:null,readUIntBE:null,readUIntLE:null};for(const t in e)!function(t){r.prototype[t]=null===e[t]?function(e,i){return this.slice(e,e+i)[t](0,i)}:function(i=0){return this.slice(i,i+e[t])[t](0)}}(t)}(),r.prototype._isBufferList=function(e){return e instanceof r||r.isBufferList(e)},r.isBufferList=function(e){return null!=e&&e[o]},e.exports=r},1926:function(e){(function(){e.exports={None:0,OpenTag:1,InsideTag:2,CloseTag:3}}).call(this)},1942:function(e){(function(){e.exports=function(){function e(e){this.arr=e||[]}return Object.defineProperty(e.prototype,"length",{get:function(){return this.arr.length}}),e.prototype.item=function(e){return this.arr[e]||null},e.prototype.contains=function(e){return-1!==this.arr.indexOf(e)},e}()}).call(this)},1956:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=i(3901);t.default=class{constructor(){this.numberAllocator=new n.NumberAllocator(1,65535)}allocate(){return this.lastId=this.numberAllocator.alloc(),this.lastId}getLastAllocated(){return this.lastId}register(e){return this.numberAllocator.use(e)}deallocate(e){this.numberAllocator.free(e)}clear(){this.numberAllocator.clear()}}},1995:function(e,t,i){(function(){var t,n,o,r={}.hasOwnProperty;t=i(5068),o=i(8945),n=i(1926),e.exports=function(e){function i(e,t){this.stream=e,i.__super__.constructor.call(this,t)}return function(e,t){for(var i in t)r.call(t,i)&&(e[i]=t[i]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(i,e),i.prototype.endline=function(e,t,o){return e.isLastRootNode&&t.state===n.CloseTag?"":i.__super__.endline.call(this,e,t,o)},i.prototype.document=function(e,t){var i,n,o,r,s,a,c,l,p;for(n=o=0,s=(c=e.children).length;o<s;n=++o)(i=c[n]).isLastRootNode=n===e.children.length-1;for(t=this.filterOptions(t),p=[],r=0,a=(l=e.children).length;r<a;r++)i=l[r],p.push(this.writeChildNode(i,t,0));return p},i.prototype.attribute=function(e,t,n){return this.stream.write(i.__super__.attribute.call(this,e,t,n))},i.prototype.cdata=function(e,t,n){return this.stream.write(i.__super__.cdata.call(this,e,t,n))},i.prototype.comment=function(e,t,n){return this.stream.write(i.__super__.comment.call(this,e,t,n))},i.prototype.declaration=function(e,t,n){return this.stream.write(i.__super__.declaration.call(this,e,t,n))},i.prototype.docType=function(e,t,i){var o,r,s,a;if(i||(i=0),this.openNode(e,t,i),t.state=n.OpenTag,this.stream.write(this.indent(e,t,i)),this.stream.write("<!DOCTYPE "+e.root().name),e.pubID&&e.sysID?this.stream.write(' PUBLIC "'+e.pubID+'" "'+e.sysID+'"'):e.sysID&&this.stream.write(' SYSTEM "'+e.sysID+'"'),e.children.length>0){for(this.stream.write(" ["),this.stream.write(this.endline(e,t,i)),t.state=n.InsideTag,r=0,s=(a=e.children).length;r<s;r++)o=a[r],this.writeChildNode(o,t,i+1);t.state=n.CloseTag,this.stream.write("]")}return t.state=n.CloseTag,this.stream.write(t.spaceBeforeSlash+">"),this.stream.write(this.endline(e,t,i)),t.state=n.None,this.closeNode(e,t,i)},i.prototype.element=function(e,i,o){var s,a,c,l,p,u,d,h,m;for(d in o||(o=0),this.openNode(e,i,o),i.state=n.OpenTag,this.stream.write(this.indent(e,i,o)+"<"+e.name),h=e.attribs)r.call(h,d)&&(s=h[d],this.attribute(s,i,o));if(l=0===(c=e.children.length)?null:e.children[0],0===c||e.children.every((function(e){return(e.type===t.Text||e.type===t.Raw)&&""===e.value})))i.allowEmpty?(this.stream.write(">"),i.state=n.CloseTag,this.stream.write("</"+e.name+">")):(i.state=n.CloseTag,this.stream.write(i.spaceBeforeSlash+"/>"));else if(!i.pretty||1!==c||l.type!==t.Text&&l.type!==t.Raw||null==l.value){for(this.stream.write(">"+this.endline(e,i,o)),i.state=n.InsideTag,p=0,u=(m=e.children).length;p<u;p++)a=m[p],this.writeChildNode(a,i,o+1);i.state=n.CloseTag,this.stream.write(this.indent(e,i,o)+"</"+e.name+">")}else this.stream.write(">"),i.state=n.InsideTag,i.suppressPrettyCount++,this.writeChildNode(l,i,o+1),i.suppressPrettyCount--,i.state=n.CloseTag,this.stream.write("</"+e.name+">");return this.stream.write(this.endline(e,i,o)),i.state=n.None,this.closeNode(e,i,o)},i.prototype.processingInstruction=function(e,t,n){return this.stream.write(i.__super__.processingInstruction.call(this,e,t,n))},i.prototype.raw=function(e,t,n){return this.stream.write(i.__super__.raw.call(this,e,t,n))},i.prototype.text=function(e,t,n){return this.stream.write(i.__super__.text.call(this,e,t,n))},i.prototype.dtdAttList=function(e,t,n){return this.stream.write(i.__super__.dtdAttList.call(this,e,t,n))},i.prototype.dtdElement=function(e,t,n){return this.stream.write(i.__super__.dtdElement.call(this,e,t,n))},i.prototype.dtdEntity=function(e,t,n){return this.stream.write(i.__super__.dtdEntity.call(this,e,t,n))},i.prototype.dtdNotation=function(e,t,n){return this.stream.write(i.__super__.dtdNotation.call(this,e,t,n))},i}(o)}).call(this)},2018:e=>{"use strict";e.exports=require("tty")},2032:function(e,t,i){(function(){var t,n,o,r={}.hasOwnProperty;o=i(5502).isObject,n=i(8711),t=i(5068),e.exports=function(e){function i(e,n,r,s){if(i.__super__.constructor.call(this,e),null==r)throw new Error("Missing DTD entity name. "+this.debugInfo(r));if(null==s)throw new Error("Missing DTD entity value. "+this.debugInfo(r));if(this.pe=!!n,this.name=this.stringify.name(r),this.type=t.EntityDeclaration,o(s)){if(!s.pubID&&!s.sysID)throw new Error("Public and/or system identifiers are required for an external entity. "+this.debugInfo(r));if(s.pubID&&!s.sysID)throw new Error("System identifier is required for a public external entity. "+this.debugInfo(r));if(this.internal=!1,null!=s.pubID&&(this.pubID=this.stringify.dtdPubID(s.pubID)),null!=s.sysID&&(this.sysID=this.stringify.dtdSysID(s.sysID)),null!=s.nData&&(this.nData=this.stringify.dtdNData(s.nData)),this.pe&&this.nData)throw new Error("Notation declaration is not allowed in a parameter entity. "+this.debugInfo(r))}else this.value=this.stringify.dtdEntityValue(s),this.internal=!0}return function(e,t){for(var i in t)r.call(t,i)&&(e[i]=t[i]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(i,e),Object.defineProperty(i.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(i.prototype,"systemId",{get:function(){return this.sysID}}),Object.defineProperty(i.prototype,"notationName",{get:function(){return this.nData||null}}),Object.defineProperty(i.prototype,"inputEncoding",{get:function(){return null}}),Object.defineProperty(i.prototype,"xmlEncoding",{get:function(){return null}}),Object.defineProperty(i.prototype,"xmlVersion",{get:function(){return null}}),i.prototype.toString=function(e){return this.options.writer.dtdEntity(this,this.options.writer.filterOptions(e))},i}(n)}).call(this)},2122:function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.splitDateRangeByDay=t.parseVideoclipName=t.findStartTimeFromFileName=t.getThumbnailMediaObject=t.cleanup=t.getFolderPaths=t.pluginId=void 0;const o=n(i(6928)),r=n(i(9896)),s=n(i(7016)),a=i(5091),c=n(i(3861)),{mediaManager:l}=c.default;t.pluginId=a.name;t.getFolderPaths=(e,t)=>{let i=t;i||(i=process.env.SCRYPTED_PLUGIN_VOLUME);const n=o.default.join(i,"thumbnails",e);return r.default.existsSync(n)||r.default.mkdirSync(n,{recursive:!0}),{thumbnailFolder:n}};t.cleanup=e=>{let t=e;t||(t=process.env.SCRYPTED_PLUGIN_VOLUME);const i=o.default.join(t,"thumbnails");r.default.existsSync(i)&&r.default.rmSync(i,{recursive:!0,force:!0})};t.getThumbnailMediaObject=async e=>{const{filename:t,thumbnailFolder:i,videoclipUrl:n,console:a}=e,c=t.replaceAll(" ","_"),p=o.default.join(i,`${c}.jpg`);let u;try{if(r.default.existsSync(p)&&0===r.default.statSync(p).size&&(a.log(`Thumbnail ${p} corrupted, removing.`),r.default.rmSync(p)),!r.default.existsSync(p)){a.log(`Thumbnail not found in ${p}, generating.`);const e=await l.createFFmpegMediaObject({inputArguments:["-ss","00:00:05","-i",n]}),t=await l.convertMediaObjectToBuffer(e,"image/jpeg");t.length?(a.log(`Saving thumbnail in ${p}`),await r.default.promises.writeFile(p,t)):a.log("Not saving, image is corrupted")}if(r.default.existsSync(p)){const e=s.default.pathToFileURL(p).toString();u=await l.createMediaObjectFromUrl(e)}return{thumbnailMo:u}}catch(e){return a.error(`Error retrieving thumbnail of videoclip ${c} (${n})`,e),r.default.existsSync(p)&&r.default.rmSync(p),{}}};t.findStartTimeFromFileName=e=>{const t=/.*Rec(\w{3})(?:_|_DST)(\d{8})_(\d{6})_.*/gm;let i;const n=[];for(;null!==(i=t.exec(e));)i.index===t.lastIndex&&t.lastIndex++,i.forEach(((e,t)=>{n.push(e)}));return`${n[2]}${n[3]}`};const p={resolution_index:[0,7],tv_system:[7,1],framerate:[8,7],audio_index:[15,2],ai_pd:[17,1],ai_fd:[18,1],ai_vd:[19,1],ai_ad:[20,1],encoder_type_index:[21,2],is_schedule_record:[23,1],is_motion_record:[24,1],is_rf_record:[25,1],is_doorbell_record:[26,1],ai_other:[27,1]},u={resolution_index:[0,7],tv_system:[7,1],framerate:[8,7],audio_index:[15,2],ai_pd:[17,1],ai_fd:[18,1],ai_vd:[19,1],ai_ad:[20,1],encoder_type_index:[21,2],is_schedule_record:[23,1],is_motion_record:[24,1],is_rf_record:[25,1],is_doorbell_record:[26,1],is_ai_other_record:[27,1],picture_layout_index:[28,7],package_delivered:[35,1],package_takenaway:[36,1]},d={cam:{2:p,3:p,4:p,9:p},hub:{0:u,1:{...u,package_event:[37,1]},2:{resolution_index:[0,7],tv_system:[7,1],framerate:[8,7],audio_index:[15,2],ai_pd:[17,1],ai_fd:[18,1],ai_vd:[19,1],ai_ad:[20,1],ai_other:[21,2],encoder_type_index:[23,1],is_schedule_record:[24,1],is_motion_record:[25,1],is_rf_record:[26,1],is_doorbell_record:[27,1],picture_layout_index:[28,7],package_delivered:[35,1],package_takenaway:[36,1],package_event:[37,1],upload_flag:[38,1]}}};t.parseVideoclipName=(e,t)=>{try{const t=e.split("/").pop(),i=t.split(".")[0].split("_");let n,o;const r=parseInt(i[0].substring(4,6),16);let s;6===i.length?(s="cam",n=i[4],o=i[5]):9===i.length&&(s="hub",n=i[7],o=i[8]);const a=parseInt(n,16),c=parseInt(a.toString(2).padStart(4*n.length,"0").split("").reverse().join(""),2),l={};let p=d[s][r];"hub"===s&&4===r&&(p=d[s][2]);for(const[e,[t,i]]of Object.entries(p)){const n=parseInt(((c&(1<<i)-1<<t)>>t).toString(2).padStart(i,"0").split("").reverse().join(""),2);l[e]=n}const u=Number(`0x${o}`),h=[];return 1===l.ai_pd&&h.push("person"),1===l.ai_vd&&h.push("vehicle"),1===l.ai_fd&&h.push("face"),1===l.ai_ad&&h.push("animal"),1!==l.is_motion_record&&1!==l.ai_other||h.push("motion"),{size:u,detectionClasses:h}}catch(t){console.error("Error parsing the filename",e,t)}};t.splitDateRangeByDay=(e,t)=>{const i=[];let n=new Date(e);const o=new Date(t);for(;n<=o;){const e=new Date(n);e.setHours(23,59,59,999);const t=o<e?o:e;if(i.push({start:new Date(n).getTime(),end:new Date(t).getTime()}),t>=o)break;n=new Date(t.getTime()+1)}return i}},2144:(e,t,i)=>{"use strict";const{ArrayPrototypePop:n,Promise:o}=i(3383),{isIterable:r,isNodeStream:s,isWebStream:a}=i(6274),{pipelineImpl:c}=i(5101),{finished:l}=i(9071);i(7719),e.exports={finished:l,pipeline:function(...e){return new o(((t,i)=>{let o,l;const p=e[e.length-1];if(p&&"object"==typeof p&&!s(p)&&!r(p)&&!a(p)){const t=n(e);o=t.signal,l=t.end}c(e,((e,n)=>{e?i(e):t(n)}),{signal:o,end:l})}))}}},2189:function(e,t,i){(function(){var t,n,o,r,s,a,c,l,p={}.hasOwnProperty;l=i(5502).isObject,c=i(8711),t=i(5068),n=i(2328),r=i(2032),o=i(4423),s=i(4061),a=i(6838),e.exports=function(e){function i(e,n,o){var r,s,a,c,p,u;if(i.__super__.constructor.call(this,e),this.type=t.DocType,e.children)for(s=0,a=(c=e.children).length;s<a;s++)if((r=c[s]).type===t.Element){this.name=r.name;break}this.documentObject=e,l(n)&&(n=(p=n).pubID,o=p.sysID),null==o&&(o=(u=[n,o])[0],n=u[1]),null!=n&&(this.pubID=this.stringify.dtdPubID(n)),null!=o&&(this.sysID=this.stringify.dtdSysID(o))}return function(e,t){for(var i in t)p.call(t,i)&&(e[i]=t[i]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(i,e),Object.defineProperty(i.prototype,"entities",{get:function(){var e,i,n,o,r;for(o={},i=0,n=(r=this.children).length;i<n;i++)(e=r[i]).type!==t.EntityDeclaration||e.pe||(o[e.name]=e);return new a(o)}}),Object.defineProperty(i.prototype,"notations",{get:function(){var e,i,n,o,r;for(o={},i=0,n=(r=this.children).length;i<n;i++)(e=r[i]).type===t.NotationDeclaration&&(o[e.name]=e);return new a(o)}}),Object.defineProperty(i.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(i.prototype,"systemId",{get:function(){return this.sysID}}),Object.defineProperty(i.prototype,"internalSubset",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),i.prototype.element=function(e,t){var i;return i=new o(this,e,t),this.children.push(i),this},i.prototype.attList=function(e,t,i,o,r){var s;return s=new n(this,e,t,i,o,r),this.children.push(s),this},i.prototype.entity=function(e,t){var i;return i=new r(this,!1,e,t),this.children.push(i),this},i.prototype.pEntity=function(e,t){var i;return i=new r(this,!0,e,t),this.children.push(i),this},i.prototype.notation=function(e,t){var i;return i=new s(this,e,t),this.children.push(i),this},i.prototype.toString=function(e){return this.options.writer.docType(this,this.options.writer.filterOptions(e))},i.prototype.ele=function(e,t){return this.element(e,t)},i.prototype.att=function(e,t,i,n,o){return this.attList(e,t,i,n,o)},i.prototype.ent=function(e,t){return this.entity(e,t)},i.prototype.pent=function(e,t){return this.pEntity(e,t)},i.prototype.not=function(e,t){return this.notation(e,t)},i.prototype.up=function(){return this.root()||this.documentObject},i.prototype.isEqualNode=function(e){return!!i.__super__.isEqualNode.apply(this,arguments).isEqualNode(e)&&(e.name===this.name&&(e.publicId===this.publicId&&e.systemId===this.systemId))},i}(c)}).call(this)},2203:e=>{"use strict";e.exports=require("stream")},2328:function(e,t,i){(function(){var t,n,o={}.hasOwnProperty;n=i(8711),t=i(5068),e.exports=function(e){function i(e,n,o,r,s,a){if(i.__super__.constructor.call(this,e),null==n)throw new Error("Missing DTD element name. "+this.debugInfo());if(null==o)throw new Error("Missing DTD attribute name. "+this.debugInfo(n));if(!r)throw new Error("Missing DTD attribute type. "+this.debugInfo(n));if(!s)throw new Error("Missing DTD attribute default. "+this.debugInfo(n));if(0!==s.indexOf("#")&&(s="#"+s),!s.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/))throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. "+this.debugInfo(n));if(a&&!s.match(/^(#FIXED|#DEFAULT)$/))throw new Error("Default value only applies to #FIXED or #DEFAULT. "+this.debugInfo(n));this.elementName=this.stringify.name(n),this.type=t.AttributeDeclaration,this.attributeName=this.stringify.name(o),this.attributeType=this.stringify.dtdAttType(r),a&&(this.defaultValue=this.stringify.dtdAttDefault(a)),this.defaultValueType=s}return function(e,t){for(var i in t)o.call(t,i)&&(e[i]=t[i]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(i,e),i.prototype.toString=function(e){return this.options.writer.dtdAttList(this,this.options.writer.filterOptions(e))},i}(n)}).call(this)},2354:(e,t,i)=>{"use strict";const{ArrayIsArray:n,ArrayPrototypeIncludes:o,ArrayPrototypeJoin:r,ArrayPrototypeMap:s,NumberIsInteger:a,NumberIsNaN:c,NumberMAX_SAFE_INTEGER:l,NumberMIN_SAFE_INTEGER:p,NumberParseInt:u,ObjectPrototypeHasOwnProperty:d,RegExpPrototypeExec:h,String:m,StringPrototypeToUpperCase:f,StringPrototypeTrim:g}=i(3383),{hideStackFrames:v,codes:{ERR_SOCKET_BAD_PORT:y,ERR_INVALID_ARG_TYPE:b,ERR_INVALID_ARG_VALUE:w,ERR_OUT_OF_RANGE:_,ERR_UNKNOWN_SIGNAL:S}}=i(676),{normalizeEncoding:x}=i(3939),{isAsyncFunction:T,isArrayBufferView:E}=i(3939).types,C={};const P=/^[0-7]+$/;const k=v(((e,t,i=p,n=l)=>{if("number"!=typeof e)throw new b(t,"number",e);if(!a(e))throw new _(t,"an integer",e);if(e<i||e>n)throw new _(t,`>= ${i} && <= ${n}`,e)})),O=v(((e,t,i=-2147483648,n=2147483647)=>{if("number"!=typeof e)throw new b(t,"number",e);if(!a(e))throw new _(t,"an integer",e);if(e<i||e>n)throw new _(t,`>= ${i} && <= ${n}`,e)})),I=v(((e,t,i=!1)=>{if("number"!=typeof e)throw new b(t,"number",e);if(!a(e))throw new _(t,"an integer",e);const n=i?1:0,o=4294967295;if(e<n||e>o)throw new _(t,`>= ${n} && <= ${o}`,e)}));function A(e,t){if("string"!=typeof e)throw new b(t,"string",e)}const R=v(((e,t,i)=>{if(!o(i,e)){const n=r(s(i,(e=>"string"==typeof e?`'${e}'`:m(e))),", ");throw new w(t,e,"must be one of: "+n)}}));function D(e,t){if("boolean"!=typeof e)throw new b(t,"boolean",e)}function M(e,t,i){return null!=e&&d(e,t)?e[t]:i}const N=v(((e,t,i=null)=>{const o=M(i,"allowArray",!1),r=M(i,"allowFunction",!1);if(!M(i,"nullable",!1)&&null===e||!o&&n(e)||"object"!=typeof e&&(!r||"function"!=typeof e))throw new b(t,"Object",e)})),L=v(((e,t)=>{if(null!=e&&"object"!=typeof e&&"function"!=typeof e)throw new b(t,"a dictionary",e)})),j=v(((e,t,i=0)=>{if(!n(e))throw new b(t,"Array",e);if(e.length<i){throw new w(t,e,`must be longer than ${i}`)}}));const F=v(((e,t="buffer")=>{if(!E(e))throw new b(t,["Buffer","TypedArray","DataView"],e)}));const B=v(((e,t)=>{if(void 0!==e&&(null===e||"object"!=typeof e||!("aborted"in e)))throw new b(t,"AbortSignal",e)})),U=v(((e,t)=>{if("function"!=typeof e)throw new b(t,"Function",e)})),q=v(((e,t)=>{if("function"!=typeof e||T(e))throw new b(t,"Function",e)})),V=v(((e,t)=>{if(void 0!==e)throw new b(t,"undefined",e)}));const H=/^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;function z(e,t){if("undefined"==typeof e||!h(H,e))throw new w(t,e,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}e.exports={isInt32:function(e){return e===(0|e)},isUint32:function(e){return e===e>>>0},parseFileMode:function(e,t,i){if("undefined"==typeof e&&(e=i),"string"==typeof e){if(null===h(P,e))throw new w(t,e,"must be a 32-bit unsigned integer or an octal string");e=u(e,8)}return I(e,t),e},validateArray:j,validateStringArray:function(e,t){j(e,t);for(let i=0;i<e.length;i++)A(e[i],`${t}[${i}]`)},validateBooleanArray:function(e,t){j(e,t);for(let i=0;i<e.length;i++)D(e[i],`${t}[${i}]`)},validateAbortSignalArray:function(e,t){j(e,t);for(let i=0;i<e.length;i++){const n=e[i],o=`${t}[${i}]`;if(null==n)throw new b(o,"AbortSignal",n);B(n,o)}},validateBoolean:D,validateBuffer:F,validateDictionary:L,validateEncoding:function(e,t){const i=x(t),n=e.length;if("hex"===i&&n%2!=0)throw new w("encoding",t,`is invalid for data of length ${n}`)},validateFunction:U,validateInt32:O,validateInteger:k,validateNumber:function(e,t,i=void 0,n){if("number"!=typeof e)throw new b(t,"number",e);if(null!=i&&e<i||null!=n&&e>n||(null!=i||null!=n)&&c(e))throw new _(t,`${null!=i?`>= ${i}`:""}${null!=i&&null!=n?" && ":""}${null!=n?`<= ${n}`:""}`,e)},validateObject:N,validateOneOf:R,validatePlainFunction:q,validatePort:function(e,t="Port",i=!0){if("number"!=typeof e&&"string"!=typeof e||"string"==typeof e&&0===g(e).length||+e!==+e>>>0||e>65535||0===e&&!i)throw new y(t,e,i);return 0|e},validateSignalName:function(e,t="signal"){if(A(e,t),void 0===C[e]){if(void 0!==C[f(e)])throw new S(e+" (signals must use all capital letters)");throw new S(e)}},validateString:A,validateUint32:I,validateUndefined:V,validateUnion:function(e,t,i){if(!o(i,e))throw new b(t,`('${r(i,"|")}')`,e)},validateAbortSignal:B,validateLinkHeaderValue:function(e){if("string"==typeof e)return z(e,"hints"),e;if(n(e)){const t=e.length;let i="";if(0===t)return i;for(let n=0;n<t;n++){const o=e[n];z(o,"hints"),i+=o,n!==t-1&&(i+=", ")}return i}throw new w("hints",e,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}}},2421:function(e,t,i){(function(){var t,n;t=i(6297),n=i(1942),e.exports=function(){function e(){this.defaultParams={"canonical-form":!1,"cdata-sections":!1,comments:!1,"datatype-normalization":!1,"element-content-whitespace":!0,entities:!0,"error-handler":new t,infoset:!0,"validate-if-schema":!1,namespaces:!0,"namespace-declarations":!0,"normalize-characters":!1,"schema-location":"","schema-type":"","split-cdata-sections":!0,validate:!1,"well-formed":!0},this.params=Object.create(this.defaultParams)}return Object.defineProperty(e.prototype,"parameterNames",{get:function(){return new n(Object.keys(this.defaultParams))}}),e.prototype.getParameter=function(e){return this.params.hasOwnProperty(e)?this.params[e]:null},e.prototype.canSetParameter=function(e,t){return!0},e.prototype.setParameter=function(e,t){return null!=t?this.params[e]=t:delete this.params[e]},e}()}).call(this)},2444:function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(i(3969));t.default=class{get keepaliveTimeoutTimestamp(){return this._keepaliveTimeoutTimestamp}get intervalEvery(){return this._intervalEvery}get keepalive(){return this._keepalive}constructor(e,t){this.destroyed=!1,this.client=e,this.timer="object"==typeof t&&"set"in t&&"clear"in t?t:(0,o.default)(t),this.setKeepalive(e.options.keepalive)}clear(){this.timerId&&(this.timer.clear(this.timerId),this.timerId=null)}setKeepalive(e){if(e*=1e3,isNaN(e)||e<=0||e>2147483647)throw new Error(`Keepalive value must be an integer between 0 and 2147483647. Provided value is ${e}`);this._keepalive=e,this.reschedule(),this.client.log(`KeepaliveManager: set keepalive to ${e}ms`)}destroy(){this.clear(),this.destroyed=!0}reschedule(){if(this.destroyed)return;this.clear(),this.counter=0;const e=Math.ceil(1.5*this._keepalive);this._keepaliveTimeoutTimestamp=Date.now()+e,this._intervalEvery=Math.ceil(this._keepalive/2),this.timerId=this.timer.set((()=>{this.destroyed||(this.counter+=1,2===this.counter?this.client.sendPing():this.counter>2&&this.client.onKeepaliveTimeout())}),this._intervalEvery)}}},2502:(e,t,i)=>{"undefined"==typeof process||"renderer"===process.type||!0===process.browser||process.__nwjs?e.exports=i(7766):e.exports=i(4668)},2514:(e,t,i)=>{"use strict";const n=i(857),o=i(2018),r=i(7373),{env:s}=process;let a;function c(e){return 0!==e&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function l(e,t){if(0===a)return 0;if(r("color=16m")||r("color=full")||r("color=truecolor"))return 3;if(r("color=256"))return 2;if(e&&!t&&void 0===a)return 0;const i=a||0;if("dumb"===s.TERM)return i;if("win32"===process.platform){const e=n.release().split(".");return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if("CI"in s)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some((e=>e in s))||"codeship"===s.CI_NAME?1:i;if("TEAMCITY_VERSION"in s)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(s.TEAMCITY_VERSION)?1:0;if("truecolor"===s.COLORTERM)return 3;if("TERM_PROGRAM"in s){const e=parseInt((s.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(s.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(s.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(s.TERM)||"COLORTERM"in s?1:i}r("no-color")||r("no-colors")||r("color=false")||r("color=never")?a=0:(r("color")||r("colors")||r("color=true")||r("color=always"))&&(a=1),"FORCE_COLOR"in s&&(a="true"===s.FORCE_COLOR?1:"false"===s.FORCE_COLOR?0:0===s.FORCE_COLOR.length?1:Math.min(parseInt(s.FORCE_COLOR,10),3)),e.exports={supportsColor:function(e){return c(l(e,e&&e.isTTY))},stdout:c(l(!0,o.isatty(1))),stderr:c(l(!0,o.isatty(2)))}},2574:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{constructor(){this.nextId=Math.max(1,Math.floor(65535*Math.random()))}allocate(){const e=this.nextId++;return 65536===this.nextId&&(this.nextId=1),e}getLastAllocated(){return 1===this.nextId?65535:this.nextId-1}register(e){return!0}deallocate(e){}clear(){}}},2613:e=>{"use strict";e.exports=require("assert")},2695:(e,t,i)=>{const n=i(7060),{Buffer:o}=i(181),r=o.allocUnsafe(0),s=o.from([0]),a=i(9815),c=i(3628).nextTick,l=i(8766)("mqtt-packet:writeToStream"),p=a.cache,u=a.generateNumber,d=a.generateCache,h=a.genBufVariableByteInt,m=a.generate4ByteBuffer;let f=x,g=!0;function v(e,t,i){switch(l("generate called"),t.cork&&(t.cork(),c(y,t)),g&&(g=!1,d()),l("generate: packet.cmd: %s",e.cmd),e.cmd){case"connect":return function(e,t){const i=e||{},r=i.protocolId||"MQTT";let s=i.protocolVersion||4;const a=i.will;let c=i.clean;const l=i.keepalive||0,p=i.clientId||"",u=i.username,d=i.password,h=i.properties;void 0===c&&(c=!0);let m,g,v=0;if(!r||"string"!=typeof r&&!o.isBuffer(r))return t.destroy(new Error("Invalid protocolId")),!1;v+=r.length+2;if(3!==s&&4!==s&&5!==s)return t.destroy(new Error("Invalid protocol version")),!1;v+=1;if(("string"==typeof p||o.isBuffer(p))&&(p||s>=4)&&(p||c))v+=o.byteLength(p)+2;else{if(s<4)return t.destroy(new Error("clientId must be supplied before 3.1.1")),!1;if(1*c==0)return t.destroy(new Error("clientId must be given if cleanSession set to 0")),!1}if("number"!=typeof l||l<0||l>65535||l%1!=0)return t.destroy(new Error("Invalid keepalive")),!1;v+=2;if(v+=1,5===s){if(m=C(t,h),!m)return!1;v+=m.length}if(a){if("object"!=typeof a)return t.destroy(new Error("Invalid will")),!1;if(!a.topic||"string"!=typeof a.topic)return t.destroy(new Error("Invalid will topic")),!1;if(v+=o.byteLength(a.topic)+2,v+=2,a.payload){if(!(a.payload.length>=0))return t.destroy(new Error("Invalid will payload")),!1;"string"==typeof a.payload?v+=o.byteLength(a.payload):v+=a.payload.length}if(g={},5===s){if(g=C(t,a.properties),!g)return!1;v+=g.length}}let y=!1;if(null!=u){if(!A(u))return t.destroy(new Error("Invalid username")),!1;y=!0,v+=o.byteLength(u)+2}if(null!=d){if(!y)return t.destroy(new Error("Username is required to use password")),!1;if(!A(d))return t.destroy(new Error("Invalid password")),!1;v+=I(d)+2}t.write(n.CONNECT_HEADER),w(t,v),E(t,r),i.bridgeMode&&(s+=128);t.write(131===s?n.VERSION131:132===s?n.VERSION132:4===s?n.VERSION4:5===s?n.VERSION5:n.VERSION3);let b=0;b|=null!=u?n.USERNAME_MASK:0,b|=null!=d?n.PASSWORD_MASK:0,b|=a&&a.retain?n.WILL_RETAIN_MASK:0,b|=a&&a.qos?a.qos<<n.WILL_QOS_SHIFT:0,b|=a?n.WILL_FLAG_MASK:0,b|=c?n.CLEAN_SESSION_MASK:0,t.write(o.from([b])),f(t,l),5===s&&m.write();E(t,p),a&&(5===s&&g.write(),_(t,a.topic),E(t,a.payload));null!=u&&E(t,u);null!=d&&E(t,d);return!0}(e,t);case"connack":return function(e,t,i){const r=i?i.protocolVersion:4,a=e||{},c=5===r?a.reasonCode:a.returnCode,l=a.properties;let p=2;if("number"!=typeof c)return t.destroy(new Error("Invalid return code")),!1;let u=null;if(5===r){if(u=C(t,l),!u)return!1;p+=u.length}t.write(n.CONNACK_HEADER),w(t,p),t.write(a.sessionPresent?n.SESSIONPRESENT_HEADER:s),t.write(o.from([c])),null!=u&&u.write();return!0}(e,t,i);case"publish":return function(e,t,i){l("publish: packet: %o",e);const s=i?i.protocolVersion:4,a=e||{},c=a.qos||0,p=a.retain?n.RETAIN_MASK:0,u=a.topic,d=a.payload||r,h=a.messageId,m=a.properties;let g=0;if("string"==typeof u)g+=o.byteLength(u)+2;else{if(!o.isBuffer(u))return t.destroy(new Error("Invalid topic")),!1;g+=u.length+2}o.isBuffer(d)?g+=d.length:g+=o.byteLength(d);if(c&&"number"!=typeof h)return t.destroy(new Error("Invalid messageId")),!1;c&&(g+=2);let v=null;if(5===s){if(v=C(t,m),!v)return!1;g+=v.length}t.write(n.PUBLISH_HEADER[c][a.dup?1:0][p?1:0]),w(t,g),f(t,I(u)),t.write(u),c>0&&f(t,h);null!=v&&v.write();return l("publish: payload: %o",d),t.write(d)}(e,t,i);case"puback":case"pubrec":case"pubrel":case"pubcomp":return function(e,t,i){const r=i?i.protocolVersion:4,s=e||{},a=s.cmd||"puback",c=s.messageId,l=s.dup&&"pubrel"===a?n.DUP_MASK:0;let p=0;const u=s.reasonCode,d=s.properties;let h=5===r?3:2;"pubrel"===a&&(p=1);if("number"!=typeof c)return t.destroy(new Error("Invalid messageId")),!1;let m=null;if(5===r&&"object"==typeof d){if(m=P(t,d,i,h),!m)return!1;h+=m.length}t.write(n.ACKS[a][p][l][0]),3===h&&(h+=0!==u?1:-1);w(t,h),f(t,c),5===r&&2!==h&&t.write(o.from([u]));null!==m?m.write():4===h&&t.write(o.from([0]));return!0}(e,t,i);case"subscribe":return function(e,t,i){l("subscribe: packet: ");const r=i?i.protocolVersion:4,s=e||{},a=s.dup?n.DUP_MASK:0,c=s.messageId,p=s.subscriptions,u=s.properties;let d=0;if("number"!=typeof c)return t.destroy(new Error("Invalid messageId")),!1;d+=2;let h=null;if(5===r){if(h=C(t,u),!h)return!1;d+=h.length}if("object"!=typeof p||!p.length)return t.destroy(new Error("Invalid subscriptions")),!1;for(let e=0;e<p.length;e+=1){const i=p[e].topic,n=p[e].qos;if("string"!=typeof i)return t.destroy(new Error("Invalid subscriptions - invalid topic")),!1;if("number"!=typeof n)return t.destroy(new Error("Invalid subscriptions - invalid qos")),!1;if(5===r){if("boolean"!=typeof(p[e].nl||!1))return t.destroy(new Error("Invalid subscriptions - invalid No Local")),!1;if("boolean"!=typeof(p[e].rap||!1))return t.destroy(new Error("Invalid subscriptions - invalid Retain as Published")),!1;const i=p[e].rh||0;if("number"!=typeof i||i>2)return t.destroy(new Error("Invalid subscriptions - invalid Retain Handling")),!1}d+=o.byteLength(i)+2+1}l("subscribe: writing to stream: %o",n.SUBSCRIBE_HEADER),t.write(n.SUBSCRIBE_HEADER[1][a?1:0][0]),w(t,d),f(t,c),null!==h&&h.write();let m=!0;for(const e of p){const i=e.topic,s=e.qos,a=+e.nl,c=+e.rap,l=e.rh;let p;_(t,i),p=n.SUBSCRIBE_OPTIONS_QOS[s],5===r&&(p|=a?n.SUBSCRIBE_OPTIONS_NL:0,p|=c?n.SUBSCRIBE_OPTIONS_RAP:0,p|=l?n.SUBSCRIBE_OPTIONS_RH[l]:0),m=t.write(o.from([p]))}return m}(e,t,i);case"suback":return function(e,t,i){const r=i?i.protocolVersion:4,s=e||{},a=s.messageId,c=s.granted,l=s.properties;let p=0;if("number"!=typeof a)return t.destroy(new Error("Invalid messageId")),!1;p+=2;if("object"!=typeof c||!c.length)return t.destroy(new Error("Invalid qos vector")),!1;for(let e=0;e<c.length;e+=1){if("number"!=typeof c[e])return t.destroy(new Error("Invalid qos vector")),!1;p+=1}let u=null;if(5===r){if(u=P(t,l,i,p),!u)return!1;p+=u.length}t.write(n.SUBACK_HEADER),w(t,p),f(t,a),null!==u&&u.write();return t.write(o.from(c))}(e,t,i);case"unsubscribe":return function(e,t,i){const r=i?i.protocolVersion:4,s=e||{},a=s.messageId,c=s.dup?n.DUP_MASK:0,l=s.unsubscriptions,p=s.properties;let u=0;if("number"!=typeof a)return t.destroy(new Error("Invalid messageId")),!1;u+=2;if("object"!=typeof l||!l.length)return t.destroy(new Error("Invalid unsubscriptions")),!1;for(let e=0;e<l.length;e+=1){if("string"!=typeof l[e])return t.destroy(new Error("Invalid unsubscriptions")),!1;u+=o.byteLength(l[e])+2}let d=null;if(5===r){if(d=C(t,p),!d)return!1;u+=d.length}t.write(n.UNSUBSCRIBE_HEADER[1][c?1:0][0]),w(t,u),f(t,a),null!==d&&d.write();let h=!0;for(let e=0;e<l.length;e++)h=_(t,l[e]);return h}(e,t,i);case"unsuback":return function(e,t,i){const r=i?i.protocolVersion:4,s=e||{},a=s.messageId,c=s.dup?n.DUP_MASK:0,l=s.granted,p=s.properties,u=s.cmd,d=0;let h=2;if("number"!=typeof a)return t.destroy(new Error("Invalid messageId")),!1;if(5===r){if("object"!=typeof l||!l.length)return t.destroy(new Error("Invalid qos vector")),!1;for(let e=0;e<l.length;e+=1){if("number"!=typeof l[e])return t.destroy(new Error("Invalid qos vector")),!1;h+=1}}let m=null;if(5===r){if(m=P(t,p,i,h),!m)return!1;h+=m.length}t.write(n.ACKS[u][d][c][0]),w(t,h),f(t,a),null!==m&&m.write();5===r&&t.write(o.from(l));return!0}(e,t,i);case"pingreq":case"pingresp":return function(e,t){return t.write(n.EMPTY[e.cmd])}(e,t);case"disconnect":return function(e,t,i){const r=i?i.protocolVersion:4,s=e||{},a=s.reasonCode,c=s.properties;let l=5===r?1:0,p=null;if(5===r){if(p=P(t,c,i,l),!p)return!1;l+=p.length}t.write(o.from([n.codes.disconnect<<4])),w(t,l),5===r&&t.write(o.from([a]));null!==p&&p.write();return!0}(e,t,i);case"auth":return function(e,t,i){const r=i?i.protocolVersion:4,s=e||{},a=s.reasonCode,c=s.properties;let l=5===r?1:0;5!==r&&t.destroy(new Error("Invalid mqtt version for auth packet"));const p=P(t,c,i,l);if(!p)return!1;l+=p.length,t.write(o.from([n.codes.auth<<4])),w(t,l),t.write(o.from([a])),null!==p&&p.write();return!0}(e,t,i);default:return t.destroy(new Error("Unknown command")),!1}}function y(e){e.uncork()}Object.defineProperty(v,"cacheNumbers",{get:()=>f===x,set(e){e?(p&&0!==Object.keys(p).length||(g=!0),f=x):(g=!1,f=T)}});const b={};function w(e,t){if(t>n.VARBYTEINT_MAX)return e.destroy(new Error(`Invalid variable byte integer: ${t}`)),!1;let i=b[t];return i||(i=h(t),t<16384&&(b[t]=i)),l("writeVarByteInt: writing to stream: %o",i),e.write(i)}function _(e,t){const i=o.byteLength(t);return f(e,i),l("writeString: %s",t),e.write(t,"utf8")}function S(e,t,i){_(e,t),_(e,i)}function x(e,t){return l("writeNumberCached: number: %d",t),l("writeNumberCached: %o",p[t]),e.write(p[t])}function T(e,t){const i=u(t);return l("writeNumberGenerated: %o",i),e.write(i)}function E(e,t){"string"==typeof t?_(e,t):t?(f(e,t.length),e.write(t)):f(e,0)}function C(e,t){if("object"!=typeof t||null!=t.length)return{length:1,write(){O(e,{},0)}};let i=0;function r(t,i){let r=0;switch(n.propertiesTypes[t]){case"byte":if("boolean"!=typeof i)return e.destroy(new Error(`Invalid ${t}: ${i}`)),!1;r+=2;break;case"int8":if("number"!=typeof i||i<0||i>255)return e.destroy(new Error(`Invalid ${t}: ${i}`)),!1;r+=2;break;case"binary":if(i&&null===i)return e.destroy(new Error(`Invalid ${t}: ${i}`)),!1;r+=1+o.byteLength(i)+2;break;case"int16":if("number"!=typeof i||i<0||i>65535)return e.destroy(new Error(`Invalid ${t}: ${i}`)),!1;r+=3;break;case"int32":if("number"!=typeof i||i<0||i>4294967295)return e.destroy(new Error(`Invalid ${t}: ${i}`)),!1;r+=5;break;case"var":if("number"!=typeof i||i<0||i>268435455)return e.destroy(new Error(`Invalid ${t}: ${i}`)),!1;r+=1+o.byteLength(h(i));break;case"string":if("string"!=typeof i)return e.destroy(new Error(`Invalid ${t}: ${i}`)),!1;r+=3+o.byteLength(i.toString());break;case"pair":if("object"!=typeof i)return e.destroy(new Error(`Invalid ${t}: ${i}`)),!1;r+=Object.getOwnPropertyNames(i).reduce(((e,t)=>{const n=i[t];return Array.isArray(n)?e+=n.reduce(((e,i)=>e+=3+o.byteLength(t.toString())+2+o.byteLength(i.toString())),0):e+=3+o.byteLength(t.toString())+2+o.byteLength(i[t].toString()),e}),0);break;default:return e.destroy(new Error(`Invalid property ${t}: ${i}`)),!1}return r}if(t)for(const e in t){let n=0,o=0;const s=t[e];if(Array.isArray(s))for(let t=0;t<s.length;t++){if(o=r(e,s[t]),!o)return!1;n+=o}else{if(o=r(e,s),!o)return!1;n=o}if(!n)return!1;i+=n}return{length:o.byteLength(h(i))+i,write(){O(e,t,i)}}}function P(e,t,i,n){const o=["reasonString","userProperties"],r=i&&i.properties&&i.properties.maximumPacketSize?i.properties.maximumPacketSize:0;let s=C(e,t);if(r)for(;n+s.length>r;){const i=o.shift();if(!i||!t[i])return!1;delete t[i],s=C(e,t)}return s}function k(e,t,i){switch(n.propertiesTypes[t]){case"byte":e.write(o.from([n.properties[t]])),e.write(o.from([+i]));break;case"int8":e.write(o.from([n.properties[t]])),e.write(o.from([i]));break;case"binary":e.write(o.from([n.properties[t]])),E(e,i);break;case"int16":e.write(o.from([n.properties[t]])),f(e,i);break;case"int32":e.write(o.from([n.properties[t]])),function(e,t){const i=m(t);l("write4ByteNumber: %o",i),e.write(i)}(e,i);break;case"var":e.write(o.from([n.properties[t]])),w(e,i);break;case"string":e.write(o.from([n.properties[t]])),_(e,i);break;case"pair":Object.getOwnPropertyNames(i).forEach((r=>{const s=i[r];Array.isArray(s)?s.forEach((i=>{e.write(o.from([n.properties[t]])),S(e,r.toString(),i.toString())})):(e.write(o.from([n.properties[t]])),S(e,r.toString(),s.toString()))}));break;default:return e.destroy(new Error(`Invalid property ${t} value: ${i}`)),!1}}function O(e,t,i){w(e,i);for(const i in t)if(Object.prototype.hasOwnProperty.call(t,i)&&null!==t[i]){const n=t[i];if(Array.isArray(n))for(let t=0;t<n.length;t++)k(e,i,n[t]);else k(e,i,n)}}function I(e){return e?e instanceof o?e.length:o.byteLength(e):0}function A(e){return"string"==typeof e||e instanceof o}e.exports=v},2707:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ScryptedMimeTypes=t.ScryptedInterface=t.MediaPlayerState=t.SecuritySystemObstruction=t.SecuritySystemMode=t.AirQuality=t.AirPurifierMode=t.AirPurifierStatus=t.ChargeState=t.LockState=t.PanTiltZoomMovement=t.ThermostatMode=t.TemperatureUnit=t.FanMode=t.HumidityMode=t.ScryptedDeviceType=t.ScryptedInterfaceDescriptors=t.ScryptedInterfaceMethod=t.ScryptedInterfaceProperty=t.DeviceBase=t.TYPES_VERSION=void 0,t.TYPES_VERSION="0.5.26";var i,n,o,r,s,a,c,l,p,u,d,h,m,f,g,v,y,b;t.DeviceBase=class{},function(e){e.id="id",e.info="info",e.interfaces="interfaces",e.mixins="mixins",e.name="name",e.nativeId="nativeId",e.pluginId="pluginId",e.providedInterfaces="providedInterfaces",e.providedName="providedName",e.providedRoom="providedRoom",e.providedType="providedType",e.providerId="providerId",e.room="room",e.type="type",e.scryptedRuntimeArguments="scryptedRuntimeArguments",e.on="on",e.brightness="brightness",e.colorTemperature="colorTemperature",e.rgb="rgb",e.hsv="hsv",e.buttons="buttons",e.sensors="sensors",e.running="running",e.paused="paused",e.docked="docked",e.temperatureSetting="temperatureSetting",e.temperature="temperature",e.temperatureUnit="temperatureUnit",e.humidity="humidity",e.audioVolumes="audioVolumes",e.recordingActive="recordingActive",e.ptzCapabilities="ptzCapabilities",e.lockState="lockState",e.entryOpen="entryOpen",e.batteryLevel="batteryLevel",e.chargeState="chargeState",e.online="online",e.fromMimeType="fromMimeType",e.toMimeType="toMimeType",e.converters="converters",e.binaryState="binaryState",e.tampered="tampered",e.sleeping="sleeping",e.powerDetected="powerDetected",e.audioDetected="audioDetected",e.motionDetected="motionDetected",e.ambientLight="ambientLight",e.occupied="occupied",e.flooded="flooded",e.ultraviolet="ultraviolet",e.luminance="luminance",e.position="position",e.securitySystemState="securitySystemState",e.pm10Density="pm10Density",e.pm25Density="pm25Density",e.vocDensity="vocDensity",e.noxDensity="noxDensity",e.co2ppm="co2ppm",e.airQuality="airQuality",e.airPurifierState="airPurifierState",e.filterChangeIndication="filterChangeIndication",e.filterLifeLevel="filterLifeLevel",e.humiditySetting="humiditySetting",e.fan="fan",e.applicationInfo="applicationInfo",e.systemDevice="systemDevice"}(i||(t.ScryptedInterfaceProperty=i={})),function(e){e.listen="listen",e.probe="probe",e.setMixins="setMixins",e.setName="setName",e.setRoom="setRoom",e.setType="setType",e.getPluginJson="getPluginJson",e.turnOff="turnOff",e.turnOn="turnOn",e.setBrightness="setBrightness",e.getTemperatureMaxK="getTemperatureMaxK",e.getTemperatureMinK="getTemperatureMinK",e.setColorTemperature="setColorTemperature",e.setRgb="setRgb",e.setHsv="setHsv",e.pressButton="pressButton",e.sendNotification="sendNotification",e.start="start",e.stop="stop",e.pause="pause",e.resume="resume",e.dock="dock",e.setTemperature="setTemperature",e.setTemperatureUnit="setTemperatureUnit",e.getPictureOptions="getPictureOptions",e.takePicture="takePicture",e.getAudioStream="getAudioStream",e.setAudioVolumes="setAudioVolumes",e.startDisplay="startDisplay",e.stopDisplay="stopDisplay",e.getVideoStream="getVideoStream",e.getVideoStreamOptions="getVideoStreamOptions",e.getPrivacyMasks="getPrivacyMasks",e.setPrivacyMasks="setPrivacyMasks",e.getVideoTextOverlays="getVideoTextOverlays",e.setVideoTextOverlay="setVideoTextOverlay",e.getRecordingStream="getRecordingStream",e.getRecordingStreamCurrentTime="getRecordingStreamCurrentTime",e.getRecordingStreamOptions="getRecordingStreamOptions",e.getRecordingStreamThumbnail="getRecordingStreamThumbnail",e.deleteRecordingStream="deleteRecordingStream",e.setRecordingActive="setRecordingActive",e.ptzCommand="ptzCommand",e.getRecordedEvents="getRecordedEvents",e.getVideoClip="getVideoClip",e.getVideoClips="getVideoClips",e.getVideoClipThumbnail="getVideoClipThumbnail",e.removeVideoClips="removeVideoClips",e.setVideoStreamOptions="setVideoStreamOptions",e.startIntercom="startIntercom",e.stopIntercom="stopIntercom",e.lock="lock",e.unlock="unlock",e.addPassword="addPassword",e.getPasswords="getPasswords",e.removePassword="removePassword",e.activate="activate",e.deactivate="deactivate",e.isReversible="isReversible",e.closeEntry="closeEntry",e.openEntry="openEntry",e.getDevice="getDevice",e.releaseDevice="releaseDevice",e.adoptDevice="adoptDevice",e.discoverDevices="discoverDevices",e.createDevice="createDevice",e.getCreateDeviceSettings="getCreateDeviceSettings",e.reboot="reboot",e.getRefreshFrequency="getRefreshFrequency",e.refresh="refresh",e.getMediaStatus="getMediaStatus",e.load="load",e.seek="seek",e.skipNext="skipNext",e.skipPrevious="skipPrevious",e.convert="convert",e.convertMedia="convertMedia",e.getSettings="getSettings",e.putSetting="putSetting",e.armSecuritySystem="armSecuritySystem",e.disarmSecuritySystem="disarmSecuritySystem",e.setAirPurifierState="setAirPurifierState",e.getReadmeMarkdown="getReadmeMarkdown",e.getOauthUrl="getOauthUrl",e.onOauthCallback="onOauthCallback",e.canMixin="canMixin",e.getMixin="getMixin",e.releaseMixin="releaseMixin",e.onRequest="onRequest",e.onConnection="onConnection",e.onPush="onPush",e.run="run",e.eval="eval",e.loadScripts="loadScripts",e.saveScript="saveScript",e.forkInterface="forkInterface",e.trackObjects="trackObjects",e.getDetectionInput="getDetectionInput",e.getObjectTypes="getObjectTypes",e.detectObjects="detectObjects",e.generateObjectDetections="generateObjectDetections",e.getDetectionModel="getDetectionModel",e.setHumidity="setHumidity",e.setFan="setFan",e.startRTCSignalingSession="startRTCSignalingSession",e.createRTCSignalingSession="createRTCSignalingSession",e.getScryptedUserAccessControl="getScryptedUserAccessControl",e.generateVideoFrames="generateVideoFrames",e.connectStream="connectStream",e.getTTYSettings="getTTYSettings",e.getChatCompletion="getChatCompletion",e.streamChatCompletion="streamChatCompletion",e.getTextEmbedding="getTextEmbedding",e.getImageEmbedding="getImageEmbedding",e.callLLMTool="callLLMTool",e.getLLMTools="getLLMTools"}(n||(t.ScryptedInterfaceMethod=n={})),t.ScryptedInterfaceDescriptors={ScryptedDevice:{name:"ScryptedDevice",methods:["listen","probe","setMixins","setName","setRoom","setType"],properties:["id","info","interfaces","mixins","name","nativeId","pluginId","providedInterfaces","providedName","providedRoom","providedType","providerId","room","type"]},ScryptedPlugin:{name:"ScryptedPlugin",methods:["getPluginJson"],properties:[]},ScryptedPluginRuntime:{name:"ScryptedPluginRuntime",methods:[],properties:["scryptedRuntimeArguments"]},OnOff:{name:"OnOff",methods:["turnOff","turnOn"],properties:["on"]},Brightness:{name:"Brightness",methods:["setBrightness"],properties:["brightness"]},ColorSettingTemperature:{name:"ColorSettingTemperature",methods:["getTemperatureMaxK","getTemperatureMinK","setColorTemperature"],properties:["colorTemperature"]},ColorSettingRgb:{name:"ColorSettingRgb",methods:["setRgb"],properties:["rgb"]},ColorSettingHsv:{name:"ColorSettingHsv",methods:["setHsv"],properties:["hsv"]},Buttons:{name:"Buttons",methods:[],properties:["buttons"]},PressButtons:{name:"PressButtons",methods:["pressButton"],properties:[]},Sensors:{name:"Sensors",methods:[],properties:["sensors"]},Notifier:{name:"Notifier",methods:["sendNotification"],properties:[]},StartStop:{name:"StartStop",methods:["start","stop"],properties:["running"]},Pause:{name:"Pause",methods:["pause","resume"],properties:["paused"]},Dock:{name:"Dock",methods:["dock"],properties:["docked"]},TemperatureSetting:{name:"TemperatureSetting",methods:["setTemperature"],properties:["temperatureSetting"]},Thermometer:{name:"Thermometer",methods:["setTemperatureUnit"],properties:["temperature","temperatureUnit"]},HumiditySensor:{name:"HumiditySensor",methods:[],properties:["humidity"]},Camera:{name:"Camera",methods:["getPictureOptions","takePicture"],properties:[]},Microphone:{name:"Microphone",methods:["getAudioStream"],properties:[]},AudioVolumeControl:{name:"AudioVolumeControl",methods:["setAudioVolumes"],properties:["audioVolumes"]},Display:{name:"Display",methods:["startDisplay","stopDisplay"],properties:[]},VideoCamera:{name:"VideoCamera",methods:["getVideoStream","getVideoStreamOptions"],properties:[]},VideoCameraMask:{name:"VideoCameraMask",methods:["getPrivacyMasks","setPrivacyMasks"],properties:[]},VideoTextOverlays:{name:"VideoTextOverlays",methods:["getVideoTextOverlays","setVideoTextOverlay"],properties:[]},VideoRecorder:{name:"VideoRecorder",methods:["getRecordingStream","getRecordingStreamCurrentTime","getRecordingStreamOptions","getRecordingStreamThumbnail"],properties:["recordingActive"]},VideoRecorderManagement:{name:"VideoRecorderManagement",methods:["deleteRecordingStream","setRecordingActive"],properties:[]},PanTiltZoom:{name:"PanTiltZoom",methods:["ptzCommand"],properties:["ptzCapabilities"]},EventRecorder:{name:"EventRecorder",methods:["getRecordedEvents"],properties:[]},VideoClips:{name:"VideoClips",methods:["getVideoClip","getVideoClips","getVideoClipThumbnail","removeVideoClips"],properties:[]},VideoCameraConfiguration:{name:"VideoCameraConfiguration",methods:["setVideoStreamOptions"],properties:[]},Intercom:{name:"Intercom",methods:["startIntercom","stopIntercom"],properties:[]},Lock:{name:"Lock",methods:["lock","unlock"],properties:["lockState"]},PasswordStore:{name:"PasswordStore",methods:["addPassword","getPasswords","removePassword"],properties:[]},Scene:{name:"Scene",methods:["activate","deactivate","isReversible"],properties:[]},Entry:{name:"Entry",methods:["closeEntry","openEntry"],properties:[]},EntrySensor:{name:"EntrySensor",methods:[],properties:["entryOpen"]},DeviceProvider:{name:"DeviceProvider",methods:["getDevice","releaseDevice"],properties:[]},DeviceDiscovery:{name:"DeviceDiscovery",methods:["adoptDevice","discoverDevices"],properties:[]},DeviceCreator:{name:"DeviceCreator",methods:["createDevice","getCreateDeviceSettings"],properties:[]},Battery:{name:"Battery",methods:[],properties:["batteryLevel"]},Charger:{name:"Charger",methods:[],properties:["chargeState"]},Reboot:{name:"Reboot",methods:["reboot"],properties:[]},Refresh:{name:"Refresh",methods:["getRefreshFrequency","refresh"],properties:[]},MediaPlayer:{name:"MediaPlayer",methods:["getMediaStatus","load","seek","skipNext","skipPrevious"],properties:[]},Online:{name:"Online",methods:[],properties:["online"]},BufferConverter:{name:"BufferConverter",methods:["convert"],properties:["fromMimeType","toMimeType"]},MediaConverter:{name:"MediaConverter",methods:["convertMedia"],properties:["converters"]},Settings:{name:"Settings",methods:["getSettings","putSetting"],properties:[]},BinarySensor:{name:"BinarySensor",methods:[],properties:["binaryState"]},TamperSensor:{name:"TamperSensor",methods:[],properties:["tampered"]},Sleep:{name:"Sleep",methods:[],properties:["sleeping"]},PowerSensor:{name:"PowerSensor",methods:[],properties:["powerDetected"]},AudioSensor:{name:"AudioSensor",methods:[],properties:["audioDetected"]},MotionSensor:{name:"MotionSensor",methods:[],properties:["motionDetected"]},AmbientLightSensor:{name:"AmbientLightSensor",methods:[],properties:["ambientLight"]},OccupancySensor:{name:"OccupancySensor",methods:[],properties:["occupied"]},FloodSensor:{name:"FloodSensor",methods:[],properties:["flooded"]},UltravioletSensor:{name:"UltravioletSensor",methods:[],properties:["ultraviolet"]},LuminanceSensor:{name:"LuminanceSensor",methods:[],properties:["luminance"]},PositionSensor:{name:"PositionSensor",methods:[],properties:["position"]},SecuritySystem:{name:"SecuritySystem",methods:["armSecuritySystem","disarmSecuritySystem"],properties:["securitySystemState"]},PM10Sensor:{name:"PM10Sensor",methods:[],properties:["pm10Density"]},PM25Sensor:{name:"PM25Sensor",methods:[],properties:["pm25Density"]},VOCSensor:{name:"VOCSensor",methods:[],properties:["vocDensity"]},NOXSensor:{name:"NOXSensor",methods:[],properties:["noxDensity"]},CO2Sensor:{name:"CO2Sensor",methods:[],properties:["co2ppm"]},AirQualitySensor:{name:"AirQualitySensor",methods:[],properties:["airQuality"]},AirPurifier:{name:"AirPurifier",methods:["setAirPurifierState"],properties:["airPurifierState"]},FilterMaintenance:{name:"FilterMaintenance",methods:[],properties:["filterChangeIndication","filterLifeLevel"]},Readme:{name:"Readme",methods:["getReadmeMarkdown"],properties:[]},OauthClient:{name:"OauthClient",methods:["getOauthUrl","onOauthCallback"],properties:[]},MixinProvider:{name:"MixinProvider",methods:["canMixin","getMixin","releaseMixin"],properties:[]},HttpRequestHandler:{name:"HttpRequestHandler",methods:["onRequest"],properties:[]},EngineIOHandler:{name:"EngineIOHandler",methods:["onConnection"],properties:[]},PushHandler:{name:"PushHandler",methods:["onPush"],properties:[]},Program:{name:"Program",methods:["run"],properties:[]},Scriptable:{name:"Scriptable",methods:["eval","loadScripts","saveScript"],properties:[]},ClusterForkInterface:{name:"ClusterForkInterface",methods:["forkInterface"],properties:[]},ObjectTracker:{name:"ObjectTracker",methods:["trackObjects"],properties:[]},ObjectDetector:{name:"ObjectDetector",methods:["getDetectionInput","getObjectTypes"],properties:[]},ObjectDetection:{name:"ObjectDetection",methods:["detectObjects","generateObjectDetections","getDetectionModel"],properties:[]},ObjectDetectionPreview:{name:"ObjectDetectionPreview",methods:[],properties:[]},ObjectDetectionGenerator:{name:"ObjectDetectionGenerator",methods:[],properties:[]},HumiditySetting:{name:"HumiditySetting",methods:["setHumidity"],properties:["humiditySetting"]},Fan:{name:"Fan",methods:["setFan"],properties:["fan"]},RTCSignalingChannel:{name:"RTCSignalingChannel",methods:["startRTCSignalingSession"],properties:[]},RTCSignalingClient:{name:"RTCSignalingClient",methods:["createRTCSignalingSession"],properties:[]},LauncherApplication:{name:"LauncherApplication",methods:[],properties:["applicationInfo"]},ScryptedUser:{name:"ScryptedUser",methods:["getScryptedUserAccessControl"],properties:[]},VideoFrameGenerator:{name:"VideoFrameGenerator",methods:["generateVideoFrames"],properties:[]},StreamService:{name:"StreamService",methods:["connectStream"],properties:[]},TTY:{name:"TTY",methods:[],properties:[]},TTYSettings:{name:"TTYSettings",methods:["getTTYSettings"],properties:[]},ChatCompletion:{name:"ChatCompletion",methods:["getChatCompletion","streamChatCompletion"],properties:[]},TextEmbedding:{name:"TextEmbedding",methods:["getTextEmbedding"],properties:[]},ImageEmbedding:{name:"ImageEmbedding",methods:["getImageEmbedding"],properties:[]},LLMTools:{name:"LLMTools",methods:["callLLMTool","getLLMTools"],properties:[]},ScryptedSystemDevice:{name:"ScryptedSystemDevice",methods:[],properties:["systemDevice"]},ScryptedDeviceCreator:{name:"ScryptedDeviceCreator",methods:[],properties:[]},ScryptedSettings:{name:"ScryptedSettings",methods:[],properties:[]}},function(e){e.Builtin="Builtin",e.Internal="Internal",e.Camera="Camera",e.Fan="Fan",e.Light="Light",e.Switch="Switch",e.Outlet="Outlet",e.Sensor="Sensor",e.Scene="Scene",e.Program="Program",e.Automation="Automation",e.Vacuum="Vacuum",e.Notifier="Notifier",e.Thermostat="Thermostat",e.Lock="Lock",e.PasswordControl="PasswordControl",e.Display="Display",e.SmartDisplay="SmartDisplay",e.Speaker="Speaker",e.SmartSpeaker="SmartSpeaker",e.RemoteDesktop="RemoteDesktop",e.Event="Event",e.Entry="Entry",e.Garage="Garage",e.DeviceProvider="DeviceProvider",e.DataSource="DataSource",e.API="API",e.Doorbell="Doorbell",e.Irrigation="Irrigation",e.Valve="Valve",e.Person="Person",e.SecuritySystem="SecuritySystem",e.WindowCovering="WindowCovering",e.Siren="Siren",e.AirPurifier="AirPurifier",e.Internet="Internet",e.Network="Network",e.Bridge="Bridge",e.LLM="LLM",e.Unknown="Unknown"}(o||(t.ScryptedDeviceType=o={})),function(e){e.Humidify="Humidify",e.Dehumidify="Dehumidify",e.Auto="Auto",e.Off="Off"}(r||(t.HumidityMode=r={})),function(e){e.Auto="Auto",e.Manual="Manual"}(s||(t.FanMode=s={})),function(e){e.C="C",e.F="F"}(a||(t.TemperatureUnit=a={})),function(e){e.Off="Off",e.Cool="Cool",e.Heat="Heat",e.HeatCool="HeatCool",e.Auto="Auto",e.FanOnly="FanOnly",e.Purifier="Purifier",e.Eco="Eco",e.Dry="Dry",e.On="On"}(c||(t.ThermostatMode=c={})),function(e){e.Absolute="Absolute",e.Relative="Relative",e.Continuous="Continuous",e.Preset="Preset",e.Home="Home"}(l||(t.PanTiltZoomMovement=l={})),function(e){e.Locked="Locked",e.Unlocked="Unlocked",e.Jammed="Jammed"}(p||(t.LockState=p={})),function(e){e.Trickle="trickle",e.Charging="charging",e.NotCharging="not-charging"}(u||(t.ChargeState=u={})),function(e){e.Inactive="Inactive",e.Idle="Idle",e.Active="Active",e.ActiveNightMode="ActiveNightMode"}(d||(t.AirPurifierStatus=d={})),function(e){e.Manual="Manual",e.Automatic="Automatic"}(h||(t.AirPurifierMode=h={})),function(e){e.Unknown="Unknown",e.Excellent="Excellent",e.Good="Good",e.Fair="Fair",e.Inferior="Inferior",e.Poor="Poor"}(m||(t.AirQuality=m={})),function(e){e.Disarmed="Disarmed",e.HomeArmed="HomeArmed",e.AwayArmed="AwayArmed",e.NightArmed="NightArmed"}(f||(t.SecuritySystemMode=f={})),function(e){e.Sensor="Sensor",e.Occupied="Occupied",e.Time="Time",e.Error="Error"}(g||(t.SecuritySystemObstruction=g={})),function(e){e.Idle="Idle",e.Playing="Playing",e.Paused="Paused",e.Buffering="Buffering"}(v||(t.MediaPlayerState=v={})),function(e){e.ScryptedDevice="ScryptedDevice",e.ScryptedPlugin="ScryptedPlugin",e.ScryptedPluginRuntime="ScryptedPluginRuntime",e.OnOff="OnOff",e.Brightness="Brightness",e.ColorSettingTemperature="ColorSettingTemperature",e.ColorSettingRgb="ColorSettingRgb",e.ColorSettingHsv="ColorSettingHsv",e.Buttons="Buttons",e.PressButtons="PressButtons",e.Sensors="Sensors",e.Notifier="Notifier",e.StartStop="StartStop",e.Pause="Pause",e.Dock="Dock",e.TemperatureSetting="TemperatureSetting",e.Thermometer="Thermometer",e.HumiditySensor="HumiditySensor",e.Camera="Camera",e.Microphone="Microphone",e.AudioVolumeControl="AudioVolumeControl",e.Display="Display",e.VideoCamera="VideoCamera",e.VideoCameraMask="VideoCameraMask",e.VideoTextOverlays="VideoTextOverlays",e.VideoRecorder="VideoRecorder",e.VideoRecorderManagement="VideoRecorderManagement",e.PanTiltZoom="PanTiltZoom",e.EventRecorder="EventRecorder",e.VideoClips="VideoClips",e.VideoCameraConfiguration="VideoCameraConfiguration",e.Intercom="Intercom",e.Lock="Lock",e.PasswordStore="PasswordStore",e.Scene="Scene",e.Entry="Entry",e.EntrySensor="EntrySensor",e.DeviceProvider="DeviceProvider",e.DeviceDiscovery="DeviceDiscovery",e.DeviceCreator="DeviceCreator",e.Battery="Battery",e.Charger="Charger",e.Reboot="Reboot",e.Refresh="Refresh",e.MediaPlayer="MediaPlayer",e.Online="Online",e.BufferConverter="BufferConverter",e.MediaConverter="MediaConverter",e.Settings="Settings",e.BinarySensor="BinarySensor",e.TamperSensor="TamperSensor",e.Sleep="Sleep",e.PowerSensor="PowerSensor",e.AudioSensor="AudioSensor",e.MotionSensor="MotionSensor",e.AmbientLightSensor="AmbientLightSensor",e.OccupancySensor="OccupancySensor",e.FloodSensor="FloodSensor",e.UltravioletSensor="UltravioletSensor",e.LuminanceSensor="LuminanceSensor",e.PositionSensor="PositionSensor",e.SecuritySystem="SecuritySystem",e.PM10Sensor="PM10Sensor",e.PM25Sensor="PM25Sensor",e.VOCSensor="VOCSensor",e.NOXSensor="NOXSensor",e.CO2Sensor="CO2Sensor",e.AirQualitySensor="AirQualitySensor",e.AirPurifier="AirPurifier",e.FilterMaintenance="FilterMaintenance",e.Readme="Readme",e.OauthClient="OauthClient",e.MixinProvider="MixinProvider",e.HttpRequestHandler="HttpRequestHandler",e.EngineIOHandler="EngineIOHandler",e.PushHandler="PushHandler",e.Program="Program",e.Scriptable="Scriptable",e.ClusterForkInterface="ClusterForkInterface",e.ObjectTracker="ObjectTracker",e.ObjectDetector="ObjectDetector",e.ObjectDetection="ObjectDetection",e.ObjectDetectionPreview="ObjectDetectionPreview",e.ObjectDetectionGenerator="ObjectDetectionGenerator",e.HumiditySetting="HumiditySetting",e.Fan="Fan",e.RTCSignalingChannel="RTCSignalingChannel",e.RTCSignalingClient="RTCSignalingClient",e.LauncherApplication="LauncherApplication",e.ScryptedUser="ScryptedUser",e.VideoFrameGenerator="VideoFrameGenerator",e.StreamService="StreamService",e.TTY="TTY",e.TTYSettings="TTYSettings",e.ChatCompletion="ChatCompletion",e.TextEmbedding="TextEmbedding",e.ImageEmbedding="ImageEmbedding",e.LLMTools="LLMTools",e.ScryptedSystemDevice="ScryptedSystemDevice",e.ScryptedDeviceCreator="ScryptedDeviceCreator",e.ScryptedSettings="ScryptedSettings"}(y||(t.ScryptedInterface=y={})),function(e){e.Url="text/x-uri",e.InsecureLocalUrl="text/x-insecure-local-uri",e.LocalUrl="text/x-local-uri",e.ServerId="text/x-server-id",e.PushEndpoint="text/x-push-endpoint",e.SchemePrefix="x-scrypted/x-scrypted-scheme-",e.MediaStreamUrl="text/x-media-url",e.MediaObject="x-scrypted/x-scrypted-media-object",e.RequestMediaObject="x-scrypted/x-scrypted-request-media-object",e.RequestMediaStream="x-scrypted/x-scrypted-request-stream",e.MediaStreamFeedback="x-scrypted/x-media-stream-feedback",e.FFmpegInput="x-scrypted/x-ffmpeg-input",e.FFmpegTranscodeStream="x-scrypted/x-ffmpeg-transcode-stream",e.RTCSignalingChannel="x-scrypted/x-scrypted-rtc-signaling-channel",e.RTCSignalingSession="x-scrypted/x-scrypted-rtc-signaling-session",e.RTCConnectionManagement="x-scrypted/x-scrypted-rtc-connection-management",e.Image="x-scrypted/x-scrypted-image"}(b||(t.ScryptedMimeTypes=b={}))},2726:e=>{var t=1e3,i=60*t,n=60*i,o=24*n,r=7*o,s=365.25*o;function a(e,t,i,n){var o=t>=1.5*i;return Math.round(e/i)+" "+n+(o?"s":"")}e.exports=function(e,c){c=c||{};var l=typeof e;if("string"===l&&e.length>0)return function(e){if((e=String(e)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*s;case"weeks":case"week":case"w":return c*r;case"days":case"day":case"d":return c*o;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*i;case"seconds":case"second":case"secs":case"sec":case"s":return c*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(e);if("number"===l&&isFinite(e))return c.long?function(e){var r=Math.abs(e);if(r>=o)return a(e,r,o,"day");if(r>=n)return a(e,r,n,"hour");if(r>=i)return a(e,r,i,"minute");if(r>=t)return a(e,r,t,"second");return e+" ms"}(e):function(e){var r=Math.abs(e);if(r>=o)return Math.round(e/o)+"d";if(r>=n)return Math.round(e/n)+"h";if(r>=i)return Math.round(e/i)+"m";if(r>=t)return Math.round(e/t)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},2833:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=i(9913),o=i(546),r=(e,t)=>{const i=e.split("/"),n=t.split("/");for(let e=0;e<i.length;e++){if("#"===i[e])return!0;if("+"!==i[e]&&i[e]!==n[e])return!1}return i.length===n.length};t.default=class{constructor(e,t,i,n,o,r){this.topicLastValue={},this.topicCbMap={},this.currentAutodiscoveryTopics=[],this.host=e,this.username=t,this.password=i,this.logger=n,this.clientId=o,this.configTopicPattern=r}async disconnect(){if(this.mqttClient)try{this.logger.log("Disconnecting mqtt client"),await this.mqttClient.endAsync(!0)}catch(e){this.logger.log("Error closing MQTT connection",e)}}async getMqttClient(e){if(this.connecting)return this.mqttClient;const t=async()=>{try{const e=this.logger;this.connecting=!0;const t=await(0,n.connectAsync)(this.mqttPathmame,{rejectUnauthorized:!1,username:this.username,password:this.password,clientId:this.clientId,reschedulePings:!0},!0);this.configTopicPattern&&await t.subscribeAsync([this.configTopicPattern]),t.on("message",(async(t,i,n)=>{const o=[];for(const[e,i]of Object.entries(this.topicCbMap))r(e,t)&&o.push(...i);const s=i.toString();if(o?.length){e.info(`Topic ${t} for ${o.length} cbs sent with data ${i}: ${JSON.stringify(n)}`);for(const i of o)i(t,s,n).catch(e.log)}this.configTopicPattern&&i&&t.endsWith("/config")&&!this.currentAutodiscoveryTopics.includes(t)&&this.currentAutodiscoveryTopics.push(t)})),t.on("disconnect",(t=>{e.info(`Client disconnecting: ${JSON.stringify(t)}`)})),t.on("reconnect",(()=>{e.info("Client reconnecting")})),t.setMaxListeners(1/0),this.logger.log("Connected to MQTT",this.mqttPathmame,this.username,this.clientId),this.mqttClient=t}catch(e){this.logger.log("Error connecting to mqtt. Waiting before trying again. Client id is ",this.clientId,e),await(this.mqttClient?.endAsync(!0)),await(0,o.sleep)(5e3)}finally{this.connecting=!1}};if(!this.mqttClient||e){if(e&&this.mqttClient)try{await this.mqttClient.endAsync()}catch(e){}const i=this.host,n=new URL(i);return n.pathname="",this.mqttPathmame=n.toString(),this.mqttPathmame.endsWith("/")||(this.mqttPathmame=`${this.mqttPathmame}/`),this.logger.log("Starting MQTT connection",this.mqttPathmame,this.username,this.clientId),await t(),this.mqttClient}return this.mqttClient}async publish(e,t,i=!0){let n;try{"object"==typeof t&&(n=JSON.stringify(t)),t.constructor.name!==Buffer.name&&(n=t.toString())}catch(t){return void this.logger.log(`Error parsing publish values: ${JSON.stringify({topic:e,value:n?.slice(0,50)})}`,t)}if(this.topicLastValue[e]===n)return void this.logger.debug(`Skipping publish, same as previous value: ${JSON.stringify({topic:e,value:n?.slice(0,50),previousValue:this.topicLastValue[e]})}`);this.logger.debug(`Publishing ${JSON.stringify({topic:e,value:n})}`);const o=await this.getMqttClient();if(o)try{await o.publishAsync(e,n,{retain:i})}catch(t){this.logger.log(`Error publishing to MQTT. Reconnecting. ${JSON.stringify({topic:e,value:n?.slice(0,50)})}`,t),await this.getMqttClient(!0),await o.publishAsync(e,n,{retain:i}).catch((t=>this.logger.log(`Error publish retry. ${JSON.stringify({topic:e,value:n?.slice(0,50)})}`,t)))}finally{this.topicLastValue[e]=n}}getMqttTopicTopics(e,t){const i=t.id,n=t=>`scrypted/${e}/${i}/${t}`;return{getEntityTopic:n,getDiscoveryTopic:(t,n)=>`homeassistant/${t}/${e}-${i}/${n}/config`,getInfoTopic:e=>`${n(e)}/info`}}async subscribe(e,t){const i=await this.getMqttClient();if(i){await i.subscribeAsync(e);for(const i of e)this.topicCbMap[i]||(this.topicCbMap[i]=[]),this.topicCbMap[i].push(t)}}async unsubscribe(e){const t=await this.getMqttClient();if(t){await t.unsubscribeAsync(e);for(const t of e)delete this.topicCbMap[t]}}async unsubscribeWithCb(e){const t=await this.getMqttClient();if(t)for(const{cb:i,topic:n}of e){for(const e of this.topicCbMap[n])delete this.topicCbMap[n],e===i&&(this.topicCbMap[n]=this.topicCbMap[n].filter((e=>e!==i)));this.topicCbMap[n].length||await t.unsubscribeAsync(n)}}async removeAllListeners(){const e=await this.getMqttClient();e&&e.removeAllListeners()}async cleanupAutodiscoveryTopics(e){const t=this.currentAutodiscoveryTopics.filter((t=>!e.includes(t)));if(t.length>0){for(const e of t)await this.publish(e,"",!0);this.logger.log(`${t.length} topics to delete found: ${t.join(", ")}`)}}}},3009:e=>{var t="__lodash_hash_undefined__",i="[object Function]",n="[object GeneratorFunction]",o=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/,s=/^\./,a=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,c=/\\(\\)?/g,l=/^\[object .+?Constructor\]$/,p="object"==typeof global&&global&&global.Object===Object&&global,u="object"==typeof self&&self&&self.Object===Object&&self,d=p||u||Function("return this")();var h,m=Array.prototype,f=Function.prototype,g=Object.prototype,v=d["__core-js_shared__"],y=(h=/[^.]+$/.exec(v&&v.keys&&v.keys.IE_PROTO||""))?"Symbol(src)_1."+h:"",b=f.toString,w=g.hasOwnProperty,_=g.toString,S=RegExp("^"+b.call(w).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),x=d.Symbol,T=m.splice,E=L(d,"Map"),C=L(Object,"create"),P=x?x.prototype:void 0,k=P?P.toString:void 0;function O(e){var t=-1,i=e?e.length:0;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}function I(e){var t=-1,i=e?e.length:0;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}function A(e){var t=-1,i=e?e.length:0;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}function R(e,t){for(var i,n,o=e.length;o--;)if((i=e[o][0])===(n=t)||i!=i&&n!=n)return o;return-1}function D(e,t){var i;t=function(e,t){if(U(e))return!1;var i=typeof e;if("number"==i||"symbol"==i||"boolean"==i||null==e||V(e))return!0;return r.test(e)||!o.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:U(i=t)?i:j(i);for(var n=0,s=t.length;null!=e&&n<s;)e=e[F(t[n++])];return n&&n==s?e:void 0}function M(e){if(!q(e)||(t=e,y&&y in t))return!1;var t,o=function(e){var t=q(e)?_.call(e):"";return t==i||t==n}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?S:l;return o.test(function(e){if(null!=e){try{return b.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function N(e,t){var i,n,o=e.__data__;return("string"==(n=typeof(i=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==i:null===i)?o["string"==typeof t?"string":"hash"]:o.map}function L(e,t){var i=function(e,t){return null==e?void 0:e[t]}(e,t);return M(i)?i:void 0}O.prototype.clear=function(){this.__data__=C?C(null):{}},O.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},O.prototype.get=function(e){var i=this.__data__;if(C){var n=i[e];return n===t?void 0:n}return w.call(i,e)?i[e]:void 0},O.prototype.has=function(e){var t=this.__data__;return C?void 0!==t[e]:w.call(t,e)},O.prototype.set=function(e,i){return this.__data__[e]=C&&void 0===i?t:i,this},I.prototype.clear=function(){this.__data__=[]},I.prototype.delete=function(e){var t=this.__data__,i=R(t,e);return!(i<0)&&(i==t.length-1?t.pop():T.call(t,i,1),!0)},I.prototype.get=function(e){var t=this.__data__,i=R(t,e);return i<0?void 0:t[i][1]},I.prototype.has=function(e){return R(this.__data__,e)>-1},I.prototype.set=function(e,t){var i=this.__data__,n=R(i,e);return n<0?i.push([e,t]):i[n][1]=t,this},A.prototype.clear=function(){this.__data__={hash:new O,map:new(E||I),string:new O}},A.prototype.delete=function(e){return N(this,e).delete(e)},A.prototype.get=function(e){return N(this,e).get(e)},A.prototype.has=function(e){return N(this,e).has(e)},A.prototype.set=function(e,t){return N(this,e).set(e,t),this};var j=B((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(V(e))return k?k.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(t);var i=[];return s.test(e)&&i.push(""),e.replace(a,(function(e,t,n,o){i.push(n?o.replace(c,"$1"):t||e)})),i}));function F(e){if("string"==typeof e||V(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function B(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError("Expected a function");var i=function(){var n=arguments,o=t?t.apply(this,n):n[0],r=i.cache;if(r.has(o))return r.get(o);var s=e.apply(this,n);return i.cache=r.set(o,s),s};return i.cache=new(B.Cache||A),i}B.Cache=A;var U=Array.isArray;function q(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function V(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==_.call(e)}e.exports=function(e,t,i){var n=null==e?void 0:D(e,t);return void 0===n?i:n}},3024:e=>{var t=1e3,i=60*t,n=60*i,o=24*n,r=7*o,s=365.25*o;function a(e,t,i,n){var o=t>=1.5*i;return Math.round(e/i)+" "+n+(o?"s":"")}e.exports=function(e,c){c=c||{};var l=typeof e;if("string"===l&&e.length>0)return function(e){if((e=String(e)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*s;case"weeks":case"week":case"w":return c*r;case"days":case"day":case"d":return c*o;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*i;case"seconds":case"second":case"secs":case"sec":case"s":return c*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(e);if("number"===l&&isFinite(e))return c.long?function(e){var r=Math.abs(e);if(r>=o)return a(e,r,o,"day");if(r>=n)return a(e,r,n,"hour");if(r>=i)return a(e,r,i,"minute");if(r>=t)return a(e,r,t,"second");return e+" ms"}(e):function(e){var r=Math.abs(e);if(r>=o)return Math.round(e/o)+"d";if(r>=n)return Math.round(e/n)+"h";if(r>=i)return Math.round(e/i)+"m";if(r>=t)return Math.round(e/t)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},3087:function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.reolinkHttpsAgent=void 0,t.getDeviceInfo=async function(e,t,i){const n=await a(e,t,i);return s(e,n.parameters)},t.getLoginParameters=a;const o=n(i(5692)),r=i(3609);async function s(e,t){const i=new URL(`http://${e}/api.cgi`),n=i.searchParams;n.set("cmd","GetDevInfo");for(const[e,i]of Object.entries(t))n.set(e,i);const o=await(0,r.httpFetch)({url:i,responseType:"json"}),s=o.body?.[0]?.error;if(s)throw new Error("error during call to getDeviceInfo");const a=o.body?.[0]?.value?.DevInfo;if(!a?.type&&!a?.model&&!a?.exactType)throw new Error("device info return unexpected data");return a}async function a(e,t,i,n){if(!n)try{return await s(e,{user:t,password:i}),{parameters:{user:t,password:i},leaseTimeSeconds:1/0}}catch(e){}try{const n=new URL(`http://${e}/api.cgi`);n.searchParams.set("cmd","Login");const o=await(0,r.httpFetch)({url:n,method:"POST",responseType:"json",rejectUnauthorized:!1,body:[{cmd:"Login",action:0,param:{User:{userName:t,password:i}}}]}),s=o.body?.[0]?.value?.Token?.name||o.body?.value?.Token?.name;if(!s)throw new Error("unable to login");const{body:a}=o;return{parameters:{token:s},leaseTimeSeconds:a?.[0]?.value?.Token.leaseTime||a?.value?.Token.leaseTime}}catch(e){return{parameters:{user:t,password:i},leaseTimeSeconds:60}}}t.reolinkHttpsAgent=new o.default.Agent({rejectUnauthorized:!1})},3089:(e,t,i)=>{"use strict";i.d(t,{CD:()=>_});var n,o=(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),r=function(){function e(e,t){this.ee=1,this.u=void 0,this.p=void 0,this.K=void 0,this.N=void 0,this.rr=void 0,this.u=e,this.p=t}return e.prototype.L=function(){var e=this;if(1===e.ee&&e.rr.rr===e)e=e.N;else if(e.K)for(e=e.K;e.N;)e=e.N;else{for(var t=e.rr;t.K===e;)t=(e=t).rr;e=t}return e},e.prototype.m=function(){var e=this;if(e.N){for(e=e.N;e.K;)e=e.K;return e}for(var t=e.rr;t.N===e;)t=(e=t).rr;return e.N!==t?t:e},e.prototype.ne=function(){var e=this.rr,t=this.N,i=t.K;return e.rr===this?e.rr=t:e.K===this?e.K=t:e.N=t,t.rr=e,t.K=this,this.rr=t,this.N=i,i&&(i.rr=this),t},e.prototype.te=function(){var e=this.rr,t=this.K,i=t.N;return e.rr===this?e.rr=t:e.K===this?e.K=t:e.N=t,t.rr=e,t.N=this,this.rr=t,this.K=i,i&&(i.rr=this),t},e}(),s=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.tr=1,t}return o(t,e),t.prototype.ne=function(){var t=e.prototype.ne.call(this);return this.ie(),t.ie(),t},t.prototype.te=function(){var t=e.prototype.te.call(this);return this.ie(),t.ie(),t},t.prototype.ie=function(){this.tr=1,this.K&&(this.tr+=this.K.tr),this.N&&(this.tr+=this.N.tr)},t}(r),a=function(){var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)};return function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}(),c=function(){function e(e){void 0===e&&(e=0),this.iteratorType=e}return e.prototype.equals=function(e){return this.o===e.o},e}(),l=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return a(t,e),t}(function(){function e(){this.M=0}return Object.defineProperty(e.prototype,"length",{get:function(){return this.M},enumerable:!1,configurable:!0}),e.prototype.size=function(){return this.M},e.prototype.empty=function(){return 0===this.M},e}());function p(){throw new RangeError("Iterator access denied!")}var u=function(){var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)};return function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}(),d=function(e,t){var i="function"==typeof Symbol&&e[Symbol.iterator];if(!i)return e;var n,o,r=i.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=r.next()).done;)s.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(i=r.return)&&i.call(r)}finally{if(o)throw o.error}}return s},h=function(e){var t="function"==typeof Symbol&&Symbol.iterator,i=t&&e[t],n=0;if(i)return i.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};const m=function(e){function t(t,i){void 0===t&&(t=function(e,t){return e<t?-1:e>t?1:0}),void 0===i&&(i=!1);var n=e.call(this)||this;return n.W=void 0,n.$=t,i?(n.re=s,n.v=function(e,t,i){var n=this.se(e,t,i);if(n){for(var o=n.rr;o!==this.h;)o.tr+=1,o=o.rr;var r=this.fe(n);if(r){var s=r,a=s.parentNode,c=s.grandParent,l=s.curNode;a.ie(),c.ie(),l.ie()}}return this.M},n.G=function(e){for(var t=this.he(e);t!==this.h;)t.tr-=1,t=t.rr}):(n.re=r,n.v=function(e,t,i){var n=this.se(e,t,i);return n&&this.fe(n),this.M},n.G=n.he),n.h=new n.re,n}return u(t,e),t.prototype.U=function(e,t){for(var i=this.h;e;){var n=this.$(e.u,t);if(n<0)e=e.N;else{if(!(n>0))return e;i=e,e=e.K}}return i},t.prototype.X=function(e,t){for(var i=this.h;e;){this.$(e.u,t)<=0?e=e.N:(i=e,e=e.K)}return i},t.prototype.Y=function(e,t){for(var i=this.h;e;){var n=this.$(e.u,t);if(n<0)i=e,e=e.N;else{if(!(n>0))return e;e=e.K}}return i},t.prototype.Z=function(e,t){for(var i=this.h;e;){this.$(e.u,t)<0?(i=e,e=e.N):e=e.K}return i},t.prototype.ue=function(e){for(;;){var t,i=e.rr;if(i===this.h)return;if(1===e.ee)return void(e.ee=0);if(e===i.K)if(1===(t=i.N).ee)t.ee=0,i.ee=1,i===this.W?this.W=i.ne():i.ne();else{if(t.N&&1===t.N.ee)return t.ee=i.ee,i.ee=0,t.N.ee=0,void(i===this.W?this.W=i.ne():i.ne());t.K&&1===t.K.ee?(t.ee=1,t.K.ee=0,t.te()):(t.ee=1,e=i)}else if(1===(t=i.K).ee)t.ee=0,i.ee=1,i===this.W?this.W=i.te():i.te();else{if(t.K&&1===t.K.ee)return t.ee=i.ee,i.ee=0,t.K.ee=0,void(i===this.W?this.W=i.te():i.te());t.N&&1===t.N.ee?(t.ee=1,t.N.ee=0,t.ne()):(t.ee=1,e=i)}}},t.prototype.he=function(e){var t,i;if(1===this.M)return this.clear(),this.h;for(var n=e;n.K||n.N;){if(n.N)for(n=n.N;n.K;)n=n.K;else n=n.K;t=d([n.u,e.u],2),e.u=t[0],n.u=t[1],i=d([n.p,e.p],2),e.p=i[0],n.p=i[1],e=n}this.h.K===n?this.h.K=n.rr:this.h.N===n&&(this.h.N=n.rr),this.ue(n);var o=n.rr;return n===o.K?o.K=void 0:o.N=void 0,this.M-=1,this.W.ee=0,o},t.prototype.ae=function(e,t){return void 0!==e&&(!!this.ae(e.K,t)||(!!t(e)||this.ae(e.N,t)))},t.prototype.fe=function(e){for(;;){var t=e.rr;if(0===t.ee)return;var i=t.rr;if(t===i.K){if((n=i.N)&&1===n.ee){if(n.ee=t.ee=0,i===this.W)return;i.ee=1,e=i;continue}if(e===t.N){if(e.ee=0,e.K&&(e.K.rr=t),e.N&&(e.N.rr=i),t.N=e.K,i.K=e.N,e.K=t,e.N=i,i===this.W)this.W=e,this.h.rr=e;else(o=i.rr).K===i?o.K=e:o.N=e;return e.rr=i.rr,t.rr=e,i.rr=e,i.ee=1,{parentNode:t,grandParent:i,curNode:e}}t.ee=0,i===this.W?this.W=i.te():i.te(),i.ee=1}else{var n;if((n=i.K)&&1===n.ee){if(n.ee=t.ee=0,i===this.W)return;i.ee=1,e=i;continue}if(e===t.K){var o;if(e.ee=0,e.K&&(e.K.rr=i),e.N&&(e.N.rr=t),i.N=e.K,t.K=e.N,e.K=i,e.N=t,i===this.W)this.W=e,this.h.rr=e;else(o=i.rr).K===i?o.K=e:o.N=e;return e.rr=i.rr,t.rr=e,i.rr=e,i.ee=1,{parentNode:t,grandParent:i,curNode:e}}t.ee=0,i===this.W?this.W=i.ne():i.ne(),i.ee=1}return}},t.prototype.se=function(e,t,i){if(void 0===this.W)return this.M+=1,this.W=new this.re(e,t),this.W.ee=0,this.W.rr=this.h,this.h.rr=this.W,this.h.K=this.W,void(this.h.N=this.W);var n,o=this.h.K,r=this.$(o.u,e);if(0!==r){if(r>0)o.K=new this.re(e,t),o.K.rr=o,n=o.K,this.h.K=n;else{var s=this.h.N,a=this.$(s.u,e);if(0===a)return void(s.p=t);if(a<0)s.N=new this.re(e,t),s.N.rr=s,n=s.N,this.h.N=n;else{if(void 0!==i){var c=i.o;if(c!==this.h){var l=this.$(c.u,e);if(0===l)return void(c.p=t);if(l>0){var p=c.L(),u=this.$(p.u,e);if(0===u)return void(p.p=t);u<0&&(n=new this.re(e,t),void 0===p.N?(p.N=n,n.rr=p):(c.K=n,n.rr=c))}}}if(void 0===n)for(n=this.W;;){var d=this.$(n.u,e);if(d>0){if(void 0===n.K){n.K=new this.re(e,t),n.K.rr=n,n=n.K;break}n=n.K}else{if(!(d<0))return void(n.p=t);if(void 0===n.N){n.N=new this.re(e,t),n.N.rr=n,n=n.N;break}n=n.N}}}}return this.M+=1,n}o.p=t},t.prototype.g=function(e,t){for(;e;){var i=this.$(e.u,t);if(i<0)e=e.N;else{if(!(i>0))return e;e=e.K}}return e||this.h},t.prototype.clear=function(){this.M=0,this.W=void 0,this.h.rr=void 0,this.h.K=this.h.N=void 0},t.prototype.updateKeyByIterator=function(e,t){var i=e.o;if(i===this.h&&p(),1===this.M)return i.u=t,!0;if(i===this.h.K)return this.$(i.m().u,t)>0&&(i.u=t,!0);if(i===this.h.N)return this.$(i.L().u,t)<0&&(i.u=t,!0);var n=i.L().u;if(this.$(n,t)>=0)return!1;var o=i.m().u;return!(this.$(o,t)<=0)&&(i.u=t,!0)},t.prototype.eraseElementByPos=function(e){if(e<0||e>this.M-1)throw new RangeError;var t=0,i=this;return this.ae(this.W,(function(n){return e===t?(i.G(n),!0):(t+=1,!1)})),this.M},t.prototype.eraseElementByKey=function(e){if(0===this.M)return!1;var t=this.g(this.W,e);return t!==this.h&&(this.G(t),!0)},t.prototype.eraseElementByIterator=function(e){var t=e.o;t===this.h&&p();var i=void 0===t.N;return 0===e.iteratorType?i&&e.next():i&&void 0!==t.K||e.next(),this.G(t),e},t.prototype.forEach=function(e){var t,i,n=0;try{for(var o=h(this),r=o.next();!r.done;r=o.next()){e(r.value,n++,this)}}catch(e){t={error:e}}finally{try{r&&!r.done&&(i=o.return)&&i.call(o)}finally{if(t)throw t.error}}},t.prototype.getElementByPos=function(e){var t,i,n;if(e<0||e>this.M-1)throw new RangeError;var o=0;try{for(var r=h(this),s=r.next();!s.done;s=r.next()){var a=s.value;if(o===e){n=a;break}o+=1}}catch(e){t={error:e}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(t)throw t.error}}return n},t.prototype.getHeight=function(){if(0===this.M)return 0;var e=function(t){return t?Math.max(e(t.K),e(t.N))+1:0};return e(this.W)},t}(l);var f=function(){var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)};return function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}();const g=function(e){function t(t,i,n){var o=e.call(this,n)||this;return o.o=t,o.h=i,0===o.iteratorType?(o.pre=function(){return this.o===this.h.K&&p(),this.o=this.o.L(),this},o.next=function(){return this.o===this.h&&p(),this.o=this.o.m(),this}):(o.pre=function(){return this.o===this.h.N&&p(),this.o=this.o.m(),this},o.next=function(){return this.o===this.h&&p(),this.o=this.o.L(),this}),o}return f(t,e),Object.defineProperty(t.prototype,"index",{get:function(){var e=this.o,t=this.h.rr;if(e===this.h)return t?t.tr-1:0;var i=0;for(e.K&&(i+=e.K.tr);e!==t;){var n=e.rr;e===n.N&&(i+=1,n.K&&(i+=n.K.tr)),e=n}return i},enumerable:!1,configurable:!0}),t}(c);var v=function(){var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)};return function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}(),y=function(e,t){var i,n,o,r,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(e){return function(t){return c([e,t])}}function c(r){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(o=2&r[0]?n.return:r[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,r[1])).done)return o;switch(n=0,o&&(r=[2&r[0],o.value]),r[0]){case 0:case 1:o=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,n=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!o||r[1]>o[0]&&r[1]<o[3])){s.label=r[1];break}if(6===r[0]&&s.label<o[1]){s.label=o[1],o=r;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(r);break}o[2]&&s.ops.pop(),s.trys.pop();continue}r=t.call(e,s)}catch(e){r=[6,e],n=0}finally{i=o=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}},b=function(e){var t="function"==typeof Symbol&&Symbol.iterator,i=t&&e[t],n=0;if(i)return i.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},w=function(e){function t(t,i,n,o){var r=e.call(this,t,i,o)||this;return r.container=n,r}return v(t,e),Object.defineProperty(t.prototype,"pointer",{get:function(){return this.o===this.h&&p(),this.o.u},enumerable:!1,configurable:!0}),t.prototype.copy=function(){return new t(this.o,this.h,this.container,this.iteratorType)},t}(g);const _=function(e){function t(t,i,n){void 0===t&&(t=[]);var o=e.call(this,i,n)||this,r=o;return t.forEach((function(e){r.insert(e)})),o}return v(t,e),t.prototype.P=function(e){return y(this,(function(t){switch(t.label){case 0:return void 0===e?[2]:[5,b(this.P(e.K))];case 1:return t.sent(),[4,e.u];case 2:return t.sent(),[5,b(this.P(e.N))];case 3:return t.sent(),[2]}}))},t.prototype.begin=function(){return new w(this.h.K||this.h,this.h,this)},t.prototype.end=function(){return new w(this.h,this.h,this)},t.prototype.rBegin=function(){return new w(this.h.N||this.h,this.h,this,1)},t.prototype.rEnd=function(){return new w(this.h,this.h,this,1)},t.prototype.front=function(){return this.h.K?this.h.K.u:void 0},t.prototype.back=function(){return this.h.N?this.h.N.u:void 0},t.prototype.insert=function(e,t){return this.v(e,void 0,t)},t.prototype.find=function(e){var t=this.g(this.W,e);return new w(t,this.h,this)},t.prototype.lowerBound=function(e){var t=this.U(this.W,e);return new w(t,this.h,this)},t.prototype.upperBound=function(e){var t=this.X(this.W,e);return new w(t,this.h,this)},t.prototype.reverseLowerBound=function(e){var t=this.Y(this.W,e);return new w(t,this.h,this)},t.prototype.reverseUpperBound=function(e){var t=this.Z(this.W,e);return new w(t,this.h,this)},t.prototype.union=function(e){var t=this;return e.forEach((function(e){t.insert(e)})),this.M},t.prototype[Symbol.iterator]=function(){return this.P(this.W)},t}(m)},3106:e=>{"use strict";e.exports=require("zlib")},3141:(e,t)=>{"use strict";function i(e,t){if(t===e)return 0;const i=t-e;let n;return n=t>e?e+65536-t:t+65536-e,Math.abs(i)<Math.abs(n)?i:n}function n(e,t=1){return(e+t+65536)%65536}Object.defineProperty(t,"__esModule",{value:!0}),t.JitterBuffer=void 0,t.sequenceNumberDistance=i,t.nextSequenceNumber=n,t.addRtpTimestamp=function(e,t){return Number(o&BigInt(e)+BigInt(t))},t.isNextSequenceNumber=r;const o=BigInt(4294967295);function r(e,t){return n(e)===t}t.JitterBuffer=class{constructor(e,t){this.console=e,this.jitterSize=t,this.pending=[]}flushPending(e,t){if(!this.pending)return t;const o=n(e);for(let e=0;e<this.jitterSize;e++){const n=(o+e)%this.jitterSize,r=this.pending[n];if(!r)continue;const{sequenceNumber:s}=r.header,a=i(this.lastSequenceNumber,s);a<=0?(this.console.log("jitter buffer purged packet:",s),this.pending[n]=void 0,t.push(r)):1===a&&(this.pending[n]=void 0,this.lastSequenceNumber=s,t.push(r))}return t}queue(e){if(void 0===this.lastSequenceNumber||r(this.lastSequenceNumber,e.header.sequenceNumber))return this.lastSequenceNumber=e.header.sequenceNumber,this.flushPending(this.lastSequenceNumber,[e]);const{sequenceNumber:t}=e.header,n=i(this.lastSequenceNumber,t);if(n<=0)return[];const o=[];if(n>this.jitterSize){const{lastSequenceNumber:e}=this;this.lastSequenceNumber=t-this.jitterSize,this.flushPending(e,o)}return this.pending[e.header.sequenceNumber%this.jitterSize]=e,this.flushPending(this.lastSequenceNumber,o)}}},3193:e=>{"use strict";e.exports=require("string_decoder")},3271:(e,t,i)=>{"use strict";const{isUtf8:n}=i(181),{hasBlob:o}=i(6639);function r(e){const t=e.length;let i=0;for(;i<t;)if(128&e[i])if(192==(224&e[i])){if(i+1===t||128!=(192&e[i+1])||192==(254&e[i]))return!1;i+=2}else if(224==(240&e[i])){if(i+2>=t||128!=(192&e[i+1])||128!=(192&e[i+2])||224===e[i]&&128==(224&e[i+1])||237===e[i]&&160==(224&e[i+1]))return!1;i+=3}else{if(240!=(248&e[i]))return!1;if(i+3>=t||128!=(192&e[i+1])||128!=(192&e[i+2])||128!=(192&e[i+3])||240===e[i]&&128==(240&e[i+1])||244===e[i]&&e[i+1]>143||e[i]>244)return!1;i+=4}else i++;return!0}if(e.exports={isBlob:function(e){return o&&"object"==typeof e&&"function"==typeof e.arrayBuffer&&"string"==typeof e.type&&"function"==typeof e.stream&&("Blob"===e[Symbol.toStringTag]||"File"===e[Symbol.toStringTag])},isValidStatusCode:function(e){return e>=1e3&&e<=1014&&1004!==e&&1005!==e&&1006!==e||e>=3e3&&e<=4999},isValidUTF8:r,tokenChars:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0]},n)e.exports.isValidUTF8=function(e){return e.length<24?r(e):n(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{const t=i(Object(function(){var e=new Error("Cannot find module 'utf-8-validate'");throw e.code="MODULE_NOT_FOUND",e}()));e.exports.isValidUTF8=function(e){return e.length<32?r(e):t(e)}}catch(e){}},3328:(e,t,i)=>{"use strict";const n=i(3089).CD,o=i(8766)("number-allocator:trace"),r=i(8766)("number-allocator:error");function s(e,t){this.low=e,this.high=t}function a(e,t){if(!(this instanceof a))return new a(e,t);this.min=e,this.max=t,this.ss=new n([],((e,t)=>e.compare(t))),o("Create"),this.clear()}s.prototype.equals=function(e){return this.low===e.low&&this.high===e.high},s.prototype.compare=function(e){return this.low<e.low&&this.high<e.low?-1:e.low<this.low&&e.high<this.low?1:0},a.prototype.firstVacant=function(){return 0===this.ss.size()?null:this.ss.front().low},a.prototype.alloc=function(){if(0===this.ss.size())return o("alloc():empty"),null;const e=this.ss.begin(),t=e.pointer.low,i=e.pointer.high,n=t;return n+1<=i?this.ss.updateKeyByIterator(e,new s(t+1,i)):this.ss.eraseElementByPos(0),o("alloc():"+n),n},a.prototype.use=function(e){const t=new s(e,e),i=this.ss.lowerBound(t);if(!i.equals(this.ss.end())){const n=i.pointer.low,r=i.pointer.high;return i.pointer.equals(t)?(this.ss.eraseElementByIterator(i),o("use():"+e),!0):!(n>e)&&(n===e?(this.ss.updateKeyByIterator(i,new s(n+1,r)),o("use():"+e),!0):r===e?(this.ss.updateKeyByIterator(i,new s(n,r-1)),o("use():"+e),!0):(this.ss.updateKeyByIterator(i,new s(e+1,r)),this.ss.insert(new s(n,e-1)),o("use():"+e),!0))}return o("use():failed"),!1},a.prototype.free=function(e){if(e<this.min||e>this.max)return void r("free():"+e+" is out of range");const t=new s(e,e),i=this.ss.upperBound(t);if(i.equals(this.ss.end())){if(i.equals(this.ss.begin()))return void this.ss.insert(t);i.pre();const n=i.pointer.high;i.pointer.high+1===e?this.ss.updateKeyByIterator(i,new s(n,e)):this.ss.insert(t)}else if(i.equals(this.ss.begin()))if(e+1===i.pointer.low){const t=i.pointer.high;this.ss.updateKeyByIterator(i,new s(e,t))}else this.ss.insert(t);else{const n=i.pointer.low,o=i.pointer.high;i.pre();const r=i.pointer.low;i.pointer.high+1===e?e+1===n?(this.ss.eraseElementByIterator(i),this.ss.updateKeyByIterator(i,new s(r,o))):this.ss.updateKeyByIterator(i,new s(r,e)):e+1===n?(this.ss.eraseElementByIterator(i.next()),this.ss.insert(new s(e,o))):this.ss.insert(t)}o("free():"+e)},a.prototype.clear=function(){o("clear()"),this.ss.clear(),this.ss.insert(new s(this.min,this.max))},a.prototype.intervalCount=function(){return this.ss.size()},a.prototype.dump=function(){console.log("length:"+this.ss.size());for(const e of this.ss)console.log(e)},e.exports=a},3339:e=>{"use strict";e.exports=require("module")},3383:e=>{"use strict";e.exports={ArrayIsArray:e=>Array.isArray(e),ArrayPrototypeIncludes:(e,t)=>e.includes(t),ArrayPrototypeIndexOf:(e,t)=>e.indexOf(t),ArrayPrototypeJoin:(e,t)=>e.join(t),ArrayPrototypeMap:(e,t)=>e.map(t),ArrayPrototypePop:(e,t)=>e.pop(t),ArrayPrototypePush:(e,t)=>e.push(t),ArrayPrototypeSlice:(e,t,i)=>e.slice(t,i),Error,FunctionPrototypeCall:(e,t,...i)=>e.call(t,...i),FunctionPrototypeSymbolHasInstance:(e,t)=>Function.prototype[Symbol.hasInstance].call(e,t),MathFloor:Math.floor,Number,NumberIsInteger:Number.isInteger,NumberIsNaN:Number.isNaN,NumberMAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,NumberParseInt:Number.parseInt,ObjectDefineProperties:(e,t)=>Object.defineProperties(e,t),ObjectDefineProperty:(e,t,i)=>Object.defineProperty(e,t,i),ObjectGetOwnPropertyDescriptor:(e,t)=>Object.getOwnPropertyDescriptor(e,t),ObjectKeys:e=>Object.keys(e),ObjectSetPrototypeOf:(e,t)=>Object.setPrototypeOf(e,t),Promise,PromisePrototypeCatch:(e,t)=>e.catch(t),PromisePrototypeThen:(e,t,i)=>e.then(t,i),PromiseReject:e=>Promise.reject(e),PromiseResolve:e=>Promise.resolve(e),ReflectApply:Reflect.apply,RegExpPrototypeTest:(e,t)=>e.test(t),SafeSet:Set,String,StringPrototypeSlice:(e,t,i)=>e.slice(t,i),StringPrototypeToLowerCase:e=>e.toLowerCase(),StringPrototypeToUpperCase:e=>e.toUpperCase(),StringPrototypeTrim:e=>e.trim(),Symbol,SymbolFor:Symbol.for,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,SymbolDispose:Symbol.dispose||Symbol("Symbol.dispose"),SymbolAsyncDispose:Symbol.asyncDispose||Symbol("Symbol.asyncDispose"),TypedArrayPrototypeSet:(e,t,i)=>e.set(t,i),Boolean,Uint8Array}},3390:(e,t,i)=>{var n=i(9023),o=i(2203).Stream,r=i(5830);function s(){this.writable=!1,this.readable=!0,this.dataSize=0,this.maxDataSize=2097152,this.pauseStreams=!0,this._released=!1,this._streams=[],this._currentStream=null,this._insideLoop=!1,this._pendingNext=!1}e.exports=s,n.inherits(s,o),s.create=function(e){var t=new this;for(var i in e=e||{})t[i]=e[i];return t},s.isStreamLike=function(e){return"function"!=typeof e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e&&!Buffer.isBuffer(e)},s.prototype.append=function(e){if(s.isStreamLike(e)){if(!(e instanceof r)){var t=r.create(e,{maxDataSize:1/0,pauseStream:this.pauseStreams});e.on("data",this._checkDataSize.bind(this)),e=t}this._handleErrors(e),this.pauseStreams&&e.pause()}return this._streams.push(e),this},s.prototype.pipe=function(e,t){return o.prototype.pipe.call(this,e,t),this.resume(),e},s.prototype._getNext=function(){if(this._currentStream=null,this._insideLoop)this._pendingNext=!0;else{this._insideLoop=!0;try{do{this._pendingNext=!1,this._realGetNext()}while(this._pendingNext)}finally{this._insideLoop=!1}}},s.prototype._realGetNext=function(){var e=this._streams.shift();"undefined"!=typeof e?"function"==typeof e?e(function(e){s.isStreamLike(e)&&(e.on("data",this._checkDataSize.bind(this)),this._handleErrors(e)),this._pipeNext(e)}.bind(this)):this._pipeNext(e):this.end()},s.prototype._pipeNext=function(e){if(this._currentStream=e,s.isStreamLike(e))return e.on("end",this._getNext.bind(this)),void e.pipe(this,{end:!1});var t=e;this.write(t),this._getNext()},s.prototype._handleErrors=function(e){var t=this;e.on("error",(function(e){t._emitError(e)}))},s.prototype.write=function(e){this.emit("data",e)},s.prototype.pause=function(){this.pauseStreams&&(this.pauseStreams&&this._currentStream&&"function"==typeof this._currentStream.pause&&this._currentStream.pause(),this.emit("pause"))},s.prototype.resume=function(){this._released||(this._released=!0,this.writable=!0,this._getNext()),this.pauseStreams&&this._currentStream&&"function"==typeof this._currentStream.resume&&this._currentStream.resume(),this.emit("resume")},s.prototype.end=function(){this._reset(),this.emit("end")},s.prototype.destroy=function(){this._reset(),this.emit("close")},s.prototype._reset=function(){this.writable=!1,this._streams=[],this._currentStream=null},s.prototype._checkDataSize=function(){if(this._updateDataSize(),!(this.dataSize<=this.maxDataSize)){var e="DelayedStream#maxDataSize of "+this.maxDataSize+" bytes exceeded.";this._emitError(new Error(e))}},s.prototype._updateDataSize=function(){this.dataSize=0;var e=this;this._streams.forEach((function(t){t.dataSize&&(e.dataSize+=t.dataSize)})),this._currentStream&&this._currentStream.dataSize&&(this.dataSize+=this._currentStream.dataSize)},s.prototype._emitError=function(e){this._reset(),this.emit("error",e)}},3417:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.interfaceAddress=void 0,t.randomPort=o,t.randomPorts=async function(e,t="udp4",i){return Promise.all([...Array(e)].map((()=>o(t,i))))},t.findPort=async function(e,i,o="udp4",r){let s;for(let a=e;a<=i;a++){const c=(0,n.createSocket)(o);setImmediate((()=>c.bind({port:a,address:(0,t.interfaceAddress)(o,r)})));if(await new Promise((e=>{c.once("error",(t=>e(t))),c.once("listening",(()=>e()))})))await new Promise((e=>c.close((()=>e()))));else if(s=c.address()?.port,await new Promise((e=>c.close((()=>e())))),e<=s&&s<=i)break}if(!s)throw new Error("port not found");return s},t.normalizeFamilyNodeV18=function(e){return"IPv4"===e?4:"IPv6"===e?6:e};const n=i(7194);async function o(e="udp4",i){const o=(0,n.createSocket)(e);setImmediate((()=>o.bind({port:0,address:(0,t.interfaceAddress)(e,i)}))),await new Promise((e=>{o.once("error",e),o.once("listening",e)}));const r=o.address()?.port;return await new Promise((e=>o.close((()=>e())))),r}t.interfaceAddress=(e,t)=>t?t[e]:void 0},3482:(e,t,i)=>{const n=i(2018),o=i(9023);t.init=function(e){e.inspectOpts={};const i=Object.keys(t.inspectOpts);for(let n=0;n<i.length;n++)e.inspectOpts[i[n]]=t.inspectOpts[i[n]]},t.log=function(...e){return process.stderr.write(o.format(...e)+"\n")},t.formatArgs=function(i){const{namespace:n,useColors:o}=this;if(o){const t=this.color,o="[3"+(t<8?t:"8;5;"+t),r=` ${o};1m${n} [0m`;i[0]=r+i[0].split("\n").join("\n"+r),i.push(o+"m+"+e.exports.humanize(this.diff)+"[0m")}else i[0]=function(){if(t.inspectOpts.hideDate)return"";return(new Date).toISOString()+" "}()+n+" "+i[0]},t.save=function(e){e?process.env.DEBUG=e:delete process.env.DEBUG},t.load=function(){return process.env.DEBUG},t.useColors=function(){return"colors"in t.inspectOpts?Boolean(t.inspectOpts.colors):n.isatty(process.stderr.fd)},t.destroy=o.deprecate((()=>{}),"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{const e=i(Object(function(){var e=new Error("Cannot find module 'supports-color'");throw e.code="MODULE_NOT_FOUND",e}()));e&&(e.stderr||e).level>=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}t.inspectOpts=Object.keys(process.env).filter((e=>/^debug_/i.test(e))).reduce(((e,t)=>{const i=t.substring(6).toLowerCase().replace(/_([a-z])/g,((e,t)=>t.toUpperCase()));let n=process.env[t];return n=!!/^(yes|on|true|enabled)$/i.test(n)||!/^(no|off|false|disabled)$/i.test(n)&&("null"===n?null:Number(n)),e[i]=n,e}),{}),e.exports=i(5175)(t);const{formatters:r}=e.exports;r.o=function(e){return this.inspectOpts.colors=this.useColors,o.inspect(e,this.inspectOpts).split("\n").map((e=>e.trim())).join(" ")},r.O=function(e){return this.inspectOpts.colors=this.useColors,o.inspect(e,this.inspectOpts)}},3500:e=>{"use strict";e.exports=JSON.parse('{"name":"@apocaliss92/scrypted-events-recorder","description":"Record events on detections or motion on a mounted volume","repository":{"type":"git","url":"https://github.com/apocaliss92/scrypted-events-recorder"},"version":"0.0.51","scripts":{"scrypted-setup-project":"scrypted-setup-project","prescrypted-setup-project":"scrypted-package-json","build":"scrypted-webpack","prepublishOnly":"NODE_ENV=production scrypted-webpack","prescrypted-vscode-launch":"scrypted-webpack","scrypted-vscode-launch":"scrypted-deploy-debug","scrypted-deploy-debug":"scrypted-deploy-debug","scrypted-debug":"scrypted-debug","scrypted-deploy":"scrypted-deploy","scrypted-readme":"scrypted-readme","scrypted-package-json":"scrypted-package-json"},"keywords":["scrypted","plugin","detect","events","recorder","motion","storage","clips","videoclips"],"scrypted":{"name":"Events recorder","type":"API","interfaces":["ScryptedSystemDevice","Settings","MixinProvider","HttpRequestHandler"]},"dependencies":{"@scrypted/common":"file:../scrypted/common","@scrypted/sdk":"0.5.32","@types/lodash":"^4.17.14","lodash":"^4.17.21","moment":"^2.30.1"},"devDependencies":{"@types/moment":"^2.11.29","@types/node":"^20.11.0"}}')},3540:function(e,t,i){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[t.length]=i);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i=n(e),s=0;s<i.length;s++)"default"!==i[s]&&o(t,e,i[s]);return r(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.StorageSettings=void 0;const a=s(i(3861)),{systemManager:c}=a.default;t.StorageSettings=class{constructor(e,t){this.device=e,this.settings=t,this.values={},this.hasValue={};for(const e of Object.keys(t)){const i=t[e],n=()=>this.getItem(e);let o;o="clippath"!==i.type?n:()=>{try{return JSON.parse(n())}catch(e){}},Object.defineProperty(this.values,e,{get:o,set:t=>this.putSetting(e,t),enumerable:!0}),Object.defineProperty(this.hasValue,e,{get:()=>null!=this.device.storage.getItem(e),enumerable:!0})}}get keys(){const e={};for(const t of Object.keys(this.settings))e[t]=t;return e}async getSettings(){const e=await(this.options?.onGet?.()),t=[];for(const[i,n]of Object.entries(this.settings)){let o=Object.assign({},n);e?.[i]&&(o=Object.assign(o,e[i])),o.onGet&&(o=Object.assign(o,await o.onGet())),o.hide||await(this.options?.hide?.[i]?.())||(o.key=i,o.value=this.getItemInternal(i,o,!0),"function"==typeof o.deviceFilter&&(o.deviceFilter=o.deviceFilter.toString()),t.push(o),delete o.onPut,delete o.onGet,delete o.mapPut,delete o.mapGet)}return t}async putSetting(e,t){const i=this.settings[e];let n;return i&&(n=this.getItemInternal(e,i)),this.putSettingInternal(i,n,e,t)}putSettingInternal(e,t,i,n){e?.noStore||(e?.mapPut&&(n=e.mapPut(t,n)),null==n?this.device.storage.removeItem(i):"object"==typeof n?this.device.storage.setItem(i,JSON.stringify(n)):this.device.storage.setItem(i,n?.toString())),e?.onPut?.(t,n),e?.hide||this.device.onDeviceEvent(a.ScryptedInterface.Settings,void 0)}getItemInternal(e,t,i){if(!t)return this.device.storage.getItem(e);const n=function(e,t,i,n){if(null==e)return i();const o=t.multiple?"array":t.type;if("boolean"===o)return"true"===e||"false"!==e&&(i()||!1);if("number"===o){const t=parseFloat(e);return isNaN(t)?i()||0:t}if("integer"===o){const t=parseInt(e);return isNaN(t)?i()||0:t}if("array"===o){if(!e)return i()||[];try{return JSON.parse(e)}catch(e){return i()||[]}}if("device"===o)return n?e:c.getDeviceById(e)||c.getDeviceById(i());if(e&&t.json)try{return JSON.parse(e)}catch(e){return i()}return e||i()}(this.device.storage.getItem(e),t,(()=>null!=t.persistedDefaultValue?(this.putSettingInternal(t,void 0,e,t.persistedDefaultValue),t.persistedDefaultValue):t.defaultValue),i);return t.mapGet?t.mapGet(n):n}getItem(e){return this.getItemInternal(e,this.settings[e])}}},3557:e=>{"use strict";e.exports=require("timers")},3586:(e,t,i)=>{e.exports=function(e){const t=i(4081).linerase,n=i(3009);e.prototype.getPresets=function(e,i){void 0===i&&(i=e,e={}),this._request({service:"ptz",body:this._envelopeHeader()+'<GetPresets xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>'+(e.profileToken||this.activeSource.profileToken)+"</ProfileToken></GetPresets>"+this._envelopeFooter()},function(e,n,o){if(!e){this.presets={};var r=t(n).getPresetsResponse.preset;"undefined"!=typeof r&&(Array.isArray(r)||(r=[r]),r.forEach(function(e){this.presets[e.name]=e.$.token}.bind(this)))}i&&i.call(this,e,this.presets,o)}.bind(this))},e.prototype.gotoPreset=function(e,t){this._request({service:"ptz",body:this._envelopeHeader()+'<GotoPreset xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>'+(e.profileToken||this.activeSource.profileToken)+"</ProfileToken><PresetToken>"+e.preset+"</PresetToken>"+(e.speed?"<Speed>"+this._panTiltZoomVectors(e.speed)+"</Speed>":"")+"</GotoPreset>"+this._envelopeFooter()},t.bind(this))},e.prototype.setPreset=function(e,t){this._request({service:"ptz",body:this._envelopeHeader()+'<SetPreset xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>'+(e.profileToken||this.activeSource.profileToken)+"</ProfileToken><PresetName>"+e.presetName+"</PresetName>"+(e.presetToken?"<PresetToken>"+e.presetToken+"</PresetToken>":"")+"</SetPreset>"+this._envelopeFooter()},t.bind(this))},e.prototype.removePreset=function(e,t){this._request({service:"ptz",body:this._envelopeHeader()+'<RemovePreset xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>'+(e.profileToken||this.activeSource.profileToken)+"</ProfileToken><PresetToken>"+e.presetToken+"</PresetToken></RemovePreset>"+this._envelopeFooter()},t.bind(this))},e.prototype.gotoHomePosition=function(e,t){this._request({service:"ptz",body:this._envelopeHeader()+'<GotoHomePosition xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>'+(e.profileToken||this.activeSource.profileToken)+"</ProfileToken>"+(e.speed?"<Speed>"+this._panTiltZoomVectors(e.speed)+"</Speed>":"")+"</GotoHomePosition>"+this._envelopeFooter()},t.bind(this))},e.prototype.setHomePosition=function(e,t){this._request({service:"ptz",body:this._envelopeHeader()+'<SetHomePosition xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>'+(e.profileToken||this.activeSource.profileToken)+"</ProfileToken></SetHomePosition>"+this._envelopeFooter()},t.bind(this))},e.prototype.getStatus=function(e,i){void 0===i&&(i=e,e={}),this._request({service:"ptz",body:this._envelopeHeader()+'<GetStatus xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>'+(e.profileToken||this.activeSource.profileToken)+"</ProfileToken></GetStatus>"+this._envelopeFooter()},function(e,o,r){if(!e)var s=t(o).getStatusResponse.PTZStatus,a={position:{x:n(s,"position.panTilt.$.x",0),y:n(s,"position.panTilt.$.y",0),zoom:n(s,"position.zoom.$.x",0)},moveStatus:s.moveStatus,error:s.error,utcTime:s.utcTime};i.call(this,e,e?null:a,r)}.bind(this))},e.prototype.getNodes=function(e){this._request({service:"ptz",body:this._envelopeHeader()+'<GetNodes xmlns="http://www.onvif.org/ver20/ptz/wsdl" />'+this._envelopeFooter()},function(i,n,o){if(!i){var r=this.nodes={};n[0].getNodesResponse.forEach((function(e){r[e.PTZNode[0].$.token]=t(e.PTZNode[0]),delete r[e.PTZNode[0].$.token].$}))}e.call(this,i,r,o)}.bind(this))},e.prototype.getConfigurations=function(e){this._request({service:"ptz",body:this._envelopeHeader()+'<GetConfigurations xmlns="http://www.onvif.org/ver20/ptz/wsdl"></GetConfigurations>'+this._envelopeFooter()},function(t,i,n){if(!t){var o={};i[0].getConfigurationsResponse.forEach((function(e){e.PTZConfiguration.forEach((function(e){var t=e.name;if(Array.isArray(t)&&(t=t[0]),o[t]={},o[t].useCount=parseInt(e.useCount),"$"in e&&(o[t].token=e.$.token),"nodeToken"in e&&(o[t].nodeToken=e.nodeToken[0]),"defaultPTZSpeed"in e){var i=e.defaultPTZSpeed[0];o[t].defaultPTZSpeed={},"panTilt"in i&&(o[t].defaultPTZSpeed.x=i.panTilt[0].$.x,o[t].defaultPTZSpeed.y=i.panTilt[0].$.y),"zoom"in i&&(o[t].defaultPTZSpeed.zoom=i.zoom[0].$.x)}if("defaultPTZTimeout"in e&&(o[t].defaultPTZTimeout=e.defaultPTZTimeout[0]),"panTiltLimits"in e){o[t].panTiltLimits={};var n=e.panTiltLimits[0].range[0];o[t].panTiltLimits.XRange={},o[t].panTiltLimits.XRange.min=n.XRange[0].min[0],o[t].panTiltLimits.XRange.max=n.XRange[0].max[0],o[t].panTiltLimits.YRange={},o[t].panTiltLimits.YRange.min=n.YRange[0].min[0],o[t].panTiltLimits.YRange.max=n.YRange[0].max[0]}if("zoomLimits"in e){o[t].zoomLimits={};var r=e.zoomLimits[0].range[0];o[t].zoomLimits.XRange={},o[t].zoomLimits.XRange.min=r.XRange[0].min[0],o[t].zoomLimits.XRange.max=r.XRange[0].max[0]}}))})),this.configurations=o}e&&e.call(this,t,this.configurations,n)}.bind(this))},e.prototype.getConfigurationOptions=function(e,t){this._request({service:"ptz",body:this._envelopeHeader()+'<GetConfigurationOptions xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ConfigurationToken>'+e+"</ConfigurationToken></GetConfigurationOptions>"+this._envelopeFooter()},function(i,n,o){var r;if(!i){var s=n[0].getConfigurationOptionsResponse[0].PTZConfigurationOptions[0].spaces[0];(r={ptzTimeout:{min:n[0].getConfigurationOptionsResponse[0].PTZConfigurationOptions[0].PTZTimeout[0].min,max:n[0].getConfigurationOptionsResponse[0].PTZConfigurationOptions[0].PTZTimeout[0].max},spaces:{absolute:{x:{min:s.absolutePanTiltPositionSpace?parseFloat(s.absolutePanTiltPositionSpace[0].XRange[0].min[0]):0,max:s.absolutePanTiltPositionSpace?parseFloat(s.absolutePanTiltPositionSpace[0].XRange[0].max[0]):0,uri:s.absolutePanTiltPositionSpace?s.absolutePanTiltPositionSpace[0].URI:""},y:{min:s.absolutePanTiltPositionSpace?parseFloat(s.absolutePanTiltPositionSpace[0].YRange[0].min[0]):0,max:s.absolutePanTiltPositionSpace?parseFloat(s.absolutePanTiltPositionSpace[0].YRange[0].max[0]):0,uri:s.absolutePanTiltPositionSpace?s.absolutePanTiltPositionSpace[0].URI:""},zoom:{min:s.absoluteZoomPositionSpace?parseFloat(s.absoluteZoomPositionSpace[0].XRange[0].min[0]):0,max:s.absoluteZoomPositionSpace?parseFloat(s.absoluteZoomPositionSpace[0].XRange[0].max[0]):0,uri:s.absoluteZoomPositionSpace?s.absoluteZoomPositionSpace[0].URI:""}},relative:{x:{min:s.relativePanTiltTranslationSpace?parseFloat(s.relativePanTiltTranslationSpace[0].XRange[0].min[0]):0,max:s.relativePanTiltTranslationSpace?parseFloat(s.relativePanTiltTranslationSpace[0].XRange[0].max[0]):0,uri:s.relativePanTiltTranslationSpace?s.relativePanTiltTranslationSpace[0].URI:""},y:{min:s.relativePanTiltTranslationSpace?parseFloat(s.relativePanTiltTranslationSpace[0].YRange[0].min[0]):0,max:s.relativePanTiltTranslationSpace?parseFloat(s.relativePanTiltTranslationSpace[0].YRange[0].max[0]):0,uri:s.relativePanTiltTranslationSpace?s.relativePanTiltTranslationSpace[0].URI:""},zoom:{min:s.relativeZoomTranslationSpace?parseFloat(s.relativeZoomTranslationSpace[0].XRange[0].min[0]):0,max:s.relativeZoomTranslationSpace?parseFloat(s.relativeZoomTranslationSpace[0].XRange[0].max[0]):0,uri:s.relativeZoomTranslationSpace?s.relativeZoomTranslationSpace[0].URI:""}},continuous:{x:{min:s.continuousPanTiltVelocitySpace?parseFloat(s.continuousPanTiltVelocitySpace[0].XRange[0].min[0]):0,max:s.continuousPanTiltVelocitySpace?parseFloat(s.continuousPanTiltVelocitySpace[0].XRange[0].max[0]):0,uri:s.continuousPanTiltVelocitySpace?s.continuousPanTiltVelocitySpace[0].URI:""},y:{min:s.continuousPanTiltVelocitySpace?parseFloat(s.continuousPanTiltVelocitySpace[0].YRange[0].min[0]):0,max:s.continuousPanTiltVelocitySpace?parseFloat(s.continuousPanTiltVelocitySpace[0].YRange[0].max[0]):0,uri:s.continuousPanTiltVelocitySpace?s.continuousPanTiltVelocitySpace[0].URI:""},zoom:{min:s.continuousZoomVelocitySpace?parseFloat(s.continuousZoomVelocitySpace[0].XRange[0].min[0]):0,max:s.continuousZoomVelocitySpace?parseFloat(s.continuousZoomVelocitySpace[0].XRange[0].max[0]):0,uri:s.continuousZoomVelocitySpace?s.continuousZoomVelocitySpace[0].URI:""}},common:{x:{min:s.panTiltSpeedSpace?parseFloat(s.panTiltSpeedSpace[0].XRange[0].min[0]):0,max:s.panTiltSpeedSpace?parseFloat(s.panTiltSpeedSpace[0].XRange[0].max[0]):0,uri:s.panTiltSpeedSpace?s.panTiltSpeedSpace[0].URI:""},zoom:{min:s.zoomSpeedSpace?parseFloat(s.zoomSpeedSpace[0].XRange[0].min[0]):0,max:s.zoomSpeedSpace?parseFloat(s.zoomSpeedSpace[0].XRange[0].max[0]):0,uri:s.zoomSpeedSpace?s.zoomSpeedSpace[0].URI:""}}}}).ptzspaces=[];for(const e of Object.keys(s))for(const t of s[e]){let i={name:e,uri:t.URI[0]};t.XRange&&(i.x={min:parseFloat(t.XRange[0].min[0]),max:parseFloat(t.XRange[0].max[0])}),t.YRange&&(i.y={min:parseFloat(t.YRange[0].min[0]),max:parseFloat(t.YRange[0].max[0])}),r.ptzspaces.push(i)}this.configurations&&this.configurations[e]&&Object.assign(this.configurations[e],r)}t&&t.call(this,i,r,o)}.bind(this))},e.prototype.relativeMove=function(e,t){t=t?t.bind(this):function(){},e.x=e.x||0,e.y=e.y||0,e.zoom=e.zoom||0,this._request({service:"ptz",body:this._envelopeHeader()+'<RelativeMove xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>'+(e.profileToken||this.activeSource.profileToken)+"</ProfileToken><Translation>"+this._panTiltZoomVectors(e)+"</Translation>"+(e.speed?"<Speed>"+this._panTiltZoomVectors(e.speed)+"</Speed>":"")+"</RelativeMove>"+this._envelopeFooter()},t.bind(this))},e.prototype.absoluteMove=function(e,t){t=t?t.bind(this):function(){},e.x=e.x||0,e.y=e.y||0,e.zoom=e.zoom||0,e.onlySendPanTilt&&delete e.zoom,e.onlySendZoom&&(delete e.x,delete e.y),this._request({service:"ptz",body:this._envelopeHeader()+'<AbsoluteMove xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>'+(e.profileToken||this.activeSource.profileToken)+"</ProfileToken><Position>"+this._panTiltZoomVectors(e)+"</Position>"+(e.speed?"<Speed>"+this._panTiltZoomVectors(e.speed)+"</Speed>":"")+"</AbsoluteMove>"+this._envelopeFooter()},t.bind(this))},e.prototype.continuousMove=function(e,t){t=t?t.bind(this):function(){},e.x=e.x||0,e.y=e.y||0,e.zoom=e.zoom||0,e.onlySendPanTilt&&delete e.zoom,e.onlySendZoom&&(delete e.x,delete e.y),this._request({service:"ptz",body:this._envelopeHeader()+'<ContinuousMove xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>'+(e.profileToken||this.activeSource.profileToken)+"</ProfileToken><Velocity>"+this._panTiltZoomVectors(e)+"</Velocity>"+(e.timeout?"<Timeout>PT"+e.timeout/1e3+"S</Timeout>":"")+"</ContinuousMove>"+this._envelopeFooter()},t.bind(this))},e.prototype.stop=function(e,t){if(void 0===t)switch(typeof e){case"object":t=function(){};break;case"function":t=e,e={};break;default:t=function(){},e={}}this._request({service:"ptz",body:this._envelopeHeader()+'<Stop xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>'+(e.profileToken||this.activeSource.profileToken)+"</ProfileToken>"+(e.panTilt?"<PanTilt>"+e.panTilt+"</PanTilt>":"")+(e.zoom?"<Zoom>"+e.zoom+"</Zoom>":"")+"</Stop>"+this._envelopeFooter()},t.bind(this))},e.prototype._panTiltZoomVectors=function(e){const t=void 0!==e.xyspace?' space="'+e.xyspace+'"':"",i=void 0!==e.zoomspace?' space="'+e.zoomspace+'"':"";return e?(void 0!==e.x&&void 0!==e.y?'<PanTilt x="'+e.x+'" y="'+e.y+'"'+t+' xmlns="http://www.onvif.org/ver10/schema"/>':"")+(void 0!==e.zoom?'<Zoom x="'+e.zoom+'"'+i+' xmlns="http://www.onvif.org/ver10/schema"/>':""):""},e.prototype.ptzSendAuxiliaryCommand=function(e,t){let i=this._envelopeHeader()+'<SendAuxiliaryCommand xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>'+(e.profileToken||this.activeSource.profileToken)+"</ProfileToken><AuxiliaryData>"+e.data+"</AuxiliaryData></SendAuxiliaryCommand>"+this._envelopeFooter();this._request({service:"ptz",body:i},function(e,i,n){t&&t.call(this,e,i,n)}.bind(this))}}},3609:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getHttpFetchParser=l,t.httpFetchParseIncomingMessage=p,t.httpFetch=async function(e){const t=(0,n.createHeadersArray)(e.headers);(0,n.setDefaultHttpFetchAccept)(t,e.responseType);const{once:r}=i(4434),{PassThrough:s,Readable:a}=i(2203),{http:c,https:l}=i(1783),{url:u}=e,d=u.toString().startsWith("https:")?l:c;let h,m,{body:f}=e;if(f&&!(f instanceof a)){const e=new s;e.write(Buffer.from((0,n.createStringOrBufferBody)(t,f))),e.end(),f=e}e.timeout&&(h=new AbortController,m=setTimeout((()=>h.abort()),e.timeout),e.signal?.addEventListener("abort",(()=>h.abort(e.signal?.reason))));const g=h?.signal||e.signal;g?.addEventListener("abort",(()=>y.destroy(new Error(e.signal?.reason||"abort"))));const v={};for(const[e,i]of t)v[e]?v[e].push(i):v[e]=[i];const y=d.request(u,{method:(0,n.getFetchMethod)(e),rejectUnauthorized:e.rejectUnauthorized,family:e.family,headers:v,signal:g,timeout:e.timeout});f?f.pipe(y):y.end();try{const[t]=await r(y,"response");if(void 0===e?.checkStatusCode||e?.checkStatusCode)try{const i="function"==typeof e?.checkStatusCode?e.checkStatusCode:n.checkStatus;if(!t.statusCode||!i(t.statusCode))throw new Error(`http response statusCode ${t.statusCode}`)}catch(e){throw o(t).catch((()=>{})),e}const i=new Headers;for(const[e,n]of Object.entries(t.headers))for(const t of"string"==typeof n?[n]:n)i.append(e,t);return{statusCode:t.statusCode,headers:i,body:await p(t,e.responseType)}}finally{clearTimeout(m)}};const n=i(4426);async function o(e){const t=[];e.on("data",(e=>t.push(e)));const{once:n}=i(4434);return await n(e,"end"),Buffer.concat(t)}const r={parse:async e=>(await o(e)).toString()},s={parse:async e=>JSON.parse((await o(e)).toString())},a={parse:async e=>o(e)},c={parse:async e=>e};function l(e){switch(e){case"json":return s;case"text":return r;case"readable":return c}return a}function p(e,t){return l(t).parse(e)}},3628:e=>{"use strict";"undefined"==typeof process||!process.version||0===process.version.indexOf("v0.")||0===process.version.indexOf("v1.")&&0!==process.version.indexOf("v1.8.")?e.exports={nextTick:function(e,t,i,n){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var o,r,s=arguments.length;switch(s){case 0:case 1:return process.nextTick(e);case 2:return process.nextTick((function(){e.call(null,t)}));case 3:return process.nextTick((function(){e.call(null,t,i)}));case 4:return process.nextTick((function(){e.call(null,t,i,n)}));default:for(o=new Array(s-1),r=0;r<o.length;)o[r++]=arguments[r];return process.nextTick((function(){e.apply(null,o)}))}}}:e.exports=process},3725:function(e){(function(){e.exports=function(){function e(){}return e.prototype.hasFeature=function(e,t){return!0},e.prototype.createDocumentType=function(e,t,i){throw new Error("This DOM method is not implemented.")},e.prototype.createDocument=function(e,t,i){throw new Error("This DOM method is not implemented.")},e.prototype.createHTMLDocument=function(e){throw new Error("This DOM method is not implemented.")},e.prototype.getFeature=function(e,t){throw new Error("This DOM method is not implemented.")},e}()}).call(this)},3751:(e,t,i)=>{"use strict";const{tokenChars:n}=i(3271);function o(e,t,i){void 0===e[t]?e[t]=[i]:e[t].push(i)}e.exports={format:function(e){return Object.keys(e).map((t=>{let i=e[t];return Array.isArray(i)||(i=[i]),i.map((e=>[t].concat(Object.keys(e).map((t=>{let i=e[t];return Array.isArray(i)||(i=[i]),i.map((e=>!0===e?t:`${t}=${e}`)).join("; ")}))).join("; "))).join(", ")})).join(", ")},parse:function(e){const t=Object.create(null);let i,r,s=Object.create(null),a=!1,c=!1,l=!1,p=-1,u=-1,d=-1,h=0;for(;h<e.length;h++)if(u=e.charCodeAt(h),void 0===i)if(-1===d&&1===n[u])-1===p&&(p=h);else if(0===h||32!==u&&9!==u){if(59!==u&&44!==u)throw new SyntaxError(`Unexpected character at index ${h}`);{if(-1===p)throw new SyntaxError(`Unexpected character at index ${h}`);-1===d&&(d=h);const n=e.slice(p,d);44===u?(o(t,n,s),s=Object.create(null)):i=n,p=d=-1}}else-1===d&&-1!==p&&(d=h);else if(void 0===r)if(-1===d&&1===n[u])-1===p&&(p=h);else if(32===u||9===u)-1===d&&-1!==p&&(d=h);else if(59===u||44===u){if(-1===p)throw new SyntaxError(`Unexpected character at index ${h}`);-1===d&&(d=h),o(s,e.slice(p,d),!0),44===u&&(o(t,i,s),s=Object.create(null),i=void 0),p=d=-1}else{if(61!==u||-1===p||-1!==d)throw new SyntaxError(`Unexpected character at index ${h}`);r=e.slice(p,h),p=d=-1}else if(c){if(1!==n[u])throw new SyntaxError(`Unexpected character at index ${h}`);-1===p?p=h:a||(a=!0),c=!1}else if(l)if(1===n[u])-1===p&&(p=h);else if(34===u&&-1!==p)l=!1,d=h;else{if(92!==u)throw new SyntaxError(`Unexpected character at index ${h}`);c=!0}else if(34===u&&61===e.charCodeAt(h-1))l=!0;else if(-1===d&&1===n[u])-1===p&&(p=h);else if(-1===p||32!==u&&9!==u){if(59!==u&&44!==u)throw new SyntaxError(`Unexpected character at index ${h}`);{if(-1===p)throw new SyntaxError(`Unexpected character at index ${h}`);-1===d&&(d=h);let n=e.slice(p,d);a&&(n=n.replace(/\\/g,""),a=!1),o(s,r,n),44===u&&(o(t,i,s),s=Object.create(null),i=void 0),r=void 0,p=d=-1}}else-1===d&&(d=h);if(-1===p||l||32===u||9===u)throw new SyntaxError("Unexpected end of input");-1===d&&(d=h);const m=e.slice(p,d);return void 0===i?o(t,m,s):(void 0===r?o(s,m,!0):o(s,r,a?m.replace(/\\/g,""):m),o(t,i,s)),t}}},3861:function(e,t,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||n(t,e,i)};Object.defineProperty(t,"__esModule",{value:!0}),t.sdk=t.MixinDeviceBase=t.ScryptedDeviceBase=void 0,o(i(9387),t);const r=i(9387);i(3339);class s extends r.DeviceBase{constructor(e){super(),this.nativeId=e}get storage(){return this._storage||(this._storage=t.sdk.deviceManager.getDeviceStorage(this.nativeId)),this._storage}get log(){return this._log||(this._log=t.sdk.deviceManager.getDeviceLogger(this.nativeId)),this._log}get console(){return this._console||(this._console=t.sdk.deviceManager.getDeviceConsole(this.nativeId)),this._console}async createMediaObject(e,i){return t.sdk.mediaManager.createMediaObject(e,i,{sourceId:this.id})}getMediaObjectConsole(e){return"string"!=typeof e.sourceId?this.console:t.sdk.deviceManager.getMixinConsole(e.sourceId,this.nativeId)}_lazyLoadDeviceState(){this._deviceState||(this.nativeId?this._deviceState=t.sdk.deviceManager.getDeviceState(this.nativeId):this._deviceState=t.sdk.deviceManager.getDeviceState())}onDeviceEvent(e,i){return t.sdk.deviceManager.onDeviceEvent(this.nativeId,e,i)}}t.ScryptedDeviceBase=s;class a extends r.DeviceBase{constructor(e){super(),this._listeners=new Set,this.mixinDevice=e.mixinDevice,this.mixinDeviceInterfaces=e.mixinDeviceInterfaces,this.mixinStorageSuffix=e.mixinStorageSuffix,this._deviceState=e.mixinDeviceState,this.nativeId=t.sdk.systemManager.getDeviceById(this.id).nativeId,this.mixinProviderNativeId=e.mixinProviderNativeId,this._deviceState.__rpcproxy_traps_all_properties&&"string"==typeof this._deviceState.id&&(this._deviceState=t.sdk.deviceManager.createDeviceState(this._deviceState.id,this._deviceState.setState))}get storage(){if(!this._storage){const e=this.mixinStorageSuffix,i=this.id+(e?":"+e:"");this._storage=t.sdk.deviceManager.getMixinStorage(i,this.mixinProviderNativeId)}return this._storage}get console(){return this._console||(t.sdk.deviceManager.getMixinConsole?this._console=t.sdk.deviceManager.getMixinConsole(this.id,this.mixinProviderNativeId):this._console=t.sdk.deviceManager.getDeviceConsole(this.mixinProviderNativeId)),this._console}async createMediaObject(e,i){return t.sdk.mediaManager.createMediaObject(e,i,{sourceId:this.id})}getMediaObjectConsole(e){return"string"!=typeof e.sourceId?this.console:t.sdk.deviceManager.getMixinConsole(e.sourceId,this.mixinProviderNativeId)}onDeviceEvent(e,i){return t.sdk.deviceManager.onMixinEvent(this.id,this,e,i)}_lazyLoadDeviceState(){}manageListener(e){this._listeners.add(e)}release(){for(const e of this._listeners)e.removeListener()}}t.MixinDeviceBase=a,function(){function e(e){return function(){return this._lazyLoadDeviceState(),this._deviceState?.[e]}}function t(e){return function(t){this._lazyLoadDeviceState(),this._deviceState?this._deviceState[e]=t:console.warn("device state is unavailable. the device must be discovered with deviceManager.onDeviceDiscovered or deviceManager.onDevicesChanged before the state can be set.")}}for(const i of Object.values(r.ScryptedInterfaceProperty))i!==r.ScryptedInterfaceProperty.nativeId&&(Object.defineProperty(s.prototype,i,{set:t(i),get:e(i)}),Object.defineProperty(a.prototype,i,{set:t(i),get:e(i)}))}(),t.sdk={};try{let e=!1;try{process.env.SCRYPTED_SDK_ES_MODULE||process.env.SCRYPTED_SDK_MODULE;const n=process.env.SCRYPTED_SDK_CJS_MODULE||process.env.SCRYPTED_SDK_MODULE;if(n)if("undefined"!=typeof require){const i=require(process.env.SCRYPTED_SDK_MODULE);Object.assign(t.sdk,i.getScryptedStatic()),e=!0}else{const o=i(5520)(n);Object.assign(t.sdk,o.getScryptedStatic()),e=!0}}catch(e){throw console.warn("failed to load sdk module",e),e}if(!e){let e;try{e=pluginRuntimeAPI}catch(e){}Object.assign(t.sdk,{log:deviceManager.getDeviceLogger(void 0),deviceManager,endpointManager,mediaManager,systemManager,pluginHostAPI,...e})}try{t.sdk.systemManager.setScryptedInterfaceDescriptors?.(r.TYPES_VERSION,r.ScryptedInterfaceDescriptors)?.catch((()=>{}))}catch(e){}}catch(e){console.error("sdk initialization error, import @scrypted/types or use @scrypted/client instead",e)}t.default=t.sdk},3874:function(e,t){(function(){"use strict";t.stripBOM=function(e){return"\ufeff"===e[0]?e.substring(1):e}}).call(this)},3901:(e,t,i)=>{const n=i(3328);e.exports.NumberAllocator=n},3939:(e,t,i)=>{"use strict";const n=i(181),{kResistStopPropagation:o,SymbolDispose:r}=i(3383),s=globalThis.AbortSignal||i(581).AbortSignal,a=globalThis.AbortController||i(581).AbortController,c=Object.getPrototypeOf((async function(){})).constructor,l=globalThis.Blob||n.Blob,p="undefined"!=typeof l?function(e){return e instanceof l}:function(e){return!1},u=(e,t)=>{if(void 0!==e&&(null===e||"object"!=typeof e||!("aborted"in e)))throw new ERR_INVALID_ARG_TYPE(t,"AbortSignal",e)};class d extends Error{constructor(e){if(!Array.isArray(e))throw new TypeError("Expected input to be an Array, got "+typeof e);let t="";for(let i=0;i<e.length;i++)t+=` ${e[i].stack}\n`;super(t),this.name="AggregateError",this.errors=e}}e.exports={AggregateError:d,kEmptyObject:Object.freeze({}),once(e){let t=!1;return function(...i){t||(t=!0,e.apply(this,i))}},createDeferredPromise:function(){let e,t;return{promise:new Promise(((i,n)=>{e=i,t=n})),resolve:e,reject:t}},promisify:e=>new Promise(((t,i)=>{e(((e,...n)=>e?i(e):t(...n)))})),debuglog:()=>function(){},format:(e,...t)=>e.replace(/%([sdifj])/g,(function(...[e,i]){const n=t.shift();if("f"===i)return n.toFixed(6);if("j"===i)return JSON.stringify(n);if("s"===i&&"object"==typeof n){return`${n.constructor!==Object?n.constructor.name:""} {}`.trim()}return n.toString()})),inspect(e){switch(typeof e){case"string":if(e.includes("'")){if(!e.includes('"'))return`"${e}"`;if(!e.includes("`")&&!e.includes("${"))return`\`${e}\``}return`'${e}'`;case"number":return isNaN(e)?"NaN":Object.is(e,-0)?String(e):e;case"bigint":return`${String(e)}n`;case"boolean":case"undefined":return String(e);case"object":return"{}"}},types:{isAsyncFunction:e=>e instanceof c,isArrayBufferView:e=>ArrayBuffer.isView(e)},isBlob:p,deprecate:(e,t)=>e,addAbortListener:i(4434).addAbortListener||function(e,t){if(void 0===e)throw new ERR_INVALID_ARG_TYPE("signal","AbortSignal",e);let i;return u(e,"signal"),((e,t)=>{if("function"!=typeof e)throw new ERR_INVALID_ARG_TYPE(t,"Function",e)})(t,"listener"),e.aborted?queueMicrotask((()=>t())):(e.addEventListener("abort",t,{__proto__:null,once:!0,[o]:!0}),i=()=>{e.removeEventListener("abort",t)}),{__proto__:null,[r](){var e;null===(e=i)||void 0===e||e()}}},AbortSignalAny:s.any||function(e){if(1===e.length)return e[0];const t=new a,i=()=>t.abort();return e.forEach((e=>{u(e,"signals"),e.addEventListener("abort",i,{once:!0})})),t.signal.addEventListener("abort",(()=>{e.forEach((e=>e.removeEventListener("abort",i)))}),{once:!0}),t.signal}},e.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")},3969:function(e,t,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0});const s=r(i(8032)),a=i(4904),c={set:a.setInterval,clear:a.clearInterval},l={set:(e,t)=>setInterval(e,t),clear:e=>clearInterval(e)};t.default=e=>{switch(e){case"native":return l;case"worker":return c;default:return!s.default||s.isWebWorker||s.isReactNativeBrowser?l:c}}},4001:(e,t,i)=>{"use strict";const n=i(4434),o=i(8611),{Duplex:r}=i(2203),{createHash:s}=i(6982),a=i(3751),c=i(9064),l=i(1172),p=i(7465),{GUID:u,kWebSocket:d}=i(6639),h=/^[+/0-9A-Za-z]{22}==$/;function m(e){e._state=2,e.emit("close")}function f(){this.destroy()}function g(e,t,i,n){i=i||o.STATUS_CODES[t],n={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(i),...n},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${t} ${o.STATUS_CODES[t]}\r\n`+Object.keys(n).map((e=>`${e}: ${n[e]}`)).join("\r\n")+"\r\n\r\n"+i)}function v(e,t,i,n,o){if(e.listenerCount("wsClientError")){const n=new Error(o);Error.captureStackTrace(n,v),e.emit("wsClientError",n,i,t)}else g(i,n,o)}e.exports=class extends n{constructor(e,t){if(super(),null==(e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:p,...e}).port&&!e.server&&!e.noServer||null!=e.port&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(null!=e.port?(this._server=o.createServer(((e,t)=>{const i=o.STATUS_CODES[426];t.writeHead(426,{"Content-Length":i.length,"Content-Type":"text/plain"}),t.end(i)})),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){const e=this.emit.bind(this,"connection");this._removeListeners=function(e,t){for(const i of Object.keys(t))e.on(i,t[i]);return function(){for(const i of Object.keys(t))e.removeListener(i,t[i])}}(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(t,i,n)=>{this.handleUpgrade(t,i,n,e)}})}!0===e.perMessageDeflate&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(2===this._state)return e&&this.once("close",(()=>{e(new Error("The server is not running"))})),void process.nextTick(m,this);if(e&&this.once("close",e),1!==this._state)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:process.nextTick(m,this);else{const e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close((()=>{m(this)}))}}shouldHandle(e){if(this.options.path){const t=e.url.indexOf("?");if((-1!==t?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,i,n){t.on("error",f);const o=e.headers["sec-websocket-key"],r=e.headers.upgrade,s=+e.headers["sec-websocket-version"];if("GET"!==e.method){return void v(this,e,t,405,"Invalid HTTP method")}if(void 0===r||"websocket"!==r.toLowerCase()){return void v(this,e,t,400,"Invalid Upgrade header")}if(void 0===o||!h.test(o)){return void v(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header")}if(8!==s&&13!==s){return void v(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header")}if(!this.shouldHandle(e))return void g(t,400);const p=e.headers["sec-websocket-protocol"];let u=new Set;if(void 0!==p)try{u=l.parse(p)}catch(i){return void v(this,e,t,400,"Invalid Sec-WebSocket-Protocol header")}const d=e.headers["sec-websocket-extensions"],m={};if(this.options.perMessageDeflate&&void 0!==d){const i=new c(this.options.perMessageDeflate,!0,this.options.maxPayload);try{const e=a.parse(d);e[c.extensionName]&&(i.accept(e[c.extensionName]),m[c.extensionName]=i)}catch(i){return void v(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header")}}if(this.options.verifyClient){const r={origin:e.headers[""+(8===s?"sec-websocket-origin":"origin")],secure:!(!e.socket.authorized&&!e.socket.encrypted),req:e};if(2===this.options.verifyClient.length)return void this.options.verifyClient(r,((r,s,a,c)=>{if(!r)return g(t,s||401,a,c);this.completeUpgrade(m,o,u,e,t,i,n)}));if(!this.options.verifyClient(r))return g(t,401)}this.completeUpgrade(m,o,u,e,t,i,n)}completeUpgrade(e,t,i,n,o,r,l){if(!o.readable||!o.writable)return o.destroy();if(o[d])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return g(o,503);const p=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${s("sha1").update(t+u).digest("base64")}`],h=new this.options.WebSocket(null,void 0,this.options);if(i.size){const e=this.options.handleProtocols?this.options.handleProtocols(i,n):i.values().next().value;e&&(p.push(`Sec-WebSocket-Protocol: ${e}`),h._protocol=e)}if(e[c.extensionName]){const t=e[c.extensionName].params,i=a.format({[c.extensionName]:[t]});p.push(`Sec-WebSocket-Extensions: ${i}`),h._extensions=e}this.emit("headers",p,n),o.write(p.concat("\r\n").join("\r\n")),o.removeListener("error",f),h.setSocket(o,r,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(h),h.on("close",(()=>{this.clients.delete(h),this._shouldEmitClose&&!this.clients.size&&process.nextTick(m,this)}))),l(h,n)}}},4012:(e,t,i)=>{e.exports={parallel:i(7249),serial:i(6574),serialOrdered:i(7897)}},4061:function(e,t,i){(function(){var t,n,o={}.hasOwnProperty;n=i(8711),t=i(5068),e.exports=function(e){function i(e,n,o){if(i.__super__.constructor.call(this,e),null==n)throw new Error("Missing DTD notation name. "+this.debugInfo(n));if(!o.pubID&&!o.sysID)throw new Error("Public or system identifiers are required for an external entity. "+this.debugInfo(n));this.name=this.stringify.name(n),this.type=t.NotationDeclaration,null!=o.pubID&&(this.pubID=this.stringify.dtdPubID(o.pubID)),null!=o.sysID&&(this.sysID=this.stringify.dtdSysID(o.sysID))}return function(e,t){for(var i in t)o.call(t,i)&&(e[i]=t[i]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(i,e),Object.defineProperty(i.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(i.prototype,"systemId",{get:function(){return this.sysID}}),i.prototype.toString=function(e){return this.options.writer.dtdNotation(this,this.options.writer.filterOptions(e))},i}(n)}).call(this)},4081:(e,t,i)=>{const n=i(1792),o=/^-?([1-9]\d*|0)(\.\d*)?$/,r=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(.\d+)?Z$/,s=/(?!xmlns)^.*:/,a=function(e){if(Array.isArray(e)){if(e.length>1)return e.map(a);e=e[0]}if("object"==typeof e){var t={};return Object.keys(e).forEach((function(i){t[i]=a(e[i])})),t}return"true"===e||"false"!==e&&(o.test(e)?parseFloat(e):r.test(e)?new Date(e):e)},c=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};e.exports={linerase:a,parseSOAPString:function(e,t,i){e=e.replace(/xmlns([^=]*?)=(".*?")/g,"");try{n.parseString(e,{tagNameProcessors:[function(e){var t=(e=e.replace(s,"")).charAt(1);return t&&t.toUpperCase()!==t?e.charAt(0).toLowerCase()+e.slice(1):e}]},(function(n,o){if(o&&o.envelope&&o.envelope.body){if(!n&&o.envelope.body[0].fault){var r,s=o.envelope.body[0].fault[0];try{s.reason[0].text[0]._&&(r=s.reason[0].text[0]._)}catch(e){r=""}if(!r)try{r=JSON.stringify(a(s.code[0]))}catch(e){r=""}var c="";try{c=s.detail[0].text[0]}catch(e){c=""}n=new Error("ONVIF SOAP Fault: "+r+c)}t(n,o.envelope.body,e,i)}else t(new Error("Wrong ONVIF SOAP response"),null,e,i)}))}catch(n){t(n,"",e,i)}},guid:function(){return c()+c()+"-"+c()+"-"+c()+"-"+c()+"-"+c()+c()+c()}}},4151:(e,t,i)=>{var n=i(4370),o=i(5556);e.exports=function(e){if(!Object.keys(this.jobs).length)return;this.index=this.size,n(this),o(e)(null,this.results)}},4154:(e,t,i)=>{var n;e.exports=function(){if(!n){try{n=i(8766)("follow-redirects")}catch(e){}"function"!=typeof n&&(n=function(){})}n.apply(null,arguments)}},4232:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BufferedDuplex=t.writev=void 0;const n=i(5899),o=i(181);function r(e,t){const i=new Array(e.length);for(let t=0;t<e.length;t++)"string"==typeof e[t].chunk?i[t]=o.Buffer.from(e[t].chunk,"utf8"):i[t]=e[t].chunk;this._write(o.Buffer.concat(i),"binary",t)}t.writev=r;class s extends n.Duplex{constructor(e,t,i){super({objectMode:!0}),this.proxy=t,this.socket=i,this.writeQueue=[],e.objectMode||(this._writev=r.bind(this)),this.isSocketOpen=!1,this.proxy.on("data",(e=>{this.destroyed||this.push(e)}))}_read(e){this.proxy.read(e)}_write(e,t,i){this.isSocketOpen?this.writeToProxy(e,t,i):this.writeQueue.push({chunk:e,encoding:t,cb:i})}_final(e){this.writeQueue=[],this.proxy.end(e)}_destroy(e,t){this.writeQueue=[],this.proxy.destroy(),t(e)}socketReady(){this.emit("connect"),this.isSocketOpen=!0,this.processWriteQueue()}writeToProxy(e,t,i){!1===this.proxy.write(e,t)?this.proxy.once("drain",i):i()}processWriteQueue(){for(;this.writeQueue.length>0;){const{chunk:e,encoding:t,cb:i}=this.writeQueue.shift();this.writeToProxy(e,t,i)}}}t.BufferedDuplex=s},4298:(e,t,i)=>{"use strict";const n=i(5899).Duplex,o=i(5198),r=i(1922);function s(e){if(!(this instanceof s))return new s(e);if("function"==typeof e){this._callback=e;const t=function(e){this._callback&&(this._callback(e),this._callback=null)}.bind(this);this.on("pipe",(function(e){e.on("error",t)})),this.on("unpipe",(function(e){e.removeListener("error",t)})),e=null}r._init.call(this,e),n.call(this)}o(s,n),Object.assign(s.prototype,r.prototype),s.prototype._new=function(e){return new s(e)},s.prototype._write=function(e,t,i){this._appendBuffer(e),"function"==typeof i&&i()},s.prototype._read=function(e){if(!this.length)return this.push(null);e=Math.min(e,this.length),this.push(this.slice(0,e)),this.consume(e)},s.prototype.end=function(e){n.prototype.end.call(this,e),this._callback&&(this._callback(null,this.slice()),this._callback=null)},s.prototype._destroy=function(e,t){this._bufs.length=0,this.length=0,t(e)},s.prototype._isBufferList=function(e){return e instanceof s||e instanceof r||s.isBufferList(e)},s.isBufferList=r.isBufferList,e.exports=s,e.exports.BufferListStream=s,e.exports.BufferList=r},4370:e=>{function t(e){"function"==typeof this.jobs[e]&&this.jobs[e]()}e.exports=function(e){Object.keys(e.jobs).forEach(t.bind(e)),e.jobs={}}},4376:(e,t,i)=>{var n;e.exports=function(){if(!n){try{n=i(6556)("follow-redirects")}catch(e){}"function"!=typeof n&&(n=function(){})}n.apply(null,arguments)}},4392:function(e,t,i){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[t.length]=i);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i=n(e),s=0;s<i.length;s++)"default"!==i[s]&&o(t,e,i[s]);return r(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.SettingsMixinDeviceBase=void 0;const a=s(i(3861)),{deviceManager:c}=a.default;class l extends a.MixinDeviceBase{constructor(e){super(e),this.settingsGroup=e.group,this.settingsGroupKey=e.groupKey,process.nextTick((()=>c.onMixinEvent(this.id,this,a.ScryptedInterface.Settings,null)))}async getSettings(){const e=this.mixinDeviceInterfaces.includes(a.ScryptedInterface.Settings)?this.mixinDevice.getSettings():void 0,t=this.getMixinSettings(),i=[];try{const t=await e||[];i.push(...t)}catch(e){const t=this.name,n=`${t} Extension settings failed to load.`;this.console.error(n,e),i.push({key:Math.random().toString(),title:t,value:"Settings Error",group:"Errors",description:n,readonly:!0})}try{const e=await t||[];for(const t of e)t.group=t.group||this.settingsGroup,t.key=this.settingsGroupKey+":"+t.key;i.push(...e)}catch(e){const t=c.getDeviceState(this.mixinProviderNativeId).name,n=`${t} Extension settings failed to load.`;this.console.error(n,e),i.push({key:Math.random().toString(),title:t,value:"Settings Error",group:"Errors",description:n,readonly:!0})}return i}async putSetting(e,t){const i=this.settingsGroupKey+":";if(!e?.startsWith(i))return this.mixinDevice.putSetting(e,t);await this.putMixinSetting(e.substring(i.length),t)||c.onMixinEvent(this.id,this,a.ScryptedInterface.Settings,null)}async release(){await c.onMixinEvent(this.id,this,a.ScryptedInterface.Settings,null)}}t.SettingsMixinDeviceBase=l},4423:function(e,t,i){(function(){var t,n,o={}.hasOwnProperty;n=i(8711),t=i(5068),e.exports=function(e){function i(e,n,o){if(i.__super__.constructor.call(this,e),null==n)throw new Error("Missing DTD element name. "+this.debugInfo());o||(o="(#PCDATA)"),Array.isArray(o)&&(o="("+o.join(",")+")"),this.name=this.stringify.name(n),this.type=t.ElementDeclaration,this.value=this.stringify.dtdElementValue(o)}return function(e,t){for(var i in t)o.call(t,i)&&(e[i]=t[i]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(i,e),i.prototype.toString=function(e){return this.options.writer.dtdElement(this,this.options.writer.filterOptions(e))},i}(n)}).call(this)},4426:(e,t)=>{"use strict";function i(e){return e>=200&&e<=299}function n(e){if(!i(e))throw new Error(`http response statusCode ${e}`);return!0}function o(e){return e.method||(e.body?"POST":"GET")}function r(e){switch(e){case"json":return"application/json";case"text":return"text/plain"}}function s(e,t){return t=t.toLowerCase(),e.find((([e])=>e.toLowerCase()===t))}function a(e,t){t=t.toLowerCase();const i=e.filter((([e,i])=>e.toLowerCase()!==t));e.length=0,i.forEach((t=>e.push(t)))}function c(e,t,i){a(e,t),e.push([t,i])}function l(e,t){if(s(e,"Accept"))return;const i=r(t);i&&c(e,"Accept",i)}function p(e){const t=[];if(!e)return t;if(e instanceof Headers){for(const[i,n]of e.entries())t.push([i,n]);return t}if(e instanceof Array){for(const[i,n]of e)t.push([i,n]);return t}for(const i of Object.keys(e)){const n=e[i];t.push([i,n])}return t}function u(e,t){let i;return"object"==typeof t?(t=JSON.stringify(t),i="application/json"):"string"==typeof t&&(i="text/plain"),i&&!s(e,"Content-Type")&&c(e,"Content-Type",i),s(e,"Content-Length")||c(e,"Content-Length",(t=Buffer.from(t)).length.toString()),t}async function d(e,t){switch(t){case"json":return e.json();case"text":return e.text();case"readable":return e}return new Uint8Array(await e.arrayBuffer())}Object.defineProperty(t,"__esModule",{value:!0}),t.fetchStatusCodeOk=i,t.checkStatus=n,t.getFetchMethod=o,t.getHttpFetchAccept=r,t.hasHeader=s,t.removeHeader=a,t.setHeader=c,t.setDefaultHttpFetchAccept=l,t.createHeadersArray=p,t.createStringOrBufferBody=u,t.domFetchParseIncomingMessage=d,t.domFetch=async function(e){const t=p(e.headers);l(t,e.responseType);let i,r,{body:s}=e;!s||s instanceof ReadableStream||(s=u(t,s));e.timeout&&(i=new AbortController,r=setTimeout((()=>i.abort()),e.timeout),e.signal?.addEventListener("abort",(()=>i.abort(e.signal?.reason))));try{const{url:r}=e,a=await fetch(r,{method:o(e),credentials:e.withCredentials?"include":void 0,headers:t,signal:i?.signal||e.signal,body:s});if(void 0===e?.checkStatusCode||e?.checkStatusCode)try{if(!("function"==typeof e?.checkStatusCode?e.checkStatusCode:n)(a.status))throw new Error(`http response statusCode ${a.status}`)}catch(e){throw a.arrayBuffer().catch((()=>{})),e}return{statusCode:a.status,headers:a.headers,body:await d(a,e.responseType)}}finally{clearTimeout(r)}}},4430:function(e,t,i){(function(){var t,n,o,r,s,a,c,l,p,u;u=i(5502),l=u.assign,p=u.isFunction,o=i(3725),r=i(8470),s=i(1711),c=i(661),a=i(1995),t=i(5068),n=i(1926),e.exports.create=function(e,t,i,n){var o,s;if(null==e)throw new Error("Root element needs a name.");return n=l({},t,i,n),s=(o=new r(n)).element(e),n.headless||(o.declaration(n),null==n.pubID&&null==n.sysID||o.dtd(n)),s},e.exports.begin=function(e,t,i){var n;return p(e)&&(t=(n=[e,t])[0],i=n[1],e={}),t?new s(e,t,i):new r(e)},e.exports.stringWriter=function(e){return new c(e)},e.exports.streamWriter=function(e,t){return new a(e,t)},e.exports.implementation=new o,e.exports.nodeType=t,e.exports.writerState=n}).call(this)},4434:e=>{"use strict";e.exports=require("events")},4435:(e,t,i)=>{"use strict";const n=i(7097),{PromisePrototypeThen:o,SymbolAsyncIterator:r,SymbolIterator:s}=i(3383),{Buffer:a}=i(181),{ERR_INVALID_ARG_TYPE:c,ERR_STREAM_NULL_VALUES:l}=i(676).codes;e.exports=function(e,t,i){let p,u;if("string"==typeof t||t instanceof a)return new e({objectMode:!0,...i,read(){this.push(t),this.push(null)}});if(t&&t[r])u=!0,p=t[r]();else{if(!t||!t[s])throw new c("iterable",["Iterable"],t);u=!1,p=t[s]()}const d=new e({objectMode:!0,highWaterMark:1,...i});let h=!1;return d._read=function(){h||(h=!0,async function(){for(;;){try{const{value:e,done:t}=u?await p.next():p.next();if(t)d.push(null);else{const t=e&&"function"==typeof e.then?await e:e;if(null===t)throw h=!1,new l;if(d.push(t))continue;h=!1}}catch(e){d.destroy(e)}break}}())},d._destroy=function(e,t){o(async function(e){const t=null!=e,i="function"==typeof p.throw;if(t&&i){const{value:t,done:i}=await p.throw(e);if(await t,i)return}if("function"==typeof p.return){const{value:e}=await p.return();await e}}(e),(()=>n.nextTick(t,e)),(i=>n.nextTick(t,i||e)))},d}},4472:function(e,t,i){(function(){var t,n={}.hasOwnProperty;t=i(8711),e.exports=function(e){function t(e){t.__super__.constructor.call(this,e),this.value=""}return function(e,t){for(var i in t)n.call(t,i)&&(e[i]=t[i]);function o(){this.constructor=e}o.prototype=t.prototype,e.prototype=new o,e.__super__=t.prototype}(t,e),Object.defineProperty(t.prototype,"data",{get:function(){return this.value},set:function(e){return this.value=e||""}}),Object.defineProperty(t.prototype,"length",{get:function(){return this.value.length}}),Object.defineProperty(t.prototype,"textContent",{get:function(){return this.value},set:function(e){return this.value=e||""}}),t.prototype.clone=function(){return Object.create(this)},t.prototype.substringData=function(e,t){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.appendData=function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.insertData=function(e,t){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.deleteData=function(e,t){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.replaceData=function(e,t,i){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.isEqualNode=function(e){return!!t.__super__.isEqualNode.apply(this,arguments).isEqualNode(e)&&e.data===this.data},t}(t)}).call(this)},4495:function(e,t,i){(function(){"use strict";var e,n,o,r,s,a={}.hasOwnProperty;e=i(4430),n=i(8732).defaults,r=function(e){return"string"==typeof e&&(e.indexOf("&")>=0||e.indexOf(">")>=0||e.indexOf("<")>=0)},s=function(e){return"<![CDATA["+o(e)+"]]>"},o=function(e){return e.replace("]]>","]]]]><![CDATA[>")},t.Builder=function(){function t(e){var t,i,o;for(t in this.options={},i=n[.2])a.call(i,t)&&(o=i[t],this.options[t]=o);for(t in e)a.call(e,t)&&(o=e[t],this.options[t]=o)}return t.prototype.buildObject=function(t){var i,o,c,l,p,u;return i=this.options.attrkey,o=this.options.charkey,1===Object.keys(t).length&&this.options.rootName===n[.2].rootName?t=t[p=Object.keys(t)[0]]:p=this.options.rootName,u=this,c=function(e,t){var n,l,p,d,h,m;if("object"!=typeof t)u.options.cdata&&r(t)?e.raw(s(t)):e.txt(t);else if(Array.isArray(t)){for(d in t)if(a.call(t,d))for(h in l=t[d])p=l[h],e=c(e.ele(h),p).up()}else for(h in t)if(a.call(t,h))if(l=t[h],h===i){if("object"==typeof l)for(n in l)m=l[n],e=e.att(n,m)}else if(h===o)e=u.options.cdata&&r(l)?e.raw(s(l)):e.txt(l);else if(Array.isArray(l))for(d in l)a.call(l,d)&&(e="string"==typeof(p=l[d])?u.options.cdata&&r(p)?e.ele(h).raw(s(p)).up():e.ele(h,p).up():c(e.ele(h),p).up());else"object"==typeof l?e=c(e.ele(h),l).up():"string"==typeof l&&u.options.cdata&&r(l)?e=e.ele(h).raw(s(l)).up():(null==l&&(l=""),e=e.ele(h,l.toString()).up());return e},l=e.create(p,this.options.xmldec,this.options.doctype,{headless:this.options.headless,allowSurrogateChars:this.options.allowSurrogateChars}),c(l,t).end(this.options.renderOpts)},t}()}).call(this)},4520:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TimeoutError=void 0,t.singletonPromise=function(e,t,i=0){if(e?.promise)return e;const n=t();e?e.promise=n:e={promise:n,cacheDuration:i};return n.finally((()=>setTimeout((()=>e.promise=void 0),e.cacheDuration))),e},t.timeoutPromise=function(e,t){return new Promise(((n,o)=>{const r=setTimeout((()=>o(new i(t))),e);t.then((e=>{clearTimeout(r),n(e)})).catch((e=>{clearTimeout(r),o(e)}))}))},t.timeoutFunction=function(e,t){return new Promise(((n,o)=>{let r=!1;const s=t((()=>r)),a=setTimeout((()=>{r=!0,o(new i(s))}),e);s.then((e=>{clearTimeout(a),n(e)})).catch((e=>{clearTimeout(a),o(e)}))}))},t.createPromiseDebouncer=function(){let e;return t=>(e||(e=t().finally((()=>e=void 0))),e)},t.createMapPromiseDebouncer=function(){const e=new Map;return(t,i,n)=>{const o=JSON.stringify(t);let r=e.get(o);return r||(r=n().finally((()=>{i?setTimeout((()=>e.delete(o)),i):e.delete(o)})),e.set(o,r)),r}};class i extends Error{constructor(e){super("Operation Timed Out"),this.promise=e}}t.TimeoutError=i},4536:(e,t,i)=>{"use strict";const{StringPrototypeSlice:n,SymbolIterator:o,TypedArrayPrototypeSet:r,Uint8Array:s}=i(3383),{Buffer:a}=i(181),{inspect:c}=i(3939);e.exports=class{constructor(){this.head=null,this.tail=null,this.length=0}push(e){const t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}unshift(e){const t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}shift(){if(0===this.length)return;const e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}clear(){this.head=this.tail=null,this.length=0}join(e){if(0===this.length)return"";let t=this.head,i=""+t.data;for(;null!==(t=t.next);)i+=e+t.data;return i}concat(e){if(0===this.length)return a.alloc(0);const t=a.allocUnsafe(e>>>0);let i=this.head,n=0;for(;i;)r(t,i.data,n),n+=i.data.length,i=i.next;return t}consume(e,t){const i=this.head.data;if(e<i.length){const t=i.slice(0,e);return this.head.data=i.slice(e),t}return e===i.length?this.shift():t?this._getString(e):this._getBuffer(e)}first(){return this.head.data}*[o](){for(let e=this.head;e;e=e.next)yield e.data}_getString(e){let t="",i=this.head,o=0;do{const r=i.data;if(!(e>r.length)){e===r.length?(t+=r,++o,i.next?this.head=i.next:this.head=this.tail=null):(t+=n(r,0,e),this.head=i,i.data=n(r,e));break}t+=r,e-=r.length,++o}while(null!==(i=i.next));return this.length-=o,t}_getBuffer(e){const t=a.allocUnsafe(e),i=e;let n=this.head,o=0;do{const a=n.data;if(!(e>a.length)){e===a.length?(r(t,a,i-e),++o,n.next?this.head=n.next:this.head=this.tail=null):(r(t,new s(a.buffer,a.byteOffset,e),i-e),this.head=n,n.data=a.slice(e));break}r(t,a,i-e),e-=a.length,++o}while(null!==(n=n.next));return this.length-=o,t}[Symbol.for("nodejs.util.inspect.custom")](e,t){return c(this,{...t,depth:0,customInspect:!1})}}},4563:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},4565:function(e,t,i){(function(){var t,n,o={}.hasOwnProperty;t=i(5068),n=i(8711),e.exports=function(e){function i(e,n){if(i.__super__.constructor.call(this,e),null==n)throw new Error("Missing raw text. "+this.debugInfo());this.type=t.Raw,this.value=this.stringify.raw(n)}return function(e,t){for(var i in t)o.call(t,i)&&(e[i]=t[i]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(i,e),i.prototype.clone=function(){return Object.create(this)},i.prototype.toString=function(e){return this.options.writer.raw(this,this.options.writer.filterOptions(e))},i}(n)}).call(this)},4602:(e,t,i)=>{"use strict";const{kForOnEventAttribute:n,kListener:o}=i(6639),r=Symbol("kCode"),s=Symbol("kData"),a=Symbol("kError"),c=Symbol("kMessage"),l=Symbol("kReason"),p=Symbol("kTarget"),u=Symbol("kType"),d=Symbol("kWasClean");class h{constructor(e){this[p]=null,this[u]=e}get target(){return this[p]}get type(){return this[u]}}Object.defineProperty(h.prototype,"target",{enumerable:!0}),Object.defineProperty(h.prototype,"type",{enumerable:!0});class m extends h{constructor(e,t={}){super(e),this[r]=void 0===t.code?0:t.code,this[l]=void 0===t.reason?"":t.reason,this[d]=void 0!==t.wasClean&&t.wasClean}get code(){return this[r]}get reason(){return this[l]}get wasClean(){return this[d]}}Object.defineProperty(m.prototype,"code",{enumerable:!0}),Object.defineProperty(m.prototype,"reason",{enumerable:!0}),Object.defineProperty(m.prototype,"wasClean",{enumerable:!0});class f extends h{constructor(e,t={}){super(e),this[a]=void 0===t.error?null:t.error,this[c]=void 0===t.message?"":t.message}get error(){return this[a]}get message(){return this[c]}}Object.defineProperty(f.prototype,"error",{enumerable:!0}),Object.defineProperty(f.prototype,"message",{enumerable:!0});class g extends h{constructor(e,t={}){super(e),this[s]=void 0===t.data?null:t.data}get data(){return this[s]}}Object.defineProperty(g.prototype,"data",{enumerable:!0});const v={addEventListener(e,t,i={}){for(const r of this.listeners(e))if(!i[n]&&r[o]===t&&!r[n])return;let r;if("message"===e)r=function(e,i){const n=new g("message",{data:i?e:e.toString()});n[p]=this,y(t,this,n)};else if("close"===e)r=function(e,i){const n=new m("close",{code:e,reason:i.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});n[p]=this,y(t,this,n)};else if("error"===e)r=function(e){const i=new f("error",{error:e,message:e.message});i[p]=this,y(t,this,i)};else{if("open"!==e)return;r=function(){const e=new h("open");e[p]=this,y(t,this,e)}}r[n]=!!i[n],r[o]=t,i.once?this.once(e,r):this.on(e,r)},removeEventListener(e,t){for(const i of this.listeners(e))if(i[o]===t&&!i[n]){this.removeListener(e,i);break}}};function y(e,t,i){"object"==typeof e&&e.handleEvent?e.handleEvent.call(e,i):e.call(t,i)}e.exports={CloseEvent:m,ErrorEvent:f,Event:h,EventTarget:v,MessageEvent:g}},4629:e=>{"use strict";e.exports=(e,t=process.argv)=>{const i=e.startsWith("-")?"":1===e.length?"-":"--",n=t.indexOf(i+e),o=t.indexOf("--");return-1!==n&&(-1===o||n<o)}},4668:(e,t,i)=>{const n=i(2018),o=i(9023);t.init=function(e){e.inspectOpts={};const i=Object.keys(t.inspectOpts);for(let n=0;n<i.length;n++)e.inspectOpts[i[n]]=t.inspectOpts[i[n]]},t.log=function(...e){return process.stderr.write(o.formatWithOptions(t.inspectOpts,...e)+"\n")},t.formatArgs=function(i){const{namespace:n,useColors:o}=this;if(o){const t=this.color,o="[3"+(t<8?t:"8;5;"+t),r=` ${o};1m${n} [0m`;i[0]=r+i[0].split("\n").join("\n"+r),i.push(o+"m+"+e.exports.humanize(this.diff)+"[0m")}else i[0]=function(){if(t.inspectOpts.hideDate)return"";return(new Date).toISOString()+" "}()+n+" "+i[0]},t.save=function(e){e?process.env.DEBUG=e:delete process.env.DEBUG},t.load=function(){return process.env.DEBUG},t.useColors=function(){return"colors"in t.inspectOpts?Boolean(t.inspectOpts.colors):n.isatty(process.stderr.fd)},t.destroy=o.deprecate((()=>{}),"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{const e=i(2514);e&&(e.stderr||e).level>=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}t.inspectOpts=Object.keys(process.env).filter((e=>/^debug_/i.test(e))).reduce(((e,t)=>{const i=t.substring(6).toLowerCase().replace(/_([a-z])/g,((e,t)=>t.toUpperCase()));let n=process.env[t];return n=!!/^(yes|on|true|enabled)$/i.test(n)||!/^(no|off|false|disabled)$/i.test(n)&&("null"===n?null:Number(n)),e[i]=n,e}),{}),e.exports=i(5337)(t);const{formatters:r}=e.exports;r.o=function(e){return this.inspectOpts.colors=this.useColors,o.inspect(e,this.inspectOpts).split("\n").map((e=>e.trim())).join(" ")},r.O=function(e){return this.inspectOpts.colors=this.useColors,o.inspect(e,this.inspectOpts)}},4699:function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.listenZeroSingleClient=t.listenZero=t.ListenZeroSingleClientTimeoutError=void 0,t.closeQuiet=s,t.bindUdp=a,t.bindZero=async function(e){return a(e,0)},t.createBindZero=c,t.createSquentialBindZero=async function(e){let t=0;for(;;){const i=await c(e);try{return[i,await l(i.port+1,e)]}catch(e){t++,s(i.server)}if(10===t)throw new Error("unable to reserve sequential udp ports")}},t.reserveUdpPort=async function(){const e=await c();return await new Promise((t=>e.server.close((()=>t(void 0))))),e.port},t.createBindUdp=l,t.bind=async function(e,t){return e.bind(t),await(0,r.once)(e,"listening"),{port:t,url:`udp://127.0.0.1:${t}`}};const o=n(i(7194)),r=i(4434);async function s(e){if(e)try{await new Promise(((t,i)=>{try{e.close(t)}catch(e){i(e)}}))}catch(e){}}async function a(e,t,i){e.bind(t,i),await(0,r.once)(e,"listening");const n=e.address().port;return{port:n,url:`udp://127.0.0.1:${n}`}}async function c(e){return l(0,e)}async function l(e,t){const i=o.default.createSocket(t||"udp4"),{port:n,url:r}=await a(i,e);return{server:i,port:n,url:r}}var p=i(7449);Object.defineProperty(t,"ListenZeroSingleClientTimeoutError",{enumerable:!0,get:function(){return p.ListenZeroSingleClientTimeoutError}}),Object.defineProperty(t,"listenZero",{enumerable:!0,get:function(){return p.listenZero}}),Object.defineProperty(t,"listenZeroSingleClient",{enumerable:!0,get:function(){return p.listenZeroSingleClient}})},4724:(e,t)=>{t.jspack=new function(){var e,t=!1,i=this;i._DeArray=function(e,t,i){return[e.slice(t,t+i)]},i._EnArray=function(e,t,i,n){for(var o=0;o<i;e[t+o]=n[o]?n[o]:0,o++);},i._DeChar=function(e,t){return String.fromCharCode(e[t])},i._EnChar=function(e,t,i){e[t]=i.charCodeAt(0)},i._DeInt=function(i,n){var o,r,s,a=t?e.len-1:0,c=t?-1:1,l=a+c*e.len;for(o=0,r=a,s=1;r!=l;o+=i[n+r]*s,r+=c,s*=256);return e.bSigned&&o&Math.pow(2,8*e.len-1)&&(o-=Math.pow(2,8*e.len)),o},i._EnInt=function(i,n,o){var r,s=t?e.len-1:0,a=t?-1:1,c=s+a*e.len;for(o=o<e.min?e.min:o>e.max?e.max:o,r=s;r!=c;i[n+r]=255&o,r+=a,o>>=8);},i._DeString=function(e,t,i){for(var n=new Array(i),o=0;o<i;n[o]=String.fromCharCode(e[t+o]),o++);return n.join("")},i._EnString=function(e,t,i,n){for(var o,r=0;r<i;e[t+r]=(o=n.charCodeAt(r))?o:0,r++);},i._De754=function(i,n){var o,r,s,a,c,l,p,u,d,h;for(p=e.mLen,d=(h=(1<<(u=8*e.len-e.mLen-1))-1)>>1,a=t?0:e.len-1,c=t?1:-1,o=i[n+a],a+=c,r=o&(1<<-(l=-7))-1,o>>=-l,l+=u;l>0;r=256*r+i[n+a],a+=c,l-=8);for(s=r&(1<<-l)-1,r>>=-l,l+=p;l>0;s=256*s+i[n+a],a+=c,l-=8);switch(r){case 0:r=1-d;break;case h:return s?NaN:1/0*(o?-1:1);default:s+=Math.pow(2,p),r-=d}return(o?-1:1)*s*Math.pow(2,r-p)},i._En754=function(i,n,o){var r,s,a,c,l,p,u,d,h,m;for(u=e.mLen,h=(m=(1<<(d=8*e.len-e.mLen-1))-1)>>1,r=o<0?1:0,o=Math.abs(o),isNaN(o)||o==1/0?(a=isNaN(o)?1:0,s=m):(s=Math.floor(Math.log(o)/Math.LN2),o*(p=Math.pow(2,-s))<1&&(s--,p*=2),(o+=s+h>=1?e.rt/p:e.rt*Math.pow(2,1-h))*p>=2&&(s++,p/=2),s+h>=m?(a=0,s=m):s+h>=1?(a=(o*p-1)*Math.pow(2,u),s+=h):(a=o*Math.pow(2,h-1)*Math.pow(2,u),s=0)),c=t?e.len-1:0,l=t?-1:1;u>=8;i[n+c]=255&a,c+=l,a/=256,u-=8);for(s=s<<u|a,d+=u;d>0;i[n+c]=255&s,c+=l,s/=256,d-=8);i[n+c-l]|=128*r},i._DeInt64=function(i,n){var o,r,s,a=t?0:7,c=t?1:-1,l=a+8*c,p=[0,0,!e.bSigned];for(o=a,s=1,r=0;o!=l;p[s]=(p[s]<<8>>>0)+i[n+o],o+=c,s=++r<4?1:0);return p},i._EnInt64=function(e,i,n){var o,r,s,a,c=t?0:7,l=t?1:-1,p=c+8*l;for(o=c,s=1,r=0,a=24;o!=p;e[i+o]=n[s]>>a&255,o+=l,s=++r<4?1:0,a=24-r%4*8);},i._sPattern="(\\d + )?([AxcbBhHsfdiIlLqQ])",i._lenLut={A:1,x:1,c:1,b:1,B:1,h:2,H:2,s:1,f:4,d:8,i:4,I:4,l:4,L:4,q:8,Q:8},i._elLut={A:{en:i._EnArray,de:i._DeArray},s:{en:i._EnString,de:i._DeString},c:{en:i._EnChar,de:i._DeChar},b:{en:i._EnInt,de:i._DeInt,len:1,bSigned:!0,min:-Math.pow(2,7),max:Math.pow(2,7)-1},B:{en:i._EnInt,de:i._DeInt,len:1,bSigned:!1,min:0,max:Math.pow(2,8)-1},h:{en:i._EnInt,de:i._DeInt,len:2,bSigned:!0,min:-Math.pow(2,15),max:Math.pow(2,15)-1},H:{en:i._EnInt,de:i._DeInt,len:2,bSigned:!1,min:0,max:Math.pow(2,16)-1},i:{en:i._EnInt,de:i._DeInt,len:4,bSigned:!0,min:-Math.pow(2,31),max:Math.pow(2,31)-1},I:{en:i._EnInt,de:i._DeInt,len:4,bSigned:!1,min:0,max:Math.pow(2,32)-1},l:{en:i._EnInt,de:i._DeInt,len:4,bSigned:!0,min:-Math.pow(2,31),max:Math.pow(2,31)-1},L:{en:i._EnInt,de:i._DeInt,len:4,bSigned:!1,min:0,max:Math.pow(2,32)-1},f:{en:i._En754,de:i._De754,len:4,mLen:23,rt:Math.pow(2,-24)-Math.pow(2,-77)},d:{en:i._En754,de:i._De754,len:8,mLen:52,rt:0},q:{en:i._EnInt64,de:i._DeInt64,bSigned:!0},Q:{en:i._EnInt64,de:i._DeInt64,bSigned:!1}},i._UnpackSeries=function(t,i,n,o){for(var r=e.de,s=[],a=0;a<t;s.push(r(n,o+a*i)),a++);return s},i._PackSeries=function(t,i,n,o,r,s){for(var a=e.en,c=0;c<t;a(n,o+c*i,r[s+c]),c++);},i.Unpack=function(i,n,o){t="<"!=i.charAt(0),o=o||0;for(var r,s,a,c=new RegExp(this._sPattern,"g"),l=[];r=c.exec(i);){if(o+(s=null==r[1]||""==r[1]?1:parseInt(r[1]))*(a=this._lenLut[r[2]])>n.length)return;switch(r[2]){case"A":case"s":l.push(this._elLut[r[2]].de(n,o,s));break;case"c":case"b":case"B":case"h":case"H":case"i":case"I":case"l":case"L":case"f":case"d":case"q":case"Q":e=this._elLut[r[2]],l.push(this._UnpackSeries(s,a,n,o))}o+=s*a}return Array.prototype.concat.apply([],l)},i.PackTo=function(i,n,o,r){t="<"!=i.charAt(0);for(var s,a,c,l,p=new RegExp(this._sPattern,"g"),u=0;s=p.exec(i);){if(o+(a=null==s[1]||""==s[1]?1:parseInt(s[1]))*(c=this._lenLut[s[2]])>n.length)return!1;switch(s[2]){case"A":case"s":if(u+1>r.length)return!1;this._elLut[s[2]].en(n,o,a,r[u]),u+=1;break;case"c":case"b":case"B":case"h":case"H":case"i":case"I":case"l":case"L":case"f":case"d":case"q":case"Q":if(e=this._elLut[s[2]],u+a>r.length)return!1;this._PackSeries(a,c,n,o,r,u),u+=a;break;case"x":for(l=0;l<a;l++)n[o+l]=0}o+=a*c}return n},i.Pack=function(e,t){return this.PackTo(e,new Array(this.CalcLength(e)),0,t)},i.CalcLength=function(e){for(var t,i=new RegExp(this._sPattern,"g"),n=0;t=i.exec(e);)n+=(null==t[1]||""==t[1]?1:parseInt(t[1]))*this._lenLut[t[2]];return n}}},4756:e=>{"use strict";e.exports=require("tls")},4770:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PromiseQueue=void 0;t.PromiseQueue=class{constructor(){this.queue=[],this.running=!1,this.push=e=>new Promise(((t,i)=>{this.queue.push({promise:e,done:t,failed:i}),this.running||this.run()}))}async run(){const e=this.queue.shift();if(e){this.running=!0;try{const t=await e.promise();e.done(t)}catch(t){e.failed(t)}this.run()}else this.running=!1}cancel(){this.queue=[]}}},4797:function(e,t,i){(function(){"use strict";var e,n,o,r,s,a,c,l,p,u=function(e,t){return function(){return e.apply(t,arguments)}},d={}.hasOwnProperty;l=i(6162),r=i(4434),e=i(3874),c=i(7443),p=i(3557).setImmediate,n=i(8732).defaults,s=function(e){return"object"==typeof e&&null!=e&&0===Object.keys(e).length},a=function(e,t,i){var n,o;for(n=0,o=e.length;n<o;n++)t=(0,e[n])(t,i);return t},o=function(e,t,i){var n;return(n=Object.create(null)).value=i,n.writable=!0,n.enumerable=!0,n.configurable=!0,Object.defineProperty(e,t,n)},t.Parser=function(i){function r(e){var i,o,r;if(this.parseStringPromise=u(this.parseStringPromise,this),this.parseString=u(this.parseString,this),this.reset=u(this.reset,this),this.assignOrPush=u(this.assignOrPush,this),this.processAsync=u(this.processAsync,this),!(this instanceof t.Parser))return new t.Parser(e);for(i in this.options={},o=n[.2])d.call(o,i)&&(r=o[i],this.options[i]=r);for(i in e)d.call(e,i)&&(r=e[i],this.options[i]=r);this.options.xmlns&&(this.options.xmlnskey=this.options.attrkey+"ns"),this.options.normalizeTags&&(this.options.tagNameProcessors||(this.options.tagNameProcessors=[]),this.options.tagNameProcessors.unshift(c.normalize)),this.reset()}return function(e,t){for(var i in t)d.call(t,i)&&(e[i]=t[i]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(r,i),r.prototype.processAsync=function(){var e,t;try{return this.remaining.length<=this.options.chunkSize?(e=this.remaining,this.remaining="",this.saxParser=this.saxParser.write(e),this.saxParser.close()):(e=this.remaining.substr(0,this.options.chunkSize),this.remaining=this.remaining.substr(this.options.chunkSize,this.remaining.length),this.saxParser=this.saxParser.write(e),p(this.processAsync))}catch(e){if(t=e,!this.saxParser.errThrown)return this.saxParser.errThrown=!0,this.emit(t)}},r.prototype.assignOrPush=function(e,t,i){return t in e?(e[t]instanceof Array||o(e,t,[e[t]]),e[t].push(i)):this.options.explicitArray?o(e,t,[i]):o(e,t,i)},r.prototype.reset=function(){var e,t,i,n,r;return this.removeAllListeners(),this.saxParser=l.parser(this.options.strict,{trim:!1,normalize:!1,xmlns:this.options.xmlns}),this.saxParser.errThrown=!1,this.saxParser.onerror=(r=this,function(e){if(r.saxParser.resume(),!r.saxParser.errThrown)return r.saxParser.errThrown=!0,r.emit("error",e)}),this.saxParser.onend=function(e){return function(){if(!e.saxParser.ended)return e.saxParser.ended=!0,e.emit("end",e.resultObject)}}(this),this.saxParser.ended=!1,this.EXPLICIT_CHARKEY=this.options.explicitCharkey,this.resultObject=null,n=[],e=this.options.attrkey,t=this.options.charkey,this.saxParser.onopentag=function(i){return function(r){var s,c,l,p,u;if((l={})[t]="",!i.options.ignoreAttrs)for(s in u=r.attributes)d.call(u,s)&&(e in l||i.options.mergeAttrs||(l[e]={}),c=i.options.attrValueProcessors?a(i.options.attrValueProcessors,r.attributes[s],s):r.attributes[s],p=i.options.attrNameProcessors?a(i.options.attrNameProcessors,s):s,i.options.mergeAttrs?i.assignOrPush(l,p,c):o(l[e],p,c));return l["#name"]=i.options.tagNameProcessors?a(i.options.tagNameProcessors,r.name):r.name,i.options.xmlns&&(l[i.options.xmlnskey]={uri:r.uri,local:r.local}),n.push(l)}}(this),this.saxParser.onclosetag=function(e){return function(){var i,r,c,l,p,u,h,m,f,g;if(u=n.pop(),p=u["#name"],e.options.explicitChildren&&e.options.preserveChildrenOrder||delete u["#name"],!0===u.cdata&&(i=u.cdata,delete u.cdata),f=n[n.length-1],u[t].match(/^\s*$/)&&!i?(r=u[t],delete u[t]):(e.options.trim&&(u[t]=u[t].trim()),e.options.normalize&&(u[t]=u[t].replace(/\s{2,}/g," ").trim()),u[t]=e.options.valueProcessors?a(e.options.valueProcessors,u[t],p):u[t],1===Object.keys(u).length&&t in u&&!e.EXPLICIT_CHARKEY&&(u=u[t])),s(u)&&(u="function"==typeof e.options.emptyTag?e.options.emptyTag():""!==e.options.emptyTag?e.options.emptyTag:r),null!=e.options.validator&&(g="/"+function(){var e,t,i;for(i=[],e=0,t=n.length;e<t;e++)l=n[e],i.push(l["#name"]);return i}().concat(p).join("/"),function(){var t;try{return u=e.options.validator(g,f&&f[p],u)}catch(i){return t=i,e.emit("error",t)}}()),e.options.explicitChildren&&!e.options.mergeAttrs&&"object"==typeof u)if(e.options.preserveChildrenOrder){if(f){for(c in f[e.options.childkey]=f[e.options.childkey]||[],h={},u)d.call(u,c)&&o(h,c,u[c]);f[e.options.childkey].push(h),delete u["#name"],1===Object.keys(u).length&&t in u&&!e.EXPLICIT_CHARKEY&&(u=u[t])}}else l={},e.options.attrkey in u&&(l[e.options.attrkey]=u[e.options.attrkey],delete u[e.options.attrkey]),!e.options.charsAsChildren&&e.options.charkey in u&&(l[e.options.charkey]=u[e.options.charkey],delete u[e.options.charkey]),Object.getOwnPropertyNames(u).length>0&&(l[e.options.childkey]=u),u=l;return n.length>0?e.assignOrPush(f,p,u):(e.options.explicitRoot&&(m=u,o(u={},p,m)),e.resultObject=u,e.saxParser.ended=!0,e.emit("end",e.resultObject))}}(this),i=function(e){return function(i){var o,r;if(r=n[n.length-1])return r[t]+=i,e.options.explicitChildren&&e.options.preserveChildrenOrder&&e.options.charsAsChildren&&(e.options.includeWhiteChars||""!==i.replace(/\\n/g,"").trim())&&(r[e.options.childkey]=r[e.options.childkey]||[],(o={"#name":"__text__"})[t]=i,e.options.normalize&&(o[t]=o[t].replace(/\s{2,}/g," ").trim()),r[e.options.childkey].push(o)),r}}(this),this.saxParser.ontext=i,this.saxParser.oncdata=function(e){var t;if(t=i(e))return t.cdata=!0}},r.prototype.parseString=function(t,i){var n;null!=i&&"function"==typeof i&&(this.on("end",(function(e){return this.reset(),i(null,e)})),this.on("error",(function(e){return this.reset(),i(e)})));try{return""===(t=t.toString()).trim()?(this.emit("end",null),!0):(t=e.stripBOM(t),this.options.async?(this.remaining=t,p(this.processAsync),this.saxParser):this.saxParser.write(t).close())}catch(e){if(n=e,!this.saxParser.errThrown&&!this.saxParser.ended)return this.emit("error",n),this.saxParser.errThrown=!0;if(this.saxParser.ended)throw n}},r.prototype.parseStringPromise=function(e){return new Promise((t=this,function(i,n){return t.parseString(e,(function(e,t){return e?n(e):i(t)}))}));var t},r}(r),t.parseString=function(e,i,n){var o,r;return null!=n?("function"==typeof n&&(o=n),"object"==typeof i&&(r=i)):("function"==typeof i&&(o=i),r={}),new t.Parser(r).parseString(e,o)},t.parseStringPromise=function(e,i){var n;return"object"==typeof i&&(n=i),new t.Parser(n).parseStringPromise(e)}}).call(this)},4808:e=>{var t=1e3,i=60*t,n=60*i,o=24*n,r=7*o,s=365.25*o;function a(e,t,i,n){var o=t>=1.5*i;return Math.round(e/i)+" "+n+(o?"s":"")}e.exports=function(e,c){c=c||{};var l=typeof e;if("string"===l&&e.length>0)return function(e){if((e=String(e)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*s;case"weeks":case"week":case"w":return c*r;case"days":case"day":case"d":return c*o;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*i;case"seconds":case"second":case"secs":case"sec":case"s":return c*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(e);if("number"===l&&isFinite(e))return c.long?function(e){var r=Math.abs(e);if(r>=o)return a(e,r,o,"day");if(r>=n)return a(e,r,n,"hour");if(r>=i)return a(e,r,i,"minute");if(r>=t)return a(e,r,t,"second");return e+" ms"}(e):function(e){var r=Math.abs(e);if(r>=o)return Math.round(e/o)+"d";if(r>=n)return Math.round(e/n)+"h";if(r>=i)return Math.round(e/i)+"m";if(r>=t)return Math.round(e/t)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},4904:(e,t,i)=>{"use strict";i.r(t),i.d(t,{clearInterval:()=>p,clearTimeout:()=>u,setInterval:()=>d,setTimeout:()=>h});const n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,o=536870912,r=1073741824,s=new WeakMap;var a;const c=((e,t)=>i=>{const s=t.get(i);let a=void 0===s?i.size:s<r?s+1:0;if(!i.has(a))return e(i,a);if(i.size<o){for(;i.has(a);)a=Math.floor(Math.random()*r);return e(i,a)}if(i.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;i.has(a);)a=Math.floor(Math.random()*n);return e(i,a)})((a=s,(e,t)=>(a.set(e,t),t)),s),l=((e=>{})(c),((e,t)=>{let i=null;return()=>{if(null!==i)return i;const n=new Blob([t],{type:"application/javascript; charset=utf-8"}),o=URL.createObjectURL(n);return i=e(o),setTimeout((()=>URL.revokeObjectURL(o))),i}})((e=>{const t=new Map([[0,()=>{}]]),i=new Map([[0,()=>{}]]),n=new Map,o=new Worker(e);o.addEventListener("message",(({data:e})=>{if(void 0!==(o=e).method&&"call"===o.method){const{params:{timerId:o,timerType:r}}=e;if("interval"===r){const e=t.get(o);if("number"==typeof e){const t=n.get(e);if(void 0===t||t.timerId!==o||t.timerType!==r)throw new Error("The timer is in an undefined state.")}else{if("undefined"==typeof e)throw new Error("The timer is in an undefined state.");e()}}else if("timeout"===r){const e=i.get(o);if("number"==typeof e){const t=n.get(e);if(void 0===t||t.timerId!==o||t.timerType!==r)throw new Error("The timer is in an undefined state.")}else{if("undefined"==typeof e)throw new Error("The timer is in an undefined state.");e(),i.delete(o)}}}else{if(!(e=>null===e.error&&"number"==typeof e.id)(e)){const{error:{message:t}}=e;throw new Error(t)}{const{id:o}=e,r=n.get(o);if(void 0===r)throw new Error("The timer is in an undefined state.");const{timerId:s,timerType:a}=r;n.delete(o),"interval"===a?t.delete(s):i.delete(s)}}var o}));return{clearInterval:e=>{const i=c(n);n.set(i,{timerId:e,timerType:"interval"}),t.set(e,i),o.postMessage({id:i,method:"clear",params:{timerId:e,timerType:"interval"}})},clearTimeout:e=>{const t=c(n);n.set(t,{timerId:e,timerType:"timeout"}),i.set(e,t),o.postMessage({id:t,method:"clear",params:{timerId:e,timerType:"timeout"}})},setInterval:(e,i=0)=>{const n=c(t);return t.set(n,(()=>{e(),"function"==typeof t.get(n)&&o.postMessage({id:null,method:"set",params:{delay:i,now:performance.now(),timerId:n,timerType:"interval"}})})),o.postMessage({id:null,method:"set",params:{delay:i,now:performance.now(),timerId:n,timerType:"interval"}}),n},setTimeout:(e,t=0)=>{const n=c(i);return i.set(n,e),o.postMessage({id:null,method:"set",params:{delay:t,now:performance.now(),timerId:n,timerType:"timeout"}}),n}}}),'(()=>{"use strict";const e=new Map,t=new Map,r=(e,t)=>{let r,o;const i=performance.now();r=i,o=e-Math.max(0,i-t);return{expected:r+o,remainingDelay:o}},o=(e,t,r,i)=>{const s=performance.now();s>r?postMessage({id:null,method:"call",params:{timerId:t,timerType:i}}):e.set(t,setTimeout(o,r-s,e,t,r,i))};addEventListener("message",(i=>{let{data:s}=i;try{if("clear"===s.method){const{id:r,params:{timerId:o,timerType:i}}=s;if("interval"===i)(t=>{const r=e.get(t);if(void 0===r)throw new Error(\'There is no interval scheduled with the given id "\'.concat(t,\'".\'));clearTimeout(r),e.delete(t)})(o),postMessage({error:null,id:r});else{if("timeout"!==i)throw new Error(\'The given type "\'.concat(i,\'" is not supported\'));(e=>{const r=t.get(e);if(void 0===r)throw new Error(\'There is no timeout scheduled with the given id "\'.concat(e,\'".\'));clearTimeout(r),t.delete(e)})(o),postMessage({error:null,id:r})}}else{if("set"!==s.method)throw new Error(\'The given method "\'.concat(s.method,\'" is not supported\'));{const{params:{delay:i,now:n,timerId:a,timerType:d}}=s;if("interval"===d)((t,i,s)=>{const{expected:n,remainingDelay:a}=r(t,s);e.set(i,setTimeout(o,a,e,i,n,"interval"))})(i,a,n);else{if("timeout"!==d)throw new Error(\'The given type "\'.concat(d,\'" is not supported\'));((e,i,s)=>{const{expected:n,remainingDelay:a}=r(e,s);t.set(i,setTimeout(o,a,t,i,n,"timeout"))})(i,a,n)}}}}catch(e){postMessage({error:{message:e.message},id:s.id,result:null})}}))})();')),p=e=>l().clearInterval(e),u=e=>l().clearTimeout(e),d=(...e)=>l().setInterval(...e),h=(...e)=>l().setTimeout(...e)},4940:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StreamEndError=void 0,t.read16BELengthLoop=async function(e,t){let i;const{skipHeader:r,callback:s}=t,a=t.offset||0,c=t.headerLength||2;let l,p;e.on("error",(e=>i=e));let u=0,d=0;const h=()=>{d++,m()},m=()=>{for(;;){if(u!==d)return;if(l){const t=e.read(p);if(!t)return;s(l,t),l=void 0}else{if(l=e.read(c),!l)return;if(r?.(l,h)){u++,l=void 0;continue}p=l.readUInt16BE(a)}}};throw m(),e.on("readable",m),await(0,n.once)(e,"end"),new o("read16BELengthLoop")},t.readLength=async function(e,t){if(e.readableEnded||e.destroyed)throw new o("readLength start");if(!t)return Buffer.alloc(0);{const i=e.read(t);if(i)return i}return new Promise(((i,n)=>{const r=()=>{const r=e.read(t);if(r)return a(),void i(r);(e.readableEnded||e.destroyed)&&n(new o("readLength readable"))},s=()=>{a(),n(new o("readLength end"))},a=()=>{e.removeListener("readable",r),e.removeListener("end",s)};e.on("readable",r),e.on("end",s)}))},t.readUntil=s,t.readLine=async function(e){return s(e,r)},t.readString=async function(e){return(await a(e)).toString()},t.readBuffer=a;const n=i(4434);class o extends Error{constructor(e){super(`stream ended: ${e}`)}}t.StreamEndError=o;const r="\n".charCodeAt(0);async function s(e,t){const i=[];for(;;){const o=e.read();if(!o){await(0,n.once)(e,"readable");continue}const r=o.findIndex((e=>e===t));if(-1===r){i.push(o);continue}const s=o.subarray(0,r);i.push(s);const a=o.subarray(r+1);return e.unshift(a),Buffer.concat(i).toString()}}async function a(e){const t=[];return(e=await e).on("data",(e=>{t.push(e)})),e.resume(),await(0,n.once)(e,"end"),Buffer.concat(t)}},4988:(e,t,i)=>{"use strict";const{Duplex:n}=i(2203);function o(e){e.emit("close")}function r(){!this.destroyed&&this._writableState.finished&&this.destroy()}function s(e){this.removeListener("error",s),this.destroy(),0===this.listenerCount("error")&&this.emit("error",e)}e.exports=function(e,t){let i=!0;const a=new n({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",(function(t,i){const n=!i&&a._readableState.objectMode?t.toString():t;a.push(n)||e.pause()})),e.once("error",(function(e){a.destroyed||(i=!1,a.destroy(e))})),e.once("close",(function(){a.destroyed||a.push(null)})),a._destroy=function(t,n){if(e.readyState===e.CLOSED)return n(t),void process.nextTick(o,a);let r=!1;e.once("error",(function(e){r=!0,n(e)})),e.once("close",(function(){r||n(t),process.nextTick(o,a)})),i&&e.terminate()},a._final=function(t){e.readyState!==e.CONNECTING?null!==e._socket&&(e._socket._writableState.finished?(t(),a._readableState.endEmitted&&a.destroy()):(e._socket.once("finish",(function(){t()})),e.close())):e.once("open",(function(){a._final(t)}))},a._read=function(){e.isPaused&&e.resume()},a._write=function(t,i,n){e.readyState!==e.CONNECTING?e.send(t,n):e.once("open",(function(){a._write(t,i,n)}))},a.on("end",r),a.on("error",s),a}},5047:(e,t,i)=>{const n=i(7097),{ArrayPrototypeIndexOf:o,NumberIsInteger:r,NumberIsNaN:s,NumberParseInt:a,ObjectDefineProperties:c,ObjectKeys:l,ObjectSetPrototypeOf:p,Promise:u,SafeSet:d,SymbolAsyncDispose:h,SymbolAsyncIterator:m,Symbol:f}=i(3383);e.exports=G,G.ReadableState=W;const{EventEmitter:g}=i(4434),{Stream:v,prependListener:y}=i(1808),{Buffer:b}=i(181),{addAbortSignal:w}=i(1564),_=i(9071);let S=i(3939).debuglog("stream",(e=>{S=e}));const x=i(4536),T=i(577),{getHighWaterMark:E,getDefaultHighWaterMark:C}=i(5722),{aggregateTwoErrors:P,codes:{ERR_INVALID_ARG_TYPE:k,ERR_METHOD_NOT_IMPLEMENTED:O,ERR_OUT_OF_RANGE:I,ERR_STREAM_PUSH_AFTER_EOF:A,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:R},AbortError:D}=i(676),{validateObject:M}=i(2354),N=f("kPaused"),{StringDecoder:L}=i(3193),j=i(4435);p(G.prototype,v.prototype),p(G,v);const F=()=>{},{errorOrDestroy:B}=T,U=1,q=16,V=32,H=2048,z=4096;function $(e){return{enumerable:!1,get(){return 0!==(this.state&e)},set(t){t?this.state|=e:this.state&=~e}}}function W(e,t,n){"boolean"!=typeof n&&(n=t instanceof i(5745)),this.state=H|z|q|V,e&&e.objectMode&&(this.state|=U),n&&e&&e.readableObjectMode&&(this.state|=U),this.highWaterMark=e?E(this,e,"readableHighWaterMark",n):C(!1),this.buffer=new x,this.length=0,this.pipes=[],this.flowing=null,this[N]=null,e&&!1===e.emitClose&&(this.state&=~H),e&&!1===e.autoDestroy&&(this.state&=~z),this.errored=null,this.defaultEncoding=e&&e.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.decoder=null,this.encoding=null,e&&e.encoding&&(this.decoder=new L(e.encoding),this.encoding=e.encoding)}function G(e){if(!(this instanceof G))return new G(e);const t=this instanceof i(5745);this._readableState=new W(e,this,t),e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.construct&&(this._construct=e.construct),e.signal&&!t&&w(e.signal,this)),v.call(this,e),T.construct(this,(()=>{this._readableState.needReadable&&X(this,this._readableState)}))}function K(e,t,i,n){S("readableAddChunk",t);const o=e._readableState;let r;if(0===(o.state&U)&&("string"==typeof t?(i=i||o.defaultEncoding,o.encoding!==i&&(n&&o.encoding?t=b.from(t,i).toString(o.encoding):(t=b.from(t,i),i=""))):t instanceof b?i="":v._isUint8Array(t)?(t=v._uint8ArrayToBuffer(t),i=""):null!=t&&(r=new k("chunk",["string","Buffer","Uint8Array"],t))),r)B(e,r);else if(null===t)o.state&=-9,function(e,t){if(S("onEofChunk"),t.ended)return;if(t.decoder){const e=t.decoder.end();e&&e.length&&(t.buffer.push(e),t.length+=t.objectMode?1:e.length)}t.ended=!0,t.sync?J(e):(t.needReadable=!1,t.emittedReadable=!0,Z(e))}(e,o);else if(0!==(o.state&U)||t&&t.length>0)if(n)if(4&o.state)B(e,new R);else{if(o.destroyed||o.errored)return!1;Y(e,o,t,!0)}else if(o.ended)B(e,new A);else{if(o.destroyed||o.errored)return!1;o.state&=-9,o.decoder&&!i?(t=o.decoder.write(t),o.objectMode||0!==t.length?Y(e,o,t,!1):X(e,o)):Y(e,o,t,!1)}else n||(o.state&=-9,X(e,o));return!o.ended&&(o.length<o.highWaterMark||0===o.length)}function Y(e,t,i,n){t.flowing&&0===t.length&&!t.sync&&e.listenerCount("data")>0?(65536&t.state?t.awaitDrainWriters.clear():t.awaitDrainWriters=null,t.dataEmitted=!0,e.emit("data",i)):(t.length+=t.objectMode?1:i.length,n?t.buffer.unshift(i):t.buffer.push(i),64&t.state&&J(e)),X(e,t)}c(W.prototype,{objectMode:$(U),ended:$(2),endEmitted:$(4),reading:$(8),constructed:$(q),sync:$(V),needReadable:$(64),emittedReadable:$(128),readableListening:$(256),resumeScheduled:$(512),errorEmitted:$(1024),emitClose:$(H),autoDestroy:$(z),destroyed:$(8192),closed:$(16384),closeEmitted:$(32768),multiAwaitDrain:$(65536),readingMore:$(1<<17),dataEmitted:$(1<<18)}),G.prototype.destroy=T.destroy,G.prototype._undestroy=T.undestroy,G.prototype._destroy=function(e,t){t(e)},G.prototype[g.captureRejectionSymbol]=function(e){this.destroy(e)},G.prototype[h]=function(){let e;return this.destroyed||(e=this.readableEnded?null:new D,this.destroy(e)),new u(((t,i)=>_(this,(n=>n&&n!==e?i(n):t(null)))))},G.prototype.push=function(e,t){return K(this,e,t,!1)},G.prototype.unshift=function(e,t){return K(this,e,t,!0)},G.prototype.isPaused=function(){const e=this._readableState;return!0===e[N]||!1===e.flowing},G.prototype.setEncoding=function(e){const t=new L(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;const i=this._readableState.buffer;let n="";for(const e of i)n+=t.write(e);return i.clear(),""!==n&&i.push(n),this._readableState.length=n.length,this};function Q(e,t){return e<=0||0===t.length&&t.ended?0:0!==(t.state&U)?1:s(e)?t.flowing&&t.length?t.buffer.first().length:t.length:e<=t.length?e:t.ended?t.length:0}function J(e){const t=e._readableState;S("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(S("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(Z,e))}function Z(e){const t=e._readableState;S("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||t.errored||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,oe(e)}function X(e,t){!t.readingMore&&t.constructed&&(t.readingMore=!0,n.nextTick(ee,e,t))}function ee(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){const i=t.length;if(S("maybeReadMore read 0"),e.read(0),i===t.length)break}t.readingMore=!1}function te(e){const t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!1===t[N]?t.flowing=!0:e.listenerCount("data")>0?e.resume():t.readableListening||(t.flowing=null)}function ie(e){S("readable nexttick read 0"),e.read(0)}function ne(e,t){S("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),oe(e),t.flowing&&!t.reading&&e.read(0)}function oe(e){const t=e._readableState;for(S("flow",t.flowing);t.flowing&&null!==e.read(););}function re(e,t){"function"!=typeof e.read&&(e=G.wrap(e,{objectMode:!0}));const i=async function*(e,t){let i,n=F;function o(t){this===e?(n(),n=F):n=t}e.on("readable",o);const r=_(e,{writable:!1},(e=>{i=e?P(i,e):null,n(),n=F}));try{for(;;){const t=e.destroyed?null:e.read();if(null!==t)yield t;else{if(i)throw i;if(null===i)return;await new u(o)}}}catch(e){throw i=P(i,e),i}finally{!i&&!1===(null==t?void 0:t.destroyOnReturn)||void 0!==i&&!e._readableState.autoDestroy?(e.off("readable",o),r()):T.destroyer(e,null)}}(e,t);return i.stream=e,i}function se(e,t){if(0===t.length)return null;let i;return t.objectMode?i=t.buffer.shift():!e||e>=t.length?(i=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):i=t.buffer.consume(e,t.decoder),i}function ae(e){const t=e._readableState;S("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(ce,t,e))}function ce(e,t){if(S("endReadableNT",e.endEmitted,e.length),!e.errored&&!e.closeEmitted&&!e.endEmitted&&0===e.length)if(e.endEmitted=!0,t.emit("end"),t.writable&&!1===t.allowHalfOpen)n.nextTick(le,t);else if(e.autoDestroy){const e=t._writableState;(!e||e.autoDestroy&&(e.finished||!1===e.writable))&&t.destroy()}}function le(e){e.writable&&!e.writableEnded&&!e.destroyed&&e.end()}let pe;function ue(){return void 0===pe&&(pe={}),pe}G.prototype.read=function(e){S("read",e),void 0===e?e=NaN:r(e)||(e=a(e,10));const t=this._readableState,i=e;if(e>t.highWaterMark&&(t.highWaterMark=function(e){if(e>1073741824)throw new I("size","<= 1GiB",e);return e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,++e}(e)),0!==e&&(t.state&=-129),0===e&&t.needReadable&&((0!==t.highWaterMark?t.length>=t.highWaterMark:t.length>0)||t.ended))return S("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?ae(this):J(this),null;if(0===(e=Q(e,t))&&t.ended)return 0===t.length&&ae(this),null;let n,o=!!(64&t.state);if(S("need readable",o),(0===t.length||t.length-e<t.highWaterMark)&&(o=!0,S("length less than watermark",o)),t.ended||t.reading||t.destroyed||t.errored||!t.constructed)o=!1,S("reading, ended or constructing",o);else if(o){S("do read"),t.state|=8|V,0===t.length&&(t.state|=64);try{this._read(t.highWaterMark)}catch(e){B(this,e)}t.state&=~V,t.reading||(e=Q(i,t))}return n=e>0?se(e,t):null,null===n?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.multiAwaitDrain?t.awaitDrainWriters.clear():t.awaitDrainWriters=null),0===t.length&&(t.ended||(t.needReadable=!0),i!==e&&t.ended&&ae(this)),null===n||t.errorEmitted||t.closeEmitted||(t.dataEmitted=!0,this.emit("data",n)),n},G.prototype._read=function(e){throw new O("_read()")},G.prototype.pipe=function(e,t){const i=this,o=this._readableState;1===o.pipes.length&&(o.multiAwaitDrain||(o.multiAwaitDrain=!0,o.awaitDrainWriters=new d(o.awaitDrainWriters?[o.awaitDrainWriters]:[]))),o.pipes.push(e),S("pipe count=%d opts=%j",o.pipes.length,t);const r=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?a:g;function s(t,n){S("onunpipe"),t===i&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,function(){S("cleanup"),e.removeListener("close",m),e.removeListener("finish",f),c&&e.removeListener("drain",c);e.removeListener("error",h),e.removeListener("unpipe",s),i.removeListener("end",a),i.removeListener("end",g),i.removeListener("data",u),l=!0,c&&o.awaitDrainWriters&&(!e._writableState||e._writableState.needDrain)&&c()}())}function a(){S("onend"),e.end()}let c;o.endEmitted?n.nextTick(r):i.once("end",r),e.on("unpipe",s);let l=!1;function p(){l||(1===o.pipes.length&&o.pipes[0]===e?(S("false write response, pause",0),o.awaitDrainWriters=e,o.multiAwaitDrain=!1):o.pipes.length>1&&o.pipes.includes(e)&&(S("false write response, pause",o.awaitDrainWriters.size),o.awaitDrainWriters.add(e)),i.pause()),c||(c=function(e,t){return function(){const i=e._readableState;i.awaitDrainWriters===t?(S("pipeOnDrain",1),i.awaitDrainWriters=null):i.multiAwaitDrain&&(S("pipeOnDrain",i.awaitDrainWriters.size),i.awaitDrainWriters.delete(t)),i.awaitDrainWriters&&0!==i.awaitDrainWriters.size||!e.listenerCount("data")||e.resume()}}(i,e),e.on("drain",c))}function u(t){S("ondata");const i=e.write(t);S("dest.write",i),!1===i&&p()}function h(t){if(S("onerror",t),g(),e.removeListener("error",h),0===e.listenerCount("error")){const i=e._writableState||e._readableState;i&&!i.errorEmitted?B(e,t):e.emit("error",t)}}function m(){e.removeListener("finish",f),g()}function f(){S("onfinish"),e.removeListener("close",m),g()}function g(){S("unpipe"),i.unpipe(e)}return i.on("data",u),y(e,"error",h),e.once("close",m),e.once("finish",f),e.emit("pipe",i),!0===e.writableNeedDrain?p():o.flowing||(S("pipe resume"),i.resume()),e},G.prototype.unpipe=function(e){const t=this._readableState;if(0===t.pipes.length)return this;if(!e){const e=t.pipes;t.pipes=[],this.pause();for(let t=0;t<e.length;t++)e[t].emit("unpipe",this,{hasUnpiped:!1});return this}const i=o(t.pipes,e);return-1===i||(t.pipes.splice(i,1),0===t.pipes.length&&this.pause(),e.emit("unpipe",this,{hasUnpiped:!1})),this},G.prototype.on=function(e,t){const i=v.prototype.on.call(this,e,t),o=this._readableState;return"data"===e?(o.readableListening=this.listenerCount("readable")>0,!1!==o.flowing&&this.resume()):"readable"===e&&(o.endEmitted||o.readableListening||(o.readableListening=o.needReadable=!0,o.flowing=!1,o.emittedReadable=!1,S("on readable",o.length,o.reading),o.length?J(this):o.reading||n.nextTick(ie,this))),i},G.prototype.addListener=G.prototype.on,G.prototype.removeListener=function(e,t){const i=v.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(te,this),i},G.prototype.off=G.prototype.removeListener,G.prototype.removeAllListeners=function(e){const t=v.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||n.nextTick(te,this),t},G.prototype.resume=function(){const e=this._readableState;return e.flowing||(S("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(ne,e,t))}(this,e)),e[N]=!1,this},G.prototype.pause=function(){return S("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(S("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState[N]=!0,this},G.prototype.wrap=function(e){let t=!1;e.on("data",(i=>{!this.push(i)&&e.pause&&(t=!0,e.pause())})),e.on("end",(()=>{this.push(null)})),e.on("error",(e=>{B(this,e)})),e.on("close",(()=>{this.destroy()})),e.on("destroy",(()=>{this.destroy()})),this._read=()=>{t&&e.resume&&(t=!1,e.resume())};const i=l(e);for(let t=1;t<i.length;t++){const n=i[t];void 0===this[n]&&"function"==typeof e[n]&&(this[n]=e[n].bind(e))}return this},G.prototype[m]=function(){return re(this)},G.prototype.iterator=function(e){return void 0!==e&&M(e,"options"),re(this,e)},c(G.prototype,{readable:{__proto__:null,get(){const e=this._readableState;return!(!e||!1===e.readable||e.destroyed||e.errorEmitted||e.endEmitted)},set(e){this._readableState&&(this._readableState.readable=!!e)}},readableDidRead:{__proto__:null,enumerable:!1,get:function(){return this._readableState.dataEmitted}},readableAborted:{__proto__:null,enumerable:!1,get:function(){return!(!1===this._readableState.readable||!this._readableState.destroyed&&!this._readableState.errored||this._readableState.endEmitted)}},readableHighWaterMark:{__proto__:null,enumerable:!1,get:function(){return this._readableState.highWaterMark}},readableBuffer:{__proto__:null,enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}},readableFlowing:{__proto__:null,enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}},readableLength:{__proto__:null,enumerable:!1,get(){return this._readableState.length}},readableObjectMode:{__proto__:null,enumerable:!1,get(){return!!this._readableState&&this._readableState.objectMode}},readableEncoding:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.encoding:null}},errored:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.errored:null}},closed:{__proto__:null,get(){return!!this._readableState&&this._readableState.closed}},destroyed:{__proto__:null,enumerable:!1,get(){return!!this._readableState&&this._readableState.destroyed},set(e){this._readableState&&(this._readableState.destroyed=e)}},readableEnded:{__proto__:null,enumerable:!1,get(){return!!this._readableState&&this._readableState.endEmitted}}}),c(W.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return!1!==this[N]},set(e){this[N]=!!e}}}),G._fromList=se,G.from=function(e,t){return j(G,e,t)},G.fromWeb=function(e,t){return ue().newStreamReadableFromReadableStream(e,t)},G.toWeb=function(e,t){return ue().newReadableStreamFromStreamReadable(e,t)},G.wrap=function(e,t){var i,n;return new G({objectMode:null===(i=null!==(n=e.readableObjectMode)&&void 0!==n?n:e.objectMode)||void 0===i||i,...t,destroy(t,i){T.destroyer(e,t),i(t)}}).wrap(e)}},5049:(e,t,i)=>{e.exports={Cam:i(123).Cam,Discovery:i(6662).Discovery}},5068:function(e){(function(){e.exports={Element:1,Attribute:2,Text:3,CData:4,EntityReference:5,EntityDeclaration:6,ProcessingInstruction:7,Comment:8,Document:9,DocType:10,DocumentFragment:11,NotationDeclaration:12,Declaration:201,Raw:202,AttributeDeclaration:203,ElementDeclaration:204,Dummy:205}}).call(this)},5083:(e,t,i)=>{e.exports=function(e){const t=i(4081).linerase;e.prototype.getRecordings=function(e){this._request({service:"recording",body:this._envelopeHeader()+'<GetRecordings xmlns="http://www.onvif.org/ver10/recording/wsdl"/>'+this._envelopeFooter()},function(i,n,o){i||(this.recordingItems=t(n).getRecordingsResponse.recordingItem),e&&e.call(this,i,this.recordingItems,o)}.bind(this))},e.prototype.getRecordingJobs=function(e){this._request({service:"recording",body:this._envelopeHeader()+'<GetRecordingJobs xmlns="http://www.onvif.org/ver10/recording/wsdl"/>'+this._envelopeFooter()},function(i,n,o){i||(this.jobItem=t(n).getRecordingJobsResponse.jobItem),e&&e.call(this,i,this.jobItem,o)}.bind(this))},e.prototype.createRecordingJob=function(e,i){let n;try{n='<CreateRecordingJob xmlns="http://www.onvif.org/ver10/recording/wsdl"><JobConfiguration><ScheduleToken>'+(e.scheduleToken||"")+"</ScheduleToken><RecordingToken>"+(e.recordingToken||"")+"</RecordingToken><Mode>"+(e.mode||"")+"</Mode><Priority>"+(e.priority||"")+"</Priority><Source><SourceToken><Type>"+(e.source.sourceToken.type||"")+"</Type><Token>"+(e.source.sourceToken.token||"")+"</Token></SourceToken><AutoCreateReceiver>"+(e.source.autoCreateReceiver||"")+"</AutoCreateReceiver><Tracks><SourceTag>"+((e&&e.source&&e.source.tracks?e.source.tracks.sourceTag:"")||"")+"</SourceTag><Destination>"+((e&&e.source&&e.source.tracks?e.source.tracks.destination:"")||"")+"</Destination></Tracks><Extension>"+(e.source.extension||"")+"</Extension></Source><Extension>"+(e.extension||"")+"</Extension></JobConfiguration></CreateRecordingJob>"}catch(e){console.log(e)}this._request({service:"recording",body:this._envelopeHeader()+n+this._envelopeFooter()},function(e,n,o){e||(this.recordingJob=t(n).createRecordingJobResponse),i&&i.call(this,e,this.recordingJob,o)}.bind(this))},e.prototype.deleteRecordingJob=function(e,i){this._request({service:"recording",body:this._envelopeHeader()+'<DeleteRecordingJob xmlns="http://www.onvif.org/ver10/recording/wsdl"><JobToken>'+e.JobToken+"</JobToken></DeleteRecordingJob>"+this._envelopeFooter()},function(e,n,o){let r;e||(r=t(n).getRecordingJobsResponse),i&&i.call(this,e,r,o)}.bind(this))},e.prototype.getRecordingSummary=function(e){this._request({service:"search",body:this._envelopeHeader()+'<GetRecordingSummary xmlns="http://www.onvif.org/ver10/search/wsdl"/>'+this._envelopeFooter()},function(i,n,o){i||(this.recordingSummary=t(n).getRecordingSummaryResponse.summary),e&&e.call(this,i,this.recordingSummary,o)}.bind(this))},e.prototype.getRecordingInformation=function(e,i){this._request({service:"search",body:this._envelopeHeader()+'<GetRecordingInformation xmlns="http://www.onvif.org/ver10/search/wsdl"><RecordingToken>'+e.RecordingToken+"</RecordingToken></GetRecordingInformation>"+this._envelopeFooter()},function(e,n,o){e||(this.summary=t(n).getRecordingSummaryResponse.summary),i&&i.call(this,e,this.summary,o)}.bind(this))},e.prototype.getRecordingConfiguration=function(e,i){this._request({service:"recording",body:this._envelopeHeader()+'<GetRecordingConfiguration xmlns="http://www.onvif.org/ver10/recording/wsdl"><RecordingToken>'+e.RecordingToken+"</RecordingToken></GetRecordingConfiguration>"+this._envelopeFooter()},function(e,n,o){e||(this.recordingConfiguration=t(n).getRecordingConfigurationResponse.recordingConfiguration),i&&i.call(this,e,this.recordingConfiguration,o)}.bind(this))},e.prototype.getRecordingJobState=function(e,i){this._request({service:"recording",body:this._envelopeHeader()+'<GetRecordingJobState xmlns="http://www.onvif.org/ver10/recording/wsdl"><JobToken>'+e.JobToken+"</JobToken></GetRecordingJobState>"+this._envelopeFooter()},function(e,n,o){e||(this.recordingJobState=t(n).getRecordingJobStateResponse.state),i&&i.call(this,e,this.recordingJobState,o)}.bind(this))},e.prototype.deleteRecordingJob=function(e,i){this._request({service:"recording",body:this._envelopeHeader()+'<DeleteRecordingJob xmlns="http://www.onvif.org/ver10/recording/wsdl"><JobToken>'+e.JobToken+"</JobToken></DeleteRecordingJob>"+this._envelopeFooter()},function(e,n,o){let r={};e||(r=t(n).deleteRecordingJobResponse),i&&i.call(this,e,r,o)}.bind(this))},e.prototype.getRecordingOptions=function(e,i){this._request({service:"recording",body:this._envelopeHeader()+'<GetRecordingOptions xmlns="http://www.onvif.org/ver10/recording/wsdl"><RecordingToken>'+e.RecordingToken+"</RecordingToken></GetRecordingOptions>"+this._envelopeFooter()},function(e,n,o){e||(this.recordingOptions=t(n).getRecordingOptionsResponse.options),i&&i.call(this,e,this.recordingOptions,o)}.bind(this))},e.prototype.getRecordingServiceCapabilities=function(e){this._request({service:"recording",body:this._envelopeHeader()+'<GetServiceCapabilities xmlns="http://www.onvif.org/ver10/recording/wsdl"/>'+this._envelopeFooter()},function(i,n,o){i||(this.searchCapabilities=t(n).getServiceCapabilitiesResponse.capabilities),e&&e.call(this,i,this.searchCapabilities,o)}.bind(this))},e.prototype.getTrackConfiguration=function(e,i){this._request({service:"recording",body:this._envelopeHeader()+'<GetTrackConfiguration xmlns="http://www.onvif.org/ver10/recording/wsdl"><RecordingToken>'+e.recordingToken+"</RecordingToken><TrackToken>"+e.trackToken+"</TrackToken></GetTrackConfiguration>"+this._envelopeFooter()},function(e,n,o){e||(this.trackConfiguration=t(n).getTrackConfigurationResponse.trackConfiguration),i&&i.call(this,e,this.trackConfiguration,o)}.bind(this))},e.prototype.getRecordingJobConfiguration=function(e,i){this._request({service:"recording",body:this._envelopeHeader()+'<GetRecordingJobConfiguration xmlns="http://www.onvif.org/ver10/recording/wsdl"><JobToken>'+(e.JobToken||"")+"</JobToken></GetRecordingJobConfiguration>"+this._envelopeFooter()},function(e,n,o){e||(this.recordingJobConfiguration=t(n).getRecordingJobConfigurationResponse.jobConfiguration),i&&i.call(this,e,this.recordingJobConfiguration,o)}.bind(this))},e.prototype.setRecordingJobMode=function(e,i){this._request({service:"recording",body:this._envelopeHeader()+'<SetRecordingJobMode xmlns="http://www.onvif.org/ver10/recording/wsdl"><JobToken>'+(e.JobToken||"")+"</JobToken><Mode>"+(e.Mode||"")+"</Mode></SetRecordingJobMode>"+this._envelopeFooter()},function(e,n,o){e||(this.recordingJobMode=t(n).SetRecordingJobMode),i&&i.call(this,e,this.recordingJobMode,o)}.bind(this))}}},5091:e=>{"use strict";e.exports=JSON.parse('{"name":"@apocaliss92/scrypted-reolink-videoclips","description":"Scrypted plugin to let reolink cameras to show stored videoclips","repository":{"type":"git","url":"https://github.com/apocaliss92/scrypted-reolink-videoclips"},"version":"0.1.15","scripts":{"scrypted-setup-project":"scrypted-setup-project","prescrypted-setup-project":"scrypted-package-json","build":"scrypted-webpack","prepublishOnly":"NODE_ENV=production scrypted-webpack","prescrypted-vscode-launch":"scrypted-webpack","scrypted-vscode-launch":"scrypted-deploy-debug","scrypted-deploy-debug":"scrypted-deploy-debug","scrypted-debug":"scrypted-debug","scrypted-deploy":"scrypted-deploy","scrypted-readme":"scrypted-readme","scrypted-package-json":"scrypted-package-json"},"keywords":["scrypted","plugin","reolink","videoclips","snapshots"],"scrypted":{"name":"Reolink videoclips","type":"API","interfaces":["Settings","MixinProvider","HttpRequestHandler"],"pluginDependencies":[]},"dependencies":{"@scrypted/sdk":"file:../scrypted/sdk","@scrypted/common":"file:../scrypted/common","lodash":"^4.17.21"},"devDependencies":{"@types/lodash":"^4.17.12","@types/node":"^20.11.0"}}')},5101:(e,t,i)=>{const n=i(7097),{ArrayIsArray:o,Promise:r,SymbolAsyncIterator:s,SymbolDispose:a}=i(3383),c=i(9071),{once:l}=i(3939),p=i(577),u=i(5745),{aggregateTwoErrors:d,codes:{ERR_INVALID_ARG_TYPE:h,ERR_INVALID_RETURN_VALUE:m,ERR_MISSING_ARGS:f,ERR_STREAM_DESTROYED:g,ERR_STREAM_PREMATURE_CLOSE:v},AbortError:y}=i(676),{validateFunction:b,validateAbortSignal:w}=i(2354),{isIterable:_,isReadable:S,isReadableNodeStream:x,isNodeStream:T,isTransformStream:E,isWebStream:C,isReadableStream:P,isReadableFinished:k}=i(6274),O=globalThis.AbortController||i(581).AbortController;let I,A,R;function D(e,t,i){let n=!1;e.on("close",(()=>{n=!0}));return{destroy:t=>{n||(n=!0,p.destroyer(e,t||new g("pipe")))},cleanup:c(e,{readable:t,writable:i},(e=>{n=!e}))}}function M(e){if(_(e))return e;if(x(e))return async function*(e){A||(A=i(5047));yield*A.prototype[s].call(e)}(e);throw new h("val",["Readable","Iterable","AsyncIterable"],e)}async function N(e,t,i,{end:n}){let o,s=null;const a=e=>{if(e&&(o=e),s){const e=s;s=null,e()}},l=()=>new r(((e,t)=>{o?t(o):s=()=>{o?t(o):e()}}));t.on("drain",a);const p=c(t,{readable:!1},a);try{t.writableNeedDrain&&await l();for await(const i of e)t.write(i)||await l();n&&(t.end(),await l()),i()}catch(e){i(o!==e?d(o,e):e)}finally{p(),t.off("drain",a)}}async function L(e,t,i,{end:n}){E(t)&&(t=t.writable);const o=t.getWriter();try{for await(const t of e)await o.ready,o.write(t).catch((()=>{}));await o.ready,n&&await o.close(),i()}catch(e){try{await o.abort(e),i(e)}catch(e){i(e)}}}function j(e,t,r){if(1===e.length&&o(e[0])&&(e=e[0]),e.length<2)throw new f("streams");const s=new O,c=s.signal,l=null==r?void 0:r.signal,p=[];function d(){U(new y)}let g,v,b;w(l,"options.signal"),R=R||i(3939).addAbortListener,l&&(g=R(l,d));const k=[];let A,j=0;function B(e){U(e,0===--j)}function U(e,i){var o;if(!e||v&&"ERR_STREAM_PREMATURE_CLOSE"!==v.code||(v=e),v||i){for(;k.length;)k.shift()(v);null===(o=g)||void 0===o||o[a](),s.abort(),i&&(v||p.forEach((e=>e())),n.nextTick(t,v,b))}}for(let z=0;z<e.length;z++){const $=e[z],W=z<e.length-1,G=z>0,K=W||!1!==(null==r?void 0:r.end),Y=z===e.length-1;if(T($)){if(K){const{destroy:Q,cleanup:J}=D($,W,G);k.push(Q),S($)&&Y&&p.push(J)}function q(e){e&&"AbortError"!==e.name&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code&&B(e)}$.on("error",q),S($)&&Y&&p.push((()=>{$.removeListener("error",q)}))}if(0===z)if("function"==typeof $){if(A=$({signal:c}),!_(A))throw new m("Iterable, AsyncIterable or Stream","source",A)}else A=_($)||x($)||E($)?$:u.from($);else if("function"==typeof $){var V;if(E(A))A=M(null===(V=A)||void 0===V?void 0:V.readable);else A=M(A);if(A=$(A,{signal:c}),W){if(!_(A,!0))throw new m("AsyncIterable",`transform[${z-1}]`,A)}else{var H;I||(I=i(5253));const Z=new I({objectMode:!0}),X=null===(H=A)||void 0===H?void 0:H.then;if("function"==typeof X)j++,X.call(A,(e=>{b=e,null!=e&&Z.write(e),K&&Z.end(),n.nextTick(B)}),(e=>{Z.destroy(e),n.nextTick(B,e)}));else if(_(A,!0))j++,N(A,Z,B,{end:K});else{if(!P(A)&&!E(A))throw new m("AsyncIterable or Promise","destination",A);{const ie=A.readable||A;j++,N(ie,Z,B,{end:K})}}A=Z;const{destroy:ee,cleanup:te}=D(A,!1,!0);k.push(ee),Y&&p.push(te)}}else if(T($)){if(x(A)){j+=2;const ne=F(A,$,B,{end:K});S($)&&Y&&p.push(ne)}else if(E(A)||P(A)){const oe=A.readable||A;j++,N(oe,$,B,{end:K})}else{if(!_(A))throw new h("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],A);j++,N(A,$,B,{end:K})}A=$}else if(C($)){if(x(A))j++,L(M(A),$,B,{end:K});else if(P(A)||_(A))j++,L(A,$,B,{end:K});else{if(!E(A))throw new h("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],A);j++,L(A.readable,$,B,{end:K})}A=$}else A=u.from($)}return(null!=c&&c.aborted||null!=l&&l.aborted)&&n.nextTick(d),A}function F(e,t,i,{end:o}){let r=!1;if(t.on("close",(()=>{r||i(new v)})),e.pipe(t,{end:!1}),o){function s(){r=!0,t.end()}k(e)?n.nextTick(s):e.once("end",s)}else i();return c(e,{readable:!0,writable:!1},(t=>{const n=e._readableState;t&&"ERR_STREAM_PREMATURE_CLOSE"===t.code&&n&&n.ended&&!n.errored&&!n.errorEmitted?e.once("end",i).once("error",i):i(t)})),c(t,{readable:!1,writable:!0},i)}e.exports={pipelineImpl:j,pipeline:function(...e){return j(e,l(function(e){return b(e[e.length-1],"streams[stream.length - 1]"),e.pop()}(e)))}}},5175:(e,t,i)=>{e.exports=function(e){function t(e){let i,o,r,s=null;function a(...e){if(!a.enabled)return;const n=a,o=Number(new Date),r=o-(i||o);n.diff=r,n.prev=i,n.curr=o,i=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((i,o)=>{if("%%"===i)return"%";s++;const r=t.formatters[o];if("function"==typeof r){const t=e[s];i=r.call(n,t),e.splice(s,1),s--}return i})),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(o!==t.namespaces&&(o=t.namespaces,r=t.enabled(e)),r),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,i){const n=t(this.namespace+("undefined"==typeof i?":":i)+e);return n.log=this.log,n}function o(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(o),...t.skips.map(o).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let i;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(i=0;i<o;i++)n[i]&&("-"===(e=n[i].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let i,n;for(i=0,n=t.skips.length;i<n;i++)if(t.skips[i].test(e))return!1;for(i=0,n=t.names.length;i<n;i++)if(t.names[i].test(e))return!0;return!1},t.humanize=i(2726),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((i=>{t[i]=e[i]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let i=0;for(let t=0;t<e.length;t++)i=(i<<5)-i+e.charCodeAt(t),i|=0;return t.colors[Math.abs(i)%t.colors.length]},t.enable(t.load()),t}},5188:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.levenshteinDistance=t.getParentDetectionClass=t.detectionClassesDefaultMap=t.isObjectClassname=t.isLabelDetection=t.isAudioClassname=t.isPackageClassname=t.isDoorbellClassname=t.isMotionClassname=t.isVehicleClassname=t.isPersonClassname=t.isAnimalClassname=t.isPlateClassname=t.isFaceClassname=t.doorbellClasses=t.audioClasses=t.objectClasses=t.packageClasses=t.motionClasses=t.licensePlateClasses=t.faceClasses=t.vehicleClasses=t.personClasses=t.animalClasses=t.defaultDetectionClasses=t.basicDetectionClasses=t.classnamePrio=t.DetectionClass=void 0,function(e){e.Motion="motion",e.Person="person",e.Vehicle="vehicle",e.Animal="animal",e.Audio="audio",e.AnyObject="any_object",e.Face="face",e.Plate="plate",e.Package="package",e.Doorbell="doorbell",e.Sensor="sensor"}(i||(t.DetectionClass=i={})),t.classnamePrio={[i.Face]:1,[i.Plate]:1,[i.Person]:2,[i.Vehicle]:3,[i.Animal]:4,[i.Package]:5,[i.Motion]:6},t.basicDetectionClasses=[i.Vehicle,i.Person,i.Animal],t.defaultDetectionClasses=Object.values(i),t.animalClasses=[i.Animal,"dog_cat","dog","cat","horse","sheep","cow","elephant","bear","zebra","giraffe","mouse","rabbit","deer","lion","tiger","bird","eagle","owl","pigeon","fish","whale","dolphin","snake","turtle","lizard"],t.personClasses=[i.Person,"people","pedestrian","rider","driver","cyclist","skier","skateboarder","face","hand","head","body"],t.vehicleClasses=[i.Vehicle,"car","truck","bus","motorcycle","bicycle","van","ambulance","police_car","fire_truck","train","subway","tram","airplane","boat","ship","helicopter"],t.faceClasses=[i.Face,"eyes","nose","mouth","ears","eyebrows","left_eye","right_eye","pupil","iris","eyelid","eye_corner","upper_lip","lower_lip","teeth","chin","cheek","forehead","jaw","glasses","sunglasses","facial_hair","beard","mustache","facial_landmark","facial_keypoint"],t.licensePlateClasses=[i.Plate,"license_plate","front_plate","rear_plate","motorcycle_plate","temporary_plate","dealer_plate","licensePlate","plate_number","plate_character","plate_digit","plate_letter","plate_symbol","plate_region","plate_country_identifier","plate_frame","plate_bolt","plate_sticker","plate_validation_tag","damaged_plate","obscured_plate","dirty_plate"],t.motionClasses=[i.Motion,"movement","other"],t.packageClasses=[i.Package,"packet"],t.objectClasses=[i.AnyObject,"object"],t.audioClasses=[i.Audio,"speech","scream","babbling","yell","bellow","whoop","whispering","laughter","snicker","crying","sigh","singing","choir","sodeling","chant","mantra","child_singing","synthetic_singing","rapping","humming","groan","grunt","whistling","breathing","wheeze","snoring","gasp","pant","snort","cough","throat_clearing","sneeze","sniff","run","shuffle","footsteps","chewing","biting","gargling","stomach_rumble","burping","hiccup","fart","hands","finger_snapping","clapping","heartbeat","heart_murmur","cheering","applause","chatter","crowd","children_playing","pets","bark","yip","howl","bow-wow","growling","whimper_dog","purr","meow","hiss","caterwaul","livestock","clip-clop","neigh","cattle","moo","cowbell","pig","oink","goat","bleat","fowl","chicken","cluck","cock-a-doodle-doo","turkey","gobble","duck","quack","goose","honk","wild_animals","roaring_cats","roar","chird","chirp","squawk","coo","crow","caw","hoot","flapping_wings","dogs","rats","patter","insect","cricket","mosquito","fly","buzz","frog","croak","rattle","whale_vocalization","music","musical_instrument","plucked_string_instrument","guitar","electric_guitar","bass_guitar","acoustic_guitar","steel_guitar","tapping","strum","banjo","sitar","mandolin","zither","ukulele","keyboard","piano","electric_piano","organ","electronic_organ","hammond_organ","synthesizer","sampler","harpsichord","percussion","drum_kit","drum_machine","drum","snare_drum","rimshot","drum_roll","bass_drum","timpani","tabla","cymbal","hi-hat","wood_block","tambourine","maraca","gong","tubular_bells","mallet_percussion","marimba","glockenspiel","vibraphone","steelpan","orchestra","brass_instrument","french_horn","trumpet","trombone","bowed_string_instrument","string_section","violin","pizzicato","cello","double_bass","wind_instrument","flute","saxophone","clarinet","harp","bell","church_bell","jingle_bell","bicycle_bell","tuning_fork","chime","wind_chime","change_ringing","harmonica","accordion","bagpipes","didgeridoo","shofar","theremin","singing_bowl","scratching","pop_music","hip_hop_music","beatboxing","rock_music","heavy_metal","punk_rock","grunge","progressive_rock","rock_and_roll","psychedelic_rock","rhythm_and_blues","soul_music","reggae","country","swing_music","bluegrass","funk","folk_music","middle_eastern_music","jazz","disco","classical_music","opera","electronic_music","house_music","techno","dubstep","drum_and_bass","electronica","electronic_dance_music","ambient_music","trance_music","music_of_latin_america","salsa_music","flamenco","blues","music_for_children","new-age_music","vocal_music","a_capella","music_of_africa","afrobeat","christian_music","gospel_music","music_of_asia","carnatic_music","music_of_bollywood","ska","traditional_music","independent_music","song","background_music","theme_music","jingle","soundtrack_music","lullaby","video_game_music","christmas_music","dance_music","wedding_music","happy_music","sad_music","tender_music","exciting_music","angry_music","scary_music","wind","rustling_leaves","wind_noise","thunderstorm","thunder","water","rain","raindrop","rain_on_surface","stream","waterfall","ocean","waves","steam","gurgling","fire","crackle","sailboat","rowboat","motorboat","air_brake","air_horn","reversing_beeps","ice_cream_truck","aircraft_engine","jet_engine","propeller","fixed-wing_aircraft","engine","light_engine","dental_drill's_drill","lawn_mower","chainsaw","medium_engine","heavy_engine","engine_knocking","engine_starting","idling","accelerating","door","doorbell","ding-dong","sliding_door","slam","knock","tap","squeak","cupboard_open_or_close","drawer_open_or_close","dishes","cutlery","chopping","frying","microwave_oven","blender","water_tap","sink","bathtub","hair_dryer","toilet_flush","toothbrush","electric_toothbrush","vacuum_cleaner","zipper","keys_jangling","coin","scissors","electric_shaver","shuffling_cards","typing","typewriter","computer_keyboard","writing","alarm","telephone","telephone_bell_ringing","ringtone","telephone_dialing","dial_tone","busy_signal","alarm_clock","siren","civil_defense_siren","buzzer","smoke_detector","fire_alarm","foghorn","whistle","steam_whistle","mechanisms","ratchet","clock","tick","tick-tock","gears","pulleys","sewing_machine","mechanical_fan","air_conditioning","cash_register","printer","camera","single-lens_reflex_camera","tools","hammer","jackhammer","sawing","filing","sanding","power_tool","drill","explosion","gunshot","machine_gun","fusillade","artillery_fire","cap_gun","fireworks","firecracker","burst","eruption","boom","wood","chop","splinter","crack","glass","chink","shatter","liquid","splash","slosh","squish","drip","pour","trickle","gush","fill","spray","pump","stir","boiling","sonar","arrow","whoosh","thump","thunk","electronic_tuner","effects_unit","chorus_effect","basketball_bounce","bang","slap","whack","smash","breaking","bouncing","whip","flap","scratch","scrape","rub","roll","crushing","crumpling","tearing","beep","ping","ding","clang","squeal","creak","rustle","whir","clatter","sizzle","clicking","clickety-clack","rumble","plop","jingle","hum","zing","boing","crunch","silence","sine_wave","harmonic","chirp_tone","sound_effect","pulse","inside","outside","reverberation","echo","noise","environmental_noise","static","mains_hum","distortion","sidetone","cacophony","white_noise","pink_noise","throbbing","vibration","television","radio","field_recording"],t.doorbellClasses=[i.Doorbell,"ring"];t.isFaceClassname=e=>t.faceClasses.includes(e);t.isPlateClassname=e=>t.licensePlateClasses.includes(e);t.isAnimalClassname=e=>t.animalClasses.includes(e);t.isPersonClassname=e=>t.personClasses.includes(e);t.isVehicleClassname=e=>t.vehicleClasses.includes(e);t.isMotionClassname=e=>t.motionClasses.includes(e);t.isDoorbellClassname=e=>t.doorbellClasses.includes(e);t.isPackageClassname=e=>t.packageClasses.includes(e);t.isAudioClassname=e=>t.audioClasses.includes(e);t.isLabelDetection=e=>(0,t.isFaceClassname)(e)||(0,t.isPlateClassname)(e);t.isObjectClassname=e=>(0,t.isPackageClassname)(e)||(0,t.isAnimalClassname)(e)||(0,t.isPersonClassname)(e)||(0,t.isVehicleClassname)(e),t.detectionClassesDefaultMap={...t.animalClasses.reduce(((e,t)=>({...e,[t]:i.Animal})),{}),...t.personClasses.reduce(((e,t)=>({...e,[t]:i.Person})),{}),...t.vehicleClasses.reduce(((e,t)=>({...e,[t]:i.Vehicle})),{}),...t.motionClasses.reduce(((e,t)=>({...e,[t]:i.Motion})),{}),...t.packageClasses.reduce(((e,t)=>({...e,[t]:i.Package})),{}),...t.faceClasses.reduce(((e,t)=>({...e,[t]:i.Face})),{}),...t.licensePlateClasses.reduce(((e,t)=>({...e,[t]:i.Plate})),{}),...t.objectClasses.reduce(((e,t)=>({...e,[t]:i.AnyObject})),{}),...t.audioClasses.reduce(((e,t)=>({...e,[t]:i.Audio})),{}),...t.doorbellClasses.reduce(((e,t)=>({...e,[t]:i.Doorbell})),{})};t.getParentDetectionClass=e=>{const{className:n}=e,o={[i.Face]:i.Person,[i.Plate]:i.Vehicle},r=t.detectionClassesDefaultMap[n];return r&&r!==n?r:o[n]};const n=[["0","O","D"],["1","I"],["2","Z"],["4","A"],["5","S"],["8","B"],["6","G"],["A","4"],["C","G"],["E","F"]],o=new Map;for(const e of n)for(const t of e){o.has(t)||o.set(t,new Set);for(const i of e)o.get(t).add(i)}t.levenshteinDistance=(e,t)=>{e=e.toUpperCase(),t=t.toUpperCase();const i=e.length,n=t.length;if(0===i)return n;if(0===n)return i;let r=new Array(n+1),s=new Array(n+1);for(let e=0;e<=n;e++)r[e]=e;for(let l=1;l<=i;l++){s[0]=l;for(let i=1;i<=n;i++){let n=(a=e.charAt(l-1),c=t.charAt(i-1),a===c||o.get(a)?.has(c)?0:1);s[i]=Math.min(r[i]+1,s[i-1]+1,r[i-1]+n)}const i=r;r=s,s=i}var a,c;return r[n]}},5198:(e,t,i)=>{try{var n=i(9023);if("function"!=typeof n.inherits)throw"";e.exports=n.inherits}catch(t){e.exports=i(6029)}},5208:(e,t,i)=>{"use strict";const n=i(181),o=i(5899),r=i(4232);let s,a,c,l=!1;t.A=(e,t)=>{if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");const i="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";!function(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}(t);const p=function(e,t){const i="alis"===e.protocol?"wss":"ws";let n=`${i}://${e.hostname}${e.path}`;return e.port&&80!==e.port&&443!==e.port&&(n=`${i}://${e.hostname}:${e.port}${e.path}`),"function"==typeof e.transformWsUrl&&(n=e.transformWsUrl(n,e,t)),n}(t,e);return s=t.my,s.connectSocket({url:p,protocols:i}),a=function(){const e=new o.Transform;return e._write=(e,t,i)=>{s.sendSocketMessage({data:e.buffer,success(){i()},fail(){i(new Error)}})},e._flush=e=>{s.closeSocket({success(){e()}})},e}(),c=new r.BufferedDuplex(t,a,s),l||(l=!0,s.onSocketOpen((()=>{c.socketReady()})),s.onSocketMessage((e=>{if("string"==typeof e.data){const t=n.Buffer.from(e.data,"base64");a.push(t)}else{const t=new FileReader;t.addEventListener("load",(()=>{let e=t.result;e=e instanceof ArrayBuffer?n.Buffer.from(e):n.Buffer.from(e,"utf8"),a.push(e)})),t.readAsArrayBuffer(e.data)}})),s.onSocketClose((()=>{c.end(),c.destroy()})),s.onSocketError((e=>{c.destroy(e)}))),c}},5253:(e,t,i)=>{"use strict";const{ObjectSetPrototypeOf:n}=i(3383);e.exports=r;const o=i(39);function r(e){if(!(this instanceof r))return new r(e);o.call(this,e)}n(r.prototype,o.prototype),n(r,o),r.prototype._transform=function(e,t,i){i(null,e)}},5293:(e,t,i)=>{"use strict";const n=i(181),o=i(5899),r=i(4232);let s,a,c;t.A=(e,t)=>{if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");const i="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";!function(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}(t);const l=function(e,t){const i="wxs"===e.protocol?"wss":"ws";let n=`${i}://${e.hostname}${e.path}`;return e.port&&80!==e.port&&443!==e.port&&(n=`${i}://${e.hostname}:${e.port}${e.path}`),"function"==typeof e.transformWsUrl&&(n=e.transformWsUrl(n,e,t)),n}(t,e);s=wx.connectSocket({url:l,protocols:[i]}),a=function(){const e=new o.Transform;return e._write=(e,t,i)=>{s.send({data:e.buffer,success(){i()},fail(e){i(new Error(e))}})},e._flush=e=>{s.close({success(){e()}})},e}(),c=new r.BufferedDuplex(t,a,s),c._destroy=(e,t)=>{s.close({success(){t&&t(e)}})};const p=c.destroy;return c.destroy=(e,t)=>(c.destroy=p,setTimeout((()=>{s.close({fail(){c._destroy(e,t)}})}),0),c),s.onOpen((()=>{c.socketReady()})),s.onMessage((e=>{let{data:t}=e;t=t instanceof ArrayBuffer?n.Buffer.from(t):n.Buffer.from(t,"utf8"),a.push(t)})),s.onClose((()=>{c.emit("close"),c.end(),c.destroy()})),s.onError((e=>{const t=new Error(e.errMsg);c.destroy(t)})),c}},5311:function(e,t,i){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[t.length]=i);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i=n(e),s=0;s<i.length;s++)"default"!==i[s]&&o(t,e,i[s]);return r(t,e),t}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.OnvifIntercom=void 0;const c=i(4699),l=i(9280),p=i(8938),u=s(i(3861)),d=a(i(6982)),h=i(7225),m=i(3141),f=i(8338),{mediaManager:g}=u.default,v="www.onvif.org/ver20/backchannel";t.OnvifIntercom=class{constructor(e){this.camera=e}async checkIntercom(){const e=this.camera.storage.getItem("username"),t=this.camera.storage.getItem("password"),i=new URL(this.url);i.username=e,i.password=t;const n=this.intercomClient=new l.RtspClient(i.toString());n.console=this.camera.console,await n.options();const o=await n.describe({Require:v});this.camera.console.log("ONVIF Backchannel SDP:"),this.camera.console.log(o.body?.toString());const r=(0,p.parseSdp)(o.body.toString()).msections.find((e=>"audio"===e.type&&"sendonly"===e.direction));if(!r)throw new Error("ONVIF audio backchannel not found");return{audioBackchannel:r,intercomClient:n}}async startIntercom(e){const t=await g.convertMediaObjectToJSON(e,u.ScryptedMimeTypes.FFmpegInput);await this.stopIntercom();const{audioBackchannel:i,intercomClient:n}=await this.checkIntercom();if(!i)throw new Error("ONVIF audio backchannel not found");const o=await(0,c.createBindZero)("udp4"),r=o.port,s=r+1;let a,p,y,b=!1;try{const e={Require:v,Transport:`RTP/AVP;unicast;client_port=${r}-${s}`},t=await n.request("SETUP",e,i.control);y=(0,l.parseSemicolonDelimited)(t.headers.transport),n.session=t.headers.session.split(";")[0],a=this.camera.getIPAddress();const{server_port:o}=y,c=o.split("-");p=parseInt(c[0])}catch(e){b=!0,this.camera.console.error("onvif udp backchannel failed, falling back to tcp",e);const t={Require:v,Transport:"RTP/AVP/TCP;unicast;interleaved=0-1"},o=await n.request("SETUP",t,i.control);y=(0,l.parseSemicolonDelimited)(o.headers.transport),n.session=o.headers.session.split(";")[0],a="127.0.0.1";const r=await(0,c.createBindZero)("udp4");n.client.on("close",(()=>r.server.close())),p=r.port,r.server.on("message",(e=>{n.send(e,0)}))}this.camera.console.log("backchannel transport",y);const w=i.rtpmaps.filter((e=>e.ffmpegEncoder)),_=i.rtpmaps.find((e=>"pcm_mulaw"===e.ffmpegEncoder))||i.rtpmaps.find((e=>e.ffmpegEncoder));if(!_)throw new Error("no supported codec was found for back channel");let S;S=y.ssrc?Buffer.from(y.ssrc,"hex"):d.default.randomBytes(4);const x=S.readInt32BE(0),T=S.readUint32BE(0);let E,{payloadType:C}=_;await n.play({Require:v});let P=0;const k=await(0,f.startRtpForwarderProcess)(this.camera.console,t,{audio:{negotiate:async e=>{const t=e.rtpmap,i=t.channels||1;return!!w.find((e=>t.codec===e.codec&&(i===(e.channels||1)&&(t.clock===e.clock&&(C=t.payloadType,void 0===C&&(C=8),!0)))))},onRtp:e=>{const t=h.RtpPacket.deSerialize(e);if(!E)return void(E=t);Math.abs(E.header.timestamp-t.header.timestamp)/8e3*1e3<=160&&E.payload.length+t.payload.length<=1024?E.payload=Buffer.concat([E.payload,t.payload]):(E.header.payloadType=C,E.header.ssrc=T,E.header.sequenceNumber=P,P=(0,m.nextSequenceNumber)(P),E.header.marker=!0,b?n.send(E.serialize(),0):o.server.send(E.serialize(),p,a),E=t)},codecCopy:"ffmpeg",payloadType:C,ssrc:x,packetSize:1024,encoderArguments:["-acodec",_.ffmpegEncoder,"-ar",_.clock.toString(),"-b:a","64k","-ac",_.channels?.toString()||"1"]}});n.client.on("close",(()=>k.kill())),k.killPromise.finally((()=>n.safeTeardown())),this.camera.console.log("intercom playing")}async stopIntercom(){this.intercomClient?.safeTeardown(),this.intercomClient=void 0}}},5317:e=>{"use strict";e.exports=require("child_process")},5329:(e,t,i)=>{e.exports=function(e){function t(e){let i,o,r,s=null;function a(...e){if(!a.enabled)return;const n=a,o=Number(new Date),r=o-(i||o);n.diff=r,n.prev=i,n.curr=o,i=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((i,o)=>{if("%%"===i)return"%";s++;const r=t.formatters[o];if("function"==typeof r){const t=e[s];i=r.call(n,t),e.splice(s,1),s--}return i})),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(o!==t.namespaces&&(o=t.namespaces,r=t.enabled(e)),r),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,i){const n=t(this.namespace+("undefined"==typeof i?":":i)+e);return n.log=this.log,n}function o(e,t){let i=0,n=0,o=-1,r=0;for(;i<e.length;)if(n<t.length&&(t[n]===e[i]||"*"===t[n]))"*"===t[n]?(o=n,r=i,n++):(i++,n++);else{if(-1===o)return!1;n=o+1,r++,i=r}for(;n<t.length&&"*"===t[n];)n++;return n===t.length}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names,...t.skips.map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const i=("string"==typeof e?e:"").trim().replace(" ",",").split(",").filter(Boolean);for(const e of i)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const i of t.skips)if(o(e,i))return!1;for(const i of t.names)if(o(e,i))return!0;return!1},t.humanize=i(4808),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((i=>{t[i]=e[i]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let i=0;for(let t=0;t<e.length;t++)i=(i<<5)-i+e.charCodeAt(t),i|=0;return t.colors[Math.abs(i)%t.colors.length]},t.enable(t.load()),t}},5336:(e,t,i)=>{t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const i="color: "+this.color;t.splice(1,0,i,"color: inherit");let n=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(o=n))})),t.splice(o,0,i)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=i(5175)(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},5337:(e,t,i)=>{e.exports=function(e){function t(e){let i,o,r,s=null;function a(...e){if(!a.enabled)return;const n=a,o=Number(new Date),r=o-(i||o);n.diff=r,n.prev=i,n.curr=o,i=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((i,o)=>{if("%%"===i)return"%";s++;const r=t.formatters[o];if("function"==typeof r){const t=e[s];i=r.call(n,t),e.splice(s,1),s--}return i})),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(o!==t.namespaces&&(o=t.namespaces,r=t.enabled(e)),r),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,i){const n=t(this.namespace+("undefined"==typeof i?":":i)+e);return n.log=this.log,n}function o(e,t){let i=0,n=0,o=-1,r=0;for(;i<e.length;)if(n<t.length&&(t[n]===e[i]||"*"===t[n]))"*"===t[n]?(o=n,r=i,n++):(i++,n++);else{if(-1===o)return!1;n=o+1,r++,i=r}for(;n<t.length&&"*"===t[n];)n++;return n===t.length}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names,...t.skips.map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const i=("string"==typeof e?e:"").trim().replace(" ",",").split(",").filter(Boolean);for(const e of i)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const i of t.skips)if(o(e,i))return!1;for(const i of t.names)if(o(e,i))return!0;return!1},t.humanize=i(3024),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((i=>{t[i]=e[i]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let i=0;for(let t=0;t<e.length;t++)i=(i<<5)-i+e.charCodeAt(t),i|=0;return t.colors[Math.abs(i)%t.colors.length]},t.enable(t.load()),t}},5425:function(e,t,i){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[t.length]=i);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i=n(e),s=0;s<i.length;s++)"default"!==i[s]&&o(t,e,i[s]);return r(t,e),t}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.videoclipsNativeId=t.REOLINK_HUB_VIDEOCLIPS_INTERFACE=t.pluginId=void 0;const c=s(i(3861)),l=i(3540),p=a(i(9896)),u=a(i(8611)),d=i(8705),h=i(2122),m=i(5629),f=i(8330),g=i(9151),v=i(6357),y=a(i(7658));t.pluginId=f.name,t.REOLINK_HUB_VIDEOCLIPS_INTERFACE=`${t.pluginId}:videoclips`,t.videoclipsNativeId="reolinkHubVideoclips";class b extends m.RtspProvider{constructor(){super(),this.processing=!1,this.storageSettings=new l.StorageSettings(this,{logLevel:{...d.logLevelSetting},address:{title:"HUB IP",type:"string"},username:{title:"Username",placeholder:"admin",defaultValue:"admin",type:"string"},password:{title:"Password",type:"password"},port:{title:"HTTP Port",subgroup:"Advanced",defaultValue:80,placeholder:"80",type:"number"},rtspPort:{subgroup:"Advanced",title:"RTSP Port",placeholder:"554",defaultValue:554,type:"number"},downloadFolder:{title:"Directory where to cache thumbnails and videoclips",description:"Default to the plugin folder",type:"string",group:"Videoclips"},clearDownloadedData:{title:"clear stored data",type:"button",group:"Videoclips",onPut:async()=>(0,h.cleanup)(this.storageSettings.values.downloadFolder)},abilities:{json:!0,hide:!0,defaultValue:{}},devicesData:{json:!0,hide:!0,defaultValue:{}},hubData:{json:!0,hide:!0,defaultValue:{}}}),this.lastHubInfoCheck=void 0,this.lastErrorsCheck=Date.now(),this.lastDevicesStatusCheck=Date.now(),this.cameraChannelMap=new Map;const e=this.getLogger();this.init().catch(e.error)}getLogger(){return(0,d.getBaseLogger)({console:this.console,storage:this.storageSettings})}async reboot(){const e=this.getClient();e&&await e.reboot()}async init(){const e=this.getClient();await e.login();const i=this.getLogger();setInterval((async()=>{if(!this.processing){this.processing=!0;try{const e=Date.now(),t=this.getClient();if(e-this.lastErrorsCheck>6e4&&(this.lastErrorsCheck=e,await t.checkErrors()),!this.lastHubInfoCheck||e-this.lastHubInfoCheck>3e5){this.lastHubInfoCheck=e;const{abilities:n,hubData:o}=await t.getHubInfo(),{devicesData:r,channelsResponse:s,response:a}=await t.getDevicesInfo();i.log("Hub info data fetched"),i.info(`${JSON.stringify({abilities:n,hubData:o,devicesData:r,channelsResponse:s,response:a})}`),this.storageSettings.values.abilities=n,this.storageSettings.values.hubData=o,this.storageSettings.values.devicesData=r}const n=new Map;let o=!1,r=!1,s=!1;if(this.cameraChannelMap.forEach((e=>{if(e){s=!0;const t=e.storageSettings.values.rtspChannel;if(e.getAbilities()){const i=e.hasBattery(),s=e.hasPirEvents(),a=e.hasFloodlight(),c=e.sleeping,{hasPtz:l}=e.getPtzCapabilities();n.set(Number(t),{hasFloodlight:a,hasBattery:i,hasPirEvents:s,hasPtz:l,sleeping:c}),i&&!o&&(o=!0),c||r||(r=!0)}}})),s){const e=await t.getEvents(n);i.debug(`Events call result: ${JSON.stringify(e)}`),this.cameraChannelMap.forEach((t=>{if(t){const i=t.storageSettings.values.rtspChannel,n=e?.parsed[i];n&&t.processEvents(n)}}))}if(o){const{batteryInfoData:e,response:o}=await t.getBatteryInfo(n);i.debug(`Battery info call result: ${JSON.stringify({batteryInfoData:e,response:o})}`),this.cameraChannelMap.forEach((t=>{if(t){const i=t.storageSettings.values.rtspChannel,n=e[i];n&&t.processBatteryData(n)}}))}if(e-this.lastDevicesStatusCheck>15e3&&r){this.lastDevicesStatusCheck=e;const{deviceStatusData:o,response:r}=await t.getStatusInfo(n);i.info(`Status info call result: ${JSON.stringify({deviceStatusData:o,response:r})}`),this.cameraChannelMap.forEach((e=>{if(e){const t=e.storageSettings.values.rtspChannel,i=o[t];i&&e.processDeviceStatusData(i)}}))}}catch(e){this.getLogger().error("Error on events flow",e)}finally{this.processing=!1}}}),1e3),await c.default.deviceManager.onDeviceDiscovered({name:"Reolink HUB Videoclips",nativeId:t.videoclipsNativeId,interfaces:[c.ScryptedInterface.MixinProvider,c.ScryptedInterface.Settings],type:c.ScryptedDeviceType.API})}async onRequest(e,t){const i=new URL(`http://localhost${e.url}`),n=i.searchParams.get("params")??"{}",o=this.getLogger();try{const[o,r,s,a,l,d]=i.pathname.split("/"),{nativeId:h,videoclipPath:m}=JSON.parse(n),f=this.devices.get(h).id,g=this.videoclipsDevice.currentMixinsMap[f],v=g.getLogger(),y=c.default.systemManager.getDeviceById(f);try{if("videoclip"===d){if(g.storageSettings.values.ftp){const i=p.default.statSync(m).size,n=e.headers.range;if(n){const e=n.replace(/bytes=/,"").split("-"),o=parseInt(e[0],10),r=e[1]?parseInt(e[1],10):i-1,s=r-o+1,a=p.default.createReadStream(m,{start:o,end:r}),c=async()=>new Promise(((e,n)=>{try{t.sendStream(async function*(){for await(const e of a)yield e}(),{code:206,headers:{"Content-Range":`bytes ${o}-${r}/${i}`,"Accept-Ranges":"bytes","Content-Length":s,"Content-Type":"video/mp4"}}),e()}catch(e){n(e)}}));try{return void await c()}catch(e){v.error("Error fetching videoclip",e)}}else t.sendFile(m,{code:200,headers:{"Content-Length":i,"Content-Type":"video/mp4"}});return}{const i=this.getClient(),{downloadPathWithHost:n}=await i.getVideoClipUrl(m,f),o=async()=>new Promise(((i,o)=>{u.default.get(n,{headers:e.headers},(n=>{if(400!==n.statusCode[0])try{t.sendStream(async function*(){for await(const e of n)yield e}(),{headers:n.headers}),i()}catch(e){o(e)}else o(new Error(`Error loading the video: ${n.statusCode} - ${n.statusMessage}. Headers: ${JSON.stringify(e.headers)}`))})).on("error",(e=>{v.error("Error fetching videoclip",e),o(e)}))}));try{return void await o()}catch(e){v.error("Error fetching videoclip",e)}}}else if("thumbnail"===d){v.info(`Thumbnail requested: ${JSON.stringify({videoclipPath:m,deviceId:f})}`);const e=await y.getVideoClipThumbnail(m);if(e){const i=await c.default.mediaManager.convertMediaObjectToBuffer(e,"image/jpeg");return void t.send(i,{headers:{"Content-Type":"image/jpeg"}})}return void t.send("",{headers:{"Content-Type":"image/jpeg"}})}}catch(e){return v.error("Error in webhook",e),void t.send(`${JSON.stringify(e)}, ${e.message}`,{code:400})}return void t.send(`Webhook not found: ${i.pathname}`,{code:404})}catch(i){o.error("Error in data parsing for webhook",i),t.send(`Error in data parsing for webhook: ${JSON.stringify({params:n,url:e.url})}`,{code:500})}}async getSettings(){return await this.storageSettings.getSettings()}async putSetting(e,t){return this.client=void 0,this.storageSettings.putSetting(e,t)}getHttpAddress(){const{address:e,port:t}=this.storageSettings.values;return`${e}:${t}`}getClient(){if(!this.client){const{password:e,username:t}=this.storageSettings.values;this.client=new v.ReolinkHubClient(this.getHttpAddress(),t,e,this.getLogger())}return this.client}getScryptedDeviceCreator(){return"Reolink HUB Camera"}getAdditionalInterfaces(){return[c.ScryptedInterface.VideoCameraConfiguration,c.ScryptedInterface.Camera,c.ScryptedInterface.MotionSensor,c.ScryptedInterface.VideoTextOverlays,c.ScryptedInterface.MixinProvider,t.pluginId]}async getDevice(e){return e===t.videoclipsNativeId?this.videoclipsDevice||=new y.default(t.videoclipsNativeId,this):super.getDevice(e)}async createDevice(e,t){const i=parseInt(e.rtspChannel?.toString())||0,n=this.getClient();try{await n.jpegSnapshot(i)}catch(e){throw this.getLogger().error("Error adding Reolink camera",e),e}const o=this.storageSettings.values.devicesData[i]?.channelStatus?.name;e.newCamera||=o??"Reolink Camera",t=await super.createDevice(e,t);const r=await this.getDevice(t);return r.info={},r.storageSettings.values.rtspChannel=i,r.updateDeviceInfo(),this.cameraChannelMap.set(String(i),r),t}async releaseDevice(e,t){this.cameraChannelMap.delete(e),this.devices.delete(e)}async getCreateDeviceSettings(){return[{key:"rtspChannel",title:"Channel Number Override",description:"The channel number to use for snapshots and video. E.g., 0, 1, 2, etc.",placeholder:"0",type:"number"}]}createCamera(e){try{return new g.ReolinkCamera(e,this)}catch(t){this.getLogger().error("Error creating device",e,t)}}}t.default=b},5502:function(e){(function(){var t,i,n,o,r,s,a,c=[].slice,l={}.hasOwnProperty;t=function(){var e,t,i,n,o,s;if(s=arguments[0],o=2<=arguments.length?c.call(arguments,1):[],r(Object.assign))Object.assign.apply(null,arguments);else for(e=0,i=o.length;e<i;e++)if(null!=(n=o[e]))for(t in n)l.call(n,t)&&(s[t]=n[t]);return s},r=function(e){return!!e&&"[object Function]"===Object.prototype.toString.call(e)},s=function(e){var t;return!!e&&("function"==(t=typeof e)||"object"===t)},n=function(e){return r(Array.isArray)?Array.isArray(e):"[object Array]"===Object.prototype.toString.call(e)},o=function(e){var t;if(n(e))return!e.length;for(t in e)if(l.call(e,t))return!1;return!0},a=function(e){var t,i;return s(e)&&(i=Object.getPrototypeOf(e))&&(t=i.constructor)&&"function"==typeof t&&t instanceof t&&Function.prototype.toString.call(t)===Function.prototype.toString.call(Object)},i=function(e){return r(e.valueOf)?e.valueOf():e},e.exports.assign=t,e.exports.isFunction=r,e.exports.isObject=s,e.exports.isArray=n,e.exports.isEmpty=o,e.exports.isPlainObject=a,e.exports.getValue=i}).call(this)},5520:e=>{function t(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}t.keys=()=>[],t.resolve=t,t.id=5520,e.exports=t},5556:(e,t,i)=>{var n=i(320);e.exports=function(e){var t=!1;return n((function(){t=!0})),function(i,o){t?e(i,o):n((function(){e(i,o)}))}}},5611:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LRUCache=void 0;const i="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,n=new Set,o="object"==typeof process&&process?process:{},r=(e,t,i,n)=>{"function"==typeof o.emitWarning?o.emitWarning(e,t,i,n):console.error(`[${i}] ${t}: ${e}`)};let s=globalThis.AbortController,a=globalThis.AbortSignal;if("undefined"==typeof s){a=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(e,t){this._onabort.push(t)}},s=class{constructor(){t()}signal=new a;abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=!0;for(const t of this.signal._onabort)t(e);this.signal.onabort?.(e)}}};let e="1"!==o.env?.LRU_CACHE_IGNORE_AC_WARNING;const t=()=>{e&&(e=!1,r("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}Symbol("type");const c=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),l=e=>c(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?p:null:null;class p extends Array{constructor(e){super(e),this.fill(0)}}class u{heap;length;static#e=!1;static create(e){const t=l(e);if(!t)return[];u.#e=!0;const i=new u(e,t);return u.#e=!1,i}constructor(e,t){if(!u.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}}class d{#t;#i;#n;#o;#r;#s;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#c;#l;#p;#u;#d;#h;#m;#f;#g;#v;#y;#b;#w;#_;#S;#x;static unsafeExposeInternals(e){return{starts:e.#b,ttls:e.#w,sizes:e.#y,keyMap:e.#l,keyList:e.#p,valList:e.#u,next:e.#d,prev:e.#h,get head(){return e.#m},get tail(){return e.#f},free:e.#g,isBackgroundFetch:t=>e.#T(t),backgroundFetch:(t,i,n,o)=>e.#E(t,i,n,o),moveToTail:t=>e.#C(t),indexes:t=>e.#P(t),rindexes:t=>e.#k(t),isStale:t=>e.#O(t)}}get max(){return this.#t}get maxSize(){return this.#i}get calculatedSize(){return this.#c}get size(){return this.#a}get fetchMethod(){return this.#r}get memoMethod(){return this.#s}get dispose(){return this.#n}get disposeAfter(){return this.#o}constructor(e){const{max:t=0,ttl:i,ttlResolution:o=1,ttlAutopurge:s,updateAgeOnGet:a,updateAgeOnHas:p,allowStale:h,dispose:m,disposeAfter:f,noDisposeOnSet:g,noUpdateTTL:v,maxSize:y=0,maxEntrySize:b=0,sizeCalculation:w,fetchMethod:_,memoMethod:S,noDeleteOnFetchRejection:x,noDeleteOnStaleGet:T,allowStaleOnFetchRejection:E,allowStaleOnFetchAbort:C,ignoreFetchAbort:P}=e;if(0!==t&&!c(t))throw new TypeError("max option must be a nonnegative integer");const k=t?l(t):Array;if(!k)throw new Error("invalid max value: "+t);if(this.#t=t,this.#i=y,this.maxEntrySize=b||this.#i,this.sizeCalculation=w,this.sizeCalculation){if(!this.#i&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==S&&"function"!=typeof S)throw new TypeError("memoMethod must be a function if defined");if(this.#s=S,void 0!==_&&"function"!=typeof _)throw new TypeError("fetchMethod must be a function if specified");if(this.#r=_,this.#S=!!_,this.#l=new Map,this.#p=new Array(t).fill(void 0),this.#u=new Array(t).fill(void 0),this.#d=new k(t),this.#h=new k(t),this.#m=0,this.#f=0,this.#g=u.create(t),this.#a=0,this.#c=0,"function"==typeof m&&(this.#n=m),"function"==typeof f?(this.#o=f,this.#v=[]):(this.#o=void 0,this.#v=void 0),this.#_=!!this.#n,this.#x=!!this.#o,this.noDisposeOnSet=!!g,this.noUpdateTTL=!!v,this.noDeleteOnFetchRejection=!!x,this.allowStaleOnFetchRejection=!!E,this.allowStaleOnFetchAbort=!!C,this.ignoreFetchAbort=!!P,0!==this.maxEntrySize){if(0!==this.#i&&!c(this.#i))throw new TypeError("maxSize must be a positive integer if specified");if(!c(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#I()}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!T,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!p,this.ttlResolution=c(o)||0===o?o:1,this.ttlAutopurge=!!s,this.ttl=i||0,this.ttl){if(!c(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#A()}if(0===this.#t&&0===this.ttl&&0===this.#i)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#i){const e="LRU_CACHE_UNBOUNDED";if((e=>!n.has(e))(e)){n.add(e);r("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",e,d)}}}getRemainingTTL(e){return this.#l.has(e)?1/0:0}#A(){const e=new p(this.#t),t=new p(this.#t);this.#w=e,this.#b=t,this.#R=(n,o,r=i.now())=>{if(t[n]=0!==o?r:0,e[n]=o,0!==o&&this.ttlAutopurge){const e=setTimeout((()=>{this.#O(n)&&this.#D(this.#p[n],"expire")}),o+1);e.unref&&e.unref()}},this.#M=n=>{t[n]=0!==e[n]?i.now():0},this.#N=(i,r)=>{if(e[r]){const s=e[r],a=t[r];if(!s||!a)return;i.ttl=s,i.start=a,i.now=n||o();const c=i.now-a;i.remainingTTL=s-c}};let n=0;const o=()=>{const e=i.now();if(this.ttlResolution>0){n=e;const t=setTimeout((()=>n=0),this.ttlResolution);t.unref&&t.unref()}return e};this.getRemainingTTL=i=>{const r=this.#l.get(i);if(void 0===r)return 0;const s=e[r],a=t[r];if(!s||!a)return 1/0;return s-((n||o())-a)},this.#O=i=>{const r=t[i],s=e[i];return!!s&&!!r&&(n||o())-r>s}}#M=()=>{};#N=()=>{};#R=()=>{};#O=()=>!1;#I(){const e=new p(this.#t);this.#c=0,this.#y=e,this.#L=t=>{this.#c-=e[t],e[t]=0},this.#j=(e,t,i,n)=>{if(this.#T(t))return 0;if(!c(i)){if(!n)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof n)throw new TypeError("sizeCalculation must be a function");if(i=n(t,e),!c(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return i},this.#F=(t,i,n)=>{if(e[t]=i,this.#i){const i=this.#i-e[t];for(;this.#c>i;)this.#B(!0)}this.#c+=e[t],n&&(n.entrySize=i,n.totalCalculatedSize=this.#c)}}#L=e=>{};#F=(e,t,i)=>{};#j=(e,t,i,n)=>{if(i||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#P({allowStale:e=this.allowStale}={}){if(this.#a)for(let t=this.#f;this.#U(t)&&(!e&&this.#O(t)||(yield t),t!==this.#m);)t=this.#h[t]}*#k({allowStale:e=this.allowStale}={}){if(this.#a)for(let t=this.#m;this.#U(t)&&(!e&&this.#O(t)||(yield t),t!==this.#f);)t=this.#d[t]}#U(e){return void 0!==e&&this.#l.get(this.#p[e])===e}*entries(){for(const e of this.#P())void 0===this.#u[e]||void 0===this.#p[e]||this.#T(this.#u[e])||(yield[this.#p[e],this.#u[e]])}*rentries(){for(const e of this.#k())void 0===this.#u[e]||void 0===this.#p[e]||this.#T(this.#u[e])||(yield[this.#p[e],this.#u[e]])}*keys(){for(const e of this.#P()){const t=this.#p[e];void 0===t||this.#T(this.#u[e])||(yield t)}}*rkeys(){for(const e of this.#k()){const t=this.#p[e];void 0===t||this.#T(this.#u[e])||(yield t)}}*values(){for(const e of this.#P()){void 0===this.#u[e]||this.#T(this.#u[e])||(yield this.#u[e])}}*rvalues(){for(const e of this.#k()){void 0===this.#u[e]||this.#T(this.#u[e])||(yield this.#u[e])}}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(const i of this.#P()){const n=this.#u[i],o=this.#T(n)?n.__staleWhileFetching:n;if(void 0!==o&&e(o,this.#p[i],this))return this.get(this.#p[i],t)}}forEach(e,t=this){for(const i of this.#P()){const n=this.#u[i],o=this.#T(n)?n.__staleWhileFetching:n;void 0!==o&&e.call(t,o,this.#p[i],this)}}rforEach(e,t=this){for(const i of this.#k()){const n=this.#u[i],o=this.#T(n)?n.__staleWhileFetching:n;void 0!==o&&e.call(t,o,this.#p[i],this)}}purgeStale(){let e=!1;for(const t of this.#k({allowStale:!0}))this.#O(t)&&(this.#D(this.#p[t],"expire"),e=!0);return e}info(e){const t=this.#l.get(e);if(void 0===t)return;const n=this.#u[t],o=this.#T(n)?n.__staleWhileFetching:n;if(void 0===o)return;const r={value:o};if(this.#w&&this.#b){const e=this.#w[t],n=this.#b[t];if(e&&n){const t=e-(i.now()-n);r.ttl=t,r.start=Date.now()}}return this.#y&&(r.size=this.#y[t]),r}dump(){const e=[];for(const t of this.#P({allowStale:!0})){const n=this.#p[t],o=this.#u[t],r=this.#T(o)?o.__staleWhileFetching:o;if(void 0===r||void 0===n)continue;const s={value:r};if(this.#w&&this.#b){s.ttl=this.#w[t];const e=i.now()-this.#b[t];s.start=Math.floor(Date.now()-e)}this.#y&&(s.size=this.#y[t]),e.unshift([n,s])}return e}load(e){this.clear();for(const[t,n]of e){if(n.start){const e=Date.now()-n.start;n.start=i.now()-e}this.set(t,n.value,n)}}set(e,t,i={}){if(void 0===t)return this.delete(e),this;const{ttl:n=this.ttl,start:o,noDisposeOnSet:r=this.noDisposeOnSet,sizeCalculation:s=this.sizeCalculation,status:a}=i;let{noUpdateTTL:c=this.noUpdateTTL}=i;const l=this.#j(e,t,i.size||0,s);if(this.maxEntrySize&&l>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#D(e,"set"),this;let p=0===this.#a?void 0:this.#l.get(e);if(void 0===p)p=0===this.#a?this.#f:0!==this.#g.length?this.#g.pop():this.#a===this.#t?this.#B(!1):this.#a,this.#p[p]=e,this.#u[p]=t,this.#l.set(e,p),this.#d[this.#f]=p,this.#h[p]=this.#f,this.#f=p,this.#a++,this.#F(p,l,a),a&&(a.set="add"),c=!1;else{this.#C(p);const i=this.#u[p];if(t!==i){if(this.#S&&this.#T(i)){i.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:t}=i;void 0===t||r||(this.#_&&this.#n?.(t,e,"set"),this.#x&&this.#v?.push([t,e,"set"]))}else r||(this.#_&&this.#n?.(i,e,"set"),this.#x&&this.#v?.push([i,e,"set"]));if(this.#L(p),this.#F(p,l,a),this.#u[p]=t,a){a.set="replace";const e=i&&this.#T(i)?i.__staleWhileFetching:i;void 0!==e&&(a.oldValue=e)}}else a&&(a.set="update")}if(0===n||this.#w||this.#A(),this.#w&&(c||this.#R(p,n,o),a&&this.#N(a,p)),!r&&this.#x&&this.#v){const e=this.#v;let t;for(;t=e?.shift();)this.#o?.(...t)}return this}pop(){try{for(;this.#a;){const e=this.#u[this.#m];if(this.#B(!0),this.#T(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(void 0!==e)return e}}finally{if(this.#x&&this.#v){const e=this.#v;let t;for(;t=e?.shift();)this.#o?.(...t)}}}#B(e){const t=this.#m,i=this.#p[t],n=this.#u[t];return this.#S&&this.#T(n)?n.__abortController.abort(new Error("evicted")):(this.#_||this.#x)&&(this.#_&&this.#n?.(n,i,"evict"),this.#x&&this.#v?.push([n,i,"evict"])),this.#L(t),e&&(this.#p[t]=void 0,this.#u[t]=void 0,this.#g.push(t)),1===this.#a?(this.#m=this.#f=0,this.#g.length=0):this.#m=this.#d[t],this.#l.delete(i),this.#a--,t}has(e,t={}){const{updateAgeOnHas:i=this.updateAgeOnHas,status:n}=t,o=this.#l.get(e);if(void 0!==o){const e=this.#u[o];if(this.#T(e)&&void 0===e.__staleWhileFetching)return!1;if(!this.#O(o))return i&&this.#M(o),n&&(n.has="hit",this.#N(n,o)),!0;n&&(n.has="stale",this.#N(n,o))}else n&&(n.has="miss");return!1}peek(e,t={}){const{allowStale:i=this.allowStale}=t,n=this.#l.get(e);if(void 0===n||!i&&this.#O(n))return;const o=this.#u[n];return this.#T(o)?o.__staleWhileFetching:o}#E(e,t,i,n){const o=void 0===t?void 0:this.#u[t];if(this.#T(o))return o;const r=new s,{signal:a}=i;a?.addEventListener("abort",(()=>r.abort(a.reason)),{signal:r.signal});const c={signal:r.signal,options:i,context:n},l=(n,o=!1)=>{const{aborted:s}=r.signal,a=i.ignoreFetchAbort&&void 0!==n;if(i.status&&(s&&!o?(i.status.fetchAborted=!0,i.status.fetchError=r.signal.reason,a&&(i.status.fetchAbortIgnored=!0)):i.status.fetchResolved=!0),s&&!a&&!o)return p(r.signal.reason);const l=u;return this.#u[t]===u&&(void 0===n?l.__staleWhileFetching?this.#u[t]=l.__staleWhileFetching:this.#D(e,"fetch"):(i.status&&(i.status.fetchUpdated=!0),this.set(e,n,c.options))),n},p=n=>{const{aborted:o}=r.signal,s=o&&i.allowStaleOnFetchAbort,a=s||i.allowStaleOnFetchRejection,c=a||i.noDeleteOnFetchRejection,l=u;if(this.#u[t]===u){!c||void 0===l.__staleWhileFetching?this.#D(e,"fetch"):s||(this.#u[t]=l.__staleWhileFetching)}if(a)return i.status&&void 0!==l.__staleWhileFetching&&(i.status.returnedStale=!0),l.__staleWhileFetching;if(l.__returned===l)throw n};i.status&&(i.status.fetchDispatched=!0);const u=new Promise(((t,n)=>{const s=this.#r?.(e,o,c);s&&s instanceof Promise&&s.then((e=>t(void 0===e?void 0:e)),n),r.signal.addEventListener("abort",(()=>{i.ignoreFetchAbort&&!i.allowStaleOnFetchAbort||(t(void 0),i.allowStaleOnFetchAbort&&(t=e=>l(e,!0)))}))})).then(l,(e=>(i.status&&(i.status.fetchRejected=!0,i.status.fetchError=e),p(e)))),d=Object.assign(u,{__abortController:r,__staleWhileFetching:o,__returned:void 0});return void 0===t?(this.set(e,d,{...c.options,status:void 0}),t=this.#l.get(e)):this.#u[t]=d,d}#T(e){if(!this.#S)return!1;const t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof s}async fetch(e,t={}){const{allowStale:i=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:r=this.ttl,noDisposeOnSet:s=this.noDisposeOnSet,size:a=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:l=this.noUpdateTTL,noDeleteOnFetchRejection:p=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:u=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:h=this.allowStaleOnFetchAbort,context:m,forceRefresh:f=!1,status:g,signal:v}=t;if(!this.#S)return g&&(g.fetch="get"),this.get(e,{allowStale:i,updateAgeOnGet:n,noDeleteOnStaleGet:o,status:g});const y={allowStale:i,updateAgeOnGet:n,noDeleteOnStaleGet:o,ttl:r,noDisposeOnSet:s,size:a,sizeCalculation:c,noUpdateTTL:l,noDeleteOnFetchRejection:p,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:h,ignoreFetchAbort:d,status:g,signal:v};let b=this.#l.get(e);if(void 0===b){g&&(g.fetch="miss");const t=this.#E(e,b,y,m);return t.__returned=t}{const t=this.#u[b];if(this.#T(t)){const e=i&&void 0!==t.__staleWhileFetching;return g&&(g.fetch="inflight",e&&(g.returnedStale=!0)),e?t.__staleWhileFetching:t.__returned=t}const o=this.#O(b);if(!f&&!o)return g&&(g.fetch="hit"),this.#C(b),n&&this.#M(b),g&&this.#N(g,b),t;const r=this.#E(e,b,y,m),s=void 0!==r.__staleWhileFetching&&i;return g&&(g.fetch=o?"stale":"refresh",s&&o&&(g.returnedStale=!0)),s?r.__staleWhileFetching:r.__returned=r}}async forceFetch(e,t={}){const i=await this.fetch(e,t);if(void 0===i)throw new Error("fetch() returned undefined");return i}memo(e,t={}){const i=this.#s;if(!i)throw new Error("no memoMethod provided to constructor");const{context:n,forceRefresh:o,...r}=t,s=this.get(e,r);if(!o&&void 0!==s)return s;const a=i(e,s,{options:r,context:n});return this.set(e,a,r),a}get(e,t={}){const{allowStale:i=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:r}=t,s=this.#l.get(e);if(void 0!==s){const t=this.#u[s],a=this.#T(t);return r&&this.#N(r,s),this.#O(s)?(r&&(r.get="stale"),a?(r&&i&&void 0!==t.__staleWhileFetching&&(r.returnedStale=!0),i?t.__staleWhileFetching:void 0):(o||this.#D(e,"expire"),r&&i&&(r.returnedStale=!0),i?t:void 0)):(r&&(r.get="hit"),a?t.__staleWhileFetching:(this.#C(s),n&&this.#M(s),t))}r&&(r.get="miss")}#q(e,t){this.#h[t]=e,this.#d[e]=t}#C(e){e!==this.#f&&(e===this.#m?this.#m=this.#d[e]:this.#q(this.#h[e],this.#d[e]),this.#q(this.#f,e),this.#f=e)}delete(e){return this.#D(e,"delete")}#D(e,t){let i=!1;if(0!==this.#a){const n=this.#l.get(e);if(void 0!==n)if(i=!0,1===this.#a)this.#V(t);else{this.#L(n);const i=this.#u[n];if(this.#T(i)?i.__abortController.abort(new Error("deleted")):(this.#_||this.#x)&&(this.#_&&this.#n?.(i,e,t),this.#x&&this.#v?.push([i,e,t])),this.#l.delete(e),this.#p[n]=void 0,this.#u[n]=void 0,n===this.#f)this.#f=this.#h[n];else if(n===this.#m)this.#m=this.#d[n];else{const e=this.#h[n];this.#d[e]=this.#d[n];const t=this.#d[n];this.#h[t]=this.#h[n]}this.#a--,this.#g.push(n)}}if(this.#x&&this.#v?.length){const e=this.#v;let t;for(;t=e?.shift();)this.#o?.(...t)}return i}clear(){return this.#V("delete")}#V(e){for(const t of this.#k({allowStale:!0})){const i=this.#u[t];if(this.#T(i))i.__abortController.abort(new Error("deleted"));else{const n=this.#p[t];this.#_&&this.#n?.(i,n,e),this.#x&&this.#v?.push([i,n,e])}}if(this.#l.clear(),this.#u.fill(void 0),this.#p.fill(void 0),this.#w&&this.#b&&(this.#w.fill(0),this.#b.fill(0)),this.#y&&this.#y.fill(0),this.#m=0,this.#f=0,this.#g.length=0,this.#c=0,this.#a=0,this.#x&&this.#v){const e=this.#v;let t;for(;t=e?.shift();)this.#o?.(...t)}}}t.LRUCache=d},5629:function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.RtspProvider=t.RtspSmartCamera=t.RtspCamera=void 0,t.createRtspMediaStreamOptions=c;const o=i(4520),r=i(3861),s=n(i(7016)),a=i(8287);function c(e,t){return{id:`channel${t}`,name:`Stream ${t+1}`,url:e,container:"rtsp",video:{},audio:{}}}class l extends a.CameraBase{takePicture(e){throw new Error("The RTSP Camera does not provide snapshots. Install the Snapshot Plugin if snapshots are available via an URL.")}getRawVideoStreamOptions(){let e=[];try{e=JSON.parse(this.storage.getItem("urls"))}catch(t){const i=this.storage.getItem("url");i&&(e.push(i),this.storage.setItem("urls",JSON.stringify(e)),this.storage.removeItem("url"))}const t=e.filter((e=>!!e)).map(((e,t)=>c(e,t)));if(t.length)return t}addRtspCredentials(e){const t=s.default.parse(e);this.console.log("stream url",e);const i=this.storage.getItem("username"),n=this.storage.getItem("password");if(i){const e=`${i}:${n||""}`;t.auth=e}return s.default.format(t)}createMediaStreamUrl(e,t){const i={container:t.container,url:e,mediaStreamOptions:t};return this.createMediaObject(i,r.ScryptedMimeTypes.MediaStreamUrl)}async createVideoStream(e){if(!e)throw new Error("video streams not set up or no longer exists.");const t=this.addRtspCredentials(e.url);return this.createMediaStreamUrl(t,e)}getUsernameDescription(){}getPasswordDescription(){}async getRtspUrlSettings(){return[{key:"urls",title:"RTSP Stream URL",description:"An RTSP Stream URL provided by the camera.",placeholder:"rtsp://192.168.1.100[:554]/channel/101",value:this.getRawVideoStreamOptions()?.map((e=>e.url)),multiple:!0}]}async getOtherSettings(){const e=[];return e.push({subgroup:"Advanced",key:"debug",title:"Debug Events",description:"Log all events to the console. This will be very noisy and should not be left enabled.",value:"true"===this.storage.getItem("debug"),type:"boolean"}),e}async getUrlSettings(){return[...await this.getRtspUrlSettings()]}async putRtspUrls(e){this.storage.setItem("urls",JSON.stringify(e.filter((e=>!!e)))),this.onDeviceEvent(r.ScryptedInterface.Settings,void 0)}async putSettingBase(e,t){"urls"===e?this.putRtspUrls(t):super.putSettingBase(e,t)}}t.RtspCamera=l;t.RtspSmartCamera=class extends l{constructor(e,t){super(e,t),this.lastListen=0,process.nextTick((()=>this.listenLoop()))}resetSensors(){this.interfaces.includes(r.ScryptedInterface.MotionSensor)&&(this.motionDetected=!1),this.interfaces.includes(r.ScryptedInterface.AudioSensor)&&(this.audioDetected=!1),this.interfaces.includes(r.ScryptedInterface.TamperSensor)&&(this.tampered=!1),this.interfaces.includes(r.ScryptedInterface.BinarySensor)&&(this.binaryState=!1)}async listenLoop(){if(this.resetSensors(),this.lastListen=Date.now(),this.listener)return;let e;const t=this.listener=this.listenEvents();let i;const n=()=>{t===this.listener&&(this.listener=void 0),clearTimeout(i),e?.destroy();const n=Date.now()-this.lastListen;setTimeout((()=>this.listenLoop()),n>1e4?0:1e4)};try{e=await this.listener}catch(e){return this.console.error("listen loop connection failed, restarting listener.",e.message),void n()}const o=()=>{clearTimeout(i),i=setTimeout((()=>{this.console.error("listen loop 5m idle timeout, destroying listener."),n()}),3e5)};o(),e.on("data",(e=>{"true"===this.storage.getItem("debug")&&this.console.log("debug event:\n",e.toString()),o()})),e.on("close",(()=>{this.console.error("listen loop closed, restarting listener."),n()})),e.on("error",(e=>{this.console.error("listen loop error, restarting listener.",e),n()}))}async putSetting(e,t){this.putSettingBase(e,t),this.listener?.then((e=>e.emit("error",new Error("new settings"))))}async takePicture(e){return this.takeSmartCameraPicture(e)}async getRtspUrlSettings(){return[{key:"urls",title:"RTSP Stream URL Override",description:"Override the RTSP Stream URL provided by the camera.",placeholder:"rtsp://192.168.1.100[:554]/channel/101",value:this.getRawVideoStreamOptions()?.map((e=>e.url)),multiple:!0}]}async getUrlSettings(){const e=[{key:"ip",title:"IP Address",placeholder:"192.168.1.100",value:this.storage.getItem("ip")},...this.getHttpPortOverrideSettings(),...await this.getRtspPortOverrideSettings()];if(this.showRtspUrlOverride()){const t=this.storage.getItem("rtspUrlOverride");t&&(await this.putRtspUrls([t]),this.storage.removeItem("rtspUrlOverride")),e.push(...await this.getRtspUrlSettings())}return e}getHttpPortOverrideSettings(){return this.showHttpPortOverride()?[{key:"httpPort",subgroup:"Advanced",title:"HTTP Port Override",placeholder:"80",value:this.storage.getItem("httpPort")}]:[]}showHttpPortOverride(){return!0}async getRtspPortOverrideSettings(){return this.showRtspPortOverride()?[{key:"rtspPort",subgroup:"Advanced",title:"RTSP Port Override",placeholder:"554",value:this.storage.getItem("rtspPort")}]:[]}showRtspPortOverride(){return!0}showRtspUrlOverride(){return!0}getHttpAddress(){return`${this.getIPAddress()}:${this.storage.getItem("httpPort")||80}`}setHttpPortOverride(e){this.storage.setItem("httpPort",e||"")}getRtspUrlOverride(){if(this.showRtspUrlOverride())return this.storage.getItem("rtspUrlOverride")}getIPAddress(){return this.storage.getItem("ip")}setIPAddress(e){return this.storage.setItem("ip",e)}getRtspAddress(){return`${this.getIPAddress()}:${this.storage.getItem("rtspPort")||554}`}async getVideoStreamOptions(){if(this.showRtspUrlOverride()){const e=await super.getVideoStreamOptions();if(e)return e}return this.constructedVideoStreamOptions||(this.constructedVideoStreamOptions=(0,o.timeoutPromise)(5e3,this.getConstructedVideoStreamOptions()).finally((()=>{this.constructedVideoStreamOptions=void 0}))),this.constructedVideoStreamOptions}async putSettingBase(e,t){try{return await super.putSettingBase(e,t)}finally{this.constructedVideoStreamOptions=void 0}}};class p extends a.CameraProviderBase{createCamera(e){return new l(e,this)}}t.RtspProvider=p},5670:function(e,t,i){(function(){var t,n,o={}.hasOwnProperty;t=i(5068),n=i(4472),e.exports=function(e){function i(e,n){if(i.__super__.constructor.call(this,e),null==n)throw new Error("Missing CDATA text. "+this.debugInfo());this.name="#cdata-section",this.type=t.CData,this.value=this.stringify.cdata(n)}return function(e,t){for(var i in t)o.call(t,i)&&(e[i]=t[i]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(i,e),i.prototype.clone=function(){return Object.create(this)},i.prototype.toString=function(e){return this.options.writer.cdata(this,this.options.writer.filterOptions(e))},i}(n)}).call(this)},5692:e=>{"use strict";e.exports=require("https")},5722:(e,t,i)=>{"use strict";const{MathFloor:n,NumberIsInteger:o}=i(3383),{validateInteger:r}=i(2354),{ERR_INVALID_ARG_VALUE:s}=i(676).codes;let a=16384,c=16;function l(e){return e?c:a}e.exports={getHighWaterMark:function(e,t,i,r){const a=function(e,t,i){return null!=e.highWaterMark?e.highWaterMark:t?e[i]:null}(t,r,i);if(null!=a){if(!o(a)||a<0){throw new s(r?`options.${i}`:"options.highWaterMark",a)}return n(a)}return l(e.objectMode)},getDefaultHighWaterMark:l,setDefaultHighWaterMark:function(e,t){r(t,"value",0),e?c=t:a=t}}},5745:(e,t,i)=>{"use strict";const{ObjectDefineProperties:n,ObjectGetOwnPropertyDescriptor:o,ObjectKeys:r,ObjectSetPrototypeOf:s}=i(3383);e.exports=l;const a=i(5047),c=i(7819);s(l.prototype,a.prototype),s(l,a);{const e=r(c.prototype);for(let t=0;t<e.length;t++){const i=e[t];l.prototype[i]||(l.prototype[i]=c.prototype[i])}}function l(e){if(!(this instanceof l))return new l(e);a.call(this,e),c.call(this,e),e?(this.allowHalfOpen=!1!==e.allowHalfOpen,!1===e.readable&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),!1===e.writable&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)):this.allowHalfOpen=!0}let p,u;function d(){return void 0===p&&(p={}),p}n(l.prototype,{writable:{__proto__:null,...o(c.prototype,"writable")},writableHighWaterMark:{__proto__:null,...o(c.prototype,"writableHighWaterMark")},writableObjectMode:{__proto__:null,...o(c.prototype,"writableObjectMode")},writableBuffer:{__proto__:null,...o(c.prototype,"writableBuffer")},writableLength:{__proto__:null,...o(c.prototype,"writableLength")},writableFinished:{__proto__:null,...o(c.prototype,"writableFinished")},writableCorked:{__proto__:null,...o(c.prototype,"writableCorked")},writableEnded:{__proto__:null,...o(c.prototype,"writableEnded")},writableNeedDrain:{__proto__:null,...o(c.prototype,"writableNeedDrain")},destroyed:{__proto__:null,get(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set(e){this._readableState&&this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}}}),l.fromWeb=function(e,t){return d().newStreamDuplexFromReadableWritablePair(e,t)},l.toWeb=function(e){return d().newReadableWritablePairFromDuplex(e)},l.from=function(e){return u||(u=i(7303)),u(e,"body")}},5825:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=new WeakMap,n=new WeakMap;function o(e){const t=i.get(e);return console.assert(null!=t,"'this' is expected an Event object, but got",e),t}function r(e){null==e.passiveListener?e.event.cancelable&&(e.canceled=!0,"function"==typeof e.event.preventDefault&&e.event.preventDefault()):"undefined"!=typeof console&&"function"==typeof console.error&&console.error("Unable to preventDefault inside passive event listener invocation.",e.passiveListener)}function s(e,t){i.set(this,{eventTarget:e,event:t,eventPhase:2,currentTarget:e,canceled:!1,stopped:!1,immediateStopped:!1,passiveListener:null,timeStamp:t.timeStamp||Date.now()}),Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});const n=Object.keys(t);for(let e=0;e<n.length;++e){const t=n[e];t in this||Object.defineProperty(this,t,a(t))}}function a(e){return{get(){return o(this).event[e]},set(t){o(this).event[e]=t},configurable:!0,enumerable:!0}}function c(e){return{value(){const t=o(this).event;return t[e].apply(t,arguments)},configurable:!0,enumerable:!0}}function l(e){if(null==e||e===Object.prototype)return s;let t=n.get(e);return null==t&&(t=function(e,t){const i=Object.keys(t);if(0===i.length)return e;function n(t,i){e.call(this,t,i)}n.prototype=Object.create(e.prototype,{constructor:{value:n,configurable:!0,writable:!0}});for(let o=0;o<i.length;++o){const r=i[o];if(!(r in e.prototype)){const e="function"==typeof Object.getOwnPropertyDescriptor(t,r).value;Object.defineProperty(n.prototype,r,e?c(r):a(r))}}return n}(l(Object.getPrototypeOf(e)),e),n.set(e,t)),t}function p(e){return o(e).immediateStopped}function u(e,t){o(e).passiveListener=t}s.prototype={get type(){return o(this).event.type},get target(){return o(this).eventTarget},get currentTarget(){return o(this).currentTarget},composedPath(){const e=o(this).currentTarget;return null==e?[]:[e]},get NONE(){return 0},get CAPTURING_PHASE(){return 1},get AT_TARGET(){return 2},get BUBBLING_PHASE(){return 3},get eventPhase(){return o(this).eventPhase},stopPropagation(){const e=o(this);e.stopped=!0,"function"==typeof e.event.stopPropagation&&e.event.stopPropagation()},stopImmediatePropagation(){const e=o(this);e.stopped=!0,e.immediateStopped=!0,"function"==typeof e.event.stopImmediatePropagation&&e.event.stopImmediatePropagation()},get bubbles(){return Boolean(o(this).event.bubbles)},get cancelable(){return Boolean(o(this).event.cancelable)},preventDefault(){r(o(this))},get defaultPrevented(){return o(this).canceled},get composed(){return Boolean(o(this).event.composed)},get timeStamp(){return o(this).timeStamp},get srcElement(){return o(this).eventTarget},get cancelBubble(){return o(this).stopped},set cancelBubble(e){if(!e)return;const t=o(this);t.stopped=!0,"boolean"==typeof t.event.cancelBubble&&(t.event.cancelBubble=!0)},get returnValue(){return!o(this).canceled},set returnValue(e){e||r(o(this))},initEvent(){}},Object.defineProperty(s.prototype,"constructor",{value:s,configurable:!0,writable:!0}),"undefined"!=typeof window&&"undefined"!=typeof window.Event&&(Object.setPrototypeOf(s.prototype,window.Event.prototype),n.set(window.Event.prototype,s));const d=new WeakMap;function h(e){return null!==e&&"object"==typeof e}function m(e){const t=d.get(e);if(null==t)throw new TypeError("'this' is expected an EventTarget object, but got another value.");return t}function f(e,t){Object.defineProperty(e,`on${t}`,function(e){return{get(){let t=m(this).get(e);for(;null!=t;){if(3===t.listenerType)return t.listener;t=t.next}return null},set(t){"function"==typeof t||h(t)||(t=null);const i=m(this);let n=null,o=i.get(e);for(;null!=o;)3===o.listenerType?null!==n?n.next=o.next:null!==o.next?i.set(e,o.next):i.delete(e):n=o,o=o.next;if(null!==t){const o={listener:t,listenerType:3,passive:!1,once:!1,next:null};null===n?i.set(e,o):n.next=o}},configurable:!0,enumerable:!0}}(t))}function g(e){function t(){v.call(this)}t.prototype=Object.create(v.prototype,{constructor:{value:t,configurable:!0,writable:!0}});for(let i=0;i<e.length;++i)f(t.prototype,e[i]);return t}function v(){if(!(this instanceof v)){if(1===arguments.length&&Array.isArray(arguments[0]))return g(arguments[0]);if(arguments.length>0){const e=new Array(arguments.length);for(let t=0;t<arguments.length;++t)e[t]=arguments[t];return g(e)}throw new TypeError("Cannot call a class as a function")}d.set(this,new Map)}v.prototype={addEventListener(e,t,i){if(null==t)return;if("function"!=typeof t&&!h(t))throw new TypeError("'listener' should be a function or an object.");const n=m(this),o=h(i),r=(o?Boolean(i.capture):Boolean(i))?1:2,s={listener:t,listenerType:r,passive:o&&Boolean(i.passive),once:o&&Boolean(i.once),next:null};let a=n.get(e);if(void 0===a)return void n.set(e,s);let c=null;for(;null!=a;){if(a.listener===t&&a.listenerType===r)return;c=a,a=a.next}c.next=s},removeEventListener(e,t,i){if(null==t)return;const n=m(this),o=(h(i)?Boolean(i.capture):Boolean(i))?1:2;let r=null,s=n.get(e);for(;null!=s;){if(s.listener===t&&s.listenerType===o)return void(null!==r?r.next=s.next:null!==s.next?n.set(e,s.next):n.delete(e));r=s,s=s.next}},dispatchEvent(e){if(null==e||"string"!=typeof e.type)throw new TypeError('"event.type" should be a string.');const t=m(this),i=e.type;let n=t.get(i);if(null==n)return!0;const r=function(e,t){return new(l(Object.getPrototypeOf(t)))(e,t)}(this,e);let s=null;for(;null!=n;){if(n.once?null!==s?s.next=n.next:null!==n.next?t.set(i,n.next):t.delete(i):s=n,u(r,n.passive?n.listener:null),"function"==typeof n.listener)try{n.listener.call(this,r)}catch(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e)}else 3!==n.listenerType&&"function"==typeof n.listener.handleEvent&&n.listener.handleEvent(r);if(p(r))break;n=n.next}return u(r,null),function(e,t){o(e).eventPhase=t}(r,0),function(e,t){o(e).currentTarget=t}(r,null),!r.defaultPrevented}},Object.defineProperty(v.prototype,"constructor",{value:v,configurable:!0,writable:!0}),"undefined"!=typeof window&&"undefined"!=typeof window.EventTarget&&Object.setPrototypeOf(v.prototype,window.EventTarget.prototype),t.defineEventAttribute=f,t.EventTarget=v,t.default=v,e.exports=v,e.exports.EventTarget=e.exports.default=v,e.exports.defineEventAttribute=f},5830:(e,t,i)=>{var n=i(2203).Stream,o=i(9023);function r(){this.source=null,this.dataSize=0,this.maxDataSize=1048576,this.pauseStream=!0,this._maxDataSizeExceeded=!1,this._released=!1,this._bufferedEvents=[]}e.exports=r,o.inherits(r,n),r.create=function(e,t){var i=new this;for(var n in t=t||{})i[n]=t[n];i.source=e;var o=e.emit;return e.emit=function(){return i._handleEmit(arguments),o.apply(e,arguments)},e.on("error",(function(){})),i.pauseStream&&e.pause(),i},Object.defineProperty(r.prototype,"readable",{configurable:!0,enumerable:!0,get:function(){return this.source.readable}}),r.prototype.setEncoding=function(){return this.source.setEncoding.apply(this.source,arguments)},r.prototype.resume=function(){this._released||this.release(),this.source.resume()},r.prototype.pause=function(){this.source.pause()},r.prototype.release=function(){this._released=!0,this._bufferedEvents.forEach(function(e){this.emit.apply(this,e)}.bind(this)),this._bufferedEvents=[]},r.prototype.pipe=function(){var e=n.prototype.pipe.apply(this,arguments);return this.resume(),e},r.prototype._handleEmit=function(e){this._released?this.emit.apply(this,e):("data"===e[0]&&(this.dataSize+=e[1].length,this._checkIfMaxDataSizeExceeded()),this._bufferedEvents.push(e))},r.prototype._checkIfMaxDataSizeExceeded=function(){if(!(this._maxDataSizeExceeded||this.dataSize<=this.maxDataSize)){this._maxDataSizeExceeded=!0;var e="DelayedStream#maxDataSize of "+this.maxDataSize+" bytes exceeded.";this.emit("error",new Error(e))}}},5899:(e,t,i)=>{"use strict";const n=i(2203);if(n&&"disable"===process.env.READABLE_STREAM){const t=n.promises;e.exports._uint8ArrayToBuffer=n._uint8ArrayToBuffer,e.exports._isUint8Array=n._isUint8Array,e.exports.isDisturbed=n.isDisturbed,e.exports.isErrored=n.isErrored,e.exports.isReadable=n.isReadable,e.exports.Readable=n.Readable,e.exports.Writable=n.Writable,e.exports.Duplex=n.Duplex,e.exports.Transform=n.Transform,e.exports.PassThrough=n.PassThrough,e.exports.addAbortSignal=n.addAbortSignal,e.exports.finished=n.finished,e.exports.destroy=n.destroy,e.exports.pipeline=n.pipeline,e.exports.compose=n.compose,Object.defineProperty(n,"promises",{configurable:!0,enumerable:!0,get:()=>t}),e.exports.Stream=n.Stream}else{const t=i(7719),n=i(2144),o=t.Readable.destroy;e.exports=t.Readable,e.exports._uint8ArrayToBuffer=t._uint8ArrayToBuffer,e.exports._isUint8Array=t._isUint8Array,e.exports.isDisturbed=t.isDisturbed,e.exports.isErrored=t.isErrored,e.exports.isReadable=t.isReadable,e.exports.Readable=t.Readable,e.exports.Writable=t.Writable,e.exports.Duplex=t.Duplex,e.exports.Transform=t.Transform,e.exports.PassThrough=t.PassThrough,e.exports.addAbortSignal=t.addAbortSignal,e.exports.finished=t.finished,e.exports.destroy=t.destroy,e.exports.destroy=o,e.exports.pipeline=t.pipeline,e.exports.compose=t.compose,Object.defineProperty(t,"promises",{configurable:!0,enumerable:!0,get:()=>n}),e.exports.Stream=t.Stream}e.exports.default=e.exports},5946:(e,t,i)=>{"use strict";const n=i(7465);n.createWebSocketStream=i(4988),n.Server=i(4001),n.Receiver=i(7229),n.Sender=i(8573),n.WebSocket=n,n.WebSocketServer=n.Server,e.exports=n},5998:(e,t,i)=>{t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const i="color: "+this.color;t.splice(1,0,i,"color: inherit");let n=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(o=n))})),t.splice(o,0,i)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=i(5329)(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},6029:e=>{"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e}}},6039:function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(i(6756)),r=n(i(541)),s=n(i(8284)),a=n(i(9086)),c=n(i(7925));t.default=(e,t,i)=>{const{options:n}=e;if(5===n.protocolVersion&&n.properties&&n.properties.maximumPacketSize&&n.properties.maximumPacketSize<t.length)return e.emit("error",new Error(`exceeding packets size ${t.cmd}`)),e.end({reasonCode:149,properties:{reasonString:"Maximum packet size was exceeded"}}),e;switch(e.log("_handlePacket :: emitting packetreceive"),e.emit("packetreceive",t),t.cmd){case"publish":(0,o.default)(e,t,i);break;case"puback":case"pubrec":case"pubcomp":case"suback":case"unsuback":e.reschedulePing(),(0,a.default)(e,t),i();break;case"pubrel":e.reschedulePing(),(0,c.default)(e,t,i);break;case"connack":(0,s.default)(e,t),i();break;case"auth":e.reschedulePing(),(0,r.default)(e,t),i();break;case"pingresp":e.log("_handlePacket :: received pingresp"),e.reschedulePing(!0),i();break;case"disconnect":e.emit("disconnect",t),i();break;default:e.log("_handlePacket :: unknown command"),i()}}},6141:function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(i(4756)),r=n(i(9278)),s=(0,n(i(8766)).default)("mqttjs:tls");t.default=(e,t)=>{t.port=t.port||8883,t.host=t.hostname||t.host||"localhost",0===r.default.isIP(t.host)&&(t.servername=t.host),t.rejectUnauthorized=!1!==t.rejectUnauthorized,delete t.path,s("port %d host %s rejectUnauthorized %b",t.port,t.host,t.rejectUnauthorized);const i=o.default.connect(t);function n(n){t.rejectUnauthorized&&e.emit("error",n),i.end()}return i.on("secureConnect",(()=>{t.rejectUnauthorized&&!i.authorized?i.emit("error",new Error("TLS not authorized")):i.removeListener("error",n)})),i.on("error",n),i}},6162:(e,t,i)=>{!function(e){e.parser=function(e,t){return new o(e,t)},e.SAXParser=o,e.SAXStream=s,e.createStream=function(e,t){return new s(e,t)},e.MAX_BUFFER_LENGTH=65536;var t,n=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];function o(t,i){if(!(this instanceof o))return new o(t,i);var r=this;!function(e){for(var t=0,i=n.length;t<i;t++)e[n[t]]=""}(r),r.q=r.c="",r.bufferCheckPosition=e.MAX_BUFFER_LENGTH,r.opt=i||{},r.opt.lowercase=r.opt.lowercase||r.opt.lowercasetags,r.looseCase=r.opt.lowercase?"toLowerCase":"toUpperCase",r.tags=[],r.closed=r.closedRoot=r.sawRoot=!1,r.tag=r.error=null,r.strict=!!t,r.noscript=!(!t&&!r.opt.noscript),r.state=T.BEGIN,r.strictEntities=r.opt.strictEntities,r.ENTITIES=r.strictEntities?Object.create(e.XML_ENTITIES):Object.create(e.ENTITIES),r.attribList=[],r.opt.xmlns&&(r.ns=Object.create(u)),r.trackPosition=!1!==r.opt.position,r.trackPosition&&(r.position=r.line=r.column=0),C(r,"onready")}e.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"],Object.create||(Object.create=function(e){function t(){}return t.prototype=e,new t}),Object.keys||(Object.keys=function(e){var t=[];for(var i in e)e.hasOwnProperty(i)&&t.push(i);return t}),o.prototype={end:function(){A(this)},write:function(t){var i=this;if(this.error)throw this.error;if(i.closed)return I(i,"Cannot write after close. Assign an onready handler.");if(null===t)return A(i);"object"==typeof t&&(t=t.toString());var o=0,r="";for(;r=U(t,o++),i.c=r,r;)switch(i.trackPosition&&(i.position++,"\n"===r?(i.line++,i.column=0):i.column++),i.state){case T.BEGIN:if(i.state=T.BEGIN_WHITESPACE,"\ufeff"===r)continue;B(i,r);continue;case T.BEGIN_WHITESPACE:B(i,r);continue;case T.TEXT:if(i.sawRoot&&!i.closedRoot){for(var s=o-1;r&&"<"!==r&&"&"!==r;)(r=U(t,o++))&&i.trackPosition&&(i.position++,"\n"===r?(i.line++,i.column=0):i.column++);i.textNode+=t.substring(s,o-1)}"<"!==r||i.sawRoot&&i.closedRoot&&!i.strict?(g(r)||i.sawRoot&&!i.closedRoot||R(i,"Text data outside of root node."),"&"===r?i.state=T.TEXT_ENTITY:i.textNode+=r):(i.state=T.OPEN_WAKA,i.startTagPosition=i.position);continue;case T.SCRIPT:"<"===r?i.state=T.SCRIPT_ENDING:i.script+=r;continue;case T.SCRIPT_ENDING:"/"===r?i.state=T.CLOSE_TAG:(i.script+="<"+r,i.state=T.SCRIPT);continue;case T.OPEN_WAKA:if("!"===r)i.state=T.SGML_DECL,i.sgmlDecl="";else if(g(r));else if(b(d,r))i.state=T.OPEN_TAG,i.tagName=r;else if("/"===r)i.state=T.CLOSE_TAG,i.tagName="";else if("?"===r)i.state=T.PROC_INST,i.procInstName=i.procInstBody="";else{if(R(i,"Unencoded <"),i.startTagPosition+1<i.position){var l=i.position-i.startTagPosition;r=new Array(l).join(" ")+r}i.textNode+="<"+r,i.state=T.TEXT}continue;case T.SGML_DECL:(i.sgmlDecl+r).toUpperCase()===a?(P(i,"onopencdata"),i.state=T.CDATA,i.sgmlDecl="",i.cdata=""):i.sgmlDecl+r==="--"?(i.state=T.COMMENT,i.comment="",i.sgmlDecl=""):(i.sgmlDecl+r).toUpperCase()===c?(i.state=T.DOCTYPE,(i.doctype||i.sawRoot)&&R(i,"Inappropriately located doctype declaration"),i.doctype="",i.sgmlDecl=""):">"===r?(P(i,"onsgmldeclaration",i.sgmlDecl),i.sgmlDecl="",i.state=T.TEXT):v(r)?(i.state=T.SGML_DECL_QUOTED,i.sgmlDecl+=r):i.sgmlDecl+=r;continue;case T.SGML_DECL_QUOTED:r===i.q&&(i.state=T.SGML_DECL,i.q=""),i.sgmlDecl+=r;continue;case T.DOCTYPE:">"===r?(i.state=T.TEXT,P(i,"ondoctype",i.doctype),i.doctype=!0):(i.doctype+=r,"["===r?i.state=T.DOCTYPE_DTD:v(r)&&(i.state=T.DOCTYPE_QUOTED,i.q=r));continue;case T.DOCTYPE_QUOTED:i.doctype+=r,r===i.q&&(i.q="",i.state=T.DOCTYPE);continue;case T.DOCTYPE_DTD:i.doctype+=r,"]"===r?i.state=T.DOCTYPE:v(r)&&(i.state=T.DOCTYPE_DTD_QUOTED,i.q=r);continue;case T.DOCTYPE_DTD_QUOTED:i.doctype+=r,r===i.q&&(i.state=T.DOCTYPE_DTD,i.q="");continue;case T.COMMENT:"-"===r?i.state=T.COMMENT_ENDING:i.comment+=r;continue;case T.COMMENT_ENDING:"-"===r?(i.state=T.COMMENT_ENDED,i.comment=O(i.opt,i.comment),i.comment&&P(i,"oncomment",i.comment),i.comment=""):(i.comment+="-"+r,i.state=T.COMMENT);continue;case T.COMMENT_ENDED:">"!==r?(R(i,"Malformed comment"),i.comment+="--"+r,i.state=T.COMMENT):i.state=T.TEXT;continue;case T.CDATA:"]"===r?i.state=T.CDATA_ENDING:i.cdata+=r;continue;case T.CDATA_ENDING:"]"===r?i.state=T.CDATA_ENDING_2:(i.cdata+="]"+r,i.state=T.CDATA);continue;case T.CDATA_ENDING_2:">"===r?(i.cdata&&P(i,"oncdata",i.cdata),P(i,"onclosecdata"),i.cdata="",i.state=T.TEXT):"]"===r?i.cdata+="]":(i.cdata+="]]"+r,i.state=T.CDATA);continue;case T.PROC_INST:"?"===r?i.state=T.PROC_INST_ENDING:g(r)?i.state=T.PROC_INST_BODY:i.procInstName+=r;continue;case T.PROC_INST_BODY:if(!i.procInstBody&&g(r))continue;"?"===r?i.state=T.PROC_INST_ENDING:i.procInstBody+=r;continue;case T.PROC_INST_ENDING:">"===r?(P(i,"onprocessinginstruction",{name:i.procInstName,body:i.procInstBody}),i.procInstName=i.procInstBody="",i.state=T.TEXT):(i.procInstBody+="?"+r,i.state=T.PROC_INST_BODY);continue;case T.OPEN_TAG:b(h,r)?i.tagName+=r:(D(i),">"===r?L(i):"/"===r?i.state=T.OPEN_TAG_SLASH:(g(r)||R(i,"Invalid character in tag name"),i.state=T.ATTRIB));continue;case T.OPEN_TAG_SLASH:">"===r?(L(i,!0),j(i)):(R(i,"Forward-slash in opening tag not followed by >"),i.state=T.ATTRIB);continue;case T.ATTRIB:if(g(r))continue;">"===r?L(i):"/"===r?i.state=T.OPEN_TAG_SLASH:b(d,r)?(i.attribName=r,i.attribValue="",i.state=T.ATTRIB_NAME):R(i,"Invalid attribute name");continue;case T.ATTRIB_NAME:"="===r?i.state=T.ATTRIB_VALUE:">"===r?(R(i,"Attribute without value"),i.attribValue=i.attribName,N(i),L(i)):g(r)?i.state=T.ATTRIB_NAME_SAW_WHITE:b(h,r)?i.attribName+=r:R(i,"Invalid attribute name");continue;case T.ATTRIB_NAME_SAW_WHITE:if("="===r)i.state=T.ATTRIB_VALUE;else{if(g(r))continue;R(i,"Attribute without value"),i.tag.attributes[i.attribName]="",i.attribValue="",P(i,"onattribute",{name:i.attribName,value:""}),i.attribName="",">"===r?L(i):b(d,r)?(i.attribName=r,i.state=T.ATTRIB_NAME):(R(i,"Invalid attribute name"),i.state=T.ATTRIB)}continue;case T.ATTRIB_VALUE:if(g(r))continue;v(r)?(i.q=r,i.state=T.ATTRIB_VALUE_QUOTED):(R(i,"Unquoted attribute value"),i.state=T.ATTRIB_VALUE_UNQUOTED,i.attribValue=r);continue;case T.ATTRIB_VALUE_QUOTED:if(r!==i.q){"&"===r?i.state=T.ATTRIB_VALUE_ENTITY_Q:i.attribValue+=r;continue}N(i),i.q="",i.state=T.ATTRIB_VALUE_CLOSED;continue;case T.ATTRIB_VALUE_CLOSED:g(r)?i.state=T.ATTRIB:">"===r?L(i):"/"===r?i.state=T.OPEN_TAG_SLASH:b(d,r)?(R(i,"No whitespace between attributes"),i.attribName=r,i.attribValue="",i.state=T.ATTRIB_NAME):R(i,"Invalid attribute name");continue;case T.ATTRIB_VALUE_UNQUOTED:if(!y(r)){"&"===r?i.state=T.ATTRIB_VALUE_ENTITY_U:i.attribValue+=r;continue}N(i),">"===r?L(i):i.state=T.ATTRIB;continue;case T.CLOSE_TAG:if(i.tagName)">"===r?j(i):b(h,r)?i.tagName+=r:i.script?(i.script+="</"+i.tagName,i.tagName="",i.state=T.SCRIPT):(g(r)||R(i,"Invalid tagname in closing tag"),i.state=T.CLOSE_TAG_SAW_WHITE);else{if(g(r))continue;w(d,r)?i.script?(i.script+="</"+r,i.state=T.SCRIPT):R(i,"Invalid tagname in closing tag."):i.tagName=r}continue;case T.CLOSE_TAG_SAW_WHITE:if(g(r))continue;">"===r?j(i):R(i,"Invalid characters in closing tag");continue;case T.TEXT_ENTITY:case T.ATTRIB_VALUE_ENTITY_Q:case T.ATTRIB_VALUE_ENTITY_U:var p,u;switch(i.state){case T.TEXT_ENTITY:p=T.TEXT,u="textNode";break;case T.ATTRIB_VALUE_ENTITY_Q:p=T.ATTRIB_VALUE_QUOTED,u="attribValue";break;case T.ATTRIB_VALUE_ENTITY_U:p=T.ATTRIB_VALUE_UNQUOTED,u="attribValue"}";"===r?(i[u]+=F(i),i.entity="",i.state=p):b(i.entity.length?f:m,r)?i.entity+=r:(R(i,"Invalid character in entity name"),i[u]+="&"+i.entity+r,i.entity="",i.state=p);continue;default:throw new Error(i,"Unknown state: "+i.state)}i.position>=i.bufferCheckPosition&&function(t){for(var i=Math.max(e.MAX_BUFFER_LENGTH,10),o=0,r=0,s=n.length;r<s;r++){var a=t[n[r]].length;if(a>i)switch(n[r]){case"textNode":k(t);break;case"cdata":P(t,"oncdata",t.cdata),t.cdata="";break;case"script":P(t,"onscript",t.script),t.script="";break;default:I(t,"Max buffer length exceeded: "+n[r])}o=Math.max(o,a)}var c=e.MAX_BUFFER_LENGTH-o;t.bufferCheckPosition=c+t.position}(i);return i},resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){var e;k(e=this),""!==e.cdata&&(P(e,"oncdata",e.cdata),e.cdata=""),""!==e.script&&(P(e,"onscript",e.script),e.script="")}};try{t=i(2203).Stream}catch(e){t=function(){}}var r=e.EVENTS.filter((function(e){return"error"!==e&&"end"!==e}));function s(e,i){if(!(this instanceof s))return new s(e,i);t.apply(this),this._parser=new o(e,i),this.writable=!0,this.readable=!0;var n=this;this._parser.onend=function(){n.emit("end")},this._parser.onerror=function(e){n.emit("error",e),n._parser.error=null},this._decoder=null,r.forEach((function(e){Object.defineProperty(n,"on"+e,{get:function(){return n._parser["on"+e]},set:function(t){if(!t)return n.removeAllListeners(e),n._parser["on"+e]=t,t;n.on(e,t)},enumerable:!0,configurable:!1})}))}s.prototype=Object.create(t.prototype,{constructor:{value:s}}),s.prototype.write=function(e){if("function"==typeof Buffer&&"function"==typeof Buffer.isBuffer&&Buffer.isBuffer(e)){if(!this._decoder){var t=i(3193).StringDecoder;this._decoder=new t("utf8")}e=this._decoder.write(e)}return this._parser.write(e.toString()),this.emit("data",e),!0},s.prototype.end=function(e){return e&&e.length&&this.write(e),this._parser.end(),!0},s.prototype.on=function(e,i){var n=this;return n._parser["on"+e]||-1===r.indexOf(e)||(n._parser["on"+e]=function(){var t=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);t.splice(0,0,e),n.emit.apply(n,t)}),t.prototype.on.call(n,e,i)};var a="[CDATA[",c="DOCTYPE",l="http://www.w3.org/XML/1998/namespace",p="http://www.w3.org/2000/xmlns/",u={xml:l,xmlns:p},d=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,h=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,m=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,f=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function g(e){return" "===e||"\n"===e||"\r"===e||"\t"===e}function v(e){return'"'===e||"'"===e}function y(e){return">"===e||g(e)}function b(e,t){return e.test(t)}function w(e,t){return!b(e,t)}var _,S,x,T=0;for(var E in e.STATE={BEGIN:T++,BEGIN_WHITESPACE:T++,TEXT:T++,TEXT_ENTITY:T++,OPEN_WAKA:T++,SGML_DECL:T++,SGML_DECL_QUOTED:T++,DOCTYPE:T++,DOCTYPE_QUOTED:T++,DOCTYPE_DTD:T++,DOCTYPE_DTD_QUOTED:T++,COMMENT_STARTING:T++,COMMENT:T++,COMMENT_ENDING:T++,COMMENT_ENDED:T++,CDATA:T++,CDATA_ENDING:T++,CDATA_ENDING_2:T++,PROC_INST:T++,PROC_INST_BODY:T++,PROC_INST_ENDING:T++,OPEN_TAG:T++,OPEN_TAG_SLASH:T++,ATTRIB:T++,ATTRIB_NAME:T++,ATTRIB_NAME_SAW_WHITE:T++,ATTRIB_VALUE:T++,ATTRIB_VALUE_QUOTED:T++,ATTRIB_VALUE_CLOSED:T++,ATTRIB_VALUE_UNQUOTED:T++,ATTRIB_VALUE_ENTITY_Q:T++,ATTRIB_VALUE_ENTITY_U:T++,CLOSE_TAG:T++,CLOSE_TAG_SAW_WHITE:T++,SCRIPT:T++,SCRIPT_ENDING:T++},e.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},e.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(e.ENTITIES).forEach((function(t){var i=e.ENTITIES[t],n="number"==typeof i?String.fromCharCode(i):i;e.ENTITIES[t]=n})),e.STATE)e.STATE[e.STATE[E]]=E;function C(e,t,i){e[t]&&e[t](i)}function P(e,t,i){e.textNode&&k(e),C(e,t,i)}function k(e){e.textNode=O(e.opt,e.textNode),e.textNode&&C(e,"ontext",e.textNode),e.textNode=""}function O(e,t){return e.trim&&(t=t.trim()),e.normalize&&(t=t.replace(/\s+/g," ")),t}function I(e,t){return k(e),e.trackPosition&&(t+="\nLine: "+e.line+"\nColumn: "+e.column+"\nChar: "+e.c),t=new Error(t),e.error=t,C(e,"onerror",t),e}function A(e){return e.sawRoot&&!e.closedRoot&&R(e,"Unclosed root tag"),e.state!==T.BEGIN&&e.state!==T.BEGIN_WHITESPACE&&e.state!==T.TEXT&&I(e,"Unexpected end"),k(e),e.c="",e.closed=!0,C(e,"onend"),o.call(e,e.strict,e.opt),e}function R(e,t){if("object"!=typeof e||!(e instanceof o))throw new Error("bad call to strictFail");e.strict&&I(e,t)}function D(e){e.strict||(e.tagName=e.tagName[e.looseCase]());var t=e.tags[e.tags.length-1]||e,i=e.tag={name:e.tagName,attributes:{}};e.opt.xmlns&&(i.ns=t.ns),e.attribList.length=0,P(e,"onopentagstart",i)}function M(e,t){var i=e.indexOf(":")<0?["",e]:e.split(":"),n=i[0],o=i[1];return t&&"xmlns"===e&&(n="xmlns",o=""),{prefix:n,local:o}}function N(e){if(e.strict||(e.attribName=e.attribName[e.looseCase]()),-1!==e.attribList.indexOf(e.attribName)||e.tag.attributes.hasOwnProperty(e.attribName))e.attribName=e.attribValue="";else{if(e.opt.xmlns){var t=M(e.attribName,!0),i=t.prefix,n=t.local;if("xmlns"===i)if("xml"===n&&e.attribValue!==l)R(e,"xml: prefix must be bound to "+l+"\nActual: "+e.attribValue);else if("xmlns"===n&&e.attribValue!==p)R(e,"xmlns: prefix must be bound to "+p+"\nActual: "+e.attribValue);else{var o=e.tag,r=e.tags[e.tags.length-1]||e;o.ns===r.ns&&(o.ns=Object.create(r.ns)),o.ns[n]=e.attribValue}e.attribList.push([e.attribName,e.attribValue])}else e.tag.attributes[e.attribName]=e.attribValue,P(e,"onattribute",{name:e.attribName,value:e.attribValue});e.attribName=e.attribValue=""}}function L(e,t){if(e.opt.xmlns){var i=e.tag,n=M(e.tagName);i.prefix=n.prefix,i.local=n.local,i.uri=i.ns[n.prefix]||"",i.prefix&&!i.uri&&(R(e,"Unbound namespace prefix: "+JSON.stringify(e.tagName)),i.uri=n.prefix);var o=e.tags[e.tags.length-1]||e;i.ns&&o.ns!==i.ns&&Object.keys(i.ns).forEach((function(t){P(e,"onopennamespace",{prefix:t,uri:i.ns[t]})}));for(var r=0,s=e.attribList.length;r<s;r++){var a=e.attribList[r],c=a[0],l=a[1],p=M(c,!0),u=p.prefix,d=p.local,h=""===u?"":i.ns[u]||"",m={name:c,value:l,prefix:u,local:d,uri:h};u&&"xmlns"!==u&&!h&&(R(e,"Unbound namespace prefix: "+JSON.stringify(u)),m.uri=u),e.tag.attributes[c]=m,P(e,"onattribute",m)}e.attribList.length=0}e.tag.isSelfClosing=!!t,e.sawRoot=!0,e.tags.push(e.tag),P(e,"onopentag",e.tag),t||(e.noscript||"script"!==e.tagName.toLowerCase()?e.state=T.TEXT:e.state=T.SCRIPT,e.tag=null,e.tagName=""),e.attribName=e.attribValue="",e.attribList.length=0}function j(e){if(!e.tagName)return R(e,"Weird empty close tag."),e.textNode+="</>",void(e.state=T.TEXT);if(e.script){if("script"!==e.tagName)return e.script+="</"+e.tagName+">",e.tagName="",void(e.state=T.SCRIPT);P(e,"onscript",e.script),e.script=""}var t=e.tags.length,i=e.tagName;e.strict||(i=i[e.looseCase]());for(var n=i;t--;){if(e.tags[t].name===n)break;R(e,"Unexpected close tag")}if(t<0)return R(e,"Unmatched closing tag: "+e.tagName),e.textNode+="</"+e.tagName+">",void(e.state=T.TEXT);e.tagName=i;for(var o=e.tags.length;o-- >t;){var r=e.tag=e.tags.pop();e.tagName=e.tag.name,P(e,"onclosetag",e.tagName);var s={};for(var a in r.ns)s[a]=r.ns[a];var c=e.tags[e.tags.length-1]||e;e.opt.xmlns&&r.ns!==c.ns&&Object.keys(r.ns).forEach((function(t){var i=r.ns[t];P(e,"onclosenamespace",{prefix:t,uri:i})}))}0===t&&(e.closedRoot=!0),e.tagName=e.attribValue=e.attribName="",e.attribList.length=0,e.state=T.TEXT}function F(e){var t,i=e.entity,n=i.toLowerCase(),o="";return e.ENTITIES[i]?e.ENTITIES[i]:e.ENTITIES[n]?e.ENTITIES[n]:("#"===(i=n).charAt(0)&&("x"===i.charAt(1)?(i=i.slice(2),o=(t=parseInt(i,16)).toString(16)):(i=i.slice(1),o=(t=parseInt(i,10)).toString(10))),i=i.replace(/^0+/,""),isNaN(t)||o.toLowerCase()!==i?(R(e,"Invalid character entity"),"&"+e.entity+";"):String.fromCodePoint(t))}function B(e,t){"<"===t?(e.state=T.OPEN_WAKA,e.startTagPosition=e.position):g(t)||(R(e,"Non-whitespace before first tag."),e.textNode=t,e.state=T.TEXT)}function U(e,t){var i="";return t<e.length&&(i=e.charAt(t)),i}T=e.STATE,String.fromCodePoint||(_=String.fromCharCode,S=Math.floor,x=function(){var e,t,i=[],n=-1,o=arguments.length;if(!o)return"";for(var r="";++n<o;){var s=Number(arguments[n]);if(!isFinite(s)||s<0||s>1114111||S(s)!==s)throw RangeError("Invalid code point: "+s);s<=65535?i.push(s):(e=55296+((s-=65536)>>10),t=s%1024+56320,i.push(e,t)),(n+1===o||i.length>16384)&&(r+=_.apply(null,i),i.length=0)}return r},Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:x,configurable:!0,writable:!0}):String.fromCodePoint=x)}(t)},6274:(e,t,i)=>{"use strict";const{SymbolAsyncIterator:n,SymbolIterator:o,SymbolFor:r}=i(3383),s=r("nodejs.stream.destroyed"),a=r("nodejs.stream.errored"),c=r("nodejs.stream.readable"),l=r("nodejs.stream.writable"),p=r("nodejs.stream.disturbed"),u=r("nodejs.webstream.isClosedPromise"),d=r("nodejs.webstream.controllerErrorFunction");function h(e,t=!1){var i;return!(!e||"function"!=typeof e.pipe||"function"!=typeof e.on||t&&("function"!=typeof e.pause||"function"!=typeof e.resume)||e._writableState&&!1===(null===(i=e._readableState)||void 0===i?void 0:i.readable)||e._writableState&&!e._readableState)}function m(e){var t;return!(!e||"function"!=typeof e.write||"function"!=typeof e.on||e._readableState&&!1===(null===(t=e._writableState)||void 0===t?void 0:t.writable))}function f(e){return e&&(e._readableState||e._writableState||"function"==typeof e.write&&"function"==typeof e.on||"function"==typeof e.pipe&&"function"==typeof e.on)}function g(e){return!(!e||f(e)||"function"!=typeof e.pipeThrough||"function"!=typeof e.getReader||"function"!=typeof e.cancel)}function v(e){return!(!e||f(e)||"function"!=typeof e.getWriter||"function"!=typeof e.abort)}function y(e){return!(!e||f(e)||"object"!=typeof e.readable||"object"!=typeof e.writable)}function b(e){if(!f(e))return null;const t=e._writableState,i=e._readableState,n=t||i;return!!(e.destroyed||e[s]||null!=n&&n.destroyed)}function w(e){if(!m(e))return null;if(!0===e.writableEnded)return!0;const t=e._writableState;return(null==t||!t.errored)&&("boolean"!=typeof(null==t?void 0:t.ended)?null:t.ended)}function _(e,t){if(!h(e))return null;const i=e._readableState;return(null==i||!i.errored)&&("boolean"!=typeof(null==i?void 0:i.endEmitted)?null:!!(i.endEmitted||!1===t&&!0===i.ended&&0===i.length))}function S(e){return e&&null!=e[c]?e[c]:"boolean"!=typeof(null==e?void 0:e.readable)?null:!b(e)&&(h(e)&&e.readable&&!_(e))}function x(e){return e&&null!=e[l]?e[l]:"boolean"!=typeof(null==e?void 0:e.writable)?null:!b(e)&&(m(e)&&e.writable&&!w(e))}function T(e){return"boolean"==typeof e._closed&&"boolean"==typeof e._defaultKeepAlive&&"boolean"==typeof e._removedConnection&&"boolean"==typeof e._removedContLen}function E(e){return"boolean"==typeof e._sent100&&T(e)}e.exports={isDestroyed:b,kIsDestroyed:s,isDisturbed:function(e){var t;return!(!e||!(null!==(t=e[p])&&void 0!==t?t:e.readableDidRead||e.readableAborted))},kIsDisturbed:p,isErrored:function(e){var t,i,n,o,r,s,c,l,p,u;return!(!e||!(null!==(t=null!==(i=null!==(n=null!==(o=null!==(r=null!==(s=e[a])&&void 0!==s?s:e.readableErrored)&&void 0!==r?r:e.writableErrored)&&void 0!==o?o:null===(c=e._readableState)||void 0===c?void 0:c.errorEmitted)&&void 0!==n?n:null===(l=e._writableState)||void 0===l?void 0:l.errorEmitted)&&void 0!==i?i:null===(p=e._readableState)||void 0===p?void 0:p.errored)&&void 0!==t?t:null===(u=e._writableState)||void 0===u?void 0:u.errored))},kIsErrored:a,isReadable:S,kIsReadable:c,kIsClosedPromise:u,kControllerErrorFunction:d,kIsWritable:l,isClosed:function(e){if(!f(e))return null;if("boolean"==typeof e.closed)return e.closed;const t=e._writableState,i=e._readableState;return"boolean"==typeof(null==t?void 0:t.closed)||"boolean"==typeof(null==i?void 0:i.closed)?(null==t?void 0:t.closed)||(null==i?void 0:i.closed):"boolean"==typeof e._closed&&T(e)?e._closed:null},isDuplexNodeStream:function(e){return!(!e||"function"!=typeof e.pipe||!e._readableState||"function"!=typeof e.on||"function"!=typeof e.write)},isFinished:function(e,t){return f(e)?!!b(e)||(!1===(null==t?void 0:t.readable)||!S(e))&&(!1===(null==t?void 0:t.writable)||!x(e)):null},isIterable:function(e,t){return null!=e&&(!0===t?"function"==typeof e[n]:!1===t?"function"==typeof e[o]:"function"==typeof e[n]||"function"==typeof e[o])},isReadableNodeStream:h,isReadableStream:g,isReadableEnded:function(e){if(!h(e))return null;if(!0===e.readableEnded)return!0;const t=e._readableState;return!(!t||t.errored)&&("boolean"!=typeof(null==t?void 0:t.ended)?null:t.ended)},isReadableFinished:_,isReadableErrored:function(e){var t,i;return f(e)?e.readableErrored?e.readableErrored:null!==(t=null===(i=e._readableState)||void 0===i?void 0:i.errored)&&void 0!==t?t:null:null},isNodeStream:f,isWebStream:function(e){return g(e)||v(e)||y(e)},isWritable:x,isWritableNodeStream:m,isWritableStream:v,isWritableEnded:w,isWritableFinished:function(e,t){if(!m(e))return null;if(!0===e.writableFinished)return!0;const i=e._writableState;return(null==i||!i.errored)&&("boolean"!=typeof(null==i?void 0:i.finished)?null:!!(i.finished||!1===t&&!0===i.ended&&0===i.length))},isWritableErrored:function(e){var t,i;return f(e)?e.writableErrored?e.writableErrored:null!==(t=null===(i=e._writableState)||void 0===i?void 0:i.errored)&&void 0!==t?t:null:null},isServerRequest:function(e){var t;return"boolean"==typeof e._consuming&&"boolean"==typeof e._dumped&&void 0===(null===(t=e.req)||void 0===t?void 0:t.upgradeOrConnect)},isServerResponse:E,willEmitClose:function(e){if(!f(e))return null;const t=e._writableState,i=e._readableState,n=t||i;return!n&&E(e)||!!(n&&n.autoDestroy&&n.emitClose&&!1===n.closed)},isTransformStream:y}},6284:(e,t,i)=>{"use strict";i.d(t,{$:()=>l,parseHTTPHeadersQuotedKeyValueSet:()=>c});var n=i(9145);const o='"',r="=",s=", ",a=/\w+=(".*?"|[^",]+)(?=,|$)/g;function c(e,t,i=[],o=[]){const s=e.trim().match(a);if(!s)throw new n.w("E_MALFORMED_QUOTEDKEYVALUE",e);const c=s.map(((e,t)=>{const[i,...o]=e.split(r),s=o.join(r);if(0===o.length)throw new n.w("E_MALFORMED_QUOTEDKEYVALUE",t,e);return[i,s]})).reduce((function(e,[i,r],s){const a=i.toLowerCase();if(-1===t.indexOf(a))throw new n.w("E_UNAUTHORIZED_KEY",s,a);const c=r.replace(/^"(.+(?="$))"$/,"$1");return e[a]=o.includes(a)?c.toLowerCase():c,e}),{});return p(i,c),c}function l(e,t,i=[]){return p(i,e),t.reduce((function(t,i){return e[i]?t+(t?s:"")+i+r+o+e[i]+o:t}),"")}function p(e,t){e.forEach((e=>{if("undefined"==typeof t[e])throw new n.w("E_REQUIRED_KEY",e)}))}},6297:function(e){(function(){e.exports=function(){function e(){}return e.prototype.handleError=function(e){throw new Error(e)},e}()}).call(this)},6344:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=i(5899),o={objectMode:!0},r={clean:!0};t.default=class{constructor(e){this.options=e||{},this.options=Object.assign(Object.assign({},r),e),this._inflights=new Map}put(e,t){return this._inflights.set(e.messageId,e),t&&t(),this}createStream(){const e=new n.Readable(o),t=[];let i=!1,r=0;return this._inflights.forEach(((e,i)=>{t.push(e)})),e._read=()=>{!i&&r<t.length?e.push(t[r++]):e.push(null)},e.destroy=t=>{if(!i)return i=!0,setTimeout((()=>{e.emit("close")}),0),e},e}del(e,t){const i=this._inflights.get(e.messageId);return i?(this._inflights.delete(e.messageId),t(null,i)):t&&t(new Error("missing packet")),this}get(e,t){const i=this._inflights.get(e.messageId);return i?t(null,i):t&&t(new Error("missing packet")),this}close(e){this.options.clean&&(this._inflights=null),e&&e()}}},6356:(e,t,i)=>{const n=i(2018),o=i(9023);t.init=function(e){e.inspectOpts={};const i=Object.keys(t.inspectOpts);for(let n=0;n<i.length;n++)e.inspectOpts[i[n]]=t.inspectOpts[i[n]]},t.log=function(...e){return process.stderr.write(o.formatWithOptions(t.inspectOpts,...e)+"\n")},t.formatArgs=function(i){const{namespace:n,useColors:o}=this;if(o){const t=this.color,o="[3"+(t<8?t:"8;5;"+t),r=` ${o};1m${n} [0m`;i[0]=r+i[0].split("\n").join("\n"+r),i.push(o+"m+"+e.exports.humanize(this.diff)+"[0m")}else i[0]=function(){if(t.inspectOpts.hideDate)return"";return(new Date).toISOString()+" "}()+n+" "+i[0]},t.save=function(e){e?process.env.DEBUG=e:delete process.env.DEBUG},t.load=function(){return process.env.DEBUG},t.useColors=function(){return"colors"in t.inspectOpts?Boolean(t.inspectOpts.colors):n.isatty(process.stderr.fd)},t.destroy=o.deprecate((()=>{}),"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{const e=i(9930);e&&(e.stderr||e).level>=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}t.inspectOpts=Object.keys(process.env).filter((e=>/^debug_/i.test(e))).reduce(((e,t)=>{const i=t.substring(6).toLowerCase().replace(/_([a-z])/g,((e,t)=>t.toUpperCase()));let n=process.env[t];return n=!!/^(yes|on|true|enabled)$/i.test(n)||!/^(no|off|false|disabled)$/i.test(n)&&("null"===n?null:Number(n)),e[i]=n,e}),{}),e.exports=i(5329)(t);const{formatters:r}=e.exports;r.o=function(e){return this.inspectOpts.colors=this.useColors,o.inspect(e,this.inspectOpts).split("\n").map((e=>e.trim())).join(" ")},r.O=function(e){return this.inspectOpts.colors=this.useColors,o.inspect(e,this.inspectOpts)}},6357:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReolinkHubClient=void 0;const n=i(6739),o=i(2203),r=i(7260),s=i(3087);t.ReolinkHubClient=class{constructor(e,t,i,n){this.host=e,this.username=t,this.password=i,this.console=n,this.loggingIn=!1,this.loggedIn=!1,this.rebooting=!1,this.conmnectionTime=Date.now(),this.maxSessionsCount=0,this.loginFirstCount=0,this.createReadable=e=>{const t=new o.PassThrough;return t.write(Buffer.from(JSON.stringify(e))),t.end(),t},this.credential={username:t,password:i}}async request(e,t){return await(0,n.authHttpFetch)({...e,rejectUnauthorized:!1,credential:this.credential,body:t})}async login(){if(this.parameters&&this.tokenLease&&this.tokenLease>Date.now())return;if(this.loggingIn)return;this.loggingIn=!0,this.tokenLease&&this.parameters?this.console.log(`Token expired at ${new Date(this.tokenLease).toISOString()}, renewing`):this.console.log("Creating authentication session");const{parameters:e,leaseTimeSeconds:t}=await(0,s.getLoginParameters)(this.host,this.username,this.password,!0);this.parameters=e;const i=Date.now();this.tokenLease=i+1e3*t,this.loggingIn=!1,this.loggedIn=!0,this.conmnectionTime=i}async checkErrors(){this.rebooting||(Date.now()-this.conmnectionTime>36e5||this.loginFirstCount>5?(this.console.log("Reconnecting"),await this.reconnect()):this.maxSessionsCount>5&&await this.reboot())}async requestWithLogin(e,t){if(await this.login(),!this.parameters)return;if(this.rebooting)return;const i=e.url.searchParams;for(const[e,t]of Object.entries(this.parameters))i.set(e,t);const n=await this.request(e,t),o=n?.body?.filter((e=>e.error)).map((e=>e.error));if(o.length)for(const e of o){const t=e.rspCode;[-6].includes(t)?this.loginFirstCount++:[-5].includes(t)?this.maxSessionsCount++:(this.maxSessionsCount=0,this.loginFirstCount=0)}return n}async reboot(){const e=new URL(`http://${this.host}/api.cgi`);e.searchParams.set("cmd","Reboot"),this.rebooting=!0;const t=await this.requestWithLogin({url:e,responseType:"json"});return setTimeout((()=>{this.rebooting=!1,this.maxSessionsCount=0,this.loginFirstCount=0}),6e4),{value:t?.body?.[0]?.value?.rspCode,data:t?.body}}async logout(){const e=new URL(`http://${this.host}/api.cgi`);await this.requestWithLogin({url:e,responseType:"json",method:"POST"},this.createReadable([{cmd:"Logout"}])),this.tokenLease=void 0,this.parameters={}}async reconnect(){await this.logout(),await this.login()}async getOsd(e){const t=new URL(`http://${this.host}/api.cgi`),i=[{cmd:"GetOsd",action:1,param:{channel:e}}],n=await this.requestWithLogin({url:t,responseType:"json",method:"POST"},this.createReadable(i)),o=n?.body?.find((e=>e.error))?.error;return o&&this.console.error("error during call to getOsd",o),n?.body?.[0]}async setOsd(e,t){const i=new URL(`http://${this.host}/api.cgi`),n=[{cmd:"SetOsd",param:{Osd:{channel:e,osdChannel:t.value.Osd.osdChannel,osdTime:t.value.Osd.osdTime}}}],o=await this.requestWithLogin({url:i,responseType:"json",method:"POST"},this.createReadable(n)),r=o?.body?.find((e=>e.error))?.error;r&&this.console.error("error during call to getOsd",r)}async getAiState(e){const t=new URL(`http://${this.host}/api.cgi`),i=t.searchParams;i.set("cmd","GetAiState"),i.set("channel",String(e));const n=await this.requestWithLogin({url:t,responseType:"json"});return{value:n?.body?.[0]?.value||n?.body?.value,data:n?.body}}printErrors(e,t,i){const n=e?.body?.filter((e=>e.error)).map((e=>({...e.error,cmd:e.cmd})));n.length&&this.console.error(`error during call to ${t}`,JSON.stringify({errors:n,body:i}))}async getHubInfo(){const e=new URL(`http://${this.host}/api.cgi`),t=[{cmd:"GetAbility",action:0,param:{User:{userName:this.username}}},{cmd:"GetDevInfo",action:0,param:{}}],i=await this.requestWithLogin({url:e,responseType:"json",method:"POST"},this.createReadable(t));this.printErrors(i,"getHubInfo",t);const n=i.body.find((e=>"GetAbility"===e.cmd))?.value,o=i.body.find((e=>"GetDevInfo"===e.cmd))?.value;return{abilities:n,hubData:o,response:i.body}}async jpegSnapshot(e,t=1e4){const i=new URL(`http://${this.host}/cgi-bin/api.cgi`),n=i.searchParams;n.set("cmd","Snap"),n.set("channel",String(e)),n.set("rs",Date.now().toString());const o=await this.requestWithLogin({url:i,timeout:t});return o?.body}async getEncoderConfiguration(e){const t=new URL(`http://${this.host}/api.cgi`),i=t.searchParams;i.set("cmd","GetEnc"),i.set("channel",String(e));const n=await this.requestWithLogin({url:t,responseType:"json"});return n?.body?.[0]?.value?.Enc}async ptzOp(e,t,i,n){const o=new URL(`http://${this.host}/api.cgi`);o.searchParams.set("cmd","PtzCtrl");const s=this.requestWithLogin({url:o,method:"POST",responseType:"text"},this.createReadable([{cmd:"PtzCtrl",param:{channel:e,op:t,speed:i,timeout:1,id:n}}]));await(0,r.sleep)(500);const a=this.requestWithLogin({url:o,method:"POST"},this.createReadable([{cmd:"PtzCtrl",param:{channel:e,op:"Stop"}}]));this.console.log(await s),this.console.log(await a)}async presetOp(e,t,i){const n=new URL(`http://${this.host}/api.cgi`);n.searchParams.set("cmd","PtzCtrl");this.requestWithLogin({url:n,method:"POST",responseType:"text"},this.createReadable([{cmd:"PtzCtrl",param:{channel:e,op:"ToPos",speed:t,id:i}}]))}async ptz(e,t){if(t.preset&&!Number.isNaN(Number(t.preset)))return void await this.presetOp(e,1,Number(t.preset));let i="";t.pan<0?i+="Left":t.pan>0&&(i+="Right"),t.tilt<0?i+="Down":t.tilt>0&&(i+="Up"),i&&await this.ptzOp(e,i,Math.ceil(10*Math.abs(t?.pan||t?.tilt||1))),i=void 0,t.zoom<0?i="ZoomDec":t.zoom>0&&(i="ZoomInc"),i&&await this.ptzOp(e,i,Math.ceil(10*Math.abs(t?.zoom||1)))}async getSiren(e){const t=new URL(`http://${this.host}/api.cgi`),i=[{cmd:"GetAudioAlarmV20",action:0,param:{channel:e}}],n=await this.requestWithLogin({url:t,method:"POST",responseType:"json"},this.createReadable(i)),o=n?.body?.[0]?.error;return o&&this.console.error("error during call to getSiren",JSON.stringify(i),o),{enabled:1===n?.body?.[0]?.value?.Audio?.enable}}async setSiren(e,t,i){const n=new URL(`http://${this.host}/api.cgi`);let o;n.searchParams.set("cmd","AudioAlarmPlay"),o=i?{alarm_mode:"times",times:i}:{alarm_mode:"manul",manual_switch:t?1:0};const r=await this.requestWithLogin({url:n,method:"POST",responseType:"json"},this.createReadable([{cmd:"AudioAlarmPlay",action:0,param:{channel:e,...o}}]));return{value:r?.body?.[0]?.value||r?.body?.value,data:r?.body}}async setWhiteLedState(e,t,i){const n=new URL(`http://${this.host}/api.cgi`),o={channel:e};void 0!==t&&(o.state=t?1:0),void 0!==i&&(o.bright=i);const r=[{cmd:"SetWhiteLed",param:{WhiteLed:o}}],s=await this.requestWithLogin({url:n,method:"POST",responseType:"json"},this.createReadable(r)),a=s?.body?.[0]?.error;a&&this.console.error("error during call to setWhiteLedState",JSON.stringify(r),a)}async getStatusInfo(e){const t=new URL(`http://${this.host}/api.cgi`),i={},n=[];e.forEach((({hasFloodlight:e,hasPirEvents:t,hasPtz:o,sleeping:r},s)=>{i[s]={},r||(n.push({cmd:"GetOsd",action:1,param:{channel:s}}),i[s].osd=n.length-1,e&&(n.push({cmd:"GetWhiteLed",action:0,param:{channel:s}}),i[s].floodlight=n.length-1),t&&(n.push({cmd:"GetPirInfo",action:0,param:{channel:s}}),i[s].pir=n.length-1),o&&(n.push({cmd:"GetPtzPreset",action:1,param:{channel:s}}),i[s].presets=n.length-1))}));const o={},r=await this.requestWithLogin({url:t,responseType:"json",method:"POST"},this.createReadable(n));return this.printErrors(r,"getStatusInfo",n),e.forEach((({hasFloodlight:e,hasPirEvents:t,hasPtz:n},s)=>{const{floodlight:a,pir:c,presets:l,osd:p}=i[s];if(o[s]={entries:[]},void 0!==p){const e=r?.body?.[p];o[s].osd=e,o[s].entries.push(e)}if(e&&void 0!==a){const e=r?.body?.[a];o[s].floodlightEnabled=1===e?.value?.WhiteLed?.state,o[s].entries.push(e)}if(t&&void 0!==c){const e=r?.body?.[c];o[s].pirEnabled=1===e?.value?.pirInfo?.enable,o[s].entries.push(e)}if(n&&void 0!==l){const e=r?.body?.[l];o[s].ptzPresets=e?.value?.PtzPreset?.filter((e=>1===e.enable)),o[s].entries.push(e)}})),{deviceStatusData:o,response:r.body}}async getBatteryInfo(e){const t=new URL(`http://${this.host}/api.cgi`),i={},n=[{cmd:"GetChannelstatus"}],o=[];e.forEach((({hasBattery:e},t)=>{e&&o.push(t)}));for(const e of o)n.push({cmd:"GetBatteryInfo",action:0,param:{channel:e}}),i[e]=n.length-1;const r=await this.requestWithLogin({url:t,responseType:"json",method:"POST"},this.createReadable(n));this.printErrors(r,"getBatteryInfo",n);const s={},a=r?.body?.[0];for(const e of o){const t=r?.body?.[i[e]]?.value?.Battery,n=a?.value?.status?.find((t=>t.channel===e));s[e]={entries:[t,n],batteryLevel:t?.batteryPercent,sleeping:1===n?.sleep}}return{batteryInfoData:s,response:r.body}}async getChannels(){const e=new URL(`http://${this.host}/api.cgi`),t=await this.requestWithLogin({url:e,responseType:"json",method:"POST"},this.createReadable([{cmd:"GetChannelstatus"}])),i=t.body?.[0]?.value?.status?.filter((e=>!!e.uid))?.map((e=>e.channel));return{channels:i,channelsResponse:t}}async getEvents(e){const t=new URL(`http://${this.host}/api.cgi`),i=[],n={};e.forEach((({hasPirEvents:e},t)=>{n[t]={},e?(i.push({cmd:"GetEvents",action:0,param:{channel:t}}),n[t].events=i.length-1):(i.push({cmd:"GetMdState",action:0,param:{channel:t}}),n[t].motion=i.length-1,i.push({cmd:"GetAiState",action:0,param:{channel:t}}),n[t].events=i.length-1)}));const o=await this.requestWithLogin({url:t,responseType:"json",method:"POST"},this.createReadable(i));if(!o)return{};const r={},s=e=>{const t=[];for(const i of Object.keys(e??{})){if("channel"===i)continue;const{support:n,alarm_state:o}=e[i];o&&t.push(i)}return t};return e.forEach((({hasPirEvents:e},t)=>{const{events:i,motion:a}=n[t];if(r[t]={motion:!1,objects:[],entries:[]},e){const e=o?.body?.[i],n=s(e?.value?.ai);r[t].motion=n.includes("other")||n.length>0,r[t].objects=n.filter((e=>"other"!==e)),r[t].entries.push(e)}else{const e=o?.body?.[i],n=o?.body?.[a],c=s(e?.value?.ai);r[t].motion=n?.value?.state,r[t].objects=c.filter((e=>"other"!==e)),r[t].entries.push(e,n)}})),this.printErrors(o,"getEvents",i),{parsed:r,response:o.body,body:o.body}}async getDevicesInfo(){const e=new URL(`http://${this.host}/api.cgi`),{channels:t,channelsResponse:i}=await this.getChannels(),n=[],o={};for(const e of t)o[e]={ai:n.length,chnInfo:n.length+1},n.push({cmd:"GetChnTypeInfo",action:0,param:{channel:e}},{cmd:"GetAiState",action:0,param:{channel:e}});const r=await this.requestWithLogin({url:e,responseType:"json",method:"POST"},this.createReadable(n)),s={};let a=0;for(const e of t){const t=2*a,n=r.body[t],o=r.body[t+1],c=i.body?.[0]?.value?.status?.find((t=>t?.channel===e));s[e]={entries:[n,o]},!n?.error&&(s[e].channelInfo=n?.value),!o?.error&&(s[e].ai=o?.value),s[e].channelStatus=c,a++}return this.printErrors(r,"getDevicesInfo",n),{devicesData:s,response:r.body,channels:t,channelsResponse:i,requestBody:n}}async getPirState(e){const t=new URL(`http://${this.host}/api.cgi`),i=[{cmd:"GetPirInfo",action:0,param:{channel:e}}],n=await this.requestWithLogin({url:t,method:"POST",responseType:"json"},this.createReadable(i)),o=n?.body?.[0]?.error;return o&&this.console.error("error during call to getPirState",JSON.stringify(i),o),{enabled:1===n?.body?.[0]?.value?.pirInfo?.enable,state:n?.body?.[0]?.value?.pirInfo}}async setPirState(e,t){const i=new URL(`http://${this.host}/api.cgi`),n=await this.getPirState(e),o=t?1:0;if(!n||n.state?.enable===o)return;const r=[{cmd:"SetPirInfo",action:0,param:{pirInfo:{...n,channel:e,enable:o}}}],s=await this.requestWithLogin({url:i,method:"POST",responseType:"json"},this.createReadable(r)),a=s?.body?.[0]?.error;a&&this.console.error("error during call to setPirState",JSON.stringify(r),a)}async getLocalLink(e){const t=new URL(`http://${this.host}/api.cgi`),i=[{cmd:"GetLocalLink",action:0,param:{}},{cmd:"GetWifiSignal",action:0,param:{channel:e}}],n=await this.requestWithLogin({url:t,method:"POST",responseType:"json"},this.createReadable(i)),o=n?.body?.[0]?.error;o&&this.console.error("error during call to getLocalLink",JSON.stringify(i),o);const r=n?.body?.find((e=>"GetLocalLink"===e.cmd))?.value?.LocalLink?.activeLink,s=n?.body?.find((e=>"GetWifiSignal"===e.cmd))?.value?.wifiSignal??void 0;let a=!1;return void 0!==s&&(a=s>=0&&s<=4),!a&&r&&(a="LAN"!==r),{activeLink:r,wifiSignal:s,isWifi:a}}async getVideoClips(e,t,i="main"){const n=new URL(`http://${this.host}/api.cgi`),o=new Date(t.startTime);let r=t.endTime?new Date(t.endTime):void 0;(!r||r.getDate()>o.getDate())&&(r=new Date(o),r.setHours(23),r.setMinutes(59),r.setSeconds(59));const s=[{cmd:"Search",action:1,param:{Search:{channel:e,streamType:i,onlyStatus:0,StartTime:{year:o.getFullYear(),mon:o.getMonth()+1,day:o.getDate(),hour:o.getHours(),min:o.getMinutes(),sec:o.getSeconds()},EndTime:{year:r.getFullYear(),mon:r.getMonth()+1,day:r.getDate(),hour:r.getHours(),min:r.getMinutes(),sec:r.getSeconds()}}}}];try{const e=await this.requestWithLogin({url:n,responseType:"json",method:"POST"},this.createReadable(s)),t=e?.body?.[0]?.error;return t?(this.console.log("Error fetching videoclips",t,JSON.stringify({body:s,url:n})),[]):e?.body?.[0]?.value?.SearchResult?.File??[]}catch(e){return this.console.log("Error fetching videoclips",e),[]}}async getVideoClipUrl(e,t){const i=e.split("/").pop();let n=e.replaceAll(" ","%20");n.startsWith("/")||(n=`/${n}`);const o=i.match(/.*Rec(\w{3})(?:_|_DST)(\d{8})_(\d{6})_.*/),r=`${o[2]}${o[3]}`,s=(this.parameters.token,`cgi-bin/api.cgi?cmd=Download&source=${n}&output=ha_playback_${r}.mp4&start=${r}&token=${this.parameters.token}`);return{downloadPathWithHost:`http://${this.host}/${s}`}}}},6465:function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.debug=t.WeriftError=void 0;const o=n(i(2502));class r extends Error{constructor(e){super(e.message)}toJSON(){return{message:this.message,payload:JSON.parse(JSON.stringify(this.payload)),path:this.path}}}t.WeriftError=r,t.debug=o.default.debug},6493:function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.safeKillFFmpeg=async function(e){if(!e)return;if(null!=e.exitCode)return;await new Promise((async t=>{e.on("exit",t);try{e.stdin.on("error",(()=>{})),e.stdin.write("q\n")}catch(e){}await(0,r.sleep)(2e3);for(const t of e.stdio)try{t?.destroy()}catch(e){}e.kill(),await(0,r.sleep)(2e3),e.kill("SIGKILL")}))},t.ffmpegLogInitialOutput=function(e,t,i,n){if(!e)return;const r=!!o.default.env.SCRYPTED_FFMPEG_NOISY||!!n?.getItem("SCRYPTED_FFMPEG_NOISY");function a(e){const n=o=>{const a=o.toString();for(const e of s)if(-1!==a.indexOf(e))return;if(!(r||i||-1===a.indexOf("frame=")&&-1===a.indexOf("size=")))return e(a),e("video/audio detected, discarding further input"),t.stdout.removeListener("data",n),void t.stderr.removeListener("data",n);e(a)};return n}t.stdout?.on("data",a(e.log)),t.stderr?.on("data",a(e.error)),t.on("exit",(()=>e.log("ffmpeg exited")))},t.safePrintFFmpegArguments=function(e,t){if(!e)return;const i=[];let n=!1;for(const e of t){try{if(n){const t=new URL(e);i.push(`${t.protocol}[REDACTED]`)}else i.push(e)}catch(t){i.push(e)}n="-i"===e}e.log(i.join(" "))};const o=n(i(932)),r=i(546),s=["decode_slice_header error","no frame!","non-existing PPS"]},6556:(e,t,i)=>{"undefined"==typeof process||"renderer"===process.type||!0===process.browser||process.__nwjs?e.exports=i(5336):e.exports=i(3482)},6560:(e,t,i)=>{e.exports=function(e){const t=i(4081).linerase;e.prototype.getVideoSources=function(e){this._request({service:"media",body:this._envelopeHeader()+'<GetVideoSources xmlns="http://www.onvif.org/ver10/media/wsdl"/>'+this._envelopeFooter()},function(i,n,o){i||(this.videoSources=t(n).getVideoSourcesResponse.videoSources,Array.isArray(this.videoSources)||(this.videoSources=[this.videoSources])),e&&e.call(this,i,this.videoSources,o)}.bind(this))},e.prototype.getVideoSourceConfigurations=function(e){this._request({service:"media",body:this._envelopeHeader()+'<GetVideoSourceConfigurations xmlns="http://www.onvif.org/ver10/media/wsdl"/>'+this._envelopeFooter()},function(i,n,o){i||(this.videoSourceConfigurations=n[0].getVideoSourceConfigurationsResponse[0].configurations.map((function(e){var i=t(e);return{token:i.$.token,name:i.name,useCount:i.useCount,sourceToken:i.sourceToken,bounds:{height:i.bounds.$.height,width:i.bounds.$.width,x:i.bounds.$.x,y:i.bounds.$.y}}}))),e&&e.call(this,i,this.videoSourceConfigurations,o)}.bind(this))},e.prototype.getVideoEncoderConfiguration=function(e,i){if(void 0===i){if(i=e,!this.videoEncoderConfigurations||!this.videoEncoderConfigurations[0])return i(new Error("No video encoder configuration token is present!"));e=this.videoEncoderConfigurations[0].$.token}this._request({service:"media",body:this._envelopeHeader()+'<GetVideoEncoderConfiguration xmlns="http://www.onvif.org/ver10/media/wsdl"><ConfigurationToken>'+e+"</ConfigurationToken></GetVideoEncoderConfiguration>"+this._envelopeFooter()},function(e,n,o){i&&i.call(this,e,e?null:t(n[0].getVideoEncoderConfigurationResponse[0].configuration),o)}.bind(this))},e.prototype.getVideoEncoderConfigurationOptions=function(e,i){if(void 0===i){if(i=e,!this.videoEncoderConfigurations||!this.videoEncoderConfigurations[0])return i(new Error("No video encoder configuration token is present!"));e={configurationToken:this.videoEncoderConfigurations[0].$.token}}else if("string"==typeof e)e={configurationToken:e};else if(!e||!e.configurationToken&&!e.profileToken)return i(new Error("'options' must have one or both 'configurationToken' or 'profileToken'"));this._request({service:"media",body:this._envelopeHeader()+(e?'<GetVideoEncoderConfigurationOptions xmlns="http://www.onvif.org/ver10/media/wsdl">'+(e.configurationToken?"<ConfigurationToken>"+e.configurationToken+"</ConfigurationToken>":"")+(e.profileToken?"<ProfileToken>"+e.profileToken+"</ProfileToken>":"")+"</GetVideoEncoderConfigurationOptions>":'<GetVideoEncoderConfigurationOptions xmlns="http://www.onvif.org/ver10/media/wsdl" />')+this._envelopeFooter()},function(e,n,o){i&&i.call(this,e,e?null:t(n[0].getVideoEncoderConfigurationOptionsResponse[0].options),o)}.bind(this))},e.prototype.getVideoEncoderConfigurations=function(e){this._request({service:"media",body:this._envelopeHeader()+'<GetVideoEncoderConfigurations xmlns="http://www.onvif.org/ver10/media/wsdl"/>'+this._envelopeFooter()},function(i,n,o){i||(this.videoEncoderConfigurations=n[0].getVideoEncoderConfigurationsResponse[0].configurations.map((function(e){return t(e)}))),e&&e.call(this,i,this.videoEncoderConfigurations,o)}.bind(this))},e.prototype.setVideoEncoderConfiguration=function(e,i){if(!(e.token||e.$&&e.$.token))return i(new Error("No video encoder configuration token is present!"));this._request({service:"media",body:this._envelopeHeader()+'<SetVideoEncoderConfiguration xmlns="http://www.onvif.org/ver10/media/wsdl"><Configuration token = "'+(e.token||e.$.token)+'">'+(e.name?'<Name xmlns="http://www.onvif.org/ver10/schema">'+e.name+"</Name>":"")+(e.useCount?'<UseCount xmlns="http://www.onvif.org/ver10/schema">'+e.useCount+"</UseCount>":"")+(e.encoding?'<Encoding xmlns="http://www.onvif.org/ver10/schema">'+e.encoding+"</Encoding>":"")+(e.resolution?'<Resolution xmlns="http://www.onvif.org/ver10/schema">'+(e.resolution.width?"<Width>"+e.resolution.width+"</Width>":"")+(e.resolution.height?"<Height>"+e.resolution.height+"</Height>":"")+"</Resolution>":"")+(e.quality?'<Quality xmlns="http://www.onvif.org/ver10/schema">'+e.quality+"</Quality>":"")+(e.rateControl?'<RateControl xmlns="http://www.onvif.org/ver10/schema">'+(e.rateControl.frameRateLimit?"<FrameRateLimit>"+e.rateControl.frameRateLimit+"</FrameRateLimit>":"")+(e.rateControl.encodingInterval?"<EncodingInterval>"+e.rateControl.encodingInterval+"</EncodingInterval>":"")+(e.rateControl.bitrateLimit?"<BitrateLimit>"+e.rateControl.bitrateLimit+"</BitrateLimit>":"")+"</RateControl>":"")+(e.MPEG4?'<MPEG4 xmlns="http://www.onvif.org/ver10/schema">'+(e.MPEG4.govLength?"<GovLength>"+e.MPEG4.govLength+"</GovLength>":"")+(e.MPEG4.profile?"<MPEG4Profile>"+e.MPEG4.profile+"</MPEG4Profile>":"")+"</MPEG4>":"")+(e.H264?'<H264 xmlns="http://www.onvif.org/ver10/schema">'+(e.H264.govLength?"<GovLength>"+e.H264.govLength+"</GovLength>":"")+(e.H264.profile?"<H264Profile>"+e.H264.profile+"</H264Profile>":"")+"</H264>":"")+(e.multicast?'<Multicast xmlns="http://www.onvif.org/ver10/schema">'+(e.multicast.address?"<Address>"+(0===e.multicast.address?"0":(e.multicast.address.type?"<Type>"+e.multicast.address.type+"</Type>":"")+(e.multicast.address.IPv4Address?"<IPv4Address>"+e.multicast.address.IPv4Address+"</IPv4Address>":"")+(e.multicast.address.IPv6Address?"<IPv6Address>"+e.multicast.address.IPv6Address+"</IPv6Address>":""))+"</Address>":"")+(void 0!==e.multicast.port?"<Port>"+e.multicast.port+"</Port>":"")+(void 0!==e.multicast.TTL?"<TTL>"+e.multicast.TTL+"</TTL>":"")+(void 0!==e.multicast.autoStart?"<AutoStart>"+e.multicast.autoStart+"</AutoStart>":"")+"</Multicast>":"")+(e.sessionTimeout?'<SessionTimeout xmlns="http://www.onvif.org/ver10/schema">'+e.sessionTimeout+"</SessionTimeout>":"")+"</Configuration><ForcePersistence>true</ForcePersistence></SetVideoEncoderConfiguration>"+this._envelopeFooter()},function(n,o,r){if(n||""!==t(o).setVideoEncoderConfigurationResponse)return i.call(this,""!==t(o).setVideoEncoderConfigurationResponse?new Error("Wrong `SetVideoEncoderConfiguration` response"):n,o,r);this.getVideoEncoderConfiguration(e.token||e.$.token,i)}.bind(this))},e.prototype.getAudioSources=function(e){this._request({service:"media",body:this._envelopeHeader()+'<GetAudioSources xmlns="http://www.onvif.org/ver10/media/wsdl"/>'+this._envelopeFooter()},function(i,n,o){i||(this.audioSources=n[0].getAudioSourcesResponse[0].audioSources.map((function(e){return t(e)}))),e&&e.call(this,i,this.audioSources,o)}.bind(this))},e.prototype.getAudioEncoderConfigurations=function(e){this._request({service:"media",body:this._envelopeHeader()+'<GetAudioEncoderConfigurations xmlns="http://www.onvif.org/ver10/media/wsdl"/>'+this._envelopeFooter()},function(i,n,o){i||(this.audioEncoderConfigurations=n[0].getAudioEncoderConfigurationsResponse[0].configurations.map((function(e){return t(e)}))),e&&e.call(this,i,this.audioEncoderConfigurations,o)}.bind(this))},e.prototype.getAudioEncoderConfiguration=function(e,i){if(void 0===i){if(i=e,!this.audioEncoderConfigurations||!this.audioEncoderConfigurations[0])return i(new Error("No audio encoder configuration token is present!"));e=this.audioEncoderConfigurations[0].$.token}this._request({service:"media",body:this._envelopeHeader()+'<GetAudioEncoderConfiguration xmlns="http://www.onvif.org/ver10/media/wsdl"><ConfigurationToken>'+e+"</ConfigurationToken></GetAudioEncoderConfiguration>"+this._envelopeFooter()},function(e,n,o){i&&i.call(this,e,e?null:t(n[0].getAudioEncoderConfigurationResponse[0].configuration),o)}.bind(this))},e.prototype.getAudioEncoderConfigurationOptions=function(e,i){if(void 0===i){if(i=e,!this.audioEncoderConfigurations||!this.audioEncoderConfigurations[0])return i(new Error("No audio encoder configuration token is present!"));e=this.audioEncoderConfigurations[0].$.token}this._request({service:"media",body:this._envelopeHeader()+'<GetAudioEncoderConfigurationOptions xmlns="http://www.onvif.org/ver10/media/wsdl"><ConfigurationToken>'+e+"</ConfigurationToken></GetAudioEncoderConfigurationOptions>"+this._envelopeFooter()},function(e,n,o){i&&i.call(this,e,e?null:t(n[0].getAudioEncoderConfigurationOptionsResponse[0].options),o)}.bind(this))},e.prototype.setAudioEncoderConfiguration=function(e,i){if(!(e.token||e.$&&e.$.token))return i(new Error("No audio encoder configuration token is present!"));this._request({service:"media",body:this._envelopeHeader()+'<SetAudioEncoderConfiguration xmlns="http://www.onvif.org/ver10/media/wsdl"><Configuration token = "'+(e.token||e.$.token)+'">'+(e.name?'<Name xmlns="http://www.onvif.org/ver10/schema">'+e.name+"</Name>":"")+(e.useCount?'<UseCount xmlns="http://www.onvif.org/ver10/schema">'+e.useCount+"</UseCount>":"")+(e.encoding?'<Encoding xmlns="http://www.onvif.org/ver10/schema">'+e.encoding+"</Encoding>":"")+(e.bitrate?'<Bitrate xmlns="http://www.onvif.org/ver10/schema">'+e.bitrate+"</Bitrate>":"")+(e.sampleRate?'<SampleRate xmlns="http://www.onvif.org/ver10/schema">'+e.sampleRate+"</SampleRate>":"")+(e.multicast?'<Multicast xmlns="http://www.onvif.org/ver10/schema">'+(e.multicast.address?"<Address>"+(0===e.multicast.address?"0":(e.multicast.address.type?"<Type>"+e.multicast.address.type+"</Type>":"")+(e.multicast.address.IPv4Address?"<IPv4Address>"+e.multicast.address.IPv4Address+"</IPv4Address>":"")+(e.multicast.address.IPv6Address?"<IPv6Address>"+e.multicast.address.IPv6Address+"</IPv6Address>":""))+"</Address>":"")+(void 0!==e.multicast.port?"<Port>"+e.multicast.port+"</Port>":"")+(void 0!==e.multicast.TTL?"<TTL>"+e.multicast.TTL+"</TTL>":"")+(void 0!==e.multicast.autoStart?"<AutoStart>"+e.multicast.autoStart+"</AutoStart>":"")+"</Multicast>":"")+(e.sessionTimeout?'<SessionTimeout xmlns="http://www.onvif.org/ver10/schema">'+e.sessionTimeout+"</SessionTimeout>":"")+"</Configuration><ForcePersistence>true</ForcePersistence></SetAudioEncoderConfiguration>"+this._envelopeFooter()},function(n,o,r){if(n||""!==t(o).setAudioEncoderConfigurationResponse)return i.call(this,""!==t(o).setAudioEncoderConfigurationResponse?new Error("Wrong `SetAudioEncoderConfiguration` response"):n,o,r);this.getAudioEncoderConfiguration(e.token||e.$.token,i)}.bind(this))},e.prototype.getAudioSourceConfigurations=function(e){this._request({service:"media",body:this._envelopeHeader()+'<GetAudioSourceConfigurations xmlns="http://www.onvif.org/ver10/media/wsdl"/>'+this._envelopeFooter()},function(i,n,o){i||(this.audioSourceConfigurations=n[0].getAudioSourceConfigurationsResponse[0].configurations.map((function(e){return t(e)}))),e&&e.call(this,i,this.audioSourceConfigurations,o)}.bind(this))},e.prototype.getAudioOutputs=function(e){this._request({service:"media",body:this._envelopeHeader()+'<GetAudioOutputs xmlns="http://www.onvif.org/ver10/media/wsdl"/>'+this._envelopeFooter()},function(i,n,o){i||(this.audioOutputs=n[0].getAudioOutputsResponse[0].audioOutputs.map((function(e){return t(e)}))),e&&e.call(this,i,this.audioOutputs,o)}.bind(this))},e.prototype.getAudioOutputConfigurations=function(e){this._request({service:"media",body:this._envelopeHeader()+'<GetAudioOutputConfigurations xmlns="http://www.onvif.org/ver10/media/wsdl"/>'+this._envelopeFooter()},function(i,n,o){i||(this.audioOutputConfigurations=n[0].getAudioOutputConfigurationsResponse[0].configurations.map((function(e){return t(e)}))),e&&e.call(this,i,this.audioOutputConfigurations,o)}.bind(this))},e.prototype.addAudioEncoderConfiguration=function(e,t){let i=this._envelopeHeader()+'<AddAudioEncoderConfiguration xmlns="http://www.onvif.org/ver10/media/wsdl"><ProfileToken>'+e.profileToken+"</ProfileToken><ConfigurationToken>"+e.configurationToken+"</ConfigurationToken></AddAudioEncoderConfiguration>"+this._envelopeFooter();this._request({service:"media",body:i},function(e,i,n){t&&t.call(this,e,null,n)}.bind(this))},e.prototype.addAudioSourceConfiguration=function(e,t){let i=this._envelopeHeader()+'<AddAudioSourceConfiguration xmlns="http://www.onvif.org/ver10/media/wsdl"><ProfileToken>'+e.profileToken+"</ProfileToken><ConfigurationToken>"+e.configurationToken+"</ConfigurationToken></AddAudioSourceConfiguration>"+this._envelopeFooter();this._request({service:"media",body:i},function(e,i,n){t&&t.call(this,e,null,n)}.bind(this))},e.prototype.addVideoEncoderConfiguration=function(e,t){let i=this._envelopeHeader()+'<AddVideoEncoderConfiguration xmlns="http://www.onvif.org/ver10/media/wsdl"><ProfileToken>'+e.profileToken+"</ProfileToken><ConfigurationToken>"+e.configurationToken+"</ConfigurationToken></AddVideoEncoderConfiguration>"+this._envelopeFooter();this._request({service:"media",body:i},function(e,i,n){t&&t.call(this,e,null,n)}.bind(this))},e.prototype.addVideoSourceConfiguration=function(e,t){let i=this._envelopeHeader()+'<AddVideoSourceConfiguration xmlns="http://www.onvif.org/ver10/media/wsdl"><ProfileToken>'+e.profileToken+"</ProfileToken><ConfigurationToken>"+e.configurationToken+"</ConfigurationToken></AddVideoSourceConfiguration>"+this._envelopeFooter();this._request({service:"media",body:i},function(e,i,n){t&&t.call(this,e,null,n)}.bind(this))},e.prototype.removeAudioEncoderConfiguration=function(e,t){let i=this._envelopeHeader()+'<RemoveAudioEncoderConfiguration xmlns="http://www.onvif.org/ver10/media/wsdl"><ProfileToken>'+e+"</ProfileToken></RemoveAudioEncoderConfiguration>"+this._envelopeFooter();this._request({service:"media",body:i},function(e,i,n){t&&t.call(this,e,null,n)}.bind(this))},e.prototype.removeAudioSourceConfiguration=function(e,t){let i=this._envelopeHeader()+'<RemoveAudioSourceConfiguration xmlns="http://www.onvif.org/ver10/media/wsdl"><ProfileToken>'+e+"</ProfileToken></RemoveAudioSourceConfiguration>"+this._envelopeFooter();this._request({service:"media",body:i},function(e,i,n){t&&t.call(this,e,null,n)}.bind(this))},e.prototype.getProfiles=function(e){this.media2Support?this._request({service:"media2",body:this._envelopeHeader()+'<GetProfiles xmlns="http://www.onvif.org/ver20/media/wsdl"><Type>All</Type></GetProfiles>'+this._envelopeFooter()},function(i,n,o){i||(this.profiles=n[0].getProfilesResponse[0].profiles.map((function(e){let i=t(e),n={};return n.$=i.$,n.name=i.name,i.configurations.videoSource&&(n.videoSourceConfiguration=i.configurations.videoSource),i.configurations.audioSource&&(n.audioSourceConfiguration=i.configurations.audioSource),i.configurations.videoEncoder&&(n.videoEncoderConfiguration=i.configurations.videoEncoder),i.configurations.audioEncoder&&(n.audioEncoderConfiguration=i.configurations.audioEncoder),i.configurations.PTZ&&(n.PTZConfiguration=i.configurations.PTZ),i.configurations.analytics&&(n.analyticsConfiguration=i.configurations.analytics),i.configurations.metadata&&(n.metadataConfiguration=i.configurations.metadata),i.configurations.audioOutput&&(n.audioOutputConfiguration=i.configurations.audioOutput),i.configurations.audioOutput&&(n.audioDecoderConfiguration=i.configurations.audioDecoder),n}))),e&&e.call(this,i,this.profiles,o)}.bind(this)):this._request({service:"media",body:this._envelopeHeader()+'<GetProfiles xmlns="http://www.onvif.org/ver10/media/wsdl"/>'+this._envelopeFooter()},function(i,n,o){i||(this.profiles=n[0].getProfilesResponse[0].profiles.map((function(e){return t(e)}))),e&&e.call(this,i,this.profiles,o)}.bind(this))},e.prototype.createProfile=function(e,i){this._request({service:"media",body:this._envelopeHeader()+'<CreateProfile xmlns="http://www.onvif.org/ver10/media/wsdl"><Name>'+e.name+"</Name>"+(e.token?"<Token>"+e.token+"</Token>":"")+"</CreateProfile>"+this._envelopeFooter()},function(e,n,o){i&&i.call(this,e,e?null:t(n).createProfileResponse.profile,o)}.bind(this))},e.prototype.deleteProfile=function(e,i){this._request({service:"media",body:this._envelopeHeader()+'<DeleteProfile xmlns="http://www.onvif.org/ver10/media/wsdl"><ProfileToken>'+e+"</ProfileToken></DeleteProfile>"+this._envelopeFooter()},function(e,n,o){i&&i.call(this,e,e?null:t(n).deleteProfileResponse,o)}.bind(this))},e.prototype.getStreamUri=function(e,i){if(void 0===i&&(i=e,e={}),this.media2Support){let n=e.protocol||"RTSP",o=e.stream||"RTP-Unicast";"HTTP"==n&&(n="RtspOverHttp"),"UDP"==n&&"RTP-Unicast"==o&&(n="RtspUnicast"),"UDP"==n&&"RTP-Multicast"==o&&(n="RtspMulticast"),this._request({service:"media2",body:this._envelopeHeader()+'<GetStreamUri xmlns="http://www.onvif.org/ver20/media/wsdl"><Protocol>'+n+"</Protocol><ProfileToken>"+(e.profileToken||this.activeSource.profileToken)+"</ProfileToken></GetStreamUri>"+this._envelopeFooter()},function(e,n,o){i&&i.call(this,e,e?null:t(n).getStreamUriResponse,o)}.bind(this))}else this._request({service:"media",body:this._envelopeHeader()+'<GetStreamUri xmlns="http://www.onvif.org/ver10/media/wsdl"><StreamSetup><Stream xmlns="http://www.onvif.org/ver10/schema">'+(e.stream||"RTP-Unicast")+'</Stream><Transport xmlns="http://www.onvif.org/ver10/schema"><Protocol>'+(e.protocol||"RTSP")+"</Protocol></Transport></StreamSetup><ProfileToken>"+(e.profileToken||this.activeSource.profileToken)+"</ProfileToken></GetStreamUri>"+this._envelopeFooter()},function(e,n,o){i&&i.call(this,e,e?null:t(n).getStreamUriResponse.mediaUri,o)}.bind(this))},e.prototype.getSnapshotUri=function(e,i){void 0===i&&(i=e,e={}),this.media2Support?this._request({service:"media2",body:this._envelopeHeader()+'<GetSnapshotUri xmlns="http://www.onvif.org/ver20/media/wsdl"><ProfileToken>'+(e.profileToken||this.activeSource.profileToken)+"</ProfileToken></GetSnapshotUri>"+this._envelopeFooter()},function(e,n,o){i&&i.call(this,e,e?null:{uri:t(n).getSnapshotUriResponse.uri},o)}.bind(this)):this._request({service:"media",body:this._envelopeHeader()+'<GetSnapshotUri xmlns="http://www.onvif.org/ver10/media/wsdl"><ProfileToken>'+(e.profileToken||this.activeSource.profileToken)+"</ProfileToken></GetSnapshotUri>"+this._envelopeFooter()},function(e,n,o){i&&i.call(this,e,e?null:t(n).getSnapshotUriResponse.mediaUri,o)}.bind(this))},e.prototype.setSynchronizationPoint=function(e,t){void 0===t&&(t=e,e={}),this.media2Support?this._request({service:"media2",body:this._envelopeHeader()+'<SetSynchronizationPoint xmlns="http://www.onvif.org/ver20/media/wsdl"><ProfileToken>'+(e.profileToken||this.activeSource.profileToken)+"</ProfileToken></SetSynchronizationPoint>"+this._envelopeFooter()},function(e,i,n){t&&t.call(this,e,null,n)}.bind(this)):this._request({service:"media",body:this._envelopeHeader()+'<SetSynchronizationPoint xmlns="http://www.onvif.org/ver10/media/wsdl"><ProfileToken>'+(e.profileToken||this.activeSource.profileToken)+"</ProfileToken></SetSynchronizationPoint>"+this._envelopeFooter()},function(e,i,n){t&&t.call(this,e,null,n)}.bind(this))},e.prototype.getOSDs=function(e,i){void 0===i&&(i=e,e="");let n=this.media2Support?"media2":"media",o=this.media2Support?"http://www.onvif.org/ver20/media/wsdl":"http://www.onvif.org/ver10/media/wsdl";this._request({service:n,body:this._envelopeHeader()+'<GetOSDs xmlns="'+o+'" >'+(e?"<ConfigurationToken>"+e+"</ConfigurationToken>":"")+"</GetOSDs>"+this._envelopeFooter()},function(e,n,o){let r={};e||(r=t(n),Array.isArray(r.getOSDsResponse.OSDs)||(r.getOSDsResponse.OSDs=[r.getOSDsResponse.OSDs])),i&&i.call(this,e,e?null:r,o)}.bind(this))},e.prototype.getOSDOptions=function(e,i){void 0===i&&(i=e,e={});let n=this.media2Support?"media2":"media",o=this.media2Support?"http://www.onvif.org/ver20/media/wsdl":"http://www.onvif.org/ver10/media/wsdl";this._request({service:n,body:this._envelopeHeader()+'<GetOSDOptions xmlns="'+o+'" ><ConfigurationToken>'+(e.videoSourceConfiguationToken||this.activeSource.videoSourceConfigurationToken)+"</ConfigurationToken></GetOSDOptions>"+this._envelopeFooter()},function(e,n,o){i&&i.call(this,e,e?null:t(n),o)}.bind(this))},e.prototype.createOSD=function(e,i){void 0===i&&(i=e,e={});let n=this.media2Support?"media2":"media",o=this.media2Support?"http://www.onvif.org/ver20/media/wsdl":"http://www.onvif.org/ver10/media/wsdl";this._request({service:n,body:this._envelopeHeader()+`<wsdl:CreateOSD xmlns:wsdl="${o}" xmlns:sch="http://www.onvif.org/ver10/schema">\n <wsdl:OSD token="">\n <sch:VideoSourceConfigurationToken>${e.videoSourceConfiguationToken||this.activeSource.videoSourceConfigurationToken}</sch:VideoSourceConfigurationToken>\n\t\t\t\t\t\t<sch:Type>Text</sch:Type>\n\t\t\t\t\t\t<sch:Position>\n\t\t\t\t\t\t\t<sch:Type>${"object"==typeof e.position?"Custom":e.position?e.position:"LowerLeft"}</sch:Type>\n\t\t\t\t ${"object"==typeof e.position?'<sch:Pos x="'+e.position.x+'" y="'+e.position.y+'"/>':""}\n\t\t\t\t</sch:Position>\n\t\t\t\t <sch:TextString IsPersistentText="false">\n\t\t\t\t\t${e.dateFormat&&e.timeFormat?`<sch:Type>DateAndTime</sch:Type>\n\t\t\t\t\t\t\t\t\t<sch:DateFormat>${e.dateFormat}</sch:DateFormat>\n\t\t\t\t\t\t\t\t\t<sch:TimeFormat>${e.timeFormat}</sch:TimeFormat>`:`<sch:Type>Plain</sch:Type>\n\t\t\t\t\t\t\t\t\t<sch:PlainText>${e.plaintext}</sch:PlainText>`}\n\n\t\t\t\t\t${e.fontSize?`<sch:FontSize>${e.fontSize}</sch:FontSize>`:""}\t\t\t\t\n\t\t\t\t\t${e.fontColor&&e.fontColor.X&&e.fontColor.Y&&e.fontColor.Z?`\n\t\t\t\t\t\t\t\t\t<sch:FontColor>\n\t\t\t\t\t\t\t\t\t${'<sch:Color Z="'+e.fontColor.Z+'" Y="'+e.fontColor.Y+'" X="'+e.fontColor.X+'" Colorspace="'+("YCbCr"===e.colorspace?"http://www.onvif.org/ver10/colorspace/YCbCr":"http://www.onvif.org/ver10/colorspace/RGB")+'"/>'}\n\t\t\t\t\t\t\t\t\t</sch:FontColor>`:""}\n\t\t\t\t\t</sch:TextString>\n </wsdl:OSD>\n </wsdl:CreateOSD>`+this._envelopeFooter()},function(e,n,o){i&&i.call(this,e,e?null:t(n),o)}.bind(this))},e.prototype.setOSD=function(e,i){let n=this.media2Support?"media2":"media",o=this.media2Support?"http://www.onvif.org/ver20/media/wsdl":"http://www.onvif.org/ver10/media/wsdl";void 0===i&&(i=e,e={}),this._request({service:n,body:this._envelopeHeader()+`<wsdl:SetOSD xmlns:wsdl="${o}" xmlns:sch="http://www.onvif.org/ver10/schema">\n\t\t\t <wsdl:OSD token="${e.OSDToken}">\n\t\t\t\t<sch:VideoSourceConfigurationToken>${e.videoSourceConfigurationToken||this.activeSource.videoSourceConfigurationToken}</sch:VideoSourceConfigurationToken>\n\t\t\t\t<sch:Type>Text</sch:Type>\n\t\t\t\t<sch:Position>\n\t\t\t\t <sch:Type>${"object"==typeof e.position?"Custom":e.position?e.position:"LowerLeft"}</sch:Type>\n\t\t\t\t ${"object"==typeof e.position?'<sch:Pos x="'+e.position.x+'" y="'+e.position.y+'"/>':""}\n\t\t\t\t</sch:Position>\n\t\t\t\t <sch:TextString IsPersistentText="false">\n\t\t\t\t\t${e.dateFormat&&e.timeFormat?`<sch:Type>DateAndTime</sch:Type>\n\t\t\t\t\t\t\t\t\t<sch:DateFormat>${e.dateFormat}</sch:DateFormat>\n\t\t\t\t\t\t\t\t\t<sch:TimeFormat>${e.timeFormat}</sch:TimeFormat>`:`<sch:Type>Plain</sch:Type>\n\t\t\t\t\t\t\t\t\t<sch:PlainText>${e.plaintext}</sch:PlainText>`}\n\t\t\t\t\t\t\t\t\t${e.fontSize?`<sch:FontSize>${e.fontSize}</sch:FontSize>`:""}\t\t\t\t\n\t\t\t\t\t\t\t\t\t${e.fontColor&&e.fontColor.X&&e.fontColor.Y&&e.fontColor.Z?`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<sch:FontColor>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t${'<sch:Color Z="'+e.fontColor.Z+'" Y="'+e.fontColor.Y+'" X="'+e.fontColor.X+'" Colorspace="'+("YCbCr"===e.colorspace?"http://www.onvif.org/ver10/colorspace/YCbCr":"http://www.onvif.org/ver10/colorspace/RGB")+'"/>'}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</sch:FontColor>`:""}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</sch:TextString>\n\t\t\t\t\t\t\t\t\t\t\t\t </wsdl:OSD>\n\t\t\t\t\t\t\t\t\t\t\t\t</wsdl:SetOSD>`+this._envelopeFooter()},function(e,n,o){i&&i.call(this,e,e?null:t(n),o)}.bind(this))},e.prototype.deleteOSD=function(e,i){let n=this.media2Support?"media2":"media",o=this.media2Support?"http://www.onvif.org/ver20/media/wsdl":"http://www.onvif.org/ver10/media/wsdl";this._request({service:n,body:this._envelopeHeader()+'<DeleteOSD xmlns="'+o+'"><OSDToken>'+e+"</OSDToken></DeleteOSD>"+this._envelopeFooter()},function(e,n,o){i&&i.call(this,e,e?null:t(n),o)}.bind(this))},e.prototype.getMediaServiceCapabilities=function(e){this._request({service:"media",body:this._envelopeHeader()+'<GetServiceCapabilities xmlns="http://www.onvif.org/ver10/media/wsdl" />'+this._envelopeFooter()},function(i,n,o){e&&(i||(n=t(n[0].getServiceCapabilitiesResponse[0].capabilities),this.mediaCapabilities=n),e.call(this,i,n,o))}.bind(this))}}},6570:e=>{function t(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}t.keys=()=>[],t.resolve=t,t.id=6570,e.exports=t},6574:(e,t,i)=>{var n=i(7897);e.exports=function(e,t,i){return n(e,t,null,i)}},6578:(e,t,i)=>{"use strict";const n=i(6870),o=i(6982),r=i(7016),s=i(7441),a=i(8611),c=i(5692),l=i(9023),p=i(7589),u=i(3106),d=i(2203),h=i(4434);function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const f=m(n),g=m(o),v=m(r),y=m(s),b=m(a),w=m(c),_=m(l),S=m(p),x=m(u),T=m(d);function E(e,t){return function(){return e.apply(t,arguments)}}const{toString:C}=Object.prototype,{getPrototypeOf:P}=Object,{iterator:k,toStringTag:O}=Symbol,I=(A=Object.create(null),e=>{const t=C.call(e);return A[t]||(A[t]=t.slice(8,-1).toLowerCase())});var A;const R=e=>(e=e.toLowerCase(),t=>I(t)===e),D=e=>t=>typeof t===e,{isArray:M}=Array,N=D("undefined");const L=R("ArrayBuffer");const j=D("string"),F=D("function"),B=D("number"),U=e=>null!==e&&"object"==typeof e,q=e=>{if("object"!==I(e))return!1;const t=P(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||O in e||k in e)},V=R("Date"),H=R("File"),z=R("Blob"),$=R("FileList"),W=R("URLSearchParams"),[G,K,Y,Q]=["ReadableStream","Request","Response","Headers"].map(R);function J(e,t,{allOwnKeys:i=!1}={}){if(null===e||"undefined"==typeof e)return;let n,o;if("object"!=typeof e&&(e=[e]),M(e))for(n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else{const o=i?Object.getOwnPropertyNames(e):Object.keys(e),r=o.length;let s;for(n=0;n<r;n++)s=o[n],t.call(null,e[s],s,e)}}function Z(e,t){t=t.toLowerCase();const i=Object.keys(e);let n,o=i.length;for(;o-- >0;)if(n=i[o],t===n.toLowerCase())return n;return null}const X="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,ee=e=>!N(e)&&e!==X;const te=(ie="undefined"!=typeof Uint8Array&&P(Uint8Array),e=>ie&&e instanceof ie);var ie;const ne=R("HTMLFormElement"),oe=(({hasOwnProperty:e})=>(t,i)=>e.call(t,i))(Object.prototype),re=R("RegExp"),se=(e,t)=>{const i=Object.getOwnPropertyDescriptors(e),n={};J(i,((i,o)=>{let r;!1!==(r=t(i,o,e))&&(n[o]=r||i)})),Object.defineProperties(e,n)};const ae=R("AsyncFunction"),ce=(le="function"==typeof setImmediate,pe=F(X.postMessage),le?setImmediate:pe?(ue=`axios@${Math.random()}`,de=[],X.addEventListener("message",(({source:e,data:t})=>{e===X&&t===ue&&de.length&&de.shift()()}),!1),e=>{de.push(e),X.postMessage(ue,"*")}):e=>setTimeout(e));var le,pe,ue,de;const he="undefined"!=typeof queueMicrotask?queueMicrotask.bind(X):"undefined"!=typeof process&&process.nextTick||ce,me={isArray:M,isArrayBuffer:L,isBuffer:function(e){return null!==e&&!N(e)&&null!==e.constructor&&!N(e.constructor)&&F(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||F(e.append)&&("formdata"===(t=I(e))||"object"===t&&F(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&L(e.buffer),t},isString:j,isNumber:B,isBoolean:e=>!0===e||!1===e,isObject:U,isPlainObject:q,isReadableStream:G,isRequest:K,isResponse:Y,isHeaders:Q,isUndefined:N,isDate:V,isFile:H,isBlob:z,isRegExp:re,isFunction:F,isStream:e=>U(e)&&F(e.pipe),isURLSearchParams:W,isTypedArray:te,isFileList:$,forEach:J,merge:function e(){const{caseless:t}=ee(this)&&this||{},i={},n=(n,o)=>{const r=t&&Z(i,o)||o;q(i[r])&&q(n)?i[r]=e(i[r],n):q(n)?i[r]=e({},n):M(n)?i[r]=n.slice():i[r]=n};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&J(arguments[e],n);return i},extend:(e,t,i,{allOwnKeys:n}={})=>(J(t,((t,n)=>{i&&F(t)?e[n]=E(t,i):e[n]=t}),{allOwnKeys:n}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,i,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),i&&Object.assign(e.prototype,i)},toFlatObject:(e,t,i,n)=>{let o,r,s;const a={};if(t=t||{},null==e)return t;do{for(o=Object.getOwnPropertyNames(e),r=o.length;r-- >0;)s=o[r],n&&!n(s,e,t)||a[s]||(t[s]=e[s],a[s]=!0);e=!1!==i&&P(e)}while(e&&(!i||i(e,t))&&e!==Object.prototype);return t},kindOf:I,kindOfTest:R,endsWith:(e,t,i)=>{e=String(e),(void 0===i||i>e.length)&&(i=e.length),i-=t.length;const n=e.indexOf(t,i);return-1!==n&&n===i},toArray:e=>{if(!e)return null;if(M(e))return e;let t=e.length;if(!B(t))return null;const i=new Array(t);for(;t-- >0;)i[t]=e[t];return i},forEachEntry:(e,t)=>{const i=(e&&e[k]).call(e);let n;for(;(n=i.next())&&!n.done;){const i=n.value;t.call(e,i[0],i[1])}},matchAll:(e,t)=>{let i;const n=[];for(;null!==(i=e.exec(t));)n.push(i);return n},isHTMLForm:ne,hasOwnProperty:oe,hasOwnProp:oe,reduceDescriptors:se,freezeMethods:e=>{se(e,((t,i)=>{if(F(e)&&-1!==["arguments","caller","callee"].indexOf(i))return!1;const n=e[i];F(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+i+"'")}))}))},toObjectSet:(e,t)=>{const i={},n=e=>{e.forEach((e=>{i[e]=!0}))};return M(e)?n(e):n(String(e).split(t)),i},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,i){return t.toUpperCase()+i})),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:Z,global:X,isContextDefined:ee,isSpecCompliantForm:function(e){return!!(e&&F(e.append)&&"FormData"===e[O]&&e[k])},toJSONObject:e=>{const t=new Array(10),i=(e,n)=>{if(U(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[n]=e;const o=M(e)?[]:{};return J(e,((e,t)=>{const r=i(e,n+1);!N(r)&&(o[t]=r)})),t[n]=void 0,o}}return e};return i(e,0)},isAsyncFn:ae,isThenable:e=>e&&(U(e)||F(e))&&F(e.then)&&F(e.catch),setImmediate:ce,asap:he,isIterable:e=>null!=e&&F(e[k])};function fe(e,t,i,n,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),i&&(this.config=i),n&&(this.request=n),o&&(this.response=o,this.status=o.status?o.status:null)}me.inherits(fe,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:me.toJSONObject(this.config),code:this.code,status:this.status}}});const ge=fe.prototype,ve={};function ye(e){return me.isPlainObject(e)||me.isArray(e)}function be(e){return me.endsWith(e,"[]")?e.slice(0,-2):e}function we(e,t,i){return e?e.concat(t).map((function(e,t){return e=be(e),!i&&t?"["+e+"]":e})).join(i?".":""):t}["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((e=>{ve[e]={value:e}})),Object.defineProperties(fe,ve),Object.defineProperty(ge,"isAxiosError",{value:!0}),fe.from=(e,t,i,n,o,r)=>{const s=Object.create(ge);return me.toFlatObject(e,s,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),fe.call(s,e.message,t,i,n,o),s.cause=e,s.name=e.name,r&&Object.assign(s,r),s};const _e=me.toFlatObject(me,{},null,(function(e){return/^is[A-Z]/.test(e)}));function Se(e,t,i){if(!me.isObject(e))throw new TypeError("target must be an object");t=t||new(f.default||FormData);const n=(i=me.toFlatObject(i,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!me.isUndefined(t[e])}))).metaTokens,o=i.visitor||l,r=i.dots,s=i.indexes,a=(i.Blob||"undefined"!=typeof Blob&&Blob)&&me.isSpecCompliantForm(t);if(!me.isFunction(o))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(me.isDate(e))return e.toISOString();if(me.isBoolean(e))return e.toString();if(!a&&me.isBlob(e))throw new fe("Blob is not supported. Use a Buffer instead.");return me.isArrayBuffer(e)||me.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function l(e,i,o){let a=e;if(e&&!o&&"object"==typeof e)if(me.endsWith(i,"{}"))i=n?i:i.slice(0,-2),e=JSON.stringify(e);else if(me.isArray(e)&&function(e){return me.isArray(e)&&!e.some(ye)}(e)||(me.isFileList(e)||me.endsWith(i,"[]"))&&(a=me.toArray(e)))return i=be(i),a.forEach((function(e,n){!me.isUndefined(e)&&null!==e&&t.append(!0===s?we([i],n,r):null===s?i:i+"[]",c(e))})),!1;return!!ye(e)||(t.append(we(o,i,r),c(e)),!1)}const p=[],u=Object.assign(_e,{defaultVisitor:l,convertValue:c,isVisitable:ye});if(!me.isObject(e))throw new TypeError("data must be an object");return function e(i,n){if(!me.isUndefined(i)){if(-1!==p.indexOf(i))throw Error("Circular reference detected in "+n.join("."));p.push(i),me.forEach(i,(function(i,r){!0===(!(me.isUndefined(i)||null===i)&&o.call(t,i,me.isString(r)?r.trim():r,n,u))&&e(i,n?n.concat(r):[r])})),p.pop()}}(e),t}function xe(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function Te(e,t){this._pairs=[],e&&Se(e,this,t)}const Ee=Te.prototype;function Ce(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Pe(e,t,i){if(!t)return e;const n=i&&i.encode||Ce;me.isFunction(i)&&(i={serialize:i});const o=i&&i.serialize;let r;if(r=o?o(t,i):me.isURLSearchParams(t)?t.toString():new Te(t,i).toString(n),r){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e}Ee.append=function(e,t){this._pairs.push([e,t])},Ee.toString=function(e){const t=e?function(t){return e.call(this,t,xe)}:xe;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};const ke=class{constructor(){this.handlers=[]}use(e,t,i){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!i&&i.synchronous,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){me.forEach(this.handlers,(function(t){null!==t&&e(t)}))}},Oe={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Ie=v.default.URLSearchParams,Ae="abcdefghijklmnopqrstuvwxyz",Re="0123456789",De={DIGIT:Re,ALPHA:Ae,ALPHA_DIGIT:Ae+Ae.toUpperCase()+Re},Me={isNode:!0,classes:{URLSearchParams:Ie,FormData:f.default,Blob:"undefined"!=typeof Blob&&Blob||null},ALPHABET:De,generateString:(e=16,t=De.ALPHA_DIGIT)=>{let i="";const{length:n}=t,o=new Uint32Array(e);g.default.randomFillSync(o);for(let r=0;r<e;r++)i+=t[o[r]%n];return i},protocols:["http","https","file","data"]},Ne="undefined"!=typeof window&&"undefined"!=typeof document,Le="object"==typeof navigator&&navigator||void 0,je=Ne&&(!Le||["ReactNative","NativeScript","NS"].indexOf(Le.product)<0),Fe="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,Be=Ne&&window.location.href||"http://localhost",Ue={...Object.freeze({__proto__:null,hasBrowserEnv:Ne,hasStandardBrowserWebWorkerEnv:Fe,hasStandardBrowserEnv:je,navigator:Le,origin:Be}),...Me};function qe(e){function t(e,i,n,o){let r=e[o++];if("__proto__"===r)return!0;const s=Number.isFinite(+r),a=o>=e.length;if(r=!r&&me.isArray(n)?n.length:r,a)return me.hasOwnProp(n,r)?n[r]=[n[r],i]:n[r]=i,!s;n[r]&&me.isObject(n[r])||(n[r]=[]);return t(e,i,n[r],o)&&me.isArray(n[r])&&(n[r]=function(e){const t={},i=Object.keys(e);let n;const o=i.length;let r;for(n=0;n<o;n++)r=i[n],t[r]=e[r];return t}(n[r])),!s}if(me.isFormData(e)&&me.isFunction(e.entries)){const i={};return me.forEachEntry(e,((e,n)=>{t(function(e){return me.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),n,i,0)})),i}return null}const Ve={transitional:Oe,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const i=t.getContentType()||"",n=i.indexOf("application/json")>-1,o=me.isObject(e);o&&me.isHTMLForm(e)&&(e=new FormData(e));if(me.isFormData(e))return n?JSON.stringify(qe(e)):e;if(me.isArrayBuffer(e)||me.isBuffer(e)||me.isStream(e)||me.isFile(e)||me.isBlob(e)||me.isReadableStream(e))return e;if(me.isArrayBufferView(e))return e.buffer;if(me.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let r;if(o){if(i.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return Se(e,new Ue.classes.URLSearchParams,Object.assign({visitor:function(e,t,i,n){return Ue.isNode&&me.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((r=me.isFileList(e))||i.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return Se(r?{"files[]":e}:e,t&&new t,this.formSerializer)}}return o||n?(t.setContentType("application/json",!1),function(e,t,i){if(me.isString(e))try{return(t||JSON.parse)(e),me.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(i||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||Ve.transitional,i=t&&t.forcedJSONParsing,n="json"===this.responseType;if(me.isResponse(e)||me.isReadableStream(e))return e;if(e&&me.isString(e)&&(i&&!this.responseType||n)){const i=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(e){if(i){if("SyntaxError"===e.name)throw fe.from(e,fe.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ue.classes.FormData,Blob:Ue.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};me.forEach(["delete","get","head","post","put","patch"],(e=>{Ve.headers[e]={}}));const He=Ve,ze=me.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),$e=Symbol("internals");function We(e){return e&&String(e).trim().toLowerCase()}function Ge(e){return!1===e||null==e?e:me.isArray(e)?e.map(Ge):String(e)}function Ke(e,t,i,n,o){return me.isFunction(n)?n.call(this,t,i):(o&&(t=i),me.isString(t)?me.isString(n)?-1!==t.indexOf(n):me.isRegExp(n)?n.test(t):void 0:void 0)}class Ye{constructor(e){e&&this.set(e)}set(e,t,i){const n=this;function o(e,t,i){const o=We(t);if(!o)throw new Error("header name must be a non-empty string");const r=me.findKey(n,o);(!r||void 0===n[r]||!0===i||void 0===i&&!1!==n[r])&&(n[r||t]=Ge(e))}const r=(e,t)=>me.forEach(e,((e,i)=>o(e,i,t)));if(me.isPlainObject(e)||e instanceof this.constructor)r(e,t);else if(me.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))r((e=>{const t={};let i,n,o;return e&&e.split("\n").forEach((function(e){o=e.indexOf(":"),i=e.substring(0,o).trim().toLowerCase(),n=e.substring(o+1).trim(),!i||t[i]&&ze[i]||("set-cookie"===i?t[i]?t[i].push(n):t[i]=[n]:t[i]=t[i]?t[i]+", "+n:n)})),t})(e),t);else if(me.isObject(e)&&me.isIterable(e)){let i,n,o={};for(const t of e){if(!me.isArray(t))throw TypeError("Object iterator must return a key-value pair");o[n=t[0]]=(i=o[n])?me.isArray(i)?[...i,t[1]]:[i,t[1]]:t[1]}r(o,t)}else null!=e&&o(t,e,i);return this}get(e,t){if(e=We(e)){const i=me.findKey(this,e);if(i){const e=this[i];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),i=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=i.exec(e);)t[n[1]]=n[2];return t}(e);if(me.isFunction(t))return t.call(this,e,i);if(me.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=We(e)){const i=me.findKey(this,e);return!(!i||void 0===this[i]||t&&!Ke(0,this[i],i,t))}return!1}delete(e,t){const i=this;let n=!1;function o(e){if(e=We(e)){const o=me.findKey(i,e);!o||t&&!Ke(0,i[o],o,t)||(delete i[o],n=!0)}}return me.isArray(e)?e.forEach(o):o(e),n}clear(e){const t=Object.keys(this);let i=t.length,n=!1;for(;i--;){const o=t[i];e&&!Ke(0,this[o],o,e,!0)||(delete this[o],n=!0)}return n}normalize(e){const t=this,i={};return me.forEach(this,((n,o)=>{const r=me.findKey(i,o);if(r)return t[r]=Ge(n),void delete t[o];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,i)=>t.toUpperCase()+i))}(o):String(o).trim();s!==o&&delete t[o],t[s]=Ge(n),i[s]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return me.forEach(this,((i,n)=>{null!=i&&!1!==i&&(t[n]=e&&me.isArray(i)?i.join(", "):i)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const i=new this(e);return t.forEach((e=>i.set(e))),i}static accessor(e){const t=(this[$e]=this[$e]={accessors:{}}).accessors,i=this.prototype;function n(e){const n=We(e);t[n]||(!function(e,t){const i=me.toCamelCase(" "+t);["get","set","has"].forEach((n=>{Object.defineProperty(e,n+i,{value:function(e,i,o){return this[n].call(this,t,e,i,o)},configurable:!0})}))}(i,e),t[n]=!0)}return me.isArray(e)?e.forEach(n):n(e),this}}Ye.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),me.reduceDescriptors(Ye.prototype,(({value:e},t)=>{let i=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[i]=e}}})),me.freezeMethods(Ye);const Qe=Ye;function Je(e,t){const i=this||He,n=t||i,o=Qe.from(n.headers);let r=n.data;return me.forEach(e,(function(e){r=e.call(i,r,o.normalize(),t?t.status:void 0)})),o.normalize(),r}function Ze(e){return!(!e||!e.__CANCEL__)}function Xe(e,t,i){fe.call(this,null==e?"canceled":e,fe.ERR_CANCELED,t,i),this.name="CanceledError"}function et(e,t,i){const n=i.config.validateStatus;i.status&&n&&!n(i.status)?t(new fe("Request failed with status code "+i.status,[fe.ERR_BAD_REQUEST,fe.ERR_BAD_RESPONSE][Math.floor(i.status/100)-4],i.config,i.request,i)):e(i)}function tt(e,t,i){let n=!function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}(t);return e&&(n||0==i)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}me.inherits(Xe,fe,{__CANCEL__:!0});const it="1.10.0";function nt(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}const ot=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;const rt=Symbol("internals");class st extends T.default.Transform{constructor(e){super({readableHighWaterMark:(e=me.toFlatObject(e,{maxRate:0,chunkSize:65536,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,((e,t)=>!me.isUndefined(t[e])))).chunkSize});const t=this[rt]={timeWindow:e.timeWindow,chunkSize:e.chunkSize,maxRate:e.maxRate,minChunkSize:e.minChunkSize,bytesSeen:0,isCaptured:!1,notifiedBytesLoaded:0,ts:Date.now(),bytes:0,onReadCallback:null};this.on("newListener",(e=>{"progress"===e&&(t.isCaptured||(t.isCaptured=!0))}))}_read(e){const t=this[rt];return t.onReadCallback&&t.onReadCallback(),super._read(e)}_transform(e,t,i){const n=this[rt],o=n.maxRate,r=this.readableHighWaterMark,s=n.timeWindow,a=o/(1e3/s),c=!1!==n.minChunkSize?Math.max(n.minChunkSize,.01*a):0,l=(e,t)=>{const i=Buffer.byteLength(e);n.bytesSeen+=i,n.bytes+=i,n.isCaptured&&this.emit("progress",n.bytesSeen),this.push(e)?process.nextTick(t):n.onReadCallback=()=>{n.onReadCallback=null,process.nextTick(t)}},p=(e,t)=>{const i=Buffer.byteLength(e);let p,u=null,d=r,h=0;if(o){const e=Date.now();(!n.ts||(h=e-n.ts)>=s)&&(n.ts=e,p=a-n.bytes,n.bytes=p<0?-p:0,h=0),p=a-n.bytes}if(o){if(p<=0)return setTimeout((()=>{t(null,e)}),s-h);p<d&&(d=p)}d&&i>d&&i-d>c&&(u=e.subarray(d),e=e.subarray(0,d)),l(e,u?()=>{process.nextTick(t,null,u)}:t)};p(e,(function e(t,n){if(t)return i(t);n?p(n,e):i(null)}))}}const at=st,{asyncIterator:ct}=Symbol,lt=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[ct]?yield*e[ct]():yield e},pt=Ue.ALPHABET.ALPHA_DIGIT+"-_",ut="function"==typeof TextEncoder?new TextEncoder:new _.default.TextEncoder,dt="\r\n",ht=ut.encode(dt);class mt{constructor(e,t){const{escapeName:i}=this.constructor,n=me.isString(t);let o=`Content-Disposition: form-data; name="${i(e)}"${!n&&t.name?`; filename="${i(t.name)}"`:""}${dt}`;n?t=ut.encode(String(t).replace(/\r?\n|\r\n?/g,dt)):o+=`Content-Type: ${t.type||"application/octet-stream"}${dt}`,this.headers=ut.encode(o+dt),this.contentLength=n?t.byteLength:t.size,this.size=this.headers.byteLength+this.contentLength+2,this.name=e,this.value=t}async*encode(){yield this.headers;const{value:e}=this;me.isTypedArray(e)?yield e:yield*lt(e),yield ht}static escapeName(e){return String(e).replace(/[\r\n"]/g,(e=>({"\r":"%0D","\n":"%0A",'"':"%22"}[e])))}}const ft=(e,t,i)=>{const{tag:n="form-data-boundary",size:o=25,boundary:r=n+"-"+Ue.generateString(o,pt)}=i||{};if(!me.isFormData(e))throw TypeError("FormData instance required");if(r.length<1||r.length>70)throw Error("boundary must be 10-70 characters long");const s=ut.encode("--"+r+dt),a=ut.encode("--"+r+"--"+dt);let c=a.byteLength;const l=Array.from(e.entries()).map((([e,t])=>{const i=new mt(e,t);return c+=i.size,i}));c+=s.byteLength*l.length,c=me.toFiniteNumber(c);const p={"Content-Type":`multipart/form-data; boundary=${r}`};return Number.isFinite(c)&&(p["Content-Length"]=c),t&&t(p),d.Readable.from(async function*(){for(const e of l)yield s,yield*e.encode();yield a}())};class gt extends T.default.Transform{__transform(e,t,i){this.push(e),i()}_transform(e,t,i){if(0!==e.length&&(this._transform=this.__transform,120!==e[0])){const e=Buffer.alloc(2);e[0]=120,e[1]=156,this.push(e,t)}this.__transform(e,t,i)}}const vt=gt,yt=(e,t)=>me.isAsyncFn(e)?function(...i){const n=i.pop();e.apply(this,i).then((e=>{try{t?n(null,...t(e)):n(null,e)}catch(e){n(e)}}),n)}:e;const bt=(e,t,i=3)=>{let n=0;const o=function(e,t){e=e||10;const i=new Array(e),n=new Array(e);let o,r=0,s=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),l=n[s];o||(o=c),i[r]=a,n[r]=c;let p=s,u=0;for(;p!==r;)u+=i[p++],p%=e;if(r=(r+1)%e,r===s&&(s=(s+1)%e),c-o<t)return;const d=l&&c-l;return d?Math.round(1e3*u/d):void 0}}(50,250);return function(e,t){let i,n,o=0,r=1e3/t;const s=(t,r=Date.now())=>{o=r,i=null,n&&(clearTimeout(n),n=null),e.apply(null,t)};return[(...e)=>{const t=Date.now(),a=t-o;a>=r?s(e,t):(i=e,n||(n=setTimeout((()=>{n=null,s(i)}),r-a)))},()=>i&&s(i)]}((i=>{const r=i.loaded,s=i.lengthComputable?i.total:void 0,a=r-n,c=o(a);n=r;e({loaded:r,total:s,progress:s?r/s:void 0,bytes:a,rate:c||void 0,estimated:c&&s&&r<=s?(s-r)/c:void 0,event:i,lengthComputable:null!=s,[t?"download":"upload"]:!0})}),i)},wt=(e,t)=>{const i=null!=e;return[n=>t[0]({lengthComputable:i,total:e,loaded:n}),t[1]]},_t=e=>(...t)=>me.asap((()=>e(...t))),St={flush:x.default.constants.Z_SYNC_FLUSH,finishFlush:x.default.constants.Z_SYNC_FLUSH},xt={flush:x.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:x.default.constants.BROTLI_OPERATION_FLUSH},Tt=me.isFunction(x.default.createBrotliDecompress),{http:Et,https:Ct}=S.default,Pt=/https:?/,kt=Ue.protocols.map((e=>e+":")),Ot=(e,[t,i])=>(e.on("end",i).on("error",i),t);function It(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function At(e,t,i){let n=t;if(!n&&!1!==n){const e=y.default.getProxyForUrl(i);e&&(n=new URL(e))}if(n){if(n.username&&(n.auth=(n.username||"")+":"+(n.password||"")),n.auth){(n.auth.username||n.auth.password)&&(n.auth=(n.auth.username||"")+":"+(n.auth.password||""));const t=Buffer.from(n.auth,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+t}e.headers.host=e.hostname+(e.port?":"+e.port:"");const t=n.hostname||n.host;e.hostname=t,e.host=t,e.port=n.port,e.path=i,n.protocol&&(e.protocol=n.protocol.includes(":")?n.protocol:`${n.protocol}:`)}e.beforeRedirects.proxy=function(e){At(e,t,e.href)}}const Rt="undefined"!=typeof process&&"process"===me.kindOf(process),Dt=(e,t)=>(({address:e,family:t})=>{if(!me.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}})(me.isObject(e)?e:{address:e,family:t}),Mt=Rt&&function(e){return t=async function(t,i,n){let{data:o,lookup:r,family:s}=e;const{responseType:a,responseEncoding:c}=e,l=e.method.toUpperCase();let p,u,d=!1;if(r){const e=yt(r,(e=>me.isArray(e)?e:[e]));r=(t,i,n)=>{e(t,i,((e,t,o)=>{if(e)return n(e);const r=me.isArray(t)?t.map((e=>Dt(e))):[Dt(t,o)];i.all?n(e,r):n(e,r[0].address,r[0].family)}))}}const m=new h.EventEmitter,f=()=>{e.cancelToken&&e.cancelToken.unsubscribe(g),e.signal&&e.signal.removeEventListener("abort",g),m.removeAllListeners()};function g(t){m.emit("abort",!t||t.type?new Xe(null,e,u):t)}n(((e,t)=>{p=!0,t&&(d=!0,f())})),m.once("abort",i),(e.cancelToken||e.signal)&&(e.cancelToken&&e.cancelToken.subscribe(g),e.signal&&(e.signal.aborted?g():e.signal.addEventListener("abort",g)));const v=tt(e.baseURL,e.url,e.allowAbsoluteUrls),y=new URL(v,Ue.hasBrowserEnv?Ue.origin:void 0),S=y.protocol||kt[0];if("data:"===S){let n;if("GET"!==l)return et(t,i,{status:405,statusText:"method not allowed",headers:{},config:e});try{n=function(e,t,i){const n=i&&i.Blob||Ue.classes.Blob,o=nt(e);if(void 0===t&&n&&(t=!0),"data"===o){e=o.length?e.slice(o.length+1):e;const i=ot.exec(e);if(!i)throw new fe("Invalid URL",fe.ERR_INVALID_URL);const r=i[1],s=i[2],a=i[3],c=Buffer.from(decodeURIComponent(a),s?"base64":"utf8");if(t){if(!n)throw new fe("Blob is not supported",fe.ERR_NOT_SUPPORT);return new n([c],{type:r})}return c}throw new fe("Unsupported protocol "+o,fe.ERR_NOT_SUPPORT)}(e.url,"blob"===a,{Blob:e.env&&e.env.Blob})}catch(t){throw fe.from(t,fe.ERR_BAD_REQUEST,e)}return"text"===a?(n=n.toString(c),c&&"utf8"!==c||(n=me.stripBOM(n))):"stream"===a&&(n=T.default.Readable.from(n)),et(t,i,{data:n,status:200,statusText:"OK",headers:new Qe,config:e})}if(-1===kt.indexOf(S))return i(new fe("Unsupported protocol "+S,fe.ERR_BAD_REQUEST,e));const E=Qe.from(e.headers).normalize();E.set("User-Agent","axios/"+it,!1);const{onUploadProgress:C,onDownloadProgress:P}=e,k=e.maxRate;let O,I;if(me.isSpecCompliantForm(o)){const e=E.getContentType(/boundary=([-_\w\d]{10,70})/i);o=ft(o,(e=>{E.set(e)}),{tag:`axios-${it}-boundary`,boundary:e&&e[1]||void 0})}else if(me.isFormData(o)&&me.isFunction(o.getHeaders)){if(E.set(o.getHeaders()),!E.hasContentLength())try{const e=await _.default.promisify(o.getLength).call(o);Number.isFinite(e)&&e>=0&&E.setContentLength(e)}catch(e){}}else if(me.isBlob(o)||me.isFile(o))o.size&&E.setContentType(o.type||"application/octet-stream"),E.setContentLength(o.size||0),o=T.default.Readable.from(lt(o));else if(o&&!me.isStream(o)){if(Buffer.isBuffer(o));else if(me.isArrayBuffer(o))o=Buffer.from(new Uint8Array(o));else{if(!me.isString(o))return i(new fe("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",fe.ERR_BAD_REQUEST,e));o=Buffer.from(o,"utf-8")}if(E.setContentLength(o.length,!1),e.maxBodyLength>-1&&o.length>e.maxBodyLength)return i(new fe("Request body larger than maxBodyLength limit",fe.ERR_BAD_REQUEST,e))}const A=me.toFiniteNumber(E.getContentLength());let R,D;me.isArray(k)?(O=k[0],I=k[1]):O=I=k,o&&(C||O)&&(me.isStream(o)||(o=T.default.Readable.from(o,{objectMode:!1})),o=T.default.pipeline([o,new at({maxRate:me.toFiniteNumber(O)})],me.noop),C&&o.on("progress",Ot(o,wt(A,bt(_t(C),!1,3))))),e.auth&&(R=(e.auth.username||"")+":"+(e.auth.password||"")),!R&&y.username&&(R=y.username+":"+y.password),R&&E.delete("authorization");try{D=Pe(y.pathname+y.search,e.params,e.paramsSerializer).replace(/^\?/,"")}catch(t){const n=new Error(t.message);return n.config=e,n.url=e.url,n.exists=!0,i(n)}E.set("Accept-Encoding","gzip, compress, deflate"+(Tt?", br":""),!1);const M={path:D,method:l,headers:E.toJSON(),agents:{http:e.httpAgent,https:e.httpsAgent},auth:R,protocol:S,family:s,beforeRedirect:It,beforeRedirects:{}};let N;!me.isUndefined(r)&&(M.lookup=r),e.socketPath?M.socketPath=e.socketPath:(M.hostname=y.hostname.startsWith("[")?y.hostname.slice(1,-1):y.hostname,M.port=y.port,At(M,e.proxy,S+"//"+y.hostname+(y.port?":"+y.port:"")+M.path));const L=Pt.test(M.protocol);if(M.agent=L?e.httpsAgent:e.httpAgent,e.transport?N=e.transport:0===e.maxRedirects?N=L?w.default:b.default:(e.maxRedirects&&(M.maxRedirects=e.maxRedirects),e.beforeRedirect&&(M.beforeRedirects.config=e.beforeRedirect),N=L?Ct:Et),e.maxBodyLength>-1?M.maxBodyLength=e.maxBodyLength:M.maxBodyLength=1/0,e.insecureHTTPParser&&(M.insecureHTTPParser=e.insecureHTTPParser),u=N.request(M,(function(n){if(u.destroyed)return;const o=[n],r=+n.headers["content-length"];if(P||I){const e=new at({maxRate:me.toFiniteNumber(I)});P&&e.on("progress",Ot(e,wt(r,bt(_t(P),!0,3)))),o.push(e)}let s=n;const p=n.req||u;if(!1!==e.decompress&&n.headers["content-encoding"])switch("HEAD"!==l&&204!==n.statusCode||delete n.headers["content-encoding"],(n.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":o.push(x.default.createUnzip(St)),delete n.headers["content-encoding"];break;case"deflate":o.push(new vt),o.push(x.default.createUnzip(St)),delete n.headers["content-encoding"];break;case"br":Tt&&(o.push(x.default.createBrotliDecompress(xt)),delete n.headers["content-encoding"])}s=o.length>1?T.default.pipeline(o,me.noop):o[0];const h=T.default.finished(s,(()=>{h(),f()})),g={status:n.statusCode,statusText:n.statusMessage,headers:new Qe(n.headers),config:e,request:p};if("stream"===a)g.data=s,et(t,i,g);else{const n=[];let o=0;s.on("data",(function(t){n.push(t),o+=t.length,e.maxContentLength>-1&&o>e.maxContentLength&&(d=!0,s.destroy(),i(new fe("maxContentLength size of "+e.maxContentLength+" exceeded",fe.ERR_BAD_RESPONSE,e,p)))})),s.on("aborted",(function(){if(d)return;const t=new fe("stream has been aborted",fe.ERR_BAD_RESPONSE,e,p);s.destroy(t),i(t)})),s.on("error",(function(t){u.destroyed||i(fe.from(t,null,e,p))})),s.on("end",(function(){try{let e=1===n.length?n[0]:Buffer.concat(n);"arraybuffer"!==a&&(e=e.toString(c),c&&"utf8"!==c||(e=me.stripBOM(e))),g.data=e}catch(t){return i(fe.from(t,null,e,g.request,g))}et(t,i,g)}))}m.once("abort",(e=>{s.destroyed||(s.emit("error",e),s.destroy())}))})),m.once("abort",(e=>{i(e),u.destroy(e)})),u.on("error",(function(t){i(fe.from(t,null,e,u))})),u.on("socket",(function(e){e.setKeepAlive(!0,6e4)})),e.timeout){const t=parseInt(e.timeout,10);if(Number.isNaN(t))return void i(new fe("error trying to parse `config.timeout` to int",fe.ERR_BAD_OPTION_VALUE,e,u));u.setTimeout(t,(function(){if(p)return;let t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const n=e.transitional||Oe;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),i(new fe(t,n.clarifyTimeoutError?fe.ETIMEDOUT:fe.ECONNABORTED,e,u)),g()}))}if(me.isStream(o)){let t=!1,i=!1;o.on("end",(()=>{t=!0})),o.once("error",(e=>{i=!0,u.destroy(e)})),o.on("close",(()=>{t||i||g(new Xe("Request stream has been aborted",e,u))})),o.pipe(u)}else u.end(o)},new Promise(((e,i)=>{let n,o;const r=(e,t)=>{o||(o=!0,n&&n(e,t))},s=e=>{r(e,!0),i(e)};t((t=>{r(t),e(t)}),s,(e=>n=e)).catch(s)}));var t},Nt=Ue.hasStandardBrowserEnv?((e,t)=>i=>(i=new URL(i,Ue.origin),e.protocol===i.protocol&&e.host===i.host&&(t||e.port===i.port)))(new URL(Ue.origin),Ue.navigator&&/(msie|trident)/i.test(Ue.navigator.userAgent)):()=>!0,Lt=Ue.hasStandardBrowserEnv?{write(e,t,i,n,o,r){const s=[e+"="+encodeURIComponent(t)];me.isNumber(i)&&s.push("expires="+new Date(i).toGMTString()),me.isString(n)&&s.push("path="+n),me.isString(o)&&s.push("domain="+o),!0===r&&s.push("secure"),document.cookie=s.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}},jt=e=>e instanceof Qe?{...e}:e;function Ft(e,t){t=t||{};const i={};function n(e,t,i,n){return me.isPlainObject(e)&&me.isPlainObject(t)?me.merge.call({caseless:n},e,t):me.isPlainObject(t)?me.merge({},t):me.isArray(t)?t.slice():t}function o(e,t,i,o){return me.isUndefined(t)?me.isUndefined(e)?void 0:n(void 0,e,0,o):n(e,t,0,o)}function r(e,t){if(!me.isUndefined(t))return n(void 0,t)}function s(e,t){return me.isUndefined(t)?me.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function a(i,o,r){return r in t?n(i,o):r in e?n(void 0,i):void 0}const c={url:r,method:r,data:r,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(e,t,i)=>o(jt(e),jt(t),0,!0)};return me.forEach(Object.keys(Object.assign({},e,t)),(function(n){const r=c[n]||o,s=r(e[n],t[n],n);me.isUndefined(s)&&r!==a||(i[n]=s)})),i}const Bt=e=>{const t=Ft({},e);let i,{data:n,withXSRFToken:o,xsrfHeaderName:r,xsrfCookieName:s,headers:a,auth:c}=t;if(t.headers=a=Qe.from(a),t.url=Pe(tt(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&a.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),me.isFormData(n))if(Ue.hasStandardBrowserEnv||Ue.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(!1!==(i=a.getContentType())){const[e,...t]=i?i.split(";").map((e=>e.trim())).filter(Boolean):[];a.setContentType([e||"multipart/form-data",...t].join("; "))}if(Ue.hasStandardBrowserEnv&&(o&&me.isFunction(o)&&(o=o(t)),o||!1!==o&&Nt(t.url))){const e=r&&s&&Lt.read(s);e&&a.set(r,e)}return t},Ut="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,i){const n=Bt(e);let o=n.data;const r=Qe.from(n.headers).normalize();let s,a,c,l,p,{responseType:u,onUploadProgress:d,onDownloadProgress:h}=n;function m(){l&&l(),p&&p(),n.cancelToken&&n.cancelToken.unsubscribe(s),n.signal&&n.signal.removeEventListener("abort",s)}let f=new XMLHttpRequest;function g(){if(!f)return;const n=Qe.from("getAllResponseHeaders"in f&&f.getAllResponseHeaders());et((function(e){t(e),m()}),(function(e){i(e),m()}),{data:u&&"text"!==u&&"json"!==u?f.response:f.responseText,status:f.status,statusText:f.statusText,headers:n,config:e,request:f}),f=null}f.open(n.method.toUpperCase(),n.url,!0),f.timeout=n.timeout,"onloadend"in f?f.onloadend=g:f.onreadystatechange=function(){f&&4===f.readyState&&(0!==f.status||f.responseURL&&0===f.responseURL.indexOf("file:"))&&setTimeout(g)},f.onabort=function(){f&&(i(new fe("Request aborted",fe.ECONNABORTED,e,f)),f=null)},f.onerror=function(){i(new fe("Network Error",fe.ERR_NETWORK,e,f)),f=null},f.ontimeout=function(){let t=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const o=n.transitional||Oe;n.timeoutErrorMessage&&(t=n.timeoutErrorMessage),i(new fe(t,o.clarifyTimeoutError?fe.ETIMEDOUT:fe.ECONNABORTED,e,f)),f=null},void 0===o&&r.setContentType(null),"setRequestHeader"in f&&me.forEach(r.toJSON(),(function(e,t){f.setRequestHeader(t,e)})),me.isUndefined(n.withCredentials)||(f.withCredentials=!!n.withCredentials),u&&"json"!==u&&(f.responseType=n.responseType),h&&([c,p]=bt(h,!0),f.addEventListener("progress",c)),d&&f.upload&&([a,l]=bt(d),f.upload.addEventListener("progress",a),f.upload.addEventListener("loadend",l)),(n.cancelToken||n.signal)&&(s=t=>{f&&(i(!t||t.type?new Xe(null,e,f):t),f.abort(),f=null)},n.cancelToken&&n.cancelToken.subscribe(s),n.signal&&(n.signal.aborted?s():n.signal.addEventListener("abort",s)));const v=nt(n.url);v&&-1===Ue.protocols.indexOf(v)?i(new fe("Unsupported protocol "+v+":",fe.ERR_BAD_REQUEST,e)):f.send(o||null)}))},qt=(e,t)=>{const{length:i}=e=e?e.filter(Boolean):[];if(t||i){let i,n=new AbortController;const o=function(e){if(!i){i=!0,s();const t=e instanceof Error?e:this.reason;n.abort(t instanceof fe?t:new Xe(t instanceof Error?t.message:t))}};let r=t&&setTimeout((()=>{r=null,o(new fe(`timeout ${t} of ms exceeded`,fe.ETIMEDOUT))}),t);const s=()=>{e&&(r&&clearTimeout(r),r=null,e.forEach((e=>{e.unsubscribe?e.unsubscribe(o):e.removeEventListener("abort",o)})),e=null)};e.forEach((e=>e.addEventListener("abort",o)));const{signal:a}=n;return a.unsubscribe=()=>me.asap(s),a}},Vt=function*(e,t){let i=e.byteLength;if(!t||i<t)return void(yield e);let n,o=0;for(;o<i;)n=o+t,yield e.slice(o,n),o=n},Ht=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:i}=await t.read();if(e)break;yield i}}finally{await t.cancel()}},zt=(e,t,i,n)=>{const o=async function*(e,t){for await(const i of Ht(e))yield*Vt(i,t)}(e,t);let r,s=0,a=e=>{r||(r=!0,n&&n(e))};return new ReadableStream({async pull(e){try{const{done:t,value:n}=await o.next();if(t)return a(),void e.close();let r=n.byteLength;if(i){let e=s+=r;i(e)}e.enqueue(new Uint8Array(n))}catch(e){throw a(e),e}},cancel:e=>(a(e),o.return())},{highWaterMark:2})},$t="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,Wt=$t&&"function"==typeof ReadableStream,Gt=$t&&("function"==typeof TextEncoder?(Kt=new TextEncoder,e=>Kt.encode(e)):async e=>new Uint8Array(await new Response(e).arrayBuffer()));var Kt;const Yt=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},Qt=Wt&&Yt((()=>{let e=!1;const t=new Request(Ue.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t})),Jt=Wt&&Yt((()=>me.isReadableStream(new Response("").body))),Zt={stream:Jt&&(e=>e.body)};var Xt;$t&&(Xt=new Response,["text","arrayBuffer","blob","formData","stream"].forEach((e=>{!Zt[e]&&(Zt[e]=me.isFunction(Xt[e])?t=>t[e]():(t,i)=>{throw new fe(`Response type '${e}' is not supported`,fe.ERR_NOT_SUPPORT,i)})})));const ei=async(e,t)=>{const i=me.toFiniteNumber(e.getContentLength());return null==i?(async e=>{if(null==e)return 0;if(me.isBlob(e))return e.size;if(me.isSpecCompliantForm(e)){const t=new Request(Ue.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return me.isArrayBufferView(e)||me.isArrayBuffer(e)?e.byteLength:(me.isURLSearchParams(e)&&(e+=""),me.isString(e)?(await Gt(e)).byteLength:void 0)})(t):i},ti=$t&&(async e=>{let{url:t,method:i,data:n,signal:o,cancelToken:r,timeout:s,onDownloadProgress:a,onUploadProgress:c,responseType:l,headers:p,withCredentials:u="same-origin",fetchOptions:d}=Bt(e);l=l?(l+"").toLowerCase():"text";let h,m=qt([o,r&&r.toAbortSignal()],s);const f=m&&m.unsubscribe&&(()=>{m.unsubscribe()});let g;try{if(c&&Qt&&"get"!==i&&"head"!==i&&0!==(g=await ei(p,n))){let e,i=new Request(t,{method:"POST",body:n,duplex:"half"});if(me.isFormData(n)&&(e=i.headers.get("content-type"))&&p.setContentType(e),i.body){const[e,t]=wt(g,bt(_t(c)));n=zt(i.body,65536,e,t)}}me.isString(u)||(u=u?"include":"omit");const o="credentials"in Request.prototype;h=new Request(t,{...d,signal:m,method:i.toUpperCase(),headers:p.normalize().toJSON(),body:n,duplex:"half",credentials:o?u:void 0});let r=await fetch(h,d);const s=Jt&&("stream"===l||"response"===l);if(Jt&&(a||s&&f)){const e={};["status","statusText","headers"].forEach((t=>{e[t]=r[t]}));const t=me.toFiniteNumber(r.headers.get("content-length")),[i,n]=a&&wt(t,bt(_t(a),!0))||[];r=new Response(zt(r.body,65536,i,(()=>{n&&n(),f&&f()})),e)}l=l||"text";let v=await Zt[me.findKey(Zt,l)||"text"](r,e);return!s&&f&&f(),await new Promise(((t,i)=>{et(t,i,{data:v,headers:Qe.from(r.headers),status:r.status,statusText:r.statusText,config:e,request:h})}))}catch(t){if(f&&f(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new fe("Network Error",fe.ERR_NETWORK,e,h),{cause:t.cause||t});throw fe.from(t,t&&t.code,e,h)}}),ii={http:Mt,xhr:Ut,fetch:ti};me.forEach(ii,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));const ni=e=>`- ${e}`,oi=e=>me.isFunction(e)||null===e||!1===e,ri=e=>{e=me.isArray(e)?e:[e];const{length:t}=e;let i,n;const o={};for(let r=0;r<t;r++){let t;if(i=e[r],n=i,!oi(i)&&(n=ii[(t=String(i)).toLowerCase()],void 0===n))throw new fe(`Unknown adapter '${t}'`);if(n)break;o[t||"#"+r]=n}if(!n){const e=Object.entries(o).map((([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build")));throw new fe("There is no suitable adapter to dispatch the request "+(t?e.length>1?"since :\n"+e.map(ni).join("\n"):" "+ni(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return n};function si(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Xe(null,e)}function ai(e){si(e),e.headers=Qe.from(e.headers),e.data=Je.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return ri(e.adapter||He.adapter)(e).then((function(t){return si(e),t.data=Je.call(e,e.transformResponse,t),t.headers=Qe.from(t.headers),t}),(function(t){return Ze(t)||(si(e),t&&t.response&&(t.response.data=Je.call(e,e.transformResponse,t.response),t.response.headers=Qe.from(t.response.headers))),Promise.reject(t)}))}const ci={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{ci[e]=function(i){return typeof i===e||"a"+(t<1?"n ":" ")+e}}));const li={};ci.transitional=function(e,t,i){function n(e,t){return"[Axios v"+it+"] Transitional option '"+e+"'"+t+(i?". "+i:"")}return(i,o,r)=>{if(!1===e)throw new fe(n(o," has been removed"+(t?" in "+t:"")),fe.ERR_DEPRECATED);return t&&!li[o]&&(li[o]=!0,console.warn(n(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(i,o,r)}},ci.spelling=function(e){return(t,i)=>(console.warn(`${i} is likely a misspelling of ${e}`),!0)};const pi={assertOptions:function(e,t,i){if("object"!=typeof e)throw new fe("options must be an object",fe.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let o=n.length;for(;o-- >0;){const r=n[o],s=t[r];if(s){const t=e[r],i=void 0===t||s(t,r,e);if(!0!==i)throw new fe("option "+r+" must be "+i,fe.ERR_BAD_OPTION_VALUE)}else if(!0!==i)throw new fe("Unknown option "+r,fe.ERR_BAD_OPTION)}},validators:ci},ui=pi.validators;class di{constructor(e){this.defaults=e||{},this.interceptors={request:new ke,response:new ke}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const i=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?i&&!String(e.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+i):e.stack=i}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=Ft(this.defaults,t);const{transitional:i,paramsSerializer:n,headers:o}=t;void 0!==i&&pi.assertOptions(i,{silentJSONParsing:ui.transitional(ui.boolean),forcedJSONParsing:ui.transitional(ui.boolean),clarifyTimeoutError:ui.transitional(ui.boolean)},!1),null!=n&&(me.isFunction(n)?t.paramsSerializer={serialize:n}:pi.assertOptions(n,{encode:ui.function,serialize:ui.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),pi.assertOptions(t,{baseUrl:ui.spelling("baseURL"),withXsrfToken:ui.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let r=o&&me.merge(o.common,o[t.method]);o&&me.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete o[e]})),t.headers=Qe.concat(r,o);const s=[];let a=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,s.unshift(e.fulfilled,e.rejected))}));const c=[];let l;this.interceptors.response.forEach((function(e){c.push(e.fulfilled,e.rejected)}));let p,u=0;if(!a){const e=[ai.bind(this),void 0];for(e.unshift.apply(e,s),e.push.apply(e,c),p=e.length,l=Promise.resolve(t);u<p;)l=l.then(e[u++],e[u++]);return l}p=s.length;let d=t;for(u=0;u<p;){const e=s[u++],t=s[u++];try{d=e(d)}catch(e){t.call(this,e);break}}try{l=ai.call(this,d)}catch(e){return Promise.reject(e)}for(u=0,p=c.length;u<p;)l=l.then(c[u++],c[u++]);return l}getUri(e){return Pe(tt((e=Ft(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}}me.forEach(["delete","get","head","options"],(function(e){di.prototype[e]=function(t,i){return this.request(Ft(i||{},{method:e,url:t,data:(i||{}).data}))}})),me.forEach(["post","put","patch"],(function(e){function t(t){return function(i,n,o){return this.request(Ft(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:i,data:n}))}}di.prototype[e]=t(),di.prototype[e+"Form"]=t(!0)}));const hi=di;class mi{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const i=this;this.promise.then((e=>{if(!i._listeners)return;let t=i._listeners.length;for(;t-- >0;)i._listeners[t](e);i._listeners=null})),this.promise.then=e=>{let t;const n=new Promise((e=>{i.subscribe(e),t=e})).then(e);return n.cancel=function(){i.unsubscribe(t)},n},e((function(e,n,o){i.reason||(i.reason=new Xe(e,n,o),t(i.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new mi((function(t){e=t})),cancel:e}}}const fi=mi;const gi={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(gi).forEach((([e,t])=>{gi[t]=e}));const vi=gi;const yi=function e(t){const i=new hi(t),n=E(hi.prototype.request,i);return me.extend(n,hi.prototype,i,{allOwnKeys:!0}),me.extend(n,i,null,{allOwnKeys:!0}),n.create=function(i){return e(Ft(t,i))},n}(He);yi.Axios=hi,yi.CanceledError=Xe,yi.CancelToken=fi,yi.isCancel=Ze,yi.VERSION=it,yi.toFormData=Se,yi.AxiosError=fe,yi.Cancel=yi.CanceledError,yi.all=function(e){return Promise.all(e)},yi.spread=function(e){return function(t){return e.apply(null,t)}},yi.isAxiosError=function(e){return me.isObject(e)&&!0===e.isAxiosError},yi.mergeConfig=Ft,yi.AxiosHeaders=Qe,yi.formToJSON=e=>qe(me.isHTMLForm(e)?new FormData(e):e),yi.getAdapter=ri,yi.HttpStatusCode=vi,yi.default=yi,e.exports=yi},6639:e=>{"use strict";const t=["nodebuffer","arraybuffer","fragments"],i="undefined"!=typeof Blob;i&&t.push("blob"),e.exports={BINARY_TYPES:t,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:i,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}},6662:(e,t,i)=>{const n=i(123).Cam,o=i(4434),r=i(4081).guid,s=i(4081).linerase,a=i(4081).parseSOAPString,c=i(7016),l=i(857);var p=Object.create(new o.EventEmitter);p.probe=function(e,t){void 0===t&&("function"==typeof e?(t=e,e={}):e=e||{}),t=t||function(){};var o={},u=[],d="urn:uuid:"+(e.messageId||r()),h=Buffer.from('<Envelope xmlns="http://www.w3.org/2003/05/soap-envelope" xmlns:dn="http://www.onvif.org/ver10/network/wsdl"><Header><wsa:MessageID xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">'+d+'</wsa:MessageID><wsa:To xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">urn:schemas-xmlsoap-org:ws:2005:04:discovery</wsa:To><wsa:Action xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</wsa:Action></Header><Body><Probe xmlns="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><Types>dn:NetworkVideoTransmitter</Types><Scopes /></Probe></Body></Envelope>'),m=i(7194).createSocket("udp4");m.on("error",(function(e){p.emit("error",e),t(e)}));const f=function(t,i){a(t.toString(),(function(t,r,a,l){if(t||!r[0].probeMatches)u.push(t||new Error("Wrong SOAP message from "+i.address+":"+i.port,a)),p.emit("error","Wrong SOAP message from "+i.address+":"+i.port,a);else{var d=(r=s(r)).probeMatches.probeMatch.endpointReference.address;if(!o[d]){var h;if(!1!==e.resolve){var m=r.probeMatches.probeMatch.XAddrs.split(" ").map(c.parse),f=(g=m,v=i.address,g.filter((function(e){return e.hostname===v}))[0]||g[0]);(h=new n({hostname:f.hostname,port:f.port,path:f.path,urn:d})).xaddrs=m}else h=r;o[d]=h,p.emit("device",h,i,a)}}var g,v}),200)};if(e.device){var g=l.networkInterfaces();e.device in g&&g[e.device].some((function(t){if("IPv4"===t.family)return m.bind(e.listeningPort||null,t.address),!0}))}m.on("message",f),m.send(h,0,h.length,3702,"239.255.255.250"),setTimeout(function(){m.removeListener("message",f),m.close(),t(u.length?u:null,Object.keys(o).map((function(e){return o[e]})))}.bind(this),e.timeout||5e3)},e.exports={Discovery:p}},6667:(e,t,i)=>{"use strict";const{EMPTY_BUFFER:n}=i(6639),o=Buffer[Symbol.species];function r(e,t,i,n,o){for(let r=0;r<o;r++)i[n+r]=e[r]^t[3&r]}function s(e,t){for(let i=0;i<e.length;i++)e[i]^=t[3&i]}if(e.exports={concat:function(e,t){if(0===e.length)return n;if(1===e.length)return e[0];const i=Buffer.allocUnsafe(t);let r=0;for(let t=0;t<e.length;t++){const n=e[t];i.set(n,r),r+=n.length}return r<t?new o(i.buffer,i.byteOffset,r):i},mask:r,toArrayBuffer:function(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)},toBuffer:function e(t){if(e.readOnly=!0,Buffer.isBuffer(t))return t;let i;return t instanceof ArrayBuffer?i=new o(t):ArrayBuffer.isView(t)?i=new o(t.buffer,t.byteOffset,t.byteLength):(i=Buffer.from(t),e.readOnly=!1),i},unmask:s},!process.env.WS_NO_BUFFER_UTIL)try{const t=i(Object(function(){var e=new Error("Cannot find module 'bufferutil'");throw e.code="MODULE_NOT_FOUND",e}()));e.exports.mask=function(e,i,n,o,s){s<48?r(e,i,n,o,s):t.mask(e,i,n,o,s)},e.exports.unmask=function(e,i){e.length<32?s(e,i):t.unmask(e,i)}}catch(e){}},6739:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.authHttpFetch=void 0;const n=i(3609),o=i(614);t.authHttpFetch=(0,o.createAuthFetch)(n.httpFetch,n.httpFetchParseIncomingMessage)},6756:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=[0,16,128,131,135,144,145,151,153];t.default=(e,t,n)=>{e.log("handlePublish: packet %o",t),n="undefined"!=typeof n?n:e.noop;let o=t.topic.toString();const r=t.payload,{qos:s}=t,{messageId:a}=t,{options:c}=e;if(5===e.options.protocolVersion){let i;if(t.properties&&(i=t.properties.topicAlias),"undefined"!=typeof i)if(0===o.length){if(!(i>0&&i<=65535))return e.log("handlePublish :: topic alias out of range. alias: %d",i),void e.emit("error",new Error("Received Topic Alias is out of range"));{const t=e.topicAliasRecv.getTopicByAlias(i);if(!t)return e.log("handlePublish :: unregistered topic alias. alias: %d",i),void e.emit("error",new Error("Received unregistered Topic Alias"));o=t,e.log("handlePublish :: topic complemented by alias. topic: %s - alias: %d",o,i)}}else{if(!e.topicAliasRecv.put(o,i))return e.log("handlePublish :: topic alias out of range. alias: %d",i),void e.emit("error",new Error("Received Topic Alias is out of range"));e.log("handlePublish :: registered topic: %s - alias: %d",o,i)}}switch(e.log("handlePublish: qos %d",s),s){case 2:c.customHandleAcks(o,r,t,((o,r)=>("number"==typeof o&&(r=o,o=null),o?e.emit("error",o):-1===i.indexOf(r)?e.emit("error",new Error("Wrong reason code for pubrec")):void(r?e._sendPacket({cmd:"pubrec",messageId:a,reasonCode:r},n):e.incomingStore.put(t,(()=>{e._sendPacket({cmd:"pubrec",messageId:a},n)}))))));break;case 1:c.customHandleAcks(o,r,t,((s,c)=>("number"==typeof s&&(c=s,s=null),s?e.emit("error",s):-1===i.indexOf(c)?e.emit("error",new Error("Wrong reason code for puback")):(c||e.emit("message",o,r,t),void e.handleMessage(t,(t=>{if(t)return n&&n(t);e._sendPacket({cmd:"puback",messageId:a,reasonCode:c},n)}))))));break;case 0:e.emit("message",o,r,t),e.handleMessage(t,n);break;default:e.log("handlePublish: unknown QoS. Doing nothing.")}}},6766:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=i(5611),o=i(3901);t.default=class{constructor(e){e>0&&(this.aliasToTopic=new n.LRUCache({max:e}),this.topicToAlias={},this.numberAllocator=new o.NumberAllocator(1,e),this.max=e,this.length=0)}put(e,t){if(0===t||t>this.max)return!1;const i=this.aliasToTopic.get(t);return i&&delete this.topicToAlias[i],this.aliasToTopic.set(t,e),this.topicToAlias[e]=t,this.numberAllocator.use(t),this.length=this.aliasToTopic.size,!0}getTopicByAlias(e){return this.aliasToTopic.get(e)}getAliasByTopic(e){const t=this.topicToAlias[e];return"undefined"!=typeof t&&this.aliasToTopic.get(t),t}clear(){this.aliasToTopic.clear(),this.topicToAlias={},this.numberAllocator.clear(),this.length=0}getLruAlias(){const e=this.numberAllocator.firstVacant();return e||[...this.aliasToTopic.keys()][this.aliasToTopic.size-1]}}},6838:function(e){(function(){e.exports=function(){function e(e){this.nodes=e}return Object.defineProperty(e.prototype,"length",{get:function(){return Object.keys(this.nodes).length||0}}),e.prototype.clone=function(){return this.nodes=null},e.prototype.getNamedItem=function(e){return this.nodes[e]},e.prototype.setNamedItem=function(e){var t;return t=this.nodes[e.nodeName],this.nodes[e.nodeName]=e,t||null},e.prototype.removeNamedItem=function(e){var t;return t=this.nodes[e],delete this.nodes[e],t||null},e.prototype.item=function(e){return this.nodes[Object.keys(this.nodes)[e]]||null},e.prototype.getNamedItemNS=function(e,t){throw new Error("This DOM method is not implemented.")},e.prototype.setNamedItemNS=function(e){throw new Error("This DOM method is not implemented.")},e.prototype.removeNamedItemNS=function(e,t){throw new Error("This DOM method is not implemented.")},e}()}).call(this)},6844:function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.streamBuilder=t.browserStreamBuilder=void 0;const o=i(181),r=n(i(5946)),s=n(i(8766)),a=i(5899),c=n(i(8032)),l=i(4232),p=(0,s.default)("mqttjs:ws"),u=["rejectUnauthorized","ca","cert","key","pfx","passphrase"];function d(e,t){let i=`${e.protocol}://${e.hostname}:${e.port}${e.path}`;return"function"==typeof e.transformWsUrl&&(i=e.transformWsUrl(i,e,t)),i}function h(e){const t=e;return e.port||("wss"===e.protocol?t.port=443:t.port=80),e.path||(t.path="/"),e.wsOptions||(t.wsOptions={}),c.default||e.forceNativeWebSocket||"wss"!==e.protocol||u.forEach((i=>{Object.prototype.hasOwnProperty.call(e,i)&&!Object.prototype.hasOwnProperty.call(e.wsOptions,i)&&(t.wsOptions[i]=e[i])})),t}t.streamBuilder=(e,t)=>{p("streamBuilder");const i=h(t);i.hostname=i.hostname||i.host||"localhost";const n=d(i,e),o=function(e,t,i){p("createWebSocket"),p(`protocol: ${i.protocolId} ${i.protocolVersion}`);const n="MQIsdp"===i.protocolId&&3===i.protocolVersion?"mqttv3.1":"mqtt";let o;return p(`creating new Websocket for url: ${t} and protocol: ${n}`),o=i.createWebsocket?i.createWebsocket(t,[n],i):new r.default(t,[n],i.wsOptions),o}(0,n,i),s=r.default.createWebSocketStream(o,i.wsOptions);return s.url=n,o.on("close",(()=>{s.destroy()})),s};t.browserStreamBuilder=(e,t)=>{let i;p("browserStreamBuilder");const n=function(e){const t=h(e);if(t.hostname||(t.hostname=t.host),!t.hostname){if("undefined"==typeof document)throw new Error("Could not determine host. Specify host manually.");const e=new URL(document.URL);t.hostname=e.hostname,t.port||(t.port=Number(e.port))}return void 0===t.objectMode&&(t.objectMode=!(!0===t.binary||void 0===t.binary)),t}(t),r=n.browserBufferSize||524288,s=t.browserBufferTimeout||1e3,c=!t.objectMode,u=function(e,t){const i="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt",n=d(t,e);let o;return o=t.createWebsocket?t.createWebsocket(n,[i],t):new WebSocket(n,[i]),o.binaryType="arraybuffer",o}(e,t),m=function(e,t,i){const n=new a.Transform({objectMode:e.objectMode});return n._write=t,n._flush=i,n}(t,(function e(t,i,n){if(u.bufferedAmount>r)return void setTimeout(e,s,t,i,n);c&&"string"==typeof t&&(t=o.Buffer.from(t,"utf8"));try{u.send(t)}catch(e){return n(e)}n()}),(function(e){u.close(),e()}));t.objectMode||(m._writev=l.writev.bind(m)),m.on("close",(()=>{u.close()}));const f="undefined"!=typeof u.addEventListener;function g(){p("WebSocket onOpen"),i instanceof l.BufferedDuplex&&i.socketReady()}function v(e){p("WebSocket onClose",e),i.end(),i.destroy()}function y(e){p("WebSocket onError",e);const t=new Error("WebSocket error");t.event=e,i.destroy(t)}async function b(e){let{data:t}=e;t=t instanceof ArrayBuffer?o.Buffer.from(t):t instanceof Blob?o.Buffer.from(await new Response(t).arrayBuffer()):o.Buffer.from(t,"utf8"),m&&!m.destroyed&&m.push(t)}return u.readyState===u.OPEN?(i=m,i.socket=u):(i=new l.BufferedDuplex(t,m,u),f?u.addEventListener("open",g):u.onopen=g),f?(u.addEventListener("close",v),u.addEventListener("error",y),u.addEventListener("message",b)):(u.onclose=v,u.onerror=y,u.onmessage=b),i}},6845:e=>{"use strict";e.exports={version:"5.10.2"}},6859:function(e,t,i){(function(){var t,n,o,r,s,a,c,l,p={}.hasOwnProperty;l=i(5502),c=l.isObject,a=l.isFunction,s=l.getValue,r=i(8711),t=i(5068),n=i(9299),o=i(6838),e.exports=function(e){function i(e,n,o){var r,s,a,c;if(i.__super__.constructor.call(this,e),null==n)throw new Error("Missing element name. "+this.debugInfo());if(this.name=this.stringify.name(n),this.type=t.Element,this.attribs={},this.schemaTypeInfo=null,null!=o&&this.attribute(o),e.type===t.Document&&(this.isRoot=!0,this.documentObject=e,e.rootObject=this,e.children))for(s=0,a=(c=e.children).length;s<a;s++)if((r=c[s]).type===t.DocType){r.name=this.name;break}}return function(e,t){for(var i in t)p.call(t,i)&&(e[i]=t[i]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(i,e),Object.defineProperty(i.prototype,"tagName",{get:function(){return this.name}}),Object.defineProperty(i.prototype,"namespaceURI",{get:function(){return""}}),Object.defineProperty(i.prototype,"prefix",{get:function(){return""}}),Object.defineProperty(i.prototype,"localName",{get:function(){return this.name}}),Object.defineProperty(i.prototype,"id",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(i.prototype,"className",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(i.prototype,"classList",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(i.prototype,"attributes",{get:function(){return this.attributeMap&&this.attributeMap.nodes||(this.attributeMap=new o(this.attribs)),this.attributeMap}}),i.prototype.clone=function(){var e,t,i,n;for(t in(i=Object.create(this)).isRoot&&(i.documentObject=null),i.attribs={},n=this.attribs)p.call(n,t)&&(e=n[t],i.attribs[t]=e.clone());return i.children=[],this.children.forEach((function(e){var t;return(t=e.clone()).parent=i,i.children.push(t)})),i},i.prototype.attribute=function(e,t){var i,o;if(null!=e&&(e=s(e)),c(e))for(i in e)p.call(e,i)&&(o=e[i],this.attribute(i,o));else a(t)&&(t=t.apply()),this.options.keepNullAttributes&&null==t?this.attribs[e]=new n(this,e,""):null!=t&&(this.attribs[e]=new n(this,e,t));return this},i.prototype.removeAttribute=function(e){var t,i,n;if(null==e)throw new Error("Missing attribute name. "+this.debugInfo());if(e=s(e),Array.isArray(e))for(i=0,n=e.length;i<n;i++)t=e[i],delete this.attribs[t];else delete this.attribs[e];return this},i.prototype.toString=function(e){return this.options.writer.element(this,this.options.writer.filterOptions(e))},i.prototype.att=function(e,t){return this.attribute(e,t)},i.prototype.a=function(e,t){return this.attribute(e,t)},i.prototype.getAttribute=function(e){return this.attribs.hasOwnProperty(e)?this.attribs[e].value:null},i.prototype.setAttribute=function(e,t){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.getAttributeNode=function(e){return this.attribs.hasOwnProperty(e)?this.attribs[e]:null},i.prototype.setAttributeNode=function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.removeAttributeNode=function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.getElementsByTagName=function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.getAttributeNS=function(e,t){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.setAttributeNS=function(e,t,i){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.removeAttributeNS=function(e,t){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.getAttributeNodeNS=function(e,t){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.setAttributeNodeNS=function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.getElementsByTagNameNS=function(e,t){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.hasAttribute=function(e){return this.attribs.hasOwnProperty(e)},i.prototype.hasAttributeNS=function(e,t){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.setIdAttribute=function(e,t){return this.attribs.hasOwnProperty(e)?this.attribs[e].isId:t},i.prototype.setIdAttributeNS=function(e,t,i){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.setIdAttributeNode=function(e,t){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.getElementsByTagName=function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.getElementsByTagNameNS=function(e,t){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.getElementsByClassName=function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.isEqualNode=function(e){var t,n,o;if(!i.__super__.isEqualNode.apply(this,arguments).isEqualNode(e))return!1;if(e.namespaceURI!==this.namespaceURI)return!1;if(e.prefix!==this.prefix)return!1;if(e.localName!==this.localName)return!1;if(e.attribs.length!==this.attribs.length)return!1;for(t=n=0,o=this.attribs.length-1;0<=o?n<=o:n>=o;t=0<=o?++n:--n)if(!this.attribs[t].isEqualNode(e.attribs[t]))return!1;return!0},i}(r)}).call(this)},6870:(e,t,i)=>{var n=i(3390),o=i(9023),r=i(6928),s=i(8611),a=i(5692),c=i(7016).parse,l=i(9896),p=i(2203).Stream,u=i(336),d=i(4012),h=i(7019);function m(e){if(!(this instanceof m))return new m(e);for(var t in this._overheadLength=0,this._valueLength=0,this._valuesToMeasure=[],n.call(this),e=e||{})this[t]=e[t]}e.exports=m,o.inherits(m,n),m.LINE_BREAK="\r\n",m.DEFAULT_CONTENT_TYPE="application/octet-stream",m.prototype.append=function(e,t,i){"string"==typeof(i=i||{})&&(i={filename:i});var o=n.prototype.append.bind(this);if("number"==typeof t&&(t=""+t),Array.isArray(t))this._error(new Error("Arrays are not supported."));else{var r=this._multiPartHeader(e,t,i),s=this._multiPartFooter();o(r),o(t),o(s),this._trackLength(r,t,i)}},m.prototype._trackLength=function(e,t,i){var n=0;null!=i.knownLength?n+=+i.knownLength:Buffer.isBuffer(t)?n=t.length:"string"==typeof t&&(n=Buffer.byteLength(t)),this._valueLength+=n,this._overheadLength+=Buffer.byteLength(e)+m.LINE_BREAK.length,t&&(t.path||t.readable&&t.hasOwnProperty("httpVersion")||t instanceof p)&&(i.knownLength||this._valuesToMeasure.push(t))},m.prototype._lengthRetriever=function(e,t){e.hasOwnProperty("fd")?null!=e.end&&e.end!=1/0&&null!=e.start?t(null,e.end+1-(e.start?e.start:0)):l.stat(e.path,(function(i,n){var o;i?t(i):(o=n.size-(e.start?e.start:0),t(null,o))})):e.hasOwnProperty("httpVersion")?t(null,+e.headers["content-length"]):e.hasOwnProperty("httpModule")?(e.on("response",(function(i){e.pause(),t(null,+i.headers["content-length"])})),e.resume()):t("Unknown stream")},m.prototype._multiPartHeader=function(e,t,i){if("string"==typeof i.header)return i.header;var n,o=this._getContentDisposition(t,i),r=this._getContentType(t,i),s="",a={"Content-Disposition":["form-data",'name="'+e+'"'].concat(o||[]),"Content-Type":[].concat(r||[])};for(var c in"object"==typeof i.header&&h(a,i.header),a)a.hasOwnProperty(c)&&null!=(n=a[c])&&(Array.isArray(n)||(n=[n]),n.length&&(s+=c+": "+n.join("; ")+m.LINE_BREAK));return"--"+this.getBoundary()+m.LINE_BREAK+s+m.LINE_BREAK},m.prototype._getContentDisposition=function(e,t){var i,n;return"string"==typeof t.filepath?i=r.normalize(t.filepath).replace(/\\/g,"/"):t.filename||e.name||e.path?i=r.basename(t.filename||e.name||e.path):e.readable&&e.hasOwnProperty("httpVersion")&&(i=r.basename(e.client._httpMessage.path||"")),i&&(n='filename="'+i+'"'),n},m.prototype._getContentType=function(e,t){var i=t.contentType;return!i&&e.name&&(i=u.lookup(e.name)),!i&&e.path&&(i=u.lookup(e.path)),!i&&e.readable&&e.hasOwnProperty("httpVersion")&&(i=e.headers["content-type"]),i||!t.filepath&&!t.filename||(i=u.lookup(t.filepath||t.filename)),i||"object"!=typeof e||(i=m.DEFAULT_CONTENT_TYPE),i},m.prototype._multiPartFooter=function(){return function(e){var t=m.LINE_BREAK;0===this._streams.length&&(t+=this._lastBoundary()),e(t)}.bind(this)},m.prototype._lastBoundary=function(){return"--"+this.getBoundary()+"--"+m.LINE_BREAK},m.prototype.getHeaders=function(e){var t,i={"content-type":"multipart/form-data; boundary="+this.getBoundary()};for(t in e)e.hasOwnProperty(t)&&(i[t.toLowerCase()]=e[t]);return i},m.prototype.setBoundary=function(e){this._boundary=e},m.prototype.getBoundary=function(){return this._boundary||this._generateBoundary(),this._boundary},m.prototype.getBuffer=function(){for(var e=new Buffer.alloc(0),t=this.getBoundary(),i=0,n=this._streams.length;i<n;i++)"function"!=typeof this._streams[i]&&(e=Buffer.isBuffer(this._streams[i])?Buffer.concat([e,this._streams[i]]):Buffer.concat([e,Buffer.from(this._streams[i])]),"string"==typeof this._streams[i]&&this._streams[i].substring(2,t.length+2)===t||(e=Buffer.concat([e,Buffer.from(m.LINE_BREAK)])));return Buffer.concat([e,Buffer.from(this._lastBoundary())])},m.prototype._generateBoundary=function(){for(var e="--------------------------",t=0;t<24;t++)e+=Math.floor(10*Math.random()).toString(16);this._boundary=e},m.prototype.getLengthSync=function(){var e=this._overheadLength+this._valueLength;return this._streams.length&&(e+=this._lastBoundary().length),this.hasKnownLength()||this._error(new Error("Cannot calculate proper length in synchronous way.")),e},m.prototype.hasKnownLength=function(){var e=!0;return this._valuesToMeasure.length&&(e=!1),e},m.prototype.getLength=function(e){var t=this._overheadLength+this._valueLength;this._streams.length&&(t+=this._lastBoundary().length),this._valuesToMeasure.length?d.parallel(this._valuesToMeasure,this._lengthRetriever,(function(i,n){i?e(i):(n.forEach((function(e){t+=e})),e(null,t))})):process.nextTick(e.bind(this,null,t))},m.prototype.submit=function(e,t){var i,n,o={method:"post"};return"string"==typeof e?(e=c(e),n=h({port:e.port,path:e.pathname,host:e.hostname,protocol:e.protocol},o)):(n=h(e,o)).port||(n.port="https:"==n.protocol?443:80),n.headers=this.getHeaders(e.headers),i="https:"==n.protocol?a.request(n):s.request(n),this.getLength(function(e,n){if(e&&"Unknown stream"!==e)this._error(e);else if(n&&i.setHeader("Content-Length",n),this.pipe(i),t){var o,r=function(e,n){return i.removeListener("error",r),i.removeListener("response",o),t.call(this,e,n)};o=r.bind(this,null),i.on("error",r),i.on("response",o)}}.bind(this)),i},m.prototype._error=function(e){this.error||(this.error=e,this.pause(),this.emit("error",e))},m.prototype.toString=function(){return"[object FormData]"}},6928:e=>{"use strict";e.exports=require("path")},6962:(e,t,i)=>{const n=i(2695),{EventEmitter:o}=i(4434),{Buffer:r}=i(181);class s extends o{constructor(){super(),this._array=new Array(20),this._i=0}write(e){return this._array[this._i++]=e,!0}concat(){let e=0;const t=new Array(this._array.length),i=this._array;let n,o=0;for(n=0;n<i.length&&void 0!==i[n];n++)"string"!=typeof i[n]?t[n]=i[n].length:t[n]=r.byteLength(i[n]),e+=t[n];const s=r.allocUnsafe(e);for(n=0;n<i.length&&void 0!==i[n];n++)"string"!=typeof i[n]?(i[n].copy(s,o),o+=t[n]):(s.write(i[n],o),o+=t[n]);return s}destroy(e){e&&this.emit("error",e)}}e.exports=function(e,t){const i=new s;return n(e,i,t),i.concat()}},6973:function(e,t,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||n(t,e,i)};Object.defineProperty(t,"__esModule",{value:!0}),t.sdk=t.MixinDeviceBase=t.ScryptedDeviceBase=void 0,o(i(2707),t);const r=i(2707);i(3339);class s extends r.DeviceBase{constructor(e){super(),this.nativeId=e}get storage(){return this._storage||(this._storage=t.sdk.deviceManager.getDeviceStorage(this.nativeId)),this._storage}get log(){return this._log||(this._log=t.sdk.deviceManager.getDeviceLogger(this.nativeId)),this._log}get console(){return this._console||(this._console=t.sdk.deviceManager.getDeviceConsole(this.nativeId)),this._console}async createMediaObject(e,i){return t.sdk.mediaManager.createMediaObject(e,i,{sourceId:this.id})}getMediaObjectConsole(e){return"string"!=typeof e.sourceId?this.console:t.sdk.deviceManager.getMixinConsole(e.sourceId,this.nativeId)}_lazyLoadDeviceState(){this._deviceState||(this.nativeId?this._deviceState=t.sdk.deviceManager.getDeviceState(this.nativeId):this._deviceState=t.sdk.deviceManager.getDeviceState())}onDeviceEvent(e,i){return t.sdk.deviceManager.onDeviceEvent(this.nativeId,e,i)}}t.ScryptedDeviceBase=s;class a extends r.DeviceBase{constructor(e){super(),this._listeners=new Set,this.mixinDevice=e.mixinDevice,this.mixinDeviceInterfaces=e.mixinDeviceInterfaces,this.mixinStorageSuffix=e.mixinStorageSuffix,this._deviceState=e.mixinDeviceState,this.nativeId=t.sdk.systemManager.getDeviceById(this.id).nativeId,this.mixinProviderNativeId=e.mixinProviderNativeId,this._deviceState.__rpcproxy_traps_all_properties&&"string"==typeof this._deviceState.id&&(this._deviceState=t.sdk.deviceManager.createDeviceState(this._deviceState.id,this._deviceState.setState))}get storage(){if(!this._storage){const e=this.mixinStorageSuffix,i=this.id+(e?":"+e:"");this._storage=t.sdk.deviceManager.getMixinStorage(i,this.mixinProviderNativeId)}return this._storage}get console(){return this._console||(t.sdk.deviceManager.getMixinConsole?this._console=t.sdk.deviceManager.getMixinConsole(this.id,this.mixinProviderNativeId):this._console=t.sdk.deviceManager.getDeviceConsole(this.mixinProviderNativeId)),this._console}async createMediaObject(e,i){return t.sdk.mediaManager.createMediaObject(e,i,{sourceId:this.id})}getMediaObjectConsole(e){return"string"!=typeof e.sourceId?this.console:t.sdk.deviceManager.getMixinConsole(e.sourceId,this.mixinProviderNativeId)}onDeviceEvent(e,i){return t.sdk.deviceManager.onMixinEvent(this.id,this,e,i)}_lazyLoadDeviceState(){}manageListener(e){this._listeners.add(e)}release(){for(const e of this._listeners)e.removeListener()}}t.MixinDeviceBase=a,function(){function e(e){return function(){return this._lazyLoadDeviceState(),this._deviceState?.[e]}}function t(e){return function(t){this._lazyLoadDeviceState(),this._deviceState?this._deviceState[e]=t:console.warn("device state is unavailable. the device must be discovered with deviceManager.onDeviceDiscovered or deviceManager.onDevicesChanged before the state can be set.")}}for(const i of Object.values(r.ScryptedInterfaceProperty))i!==r.ScryptedInterfaceProperty.nativeId&&(Object.defineProperty(s.prototype,i,{set:t(i),get:e(i)}),Object.defineProperty(a.prototype,i,{set:t(i),get:e(i)}))}(),t.sdk={};try{let e=!1;try{process.env.SCRYPTED_SDK_ES_MODULE||process.env.SCRYPTED_SDK_MODULE;const n=process.env.SCRYPTED_SDK_CJS_MODULE||process.env.SCRYPTED_SDK_MODULE;if(n)if("undefined"!=typeof require){const i=require(process.env.SCRYPTED_SDK_MODULE);Object.assign(t.sdk,i.getScryptedStatic()),e=!0}else{const o=i(1832)(n);Object.assign(t.sdk,o.getScryptedStatic()),e=!0}}catch(e){throw console.warn("failed to load sdk module",e),e}if(!e){let e;try{e=pluginRuntimeAPI}catch(e){}Object.assign(t.sdk,{log:deviceManager.getDeviceLogger(void 0),deviceManager,endpointManager,mediaManager,systemManager,pluginHostAPI,...e})}try{t.sdk.systemManager.setScryptedInterfaceDescriptors?.(r.TYPES_VERSION,r.ScryptedInterfaceDescriptors)?.catch((()=>{}))}catch(e){}}catch(e){console.error("sdk initialization error, import @scrypted/types or use @scrypted/client instead",e)}t.default=t.sdk},6982:e=>{"use strict";e.exports=require("crypto")},7016:e=>{"use strict";e.exports=require("url")},7019:e=>{e.exports=function(e,t){return Object.keys(t).forEach((function(i){e[i]=e[i]||t[i]})),e}},7060:(e,t,i)=>{const n=e.exports,{Buffer:o}=i(181);n.types={0:"reserved",1:"connect",2:"connack",3:"publish",4:"puback",5:"pubrec",6:"pubrel",7:"pubcomp",8:"subscribe",9:"suback",10:"unsubscribe",11:"unsuback",12:"pingreq",13:"pingresp",14:"disconnect",15:"auth"},n.requiredHeaderFlags={1:0,2:0,4:0,5:0,6:2,7:0,8:2,9:0,10:2,11:0,12:0,13:0,14:0,15:0},n.requiredHeaderFlagsErrors={};for(const e in n.requiredHeaderFlags){const t=n.requiredHeaderFlags[e];n.requiredHeaderFlagsErrors[e]="Invalid header flag bits, must be 0x"+t.toString(16)+" for "+n.types[e]+" packet"}n.codes={};for(const e in n.types){const t=n.types[e];n.codes[t]=e}n.CMD_SHIFT=4,n.CMD_MASK=240,n.DUP_MASK=8,n.QOS_MASK=3,n.QOS_SHIFT=1,n.RETAIN_MASK=1,n.VARBYTEINT_MASK=127,n.VARBYTEINT_FIN_MASK=128,n.VARBYTEINT_MAX=268435455,n.SESSIONPRESENT_MASK=1,n.SESSIONPRESENT_HEADER=o.from([n.SESSIONPRESENT_MASK]),n.CONNACK_HEADER=o.from([n.codes.connack<<n.CMD_SHIFT]),n.USERNAME_MASK=128,n.PASSWORD_MASK=64,n.WILL_RETAIN_MASK=32,n.WILL_QOS_MASK=24,n.WILL_QOS_SHIFT=3,n.WILL_FLAG_MASK=4,n.CLEAN_SESSION_MASK=2,n.CONNECT_HEADER=o.from([n.codes.connect<<n.CMD_SHIFT]),n.properties={sessionExpiryInterval:17,willDelayInterval:24,receiveMaximum:33,maximumPacketSize:39,topicAliasMaximum:34,requestResponseInformation:25,requestProblemInformation:23,userProperties:38,authenticationMethod:21,authenticationData:22,payloadFormatIndicator:1,messageExpiryInterval:2,contentType:3,responseTopic:8,correlationData:9,maximumQoS:36,retainAvailable:37,assignedClientIdentifier:18,reasonString:31,wildcardSubscriptionAvailable:40,subscriptionIdentifiersAvailable:41,sharedSubscriptionAvailable:42,serverKeepAlive:19,responseInformation:26,serverReference:28,topicAlias:35,subscriptionIdentifier:11},n.propertiesCodes={};for(const e in n.properties){const t=n.properties[e];n.propertiesCodes[t]=e}function r(e){return[0,1,2].map((t=>[0,1].map((i=>[0,1].map((r=>{const s=o.alloc(1);return s.writeUInt8(n.codes[e]<<n.CMD_SHIFT|(i?n.DUP_MASK:0)|t<<n.QOS_SHIFT|r,0,!0),s}))))))}n.propertiesTypes={sessionExpiryInterval:"int32",willDelayInterval:"int32",receiveMaximum:"int16",maximumPacketSize:"int32",topicAliasMaximum:"int16",requestResponseInformation:"byte",requestProblemInformation:"byte",userProperties:"pair",authenticationMethod:"string",authenticationData:"binary",payloadFormatIndicator:"byte",messageExpiryInterval:"int32",contentType:"string",responseTopic:"string",correlationData:"binary",maximumQoS:"int8",retainAvailable:"byte",assignedClientIdentifier:"string",reasonString:"string",wildcardSubscriptionAvailable:"byte",subscriptionIdentifiersAvailable:"byte",sharedSubscriptionAvailable:"byte",serverKeepAlive:"int16",responseInformation:"string",serverReference:"string",topicAlias:"int16",subscriptionIdentifier:"var"},n.PUBLISH_HEADER=r("publish"),n.SUBSCRIBE_HEADER=r("subscribe"),n.SUBSCRIBE_OPTIONS_QOS_MASK=3,n.SUBSCRIBE_OPTIONS_NL_MASK=1,n.SUBSCRIBE_OPTIONS_NL_SHIFT=2,n.SUBSCRIBE_OPTIONS_RAP_MASK=1,n.SUBSCRIBE_OPTIONS_RAP_SHIFT=3,n.SUBSCRIBE_OPTIONS_RH_MASK=3,n.SUBSCRIBE_OPTIONS_RH_SHIFT=4,n.SUBSCRIBE_OPTIONS_RH=[0,16,32],n.SUBSCRIBE_OPTIONS_NL=4,n.SUBSCRIBE_OPTIONS_RAP=8,n.SUBSCRIBE_OPTIONS_QOS=[0,1,2],n.UNSUBSCRIBE_HEADER=r("unsubscribe"),n.ACKS={unsuback:r("unsuback"),puback:r("puback"),pubcomp:r("pubcomp"),pubrel:r("pubrel"),pubrec:r("pubrec")},n.SUBACK_HEADER=o.from([n.codes.suback<<n.CMD_SHIFT]),n.VERSION3=o.from([3]),n.VERSION4=o.from([4]),n.VERSION5=o.from([5]),n.VERSION131=o.from([131]),n.VERSION132=o.from([132]),n.QOS=[0,1,2].map((e=>o.from([e]))),n.EMPTY={pingreq:o.from([n.codes.pingreq<<4,0]),pingresp:o.from([n.codes.pingresp<<4,0]),disconnect:o.from([n.codes.disconnect<<4,0])},n.MQTT5_PUBACK_PUBREC_CODES={0:"Success",16:"No matching subscribers",128:"Unspecified error",131:"Implementation specific error",135:"Not authorized",144:"Topic Name invalid",145:"Packet identifier in use",151:"Quota exceeded",153:"Payload format invalid"},n.MQTT5_PUBREL_PUBCOMP_CODES={0:"Success",146:"Packet Identifier not found"},n.MQTT5_SUBACK_CODES={0:"Granted QoS 0",1:"Granted QoS 1",2:"Granted QoS 2",128:"Unspecified error",131:"Implementation specific error",135:"Not authorized",143:"Topic Filter invalid",145:"Packet Identifier in use",151:"Quota exceeded",158:"Shared Subscriptions not supported",161:"Subscription Identifiers not supported",162:"Wildcard Subscriptions not supported"},n.MQTT5_UNSUBACK_CODES={0:"Success",17:"No subscription existed",128:"Unspecified error",131:"Implementation specific error",135:"Not authorized",143:"Topic Filter invalid",145:"Packet Identifier in use"},n.MQTT5_DISCONNECT_CODES={0:"Normal disconnection",4:"Disconnect with Will Message",128:"Unspecified error",129:"Malformed Packet",130:"Protocol Error",131:"Implementation specific error",135:"Not authorized",137:"Server busy",139:"Server shutting down",141:"Keep Alive timeout",142:"Session taken over",143:"Topic Filter invalid",144:"Topic Name invalid",147:"Receive Maximum exceeded",148:"Topic Alias invalid",149:"Packet too large",150:"Message rate too high",151:"Quota exceeded",152:"Administrative action",153:"Payload format invalid",154:"Retain not supported",155:"QoS not supported",156:"Use another server",157:"Server moved",158:"Shared Subscriptions not supported",159:"Connection rate exceeded",160:"Maximum connect time",161:"Subscription Identifiers not supported",162:"Wildcard Subscriptions not supported"},n.MQTT5_AUTH_CODES={0:"Success",24:"Continue authentication",25:"Re-authenticate"}},7072:(e,t,i)=>{e.exports=function(e){const t=i(4081).linerase;e.prototype.getNTP=function(e){this._request({service:"device",body:this._envelopeHeader()+'<GetNTP xmlns="http://www.onvif.org/ver10/device/wsdl"/></s:Body></s:Envelope>'},(function(i,n,o){i||(this.NTP=t(n[0].getNTPResponse[0].NTPInformation[0])),e.call(this,i,i?null:this.NTP,o)}))},e.prototype.setNTP=function(e,t){Array.isArray(e.NTPManual)||(e.NTPManual=[]),(e.type||e.ipv4Address||e.ipv6Address||e.dnsName||e.extension)&&e.NTPManual.push({type:e.type,IPv4Address:e.ipv4Address,IPv6Address:e.ipv6Address,DNSname:e.dnsName,extension:e.extension});let i=this._envelopeHeader()+'<SetNTP xmlns="http://www.onvif.org/ver10/device/wsdl"><FromDHCP>'+e.fromDHCP+"</FromDHCP>";e.NTPManual&&Array.isArray(e.NTPManual)&&e.NTPManual.forEach((e=>{i+=e.type?'<NTPManual><Type xmlns="http://www.onvif.org/ver10/schema">'+e.type+"</Type>"+(e.IPv4Address?'<IPv4Address xmlns="http://www.onvif.org/ver10/schema">'+e.IPv4Address+"</IPv4Address>":"")+(e.IPv6Address?'<IPv6Address xmlns="http://www.onvif.org/ver10/schema">'+e.IPv6Address+"</IPv6Address>":"")+(e.DNSname?"<DNSname>"+e.DNSname+"</DNSname>":"")+(e.extension?"<Extension>"+e.extension+"</Extension>":"")+"</NTPManual>":""})),i+="</SetNTP>"+this._envelopeFooter(),this._request({service:"device",body:i},t.bind(this))},e.prototype.getNetworkInterfaces=function(e){this._request({service:"device",body:this._envelopeHeader()+'<GetNetworkInterfaces xmlns="http://www.onvif.org/ver10/device/wsdl"/>'+this._envelopeFooter()},function(i,n,o){i||(this.networkInterfaces=t(n).getNetworkInterfacesResponse.networkInterfaces,Array.isArray(this.networkInterfaces)||(this.networkInterfaces=[this.networkInterfaces])),e&&e.call(this,i,this.networkInterfaces,o)}.bind(this))},e.prototype.setNetworkInterfaces=function(e,i){let n=e.networkInterface,o=!1,r=!1;if(n.IPv4)try{o=n.IPv4.manual.address!==this.hostname}catch(e){o=!1}else if(n.IPv6)try{r=n.IPv6.manual.address!==this.hostname}catch(e){r=!1}let s=this._envelopeHeader()+'<SetNetworkInterfaces xmlns="http://www.onvif.org/ver10/device/wsdl"><InterfaceToken>'+e.interfaceToken+'</InterfaceToken><NetworkInterface><Enabled xmlns="http://www.onvif.org/ver10/schema">'+n.enabled+"</Enabled>"+(n.link?'<Link xmlns="http://www.onvif.org/ver10/schema"><AutoNegotiation>'+n.link.autoNegotiation+"</AutoNegotiation><Speed>"+n.link.speed+"</Speed><Duplex>"+n.link.duplex+"</Duplex></Link>":"")+(isNaN(n.MTU)?"":'<MTU xmlns="http://www.onvif.org/ver10/schema">'+n.MTU+"</MTU>")+(n.IPv4?'<IPv4 xmlns="http://www.onvif.org/ver10/schema"><Enabled>'+n.IPv4.enabled+"</Enabled><Manual><Address>"+n.IPv4.manual.address+"</Address><PrefixLength>"+n.IPv4.manual.prefixLength+"</PrefixLength></Manual><DHCP>"+n.IPv4.DHCP+"</DHCP></IPv4>":"")+(n.IPv6?'<IPv6 xmlns="http://www.onvif.org/ver10/schema"><Enabled>'+n.IPv6.enabled+"</Enabled><AcceptRouterAdvert >"+n.IPv6.acceptRouterAdvert+"</AcceptRouterAdvert><Manual><Address>"+n.IPv6.manual.address+"</Address><PrefixLength>"+n.IPv6.manual.prefixLength+"</PrefixLength></Manual><DHCP>"+n.IPv6.DHCP+"</DHCP></IPv6>":"")+"</NetworkInterface></SetNetworkInterfaces>"+this._envelopeFooter();this._request({service:"device",body:s},function(e,s,a){i&&(e||(o&&(this.hostname=n.IPv4.manual.address),r&&(this.hostname=n.IPv6.manual.address),s=t(s[0].setNetworkInterfacesResponse)),i.call(this,e,s,a))}.bind(this))},e.prototype.getNetworkDefaultGateway=function(e){this._request({service:"device",body:this._envelopeHeader()+'<GetNetworkDefaultGateway xmlns="http://www.onvif.org/ver10/device/wsdl"/>'+this._envelopeFooter()},function(i,n,o){e&&(i||(this.networkDefaultGateway=t(n[0].getNetworkDefaultGatewayResponse[0].networkGateway)),e.call(this,i,this.networkDefaultGateway,o))}.bind(this))},e.prototype.setNetworkDefaultGateway=function(e,t){this._request({service:"device",body:this._envelopeHeader()+'<SetNetworkDefaultGateway xmlns="http://www.onvif.org/ver10/device/wsdl">'+(e.IPv4Address?"<IPv4Address>"+e.IPv4Address+"</IPv4Address>":"")+(e.IPv6Address?"<IPv6Address>"+e.IPv6Address+"</IPv6Address>":"")+"</SetNetworkDefaultGateway>"+this._envelopeFooter()},function(e,i,n){if(t){if(e)return t.call(this,e,i,n);this.getNetworkDefaultGateway(t.bind(this))}}.bind(this))},e.prototype.getDNS=function(e){this._request({service:"device",body:this._envelopeHeader()+'<GetDNS xmlns="http://www.onvif.org/ver10/device/wsdl"/>'+this._envelopeFooter()},function(i,n,o){e&&(i||(this.DNS=t(n[0].getDNSResponse[0].DNSInformation),this.DNS.DNSManual&&!Array.isArray(this.DNS.DNSManual)&&(this.DNS.DNSManual=[this.DNS.DNSManual]),this.DNS.DNSFromDHCP&&!Array.isArray(this.DNS.DNSFromDHCP)&&(this.DNS.DNSFromDHCP=[this.DNS.DNSFromDHCP])),e.call(this,i,this.DNS,o))}.bind(this))},e.prototype.setDNS=function(e,t){let i=this._envelopeHeader()+'<SetDNS xmlns="http://www.onvif.org/ver10/device/wsdl"><FromDHCP>'+!!e.fromDHCP+"</FromDHCP>"+(e.searchDomain?"<SearchDomain>"+e.searchDomain+"</SearchDomain>":"");e.DNSManual.forEach((function(e){i+='<DNSManual><Type xmlns="http://www.onvif.org/ver10/schema">'+("IPv6"===e.type?"IPv6":"IPv4")+"</Type>"+(e.IPv4Address?'<IPv4Address xmlns="http://www.onvif.org/ver10/schema">'+e.IPv4Address+"</IPv4Address>":"")+(e.IPv6Address?'<IPv6Address xmlns="http://www.onvif.org/ver10/schema">'+e.IPv6Address+"</IPv6Address>":"")+"</DNSManual>"})),i+="</SetDNS>"+this._envelopeFooter(),this._request({service:"device",body:i},function(e,i,n){if(t){if(e)return t.call(this,e,null,n);this.getDNS(t)}}.bind(this))},e.prototype.getNetworkProtocols=function(e){this._request({service:"device",body:this._envelopeHeader()+'<GetNetworkProtocols xmlns="http://www.onvif.org/ver10/device/wsdl"/>'+this._envelopeFooter()},function(i,n,o){i||(this.networkProtocols=t(n).getNetworkProtocolsResponse),e&&e.call(this,i,this.networkProtocols,o)}.bind(this))},e.prototype.getUsers=function(e){this._request({service:"device",body:this._envelopeHeader()+'<GetUsers xmlns="http://www.onvif.org/ver10/device/wsdl" />'+this._envelopeFooter()},function(i,n,o){if(e){if(!i){var r=n[0].getUsersResponse[0].user;r=r.map((function(e){return t(e)})),this.users=r,n=r}e.call(this,i,n,o)}}.bind(this))},e.prototype.createUsers=function(e,t){if(e.every((function(e){return!!(e.username&&e.password&&e.userLevel)}))){var i="";e.forEach((function(e){i+='<User><Username xmlns="http://www.onvif.org/ver10/schema">'+e.username+'</Username><Password xmlns="http://www.onvif.org/ver10/schema">'+e.password+'</Password><UserLevel xmlns="http://www.onvif.org/ver10/schema">'+e.userLevel+"</UserLevel></User>"}));var n=this._envelopeHeader()+'<CreateUsers xmlns="http://www.onvif.org/ver10/device/wsdl">'+i+"</CreateUsers>"+this._envelopeFooter();this._request({service:"device",body:n},function(e,i,n){t&&(e?t.call(this,e,i,n):this.getUsers(t))}.bind(this))}else t.call(this,new Error("Missing username, password or user level"),null,null)},e.prototype.setUsers=function(e,t){if(e.every((function(e){return!!(e.username&&e.password&&e.userLevel)}))){var i="";e.forEach((function(e){i+='<User><Username xmlns="http://www.onvif.org/ver10/schema">'+e.username+'</Username><Password xmlns="http://www.onvif.org/ver10/schema">'+e.password+'</Password><UserLevel xmlns="http://www.onvif.org/ver10/schema">'+e.userLevel+"</UserLevel></User>"}));var n=this._envelopeHeader()+'<SetUser xmlns="http://www.onvif.org/ver10/device/wsdl">'+i+"</SetUser>"+this._envelopeFooter();this._request({service:"device",body:n},function(i,n,o){if(t)if(i)t.call(this,i,n,o);else{var r=!1;e.some((function(e){if(e.username===this.username)return r=!0,this.password=e.password,!0})),r?setTimeout(function(){this.getUsers(t)}.bind(this),2e3):this.getUsers(t)}}.bind(this))}else t.call(this,new Error("Missing username, password or user level"),null,null)},e.prototype.deleteUsers=function(e,t){var i=[];if(e.forEach((function(e){"string"==typeof e&&e.length>0?i.push(e):"object"==typeof e&&e.username&&i.push(e.username)})),!i.length)return t.call(this,new Error("No username"),null,null);var n="";i.forEach((function(e){n+="<Username>"+e+"</Username>"}));var o=this._envelopeHeader()+'<DeleteUsers xmlns="http://www.onvif.org/ver10/device/wsdl">'+n+"</DeleteUsers>"+this._envelopeFooter();this._request({service:"device",body:o},function(e,i,n){t&&(e?t.call(this,e,i,n):this.getUsers(t))}.bind(this))},e.prototype.sendAuxiliaryCommand=function(e,t){let i=this._envelopeHeader()+'<SendAuxiliaryCommand xmlns="http://www.onvif.org/ver10/device/wsdl"><AuxiliaryCommand xmlns="http://www.onvif.org/ver10/schema">'+e.data+"</AuxiliaryCommand></SendAuxiliaryCommand>"+this._envelopeFooter();this._request({service:"device",body:i},function(e,i,n){t&&t.call(this,e,i,n)}.bind(this))}}},7097:e=>{e.exports=global.process},7194:e=>{"use strict";e.exports=require("dgram")},7225:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RtpPacket=t.RtpHeader=t.ExtensionProfiles=void 0;const n=i(1092);t.ExtensionProfiles={OneByte:48862,TwoByte:4096};class o{constructor(e={}){this.version=2,this.padding=!1,this.paddingSize=0,this.extension=!1,this.marker=!1,this.payloadOffset=0,this.payloadType=0,this.sequenceNumber=0,this.timestamp=0,this.ssrc=0,this.csrcLength=0,this.csrc=[],this.extensionProfile=t.ExtensionProfiles.OneByte,this.extensions=[],Object.assign(this,e)}static deSerialize(e){const i=new o;let r=0;const s=e[r++];i.version=(0,n.getBit)(s,0,2),i.padding=(0,n.getBit)(s,2)>0,i.extension=(0,n.getBit)(s,3)>0,i.csrcLength=(0,n.getBit)(s,4,4),i.csrc=[...Array(i.csrcLength)].map((()=>{const t=e.readUInt32BE(r);return r+=4,t})),r+=11;const a=e[1];i.marker=(0,n.getBit)(a,0)>0,i.payloadType=(0,n.getBit)(a,1,7),i.sequenceNumber=e.readUInt16BE(2),i.timestamp=e.readUInt32BE(4),i.ssrc=e.readUInt32BE(8);for(let t=0;t<i.csrc.length;t++){const n=12+4*t;i.csrc[t]=e.subarray(n).readUInt32BE()}if(i.extension){i.extensionProfile=e.subarray(r).readUInt16BE(),r+=2;const n=4*e.subarray(r).readUInt16BE();switch(i.extensionLength=n,r+=2,i.extensionProfile){case t.ExtensionProfiles.OneByte:{const t=r+n;for(;r<t;){if(0===e[r]){r++;continue}const t=e[r]>>4,n=1+(e[r]&(240^e[r]));if(r++,15===t)break;const o={id:t,payload:e.subarray(r,r+n)};i.extensions=[...i.extensions,o],r+=n}}break;case t.ExtensionProfiles.TwoByte:{const t=r+n;for(;r<t;){if(0===e[r]){r++;continue}const t=e[r];r++;const n=e[r];r++;const o={id:t,payload:e.subarray(r,r+n)};i.extensions=[...i.extensions,o],r+=n}}break;default:{const t={id:0,payload:e.subarray(r,r+n)};i.extensions=[...i.extensions,t],r+=i.extensions[0].payload.length}}}return i.payloadOffset=r,i.padding&&(i.paddingSize=e[e.length-1]),i}get serializeSize(){const{csrc:e,extensionProfile:i,extensions:n}=this;let o=12+4*e.length;if(n.length>0||!0===this.extension){let e=4;switch(i){case t.ExtensionProfiles.OneByte:for(const t of n)e+=1+t.payload.length;break;case t.ExtensionProfiles.TwoByte:for(const t of n)e+=2+t.payload.length;break;default:e+=n[0].payload.length}o+=4*Math.floor((e+3)/4)}return o}serialize(e){const i=Buffer.alloc(e);let o=0;const r=new n.BitWriter(8);r.set(2,0,this.version),this.padding&&r.set(1,2,1),this.extensions.length>0&&(this.extension=!0),this.extension&&r.set(1,3,1),r.set(4,4,this.csrc.length),i.writeUInt8(r.value,o++);const s=new n.BitWriter(8);this.marker&&s.set(1,0,1),s.set(7,1,this.payloadType),i.writeUInt8(s.value,o++),i.writeUInt16BE(this.sequenceNumber,2),o+=2,i.writeUInt32BE(this.timestamp,4),o+=4,i.writeUInt32BE(this.ssrc,8),o+=4;for(const e of this.csrc)i.writeUInt32BE(e,o),o+=4;if(this.extension){const e=o;i.writeUInt16BE(this.extensionProfile,o),o+=4;const n=o;switch(this.extensionProfile){case t.ExtensionProfiles.OneByte:for(const e of this.extensions)i.writeUInt8(e.id<<4|e.payload.length-1,o++),e.payload.copy(i,o),o+=e.payload.length;break;case t.ExtensionProfiles.TwoByte:for(const e of this.extensions)i.writeUInt8(e.id,o++),i.writeUInt8(e.payload.length,o++),e.payload.copy(i,o),o+=e.payload.length;break;default:{const e=this.extensions[0].payload.length;if(e%4!=0)throw new Error;this.extensions[0].payload.copy(i,o),o+=e}}const r=o-n,s=4*Math.trunc((r+3)/4);i.writeUInt16BE(Math.trunc(s/4),e+2);for(let e=0;e<s-r;e++)i.writeUInt8(0,o),o++}return this.payloadOffset=o,i}}t.RtpHeader=o;class r{constructor(e,t){this.header=e,this.payload=t}get serializeSize(){return this.header.serializeSize+this.payload.length}clone(){return new r(new o({...this.header}),this.payload)}serialize(){let e=this.header.serialize(this.header.serializeSize+this.payload.length);const{payloadOffset:t}=this.header;if(this.payload.copy(e,t),this.header.padding){const t=Buffer.alloc(this.header.paddingSize);t.writeUInt8(this.header.paddingSize,this.header.paddingSize-1),e=Buffer.concat([e,t])}return e}static deSerialize(e){const t=o.deSerialize(e);return new r(t,e.subarray(t.payloadOffset,e.length-t.paddingSize))}clear(){this.payload=null}}t.RtpPacket=r},7229:(e,t,i)=>{"use strict";const{Writable:n}=i(2203),o=i(9064),{BINARY_TYPES:r,EMPTY_BUFFER:s,kStatusCode:a,kWebSocket:c}=i(6639),{concat:l,toArrayBuffer:p,unmask:u}=i(6667),{isValidStatusCode:d,isValidUTF8:h}=i(3271),m=Buffer[Symbol.species];e.exports=class extends n{constructor(e={}){super(),this._allowSynchronousEvents=void 0===e.allowSynchronousEvents||e.allowSynchronousEvents,this._binaryType=e.binaryType||r[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=0|e.maxPayload,this._skipUTF8Validation=!!e.skipUTF8Validation,this[c]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(e,t,i){if(8===this._opcode&&0==this._state)return i();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(i)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){const t=this._buffers[0];return this._buffers[0]=new m(t.buffer,t.byteOffset+e,t.length-e),new m(t.buffer,t.byteOffset,e)}const t=Buffer.allocUnsafe(e);do{const i=this._buffers[0],n=t.length-e;e>=i.length?t.set(this._buffers.shift(),n):(t.set(new Uint8Array(i.buffer,i.byteOffset,e),n),this._buffers[0]=new m(i.buffer,i.byteOffset+e,i.length-e)),e-=i.length}while(e>0);return t}startLoop(e){this._loop=!0;do{switch(this._state){case 0:this.getInfo(e);break;case 1:this.getPayloadLength16(e);break;case 2:this.getPayloadLength64(e);break;case 3:this.getMask();break;case 4:this.getData(e);break;case 5:case 6:return void(this._loop=!1)}}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2)return void(this._loop=!1);const t=this.consume(2);if(48&t[0]){return void e(this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3"))}const i=!(64&~t[0]);if(!i||this._extensions[o.extensionName]){if(this._fin=!(128&~t[0]),this._opcode=15&t[0],this._payloadLength=127&t[1],0===this._opcode){if(i){return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}if(!this._fragmented){return void e(this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE"))}this._opcode=this._fragmented}else if(1===this._opcode||2===this._opcode){if(this._fragmented){return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"))}this._compressed=i}else{if(!(this._opcode>7&&this._opcode<11)){return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"))}if(!this._fin){return void e(this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN"))}if(i){return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}if(this._payloadLength>125||8===this._opcode&&1===this._payloadLength){return void e(this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"))}}if(this._fin||this._fragmented||(this._fragmented=this._opcode),this._masked=!(128&~t[1]),this._isServer){if(!this._masked){return void e(this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK"))}}else if(this._masked){return void e(this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK"))}126===this._payloadLength?this._state=1:127===this._payloadLength?this._state=2:this.haveLength(e)}else{e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}}getPayloadLength16(e){this._bufferedBytes<2?this._loop=!1:(this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e))}getPayloadLength64(e){if(this._bufferedBytes<8)return void(this._loop=!1);const t=this.consume(8),i=t.readUInt32BE(0);if(i>Math.pow(2,21)-1){e(this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH"))}else this._payloadLength=i*Math.pow(2,32)+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){e(this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"))}else this._masked?this._state=3:this._state=4}getMask(){this._bufferedBytes<4?this._loop=!1:(this._mask=this.consume(4),this._state=4)}getData(e){let t=s;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength)return void(this._loop=!1);t=this.consume(this._payloadLength),this._masked&&0!==(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])&&u(t,this._mask)}if(this._opcode>7)this.controlMessage(t,e);else{if(this._compressed)return this._state=5,void this.decompress(t,e);t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}}decompress(e,t){this._extensions[o.extensionName].decompress(e,this._fin,((e,i)=>{if(e)return t(e);if(i.length){if(this._messageLength+=i.length,this._messageLength>this._maxPayload&&this._maxPayload>0){const e=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");return void t(e)}this._fragments.push(i)}this.dataMessage(t),0===this._state&&this.startLoop(t)}))}dataMessage(e){if(!this._fin)return void(this._state=0);const t=this._messageLength,i=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],2===this._opcode){let n;n="nodebuffer"===this._binaryType?l(i,t):"arraybuffer"===this._binaryType?p(l(i,t)):"blob"===this._binaryType?new Blob(i):i,this._allowSynchronousEvents?(this.emit("message",n,!0),this._state=0):(this._state=6,setImmediate((()=>{this.emit("message",n,!0),this._state=0,this.startLoop(e)})))}else{const n=l(i,t);if(!this._skipUTF8Validation&&!h(n)){const t=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");return void e(t)}5===this._state||this._allowSynchronousEvents?(this.emit("message",n,!1),this._state=0):(this._state=6,setImmediate((()=>{this.emit("message",n,!1),this._state=0,this.startLoop(e)})))}}controlMessage(e,t){if(8!==this._opcode)this._allowSynchronousEvents?(this.emit(9===this._opcode?"ping":"pong",e),this._state=0):(this._state=6,setImmediate((()=>{this.emit(9===this._opcode?"ping":"pong",e),this._state=0,this.startLoop(t)})));else{if(0===e.length)this._loop=!1,this.emit("conclude",1005,s),this.end();else{const i=e.readUInt16BE(0);if(!d(i)){const e=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");return void t(e)}const n=new m(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!h(n)){const e=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");return void t(e)}this._loop=!1,this.emit("conclude",i,n),this.end()}this._state=0}}createError(e,t,i,n,o){this._loop=!1,this._errored=!0;const r=new e(i?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(r,this.createError),r.code=o,r[a]=n,r}}},7241:e=>{e.exports=function(e,t){var i=!Array.isArray(e),n={index:0,keyedList:i||t?Object.keys(e):null,jobs:{},results:i?{}:[],size:i?Object.keys(e).length:e.length};t&&n.keyedList.sort(i?t:function(i,n){return t(e[i],e[n])});return n}},7249:(e,t,i)=>{var n=i(7430),o=i(7241),r=i(4151);e.exports=function(e,t,i){var s=o(e);for(;s.index<(s.keyedList||e).length;)n(e,t,s,(function(e,t){e?i(e,t):0!==Object.keys(s.jobs).length||i(null,s.results)})),s.index++;return r.bind(s,i)}},7260:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sleep=void 0;var n=i(546);Object.defineProperty(t,"sleep",{enumerable:!0,get:function(){return n.sleep}})},7303:(e,t,i)=>{const n=i(7097),o=i(181),{isReadable:r,isWritable:s,isIterable:a,isNodeStream:c,isReadableNodeStream:l,isWritableNodeStream:p,isDuplexNodeStream:u,isReadableStream:d,isWritableStream:h}=i(6274),m=i(9071),{AbortError:f,codes:{ERR_INVALID_ARG_TYPE:g,ERR_INVALID_RETURN_VALUE:v}}=i(676),{destroyer:y}=i(577),b=i(5745),w=i(5047),_=i(7819),{createDeferredPromise:S}=i(3939),x=i(4435),T=globalThis.Blob||o.Blob,E="undefined"!=typeof T?function(e){return e instanceof T}:function(e){return!1},C=globalThis.AbortController||i(581).AbortController,{FunctionPrototypeCall:P}=i(3383);class k extends b{constructor(e){super(e),!1===(null==e?void 0:e.readable)&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),!1===(null==e?void 0:e.writable)&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)}}function O(e){const t=e.readable&&"function"!=typeof e.readable.read?w.wrap(e.readable):e.readable,i=e.writable;let n,o,a,c,l,p=!!r(t),u=!!s(i);function d(e){const t=c;c=null,t?t(e):e&&l.destroy(e)}return l=new k({readableObjectMode:!(null==t||!t.readableObjectMode),writableObjectMode:!(null==i||!i.writableObjectMode),readable:p,writable:u}),u&&(m(i,(e=>{u=!1,e&&y(t,e),d(e)})),l._write=function(e,t,o){i.write(e,t)?o():n=o},l._final=function(e){i.end(),o=e},i.on("drain",(function(){if(n){const e=n;n=null,e()}})),i.on("finish",(function(){if(o){const e=o;o=null,e()}}))),p&&(m(t,(e=>{p=!1,e&&y(t,e),d(e)})),t.on("readable",(function(){if(a){const e=a;a=null,e()}})),t.on("end",(function(){l.push(null)})),l._read=function(){for(;;){const e=t.read();if(null===e)return void(a=l._read);if(!l.push(e))return}}),l._destroy=function(e,r){e||null===c||(e=new f),a=null,n=null,o=null,null===c?r(e):(c=r,y(i,e),y(t,e))},l}e.exports=function e(t,i){if(u(t))return t;if(l(t))return O({readable:t});if(p(t))return O({writable:t});if(c(t))return O({writable:!1,readable:!1});if(d(t))return O({readable:w.fromWeb(t)});if(h(t))return O({writable:_.fromWeb(t)});if("function"==typeof t){const{value:e,write:o,final:r,destroy:s}=function(e){let{promise:t,resolve:i}=S();const o=new C,r=o.signal,s=e(async function*(){for(;;){const e=t;t=null;const{chunk:o,done:s,cb:a}=await e;if(n.nextTick(a),s)return;if(r.aborted)throw new f(void 0,{cause:r.reason});({promise:t,resolve:i}=S()),yield o}}(),{signal:r});return{value:s,write(e,t,n){const o=i;i=null,o({chunk:e,done:!1,cb:n})},final(e){const t=i;i=null,t({done:!0,cb:e})},destroy(e,t){o.abort(),t(e)}}}(t);if(a(e))return x(k,e,{objectMode:!0,write:o,final:r,destroy:s});const c=null==e?void 0:e.then;if("function"==typeof c){let t;const i=P(c,e,(e=>{if(null!=e)throw new v("nully","body",e)}),(e=>{y(t,e)}));return t=new k({objectMode:!0,readable:!1,write:o,final(e){r((async()=>{try{await i,n.nextTick(e,null)}catch(t){n.nextTick(e,t)}}))},destroy:s})}throw new v("Iterable, AsyncIterable or AsyncFunction",i,e)}if(E(t))return e(t.arrayBuffer());if(a(t))return x(k,t,{objectMode:!0,writable:!1});if(d(null==t?void 0:t.readable)&&h(null==t?void 0:t.writable))return k.fromWeb(t);if("object"==typeof(null==t?void 0:t.writable)||"object"==typeof(null==t?void 0:t.readable)){return O({readable:null!=t&&t.readable?l(null==t?void 0:t.readable)?null==t?void 0:t.readable:e(t.readable):void 0,writable:null!=t&&t.writable?p(null==t?void 0:t.writable)?null==t?void 0:t.writable:e(t.writable):void 0})}const o=null==t?void 0:t.then;if("function"==typeof o){let e;return P(o,t,(t=>{null!=t&&e.push(t),e.push(null)}),(t=>{y(e,t)})),e=new k({objectMode:!0,writable:!1,read(){}})}throw new g(i,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],t)}},7325:(e,t,i)=>{e.exports=function(e){const t=i(4081).linerase;e.prototype.getReplayUri=function(e,i){void 0===i&&(i=e,e={}),this._request({service:"replay",body:this._envelopeHeader()+'<GetReplayUri xmlns="http://www.onvif.org/ver10/replay/wsdl"><StreamSetup><Stream xmlns="http://www.onvif.org/ver10/schema">'+(e.stream||"RTP-Unicast")+'</Stream><Transport xmlns="http://www.onvif.org/ver10/schema"><Protocol>'+(e.protocol||"RTSP")+"</Protocol></Transport></StreamSetup><RecordingToken>"+e.recordingToken+"</RecordingToken></GetReplayUri>"+this._envelopeFooter()},function(e,n,o){i&&i.call(this,e,e?null:t(n).getReplayUriResponse.uri,o)}.bind(this))}}},7373:e=>{"use strict";e.exports=(e,t=process.argv)=>{const i=e.startsWith("-")?"":1===e.length?"-":"--",n=t.indexOf(i+e),o=t.indexOf("--");return-1!==n&&(-1===o||n<o)}},7430:(e,t,i)=>{var n=i(5556),o=i(4370);e.exports=function(e,t,i,r){var s=i.keyedList?i.keyedList[i.index]:i.index;i.jobs[s]=function(e,t,i,o){var r;r=2==e.length?e(i,n(o)):e(i,t,n(o));return r}(t,s,e[s],(function(e,t){s in i.jobs&&(delete i.jobs[s],e?o(i):i.results[s]=t,r(e,i.results))}))}},7441:(e,t,i)=>{"use strict";var n=i(7016).parse,o={ftp:21,gopher:70,http:80,https:443,ws:80,wss:443},r=String.prototype.endsWith||function(e){return e.length<=this.length&&-1!==this.indexOf(e,this.length-e.length)};function s(e){return process.env[e.toLowerCase()]||process.env[e.toUpperCase()]||""}t.getProxyForUrl=function(e){var t="string"==typeof e?n(e):e||{},i=t.protocol,a=t.host,c=t.port;if("string"!=typeof a||!a||"string"!=typeof i)return"";if(i=i.split(":",1)[0],!function(e,t){var i=(s("npm_config_no_proxy")||s("no_proxy")).toLowerCase();if(!i)return!0;if("*"===i)return!1;return i.split(/[,\s]/).every((function(i){if(!i)return!0;var n=i.match(/^(.+):(\d+)$/),o=n?n[1]:i,s=n?parseInt(n[2]):0;return!(!s||s===t)||(/^[.*]/.test(o)?("*"===o.charAt(0)&&(o=o.slice(1)),!r.call(e,o)):e!==o)}))}(a=a.replace(/:\d*$/,""),c=parseInt(c)||o[i]||0))return"";var l=s("npm_config_"+i+"_proxy")||s(i+"_proxy")||s("npm_config_proxy")||s("all_proxy");return l&&-1===l.indexOf("://")&&(l=i+"://"+l),l}},7443:function(e,t){(function(){"use strict";var e;e=new RegExp(/(?!xmlns)^.*:/),t.normalize=function(e){return e.toLowerCase()},t.firstCharLowerCase=function(e){return e.charAt(0).toLowerCase()+e.slice(1)},t.stripPrefix=function(t){return t.replace(e,"")},t.parseNumbers=function(e){return isNaN(e)||(e=e%1==0?parseInt(e,10):parseFloat(e)),e},t.parseBooleans=function(e){return/^(?:true|false)$/i.test(e)&&(e="true"===e.toLowerCase()),e}}).call(this)},7449:function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ListenZeroSingleClientTimeoutError=void 0,t.listenZero=c,t.listenZeroSingleClient=async function(e,t,i=3e4){const n=t?.tls?new s.default.Server(t):new r.default.Server(t),o=await c(n,e);let l;const p=new Promise(((e,t)=>{const o=setTimeout((()=>{n.close(),t(new a)}),i);l=()=>{clearTimeout(o),n.close()},n.on("connection",(t=>{l(),e(t)}))}));p.catch((()=>{}));let u=e;u&&"0.0.0.0"!==u||(u="127.0.0.1");return{server:n,cancel:l,url:`tcp://${u}:${o}`,host:u,port:o,clientPromise:p}};const o=i(4434),r=n(i(9278)),s=n(i(4756));class a extends Error{constructor(){super("timeout waiting for client")}}async function c(e,t){return e.listen(0,t||"127.0.0.1"),await(0,o.once)(e,"listening"),e.address().port}t.ListenZeroSingleClientTimeoutError=a},7465:(e,t,i)=>{"use strict";const n=i(4434),o=i(5692),r=i(8611),s=i(9278),a=i(4756),{randomBytes:c,createHash:l}=i(6982),{Duplex:p,Readable:u}=i(2203),{URL:d}=i(7016),h=i(9064),m=i(7229),f=i(8573),{isBlob:g}=i(3271),{BINARY_TYPES:v,EMPTY_BUFFER:y,GUID:b,kForOnEventAttribute:w,kListener:_,kStatusCode:S,kWebSocket:x,NOOP:T}=i(6639),{EventTarget:{addEventListener:E,removeEventListener:C}}=i(4602),{format:P,parse:k}=i(3751),{toBuffer:O}=i(6667),I=Symbol("kAborted"),A=[8,13],R=["CONNECTING","OPEN","CLOSING","CLOSED"],D=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class M extends n{constructor(e,t,i){super(),this._binaryType=v[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=y,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=M.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,null!==e?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,void 0===t?t=[]:Array.isArray(t)||("object"==typeof t&&null!==t?(i=t,t=[]):t=[t]),N(this,e,t,i)):(this._autoPong=i.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){v.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,i){const n=new m({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),o=new f(e,this._extensions,i.generateMask);this._receiver=n,this._sender=o,this._socket=e,n[x]=this,o[x]=this,e[x]=this,n.on("conclude",q),n.on("drain",V),n.on("error",H),n.on("message",$),n.on("ping",W),n.on("pong",G),o.onerror=Y,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",J),e.on("data",Z),e.on("end",X),e.on("error",ee),this._readyState=M.OPEN,this.emit("open")}emitClose(){if(!this._socket)return this._readyState=M.CLOSED,void this.emit("close",this._closeCode,this._closeMessage);this._extensions[h.extensionName]&&this._extensions[h.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=M.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==M.CLOSED)if(this.readyState!==M.CONNECTING)this.readyState!==M.CLOSING?(this._readyState=M.CLOSING,this._sender.close(e,t,!this._isServer,(e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())})),Q(this)):this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();else{const e="WebSocket was closed before the connection was established";B(this,this._req,e)}}pause(){this.readyState!==M.CONNECTING&&this.readyState!==M.CLOSED&&(this._paused=!0,this._socket.pause())}ping(e,t,i){if(this.readyState===M.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(i=e,e=t=void 0):"function"==typeof t&&(i=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===M.OPEN?(void 0===t&&(t=!this._isServer),this._sender.ping(e||y,t,i)):U(this,e,i)}pong(e,t,i){if(this.readyState===M.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(i=e,e=t=void 0):"function"==typeof t&&(i=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===M.OPEN?(void 0===t&&(t=!this._isServer),this._sender.pong(e||y,t,i)):U(this,e,i)}resume(){this.readyState!==M.CONNECTING&&this.readyState!==M.CLOSED&&(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,i){if(this.readyState===M.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if("function"==typeof t&&(i=t,t={}),"number"==typeof e&&(e=e.toString()),this.readyState!==M.OPEN)return void U(this,e,i);const n={binary:"string"!=typeof e,mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[h.extensionName]||(n.compress=!1),this._sender.send(e||y,n,i)}terminate(){if(this.readyState!==M.CLOSED)if(this.readyState!==M.CONNECTING)this._socket&&(this._readyState=M.CLOSING,this._socket.destroy());else{const e="WebSocket was closed before the connection was established";B(this,this._req,e)}}}function N(e,t,i,n){const s={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:A[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...n,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(e._autoPong=s.autoPong,!A.includes(s.protocolVersion))throw new RangeError(`Unsupported protocol version: ${s.protocolVersion} (supported versions: ${A.join(", ")})`);let a;if(t instanceof d)a=t;else try{a=new d(t)}catch(e){throw new SyntaxError(`Invalid URL: ${t}`)}"http:"===a.protocol?a.protocol="ws:":"https:"===a.protocol&&(a.protocol="wss:"),e._url=a.href;const p="wss:"===a.protocol,u="ws+unix:"===a.protocol;let m;if("ws:"===a.protocol||p||u?u&&!a.pathname?m="The URL's pathname is empty":a.hash&&(m="The URL contains a fragment identifier"):m='The URL\'s protocol must be one of "ws:", "wss:", "http:", "https", or "ws+unix:"',m){const t=new SyntaxError(m);if(0===e._redirects)throw t;return void L(e,t)}const f=p?443:80,g=c(16).toString("base64"),v=p?o.request:r.request,y=new Set;let w,_;if(s.createConnection=s.createConnection||(p?F:j),s.defaultPort=s.defaultPort||f,s.port=a.port||f,s.host=a.hostname.startsWith("[")?a.hostname.slice(1,-1):a.hostname,s.headers={...s.headers,"Sec-WebSocket-Version":s.protocolVersion,"Sec-WebSocket-Key":g,Connection:"Upgrade",Upgrade:"websocket"},s.path=a.pathname+a.search,s.timeout=s.handshakeTimeout,s.perMessageDeflate&&(w=new h(!0!==s.perMessageDeflate?s.perMessageDeflate:{},!1,s.maxPayload),s.headers["Sec-WebSocket-Extensions"]=P({[h.extensionName]:w.offer()})),i.length){for(const e of i){if("string"!=typeof e||!D.test(e)||y.has(e))throw new SyntaxError("An invalid or duplicated subprotocol was specified");y.add(e)}s.headers["Sec-WebSocket-Protocol"]=i.join(",")}if(s.origin&&(s.protocolVersion<13?s.headers["Sec-WebSocket-Origin"]=s.origin:s.headers.Origin=s.origin),(a.username||a.password)&&(s.auth=`${a.username}:${a.password}`),u){const e=s.path.split(":");s.socketPath=e[0],s.path=e[1]}if(s.followRedirects){if(0===e._redirects){e._originalIpc=u,e._originalSecure=p,e._originalHostOrSocketPath=u?s.socketPath:a.host;const t=n&&n.headers;if(n={...n,headers:{}},t)for(const[e,i]of Object.entries(t))n.headers[e.toLowerCase()]=i}else if(0===e.listenerCount("redirect")){const t=u?!!e._originalIpc&&s.socketPath===e._originalHostOrSocketPath:!e._originalIpc&&a.host===e._originalHostOrSocketPath;(!t||e._originalSecure&&!p)&&(delete s.headers.authorization,delete s.headers.cookie,t||delete s.headers.host,s.auth=void 0)}s.auth&&!n.headers.authorization&&(n.headers.authorization="Basic "+Buffer.from(s.auth).toString("base64")),_=e._req=v(s),e._redirects&&e.emit("redirect",e.url,_)}else _=e._req=v(s);s.timeout&&_.on("timeout",(()=>{B(e,_,"Opening handshake has timed out")})),_.on("error",(t=>{null===_||_[I]||(_=e._req=null,L(e,t))})),_.on("response",(o=>{const r=o.headers.location,a=o.statusCode;if(r&&s.followRedirects&&a>=300&&a<400){if(++e._redirects>s.maxRedirects)return void B(e,_,"Maximum redirects exceeded");let o;_.abort();try{o=new d(r,t)}catch(t){const i=new SyntaxError(`Invalid URL: ${r}`);return void L(e,i)}N(e,o,i,n)}else e.emit("unexpected-response",_,o)||B(e,_,`Unexpected server response: ${o.statusCode}`)})),_.on("upgrade",((t,i,n)=>{if(e.emit("upgrade",t),e.readyState!==M.CONNECTING)return;_=e._req=null;const o=t.headers.upgrade;if(void 0===o||"websocket"!==o.toLowerCase())return void B(e,i,"Invalid Upgrade header");const r=l("sha1").update(g+b).digest("base64");if(t.headers["sec-websocket-accept"]!==r)return void B(e,i,"Invalid Sec-WebSocket-Accept header");const a=t.headers["sec-websocket-protocol"];let c;if(void 0!==a?y.size?y.has(a)||(c="Server sent an invalid subprotocol"):c="Server sent a subprotocol but none was requested":y.size&&(c="Server sent no subprotocol"),c)return void B(e,i,c);a&&(e._protocol=a);const p=t.headers["sec-websocket-extensions"];if(void 0!==p){if(!w){return void B(e,i,"Server sent a Sec-WebSocket-Extensions header but no extension was requested")}let t;try{t=k(p)}catch(t){return void B(e,i,"Invalid Sec-WebSocket-Extensions header")}const n=Object.keys(t);if(1!==n.length||n[0]!==h.extensionName){return void B(e,i,"Server indicated an extension that was not requested")}try{w.accept(t[h.extensionName])}catch(t){return void B(e,i,"Invalid Sec-WebSocket-Extensions header")}e._extensions[h.extensionName]=w}e.setSocket(i,n,{allowSynchronousEvents:s.allowSynchronousEvents,generateMask:s.generateMask,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation})})),s.finishRequest?s.finishRequest(_,e):_.end()}function L(e,t){e._readyState=M.CLOSING,e._errorEmitted=!0,e.emit("error",t),e.emitClose()}function j(e){return e.path=e.socketPath,s.connect(e)}function F(e){return e.path=void 0,e.servername||""===e.servername||(e.servername=s.isIP(e.host)?"":e.host),a.connect(e)}function B(e,t,i){e._readyState=M.CLOSING;const n=new Error(i);Error.captureStackTrace(n,B),t.setHeader?(t[I]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(L,e,n)):(t.destroy(n),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function U(e,t,i){if(t){const i=g(t)?t.size:O(t).length;e._socket?e._sender._bufferedBytes+=i:e._bufferedAmount+=i}if(i){const t=new Error(`WebSocket is not open: readyState ${e.readyState} (${R[e.readyState]})`);process.nextTick(i,t)}}function q(e,t){const i=this[x];i._closeFrameReceived=!0,i._closeMessage=t,i._closeCode=e,void 0!==i._socket[x]&&(i._socket.removeListener("data",Z),process.nextTick(K,i._socket),1005===e?i.close():i.close(e,t))}function V(){const e=this[x];e.isPaused||e._socket.resume()}function H(e){const t=this[x];void 0!==t._socket[x]&&(t._socket.removeListener("data",Z),process.nextTick(K,t._socket),t.close(e[S])),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e))}function z(){this[x].emitClose()}function $(e,t){this[x].emit("message",e,t)}function W(e){const t=this[x];t._autoPong&&t.pong(e,!this._isServer,T),t.emit("ping",e)}function G(e){this[x].emit("pong",e)}function K(e){e.resume()}function Y(e){const t=this[x];t.readyState!==M.CLOSED&&(t.readyState===M.OPEN&&(t._readyState=M.CLOSING,Q(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e)))}function Q(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),3e4)}function J(){const e=this[x];let t;this.removeListener("close",J),this.removeListener("data",Z),this.removeListener("end",X),e._readyState=M.CLOSING,this._readableState.endEmitted||e._closeFrameReceived||e._receiver._writableState.errorEmitted||null===(t=e._socket.read())||e._receiver.write(t),e._receiver.end(),this[x]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",z),e._receiver.on("finish",z))}function Z(e){this[x]._receiver.write(e)||this.pause()}function X(){const e=this[x];e._readyState=M.CLOSING,e._receiver.end(),this.end()}function ee(){const e=this[x];this.removeListener("error",ee),this.on("error",T),e&&(e._readyState=M.CLOSING,this.destroy())}Object.defineProperty(M,"CONNECTING",{enumerable:!0,value:R.indexOf("CONNECTING")}),Object.defineProperty(M.prototype,"CONNECTING",{enumerable:!0,value:R.indexOf("CONNECTING")}),Object.defineProperty(M,"OPEN",{enumerable:!0,value:R.indexOf("OPEN")}),Object.defineProperty(M.prototype,"OPEN",{enumerable:!0,value:R.indexOf("OPEN")}),Object.defineProperty(M,"CLOSING",{enumerable:!0,value:R.indexOf("CLOSING")}),Object.defineProperty(M.prototype,"CLOSING",{enumerable:!0,value:R.indexOf("CLOSING")}),Object.defineProperty(M,"CLOSED",{enumerable:!0,value:R.indexOf("CLOSED")}),Object.defineProperty(M.prototype,"CLOSED",{enumerable:!0,value:R.indexOf("CLOSED")}),["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((e=>{Object.defineProperty(M.prototype,e,{enumerable:!0})})),["open","error","close","message"].forEach((e=>{Object.defineProperty(M.prototype,`on${e}`,{enumerable:!0,get(){for(const t of this.listeners(e))if(t[w])return t[_];return null},set(t){for(const t of this.listeners(e))if(t[w]){this.removeListener(e,t);break}"function"==typeof t&&this.addEventListener(e,t,{[w]:!0})}})})),M.prototype.addEventListener=E,M.prototype.removeEventListener=C,e.exports=M},7486:(e,t,i)=>{"use strict";i.d(t,{BASIC:()=>c});var n=i(9145),o=i(6284);const r=["realm"],s=r,a={type:"Basic",parseWWWAuthenticateRest:function(e){return(0,o.parseHTTPHeadersQuotedKeyValueSet)(e,s,r)},buildWWWAuthenticateRest:function(e){return(0,o.$)(e,s,r)},parseAuthorizationRest:function(e){if(!e)throw new n.w("E_EMPTY_AUTH");const{username:t,password:i}=a.decodeHash(e);return{hash:e,username:t,password:i}},buildAuthorizationRest:function({hash:e,username:t,password:i}){if(t&&i)return a.computeHash({username:t,password:i});if(!e)throw new n.w("E_NO_HASH");return e},computeHash:function({username:e,password:t}){return Buffer.from(e+":"+t).toString("base64")},decodeHash:function(e){const[t,...i]=Buffer.from(e,"base64").toString().split(":");return{username:t,password:i.join(":")}}},c=a;i(6982);const l=["realm","nonce"],p=["username","realm","nonce","uri","response"]},7510:(e,t,i)=>{"use strict";const n=globalThis.AbortController||i(581).AbortController,{codes:{ERR_INVALID_ARG_VALUE:o,ERR_INVALID_ARG_TYPE:r,ERR_MISSING_ARGS:s,ERR_OUT_OF_RANGE:a},AbortError:c}=i(676),{validateAbortSignal:l,validateInteger:p,validateObject:u}=i(2354),d=i(3383).Symbol("kWeak"),h=i(3383).Symbol("kResistStopPropagation"),{finished:m}=i(9071),f=i(8279),{addAbortSignalNoValidate:g}=i(1564),{isWritable:v,isNodeStream:y}=i(6274),{deprecate:b}=i(3939),{ArrayPrototypePush:w,Boolean:_,MathFloor:S,Number:x,NumberIsNaN:T,Promise:E,PromiseReject:C,PromiseResolve:P,PromisePrototypeThen:k,Symbol:O}=i(3383),I=O("kEmpty"),A=O("kEof");function R(e,t){if("function"!=typeof e)throw new r("fn",["Function","AsyncFunction"],e);null!=t&&u(t,"options"),null!=(null==t?void 0:t.signal)&&l(t.signal,"options.signal");let n=1;null!=(null==t?void 0:t.concurrency)&&(n=S(t.concurrency));let o=n-1;return null!=(null==t?void 0:t.highWaterMark)&&(o=S(t.highWaterMark)),p(n,"options.concurrency",1),p(o,"options.highWaterMark",0),o+=n,async function*(){const r=i(3939).AbortSignalAny([null==t?void 0:t.signal].filter(_)),s=this,a=[],l={signal:r};let p,u,d=!1,h=0;function m(){d=!0,f()}function f(){h-=1,g()}function g(){u&&!d&&h<n&&a.length<o&&(u(),u=null)}!async function(){try{for await(let t of s){if(d)return;if(r.aborted)throw new c;try{if(t=e(t,l),t===I)continue;t=P(t)}catch(e){t=C(e)}h+=1,k(t,f,m),a.push(t),p&&(p(),p=null),!d&&(a.length>=o||h>=n)&&await new E((e=>{u=e}))}a.push(A)}catch(e){const t=C(e);k(t,f,m),a.push(t)}finally{d=!0,p&&(p(),p=null)}}();try{for(;;){for(;a.length>0;){const e=await a[0];if(e===A)return;if(r.aborted)throw new c;e!==I&&(yield e),a.shift(),g()}await new E((e=>{p=e}))}}finally{d=!0,u&&(u(),u=null)}}.call(this)}async function D(e,t=void 0){for await(const i of M.call(this,e,t))return!0;return!1}function M(e,t){if("function"!=typeof e)throw new r("fn",["Function","AsyncFunction"],e);return R.call(this,(async function(t,i){return await e(t,i)?t:I}),t)}class N extends s{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}}function L(e){if(e=x(e),T(e))return 0;if(e<0)throw new a("number",">= 0",e);return e}e.exports.streamReturningOperators={asIndexedPairs:b((function(e=void 0){return null!=e&&u(e,"options"),null!=(null==e?void 0:e.signal)&&l(e.signal,"options.signal"),async function*(){let t=0;for await(const n of this){var i;if(null!=e&&null!==(i=e.signal)&&void 0!==i&&i.aborted)throw new c({cause:e.signal.reason});yield[t++,n]}}.call(this)}),"readable.asIndexedPairs will be removed in a future version."),drop:function(e,t=void 0){return null!=t&&u(t,"options"),null!=(null==t?void 0:t.signal)&&l(t.signal,"options.signal"),e=L(e),async function*(){var i;if(null!=t&&null!==(i=t.signal)&&void 0!==i&&i.aborted)throw new c;for await(const i of this){var n;if(null!=t&&null!==(n=t.signal)&&void 0!==n&&n.aborted)throw new c;e--<=0&&(yield i)}}.call(this)},filter:M,flatMap:function(e,t){const i=R.call(this,e,t);return async function*(){for await(const e of i)yield*e}.call(this)},map:R,take:function(e,t=void 0){return null!=t&&u(t,"options"),null!=(null==t?void 0:t.signal)&&l(t.signal,"options.signal"),e=L(e),async function*(){var i;if(null!=t&&null!==(i=t.signal)&&void 0!==i&&i.aborted)throw new c;for await(const i of this){var n;if(null!=t&&null!==(n=t.signal)&&void 0!==n&&n.aborted)throw new c;if(e-- >0&&(yield i),e<=0)return}}.call(this)},compose:function(e,t){if(null!=t&&u(t,"options"),null!=(null==t?void 0:t.signal)&&l(t.signal,"options.signal"),y(e)&&!v(e))throw new o("stream",e,"must be writable");const i=f(this,e);return null!=t&&t.signal&&g(t.signal,i),i}},e.exports.promiseReturningOperators={every:async function(e,t=void 0){if("function"!=typeof e)throw new r("fn",["Function","AsyncFunction"],e);return!await D.call(this,(async(...t)=>!await e(...t)),t)},forEach:async function(e,t){if("function"!=typeof e)throw new r("fn",["Function","AsyncFunction"],e);for await(const i of R.call(this,(async function(t,i){return await e(t,i),I}),t));},reduce:async function(e,t,i){var o;if("function"!=typeof e)throw new r("reducer",["Function","AsyncFunction"],e);null!=i&&u(i,"options"),null!=(null==i?void 0:i.signal)&&l(i.signal,"options.signal");let s=arguments.length>1;if(null!=i&&null!==(o=i.signal)&&void 0!==o&&o.aborted){const e=new c(void 0,{cause:i.signal.reason});throw this.once("error",(()=>{})),await m(this.destroy(e)),e}const a=new n,p=a.signal;if(null!=i&&i.signal){const e={once:!0,[d]:this,[h]:!0};i.signal.addEventListener("abort",(()=>a.abort()),e)}let f=!1;try{for await(const n of this){var g;if(f=!0,null!=i&&null!==(g=i.signal)&&void 0!==g&&g.aborted)throw new c;s?t=await e(t,n,{signal:p}):(t=n,s=!0)}if(!f&&!s)throw new N}finally{a.abort()}return t},toArray:async function(e){null!=e&&u(e,"options"),null!=(null==e?void 0:e.signal)&&l(e.signal,"options.signal");const t=[];for await(const n of this){var i;if(null!=e&&null!==(i=e.signal)&&void 0!==i&&i.aborted)throw new c(void 0,{cause:e.signal.reason});w(t,n)}return t},some:D,find:async function(e,t){for await(const i of M.call(this,e,t))return i}}},7589:(e,t,i)=>{var n,o,r,s=i(7016),a=s.URL,c=i(8611),l=i(5692),p=i(2203).Writable,u=i(2613),d=i(4154);n="undefined"!=typeof process,o="undefined"!=typeof window&&"undefined"!=typeof document,r=D(Error.captureStackTrace),n||!o&&r||console.warn("The follow-redirects package should be excluded from browser builds.");var h=!1;try{u(new a(""))}catch(e){h="ERR_INVALID_URL"===e.code}var m=["auth","host","hostname","href","path","pathname","port","protocol","query","search","hash"],f=["abort","aborted","connect","error","socket","timeout"],g=Object.create(null);f.forEach((function(e){g[e]=function(t,i,n){this._redirectable.emit(e,t,i,n)}}));var v=I("ERR_INVALID_URL","Invalid URL",TypeError),y=I("ERR_FR_REDIRECTION_FAILURE","Redirected request failed"),b=I("ERR_FR_TOO_MANY_REDIRECTS","Maximum number of redirects exceeded",y),w=I("ERR_FR_MAX_BODY_LENGTH_EXCEEDED","Request body larger than maxBodyLength limit"),_=I("ERR_STREAM_WRITE_AFTER_END","write after end"),S=p.prototype.destroy||E;function x(e,t){p.call(this),this._sanitizeOptions(e),this._options=e,this._ended=!1,this._ending=!1,this._redirectCount=0,this._redirects=[],this._requestBodyLength=0,this._requestBodyBuffers=[],t&&this.on("response",t);var i=this;this._onNativeResponse=function(e){try{i._processResponse(e)}catch(e){i.emit("error",e instanceof y?e:new y({cause:e}))}},this._performRequest()}function T(e){var t={maxRedirects:21,maxBodyLength:10485760},i={};return Object.keys(e).forEach((function(n){var o=n+":",r=i[o]=e[n],s=t[n]=Object.create(r);Object.defineProperties(s,{request:{value:function(e,n,r){var s;return s=e,a&&s instanceof a?e=k(e):R(e)?e=k(C(e)):(r=n,n=P(e),e={protocol:o}),D(n)&&(r=n,n=null),(n=Object.assign({maxRedirects:t.maxRedirects,maxBodyLength:t.maxBodyLength},e,n)).nativeProtocols=i,R(n.host)||R(n.hostname)||(n.hostname="::1"),u.equal(n.protocol,o,"protocol mismatch"),d("options",n),new x(n,r)},configurable:!0,enumerable:!0,writable:!0},get:{value:function(e,t,i){var n=s.request(e,t,i);return n.end(),n},configurable:!0,enumerable:!0,writable:!0}})})),t}function E(){}function C(e){var t;if(h)t=new a(e);else if(!R((t=P(s.parse(e))).protocol))throw new v({input:e});return t}function P(e){if(/^\[/.test(e.hostname)&&!/^\[[:0-9a-f]+\]$/i.test(e.hostname))throw new v({input:e.href||e});if(/^\[/.test(e.host)&&!/^\[[:0-9a-f]+\](:\d+)?$/i.test(e.host))throw new v({input:e.href||e});return e}function k(e,t){var i=t||{};for(var n of m)i[n]=e[n];return i.hostname.startsWith("[")&&(i.hostname=i.hostname.slice(1,-1)),""!==i.port&&(i.port=Number(i.port)),i.path=i.search?i.pathname+i.search:i.pathname,i}function O(e,t){var i;for(var n in t)e.test(n)&&(i=t[n],delete t[n]);return null===i||"undefined"==typeof i?void 0:String(i).trim()}function I(e,t,i){function n(i){D(Error.captureStackTrace)&&Error.captureStackTrace(this,this.constructor),Object.assign(this,i||{}),this.code=e,this.message=this.cause?t+": "+this.cause.message:t}return n.prototype=new(i||Error),Object.defineProperties(n.prototype,{constructor:{value:n,enumerable:!1},name:{value:"Error ["+e+"]",enumerable:!1}}),n}function A(e,t){for(var i of f)e.removeListener(i,g[i]);e.on("error",E),e.destroy(t)}function R(e){return"string"==typeof e||e instanceof String}function D(e){return"function"==typeof e}x.prototype=Object.create(p.prototype),x.prototype.abort=function(){A(this._currentRequest),this._currentRequest.abort(),this.emit("abort")},x.prototype.destroy=function(e){return A(this._currentRequest,e),S.call(this,e),this},x.prototype.write=function(e,t,i){if(this._ending)throw new _;if(!R(e)&&("object"!=typeof(n=e)||!("length"in n)))throw new TypeError("data should be a string, Buffer or Uint8Array");var n;D(t)&&(i=t,t=null),0!==e.length?this._requestBodyLength+e.length<=this._options.maxBodyLength?(this._requestBodyLength+=e.length,this._requestBodyBuffers.push({data:e,encoding:t}),this._currentRequest.write(e,t,i)):(this.emit("error",new w),this.abort()):i&&i()},x.prototype.end=function(e,t,i){if(D(e)?(i=e,e=t=null):D(t)&&(i=t,t=null),e){var n=this,o=this._currentRequest;this.write(e,t,(function(){n._ended=!0,o.end(null,null,i)})),this._ending=!0}else this._ended=this._ending=!0,this._currentRequest.end(null,null,i)},x.prototype.setHeader=function(e,t){this._options.headers[e]=t,this._currentRequest.setHeader(e,t)},x.prototype.removeHeader=function(e){delete this._options.headers[e],this._currentRequest.removeHeader(e)},x.prototype.setTimeout=function(e,t){var i=this;function n(t){t.setTimeout(e),t.removeListener("timeout",t.destroy),t.addListener("timeout",t.destroy)}function o(t){i._timeout&&clearTimeout(i._timeout),i._timeout=setTimeout((function(){i.emit("timeout"),r()}),e),n(t)}function r(){i._timeout&&(clearTimeout(i._timeout),i._timeout=null),i.removeListener("abort",r),i.removeListener("error",r),i.removeListener("response",r),i.removeListener("close",r),t&&i.removeListener("timeout",t),i.socket||i._currentRequest.removeListener("socket",o)}return t&&this.on("timeout",t),this.socket?o(this.socket):this._currentRequest.once("socket",o),this.on("socket",n),this.on("abort",r),this.on("error",r),this.on("response",r),this.on("close",r),this},["flushHeaders","getHeader","setNoDelay","setSocketKeepAlive"].forEach((function(e){x.prototype[e]=function(t,i){return this._currentRequest[e](t,i)}})),["aborted","connection","socket"].forEach((function(e){Object.defineProperty(x.prototype,e,{get:function(){return this._currentRequest[e]}})})),x.prototype._sanitizeOptions=function(e){if(e.headers||(e.headers={}),e.host&&(e.hostname||(e.hostname=e.host),delete e.host),!e.pathname&&e.path){var t=e.path.indexOf("?");t<0?e.pathname=e.path:(e.pathname=e.path.substring(0,t),e.search=e.path.substring(t))}},x.prototype._performRequest=function(){var e=this._options.protocol,t=this._options.nativeProtocols[e];if(!t)throw new TypeError("Unsupported protocol "+e);if(this._options.agents){var i=e.slice(0,-1);this._options.agent=this._options.agents[i]}var n=this._currentRequest=t.request(this._options,this._onNativeResponse);for(var o of(n._redirectable=this,f))n.on(o,g[o]);if(this._currentUrl=/^\//.test(this._options.path)?s.format(this._options):this._options.path,this._isRedirect){var r=0,a=this,c=this._requestBodyBuffers;!function e(t){if(n===a._currentRequest)if(t)a.emit("error",t);else if(r<c.length){var i=c[r++];n.finished||n.write(i.data,i.encoding,e)}else a._ended&&n.end()}()}},x.prototype._processResponse=function(e){var t=e.statusCode;this._options.trackRedirects&&this._redirects.push({url:this._currentUrl,headers:e.headers,statusCode:t});var i,n=e.headers.location;if(!n||!1===this._options.followRedirects||t<300||t>=400)return e.responseUrl=this._currentUrl,e.redirects=this._redirects,this.emit("response",e),void(this._requestBodyBuffers=[]);if(A(this._currentRequest),e.destroy(),++this._redirectCount>this._options.maxRedirects)throw new b;var o=this._options.beforeRedirect;o&&(i=Object.assign({Host:e.req.getHeader("host")},this._options.headers));var r=this._options.method;((301===t||302===t)&&"POST"===this._options.method||303===t&&!/^(?:GET|HEAD)$/.test(this._options.method))&&(this._options.method="GET",this._requestBodyBuffers=[],O(/^content-/i,this._options.headers));var c,l,p=O(/^host$/i,this._options.headers),m=C(this._currentUrl),f=p||m.host,g=/^\w+:/.test(n)?this._currentUrl:s.format(Object.assign(m,{host:f})),v=(c=n,l=g,h?new a(c,l):C(s.resolve(l,c)));if(d("redirecting to",v.href),this._isRedirect=!0,k(v,this._options),(v.protocol!==m.protocol&&"https:"!==v.protocol||v.host!==f&&!function(e,t){u(R(e)&&R(t));var i=e.length-t.length-1;return i>0&&"."===e[i]&&e.endsWith(t)}(v.host,f))&&O(/^(?:(?:proxy-)?authorization|cookie)$/i,this._options.headers),D(o)){var y={headers:e.headers,statusCode:t},w={url:g,method:r,headers:i};o(this._options,y,w),this._sanitizeOptions(this._options)}this._performRequest()},e.exports=T({http:c,https:l}),e.exports.wrap=T},7658:function(e,t,i){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[t.length]=i);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i=n(e),s=0;s<i.length;s++)"default"!==i[s]&&o(t,e,i[s]);return r(t,e),t}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const c=i(7260),l=s(i(3861)),p=i(3540),u=a(i(9896)),d=i(8705),h=i(5425),m=a(i(145));class f extends l.ScryptedDeviceBase{constructor(e,t){super(e),this.initStorage={},this.storageSettings=new p.StorageSettings(this,this.initStorage),this.currentMixinsMap={},this.thumbnailsToGenerate=[],this.generatingThumbnails=!1,this.plugin=t;const i=this.getLogger();this.init().catch(i.error)}async init(){this.ffmpegPath=await l.default.mediaManager.getFFmpegPath(),setInterval((async()=>{if(!this.generatingThumbnails){const e=this.thumbnailsToGenerate.shift();if(e){const{deviceId:t,thumbnailId:i}=e,n=this.currentMixinsMap[t],o=n.getLogger();o.log(`Generating thumbnail of clip ${i}`),this.generatingThumbnails=!0;const{videoclipUrl:r,thumbnailUrl:s}=await n.getVideoclipParams(i);try{const e=await n.generateThumbnail(r);e.length?(o.log(`Saving thumbnail in ${s}`),await u.default.promises.writeFile(s,e)):o.log("Not saving, image is corrupted")}catch(e){o.log("Failed generating thumbnail",r,i,e)}finally{this.generatingThumbnails=!1,await(0,c.sleep)(3e3)}}}}),1e3)}async putSetting(e,t){return this.storageSettings.putSetting(e,t)}getLogger(){return(0,d.getBaseLogger)({console:this.console,storage:this.storageSettings})}async getSettings(){try{return await this.storageSettings.getSettings()}catch(e){return this.getLogger().log("Error in getSettings",e),[]}}async canMixin(e,t){return[l.ScryptedInterface.Camera,l.ScryptedInterface.VideoCamera].some((e=>t.includes(e)))&&t.includes(h.pluginId)?[l.ScryptedInterface.Settings,l.ScryptedInterface.VideoClips,h.REOLINK_HUB_VIDEOCLIPS_INTERFACE]:void 0}async getMixin(e,t,i){return new m.default({mixinDevice:e,mixinDeviceInterfaces:t,mixinDeviceState:i,mixinProviderNativeId:this.nativeId,group:"Reolink HUB videoclips",groupKey:"reolinkHubVideoclips"},this)}async releaseMixin(e,t){await t.release()}}t.default=f},7701:(e,t,i)=>{e.exports=i(8396)},7719:(e,t,i)=>{const{Buffer:n}=i(181),{ObjectDefineProperty:o,ObjectKeys:r,ReflectApply:s}=i(3383),{promisify:{custom:a}}=i(3939),{streamReturningOperators:c,promiseReturningOperators:l}=i(7510),{codes:{ERR_ILLEGAL_CONSTRUCTOR:p}}=i(676),u=i(8279),{setDefaultHighWaterMark:d,getDefaultHighWaterMark:h}=i(5722),{pipeline:m}=i(5101),{destroyer:f}=i(577),g=i(9071),v=i(2144),y=i(6274),b=e.exports=i(1808).Stream;b.isDestroyed=y.isDestroyed,b.isDisturbed=y.isDisturbed,b.isErrored=y.isErrored,b.isReadable=y.isReadable,b.isWritable=y.isWritable,b.Readable=i(5047);for(const S of r(c)){const x=c[S];function w(...e){if(new.target)throw p();return b.Readable.from(s(x,this,e))}o(w,"name",{__proto__:null,value:x.name}),o(w,"length",{__proto__:null,value:x.length}),o(b.Readable.prototype,S,{__proto__:null,value:w,enumerable:!1,configurable:!0,writable:!0})}for(const T of r(l)){const E=l[T];function w(...e){if(new.target)throw p();return s(E,this,e)}o(w,"name",{__proto__:null,value:E.name}),o(w,"length",{__proto__:null,value:E.length}),o(b.Readable.prototype,T,{__proto__:null,value:w,enumerable:!1,configurable:!0,writable:!0})}b.Writable=i(7819),b.Duplex=i(5745),b.Transform=i(39),b.PassThrough=i(5253),b.pipeline=m;const{addAbortSignal:_}=i(1564);b.addAbortSignal=_,b.finished=g,b.destroy=f,b.compose=u,b.setDefaultHighWaterMark=d,b.getDefaultHighWaterMark=h,o(b,"promises",{__proto__:null,configurable:!0,enumerable:!0,get:()=>v}),o(m,a,{__proto__:null,enumerable:!0,get:()=>v.pipeline}),o(g,a,{__proto__:null,enumerable:!0,get:()=>v.finished}),b.Stream=b,b._isUint8Array=function(e){return e instanceof Uint8Array},b._uint8ArrayToBuffer=function(e){return n.from(e.buffer,e.byteOffset,e.byteLength)}},7766:(e,t,i)=>{t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const i="color: "+this.color;t.splice(1,0,i,"color: inherit");let n=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(o=n))})),t.splice(o,0,i)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=i(5337)(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},7819:(e,t,i)=>{const n=i(7097),{ArrayPrototypeSlice:o,Error:r,FunctionPrototypeSymbolHasInstance:s,ObjectDefineProperty:a,ObjectDefineProperties:c,ObjectSetPrototypeOf:l,StringPrototypeToLowerCase:p,Symbol:u,SymbolHasInstance:d}=i(3383);e.exports=M,M.WritableState=R;const{EventEmitter:h}=i(4434),m=i(1808).Stream,{Buffer:f}=i(181),g=i(577),{addAbortSignal:v}=i(1564),{getHighWaterMark:y,getDefaultHighWaterMark:b}=i(5722),{ERR_INVALID_ARG_TYPE:w,ERR_METHOD_NOT_IMPLEMENTED:_,ERR_MULTIPLE_CALLBACK:S,ERR_STREAM_CANNOT_PIPE:x,ERR_STREAM_DESTROYED:T,ERR_STREAM_ALREADY_FINISHED:E,ERR_STREAM_NULL_VALUES:C,ERR_STREAM_WRITE_AFTER_END:P,ERR_UNKNOWN_ENCODING:k}=i(676).codes,{errorOrDestroy:O}=g;function I(){}l(M.prototype,m.prototype),l(M,m);const A=u("kOnFinished");function R(e,t,n){"boolean"!=typeof n&&(n=t instanceof i(5745)),this.objectMode=!(!e||!e.objectMode),n&&(this.objectMode=this.objectMode||!(!e||!e.writableObjectMode)),this.highWaterMark=e?y(this,e,"writableHighWaterMark",n):b(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;const o=!(!e||!1!==e.decodeStrings);this.decodeStrings=!o,this.defaultEncoding=e&&e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=F.bind(void 0,t),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,D(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!e||!1!==e.emitClose,this.autoDestroy=!e||!1!==e.autoDestroy,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[A]=[]}function D(e){e.buffered=[],e.bufferedIndex=0,e.allBuffers=!0,e.allNoop=!0}function M(e){const t=this instanceof i(5745);if(!t&&!s(M,this))return new M(e);this._writableState=new R(e,this,t),e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final),"function"==typeof e.construct&&(this._construct=e.construct),e.signal&&v(e.signal,this)),m.call(this,e),g.construct(this,(()=>{const e=this._writableState;e.writing||V(this,e),$(this,e)}))}function N(e,t,i,o){const r=e._writableState;if("function"==typeof i)o=i,i=r.defaultEncoding;else{if(i){if("buffer"!==i&&!f.isEncoding(i))throw new k(i)}else i=r.defaultEncoding;"function"!=typeof o&&(o=I)}if(null===t)throw new C;if(!r.objectMode)if("string"==typeof t)!1!==r.decodeStrings&&(t=f.from(t,i),i="buffer");else if(t instanceof f)i="buffer";else{if(!m._isUint8Array(t))throw new w("chunk",["string","Buffer","Uint8Array"],t);t=m._uint8ArrayToBuffer(t),i="buffer"}let s;return r.ending?s=new P:r.destroyed&&(s=new T("write")),s?(n.nextTick(o,s),O(e,s,!0),s):(r.pendingcb++,function(e,t,i,n,o){const r=t.objectMode?1:i.length;t.length+=r;const s=t.length<t.highWaterMark;s||(t.needDrain=!0);t.writing||t.corked||t.errored||!t.constructed?(t.buffered.push({chunk:i,encoding:n,callback:o}),t.allBuffers&&"buffer"!==n&&(t.allBuffers=!1),t.allNoop&&o!==I&&(t.allNoop=!1)):(t.writelen=r,t.writecb=o,t.writing=!0,t.sync=!0,e._write(i,n,t.onwrite),t.sync=!1);return s&&!t.errored&&!t.destroyed}(e,r,t,i,o))}function L(e,t,i,n,o,r,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new T("write")):i?e._writev(o,t.onwrite):e._write(o,r,t.onwrite),t.sync=!1}function j(e,t,i,n){--t.pendingcb,n(i),q(t),O(e,i)}function F(e,t){const i=e._writableState,o=i.sync,r=i.writecb;"function"==typeof r?(i.writing=!1,i.writecb=null,i.length-=i.writelen,i.writelen=0,t?(t.stack,i.errored||(i.errored=t),e._readableState&&!e._readableState.errored&&(e._readableState.errored=t),o?n.nextTick(j,e,i,t,r):j(e,i,t,r)):(i.buffered.length>i.bufferedIndex&&V(e,i),o?null!==i.afterWriteTickInfo&&i.afterWriteTickInfo.cb===r?i.afterWriteTickInfo.count++:(i.afterWriteTickInfo={count:1,cb:r,stream:e,state:i},n.nextTick(B,i.afterWriteTickInfo)):U(e,i,1,r))):O(e,new S)}function B({stream:e,state:t,count:i,cb:n}){return t.afterWriteTickInfo=null,U(e,t,i,n)}function U(e,t,i,n){for(!t.ending&&!e.destroyed&&0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"));i-- >0;)t.pendingcb--,n();t.destroyed&&q(t),$(e,t)}function q(e){if(e.writing)return;for(let i=e.bufferedIndex;i<e.buffered.length;++i){var t;const{chunk:n,callback:o}=e.buffered[i],r=e.objectMode?1:n.length;e.length-=r,o(null!==(t=e.errored)&&void 0!==t?t:new T("write"))}const i=e[A].splice(0);for(let t=0;t<i.length;t++){var n;i[t](null!==(n=e.errored)&&void 0!==n?n:new T("end"))}D(e)}function V(e,t){if(t.corked||t.bufferProcessing||t.destroyed||!t.constructed)return;const{buffered:i,bufferedIndex:n,objectMode:r}=t,s=i.length-n;if(!s)return;let a=n;if(t.bufferProcessing=!0,s>1&&e._writev){t.pendingcb-=s-1;const n=t.allNoop?I:e=>{for(let t=a;t<i.length;++t)i[t].callback(e)},r=t.allNoop&&0===a?i:o(i,a);r.allBuffers=t.allBuffers,L(e,t,!0,t.length,r,"",n),D(t)}else{do{const{chunk:n,encoding:o,callback:s}=i[a];i[a++]=null;L(e,t,!1,r?1:n.length,n,o,s)}while(a<i.length&&!t.writing);a===i.length?D(t):a>256?(i.splice(0,a),t.bufferedIndex=0):t.bufferedIndex=a}t.bufferProcessing=!1}function H(e){return e.ending&&!e.destroyed&&e.constructed&&0===e.length&&!e.errored&&0===e.buffered.length&&!e.finished&&!e.writing&&!e.errorEmitted&&!e.closeEmitted}function z(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.finalCalled=!0,function(e,t){let i=!1;function o(o){if(i)O(e,null!=o?o:S());else if(i=!0,t.pendingcb--,o){const i=t[A].splice(0);for(let e=0;e<i.length;e++)i[e](o);O(e,o,t.sync)}else H(t)&&(t.prefinished=!0,e.emit("prefinish"),t.pendingcb++,n.nextTick(W,e,t))}t.sync=!0,t.pendingcb++;try{e._final(o)}catch(e){o(e)}t.sync=!1}(e,t)))}function $(e,t,i){H(t)&&(z(e,t),0===t.pendingcb&&(i?(t.pendingcb++,n.nextTick(((e,t)=>{H(t)?W(e,t):t.pendingcb--}),e,t)):H(t)&&(t.pendingcb++,W(e,t))))}function W(e,t){t.pendingcb--,t.finished=!0;const i=t[A].splice(0);for(let e=0;e<i.length;e++)i[e]();if(e.emit("finish"),t.autoDestroy){const t=e._readableState;(!t||t.autoDestroy&&(t.endEmitted||!1===t.readable))&&e.destroy()}}R.prototype.getBuffer=function(){return o(this.buffered,this.bufferedIndex)},a(R.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}}),a(M,d,{__proto__:null,value:function(e){return!!s(this,e)||this===M&&(e&&e._writableState instanceof R)}}),M.prototype.pipe=function(){O(this,new x)},M.prototype.write=function(e,t,i){return!0===N(this,e,t,i)},M.prototype.cork=function(){this._writableState.corked++},M.prototype.uncork=function(){const e=this._writableState;e.corked&&(e.corked--,e.writing||V(this,e))},M.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=p(e)),!f.isEncoding(e))throw new k(e);return this._writableState.defaultEncoding=e,this},M.prototype._write=function(e,t,i){if(!this._writev)throw new _("_write()");this._writev([{chunk:e,encoding:t}],i)},M.prototype._writev=null,M.prototype.end=function(e,t,i){const o=this._writableState;let s;if("function"==typeof e?(i=e,e=null,t=null):"function"==typeof t&&(i=t,t=null),null!=e){const i=N(this,e,t);i instanceof r&&(s=i)}return o.corked&&(o.corked=1,this.uncork()),s||(o.errored||o.ending?o.finished?s=new E("end"):o.destroyed&&(s=new T("end")):(o.ending=!0,$(this,o,!0),o.ended=!0)),"function"==typeof i&&(s||o.finished?n.nextTick(i,s):o[A].push(i)),this},c(M.prototype,{closed:{__proto__:null,get(){return!!this._writableState&&this._writableState.closed}},destroyed:{__proto__:null,get(){return!!this._writableState&&this._writableState.destroyed},set(e){this._writableState&&(this._writableState.destroyed=e)}},writable:{__proto__:null,get(){const e=this._writableState;return!(!e||!1===e.writable||e.destroyed||e.errored||e.ending||e.ended)},set(e){this._writableState&&(this._writableState.writable=!!e)}},writableFinished:{__proto__:null,get(){return!!this._writableState&&this._writableState.finished}},writableObjectMode:{__proto__:null,get(){return!!this._writableState&&this._writableState.objectMode}},writableBuffer:{__proto__:null,get(){return this._writableState&&this._writableState.getBuffer()}},writableEnded:{__proto__:null,get(){return!!this._writableState&&this._writableState.ending}},writableNeedDrain:{__proto__:null,get(){const e=this._writableState;return!!e&&(!e.destroyed&&!e.ending&&e.needDrain)}},writableHighWaterMark:{__proto__:null,get(){return this._writableState&&this._writableState.highWaterMark}},writableCorked:{__proto__:null,get(){return this._writableState?this._writableState.corked:0}},writableLength:{__proto__:null,get(){return this._writableState&&this._writableState.length}},errored:{__proto__:null,enumerable:!1,get(){return this._writableState?this._writableState.errored:null}},writableAborted:{__proto__:null,enumerable:!1,get:function(){return!(!1===this._writableState.writable||!this._writableState.destroyed&&!this._writableState.errored||this._writableState.finished)}}});const G=g.destroy;let K;function Y(){return void 0===K&&(K={}),K}M.prototype.destroy=function(e,t){const i=this._writableState;return!i.destroyed&&(i.bufferedIndex<i.buffered.length||i[A].length)&&n.nextTick(q,i),G.call(this,e,t),this},M.prototype._undestroy=g.undestroy,M.prototype._destroy=function(e,t){t(e)},M.prototype[h.captureRejectionSymbol]=function(e){this.destroy(e)},M.fromWeb=function(e,t){return Y().newStreamWritableFromWritableStream(e,t)},M.toWeb=function(e){return Y().newWritableStreamFromStreamWritable(e)}},7897:(e,t,i)=>{var n=i(7430),o=i(7241),r=i(4151);function s(e,t){return e<t?-1:e>t?1:0}e.exports=function(e,t,i,s){var a=o(e,i);return n(e,t,a,(function i(o,r){o?s(o,r):(a.index++,a.index<(a.keyedList||e).length?n(e,t,a,i):s(null,a.results))})),r.bind(a,s)},e.exports.ascending=s,e.exports.descending=function(e,t){return-1*s(e,t)}},7917:(e,t,i)=>{"use strict";i.d(t,{BASIC:()=>m,DIGEST:()=>x,buildAuthorizationHeader:()=>O,parseWWWAuthenticateHeader:()=>k});var n=i(857);class o extends Error{code;params;wrappedErrors;constructor(e,t,...i){e instanceof Array||(i=("undefined"==typeof t?[]:[t]).concat(i),t=e,e=[]),super(t),this.code=t||"E_UNEXPECTED",this.params=i,this.wrappedErrors=e,this.name=this.toString(),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}static wrap(e,t,...i){const n=s(e.message),r=("wrappedErrors"in e?e.wrappedErrors:[]).concat(e);return t||(t=n?e.message:"E_UNEXPECTED"),e.message&&!n&&i.push(e.message),new o(r,t,...i)}static cast(e,t,...i){return r(e)?e:o.wrap(e,t,...i)}static bump(e,t,...i){return r(e)?o.wrap(e,e.code,...e.params):o.wrap(e,t,...i)}toString(){return(this.wrappedErrors.length?this.wrappedErrors[this.wrappedErrors.length-1].stack+n.EOL:"")+this.constructor.name+": "+this.code+" ("+this.params.join(", ")+")"}}function r(e){return!!(e instanceof o)||!!(e.constructor&&e.constructor.name&&e.constructor.name.endsWith("Error")&&"code"in e&&"string"==typeof e.code&&s(e.code)&&"params"in e&&e.params&&e.params instanceof Array)}function s(e){return/^([A-Z0-9_]+)$/.test(e)}const a=/\w+=(".*?"|[^",]+)(?=,|$)/g;function c(e,t,i=[],n=[]){const r=e.trim().match(a);if(!r)throw new o("E_MALFORMED_QUOTEDKEYVALUE",e);const s=r.map(((e,t)=>{const[i,...n]=e.split("="),r=n.join("=");if(0===n.length)throw new o("E_MALFORMED_QUOTEDKEYVALUE",t,e);return[i,r]})).reduce((function(e,[i,r],s){const a=i.toLowerCase();if(-1===t.indexOf(a))throw new o("E_UNAUTHORIZED_KEY",s,a);const c=r.replace(/^"(.+(?="$))"$/,"$1");return e[a]=n.includes(a)?c.toLowerCase():c,e}),{});return p(i,s),s}function l(e,t,i=[]){return p(i,e),t.reduce((function(t,i){return e[i]?t+(t?", ":"")+i+'="'+e[i]+'"':t}),"")}function p(e,t){e.forEach((e=>{if("undefined"==typeof t[e])throw new o("E_REQUIRED_KEY",e)}))}const u=["realm"],d=u,h={type:"Basic",parseWWWAuthenticateRest:function(e){return c(e,d,u)},buildWWWAuthenticateRest:function(e){return l(e,d,u)},parseAuthorizationRest:function(e){if(!e)throw new o("E_EMPTY_AUTH");const{username:t,password:i}=h.decodeHash(e);return{hash:e,username:t,password:i}},buildAuthorizationRest:function({hash:e,username:t,password:i}){if(t&&i)return h.computeHash({username:t,password:i});if(!e)throw new o("E_NO_HASH");return e},computeHash:function({username:e,password:t}){return Buffer.from(e+":"+t).toString("base64")},decodeHash:function(e){const[t,...i]=Buffer.from(e,"base64").toString().split(":");return{username:t,password:i.join(":")}}},m=h;var f=i(6982);const g=["realm","nonce"],v=[...g,"domain","opaque","stale","algorithm","qop"],y=["stale"],b=["username","realm","nonce","uri","response"],w=[...b,"algorithm","cnonce","opaque","qop","nc"],_={type:"Digest",parseWWWAuthenticateRest:function(e){return c(e,v,g,y)},buildWWWAuthenticateRest:function(e){return l(e,v,g)},parseAuthorizationRest:function(e){return c(e,w,b)},buildAuthorizationRest:function(e){return l(e,w,b)},computeHash:function(e){const t=e.ha1||S(e.algorithm,[e.username,e.realm,e.password].join(":")),i=S(e.algorithm,[e.method,e.uri].join(":"));return S(e.algorithm,[t,e.nonce,e.nc,e.cnonce,e.qop,i].join(":"))}};function S(e,t){const i=f.createHash(e);return i.update(t),i.digest("hex")}const x=_,T=["invalid_request","invalid_token","insufficient_scope"],E=["realm","scope","error","error_description"],C={type:"Bearer",parseWWWAuthenticateRest:function(e){return c(e,E,[])},buildWWWAuthenticateRest:function(e){if(e.error&&-1===T.indexOf(e.error))throw new o("E_INVALID_ERROR",e.error,T);return l(e,E,[])},parseAuthorizationRest:function(e){if(!e)throw new o("E_EMPTY_AUTH");return{hash:e}},buildAuthorizationRest:function({hash:e}){if(!e)throw new o("E_NO_HASH");return e}},P=[m,_,C];function k(e,t=P,{strict:i=!0}={strict:!0}){let n=null;if(t.some((t=>(0===e.indexOf(t.type+" ")||!i&&0===e.indexOf(t.type.toLowerCase()+" "))&&(n={type:t.type,data:t.parseWWWAuthenticateRest(e.substr(t.type.length+1))},!0))),!n)throw new o("E_UNKNOWN_AUTH_MECHANISM",e);return n}function O(e,t){return`${e.type} ${e.buildAuthorizationRest(t)}`}},7925:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=(e,t,i)=>{e.log("handling pubrel packet");const n="undefined"!=typeof i?i:e.noop,{messageId:o}=t,r={cmd:"pubcomp",messageId:o};e.incomingStore.get(t,((t,i)=>{t?e._sendPacket(r,n):(e.emit("message",i.topic,i.payload,i),e.handleMessage(i,(t=>{if(t)return n(t);e.incomingStore.del(i,e.noop),e._sendPacket(r,n)})))}))}},7934:e=>{"use strict";const t=Symbol("kDone"),i=Symbol("kRun");e.exports=class{constructor(e){this[t]=()=>{this.pending--,this[i]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[i]()}[i](){if(this.pending!==this.concurrency&&this.jobs.length){const e=this.jobs.shift();this.pending++,e(this[t])}}}},8032:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isReactNativeBrowser=t.isWebWorker=void 0;const i=()=>{var e,t;return Boolean("object"==typeof self&&(null===(t=null===(e=null===self||void 0===self?void 0:self.constructor)||void 0===e?void 0:e.name)||void 0===t?void 0:t.includes("WorkerGlobalScope")))},n=()=>"undefined"!=typeof navigator&&"ReactNative"===navigator.product,o=(()=>{var e;if("undefined"!=typeof window){if("undefined"!=typeof navigator&&(null===(e=navigator.userAgent)||void 0===e?void 0:e.toLowerCase().indexOf(" electron/"))>-1&&(null===process||void 0===process?void 0:process.versions)){return!Object.prototype.hasOwnProperty.call(process.versions,"electron")}return"undefined"!=typeof window.document}return!1})()||i()||n();t.isWebWorker=i(),t.isReactNativeBrowser=n(),t.default=o},8218:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OnvifCameraAPI=t.OnvifEvent=void 0,t.connectCameraAPI=async function(e,t,i,n,o){const r=e.split(":"),[a,p]=r,u=await c((e=>{const n=new s({hostname:a,username:t,password:i,port:p},(t=>e(t,n)))}));return new l(u,t,i,n,o)};const n=i(6739),o=i(4434),r=i(5049),{Cam:s}=r;var a;async function c(e){return new Promise(((t,i)=>{e(((e,n)=>{if(e)return i(e);t(n)}))}))}!function(e){e[e.MotionBuggy=0]="MotionBuggy",e[e.MotionStart=1]="MotionStart",e[e.MotionStop=2]="MotionStop",e[e.AudioStart=3]="AudioStart",e[e.AudioStop=4]="AudioStop",e[e.BinaryStart=5]="BinaryStart",e[e.BinaryStop=6]="BinaryStop",e[e.CellMotion=7]="CellMotion",e[e.Detection=8]="Detection",e[e.BinaryRingEvent=9]="BinaryRingEvent",e[e.DigitalInputStart=10]="DigitalInputStart",e[e.DigitalInputStop=11]="DigitalInputStop"}(a||(t.OnvifEvent=a={}));class l{constructor(e,t,i,n,o){this.cam=e,this.console=n,this.snapshotUrls=new Map,this.rtspUrls=new Map,this.binaryStateEvent=o,this.credential={username:t,password:i}}async request(e,t){return await(0,n.authHttpFetch)({..."string"==typeof e||e instanceof URL?{url:e}:e,rejectUnauthorized:!1,credential:this.credential,body:t})}async reboot(){return new Promise(((e,t)=>{this.cam.systemReboot(((i,n,o)=>{if(i)return this.console.log("reboot error",i),t(i);e(n)}))}))}listenEvents(){const e=new o.EventEmitter;return this.cam.on("event",((t,i)=>{if(e.emit("data",i),!t.message.message.data?.simpleItem?.$)return;const n=t.message.message.data.simpleItem.$.Value,o=function(e){let t="",i=e.split("/");for(let e=0;e<i.length;e++){let n=i[e].split(":").pop();0===t.length?t+=n:t+="/"+n}return t}(t.topic._);if(e.emit("onvifEvent",o,n),o.includes("MotionAlarm"))n?e.emit("event",a.MotionStart):e.emit("event",a.MotionStop);else if(o.includes("DetectedSound"))n?e.emit("event",a.AudioStart):e.emit("event",a.AudioStop);else if(!o.includes("Visitor")||!0!==n&&!1!==n){if(o.includes("VideoSource/Alarm"))"Ring"!==n&&"CameraBellButton"!==n||e.emit("event",a.BinaryRingEvent);else if(this.binaryStateEvent&&o.includes(this.binaryStateEvent))n?e.emit("event",a.BinaryStart):e.emit("event",a.BinaryStop);else if(o.includes("RuleEngine/CellMotionDetector/Motion"))"IsMotion"===t.message.message.data.simpleItem.$.Name&&n&&e.emit("event",a.MotionBuggy);else if(o.includes("RuleEngine/ObjectDetector")&&n)try{const i=t.message.message.data.simpleItem.$.Name,n=this.detections.get(i);this.console.log("object detected:",n),e.emit("event",a.Detection,n)}catch(e){this.console.warn("error parsing detection",e)}}else n?e.emit("event",a.BinaryStart):e.emit("event",a.BinaryStop)})),e}async canConfigureEncoding(){return!!(await c((e=>this.cam.getMediaServiceCapabilities(e)))).profileCapabilities}async getVideoEncoderConfigurationOptions(e,t){const i=await c((t=>this.cam.getVideoEncoderConfigurationOptions({profileToken:e},t))),n=[];let o;i.H264&&n.push("h264"),i.H265&&n.push("h265");const r=[];let s,a;const l=[];let p;const u=e=>Array.isArray(e)?e:[e],d=i?.extension?.H264||i?.H264;return d&&(d?.H264ProfilesSupported&&l.push(...u(d.H264ProfilesSupported).map((e=>e.toLowerCase()))),d?.resolutionsAvailable&&r.push(...u(d.resolutionsAvailable).map((e=>[e.width,e.height]))),(d?.frameRateRange?.min||d?.frameRateRange?.max)&&(s=[d.frameRateRange.min,d.frameRateRange.max]),(d?.govLengthRange?.min||d?.govLengthRange?.max)&&(a=[d.govLengthRange.min,d.govLengthRange.max]),(d?.bitrateRange?.min||d?.bitrateRange?.max)&&(p=[d.bitrateRange.min,d.bitrateRange.max])),(i.qualityRange?.min||i?.qualityRange?.max)&&(o=[i.qualityRange.min,i.qualityRange.max]),{codecs:n,qualityRange:o,fpsRange:s,keyframeIntervalRange:a,resolutions:r,profiles:l,bitrateRange:p}}async setVideoEncoderConfiguration(e){return c((t=>this.cam.setVideoEncoderConfiguration(e,t)))}async setAudioEncoderConfiguration(e){return c((t=>this.cam.setAudioEncoderConfiguration(e,t)))}async getProfiles(){return this.profiles||(this.profiles=c((e=>this.cam.getProfiles(e))),this.profiles.catch((()=>this.profiles=void 0))),this.profiles}async getMainProfileToken(){const e=await this.getProfiles(),{token:t}=e[0].$;return t}async supportsEvents(){return new Promise(((e,t)=>{this.cam.getCapabilities(((i,n,o)=>{if(i)return this.console.log("supportsEvents error",i),t(i);!i&&n.events&&n.events.WSPullPointSupport&&!0===n.events.WSPullPointSupport?this.console.log("Camera supports WSPullPoint",o):this.console.log("Camera does not show WSPullPoint support, but trying anyway",o),e(void 0)}))}))}async createSubscription(){return new Promise(((e,t)=>{this.cam.createPullPointSubscription(((i,n,o)=>{if(i)return this.console.log("createSubscription error",i),t(i);e(void 0)}))}))}unsubscribe(){return new Promise(((e,t)=>{this.cam.unsubscribe(((i,n,o)=>{if(i)return this.console.log("unsubscribe error",i),t(i);e(void 0)}))}))}async getEventTypes(){return this.detections?[...this.detections.values()]:new Promise(((e,t)=>{this.cam.getEventProperties(((i,n,o)=>{if(i)return this.console.log("getEventTypes error",i),t(i);this.console.log(o),this.detections=new Map;try{if(n.topicSet.ruleEngine.objectDetector)for(const[e,t]of Object.entries(n.topicSet.ruleEngine.objectDetector))try{const i=t.messageDescription.data.simpleItemDescription.$.Name;this.detections.set(i,e)}catch(e){}}catch(e){}e([...this.detections.values()])}))}))}async getStreamUrl(e){if(e||(e=await this.getMainProfileToken()),!this.rtspUrls.has(e)){const t=(await c((t=>this.cam.getStreamUri({protocol:"RTSP",profileToken:e},t)))).uri;this.rtspUrls.set(e,t)}return this.rtspUrls.get(e)}async jpegSnapshot(e,t=1e4){if(e||(e=await this.getMainProfileToken()),!this.snapshotUrls.has(e))try{const t=(await c((t=>this.cam.getSnapshotUri({profileToken:e},t)))).uri;this.snapshotUrls.set(e,t)}catch(t){if(!t.message||-1===t.message.indexOf("ActionNotSupported"))throw t;this.snapshotUrls.set(e,void 0)}const i=this.snapshotUrls.get(e);if(!i)return;return(await this.request({url:i,timeout:t})).body}getDeviceInformation(){return c((e=>{this.cam.getDeviceInformation(e)}))}async getOSDs(){return c((e=>{this.cam.getOSDs(e)}))}async setOSD(e){return c((t=>{this.cam.setOSD(e,t)}))}}t.OnvifCameraAPI=l},8279:(e,t,i)=>{"use strict";const{pipeline:n}=i(5101),o=i(5745),{destroyer:r}=i(577),{isNodeStream:s,isReadable:a,isWritable:c,isWebStream:l,isTransformStream:p,isWritableStream:u,isReadableStream:d}=i(6274),{AbortError:h,codes:{ERR_INVALID_ARG_VALUE:m,ERR_MISSING_ARGS:f}}=i(676),g=i(9071);e.exports=function(...e){if(0===e.length)throw new f("streams");if(1===e.length)return o.from(e[0]);const t=[...e];if("function"==typeof e[0]&&(e[0]=o.from(e[0])),"function"==typeof e[e.length-1]){const t=e.length-1;e[t]=o.from(e[t])}for(let i=0;i<e.length;++i)if(s(e[i])||l(e[i])){if(i<e.length-1&&!(a(e[i])||d(e[i])||p(e[i])))throw new m(`streams[${i}]`,t[i],"must be readable");if(i>0&&!(c(e[i])||u(e[i])||p(e[i])))throw new m(`streams[${i}]`,t[i],"must be writable")}let i,v,y,b,w;const _=e[0],S=n(e,(function(e){const t=b;b=null,t?t(e):e?w.destroy(e):T||x||w.destroy()})),x=!!(c(_)||u(_)||p(_)),T=!!(a(S)||d(S)||p(S));if(w=new o({writableObjectMode:!(null==_||!_.writableObjectMode),readableObjectMode:!(null==S||!S.readableObjectMode),writable:x,readable:T}),x){if(s(_))w._write=function(e,t,n){_.write(e,t)?n():i=n},w._final=function(e){_.end(),v=e},_.on("drain",(function(){if(i){const e=i;i=null,e()}}));else if(l(_)){const e=(p(_)?_.writable:_).getWriter();w._write=async function(t,i,n){try{await e.ready,e.write(t).catch((()=>{})),n()}catch(e){n(e)}},w._final=async function(t){try{await e.ready,e.close().catch((()=>{})),v=t}catch(e){t(e)}}}const e=p(S)?S.readable:S;g(e,(()=>{if(v){const e=v;v=null,e()}}))}if(T)if(s(S))S.on("readable",(function(){if(y){const e=y;y=null,e()}})),S.on("end",(function(){w.push(null)})),w._read=function(){for(;;){const e=S.read();if(null===e)return void(y=w._read);if(!w.push(e))return}};else if(l(S)){const e=(p(S)?S.readable:S).getReader();w._read=async function(){for(;;)try{const{value:t,done:i}=await e.read();if(!w.push(t))return;if(i)return void w.push(null)}catch{return}}}return w._destroy=function(e,t){e||null===b||(e=new h),y=null,i=null,v=null,null===b?t(e):(b=t,s(S)&&r(S,e))},w}},8281:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ScryptedMimeTypes=t.ScryptedInterface=t.MediaPlayerState=t.SecuritySystemObstruction=t.SecuritySystemMode=t.AirQuality=t.AirPurifierMode=t.AirPurifierStatus=t.ChargeState=t.LockState=t.PanTiltZoomMovement=t.ThermostatMode=t.TemperatureUnit=t.FanMode=t.HumidityMode=t.ScryptedDeviceType=t.ScryptedInterfaceDescriptors=t.ScryptedInterfaceMethod=t.ScryptedInterfaceProperty=t.DeviceBase=t.TYPES_VERSION=void 0,t.TYPES_VERSION="0.5.26";var i,n,o,r,s,a,c,l,p,u,d,h,m,f,g,v,y,b;t.DeviceBase=class{},function(e){e.id="id",e.info="info",e.interfaces="interfaces",e.mixins="mixins",e.name="name",e.nativeId="nativeId",e.pluginId="pluginId",e.providedInterfaces="providedInterfaces",e.providedName="providedName",e.providedRoom="providedRoom",e.providedType="providedType",e.providerId="providerId",e.room="room",e.type="type",e.scryptedRuntimeArguments="scryptedRuntimeArguments",e.on="on",e.brightness="brightness",e.colorTemperature="colorTemperature",e.rgb="rgb",e.hsv="hsv",e.buttons="buttons",e.sensors="sensors",e.running="running",e.paused="paused",e.docked="docked",e.temperatureSetting="temperatureSetting",e.temperature="temperature",e.temperatureUnit="temperatureUnit",e.humidity="humidity",e.audioVolumes="audioVolumes",e.recordingActive="recordingActive",e.ptzCapabilities="ptzCapabilities",e.lockState="lockState",e.entryOpen="entryOpen",e.batteryLevel="batteryLevel",e.chargeState="chargeState",e.online="online",e.fromMimeType="fromMimeType",e.toMimeType="toMimeType",e.converters="converters",e.binaryState="binaryState",e.tampered="tampered",e.sleeping="sleeping",e.powerDetected="powerDetected",e.audioDetected="audioDetected",e.motionDetected="motionDetected",e.ambientLight="ambientLight",e.occupied="occupied",e.flooded="flooded",e.ultraviolet="ultraviolet",e.luminance="luminance",e.position="position",e.securitySystemState="securitySystemState",e.pm10Density="pm10Density",e.pm25Density="pm25Density",e.vocDensity="vocDensity",e.noxDensity="noxDensity",e.co2ppm="co2ppm",e.airQuality="airQuality",e.airPurifierState="airPurifierState",e.filterChangeIndication="filterChangeIndication",e.filterLifeLevel="filterLifeLevel",e.humiditySetting="humiditySetting",e.fan="fan",e.applicationInfo="applicationInfo",e.systemDevice="systemDevice"}(i||(t.ScryptedInterfaceProperty=i={})),function(e){e.listen="listen",e.probe="probe",e.setMixins="setMixins",e.setName="setName",e.setRoom="setRoom",e.setType="setType",e.getPluginJson="getPluginJson",e.turnOff="turnOff",e.turnOn="turnOn",e.setBrightness="setBrightness",e.getTemperatureMaxK="getTemperatureMaxK",e.getTemperatureMinK="getTemperatureMinK",e.setColorTemperature="setColorTemperature",e.setRgb="setRgb",e.setHsv="setHsv",e.pressButton="pressButton",e.sendNotification="sendNotification",e.start="start",e.stop="stop",e.pause="pause",e.resume="resume",e.dock="dock",e.setTemperature="setTemperature",e.setTemperatureUnit="setTemperatureUnit",e.getPictureOptions="getPictureOptions",e.takePicture="takePicture",e.getAudioStream="getAudioStream",e.setAudioVolumes="setAudioVolumes",e.startDisplay="startDisplay",e.stopDisplay="stopDisplay",e.getVideoStream="getVideoStream",e.getVideoStreamOptions="getVideoStreamOptions",e.getPrivacyMasks="getPrivacyMasks",e.setPrivacyMasks="setPrivacyMasks",e.getVideoTextOverlays="getVideoTextOverlays",e.setVideoTextOverlay="setVideoTextOverlay",e.getRecordingStream="getRecordingStream",e.getRecordingStreamCurrentTime="getRecordingStreamCurrentTime",e.getRecordingStreamOptions="getRecordingStreamOptions",e.getRecordingStreamThumbnail="getRecordingStreamThumbnail",e.deleteRecordingStream="deleteRecordingStream",e.setRecordingActive="setRecordingActive",e.ptzCommand="ptzCommand",e.getRecordedEvents="getRecordedEvents",e.getVideoClip="getVideoClip",e.getVideoClips="getVideoClips",e.getVideoClipThumbnail="getVideoClipThumbnail",e.removeVideoClips="removeVideoClips",e.setVideoStreamOptions="setVideoStreamOptions",e.startIntercom="startIntercom",e.stopIntercom="stopIntercom",e.lock="lock",e.unlock="unlock",e.addPassword="addPassword",e.getPasswords="getPasswords",e.removePassword="removePassword",e.activate="activate",e.deactivate="deactivate",e.isReversible="isReversible",e.closeEntry="closeEntry",e.openEntry="openEntry",e.getDevice="getDevice",e.releaseDevice="releaseDevice",e.adoptDevice="adoptDevice",e.discoverDevices="discoverDevices",e.createDevice="createDevice",e.getCreateDeviceSettings="getCreateDeviceSettings",e.reboot="reboot",e.getRefreshFrequency="getRefreshFrequency",e.refresh="refresh",e.getMediaStatus="getMediaStatus",e.load="load",e.seek="seek",e.skipNext="skipNext",e.skipPrevious="skipPrevious",e.convert="convert",e.convertMedia="convertMedia",e.getSettings="getSettings",e.putSetting="putSetting",e.armSecuritySystem="armSecuritySystem",e.disarmSecuritySystem="disarmSecuritySystem",e.setAirPurifierState="setAirPurifierState",e.getReadmeMarkdown="getReadmeMarkdown",e.getOauthUrl="getOauthUrl",e.onOauthCallback="onOauthCallback",e.canMixin="canMixin",e.getMixin="getMixin",e.releaseMixin="releaseMixin",e.onRequest="onRequest",e.onConnection="onConnection",e.onPush="onPush",e.run="run",e.eval="eval",e.loadScripts="loadScripts",e.saveScript="saveScript",e.forkInterface="forkInterface",e.trackObjects="trackObjects",e.getDetectionInput="getDetectionInput",e.getObjectTypes="getObjectTypes",e.detectObjects="detectObjects",e.generateObjectDetections="generateObjectDetections",e.getDetectionModel="getDetectionModel",e.setHumidity="setHumidity",e.setFan="setFan",e.startRTCSignalingSession="startRTCSignalingSession",e.createRTCSignalingSession="createRTCSignalingSession",e.getScryptedUserAccessControl="getScryptedUserAccessControl",e.generateVideoFrames="generateVideoFrames",e.connectStream="connectStream",e.getTTYSettings="getTTYSettings",e.getChatCompletion="getChatCompletion",e.streamChatCompletion="streamChatCompletion",e.getTextEmbedding="getTextEmbedding",e.getImageEmbedding="getImageEmbedding",e.callLLMTool="callLLMTool",e.getLLMTools="getLLMTools"}(n||(t.ScryptedInterfaceMethod=n={})),t.ScryptedInterfaceDescriptors={ScryptedDevice:{name:"ScryptedDevice",methods:["listen","probe","setMixins","setName","setRoom","setType"],properties:["id","info","interfaces","mixins","name","nativeId","pluginId","providedInterfaces","providedName","providedRoom","providedType","providerId","room","type"]},ScryptedPlugin:{name:"ScryptedPlugin",methods:["getPluginJson"],properties:[]},ScryptedPluginRuntime:{name:"ScryptedPluginRuntime",methods:[],properties:["scryptedRuntimeArguments"]},OnOff:{name:"OnOff",methods:["turnOff","turnOn"],properties:["on"]},Brightness:{name:"Brightness",methods:["setBrightness"],properties:["brightness"]},ColorSettingTemperature:{name:"ColorSettingTemperature",methods:["getTemperatureMaxK","getTemperatureMinK","setColorTemperature"],properties:["colorTemperature"]},ColorSettingRgb:{name:"ColorSettingRgb",methods:["setRgb"],properties:["rgb"]},ColorSettingHsv:{name:"ColorSettingHsv",methods:["setHsv"],properties:["hsv"]},Buttons:{name:"Buttons",methods:[],properties:["buttons"]},PressButtons:{name:"PressButtons",methods:["pressButton"],properties:[]},Sensors:{name:"Sensors",methods:[],properties:["sensors"]},Notifier:{name:"Notifier",methods:["sendNotification"],properties:[]},StartStop:{name:"StartStop",methods:["start","stop"],properties:["running"]},Pause:{name:"Pause",methods:["pause","resume"],properties:["paused"]},Dock:{name:"Dock",methods:["dock"],properties:["docked"]},TemperatureSetting:{name:"TemperatureSetting",methods:["setTemperature"],properties:["temperatureSetting"]},Thermometer:{name:"Thermometer",methods:["setTemperatureUnit"],properties:["temperature","temperatureUnit"]},HumiditySensor:{name:"HumiditySensor",methods:[],properties:["humidity"]},Camera:{name:"Camera",methods:["getPictureOptions","takePicture"],properties:[]},Microphone:{name:"Microphone",methods:["getAudioStream"],properties:[]},AudioVolumeControl:{name:"AudioVolumeControl",methods:["setAudioVolumes"],properties:["audioVolumes"]},Display:{name:"Display",methods:["startDisplay","stopDisplay"],properties:[]},VideoCamera:{name:"VideoCamera",methods:["getVideoStream","getVideoStreamOptions"],properties:[]},VideoCameraMask:{name:"VideoCameraMask",methods:["getPrivacyMasks","setPrivacyMasks"],properties:[]},VideoTextOverlays:{name:"VideoTextOverlays",methods:["getVideoTextOverlays","setVideoTextOverlay"],properties:[]},VideoRecorder:{name:"VideoRecorder",methods:["getRecordingStream","getRecordingStreamCurrentTime","getRecordingStreamOptions","getRecordingStreamThumbnail"],properties:["recordingActive"]},VideoRecorderManagement:{name:"VideoRecorderManagement",methods:["deleteRecordingStream","setRecordingActive"],properties:[]},PanTiltZoom:{name:"PanTiltZoom",methods:["ptzCommand"],properties:["ptzCapabilities"]},EventRecorder:{name:"EventRecorder",methods:["getRecordedEvents"],properties:[]},VideoClips:{name:"VideoClips",methods:["getVideoClip","getVideoClips","getVideoClipThumbnail","removeVideoClips"],properties:[]},VideoCameraConfiguration:{name:"VideoCameraConfiguration",methods:["setVideoStreamOptions"],properties:[]},Intercom:{name:"Intercom",methods:["startIntercom","stopIntercom"],properties:[]},Lock:{name:"Lock",methods:["lock","unlock"],properties:["lockState"]},PasswordStore:{name:"PasswordStore",methods:["addPassword","getPasswords","removePassword"],properties:[]},Scene:{name:"Scene",methods:["activate","deactivate","isReversible"],properties:[]},Entry:{name:"Entry",methods:["closeEntry","openEntry"],properties:[]},EntrySensor:{name:"EntrySensor",methods:[],properties:["entryOpen"]},DeviceProvider:{name:"DeviceProvider",methods:["getDevice","releaseDevice"],properties:[]},DeviceDiscovery:{name:"DeviceDiscovery",methods:["adoptDevice","discoverDevices"],properties:[]},DeviceCreator:{name:"DeviceCreator",methods:["createDevice","getCreateDeviceSettings"],properties:[]},Battery:{name:"Battery",methods:[],properties:["batteryLevel"]},Charger:{name:"Charger",methods:[],properties:["chargeState"]},Reboot:{name:"Reboot",methods:["reboot"],properties:[]},Refresh:{name:"Refresh",methods:["getRefreshFrequency","refresh"],properties:[]},MediaPlayer:{name:"MediaPlayer",methods:["getMediaStatus","load","seek","skipNext","skipPrevious"],properties:[]},Online:{name:"Online",methods:[],properties:["online"]},BufferConverter:{name:"BufferConverter",methods:["convert"],properties:["fromMimeType","toMimeType"]},MediaConverter:{name:"MediaConverter",methods:["convertMedia"],properties:["converters"]},Settings:{name:"Settings",methods:["getSettings","putSetting"],properties:[]},BinarySensor:{name:"BinarySensor",methods:[],properties:["binaryState"]},TamperSensor:{name:"TamperSensor",methods:[],properties:["tampered"]},Sleep:{name:"Sleep",methods:[],properties:["sleeping"]},PowerSensor:{name:"PowerSensor",methods:[],properties:["powerDetected"]},AudioSensor:{name:"AudioSensor",methods:[],properties:["audioDetected"]},MotionSensor:{name:"MotionSensor",methods:[],properties:["motionDetected"]},AmbientLightSensor:{name:"AmbientLightSensor",methods:[],properties:["ambientLight"]},OccupancySensor:{name:"OccupancySensor",methods:[],properties:["occupied"]},FloodSensor:{name:"FloodSensor",methods:[],properties:["flooded"]},UltravioletSensor:{name:"UltravioletSensor",methods:[],properties:["ultraviolet"]},LuminanceSensor:{name:"LuminanceSensor",methods:[],properties:["luminance"]},PositionSensor:{name:"PositionSensor",methods:[],properties:["position"]},SecuritySystem:{name:"SecuritySystem",methods:["armSecuritySystem","disarmSecuritySystem"],properties:["securitySystemState"]},PM10Sensor:{name:"PM10Sensor",methods:[],properties:["pm10Density"]},PM25Sensor:{name:"PM25Sensor",methods:[],properties:["pm25Density"]},VOCSensor:{name:"VOCSensor",methods:[],properties:["vocDensity"]},NOXSensor:{name:"NOXSensor",methods:[],properties:["noxDensity"]},CO2Sensor:{name:"CO2Sensor",methods:[],properties:["co2ppm"]},AirQualitySensor:{name:"AirQualitySensor",methods:[],properties:["airQuality"]},AirPurifier:{name:"AirPurifier",methods:["setAirPurifierState"],properties:["airPurifierState"]},FilterMaintenance:{name:"FilterMaintenance",methods:[],properties:["filterChangeIndication","filterLifeLevel"]},Readme:{name:"Readme",methods:["getReadmeMarkdown"],properties:[]},OauthClient:{name:"OauthClient",methods:["getOauthUrl","onOauthCallback"],properties:[]},MixinProvider:{name:"MixinProvider",methods:["canMixin","getMixin","releaseMixin"],properties:[]},HttpRequestHandler:{name:"HttpRequestHandler",methods:["onRequest"],properties:[]},EngineIOHandler:{name:"EngineIOHandler",methods:["onConnection"],properties:[]},PushHandler:{name:"PushHandler",methods:["onPush"],properties:[]},Program:{name:"Program",methods:["run"],properties:[]},Scriptable:{name:"Scriptable",methods:["eval","loadScripts","saveScript"],properties:[]},ClusterForkInterface:{name:"ClusterForkInterface",methods:["forkInterface"],properties:[]},ObjectTracker:{name:"ObjectTracker",methods:["trackObjects"],properties:[]},ObjectDetector:{name:"ObjectDetector",methods:["getDetectionInput","getObjectTypes"],properties:[]},ObjectDetection:{name:"ObjectDetection",methods:["detectObjects","generateObjectDetections","getDetectionModel"],properties:[]},ObjectDetectionPreview:{name:"ObjectDetectionPreview",methods:[],properties:[]},ObjectDetectionGenerator:{name:"ObjectDetectionGenerator",methods:[],properties:[]},HumiditySetting:{name:"HumiditySetting",methods:["setHumidity"],properties:["humiditySetting"]},Fan:{name:"Fan",methods:["setFan"],properties:["fan"]},RTCSignalingChannel:{name:"RTCSignalingChannel",methods:["startRTCSignalingSession"],properties:[]},RTCSignalingClient:{name:"RTCSignalingClient",methods:["createRTCSignalingSession"],properties:[]},LauncherApplication:{name:"LauncherApplication",methods:[],properties:["applicationInfo"]},ScryptedUser:{name:"ScryptedUser",methods:["getScryptedUserAccessControl"],properties:[]},VideoFrameGenerator:{name:"VideoFrameGenerator",methods:["generateVideoFrames"],properties:[]},StreamService:{name:"StreamService",methods:["connectStream"],properties:[]},TTY:{name:"TTY",methods:[],properties:[]},TTYSettings:{name:"TTYSettings",methods:["getTTYSettings"],properties:[]},ChatCompletion:{name:"ChatCompletion",methods:["getChatCompletion","streamChatCompletion"],properties:[]},TextEmbedding:{name:"TextEmbedding",methods:["getTextEmbedding"],properties:[]},ImageEmbedding:{name:"ImageEmbedding",methods:["getImageEmbedding"],properties:[]},LLMTools:{name:"LLMTools",methods:["callLLMTool","getLLMTools"],properties:[]},ScryptedSystemDevice:{name:"ScryptedSystemDevice",methods:[],properties:["systemDevice"]},ScryptedDeviceCreator:{name:"ScryptedDeviceCreator",methods:[],properties:[]},ScryptedSettings:{name:"ScryptedSettings",methods:[],properties:[]}},function(e){e.Builtin="Builtin",e.Internal="Internal",e.Camera="Camera",e.Fan="Fan",e.Light="Light",e.Switch="Switch",e.Outlet="Outlet",e.Sensor="Sensor",e.Scene="Scene",e.Program="Program",e.Automation="Automation",e.Vacuum="Vacuum",e.Notifier="Notifier",e.Thermostat="Thermostat",e.Lock="Lock",e.PasswordControl="PasswordControl",e.Display="Display",e.SmartDisplay="SmartDisplay",e.Speaker="Speaker",e.SmartSpeaker="SmartSpeaker",e.RemoteDesktop="RemoteDesktop",e.Event="Event",e.Entry="Entry",e.Garage="Garage",e.DeviceProvider="DeviceProvider",e.DataSource="DataSource",e.API="API",e.Doorbell="Doorbell",e.Irrigation="Irrigation",e.Valve="Valve",e.Person="Person",e.SecuritySystem="SecuritySystem",e.WindowCovering="WindowCovering",e.Siren="Siren",e.AirPurifier="AirPurifier",e.Internet="Internet",e.Network="Network",e.Bridge="Bridge",e.LLM="LLM",e.Unknown="Unknown"}(o||(t.ScryptedDeviceType=o={})),function(e){e.Humidify="Humidify",e.Dehumidify="Dehumidify",e.Auto="Auto",e.Off="Off"}(r||(t.HumidityMode=r={})),function(e){e.Auto="Auto",e.Manual="Manual"}(s||(t.FanMode=s={})),function(e){e.C="C",e.F="F"}(a||(t.TemperatureUnit=a={})),function(e){e.Off="Off",e.Cool="Cool",e.Heat="Heat",e.HeatCool="HeatCool",e.Auto="Auto",e.FanOnly="FanOnly",e.Purifier="Purifier",e.Eco="Eco",e.Dry="Dry",e.On="On"}(c||(t.ThermostatMode=c={})),function(e){e.Absolute="Absolute",e.Relative="Relative",e.Continuous="Continuous",e.Preset="Preset",e.Home="Home"}(l||(t.PanTiltZoomMovement=l={})),function(e){e.Locked="Locked",e.Unlocked="Unlocked",e.Jammed="Jammed"}(p||(t.LockState=p={})),function(e){e.Trickle="trickle",e.Charging="charging",e.NotCharging="not-charging"}(u||(t.ChargeState=u={})),function(e){e.Inactive="Inactive",e.Idle="Idle",e.Active="Active",e.ActiveNightMode="ActiveNightMode"}(d||(t.AirPurifierStatus=d={})),function(e){e.Manual="Manual",e.Automatic="Automatic"}(h||(t.AirPurifierMode=h={})),function(e){e.Unknown="Unknown",e.Excellent="Excellent",e.Good="Good",e.Fair="Fair",e.Inferior="Inferior",e.Poor="Poor"}(m||(t.AirQuality=m={})),function(e){e.Disarmed="Disarmed",e.HomeArmed="HomeArmed",e.AwayArmed="AwayArmed",e.NightArmed="NightArmed"}(f||(t.SecuritySystemMode=f={})),function(e){e.Sensor="Sensor",e.Occupied="Occupied",e.Time="Time",e.Error="Error"}(g||(t.SecuritySystemObstruction=g={})),function(e){e.Idle="Idle",e.Playing="Playing",e.Paused="Paused",e.Buffering="Buffering"}(v||(t.MediaPlayerState=v={})),function(e){e.ScryptedDevice="ScryptedDevice",e.ScryptedPlugin="ScryptedPlugin",e.ScryptedPluginRuntime="ScryptedPluginRuntime",e.OnOff="OnOff",e.Brightness="Brightness",e.ColorSettingTemperature="ColorSettingTemperature",e.ColorSettingRgb="ColorSettingRgb",e.ColorSettingHsv="ColorSettingHsv",e.Buttons="Buttons",e.PressButtons="PressButtons",e.Sensors="Sensors",e.Notifier="Notifier",e.StartStop="StartStop",e.Pause="Pause",e.Dock="Dock",e.TemperatureSetting="TemperatureSetting",e.Thermometer="Thermometer",e.HumiditySensor="HumiditySensor",e.Camera="Camera",e.Microphone="Microphone",e.AudioVolumeControl="AudioVolumeControl",e.Display="Display",e.VideoCamera="VideoCamera",e.VideoCameraMask="VideoCameraMask",e.VideoTextOverlays="VideoTextOverlays",e.VideoRecorder="VideoRecorder",e.VideoRecorderManagement="VideoRecorderManagement",e.PanTiltZoom="PanTiltZoom",e.EventRecorder="EventRecorder",e.VideoClips="VideoClips",e.VideoCameraConfiguration="VideoCameraConfiguration",e.Intercom="Intercom",e.Lock="Lock",e.PasswordStore="PasswordStore",e.Scene="Scene",e.Entry="Entry",e.EntrySensor="EntrySensor",e.DeviceProvider="DeviceProvider",e.DeviceDiscovery="DeviceDiscovery",e.DeviceCreator="DeviceCreator",e.Battery="Battery",e.Charger="Charger",e.Reboot="Reboot",e.Refresh="Refresh",e.MediaPlayer="MediaPlayer",e.Online="Online",e.BufferConverter="BufferConverter",e.MediaConverter="MediaConverter",e.Settings="Settings",e.BinarySensor="BinarySensor",e.TamperSensor="TamperSensor",e.Sleep="Sleep",e.PowerSensor="PowerSensor",e.AudioSensor="AudioSensor",e.MotionSensor="MotionSensor",e.AmbientLightSensor="AmbientLightSensor",e.OccupancySensor="OccupancySensor",e.FloodSensor="FloodSensor",e.UltravioletSensor="UltravioletSensor",e.LuminanceSensor="LuminanceSensor",e.PositionSensor="PositionSensor",e.SecuritySystem="SecuritySystem",e.PM10Sensor="PM10Sensor",e.PM25Sensor="PM25Sensor",e.VOCSensor="VOCSensor",e.NOXSensor="NOXSensor",e.CO2Sensor="CO2Sensor",e.AirQualitySensor="AirQualitySensor",e.AirPurifier="AirPurifier",e.FilterMaintenance="FilterMaintenance",e.Readme="Readme",e.OauthClient="OauthClient",e.MixinProvider="MixinProvider",e.HttpRequestHandler="HttpRequestHandler",e.EngineIOHandler="EngineIOHandler",e.PushHandler="PushHandler",e.Program="Program",e.Scriptable="Scriptable",e.ClusterForkInterface="ClusterForkInterface",e.ObjectTracker="ObjectTracker",e.ObjectDetector="ObjectDetector",e.ObjectDetection="ObjectDetection",e.ObjectDetectionPreview="ObjectDetectionPreview",e.ObjectDetectionGenerator="ObjectDetectionGenerator",e.HumiditySetting="HumiditySetting",e.Fan="Fan",e.RTCSignalingChannel="RTCSignalingChannel",e.RTCSignalingClient="RTCSignalingClient",e.LauncherApplication="LauncherApplication",e.ScryptedUser="ScryptedUser",e.VideoFrameGenerator="VideoFrameGenerator",e.StreamService="StreamService",e.TTY="TTY",e.TTYSettings="TTYSettings",e.ChatCompletion="ChatCompletion",e.TextEmbedding="TextEmbedding",e.ImageEmbedding="ImageEmbedding",e.LLMTools="LLMTools",e.ScryptedSystemDevice="ScryptedSystemDevice",e.ScryptedDeviceCreator="ScryptedDeviceCreator",e.ScryptedSettings="ScryptedSettings"}(y||(t.ScryptedInterface=y={})),function(e){e.Url="text/x-uri",e.InsecureLocalUrl="text/x-insecure-local-uri",e.LocalUrl="text/x-local-uri",e.ServerId="text/x-server-id",e.PushEndpoint="text/x-push-endpoint",e.SchemePrefix="x-scrypted/x-scrypted-scheme-",e.MediaStreamUrl="text/x-media-url",e.MediaObject="x-scrypted/x-scrypted-media-object",e.RequestMediaObject="x-scrypted/x-scrypted-request-media-object",e.RequestMediaStream="x-scrypted/x-scrypted-request-stream",e.MediaStreamFeedback="x-scrypted/x-media-stream-feedback",e.FFmpegInput="x-scrypted/x-ffmpeg-input",e.FFmpegTranscodeStream="x-scrypted/x-ffmpeg-transcode-stream",e.RTCSignalingChannel="x-scrypted/x-scrypted-rtc-signaling-channel",e.RTCSignalingSession="x-scrypted/x-scrypted-rtc-signaling-session",e.RTCConnectionManagement="x-scrypted/x-scrypted-rtc-connection-management",e.Image="x-scrypted/x-scrypted-image"}(b||(t.ScryptedMimeTypes=b={}))},8284:function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=i(9086),r=n(i(6766)),s=i(1364);t.default=(e,t)=>{e.log("_handleConnack");const{options:i}=e,n=5===i.protocolVersion?t.reasonCode:t.returnCode;if(clearTimeout(e.connackTimer),delete e.topicAliasSend,t.properties){if(t.properties.topicAliasMaximum){if(t.properties.topicAliasMaximum>65535)return void e.emit("error",new Error("topicAliasMaximum from broker is out of range"));t.properties.topicAliasMaximum>0&&(e.topicAliasSend=new r.default(t.properties.topicAliasMaximum))}t.properties.serverKeepAlive&&i.keepalive&&(i.keepalive=t.properties.serverKeepAlive),t.properties.maximumPacketSize&&(i.properties||(i.properties={}),i.properties.maximumPacketSize=t.properties.maximumPacketSize)}if(0===n)e.reconnecting=!1,e._onConnect(t);else if(n>0){const t=new s.ErrorWithReasonCode(`Connection refused: ${o.ReasonCodes[n]}`,n);e.emit("error",t)}}},8287:function(e,t,i){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[t.length]=i);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i=n(e),s=0;s<i.length;s++)"default"!==i[s]&&o(t,e,i[s]);return r(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.CameraProviderBase=t.CameraBase=void 0;const a=s(i(3861)),c=i(6982),{deviceManager:l}=a.default;class p extends a.ScryptedDeviceBase{constructor(e,t){super(e),this.provider=t}takePicture(e){throw new Error("The RTSP Camera does not provide snapshots. Install the Snapshot Plugin if snapshots are available via an URL.")}async getPictureOptions(){}async getVideoStreamOptions(){return this.getRawVideoStreamOptions()}async getVideoStream(e){const t=await this.getVideoStreamOptions(),i=t?.find((t=>t.id===e?.id))||this.getDefaultStream(t);return this.createVideoStream(i)}async getUrlSettings(){return[]}getUsername(){return this.storage.getItem("username")}getPassword(){return this.storage.getItem("password")}async getOtherSettings(){return[]}getDefaultStream(e){return e?.[0]}async getStreamSettings(){return[]}getUsernameDescription(){return"Optional: Username for snapshot http requests."}getPasswordDescription(){return"Optional: Password for snapshot http requests."}async getSettings(){const e=[{key:"username",title:"Username",value:this.getUsername(),description:this.getUsernameDescription()},{key:"password",title:"Password",value:this.getPassword(),type:"password",description:this.getPasswordDescription()},...await this.getUrlSettings(),...await this.getStreamSettings(),...await this.getOtherSettings()];for(const t of e)t.group=this.provider.name.replace("Plugin","").trim(),t.subgroup||="General";return e}async putSettingBase(e,t){if("defaultStream"===e){const e=(await this.getVideoStreamOptions()).find((e=>e.name===t));this.storage.setItem("defaultStream",e?.id||"")}else this.storage.setItem(e,t.toString());this.onDeviceEvent(a.ScryptedInterface.Settings,void 0)}async putSetting(e,t){this.putSettingBase(e,t)}}t.CameraBase=p;class u extends a.ScryptedDeviceBase{constructor(e){super(e),this.devices=new Map,this.systemDevice={deviceCreator:this.getScryptedDeviceCreator()}}async createDevice(e,t){t||=(0,c.randomBytes)(4).toString("hex");const i=e.newCamera?.toString()||"New Camera";return await this.updateDevice(t,i,this.getInterfaces()),t}async getCreateDeviceSettings(){return[{key:"newCamera",title:"Add Camera",placeholder:"Camera name, e.g.: Back Yard Camera, Baby Camera, etc"}]}getAdditionalInterfaces(){return[]}getInterfaces(){return[a.ScryptedInterface.VideoCamera,a.ScryptedInterface.Settings,...this.getAdditionalInterfaces()]}updateDevice(e,t,i,n){return l.onDeviceDiscovered({nativeId:e,name:t,interfaces:i,type:n||a.ScryptedDeviceType.Camera,info:l.getNativeIds().includes(e)?l.getDeviceState(e)?.info:void 0})}getDevice(e){let t=this.devices.get(e);return t||(t=this.createCamera(e),t&&this.devices.set(e,t)),t}async releaseDevice(e,t){this.devices.delete(t)}}t.CameraProviderBase=u},8330:e=>{"use strict";e.exports=JSON.parse('{"name":"@apocaliss92/scrypted-reolink-hub","version":"0.0.35","description":"Reolink (HUBs) Plugin for Scrypted","repository":{"type":"git","url":"https://github.com/apocaliss92/scrypted-reolink-hub"},"author":"Scrypted","license":"Apache","scripts":{"scrypted-setup-project":"scrypted-setup-project","prescrypted-setup-project":"scrypted-package-json","build":"scrypted-webpack","prepublishOnly":"NODE_ENV=production scrypted-webpack","prescrypted-vscode-launch":"scrypted-webpack","scrypted-vscode-launch":"scrypted-deploy-debug","scrypted-deploy-debug":"scrypted-deploy-debug","scrypted-debug":"scrypted-debug","scrypted-deploy":"scrypted-deploy","scrypted-readme":"scrypted-readme","scrypted-package-json":"scrypted-package-json"},"keywords":["scrypted","plugin","reolink","camera"],"scrypted":{"name":"Reolink HUB Plugin","type":"API","interfaces":["Settings","DeviceProvider","HttpRequestHandler","Reboot","DeviceCreator"],"pluginDependencies":["@scrypted/prebuffer-mixin"]},"dependencies":{"@scrypted/common":"file:../scrypted/common","@scrypted/sdk":"file:../scrypted/sdk","@types/lodash":"^4.17.18","lodash":"^4.17.21"},"devDependencies":{"@types/node":"^22.0.2"}}')},8338:function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.startRtpForwarderProcess=async function(e,t,i,n){i.audio||delete i.audio;i.video||delete i.video;const l=new o.Deferred,g=e=>{const t=e?.onRtp;t&&(e.onRtp=(e,i)=>{if(l.finished)return;const n=127&e.readUint8(1);n>=72&&n<=76||t(e,i)})};g(i.video),g(i.audio);let v,{inputArguments:y}=t;l.promise.finally((()=>v?.safeTeardown()));let b=!1;const{rtspMode:w,onRtspClient:_,rtspClientForceTcp:S}=n||{},{video:x,audio:T}=i;i=Object.assign({},i);const E=x?.codecCopy,C=T?.codecCopy,P=n?.ffmpegPath||await d.getFFmpegPath(),k=t.container?.startsWith("rtsp");let O;const I=new o.Deferred;l.promise.finally((()=>{I.finished||I.reject(new Error("killed"))}));const A=new o.Deferred,R=new o.Deferred;A.promise.then((e=>x?.onMSection?.(e))),R.promise.then((e=>T?.onMSection?.(e)));let D,M,N=!1;if(t.url&&k&&(!x||(L=E,j=t.mediaStreamOptions?.video?.codec,"copy"===L||L&&L===j))){delete i.video,v=new a.RtspClient(t.url),v.requestTimeout=1e4;try{const t=await v.options();O=(await v.describe()).body.toString();const n=(0,c.parseSdp)(O);let o,d=0;if(x){if(o=n.msections.find((e=>"video"===e.type&&(e.codec===E||"copy"===E))),!o)throw new Error(`advertised video codec ${E} not found in sdp.`);o.codec||(e.warn("Unable to determine sdpvideo codec? Please report this to @koush on Discord."),e.warn(O)),A.resolve(o);const t=new Set;t.add(o);for(const e of x.alternateCodecs||[]){const i=n.msections.find((t=>"video"===t.type&&t.codec===e));i&&!t.has(i)&&t.add(i)}const i=h(x);for(const n of t)await f(e,v,d,n,S,i),d+=2}else A.resolve(void 0);const m=n.msections.filter((e=>"audio"===e.type));let g=m.find((e=>e.codec&&e.codec===C||"copy"===C));if(!g)for(const e of m)if(!0===await(T?.negotiate?.(e))){g=e;break}if(e.log("a/v",E,C,"found",o?.codec,g?.codec),T)if(g){delete i.audio,R.resolve(g);const t=new Set;t.add(g);for(const e of T.alternateCodecs||[]){const i=n.msections.find((t=>"audio"===t.type&&t.codec===e));i&&!t.has(i)&&t.add(i)}const o=h(T);for(const i of t)await f(e,v,d,i,S,o),d+=2}else{const t=(0,c.parseSdp)(O),n=t.msections.find((e=>"audio"===e.type));if(n){t.msections=t.msections.filter((e=>e===n));const i=(0,c.addTrackControls)((0,c.replaceSectionPort)(t.toSdp(),"audio",0)),o=(0,c.parseSdp)(i).msections.find((e=>"audio"===e.type)).control;let h=!0,m=!1;const g=await f(e,v,d,n,!1,(t=>{if(h&&(h=!1,"aac"===n.codec)){const i=u.RtpPacket.deSerialize(t).payload;if(255==i[0]&&!(240&~i[1])){m=!0,N=!0;const t=["-hide_banner","-f","aac","-i","pipe:3",...T.encoderArguments,...T.outputArguments];(0,s.safePrintFFmpegArguments)(e,t);const i=p.default.spawn(P,t,{stdio:["pipe","pipe","pipe","pipe","pipe"]});(0,s.ffmpegLogInitialOutput)(e,i),l.promise.finally((()=>(0,s.safeKillFFmpeg)(i))),i.on("exit",(()=>l.resolve(void 0))),i.on("error",(()=>l.resolve(void 0))),w=i.stdio[3]}}if(m){const e=u.RtpPacket.deSerialize(t);w?.write(e.payload)}else _?.sendTrack(o,t,!1)})),b=await(0,r.listenZeroSingleClient)("127.0.0.1");let w,_;l.promise.finally((()=>b.clientPromise.then((e=>e.destroy())))),b.clientPromise.then((async e=>{const t=new a.RtspServer(e,i,!g);l.promise.finally((()=>t.destroy())),await t.handlePlayback(),_=t})).catch((e=>{l.finished||l.reject(e)})),T.ffmpegDestination="127.0.0.1",T.srtp=void 0,y=["-analyzeduration","0","-probesize","512","-i",`rtsp://${b.host}:${b.port}`]}else delete i.audio,e.warn("audio section not found in sdp."),R.resolve(void 0)}else R.resolve(void 0);b=await(_?.(v,t)),b||await v.play()}catch(e){throw v.client.destroy(),e}}else e.log("video codec/container not matched, transcoding:",E,JSON.stringify(t));var L,j;const F=e=>{I.resolve(e);const t=(0,c.parseSdp)(e),i=t.msections.find((e=>"video"===e.type)),n=t.msections.find((e=>"audio"===e.type));return D=i?.codec,M=n?.codec,A.resolve(i),R.resolve(n),{videoSection:i,audioSection:n}};await async function(e,t,i){for(const e of Object.keys(i)){const n=i[e];n.bind=await(0,r.createBindZero)(),n.bind.server.setRecvBufferSize(1048576);const{server:o,port:s}=n.bind;t.promise.finally((()=>(0,r.closeQuiet)(o)));const a=n.outputArguments=[];n.payloadType&&a.push("-payload_type",n.payloadType.toString()),n.ssrc&&a.push("-ssrc",n.ssrc.toString())}}(0,l,i),v?.client.on("close",(()=>l.resolve(void 0)));const B=!w,U=new o.Deferred;let q;if(Object.keys(i).length){if(B){U.resolve(void 0);for(const e of Object.keys(i)){const t=i[e];let n=t.ffmpegDestination||"127.0.0.1";"127.0.0.1"===n&&(n=`${n}:${t.bind.port}`);const o=new URLSearchParams;let r=`rtp://${n}`;t.rtcpPort&&o.set("rtcpport",t.rtcpPort.toString()),t.packetSize&&o.set("pkt_size",t.packetSize.toString()),t.srtp&&(r=`s${r}`,t.outputArguments.push("-srtp_out_suite",t.srtp.crytoSuite,"-srtp_out_params",t.srtp.key.toString("base64"))),r=`${r}?${o}`,t.outputArguments.push("-dn","-sn"),"video"!==e&&t.outputArguments.push("-vn"),"audio"!==e&&t.outputArguments.push("-an"),t.outputArguments.push("-f","rtp"),t.outputArguments.push(r)}}const t=[];for(const e of Object.keys(i)){const n=i[e];t.push(...n.encoderArguments,...n.outputArguments)}const n=["-hide_banner",...y,...t];if(B)x?.bind?.server&&m(x,x.bind.server,(()=>D)),T?.bind?.server&&m(T,T.bind.server,(()=>M)),n.push("-sdp_file","pipe:4");else{const t="udp"===w,o=await(0,r.listenZeroSingleClient)("127.0.0.1");n.push("-rtsp_transport",t?"udp":"tcp","-f","rtsp",`rtsp://127.0.0.1:${o.port}`),o.clientPromise.then((async n=>{n.on("close",(()=>l.resolve(void 0))),l.promise.finally((()=>n.destroy()));const o=new a.RtspServer(n,void 0,t);await o.handleSetup(["announce"]);const{videoSection:r,audioSection:s}=F(o.sdp);if(await o.handleSetup(),x&&m(x,o.setupTracks[r?.control]?.rtp,(()=>r.codec)),T&&m(T,o.setupTracks[s?.control]?.rtp,(()=>s.codec)),U.resolve(o),"pull"!==w){let t=!0,n=!0;for await(const a of o.handleRecord())a.type===r.codec?(t&&(t=!1,x.firstPacket?.(a.packet,r.codec)),x.onRtp(a.packet,r.codec)):a.type===s?.codec?(n&&(n=!1,i.audio.firstPacket?.(a.packet,s?.codec)),T.onRtp(a.packet,s?.codec)):e.warn("unexpected rtsp sample",a.type)}})).catch((e=>{l.finished||l.reject(e)}))}(0,s.safePrintFFmpegArguments)(e,n),q=p.default.spawn(P,n,{stdio:["pipe","pipe","pipe","pipe","pipe","pipe"]}),l.promise.finally((()=>(0,s.safeKillFFmpeg)(q))),q.on("exit",(()=>{N||l.resolve(void 0)})),q.on("error",(()=>{N||l.resolve(void 0)})),(0,s.ffmpegLogInitialOutput)(e,q),B&&q.stdio[4].on("data",(e=>{const t=e.toString();F(t)}))}else I.resolve(O);!b&&v&&process.nextTick((async()=>{try{await v.readLoop()}catch(e){}l.resolve(void 0)}));const V=new o.Deferred;return V.promise.catch((()=>{})),(async()=>{try{const e=await A.promise,t=await R.promise;let i="v=0\no=- 0 0 IN IP4 127.0.0.1\ns=Media Server\nc=IN IP4 127.0.0.1\nt=0 0";const n=(0,c.parseSdp)(i);e&&n.msections.push(e),t&&n.msections.push(t),i=n.toSdp(),V.resolve(i)}catch(e){V.reject(e)}})(),{cp:q,rtspServer:U.promise,sdpContents:V.promise,videoSection:A.promise,audioSection:R.promise,kill:()=>l.resolve(void 0),killPromise:l.promise,get killed(){return l.finished}}};const o=i(890),r=i(4699),s=i(9400),a=i(9280),c=i(8938),l=n(i(3861)),p=n(i(5317)),u=i(7225),{mediaManager:d}=l.default;function h(e){const t=e.onRtp;return e.onRtp=(i,n)=>{e.onRtp=t,e.firstPacket?.(i,n),e.onRtp(i,n)},(t,i)=>e.onRtp(t,i)}function m(e,t,i){const n=h(e);t?.on("message",(e=>n(e,i())))}async function f(e,t,i,n,o,r){const s=n.codec;try{if(!o){await t.setup({type:"udp",path:n.control,onRtp:(e,t)=>r(t,s)});return!1}}catch(e){if(!(e instanceof a.RtspStatusError))throw e}return await t.setup({type:"tcp",port:i,path:n.control,onRtp:(e,t)=>r(t,s)}),!0}},8396:e=>{"use strict";e.exports=JSON.parse('{"application/1d-interleaved-parityfec":{"source":"iana"},"application/3gpdash-qoe-report+xml":{"source":"iana","charset":"UTF-8","compressible":true},"application/3gpp-ims+xml":{"source":"iana","compressible":true},"application/3gpphal+json":{"source":"iana","compressible":true},"application/3gpphalforms+json":{"source":"iana","compressible":true},"application/a2l":{"source":"iana"},"application/ace+cbor":{"source":"iana"},"application/activemessage":{"source":"iana"},"application/activity+json":{"source":"iana","compressible":true},"application/alto-costmap+json":{"source":"iana","compressible":true},"application/alto-costmapfilter+json":{"source":"iana","compressible":true},"application/alto-directory+json":{"source":"iana","compressible":true},"application/alto-endpointcost+json":{"source":"iana","compressible":true},"application/alto-endpointcostparams+json":{"source":"iana","compressible":true},"application/alto-endpointprop+json":{"source":"iana","compressible":true},"application/alto-endpointpropparams+json":{"source":"iana","compressible":true},"application/alto-error+json":{"source":"iana","compressible":true},"application/alto-networkmap+json":{"source":"iana","compressible":true},"application/alto-networkmapfilter+json":{"source":"iana","compressible":true},"application/alto-updatestreamcontrol+json":{"source":"iana","compressible":true},"application/alto-updatestreamparams+json":{"source":"iana","compressible":true},"application/aml":{"source":"iana"},"application/andrew-inset":{"source":"iana","extensions":["ez"]},"application/applefile":{"source":"iana"},"application/applixware":{"source":"apache","extensions":["aw"]},"application/at+jwt":{"source":"iana"},"application/atf":{"source":"iana"},"application/atfx":{"source":"iana"},"application/atom+xml":{"source":"iana","compressible":true,"extensions":["atom"]},"application/atomcat+xml":{"source":"iana","compressible":true,"extensions":["atomcat"]},"application/atomdeleted+xml":{"source":"iana","compressible":true,"extensions":["atomdeleted"]},"application/atomicmail":{"source":"iana"},"application/atomsvc+xml":{"source":"iana","compressible":true,"extensions":["atomsvc"]},"application/atsc-dwd+xml":{"source":"iana","compressible":true,"extensions":["dwd"]},"application/atsc-dynamic-event-message":{"source":"iana"},"application/atsc-held+xml":{"source":"iana","compressible":true,"extensions":["held"]},"application/atsc-rdt+json":{"source":"iana","compressible":true},"application/atsc-rsat+xml":{"source":"iana","compressible":true,"extensions":["rsat"]},"application/atxml":{"source":"iana"},"application/auth-policy+xml":{"source":"iana","compressible":true},"application/bacnet-xdd+zip":{"source":"iana","compressible":false},"application/batch-smtp":{"source":"iana"},"application/bdoc":{"compressible":false,"extensions":["bdoc"]},"application/beep+xml":{"source":"iana","charset":"UTF-8","compressible":true},"application/calendar+json":{"source":"iana","compressible":true},"application/calendar+xml":{"source":"iana","compressible":true,"extensions":["xcs"]},"application/call-completion":{"source":"iana"},"application/cals-1840":{"source":"iana"},"application/captive+json":{"source":"iana","compressible":true},"application/cbor":{"source":"iana"},"application/cbor-seq":{"source":"iana"},"application/cccex":{"source":"iana"},"application/ccmp+xml":{"source":"iana","compressible":true},"application/ccxml+xml":{"source":"iana","compressible":true,"extensions":["ccxml"]},"application/cdfx+xml":{"source":"iana","compressible":true,"extensions":["cdfx"]},"application/cdmi-capability":{"source":"iana","extensions":["cdmia"]},"application/cdmi-container":{"source":"iana","extensions":["cdmic"]},"application/cdmi-domain":{"source":"iana","extensions":["cdmid"]},"application/cdmi-object":{"source":"iana","extensions":["cdmio"]},"application/cdmi-queue":{"source":"iana","extensions":["cdmiq"]},"application/cdni":{"source":"iana"},"application/cea":{"source":"iana"},"application/cea-2018+xml":{"source":"iana","compressible":true},"application/cellml+xml":{"source":"iana","compressible":true},"application/cfw":{"source":"iana"},"application/city+json":{"source":"iana","compressible":true},"application/clr":{"source":"iana"},"application/clue+xml":{"source":"iana","compressible":true},"application/clue_info+xml":{"source":"iana","compressible":true},"application/cms":{"source":"iana"},"application/cnrp+xml":{"source":"iana","compressible":true},"application/coap-group+json":{"source":"iana","compressible":true},"application/coap-payload":{"source":"iana"},"application/commonground":{"source":"iana"},"application/conference-info+xml":{"source":"iana","compressible":true},"application/cose":{"source":"iana"},"application/cose-key":{"source":"iana"},"application/cose-key-set":{"source":"iana"},"application/cpl+xml":{"source":"iana","compressible":true,"extensions":["cpl"]},"application/csrattrs":{"source":"iana"},"application/csta+xml":{"source":"iana","compressible":true},"application/cstadata+xml":{"source":"iana","compressible":true},"application/csvm+json":{"source":"iana","compressible":true},"application/cu-seeme":{"source":"apache","extensions":["cu"]},"application/cwt":{"source":"iana"},"application/cybercash":{"source":"iana"},"application/dart":{"compressible":true},"application/dash+xml":{"source":"iana","compressible":true,"extensions":["mpd"]},"application/dash-patch+xml":{"source":"iana","compressible":true,"extensions":["mpp"]},"application/dashdelta":{"source":"iana"},"application/davmount+xml":{"source":"iana","compressible":true,"extensions":["davmount"]},"application/dca-rft":{"source":"iana"},"application/dcd":{"source":"iana"},"application/dec-dx":{"source":"iana"},"application/dialog-info+xml":{"source":"iana","compressible":true},"application/dicom":{"source":"iana"},"application/dicom+json":{"source":"iana","compressible":true},"application/dicom+xml":{"source":"iana","compressible":true},"application/dii":{"source":"iana"},"application/dit":{"source":"iana"},"application/dns":{"source":"iana"},"application/dns+json":{"source":"iana","compressible":true},"application/dns-message":{"source":"iana"},"application/docbook+xml":{"source":"apache","compressible":true,"extensions":["dbk"]},"application/dots+cbor":{"source":"iana"},"application/dskpp+xml":{"source":"iana","compressible":true},"application/dssc+der":{"source":"iana","extensions":["dssc"]},"application/dssc+xml":{"source":"iana","compressible":true,"extensions":["xdssc"]},"application/dvcs":{"source":"iana"},"application/ecmascript":{"source":"iana","compressible":true,"extensions":["es","ecma"]},"application/edi-consent":{"source":"iana"},"application/edi-x12":{"source":"iana","compressible":false},"application/edifact":{"source":"iana","compressible":false},"application/efi":{"source":"iana"},"application/elm+json":{"source":"iana","charset":"UTF-8","compressible":true},"application/elm+xml":{"source":"iana","compressible":true},"application/emergencycalldata.cap+xml":{"source":"iana","charset":"UTF-8","compressible":true},"application/emergencycalldata.comment+xml":{"source":"iana","compressible":true},"application/emergencycalldata.control+xml":{"source":"iana","compressible":true},"application/emergencycalldata.deviceinfo+xml":{"source":"iana","compressible":true},"application/emergencycalldata.ecall.msd":{"source":"iana"},"application/emergencycalldata.providerinfo+xml":{"source":"iana","compressible":true},"application/emergencycalldata.serviceinfo+xml":{"source":"iana","compressible":true},"application/emergencycalldata.subscriberinfo+xml":{"source":"iana","compressible":true},"application/emergencycalldata.veds+xml":{"source":"iana","compressible":true},"application/emma+xml":{"source":"iana","compressible":true,"extensions":["emma"]},"application/emotionml+xml":{"source":"iana","compressible":true,"extensions":["emotionml"]},"application/encaprtp":{"source":"iana"},"application/epp+xml":{"source":"iana","compressible":true},"application/epub+zip":{"source":"iana","compressible":false,"extensions":["epub"]},"application/eshop":{"source":"iana"},"application/exi":{"source":"iana","extensions":["exi"]},"application/expect-ct-report+json":{"source":"iana","compressible":true},"application/express":{"source":"iana","extensions":["exp"]},"application/fastinfoset":{"source":"iana"},"application/fastsoap":{"source":"iana"},"application/fdt+xml":{"source":"iana","compressible":true,"extensions":["fdt"]},"application/fhir+json":{"source":"iana","charset":"UTF-8","compressible":true},"application/fhir+xml":{"source":"iana","charset":"UTF-8","compressible":true},"application/fido.trusted-apps+json":{"compressible":true},"application/fits":{"source":"iana"},"application/flexfec":{"source":"iana"},"application/font-sfnt":{"source":"iana"},"application/font-tdpfr":{"source":"iana","extensions":["pfr"]},"application/font-woff":{"source":"iana","compressible":false},"application/framework-attributes+xml":{"source":"iana","compressible":true},"application/geo+json":{"source":"iana","compressible":true,"extensions":["geojson"]},"application/geo+json-seq":{"source":"iana"},"application/geopackage+sqlite3":{"source":"iana"},"application/geoxacml+xml":{"source":"iana","compressible":true},"application/gltf-buffer":{"source":"iana"},"application/gml+xml":{"source":"iana","compressible":true,"extensions":["gml"]},"application/gpx+xml":{"source":"apache","compressible":true,"extensions":["gpx"]},"application/gxf":{"source":"apache","extensions":["gxf"]},"application/gzip":{"source":"iana","compressible":false,"extensions":["gz"]},"application/h224":{"source":"iana"},"application/held+xml":{"source":"iana","compressible":true},"application/hjson":{"extensions":["hjson"]},"application/http":{"source":"iana"},"application/hyperstudio":{"source":"iana","extensions":["stk"]},"application/ibe-key-request+xml":{"source":"iana","compressible":true},"application/ibe-pkg-reply+xml":{"source":"iana","compressible":true},"application/ibe-pp-data":{"source":"iana"},"application/iges":{"source":"iana"},"application/im-iscomposing+xml":{"source":"iana","charset":"UTF-8","compressible":true},"application/index":{"source":"iana"},"application/index.cmd":{"source":"iana"},"application/index.obj":{"source":"iana"},"application/index.response":{"source":"iana"},"application/index.vnd":{"source":"iana"},"application/inkml+xml":{"source":"iana","compressible":true,"extensions":["ink","inkml"]},"application/iotp":{"source":"iana"},"application/ipfix":{"source":"iana","extensions":["ipfix"]},"application/ipp":{"source":"iana"},"application/isup":{"source":"iana"},"application/its+xml":{"source":"iana","compressible":true,"extensions":["its"]},"application/java-archive":{"source":"apache","compressible":false,"extensions":["jar","war","ear"]},"application/java-serialized-object":{"source":"apache","compressible":false,"extensions":["ser"]},"application/java-vm":{"source":"apache","compressible":false,"extensions":["class"]},"application/javascript":{"source":"iana","charset":"UTF-8","compressible":true,"extensions":["js","mjs"]},"application/jf2feed+json":{"source":"iana","compressible":true},"application/jose":{"source":"iana"},"application/jose+json":{"source":"iana","compressible":true},"application/jrd+json":{"source":"iana","compressible":true},"application/jscalendar+json":{"source":"iana","compressible":true},"application/json":{"source":"iana","charset":"UTF-8","compressible":true,"extensions":["json","map"]},"application/json-patch+json":{"source":"iana","compressible":true},"application/json-seq":{"source":"iana"},"application/json5":{"extensions":["json5"]},"application/jsonml+json":{"source":"apache","compressible":true,"extensions":["jsonml"]},"application/jwk+json":{"source":"iana","compressible":true},"application/jwk-set+json":{"source":"iana","compressible":true},"application/jwt":{"source":"iana"},"application/kpml-request+xml":{"source":"iana","compressible":true},"application/kpml-response+xml":{"source":"iana","compressible":true},"application/ld+json":{"source":"iana","compressible":true,"extensions":["jsonld"]},"application/lgr+xml":{"source":"iana","compressible":true,"extensions":["lgr"]},"application/link-format":{"source":"iana"},"application/load-control+xml":{"source":"iana","compressible":true},"application/lost+xml":{"source":"iana","compressible":true,"extensions":["lostxml"]},"application/lostsync+xml":{"source":"iana","compressible":true},"application/lpf+zip":{"source":"iana","compressible":false},"application/lxf":{"source":"iana"},"application/mac-binhex40":{"source":"iana","extensions":["hqx"]},"application/mac-compactpro":{"source":"apache","extensions":["cpt"]},"application/macwriteii":{"source":"iana"},"application/mads+xml":{"source":"iana","compressible":true,"extensions":["mads"]},"application/manifest+json":{"source":"iana","charset":"UTF-8","compressible":true,"extensions":["webmanifest"]},"application/marc":{"source":"iana","extensions":["mrc"]},"application/marcxml+xml":{"source":"iana","compressible":true,"extensions":["mrcx"]},"application/mathematica":{"source":"iana","extensions":["ma","nb","mb"]},"application/mathml+xml":{"source":"iana","compressible":true,"extensions":["mathml"]},"application/mathml-content+xml":{"source":"iana","compressible":true},"application/mathml-presentation+xml":{"source":"iana","compressible":true},"application/mbms-associated-procedure-description+xml":{"source":"iana","compressible":true},"application/mbms-deregister+xml":{"source":"iana","compressible":true},"application/mbms-envelope+xml":{"source":"iana","compressible":true},"application/mbms-msk+xml":{"source":"iana","compressible":true},"application/mbms-msk-response+xml":{"source":"iana","compressible":true},"application/mbms-protection-description+xml":{"source":"iana","compressible":true},"application/mbms-reception-report+xml":{"source":"iana","compressible":true},"application/mbms-register+xml":{"source":"iana","compressible":true},"application/mbms-register-response+xml":{"source":"iana","compressible":true},"application/mbms-schedule+xml":{"source":"iana","compressible":true},"application/mbms-user-service-description+xml":{"source":"iana","compressible":true},"application/mbox":{"source":"iana","extensions":["mbox"]},"application/media-policy-dataset+xml":{"source":"iana","compressible":true,"extensions":["mpf"]},"application/media_control+xml":{"source":"iana","compressible":true},"application/mediaservercontrol+xml":{"source":"iana","compressible":true,"extensions":["mscml"]},"application/merge-patch+json":{"source":"iana","compressible":true},"application/metalink+xml":{"source":"apache","compressible":true,"extensions":["metalink"]},"application/metalink4+xml":{"source":"iana","compressible":true,"extensions":["meta4"]},"application/mets+xml":{"source":"iana","compressible":true,"extensions":["mets"]},"application/mf4":{"source":"iana"},"application/mikey":{"source":"iana"},"application/mipc":{"source":"iana"},"application/missing-blocks+cbor-seq":{"source":"iana"},"application/mmt-aei+xml":{"source":"iana","compressible":true,"extensions":["maei"]},"application/mmt-usd+xml":{"source":"iana","compressible":true,"extensions":["musd"]},"application/mods+xml":{"source":"iana","compressible":true,"extensions":["mods"]},"application/moss-keys":{"source":"iana"},"application/moss-signature":{"source":"iana"},"application/mosskey-data":{"source":"iana"},"application/mosskey-request":{"source":"iana"},"application/mp21":{"source":"iana","extensions":["m21","mp21"]},"application/mp4":{"source":"iana","extensions":["mp4s","m4p"]},"application/mpeg4-generic":{"source":"iana"},"application/mpeg4-iod":{"source":"iana"},"application/mpeg4-iod-xmt":{"source":"iana"},"application/mrb-consumer+xml":{"source":"iana","compressible":true},"application/mrb-publish+xml":{"source":"iana","compressible":true},"application/msc-ivr+xml":{"source":"iana","charset":"UTF-8","compressible":true},"application/msc-mixer+xml":{"source":"iana","charset":"UTF-8","compressible":true},"application/msword":{"source":"iana","compressible":false,"extensions":["doc","dot"]},"application/mud+json":{"source":"iana","compressible":true},"application/multipart-core":{"source":"iana"},"application/mxf":{"source":"iana","extensions":["mxf"]},"application/n-quads":{"source":"iana","extensions":["nq"]},"application/n-triples":{"source":"iana","extensions":["nt"]},"application/nasdata":{"source":"iana"},"application/news-checkgroups":{"source":"iana","charset":"US-ASCII"},"application/news-groupinfo":{"source":"iana","charset":"US-ASCII"},"application/news-transmission":{"source":"iana"},"application/nlsml+xml":{"source":"iana","compressible":true},"application/node":{"source":"iana","extensions":["cjs"]},"application/nss":{"source":"iana"},"application/oauth-authz-req+jwt":{"source":"iana"},"application/oblivious-dns-message":{"source":"iana"},"application/ocsp-request":{"source":"iana"},"application/ocsp-response":{"source":"iana"},"application/octet-stream":{"source":"iana","compressible":false,"extensions":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"]},"application/oda":{"source":"iana","extensions":["oda"]},"application/odm+xml":{"source":"iana","compressible":true},"application/odx":{"source":"iana"},"application/oebps-package+xml":{"source":"iana","compressible":true,"extensions":["opf"]},"application/ogg":{"source":"iana","compressible":false,"extensions":["ogx"]},"application/omdoc+xml":{"source":"apache","compressible":true,"extensions":["omdoc"]},"application/onenote":{"source":"apache","extensions":["onetoc","onetoc2","onetmp","onepkg"]},"application/opc-nodeset+xml":{"source":"iana","compressible":true},"application/oscore":{"source":"iana"},"application/oxps":{"source":"iana","extensions":["oxps"]},"application/p21":{"source":"iana"},"application/p21+zip":{"source":"iana","compressible":false},"application/p2p-overlay+xml":{"source":"iana","compressible":true,"extensions":["relo"]},"application/parityfec":{"source":"iana"},"application/passport":{"source":"iana"},"application/patch-ops-error+xml":{"source":"iana","compressible":true,"extensions":["xer"]},"application/pdf":{"source":"iana","compressible":false,"extensions":["pdf"]},"application/pdx":{"source":"iana"},"application/pem-certificate-chain":{"source":"iana"},"application/pgp-encrypted":{"source":"iana","compressible":false,"extensions":["pgp"]},"application/pgp-keys":{"source":"iana","extensions":["asc"]},"application/pgp-signature":{"source":"iana","extensions":["asc","sig"]},"application/pics-rules":{"source":"apache","extensions":["prf"]},"application/pidf+xml":{"source":"iana","charset":"UTF-8","compressible":true},"application/pidf-diff+xml":{"source":"iana","charset":"UTF-8","compressible":true},"application/pkcs10":{"source":"iana","extensions":["p10"]},"application/pkcs12":{"source":"iana"},"application/pkcs7-mime":{"source":"iana","extensions":["p7m","p7c"]},"application/pkcs7-signature":{"source":"iana","extensions":["p7s"]},"application/pkcs8":{"source":"iana","extensions":["p8"]},"application/pkcs8-encrypted":{"source":"iana"},"application/pkix-attr-cert":{"source":"iana","extensions":["ac"]},"application/pkix-cert":{"source":"iana","extensions":["cer"]},"application/pkix-crl":{"source":"iana","extensions":["crl"]},"application/pkix-pkipath":{"source":"iana","extensions":["pkipath"]},"application/pkixcmp":{"source":"iana","extensions":["pki"]},"application/pls+xml":{"source":"iana","compressible":true,"extensions":["pls"]},"application/poc-settings+xml":{"source":"iana","charset":"UTF-8","compressible":true},"application/postscript":{"source":"iana","compressible":true,"extensions":["ai","eps","ps"]},"application/ppsp-tracker+json":{"source":"iana","compressible":true},"application/problem+json":{"source":"iana","compressible":true},"application/problem+xml":{"source":"iana","compressible":true},"application/provenance+xml":{"source":"iana","compressible":true,"extensions":["provx"]},"application/prs.alvestrand.titrax-sheet":{"source":"iana"},"application/prs.cww":{"source":"iana","extensions":["cww"]},"application/prs.cyn":{"source":"iana","charset":"7-BIT"},"application/prs.hpub+zip":{"source":"iana","compressible":false},"application/prs.nprend":{"source":"iana"},"application/prs.plucker":{"source":"iana"},"application/prs.rdf-xml-crypt":{"source":"iana"},"application/prs.xsf+xml":{"source":"iana","compressible":true},"application/pskc+xml":{"source":"iana","compressible":true,"extensions":["pskcxml"]},"application/pvd+json":{"source":"iana","compressible":true},"application/qsig":{"source":"iana"},"application/raml+yaml":{"compressible":true,"extensions":["raml"]},"application/raptorfec":{"source":"iana"},"application/rdap+json":{"source":"iana","compressible":true},"application/rdf+xml":{"source":"iana","compressible":true,"extensions":["rdf","owl"]},"application/reginfo+xml":{"source":"iana","compressible":true,"extensions":["rif"]},"application/relax-ng-compact-syntax":{"source":"iana","extensions":["rnc"]},"application/remote-printing":{"source":"iana"},"application/reputon+json":{"source":"iana","compressible":true},"application/resource-lists+xml":{"source":"iana","compressible":true,"extensions":["rl"]},"application/resource-lists-diff+xml":{"source":"iana","compressible":true,"extensions":["rld"]},"application/rfc+xml":{"source":"iana","compressible":true},"application/riscos":{"source":"iana"},"application/rlmi+xml":{"source":"iana","compressible":true},"application/rls-services+xml":{"source":"iana","compressible":true,"extensions":["rs"]},"application/route-apd+xml":{"source":"iana","compressible":true,"extensions":["rapd"]},"application/route-s-tsid+xml":{"source":"iana","compressible":true,"extensions":["sls"]},"application/route-usd+xml":{"source":"iana","compressible":true,"extensions":["rusd"]},"application/rpki-ghostbusters":{"source":"iana","extensions":["gbr"]},"application/rpki-manifest":{"source":"iana","extensions":["mft"]},"application/rpki-publication":{"source":"iana"},"application/rpki-roa":{"source":"iana","extensions":["roa"]},"application/rpki-updown":{"source":"iana"},"application/rsd+xml":{"source":"apache","compressible":true,"extensions":["rsd"]},"application/rss+xml":{"source":"apache","compressible":true,"extensions":["rss"]},"application/rtf":{"source":"iana","compressible":true,"extensions":["rtf"]},"application/rtploopback":{"source":"iana"},"application/rtx":{"source":"iana"},"application/samlassertion+xml":{"source":"iana","compressible":true},"application/samlmetadata+xml":{"source":"iana","compressible":true},"application/sarif+json":{"source":"iana","compressible":true},"application/sarif-external-properties+json":{"source":"iana","compressible":true},"application/sbe":{"source":"iana"},"application/sbml+xml":{"source":"iana","compressible":true,"extensions":["sbml"]},"application/scaip+xml":{"source":"iana","compressible":true},"application/scim+json":{"source":"iana","compressible":true},"application/scvp-cv-request":{"source":"iana","extensions":["scq"]},"application/scvp-cv-response":{"source":"iana","extensions":["scs"]},"application/scvp-vp-request":{"source":"iana","extensions":["spq"]},"application/scvp-vp-response":{"source":"iana","extensions":["spp"]},"application/sdp":{"source":"iana","extensions":["sdp"]},"application/secevent+jwt":{"source":"iana"},"application/senml+cbor":{"source":"iana"},"application/senml+json":{"source":"iana","compressible":true},"application/senml+xml":{"source":"iana","compressible":true,"extensions":["senmlx"]},"application/senml-etch+cbor":{"source":"iana"},"application/senml-etch+json":{"source":"iana","compressible":true},"application/senml-exi":{"source":"iana"},"application/sensml+cbor":{"source":"iana"},"application/sensml+json":{"source":"iana","compressible":true},"application/sensml+xml":{"source":"iana","compressible":true,"extensions":["sensmlx"]},"application/sensml-exi":{"source":"iana"},"application/sep+xml":{"source":"iana","compressible":true},"application/sep-exi":{"source":"iana"},"application/session-info":{"source":"iana"},"application/set-payment":{"source":"iana"},"application/set-payment-initiation":{"source":"iana","extensions":["setpay"]},"application/set-registration":{"source":"iana"},"application/set-registration-initiation":{"source":"iana","extensions":["setreg"]},"application/sgml":{"source":"iana"},"application/sgml-open-catalog":{"source":"iana"},"application/shf+xml":{"source":"iana","compressible":true,"extensions":["shf"]},"application/sieve":{"source":"iana","extensions":["siv","sieve"]},"application/simple-filter+xml":{"source":"iana","compressible":true},"application/simple-message-summary":{"source":"iana"},"application/simplesymbolcontainer":{"source":"iana"},"application/sipc":{"source":"iana"},"application/slate":{"source":"iana"},"application/smil":{"source":"iana"},"application/smil+xml":{"source":"iana","compressible":true,"extensions":["smi","smil"]},"application/smpte336m":{"source":"iana"},"application/soap+fastinfoset":{"source":"iana"},"application/soap+xml":{"source":"iana","compressible":true},"application/sparql-query":{"source":"iana","extensions":["rq"]},"application/sparql-results+xml":{"source":"iana","compressible":true,"extensions":["srx"]},"application/spdx+json":{"source":"iana","compressible":true},"application/spirits-event+xml":{"source":"iana","compressible":true},"application/sql":{"source":"iana"},"application/srgs":{"source":"iana","extensions":["gram"]},"application/srgs+xml":{"source":"iana","compressible":true,"extensions":["grxml"]},"application/sru+xml":{"source":"iana","compressible":true,"extensions":["sru"]},"application/ssdl+xml":{"source":"apache","compressible":true,"extensions":["ssdl"]},"application/ssml+xml":{"source":"iana","compressible":true,"extensions":["ssml"]},"application/stix+json":{"source":"iana","compressible":true},"application/swid+xml":{"source":"iana","compressible":true,"extensions":["swidtag"]},"application/tamp-apex-update":{"source":"iana"},"application/tamp-apex-update-confirm":{"source":"iana"},"application/tamp-community-update":{"source":"iana"},"application/tamp-community-update-confirm":{"source":"iana"},"application/tamp-error":{"source":"iana"},"application/tamp-sequence-adjust":{"source":"iana"},"application/tamp-sequence-adjust-confirm":{"source":"iana"},"application/tamp-status-query":{"source":"iana"},"application/tamp-status-response":{"source":"iana"},"application/tamp-update":{"source":"iana"},"application/tamp-update-confirm":{"source":"iana"},"application/tar":{"compressible":true},"application/taxii+json":{"source":"iana","compressible":true},"application/td+json":{"source":"iana","compressible":true},"application/tei+xml":{"source":"iana","compressible":true,"extensions":["tei","teicorpus"]},"application/tetra_isi":{"source":"iana"},"application/thraud+xml":{"source":"iana","compressible":true,"extensions":["tfi"]},"application/timestamp-query":{"source":"iana"},"application/timestamp-reply":{"source":"iana"},"application/timestamped-data":{"source":"iana","extensions":["tsd"]},"application/tlsrpt+gzip":{"source":"iana"},"application/tlsrpt+json":{"source":"iana","compressible":true},"application/tnauthlist":{"source":"iana"},"application/token-introspection+jwt":{"source":"iana"},"application/toml":{"compressible":true,"extensions":["toml"]},"application/trickle-ice-sdpfrag":{"source":"iana"},"application/trig":{"source":"iana","extensions":["trig"]},"application/ttml+xml":{"source":"iana","compressible":true,"extensions":["ttml"]},"application/tve-trigger":{"source":"iana"},"application/tzif":{"source":"iana"},"application/tzif-leap":{"source":"iana"},"application/ubjson":{"compressible":false,"extensions":["ubj"]},"application/ulpfec":{"source":"iana"},"application/urc-grpsheet+xml":{"source":"iana","compressible":true},"application/urc-ressheet+xml":{"source":"iana","compressible":true,"extensions":["rsheet"]},"application/urc-targetdesc+xml":{"source":"iana","compressible":true,"extensions":["td"]},"application/urc-uisocketdesc+xml":{"source":"iana","compressible":true},"application/vcard+json":{"source":"iana","compressible":true},"application/vcard+xml":{"source":"iana","compressible":true},"application/vemmi":{"source":"iana"},"application/vividence.scriptfile":{"source":"apache"},"application/vnd.1000minds.decision-model+xml":{"source":"iana","compressible":true,"extensions":["1km"]},"application/vnd.3gpp-prose+xml":{"source":"iana","compressible":true},"application/vnd.3gpp-prose-pc3ch+xml":{"source":"iana","compressible":true},"application/vnd.3gpp-v2x-local-service-information":{"source":"iana"},"application/vnd.3gpp.5gnas":{"source":"iana"},"application/vnd.3gpp.access-transfer-events+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.bsf+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.gmop+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.gtpc":{"source":"iana"},"application/vnd.3gpp.interworking-data":{"source":"iana"},"application/vnd.3gpp.lpp":{"source":"iana"},"application/vnd.3gpp.mc-signalling-ear":{"source":"iana"},"application/vnd.3gpp.mcdata-affiliation-command+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcdata-info+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcdata-payload":{"source":"iana"},"application/vnd.3gpp.mcdata-service-config+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcdata-signalling":{"source":"iana"},"application/vnd.3gpp.mcdata-ue-config+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcdata-user-profile+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcptt-affiliation-command+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcptt-floor-request+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcptt-info+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcptt-location-info+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcptt-mbms-usage-info+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcptt-service-config+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcptt-signed+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcptt-ue-config+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcptt-ue-init-config+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcptt-user-profile+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcvideo-affiliation-command+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcvideo-affiliation-info+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcvideo-info+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcvideo-location-info+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcvideo-mbms-usage-info+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcvideo-service-config+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcvideo-transmission-request+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcvideo-ue-config+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcvideo-user-profile+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mid-call+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.ngap":{"source":"iana"},"application/vnd.3gpp.pfcp":{"source":"iana"},"application/vnd.3gpp.pic-bw-large":{"source":"iana","extensions":["plb"]},"application/vnd.3gpp.pic-bw-small":{"source":"iana","extensions":["psb"]},"application/vnd.3gpp.pic-bw-var":{"source":"iana","extensions":["pvb"]},"application/vnd.3gpp.s1ap":{"source":"iana"},"application/vnd.3gpp.sms":{"source":"iana"},"application/vnd.3gpp.sms+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.srvcc-ext+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.srvcc-info+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.state-and-event-info+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.ussd+xml":{"source":"iana","compressible":true},"application/vnd.3gpp2.bcmcsinfo+xml":{"source":"iana","compressible":true},"application/vnd.3gpp2.sms":{"source":"iana"},"application/vnd.3gpp2.tcap":{"source":"iana","extensions":["tcap"]},"application/vnd.3lightssoftware.imagescal":{"source":"iana"},"application/vnd.3m.post-it-notes":{"source":"iana","extensions":["pwn"]},"application/vnd.accpac.simply.aso":{"source":"iana","extensions":["aso"]},"application/vnd.accpac.simply.imp":{"source":"iana","extensions":["imp"]},"application/vnd.acucobol":{"source":"iana","extensions":["acu"]},"application/vnd.acucorp":{"source":"iana","extensions":["atc","acutc"]},"application/vnd.adobe.air-application-installer-package+zip":{"source":"apache","compressible":false,"extensions":["air"]},"application/vnd.adobe.flash.movie":{"source":"iana"},"application/vnd.adobe.formscentral.fcdt":{"source":"iana","extensions":["fcdt"]},"application/vnd.adobe.fxp":{"source":"iana","extensions":["fxp","fxpl"]},"application/vnd.adobe.partial-upload":{"source":"iana"},"application/vnd.adobe.xdp+xml":{"source":"iana","compressible":true,"extensions":["xdp"]},"application/vnd.adobe.xfdf":{"source":"iana","extensions":["xfdf"]},"application/vnd.aether.imp":{"source":"iana"},"application/vnd.afpc.afplinedata":{"source":"iana"},"application/vnd.afpc.afplinedata-pagedef":{"source":"iana"},"application/vnd.afpc.cmoca-cmresource":{"source":"iana"},"application/vnd.afpc.foca-charset":{"source":"iana"},"application/vnd.afpc.foca-codedfont":{"source":"iana"},"application/vnd.afpc.foca-codepage":{"source":"iana"},"application/vnd.afpc.modca":{"source":"iana"},"application/vnd.afpc.modca-cmtable":{"source":"iana"},"application/vnd.afpc.modca-formdef":{"source":"iana"},"application/vnd.afpc.modca-mediummap":{"source":"iana"},"application/vnd.afpc.modca-objectcontainer":{"source":"iana"},"application/vnd.afpc.modca-overlay":{"source":"iana"},"application/vnd.afpc.modca-pagesegment":{"source":"iana"},"application/vnd.age":{"source":"iana","extensions":["age"]},"application/vnd.ah-barcode":{"source":"iana"},"application/vnd.ahead.space":{"source":"iana","extensions":["ahead"]},"application/vnd.airzip.filesecure.azf":{"source":"iana","extensions":["azf"]},"application/vnd.airzip.filesecure.azs":{"source":"iana","extensions":["azs"]},"application/vnd.amadeus+json":{"source":"iana","compressible":true},"application/vnd.amazon.ebook":{"source":"apache","extensions":["azw"]},"application/vnd.amazon.mobi8-ebook":{"source":"iana"},"application/vnd.americandynamics.acc":{"source":"iana","extensions":["acc"]},"application/vnd.amiga.ami":{"source":"iana","extensions":["ami"]},"application/vnd.amundsen.maze+xml":{"source":"iana","compressible":true},"application/vnd.android.ota":{"source":"iana"},"application/vnd.android.package-archive":{"source":"apache","compressible":false,"extensions":["apk"]},"application/vnd.anki":{"source":"iana"},"application/vnd.anser-web-certificate-issue-initiation":{"source":"iana","extensions":["cii"]},"application/vnd.anser-web-funds-transfer-initiation":{"source":"apache","extensions":["fti"]},"application/vnd.antix.game-component":{"source":"iana","extensions":["atx"]},"application/vnd.apache.arrow.file":{"source":"iana"},"application/vnd.apache.arrow.stream":{"source":"iana"},"application/vnd.apache.thrift.binary":{"source":"iana"},"application/vnd.apache.thrift.compact":{"source":"iana"},"application/vnd.apache.thrift.json":{"source":"iana"},"application/vnd.api+json":{"source":"iana","compressible":true},"application/vnd.aplextor.warrp+json":{"source":"iana","compressible":true},"application/vnd.apothekende.reservation+json":{"source":"iana","compressible":true},"application/vnd.apple.installer+xml":{"source":"iana","compressible":true,"extensions":["mpkg"]},"application/vnd.apple.keynote":{"source":"iana","extensions":["key"]},"application/vnd.apple.mpegurl":{"source":"iana","extensions":["m3u8"]},"application/vnd.apple.numbers":{"source":"iana","extensions":["numbers"]},"application/vnd.apple.pages":{"source":"iana","extensions":["pages"]},"application/vnd.apple.pkpass":{"compressible":false,"extensions":["pkpass"]},"application/vnd.arastra.swi":{"source":"iana"},"application/vnd.aristanetworks.swi":{"source":"iana","extensions":["swi"]},"application/vnd.artisan+json":{"source":"iana","compressible":true},"application/vnd.artsquare":{"source":"iana"},"application/vnd.astraea-software.iota":{"source":"iana","extensions":["iota"]},"application/vnd.audiograph":{"source":"iana","extensions":["aep"]},"application/vnd.autopackage":{"source":"iana"},"application/vnd.avalon+json":{"source":"iana","compressible":true},"application/vnd.avistar+xml":{"source":"iana","compressible":true},"application/vnd.balsamiq.bmml+xml":{"source":"iana","compressible":true,"extensions":["bmml"]},"application/vnd.balsamiq.bmpr":{"source":"iana"},"application/vnd.banana-accounting":{"source":"iana"},"application/vnd.bbf.usp.error":{"source":"iana"},"application/vnd.bbf.usp.msg":{"source":"iana"},"application/vnd.bbf.usp.msg+json":{"source":"iana","compressible":true},"application/vnd.bekitzur-stech+json":{"source":"iana","compressible":true},"application/vnd.bint.med-content":{"source":"iana"},"application/vnd.biopax.rdf+xml":{"source":"iana","compressible":true},"application/vnd.blink-idb-value-wrapper":{"source":"iana"},"application/vnd.blueice.multipass":{"source":"iana","extensions":["mpm"]},"application/vnd.bluetooth.ep.oob":{"source":"iana"},"application/vnd.bluetooth.le.oob":{"source":"iana"},"application/vnd.bmi":{"source":"iana","extensions":["bmi"]},"application/vnd.bpf":{"source":"iana"},"application/vnd.bpf3":{"source":"iana"},"application/vnd.businessobjects":{"source":"iana","extensions":["rep"]},"application/vnd.byu.uapi+json":{"source":"iana","compressible":true},"application/vnd.cab-jscript":{"source":"iana"},"application/vnd.canon-cpdl":{"source":"iana"},"application/vnd.canon-lips":{"source":"iana"},"application/vnd.capasystems-pg+json":{"source":"iana","compressible":true},"application/vnd.cendio.thinlinc.clientconf":{"source":"iana"},"application/vnd.century-systems.tcp_stream":{"source":"iana"},"application/vnd.chemdraw+xml":{"source":"iana","compressible":true,"extensions":["cdxml"]},"application/vnd.chess-pgn":{"source":"iana"},"application/vnd.chipnuts.karaoke-mmd":{"source":"iana","extensions":["mmd"]},"application/vnd.ciedi":{"source":"iana"},"application/vnd.cinderella":{"source":"iana","extensions":["cdy"]},"application/vnd.cirpack.isdn-ext":{"source":"iana"},"application/vnd.citationstyles.style+xml":{"source":"iana","compressible":true,"extensions":["csl"]},"application/vnd.claymore":{"source":"iana","extensions":["cla"]},"application/vnd.cloanto.rp9":{"source":"iana","extensions":["rp9"]},"application/vnd.clonk.c4group":{"source":"iana","extensions":["c4g","c4d","c4f","c4p","c4u"]},"application/vnd.cluetrust.cartomobile-config":{"source":"iana","extensions":["c11amc"]},"application/vnd.cluetrust.cartomobile-config-pkg":{"source":"iana","extensions":["c11amz"]},"application/vnd.coffeescript":{"source":"iana"},"application/vnd.collabio.xodocuments.document":{"source":"iana"},"application/vnd.collabio.xodocuments.document-template":{"source":"iana"},"application/vnd.collabio.xodocuments.presentation":{"source":"iana"},"application/vnd.collabio.xodocuments.presentation-template":{"source":"iana"},"application/vnd.collabio.xodocuments.spreadsheet":{"source":"iana"},"application/vnd.collabio.xodocuments.spreadsheet-template":{"source":"iana"},"application/vnd.collection+json":{"source":"iana","compressible":true},"application/vnd.collection.doc+json":{"source":"iana","compressible":true},"application/vnd.collection.next+json":{"source":"iana","compressible":true},"application/vnd.comicbook+zip":{"source":"iana","compressible":false},"application/vnd.comicbook-rar":{"source":"iana"},"application/vnd.commerce-battelle":{"source":"iana"},"application/vnd.commonspace":{"source":"iana","extensions":["csp"]},"application/vnd.contact.cmsg":{"source":"iana","extensions":["cdbcmsg"]},"application/vnd.coreos.ignition+json":{"source":"iana","compressible":true},"application/vnd.cosmocaller":{"source":"iana","extensions":["cmc"]},"application/vnd.crick.clicker":{"source":"iana","extensions":["clkx"]},"application/vnd.crick.clicker.keyboard":{"source":"iana","extensions":["clkk"]},"application/vnd.crick.clicker.palette":{"source":"iana","extensions":["clkp"]},"application/vnd.crick.clicker.template":{"source":"iana","extensions":["clkt"]},"application/vnd.crick.clicker.wordbank":{"source":"iana","extensions":["clkw"]},"application/vnd.criticaltools.wbs+xml":{"source":"iana","compressible":true,"extensions":["wbs"]},"application/vnd.cryptii.pipe+json":{"source":"iana","compressible":true},"application/vnd.crypto-shade-file":{"source":"iana"},"application/vnd.cryptomator.encrypted":{"source":"iana"},"application/vnd.cryptomator.vault":{"source":"iana"},"application/vnd.ctc-posml":{"source":"iana","extensions":["pml"]},"application/vnd.ctct.ws+xml":{"source":"iana","compressible":true},"application/vnd.cups-pdf":{"source":"iana"},"application/vnd.cups-postscript":{"source":"iana"},"application/vnd.cups-ppd":{"source":"iana","extensions":["ppd"]},"application/vnd.cups-raster":{"source":"iana"},"application/vnd.cups-raw":{"source":"iana"},"application/vnd.curl":{"source":"iana"},"application/vnd.curl.car":{"source":"apache","extensions":["car"]},"application/vnd.curl.pcurl":{"source":"apache","extensions":["pcurl"]},"application/vnd.cyan.dean.root+xml":{"source":"iana","compressible":true},"application/vnd.cybank":{"source":"iana"},"application/vnd.cyclonedx+json":{"source":"iana","compressible":true},"application/vnd.cyclonedx+xml":{"source":"iana","compressible":true},"application/vnd.d2l.coursepackage1p0+zip":{"source":"iana","compressible":false},"application/vnd.d3m-dataset":{"source":"iana"},"application/vnd.d3m-problem":{"source":"iana"},"application/vnd.dart":{"source":"iana","compressible":true,"extensions":["dart"]},"application/vnd.data-vision.rdz":{"source":"iana","extensions":["rdz"]},"application/vnd.datapackage+json":{"source":"iana","compressible":true},"application/vnd.dataresource+json":{"source":"iana","compressible":true},"application/vnd.dbf":{"source":"iana","extensions":["dbf"]},"application/vnd.debian.binary-package":{"source":"iana"},"application/vnd.dece.data":{"source":"iana","extensions":["uvf","uvvf","uvd","uvvd"]},"application/vnd.dece.ttml+xml":{"source":"iana","compressible":true,"extensions":["uvt","uvvt"]},"application/vnd.dece.unspecified":{"source":"iana","extensions":["uvx","uvvx"]},"application/vnd.dece.zip":{"source":"iana","extensions":["uvz","uvvz"]},"application/vnd.denovo.fcselayout-link":{"source":"iana","extensions":["fe_launch"]},"application/vnd.desmume.movie":{"source":"iana"},"application/vnd.dir-bi.plate-dl-nosuffix":{"source":"iana"},"application/vnd.dm.delegation+xml":{"source":"iana","compressible":true},"application/vnd.dna":{"source":"iana","extensions":["dna"]},"application/vnd.document+json":{"source":"iana","compressible":true},"application/vnd.dolby.mlp":{"source":"apache","extensions":["mlp"]},"application/vnd.dolby.mobile.1":{"source":"iana"},"application/vnd.dolby.mobile.2":{"source":"iana"},"application/vnd.doremir.scorecloud-binary-document":{"source":"iana"},"application/vnd.dpgraph":{"source":"iana","extensions":["dpg"]},"application/vnd.dreamfactory":{"source":"iana","extensions":["dfac"]},"application/vnd.drive+json":{"source":"iana","compressible":true},"application/vnd.ds-keypoint":{"source":"apache","extensions":["kpxx"]},"application/vnd.dtg.local":{"source":"iana"},"application/vnd.dtg.local.flash":{"source":"iana"},"application/vnd.dtg.local.html":{"source":"iana"},"application/vnd.dvb.ait":{"source":"iana","extensions":["ait"]},"application/vnd.dvb.dvbisl+xml":{"source":"iana","compressible":true},"application/vnd.dvb.dvbj":{"source":"iana"},"application/vnd.dvb.esgcontainer":{"source":"iana"},"application/vnd.dvb.ipdcdftnotifaccess":{"source":"iana"},"application/vnd.dvb.ipdcesgaccess":{"source":"iana"},"application/vnd.dvb.ipdcesgaccess2":{"source":"iana"},"application/vnd.dvb.ipdcesgpdd":{"source":"iana"},"application/vnd.dvb.ipdcroaming":{"source":"iana"},"application/vnd.dvb.iptv.alfec-base":{"source":"iana"},"application/vnd.dvb.iptv.alfec-enhancement":{"source":"iana"},"application/vnd.dvb.notif-aggregate-root+xml":{"source":"iana","compressible":true},"application/vnd.dvb.notif-container+xml":{"source":"iana","compressible":true},"application/vnd.dvb.notif-generic+xml":{"source":"iana","compressible":true},"application/vnd.dvb.notif-ia-msglist+xml":{"source":"iana","compressible":true},"application/vnd.dvb.notif-ia-registration-request+xml":{"source":"iana","compressible":true},"application/vnd.dvb.notif-ia-registration-response+xml":{"source":"iana","compressible":true},"application/vnd.dvb.notif-init+xml":{"source":"iana","compressible":true},"application/vnd.dvb.pfr":{"source":"iana"},"application/vnd.dvb.service":{"source":"iana","extensions":["svc"]},"application/vnd.dxr":{"source":"iana"},"application/vnd.dynageo":{"source":"iana","extensions":["geo"]},"application/vnd.dzr":{"source":"iana"},"application/vnd.easykaraoke.cdgdownload":{"source":"iana"},"application/vnd.ecdis-update":{"source":"iana"},"application/vnd.ecip.rlp":{"source":"iana"},"application/vnd.eclipse.ditto+json":{"source":"iana","compressible":true},"application/vnd.ecowin.chart":{"source":"iana","extensions":["mag"]},"application/vnd.ecowin.filerequest":{"source":"iana"},"application/vnd.ecowin.fileupdate":{"source":"iana"},"application/vnd.ecowin.series":{"source":"iana"},"application/vnd.ecowin.seriesrequest":{"source":"iana"},"application/vnd.ecowin.seriesupdate":{"source":"iana"},"application/vnd.efi.img":{"source":"iana"},"application/vnd.efi.iso":{"source":"iana"},"application/vnd.emclient.accessrequest+xml":{"source":"iana","compressible":true},"application/vnd.enliven":{"source":"iana","extensions":["nml"]},"application/vnd.enphase.envoy":{"source":"iana"},"application/vnd.eprints.data+xml":{"source":"iana","compressible":true},"application/vnd.epson.esf":{"source":"iana","extensions":["esf"]},"application/vnd.epson.msf":{"source":"iana","extensions":["msf"]},"application/vnd.epson.quickanime":{"source":"iana","extensions":["qam"]},"application/vnd.epson.salt":{"source":"iana","extensions":["slt"]},"application/vnd.epson.ssf":{"source":"iana","extensions":["ssf"]},"application/vnd.ericsson.quickcall":{"source":"iana"},"application/vnd.espass-espass+zip":{"source":"iana","compressible":false},"application/vnd.eszigno3+xml":{"source":"iana","compressible":true,"extensions":["es3","et3"]},"application/vnd.etsi.aoc+xml":{"source":"iana","compressible":true},"application/vnd.etsi.asic-e+zip":{"source":"iana","compressible":false},"application/vnd.etsi.asic-s+zip":{"source":"iana","compressible":false},"application/vnd.etsi.cug+xml":{"source":"iana","compressible":true},"application/vnd.etsi.iptvcommand+xml":{"source":"iana","compressible":true},"application/vnd.etsi.iptvdiscovery+xml":{"source":"iana","compressible":true},"application/vnd.etsi.iptvprofile+xml":{"source":"iana","compressible":true},"application/vnd.etsi.iptvsad-bc+xml":{"source":"iana","compressible":true},"application/vnd.etsi.iptvsad-cod+xml":{"source":"iana","compressible":true},"application/vnd.etsi.iptvsad-npvr+xml":{"source":"iana","compressible":true},"application/vnd.etsi.iptvservice+xml":{"source":"iana","compressible":true},"application/vnd.etsi.iptvsync+xml":{"source":"iana","compressible":true},"application/vnd.etsi.iptvueprofile+xml":{"source":"iana","compressible":true},"application/vnd.etsi.mcid+xml":{"source":"iana","compressible":true},"application/vnd.etsi.mheg5":{"source":"iana"},"application/vnd.etsi.overload-control-policy-dataset+xml":{"source":"iana","compressible":true},"application/vnd.etsi.pstn+xml":{"source":"iana","compressible":true},"application/vnd.etsi.sci+xml":{"source":"iana","compressible":true},"application/vnd.etsi.simservs+xml":{"source":"iana","compressible":true},"application/vnd.etsi.timestamp-token":{"source":"iana"},"application/vnd.etsi.tsl+xml":{"source":"iana","compressible":true},"application/vnd.etsi.tsl.der":{"source":"iana"},"application/vnd.eu.kasparian.car+json":{"source":"iana","compressible":true},"application/vnd.eudora.data":{"source":"iana"},"application/vnd.evolv.ecig.profile":{"source":"iana"},"application/vnd.evolv.ecig.settings":{"source":"iana"},"application/vnd.evolv.ecig.theme":{"source":"iana"},"application/vnd.exstream-empower+zip":{"source":"iana","compressible":false},"application/vnd.exstream-package":{"source":"iana"},"application/vnd.ezpix-album":{"source":"iana","extensions":["ez2"]},"application/vnd.ezpix-package":{"source":"iana","extensions":["ez3"]},"application/vnd.f-secure.mobile":{"source":"iana"},"application/vnd.familysearch.gedcom+zip":{"source":"iana","compressible":false},"application/vnd.fastcopy-disk-image":{"source":"iana"},"application/vnd.fdf":{"source":"iana","extensions":["fdf"]},"application/vnd.fdsn.mseed":{"source":"iana","extensions":["mseed"]},"application/vnd.fdsn.seed":{"source":"iana","extensions":["seed","dataless"]},"application/vnd.ffsns":{"source":"iana"},"application/vnd.ficlab.flb+zip":{"source":"iana","compressible":false},"application/vnd.filmit.zfc":{"source":"iana"},"application/vnd.fints":{"source":"iana"},"application/vnd.firemonkeys.cloudcell":{"source":"iana"},"application/vnd.flographit":{"source":"iana","extensions":["gph"]},"application/vnd.fluxtime.clip":{"source":"iana","extensions":["ftc"]},"application/vnd.font-fontforge-sfd":{"source":"iana"},"application/vnd.framemaker":{"source":"iana","extensions":["fm","frame","maker","book"]},"application/vnd.frogans.fnc":{"source":"iana","extensions":["fnc"]},"application/vnd.frogans.ltf":{"source":"iana","extensions":["ltf"]},"application/vnd.fsc.weblaunch":{"source":"iana","extensions":["fsc"]},"application/vnd.fujifilm.fb.docuworks":{"source":"iana"},"application/vnd.fujifilm.fb.docuworks.binder":{"source":"iana"},"application/vnd.fujifilm.fb.docuworks.container":{"source":"iana"},"application/vnd.fujifilm.fb.jfi+xml":{"source":"iana","compressible":true},"application/vnd.fujitsu.oasys":{"source":"iana","extensions":["oas"]},"application/vnd.fujitsu.oasys2":{"source":"iana","extensions":["oa2"]},"application/vnd.fujitsu.oasys3":{"source":"iana","extensions":["oa3"]},"application/vnd.fujitsu.oasysgp":{"source":"iana","extensions":["fg5"]},"application/vnd.fujitsu.oasysprs":{"source":"iana","extensions":["bh2"]},"application/vnd.fujixerox.art-ex":{"source":"iana"},"application/vnd.fujixerox.art4":{"source":"iana"},"application/vnd.fujixerox.ddd":{"source":"iana","extensions":["ddd"]},"application/vnd.fujixerox.docuworks":{"source":"iana","extensions":["xdw"]},"application/vnd.fujixerox.docuworks.binder":{"source":"iana","extensions":["xbd"]},"application/vnd.fujixerox.docuworks.container":{"source":"iana"},"application/vnd.fujixerox.hbpl":{"source":"iana"},"application/vnd.fut-misnet":{"source":"iana"},"application/vnd.futoin+cbor":{"source":"iana"},"application/vnd.futoin+json":{"source":"iana","compressible":true},"application/vnd.fuzzysheet":{"source":"iana","extensions":["fzs"]},"application/vnd.genomatix.tuxedo":{"source":"iana","extensions":["txd"]},"application/vnd.gentics.grd+json":{"source":"iana","compressible":true},"application/vnd.geo+json":{"source":"iana","compressible":true},"application/vnd.geocube+xml":{"source":"iana","compressible":true},"application/vnd.geogebra.file":{"source":"iana","extensions":["ggb"]},"application/vnd.geogebra.slides":{"source":"iana"},"application/vnd.geogebra.tool":{"source":"iana","extensions":["ggt"]},"application/vnd.geometry-explorer":{"source":"iana","extensions":["gex","gre"]},"application/vnd.geonext":{"source":"iana","extensions":["gxt"]},"application/vnd.geoplan":{"source":"iana","extensions":["g2w"]},"application/vnd.geospace":{"source":"iana","extensions":["g3w"]},"application/vnd.gerber":{"source":"iana"},"application/vnd.globalplatform.card-content-mgt":{"source":"iana"},"application/vnd.globalplatform.card-content-mgt-response":{"source":"iana"},"application/vnd.gmx":{"source":"iana","extensions":["gmx"]},"application/vnd.google-apps.document":{"compressible":false,"extensions":["gdoc"]},"application/vnd.google-apps.presentation":{"compressible":false,"extensions":["gslides"]},"application/vnd.google-apps.spreadsheet":{"compressible":false,"extensions":["gsheet"]},"application/vnd.google-earth.kml+xml":{"source":"iana","compressible":true,"extensions":["kml"]},"application/vnd.google-earth.kmz":{"source":"iana","compressible":false,"extensions":["kmz"]},"application/vnd.gov.sk.e-form+xml":{"source":"iana","compressible":true},"application/vnd.gov.sk.e-form+zip":{"source":"iana","compressible":false},"application/vnd.gov.sk.xmldatacontainer+xml":{"source":"iana","compressible":true},"application/vnd.grafeq":{"source":"iana","extensions":["gqf","gqs"]},"application/vnd.gridmp":{"source":"iana"},"application/vnd.groove-account":{"source":"iana","extensions":["gac"]},"application/vnd.groove-help":{"source":"iana","extensions":["ghf"]},"application/vnd.groove-identity-message":{"source":"iana","extensions":["gim"]},"application/vnd.groove-injector":{"source":"iana","extensions":["grv"]},"application/vnd.groove-tool-message":{"source":"iana","extensions":["gtm"]},"application/vnd.groove-tool-template":{"source":"iana","extensions":["tpl"]},"application/vnd.groove-vcard":{"source":"iana","extensions":["vcg"]},"application/vnd.hal+json":{"source":"iana","compressible":true},"application/vnd.hal+xml":{"source":"iana","compressible":true,"extensions":["hal"]},"application/vnd.handheld-entertainment+xml":{"source":"iana","compressible":true,"extensions":["zmm"]},"application/vnd.hbci":{"source":"iana","extensions":["hbci"]},"application/vnd.hc+json":{"source":"iana","compressible":true},"application/vnd.hcl-bireports":{"source":"iana"},"application/vnd.hdt":{"source":"iana"},"application/vnd.heroku+json":{"source":"iana","compressible":true},"application/vnd.hhe.lesson-player":{"source":"iana","extensions":["les"]},"application/vnd.hl7cda+xml":{"source":"iana","charset":"UTF-8","compressible":true},"application/vnd.hl7v2+xml":{"source":"iana","charset":"UTF-8","compressible":true},"application/vnd.hp-hpgl":{"source":"iana","extensions":["hpgl"]},"application/vnd.hp-hpid":{"source":"iana","extensions":["hpid"]},"application/vnd.hp-hps":{"source":"iana","extensions":["hps"]},"application/vnd.hp-jlyt":{"source":"iana","extensions":["jlt"]},"application/vnd.hp-pcl":{"source":"iana","extensions":["pcl"]},"application/vnd.hp-pclxl":{"source":"iana","extensions":["pclxl"]},"application/vnd.httphone":{"source":"iana"},"application/vnd.hydrostatix.sof-data":{"source":"iana","extensions":["sfd-hdstx"]},"application/vnd.hyper+json":{"source":"iana","compressible":true},"application/vnd.hyper-item+json":{"source":"iana","compressible":true},"application/vnd.hyperdrive+json":{"source":"iana","compressible":true},"application/vnd.hzn-3d-crossword":{"source":"iana"},"application/vnd.ibm.afplinedata":{"source":"iana"},"application/vnd.ibm.electronic-media":{"source":"iana"},"application/vnd.ibm.minipay":{"source":"iana","extensions":["mpy"]},"application/vnd.ibm.modcap":{"source":"iana","extensions":["afp","listafp","list3820"]},"application/vnd.ibm.rights-management":{"source":"iana","extensions":["irm"]},"application/vnd.ibm.secure-container":{"source":"iana","extensions":["sc"]},"application/vnd.iccprofile":{"source":"iana","extensions":["icc","icm"]},"application/vnd.ieee.1905":{"source":"iana"},"application/vnd.igloader":{"source":"iana","extensions":["igl"]},"application/vnd.imagemeter.folder+zip":{"source":"iana","compressible":false},"application/vnd.imagemeter.image+zip":{"source":"iana","compressible":false},"application/vnd.immervision-ivp":{"source":"iana","extensions":["ivp"]},"application/vnd.immervision-ivu":{"source":"iana","extensions":["ivu"]},"application/vnd.ims.imsccv1p1":{"source":"iana"},"application/vnd.ims.imsccv1p2":{"source":"iana"},"application/vnd.ims.imsccv1p3":{"source":"iana"},"application/vnd.ims.lis.v2.result+json":{"source":"iana","compressible":true},"application/vnd.ims.lti.v2.toolconsumerprofile+json":{"source":"iana","compressible":true},"application/vnd.ims.lti.v2.toolproxy+json":{"source":"iana","compressible":true},"application/vnd.ims.lti.v2.toolproxy.id+json":{"source":"iana","compressible":true},"application/vnd.ims.lti.v2.toolsettings+json":{"source":"iana","compressible":true},"application/vnd.ims.lti.v2.toolsettings.simple+json":{"source":"iana","compressible":true},"application/vnd.informedcontrol.rms+xml":{"source":"iana","compressible":true},"application/vnd.informix-visionary":{"source":"iana"},"application/vnd.infotech.project":{"source":"iana"},"application/vnd.infotech.project+xml":{"source":"iana","compressible":true},"application/vnd.innopath.wamp.notification":{"source":"iana"},"application/vnd.insors.igm":{"source":"iana","extensions":["igm"]},"application/vnd.intercon.formnet":{"source":"iana","extensions":["xpw","xpx"]},"application/vnd.intergeo":{"source":"iana","extensions":["i2g"]},"application/vnd.intertrust.digibox":{"source":"iana"},"application/vnd.intertrust.nncp":{"source":"iana"},"application/vnd.intu.qbo":{"source":"iana","extensions":["qbo"]},"application/vnd.intu.qfx":{"source":"iana","extensions":["qfx"]},"application/vnd.iptc.g2.catalogitem+xml":{"source":"iana","compressible":true},"application/vnd.iptc.g2.conceptitem+xml":{"source":"iana","compressible":true},"application/vnd.iptc.g2.knowledgeitem+xml":{"source":"iana","compressible":true},"application/vnd.iptc.g2.newsitem+xml":{"source":"iana","compressible":true},"application/vnd.iptc.g2.newsmessage+xml":{"source":"iana","compressible":true},"application/vnd.iptc.g2.packageitem+xml":{"source":"iana","compressible":true},"application/vnd.iptc.g2.planningitem+xml":{"source":"iana","compressible":true},"application/vnd.ipunplugged.rcprofile":{"source":"iana","extensions":["rcprofile"]},"application/vnd.irepository.package+xml":{"source":"iana","compressible":true,"extensions":["irp"]},"application/vnd.is-xpr":{"source":"iana","extensions":["xpr"]},"application/vnd.isac.fcs":{"source":"iana","extensions":["fcs"]},"application/vnd.iso11783-10+zip":{"source":"iana","compressible":false},"application/vnd.jam":{"source":"iana","extensions":["jam"]},"application/vnd.japannet-directory-service":{"source":"iana"},"application/vnd.japannet-jpnstore-wakeup":{"source":"iana"},"application/vnd.japannet-payment-wakeup":{"source":"iana"},"application/vnd.japannet-registration":{"source":"iana"},"application/vnd.japannet-registration-wakeup":{"source":"iana"},"application/vnd.japannet-setstore-wakeup":{"source":"iana"},"application/vnd.japannet-verification":{"source":"iana"},"application/vnd.japannet-verification-wakeup":{"source":"iana"},"application/vnd.jcp.javame.midlet-rms":{"source":"iana","extensions":["rms"]},"application/vnd.jisp":{"source":"iana","extensions":["jisp"]},"application/vnd.joost.joda-archive":{"source":"iana","extensions":["joda"]},"application/vnd.jsk.isdn-ngn":{"source":"iana"},"application/vnd.kahootz":{"source":"iana","extensions":["ktz","ktr"]},"application/vnd.kde.karbon":{"source":"iana","extensions":["karbon"]},"application/vnd.kde.kchart":{"source":"iana","extensions":["chrt"]},"application/vnd.kde.kformula":{"source":"iana","extensions":["kfo"]},"application/vnd.kde.kivio":{"source":"iana","extensions":["flw"]},"application/vnd.kde.kontour":{"source":"iana","extensions":["kon"]},"application/vnd.kde.kpresenter":{"source":"iana","extensions":["kpr","kpt"]},"application/vnd.kde.kspread":{"source":"iana","extensions":["ksp"]},"application/vnd.kde.kword":{"source":"iana","extensions":["kwd","kwt"]},"application/vnd.kenameaapp":{"source":"iana","extensions":["htke"]},"application/vnd.kidspiration":{"source":"iana","extensions":["kia"]},"application/vnd.kinar":{"source":"iana","extensions":["kne","knp"]},"application/vnd.koan":{"source":"iana","extensions":["skp","skd","skt","skm"]},"application/vnd.kodak-descriptor":{"source":"iana","extensions":["sse"]},"application/vnd.las":{"source":"iana"},"application/vnd.las.las+json":{"source":"iana","compressible":true},"application/vnd.las.las+xml":{"source":"iana","compressible":true,"extensions":["lasxml"]},"application/vnd.laszip":{"source":"iana"},"application/vnd.leap+json":{"source":"iana","compressible":true},"application/vnd.liberty-request+xml":{"source":"iana","compressible":true},"application/vnd.llamagraphics.life-balance.desktop":{"source":"iana","extensions":["lbd"]},"application/vnd.llamagraphics.life-balance.exchange+xml":{"source":"iana","compressible":true,"extensions":["lbe"]},"application/vnd.logipipe.circuit+zip":{"source":"iana","compressible":false},"application/vnd.loom":{"source":"iana"},"application/vnd.lotus-1-2-3":{"source":"iana","extensions":["123"]},"application/vnd.lotus-approach":{"source":"iana","extensions":["apr"]},"application/vnd.lotus-freelance":{"source":"iana","extensions":["pre"]},"application/vnd.lotus-notes":{"source":"iana","extensions":["nsf"]},"application/vnd.lotus-organizer":{"source":"iana","extensions":["org"]},"application/vnd.lotus-screencam":{"source":"iana","extensions":["scm"]},"application/vnd.lotus-wordpro":{"source":"iana","extensions":["lwp"]},"application/vnd.macports.portpkg":{"source":"iana","extensions":["portpkg"]},"application/vnd.mapbox-vector-tile":{"source":"iana","extensions":["mvt"]},"application/vnd.marlin.drm.actiontoken+xml":{"source":"iana","compressible":true},"application/vnd.marlin.drm.conftoken+xml":{"source":"iana","compressible":true},"application/vnd.marlin.drm.license+xml":{"source":"iana","compressible":true},"application/vnd.marlin.drm.mdcf":{"source":"iana"},"application/vnd.mason+json":{"source":"iana","compressible":true},"application/vnd.maxar.archive.3tz+zip":{"source":"iana","compressible":false},"application/vnd.maxmind.maxmind-db":{"source":"iana"},"application/vnd.mcd":{"source":"iana","extensions":["mcd"]},"application/vnd.medcalcdata":{"source":"iana","extensions":["mc1"]},"application/vnd.mediastation.cdkey":{"source":"iana","extensions":["cdkey"]},"application/vnd.meridian-slingshot":{"source":"iana"},"application/vnd.mfer":{"source":"iana","extensions":["mwf"]},"application/vnd.mfmp":{"source":"iana","extensions":["mfm"]},"application/vnd.micro+json":{"source":"iana","compressible":true},"application/vnd.micrografx.flo":{"source":"iana","extensions":["flo"]},"application/vnd.micrografx.igx":{"source":"iana","extensions":["igx"]},"application/vnd.microsoft.portable-executable":{"source":"iana"},"application/vnd.microsoft.windows.thumbnail-cache":{"source":"iana"},"application/vnd.miele+json":{"source":"iana","compressible":true},"application/vnd.mif":{"source":"iana","extensions":["mif"]},"application/vnd.minisoft-hp3000-save":{"source":"iana"},"application/vnd.mitsubishi.misty-guard.trustweb":{"source":"iana"},"application/vnd.mobius.daf":{"source":"iana","extensions":["daf"]},"application/vnd.mobius.dis":{"source":"iana","extensions":["dis"]},"application/vnd.mobius.mbk":{"source":"iana","extensions":["mbk"]},"application/vnd.mobius.mqy":{"source":"iana","extensions":["mqy"]},"application/vnd.mobius.msl":{"source":"iana","extensions":["msl"]},"application/vnd.mobius.plc":{"source":"iana","extensions":["plc"]},"application/vnd.mobius.txf":{"source":"iana","extensions":["txf"]},"application/vnd.mophun.application":{"source":"iana","extensions":["mpn"]},"application/vnd.mophun.certificate":{"source":"iana","extensions":["mpc"]},"application/vnd.motorola.flexsuite":{"source":"iana"},"application/vnd.motorola.flexsuite.adsi":{"source":"iana"},"application/vnd.motorola.flexsuite.fis":{"source":"iana"},"application/vnd.motorola.flexsuite.gotap":{"source":"iana"},"application/vnd.motorola.flexsuite.kmr":{"source":"iana"},"application/vnd.motorola.flexsuite.ttc":{"source":"iana"},"application/vnd.motorola.flexsuite.wem":{"source":"iana"},"application/vnd.motorola.iprm":{"source":"iana"},"application/vnd.mozilla.xul+xml":{"source":"iana","compressible":true,"extensions":["xul"]},"application/vnd.ms-3mfdocument":{"source":"iana"},"application/vnd.ms-artgalry":{"source":"iana","extensions":["cil"]},"application/vnd.ms-asf":{"source":"iana"},"application/vnd.ms-cab-compressed":{"source":"iana","extensions":["cab"]},"application/vnd.ms-color.iccprofile":{"source":"apache"},"application/vnd.ms-excel":{"source":"iana","compressible":false,"extensions":["xls","xlm","xla","xlc","xlt","xlw"]},"application/vnd.ms-excel.addin.macroenabled.12":{"source":"iana","extensions":["xlam"]},"application/vnd.ms-excel.sheet.binary.macroenabled.12":{"source":"iana","extensions":["xlsb"]},"application/vnd.ms-excel.sheet.macroenabled.12":{"source":"iana","extensions":["xlsm"]},"application/vnd.ms-excel.template.macroenabled.12":{"source":"iana","extensions":["xltm"]},"application/vnd.ms-fontobject":{"source":"iana","compressible":true,"extensions":["eot"]},"application/vnd.ms-htmlhelp":{"source":"iana","extensions":["chm"]},"application/vnd.ms-ims":{"source":"iana","extensions":["ims"]},"application/vnd.ms-lrm":{"source":"iana","extensions":["lrm"]},"application/vnd.ms-office.activex+xml":{"source":"iana","compressible":true},"application/vnd.ms-officetheme":{"source":"iana","extensions":["thmx"]},"application/vnd.ms-opentype":{"source":"apache","compressible":true},"application/vnd.ms-outlook":{"compressible":false,"extensions":["msg"]},"application/vnd.ms-package.obfuscated-opentype":{"source":"apache"},"application/vnd.ms-pki.seccat":{"source":"apache","extensions":["cat"]},"application/vnd.ms-pki.stl":{"source":"apache","extensions":["stl"]},"application/vnd.ms-playready.initiator+xml":{"source":"iana","compressible":true},"application/vnd.ms-powerpoint":{"source":"iana","compressible":false,"extensions":["ppt","pps","pot"]},"application/vnd.ms-powerpoint.addin.macroenabled.12":{"source":"iana","extensions":["ppam"]},"application/vnd.ms-powerpoint.presentation.macroenabled.12":{"source":"iana","extensions":["pptm"]},"application/vnd.ms-powerpoint.slide.macroenabled.12":{"source":"iana","extensions":["sldm"]},"application/vnd.ms-powerpoint.slideshow.macroenabled.12":{"source":"iana","extensions":["ppsm"]},"application/vnd.ms-powerpoint.template.macroenabled.12":{"source":"iana","extensions":["potm"]},"application/vnd.ms-printdevicecapabilities+xml":{"source":"iana","compressible":true},"application/vnd.ms-printing.printticket+xml":{"source":"apache","compressible":true},"application/vnd.ms-printschematicket+xml":{"source":"iana","compressible":true},"application/vnd.ms-project":{"source":"iana","extensions":["mpp","mpt"]},"application/vnd.ms-tnef":{"source":"iana"},"application/vnd.ms-windows.devicepairing":{"source":"iana"},"application/vnd.ms-windows.nwprinting.oob":{"source":"iana"},"application/vnd.ms-windows.printerpairing":{"source":"iana"},"application/vnd.ms-windows.wsd.oob":{"source":"iana"},"application/vnd.ms-wmdrm.lic-chlg-req":{"source":"iana"},"application/vnd.ms-wmdrm.lic-resp":{"source":"iana"},"application/vnd.ms-wmdrm.meter-chlg-req":{"source":"iana"},"application/vnd.ms-wmdrm.meter-resp":{"source":"iana"},"application/vnd.ms-word.document.macroenabled.12":{"source":"iana","extensions":["docm"]},"application/vnd.ms-word.template.macroenabled.12":{"source":"iana","extensions":["dotm"]},"application/vnd.ms-works":{"source":"iana","extensions":["wps","wks","wcm","wdb"]},"application/vnd.ms-wpl":{"source":"iana","extensions":["wpl"]},"application/vnd.ms-xpsdocument":{"source":"iana","compressible":false,"extensions":["xps"]},"application/vnd.msa-disk-image":{"source":"iana"},"application/vnd.mseq":{"source":"iana","extensions":["mseq"]},"application/vnd.msign":{"source":"iana"},"application/vnd.multiad.creator":{"source":"iana"},"application/vnd.multiad.creator.cif":{"source":"iana"},"application/vnd.music-niff":{"source":"iana"},"application/vnd.musician":{"source":"iana","extensions":["mus"]},"application/vnd.muvee.style":{"source":"iana","extensions":["msty"]},"application/vnd.mynfc":{"source":"iana","extensions":["taglet"]},"application/vnd.nacamar.ybrid+json":{"source":"iana","compressible":true},"application/vnd.ncd.control":{"source":"iana"},"application/vnd.ncd.reference":{"source":"iana"},"application/vnd.nearst.inv+json":{"source":"iana","compressible":true},"application/vnd.nebumind.line":{"source":"iana"},"application/vnd.nervana":{"source":"iana"},"application/vnd.netfpx":{"source":"iana"},"application/vnd.neurolanguage.nlu":{"source":"iana","extensions":["nlu"]},"application/vnd.nimn":{"source":"iana"},"application/vnd.nintendo.nitro.rom":{"source":"iana"},"application/vnd.nintendo.snes.rom":{"source":"iana"},"application/vnd.nitf":{"source":"iana","extensions":["ntf","nitf"]},"application/vnd.noblenet-directory":{"source":"iana","extensions":["nnd"]},"application/vnd.noblenet-sealer":{"source":"iana","extensions":["nns"]},"application/vnd.noblenet-web":{"source":"iana","extensions":["nnw"]},"application/vnd.nokia.catalogs":{"source":"iana"},"application/vnd.nokia.conml+wbxml":{"source":"iana"},"application/vnd.nokia.conml+xml":{"source":"iana","compressible":true},"application/vnd.nokia.iptv.config+xml":{"source":"iana","compressible":true},"application/vnd.nokia.isds-radio-presets":{"source":"iana"},"application/vnd.nokia.landmark+wbxml":{"source":"iana"},"application/vnd.nokia.landmark+xml":{"source":"iana","compressible":true},"application/vnd.nokia.landmarkcollection+xml":{"source":"iana","compressible":true},"application/vnd.nokia.n-gage.ac+xml":{"source":"iana","compressible":true,"extensions":["ac"]},"application/vnd.nokia.n-gage.data":{"source":"iana","extensions":["ngdat"]},"application/vnd.nokia.n-gage.symbian.install":{"source":"iana","extensions":["n-gage"]},"application/vnd.nokia.ncd":{"source":"iana"},"application/vnd.nokia.pcd+wbxml":{"source":"iana"},"application/vnd.nokia.pcd+xml":{"source":"iana","compressible":true},"application/vnd.nokia.radio-preset":{"source":"iana","extensions":["rpst"]},"application/vnd.nokia.radio-presets":{"source":"iana","extensions":["rpss"]},"application/vnd.novadigm.edm":{"source":"iana","extensions":["edm"]},"application/vnd.novadigm.edx":{"source":"iana","extensions":["edx"]},"application/vnd.novadigm.ext":{"source":"iana","extensions":["ext"]},"application/vnd.ntt-local.content-share":{"source":"iana"},"application/vnd.ntt-local.file-transfer":{"source":"iana"},"application/vnd.ntt-local.ogw_remote-access":{"source":"iana"},"application/vnd.ntt-local.sip-ta_remote":{"source":"iana"},"application/vnd.ntt-local.sip-ta_tcp_stream":{"source":"iana"},"application/vnd.oasis.opendocument.chart":{"source":"iana","extensions":["odc"]},"application/vnd.oasis.opendocument.chart-template":{"source":"iana","extensions":["otc"]},"application/vnd.oasis.opendocument.database":{"source":"iana","extensions":["odb"]},"application/vnd.oasis.opendocument.formula":{"source":"iana","extensions":["odf"]},"application/vnd.oasis.opendocument.formula-template":{"source":"iana","extensions":["odft"]},"application/vnd.oasis.opendocument.graphics":{"source":"iana","compressible":false,"extensions":["odg"]},"application/vnd.oasis.opendocument.graphics-template":{"source":"iana","extensions":["otg"]},"application/vnd.oasis.opendocument.image":{"source":"iana","extensions":["odi"]},"application/vnd.oasis.opendocument.image-template":{"source":"iana","extensions":["oti"]},"application/vnd.oasis.opendocument.presentation":{"source":"iana","compressible":false,"extensions":["odp"]},"application/vnd.oasis.opendocument.presentation-template":{"source":"iana","extensions":["otp"]},"application/vnd.oasis.opendocument.spreadsheet":{"source":"iana","compressible":false,"extensions":["ods"]},"application/vnd.oasis.opendocument.spreadsheet-template":{"source":"iana","extensions":["ots"]},"application/vnd.oasis.opendocument.text":{"source":"iana","compressible":false,"extensions":["odt"]},"application/vnd.oasis.opendocument.text-master":{"source":"iana","extensions":["odm"]},"application/vnd.oasis.opendocument.text-template":{"source":"iana","extensions":["ott"]},"application/vnd.oasis.opendocument.text-web":{"source":"iana","extensions":["oth"]},"application/vnd.obn":{"source":"iana"},"application/vnd.ocf+cbor":{"source":"iana"},"application/vnd.oci.image.manifest.v1+json":{"source":"iana","compressible":true},"application/vnd.oftn.l10n+json":{"source":"iana","compressible":true},"application/vnd.oipf.contentaccessdownload+xml":{"source":"iana","compressible":true},"application/vnd.oipf.contentaccessstreaming+xml":{"source":"iana","compressible":true},"application/vnd.oipf.cspg-hexbinary":{"source":"iana"},"application/vnd.oipf.dae.svg+xml":{"source":"iana","compressible":true},"application/vnd.oipf.dae.xhtml+xml":{"source":"iana","compressible":true},"application/vnd.oipf.mippvcontrolmessage+xml":{"source":"iana","compressible":true},"application/vnd.oipf.pae.gem":{"source":"iana"},"application/vnd.oipf.spdiscovery+xml":{"source":"iana","compressible":true},"application/vnd.oipf.spdlist+xml":{"source":"iana","compressible":true},"application/vnd.oipf.ueprofile+xml":{"source":"iana","compressible":true},"application/vnd.oipf.userprofile+xml":{"source":"iana","compressible":true},"application/vnd.olpc-sugar":{"source":"iana","extensions":["xo"]},"application/vnd.oma-scws-config":{"source":"iana"},"application/vnd.oma-scws-http-request":{"source":"iana"},"application/vnd.oma-scws-http-response":{"source":"iana"},"application/vnd.oma.bcast.associated-procedure-parameter+xml":{"source":"iana","compressible":true},"application/vnd.oma.bcast.drm-trigger+xml":{"source":"iana","compressible":true},"application/vnd.oma.bcast.imd+xml":{"source":"iana","compressible":true},"application/vnd.oma.bcast.ltkm":{"source":"iana"},"application/vnd.oma.bcast.notification+xml":{"source":"iana","compressible":true},"application/vnd.oma.bcast.provisioningtrigger":{"source":"iana"},"application/vnd.oma.bcast.sgboot":{"source":"iana"},"application/vnd.oma.bcast.sgdd+xml":{"source":"iana","compressible":true},"application/vnd.oma.bcast.sgdu":{"source":"iana"},"application/vnd.oma.bcast.simple-symbol-container":{"source":"iana"},"application/vnd.oma.bcast.smartcard-trigger+xml":{"source":"iana","compressible":true},"application/vnd.oma.bcast.sprov+xml":{"source":"iana","compressible":true},"application/vnd.oma.bcast.stkm":{"source":"iana"},"application/vnd.oma.cab-address-book+xml":{"source":"iana","compressible":true},"application/vnd.oma.cab-feature-handler+xml":{"source":"iana","compressible":true},"application/vnd.oma.cab-pcc+xml":{"source":"iana","compressible":true},"application/vnd.oma.cab-subs-invite+xml":{"source":"iana","compressible":true},"application/vnd.oma.cab-user-prefs+xml":{"source":"iana","compressible":true},"application/vnd.oma.dcd":{"source":"iana"},"application/vnd.oma.dcdc":{"source":"iana"},"application/vnd.oma.dd2+xml":{"source":"iana","compressible":true,"extensions":["dd2"]},"application/vnd.oma.drm.risd+xml":{"source":"iana","compressible":true},"application/vnd.oma.group-usage-list+xml":{"source":"iana","compressible":true},"application/vnd.oma.lwm2m+cbor":{"source":"iana"},"application/vnd.oma.lwm2m+json":{"source":"iana","compressible":true},"application/vnd.oma.lwm2m+tlv":{"source":"iana"},"application/vnd.oma.pal+xml":{"source":"iana","compressible":true},"application/vnd.oma.poc.detailed-progress-report+xml":{"source":"iana","compressible":true},"application/vnd.oma.poc.final-report+xml":{"source":"iana","compressible":true},"application/vnd.oma.poc.groups+xml":{"source":"iana","compressible":true},"application/vnd.oma.poc.invocation-descriptor+xml":{"source":"iana","compressible":true},"application/vnd.oma.poc.optimized-progress-report+xml":{"source":"iana","compressible":true},"application/vnd.oma.push":{"source":"iana"},"application/vnd.oma.scidm.messages+xml":{"source":"iana","compressible":true},"application/vnd.oma.xcap-directory+xml":{"source":"iana","compressible":true},"application/vnd.omads-email+xml":{"source":"iana","charset":"UTF-8","compressible":true},"application/vnd.omads-file+xml":{"source":"iana","charset":"UTF-8","compressible":true},"application/vnd.omads-folder+xml":{"source":"iana","charset":"UTF-8","compressible":true},"application/vnd.omaloc-supl-init":{"source":"iana"},"application/vnd.onepager":{"source":"iana"},"application/vnd.onepagertamp":{"source":"iana"},"application/vnd.onepagertamx":{"source":"iana"},"application/vnd.onepagertat":{"source":"iana"},"application/vnd.onepagertatp":{"source":"iana"},"application/vnd.onepagertatx":{"source":"iana"},"application/vnd.openblox.game+xml":{"source":"iana","compressible":true,"extensions":["obgx"]},"application/vnd.openblox.game-binary":{"source":"iana"},"application/vnd.openeye.oeb":{"source":"iana"},"application/vnd.openofficeorg.extension":{"source":"apache","extensions":["oxt"]},"application/vnd.openstreetmap.data+xml":{"source":"iana","compressible":true,"extensions":["osm"]},"application/vnd.opentimestamps.ots":{"source":"iana"},"application/vnd.openxmlformats-officedocument.custom-properties+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.customxmlproperties+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.drawing+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.drawingml.chart+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.drawingml.diagramcolors+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.drawingml.diagramdata+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.drawingml.diagramlayout+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.drawingml.diagramstyle+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.extended-properties+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.commentauthors+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.comments+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.handoutmaster+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.notesmaster+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.notesslide+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.presentation":{"source":"iana","compressible":false,"extensions":["pptx"]},"application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.presprops+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.slide":{"source":"iana","extensions":["sldx"]},"application/vnd.openxmlformats-officedocument.presentationml.slide+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.slidelayout+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.slidemaster+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.slideshow":{"source":"iana","extensions":["ppsx"]},"application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.slideupdateinfo+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.tablestyles+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.tags+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.template":{"source":"iana","extensions":["potx"]},"application/vnd.openxmlformats-officedocument.presentationml.template.main+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.viewprops+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.calcchain+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.externallink+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcachedefinition+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcacherecords+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.pivottable+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.querytable+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.revisionheaders+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.revisionlog+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedstrings+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":{"source":"iana","compressible":false,"extensions":["xlsx"]},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheetmetadata+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.tablesinglecells+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.template":{"source":"iana","extensions":["xltx"]},"application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.usernames+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.volatiledependencies+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.theme+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.themeoverride+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.vmldrawing":{"source":"iana"},"application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.wordprocessingml.document":{"source":"iana","compressible":false,"extensions":["docx"]},"application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.wordprocessingml.fonttable+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.wordprocessingml.template":{"source":"iana","extensions":["dotx"]},"application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.wordprocessingml.websettings+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-package.core-properties+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-package.relationships+xml":{"source":"iana","compressible":true},"application/vnd.oracle.resource+json":{"source":"iana","compressible":true},"application/vnd.orange.indata":{"source":"iana"},"application/vnd.osa.netdeploy":{"source":"iana"},"application/vnd.osgeo.mapguide.package":{"source":"iana","extensions":["mgp"]},"application/vnd.osgi.bundle":{"source":"iana"},"application/vnd.osgi.dp":{"source":"iana","extensions":["dp"]},"application/vnd.osgi.subsystem":{"source":"iana","extensions":["esa"]},"application/vnd.otps.ct-kip+xml":{"source":"iana","compressible":true},"application/vnd.oxli.countgraph":{"source":"iana"},"application/vnd.pagerduty+json":{"source":"iana","compressible":true},"application/vnd.palm":{"source":"iana","extensions":["pdb","pqa","oprc"]},"application/vnd.panoply":{"source":"iana"},"application/vnd.paos.xml":{"source":"iana"},"application/vnd.patentdive":{"source":"iana"},"application/vnd.patientecommsdoc":{"source":"iana"},"application/vnd.pawaafile":{"source":"iana","extensions":["paw"]},"application/vnd.pcos":{"source":"iana"},"application/vnd.pg.format":{"source":"iana","extensions":["str"]},"application/vnd.pg.osasli":{"source":"iana","extensions":["ei6"]},"application/vnd.piaccess.application-licence":{"source":"iana"},"application/vnd.picsel":{"source":"iana","extensions":["efif"]},"application/vnd.pmi.widget":{"source":"iana","extensions":["wg"]},"application/vnd.poc.group-advertisement+xml":{"source":"iana","compressible":true},"application/vnd.pocketlearn":{"source":"iana","extensions":["plf"]},"application/vnd.powerbuilder6":{"source":"iana","extensions":["pbd"]},"application/vnd.powerbuilder6-s":{"source":"iana"},"application/vnd.powerbuilder7":{"source":"iana"},"application/vnd.powerbuilder7-s":{"source":"iana"},"application/vnd.powerbuilder75":{"source":"iana"},"application/vnd.powerbuilder75-s":{"source":"iana"},"application/vnd.preminet":{"source":"iana"},"application/vnd.previewsystems.box":{"source":"iana","extensions":["box"]},"application/vnd.proteus.magazine":{"source":"iana","extensions":["mgz"]},"application/vnd.psfs":{"source":"iana"},"application/vnd.publishare-delta-tree":{"source":"iana","extensions":["qps"]},"application/vnd.pvi.ptid1":{"source":"iana","extensions":["ptid"]},"application/vnd.pwg-multiplexed":{"source":"iana"},"application/vnd.pwg-xhtml-print+xml":{"source":"iana","compressible":true},"application/vnd.qualcomm.brew-app-res":{"source":"iana"},"application/vnd.quarantainenet":{"source":"iana"},"application/vnd.quark.quarkxpress":{"source":"iana","extensions":["qxd","qxt","qwd","qwt","qxl","qxb"]},"application/vnd.quobject-quoxdocument":{"source":"iana"},"application/vnd.radisys.moml+xml":{"source":"iana","compressible":true},"application/vnd.radisys.msml+xml":{"source":"iana","compressible":true},"application/vnd.radisys.msml-audit+xml":{"source":"iana","compressible":true},"application/vnd.radisys.msml-audit-conf+xml":{"source":"iana","compressible":true},"application/vnd.radisys.msml-audit-conn+xml":{"source":"iana","compressible":true},"application/vnd.radisys.msml-audit-dialog+xml":{"source":"iana","compressible":true},"application/vnd.radisys.msml-audit-stream+xml":{"source":"iana","compressible":true},"application/vnd.radisys.msml-conf+xml":{"source":"iana","compressible":true},"application/vnd.radisys.msml-dialog+xml":{"source":"iana","compressible":true},"application/vnd.radisys.msml-dialog-base+xml":{"source":"iana","compressible":true},"application/vnd.radisys.msml-dialog-fax-detect+xml":{"source":"iana","compressible":true},"application/vnd.radisys.msml-dialog-fax-sendrecv+xml":{"source":"iana","compressible":true},"application/vnd.radisys.msml-dialog-group+xml":{"source":"iana","compressible":true},"application/vnd.radisys.msml-dialog-speech+xml":{"source":"iana","compressible":true},"application/vnd.radisys.msml-dialog-transform+xml":{"source":"iana","compressible":true},"application/vnd.rainstor.data":{"source":"iana"},"application/vnd.rapid":{"source":"iana"},"application/vnd.rar":{"source":"iana","extensions":["rar"]},"application/vnd.realvnc.bed":{"source":"iana","extensions":["bed"]},"application/vnd.recordare.musicxml":{"source":"iana","extensions":["mxl"]},"application/vnd.recordare.musicxml+xml":{"source":"iana","compressible":true,"extensions":["musicxml"]},"application/vnd.renlearn.rlprint":{"source":"iana"},"application/vnd.resilient.logic":{"source":"iana"},"application/vnd.restful+json":{"source":"iana","compressible":true},"application/vnd.rig.cryptonote":{"source":"iana","extensions":["cryptonote"]},"application/vnd.rim.cod":{"source":"apache","extensions":["cod"]},"application/vnd.rn-realmedia":{"source":"apache","extensions":["rm"]},"application/vnd.rn-realmedia-vbr":{"source":"apache","extensions":["rmvb"]},"application/vnd.route66.link66+xml":{"source":"iana","compressible":true,"extensions":["link66"]},"application/vnd.rs-274x":{"source":"iana"},"application/vnd.ruckus.download":{"source":"iana"},"application/vnd.s3sms":{"source":"iana"},"application/vnd.sailingtracker.track":{"source":"iana","extensions":["st"]},"application/vnd.sar":{"source":"iana"},"application/vnd.sbm.cid":{"source":"iana"},"application/vnd.sbm.mid2":{"source":"iana"},"application/vnd.scribus":{"source":"iana"},"application/vnd.sealed.3df":{"source":"iana"},"application/vnd.sealed.csf":{"source":"iana"},"application/vnd.sealed.doc":{"source":"iana"},"application/vnd.sealed.eml":{"source":"iana"},"application/vnd.sealed.mht":{"source":"iana"},"application/vnd.sealed.net":{"source":"iana"},"application/vnd.sealed.ppt":{"source":"iana"},"application/vnd.sealed.tiff":{"source":"iana"},"application/vnd.sealed.xls":{"source":"iana"},"application/vnd.sealedmedia.softseal.html":{"source":"iana"},"application/vnd.sealedmedia.softseal.pdf":{"source":"iana"},"application/vnd.seemail":{"source":"iana","extensions":["see"]},"application/vnd.seis+json":{"source":"iana","compressible":true},"application/vnd.sema":{"source":"iana","extensions":["sema"]},"application/vnd.semd":{"source":"iana","extensions":["semd"]},"application/vnd.semf":{"source":"iana","extensions":["semf"]},"application/vnd.shade-save-file":{"source":"iana"},"application/vnd.shana.informed.formdata":{"source":"iana","extensions":["ifm"]},"application/vnd.shana.informed.formtemplate":{"source":"iana","extensions":["itp"]},"application/vnd.shana.informed.interchange":{"source":"iana","extensions":["iif"]},"application/vnd.shana.informed.package":{"source":"iana","extensions":["ipk"]},"application/vnd.shootproof+json":{"source":"iana","compressible":true},"application/vnd.shopkick+json":{"source":"iana","compressible":true},"application/vnd.shp":{"source":"iana"},"application/vnd.shx":{"source":"iana"},"application/vnd.sigrok.session":{"source":"iana"},"application/vnd.simtech-mindmapper":{"source":"iana","extensions":["twd","twds"]},"application/vnd.siren+json":{"source":"iana","compressible":true},"application/vnd.smaf":{"source":"iana","extensions":["mmf"]},"application/vnd.smart.notebook":{"source":"iana"},"application/vnd.smart.teacher":{"source":"iana","extensions":["teacher"]},"application/vnd.snesdev-page-table":{"source":"iana"},"application/vnd.software602.filler.form+xml":{"source":"iana","compressible":true,"extensions":["fo"]},"application/vnd.software602.filler.form-xml-zip":{"source":"iana"},"application/vnd.solent.sdkm+xml":{"source":"iana","compressible":true,"extensions":["sdkm","sdkd"]},"application/vnd.spotfire.dxp":{"source":"iana","extensions":["dxp"]},"application/vnd.spotfire.sfs":{"source":"iana","extensions":["sfs"]},"application/vnd.sqlite3":{"source":"iana"},"application/vnd.sss-cod":{"source":"iana"},"application/vnd.sss-dtf":{"source":"iana"},"application/vnd.sss-ntf":{"source":"iana"},"application/vnd.stardivision.calc":{"source":"apache","extensions":["sdc"]},"application/vnd.stardivision.draw":{"source":"apache","extensions":["sda"]},"application/vnd.stardivision.impress":{"source":"apache","extensions":["sdd"]},"application/vnd.stardivision.math":{"source":"apache","extensions":["smf"]},"application/vnd.stardivision.writer":{"source":"apache","extensions":["sdw","vor"]},"application/vnd.stardivision.writer-global":{"source":"apache","extensions":["sgl"]},"application/vnd.stepmania.package":{"source":"iana","extensions":["smzip"]},"application/vnd.stepmania.stepchart":{"source":"iana","extensions":["sm"]},"application/vnd.street-stream":{"source":"iana"},"application/vnd.sun.wadl+xml":{"source":"iana","compressible":true,"extensions":["wadl"]},"application/vnd.sun.xml.calc":{"source":"apache","extensions":["sxc"]},"application/vnd.sun.xml.calc.template":{"source":"apache","extensions":["stc"]},"application/vnd.sun.xml.draw":{"source":"apache","extensions":["sxd"]},"application/vnd.sun.xml.draw.template":{"source":"apache","extensions":["std"]},"application/vnd.sun.xml.impress":{"source":"apache","extensions":["sxi"]},"application/vnd.sun.xml.impress.template":{"source":"apache","extensions":["sti"]},"application/vnd.sun.xml.math":{"source":"apache","extensions":["sxm"]},"application/vnd.sun.xml.writer":{"source":"apache","extensions":["sxw"]},"application/vnd.sun.xml.writer.global":{"source":"apache","extensions":["sxg"]},"application/vnd.sun.xml.writer.template":{"source":"apache","extensions":["stw"]},"application/vnd.sus-calendar":{"source":"iana","extensions":["sus","susp"]},"application/vnd.svd":{"source":"iana","extensions":["svd"]},"application/vnd.swiftview-ics":{"source":"iana"},"application/vnd.sycle+xml":{"source":"iana","compressible":true},"application/vnd.syft+json":{"source":"iana","compressible":true},"application/vnd.symbian.install":{"source":"apache","extensions":["sis","sisx"]},"application/vnd.syncml+xml":{"source":"iana","charset":"UTF-8","compressible":true,"extensions":["xsm"]},"application/vnd.syncml.dm+wbxml":{"source":"iana","charset":"UTF-8","extensions":["bdm"]},"application/vnd.syncml.dm+xml":{"source":"iana","charset":"UTF-8","compressible":true,"extensions":["xdm"]},"application/vnd.syncml.dm.notification":{"source":"iana"},"application/vnd.syncml.dmddf+wbxml":{"source":"iana"},"application/vnd.syncml.dmddf+xml":{"source":"iana","charset":"UTF-8","compressible":true,"extensions":["ddf"]},"application/vnd.syncml.dmtnds+wbxml":{"source":"iana"},"application/vnd.syncml.dmtnds+xml":{"source":"iana","charset":"UTF-8","compressible":true},"application/vnd.syncml.ds.notification":{"source":"iana"},"application/vnd.tableschema+json":{"source":"iana","compressible":true},"application/vnd.tao.intent-module-archive":{"source":"iana","extensions":["tao"]},"application/vnd.tcpdump.pcap":{"source":"iana","extensions":["pcap","cap","dmp"]},"application/vnd.think-cell.ppttc+json":{"source":"iana","compressible":true},"application/vnd.tmd.mediaflex.api+xml":{"source":"iana","compressible":true},"application/vnd.tml":{"source":"iana"},"application/vnd.tmobile-livetv":{"source":"iana","extensions":["tmo"]},"application/vnd.tri.onesource":{"source":"iana"},"application/vnd.trid.tpt":{"source":"iana","extensions":["tpt"]},"application/vnd.triscape.mxs":{"source":"iana","extensions":["mxs"]},"application/vnd.trueapp":{"source":"iana","extensions":["tra"]},"application/vnd.truedoc":{"source":"iana"},"application/vnd.ubisoft.webplayer":{"source":"iana"},"application/vnd.ufdl":{"source":"iana","extensions":["ufd","ufdl"]},"application/vnd.uiq.theme":{"source":"iana","extensions":["utz"]},"application/vnd.umajin":{"source":"iana","extensions":["umj"]},"application/vnd.unity":{"source":"iana","extensions":["unityweb"]},"application/vnd.uoml+xml":{"source":"iana","compressible":true,"extensions":["uoml"]},"application/vnd.uplanet.alert":{"source":"iana"},"application/vnd.uplanet.alert-wbxml":{"source":"iana"},"application/vnd.uplanet.bearer-choice":{"source":"iana"},"application/vnd.uplanet.bearer-choice-wbxml":{"source":"iana"},"application/vnd.uplanet.cacheop":{"source":"iana"},"application/vnd.uplanet.cacheop-wbxml":{"source":"iana"},"application/vnd.uplanet.channel":{"source":"iana"},"application/vnd.uplanet.channel-wbxml":{"source":"iana"},"application/vnd.uplanet.list":{"source":"iana"},"application/vnd.uplanet.list-wbxml":{"source":"iana"},"application/vnd.uplanet.listcmd":{"source":"iana"},"application/vnd.uplanet.listcmd-wbxml":{"source":"iana"},"application/vnd.uplanet.signal":{"source":"iana"},"application/vnd.uri-map":{"source":"iana"},"application/vnd.valve.source.material":{"source":"iana"},"application/vnd.vcx":{"source":"iana","extensions":["vcx"]},"application/vnd.vd-study":{"source":"iana"},"application/vnd.vectorworks":{"source":"iana"},"application/vnd.vel+json":{"source":"iana","compressible":true},"application/vnd.verimatrix.vcas":{"source":"iana"},"application/vnd.veritone.aion+json":{"source":"iana","compressible":true},"application/vnd.veryant.thin":{"source":"iana"},"application/vnd.ves.encrypted":{"source":"iana"},"application/vnd.vidsoft.vidconference":{"source":"iana"},"application/vnd.visio":{"source":"iana","extensions":["vsd","vst","vss","vsw"]},"application/vnd.visionary":{"source":"iana","extensions":["vis"]},"application/vnd.vividence.scriptfile":{"source":"iana"},"application/vnd.vsf":{"source":"iana","extensions":["vsf"]},"application/vnd.wap.sic":{"source":"iana"},"application/vnd.wap.slc":{"source":"iana"},"application/vnd.wap.wbxml":{"source":"iana","charset":"UTF-8","extensions":["wbxml"]},"application/vnd.wap.wmlc":{"source":"iana","extensions":["wmlc"]},"application/vnd.wap.wmlscriptc":{"source":"iana","extensions":["wmlsc"]},"application/vnd.webturbo":{"source":"iana","extensions":["wtb"]},"application/vnd.wfa.dpp":{"source":"iana"},"application/vnd.wfa.p2p":{"source":"iana"},"application/vnd.wfa.wsc":{"source":"iana"},"application/vnd.windows.devicepairing":{"source":"iana"},"application/vnd.wmc":{"source":"iana"},"application/vnd.wmf.bootstrap":{"source":"iana"},"application/vnd.wolfram.mathematica":{"source":"iana"},"application/vnd.wolfram.mathematica.package":{"source":"iana"},"application/vnd.wolfram.player":{"source":"iana","extensions":["nbp"]},"application/vnd.wordperfect":{"source":"iana","extensions":["wpd"]},"application/vnd.wqd":{"source":"iana","extensions":["wqd"]},"application/vnd.wrq-hp3000-labelled":{"source":"iana"},"application/vnd.wt.stf":{"source":"iana","extensions":["stf"]},"application/vnd.wv.csp+wbxml":{"source":"iana"},"application/vnd.wv.csp+xml":{"source":"iana","compressible":true},"application/vnd.wv.ssp+xml":{"source":"iana","compressible":true},"application/vnd.xacml+json":{"source":"iana","compressible":true},"application/vnd.xara":{"source":"iana","extensions":["xar"]},"application/vnd.xfdl":{"source":"iana","extensions":["xfdl"]},"application/vnd.xfdl.webform":{"source":"iana"},"application/vnd.xmi+xml":{"source":"iana","compressible":true},"application/vnd.xmpie.cpkg":{"source":"iana"},"application/vnd.xmpie.dpkg":{"source":"iana"},"application/vnd.xmpie.plan":{"source":"iana"},"application/vnd.xmpie.ppkg":{"source":"iana"},"application/vnd.xmpie.xlim":{"source":"iana"},"application/vnd.yamaha.hv-dic":{"source":"iana","extensions":["hvd"]},"application/vnd.yamaha.hv-script":{"source":"iana","extensions":["hvs"]},"application/vnd.yamaha.hv-voice":{"source":"iana","extensions":["hvp"]},"application/vnd.yamaha.openscoreformat":{"source":"iana","extensions":["osf"]},"application/vnd.yamaha.openscoreformat.osfpvg+xml":{"source":"iana","compressible":true,"extensions":["osfpvg"]},"application/vnd.yamaha.remote-setup":{"source":"iana"},"application/vnd.yamaha.smaf-audio":{"source":"iana","extensions":["saf"]},"application/vnd.yamaha.smaf-phrase":{"source":"iana","extensions":["spf"]},"application/vnd.yamaha.through-ngn":{"source":"iana"},"application/vnd.yamaha.tunnel-udpencap":{"source":"iana"},"application/vnd.yaoweme":{"source":"iana"},"application/vnd.yellowriver-custom-menu":{"source":"iana","extensions":["cmp"]},"application/vnd.youtube.yt":{"source":"iana"},"application/vnd.zul":{"source":"iana","extensions":["zir","zirz"]},"application/vnd.zzazz.deck+xml":{"source":"iana","compressible":true,"extensions":["zaz"]},"application/voicexml+xml":{"source":"iana","compressible":true,"extensions":["vxml"]},"application/voucher-cms+json":{"source":"iana","compressible":true},"application/vq-rtcpxr":{"source":"iana"},"application/wasm":{"source":"iana","compressible":true,"extensions":["wasm"]},"application/watcherinfo+xml":{"source":"iana","compressible":true,"extensions":["wif"]},"application/webpush-options+json":{"source":"iana","compressible":true},"application/whoispp-query":{"source":"iana"},"application/whoispp-response":{"source":"iana"},"application/widget":{"source":"iana","extensions":["wgt"]},"application/winhlp":{"source":"apache","extensions":["hlp"]},"application/wita":{"source":"iana"},"application/wordperfect5.1":{"source":"iana"},"application/wsdl+xml":{"source":"iana","compressible":true,"extensions":["wsdl"]},"application/wspolicy+xml":{"source":"iana","compressible":true,"extensions":["wspolicy"]},"application/x-7z-compressed":{"source":"apache","compressible":false,"extensions":["7z"]},"application/x-abiword":{"source":"apache","extensions":["abw"]},"application/x-ace-compressed":{"source":"apache","extensions":["ace"]},"application/x-amf":{"source":"apache"},"application/x-apple-diskimage":{"source":"apache","extensions":["dmg"]},"application/x-arj":{"compressible":false,"extensions":["arj"]},"application/x-authorware-bin":{"source":"apache","extensions":["aab","x32","u32","vox"]},"application/x-authorware-map":{"source":"apache","extensions":["aam"]},"application/x-authorware-seg":{"source":"apache","extensions":["aas"]},"application/x-bcpio":{"source":"apache","extensions":["bcpio"]},"application/x-bdoc":{"compressible":false,"extensions":["bdoc"]},"application/x-bittorrent":{"source":"apache","extensions":["torrent"]},"application/x-blorb":{"source":"apache","extensions":["blb","blorb"]},"application/x-bzip":{"source":"apache","compressible":false,"extensions":["bz"]},"application/x-bzip2":{"source":"apache","compressible":false,"extensions":["bz2","boz"]},"application/x-cbr":{"source":"apache","extensions":["cbr","cba","cbt","cbz","cb7"]},"application/x-cdlink":{"source":"apache","extensions":["vcd"]},"application/x-cfs-compressed":{"source":"apache","extensions":["cfs"]},"application/x-chat":{"source":"apache","extensions":["chat"]},"application/x-chess-pgn":{"source":"apache","extensions":["pgn"]},"application/x-chrome-extension":{"extensions":["crx"]},"application/x-cocoa":{"source":"nginx","extensions":["cco"]},"application/x-compress":{"source":"apache"},"application/x-conference":{"source":"apache","extensions":["nsc"]},"application/x-cpio":{"source":"apache","extensions":["cpio"]},"application/x-csh":{"source":"apache","extensions":["csh"]},"application/x-deb":{"compressible":false},"application/x-debian-package":{"source":"apache","extensions":["deb","udeb"]},"application/x-dgc-compressed":{"source":"apache","extensions":["dgc"]},"application/x-director":{"source":"apache","extensions":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"]},"application/x-doom":{"source":"apache","extensions":["wad"]},"application/x-dtbncx+xml":{"source":"apache","compressible":true,"extensions":["ncx"]},"application/x-dtbook+xml":{"source":"apache","compressible":true,"extensions":["dtb"]},"application/x-dtbresource+xml":{"source":"apache","compressible":true,"extensions":["res"]},"application/x-dvi":{"source":"apache","compressible":false,"extensions":["dvi"]},"application/x-envoy":{"source":"apache","extensions":["evy"]},"application/x-eva":{"source":"apache","extensions":["eva"]},"application/x-font-bdf":{"source":"apache","extensions":["bdf"]},"application/x-font-dos":{"source":"apache"},"application/x-font-framemaker":{"source":"apache"},"application/x-font-ghostscript":{"source":"apache","extensions":["gsf"]},"application/x-font-libgrx":{"source":"apache"},"application/x-font-linux-psf":{"source":"apache","extensions":["psf"]},"application/x-font-pcf":{"source":"apache","extensions":["pcf"]},"application/x-font-snf":{"source":"apache","extensions":["snf"]},"application/x-font-speedo":{"source":"apache"},"application/x-font-sunos-news":{"source":"apache"},"application/x-font-type1":{"source":"apache","extensions":["pfa","pfb","pfm","afm"]},"application/x-font-vfont":{"source":"apache"},"application/x-freearc":{"source":"apache","extensions":["arc"]},"application/x-futuresplash":{"source":"apache","extensions":["spl"]},"application/x-gca-compressed":{"source":"apache","extensions":["gca"]},"application/x-glulx":{"source":"apache","extensions":["ulx"]},"application/x-gnumeric":{"source":"apache","extensions":["gnumeric"]},"application/x-gramps-xml":{"source":"apache","extensions":["gramps"]},"application/x-gtar":{"source":"apache","extensions":["gtar"]},"application/x-gzip":{"source":"apache"},"application/x-hdf":{"source":"apache","extensions":["hdf"]},"application/x-httpd-php":{"compressible":true,"extensions":["php"]},"application/x-install-instructions":{"source":"apache","extensions":["install"]},"application/x-iso9660-image":{"source":"apache","extensions":["iso"]},"application/x-iwork-keynote-sffkey":{"extensions":["key"]},"application/x-iwork-numbers-sffnumbers":{"extensions":["numbers"]},"application/x-iwork-pages-sffpages":{"extensions":["pages"]},"application/x-java-archive-diff":{"source":"nginx","extensions":["jardiff"]},"application/x-java-jnlp-file":{"source":"apache","compressible":false,"extensions":["jnlp"]},"application/x-javascript":{"compressible":true},"application/x-keepass2":{"extensions":["kdbx"]},"application/x-latex":{"source":"apache","compressible":false,"extensions":["latex"]},"application/x-lua-bytecode":{"extensions":["luac"]},"application/x-lzh-compressed":{"source":"apache","extensions":["lzh","lha"]},"application/x-makeself":{"source":"nginx","extensions":["run"]},"application/x-mie":{"source":"apache","extensions":["mie"]},"application/x-mobipocket-ebook":{"source":"apache","extensions":["prc","mobi"]},"application/x-mpegurl":{"compressible":false},"application/x-ms-application":{"source":"apache","extensions":["application"]},"application/x-ms-shortcut":{"source":"apache","extensions":["lnk"]},"application/x-ms-wmd":{"source":"apache","extensions":["wmd"]},"application/x-ms-wmz":{"source":"apache","extensions":["wmz"]},"application/x-ms-xbap":{"source":"apache","extensions":["xbap"]},"application/x-msaccess":{"source":"apache","extensions":["mdb"]},"application/x-msbinder":{"source":"apache","extensions":["obd"]},"application/x-mscardfile":{"source":"apache","extensions":["crd"]},"application/x-msclip":{"source":"apache","extensions":["clp"]},"application/x-msdos-program":{"extensions":["exe"]},"application/x-msdownload":{"source":"apache","extensions":["exe","dll","com","bat","msi"]},"application/x-msmediaview":{"source":"apache","extensions":["mvb","m13","m14"]},"application/x-msmetafile":{"source":"apache","extensions":["wmf","wmz","emf","emz"]},"application/x-msmoney":{"source":"apache","extensions":["mny"]},"application/x-mspublisher":{"source":"apache","extensions":["pub"]},"application/x-msschedule":{"source":"apache","extensions":["scd"]},"application/x-msterminal":{"source":"apache","extensions":["trm"]},"application/x-mswrite":{"source":"apache","extensions":["wri"]},"application/x-netcdf":{"source":"apache","extensions":["nc","cdf"]},"application/x-ns-proxy-autoconfig":{"compressible":true,"extensions":["pac"]},"application/x-nzb":{"source":"apache","extensions":["nzb"]},"application/x-perl":{"source":"nginx","extensions":["pl","pm"]},"application/x-pilot":{"source":"nginx","extensions":["prc","pdb"]},"application/x-pkcs12":{"source":"apache","compressible":false,"extensions":["p12","pfx"]},"application/x-pkcs7-certificates":{"source":"apache","extensions":["p7b","spc"]},"application/x-pkcs7-certreqresp":{"source":"apache","extensions":["p7r"]},"application/x-pki-message":{"source":"iana"},"application/x-rar-compressed":{"source":"apache","compressible":false,"extensions":["rar"]},"application/x-redhat-package-manager":{"source":"nginx","extensions":["rpm"]},"application/x-research-info-systems":{"source":"apache","extensions":["ris"]},"application/x-sea":{"source":"nginx","extensions":["sea"]},"application/x-sh":{"source":"apache","compressible":true,"extensions":["sh"]},"application/x-shar":{"source":"apache","extensions":["shar"]},"application/x-shockwave-flash":{"source":"apache","compressible":false,"extensions":["swf"]},"application/x-silverlight-app":{"source":"apache","extensions":["xap"]},"application/x-sql":{"source":"apache","extensions":["sql"]},"application/x-stuffit":{"source":"apache","compressible":false,"extensions":["sit"]},"application/x-stuffitx":{"source":"apache","extensions":["sitx"]},"application/x-subrip":{"source":"apache","extensions":["srt"]},"application/x-sv4cpio":{"source":"apache","extensions":["sv4cpio"]},"application/x-sv4crc":{"source":"apache","extensions":["sv4crc"]},"application/x-t3vm-image":{"source":"apache","extensions":["t3"]},"application/x-tads":{"source":"apache","extensions":["gam"]},"application/x-tar":{"source":"apache","compressible":true,"extensions":["tar"]},"application/x-tcl":{"source":"apache","extensions":["tcl","tk"]},"application/x-tex":{"source":"apache","extensions":["tex"]},"application/x-tex-tfm":{"source":"apache","extensions":["tfm"]},"application/x-texinfo":{"source":"apache","extensions":["texinfo","texi"]},"application/x-tgif":{"source":"apache","extensions":["obj"]},"application/x-ustar":{"source":"apache","extensions":["ustar"]},"application/x-virtualbox-hdd":{"compressible":true,"extensions":["hdd"]},"application/x-virtualbox-ova":{"compressible":true,"extensions":["ova"]},"application/x-virtualbox-ovf":{"compressible":true,"extensions":["ovf"]},"application/x-virtualbox-vbox":{"compressible":true,"extensions":["vbox"]},"application/x-virtualbox-vbox-extpack":{"compressible":false,"extensions":["vbox-extpack"]},"application/x-virtualbox-vdi":{"compressible":true,"extensions":["vdi"]},"application/x-virtualbox-vhd":{"compressible":true,"extensions":["vhd"]},"application/x-virtualbox-vmdk":{"compressible":true,"extensions":["vmdk"]},"application/x-wais-source":{"source":"apache","extensions":["src"]},"application/x-web-app-manifest+json":{"compressible":true,"extensions":["webapp"]},"application/x-www-form-urlencoded":{"source":"iana","compressible":true},"application/x-x509-ca-cert":{"source":"iana","extensions":["der","crt","pem"]},"application/x-x509-ca-ra-cert":{"source":"iana"},"application/x-x509-next-ca-cert":{"source":"iana"},"application/x-xfig":{"source":"apache","extensions":["fig"]},"application/x-xliff+xml":{"source":"apache","compressible":true,"extensions":["xlf"]},"application/x-xpinstall":{"source":"apache","compressible":false,"extensions":["xpi"]},"application/x-xz":{"source":"apache","extensions":["xz"]},"application/x-zmachine":{"source":"apache","extensions":["z1","z2","z3","z4","z5","z6","z7","z8"]},"application/x400-bp":{"source":"iana"},"application/xacml+xml":{"source":"iana","compressible":true},"application/xaml+xml":{"source":"apache","compressible":true,"extensions":["xaml"]},"application/xcap-att+xml":{"source":"iana","compressible":true,"extensions":["xav"]},"application/xcap-caps+xml":{"source":"iana","compressible":true,"extensions":["xca"]},"application/xcap-diff+xml":{"source":"iana","compressible":true,"extensions":["xdf"]},"application/xcap-el+xml":{"source":"iana","compressible":true,"extensions":["xel"]},"application/xcap-error+xml":{"source":"iana","compressible":true},"application/xcap-ns+xml":{"source":"iana","compressible":true,"extensions":["xns"]},"application/xcon-conference-info+xml":{"source":"iana","compressible":true},"application/xcon-conference-info-diff+xml":{"source":"iana","compressible":true},"application/xenc+xml":{"source":"iana","compressible":true,"extensions":["xenc"]},"application/xhtml+xml":{"source":"iana","compressible":true,"extensions":["xhtml","xht"]},"application/xhtml-voice+xml":{"source":"apache","compressible":true},"application/xliff+xml":{"source":"iana","compressible":true,"extensions":["xlf"]},"application/xml":{"source":"iana","compressible":true,"extensions":["xml","xsl","xsd","rng"]},"application/xml-dtd":{"source":"iana","compressible":true,"extensions":["dtd"]},"application/xml-external-parsed-entity":{"source":"iana"},"application/xml-patch+xml":{"source":"iana","compressible":true},"application/xmpp+xml":{"source":"iana","compressible":true},"application/xop+xml":{"source":"iana","compressible":true,"extensions":["xop"]},"application/xproc+xml":{"source":"apache","compressible":true,"extensions":["xpl"]},"application/xslt+xml":{"source":"iana","compressible":true,"extensions":["xsl","xslt"]},"application/xspf+xml":{"source":"apache","compressible":true,"extensions":["xspf"]},"application/xv+xml":{"source":"iana","compressible":true,"extensions":["mxml","xhvml","xvml","xvm"]},"application/yang":{"source":"iana","extensions":["yang"]},"application/yang-data+json":{"source":"iana","compressible":true},"application/yang-data+xml":{"source":"iana","compressible":true},"application/yang-patch+json":{"source":"iana","compressible":true},"application/yang-patch+xml":{"source":"iana","compressible":true},"application/yin+xml":{"source":"iana","compressible":true,"extensions":["yin"]},"application/zip":{"source":"iana","compressible":false,"extensions":["zip"]},"application/zlib":{"source":"iana"},"application/zstd":{"source":"iana"},"audio/1d-interleaved-parityfec":{"source":"iana"},"audio/32kadpcm":{"source":"iana"},"audio/3gpp":{"source":"iana","compressible":false,"extensions":["3gpp"]},"audio/3gpp2":{"source":"iana"},"audio/aac":{"source":"iana"},"audio/ac3":{"source":"iana"},"audio/adpcm":{"source":"apache","extensions":["adp"]},"audio/amr":{"source":"iana","extensions":["amr"]},"audio/amr-wb":{"source":"iana"},"audio/amr-wb+":{"source":"iana"},"audio/aptx":{"source":"iana"},"audio/asc":{"source":"iana"},"audio/atrac-advanced-lossless":{"source":"iana"},"audio/atrac-x":{"source":"iana"},"audio/atrac3":{"source":"iana"},"audio/basic":{"source":"iana","compressible":false,"extensions":["au","snd"]},"audio/bv16":{"source":"iana"},"audio/bv32":{"source":"iana"},"audio/clearmode":{"source":"iana"},"audio/cn":{"source":"iana"},"audio/dat12":{"source":"iana"},"audio/dls":{"source":"iana"},"audio/dsr-es201108":{"source":"iana"},"audio/dsr-es202050":{"source":"iana"},"audio/dsr-es202211":{"source":"iana"},"audio/dsr-es202212":{"source":"iana"},"audio/dv":{"source":"iana"},"audio/dvi4":{"source":"iana"},"audio/eac3":{"source":"iana"},"audio/encaprtp":{"source":"iana"},"audio/evrc":{"source":"iana"},"audio/evrc-qcp":{"source":"iana"},"audio/evrc0":{"source":"iana"},"audio/evrc1":{"source":"iana"},"audio/evrcb":{"source":"iana"},"audio/evrcb0":{"source":"iana"},"audio/evrcb1":{"source":"iana"},"audio/evrcnw":{"source":"iana"},"audio/evrcnw0":{"source":"iana"},"audio/evrcnw1":{"source":"iana"},"audio/evrcwb":{"source":"iana"},"audio/evrcwb0":{"source":"iana"},"audio/evrcwb1":{"source":"iana"},"audio/evs":{"source":"iana"},"audio/flexfec":{"source":"iana"},"audio/fwdred":{"source":"iana"},"audio/g711-0":{"source":"iana"},"audio/g719":{"source":"iana"},"audio/g722":{"source":"iana"},"audio/g7221":{"source":"iana"},"audio/g723":{"source":"iana"},"audio/g726-16":{"source":"iana"},"audio/g726-24":{"source":"iana"},"audio/g726-32":{"source":"iana"},"audio/g726-40":{"source":"iana"},"audio/g728":{"source":"iana"},"audio/g729":{"source":"iana"},"audio/g7291":{"source":"iana"},"audio/g729d":{"source":"iana"},"audio/g729e":{"source":"iana"},"audio/gsm":{"source":"iana"},"audio/gsm-efr":{"source":"iana"},"audio/gsm-hr-08":{"source":"iana"},"audio/ilbc":{"source":"iana"},"audio/ip-mr_v2.5":{"source":"iana"},"audio/isac":{"source":"apache"},"audio/l16":{"source":"iana"},"audio/l20":{"source":"iana"},"audio/l24":{"source":"iana","compressible":false},"audio/l8":{"source":"iana"},"audio/lpc":{"source":"iana"},"audio/melp":{"source":"iana"},"audio/melp1200":{"source":"iana"},"audio/melp2400":{"source":"iana"},"audio/melp600":{"source":"iana"},"audio/mhas":{"source":"iana"},"audio/midi":{"source":"apache","extensions":["mid","midi","kar","rmi"]},"audio/mobile-xmf":{"source":"iana","extensions":["mxmf"]},"audio/mp3":{"compressible":false,"extensions":["mp3"]},"audio/mp4":{"source":"iana","compressible":false,"extensions":["m4a","mp4a"]},"audio/mp4a-latm":{"source":"iana"},"audio/mpa":{"source":"iana"},"audio/mpa-robust":{"source":"iana"},"audio/mpeg":{"source":"iana","compressible":false,"extensions":["mpga","mp2","mp2a","mp3","m2a","m3a"]},"audio/mpeg4-generic":{"source":"iana"},"audio/musepack":{"source":"apache"},"audio/ogg":{"source":"iana","compressible":false,"extensions":["oga","ogg","spx","opus"]},"audio/opus":{"source":"iana"},"audio/parityfec":{"source":"iana"},"audio/pcma":{"source":"iana"},"audio/pcma-wb":{"source":"iana"},"audio/pcmu":{"source":"iana"},"audio/pcmu-wb":{"source":"iana"},"audio/prs.sid":{"source":"iana"},"audio/qcelp":{"source":"iana"},"audio/raptorfec":{"source":"iana"},"audio/red":{"source":"iana"},"audio/rtp-enc-aescm128":{"source":"iana"},"audio/rtp-midi":{"source":"iana"},"audio/rtploopback":{"source":"iana"},"audio/rtx":{"source":"iana"},"audio/s3m":{"source":"apache","extensions":["s3m"]},"audio/scip":{"source":"iana"},"audio/silk":{"source":"apache","extensions":["sil"]},"audio/smv":{"source":"iana"},"audio/smv-qcp":{"source":"iana"},"audio/smv0":{"source":"iana"},"audio/sofa":{"source":"iana"},"audio/sp-midi":{"source":"iana"},"audio/speex":{"source":"iana"},"audio/t140c":{"source":"iana"},"audio/t38":{"source":"iana"},"audio/telephone-event":{"source":"iana"},"audio/tetra_acelp":{"source":"iana"},"audio/tetra_acelp_bb":{"source":"iana"},"audio/tone":{"source":"iana"},"audio/tsvcis":{"source":"iana"},"audio/uemclip":{"source":"iana"},"audio/ulpfec":{"source":"iana"},"audio/usac":{"source":"iana"},"audio/vdvi":{"source":"iana"},"audio/vmr-wb":{"source":"iana"},"audio/vnd.3gpp.iufp":{"source":"iana"},"audio/vnd.4sb":{"source":"iana"},"audio/vnd.audiokoz":{"source":"iana"},"audio/vnd.celp":{"source":"iana"},"audio/vnd.cisco.nse":{"source":"iana"},"audio/vnd.cmles.radio-events":{"source":"iana"},"audio/vnd.cns.anp1":{"source":"iana"},"audio/vnd.cns.inf1":{"source":"iana"},"audio/vnd.dece.audio":{"source":"iana","extensions":["uva","uvva"]},"audio/vnd.digital-winds":{"source":"iana","extensions":["eol"]},"audio/vnd.dlna.adts":{"source":"iana"},"audio/vnd.dolby.heaac.1":{"source":"iana"},"audio/vnd.dolby.heaac.2":{"source":"iana"},"audio/vnd.dolby.mlp":{"source":"iana"},"audio/vnd.dolby.mps":{"source":"iana"},"audio/vnd.dolby.pl2":{"source":"iana"},"audio/vnd.dolby.pl2x":{"source":"iana"},"audio/vnd.dolby.pl2z":{"source":"iana"},"audio/vnd.dolby.pulse.1":{"source":"iana"},"audio/vnd.dra":{"source":"iana","extensions":["dra"]},"audio/vnd.dts":{"source":"iana","extensions":["dts"]},"audio/vnd.dts.hd":{"source":"iana","extensions":["dtshd"]},"audio/vnd.dts.uhd":{"source":"iana"},"audio/vnd.dvb.file":{"source":"iana"},"audio/vnd.everad.plj":{"source":"iana"},"audio/vnd.hns.audio":{"source":"iana"},"audio/vnd.lucent.voice":{"source":"iana","extensions":["lvp"]},"audio/vnd.ms-playready.media.pya":{"source":"iana","extensions":["pya"]},"audio/vnd.nokia.mobile-xmf":{"source":"iana"},"audio/vnd.nortel.vbk":{"source":"iana"},"audio/vnd.nuera.ecelp4800":{"source":"iana","extensions":["ecelp4800"]},"audio/vnd.nuera.ecelp7470":{"source":"iana","extensions":["ecelp7470"]},"audio/vnd.nuera.ecelp9600":{"source":"iana","extensions":["ecelp9600"]},"audio/vnd.octel.sbc":{"source":"iana"},"audio/vnd.presonus.multitrack":{"source":"iana"},"audio/vnd.qcelp":{"source":"iana"},"audio/vnd.rhetorex.32kadpcm":{"source":"iana"},"audio/vnd.rip":{"source":"iana","extensions":["rip"]},"audio/vnd.rn-realaudio":{"compressible":false},"audio/vnd.sealedmedia.softseal.mpeg":{"source":"iana"},"audio/vnd.vmx.cvsd":{"source":"iana"},"audio/vnd.wave":{"compressible":false},"audio/vorbis":{"source":"iana","compressible":false},"audio/vorbis-config":{"source":"iana"},"audio/wav":{"compressible":false,"extensions":["wav"]},"audio/wave":{"compressible":false,"extensions":["wav"]},"audio/webm":{"source":"apache","compressible":false,"extensions":["weba"]},"audio/x-aac":{"source":"apache","compressible":false,"extensions":["aac"]},"audio/x-aiff":{"source":"apache","extensions":["aif","aiff","aifc"]},"audio/x-caf":{"source":"apache","compressible":false,"extensions":["caf"]},"audio/x-flac":{"source":"apache","extensions":["flac"]},"audio/x-m4a":{"source":"nginx","extensions":["m4a"]},"audio/x-matroska":{"source":"apache","extensions":["mka"]},"audio/x-mpegurl":{"source":"apache","extensions":["m3u"]},"audio/x-ms-wax":{"source":"apache","extensions":["wax"]},"audio/x-ms-wma":{"source":"apache","extensions":["wma"]},"audio/x-pn-realaudio":{"source":"apache","extensions":["ram","ra"]},"audio/x-pn-realaudio-plugin":{"source":"apache","extensions":["rmp"]},"audio/x-realaudio":{"source":"nginx","extensions":["ra"]},"audio/x-tta":{"source":"apache"},"audio/x-wav":{"source":"apache","extensions":["wav"]},"audio/xm":{"source":"apache","extensions":["xm"]},"chemical/x-cdx":{"source":"apache","extensions":["cdx"]},"chemical/x-cif":{"source":"apache","extensions":["cif"]},"chemical/x-cmdf":{"source":"apache","extensions":["cmdf"]},"chemical/x-cml":{"source":"apache","extensions":["cml"]},"chemical/x-csml":{"source":"apache","extensions":["csml"]},"chemical/x-pdb":{"source":"apache"},"chemical/x-xyz":{"source":"apache","extensions":["xyz"]},"font/collection":{"source":"iana","extensions":["ttc"]},"font/otf":{"source":"iana","compressible":true,"extensions":["otf"]},"font/sfnt":{"source":"iana"},"font/ttf":{"source":"iana","compressible":true,"extensions":["ttf"]},"font/woff":{"source":"iana","extensions":["woff"]},"font/woff2":{"source":"iana","extensions":["woff2"]},"image/aces":{"source":"iana","extensions":["exr"]},"image/apng":{"compressible":false,"extensions":["apng"]},"image/avci":{"source":"iana","extensions":["avci"]},"image/avcs":{"source":"iana","extensions":["avcs"]},"image/avif":{"source":"iana","compressible":false,"extensions":["avif"]},"image/bmp":{"source":"iana","compressible":true,"extensions":["bmp"]},"image/cgm":{"source":"iana","extensions":["cgm"]},"image/dicom-rle":{"source":"iana","extensions":["drle"]},"image/emf":{"source":"iana","extensions":["emf"]},"image/fits":{"source":"iana","extensions":["fits"]},"image/g3fax":{"source":"iana","extensions":["g3"]},"image/gif":{"source":"iana","compressible":false,"extensions":["gif"]},"image/heic":{"source":"iana","extensions":["heic"]},"image/heic-sequence":{"source":"iana","extensions":["heics"]},"image/heif":{"source":"iana","extensions":["heif"]},"image/heif-sequence":{"source":"iana","extensions":["heifs"]},"image/hej2k":{"source":"iana","extensions":["hej2"]},"image/hsj2":{"source":"iana","extensions":["hsj2"]},"image/ief":{"source":"iana","extensions":["ief"]},"image/jls":{"source":"iana","extensions":["jls"]},"image/jp2":{"source":"iana","compressible":false,"extensions":["jp2","jpg2"]},"image/jpeg":{"source":"iana","compressible":false,"extensions":["jpeg","jpg","jpe"]},"image/jph":{"source":"iana","extensions":["jph"]},"image/jphc":{"source":"iana","extensions":["jhc"]},"image/jpm":{"source":"iana","compressible":false,"extensions":["jpm"]},"image/jpx":{"source":"iana","compressible":false,"extensions":["jpx","jpf"]},"image/jxr":{"source":"iana","extensions":["jxr"]},"image/jxra":{"source":"iana","extensions":["jxra"]},"image/jxrs":{"source":"iana","extensions":["jxrs"]},"image/jxs":{"source":"iana","extensions":["jxs"]},"image/jxsc":{"source":"iana","extensions":["jxsc"]},"image/jxsi":{"source":"iana","extensions":["jxsi"]},"image/jxss":{"source":"iana","extensions":["jxss"]},"image/ktx":{"source":"iana","extensions":["ktx"]},"image/ktx2":{"source":"iana","extensions":["ktx2"]},"image/naplps":{"source":"iana"},"image/pjpeg":{"compressible":false},"image/png":{"source":"iana","compressible":false,"extensions":["png"]},"image/prs.btif":{"source":"iana","extensions":["btif"]},"image/prs.pti":{"source":"iana","extensions":["pti"]},"image/pwg-raster":{"source":"iana"},"image/sgi":{"source":"apache","extensions":["sgi"]},"image/svg+xml":{"source":"iana","compressible":true,"extensions":["svg","svgz"]},"image/t38":{"source":"iana","extensions":["t38"]},"image/tiff":{"source":"iana","compressible":false,"extensions":["tif","tiff"]},"image/tiff-fx":{"source":"iana","extensions":["tfx"]},"image/vnd.adobe.photoshop":{"source":"iana","compressible":true,"extensions":["psd"]},"image/vnd.airzip.accelerator.azv":{"source":"iana","extensions":["azv"]},"image/vnd.cns.inf2":{"source":"iana"},"image/vnd.dece.graphic":{"source":"iana","extensions":["uvi","uvvi","uvg","uvvg"]},"image/vnd.djvu":{"source":"iana","extensions":["djvu","djv"]},"image/vnd.dvb.subtitle":{"source":"iana","extensions":["sub"]},"image/vnd.dwg":{"source":"iana","extensions":["dwg"]},"image/vnd.dxf":{"source":"iana","extensions":["dxf"]},"image/vnd.fastbidsheet":{"source":"iana","extensions":["fbs"]},"image/vnd.fpx":{"source":"iana","extensions":["fpx"]},"image/vnd.fst":{"source":"iana","extensions":["fst"]},"image/vnd.fujixerox.edmics-mmr":{"source":"iana","extensions":["mmr"]},"image/vnd.fujixerox.edmics-rlc":{"source":"iana","extensions":["rlc"]},"image/vnd.globalgraphics.pgb":{"source":"iana"},"image/vnd.microsoft.icon":{"source":"iana","compressible":true,"extensions":["ico"]},"image/vnd.mix":{"source":"iana"},"image/vnd.mozilla.apng":{"source":"iana"},"image/vnd.ms-dds":{"compressible":true,"extensions":["dds"]},"image/vnd.ms-modi":{"source":"iana","extensions":["mdi"]},"image/vnd.ms-photo":{"source":"apache","extensions":["wdp"]},"image/vnd.net-fpx":{"source":"iana","extensions":["npx"]},"image/vnd.pco.b16":{"source":"iana","extensions":["b16"]},"image/vnd.radiance":{"source":"iana"},"image/vnd.sealed.png":{"source":"iana"},"image/vnd.sealedmedia.softseal.gif":{"source":"iana"},"image/vnd.sealedmedia.softseal.jpg":{"source":"iana"},"image/vnd.svf":{"source":"iana"},"image/vnd.tencent.tap":{"source":"iana","extensions":["tap"]},"image/vnd.valve.source.texture":{"source":"iana","extensions":["vtf"]},"image/vnd.wap.wbmp":{"source":"iana","extensions":["wbmp"]},"image/vnd.xiff":{"source":"iana","extensions":["xif"]},"image/vnd.zbrush.pcx":{"source":"iana","extensions":["pcx"]},"image/webp":{"source":"apache","extensions":["webp"]},"image/wmf":{"source":"iana","extensions":["wmf"]},"image/x-3ds":{"source":"apache","extensions":["3ds"]},"image/x-cmu-raster":{"source":"apache","extensions":["ras"]},"image/x-cmx":{"source":"apache","extensions":["cmx"]},"image/x-freehand":{"source":"apache","extensions":["fh","fhc","fh4","fh5","fh7"]},"image/x-icon":{"source":"apache","compressible":true,"extensions":["ico"]},"image/x-jng":{"source":"nginx","extensions":["jng"]},"image/x-mrsid-image":{"source":"apache","extensions":["sid"]},"image/x-ms-bmp":{"source":"nginx","compressible":true,"extensions":["bmp"]},"image/x-pcx":{"source":"apache","extensions":["pcx"]},"image/x-pict":{"source":"apache","extensions":["pic","pct"]},"image/x-portable-anymap":{"source":"apache","extensions":["pnm"]},"image/x-portable-bitmap":{"source":"apache","extensions":["pbm"]},"image/x-portable-graymap":{"source":"apache","extensions":["pgm"]},"image/x-portable-pixmap":{"source":"apache","extensions":["ppm"]},"image/x-rgb":{"source":"apache","extensions":["rgb"]},"image/x-tga":{"source":"apache","extensions":["tga"]},"image/x-xbitmap":{"source":"apache","extensions":["xbm"]},"image/x-xcf":{"compressible":false},"image/x-xpixmap":{"source":"apache","extensions":["xpm"]},"image/x-xwindowdump":{"source":"apache","extensions":["xwd"]},"message/cpim":{"source":"iana"},"message/delivery-status":{"source":"iana"},"message/disposition-notification":{"source":"iana","extensions":["disposition-notification"]},"message/external-body":{"source":"iana"},"message/feedback-report":{"source":"iana"},"message/global":{"source":"iana","extensions":["u8msg"]},"message/global-delivery-status":{"source":"iana","extensions":["u8dsn"]},"message/global-disposition-notification":{"source":"iana","extensions":["u8mdn"]},"message/global-headers":{"source":"iana","extensions":["u8hdr"]},"message/http":{"source":"iana","compressible":false},"message/imdn+xml":{"source":"iana","compressible":true},"message/news":{"source":"iana"},"message/partial":{"source":"iana","compressible":false},"message/rfc822":{"source":"iana","compressible":true,"extensions":["eml","mime"]},"message/s-http":{"source":"iana"},"message/sip":{"source":"iana"},"message/sipfrag":{"source":"iana"},"message/tracking-status":{"source":"iana"},"message/vnd.si.simp":{"source":"iana"},"message/vnd.wfa.wsc":{"source":"iana","extensions":["wsc"]},"model/3mf":{"source":"iana","extensions":["3mf"]},"model/e57":{"source":"iana"},"model/gltf+json":{"source":"iana","compressible":true,"extensions":["gltf"]},"model/gltf-binary":{"source":"iana","compressible":true,"extensions":["glb"]},"model/iges":{"source":"iana","compressible":false,"extensions":["igs","iges"]},"model/mesh":{"source":"iana","compressible":false,"extensions":["msh","mesh","silo"]},"model/mtl":{"source":"iana","extensions":["mtl"]},"model/obj":{"source":"iana","extensions":["obj"]},"model/step":{"source":"iana"},"model/step+xml":{"source":"iana","compressible":true,"extensions":["stpx"]},"model/step+zip":{"source":"iana","compressible":false,"extensions":["stpz"]},"model/step-xml+zip":{"source":"iana","compressible":false,"extensions":["stpxz"]},"model/stl":{"source":"iana","extensions":["stl"]},"model/vnd.collada+xml":{"source":"iana","compressible":true,"extensions":["dae"]},"model/vnd.dwf":{"source":"iana","extensions":["dwf"]},"model/vnd.flatland.3dml":{"source":"iana"},"model/vnd.gdl":{"source":"iana","extensions":["gdl"]},"model/vnd.gs-gdl":{"source":"apache"},"model/vnd.gs.gdl":{"source":"iana"},"model/vnd.gtw":{"source":"iana","extensions":["gtw"]},"model/vnd.moml+xml":{"source":"iana","compressible":true},"model/vnd.mts":{"source":"iana","extensions":["mts"]},"model/vnd.opengex":{"source":"iana","extensions":["ogex"]},"model/vnd.parasolid.transmit.binary":{"source":"iana","extensions":["x_b"]},"model/vnd.parasolid.transmit.text":{"source":"iana","extensions":["x_t"]},"model/vnd.pytha.pyox":{"source":"iana"},"model/vnd.rosette.annotated-data-model":{"source":"iana"},"model/vnd.sap.vds":{"source":"iana","extensions":["vds"]},"model/vnd.usdz+zip":{"source":"iana","compressible":false,"extensions":["usdz"]},"model/vnd.valve.source.compiled-map":{"source":"iana","extensions":["bsp"]},"model/vnd.vtu":{"source":"iana","extensions":["vtu"]},"model/vrml":{"source":"iana","compressible":false,"extensions":["wrl","vrml"]},"model/x3d+binary":{"source":"apache","compressible":false,"extensions":["x3db","x3dbz"]},"model/x3d+fastinfoset":{"source":"iana","extensions":["x3db"]},"model/x3d+vrml":{"source":"apache","compressible":false,"extensions":["x3dv","x3dvz"]},"model/x3d+xml":{"source":"iana","compressible":true,"extensions":["x3d","x3dz"]},"model/x3d-vrml":{"source":"iana","extensions":["x3dv"]},"multipart/alternative":{"source":"iana","compressible":false},"multipart/appledouble":{"source":"iana"},"multipart/byteranges":{"source":"iana"},"multipart/digest":{"source":"iana"},"multipart/encrypted":{"source":"iana","compressible":false},"multipart/form-data":{"source":"iana","compressible":false},"multipart/header-set":{"source":"iana"},"multipart/mixed":{"source":"iana"},"multipart/multilingual":{"source":"iana"},"multipart/parallel":{"source":"iana"},"multipart/related":{"source":"iana","compressible":false},"multipart/report":{"source":"iana"},"multipart/signed":{"source":"iana","compressible":false},"multipart/vnd.bint.med-plus":{"source":"iana"},"multipart/voice-message":{"source":"iana"},"multipart/x-mixed-replace":{"source":"iana"},"text/1d-interleaved-parityfec":{"source":"iana"},"text/cache-manifest":{"source":"iana","compressible":true,"extensions":["appcache","manifest"]},"text/calendar":{"source":"iana","extensions":["ics","ifb"]},"text/calender":{"compressible":true},"text/cmd":{"compressible":true},"text/coffeescript":{"extensions":["coffee","litcoffee"]},"text/cql":{"source":"iana"},"text/cql-expression":{"source":"iana"},"text/cql-identifier":{"source":"iana"},"text/css":{"source":"iana","charset":"UTF-8","compressible":true,"extensions":["css"]},"text/csv":{"source":"iana","compressible":true,"extensions":["csv"]},"text/csv-schema":{"source":"iana"},"text/directory":{"source":"iana"},"text/dns":{"source":"iana"},"text/ecmascript":{"source":"iana"},"text/encaprtp":{"source":"iana"},"text/enriched":{"source":"iana"},"text/fhirpath":{"source":"iana"},"text/flexfec":{"source":"iana"},"text/fwdred":{"source":"iana"},"text/gff3":{"source":"iana"},"text/grammar-ref-list":{"source":"iana"},"text/html":{"source":"iana","compressible":true,"extensions":["html","htm","shtml"]},"text/jade":{"extensions":["jade"]},"text/javascript":{"source":"iana","compressible":true},"text/jcr-cnd":{"source":"iana"},"text/jsx":{"compressible":true,"extensions":["jsx"]},"text/less":{"compressible":true,"extensions":["less"]},"text/markdown":{"source":"iana","compressible":true,"extensions":["markdown","md"]},"text/mathml":{"source":"nginx","extensions":["mml"]},"text/mdx":{"compressible":true,"extensions":["mdx"]},"text/mizar":{"source":"iana"},"text/n3":{"source":"iana","charset":"UTF-8","compressible":true,"extensions":["n3"]},"text/parameters":{"source":"iana","charset":"UTF-8"},"text/parityfec":{"source":"iana"},"text/plain":{"source":"iana","compressible":true,"extensions":["txt","text","conf","def","list","log","in","ini"]},"text/provenance-notation":{"source":"iana","charset":"UTF-8"},"text/prs.fallenstein.rst":{"source":"iana"},"text/prs.lines.tag":{"source":"iana","extensions":["dsc"]},"text/prs.prop.logic":{"source":"iana"},"text/raptorfec":{"source":"iana"},"text/red":{"source":"iana"},"text/rfc822-headers":{"source":"iana"},"text/richtext":{"source":"iana","compressible":true,"extensions":["rtx"]},"text/rtf":{"source":"iana","compressible":true,"extensions":["rtf"]},"text/rtp-enc-aescm128":{"source":"iana"},"text/rtploopback":{"source":"iana"},"text/rtx":{"source":"iana"},"text/sgml":{"source":"iana","extensions":["sgml","sgm"]},"text/shaclc":{"source":"iana"},"text/shex":{"source":"iana","extensions":["shex"]},"text/slim":{"extensions":["slim","slm"]},"text/spdx":{"source":"iana","extensions":["spdx"]},"text/strings":{"source":"iana"},"text/stylus":{"extensions":["stylus","styl"]},"text/t140":{"source":"iana"},"text/tab-separated-values":{"source":"iana","compressible":true,"extensions":["tsv"]},"text/troff":{"source":"iana","extensions":["t","tr","roff","man","me","ms"]},"text/turtle":{"source":"iana","charset":"UTF-8","extensions":["ttl"]},"text/ulpfec":{"source":"iana"},"text/uri-list":{"source":"iana","compressible":true,"extensions":["uri","uris","urls"]},"text/vcard":{"source":"iana","compressible":true,"extensions":["vcard"]},"text/vnd.a":{"source":"iana"},"text/vnd.abc":{"source":"iana"},"text/vnd.ascii-art":{"source":"iana"},"text/vnd.curl":{"source":"iana","extensions":["curl"]},"text/vnd.curl.dcurl":{"source":"apache","extensions":["dcurl"]},"text/vnd.curl.mcurl":{"source":"apache","extensions":["mcurl"]},"text/vnd.curl.scurl":{"source":"apache","extensions":["scurl"]},"text/vnd.debian.copyright":{"source":"iana","charset":"UTF-8"},"text/vnd.dmclientscript":{"source":"iana"},"text/vnd.dvb.subtitle":{"source":"iana","extensions":["sub"]},"text/vnd.esmertec.theme-descriptor":{"source":"iana","charset":"UTF-8"},"text/vnd.familysearch.gedcom":{"source":"iana","extensions":["ged"]},"text/vnd.ficlab.flt":{"source":"iana"},"text/vnd.fly":{"source":"iana","extensions":["fly"]},"text/vnd.fmi.flexstor":{"source":"iana","extensions":["flx"]},"text/vnd.gml":{"source":"iana"},"text/vnd.graphviz":{"source":"iana","extensions":["gv"]},"text/vnd.hans":{"source":"iana"},"text/vnd.hgl":{"source":"iana"},"text/vnd.in3d.3dml":{"source":"iana","extensions":["3dml"]},"text/vnd.in3d.spot":{"source":"iana","extensions":["spot"]},"text/vnd.iptc.newsml":{"source":"iana"},"text/vnd.iptc.nitf":{"source":"iana"},"text/vnd.latex-z":{"source":"iana"},"text/vnd.motorola.reflex":{"source":"iana"},"text/vnd.ms-mediapackage":{"source":"iana"},"text/vnd.net2phone.commcenter.command":{"source":"iana"},"text/vnd.radisys.msml-basic-layout":{"source":"iana"},"text/vnd.senx.warpscript":{"source":"iana"},"text/vnd.si.uricatalogue":{"source":"iana"},"text/vnd.sosi":{"source":"iana"},"text/vnd.sun.j2me.app-descriptor":{"source":"iana","charset":"UTF-8","extensions":["jad"]},"text/vnd.trolltech.linguist":{"source":"iana","charset":"UTF-8"},"text/vnd.wap.si":{"source":"iana"},"text/vnd.wap.sl":{"source":"iana"},"text/vnd.wap.wml":{"source":"iana","extensions":["wml"]},"text/vnd.wap.wmlscript":{"source":"iana","extensions":["wmls"]},"text/vtt":{"source":"iana","charset":"UTF-8","compressible":true,"extensions":["vtt"]},"text/x-asm":{"source":"apache","extensions":["s","asm"]},"text/x-c":{"source":"apache","extensions":["c","cc","cxx","cpp","h","hh","dic"]},"text/x-component":{"source":"nginx","extensions":["htc"]},"text/x-fortran":{"source":"apache","extensions":["f","for","f77","f90"]},"text/x-gwt-rpc":{"compressible":true},"text/x-handlebars-template":{"extensions":["hbs"]},"text/x-java-source":{"source":"apache","extensions":["java"]},"text/x-jquery-tmpl":{"compressible":true},"text/x-lua":{"extensions":["lua"]},"text/x-markdown":{"compressible":true,"extensions":["mkd"]},"text/x-nfo":{"source":"apache","extensions":["nfo"]},"text/x-opml":{"source":"apache","extensions":["opml"]},"text/x-org":{"compressible":true,"extensions":["org"]},"text/x-pascal":{"source":"apache","extensions":["p","pas"]},"text/x-processing":{"compressible":true,"extensions":["pde"]},"text/x-sass":{"extensions":["sass"]},"text/x-scss":{"extensions":["scss"]},"text/x-setext":{"source":"apache","extensions":["etx"]},"text/x-sfv":{"source":"apache","extensions":["sfv"]},"text/x-suse-ymp":{"compressible":true,"extensions":["ymp"]},"text/x-uuencode":{"source":"apache","extensions":["uu"]},"text/x-vcalendar":{"source":"apache","extensions":["vcs"]},"text/x-vcard":{"source":"apache","extensions":["vcf"]},"text/xml":{"source":"iana","compressible":true,"extensions":["xml"]},"text/xml-external-parsed-entity":{"source":"iana"},"text/yaml":{"compressible":true,"extensions":["yaml","yml"]},"video/1d-interleaved-parityfec":{"source":"iana"},"video/3gpp":{"source":"iana","extensions":["3gp","3gpp"]},"video/3gpp-tt":{"source":"iana"},"video/3gpp2":{"source":"iana","extensions":["3g2"]},"video/av1":{"source":"iana"},"video/bmpeg":{"source":"iana"},"video/bt656":{"source":"iana"},"video/celb":{"source":"iana"},"video/dv":{"source":"iana"},"video/encaprtp":{"source":"iana"},"video/ffv1":{"source":"iana"},"video/flexfec":{"source":"iana"},"video/h261":{"source":"iana","extensions":["h261"]},"video/h263":{"source":"iana","extensions":["h263"]},"video/h263-1998":{"source":"iana"},"video/h263-2000":{"source":"iana"},"video/h264":{"source":"iana","extensions":["h264"]},"video/h264-rcdo":{"source":"iana"},"video/h264-svc":{"source":"iana"},"video/h265":{"source":"iana"},"video/iso.segment":{"source":"iana","extensions":["m4s"]},"video/jpeg":{"source":"iana","extensions":["jpgv"]},"video/jpeg2000":{"source":"iana"},"video/jpm":{"source":"apache","extensions":["jpm","jpgm"]},"video/jxsv":{"source":"iana"},"video/mj2":{"source":"iana","extensions":["mj2","mjp2"]},"video/mp1s":{"source":"iana"},"video/mp2p":{"source":"iana"},"video/mp2t":{"source":"iana","extensions":["ts"]},"video/mp4":{"source":"iana","compressible":false,"extensions":["mp4","mp4v","mpg4"]},"video/mp4v-es":{"source":"iana"},"video/mpeg":{"source":"iana","compressible":false,"extensions":["mpeg","mpg","mpe","m1v","m2v"]},"video/mpeg4-generic":{"source":"iana"},"video/mpv":{"source":"iana"},"video/nv":{"source":"iana"},"video/ogg":{"source":"iana","compressible":false,"extensions":["ogv"]},"video/parityfec":{"source":"iana"},"video/pointer":{"source":"iana"},"video/quicktime":{"source":"iana","compressible":false,"extensions":["qt","mov"]},"video/raptorfec":{"source":"iana"},"video/raw":{"source":"iana"},"video/rtp-enc-aescm128":{"source":"iana"},"video/rtploopback":{"source":"iana"},"video/rtx":{"source":"iana"},"video/scip":{"source":"iana"},"video/smpte291":{"source":"iana"},"video/smpte292m":{"source":"iana"},"video/ulpfec":{"source":"iana"},"video/vc1":{"source":"iana"},"video/vc2":{"source":"iana"},"video/vnd.cctv":{"source":"iana"},"video/vnd.dece.hd":{"source":"iana","extensions":["uvh","uvvh"]},"video/vnd.dece.mobile":{"source":"iana","extensions":["uvm","uvvm"]},"video/vnd.dece.mp4":{"source":"iana"},"video/vnd.dece.pd":{"source":"iana","extensions":["uvp","uvvp"]},"video/vnd.dece.sd":{"source":"iana","extensions":["uvs","uvvs"]},"video/vnd.dece.video":{"source":"iana","extensions":["uvv","uvvv"]},"video/vnd.directv.mpeg":{"source":"iana"},"video/vnd.directv.mpeg-tts":{"source":"iana"},"video/vnd.dlna.mpeg-tts":{"source":"iana"},"video/vnd.dvb.file":{"source":"iana","extensions":["dvb"]},"video/vnd.fvt":{"source":"iana","extensions":["fvt"]},"video/vnd.hns.video":{"source":"iana"},"video/vnd.iptvforum.1dparityfec-1010":{"source":"iana"},"video/vnd.iptvforum.1dparityfec-2005":{"source":"iana"},"video/vnd.iptvforum.2dparityfec-1010":{"source":"iana"},"video/vnd.iptvforum.2dparityfec-2005":{"source":"iana"},"video/vnd.iptvforum.ttsavc":{"source":"iana"},"video/vnd.iptvforum.ttsmpeg2":{"source":"iana"},"video/vnd.motorola.video":{"source":"iana"},"video/vnd.motorola.videop":{"source":"iana"},"video/vnd.mpegurl":{"source":"iana","extensions":["mxu","m4u"]},"video/vnd.ms-playready.media.pyv":{"source":"iana","extensions":["pyv"]},"video/vnd.nokia.interleaved-multimedia":{"source":"iana"},"video/vnd.nokia.mp4vr":{"source":"iana"},"video/vnd.nokia.videovoip":{"source":"iana"},"video/vnd.objectvideo":{"source":"iana"},"video/vnd.radgamettools.bink":{"source":"iana"},"video/vnd.radgamettools.smacker":{"source":"iana"},"video/vnd.sealed.mpeg1":{"source":"iana"},"video/vnd.sealed.mpeg4":{"source":"iana"},"video/vnd.sealed.swf":{"source":"iana"},"video/vnd.sealedmedia.softseal.mov":{"source":"iana"},"video/vnd.uvvu.mp4":{"source":"iana","extensions":["uvu","uvvu"]},"video/vnd.vivo":{"source":"iana","extensions":["viv"]},"video/vnd.youtube.yt":{"source":"iana"},"video/vp8":{"source":"iana"},"video/vp9":{"source":"iana"},"video/webm":{"source":"apache","compressible":false,"extensions":["webm"]},"video/x-f4v":{"source":"apache","extensions":["f4v"]},"video/x-fli":{"source":"apache","extensions":["fli"]},"video/x-flv":{"source":"apache","compressible":false,"extensions":["flv"]},"video/x-m4v":{"source":"apache","extensions":["m4v"]},"video/x-matroska":{"source":"apache","compressible":false,"extensions":["mkv","mk3d","mks"]},"video/x-mng":{"source":"apache","extensions":["mng"]},"video/x-ms-asf":{"source":"apache","extensions":["asf","asx"]},"video/x-ms-vob":{"source":"apache","extensions":["vob"]},"video/x-ms-wm":{"source":"apache","extensions":["wm"]},"video/x-ms-wmv":{"source":"apache","compressible":false,"extensions":["wmv"]},"video/x-ms-wmx":{"source":"apache","extensions":["wmx"]},"video/x-ms-wvx":{"source":"apache","extensions":["wvx"]},"video/x-msvideo":{"source":"apache","extensions":["avi"]},"video/x-sgi-movie":{"source":"apache","extensions":["movie"]},"video/x-smv":{"source":"apache","extensions":["smv"]},"x-conference/x-cooltalk":{"source":"apache","extensions":["ice"]},"x-shader/x-fragment":{"compressible":true},"x-shader/x-vertex":{"compressible":true}}')},8399:function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.TypedEventEmitter=void 0;const o=n(i(4434)),r=i(1364);class s{}t.TypedEventEmitter=s,(0,r.applyMixin)(s,o.default)},8406:function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.calculateSize=t.getVideoClipName=t.attachProcessEvents=t.videoClipRegex=t.clipsToCleanup=t.cleanupMemoryThresholderInGb=t.getMainDetectionClass=t.defaultClasses=t.detectionClassIndexReversed=t.detectionClassIndex=t.pluginId=void 0;const o=i(5188),r=n(i(9896)),s=n(i(6928)),a=i(3500);t.pluginId=a.name,t.detectionClassIndex={[o.DetectionClass.Motion]:0,[o.DetectionClass.Person]:1,[o.DetectionClass.Vehicle]:2,[o.DetectionClass.Animal]:3,[o.DetectionClass.Face]:4,[o.DetectionClass.Plate]:5,[o.DetectionClass.Package]:6},t.detectionClassIndexReversed=Object.entries(t.detectionClassIndex).reduce(((e,[t,i])=>({...e,[i]:t})),{}),t.defaultClasses=[o.DetectionClass.Person,o.DetectionClass.Vehicle,o.DetectionClass.Animal,o.DetectionClass.Face,o.DetectionClass.Plate,o.DetectionClass.Package];t.getMainDetectionClass=e=>e.includes(o.DetectionClass.Face)?o.DetectionClass.Face:e.includes(o.DetectionClass.Plate)?o.DetectionClass.Plate:e.includes(o.DetectionClass.Package)?o.DetectionClass.Package:e.includes(o.DetectionClass.Person)?o.DetectionClass.Person:e.includes(o.DetectionClass.Animal)?o.DetectionClass.Animal:e.includes(o.DetectionClass.Vehicle)?o.DetectionClass.Vehicle:e.includes(o.DetectionClass.Motion)?o.DetectionClass.Motion:void 0,t.cleanupMemoryThresholderInGb=10,t.clipsToCleanup=10,t.videoClipRegex=new RegExp("(.*)_(.*)_(.*).mp4");t.attachProcessEvents=e=>{const{processName:t,childProcess:i,onClose:n,logger:o}=e;i.stdout.on("data",(e=>{o.debug(`${t} stdout: ${e.toString()}`)})),i.stderr.on("data",(e=>{o.debug(`${t} stderr: ${e.toString()}`)})),i.on("close",(async e=>{o.log(`Process ${t} closed: ${e}`),n&&n().catch(o.log)}))};t.getVideoClipName=e=>{const{startTime:i,classesDetected:n,endTime:r,logger:s}=e,a=new Array(10).fill(0);Object.entries(t.detectionClassIndex).forEach((([e,t])=>{(n.includes(e)||e===o.DetectionClass.Motion)&&(a[t]=1)}));const c=a.join(""),l=`${i}_${r}_${c}`;return s.log(`Filename calculated: ${JSON.stringify({filename:l,detectionsHashComponents:a,classesDetected:n,allClasses:Object.entries(t.detectionClassIndex),detectionsHash:c})}`),l};t.calculateSize=async e=>{const{currentPath:t,filenamePrefix:i,maxSpaceInGb:n}=e;let o=0;const a=async e=>{const t=await r.default.promises.readdir(e,{withFileTypes:!0}),n=i?t.filter((e=>e.name.includes(i))):t;for(const t of n){const i=s.default.join(e,t.name);if(t.isDirectory())await a(i);else if(t.isFile()){const e=await r.default.promises.stat(i);o+=e.size}}};await a(t),console.log(o);const c=o/1073741824,l=c.toFixed(2);return{occupiedSizeInBytes:o,occupiedSpaceInGbNumber:c,occupiedSpaceInGb:l,freeMemory:n-c}}},8416:function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.parseLog=t.getPluginConsole=t.LogLevel=t.RemoteLogServiceEnum=void 0;const o=n(i(6973)),r=i(1373),s=n(i(9278)),a=i(4434);var c,l;!function(e){e.Syslog="Syslog"}(c||(t.RemoteLogServiceEnum=c={})),function(e){e.ERROR="ERROR",e.WARN="WARN",e.NOTICE="NOTICE",e.INFO="INFO",e.DEBUG="DEBUG"}(l||(t.LogLevel=l={}));t.getPluginConsole=async e=>{const{pluginId:t,onClosed:i}=e,n=(0,r.createAsyncQueue)(),c=Buffer.from("undefined","utf8");n.enqueue(c);const l=(0,r.createAsyncQueueFromGenerator)(async function*(){for(;;){const e=n.clear();if(0===e.length){const e=await n.dequeue();e.length&&(yield e);continue}const t=Buffer.concat(e);t.length&&(yield t)}}()),p=o.default.systemManager.getDeviceByName("@scrypted/core"),u=await p.getDevice("consoleservice"),d=await o.default.connectRPCObject(u),h=await d.connectStream(l.queue,{pluginId:t}),m=await o.default.systemManager.getComponent("plugins"),f=await m.getRemoteServicePort(t,"console"),[g,v]=Array.isArray(f)?f:[f,void 0],y=s.default.connect({port:g,host:v});return await(0,a.once)(y,"connect"),y.on("close",i),{remoteGenerator:h}};t.parseLog=e=>{const t=e.replaceAll("\n",""),i=t.match(/^(\[.*\]) .*, .* - \[(.*)\]: (.*)$/);if(i){const e=i[1],t=i[2];return{severity:t,message:`[${t}]: ${e} - ${i[3]}`}}{const e=/^.*, .* - \[(.*)\]: (.*)$/,i=t.match(e);if(i){const e=i[1];return{severity:e,message:`[${e}]: ${i[2]}`}}}return{message:t,severity:l.NOTICE}}},8470:function(e,t,i){(function(){var t,n,o,r,s,a,c,l={}.hasOwnProperty;c=i(5502).isPlainObject,o=i(3725),n=i(2421),r=i(8711),t=i(5068),a=i(529),s=i(661),e.exports=function(e){function i(e){i.__super__.constructor.call(this,null),this.name="#document",this.type=t.Document,this.documentURI=null,this.domConfig=new n,e||(e={}),e.writer||(e.writer=new s),this.options=e,this.stringify=new a(e)}return function(e,t){for(var i in t)l.call(t,i)&&(e[i]=t[i]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(i,e),Object.defineProperty(i.prototype,"implementation",{value:new o}),Object.defineProperty(i.prototype,"doctype",{get:function(){var e,i,n,o;for(i=0,n=(o=this.children).length;i<n;i++)if((e=o[i]).type===t.DocType)return e;return null}}),Object.defineProperty(i.prototype,"documentElement",{get:function(){return this.rootObject||null}}),Object.defineProperty(i.prototype,"inputEncoding",{get:function(){return null}}),Object.defineProperty(i.prototype,"strictErrorChecking",{get:function(){return!1}}),Object.defineProperty(i.prototype,"xmlEncoding",{get:function(){return 0!==this.children.length&&this.children[0].type===t.Declaration?this.children[0].encoding:null}}),Object.defineProperty(i.prototype,"xmlStandalone",{get:function(){return 0!==this.children.length&&this.children[0].type===t.Declaration&&"yes"===this.children[0].standalone}}),Object.defineProperty(i.prototype,"xmlVersion",{get:function(){return 0!==this.children.length&&this.children[0].type===t.Declaration?this.children[0].version:"1.0"}}),Object.defineProperty(i.prototype,"URL",{get:function(){return this.documentURI}}),Object.defineProperty(i.prototype,"origin",{get:function(){return null}}),Object.defineProperty(i.prototype,"compatMode",{get:function(){return null}}),Object.defineProperty(i.prototype,"characterSet",{get:function(){return null}}),Object.defineProperty(i.prototype,"contentType",{get:function(){return null}}),i.prototype.end=function(e){var t;return t={},e?c(e)&&(t=e,e=this.options.writer):e=this.options.writer,e.document(this,e.filterOptions(t))},i.prototype.toString=function(e){return this.options.writer.document(this,this.options.writer.filterOptions(e))},i.prototype.createElement=function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.createDocumentFragment=function(){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.createTextNode=function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.createComment=function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.createCDATASection=function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.createProcessingInstruction=function(e,t){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.createAttribute=function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.createEntityReference=function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.getElementsByTagName=function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.importNode=function(e,t){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.createElementNS=function(e,t){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.createAttributeNS=function(e,t){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.getElementsByTagNameNS=function(e,t){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.getElementById=function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.adoptNode=function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.normalizeDocument=function(){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.renameNode=function(e,t,i){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.getElementsByClassName=function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.createEvent=function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.createRange=function(){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.createNodeIterator=function(e,t,i){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.createTreeWalker=function(e,t,i){throw new Error("This DOM method is not implemented."+this.debugInfo())},i}(r)}).call(this)},8539:(e,t,i)=>{e.exports=function(e){const t=i(4081).linerase,n=i(4081).parseSOAPString,o=["ECONNREFUSED","ECONNRESET","ETIMEDOUT","ENETUNREACH"];function r(e){return new Date(Date.now()-e.currentTime.getTime()+e.terminationTime.getTime())}e.prototype.getEventProperties=function(e){this._request({service:"events",body:this._envelopeHeader()+'<GetEventProperties xmlns="http://www.onvif.org/ver10/events/wsdl"/>'+this._envelopeFooter()},function(i,n,o){i||(this.events.properties=t(n).getEventPropertiesResponse),e.call(this,i,i?null:this.events.properties,o)}.bind(this))},e.prototype.getEventServiceCapabilities=function(e){this._request({service:"events",body:this._envelopeHeader()+'<GetServiceCapabilities xmlns="http://www.onvif.org/ver10/events/wsdl"/>'+this._envelopeFooter()},function(i,n,o){if(!i)var r=t(n[0].getServiceCapabilitiesResponse[0].capabilities[0].$);e.call(this,i,r,o)}.bind(this))},e.prototype.subscribe=function(e,i){let n=this._envelopeHeader(!0);n+="<a:ReplyTo><a:Address>"+e.url+"</a:Address></a:ReplyTo>",n+='</s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Subscribe xmlns="http://docs.oasis-open.org/wsn/b-2"><ConsumerReference><a:Address>'+e.url+"</a:Address></ConsumerReference><InitialTerminationTime>PT2M</InitialTerminationTime></Subscribe>"+this._envelopeFooter(),this._request({service:"events",body:n},function(e,n,o){e||(this.events.subscription=t(n[0].subscribeResponse[0]),this.events.subscription.subscriptionReference.address=this._parseUrl(this.events.subscription.subscriptionReference.address),this.events.terminationTime=r(this.events.subscription)),i.call(this,e,e?null:this.events.subscription,o)}.bind(this))},e.prototype.createPullPointSubscription=function(e){this._request({service:"events",body:this._envelopeHeader()+'<CreatePullPointSubscription xmlns="http://www.onvif.org/ver10/events/wsdl"><InitialTerminationTime>PT2M</InitialTerminationTime></CreatePullPointSubscription>'+this._envelopeFooter()},function(i,n,o){i||(this.events.subscription=t(n[0].createPullPointSubscriptionResponse[0]),this.events.subscription.subscriptionReference.address=this._parseUrl(this.events.subscription.subscriptionReference.address),this.events.terminationTime=r(this.events.subscription)),e.call(this,i,i?null:this.events.subscription,o)}.bind(this))},e.prototype.renew=function(e,i){i||(i=e);let n=null,o=null;try{n=this.events.subscription.subscriptionReference.address}catch(e){return void(i&&i.call&&i.call(this,new Error("You should create pull-point subscription first!")))}try{o=this.events.subscription.subscriptionReference.referenceParameters.subscriptionId}catch(e){o=null}let r=this._envelopeHeader(!0);r+=o?'<a:To mustUnderstand="1">'+n.href+'</a:To><SubscriptionId xmlns="http://www.axis.com/2009/event" a:IsReferenceParameter="true">'+this.events.subscription.subscriptionReference.referenceParameters.subscriptionId+"</SubscriptionId>":"<a:To>"+n.href+"</a:To>",r+='</s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Renew xmlns="http://docs.oasis-open.org/wsn/b-2"><TerminationTime>PT2M</TerminationTime></Renew>'+this._envelopeFooter(),this._request({url:n,body:r},function(e,n,o){if(!e)var r=t(n).renewResponse;i.call(this,e,r,o)}.bind(this))},e.prototype.pullMessages=function(e,i){let n=null,o=null;try{n=this.events.subscription.subscriptionReference.address}catch(e){if(!i||!i.call)throw new Error("You should create pull-point subscription first!");return void i.call(this,new Error("You should create pull-point subscription first!"))}try{o=this.events.subscription.subscriptionReference.referenceParameters.subscriptionId}catch(e){o=null}let r=this._envelopeHeader(!0);r+=o?'<a:To mustUnderstand="1">'+n.href+'</a:To><SubscriptionId xmlns="http://www.axis.com/2009/event" a:IsReferenceParameter="true">'+o+"</SubscriptionId>":"<a:To>"+n.href+"</a:To>",r+='</s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><PullMessages xmlns="http://www.onvif.org/ver10/events/wsdl"><Timeout>PT1M</Timeout><MessageLimit>'+(e.messageLimit||10)+"</MessageLimit></PullMessages>"+this._envelopeFooter(),this._request({url:n,body:r,replyTimeout:8e4},function(e,n,o){if(!e)var r=t(n).pullMessagesResponse;i.call(this,e,r,o)}.bind(this))},e.prototype.unsubscribe=function(e,i){let n=null,o=null;try{n=this.events.subscription.subscriptionReference.address}catch(t){return void(e&&e.call&&e.call(this,new Error("You should create pull-point subscription first!")))}try{o=this.events.subscription.subscriptionReference.referenceParameters.subscriptionId}catch(e){o=null}delete this.events.subscription,delete this.events.terminationTime;let r=this._envelopeHeader(!0);r+=o?'<a:To mustUnderstand="1">'+n.href+'</a:To><SubscriptionId xmlns="http://www.axis.com/2009/event" a:IsReferenceParameter="true">'+o+"</SubscriptionId>":"<a:To>"+n.href+"</a:To>",r+='</s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Unsubscribe xmlns="http://docs.oasis-open.org/wsn/b-2"/>'+this._envelopeFooter(),this._request({url:n,body:r},function(n,o,r){if(!n){i||this.removeAllListeners("event");var s=t(o).unsubscribeResponse}e&&e.call&&e.call(this,n,s,r)}.bind(this))},e.prototype._eventRequest=function(){this.listeners("event").length?(this.events.messageLimit=this.events.messageLimit||10,!this.events.subscription||!this.events.terminationTime||Date.now()>this.events.terminationTime?this.createPullPointSubscription(function(e){e?(this.emit("eventsError",e),"object"==typeof e&&o.includes(e.code)&&this._restartEventRequest()):(delete this._eventReconnectms,this._eventPull())}.bind(this)):this._eventPull()):(delete this.events.terminationTime,this.unsubscribe())},e.prototype._eventPull=function(){this.listeners("event").length&&this.events.subscription?this.pullMessages({messageLimit:this.events.messageLimit},function(e,t,i){e?(this.emit("eventsError",e),"object"==typeof e&&o.includes(e.code)?this._restartEventRequest():this.unsubscribe((function(e,t,i){this._eventRequest()}),!0)):(delete this._eventReconnectms,t.notificationMessage&&(Array.isArray(t.notificationMessage)||(t.notificationMessage=[t.notificationMessage]),t.notificationMessage.forEach(function(e){this.emit("event",e,i)}.bind(this))),this.events.terminationTime=r(t),this.renew({},(function(e,t){e||(this.events.terminationTime=r(t)),this._eventRequest()})))}.bind(this)):(delete this.events.terminationTime,this.events.subscription&&this.unsubscribe())},e.prototype._restartEventRequest=function(){this._eventReconnectms||(this._eventReconnectms=10),setTimeout(this._eventRequest.bind(this),this._eventReconnectms),this._eventReconnectms<12e4&&(this._eventReconnectms=1.111*this._eventReconnectms)},e.prototype.parseEventXML=function(e,i){n(e,(function(e,n,o,r){let s=t(n).notify.notificationMessage;i(e,s)}),0)}}},8573:(e,t,i)=>{"use strict";const{Duplex:n}=i(2203),{randomFillSync:o}=i(6982),r=i(9064),{EMPTY_BUFFER:s,kWebSocket:a,NOOP:c}=i(6639),{isBlob:l,isValidStatusCode:p}=i(3271),{mask:u,toBuffer:d}=i(6667),h=Symbol("kByteLength"),m=Buffer.alloc(4),f=8192;let g,v=f;class y{constructor(e,t,i){this._extensions=t||{},i&&(this._generateMask=i,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=0,this.onerror=c,this[a]=void 0}static frame(e,t){let i,n,r=!1,s=2,a=!1;t.mask&&(i=t.maskBuffer||m,t.generateMask?t.generateMask(i):(v===f&&(void 0===g&&(g=Buffer.alloc(f)),o(g,0,f),v=0),i[0]=g[v++],i[1]=g[v++],i[2]=g[v++],i[3]=g[v++]),a=0===(i[0]|i[1]|i[2]|i[3]),s=6),"string"==typeof e?n=t.mask&&!a||void 0===t[h]?(e=Buffer.from(e)).length:t[h]:(n=e.length,r=t.mask&&t.readOnly&&!a);let c=n;n>=65536?(s+=8,c=127):n>125&&(s+=2,c=126);const l=Buffer.allocUnsafe(r?n+s:s);return l[0]=t.fin?128|t.opcode:t.opcode,t.rsv1&&(l[0]|=64),l[1]=c,126===c?l.writeUInt16BE(n,2):127===c&&(l[2]=l[3]=0,l.writeUIntBE(n,4,6)),t.mask?(l[1]|=128,l[s-4]=i[0],l[s-3]=i[1],l[s-2]=i[2],l[s-1]=i[3],a?[l,e]:r?(u(e,i,l,s,n),[l]):(u(e,i,e,0,n),[l,e])):[l,e]}close(e,t,i,n){let o;if(void 0===e)o=s;else{if("number"!=typeof e||!p(e))throw new TypeError("First argument must be a valid error code number");if(void 0!==t&&t.length){const i=Buffer.byteLength(t);if(i>123)throw new RangeError("The message must not be greater than 123 bytes");o=Buffer.allocUnsafe(2+i),o.writeUInt16BE(e,0),"string"==typeof t?o.write(t,2):o.set(t,2)}else o=Buffer.allocUnsafe(2),o.writeUInt16BE(e,0)}const r={[h]:o.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};0!==this._state?this.enqueue([this.dispatch,o,!1,r,n]):this.sendFrame(y.frame(o,r),n)}ping(e,t,i){let n,o;if("string"==typeof e?(n=Buffer.byteLength(e),o=!1):l(e)?(n=e.size,o=!1):(n=(e=d(e)).length,o=d.readOnly),n>125)throw new RangeError("The data size must not be greater than 125 bytes");const r={[h]:n,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:o,rsv1:!1};l(e)?0!==this._state?this.enqueue([this.getBlobData,e,!1,r,i]):this.getBlobData(e,!1,r,i):0!==this._state?this.enqueue([this.dispatch,e,!1,r,i]):this.sendFrame(y.frame(e,r),i)}pong(e,t,i){let n,o;if("string"==typeof e?(n=Buffer.byteLength(e),o=!1):l(e)?(n=e.size,o=!1):(n=(e=d(e)).length,o=d.readOnly),n>125)throw new RangeError("The data size must not be greater than 125 bytes");const r={[h]:n,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:o,rsv1:!1};l(e)?0!==this._state?this.enqueue([this.getBlobData,e,!1,r,i]):this.getBlobData(e,!1,r,i):0!==this._state?this.enqueue([this.dispatch,e,!1,r,i]):this.sendFrame(y.frame(e,r),i)}send(e,t,i){const n=this._extensions[r.extensionName];let o,s,a=t.binary?2:1,c=t.compress;"string"==typeof e?(o=Buffer.byteLength(e),s=!1):l(e)?(o=e.size,s=!1):(o=(e=d(e)).length,s=d.readOnly),this._firstFragment?(this._firstFragment=!1,c&&n&&n.params[n._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(c=o>=n._threshold),this._compress=c):(c=!1,a=0),t.fin&&(this._firstFragment=!0);const p={[h]:o,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:a,readOnly:s,rsv1:c};l(e)?0!==this._state?this.enqueue([this.getBlobData,e,this._compress,p,i]):this.getBlobData(e,this._compress,p,i):0!==this._state?this.enqueue([this.dispatch,e,this._compress,p,i]):this.dispatch(e,this._compress,p,i)}getBlobData(e,t,i,n){this._bufferedBytes+=i[h],this._state=2,e.arrayBuffer().then((e=>{if(this._socket.destroyed){const e=new Error("The socket was closed while the blob was being read");return void process.nextTick(b,this,e,n)}this._bufferedBytes-=i[h];const o=d(e);t?this.dispatch(o,t,i,n):(this._state=0,this.sendFrame(y.frame(o,i),n),this.dequeue())})).catch((e=>{process.nextTick(w,this,e,n)}))}dispatch(e,t,i,n){if(!t)return void this.sendFrame(y.frame(e,i),n);const o=this._extensions[r.extensionName];this._bufferedBytes+=i[h],this._state=1,o.compress(e,i.fin,((e,t)=>{if(this._socket.destroyed){b(this,new Error("The socket was closed while data was being compressed"),n)}else this._bufferedBytes-=i[h],this._state=0,i.readOnly=!1,this.sendFrame(y.frame(t,i),n),this.dequeue()}))}dequeue(){for(;0===this._state&&this._queue.length;){const e=this._queue.shift();this._bufferedBytes-=e[3][h],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][h],this._queue.push(e)}sendFrame(e,t){2===e.length?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}}function b(e,t,i){"function"==typeof i&&i(t);for(let i=0;i<e._queue.length;i++){const n=e._queue[i],o=n[n.length-1];"function"==typeof o&&o(t)}}function w(e,t,i){b(e,t,i),e.onerror(t)}e.exports=y},8611:e=>{"use strict";e.exports=require("http")},8705:function(e,t,i){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[t.length]=i);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i=n(e),s=0;s<i.length;s++)"default"!==i[s]&&o(t,e,i[s]);return r(t,e),t}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.BasePlugin=t.getMqttBasicClient=t.getBaseSettings=t.logLevelSetting=t.getBaseLogger=t.applySettingsShow=void 0;const c=s(i(1687)),l=a(i(6578)),p=a(i(5692)),u=a(i(2833)),d=i(8416),{systemManager:h}=c.default,m=new p.default.Agent({rejectUnauthorized:!1});t.applySettingsShow=e=>{!!h.getDeviceByName("MQTT")||(e.settings.useMqttPluginCredentials.defaultValue=!1,e.putSetting("useMqttPluginCredentials",!1));const{mqttEnabled:t,useMqttPluginCredentials:i,haEnabled:n,useHaPluginCredentials:o}=e.values,{haEnabled:r,mqttEnabled:s}=e.settings;s?.hide||!t?(e.settings.mqttHost&&(e.settings.mqttHost.hide=!0),e.settings.mqttPassword&&(e.settings.mqttPassword.hide=!0),e.settings.mqttUsename&&(e.settings.mqttUsename.hide=!0),e.settings.useMqttPluginCredentials&&(e.settings.useMqttPluginCredentials.hide=!0)):(e.settings.mqttHost.hide=i,e.settings.mqttPassword.hide=i,e.settings.mqttUsename.hide=i,e.settings.useMqttPluginCredentials.hide=!1),r?.hide||!n?(e.settings.haAccessToken&&(e.settings.haAccessToken.hide=!0),e.settings.haProtocol&&(e.settings.haProtocol.hide=!0),e.settings.haAddress&&(e.settings.haAddress.hide=!0),e.settings.useHaPluginCredentials&&(e.settings.useHaPluginCredentials.hide=!0)):(e.settings.haAccessToken.hide=o,e.settings.haProtocol.hide=o,e.settings.haAddress.hide=o,e.settings.useHaPluginCredentials.hide=!1)};t.getBaseLogger=e=>{const{console:t,storage:i,friendlyName:n}=e,o=(e,o,...r)=>{const s=(new Date).toLocaleString(),a=i.getItem("logLevel"),c=a===d.LogLevel.DEBUG,l=c||a===d.LogLevel.INFO;let p=!1,u=d.LogLevel.NOTICE;"debug"===e?(p=c,u=d.LogLevel.DEBUG):"info"===e?(u=d.LogLevel.INFO,p=l):(p=!0,"error"===e?u=d.LogLevel.ERROR:"warn"===e&&(u=d.LogLevel.WARN)),p&&t.log(`${s} - [${u}]:`,o,...r),"error"===e&&i.values.devNotifier&&i.values.devNotifier.sendNotification(n,{body:`${o}${r?.map((e=>"\n"+e))}`,data:{pushover:{priority:1}}})};return{log:(e,...t)=>o("log",e,...t),info:(e,...t)=>o("info",e,...t),debug:(e,...t)=>o("debug",e,...t),error:(e,...t)=>o("error",e,...t),warn:(e,...t)=>o("warn",e,...t)}},t.logLevelSetting={title:"Log level",type:"string",defaultValue:d.LogLevel.NOTICE,immediate:!0,choices:[d.LogLevel.NOTICE,d.LogLevel.INFO,d.LogLevel.DEBUG]};t.getBaseSettings=e=>{const{onPluginSwitch:i,hideMqtt:n,mqttAlwaysEnabled:o,hideHa:r=!0,baseGroupName:s="Base"}=e,a=""===s?void 0:s;return{pluginEnabled:{title:"Plugin enabled",type:"boolean",defaultValue:!0,immediate:!0,group:a,onPut:i},logLevel:{...t.logLevelSetting,group:a},mqttEnabled:{title:"MQTT enabled",type:"boolean",defaultValue:!1,immediate:!0,group:a,hide:n,readonly:o},devNotifier:{title:"DEV notifier",type:"device",deviceFilter:`(type === '${c.ScryptedDeviceType.Notifier}')`,group:a,subgroup:"Advanced"},useMqttPluginCredentials:{title:"Use MQTT plugin credentials",subgroup:"MQTT",type:"boolean",immediate:!0,group:a,defaultValue:!0,hide:n},mqttHost:{title:"Host",subgroup:"MQTT",description:"Specify the mqtt address.",placeholder:"mqtt://192.168.1.100",group:a,hide:n},mqttUsename:{title:"Username",subgroup:"MQTT",description:"Specify the mqtt username.",group:a,hide:n},mqttPassword:{title:"Password",subgroup:"MQTT",description:"Specify the mqtt password.",type:"password",group:a,hide:n},haEnabled:{title:"Homeassistent enabled",type:"boolean",defaultValue:!1,immediate:!0,hide:r,group:a},useHaPluginCredentials:{group:a,subgroup:"Homeassistant",title:"Use HA plugin credentials",type:"boolean",defaultValue:!0,immediate:!0,hide:r},haAccessToken:{group:a,subgroup:"Homeassistant",title:"HAPersonal access token",type:"string",hide:r},haProtocol:{group:a,subgroup:"Homeassistant",title:"Protocol",type:"string",choices:["http","https"],defaultValue:["http"],hide:r},haAddress:{group:a,subgroup:"Homeassistant",title:"Address",placeholder:"https://192.168.1.1",type:"string",hide:r}}};t.getMqttBasicClient=async e=>{const{useMqttPluginCredentials:t,logger:i,clientId:n,configTopicPattern:o}=e;try{let r,s,a,c;if(t){i.debug("Using MQTT plugin credentials.");const e=h.getDeviceByName("MQTT");if(!e)return void i.log("MQTT plugin not installed, please provide the connection information manually");const t=await e.getSettings();JSON.parse(t.find((e=>"enableBroker"===e.key))?.value||"false")?i.debug("Internal MQTT broker not supported yet. Please disable useMqttPluginCredentials."):(r=t.find((e=>"externalBroker"===e.key))?.value,s=t.find((e=>"username"===e.key))?.value,a=t.find((e=>"password"===e.key))?.value)}else i.debug("Using provided credentials."),r=e.mqttHost,s=e.mqttUsename,a=e.mqttPassword;return r&&s&&a?(c=new u.default(r,s,a,i,n,o),c):(i.error(`MQTT params not provided: ${JSON.stringify({mqttHost:r,mqttUsename:s?"SET":"NOT_SET",mqttPassword:a?"SET":"NOT_SET"})}`),null)}catch(e){return i.error("Error in getMqttBasicClient",e),null}};class f extends c.ScryptedDeviceBase{constructor(e,t){super(e),this.opts=t,this.initializingMqtt=!1,this.getHaApiUrl=async()=>{const{haAccessToken:e,haAddress:t,haProtocol:i,useHaPluginCredentials:n}=this.storageSettings.values;let o=e,r=i,s=t;if(n){const e=h.getDeviceByName("Home Assistant"),t=await e.getSettings();o=t.find((e=>"personalAccessToken"===e.key))?.value,s=t.find((e=>"address"===e.key))?.value,r=t.find((e=>"protocol"===e.key))?.value}if(!o||!s||!r)throw new Error(`HA access params not set correctly: AccessToken: ${o}, Address: ${s}, Protocol: ${r}`);return{accessToken:o,address:s,protocol:r,url:`${r}://${s}`}}}async getSettings(){(0,t.applySettingsShow)(this.storageSettings);return await this.storageSettings.getSettings()}async getHaApi(){const{accessToken:e,url:t}=await this.getHaApiUrl();return{getTemplateData:i=>l.default.post(`${t}/api/template`,{template:i},{headers:{Authorization:"Bearer "+e},httpsAgent:m}),getStatesData:()=>l.default.get(`${t}/api/states`,{headers:{Authorization:"Bearer "+e},httpsAgent:m}),getCalendarEvents:(i,n,o)=>l.default.post(`${t}/api/services/calendar/get_events?return_response`,{start_date_time:n,end_date_time:o,entity_id:i},{headers:{Authorization:"Bearer "+e},httpsAgent:m}),postAutomation:(i,n)=>l.default.post(`${t}/api/config/automation/config/${i}`,n,{headers:{Authorization:"Bearer "+e},httpsAgent:m})}}putSetting(e,t){return this.storageSettings.putSetting(e,t)}async setupMqttClient(e){const{mqttEnabled:i,useMqttPluginCredentials:n,pluginEnabled:o}=this.storageSettings.values;if(i&&o){this.initializingMqtt=!0;const i=this.getLoggerInternal({});this.mqttClient&&(this.mqttClient.disconnect(),this.mqttClient=void 0);try{this.mqttClient=await(0,t.getMqttBasicClient)({logger:i,useMqttPluginCredentials:n,mqttHost:this.storageSettings.getItem("mqttHost"),mqttUsename:this.storageSettings.getItem("mqttUsename"),mqttPassword:this.storageSettings.getItem("mqttPassword"),clientId:e})}catch(e){i.log("Error setting up MQTT client",e)}finally{this.initializingMqtt=!1}}}async getMqttClient(e){return this.mqttClient||this.initializingMqtt||await this.setupMqttClient(e),this.mqttClient}getLoggerInternal(e){const{console:i,storage:n,friendlyName:o}=e;return i?(0,t.getBaseLogger)({console:i,storage:n,friendlyName:o}):(this.mainLogger||(this.mainLogger=(0,t.getBaseLogger)({console:this.console,storage:this.storageSettings,friendlyName:this.opts.pluginFriendlyName})),this.mainLogger)}}t.BasePlugin=f},8711:function(e,t,i){(function(){var t,n,o,r,s,a,c,l,p,u,d,h,m,f,g,v,y,b={}.hasOwnProperty;y=i(5502),v=y.isObject,g=y.isFunction,f=y.isEmpty,m=y.getValue,l=null,o=null,r=null,s=null,a=null,d=null,h=null,u=null,c=null,n=null,p=null,t=null,e.exports=function(){function e(e){this.parent=e,this.parent&&(this.options=this.parent.options,this.stringify=this.parent.stringify),this.value=null,this.children=[],this.baseURI=null,l||(l=i(6859),o=i(5670),r=i(9226),s=i(9983),a=i(2189),d=i(4565),h=i(9256),u=i(838),c=i(871),n=i(5068),p=i(111),i(6838),t=i(1510))}return Object.defineProperty(e.prototype,"nodeName",{get:function(){return this.name}}),Object.defineProperty(e.prototype,"nodeType",{get:function(){return this.type}}),Object.defineProperty(e.prototype,"nodeValue",{get:function(){return this.value}}),Object.defineProperty(e.prototype,"parentNode",{get:function(){return this.parent}}),Object.defineProperty(e.prototype,"childNodes",{get:function(){return this.childNodeList&&this.childNodeList.nodes||(this.childNodeList=new p(this.children)),this.childNodeList}}),Object.defineProperty(e.prototype,"firstChild",{get:function(){return this.children[0]||null}}),Object.defineProperty(e.prototype,"lastChild",{get:function(){return this.children[this.children.length-1]||null}}),Object.defineProperty(e.prototype,"previousSibling",{get:function(){var e;return e=this.parent.children.indexOf(this),this.parent.children[e-1]||null}}),Object.defineProperty(e.prototype,"nextSibling",{get:function(){var e;return e=this.parent.children.indexOf(this),this.parent.children[e+1]||null}}),Object.defineProperty(e.prototype,"ownerDocument",{get:function(){return this.document()||null}}),Object.defineProperty(e.prototype,"textContent",{get:function(){var e,t,i,o,r;if(this.nodeType===n.Element||this.nodeType===n.DocumentFragment){for(r="",t=0,i=(o=this.children).length;t<i;t++)(e=o[t]).textContent&&(r+=e.textContent);return r}return null},set:function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),e.prototype.setParent=function(e){var t,i,n,o,r;for(this.parent=e,e&&(this.options=e.options,this.stringify=e.stringify),r=[],i=0,n=(o=this.children).length;i<n;i++)t=o[i],r.push(t.setParent(this));return r},e.prototype.element=function(e,t,i){var n,o,r,s,a,c,l,p,u,d,h;if(c=null,null===t&&null==i&&(t=(u=[{},null])[0],i=u[1]),null==t&&(t={}),t=m(t),v(t)||(i=(d=[t,i])[0],t=d[1]),null!=e&&(e=m(e)),Array.isArray(e))for(r=0,l=e.length;r<l;r++)o=e[r],c=this.element(o);else if(g(e))c=this.element(e.apply());else if(v(e)){for(a in e)if(b.call(e,a))if(h=e[a],g(h)&&(h=h.apply()),!this.options.ignoreDecorators&&this.stringify.convertAttKey&&0===a.indexOf(this.stringify.convertAttKey))c=this.attribute(a.substr(this.stringify.convertAttKey.length),h);else if(!this.options.separateArrayItems&&Array.isArray(h)&&f(h))c=this.dummy();else if(v(h)&&f(h))c=this.element(a);else if(this.options.keepNullNodes||null!=h)if(!this.options.separateArrayItems&&Array.isArray(h))for(s=0,p=h.length;s<p;s++)o=h[s],(n={})[a]=o,c=this.element(n);else v(h)?!this.options.ignoreDecorators&&this.stringify.convertTextKey&&0===a.indexOf(this.stringify.convertTextKey)?c=this.element(h):(c=this.element(a)).element(h):c=this.element(a,h);else c=this.dummy()}else c=this.options.keepNullNodes||null!==i?!this.options.ignoreDecorators&&this.stringify.convertTextKey&&0===e.indexOf(this.stringify.convertTextKey)?this.text(i):!this.options.ignoreDecorators&&this.stringify.convertCDataKey&&0===e.indexOf(this.stringify.convertCDataKey)?this.cdata(i):!this.options.ignoreDecorators&&this.stringify.convertCommentKey&&0===e.indexOf(this.stringify.convertCommentKey)?this.comment(i):!this.options.ignoreDecorators&&this.stringify.convertRawKey&&0===e.indexOf(this.stringify.convertRawKey)?this.raw(i):!this.options.ignoreDecorators&&this.stringify.convertPIKey&&0===e.indexOf(this.stringify.convertPIKey)?this.instruction(e.substr(this.stringify.convertPIKey.length),i):this.node(e,t,i):this.dummy();if(null==c)throw new Error("Could not create any elements with: "+e+". "+this.debugInfo());return c},e.prototype.insertBefore=function(e,t,i){var n,o,r,s,a;if(null!=e?e.type:void 0)return s=t,(r=e).setParent(this),s?(o=children.indexOf(s),a=children.splice(o),children.push(r),Array.prototype.push.apply(children,a)):children.push(r),r;if(this.isRoot)throw new Error("Cannot insert elements at root level. "+this.debugInfo(e));return o=this.parent.children.indexOf(this),a=this.parent.children.splice(o),n=this.parent.element(e,t,i),Array.prototype.push.apply(this.parent.children,a),n},e.prototype.insertAfter=function(e,t,i){var n,o,r;if(this.isRoot)throw new Error("Cannot insert elements at root level. "+this.debugInfo(e));return o=this.parent.children.indexOf(this),r=this.parent.children.splice(o+1),n=this.parent.element(e,t,i),Array.prototype.push.apply(this.parent.children,r),n},e.prototype.remove=function(){var e;if(this.isRoot)throw new Error("Cannot remove the root element. "+this.debugInfo());return e=this.parent.children.indexOf(this),[].splice.apply(this.parent.children,[e,e-e+1].concat([])),this.parent},e.prototype.node=function(e,t,i){var n,o;return null!=e&&(e=m(e)),t||(t={}),t=m(t),v(t)||(i=(o=[t,i])[0],t=o[1]),n=new l(this,e,t),null!=i&&n.text(i),this.children.push(n),n},e.prototype.text=function(e){var t;return v(e)&&this.element(e),t=new h(this,e),this.children.push(t),this},e.prototype.cdata=function(e){var t;return t=new o(this,e),this.children.push(t),this},e.prototype.comment=function(e){var t;return t=new r(this,e),this.children.push(t),this},e.prototype.commentBefore=function(e){var t,i;return t=this.parent.children.indexOf(this),i=this.parent.children.splice(t),this.parent.comment(e),Array.prototype.push.apply(this.parent.children,i),this},e.prototype.commentAfter=function(e){var t,i;return t=this.parent.children.indexOf(this),i=this.parent.children.splice(t+1),this.parent.comment(e),Array.prototype.push.apply(this.parent.children,i),this},e.prototype.raw=function(e){var t;return t=new d(this,e),this.children.push(t),this},e.prototype.dummy=function(){return new c(this)},e.prototype.instruction=function(e,t){var i,n,o,r,s;if(null!=e&&(e=m(e)),null!=t&&(t=m(t)),Array.isArray(e))for(r=0,s=e.length;r<s;r++)i=e[r],this.instruction(i);else if(v(e))for(i in e)b.call(e,i)&&(n=e[i],this.instruction(i,n));else g(t)&&(t=t.apply()),o=new u(this,e,t),this.children.push(o);return this},e.prototype.instructionBefore=function(e,t){var i,n;return i=this.parent.children.indexOf(this),n=this.parent.children.splice(i),this.parent.instruction(e,t),Array.prototype.push.apply(this.parent.children,n),this},e.prototype.instructionAfter=function(e,t){var i,n;return i=this.parent.children.indexOf(this),n=this.parent.children.splice(i+1),this.parent.instruction(e,t),Array.prototype.push.apply(this.parent.children,n),this},e.prototype.declaration=function(e,t,i){var o,r;return o=this.document(),r=new s(o,e,t,i),0===o.children.length?o.children.unshift(r):o.children[0].type===n.Declaration?o.children[0]=r:o.children.unshift(r),o.root()||o},e.prototype.dtd=function(e,t){var i,o,r,s,c,l,p,u,d;for(i=this.document(),o=new a(i,e,t),r=s=0,l=(u=i.children).length;s<l;r=++s)if(u[r].type===n.DocType)return i.children[r]=o,o;for(r=c=0,p=(d=i.children).length;c<p;r=++c)if(d[r].isRoot)return i.children.splice(r,0,o),o;return i.children.push(o),o},e.prototype.up=function(){if(this.isRoot)throw new Error("The root node has no parent. Use doc() if you need to get the document object.");return this.parent},e.prototype.root=function(){var e;for(e=this;e;){if(e.type===n.Document)return e.rootObject;if(e.isRoot)return e;e=e.parent}},e.prototype.document=function(){var e;for(e=this;e;){if(e.type===n.Document)return e;e=e.parent}},e.prototype.end=function(e){return this.document().end(e)},e.prototype.prev=function(){var e;if((e=this.parent.children.indexOf(this))<1)throw new Error("Already at the first node. "+this.debugInfo());return this.parent.children[e-1]},e.prototype.next=function(){var e;if(-1===(e=this.parent.children.indexOf(this))||e===this.parent.children.length-1)throw new Error("Already at the last node. "+this.debugInfo());return this.parent.children[e+1]},e.prototype.importDocument=function(e){var t;return(t=e.root().clone()).parent=this,t.isRoot=!1,this.children.push(t),this},e.prototype.debugInfo=function(e){var t,i;return null!=(e=e||this.name)||(null!=(t=this.parent)?t.name:void 0)?null==e?"parent: <"+this.parent.name+">":(null!=(i=this.parent)?i.name:void 0)?"node: <"+e+">, parent: <"+this.parent.name+">":"node: <"+e+">":""},e.prototype.ele=function(e,t,i){return this.element(e,t,i)},e.prototype.nod=function(e,t,i){return this.node(e,t,i)},e.prototype.txt=function(e){return this.text(e)},e.prototype.dat=function(e){return this.cdata(e)},e.prototype.com=function(e){return this.comment(e)},e.prototype.ins=function(e,t){return this.instruction(e,t)},e.prototype.doc=function(){return this.document()},e.prototype.dec=function(e,t,i){return this.declaration(e,t,i)},e.prototype.e=function(e,t,i){return this.element(e,t,i)},e.prototype.n=function(e,t,i){return this.node(e,t,i)},e.prototype.t=function(e){return this.text(e)},e.prototype.d=function(e){return this.cdata(e)},e.prototype.c=function(e){return this.comment(e)},e.prototype.r=function(e){return this.raw(e)},e.prototype.i=function(e,t){return this.instruction(e,t)},e.prototype.u=function(){return this.up()},e.prototype.importXMLBuilder=function(e){return this.importDocument(e)},e.prototype.replaceChild=function(e,t){throw new Error("This DOM method is not implemented."+this.debugInfo())},e.prototype.removeChild=function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())},e.prototype.appendChild=function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())},e.prototype.hasChildNodes=function(){return 0!==this.children.length},e.prototype.cloneNode=function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())},e.prototype.normalize=function(){throw new Error("This DOM method is not implemented."+this.debugInfo())},e.prototype.isSupported=function(e,t){return!0},e.prototype.hasAttributes=function(){return 0!==this.attribs.length},e.prototype.compareDocumentPosition=function(e){var i,n;return(i=this)===e?0:this.document()!==e.document()?(n=t.Disconnected|t.ImplementationSpecific,Math.random()<.5?n|=t.Preceding:n|=t.Following,n):i.isAncestor(e)?t.Contains|t.Preceding:i.isDescendant(e)?t.Contains|t.Following:i.isPreceding(e)?t.Preceding:t.Following},e.prototype.isSameNode=function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())},e.prototype.lookupPrefix=function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())},e.prototype.isDefaultNamespace=function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())},e.prototype.lookupNamespaceURI=function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())},e.prototype.isEqualNode=function(e){var t,i,n;if(e.nodeType!==this.nodeType)return!1;if(e.children.length!==this.children.length)return!1;for(t=i=0,n=this.children.length-1;0<=n?i<=n:i>=n;t=0<=n?++i:--i)if(!this.children[t].isEqualNode(e.children[t]))return!1;return!0},e.prototype.getFeature=function(e,t){throw new Error("This DOM method is not implemented."+this.debugInfo())},e.prototype.setUserData=function(e,t,i){throw new Error("This DOM method is not implemented."+this.debugInfo())},e.prototype.getUserData=function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())},e.prototype.contains=function(e){return!!e&&(e===this||this.isDescendant(e))},e.prototype.isDescendant=function(e){var t,i,n,o;for(i=0,n=(o=this.children).length;i<n;i++){if(e===(t=o[i]))return!0;if(t.isDescendant(e))return!0}return!1},e.prototype.isAncestor=function(e){return e.isDescendant(this)},e.prototype.isPreceding=function(e){var t,i;return t=this.treePosition(e),i=this.treePosition(this),-1!==t&&-1!==i&&t<i},e.prototype.isFollowing=function(e){var t,i;return t=this.treePosition(e),i=this.treePosition(this),-1!==t&&-1!==i&&t>i},e.prototype.treePosition=function(e){var t,i;return i=0,t=!1,this.foreachTreeNode(this.document(),(function(n){if(i++,!t&&n===e)return t=!0})),t?i:-1},e.prototype.foreachTreeNode=function(e,t){var i,n,o,r,s;for(e||(e=this.document()),n=0,o=(r=e.children).length;n<o;n++){if(s=t(i=r[n]))return s;if(s=this.foreachTreeNode(i,t))return s}},e}()}).call(this)},8726:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TcpTransport=t.UdpTransport=void 0;const n=i(7194),o=i(9278),r=i(6465),s=i(3417),a=(0,r.debug)("werift-ice:packages/ice/src/transport.ts");class c{constructor(e,t={}){this.socketType=e,this.options=t,this.type="udp",this.onData=()=>{},this.send=(e,t)=>new Promise(((i,n)=>{t=t??[this.rinfo?.address,this.rinfo?.port],this.socket.send(e,t[1],t[0],(o=>{o?(a("send error",t,e),n(o)):i()}))})),this.close=()=>new Promise((e=>{this.socket.once("close",e);try{this.socket.close()}catch(t){e()}})),this.socket=(0,n.createSocket)(e),this.socket.on("message",((e,t)=>{6===(0,s.normalizeFamilyNodeV18)(t.family)&&([t.address]=t.address.split("%")),this.rinfo=t;try{this.onData(e,[t.address,t.port])}catch(e){a("onData error",e)}}))}static async init(e,t={}){const i=new c(e,t);return await i.init(),i}async init(){const e=(0,s.interfaceAddress)(this.socketType,this.options.interfaceAddresses);if(this.options.port)this.socket.bind({port:this.options.port,address:e});else if(this.options.portRange){const t=await(0,s.findPort)(this.options.portRange[0],this.options.portRange[1],this.socketType,this.options.interfaceAddresses);this.socket.bind({port:t,address:e})}else this.socket.bind({address:e});await new Promise((e=>this.socket.once("listening",e)))}get address(){return this.socket.address()}get host(){return this.socket.address().address}get port(){return this.socket.address().port}}t.UdpTransport=c;class l{constructor(e){this.addr=e,this.type="tcp",this.onData=()=>{},this.closed=!1,this.send=async(e,t)=>{await this.connecting,this.client.write(e,(e=>{e&&console.log("err",e)}))},this.close=async()=>{this.closed=!0,this.client.destroy()},this.connect()}connect(){this.closed||(this.client&&this.client.destroy(),this.connecting=new Promise(((e,t)=>{try{this.client=(0,o.connect)({port:this.addr[1],host:this.addr[0]},e)}catch(e){t(e)}})),this.client.on("data",(e=>{const t=[this.client.remoteAddress,this.client.remotePort];this.onData(e,t)})),this.client.on("end",(()=>{this.connect()})),this.client.on("error",(e=>{console.log("error",e)})))}async init(){await this.connecting}static async init(e){const t=new l(e);return await t.init(),t}get address(){return{}}}t.TcpTransport=l},8732:function(e,t){(function(){t.defaults={.1:{explicitCharkey:!1,trim:!0,normalize:!0,normalizeTags:!1,attrkey:"@",charkey:"#",explicitArray:!1,ignoreAttrs:!1,mergeAttrs:!1,explicitRoot:!1,validator:null,xmlns:!1,explicitChildren:!1,childkey:"@@",charsAsChildren:!1,includeWhiteChars:!1,async:!1,strict:!0,attrNameProcessors:null,attrValueProcessors:null,tagNameProcessors:null,valueProcessors:null,emptyTag:""},.2:{explicitCharkey:!1,trim:!1,normalize:!1,normalizeTags:!1,attrkey:"$",charkey:"_",explicitArray:!0,ignoreAttrs:!1,mergeAttrs:!1,explicitRoot:!0,validator:null,xmlns:!1,explicitChildren:!1,preserveChildrenOrder:!1,childkey:"$$",charsAsChildren:!1,includeWhiteChars:!1,async:!1,strict:!0,attrNameProcessors:null,attrValueProcessors:null,tagNameProcessors:null,valueProcessors:null,rootName:"root",xmldec:{version:"1.0",encoding:"UTF-8",standalone:!0},doctype:null,renderOpts:{pretty:!0,indent:" ",newline:"\n"},headless:!1,chunkSize:1e4,emptyTag:"",cdata:!1}}}).call(this)},8766:(e,t,i)=>{"undefined"==typeof process||"renderer"===process.type||!0===process.browser||process.__nwjs?e.exports=i(5998):e.exports=i(6356)},8938:(e,t)=>{"use strict";function i(e){let t=e.split("\n").map((e=>e.trim()));t=t.filter((e=>!e.includes("a=control:")));let i=0;for(let e=0;e<t.length;e++){t[e].startsWith("m=")&&(t.splice(e+1,0,"a=control:trackID="+i),i++)}return t.join("\r\n")}function n(e,t,i=["recvonly","sendrecv"]){const n=function(e){return("\n"+e).split("\nm=")}(e).filter((e=>e.startsWith(t)));for(const e of n){const t=()=>{const t=e.split("\n").map((e=>e.trim())),i="a=control:",n=t.find((e=>e.startsWith(i)));return{section:"m="+e,trackId:n.substring(10)}};for(const n of i)if(e.includes(`a=${n}`))return t();if(i.includes("recvonly")&&!e.includes("sendonly")&&!e.includes("inactive"))return t()}}function o(e){const t=[];for(const i of e.split(" ").slice(3)||[])t.push(parseInt(i));return t}function r(e){const t=e.split(" ");return{type:t[0].substring(2),port:parseInt(t[1]),protocol:t[2],payloadTypes:o(e)}}Object.defineProperty(t,"__esModule",{value:!0}),t.replacePorts=function(e,t,i){return e.replace(/c=IN .*/,"c=IN IP4 127.0.0.1").replace(/m=audio \d+/,`m=audio ${t}`).replace(/m=video \d+/,`m=video ${i}`)},t.replaceSectionPort=function(e,t,i){const n=new RegExp(`m=${t} \\d+`);return e.replace(/c=IN .*/,"c=IN IP4 127.0.0.1").replace(n,`m=${t} ${i}`)},t.addTrackControls=i,t.createSdpInput=function(e,t,n){let o=n.replace(/c=IN .*/,"c=IN IP4 127.0.0.1").replace(/m=audio \d+/,`m=audio ${e}`).replace(/m=video \d+/,`m=video ${t}`),r=o.split("\n").map((e=>e.trim()));return r=r.filter((e=>!e.includes("a=rtcp-mux"))).filter((e=>!e.includes("a=candidate"))).filter((e=>!e.includes("a=ice"))),o=r.join("\r\n"),o=i(o),o=o.split("m=").slice(1).map((e=>"m="+e)).join(""),o},t.findFmtp=function(e,t){let i=e.split("\n").map((e=>e.trim()));const n=new RegExp(`a=rtpmap:(\\d+) ${t}`);return i.map((e=>e.match(n))).filter((e=>!!e)).map((e=>{const t=parseInt(e[1]),n=`a=fmtp:${t} `,o=i.find((e=>e.startsWith(n)))?.substring(n.length);return{payloadType:t,fmtp:o}}))},t.findTrackByType=n,t.findTracksByType=function(e,t=["recvonly","sendrecv"]){return{audio:n(e,"audio",t)?.trackId,video:n(e,"video",t)?.trackId}},t.parseMLinePayloadTypes=o,t.parseMLine=r,t.parseFmtp=a,t.parseRtpMap=c,t.parseMSection=u,t.parseSdp=function(e){const t=e.split("\n").map((e=>e.trim())),i=[],n=[];let o;for(const e of t)e.startsWith("m=")&&(o&&n.push(o),o=[]),o?o.push(e):i.push(e);o&&n.push(o);const r={header:{lines:i,contents:i.join("\r\n")},msections:n.map(u),toSdp:()=>[...r.header.lines,...r.msections.map((e=>e.lines)).flat()].join("\r\n")};return r},t.getSpsPps=function(e){const t=e?.fmtp?.[0]?.parameters?.["sprop-parameter-sets"]?.split(",");if(2!==t?.length)return{sps:void 0,pps:void 0};const[i,n]=t;return{sps:Buffer.from(i,"base64"),pps:Buffer.from(n,"base64")}},t.getSpsPpsVps=function(e){const t=e?.fmtp?.[0]?.parameters;if(!t)return{sps:void 0,pps:void 0,vps:void 0};const i=t["sprop-sps"],n=t["sprop-pps"],o=t["sprop-vps"];return{sps:i?Buffer.from(i,"base64"):void 0,pps:n?Buffer.from(n,"base64"):void 0,vps:o?Buffer.from(o,"base64"):void 0}};const s="a=fmtp";function a(e){return e.filter((e=>e.startsWith(s))).map((e=>{const t=e.indexOf(" ");if(-1===t)return;const i=e.substring(0,t),n=e.substring(t+1),o=parseInt(i.split(":")[1]);if(!i||!n||Number.isNaN(o))return;const r={};return n.split(";").map((e=>e.trim())).forEach((e=>{const[t,...i]=e.split("=");r[t]=i.join("=")})),{payloadType:o,parameters:r}})).filter((e=>!!e))}function c(e,t){const i=e.type,n=t?.match(/a=rtpmap:([\d]+) (.*?)\/([\d]+)(\/([\d]+))?/);let o,r,s=parseInt(n?.[5])||void 0,a=parseInt(n?.[1]);t=t?.toLowerCase(),t?.includes("mpeg4")?(o="aac",r="aac"):t?.includes("opus")?(o="opus",r="libopus"):t?.includes("pcma")?(o="pcm_alaw",r="pcm_alaw"):t?.includes("pcmu")?(o="pcm_mulaw",r="pcm_mulaw"):t?.includes("g726")?o="g726":t?.includes("pcm")?o="pcm":t?.includes("l16")?(o="pcm_s16be",r="pcm_s16be"):t?.includes("speex")?(o="speex",r="libspeex"):t?.includes("h264")?o="h264":t?.includes("h265")?o="h265":t||"audio"!==i||(e.payloadTypes?.includes(0)?(o="pcm_mulaw",r="pcm_mulaw",a=0,s=1):e.payloadTypes?.includes(8)?(o="pcm_alaw",r="pcm_alaw",a=8,s=1):e.payloadTypes?.includes(14)?(o="mp3",r="mp3",a=14,s=2):(o="pcm_alaw",r="pcm_alaw",a=8,s=1));let c=parseInt(n?.[3]);return c||(c=void 0,"pcm_mulaw"===o||"pcm_alaw"===o?c=8e3:"pcm_s16be"===o&&(c=16e3)),{line:t,codec:o,ffmpegEncoder:r,rawCodec:n?.[2],clock:c,channels:s,payloadType:a}}const l="a=control:",p="a=rtpmap:";function u(e){const t=e.find((e=>e.startsWith(l)))?.substring(l.length),i=r(e[0]),n=e.filter((e=>e.startsWith(p))),o=n.map((e=>c(i,e))),s=c(i,n[0]),{codec:u}=s;let d;for(const t of["sendonly","sendrecv","recvonly","inactive"]){if(e.find((e=>e==="a="+t))){d=t;break}}const h={...i,fmtp:a(e),lines:e,rtpmaps:o,contents:e.join("\r\n"),control:t,codec:u,rtpmap:s,direction:d,toSdp:()=>h.lines.join("\r\n")};return h}},8945:function(e,t,i){(function(){var t,n,o,r={}.hasOwnProperty;o=i(5502).assign,t=i(5068),i(9983),i(2189),i(5670),i(9226),i(6859),i(4565),i(9256),i(838),i(871),i(2328),i(4423),i(2032),i(4061),n=i(1926),e.exports=function(){function e(e){var t,i,n;for(t in e||(e={}),this.options=e,i=e.writer||{})r.call(i,t)&&(n=i[t],this["_"+t]=this[t],this[t]=n)}return e.prototype.filterOptions=function(e){var t,i,r,s,a,c,l,p;return e||(e={}),e=o({},this.options,e),(t={writer:this}).pretty=e.pretty||!1,t.allowEmpty=e.allowEmpty||!1,t.indent=null!=(i=e.indent)?i:" ",t.newline=null!=(r=e.newline)?r:"\n",t.offset=null!=(s=e.offset)?s:0,t.dontPrettyTextNodes=null!=(a=null!=(c=e.dontPrettyTextNodes)?c:e.dontprettytextnodes)?a:0,t.spaceBeforeSlash=null!=(l=null!=(p=e.spaceBeforeSlash)?p:e.spacebeforeslash)?l:"",!0===t.spaceBeforeSlash&&(t.spaceBeforeSlash=" "),t.suppressPrettyCount=0,t.user={},t.state=n.None,t},e.prototype.indent=function(e,t,i){var n;return!t.pretty||t.suppressPrettyCount?"":t.pretty&&(n=(i||0)+t.offset+1)>0?new Array(n).join(t.indent):""},e.prototype.endline=function(e,t,i){return!t.pretty||t.suppressPrettyCount?"":t.newline},e.prototype.attribute=function(e,t,i){var n;return this.openAttribute(e,t,i),n=" "+e.name+'="'+e.value+'"',this.closeAttribute(e,t,i),n},e.prototype.cdata=function(e,t,i){var o;return this.openNode(e,t,i),t.state=n.OpenTag,o=this.indent(e,t,i)+"<![CDATA[",t.state=n.InsideTag,o+=e.value,t.state=n.CloseTag,o+="]]>"+this.endline(e,t,i),t.state=n.None,this.closeNode(e,t,i),o},e.prototype.comment=function(e,t,i){var o;return this.openNode(e,t,i),t.state=n.OpenTag,o=this.indent(e,t,i)+"\x3c!-- ",t.state=n.InsideTag,o+=e.value,t.state=n.CloseTag,o+=" --\x3e"+this.endline(e,t,i),t.state=n.None,this.closeNode(e,t,i),o},e.prototype.declaration=function(e,t,i){var o;return this.openNode(e,t,i),t.state=n.OpenTag,o=this.indent(e,t,i)+"<?xml",t.state=n.InsideTag,o+=' version="'+e.version+'"',null!=e.encoding&&(o+=' encoding="'+e.encoding+'"'),null!=e.standalone&&(o+=' standalone="'+e.standalone+'"'),t.state=n.CloseTag,o+=t.spaceBeforeSlash+"?>",o+=this.endline(e,t,i),t.state=n.None,this.closeNode(e,t,i),o},e.prototype.docType=function(e,t,i){var o,r,s,a,c;if(i||(i=0),this.openNode(e,t,i),t.state=n.OpenTag,a=this.indent(e,t,i),a+="<!DOCTYPE "+e.root().name,e.pubID&&e.sysID?a+=' PUBLIC "'+e.pubID+'" "'+e.sysID+'"':e.sysID&&(a+=' SYSTEM "'+e.sysID+'"'),e.children.length>0){for(a+=" [",a+=this.endline(e,t,i),t.state=n.InsideTag,r=0,s=(c=e.children).length;r<s;r++)o=c[r],a+=this.writeChildNode(o,t,i+1);t.state=n.CloseTag,a+="]"}return t.state=n.CloseTag,a+=t.spaceBeforeSlash+">",a+=this.endline(e,t,i),t.state=n.None,this.closeNode(e,t,i),a},e.prototype.element=function(e,i,o){var s,a,c,l,p,u,d,h,m,f,g,v,y,b;for(m in o||(o=0),f=!1,g="",this.openNode(e,i,o),i.state=n.OpenTag,g+=this.indent(e,i,o)+"<"+e.name,v=e.attribs)r.call(v,m)&&(s=v[m],g+=this.attribute(s,i,o));if(l=0===(c=e.children.length)?null:e.children[0],0===c||e.children.every((function(e){return(e.type===t.Text||e.type===t.Raw)&&""===e.value})))i.allowEmpty?(g+=">",i.state=n.CloseTag,g+="</"+e.name+">"+this.endline(e,i,o)):(i.state=n.CloseTag,g+=i.spaceBeforeSlash+"/>"+this.endline(e,i,o));else if(!i.pretty||1!==c||l.type!==t.Text&&l.type!==t.Raw||null==l.value){if(i.dontPrettyTextNodes)for(p=0,d=(y=e.children).length;p<d;p++)if(((a=y[p]).type===t.Text||a.type===t.Raw)&&null!=a.value){i.suppressPrettyCount++,f=!0;break}for(g+=">"+this.endline(e,i,o),i.state=n.InsideTag,u=0,h=(b=e.children).length;u<h;u++)a=b[u],g+=this.writeChildNode(a,i,o+1);i.state=n.CloseTag,g+=this.indent(e,i,o)+"</"+e.name+">",f&&i.suppressPrettyCount--,g+=this.endline(e,i,o),i.state=n.None}else g+=">",i.state=n.InsideTag,i.suppressPrettyCount++,f=!0,g+=this.writeChildNode(l,i,o+1),i.suppressPrettyCount--,f=!1,i.state=n.CloseTag,g+="</"+e.name+">"+this.endline(e,i,o);return this.closeNode(e,i,o),g},e.prototype.writeChildNode=function(e,i,n){switch(e.type){case t.CData:return this.cdata(e,i,n);case t.Comment:return this.comment(e,i,n);case t.Element:return this.element(e,i,n);case t.Raw:return this.raw(e,i,n);case t.Text:return this.text(e,i,n);case t.ProcessingInstruction:return this.processingInstruction(e,i,n);case t.Dummy:return"";case t.Declaration:return this.declaration(e,i,n);case t.DocType:return this.docType(e,i,n);case t.AttributeDeclaration:return this.dtdAttList(e,i,n);case t.ElementDeclaration:return this.dtdElement(e,i,n);case t.EntityDeclaration:return this.dtdEntity(e,i,n);case t.NotationDeclaration:return this.dtdNotation(e,i,n);default:throw new Error("Unknown XML node type: "+e.constructor.name)}},e.prototype.processingInstruction=function(e,t,i){var o;return this.openNode(e,t,i),t.state=n.OpenTag,o=this.indent(e,t,i)+"<?",t.state=n.InsideTag,o+=e.target,e.value&&(o+=" "+e.value),t.state=n.CloseTag,o+=t.spaceBeforeSlash+"?>",o+=this.endline(e,t,i),t.state=n.None,this.closeNode(e,t,i),o},e.prototype.raw=function(e,t,i){var o;return this.openNode(e,t,i),t.state=n.OpenTag,o=this.indent(e,t,i),t.state=n.InsideTag,o+=e.value,t.state=n.CloseTag,o+=this.endline(e,t,i),t.state=n.None,this.closeNode(e,t,i),o},e.prototype.text=function(e,t,i){var o;return this.openNode(e,t,i),t.state=n.OpenTag,o=this.indent(e,t,i),t.state=n.InsideTag,o+=e.value,t.state=n.CloseTag,o+=this.endline(e,t,i),t.state=n.None,this.closeNode(e,t,i),o},e.prototype.dtdAttList=function(e,t,i){var o;return this.openNode(e,t,i),t.state=n.OpenTag,o=this.indent(e,t,i)+"<!ATTLIST",t.state=n.InsideTag,o+=" "+e.elementName+" "+e.attributeName+" "+e.attributeType,"#DEFAULT"!==e.defaultValueType&&(o+=" "+e.defaultValueType),e.defaultValue&&(o+=' "'+e.defaultValue+'"'),t.state=n.CloseTag,o+=t.spaceBeforeSlash+">"+this.endline(e,t,i),t.state=n.None,this.closeNode(e,t,i),o},e.prototype.dtdElement=function(e,t,i){var o;return this.openNode(e,t,i),t.state=n.OpenTag,o=this.indent(e,t,i)+"<!ELEMENT",t.state=n.InsideTag,o+=" "+e.name+" "+e.value,t.state=n.CloseTag,o+=t.spaceBeforeSlash+">"+this.endline(e,t,i),t.state=n.None,this.closeNode(e,t,i),o},e.prototype.dtdEntity=function(e,t,i){var o;return this.openNode(e,t,i),t.state=n.OpenTag,o=this.indent(e,t,i)+"<!ENTITY",t.state=n.InsideTag,e.pe&&(o+=" %"),o+=" "+e.name,e.value?o+=' "'+e.value+'"':(e.pubID&&e.sysID?o+=' PUBLIC "'+e.pubID+'" "'+e.sysID+'"':e.sysID&&(o+=' SYSTEM "'+e.sysID+'"'),e.nData&&(o+=" NDATA "+e.nData)),t.state=n.CloseTag,o+=t.spaceBeforeSlash+">"+this.endline(e,t,i),t.state=n.None,this.closeNode(e,t,i),o},e.prototype.dtdNotation=function(e,t,i){var o;return this.openNode(e,t,i),t.state=n.OpenTag,o=this.indent(e,t,i)+"<!NOTATION",t.state=n.InsideTag,o+=" "+e.name,e.pubID&&e.sysID?o+=' PUBLIC "'+e.pubID+'" "'+e.sysID+'"':e.pubID?o+=' PUBLIC "'+e.pubID+'"':e.sysID&&(o+=' SYSTEM "'+e.sysID+'"'),t.state=n.CloseTag,o+=t.spaceBeforeSlash+">"+this.endline(e,t,i),t.state=n.None,this.closeNode(e,t,i),o},e.prototype.openNode=function(e,t,i){},e.prototype.closeNode=function(e,t,i){},e.prototype.openAttribute=function(e,t,i){},e.prototype.closeAttribute=function(e,t,i){},e}()}).call(this)},8974:(e,t,i)=>{e.exports=function(e){const t=i(4081).linerase;e.prototype.getImagingSettings=function(e,i){"undefined"==typeof i&&(i=e,e={}),this._request({service:"imaging",body:this._envelopeHeader()+'<GetImagingSettings xmlns="http://www.onvif.org/ver20/imaging/wsdl" ><VideoSourceToken xmlns="http://www.onvif.org/ver20/imaging/wsdl" >'+(e.token||this.activeSource.sourceToken)+"</VideoSourceToken></GetImagingSettings>"+this._envelopeFooter()},function(e,n,o){i&&i.call(this,e,e?null:t(n).getImagingSettingsResponse.imagingSettings,o)}.bind(this))},e.prototype.setImagingSettings=function(e,i){this._request({service:"imaging",body:this._envelopeHeader()+'<SetImagingSettings xmlns="http://www.onvif.org/ver20/imaging/wsdl" ><VideoSourceToken xmlns="http://www.onvif.org/ver20/imaging/wsdl" >'+(e.token||this.activeSource.sourceToken)+'</VideoSourceToken><ImagingSettings xmlns="http://www.onvif.org/ver20/imaging/wsdl" >'+(e.brightness?'<Brightness xmlns="http://www.onvif.org/ver10/schema">'+e.brightness+"</Brightness>":"")+(e.colorSaturation?'<ColorSaturation xmlns="http://www.onvif.org/ver10/schema">'+e.colorSaturation+"</ColorSaturation>":"")+(e.contrast?'<Contrast xmlns="http://www.onvif.org/ver10/schema">'+e.contrast+"</Contrast>":"")+(e.exposure?'<Exposure xmlns="http://www.onvif.org/ver10/schema">'+(e.exposure.mode?'<Mode xmlns="http://www.onvif.org/ver10/schema">'+e.exposure.mode+"</Mode>":"")+(e.exposure.priority?'<Priority xmlns="http://www.onvif.org/ver10/schema">'+e.exposure.priority+"</Priority>":"")+(e.exposure.minExposureTime?'<MinExposureTime xmlns="http://www.onvif.org/ver10/schema">'+e.exposure.minExposureTime+"</MinExposureTime>":"")+(e.exposure.maxExposureTime?'<MaxExposureTime xmlns="http://www.onvif.org/ver10/schema">'+e.exposure.maxExposureTime+"</MaxExposureTime>":"")+(e.exposure.minGain?'<MinGain xmlns="http://www.onvif.org/ver10/schema">'+e.exposure.minGain+"</MinGain>":"")+(e.exposure.maxGain?'<MaxGain xmlns="http://www.onvif.org/ver10/schema">'+e.exposure.maxGain+"</MaxGain>":"")+(e.exposure.minIris?'<MinIris xmlns="http://www.onvif.org/ver10/schema">'+e.exposure.minIris+"</MinIris>":"")+(e.exposure.maxIris?'<MaxIris xmlns="http://www.onvif.org/ver10/schema">'+e.exposure.maxIris+"</MaxIris>":"")+(e.exposure.exposureTime?'<ExposureTime xmlns="http://www.onvif.org/ver10/schema">'+e.exposure.exposureTime+"</ExposureTime>":"")+(e.exposure.gain?'<Gain xmlns="http://www.onvif.org/ver10/schema">'+e.exposure.gain+"</Gain>":"")+(e.exposure.iris?'<Iris xmlns="http://www.onvif.org/ver10/schema">'+e.exposure.iris+"</Iris>":"")+"</Exposure>":"")+(e.focus?'<Focus xmlns="http://www.onvif.org/ver10/schema">'+(e.focus.autoFocusMode?'<AutoFocusMode xmlns="http://www.onvif.org/ver10/schema">'+e.focus.autoFocusMode+"</AutoFocusMode>":"")+(e.focus.defaultSpeed?'<DefaultSpeed xmlns="http://www.onvif.org/ver10/schema">'+e.focus.defaultSpeed+"</DefaultSpeed>":"")+(e.focus.nearLimit?'<NearLimit xmlns="http://www.onvif.org/ver10/schema">'+e.focus.nearLimit+"</NearLimit>":"")+(e.focus.farLimit?'<FarLimit xmlns="http://www.onvif.org/ver10/schema">'+e.focus.farLimit+"</FarLimit>":"")+"</Focus>":"")+(e.sharpness?'<Sharpness xmlns="http://www.onvif.org/ver10/schema">'+e.sharpness+"</Sharpness>":"")+(e.irCutFilter?'<IrCutFilter xmlns="http://www.onvif.org/ver10/schema">'+e.irCutFilter+"</IrCutFilter>":"")+"</ImagingSettings></SetImagingSettings>"+this._envelopeFooter()},function(e,n,o){i&&i.call(this,e,e?null:t(n).setImagingSettingsResponse,o)}.bind(this))},e.prototype.getImagingServiceCapabilities=function(e){this._request({service:"imaging",body:this._envelopeHeader()+'<GetServiceCapabilities xmlns="http://www.onvif.org/ver20/imaging/wsdl" ></GetServiceCapabilities>'+this._envelopeFooter()},function(i,n,o){e&&e.call(this,i,i?null:t(n[0].getServiceCapabilitiesResponse[0].capabilities[0].$),o)}.bind(this))},e.prototype.getCurrentImagingPreset=function(e,i){"undefined"==typeof i&&(i=e,e={}),this._request({service:"imaging",body:this._envelopeHeader()+'<GetCurrentPreset xmlns="http://www.onvif.org/ver20/imaging/wsdl" ><VideoSourceToken>'+(e.token||this.activeSource.sourceToken)+"</VideoSourceToken></GetCurrentPreset>"+this._envelopeFooter()},function(e,n,o){i&&i.call(this,e,e?null:t(n).getCurrentPresetResponse.preset,o)}.bind(this))},e.prototype.setCurrentImagingPreset=function(e,i){this._request({service:"imaging",body:this._envelopeHeader()+'<SetCurrentPreset xmlns="http://www.onvif.org/ver20/imaging/wsdl" ><VideoSourceToken>'+(e.token||this.activeSource.sourceToken)+"</VideoSourceToken><PresetToken>"+e.presetToken+"</PresetToken></SetCurrentPreset>"+this._envelopeFooter()},function(e,n,o){i&&i.call(this,e,e?null:t(n).setCurrentPresetResponse,o)}.bind(this))},e.prototype.getVideoSourceOptions=function(e,i){"undefined"==typeof i&&(i=e,e={}),this._request({service:"imaging",body:this._envelopeHeader()+'<GetOptions xmlns="http://www.onvif.org/ver20/imaging/wsdl"><VideoSourceToken>'+(e.token||this.activeSource.sourceToken)+"</VideoSourceToken></GetOptions>"+this._envelopeFooter()},function(e,n,o){if(i){let r=t(n),s={};r&&r.getOptionsResponse&&r.getOptionsResponse.imagingOptions&&(s=r.getOptionsResponse.imagingOptions),i.call(this,e,s,o)}}.bind(this))},e.prototype.imagingGetMoveOptions=function(e,i){"undefined"==typeof i&&(i=e,e={}),this._request({service:"imaging",body:this._envelopeHeader()+'<GetMoveOptions xmlns="http://www.onvif.org/ver20/imaging/wsdl"><VideoSourceToken>'+(e.token||this.activeSource.sourceToken)+"</VideoSourceToken></GetMoveOptions>"+this._envelopeFooter()},function(e,n,o){if(i){let r=t(n),s={};r&&r.getMoveOptionsResponse&&r.getMoveOptionsResponse.moveOptions&&(s=r.getMoveOptionsResponse.moveOptions),i.call(this,e,s,o)}}.bind(this))},e.prototype.imagingGetStatus=function(e,i){"undefined"==typeof i&&(i=e,e={}),this._request({service:"imaging",body:this._envelopeHeader()+'<GetStatus xmlns="http://www.onvif.org/ver20/imaging/wsdl"><VideoSourceToken>'+(e.token||this.activeSource.sourceToken)+"</VideoSourceToken></GetStatus>"+this._envelopeFooter()},function(e,n,o){if(i){let r=t(n),s={};r&&r.getStatusResponse&&r.getStatusResponse.status&&(s=r.getStatusResponse.status),i.call(this,e,s,o)}}.bind(this))},e.prototype.imagingMove=function(e,i){this._request({service:"imaging",body:this._envelopeHeader()+'<Move xmlns="http://www.onvif.org/ver20/imaging/wsdl" ><VideoSourceToken xmlns="http://www.onvif.org/ver20/imaging/wsdl" >'+(e.token||this.activeSource.sourceToken)+'</VideoSourceToken><Focus xmlns="http://www.onvif.org/ver20/imaging/wsdl">'+(e.absolute?'<Absolute xmlns="http://www.onvif.org/ver10/schema">'+(e.absolute.position?'<Position xmlns="http://www.onvif.org/ver10/schema">'+e.absolute.position+"</Position>":"")+(e.absolute.speed?'<Speed xmlns="http://www.onvif.org/ver10/schema">'+e.absolute.speed+"</Speed>":"")+"</Absolute>":"")+(e.relative?'<Relative xmlns="http://www.onvif.org/ver10/schema">'+(e.relative.distance?'<Distance xmlns="http://www.onvif.org/ver10/schema">'+e.relative.distance+"</Distance>":"")+(e.relative.speed?'<Speed xmlns="http://www.onvif.org/ver10/schema">'+e.relative.speed+"</Speed>":"")+"</Relative>":"")+(e.continuous?'<Continuous xmlns="http://www.onvif.org/ver10/schema">'+(e.continuous.speed?'<Speed xmlns="http://www.onvif.org/ver10/schema">'+e.continuous.speed+"</Speed>":"")+"</Continuous>":"")+"</Focus></Move>"+this._envelopeFooter()},function(e,n,o){i&&i.call(this,e,e?null:t(n).MoveResponse,o)}.bind(this))},e.prototype.imagingStop=function(e,i){this._request({service:"imaging",body:this._envelopeHeader()+'<Stop xmlns="http://www.onvif.org/ver20/imaging/wsdl" ><VideoSourceToken xmlns="http://www.onvif.org/ver20/imaging/wsdl" >'+(e.token||this.activeSource.sourceToken)+"</VideoSourceToken></Stop>"+this._envelopeFooter()},function(e,n,o){i&&i.call(this,e,e?null:t(n).StopResponse,o)}.bind(this))}}},9023:e=>{"use strict";e.exports=require("util")},9064:(e,t,i)=>{"use strict";const n=i(3106),o=i(6667),r=i(7934),{kStatusCode:s}=i(6639),a=Buffer[Symbol.species],c=Buffer.from([0,0,255,255]),l=Symbol("permessage-deflate"),p=Symbol("total-length"),u=Symbol("callback"),d=Symbol("buffers"),h=Symbol("error");let m;function f(e){this[d].push(e),this[p]+=e.length}function g(e){this[p]+=e.length,this[l]._maxPayload<1||this[p]<=this[l]._maxPayload?this[d].push(e):(this[h]=new RangeError("Max payload size exceeded"),this[h].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[h][s]=1009,this.removeListener("data",g),this.reset())}function v(e){this[l]._inflate=null,e[s]=1007,this[u](e)}e.exports=class{constructor(e,t,i){if(this._maxPayload=0|i,this._options=e||{},this._threshold=void 0!==this._options.threshold?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!m){const e=void 0!==this._options.concurrencyLimit?this._options.concurrencyLimit:10;m=new r(e)}}static get extensionName(){return"permessage-deflate"}offer(){const e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:null==this._options.clientMaxWindowBits&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){const e=this._deflate[u];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){const t=this._options,i=e.find((e=>!(!1===t.serverNoContextTakeover&&e.server_no_context_takeover||e.server_max_window_bits&&(!1===t.serverMaxWindowBits||"number"==typeof t.serverMaxWindowBits&&t.serverMaxWindowBits>e.server_max_window_bits)||"number"==typeof t.clientMaxWindowBits&&!e.client_max_window_bits)));if(!i)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(i.server_no_context_takeover=!0),t.clientNoContextTakeover&&(i.client_no_context_takeover=!0),"number"==typeof t.serverMaxWindowBits&&(i.server_max_window_bits=t.serverMaxWindowBits),"number"==typeof t.clientMaxWindowBits?i.client_max_window_bits=t.clientMaxWindowBits:!0!==i.client_max_window_bits&&!1!==t.clientMaxWindowBits||delete i.client_max_window_bits,i}acceptAsClient(e){const t=e[0];if(!1===this._options.clientNoContextTakeover&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(t.client_max_window_bits){if(!1===this._options.clientMaxWindowBits||"number"==typeof this._options.clientMaxWindowBits&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"')}else"number"==typeof this._options.clientMaxWindowBits&&(t.client_max_window_bits=this._options.clientMaxWindowBits);return t}normalizeParams(e){return e.forEach((e=>{Object.keys(e).forEach((t=>{let i=e[t];if(i.length>1)throw new Error(`Parameter "${t}" must have only a single value`);if(i=i[0],"client_max_window_bits"===t){if(!0!==i){const e=+i;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${i}`);i=e}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${t}": ${i}`)}else if("server_max_window_bits"===t){const e=+i;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${i}`);i=e}else{if("client_no_context_takeover"!==t&&"server_no_context_takeover"!==t)throw new Error(`Unknown parameter "${t}"`);if(!0!==i)throw new TypeError(`Invalid value for parameter "${t}": ${i}`)}e[t]=i}))})),e}decompress(e,t,i){m.add((n=>{this._decompress(e,t,((e,t)=>{n(),i(e,t)}))}))}compress(e,t,i){m.add((n=>{this._compress(e,t,((e,t)=>{n(),i(e,t)}))}))}_decompress(e,t,i){const r=this._isServer?"client":"server";if(!this._inflate){const e=`${r}_max_window_bits`,t="number"!=typeof this.params[e]?n.Z_DEFAULT_WINDOWBITS:this.params[e];this._inflate=n.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[l]=this,this._inflate[p]=0,this._inflate[d]=[],this._inflate.on("error",v),this._inflate.on("data",g)}this._inflate[u]=i,this._inflate.write(e),t&&this._inflate.write(c),this._inflate.flush((()=>{const e=this._inflate[h];if(e)return this._inflate.close(),this._inflate=null,void i(e);const n=o.concat(this._inflate[d],this._inflate[p]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[p]=0,this._inflate[d]=[],t&&this.params[`${r}_no_context_takeover`]&&this._inflate.reset()),i(null,n)}))}_compress(e,t,i){const r=this._isServer?"server":"client";if(!this._deflate){const e=`${r}_max_window_bits`,t="number"!=typeof this.params[e]?n.Z_DEFAULT_WINDOWBITS:this.params[e];this._deflate=n.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[p]=0,this._deflate[d]=[],this._deflate.on("data",f)}this._deflate[u]=i,this._deflate.write(e),this._deflate.flush(n.Z_SYNC_FLUSH,(()=>{if(!this._deflate)return;let e=o.concat(this._deflate[d],this._deflate[p]);t&&(e=new a(e.buffer,e.byteOffset,e.length-4)),this._deflate[u]=null,this._deflate[p]=0,this._deflate[d]=[],t&&this.params[`${r}_no_context_takeover`]&&this._deflate.reset(),i(null,e)}))}}},9071:(e,t,i)=>{const n=i(7097),{AbortError:o,codes:r}=i(676),{ERR_INVALID_ARG_TYPE:s,ERR_STREAM_PREMATURE_CLOSE:a}=r,{kEmptyObject:c,once:l}=i(3939),{validateAbortSignal:p,validateFunction:u,validateObject:d,validateBoolean:h}=i(2354),{Promise:m,PromisePrototypeThen:f,SymbolDispose:g}=i(3383),{isClosed:v,isReadable:y,isReadableNodeStream:b,isReadableStream:w,isReadableFinished:_,isReadableErrored:S,isWritable:x,isWritableNodeStream:T,isWritableStream:E,isWritableFinished:C,isWritableErrored:P,isNodeStream:k,willEmitClose:O,kIsClosedPromise:I}=i(6274);let A;const R=()=>{};function D(e,t,r){var h,m;if(2===arguments.length?(r=t,t=c):null==t?t=c:d(t,"options"),u(r,"callback"),p(t.signal,"options.signal"),r=l(r),w(e)||E(e))return function(e,t,r){let s=!1,a=R;if(t.signal)if(a=()=>{s=!0,r.call(e,new o(void 0,{cause:t.signal.reason}))},t.signal.aborted)n.nextTick(a);else{A=A||i(3939).addAbortListener;const n=A(t.signal,a),o=r;r=l(((...t)=>{n[g](),o.apply(e,t)}))}const c=(...t)=>{s||n.nextTick((()=>r.apply(e,t)))};return f(e[I].promise,c,c),R}(e,t,r);if(!k(e))throw new s("stream",["ReadableStream","WritableStream","Stream"],e);const D=null!==(h=t.readable)&&void 0!==h?h:b(e),M=null!==(m=t.writable)&&void 0!==m?m:T(e),N=e._writableState,L=e._readableState,j=()=>{e.writable||U()};let F=O(e)&&b(e)===D&&T(e)===M,B=C(e,!1);const U=()=>{B=!0,e.destroyed&&(F=!1),(!F||e.readable&&!D)&&(D&&!q||r.call(e))};let q=_(e,!1);const V=()=>{q=!0,e.destroyed&&(F=!1),(!F||e.writable&&!M)&&(M&&!B||r.call(e))},H=t=>{r.call(e,t)};let z=v(e);const $=()=>{z=!0;const t=P(e)||S(e);return t&&"boolean"!=typeof t?r.call(e,t):D&&!q&&b(e,!0)&&!_(e,!1)?r.call(e,new a):!M||B||C(e,!1)?void r.call(e):r.call(e,new a)},W=()=>{z=!0;const t=P(e)||S(e);if(t&&"boolean"!=typeof t)return r.call(e,t);r.call(e)},G=()=>{e.req.on("finish",U)};!function(e){return e.setHeader&&"function"==typeof e.abort}(e)?M&&!N&&(e.on("end",j),e.on("close",j)):(e.on("complete",U),F||e.on("abort",$),e.req?G():e.on("request",G)),F||"boolean"!=typeof e.aborted||e.on("aborted",$),e.on("end",V),e.on("finish",U),!1!==t.error&&e.on("error",H),e.on("close",$),z?n.nextTick($):null!=N&&N.errorEmitted||null!=L&&L.errorEmitted?F||n.nextTick(W):(D||F&&!y(e)||!B&&!1!==x(e))&&(M||F&&!x(e)||!q&&!1!==y(e))?L&&e.req&&e.aborted&&n.nextTick(W):n.nextTick(W);const K=()=>{r=R,e.removeListener("aborted",$),e.removeListener("complete",U),e.removeListener("abort",$),e.removeListener("request",G),e.req&&e.req.removeListener("finish",U),e.removeListener("end",j),e.removeListener("close",j),e.removeListener("finish",U),e.removeListener("end",V),e.removeListener("error",H),e.removeListener("close",$)};if(t.signal&&!z){const s=()=>{const i=r;K(),i.call(e,new o(void 0,{cause:t.signal.reason}))};if(t.signal.aborted)n.nextTick(s);else{A=A||i(3939).addAbortListener;const n=A(t.signal,s),o=r;r=l(((...t)=>{n[g](),o.apply(e,t)}))}}return K}e.exports=D,e.exports.finished=function(e,t){var i;let n=!1;return null===t&&(t=c),null!==(i=t)&&void 0!==i&&i.cleanup&&(h(t.cleanup,"cleanup"),n=t.cleanup),new m(((i,o)=>{const r=D(e,t,(e=>{n&&r(),e?o(e):i()}))}))}},9086:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReasonCodes=void 0;const n=i(1364);t.ReasonCodes={0:"",1:"Unacceptable protocol version",2:"Identifier rejected",3:"Server unavailable",4:"Bad username or password",5:"Not authorized",16:"No matching subscribers",17:"No subscription existed",128:"Unspecified error",129:"Malformed Packet",130:"Protocol Error",131:"Implementation specific error",132:"Unsupported Protocol Version",133:"Client Identifier not valid",134:"Bad User Name or Password",135:"Not authorized",136:"Server unavailable",137:"Server busy",138:"Banned",139:"Server shutting down",140:"Bad authentication method",141:"Keep Alive timeout",142:"Session taken over",143:"Topic Filter invalid",144:"Topic Name invalid",145:"Packet identifier in use",146:"Packet Identifier not found",147:"Receive Maximum exceeded",148:"Topic Alias invalid",149:"Packet too large",150:"Message rate too high",151:"Quota exceeded",152:"Administrative action",153:"Payload format invalid",154:"Retain not supported",155:"QoS not supported",156:"Use another server",157:"Server moved",158:"Shared Subscriptions not supported",159:"Connection rate exceeded",160:"Maximum connect time",161:"Subscription Identifiers not supported",162:"Wildcard Subscriptions not supported"};t.default=(e,i)=>{const{messageId:o}=i,r=i.cmd;let s=null;const a=e.outgoing[o]?e.outgoing[o].cb:null;let c=null;if(a){switch(e.log("_handleAck :: packet type",r),r){case"pubcomp":case"puback":{const r=i.reasonCode;r&&r>0&&16!==r?(c=new n.ErrorWithReasonCode(`Publish error: ${t.ReasonCodes[r]}`,r),e._removeOutgoingAndStoreMessage(o,(()=>{a(c,i)}))):e._removeOutgoingAndStoreMessage(o,a);break}case"pubrec":{s={cmd:"pubrel",qos:2,messageId:o};const r=i.reasonCode;r&&r>0&&16!==r?(c=new n.ErrorWithReasonCode(`Publish error: ${t.ReasonCodes[r]}`,r),e._removeOutgoingAndStoreMessage(o,(()=>{a(c,i)}))):e._sendPacket(s);break}case"suback":{delete e.outgoing[o],e.messageIdProvider.deallocate(o);const n=i.granted;for(let i=0;i<n.length;i++){const r=n[i];if(128&r){c=new Error(`Subscribe error: ${t.ReasonCodes[r]}`),c.code=r;const i=e.messageIdToTopic[o];i&&i.forEach((t=>{delete e._resubscribeTopics[t]}))}}delete e.messageIdToTopic[o],e._invokeStoreProcessingQueue(),a(c,i);break}case"unsuback":delete e.outgoing[o],e.messageIdProvider.deallocate(o),e._invokeStoreProcessingQueue(),a(null,i);break;default:e.emit("error",new Error("unrecognized packet type"))}e.disconnecting&&0===Object.keys(e.outgoing).length&&e.emit("outgoingEmpty")}else e.log("_handleAck :: Server sent an ack in error. Ignoring.")}},9129:e=>{"use strict";function t(e){return e instanceof Buffer?Buffer.from(e):new e.constructor(e.buffer.slice(),e.byteOffset,e.length)}e.exports=function(e){if((e=e||{}).circles)return function(e){const i=[],n=[],o=new Map;if(o.set(Date,(e=>new Date(e))),o.set(Map,((e,t)=>new Map(s(Array.from(e),t)))),o.set(Set,((e,t)=>new Set(s(Array.from(e),t)))),e.constructorHandlers)for(const t of e.constructorHandlers)o.set(t[0],t[1]);let r=null;return e.proto?c:a;function s(e,s){const a=Object.keys(e),c=new Array(a.length);for(let l=0;l<a.length;l++){const p=a[l],u=e[p];if("object"!=typeof u||null===u)c[p]=u;else if(u.constructor!==Object&&(r=o.get(u.constructor)))c[p]=r(u,s);else if(ArrayBuffer.isView(u))c[p]=t(u);else{const e=i.indexOf(u);c[p]=-1!==e?n[e]:s(u)}}return c}function a(e){if("object"!=typeof e||null===e)return e;if(Array.isArray(e))return s(e,a);if(e.constructor!==Object&&(r=o.get(e.constructor)))return r(e,a);const c={};i.push(e),n.push(c);for(const s in e){if(!1===Object.hasOwnProperty.call(e,s))continue;const l=e[s];if("object"!=typeof l||null===l)c[s]=l;else if(l.constructor!==Object&&(r=o.get(l.constructor)))c[s]=r(l,a);else if(ArrayBuffer.isView(l))c[s]=t(l);else{const e=i.indexOf(l);c[s]=-1!==e?n[e]:a(l)}}return i.pop(),n.pop(),c}function c(e){if("object"!=typeof e||null===e)return e;if(Array.isArray(e))return s(e,c);if(e.constructor!==Object&&(r=o.get(e.constructor)))return r(e,c);const a={};i.push(e),n.push(a);for(const s in e){const l=e[s];if("object"!=typeof l||null===l)a[s]=l;else if(l.constructor!==Object&&(r=o.get(l.constructor)))a[s]=r(l,c);else if(ArrayBuffer.isView(l))a[s]=t(l);else{const e=i.indexOf(l);a[s]=-1!==e?n[e]:c(l)}}return i.pop(),n.pop(),a}}(e);const i=new Map;if(i.set(Date,(e=>new Date(e))),i.set(Map,((e,t)=>new Map(o(Array.from(e),t)))),i.set(Set,((e,t)=>new Set(o(Array.from(e),t)))),e.constructorHandlers)for(const t of e.constructorHandlers)i.set(t[0],t[1]);let n=null;return e.proto?function e(r){if("object"!=typeof r||null===r)return r;if(Array.isArray(r))return o(r,e);if(r.constructor!==Object&&(n=i.get(r.constructor)))return n(r,e);const s={};for(const o in r){const a=r[o];"object"!=typeof a||null===a?s[o]=a:a.constructor!==Object&&(n=i.get(a.constructor))?s[o]=n(a,e):ArrayBuffer.isView(a)?s[o]=t(a):s[o]=e(a)}return s}:function e(r){if("object"!=typeof r||null===r)return r;if(Array.isArray(r))return o(r,e);if(r.constructor!==Object&&(n=i.get(r.constructor)))return n(r,e);const s={};for(const o in r){if(!1===Object.hasOwnProperty.call(r,o))continue;const a=r[o];"object"!=typeof a||null===a?s[o]=a:a.constructor!==Object&&(n=i.get(a.constructor))?s[o]=n(a,e):ArrayBuffer.isView(a)?s[o]=t(a):s[o]=e(a)}return s};function o(e,o){const r=Object.keys(e),s=new Array(r.length);for(let a=0;a<r.length;a++){const c=r[a],l=e[c];"object"!=typeof l||null===l?s[c]=l:l.constructor!==Object&&(n=i.get(l.constructor))?s[c]=n(l,o):ArrayBuffer.isView(l)?s[c]=t(l):s[c]=o(l)}return s}}},9145:(e,t,i)=>{"use strict";i.d(t,{w:()=>o});var n=i(857);class o extends Error{code;params;wrappedErrors;constructor(e,t,...i){e instanceof Array||(i=("undefined"==typeof t?[]:[t]).concat(i),t=e,e=[]),super(t),this.code=t||"E_UNEXPECTED",this.params=i,this.wrappedErrors=e,this.name=this.toString(),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}static wrap(e,t,...i){const n=s(e.message),r=("wrappedErrors"in e?e.wrappedErrors:[]).concat(e);return t||(t=n?e.message:"E_UNEXPECTED"),e.message&&!n&&i.push(e.message),new o(r,t,...i)}static cast(e,t,...i){return r(e)?e:o.wrap(e,t,...i)}static bump(e,t,...i){return r(e)?o.wrap(e,e.code,...e.params):o.wrap(e,t,...i)}toString(){return(this.wrappedErrors.length?this.wrappedErrors[this.wrappedErrors.length-1].stack+n.EOL:"")+this.constructor.name+": "+this.code+" ("+this.params.join(", ")+")"}}function r(e){return!!(e instanceof o)||!!(e.constructor&&e.constructor.name&&e.constructor.name.endsWith("Error")&&"code"in e&&"string"==typeof e.code&&s(e.code)&&"params"in e&&e.params&&e.params instanceof Array)}function s(e){return/^([A-Z0-9_]+)$/.test(e)}},9150:(e,t)=>{"use strict";function i(e,t){return e<t&&t-e>32768||e>t&&e-t<32768}function n(e,t){const i=2147483648;return e<t&&t-e>i||e>t&&e-t<i}Object.defineProperty(t,"__esModule",{value:!0}),t.int=void 0,t.uint8Add=function(e,t){return e+t&255},t.uint16Add=function(e,t){return e+t&65535},t.uint32Add=function(e,t){return Number(BigInt(e)+BigInt(t)&0xffffffffn)},t.uint24=function(e){return 16777215&e},t.uint16Gt=i,t.uint16Gte=function(e,t){return e===t||i(e,t)},t.uint32Gt=n,t.uint32Gte=function(e,t){return e===t||n(e,t)};t.int=e=>Number.parseInt(e,10)},9151:function(e,t,i){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[t.length]=i);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i=n(e),s=0;s<i.length;s++)"default"!==i[s]&&o(t,e,i[s]);return r(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.ReolinkCamera=t.b64ToMo=t.moToB64=void 0;const a=i(7260),c=s(i(3861)),l=i(3540),p=i(2203),u=i(8218),d=i(5311),h=i(5629),m=i(8705);t.moToB64=async e=>{const t=await c.default.mediaManager.convertMediaObjectToBuffer(e,"image/jpeg");return t?.toString("base64")};t.b64ToMo=async e=>{const t=Buffer.from(e,"base64");return await c.default.mediaManager.createMediaObject(t,"image/jpeg")};class f extends c.ScryptedDeviceBase{constructor(e,t){super(t),this.camera=e}async turnOff(){this.on=!1,await this.setSiren(!1)}async turnOn(){this.on=!0,await this.setSiren(!0)}async setSiren(e){const t=this.camera.getClient();if(this.camera.storageSettings.values.doorbell)return e?(this.sirenTimeout=setTimeout((async()=>{await this.turnOff()}),4e3),void await t.setSiren(this.camera.getRtspChannel(),!0,1)):(clearInterval(this.sirenTimeout),void await t.setSiren(this.camera.getRtspChannel(),!1));await t.setSiren(this.camera.getRtspChannel(),e)}}class g extends c.ScryptedDeviceBase{constructor(e,t){super(t),this.camera=e}async setBrightness(e){this.brightness=e,await this.setFloodlight(void 0,e)}async turnOff(){this.on=!1,await this.setFloodlight(!1)}async turnOn(){this.on=!0,await this.setFloodlight(!0)}async setFloodlight(e,t){const i=this.camera.getClient();await i.setWhiteLedState(this.camera.getRtspChannel(),e,t)}}class v extends c.ScryptedDeviceBase{constructor(e,t){super(t),this.camera=e}async turnOff(){this.on=!1,await this.setPir(!1)}async turnOn(){this.on=!0,await this.setPir(!0)}async setPir(e){const t=this.camera.getClient();await t.setPirState(this.camera.getRtspChannel(),e)}}class y extends h.RtspSmartCamera{constructor(e,t){super(e,t),this.onvifIntercom=new d.OnvifIntercom(this),this.storageSettings=new l.StorageSettings(this,{logLevel:{...m.logLevelSetting},doorbell:{title:"Doorbell",description:"This camera is a Reolink Doorbell.",type:"boolean"},rtspChannel:{subgroup:"Advanced",title:"Channel",type:"number"},motionTimeout:{subgroup:"Advanced",title:"Motion Timeout",defaultValue:20,type:"number"},presets:{subgroup:"Advanced",title:"Presets",description:'PTZ Presets in the format "id=name". Where id is the PTZ Preset identifier and name is a friendly name.',multiple:!0,defaultValue:[],combobox:!0,onPut:async(e,t)=>{const i={...this.ptzCapabilities,presets:{}};for(const e of t){const[t,n]=e.split("=");i.presets[t]=n}this.ptzCapabilities=i},mapGet:()=>{const e=this.ptzCapabilities?.presets||{};return Object.entries(e).map((([e,t])=>e+"="+t))}},cachedPresets:{multiple:!0,hide:!0,json:!0,defaultValue:[]},cachedOsd:{multiple:!0,hide:!0,json:!0,defaultValue:[]},useOnvifTwoWayAudio:{subgroup:"Advanced",title:"Use ONVIF for Two-Way Audio",type:"boolean"},prebufferSet:{type:"boolean",hide:!0}}),this.plugin=t,this.storageSettings.settings.useOnvifTwoWayAudio.onGet=async()=>({hide:!!this.storageSettings.values.doorbell}),this.storageSettings.settings.presets.onGet=async()=>({choices:this.storageSettings.values.cachedPresets.map((e=>e.id+"="+e.name))});const i=Number(this.storageSettings.values.rtspChannel);Number.isNaN(i)||this.plugin.cameraChannelMap.set(this.id,this),this.init().catch(this.getLogger().error)}getLogger(){return(0,m.getBaseLogger)({console:this.console,storage:this.storageSettings})}async init(){setTimeout((async()=>{const e=this.getLogger();for(;!this.plugin.client.loggedIn;)e.log("Waiting for plugin connection"),await(0,a.sleep)(3e3);if(this.updatePtzCaps(),await this.updateDevice(),await this.reportDevices(),this.updateDeviceInfo(),this.hasBattery()&&!this.storageSettings.getItem("prebufferSet")){const t=c.default.systemManager.getDeviceById(this.id);e.log("Disabling prebbufer for battery cam"),await t.putSetting("prebuffer:enabledStreams","[]"),this.storageSettings.values.prebufferSet=!0}}),5e3)}getClient(){return this.plugin.getClient()}async getVideoTextOverlays(){if(!this.getClient())return;const{cachedOsd:e}=this.storageSettings.values;return{osdChannel:{text:e.value.Osd.osdChannel.enable?e.value.Osd.osdChannel.name:void 0},osdTime:{text:!!e.value.Osd.osdTime.enable,readonly:!0}}}async setVideoTextOverlay(e,t){const i=this.getClient();if(!i)return;const n=await i.getOsd(this.getRtspChannel());if("osdChannel"===e){const e=n.value.Osd.osdChannel;e.enable=t.text?1:0,e.name="string"==typeof t.text&&t.text?t.text:e.name||"Camera"}else{if("osdTime"!==e)throw new Error("unknown overlay: "+e);n.value.Osd.osdTime.enable=t.text?1:0}await i.setOsd(this.getRtspChannel(),n)}updatePtzCaps(){const{hasPanTilt:e,hasZoom:t}=this.getPtzCapabilities();this.ptzCapabilities={...this.ptzCapabilities,pan:e,tilt:e,zoom:t}}getAbilities(){return this.plugin.storageSettings.values.abilities?.Ability?.abilityChn?.[this.getRtspChannel()]}async getDetectionInput(e,t){}async ptzCommand(e){const t=this.getClient();t&&t.ptz(this.getRtspChannel(),e)}getDeviceData(){const e=this.getRtspChannel();return this.plugin.storageSettings.values.devicesData?.[e]}async getObjectTypes(){try{const e=this.getDeviceData(),t=e?.ai,i=[];for(const e of Object.keys(t??{})){if("channel"===e)continue;const{alarm_state:n,support:o}=t[e];o&&i.push(e)}return{classes:i}}catch(e){return{classes:[]}}}async startIntercom(e){if(!this.onvifIntercom.url){const e=await this.getOnvifClient(),t=await e.getStreamUrl();this.onvifIntercom.url=t}return this.onvifIntercom.startIntercom(e)}stopIntercom(){return this.onvifIntercom.stopIntercom()}hasSiren(){const e=this.getAbilities(),t=e?.supportAudioAlarm;return t&&0!==t?.ver}hasFloodlight(){const e=this.getAbilities();return(e?.floodLight?.ver??0)>0||(e?.supportFLswitch?.ver??0)>0||(e?.supportFLBrightness?.ver??0)>0}hasBattery(){const e=this.getAbilities();return(e?.battery?.ver??0)>0}getPtzCapabilities(){const e=this.getAbilities(),t=(e?.supportDigitalZoom?.ver??0)>0,i=(e?.ptzCtrl?.ver??0)>0,n=(e?.ptzPreset?.ver??0)>0;return{hasZoom:t,hasPanTilt:i,hasPresets:n,hasPtz:t||i||n}}hasPtzCtrl(){const e=this.getAbilities();return(e?.supportDigitalZoom?.ver??0)>0}hasPirEvents(){const e=this.getAbilities();return(e?.mdWithPir?.ver??0)>0}async updateDevice(){const e=this.provider.getInterfaces();let t=c.ScryptedDeviceType.Camera,i="Reolink Camera";this.storageSettings.values.doorbell&&(e.push(c.ScryptedInterface.BinarySensor),t=c.ScryptedDeviceType.Doorbell,i="Reolink Doorbell"),(this.storageSettings.values.doorbell||this.storageSettings.values.useOnvifTwoWayAudio)&&e.push(c.ScryptedInterface.Intercom);const n=this.getRtspChannel();i=this.plugin.storageSettings.values.devicesData[n]?.channelStatus?.name,this.getPtzCapabilities().hasPtz&&e.push(c.ScryptedInterface.PanTiltZoom),(await this.getObjectTypes()).classes.length>0&&e.push(c.ScryptedInterface.ObjectDetector),(this.hasSiren()||this.hasFloodlight()||this.hasPirEvents())&&e.push(c.ScryptedInterface.DeviceProvider),this.hasBattery()&&e.push(c.ScryptedInterface.Battery,c.ScryptedInterface.Sleep),await this.provider.updateDevice(this.nativeId,i??this.name,e,t)}async processBatteryData(e){this.eventsEmitter.emit("data",JSON.stringify(e));const t=this.getLogger(),{batteryLevel:i,sleeping:n}=e;t.debug(`Battery info received: ${JSON.stringify(e)}`),n!==this.sleeping&&(this.sleeping=n),i!==this.batteryLevel&&(this.batteryLevel=i)}async processDeviceStatusData(e){this.eventsEmitter.emit("data",JSON.stringify(e));const{floodlightEnabled:t,pirEnabled:i,ptzPresets:n,osd:o}=e;this.getLogger().info(`Device status received: ${JSON.stringify(e)}`),this.floodlight&&t!==this.floodlight.on&&(this.floodlight.on=t),this.pirSensor&&i!==this.pirSensor.on&&(this.pirSensor.on=i),n&&(this.storageSettings.values.cachedPresets=n),o&&(this.storageSettings.values.cachedOsd=o)}updateDeviceInfo(){const e=this.plugin.storageSettings.values.address;if(!e)return;const t=this.info||{};t.ip=e;const i=this.getDeviceData();t.serialNumber=i?.serial,t.firmware=i?.firmVer,t.version=i?.boardInfo,t.model=i?.typeInfo,t.manufacturer="Reolink",t.managementUrl=`http://${e}`,this.info=t}async getOnvifClient(){return this.onvifClient||(this.onvifClient=await this.createOnvifClient()),this.onvifClient}createOnvifClient(){const{username:e,password:t}=this.plugin.storageSettings.values;return(0,u.connectCameraAPI)(this.plugin.getHttpAddress(),e,t,this.getLogger(),this.storageSettings.values.doorbell?this.storage.getItem("onvifDoorbellEvent"):void 0)}async processEvents(e){this.eventsEmitter.emit("data",JSON.stringify(e));if(this.getLogger().debug(`Events received: ${JSON.stringify(e)}`),e.motion!==this.motionDetected&&(e.motion?(this.motionDetected=!0,this.motionTimeout&&clearTimeout(this.motionTimeout),this.motionTimeout=setTimeout((()=>this.motionDetected=!1),1e3*this.storageSettings.values.motionTimeout)):(this.motionDetected=!1,this.motionTimeout&&clearTimeout(this.motionTimeout))),e.objects.length){const t={timestamp:Date.now(),detections:[]};for(const i of e.objects)t.detections.push({className:i,score:1});c.default.deviceManager.onDeviceEvent(this.nativeId,c.ScryptedInterface.ObjectDetector,t)}}async listenEvents(){const e=new p.EventEmitter,t={on:function(t,i){e.on(t,i)},destroy:function(){},emit:function(t,...i){return e.emit(t,...i)}};return this.eventsEmitter=t,t}async takeSnapshotInternal(e){const i=Date.now(),n=this.getClient(),o=await this.createMediaObject(await n.jpegSnapshot(this.getRtspChannel(),e),"image/jpeg");return this.lastB64Snapshot=await(0,t.moToB64)(o),this.lastSnapshotTaken=i,o}async takeSmartCameraPicture(e){const i=this.hasBattery(),n=Date.now(),o=this.getLogger(),r=!this.lastSnapshotTaken||n-this.lastSnapshotTaken>36e5,s=!this.lastSnapshotTaken||n-this.lastSnapshotTaken>15e3;let a=!1;if(this.lastB64Snapshot&&this.lastSnapshotTaken?this.sleeping&&r?(o.log("Allowing new snapshot while sleeping because older than 1 hour"),a=!0):!this.sleeping&&i&&s?(o.log("Allowing new snapshot because older than 15 seconds"),a=!0):a=!0:(o.log("Allowing new snapshot because not taken yet"),a=!0),a)return this.takeSnapshotInternal(e?.timeout);if(this.lastB64Snapshot){return await(0,t.b64ToMo)(this.lastB64Snapshot)}return null}getRtspChannel(){return this.storageSettings.values.rtspChannel}createRtspMediaStreamOptions(e,t){const i=(0,h.createRtspMediaStreamOptions)(e,t);return i.tool="scrypted",i}addRtspCredentials(e){const{username:t,password:i}=this.plugin.storageSettings.values,n=new URL(e);return n.username=t,n.password=i,n.toString()}async createVideoStream(e){return await this.plugin.client.login(),super.createVideoStream(e)}async getConstructedVideoStreamOptions(){return this.videoStreamOptions||=this.getConstructedVideoStreamOptionsInternal().catch((e=>{throw this.constructedVideoStreamOptions=void 0,e})),this.videoStreamOptions}async getConstructedVideoStreamOptionsInternal(){const e=this.getClient();if(!e)return;let t;try{t=await e.getEncoderConfiguration(this.getRtspChannel())}catch(e){this.getLogger().error("Codec query failed. Falling back to known defaults.",e)}const i=(this.getRtspChannel()+1).toString().padStart(2,"0"),n=[{name:"",id:`h264Preview_${i}_main`,container:"rtsp",video:{codec:"h264",width:2560,height:1920},url:""},{name:"",id:`h264Preview_${i}_sub`,container:"rtsp",video:{codec:"h264",width:640,height:480},url:""}];for(const e of n){var o;"rtsp"===e.container&&(o=new URL(`rtsp://${this.getRtspAddress()}/${e.id}`),e.url=o.toString(),e.name=`RTSP ${e.id}`)}if(t){const{mainStream:e}=t;if(e?.width&&e?.height)for(const t of n)"main.bcs"!==t.id&&t.id!==`h264Preview_${i}_main`||(t.video.width=e.width,t.video.height=e.height),"h265"!==e.vType&&"hevc"!==e.vType||t.id===`h264Preview_${i}_main`&&(this.getLogger().warn("Detected h265. Change the camera configuration to use 2k mode to force h264. https://docs.scrypted.app/camera-preparation.html#h-264-video-codec"),t.video.codec="h265",t.id=`h265Preview_${i}_main`,t.name=`RTSP ${t.id}`,t.url=`rtsp://${this.getRtspAddress()}/${t.id}`,this.hasBattery()&&(t.allowBatteryPrebuffer=!1))}return n}async getSettings(){return await this.storageSettings.getSettings()}async putSetting(e,t){this.storageSettings.keys[e]?await this.storageSettings.putSetting(e,t):await super.putSetting(e,t)}showRtspUrlOverride(){return!1}getRtspAddress(){const{address:e,rtspPort:t}=this.plugin.storageSettings.values;return`${e}:${t}`}async reportDevices(){const e=this.hasSiren(),t=this.hasFloodlight(),i=this.hasPirEvents(),n=[];if(e){const e=`${this.nativeId}-siren`,t={providerNativeId:this.nativeId,name:`${this.name} Siren`,nativeId:e,info:{...this.info},interfaces:[c.ScryptedInterface.OnOff],type:c.ScryptedDeviceType.Siren};n.push(t)}if(t){const e=`${this.nativeId}-floodlight`,t={providerNativeId:this.nativeId,name:`${this.name} Floodlight`,nativeId:e,info:{...this.info},interfaces:[c.ScryptedInterface.OnOff],type:c.ScryptedDeviceType.Light};n.push(t)}if(i){const e=`${this.nativeId}-pir`,t={providerNativeId:this.nativeId,name:`${this.name} PIR sensor`,nativeId:e,info:{...this.info},interfaces:[c.ScryptedInterface.OnOff],type:c.ScryptedDeviceType.Switch};n.push(t)}c.default.deviceManager.onDevicesChanged({providerNativeId:this.nativeId,devices:n})}async getDevice(e){return e.endsWith("-siren")?(this.siren||=new f(this,e),this.siren):e.endsWith("-floodlight")?(this.floodlight||=new g(this,e),this.floodlight):e.endsWith("-pir")?(this.pirSensor||=new v(this,e),this.pirSensor):void 0}async releaseDevice(e,t){t.endsWith("-siren")?delete this.siren:t.endsWith("-floodlight")?delete this.floodlight:t.endsWith("-pir")&&delete this.pirSensor}}t.ReolinkCamera=y},9226:function(e,t,i){(function(){var t,n,o={}.hasOwnProperty;t=i(5068),n=i(4472),e.exports=function(e){function i(e,n){if(i.__super__.constructor.call(this,e),null==n)throw new Error("Missing comment text. "+this.debugInfo());this.name="#comment",this.type=t.Comment,this.value=this.stringify.comment(n)}return function(e,t){for(var i in t)o.call(t,i)&&(e[i]=t[i]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(i,e),i.prototype.clone=function(){return Object.create(this)},i.prototype.toString=function(e){return this.options.writer.comment(this,this.options.writer.filterOptions(e))},i}(n)}).call(this)},9256:function(e,t,i){(function(){var t,n,o={}.hasOwnProperty;t=i(5068),n=i(4472),e.exports=function(e){function i(e,n){if(i.__super__.constructor.call(this,e),null==n)throw new Error("Missing element text. "+this.debugInfo());this.name="#text",this.type=t.Text,this.value=this.stringify.text(n)}return function(e,t){for(var i in t)o.call(t,i)&&(e[i]=t[i]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(i,e),Object.defineProperty(i.prototype,"isElementContentWhitespace",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(i.prototype,"wholeText",{get:function(){var e,t,i;for(i="",t=this.previousSibling;t;)i=t.data+i,t=t.previousSibling;for(i+=this.data,e=this.nextSibling;e;)i+=e.data,e=e.nextSibling;return i}}),i.prototype.clone=function(){return Object.create(this)},i.prototype.toString=function(e){return this.options.writer.text(this,this.options.writer.filterOptions(e))},i.prototype.splitText=function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())},i.prototype.replaceWholeText=function(e){throw new Error("This DOM method is not implemented."+this.debugInfo())},i}(n)}).call(this)},9278:e=>{"use strict";e.exports=require("net")},9280:function(e,t,i){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[t.length]=i);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i=n(e),s=0;s<i.length;s++)"default"!==i[s]&&o(t,e,i[s]);return r(t,e),t}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.RtspServer=t.RtspClient=t.RtspBase=t.RtspStatusError=t.H265_NAL_TYPE_SEI_SUFFIX=t.H265_NAL_TYPE_SEI_PREFIX=t.H265_NAL_TYPE_FU=t.H265_NAL_TYPE_CRA_NUT=t.H265_NAL_TYPE_IDR_N_LP=t.H265_NAL_TYPE_IDR_W_RADL=t.H265_NAL_TYPE_BLA_N_LP=t.H265_NAL_TYPE_BLA_W_RADL=t.H265_NAL_TYPE_BLA_W_LP=t.H265_NAL_TYPE_PPS=t.H265_NAL_TYPE_SPS=t.H265_NAL_TYPE_VPS=t.H265_NAL_TYPE_AGG=t.H264_NAL_TYPE_MTAP32=t.H264_NAL_TYPE_MTAP16=t.H264_NAL_TYPE_FU_B=t.H264_NAL_TYPE_FU_A=t.H264_NAL_TYPE_STAP_B=t.H264_NAL_TYPE_STAP_A=t.H264_NAL_TYPE_PPS=t.H264_NAL_TYPE_SPS=t.H264_NAL_TYPE_SEI=t.H264_NAL_TYPE_IDR=t.H264_NAL_TYPE_RESERVED31=t.H264_NAL_TYPE_RESERVED30=t.H264_NAL_TYPE_RESERVED0=t.RTSP_FRAME_MAGIC=void 0,t.readMessage=w,t.readBody=_,t.writeMessage=S,t.findH264NaluType=function(e,t){if("h264"!==e.type)return;return T(e.chunks[e.chunks.length-1].subarray(12),t)},t.findH265NaluType=function(e,t){if("h265"!==e.type)return;return C(e.chunks[e.chunks.length-1].subarray(12),t)},t.parseH264NaluType=x,t.findH264NaluTypeInNalu=T,t.findH265NaluTypeInNalu=C,t.getStartedH264NaluTypes=P,t.getNaluTypesInNalu=k,t.getStartedH265NaluTypes=O,t.getNaluTypesInH265Nalu=I,t.isH265KeyFrameRelatedInSet=A,t.createRtspParser=function(e){let i;return{container:"rtsp",tcpProtocol:"rtsp://127.0.0.1/"+(0,c.randomBytes)(8).toString("hex"),inputArguments:["-rtsp_transport","tcp"],outputArguments:["-rtsp_transport","tcp",...e?.vcodec||[],...e?.acodec||[],"-pkt_size","32000","-f","rtsp"],findSyncFrame(e){for(let i=0;i<e.length;i++){const n=e[i];if("h264"===n.type){const o=P(n);if(o.has(t.H264_NAL_TYPE_SPS)||o.has(t.H264_NAL_TYPE_IDR))return e.slice(i)}else if("h265"===n.type){if(A(O(n)))return e.slice(i)}}},sdp:new Promise((e=>i=e)),async*parse(e,t,n){const o=new j(e);await o.handleSetup(),i(o.sdp);for await(const{type:e,rtcp:i,header:r,packet:s}of o.handleRecord())yield{chunks:[r,s],type:`${i?"rtcp-":""}${e}`,width:t,height:n}}}},t.parseHeaders=R,t.getFirstAuthenticateHeader=D,t.parseSemicolonDelimited=M,t.listenSingleRtspClient=async function(e){const t=e?.pathToken||c.default.randomBytes(8).toString("hex");let{url:i,clientPromise:n,server:o}=await(0,m.listenZeroSingleClient)(e?.hostname);const r="/"+t;i=i.replace("tcp:","rtsp:")+r;const s=n.then((t=>{const i=(e?.createServer||(e=>new j(e)))(t);return i.checkRequest=async(e,t,n,o)=>{i.checkRequest=void 0;return new d.URL(t).pathname===r},i}));return{url:i,rtspServerPromise:s,server:o}};const c=s(i(6982)),l=i(4434),p=a(i(9278)),u=a(i(4756)),d=i(7016),h=i(890),m=i(4699),f=i(4520),g=i(4940),v=i(8938),y=i(7260),b=["realm","nonce"];async function w(e){let t=[];for(;;){let i=await(0,g.readLine)(e);if(i=i.trim(),!i)return t;t.push(i)}}async function _(e,t){const i=parseInt(t["content-length"]);if(i)return(0,g.readLength)(e,i)}function S(e,t,i,n,o){let r=void 0!==t?`${t}\r\n`:"";i&&(n["Content-Length"]=i.length.toString());for(const[e,t]of Object.entries(n))r+=`${e}: ${t}\r\n`;r+="\r\n",e.write(r),o?.log("rtsp outgoing message\n",r),o?.log(),i&&e.write(i)}function x(e){return 31&e}function T(e,i){const n=x(e[0]);if(n===t.H264_NAL_TYPE_STAP_A){let t=1;for(;t<e.length;){const n=e.readUInt16BE(t);t+=2;if(x(e[t])===i)return e.subarray(t,t+n);t+=n}}else if(n===t.H264_NAL_TYPE_FU_A){const t=x(e[1]),n=!!(128&e[1]);if(t===i&&n)return e.subarray(1)}else if(n===i)return e}function E(e){return(126&e)>>1}function C(e,i){const n=E(e[0]);if(n===t.H265_NAL_TYPE_AGG){let t=1;for(;t<e.length;){const n=e.readUInt16BE(t);t+=2;if(E(e[t])===i)return e.subarray(t,t+n);t+=n}}else if(n===i)return e}function P(e){return"h264"!==e.type?new Set:k(e.chunks[e.chunks.length-1].subarray(12),!0)}function k(e,i=!1,n=!1){const o=new Set,r=x(e[0]);if(r===t.H264_NAL_TYPE_STAP_A){o.add(t.H264_NAL_TYPE_STAP_A);let i=1;for(;i<e.length;){const t=e.readUInt16BE(i);i+=2;const n=x(e[i]);o.add(n),i+=t}}else if(r===t.H264_NAL_TYPE_FU_A){o.add(t.H264_NAL_TYPE_FU_A);const r=x(e[1]);if(i){!!(128&e[1])&&o.add(r)}else if(n){!!(64&e[1])&&o.add(r)}else o.add(r)}else o.add(r);return o}function O(e){return"h265"!==e.type?new Set:I(e.chunks[e.chunks.length-1].subarray(12),!0)}function I(e,i=!1,n=!1){const o=new Set,r=E(e[0]);if(r===t.H265_NAL_TYPE_AGG){o.add(t.H265_NAL_TYPE_AGG);let i=2;for(;i<e.length;){const t=e.readUInt16BE(i);i+=2;const n=E(e[i]);o.add(n),i+=t}}else if(r===t.H265_NAL_TYPE_FU){o.add(t.H265_NAL_TYPE_FU);const r=63&e[2];if(i){!!(128&e[2])&&o.add(r)}else if(n){!!(64&e[2])&&o.add(r)}else o.add(r)}else o.add(r);return o}function A(e,i=!0){return!!(e.has(t.H265_NAL_TYPE_IDR_N_LP)||e.has(t.H265_NAL_TYPE_IDR_W_RADL)||e.has(t.H265_NAL_TYPE_CRA_NUT)||e.has(t.H265_NAL_TYPE_BLA_N_LP)||e.has(t.H265_NAL_TYPE_BLA_W_LP)||e.has(t.H265_NAL_TYPE_BLA_W_RADL))||!(!i||!(e.has(t.H265_NAL_TYPE_VPS)||e.has(t.H265_NAL_TYPE_SPS)||e.has(t.H265_NAL_TYPE_PPS)))}function R(e){const t={};for(const i of e.slice(1)){const e=i.indexOf(":");let n="";-1!==e&&(n=i.substring(e+1).trim());t[i.substring(0,e).toLowerCase()]=n}return t}function D(e){for(const t of e.slice(1)){const e=t.indexOf(":");let i="";-1!==e&&(i=t.substring(e+1).trim());if("www-authenticate"===t.substring(0,e).toLowerCase())return i}}function M(e){const t={};for(const i of e.split(";")){const[e,n]=i.split("=",2);t[e]=n}return t}t.RTSP_FRAME_MAGIC=36,t.H264_NAL_TYPE_RESERVED0=0,t.H264_NAL_TYPE_RESERVED30=30,t.H264_NAL_TYPE_RESERVED31=31,t.H264_NAL_TYPE_IDR=5,t.H264_NAL_TYPE_SEI=6,t.H264_NAL_TYPE_SPS=7,t.H264_NAL_TYPE_PPS=8,t.H264_NAL_TYPE_STAP_A=24,t.H264_NAL_TYPE_STAP_B=25,t.H264_NAL_TYPE_FU_A=28,t.H264_NAL_TYPE_FU_B=29,t.H264_NAL_TYPE_MTAP16=26,t.H264_NAL_TYPE_MTAP32=27,t.H265_NAL_TYPE_AGG=48,t.H265_NAL_TYPE_VPS=32,t.H265_NAL_TYPE_SPS=33,t.H265_NAL_TYPE_PPS=34,t.H265_NAL_TYPE_BLA_W_LP=16,t.H265_NAL_TYPE_BLA_W_RADL=17,t.H265_NAL_TYPE_BLA_N_LP=18,t.H265_NAL_TYPE_IDR_W_RADL=19,t.H265_NAL_TYPE_IDR_N_LP=20,t.H265_NAL_TYPE_CRA_NUT=21,t.H265_NAL_TYPE_FU=49,t.H265_NAL_TYPE_SEI_PREFIX=39,t.H265_NAL_TYPE_SEI_SUFFIX=40;class N extends Error{constructor(e){super(`RTSP Error: ${e.line}`),this.status=e}}t.RtspStatusError=N;class L{constructor(){}write(e,t,i){S(this.client,e,i,t,this.console)}async readMessage(){const e=await w(this.client);return this.console?.log("rtsp incoming message\n",e.join("\n")),this.console?.log(),e}}t.RtspBase=L;t.RtspClient=class extends L{constructor(e){super(),this.url=e,this.cseq=0,this.needKeepAlive=!1,this.setupOptions=new Map,this.issuedTeardown=!1,this.hasGetParameter=!0;const t=new d.URL(e),i=parseInt(t.port)||554;e.startsWith("rtsps")?this.client=u.default.connect({rejectUnauthorized:!1,port:i,host:t.hostname}):this.client=p.default.connect(i,t.hostname),this.client.on("error",(e=>{this.console?.log("client error",e)}))}async safeTeardown(){if(!this.issuedTeardown){this.issuedTeardown=!0;try{this.writeTeardown(),await(0,y.sleep)(500)}catch(e){}finally{this.client.destroy()}}}async writeRequest(e,t,i,n){let o;t=t||{},i?i.includes("rtsp://")||i.includes("rtsps://")||"*"===i?o=i:(o=this.contentBase||this.url,o+=(o.endsWith("/")?"":"/")+i):o=this.url;const r=new d.URL(o);r.username="",r.password="";const s=`${e} ${r} RTSP/1.0`,a=this.cseq++;t.CSeq=a.toString(),t["User-Agent"]="Scrypted",this.wwwAuthenticate&&(t.Authorization=await this.createAuthorizationHeader(e,new d.URL(o))),this.session&&(t.Session=this.session),this.write(s,t,n)}async handleDataPayload(e){if(e[0]!==t.RTSP_FRAME_MAGIC)throw new Error("RTSP Client received invalid frame magic. This may be a bug in your camera firmware. If this error persists, switch your RTSP Parser to FFmpeg or Scrypted (UDP): "+e.toString());const i=e.readUInt8(1),n=e.readUInt16BE(2),o=await(0,g.readLength)(this.client,n),r=this.setupOptions.get(i);r?.onRtp?.(e,o)}async readDataPayload(){const e=await(0,g.readLength)(this.client,4);return this.handleDataPayload(e)}createBadHeader(e){return new Error("RTSP Client received invalid frame magic. This may be a bug in your camera firmware. If this error persists, switch your RTSP Parser to FFmpeg or Scrypted (UDP): "+e.toString())}async readLoopLegacy(){try{for(;;)this.needKeepAlive&&(this.needKeepAlive=!1,this.hasGetParameter?await this.getParameter():await this.options()),await this.readDataPayload()}catch(e){throw this.client.destroy(e),e}}async*handleStream(){for(;;){const e=await(0,g.readLength)(this.client,4);if(e[0]!==t.RTSP_FRAME_MAGIC){if("RTSP"!==e.toString())throw this.createBadHeader(e);this.client.unshift(e);const t=await super.readMessage();await this.readBody(R(t));continue}const i=e.readUInt16BE(2),n=await(0,g.readLength)(this.client,i),o=e.readUInt8(1);yield{channel:o,rtcp:o%2==1,header:e,packet:n}}}async readLoop(){const e=new h.Deferred;let i,n,o;const r=async()=>{this.needKeepAlive&&(this.needKeepAlive=!1,this.hasGetParameter?this.writeGetParameter():this.writeOptions());try{for(;;){if(!i){if(i=this.client.read(4),!i)return;if(i[0]!==t.RTSP_FRAME_MAGIC){if("RTSP"!==i.toString())throw this.createBadHeader(i);this.client.unshift(i),i=void 0,this.client.removeListener("readable",r);const e=await super.readMessage();await this.readBody(R(e));this.client.on("readable",r);continue}n=i.readUInt8(1),o=i.readUInt16BE(2)}const e=this.client.read(o);if(!e)return;const s=i;i=void 0;const a=this.setupOptions.get(n);a?.onRtp?.(s,e)}}catch(t){e.finished||e.reject(t),this.client.destroy()}};r(),this.client.on("readable",r),await Promise.all([(0,l.once)(this.client,"end")])}async readMessage(){for(;;){const e=await(0,g.readLength)(this.client,4);if(e[0]!==t.RTSP_FRAME_MAGIC){if("RTSP"===e.toString()){this.client.unshift(e);return await super.readMessage()}throw this.createBadHeader(e)}await this.handleDataPayload(e)}}async createAuthorizationHeader(e,t){if(!this.wwwAuthenticate)throw new Error("no WWW-Authenticate found");const{BASIC:n}=await Promise.resolve().then(i.bind(i,7486)),{parseHTTPHeadersQuotedKeyValueSet:o}=await Promise.resolve().then(i.bind(i,6284)),r=new d.URL(this.url),s=decodeURIComponent(r.username),a=decodeURIComponent(r.password);if(this.wwwAuthenticate.includes("Basic")){return`Basic ${n.computeHash({username:s,password:a})}`}const l=o(this.wwwAuthenticate,{indexOf:()=>0},b),p=new d.URL(t.toString());p.username="",p.password="";const u=c.default.createHash("md5").update(`${s}:${l.realm}:${a}`).digest("hex"),h=c.default.createHash("md5").update(`${e}:${p}`).digest("hex"),m=c.default.createHash("md5").update(`${u}:${l.nonce}:${h}`).digest("hex"),f={username:s,realm:l.realm,nonce:l.nonce,uri:p.toString(),algorithm:"MD5",response:m};return`Digest ${Object.entries(f).map((([e,t])=>{return`${e}=${t&&(i=t,`"${i.replace(/"/g,'\\"')}"`)}`;var i})).join(", ")}`}async readBody(e){return _(this.client,e)}async request(e,t,i,n,o){await this.writeRequest(e,t,i,n);const r=this.requestTimeout?await(0,f.timeoutPromise)(this.requestTimeout,this.readMessage()):await this.readMessage(),s=r[0],[a,c,l]=s.split(" ",3),p=parseInt(c),u=R(r),d={line:s,code:p,version:a,reason:l};if(200!==p&&!u["www-authenticate"])throw new N(d);const h=D(r)||u["www-authenticate"];if(h){if(o)throw new Error("auth failed");return this.wwwAuthenticate=h,this.request(e,t,i,n,!0)}return{headers:u,body:await this.readBody(u),status:d}}async options(){const e=await this.request("OPTIONS",{}),t=e.headers.public;return t&&(this.hasGetParameter=t.toLowerCase().includes("get_parameter")),e}writeOptions(){return this.writeRequest("OPTIONS")}async getParameter(){return this.request("GET_PARAMETER")}writeGetParameter(){return this.writeRequest("GET_PARAMETER")}async describe(e){const t=await this.request("DESCRIBE",{...e||{},Accept:"application/sdp"});return this.contentBase=t.headers["content-base"]||t.headers["content-location"],this.contentBase&&(this.contentBase=new d.URL(this.contentBase,this.url).toString()),t}async setup(e,t){const i="udp"===e.type?"":"/TCP",n="udp"===e.type?"client_port":"interleaved";let o;if("tcp"===e.type)o=e.port;else{if(!e.dgram){const t=await(0,m.createBindZero)();e.dgram=t.server,this.client.on("close",(()=>(0,m.closeQuiet)(t.server)))}o=e.dgram.address().port,e.dgram.on("message",(t=>e.onRtp(void 0,t)))}t=Object.assign({Transport:`RTP/AVP${i};unicast;${n}=${o}-${o+1}`},t);const r=await this.request("SETUP",t,e.path);let s;if(r.headers.session){const e=M(r.headers.session);let t=parseInt(e.timeout);if(t){let e=setInterval((()=>this.needKeepAlive=!0),1e3*(t-5));this.client.once("close",(()=>clearInterval(e)))}this.session=r.headers.session.split(";")[0]}if(r.headers.transport){const e=r.headers.transport.match(/.*?interleaved=([0-9]+)-([0-9]+)/);if(e){const[t,i,n]=e;i&&n&&(s={begin:parseInt(i),end:parseInt(n)})}}return"tcp"===e.type&&this.setupOptions.set(s?s.begin:o,e),Object.assign({interleaved:s,options:e},r)}async play(e={},t="0.000"){return e.Range=`npt=${t}-`,this.request("PLAY",e)}writePlay(e="0.000"){const t={Range:`npt=${e}-`};return this.writeRequest("PLAY",t)}writeRtpPayload(e,t){return this.client.write(e),this.client.write(Buffer.from(t))}send(e,i){const n=Buffer.alloc(4);return n.writeUInt8(t.RTSP_FRAME_MAGIC,0),n.writeUInt8(i,1),n.writeUInt16BE(e.length,2),this.writeRtpPayload(n,e)}async pause(){return this.request("PAUSE")}async teardown(){try{return await this.request("TEARDOWN")}finally{this.client.destroy()}}writeTeardown(){this.writeRequest("TEARDOWN")}};class j{constructor(e,t,i,n){this.client=e,this.sdp=t,this.udp=i,this.checkRequest=n,this.setupTracks={},this.availableOptions=["DESCRIBE","OPTIONS","PAUSE","PLAY","SETUP","TEARDOWN","ANNOUNCE","RECORD","GET_PARAMETER"],this.session=(0,c.randomBytes)(4).toString("hex"),t&&(t=t.trim()),e instanceof p.default.Socket&&e.setNoDelay(!0)}async handleSetup(e=["play","record","teardown"]){let t=[];for(;;){let i=await(0,g.readLine)(this.client);if(i=i.trim(),i)t.push(i);else{const i=await this.headers(t);if(e.includes(i))return i;t=[]}}}async handlePlayback(){return this.handleSetup()}async handleTeardown(){return this.handleSetup()}async*handleRecord(){for(;;){const e=await(0,g.readLength)(this.client,4);if(e[0]!==t.RTSP_FRAME_MAGIC)throw new Error("RTSP Server expected frame magic but received: "+e.toString());const i=e.readUInt16BE(2),n=await(0,g.readLength)(this.client,i),o=e.readUInt8(1),r=o-o%2,s=Object.values(this.setupTracks).find((e=>e.destination===r));if(!s)throw new Error("RSTP Server received unknown channel: "+o);yield{type:s.codec,rtcp:o%2==1,header:e,packet:n}}}writeRtpPayload(e,t){return this.client.write(e),this.client.write(Buffer.from(t))}send(e,t){const i=Buffer.alloc(4);return i.writeUInt8(36,0),i.writeUInt8(t,1),i.writeUInt16BE(e.length,2),this.writeRtpPayload(i,e)}sendUdp(e,t,i){e.send(i,t,"127.0.0.1")}sendTrack(e,t,i){const n=this.setupTracks[e];return n?"udp"===n.protocol?(this.udp?this.sendUdp(i?n.rtcp:n.rtp,n.destination,t):this.console?.warn("RTSP Server UDP socket not available."),!0):this.send(t,i?n.destination+1:n.destination):(this.console?.warn("RTSP Server track not found:",e),!0)}options(e,t){const i={};i.Public=this.availableOptions.join(", "),this.respond(200,"OK",t,i)}async get_parameter(e,t){this.respond(200,"OK",t,{})}describe(e,t){const i={};i["Content-Base"]=e,i["Content-Type"]="application/sdp",this.respond(200,"OK",t,i,Buffer.from(this.sdp))}setupInterleaved(e,t,i){this.setupTracks[e.control]={control:e.control,protocol:"tcp",destination:t,codec:e.codec}}async setup(e,t){const i={};let n=t.transport;i.Session=this.session;const o=(0,v.parseSdp)(this.sdp).msections.find((t=>e.endsWith(t.control)));if(o){if(n.includes("TCP"))if(this.resolveInterleaved){const[e,t]=this.resolveInterleaved(o);this.setupInterleaved(o,e,t),n=`RTP/AVP/TCP;unicast;interleaved=${e}-${t}`}else{const e=n.match(/.*?interleaved=([0-9]+)-([0-9]+)/);if(e){const t=parseInt(e[1]),i=parseInt(e[2]);this.setupInterleaved(o,t,i)}}else{if(!this.udp)return void this.respond(461,"Unsupported Transport",t,{});const e=n.match(/.*?client_port=([0-9]+)-([0-9]+)/),[i,r,s]=e,[a,c]=await(0,m.createSquentialBindZero)();this.client.on("close",(()=>(0,m.closeQuiet)(a.server))),this.client.on("close",(()=>(0,m.closeQuiet)(c.server))),this.setupTracks[o.control]={control:o.control,protocol:"udp",destination:parseInt(r),codec:o.codec,rtp:a.server,rtcp:c.server},n=n.replace("RTP/AVP/UDP","RTP/AVP").replace("RTP/AVP","RTP/AVP/UDP"),n+=`;server_port=${a.port}-${c.port}`}i.Transport=n,this.respond(200,"OK",t,i)}else this.respond(404,"Not Found",t,i)}play(e,t){const i={},n=Object.values(this.setupTracks).map((t=>`url=${e}/${t.control}`)).join(",");i["RTP-Info"]=n,i.Range="npt=now-",i.Session=this.session,this.respond(200,"OK",t,i)}async announce(e,t){const i=parseInt(t["content-length"]),n=await(0,g.readLength)(this.client,i);this.sdp=n.toString();const o={};o.Session=this.session,this.respond(200,"OK",t,o)}async record(e,t){const i={};i.Session=this.session,this.respond(200,"OK",t,i)}async teardown(e,t){const i={};i.Session=this.session,this.respond(200,"OK",t,i),this.client.destroy()}async headers(e){this.console?.log("request headers",e.join("\n"));let[t,i]=e[0].split(" ",2);t=t.toLowerCase();const n=R(e);if(this.checkRequest){let o;try{o=await this.checkRequest(t,i,n,e)}catch(e){this.console?.error("error checking request",e)}if(!o)throw this.respond(400,"Bad Request",n,{}),this.client.destroy(),new Error("check request failed")}if(this[t]&&this.availableOptions.includes(t.toUpperCase()))return await this[t](i,n),t;this.respond(400,"Bad Request",n,{})}respond(e,t,i,n,o){let r=`RTSP/1.0 ${e} ${t}\r\n`;i.cseq&&(n.CSeq=i.cseq),o&&(n["Content-Length"]=o.length.toString());for(const[e,t]of Object.entries(n))r+=`${e}: ${t}\r\n`;this.console?.log("response headers",r),r+="\r\n",this.client.write(r),o&&(this.client.write(o),this.console?.log("response body",o.toString()))}destroy(){this.client.destroy();for(const e of Object.values(this.setupTracks))(0,m.closeQuiet)(e.rtp),(0,m.closeQuiet)(e.rtcp)}}t.RtspServer=j},9299:function(e,t,i){(function(){var t;t=i(5068),i(8711),e.exports=function(){function e(e,i,n){if(this.parent=e,this.parent&&(this.options=this.parent.options,this.stringify=this.parent.stringify),null==i)throw new Error("Missing attribute name. "+this.debugInfo(i));this.name=this.stringify.name(i),this.value=this.stringify.attValue(n),this.type=t.Attribute,this.isId=!1,this.schemaTypeInfo=null}return Object.defineProperty(e.prototype,"nodeType",{get:function(){return this.type}}),Object.defineProperty(e.prototype,"ownerElement",{get:function(){return this.parent}}),Object.defineProperty(e.prototype,"textContent",{get:function(){return this.value},set:function(e){return this.value=e||""}}),Object.defineProperty(e.prototype,"namespaceURI",{get:function(){return""}}),Object.defineProperty(e.prototype,"prefix",{get:function(){return""}}),Object.defineProperty(e.prototype,"localName",{get:function(){return this.name}}),Object.defineProperty(e.prototype,"specified",{get:function(){return!0}}),e.prototype.clone=function(){return Object.create(this)},e.prototype.toString=function(e){return this.options.writer.attribute(this,this.options.writer.filterOptions(e))},e.prototype.debugInfo=function(e){return null==(e=e||this.name)?"parent: <"+this.parent.name+">":"attribute: {"+e+"}, parent: <"+this.parent.name+">"},e.prototype.isEqualNode=function(e){return e.namespaceURI===this.namespaceURI&&(e.prefix===this.prefix&&(e.localName===this.localName&&e.value===this.value))},e}()}).call(this)},9387:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ScryptedMimeTypes=t.ScryptedInterface=t.MediaPlayerState=t.SecuritySystemObstruction=t.SecuritySystemMode=t.AirQuality=t.AirPurifierMode=t.AirPurifierStatus=t.ChargeState=t.LockState=t.PanTiltZoomMovement=t.ThermostatMode=t.TemperatureUnit=t.FanMode=t.HumidityMode=t.ScryptedDeviceType=t.ScryptedInterfaceDescriptors=t.ScryptedInterfaceMethod=t.ScryptedInterfaceProperty=t.DeviceBase=t.TYPES_VERSION=void 0,t.TYPES_VERSION="0.5.21";var i,n,o,r,s,a,c,l,p,u,d,h,m,f,g,v,y,b;t.DeviceBase=class{},function(e){e.id="id",e.info="info",e.interfaces="interfaces",e.mixins="mixins",e.name="name",e.nativeId="nativeId",e.pluginId="pluginId",e.providedInterfaces="providedInterfaces",e.providedName="providedName",e.providedRoom="providedRoom",e.providedType="providedType",e.providerId="providerId",e.room="room",e.type="type",e.scryptedRuntimeArguments="scryptedRuntimeArguments",e.on="on",e.brightness="brightness",e.colorTemperature="colorTemperature",e.rgb="rgb",e.hsv="hsv",e.buttons="buttons",e.sensors="sensors",e.running="running",e.paused="paused",e.docked="docked",e.temperatureSetting="temperatureSetting",e.temperature="temperature",e.temperatureUnit="temperatureUnit",e.humidity="humidity",e.audioVolumes="audioVolumes",e.recordingActive="recordingActive",e.ptzCapabilities="ptzCapabilities",e.lockState="lockState",e.entryOpen="entryOpen",e.batteryLevel="batteryLevel",e.chargeState="chargeState",e.online="online",e.fromMimeType="fromMimeType",e.toMimeType="toMimeType",e.converters="converters",e.binaryState="binaryState",e.tampered="tampered",e.sleeping="sleeping",e.powerDetected="powerDetected",e.audioDetected="audioDetected",e.motionDetected="motionDetected",e.ambientLight="ambientLight",e.occupied="occupied",e.flooded="flooded",e.ultraviolet="ultraviolet",e.luminance="luminance",e.position="position",e.securitySystemState="securitySystemState",e.pm10Density="pm10Density",e.pm25Density="pm25Density",e.vocDensity="vocDensity",e.noxDensity="noxDensity",e.co2ppm="co2ppm",e.airQuality="airQuality",e.airPurifierState="airPurifierState",e.filterChangeIndication="filterChangeIndication",e.filterLifeLevel="filterLifeLevel",e.humiditySetting="humiditySetting",e.fan="fan",e.applicationInfo="applicationInfo",e.systemDevice="systemDevice"}(i||(t.ScryptedInterfaceProperty=i={})),function(e){e.listen="listen",e.probe="probe",e.setMixins="setMixins",e.setName="setName",e.setRoom="setRoom",e.setType="setType",e.getPluginJson="getPluginJson",e.turnOff="turnOff",e.turnOn="turnOn",e.setBrightness="setBrightness",e.getTemperatureMaxK="getTemperatureMaxK",e.getTemperatureMinK="getTemperatureMinK",e.setColorTemperature="setColorTemperature",e.setRgb="setRgb",e.setHsv="setHsv",e.pressButton="pressButton",e.sendNotification="sendNotification",e.start="start",e.stop="stop",e.pause="pause",e.resume="resume",e.dock="dock",e.setTemperature="setTemperature",e.setTemperatureUnit="setTemperatureUnit",e.getPictureOptions="getPictureOptions",e.takePicture="takePicture",e.getAudioStream="getAudioStream",e.setAudioVolumes="setAudioVolumes",e.startDisplay="startDisplay",e.stopDisplay="stopDisplay",e.getVideoStream="getVideoStream",e.getVideoStreamOptions="getVideoStreamOptions",e.getPrivacyMasks="getPrivacyMasks",e.setPrivacyMasks="setPrivacyMasks",e.getVideoTextOverlays="getVideoTextOverlays",e.setVideoTextOverlay="setVideoTextOverlay",e.getRecordingStream="getRecordingStream",e.getRecordingStreamCurrentTime="getRecordingStreamCurrentTime",e.getRecordingStreamOptions="getRecordingStreamOptions",e.getRecordingStreamThumbnail="getRecordingStreamThumbnail",e.deleteRecordingStream="deleteRecordingStream",e.setRecordingActive="setRecordingActive",e.ptzCommand="ptzCommand",e.getRecordedEvents="getRecordedEvents",e.getVideoClip="getVideoClip",e.getVideoClips="getVideoClips",e.getVideoClipThumbnail="getVideoClipThumbnail",e.removeVideoClips="removeVideoClips",e.setVideoStreamOptions="setVideoStreamOptions",e.startIntercom="startIntercom",e.stopIntercom="stopIntercom",e.lock="lock",e.unlock="unlock",e.addPassword="addPassword",e.getPasswords="getPasswords",e.removePassword="removePassword",e.activate="activate",e.deactivate="deactivate",e.isReversible="isReversible",e.closeEntry="closeEntry",e.openEntry="openEntry",e.getDevice="getDevice",e.releaseDevice="releaseDevice",e.adoptDevice="adoptDevice",e.discoverDevices="discoverDevices",e.createDevice="createDevice",e.getCreateDeviceSettings="getCreateDeviceSettings",e.reboot="reboot",e.getRefreshFrequency="getRefreshFrequency",e.refresh="refresh",e.getMediaStatus="getMediaStatus",e.load="load",e.seek="seek",e.skipNext="skipNext",e.skipPrevious="skipPrevious",e.convert="convert",e.convertMedia="convertMedia",e.getSettings="getSettings",e.putSetting="putSetting",e.armSecuritySystem="armSecuritySystem",e.disarmSecuritySystem="disarmSecuritySystem",e.setAirPurifierState="setAirPurifierState",e.getReadmeMarkdown="getReadmeMarkdown",e.getOauthUrl="getOauthUrl",e.onOauthCallback="onOauthCallback",e.canMixin="canMixin",e.getMixin="getMixin",e.releaseMixin="releaseMixin",e.onRequest="onRequest",e.onConnection="onConnection",e.onPush="onPush",e.run="run",e.eval="eval",e.loadScripts="loadScripts",e.saveScript="saveScript",e.forkInterface="forkInterface",e.trackObjects="trackObjects",e.getDetectionInput="getDetectionInput",e.getObjectTypes="getObjectTypes",e.detectObjects="detectObjects",e.generateObjectDetections="generateObjectDetections",e.getDetectionModel="getDetectionModel",e.setHumidity="setHumidity",e.setFan="setFan",e.startRTCSignalingSession="startRTCSignalingSession",e.createRTCSignalingSession="createRTCSignalingSession",e.getScryptedUserAccessControl="getScryptedUserAccessControl",e.generateVideoFrames="generateVideoFrames",e.connectStream="connectStream",e.getTTYSettings="getTTYSettings",e.getChatCompletion="getChatCompletion",e.streamChatCompletion="streamChatCompletion",e.getTextEmbedding="getTextEmbedding",e.getImageEmbedding="getImageEmbedding",e.callLLMTool="callLLMTool",e.getLLMTools="getLLMTools"}(n||(t.ScryptedInterfaceMethod=n={})),t.ScryptedInterfaceDescriptors={ScryptedDevice:{name:"ScryptedDevice",methods:["listen","probe","setMixins","setName","setRoom","setType"],properties:["id","info","interfaces","mixins","name","nativeId","pluginId","providedInterfaces","providedName","providedRoom","providedType","providerId","room","type"]},ScryptedPlugin:{name:"ScryptedPlugin",methods:["getPluginJson"],properties:[]},ScryptedPluginRuntime:{name:"ScryptedPluginRuntime",methods:[],properties:["scryptedRuntimeArguments"]},OnOff:{name:"OnOff",methods:["turnOff","turnOn"],properties:["on"]},Brightness:{name:"Brightness",methods:["setBrightness"],properties:["brightness"]},ColorSettingTemperature:{name:"ColorSettingTemperature",methods:["getTemperatureMaxK","getTemperatureMinK","setColorTemperature"],properties:["colorTemperature"]},ColorSettingRgb:{name:"ColorSettingRgb",methods:["setRgb"],properties:["rgb"]},ColorSettingHsv:{name:"ColorSettingHsv",methods:["setHsv"],properties:["hsv"]},Buttons:{name:"Buttons",methods:[],properties:["buttons"]},PressButtons:{name:"PressButtons",methods:["pressButton"],properties:[]},Sensors:{name:"Sensors",methods:[],properties:["sensors"]},Notifier:{name:"Notifier",methods:["sendNotification"],properties:[]},StartStop:{name:"StartStop",methods:["start","stop"],properties:["running"]},Pause:{name:"Pause",methods:["pause","resume"],properties:["paused"]},Dock:{name:"Dock",methods:["dock"],properties:["docked"]},TemperatureSetting:{name:"TemperatureSetting",methods:["setTemperature"],properties:["temperatureSetting"]},Thermometer:{name:"Thermometer",methods:["setTemperatureUnit"],properties:["temperature","temperatureUnit"]},HumiditySensor:{name:"HumiditySensor",methods:[],properties:["humidity"]},Camera:{name:"Camera",methods:["getPictureOptions","takePicture"],properties:[]},Microphone:{name:"Microphone",methods:["getAudioStream"],properties:[]},AudioVolumeControl:{name:"AudioVolumeControl",methods:["setAudioVolumes"],properties:["audioVolumes"]},Display:{name:"Display",methods:["startDisplay","stopDisplay"],properties:[]},VideoCamera:{name:"VideoCamera",methods:["getVideoStream","getVideoStreamOptions"],properties:[]},VideoCameraMask:{name:"VideoCameraMask",methods:["getPrivacyMasks","setPrivacyMasks"],properties:[]},VideoTextOverlays:{name:"VideoTextOverlays",methods:["getVideoTextOverlays","setVideoTextOverlay"],properties:[]},VideoRecorder:{name:"VideoRecorder",methods:["getRecordingStream","getRecordingStreamCurrentTime","getRecordingStreamOptions","getRecordingStreamThumbnail"],properties:["recordingActive"]},VideoRecorderManagement:{name:"VideoRecorderManagement",methods:["deleteRecordingStream","setRecordingActive"],properties:[]},PanTiltZoom:{name:"PanTiltZoom",methods:["ptzCommand"],properties:["ptzCapabilities"]},EventRecorder:{name:"EventRecorder",methods:["getRecordedEvents"],properties:[]},VideoClips:{name:"VideoClips",methods:["getVideoClip","getVideoClips","getVideoClipThumbnail","removeVideoClips"],properties:[]},VideoCameraConfiguration:{name:"VideoCameraConfiguration",methods:["setVideoStreamOptions"],properties:[]},Intercom:{name:"Intercom",methods:["startIntercom","stopIntercom"],properties:[]},Lock:{name:"Lock",methods:["lock","unlock"],properties:["lockState"]},PasswordStore:{name:"PasswordStore",methods:["addPassword","getPasswords","removePassword"],properties:[]},Scene:{name:"Scene",methods:["activate","deactivate","isReversible"],properties:[]},Entry:{name:"Entry",methods:["closeEntry","openEntry"],properties:[]},EntrySensor:{name:"EntrySensor",methods:[],properties:["entryOpen"]},DeviceProvider:{name:"DeviceProvider",methods:["getDevice","releaseDevice"],properties:[]},DeviceDiscovery:{name:"DeviceDiscovery",methods:["adoptDevice","discoverDevices"],properties:[]},DeviceCreator:{name:"DeviceCreator",methods:["createDevice","getCreateDeviceSettings"],properties:[]},Battery:{name:"Battery",methods:[],properties:["batteryLevel"]},Charger:{name:"Charger",methods:[],properties:["chargeState"]},Reboot:{name:"Reboot",methods:["reboot"],properties:[]},Refresh:{name:"Refresh",methods:["getRefreshFrequency","refresh"],properties:[]},MediaPlayer:{name:"MediaPlayer",methods:["getMediaStatus","load","seek","skipNext","skipPrevious"],properties:[]},Online:{name:"Online",methods:[],properties:["online"]},BufferConverter:{name:"BufferConverter",methods:["convert"],properties:["fromMimeType","toMimeType"]},MediaConverter:{name:"MediaConverter",methods:["convertMedia"],properties:["converters"]},Settings:{name:"Settings",methods:["getSettings","putSetting"],properties:[]},BinarySensor:{name:"BinarySensor",methods:[],properties:["binaryState"]},TamperSensor:{name:"TamperSensor",methods:[],properties:["tampered"]},Sleep:{name:"Sleep",methods:[],properties:["sleeping"]},PowerSensor:{name:"PowerSensor",methods:[],properties:["powerDetected"]},AudioSensor:{name:"AudioSensor",methods:[],properties:["audioDetected"]},MotionSensor:{name:"MotionSensor",methods:[],properties:["motionDetected"]},AmbientLightSensor:{name:"AmbientLightSensor",methods:[],properties:["ambientLight"]},OccupancySensor:{name:"OccupancySensor",methods:[],properties:["occupied"]},FloodSensor:{name:"FloodSensor",methods:[],properties:["flooded"]},UltravioletSensor:{name:"UltravioletSensor",methods:[],properties:["ultraviolet"]},LuminanceSensor:{name:"LuminanceSensor",methods:[],properties:["luminance"]},PositionSensor:{name:"PositionSensor",methods:[],properties:["position"]},SecuritySystem:{name:"SecuritySystem",methods:["armSecuritySystem","disarmSecuritySystem"],properties:["securitySystemState"]},PM10Sensor:{name:"PM10Sensor",methods:[],properties:["pm10Density"]},PM25Sensor:{name:"PM25Sensor",methods:[],properties:["pm25Density"]},VOCSensor:{name:"VOCSensor",methods:[],properties:["vocDensity"]},NOXSensor:{name:"NOXSensor",methods:[],properties:["noxDensity"]},CO2Sensor:{name:"CO2Sensor",methods:[],properties:["co2ppm"]},AirQualitySensor:{name:"AirQualitySensor",methods:[],properties:["airQuality"]},AirPurifier:{name:"AirPurifier",methods:["setAirPurifierState"],properties:["airPurifierState"]},FilterMaintenance:{name:"FilterMaintenance",methods:[],properties:["filterChangeIndication","filterLifeLevel"]},Readme:{name:"Readme",methods:["getReadmeMarkdown"],properties:[]},OauthClient:{name:"OauthClient",methods:["getOauthUrl","onOauthCallback"],properties:[]},MixinProvider:{name:"MixinProvider",methods:["canMixin","getMixin","releaseMixin"],properties:[]},HttpRequestHandler:{name:"HttpRequestHandler",methods:["onRequest"],properties:[]},EngineIOHandler:{name:"EngineIOHandler",methods:["onConnection"],properties:[]},PushHandler:{name:"PushHandler",methods:["onPush"],properties:[]},Program:{name:"Program",methods:["run"],properties:[]},Scriptable:{name:"Scriptable",methods:["eval","loadScripts","saveScript"],properties:[]},ClusterForkInterface:{name:"ClusterForkInterface",methods:["forkInterface"],properties:[]},ObjectTracker:{name:"ObjectTracker",methods:["trackObjects"],properties:[]},ObjectDetector:{name:"ObjectDetector",methods:["getDetectionInput","getObjectTypes"],properties:[]},ObjectDetection:{name:"ObjectDetection",methods:["detectObjects","generateObjectDetections","getDetectionModel"],properties:[]},ObjectDetectionPreview:{name:"ObjectDetectionPreview",methods:[],properties:[]},ObjectDetectionGenerator:{name:"ObjectDetectionGenerator",methods:[],properties:[]},HumiditySetting:{name:"HumiditySetting",methods:["setHumidity"],properties:["humiditySetting"]},Fan:{name:"Fan",methods:["setFan"],properties:["fan"]},RTCSignalingChannel:{name:"RTCSignalingChannel",methods:["startRTCSignalingSession"],properties:[]},RTCSignalingClient:{name:"RTCSignalingClient",methods:["createRTCSignalingSession"],properties:[]},LauncherApplication:{name:"LauncherApplication",methods:[],properties:["applicationInfo"]},ScryptedUser:{name:"ScryptedUser",methods:["getScryptedUserAccessControl"],properties:[]},VideoFrameGenerator:{name:"VideoFrameGenerator",methods:["generateVideoFrames"],properties:[]},StreamService:{name:"StreamService",methods:["connectStream"],properties:[]},TTY:{name:"TTY",methods:[],properties:[]},TTYSettings:{name:"TTYSettings",methods:["getTTYSettings"],properties:[]},ChatCompletion:{name:"ChatCompletion",methods:["getChatCompletion","streamChatCompletion"],properties:[]},TextEmbedding:{name:"TextEmbedding",methods:["getTextEmbedding"],properties:[]},ImageEmbedding:{name:"ImageEmbedding",methods:["getImageEmbedding"],properties:[]},LLMTools:{name:"LLMTools",methods:["callLLMTool","getLLMTools"],properties:[]},ScryptedSystemDevice:{name:"ScryptedSystemDevice",methods:[],properties:["systemDevice"]},ScryptedDeviceCreator:{name:"ScryptedDeviceCreator",methods:[],properties:[]},ScryptedSettings:{name:"ScryptedSettings",methods:[],properties:[]}},function(e){e.Builtin="Builtin",e.Internal="Internal",e.Camera="Camera",e.Fan="Fan",e.Light="Light",e.Switch="Switch",e.Outlet="Outlet",e.Sensor="Sensor",e.Scene="Scene",e.Program="Program",e.Automation="Automation",e.Vacuum="Vacuum",e.Notifier="Notifier",e.Thermostat="Thermostat",e.Lock="Lock",e.PasswordControl="PasswordControl",e.Display="Display",e.SmartDisplay="SmartDisplay",e.Speaker="Speaker",e.SmartSpeaker="SmartSpeaker",e.RemoteDesktop="RemoteDesktop",e.Event="Event",e.Entry="Entry",e.Garage="Garage",e.DeviceProvider="DeviceProvider",e.DataSource="DataSource",e.API="API",e.Doorbell="Doorbell",e.Irrigation="Irrigation",e.Valve="Valve",e.Person="Person",e.SecuritySystem="SecuritySystem",e.WindowCovering="WindowCovering",e.Siren="Siren",e.AirPurifier="AirPurifier",e.Internet="Internet",e.Network="Network",e.Bridge="Bridge",e.LLM="LLM",e.Unknown="Unknown"}(o||(t.ScryptedDeviceType=o={})),function(e){e.Humidify="Humidify",e.Dehumidify="Dehumidify",e.Auto="Auto",e.Off="Off"}(r||(t.HumidityMode=r={})),function(e){e.Auto="Auto",e.Manual="Manual"}(s||(t.FanMode=s={})),function(e){e.C="C",e.F="F"}(a||(t.TemperatureUnit=a={})),function(e){e.Off="Off",e.Cool="Cool",e.Heat="Heat",e.HeatCool="HeatCool",e.Auto="Auto",e.FanOnly="FanOnly",e.Purifier="Purifier",e.Eco="Eco",e.Dry="Dry",e.On="On"}(c||(t.ThermostatMode=c={})),function(e){e.Absolute="Absolute",e.Relative="Relative",e.Continuous="Continuous",e.Preset="Preset",e.Home="Home"}(l||(t.PanTiltZoomMovement=l={})),function(e){e.Locked="Locked",e.Unlocked="Unlocked",e.Jammed="Jammed"}(p||(t.LockState=p={})),function(e){e.Trickle="trickle",e.Charging="charging",e.NotCharging="not-charging"}(u||(t.ChargeState=u={})),function(e){e.Inactive="Inactive",e.Idle="Idle",e.Active="Active",e.ActiveNightMode="ActiveNightMode"}(d||(t.AirPurifierStatus=d={})),function(e){e.Manual="Manual",e.Automatic="Automatic"}(h||(t.AirPurifierMode=h={})),function(e){e.Unknown="Unknown",e.Excellent="Excellent",e.Good="Good",e.Fair="Fair",e.Inferior="Inferior",e.Poor="Poor"}(m||(t.AirQuality=m={})),function(e){e.Disarmed="Disarmed",e.HomeArmed="HomeArmed",e.AwayArmed="AwayArmed",e.NightArmed="NightArmed"}(f||(t.SecuritySystemMode=f={})),function(e){e.Sensor="Sensor",e.Occupied="Occupied",e.Time="Time",e.Error="Error"}(g||(t.SecuritySystemObstruction=g={})),function(e){e.Idle="Idle",e.Playing="Playing",e.Paused="Paused",e.Buffering="Buffering"}(v||(t.MediaPlayerState=v={})),function(e){e.ScryptedDevice="ScryptedDevice",e.ScryptedPlugin="ScryptedPlugin",e.ScryptedPluginRuntime="ScryptedPluginRuntime",e.OnOff="OnOff",e.Brightness="Brightness",e.ColorSettingTemperature="ColorSettingTemperature",e.ColorSettingRgb="ColorSettingRgb",e.ColorSettingHsv="ColorSettingHsv",e.Buttons="Buttons",e.PressButtons="PressButtons",e.Sensors="Sensors",e.Notifier="Notifier",e.StartStop="StartStop",e.Pause="Pause",e.Dock="Dock",e.TemperatureSetting="TemperatureSetting",e.Thermometer="Thermometer",e.HumiditySensor="HumiditySensor",e.Camera="Camera",e.Microphone="Microphone",e.AudioVolumeControl="AudioVolumeControl",e.Display="Display",e.VideoCamera="VideoCamera",e.VideoCameraMask="VideoCameraMask",e.VideoTextOverlays="VideoTextOverlays",e.VideoRecorder="VideoRecorder",e.VideoRecorderManagement="VideoRecorderManagement",e.PanTiltZoom="PanTiltZoom",e.EventRecorder="EventRecorder",e.VideoClips="VideoClips",e.VideoCameraConfiguration="VideoCameraConfiguration",e.Intercom="Intercom",e.Lock="Lock",e.PasswordStore="PasswordStore",e.Scene="Scene",e.Entry="Entry",e.EntrySensor="EntrySensor",e.DeviceProvider="DeviceProvider",e.DeviceDiscovery="DeviceDiscovery",e.DeviceCreator="DeviceCreator",e.Battery="Battery",e.Charger="Charger",e.Reboot="Reboot",e.Refresh="Refresh",e.MediaPlayer="MediaPlayer",e.Online="Online",e.BufferConverter="BufferConverter",e.MediaConverter="MediaConverter",e.Settings="Settings",e.BinarySensor="BinarySensor",e.TamperSensor="TamperSensor",e.Sleep="Sleep",e.PowerSensor="PowerSensor",e.AudioSensor="AudioSensor",e.MotionSensor="MotionSensor",e.AmbientLightSensor="AmbientLightSensor",e.OccupancySensor="OccupancySensor",e.FloodSensor="FloodSensor",e.UltravioletSensor="UltravioletSensor",e.LuminanceSensor="LuminanceSensor",e.PositionSensor="PositionSensor",e.SecuritySystem="SecuritySystem",e.PM10Sensor="PM10Sensor",e.PM25Sensor="PM25Sensor",e.VOCSensor="VOCSensor",e.NOXSensor="NOXSensor",e.CO2Sensor="CO2Sensor",e.AirQualitySensor="AirQualitySensor",e.AirPurifier="AirPurifier",e.FilterMaintenance="FilterMaintenance",e.Readme="Readme",e.OauthClient="OauthClient",e.MixinProvider="MixinProvider",e.HttpRequestHandler="HttpRequestHandler",e.EngineIOHandler="EngineIOHandler",e.PushHandler="PushHandler",e.Program="Program",e.Scriptable="Scriptable",e.ClusterForkInterface="ClusterForkInterface",e.ObjectTracker="ObjectTracker",e.ObjectDetector="ObjectDetector",e.ObjectDetection="ObjectDetection",e.ObjectDetectionPreview="ObjectDetectionPreview",e.ObjectDetectionGenerator="ObjectDetectionGenerator",e.HumiditySetting="HumiditySetting",e.Fan="Fan",e.RTCSignalingChannel="RTCSignalingChannel",e.RTCSignalingClient="RTCSignalingClient",e.LauncherApplication="LauncherApplication",e.ScryptedUser="ScryptedUser",e.VideoFrameGenerator="VideoFrameGenerator",e.StreamService="StreamService",e.TTY="TTY",e.TTYSettings="TTYSettings",e.ChatCompletion="ChatCompletion",e.TextEmbedding="TextEmbedding",e.ImageEmbedding="ImageEmbedding",e.LLMTools="LLMTools",e.ScryptedSystemDevice="ScryptedSystemDevice",e.ScryptedDeviceCreator="ScryptedDeviceCreator",e.ScryptedSettings="ScryptedSettings"}(y||(t.ScryptedInterface=y={})),function(e){e.Url="text/x-uri",e.InsecureLocalUrl="text/x-insecure-local-uri",e.LocalUrl="text/x-local-uri",e.ServerId="text/x-server-id",e.PushEndpoint="text/x-push-endpoint",e.SchemePrefix="x-scrypted/x-scrypted-scheme-",e.MediaStreamUrl="text/x-media-url",e.MediaObject="x-scrypted/x-scrypted-media-object",e.RequestMediaObject="x-scrypted/x-scrypted-request-media-object",e.RequestMediaStream="x-scrypted/x-scrypted-request-stream",e.MediaStreamFeedback="x-scrypted/x-media-stream-feedback",e.FFmpegInput="x-scrypted/x-ffmpeg-input",e.FFmpegTranscodeStream="x-scrypted/x-ffmpeg-transcode-stream",e.RTCSignalingChannel="x-scrypted/x-scrypted-rtc-signaling-channel",e.RTCSignalingSession="x-scrypted/x-scrypted-rtc-signaling-session",e.RTCConnectionManagement="x-scrypted/x-scrypted-rtc-connection-management",e.Image="x-scrypted/x-scrypted-image"}(b||(t.ScryptedMimeTypes=b={}))},9388:(e,t,i)=>{"use strict";e.exports=i(9129)()},9400:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.safePrintFFmpegArguments=t.ffmpegLogInitialOutput=t.safeKillFFmpeg=void 0;var n=i(6493);Object.defineProperty(t,"safeKillFFmpeg",{enumerable:!0,get:function(){return n.safeKillFFmpeg}}),Object.defineProperty(t,"ffmpegLogInitialOutput",{enumerable:!0,get:function(){return n.ffmpegLogInitialOutput}}),Object.defineProperty(t,"safePrintFFmpegArguments",{enumerable:!0,get:function(){return n.safePrintFFmpegArguments}})},9815:(e,t,i)=>{const{Buffer:n}=i(181),o={},r=n.isBuffer(n.from([1,2]).subarray(0,1));function s(e){const t=n.allocUnsafe(2);return t.writeUInt8(e>>8,0),t.writeUInt8(255&e,1),t}e.exports={cache:o,generateCache:function(){for(let e=0;e<65536;e++)o[e]=s(e)},generateNumber:s,genBufVariableByteInt:function(e){let t=0,i=0;const o=n.allocUnsafe(4);do{t=e%128|0,(e=e/128|0)>0&&(t|=128),o.writeUInt8(t,i++)}while(e>0&&i<4);return e>0&&(i=0),r?o.subarray(0,i):o.slice(0,i)},generate4ByteBuffer:function(e){const t=n.allocUnsafe(4);return t.writeUInt32BE(e,0),t}}},9896:e=>{"use strict";e.exports=require("fs")},9913:function(e,t,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return o(t,e),t},s=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||n(t,e,i)};Object.defineProperty(t,"__esModule",{value:!0});const a=r(i(1091));t.default=a,s(i(1091),t)},9930:(e,t,i)=>{"use strict";const n=i(857),o=i(2018),r=i(4629),{env:s}=process;let a;function c(e){return 0!==e&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function l(e,t){if(0===a)return 0;if(r("color=16m")||r("color=full")||r("color=truecolor"))return 3;if(r("color=256"))return 2;if(e&&!t&&void 0===a)return 0;const i=a||0;if("dumb"===s.TERM)return i;if("win32"===process.platform){const e=n.release().split(".");return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if("CI"in s)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some((e=>e in s))||"codeship"===s.CI_NAME?1:i;if("TEAMCITY_VERSION"in s)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(s.TEAMCITY_VERSION)?1:0;if("truecolor"===s.COLORTERM)return 3;if("TERM_PROGRAM"in s){const e=parseInt((s.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(s.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(s.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(s.TERM)||"COLORTERM"in s?1:i}r("no-color")||r("no-colors")||r("color=false")||r("color=never")?a=0:(r("color")||r("colors")||r("color=true")||r("color=always"))&&(a=1),"FORCE_COLOR"in s&&(a="true"===s.FORCE_COLOR?1:"false"===s.FORCE_COLOR?0:0===s.FORCE_COLOR.length?1:Math.min(parseInt(s.FORCE_COLOR,10),3)),e.exports={supportsColor:function(e){return c(l(e,e&&e.isTTY))},stdout:c(l(!0,o.isatty(1))),stderr:c(l(!0,o.isatty(2)))}},9983:function(e,t,i){(function(){var t,n,o,r={}.hasOwnProperty;o=i(5502).isObject,n=i(8711),t=i(5068),e.exports=function(e){function i(e,n,r,s){var a;i.__super__.constructor.call(this,e),o(n)&&(n=(a=n).version,r=a.encoding,s=a.standalone),n||(n="1.0"),this.type=t.Declaration,this.version=this.stringify.xmlVersion(n),null!=r&&(this.encoding=this.stringify.xmlEncoding(r)),null!=s&&(this.standalone=this.stringify.xmlStandalone(s))}return function(e,t){for(var i in t)r.call(t,i)&&(e[i]=t[i]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(i,e),i.prototype.toString=function(e){return this.options.writer.declaration(this,this.options.writer.filterOptions(e))},i}(n)}).call(this)}},t={};function i(n){var o=t[n];if(void 0!==o)return o.exports;var r=t[n]={exports:{}};return e[n].call(r.exports,r,r.exports,i),r.exports}i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n=i(5425),o=exports="undefined"==typeof exports?{}:exports;for(var r in n)o[r]=n[r];n.__esModule&&Object.defineProperty(o,"__esModule",{value:!0})})();
//# sourceMappingURL=main.nodejs.js.map