@opra/client
Version:
Opra Client package
22 lines (18 loc) • 35.7 kB
JavaScript
/****************************************
* All rights reserved Panates® 2022-2025
* http://www.panates.com
*****************************************/
var kr=Object.create;var Y=Object.defineProperty;var br=Object.getOwnPropertyDescriptor;var Dr=Object.getOwnPropertyNames;var Mr=Object.getPrototypeOf,Nr=Object.prototype.hasOwnProperty;var s=(n,r)=>Y(n,"name",{value:r,configurable:!0});var G=(n,r)=>()=>(r||n((r={exports:{}}).exports,r),r.exports);var Pr=(n,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of Dr(r))!Nr.call(n,i)&&i!==e&&Y(n,i,{get:()=>r[i],enumerable:!(t=br(r,i))||t.enumerable});return n};var qr=(n,r,e)=>(e=n!=null?kr(Mr(n)):{},Pr(r||!n||!n.__esModule?Y(e,"default",{value:n,enumerable:!0}):e,n));var lr=G(k=>{"use strict";k.byteLength=_r;k.toByteArray=Or;k.fromByteArray=Yr;var U=[],E=[],Hr=typeof Uint8Array<"u"?Uint8Array:Array,J="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(T=0,pr=J.length;T<pr;++T)U[T]=J[T],E[J.charCodeAt(T)]=T;var T,pr;E[45]=62;E[95]=63;function cr(n){var r=n.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=n.indexOf("=");e===-1&&(e=r);var t=e===r?0:4-e%4;return[e,t]}s(cr,"getLens");function _r(n){var r=cr(n),e=r[0],t=r[1];return(e+t)*3/4-t}s(_r,"byteLength");function jr(n,r,e){return(r+e)*3/4-e}s(jr,"_byteLength");function Or(n){var r,e=cr(n),t=e[0],i=e[1],o=new Hr(jr(n,t,i)),a=0,h=i>0?t-4:t,f;for(f=0;f<h;f+=4)r=E[n.charCodeAt(f)]<<18|E[n.charCodeAt(f+1)]<<12|E[n.charCodeAt(f+2)]<<6|E[n.charCodeAt(f+3)],o[a++]=r>>16&255,o[a++]=r>>8&255,o[a++]=r&255;return i===2&&(r=E[n.charCodeAt(f)]<<2|E[n.charCodeAt(f+1)]>>4,o[a++]=r&255),i===1&&(r=E[n.charCodeAt(f)]<<10|E[n.charCodeAt(f+1)]<<4|E[n.charCodeAt(f+2)]>>2,o[a++]=r>>8&255,o[a++]=r&255),o}s(Or,"toByteArray");function Wr(n){return U[n>>18&63]+U[n>>12&63]+U[n>>6&63]+U[n&63]}s(Wr,"tripletToBase64");function zr(n,r,e){for(var t,i=[],o=r;o<e;o+=3)t=(n[o]<<16&16711680)+(n[o+1]<<8&65280)+(n[o+2]&255),i.push(Wr(t));return i.join("")}s(zr,"encodeChunk");function Yr(n){for(var r,e=n.length,t=e%3,i=[],o=16383,a=0,h=e-t;a<h;a+=o)i.push(zr(n,a,a+o>h?h:a+o));return t===1?(r=n[e-1],i.push(U[r>>2]+U[r<<4&63]+"==")):t===2&&(r=(n[e-2]<<8)+n[e-1],i.push(U[r>>10]+U[r>>4&63]+U[r<<2&63]+"=")),i.join("")}s(Yr,"fromByteArray")});var yr=G(X=>{"use strict";X.read=function(n,r,e,t,i){var o,a,h=i*8-t-1,f=(1<<h)-1,l=f>>1,c=-7,p=e?i-1:0,x=e?-1:1,w=n[r+p];for(p+=x,o=w&(1<<-c)-1,w>>=-c,c+=h;c>0;o=o*256+n[r+p],p+=x,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=t;c>0;a=a*256+n[r+p],p+=x,c-=8);if(o===0)o=1-l;else{if(o===f)return a?NaN:(w?-1:1)*(1/0);a=a+Math.pow(2,t),o=o-l}return(w?-1:1)*a*Math.pow(2,o-t)};X.write=function(n,r,e,t,i,o){var a,h,f,l=o*8-i-1,c=(1<<l)-1,p=c>>1,x=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=t?0:o-1,d=t?1:-1,L=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(h=isNaN(r)?1:0,a=c):(a=Math.floor(Math.log(r)/Math.LN2),r*(f=Math.pow(2,-a))<1&&(a--,f*=2),a+p>=1?r+=x/f:r+=x*Math.pow(2,1-p),r*f>=2&&(a++,f/=2),a+p>=c?(h=0,a=c):a+p>=1?(h=(r*f-1)*Math.pow(2,i),a=a+p):(h=r*Math.pow(2,p-1)*Math.pow(2,i),a=0));i>=8;n[e+w]=h&255,w+=d,h/=256,i-=8);for(a=a<<i|h,l+=i;l>0;n[e+w]=a&255,w+=d,a/=256,l-=8);n[e+w-d]|=L*128}});var Tr=G(C=>{"use strict";var K=lr(),R=yr(),xr=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;C.Buffer=u;C.SlowBuffer=Zr;C.INSPECT_MAX_BYTES=50;var b=2147483647;C.kMaxLength=b;u.TYPED_ARRAY_SUPPORT=Gr();!u.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Gr(){try{var n=new Uint8Array(1),r={foo:s(function(){return 42},"foo")};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(n,r),n.foo()===42}catch{return!1}}s(Gr,"typedArraySupport");Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:s(function(){if(u.isBuffer(this))return this.buffer},"get")});Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:s(function(){if(u.isBuffer(this))return this.byteOffset},"get")});function I(n){if(n>b)throw new RangeError('The value "'+n+'" is invalid for option "size"');var r=new Uint8Array(n);return Object.setPrototypeOf(r,u.prototype),r}s(I,"createBuffer");function u(n,r,e){if(typeof n=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Q(n)}return dr(n,r,e)}s(u,"Buffer");u.poolSize=8192;function dr(n,r,e){if(typeof n=="string")return Xr(n,r);if(ArrayBuffer.isView(n))return Kr(n);if(n==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n);if(A(n,ArrayBuffer)||n&&A(n.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(A(n,SharedArrayBuffer)||n&&A(n.buffer,SharedArrayBuffer)))return Z(n,r,e);if(typeof n=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var t=n.valueOf&&n.valueOf();if(t!=null&&t!==n)return u.from(t,r,e);var i=Vr(n);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof n[Symbol.toPrimitive]=="function")return u.from(n[Symbol.toPrimitive]("string"),r,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n)}s(dr,"from");u.from=function(n,r,e){return dr(n,r,e)};Object.setPrototypeOf(u.prototype,Uint8Array.prototype);Object.setPrototypeOf(u,Uint8Array);function Er(n){if(typeof n!="number")throw new TypeError('"size" argument must be of type number');if(n<0)throw new RangeError('The value "'+n+'" is invalid for option "size"')}s(Er,"assertSize");function Jr(n,r,e){return Er(n),n<=0?I(n):r!==void 0?typeof e=="string"?I(n).fill(r,e):I(n).fill(r):I(n)}s(Jr,"alloc");u.alloc=function(n,r,e){return Jr(n,r,e)};function Q(n){return Er(n),I(n<0?0:rr(n)|0)}s(Q,"allocUnsafe");u.allocUnsafe=function(n){return Q(n)};u.allocUnsafeSlow=function(n){return Q(n)};function Xr(n,r){if((typeof r!="string"||r==="")&&(r="utf8"),!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r);var e=gr(n,r)|0,t=I(e),i=t.write(n,r);return i!==e&&(t=t.slice(0,i)),t}s(Xr,"fromString");function V(n){for(var r=n.length<0?0:rr(n.length)|0,e=I(r),t=0;t<r;t+=1)e[t]=n[t]&255;return e}s(V,"fromArrayLike");function Kr(n){if(A(n,Uint8Array)){var r=new Uint8Array(n);return Z(r.buffer,r.byteOffset,r.byteLength)}return V(n)}s(Kr,"fromArrayView");function Z(n,r,e){if(r<0||n.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(n.byteLength<r+(e||0))throw new RangeError('"length" is outside of buffer bounds');var t;return r===void 0&&e===void 0?t=new Uint8Array(n):e===void 0?t=new Uint8Array(n,r):t=new Uint8Array(n,r,e),Object.setPrototypeOf(t,u.prototype),t}s(Z,"fromArrayBuffer");function Vr(n){if(u.isBuffer(n)){var r=rr(n.length)|0,e=I(r);return e.length===0||n.copy(e,0,0,r),e}if(n.length!==void 0)return typeof n.length!="number"||er(n.length)?I(0):V(n);if(n.type==="Buffer"&&Array.isArray(n.data))return V(n.data)}s(Vr,"fromObject");function rr(n){if(n>=b)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+b.toString(16)+" bytes");return n|0}s(rr,"checked");function Zr(n){return+n!=n&&(n=0),u.alloc(+n)}s(Zr,"SlowBuffer");u.isBuffer=s(function(r){return r!=null&&r._isBuffer===!0&&r!==u.prototype},"isBuffer");u.compare=s(function(r,e){if(A(r,Uint8Array)&&(r=u.from(r,r.offset,r.byteLength)),A(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(r)||!u.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===e)return 0;for(var t=r.length,i=e.length,o=0,a=Math.min(t,i);o<a;++o)if(r[o]!==e[o]){t=r[o],i=e[o];break}return t<i?-1:i<t?1:0},"compare");u.isEncoding=s(function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},"isEncoding");u.concat=s(function(r,e){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return u.alloc(0);var t;if(e===void 0)for(e=0,t=0;t<r.length;++t)e+=r[t].length;var i=u.allocUnsafe(e),o=0;for(t=0;t<r.length;++t){var a=r[t];if(A(a,Uint8Array))o+a.length>i.length?u.from(a).copy(i,o):Uint8Array.prototype.set.call(i,a,o);else if(u.isBuffer(a))a.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=a.length}return i},"concat");function gr(n,r){if(u.isBuffer(n))return n.length;if(ArrayBuffer.isView(n)||A(n,ArrayBuffer))return n.byteLength;if(typeof n!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof n);var e=n.length,t=arguments.length>2&&arguments[2]===!0;if(!t&&e===0)return 0;for(var i=!1;;)switch(r){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return $(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Ir(n).length;default:if(i)return t?-1:$(n).length;r=(""+r).toLowerCase(),i=!0}}s(gr,"byteLength");u.byteLength=gr;function $r(n,r,e){var t=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,r>>>=0,e<=r))return"";for(n||(n="utf8");;)switch(n){case"hex":return ue(this,r,e);case"utf8":case"utf-8":return Fr(this,r,e);case"ascii":return ae(this,r,e);case"latin1":case"binary":return se(this,r,e);case"base64":return ie(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he(this,r,e);default:if(t)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),t=!0}}s($r,"slowToString");u.prototype._isBuffer=!0;function S(n,r,e){var t=n[r];n[r]=n[e],n[e]=t}s(S,"swap");u.prototype.swap16=s(function(){var r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<r;e+=2)S(this,e,e+1);return this},"swap16");u.prototype.swap32=s(function(){var r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<r;e+=4)S(this,e,e+3),S(this,e+1,e+2);return this},"swap32");u.prototype.swap64=s(function(){var r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<r;e+=8)S(this,e,e+7),S(this,e+1,e+6),S(this,e+2,e+5),S(this,e+3,e+4);return this},"swap64");u.prototype.toString=s(function(){var r=this.length;return r===0?"":arguments.length===0?Fr(this,0,r):$r.apply(this,arguments)},"toString");u.prototype.toLocaleString=u.prototype.toString;u.prototype.equals=s(function(r){if(!u.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:u.compare(this,r)===0},"equals");u.prototype.inspect=s(function(){var r="",e=C.INSPECT_MAX_BYTES;return r=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(r+=" ... "),"<Buffer "+r+">"},"inspect");xr&&(u.prototype[xr]=u.prototype.inspect);u.prototype.compare=s(function(r,e,t,i,o){if(A(r,Uint8Array)&&(r=u.from(r,r.offset,r.byteLength)),!u.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(e===void 0&&(e=0),t===void 0&&(t=r?r.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),e<0||t>r.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&e>=t)return 0;if(i>=o)return-1;if(e>=t)return 1;if(e>>>=0,t>>>=0,i>>>=0,o>>>=0,this===r)return 0;for(var a=o-i,h=t-e,f=Math.min(a,h),l=this.slice(i,o),c=r.slice(e,t),p=0;p<f;++p)if(l[p]!==c[p]){a=l[p],h=c[p];break}return a<h?-1:h<a?1:0},"compare");function Br(n,r,e,t,i){if(n.length===0)return-1;if(typeof e=="string"?(t=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,er(e)&&(e=i?0:n.length-1),e<0&&(e=n.length+e),e>=n.length){if(i)return-1;e=n.length-1}else if(e<0)if(i)e=0;else return-1;if(typeof r=="string"&&(r=u.from(r,t)),u.isBuffer(r))return r.length===0?-1:wr(n,r,e,t,i);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(n,r,e):Uint8Array.prototype.lastIndexOf.call(n,r,e):wr(n,[r],e,t,i);throw new TypeError("val must be string, number or Buffer")}s(Br,"bidirectionalIndexOf");function wr(n,r,e,t,i){var o=1,a=n.length,h=r.length;if(t!==void 0&&(t=String(t).toLowerCase(),t==="ucs2"||t==="ucs-2"||t==="utf16le"||t==="utf-16le")){if(n.length<2||r.length<2)return-1;o=2,a/=2,h/=2,e/=2}function f(w,d){return o===1?w[d]:w.readUInt16BE(d*o)}s(f,"read");var l;if(i){var c=-1;for(l=e;l<a;l++)if(f(n,l)===f(r,c===-1?0:l-c)){if(c===-1&&(c=l),l-c+1===h)return c*o}else c!==-1&&(l-=l-c),c=-1}else for(e+h>a&&(e=a-h),l=e;l>=0;l--){for(var p=!0,x=0;x<h;x++)if(f(n,l+x)!==f(r,x)){p=!1;break}if(p)return l}return-1}s(wr,"arrayIndexOf");u.prototype.includes=s(function(r,e,t){return this.indexOf(r,e,t)!==-1},"includes");u.prototype.indexOf=s(function(r,e,t){return Br(this,r,e,t,!0)},"indexOf");u.prototype.lastIndexOf=s(function(r,e,t){return Br(this,r,e,t,!1)},"lastIndexOf");function Qr(n,r,e,t){e=Number(e)||0;var i=n.length-e;t?(t=Number(t),t>i&&(t=i)):t=i;var o=r.length;t>o/2&&(t=o/2);for(var a=0;a<t;++a){var h=parseInt(r.substr(a*2,2),16);if(er(h))return a;n[e+a]=h}return a}s(Qr,"hexWrite");function re(n,r,e,t){return D($(r,n.length-e),n,e,t)}s(re,"utf8Write");function ee(n,r,e,t){return D(ce(r),n,e,t)}s(ee,"asciiWrite");function te(n,r,e,t){return D(Ir(r),n,e,t)}s(te,"base64Write");function ne(n,r,e,t){return D(le(r,n.length-e),n,e,t)}s(ne,"ucs2Write");u.prototype.write=s(function(r,e,t,i){if(e===void 0)i="utf8",t=this.length,e=0;else if(t===void 0&&typeof e=="string")i=e,t=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(t)?(t=t>>>0,i===void 0&&(i="utf8")):(i=t,t=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var o=this.length-e;if((t===void 0||t>o)&&(t=o),r.length>0&&(t<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var a=!1;;)switch(i){case"hex":return Qr(this,r,e,t);case"utf8":case"utf-8":return re(this,r,e,t);case"ascii":case"latin1":case"binary":return ee(this,r,e,t);case"base64":return te(this,r,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,r,e,t);default:if(a)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),a=!0}},"write");u.prototype.toJSON=s(function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},"toJSON");function ie(n,r,e){return r===0&&e===n.length?K.fromByteArray(n):K.fromByteArray(n.slice(r,e))}s(ie,"base64Slice");function Fr(n,r,e){e=Math.min(n.length,e);for(var t=[],i=r;i<e;){var o=n[i],a=null,h=o>239?4:o>223?3:o>191?2:1;if(i+h<=e){var f,l,c,p;switch(h){case 1:o<128&&(a=o);break;case 2:f=n[i+1],(f&192)===128&&(p=(o&31)<<6|f&63,p>127&&(a=p));break;case 3:f=n[i+1],l=n[i+2],(f&192)===128&&(l&192)===128&&(p=(o&15)<<12|(f&63)<<6|l&63,p>2047&&(p<55296||p>57343)&&(a=p));break;case 4:f=n[i+1],l=n[i+2],c=n[i+3],(f&192)===128&&(l&192)===128&&(c&192)===128&&(p=(o&15)<<18|(f&63)<<12|(l&63)<<6|c&63,p>65535&&p<1114112&&(a=p))}}a===null?(a=65533,h=1):a>65535&&(a-=65536,t.push(a>>>10&1023|55296),a=56320|a&1023),t.push(a),i+=h}return oe(t)}s(Fr,"utf8Slice");var mr=4096;function oe(n){var r=n.length;if(r<=mr)return String.fromCharCode.apply(String,n);for(var e="",t=0;t<r;)e+=String.fromCharCode.apply(String,n.slice(t,t+=mr));return e}s(oe,"decodeCodePointsArray");function ae(n,r,e){var t="";e=Math.min(n.length,e);for(var i=r;i<e;++i)t+=String.fromCharCode(n[i]&127);return t}s(ae,"asciiSlice");function se(n,r,e){var t="";e=Math.min(n.length,e);for(var i=r;i<e;++i)t+=String.fromCharCode(n[i]);return t}s(se,"latin1Slice");function ue(n,r,e){var t=n.length;(!r||r<0)&&(r=0),(!e||e<0||e>t)&&(e=t);for(var i="",o=r;o<e;++o)i+=ye[n[o]];return i}s(ue,"hexSlice");function he(n,r,e){for(var t=n.slice(r,e),i="",o=0;o<t.length-1;o+=2)i+=String.fromCharCode(t[o]+t[o+1]*256);return i}s(he,"utf16leSlice");u.prototype.slice=s(function(r,e){var t=this.length;r=~~r,e=e===void 0?t:~~e,r<0?(r+=t,r<0&&(r=0)):r>t&&(r=t),e<0?(e+=t,e<0&&(e=0)):e>t&&(e=t),e<r&&(e=r);var i=this.subarray(r,e);return Object.setPrototypeOf(i,u.prototype),i},"slice");function y(n,r,e){if(n%1!==0||n<0)throw new RangeError("offset is not uint");if(n+r>e)throw new RangeError("Trying to access beyond buffer length")}s(y,"checkOffset");u.prototype.readUintLE=u.prototype.readUIntLE=s(function(r,e,t){r=r>>>0,e=e>>>0,t||y(r,e,this.length);for(var i=this[r],o=1,a=0;++a<e&&(o*=256);)i+=this[r+a]*o;return i},"readUIntLE");u.prototype.readUintBE=u.prototype.readUIntBE=s(function(r,e,t){r=r>>>0,e=e>>>0,t||y(r,e,this.length);for(var i=this[r+--e],o=1;e>0&&(o*=256);)i+=this[r+--e]*o;return i},"readUIntBE");u.prototype.readUint8=u.prototype.readUInt8=s(function(r,e){return r=r>>>0,e||y(r,1,this.length),this[r]},"readUInt8");u.prototype.readUint16LE=u.prototype.readUInt16LE=s(function(r,e){return r=r>>>0,e||y(r,2,this.length),this[r]|this[r+1]<<8},"readUInt16LE");u.prototype.readUint16BE=u.prototype.readUInt16BE=s(function(r,e){return r=r>>>0,e||y(r,2,this.length),this[r]<<8|this[r+1]},"readUInt16BE");u.prototype.readUint32LE=u.prototype.readUInt32LE=s(function(r,e){return r=r>>>0,e||y(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},"readUInt32LE");u.prototype.readUint32BE=u.prototype.readUInt32BE=s(function(r,e){return r=r>>>0,e||y(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},"readUInt32BE");u.prototype.readIntLE=s(function(r,e,t){r=r>>>0,e=e>>>0,t||y(r,e,this.length);for(var i=this[r],o=1,a=0;++a<e&&(o*=256);)i+=this[r+a]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},"readIntLE");u.prototype.readIntBE=s(function(r,e,t){r=r>>>0,e=e>>>0,t||y(r,e,this.length);for(var i=e,o=1,a=this[r+--i];i>0&&(o*=256);)a+=this[r+--i]*o;return o*=128,a>=o&&(a-=Math.pow(2,8*e)),a},"readIntBE");u.prototype.readInt8=s(function(r,e){return r=r>>>0,e||y(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},"readInt8");u.prototype.readInt16LE=s(function(r,e){r=r>>>0,e||y(r,2,this.length);var t=this[r]|this[r+1]<<8;return t&32768?t|4294901760:t},"readInt16LE");u.prototype.readInt16BE=s(function(r,e){r=r>>>0,e||y(r,2,this.length);var t=this[r+1]|this[r]<<8;return t&32768?t|4294901760:t},"readInt16BE");u.prototype.readInt32LE=s(function(r,e){return r=r>>>0,e||y(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},"readInt32LE");u.prototype.readInt32BE=s(function(r,e){return r=r>>>0,e||y(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},"readInt32BE");u.prototype.readFloatLE=s(function(r,e){return r=r>>>0,e||y(r,4,this.length),R.read(this,r,!0,23,4)},"readFloatLE");u.prototype.readFloatBE=s(function(r,e){return r=r>>>0,e||y(r,4,this.length),R.read(this,r,!1,23,4)},"readFloatBE");u.prototype.readDoubleLE=s(function(r,e){return r=r>>>0,e||y(r,8,this.length),R.read(this,r,!0,52,8)},"readDoubleLE");u.prototype.readDoubleBE=s(function(r,e){return r=r>>>0,e||y(r,8,this.length),R.read(this,r,!1,52,8)},"readDoubleBE");function m(n,r,e,t,i,o){if(!u.isBuffer(n))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>i||r<o)throw new RangeError('"value" argument is out of bounds');if(e+t>n.length)throw new RangeError("Index out of range")}s(m,"checkInt");u.prototype.writeUintLE=u.prototype.writeUIntLE=s(function(r,e,t,i){if(r=+r,e=e>>>0,t=t>>>0,!i){var o=Math.pow(2,8*t)-1;m(this,r,e,t,o,0)}var a=1,h=0;for(this[e]=r&255;++h<t&&(a*=256);)this[e+h]=r/a&255;return e+t},"writeUIntLE");u.prototype.writeUintBE=u.prototype.writeUIntBE=s(function(r,e,t,i){if(r=+r,e=e>>>0,t=t>>>0,!i){var o=Math.pow(2,8*t)-1;m(this,r,e,t,o,0)}var a=t-1,h=1;for(this[e+a]=r&255;--a>=0&&(h*=256);)this[e+a]=r/h&255;return e+t},"writeUIntBE");u.prototype.writeUint8=u.prototype.writeUInt8=s(function(r,e,t){return r=+r,e=e>>>0,t||m(this,r,e,1,255,0),this[e]=r&255,e+1},"writeUInt8");u.prototype.writeUint16LE=u.prototype.writeUInt16LE=s(function(r,e,t){return r=+r,e=e>>>0,t||m(this,r,e,2,65535,0),this[e]=r&255,this[e+1]=r>>>8,e+2},"writeUInt16LE");u.prototype.writeUint16BE=u.prototype.writeUInt16BE=s(function(r,e,t){return r=+r,e=e>>>0,t||m(this,r,e,2,65535,0),this[e]=r>>>8,this[e+1]=r&255,e+2},"writeUInt16BE");u.prototype.writeUint32LE=u.prototype.writeUInt32LE=s(function(r,e,t){return r=+r,e=e>>>0,t||m(this,r,e,4,4294967295,0),this[e+3]=r>>>24,this[e+2]=r>>>16,this[e+1]=r>>>8,this[e]=r&255,e+4},"writeUInt32LE");u.prototype.writeUint32BE=u.prototype.writeUInt32BE=s(function(r,e,t){return r=+r,e=e>>>0,t||m(this,r,e,4,4294967295,0),this[e]=r>>>24,this[e+1]=r>>>16,this[e+2]=r>>>8,this[e+3]=r&255,e+4},"writeUInt32BE");u.prototype.writeIntLE=s(function(r,e,t,i){if(r=+r,e=e>>>0,!i){var o=Math.pow(2,8*t-1);m(this,r,e,t,o-1,-o)}var a=0,h=1,f=0;for(this[e]=r&255;++a<t&&(h*=256);)r<0&&f===0&&this[e+a-1]!==0&&(f=1),this[e+a]=(r/h>>0)-f&255;return e+t},"writeIntLE");u.prototype.writeIntBE=s(function(r,e,t,i){if(r=+r,e=e>>>0,!i){var o=Math.pow(2,8*t-1);m(this,r,e,t,o-1,-o)}var a=t-1,h=1,f=0;for(this[e+a]=r&255;--a>=0&&(h*=256);)r<0&&f===0&&this[e+a+1]!==0&&(f=1),this[e+a]=(r/h>>0)-f&255;return e+t},"writeIntBE");u.prototype.writeInt8=s(function(r,e,t){return r=+r,e=e>>>0,t||m(this,r,e,1,127,-128),r<0&&(r=255+r+1),this[e]=r&255,e+1},"writeInt8");u.prototype.writeInt16LE=s(function(r,e,t){return r=+r,e=e>>>0,t||m(this,r,e,2,32767,-32768),this[e]=r&255,this[e+1]=r>>>8,e+2},"writeInt16LE");u.prototype.writeInt16BE=s(function(r,e,t){return r=+r,e=e>>>0,t||m(this,r,e,2,32767,-32768),this[e]=r>>>8,this[e+1]=r&255,e+2},"writeInt16BE");u.prototype.writeInt32LE=s(function(r,e,t){return r=+r,e=e>>>0,t||m(this,r,e,4,2147483647,-2147483648),this[e]=r&255,this[e+1]=r>>>8,this[e+2]=r>>>16,this[e+3]=r>>>24,e+4},"writeInt32LE");u.prototype.writeInt32BE=s(function(r,e,t){return r=+r,e=e>>>0,t||m(this,r,e,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[e]=r>>>24,this[e+1]=r>>>16,this[e+2]=r>>>8,this[e+3]=r&255,e+4},"writeInt32BE");function Ur(n,r,e,t,i,o){if(e+t>n.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}s(Ur,"checkIEEE754");function Ar(n,r,e,t,i){return r=+r,e=e>>>0,i||Ur(n,r,e,4,34028234663852886e22,-34028234663852886e22),R.write(n,r,e,t,23,4),e+4}s(Ar,"writeFloat");u.prototype.writeFloatLE=s(function(r,e,t){return Ar(this,r,e,!0,t)},"writeFloatLE");u.prototype.writeFloatBE=s(function(r,e,t){return Ar(this,r,e,!1,t)},"writeFloatBE");function vr(n,r,e,t,i){return r=+r,e=e>>>0,i||Ur(n,r,e,8,17976931348623157e292,-17976931348623157e292),R.write(n,r,e,t,52,8),e+8}s(vr,"writeDouble");u.prototype.writeDoubleLE=s(function(r,e,t){return vr(this,r,e,!0,t)},"writeDoubleLE");u.prototype.writeDoubleBE=s(function(r,e,t){return vr(this,r,e,!1,t)},"writeDoubleBE");u.prototype.copy=s(function(r,e,t,i){if(!u.isBuffer(r))throw new TypeError("argument should be a Buffer");if(t||(t=0),!i&&i!==0&&(i=this.length),e>=r.length&&(e=r.length),e||(e=0),i>0&&i<t&&(i=t),i===t||r.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(t<0||t>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),r.length-e<i-t&&(i=r.length-e+t);var o=i-t;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,t,i):Uint8Array.prototype.set.call(r,this.subarray(t,i),e),o},"copy");u.prototype.fill=s(function(r,e,t,i){if(typeof r=="string"){if(typeof e=="string"?(i=e,e=0,t=this.length):typeof t=="string"&&(i=t,t=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!u.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(r.length===1){var o=r.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(r=o)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(e<0||this.length<e||this.length<t)throw new RangeError("Out of range index");if(t<=e)return this;e=e>>>0,t=t===void 0?this.length:t>>>0,r||(r=0);var a;if(typeof r=="number")for(a=e;a<t;++a)this[a]=r;else{var h=u.isBuffer(r)?r:u.from(r,i),f=h.length;if(f===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(a=0;a<t-e;++a)this[a+e]=h[a%f]}return this},"fill");var fe=/[^+/0-9A-Za-z-_]/g;function pe(n){if(n=n.split("=")[0],n=n.trim().replace(fe,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}s(pe,"base64clean");function $(n,r){r=r||1/0;for(var e,t=n.length,i=null,o=[],a=0;a<t;++a){if(e=n.charCodeAt(a),e>55295&&e<57344){if(!i){if(e>56319){(r-=3)>-1&&o.push(239,191,189);continue}else if(a+1===t){(r-=3)>-1&&o.push(239,191,189);continue}i=e;continue}if(e<56320){(r-=3)>-1&&o.push(239,191,189),i=e;continue}e=(i-55296<<10|e-56320)+65536}else i&&(r-=3)>-1&&o.push(239,191,189);if(i=null,e<128){if((r-=1)<0)break;o.push(e)}else if(e<2048){if((r-=2)<0)break;o.push(e>>6|192,e&63|128)}else if(e<65536){if((r-=3)<0)break;o.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((r-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return o}s($,"utf8ToBytes");function ce(n){for(var r=[],e=0;e<n.length;++e)r.push(n.charCodeAt(e)&255);return r}s(ce,"asciiToBytes");function le(n,r){for(var e,t,i,o=[],a=0;a<n.length&&!((r-=2)<0);++a)e=n.charCodeAt(a),t=e>>8,i=e%256,o.push(i),o.push(t);return o}s(le,"utf16leToBytes");function Ir(n){return K.toByteArray(pe(n))}s(Ir,"base64ToBytes");function D(n,r,e,t){for(var i=0;i<t&&!(i+e>=r.length||i>=n.length);++i)r[i+e]=n[i];return i}s(D,"blitBuffer");function A(n,r){return n instanceof r||n!=null&&n.constructor!=null&&n.constructor.name!=null&&n.constructor.name===r.name}s(A,"isInstance");function er(n){return n!==n}s(er,"numberIsNaN");var ye=(function(){for(var n="0123456789abcdef",r=new Array(256),e=0;e<16;++e)for(var t=e*16,i=0;i<16;++i)r[t+i]=n[e]+n[i];return r})()});var Cr=qr(Tr(),1);var xe=Symbol.for("kClient"),g=Symbol.for("kBackend"),B=Symbol.for("kContext");var tr=class tr{constructor(r){this.document=r==null?void 0:r.document}};s(tr,"Backend");var M=tr;var nr=class nr extends Error{constructor(r,e){super(r.message),this.cause=e,this.issues=r.issues||[],this.status=r.status,e&&(this.cause=e,e.stack&&(this.stack=e.stack))}};s(nr,"ClientError");var N=nr;var v;(function(n){n.ResponseHeader="response-header",n.Response="response",n.Body="body",n.Events="events"})(v||(v={}));import or from"@browsery/type-is";import{omit as we}from"@jsopen/objects";import{isBlob as me,isFormData as de}from"@opra/common";import{Observable as Ee}from"rxjs";import{isReadableStreamLike as ge}from"rxjs/internal/util/isReadableStreamLike";var ir=class ir extends M{constructor(r,e){super(e);let t=new URL(r);this.serviceUrl=t.toString().split("?")[0].split("#")[0],this.serviceUrl.endsWith("/")||(this.serviceUrl+="/")}};s(ir,"HttpBackend");var P=ir;var H=class H{constructor(r){this.hasBody=!1,this.headers=(r==null?void 0:r.headers)instanceof Headers?r==null?void 0:r.headers:new Headers(r==null?void 0:r.headers),this.status=(r==null?void 0:r.status)||200,this.statusText=(r==null?void 0:r.statusText)||"OK",this.url=(r==null?void 0:r.url)||null,this.ok=this.status>=200&&this.status<300,this.body=r==null?void 0:r.body,this.hasBody=(r==null?void 0:r.body)!=null||!!(r!=null&&r.hasBody),this.contentType=(this.headers.get("content-type")||"").split(";")[0]}clone(r){return new H({...this,...r})}};s(H,"HttpResponse");var q=H;var F;(function(n){n.Sent="Sent",n.UploadProgress="UploadProgress",n.ResponseHeader="ResponseHeader",n.DownloadProgress="DownloadProgress",n.Response="Response",n.User="User"})(F||(F={}));var ar=class ar extends P{constructor(r,e){var t,i,o,a,h,f;super(r,e),this.interceptors=Array.from(new Set([...(e==null?void 0:e.interceptors)||[]])),this.defaults={...e==null?void 0:e.defaults,headers:((t=e==null?void 0:e.defaults)==null?void 0:t.headers)instanceof Headers?(i=e==null?void 0:e.defaults)==null?void 0:i.headers:new Headers((o=e==null?void 0:e.defaults)==null?void 0:o.headers),params:((a=e==null?void 0:e.defaults)==null?void 0:a.params)instanceof URLSearchParams?(h=e==null?void 0:e.defaults)==null?void 0:h.params:new URLSearchParams((f=e==null?void 0:e.defaults)==null?void 0:f.params)}}handle(r){return new Ee(e=>{(async()=>{let t=this.prepareRequest(r);if(t.body&&r.reportProgress){let l=t.body,c=t.headers.get("content-length")||"0",p=parseInt(c,10)||0,x=0,w=new TransformStream({transform(d,L){L.enqueue(d),x+=d.byteLength,e.next({type:F.UploadProgress,request:t,total:p,loaded:x})}});t=new Request(t.url,{cache:t.cache,credentials:t.credentials,headers:t.headers,integrity:t.integrity,keepalive:t.keepalive,method:t.method,mode:t.mode,redirect:t.redirect,referrer:t.referrer,referrerPolicy:t.referrerPolicy,signal:t.signal,body:l.pipeThrough(w),window:r.window,duplex:"half"})}let i=this.send(t);e.next({request:t,type:F.Sent});let o=await i,a=this.createResponse({url:o.url,headers:o.headers,status:o.status,statusText:o.statusText,hasBody:!!o.body});e.next({request:t,type:F.ResponseHeader,response:a});let h;if(o.body)if(r.reportProgress){let l=o.body,c=o.headers.get("content-length")||"0",p=parseInt(c,10)||0,x=0,w=new Response(new ReadableStream({async start(d){let L=l.getReader();for(;;){let{done:Lr,value:fr}=await L.read();if(Lr)break;x+=fr.byteLength,d.enqueue(fr),e.next({type:F.DownloadProgress,request:t,total:p,loaded:x})}d.close()}}));h=await this.parseBody(w)}else h=await this.parseBody(o);let f=this.createResponse({url:o.url,headers:o.headers,status:o.status,statusText:o.statusText,body:h});e.next({request:t,type:F.Response,response:f}),e.complete()})().catch(t=>e.error(t))})}send(r){return fetch(r)}prepareRequest(r){let e=r.headers||new Headers,t={...r,...we(this.defaults,["headers","params"]),headers:e};this.defaults.headers.forEach((a,h)=>{e.has(h)||e.set(h,a)});let i=new URL(t.url,this.serviceUrl);this.defaults.params.size&&(this.defaults.params.forEach((a,h)=>{i.searchParams.has(h)||i.searchParams.set(h,a)}),t.url=i.toString());let o=t.body;if(o){let a="";typeof o=="string"||typeof o=="number"||typeof o=="boolean"?(a='text/plain; charset="UTF-8"',t.body=new Blob([String(o)],{type:a}),e.set("Content-Length",String(t.body.size)),delete t.duplex):ge(o)?(a="application/octet-stream",t.duplex="half"):Buffer.isBuffer(o)?(a="application/octet-stream",e.set("Content-Length",String(o.length)),delete t.duplex):me(o)?(a=o.type||"application/octet-stream",e.set("Content-Length",String(o.size)),delete t.duplex):(de(o)||(a='application/json;charset="UTF-8"',t.body=new Blob([JSON.stringify(o)],{type:a}),e.set("Content-Length",String(t.body.size))),delete t.duplex),a&&!e.has("Content-Type")&&e.set("Content-Type",a)}return new Request(i.toString(),t)}createResponse(r){return new q(r)}async parseBody(r){let e,t=r.headers.get("Content-Type")||"";if(or.is(t,["json","application/*+json"]))e=await r.json(),typeof e=="string"&&(e=JSON.parse(e));else if(or.is(t,["text"]))e=await r.text();else if(or.is(t,["multipart"]))e=await r.formData();else{let i=await r.arrayBuffer();i.byteLength&&(e=i)}return e}};s(ar,"FetchBackend");var _=ar;import{ApiDocumentFactory as ve}from"@opra/common";import Fe from"@browsery/type-is";import{MimeTypes as Ue}from"@opra/common";import{lastValueFrom as Sr,Observable as Ae}from"rxjs";var sr=class sr{constructor(r,e){this.chain=r.reduceRight((t,i)=>(o,a)=>i.intercept(o,{handle:s(h=>t(h,a),"handle")}),Be),this.finalHandler=e}handle(r){return this.chain(r,e=>this.finalHandler.handle(e))}};s(sr,"HttpInterceptorHandler");var j=sr;function Be(n,r){return r(n)}s(Be,"chainEnd");var W=class W extends Ae{constructor(r,e){super(t=>{let i=this[B].observe;new j(r.interceptors||[],this[g]).handle(this[B]).subscribe({next(o){if(i===v.Events){t.next(o);return}if(i===v.ResponseHeader&&o.type===F.ResponseHeader){t.next(o.response),t.complete();return}if(o.type===F.Response){let{response:a}=o;if(i===v.Response){t.next(a),t.complete();return}let h=Fe.is(o.response.contentType||"",[Ue.opra_response_json]);if(a.status>=400&&a.status<600){t.error(new N({message:a.status+" "+a.statusText,status:a.status,issues:h?a.body.errors:void 0})),t.complete();return}t.next(o.response.body),t.complete()}},error(o){t.error(o)},complete(){t.complete()}})}),Object.defineProperty(this,g,{enumerable:!1,value:r}),Object.defineProperty(this,B,{enumerable:!1,value:{...e,observe:v.Body,headers:new Headers(e==null?void 0:e.headers)}})}clone(){return new W(this[g],this[B])}options(r){return Object.assign(this[B],r),this}header(r,e){let t=this[B].headers;return typeof r=="object"?((r instanceof Headers?r:new Headers(r)).forEach((o,a)=>{a.toLowerCase()==="set-cookie"?t.append(a,o):t.set(a,o)}),this):(e==null||e===""?t.delete(r):t.append(r,String(e)),this)}param(r,e){e&&typeof e=="object"&&(e=JSON.stringify(e));let t=this[B].url.searchParams;return typeof r=="object"?(typeof r.forEach=="function"?r.forEach((i,o)=>t.set(String(o),String(i))):Object.entries(r).forEach(i=>t.set(String(i[0]),String(i[1]))),this):(e==null?t.delete(r):t.set(r,String(e)),this)}observe(r){if(r===this[B].observe)return this;let e=this.clone();return e[B].observe=r||v.Body,e}getBody(){return Sr(this.observe(v.Body))}getResponse(){return Sr(this.observe(v.Response))}};s(W,"HttpRequestObservable");var O=W;var Ie=/^(\/*)(.+)/,ur=class ur{constructor(r){Object.defineProperty(this,g,{enumerable:!1,value:r})}get serviceUrl(){return this[g].serviceUrl}async fetchDocument(r){let e={},t=s(async o=>{let a=this.request("$schema",{headers:new Headers({accept:"application/json"})});o&&a.param("id",o);let h=await a.getBody().catch(f=>{throw f.message="Error fetching api schema from url ("+this.serviceUrl+`).
`+f.message,f});if(h.references){let f=h.references;h.references={};for(let[l,c]of Object.entries(f)){if(e[c.id]===null)throw new Error("Circular reference detected");e[c.id]=null;let p=await t(c.id);h.references[l]=e[c.id]=p}}return h},"getDocument"),i=await t(r==null?void 0:r.documentId);return await ve.createDocument(i).catch(o=>{throw o.message=`Error loading api document.
`+o.message,o})}request(r,e){var i;r=((i=Ie.exec(r))==null?void 0:i[2])||"";let t=new O(this[g],{...e,method:(e==null?void 0:e.method)||"GET",url:new URL(r,this.serviceUrl)});return e!=null&&e.params&&t.param(e.params),t}delete(r,e){return this.request(r,{...e,method:"DELETE"})}get(r,e){return this.request(r,{...e,method:"GET"})}patch(r,e,t){return this.request(r,{...t,method:"PATCH",body:e})}post(r,e,t){return this.request(r,{...t,method:"POST",body:e})}put(r,e,t){return this.request(r,{...t,method:"PUT",body:e})}};s(ur,"HttpClientBase");var z=ur;var hr=class hr extends z{constructor(r,e){super(new _(r,e))}get defaults(){return this[g].defaults}};s(hr,"OpraHttpClient");var Rr=hr;function Ut(n,...r){let e="",t;for(t=0;t<n.length;t++)e+=n[0]+encodeURIComponent(r[t]);return e}s(Ut,"urlPath");globalThis.Buffer=Cr.Buffer;export{M as Backend,N as ClientError,_ as FetchBackend,P as HttpBackend,z as HttpClientBase,F as HttpEventType,v as HttpObserveType,O as HttpRequestObservable,q as HttpResponse,Rr as OpraHttpClient,g as kBackend,xe as kClient,B as kContext,Ut as urlPath};
/*! Bundled license information:
ieee754/index.js:
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
buffer/index.js:
(*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*)
*/