rmapi-js 2.0.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  rmapi-js
2
2
  ========
3
3
  [![build](https://github.com/erikbrinkman/rmapi-js/actions/workflows/node.js.yml/badge.svg)](https://github.com/erikbrinkman/rmapi-js/actions/workflows/node.js.yml)
4
- [![docs](https://img.shields.io/badge/docs-docs-blue)](https://erikbrinkman.github.io/rmapi-js/)
4
+ [![docs](https://img.shields.io/badge/docs-docs-blue)](https://erikbrinkman.github.io/rmapi-js/modules.html)
5
5
  [![npm](https://img.shields.io/npm/v/rmapi-js)](https://www.npmjs.com/package/rmapi-js)
6
6
  [![license](https://img.shields.io/github/license/erikbrinkman/rmapi-js)](LICENSE)
7
7
 
@@ -1,4 +1,4 @@
1
- var Pt=Object.create;var H=Object.defineProperty;var wt=Object.getOwnPropertyDescriptor;var Et=Object.getOwnPropertyNames;var Tt=Object.getPrototypeOf,At=Object.prototype.hasOwnProperty;var c=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ot=(e,t)=>{for(var r in t)H(e,r,{get:t[r],enumerable:!0})},Ae=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Et(t))!At.call(e,n)&&n!==r&&H(e,n,{get:()=>t[n],enumerable:!(i=wt(t,n))||i.enumerable});return e};var de=(e,t,r)=>(r=e!=null?Pt(Tt(e)):{},Ae(t||!e||!e.__esModule?H(r,"default",{value:e,enumerable:!0}):r,e)),kt=e=>Ae(H({},"__esModule",{value:!0}),e);var Se=c(j=>{"use strict";j.byteLength=Mt;j.toByteArray=Rt;j.fromByteArray=Ut;var P=[],x=[],St=typeof Uint8Array<"u"?Uint8Array:Array,ce="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(O=0,Oe=ce.length;O<Oe;++O)P[O]=ce[O],x[ce.charCodeAt(O)]=O;var O,Oe;x["-".charCodeAt(0)]=62;x["_".charCodeAt(0)]=63;function ke(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var i=r===t?0:4-r%4;return[r,i]}function Mt(e){var t=ke(e),r=t[0],i=t[1];return(r+i)*3/4-i}function Ft(e,t,r){return(t+r)*3/4-r}function Rt(e){var t,r=ke(e),i=r[0],n=r[1],a=new St(Ft(e,i,n)),s=0,f=n>0?i-4:i,o;for(o=0;o<f;o+=4)t=x[e.charCodeAt(o)]<<18|x[e.charCodeAt(o+1)]<<12|x[e.charCodeAt(o+2)]<<6|x[e.charCodeAt(o+3)],a[s++]=t>>16&255,a[s++]=t>>8&255,a[s++]=t&255;return n===2&&(t=x[e.charCodeAt(o)]<<2|x[e.charCodeAt(o+1)]>>4,a[s++]=t&255),n===1&&(t=x[e.charCodeAt(o)]<<10|x[e.charCodeAt(o+1)]<<4|x[e.charCodeAt(o+2)]>>2,a[s++]=t>>8&255,a[s++]=t&255),a}function Ct(e){return P[e>>18&63]+P[e>>12&63]+P[e>>6&63]+P[e&63]}function Dt(e,t,r){for(var i,n=[],a=t;a<r;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),n.push(Ct(i));return n.join("")}function Ut(e){for(var t,r=e.length,i=r%3,n=[],a=16383,s=0,f=r-i;s<f;s+=a)n.push(Dt(e,s,s+a>f?f:s+a));return i===1?(t=e[r-1],n.push(P[t>>2]+P[t<<4&63]+"==")):i===2&&(t=(e[r-2]<<8)+e[r-1],n.push(P[t>>10]+P[t>>4&63]+P[t<<2&63]+"=")),n.join("")}});var ye=c(pe=>{"use strict";Object.defineProperty(pe,"__esModule",{value:!0});pe.default=Lt;var It=qt(require("crypto"));function qt(e){return e&&e.__esModule?e:{default:e}}var z=new Uint8Array(256),J=z.length;function Lt(){return J>z.length-16&&(It.default.randomFillSync(z),J=0),z.slice(J,J+=16)}});var Me=c(V=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});V.default=void 0;var Bt=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;V.default=Bt});var L=c(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.default=void 0;var Nt=$t(Me());function $t(e){return e&&e.__esModule?e:{default:e}}function Ht(e){return typeof e=="string"&&Nt.default.test(e)}var jt=Ht;G.default=jt});var N=c(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.default=void 0;B.unsafeStringify=Fe;var Jt=zt(L());function zt(e){return e&&e.__esModule?e:{default:e}}var y=[];for(let e=0;e<256;++e)y.push((e+256).toString(16).slice(1));function Fe(e,t=0){return(y[e[t+0]]+y[e[t+1]]+y[e[t+2]]+y[e[t+3]]+"-"+y[e[t+4]]+y[e[t+5]]+"-"+y[e[t+6]]+y[e[t+7]]+"-"+y[e[t+8]]+y[e[t+9]]+"-"+y[e[t+10]]+y[e[t+11]]+y[e[t+12]]+y[e[t+13]]+y[e[t+14]]+y[e[t+15]]).toLowerCase()}function Vt(e,t=0){let r=Fe(e,t);if(!(0,Jt.default)(r))throw TypeError("Stringified UUID is invalid");return r}var Gt=Vt;B.default=Gt});var Ce=c(Y=>{"use strict";Object.defineProperty(Y,"__esModule",{value:!0});Y.default=void 0;var Yt=Wt(ye()),Zt=N();function Wt(e){return e&&e.__esModule?e:{default:e}}var Re,me,ge=0,he=0;function Kt(e,t,r){let i=t&&r||0,n=t||new Array(16);e=e||{};let a=e.node||Re,s=e.clockseq!==void 0?e.clockseq:me;if(a==null||s==null){let p=e.random||(e.rng||Yt.default)();a==null&&(a=Re=[p[0]|1,p[1],p[2],p[3],p[4],p[5]]),s==null&&(s=me=(p[6]<<8|p[7])&16383)}let f=e.msecs!==void 0?e.msecs:Date.now(),o=e.nsecs!==void 0?e.nsecs:he+1,u=f-ge+(o-he)/1e4;if(u<0&&e.clockseq===void 0&&(s=s+1&16383),(u<0||f>ge)&&e.nsecs===void 0&&(o=0),o>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");ge=f,he=o,me=s,f+=122192928e5;let l=((f&268435455)*1e4+o)%4294967296;n[i++]=l>>>24&255,n[i++]=l>>>16&255,n[i++]=l>>>8&255,n[i++]=l&255;let v=f/4294967296*1e4&268435455;n[i++]=v>>>8&255,n[i++]=v&255,n[i++]=v>>>24&15|16,n[i++]=v>>>16&255,n[i++]=s>>>8|128,n[i++]=s&255;for(let p=0;p<6;++p)n[i+p]=a[p];return t||(0,Zt.unsafeStringify)(n)}var Qt=Kt;Y.default=Qt});var ve=c(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.default=void 0;var Xt=er(L());function er(e){return e&&e.__esModule?e:{default:e}}function tr(e){if(!(0,Xt.default)(e))throw TypeError("Invalid UUID");let t,r=new Uint8Array(16);return r[0]=(t=parseInt(e.slice(0,8),16))>>>24,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=t&255,r[4]=(t=parseInt(e.slice(9,13),16))>>>8,r[5]=t&255,r[6]=(t=parseInt(e.slice(14,18),16))>>>8,r[7]=t&255,r[8]=(t=parseInt(e.slice(19,23),16))>>>8,r[9]=t&255,r[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,r[11]=t/4294967296&255,r[12]=t>>>24&255,r[13]=t>>>16&255,r[14]=t>>>8&255,r[15]=t&255,r}var rr=tr;Z.default=rr});var xe=c(k=>{"use strict";Object.defineProperty(k,"__esModule",{value:!0});k.URL=k.DNS=void 0;k.default=or;var nr=N(),ir=ar(ve());function ar(e){return e&&e.__esModule?e:{default:e}}function sr(e){e=unescape(encodeURIComponent(e));let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t}var De="6ba7b810-9dad-11d1-80b4-00c04fd430c8";k.DNS=De;var Ue="6ba7b811-9dad-11d1-80b4-00c04fd430c8";k.URL=Ue;function or(e,t,r){function i(n,a,s,f){var o;if(typeof n=="string"&&(n=sr(n)),typeof a=="string"&&(a=(0,ir.default)(a)),((o=a)===null||o===void 0?void 0:o.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let u=new Uint8Array(16+n.length);if(u.set(a),u.set(n,a.length),u=r(u),u[6]=u[6]&15|t,u[8]=u[8]&63|128,s){f=f||0;for(let l=0;l<16;++l)s[f+l]=u[l];return s}return(0,nr.unsafeStringify)(u)}try{i.name=e}catch{}return i.DNS=De,i.URL=Ue,i}});var Ie=c(W=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.default=void 0;var fr=ur(require("crypto"));function ur(e){return e&&e.__esModule?e:{default:e}}function lr(e){return Array.isArray(e)?e=Buffer.from(e):typeof e=="string"&&(e=Buffer.from(e,"utf8")),fr.default.createHash("md5").update(e).digest()}var dr=lr;W.default=dr});var Le=c(K=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});K.default=void 0;var cr=qe(xe()),pr=qe(Ie());function qe(e){return e&&e.__esModule?e:{default:e}}var yr=(0,cr.default)("v3",48,pr.default),mr=yr;K.default=mr});var Be=c(Q=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Q.default=void 0;var gr=hr(require("crypto"));function hr(e){return e&&e.__esModule?e:{default:e}}var vr={randomUUID:gr.default.randomUUID};Q.default=vr});var He=c(X=>{"use strict";Object.defineProperty(X,"__esModule",{value:!0});X.default=void 0;var Ne=$e(Be()),xr=$e(ye()),br=N();function $e(e){return e&&e.__esModule?e:{default:e}}function _r(e,t,r){if(Ne.default.randomUUID&&!t&&!e)return Ne.default.randomUUID();e=e||{};let i=e.random||(e.rng||xr.default)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){r=r||0;for(let n=0;n<16;++n)t[r+n]=i[n];return t}return(0,br.unsafeStringify)(i)}var Pr=_r;X.default=Pr});var je=c(ee=>{"use strict";Object.defineProperty(ee,"__esModule",{value:!0});ee.default=void 0;var wr=Er(require("crypto"));function Er(e){return e&&e.__esModule?e:{default:e}}function Tr(e){return Array.isArray(e)?e=Buffer.from(e):typeof e=="string"&&(e=Buffer.from(e,"utf8")),wr.default.createHash("sha1").update(e).digest()}var Ar=Tr;ee.default=Ar});var ze=c(te=>{"use strict";Object.defineProperty(te,"__esModule",{value:!0});te.default=void 0;var Or=Je(xe()),kr=Je(je());function Je(e){return e&&e.__esModule?e:{default:e}}var Sr=(0,Or.default)("v5",80,kr.default),Mr=Sr;te.default=Mr});var Ve=c(re=>{"use strict";Object.defineProperty(re,"__esModule",{value:!0});re.default=void 0;var Fr="00000000-0000-0000-0000-000000000000";re.default=Fr});var Ge=c(ne=>{"use strict";Object.defineProperty(ne,"__esModule",{value:!0});ne.default=void 0;var Rr=Cr(L());function Cr(e){return e&&e.__esModule?e:{default:e}}function Dr(e){if(!(0,Rr.default)(e))throw TypeError("Invalid UUID");return parseInt(e.slice(14,15),16)}var Ur=Dr;ne.default=Ur});var Ye=c(_=>{"use strict";Object.defineProperty(_,"__esModule",{value:!0});Object.defineProperty(_,"NIL",{enumerable:!0,get:function(){return Nr.default}});Object.defineProperty(_,"parse",{enumerable:!0,get:function(){return Jr.default}});Object.defineProperty(_,"stringify",{enumerable:!0,get:function(){return jr.default}});Object.defineProperty(_,"v1",{enumerable:!0,get:function(){return Ir.default}});Object.defineProperty(_,"v3",{enumerable:!0,get:function(){return qr.default}});Object.defineProperty(_,"v4",{enumerable:!0,get:function(){return Lr.default}});Object.defineProperty(_,"v5",{enumerable:!0,get:function(){return Br.default}});Object.defineProperty(_,"validate",{enumerable:!0,get:function(){return Hr.default}});Object.defineProperty(_,"version",{enumerable:!0,get:function(){return $r.default}});var Ir=E(Ce()),qr=E(Le()),Lr=E(He()),Br=E(ze()),Nr=E(Ve()),$r=E(Ge()),Hr=E(L()),jr=E(N()),Jr=E(ve());function E(e){return e&&e.__esModule?e:{default:e}}});var we=c(d=>{"use strict";var Ke=d&&d.__rest||function(e,t){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(e);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(r[i[n]]=e[i[n]]);return r};Object.defineProperty(d,"__esModule",{value:!0});d.isSchema=d.isValidSchema=d.isDiscriminatorForm=d.isValuesForm=d.isPropertiesForm=d.isElementsForm=d.isEnumForm=d.isTypeForm=d.isRefForm=d.isEmptyForm=void 0;function zr(e){let{definitions:t,nullable:r,metadata:i}=e,n=Ke(e,["definitions","nullable","metadata"]);return Object.keys(n).length===0}d.isEmptyForm=zr;function Qe(e){return"ref"in e}d.isRefForm=Qe;function Vr(e){return"type"in e}d.isTypeForm=Vr;function Xe(e){return"enum"in e}d.isEnumForm=Xe;function et(e){return"elements"in e}d.isElementsForm=et;function Pe(e){return"properties"in e||"optionalProperties"in e}d.isPropertiesForm=Pe;function tt(e){return"values"in e}d.isValuesForm=tt;function rt(e){return"discriminator"in e}d.isDiscriminatorForm=rt;function S(e,t){if(t===void 0&&(t=e),e.definitions!==void 0){if(t!==e)return!1;for(let r of Object.values(e.definitions))if(!S(r,t))return!1}if(Qe(e)&&!(e.ref in(t.definitions||{}))||Xe(e)&&(e.enum.length===0||e.enum.length!==new Set(e.enum).size))return!1;if(et(e))return S(e.elements,t);if(Pe(e)){for(let r of Object.values(e.properties||{}))if(!S(r,t))return!1;for(let r of Object.values(e.optionalProperties||{}))if(!S(r,t))return!1;for(let r of Object.keys(e.properties||{}))if(r in(e.optionalProperties||{}))return!1}if(tt(e))return S(e.values,t);if(rt(e)){for(let r of Object.values(e.mapping))if(!S(r,t)||!Pe(r)||r.nullable||e.discriminator in(r.properties||{})||e.discriminator in(r.optionalProperties||{}))return!1}return!0}d.isValidSchema=S;var Gr=[[!1,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!0,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!0,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!0,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!0,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!0,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!1,!0,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!0,!1,!1,!1],[!1,!1,!1,!1,!0,!0,!0,!1,!1,!1],[!1,!1,!1,!1,!1,!1,!1,!0,!1,!1],[!1,!1,!1,!1,!1,!1,!1,!1,!0,!0]],Yr=["boolean","float32","float64","int8","uint8","int16","uint16","int32","uint32","string","timestamp"];function M(e){if(typeof e!="object"||Array.isArray(e)||e===null)return!1;let t=e,{definitions:r=void 0,nullable:i=void 0,metadata:n=void 0,ref:a=void 0,type:s=void 0,enum:f=void 0,elements:o=void 0,properties:u=void 0,optionalProperties:l=void 0,additionalProperties:v=void 0,values:p=void 0,discriminator:ue=void 0,mapping:I=void 0}=t,vt=Ke(t,["definitions","nullable","metadata","ref","type","enum","elements","properties","optionalProperties","additionalProperties","values","discriminator","mapping"]),xt=[a!==void 0,s!==void 0,f!==void 0,o!==void 0,u!==void 0,l!==void 0,v!==void 0,p!==void 0,ue!==void 0,I!==void 0],le=!1;for(let b of Gr)le=le||b.every((bt,_t)=>bt===xt[_t]);if(!le)return!1;if(r!==void 0){if(typeof r!="object"||Array.isArray(r)||r===null)return!1;for(let b of Object.values(r))if(!M(b))return!1}if(i!==void 0&&typeof i!="boolean"||n!==void 0&&(typeof n!="object"||Array.isArray(n)||n===null)||a!==void 0&&typeof a!="string"||s!==void 0&&(typeof s!="string"||!Yr.includes(s))||f!==void 0&&(!Array.isArray(f)||!f.every(b=>typeof b=="string"))||o!==void 0&&!M(o))return!1;if(u!==void 0){if(typeof u!="object"||Array.isArray(u)||u===null)return!1;for(let b of Object.values(u))if(!M(b))return!1}if(l!==void 0){if(typeof l!="object"||Array.isArray(l)||l===null)return!1;for(let b of Object.values(l))if(!M(b))return!1}if(v!==void 0&&typeof v!="boolean"||p!==void 0&&!M(p)||ue!==void 0&&typeof ue!="string")return!1;if(I!==void 0){if(typeof I!="object"||Array.isArray(I)||I===null)return!1;for(let b of Object.values(I))if(!M(b))return!1}return Object.keys(vt).length===0}d.isSchema=M});var nt=c(Ee=>{"use strict";Object.defineProperty(Ee,"__esModule",{value:!0});var Zr=/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(\.\d+)?([zZ]|((\+|-)(\d{2}):(\d{2})))$/;function Wr(e){let t=e.match(Zr);if(t===null)return!1;let r=parseInt(t[1],10),i=parseInt(t[2],10),n=parseInt(t[3],10),a=parseInt(t[4],10),s=parseInt(t[5],10),f=parseInt(t[6],10);return!(i>12||n>Kr(r,i)||a>23||s>59||f>60)}Ee.default=Wr;function Kr(e,t){return t===2?Qr(e)?29:28:Xr[t]}function Qr(e){return e%4===0&&(e%100!==0||e%400===0)}var Xr=[0,31,0,31,30,31,30,31,31,30,31,30,31]});var it=c(T=>{"use strict";var en=T&&T.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(T,"__esModule",{value:!0});T.validate=T.MaxDepthExceededError=void 0;var tn=en(nt()),F=we(),ie=class extends Error{};T.MaxDepthExceededError=ie;var ae=class extends Error{};function rn(e,t,r){let i={errors:[],instanceTokens:[],schemaTokens:[[]],root:e,config:r||{maxDepth:0,maxErrors:0}};try{D(i,e,t)}catch(n){if(!(n instanceof ae))throw n}return i.errors}T.validate=rn;function D(e,t,r,i){if(!(t.nullable&&r===null)){if(F.isRefForm(t)){if(e.schemaTokens.length===e.config.maxDepth)throw new ie;e.schemaTokens.push(["definitions",t.ref]),D(e,e.root.definitions[t.ref],r),e.schemaTokens.pop()}else if(F.isTypeForm(t)){switch(m(e,"type"),t.type){case"boolean":typeof r!="boolean"&&g(e);break;case"float32":case"float64":typeof r!="number"&&g(e);break;case"int8":q(e,r,-128,127);break;case"uint8":q(e,r,0,255);break;case"int16":q(e,r,-32768,32767);break;case"uint16":q(e,r,0,65535);break;case"int32":q(e,r,-2147483648,2147483647);break;case"uint32":q(e,r,0,4294967295);break;case"string":typeof r!="string"&&g(e);break;case"timestamp":typeof r!="string"?g(e):tn.default(r)||g(e);break}h(e)}else if(F.isEnumForm(t))m(e,"enum"),(typeof r!="string"||!t.enum.includes(r))&&g(e),h(e);else if(F.isElementsForm(t)){if(m(e,"elements"),Array.isArray(r))for(let[n,a]of r.entries())R(e,n.toString()),D(e,t.elements,a),C(e);else g(e);h(e)}else if(F.isPropertiesForm(t))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){if(t.properties!==void 0){m(e,"properties");for(let[n,a]of Object.entries(t.properties))m(e,n),r.hasOwnProperty(n)?(R(e,n),D(e,a,r[n]),C(e)):g(e),h(e);h(e)}if(t.optionalProperties!==void 0){m(e,"optionalProperties");for(let[n,a]of Object.entries(t.optionalProperties))m(e,n),r.hasOwnProperty(n)&&(R(e,n),D(e,a,r[n]),C(e)),h(e);h(e)}if(t.additionalProperties!==!0)for(let n of Object.keys(r)){let a=t.properties&&n in t.properties,s=t.optionalProperties&&n in t.optionalProperties;!a&&!s&&n!==i&&(R(e,n),g(e),C(e))}}else t.properties!==void 0?m(e,"properties"):m(e,"optionalProperties"),g(e),h(e);else if(F.isValuesForm(t)){if(m(e,"values"),typeof r=="object"&&r!==null&&!Array.isArray(r))for(let[n,a]of Object.entries(r))R(e,n),D(e,t.values,a),C(e);else g(e);h(e)}else if(F.isDiscriminatorForm(t))if(typeof r=="object"&&r!==null&&!Array.isArray(r))if(r.hasOwnProperty(t.discriminator)){let n=r[t.discriminator];typeof n=="string"?n in t.mapping?(m(e,"mapping"),m(e,n),D(e,t.mapping[n],r,t.discriminator),h(e),h(e)):(m(e,"mapping"),R(e,t.discriminator),g(e),C(e),h(e)):(m(e,"discriminator"),R(e,t.discriminator),g(e),C(e),h(e))}else m(e,"discriminator"),g(e),h(e);else m(e,"discriminator"),g(e),h(e)}}function q(e,t,r,i){(typeof t!="number"||!Number.isInteger(t)||t<r||t>i)&&g(e)}function R(e,t){e.instanceTokens.push(t)}function C(e){e.instanceTokens.pop()}function m(e,t){e.schemaTokens[e.schemaTokens.length-1].push(t)}function h(e){e.schemaTokens[e.schemaTokens.length-1].pop()}function g(e){if(e.errors.push({instancePath:[...e.instanceTokens],schemaPath:[...e.schemaTokens[e.schemaTokens.length-1]]}),e.errors.length===e.config.maxErrors)throw new ae}});var st=c(A=>{"use strict";var nn=A&&A.__createBinding||(Object.create?function(e,t,r,i){i===void 0&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){i===void 0&&(i=r),e[i]=t[r]}),at=A&&A.__exportStar||function(e,t){for(var r in e)r!=="default"&&!t.hasOwnProperty(r)&&nn(t,e,r)};Object.defineProperty(A,"__esModule",{value:!0});at(we(),A);at(it(),A)});var gn={};Ot(gn,{GenerationError:()=>fe,ResponseError:()=>U,builtinFontNames:()=>un,builtinLineHeights:()=>mt,builtinMargins:()=>yt,builtinTextScales:()=>pt,builtinTools:()=>fn,formatEntry:()=>gt,parseEntry:()=>ht,register:()=>yn,remarkable:()=>mn});module.exports=kt(gn);var dt=de(Se());var w=de(Ye(),1),Un=w.default.v1,In=w.default.v3,be=w.default.v4,qn=w.default.v5,Ln=w.default.NIL,Bn=w.default.version,Nn=w.default.validate,$n=w.default.stringify,Hn=w.default.parse;function _e(e){return[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join("")}function Ze(e){return new Uint8Array((e.match(/../g)??[]).map(t=>parseInt(t,16)))}function We(e){let t=0;for(let n of e)t+=n.length;let r=new Uint8Array(t),i=0;for(let n of e)r.set(n,i),i+=n.length;return r}var ot=de(st());function $(e,t){if((0,ot.validate)(e,t).length)throw new Error(`couldn't validate schema: ${JSON.stringify(t)} didn't match schema ${JSON.stringify(e)}`)}var ft="3",ct="https://webapp-prod.cloud.remarkable.engineering",an="https://internal.cloud.remarkable.com",ut="x-goog-generation",sn="x-goog-if-generation-match",on="x-goog-content-length-range",fn=["Ballpoint","Ballpointv2","Brush","Calligraphy","ClearPage","EraseSection","Eraser","Fineliner","Finelinerv2","Highlighter","Highlighterv2","Marker","Markerv2","Paintbrush","Paintbrushv2","Pencilv2","SharpPencil","SharpPencilv2","SolidPen","ZoomTool"],un=["Maison Neue","EB Garamond","Noto Sans","Noto Serif","Noto Mono","Noto Sans UI"],pt={xs:.7,sm:.8,md:1,lg:1.2,xl:1.5,xx:2},yt={sm:50,md:125,rr:180,lg:200},mt={df:-1,md:100,lg:150,xl:200},ln={properties:{docID:{type:"string"},hash:{type:"string"}}},dn={properties:{relative_path:{type:"string"},url:{type:"string"},expires:{type:"timestamp"},method:{enum:["POST","GET","PUT","DELETE"]}},optionalProperties:{maxuploadsize_bytes:{type:"float64"}}},se={visibleName:{type:"string"},lastModified:{type:"string"}},oe={version:{type:"int32"},pinned:{type:"boolean"},synced:{type:"boolean"},modified:{type:"boolean"},deleted:{type:"boolean"},metadatamodified:{type:"boolean"},parent:{type:"string"}},cn={discriminator:"type",mapping:{CollectionType:{properties:se,optionalProperties:oe},DocumentType:{properties:se,optionalProperties:{...oe,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"}}}}},lt={id:{type:"string"},hash:{type:"string"}},pn={discriminator:"type",mapping:{CollectionType:{properties:{...se,...lt},optionalProperties:oe},DocumentType:{properties:{...se,...lt,fileType:{enum:["notebook","epub","pdf",""]}},optionalProperties:{...oe,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"}}}}},U=class extends Error{constructor(r,i,n){super(n);this.status=r,this.statusText=i}},fe=class extends Error{constructor(){super("Generation preconditions failed. This means the current state is out of date with the cloud and needs to be re-synced.")}};async function yn(e,{deviceDesc:t="browser-chrome",uuid:r=be(),authHost:i=ct,fetch:n=globalThis.fetch}={}){if(e.length!==8)throw new Error(`code should be length 8, but was ${e.length}`);let a=await n(`${i}/token/json/2/device/new`,{method:"POST",headers:{Authorization:"Bearer"},body:JSON.stringify({code:e,deviceDesc:t,deviceID:r})});if(a.ok)return await a.text();throw new U(a.status,a.statusText,"couldn't register api")}function gt({hash:e,type:t,documentId:r,subfiles:i,size:n}){return`${e}:${t}:${r}:${i}:${n}
2
- `}function ht(e){let[t,r,i,n,a]=e.split(":");if(t===void 0||r===void 0||i===void 0||n===void 0||a===void 0)throw new Error(`entries line didn't contain five fields: '${e}'`);if(r==="80000000")return{hash:t,type:r,documentId:i,subfiles:parseInt(n),size:BigInt(a)};if(r==="0"){if(n!=="0")throw new Error(`file type entry had nonzero number of subfiles: ${n}`);return{hash:t,type:r,documentId:i,subfiles:0,size:BigInt(a)}}else throw new Error(`entries line contained invalid type: ${r}`)}var Te=class{#o;#a;#e;#s;#t;constructor(t,r,i,n,a){this.#o=t,this.#a=r,this.#e=i,this.#s=n,this.#t=a}async#i(t,{body:r,method:i="POST",headers:n={}}){let a=await this.#a(t,{method:i,headers:{Authorization:`Bearer ${this.#o}`,...n},body:r});if(a.ok)return a;{let s=await a.text();throw new U(a.status,a.statusText,`failed reMarkable request: ${s}`)}}async#r({url:t,method:r,maxuploadsize_bytes:i},n,a={}){let s=i?{...a,[on]:`0,${i}`}:a,f=await this.#a(t,{method:r,body:n,headers:s});if(f.ok)return f;{let o=await f.text();throw new U(f.status,f.statusText,o)}}async#n(t,r,i){let n=r===void 0?"downloads":"uploads",a=i?`{ "http_method": "PUT", "relative_path": "${t}", "root_schema": "${i}", "generation": ${r} }`:JSON.stringify({http_method:"GET",relative_path:t}),f=await(await this.#i(`${this.#t}/sync/v2/signed-urls/${n}`,{body:a})).text(),o=JSON.parse(f);return $(dn,o),o}async getRootHash(){let t=await this.#n("root"),r=await this.#r(t),i=r.headers.get(ut);if(!i)throw new Error("no generation header in root hash");return[await r.text(),BigInt(i)]}async putRootHash(t,r){let i=await this.#n("root",r,t),n;try{n=await this.#r(i,t,{[sn]:`${r}`})}catch(s){throw s instanceof U&&s.status===412?new fe:s}let a=n.headers.get(ut);if(!a)throw new Error("no generation header in root hash");return BigInt(a)}async getBuffer(t){let r=await this.#n(t);return await(await this.#r(r)).arrayBuffer()}async getText(t){let r=await this.#e?.get(t);if(r)return r;{let i=await this.#n(t),a=await(await this.#r(i)).text();return await this.#e?.set(t,a),a}}async getMetadata(t){let r=await this.getText(t),i=JSON.parse(r);return $(cn,i),i}async getEntries(t){let r=await this.getText(t),[i,...n]=r.slice(0,-1).split(`
3
- `);if(i!==ft)throw new Error(`got unexpected schema version: ${i}`);return n.map(ht)}async#f(t,r){let i=await this.#n(t,null);await this.#r(i,r)}async putEntries(t,r){let i=new TextEncoder;r.sort((l,v)=>l.documentId.localeCompare(v.documentId));let n=We(r.map(l=>Ze(l.hash))),a=await this.#s.digest("SHA-256",n),s=_e(a),f=r.map(gt).join(""),o=`${ft}
4
- ${f}`,u=i.encode(o);return await this.#f(s,u),await this.#e?.set(s,o),{hash:s,type:"80000000",documentId:t,subfiles:r.length,size:0n}}async putBuffer(t,r){let i=await this.#s.digest("SHA-256",r),n=_e(i);return await this.#f(n,r),{hash:n,type:"0",documentId:t,subfiles:0,size:BigInt(r.length)}}async putText(t,r){let i=new TextEncoder,n=await this.putBuffer(t,i.encode(r));return await this.#e?.set(n.hash,r),n}async#u(t,r,i,n,a){if(a.fileType!==i)throw new Error(`internal error: fileTypes don't match: ${i}, ${a.fileType}`);let s=be(),f=`${new Date().valueOf()}`,o=[];o.push(this.putBuffer(`${s}.${i}`,r));let u={type:"DocumentType",visibleName:t,version:0,parent:n,synced:!0,lastModified:f};o.push(this.putText(`${s}.metadata`,JSON.stringify(u))),o.push(this.putText(`${s}.content`,JSON.stringify(a)));let l=await Promise.all(o);return await this.putEntries(s,l)}async putEpub(t,r,{parent:i="",margins:n=125,orientation:a,textAlignment:s,textScale:f=1,lineHeight:o=-1,fontName:u="",cover:l="visited",lastTool:v}={}){let p={dummyDocument:!1,extraMetadata:{LastTool:v},fileType:"epub",pageCount:0,lastOpenedPage:0,lineHeight:typeof o=="string"?mt[o]:o,margins:typeof n=="string"?yt[n]:n,textScale:typeof f=="string"?pt[f]:f,pages:[],coverPageNumber:l==="first"?0:-1,formatVersion:1,orientation:a,textAlignment:s,fontName:u};return await this.#u(t,r,"epub",i,p)}async putPdf(t,r,{parent:i="",orientation:n,cover:a="first",lastTool:s}={}){let f={dummyDocument:!1,extraMetadata:{LastTool:s},fileType:"pdf",pageCount:0,lastOpenedPage:0,lineHeight:-1,margins:125,textScale:1,pages:[],coverPageNumber:a==="first"?0:-1,formatVersion:1,orientation:n};return await this.#u(t,r,"pdf",i,f)}async syncComplete(t){let r=`{ "generation": ${t} }`;await this.#i(`${this.#t}/sync/v2/sync-complete`,{body:r})}async getEntriesMetadata(){let r=await(await this.#i(`${this.#t}/doc/v2/files`,{method:"GET",headers:{"rm-source":"RoR-Browser"}})).text(),i=JSON.parse(r);return $({elements:pn},i),i}async#l(t,r,i){let a=new TextEncoder().encode(JSON.stringify({file_name:t})),f=await(await this.#i(`${this.#t}/doc/v2/files`,{body:r,headers:{"content-type":i,"rm-meta":(0,dt.fromByteArray)(a),"rm-source":"RoR-Browser"}})).text(),o=JSON.parse(f);return $(ln,o),o}async uploadEpub(t,r){return await this.#l(t,r,"application/epub+zip")}async uploadPdf(t,r){return await this.#l(t,r,"application/pdf")}};async function mn(e,{fetch:t=globalThis.fetch,cache:r,subtle:i=globalThis.crypto?.subtle,authHost:n=ct,syncHost:a=an}={}){let s=await t(`${n}/token/json/2/user/new`,{method:"POST",headers:{Authorization:`Bearer ${e}`}});if(!s.ok)throw new Error(`couldn't fetch auth token: ${s.statusText}`);let f=await s.text();return new Te(f,t,r,i,a)}0&&(module.exports={GenerationError,ResponseError,builtinFontNames,builtinLineHeights,builtinMargins,builtinTextScales,builtinTools,formatEntry,parseEntry,register,remarkable});
1
+ var Pt=Object.create;var H=Object.defineProperty;var wt=Object.getOwnPropertyDescriptor;var Et=Object.getOwnPropertyNames;var Tt=Object.getPrototypeOf,At=Object.prototype.hasOwnProperty;var c=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ot=(e,t)=>{for(var r in t)H(e,r,{get:t[r],enumerable:!0})},Ae=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Et(t))!At.call(e,i)&&i!==r&&H(e,i,{get:()=>t[i],enumerable:!(n=wt(t,i))||n.enumerable});return e};var ce=(e,t,r)=>(r=e!=null?Pt(Tt(e)):{},Ae(t||!e||!e.__esModule?H(r,"default",{value:e,enumerable:!0}):r,e)),Mt=e=>Ae(H({},"__esModule",{value:!0}),e);var ke=c(j=>{"use strict";j.byteLength=St;j.toByteArray=Ct;j.fromByteArray=It;var P=[],x=[],kt=typeof Uint8Array<"u"?Uint8Array:Array,pe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(O=0,Oe=pe.length;O<Oe;++O)P[O]=pe[O],x[pe.charCodeAt(O)]=O;var O,Oe;x["-".charCodeAt(0)]=62;x["_".charCodeAt(0)]=63;function Me(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function St(e){var t=Me(e),r=t[0],n=t[1];return(r+n)*3/4-n}function Ft(e,t,r){return(t+r)*3/4-r}function Ct(e){var t,r=Me(e),n=r[0],i=r[1],a=new kt(Ft(e,n,i)),s=0,o=i>0?n-4:n,f;for(f=0;f<o;f+=4)t=x[e.charCodeAt(f)]<<18|x[e.charCodeAt(f+1)]<<12|x[e.charCodeAt(f+2)]<<6|x[e.charCodeAt(f+3)],a[s++]=t>>16&255,a[s++]=t>>8&255,a[s++]=t&255;return i===2&&(t=x[e.charCodeAt(f)]<<2|x[e.charCodeAt(f+1)]>>4,a[s++]=t&255),i===1&&(t=x[e.charCodeAt(f)]<<10|x[e.charCodeAt(f+1)]<<4|x[e.charCodeAt(f+2)]>>2,a[s++]=t>>8&255,a[s++]=t&255),a}function Dt(e){return P[e>>18&63]+P[e>>12&63]+P[e>>6&63]+P[e&63]}function Rt(e,t,r){for(var n,i=[],a=t;a<r;a+=3)n=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),i.push(Dt(n));return i.join("")}function It(e){for(var t,r=e.length,n=r%3,i=[],a=16383,s=0,o=r-n;s<o;s+=a)i.push(Rt(e,s,s+a>o?o:s+a));return n===1?(t=e[r-1],i.push(P[t>>2]+P[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(P[t>>10]+P[t>>4&63]+P[t<<2&63]+"=")),i.join("")}});var me=c(ye=>{"use strict";Object.defineProperty(ye,"__esModule",{value:!0});ye.default=Lt;var Ut=qt(require("crypto"));function qt(e){return e&&e.__esModule?e:{default:e}}var z=new Uint8Array(256),J=z.length;function Lt(){return J>z.length-16&&(Ut.default.randomFillSync(z),J=0),z.slice(J,J+=16)}});var Se=c(V=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});V.default=void 0;var Nt=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;V.default=Nt});var L=c(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.default=void 0;var Bt=$t(Se());function $t(e){return e&&e.__esModule?e:{default:e}}function Ht(e){return typeof e=="string"&&Bt.default.test(e)}var jt=Ht;G.default=jt});var B=c(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});N.default=void 0;N.unsafeStringify=Fe;var Jt=zt(L());function zt(e){return e&&e.__esModule?e:{default:e}}var y=[];for(let e=0;e<256;++e)y.push((e+256).toString(16).slice(1));function Fe(e,t=0){return(y[e[t+0]]+y[e[t+1]]+y[e[t+2]]+y[e[t+3]]+"-"+y[e[t+4]]+y[e[t+5]]+"-"+y[e[t+6]]+y[e[t+7]]+"-"+y[e[t+8]]+y[e[t+9]]+"-"+y[e[t+10]]+y[e[t+11]]+y[e[t+12]]+y[e[t+13]]+y[e[t+14]]+y[e[t+15]]).toLowerCase()}function Vt(e,t=0){let r=Fe(e,t);if(!(0,Jt.default)(r))throw TypeError("Stringified UUID is invalid");return r}var Gt=Vt;N.default=Gt});var De=c(Y=>{"use strict";Object.defineProperty(Y,"__esModule",{value:!0});Y.default=void 0;var Yt=Wt(me()),Zt=B();function Wt(e){return e&&e.__esModule?e:{default:e}}var Ce,ge,he=0,ve=0;function Kt(e,t,r){let n=t&&r||0,i=t||new Array(16);e=e||{};let a=e.node||Ce,s=e.clockseq!==void 0?e.clockseq:ge;if(a==null||s==null){let p=e.random||(e.rng||Yt.default)();a==null&&(a=Ce=[p[0]|1,p[1],p[2],p[3],p[4],p[5]]),s==null&&(s=ge=(p[6]<<8|p[7])&16383)}let o=e.msecs!==void 0?e.msecs:Date.now(),f=e.nsecs!==void 0?e.nsecs:ve+1,u=o-he+(f-ve)/1e4;if(u<0&&e.clockseq===void 0&&(s=s+1&16383),(u<0||o>he)&&e.nsecs===void 0&&(f=0),f>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");he=o,ve=f,ge=s,o+=122192928e5;let l=((o&268435455)*1e4+f)%4294967296;i[n++]=l>>>24&255,i[n++]=l>>>16&255,i[n++]=l>>>8&255,i[n++]=l&255;let v=o/4294967296*1e4&268435455;i[n++]=v>>>8&255,i[n++]=v&255,i[n++]=v>>>24&15|16,i[n++]=v>>>16&255,i[n++]=s>>>8|128,i[n++]=s&255;for(let p=0;p<6;++p)i[n+p]=a[p];return t||(0,Zt.unsafeStringify)(i)}var Qt=Kt;Y.default=Qt});var xe=c(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.default=void 0;var Xt=er(L());function er(e){return e&&e.__esModule?e:{default:e}}function tr(e){if(!(0,Xt.default)(e))throw TypeError("Invalid UUID");let t,r=new Uint8Array(16);return r[0]=(t=parseInt(e.slice(0,8),16))>>>24,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=t&255,r[4]=(t=parseInt(e.slice(9,13),16))>>>8,r[5]=t&255,r[6]=(t=parseInt(e.slice(14,18),16))>>>8,r[7]=t&255,r[8]=(t=parseInt(e.slice(19,23),16))>>>8,r[9]=t&255,r[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,r[11]=t/4294967296&255,r[12]=t>>>24&255,r[13]=t>>>16&255,r[14]=t>>>8&255,r[15]=t&255,r}var rr=tr;Z.default=rr});var be=c(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});M.URL=M.DNS=void 0;M.default=or;var nr=B(),ir=ar(xe());function ar(e){return e&&e.__esModule?e:{default:e}}function sr(e){e=unescape(encodeURIComponent(e));let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t}var Re="6ba7b810-9dad-11d1-80b4-00c04fd430c8";M.DNS=Re;var Ie="6ba7b811-9dad-11d1-80b4-00c04fd430c8";M.URL=Ie;function or(e,t,r){function n(i,a,s,o){var f;if(typeof i=="string"&&(i=sr(i)),typeof a=="string"&&(a=(0,ir.default)(a)),((f=a)===null||f===void 0?void 0:f.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let u=new Uint8Array(16+i.length);if(u.set(a),u.set(i,a.length),u=r(u),u[6]=u[6]&15|t,u[8]=u[8]&63|128,s){o=o||0;for(let l=0;l<16;++l)s[o+l]=u[l];return s}return(0,nr.unsafeStringify)(u)}try{n.name=e}catch{}return n.DNS=Re,n.URL=Ie,n}});var Ue=c(W=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.default=void 0;var fr=ur(require("crypto"));function ur(e){return e&&e.__esModule?e:{default:e}}function lr(e){return Array.isArray(e)?e=Buffer.from(e):typeof e=="string"&&(e=Buffer.from(e,"utf8")),fr.default.createHash("md5").update(e).digest()}var dr=lr;W.default=dr});var Le=c(K=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});K.default=void 0;var cr=qe(be()),pr=qe(Ue());function qe(e){return e&&e.__esModule?e:{default:e}}var yr=(0,cr.default)("v3",48,pr.default),mr=yr;K.default=mr});var Ne=c(Q=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Q.default=void 0;var gr=hr(require("crypto"));function hr(e){return e&&e.__esModule?e:{default:e}}var vr={randomUUID:gr.default.randomUUID};Q.default=vr});var He=c(X=>{"use strict";Object.defineProperty(X,"__esModule",{value:!0});X.default=void 0;var Be=$e(Ne()),xr=$e(me()),br=B();function $e(e){return e&&e.__esModule?e:{default:e}}function _r(e,t,r){if(Be.default.randomUUID&&!t&&!e)return Be.default.randomUUID();e=e||{};let n=e.random||(e.rng||xr.default)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(let i=0;i<16;++i)t[r+i]=n[i];return t}return(0,br.unsafeStringify)(n)}var Pr=_r;X.default=Pr});var je=c(ee=>{"use strict";Object.defineProperty(ee,"__esModule",{value:!0});ee.default=void 0;var wr=Er(require("crypto"));function Er(e){return e&&e.__esModule?e:{default:e}}function Tr(e){return Array.isArray(e)?e=Buffer.from(e):typeof e=="string"&&(e=Buffer.from(e,"utf8")),wr.default.createHash("sha1").update(e).digest()}var Ar=Tr;ee.default=Ar});var ze=c(te=>{"use strict";Object.defineProperty(te,"__esModule",{value:!0});te.default=void 0;var Or=Je(be()),Mr=Je(je());function Je(e){return e&&e.__esModule?e:{default:e}}var kr=(0,Or.default)("v5",80,Mr.default),Sr=kr;te.default=Sr});var Ve=c(re=>{"use strict";Object.defineProperty(re,"__esModule",{value:!0});re.default=void 0;var Fr="00000000-0000-0000-0000-000000000000";re.default=Fr});var Ge=c(ne=>{"use strict";Object.defineProperty(ne,"__esModule",{value:!0});ne.default=void 0;var Cr=Dr(L());function Dr(e){return e&&e.__esModule?e:{default:e}}function Rr(e){if(!(0,Cr.default)(e))throw TypeError("Invalid UUID");return parseInt(e.slice(14,15),16)}var Ir=Rr;ne.default=Ir});var Ye=c(_=>{"use strict";Object.defineProperty(_,"__esModule",{value:!0});Object.defineProperty(_,"NIL",{enumerable:!0,get:function(){return Br.default}});Object.defineProperty(_,"parse",{enumerable:!0,get:function(){return Jr.default}});Object.defineProperty(_,"stringify",{enumerable:!0,get:function(){return jr.default}});Object.defineProperty(_,"v1",{enumerable:!0,get:function(){return Ur.default}});Object.defineProperty(_,"v3",{enumerable:!0,get:function(){return qr.default}});Object.defineProperty(_,"v4",{enumerable:!0,get:function(){return Lr.default}});Object.defineProperty(_,"v5",{enumerable:!0,get:function(){return Nr.default}});Object.defineProperty(_,"validate",{enumerable:!0,get:function(){return Hr.default}});Object.defineProperty(_,"version",{enumerable:!0,get:function(){return $r.default}});var Ur=E(De()),qr=E(Le()),Lr=E(He()),Nr=E(ze()),Br=E(Ve()),$r=E(Ge()),Hr=E(L()),jr=E(B()),Jr=E(xe());function E(e){return e&&e.__esModule?e:{default:e}}});var we=c(d=>{"use strict";var Ke=d&&d.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r};Object.defineProperty(d,"__esModule",{value:!0});d.isSchema=d.isValidSchema=d.isDiscriminatorForm=d.isValuesForm=d.isPropertiesForm=d.isElementsForm=d.isEnumForm=d.isTypeForm=d.isRefForm=d.isEmptyForm=void 0;function zr(e){let{definitions:t,nullable:r,metadata:n}=e,i=Ke(e,["definitions","nullable","metadata"]);return Object.keys(i).length===0}d.isEmptyForm=zr;function Qe(e){return"ref"in e}d.isRefForm=Qe;function Vr(e){return"type"in e}d.isTypeForm=Vr;function Xe(e){return"enum"in e}d.isEnumForm=Xe;function et(e){return"elements"in e}d.isElementsForm=et;function Pe(e){return"properties"in e||"optionalProperties"in e}d.isPropertiesForm=Pe;function tt(e){return"values"in e}d.isValuesForm=tt;function rt(e){return"discriminator"in e}d.isDiscriminatorForm=rt;function k(e,t){if(t===void 0&&(t=e),e.definitions!==void 0){if(t!==e)return!1;for(let r of Object.values(e.definitions))if(!k(r,t))return!1}if(Qe(e)&&!(e.ref in(t.definitions||{}))||Xe(e)&&(e.enum.length===0||e.enum.length!==new Set(e.enum).size))return!1;if(et(e))return k(e.elements,t);if(Pe(e)){for(let r of Object.values(e.properties||{}))if(!k(r,t))return!1;for(let r of Object.values(e.optionalProperties||{}))if(!k(r,t))return!1;for(let r of Object.keys(e.properties||{}))if(r in(e.optionalProperties||{}))return!1}if(tt(e))return k(e.values,t);if(rt(e)){for(let r of Object.values(e.mapping))if(!k(r,t)||!Pe(r)||r.nullable||e.discriminator in(r.properties||{})||e.discriminator in(r.optionalProperties||{}))return!1}return!0}d.isValidSchema=k;var Gr=[[!1,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!0,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!0,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!0,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!0,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!0,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!1,!0,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!0,!1,!1,!1],[!1,!1,!1,!1,!0,!0,!0,!1,!1,!1],[!1,!1,!1,!1,!1,!1,!1,!0,!1,!1],[!1,!1,!1,!1,!1,!1,!1,!1,!0,!0]],Yr=["boolean","float32","float64","int8","uint8","int16","uint16","int32","uint32","string","timestamp"];function S(e){if(typeof e!="object"||Array.isArray(e)||e===null)return!1;let t=e,{definitions:r=void 0,nullable:n=void 0,metadata:i=void 0,ref:a=void 0,type:s=void 0,enum:o=void 0,elements:f=void 0,properties:u=void 0,optionalProperties:l=void 0,additionalProperties:v=void 0,values:p=void 0,discriminator:le=void 0,mapping:U=void 0}=t,vt=Ke(t,["definitions","nullable","metadata","ref","type","enum","elements","properties","optionalProperties","additionalProperties","values","discriminator","mapping"]),xt=[a!==void 0,s!==void 0,o!==void 0,f!==void 0,u!==void 0,l!==void 0,v!==void 0,p!==void 0,le!==void 0,U!==void 0],de=!1;for(let b of Gr)de=de||b.every((bt,_t)=>bt===xt[_t]);if(!de)return!1;if(r!==void 0){if(typeof r!="object"||Array.isArray(r)||r===null)return!1;for(let b of Object.values(r))if(!S(b))return!1}if(n!==void 0&&typeof n!="boolean"||i!==void 0&&(typeof i!="object"||Array.isArray(i)||i===null)||a!==void 0&&typeof a!="string"||s!==void 0&&(typeof s!="string"||!Yr.includes(s))||o!==void 0&&(!Array.isArray(o)||!o.every(b=>typeof b=="string"))||f!==void 0&&!S(f))return!1;if(u!==void 0){if(typeof u!="object"||Array.isArray(u)||u===null)return!1;for(let b of Object.values(u))if(!S(b))return!1}if(l!==void 0){if(typeof l!="object"||Array.isArray(l)||l===null)return!1;for(let b of Object.values(l))if(!S(b))return!1}if(v!==void 0&&typeof v!="boolean"||p!==void 0&&!S(p)||le!==void 0&&typeof le!="string")return!1;if(U!==void 0){if(typeof U!="object"||Array.isArray(U)||U===null)return!1;for(let b of Object.values(U))if(!S(b))return!1}return Object.keys(vt).length===0}d.isSchema=S});var nt=c(Ee=>{"use strict";Object.defineProperty(Ee,"__esModule",{value:!0});var Zr=/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(\.\d+)?([zZ]|((\+|-)(\d{2}):(\d{2})))$/;function Wr(e){let t=e.match(Zr);if(t===null)return!1;let r=parseInt(t[1],10),n=parseInt(t[2],10),i=parseInt(t[3],10),a=parseInt(t[4],10),s=parseInt(t[5],10),o=parseInt(t[6],10);return!(n>12||i>Kr(r,n)||a>23||s>59||o>60)}Ee.default=Wr;function Kr(e,t){return t===2?Qr(e)?29:28:Xr[t]}function Qr(e){return e%4===0&&(e%100!==0||e%400===0)}var Xr=[0,31,0,31,30,31,30,31,31,30,31,30,31]});var it=c(T=>{"use strict";var en=T&&T.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(T,"__esModule",{value:!0});T.validate=T.MaxDepthExceededError=void 0;var tn=en(nt()),F=we(),ae=class extends Error{};T.MaxDepthExceededError=ae;var se=class extends Error{};function rn(e,t,r){let n={errors:[],instanceTokens:[],schemaTokens:[[]],root:e,config:r||{maxDepth:0,maxErrors:0}};try{R(n,e,t)}catch(i){if(!(i instanceof se))throw i}return n.errors}T.validate=rn;function R(e,t,r,n){if(!(t.nullable&&r===null)){if(F.isRefForm(t)){if(e.schemaTokens.length===e.config.maxDepth)throw new ae;e.schemaTokens.push(["definitions",t.ref]),R(e,e.root.definitions[t.ref],r),e.schemaTokens.pop()}else if(F.isTypeForm(t)){switch(m(e,"type"),t.type){case"boolean":typeof r!="boolean"&&g(e);break;case"float32":case"float64":typeof r!="number"&&g(e);break;case"int8":q(e,r,-128,127);break;case"uint8":q(e,r,0,255);break;case"int16":q(e,r,-32768,32767);break;case"uint16":q(e,r,0,65535);break;case"int32":q(e,r,-2147483648,2147483647);break;case"uint32":q(e,r,0,4294967295);break;case"string":typeof r!="string"&&g(e);break;case"timestamp":typeof r!="string"?g(e):tn.default(r)||g(e);break}h(e)}else if(F.isEnumForm(t))m(e,"enum"),(typeof r!="string"||!t.enum.includes(r))&&g(e),h(e);else if(F.isElementsForm(t)){if(m(e,"elements"),Array.isArray(r))for(let[i,a]of r.entries())C(e,i.toString()),R(e,t.elements,a),D(e);else g(e);h(e)}else if(F.isPropertiesForm(t))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){if(t.properties!==void 0){m(e,"properties");for(let[i,a]of Object.entries(t.properties))m(e,i),r.hasOwnProperty(i)?(C(e,i),R(e,a,r[i]),D(e)):g(e),h(e);h(e)}if(t.optionalProperties!==void 0){m(e,"optionalProperties");for(let[i,a]of Object.entries(t.optionalProperties))m(e,i),r.hasOwnProperty(i)&&(C(e,i),R(e,a,r[i]),D(e)),h(e);h(e)}if(t.additionalProperties!==!0)for(let i of Object.keys(r)){let a=t.properties&&i in t.properties,s=t.optionalProperties&&i in t.optionalProperties;!a&&!s&&i!==n&&(C(e,i),g(e),D(e))}}else t.properties!==void 0?m(e,"properties"):m(e,"optionalProperties"),g(e),h(e);else if(F.isValuesForm(t)){if(m(e,"values"),typeof r=="object"&&r!==null&&!Array.isArray(r))for(let[i,a]of Object.entries(r))C(e,i),R(e,t.values,a),D(e);else g(e);h(e)}else if(F.isDiscriminatorForm(t))if(typeof r=="object"&&r!==null&&!Array.isArray(r))if(r.hasOwnProperty(t.discriminator)){let i=r[t.discriminator];typeof i=="string"?i in t.mapping?(m(e,"mapping"),m(e,i),R(e,t.mapping[i],r,t.discriminator),h(e),h(e)):(m(e,"mapping"),C(e,t.discriminator),g(e),D(e),h(e)):(m(e,"discriminator"),C(e,t.discriminator),g(e),D(e),h(e))}else m(e,"discriminator"),g(e),h(e);else m(e,"discriminator"),g(e),h(e)}}function q(e,t,r,n){(typeof t!="number"||!Number.isInteger(t)||t<r||t>n)&&g(e)}function C(e,t){e.instanceTokens.push(t)}function D(e){e.instanceTokens.pop()}function m(e,t){e.schemaTokens[e.schemaTokens.length-1].push(t)}function h(e){e.schemaTokens[e.schemaTokens.length-1].pop()}function g(e){if(e.errors.push({instancePath:[...e.instanceTokens],schemaPath:[...e.schemaTokens[e.schemaTokens.length-1]]}),e.errors.length===e.config.maxErrors)throw new se}});var st=c(A=>{"use strict";var nn=A&&A.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),at=A&&A.__exportStar||function(e,t){for(var r in e)r!=="default"&&!t.hasOwnProperty(r)&&nn(t,e,r)};Object.defineProperty(A,"__esModule",{value:!0});at(we(),A);at(it(),A)});var gn={};Ot(gn,{GenerationError:()=>ue,ResponseError:()=>I,builtinFontNames:()=>un,builtinLineHeights:()=>mt,builtinMargins:()=>yt,builtinTextScales:()=>pt,builtinTools:()=>fn,formatEntry:()=>gt,parseEntry:()=>ht,register:()=>yn,remarkable:()=>mn});module.exports=Mt(gn);var dt=ce(ke());var w=ce(Ye(),1),In=w.default.v1,Un=w.default.v3,ie=w.default.v4,qn=w.default.v5,Ln=w.default.NIL,Nn=w.default.version,Bn=w.default.validate,$n=w.default.stringify,Hn=w.default.parse;function _e(e){return[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join("")}function Ze(e){return new Uint8Array((e.match(/../g)??[]).map(t=>parseInt(t,16)))}function We(e){let t=0;for(let i of e)t+=i.length;let r=new Uint8Array(t),n=0;for(let i of e)r.set(i,n),n+=i.length;return r}var ot=ce(st());function $(e,t){if((0,ot.validate)(e,t).length)throw new Error(`couldn't validate schema: ${JSON.stringify(t)} didn't match schema ${JSON.stringify(e)}`)}var ft="3",ct="https://webapp-prod.cloud.remarkable.engineering",an="https://internal.cloud.remarkable.com",ut="x-goog-generation",sn="x-goog-if-generation-match",on="x-goog-content-length-range",fn=["Ballpoint","Ballpointv2","Brush","Calligraphy","ClearPage","EraseSection","Eraser","Fineliner","Finelinerv2","Highlighter","Highlighterv2","Marker","Markerv2","Paintbrush","Paintbrushv2","Pencilv2","SharpPencil","SharpPencilv2","SolidPen","ZoomTool"],un=["Maison Neue","EB Garamond","Noto Sans","Noto Serif","Noto Mono","Noto Sans UI"],pt={xs:.7,sm:.8,md:1,lg:1.2,xl:1.5,xx:2},yt={sm:50,md:125,rr:180,lg:200},mt={df:-1,md:100,lg:150,xl:200},ln={properties:{docID:{type:"string"},hash:{type:"string"}}},dn={properties:{relative_path:{type:"string"},url:{type:"string"},expires:{type:"timestamp"},method:{enum:["POST","GET","PUT","DELETE"]}},optionalProperties:{maxuploadsize_bytes:{type:"float64"}}},oe={visibleName:{type:"string"},lastModified:{type:"string"}},fe={version:{type:"int32"},pinned:{type:"boolean"},synced:{type:"boolean"},modified:{type:"boolean"},deleted:{type:"boolean"},metadatamodified:{type:"boolean"},parent:{type:"string"}},cn={discriminator:"type",mapping:{CollectionType:{properties:oe,optionalProperties:fe},DocumentType:{properties:oe,optionalProperties:{...fe,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"}}}}},lt={id:{type:"string"},hash:{type:"string"}},pn={discriminator:"type",mapping:{CollectionType:{properties:{...oe,...lt},optionalProperties:fe},DocumentType:{properties:{...oe,...lt,fileType:{enum:["notebook","epub","pdf",""]}},optionalProperties:{...fe,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"}}}}},I=class extends Error{constructor(r,n,i){super(i);this.status=r,this.statusText=n}},ue=class extends Error{constructor(){super("Generation preconditions failed. This means the current state is out of date with the cloud and needs to be re-synced.")}};async function yn(e,{deviceDesc:t="browser-chrome",uuid:r=ie(),authHost:n=ct,fetch:i=globalThis.fetch}={}){if(e.length!==8)throw new Error(`code should be length 8, but was ${e.length}`);let a=await i(`${n}/token/json/2/device/new`,{method:"POST",headers:{Authorization:"Bearer"},body:JSON.stringify({code:e,deviceDesc:t,deviceID:r})});if(a.ok)return await a.text();throw new I(a.status,a.statusText,"couldn't register api")}function gt({hash:e,type:t,documentId:r,subfiles:n,size:i}){return`${e}:${t}:${r}:${n}:${i}
2
+ `}function ht(e){let[t,r,n,i,a]=e.split(":");if(t===void 0||r===void 0||n===void 0||i===void 0||a===void 0)throw new Error(`entries line didn't contain five fields: '${e}'`);if(r==="80000000")return{hash:t,type:r,documentId:n,subfiles:parseInt(i),size:BigInt(a)};if(r==="0"){if(i!=="0")throw new Error(`file type entry had nonzero number of subfiles: ${i}`);return{hash:t,type:r,documentId:n,subfiles:0,size:BigInt(a)}}else throw new Error(`entries line contained invalid type: ${r}`)}var Te=class{#o;#a;#e;#s;#t;constructor(t,r,n,i,a){this.#o=t,this.#a=r,this.#e=n,this.#s=i,this.#t=a}async#i(t,{body:r,method:n="POST",headers:i={}}){let a=await this.#a(t,{method:n,headers:{Authorization:`Bearer ${this.#o}`,...i},body:r});if(a.ok)return a;{let s=await a.text();throw new I(a.status,a.statusText,`failed reMarkable request: ${s}`)}}async#r({url:t,method:r,maxuploadsize_bytes:n},i,a={}){let s=n?{...a,[on]:`0,${n}`}:a,o=await this.#a(t,{method:r,body:i,headers:s});if(o.ok)return o;{let f=await o.text();throw new I(o.status,o.statusText,f)}}async#n(t,r,n){let i=r===void 0?"downloads":"uploads",a=n?`{ "http_method": "PUT", "relative_path": "${t}", "root_schema": "${n}", "generation": ${r} }`:JSON.stringify({http_method:"GET",relative_path:t}),o=await(await this.#i(`${this.#t}/sync/v2/signed-urls/${i}`,{body:a})).text(),f=JSON.parse(o);return $(dn,f),f}async getRootHash(){let t=await this.#n("root"),r=await this.#r(t),n=r.headers.get(ut);if(!n)throw new Error("no generation header in root hash");return[await r.text(),BigInt(n)]}async putRootHash(t,r){let n=await this.#n("root",r,t),i;try{i=await this.#r(n,t,{[sn]:`${r}`})}catch(s){throw s instanceof I&&s.status===412?new ue:s}let a=i.headers.get(ut);if(!a)throw new Error("no generation header in root hash");return BigInt(a)}async getBuffer(t){let r=await this.#n(t);return await(await this.#r(r)).arrayBuffer()}async getText(t){let r=await this.#e?.get(t);if(r)return r;{let n=await this.#n(t),a=await(await this.#r(n)).text();return await this.#e?.set(t,a),a}}async getMetadata(t){let r=await this.getText(t),n=JSON.parse(r);return $(cn,n),n}async getEntries(t){let r=await this.getText(t),[n,...i]=r.slice(0,-1).split(`
3
+ `);if(n!==ft)throw new Error(`got unexpected schema version: ${n}`);return i.map(ht)}async#f(t,r){let n=await this.#n(t,null);await this.#r(n,r)}async putEntries(t,r){let n=new TextEncoder;r.sort((l,v)=>l.documentId.localeCompare(v.documentId));let i=We(r.map(l=>Ze(l.hash))),a=await this.#s.digest("SHA-256",i),s=_e(a),o=r.map(gt).join(""),f=`${ft}
4
+ ${o}`,u=n.encode(f);return await this.#f(s,u),await this.#e?.set(s,f),{hash:s,type:"80000000",documentId:t,subfiles:r.length,size:0n}}async putBuffer(t,r){let n=await this.#s.digest("SHA-256",r),i=_e(n);return await this.#f(i,r),{hash:i,type:"0",documentId:t,subfiles:0,size:BigInt(r.length)}}async putText(t,r){let n=new TextEncoder,i=await this.putBuffer(t,n.encode(r));return await this.#e?.set(i.hash,r),i}async putMetadata(t,r){return await this.putText(`${t}.metadata`,JSON.stringify(r))}async putCollection(t,r=""){let n=ie(),i=`${new Date().valueOf()}`,a=[],s={type:"CollectionType",visibleName:t,version:0,parent:r,synced:!0,lastModified:i};a.push(this.putMetadata(n,s)),a.push(this.putText(`${n}.content`,"{}"));let o=await Promise.all(a);return await this.putEntries(n,o)}async#u(t,r,n,i,a){if(a.fileType!==n)throw new Error(`internal error: fileTypes don't match: ${n}, ${a.fileType}`);let s=ie(),o=`${new Date().valueOf()}`,f=[];f.push(this.putBuffer(`${s}.${n}`,r));let u={type:"DocumentType",visibleName:t,version:0,parent:i,synced:!0,lastModified:o};f.push(this.putMetadata(s,u)),f.push(this.putText(`${s}.content`,JSON.stringify(a)));let l=await Promise.all(f);return await this.putEntries(s,l)}async putEpub(t,r,{parent:n="",margins:i=125,orientation:a,textAlignment:s,textScale:o=1,lineHeight:f=-1,fontName:u="",cover:l="visited",lastTool:v}={}){let p={dummyDocument:!1,extraMetadata:{LastTool:v},fileType:"epub",pageCount:0,lastOpenedPage:0,lineHeight:typeof f=="string"?mt[f]:f,margins:typeof i=="string"?yt[i]:i,textScale:typeof o=="string"?pt[o]:o,pages:[],coverPageNumber:l==="first"?0:-1,formatVersion:1,orientation:a,textAlignment:s,fontName:u};return await this.#u(t,r,"epub",n,p)}async putPdf(t,r,{parent:n="",orientation:i,cover:a="first",lastTool:s}={}){let o={dummyDocument:!1,extraMetadata:{LastTool:s},fileType:"pdf",pageCount:0,lastOpenedPage:0,lineHeight:-1,margins:125,textScale:1,pages:[],coverPageNumber:a==="first"?0:-1,formatVersion:1,orientation:i};return await this.#u(t,r,"pdf",n,o)}async syncComplete(t){let r=`{ "generation": ${t} }`;await this.#i(`${this.#t}/sync/v2/sync-complete`,{body:r})}async getEntriesMetadata(){let r=await(await this.#i(`${this.#t}/doc/v2/files`,{method:"GET",headers:{"rm-source":"RoR-Browser"}})).text(),n=JSON.parse(r);return $({elements:pn},n),n}async#l(t,r,n){let a=new TextEncoder().encode(JSON.stringify({file_name:t})),o=await(await this.#i(`${this.#t}/doc/v2/files`,{body:r,headers:{"content-type":n,"rm-meta":(0,dt.fromByteArray)(a),"rm-source":"RoR-Browser"}})).text(),f=JSON.parse(o);return $(ln,f),f}async uploadEpub(t,r){return await this.#l(t,r,"application/epub+zip")}async uploadPdf(t,r){return await this.#l(t,r,"application/pdf")}};async function mn(e,{fetch:t=globalThis.fetch,cache:r,subtle:n=globalThis.crypto?.subtle,authHost:i=ct,syncHost:a=an}={}){let s=await t(`${i}/token/json/2/user/new`,{method:"POST",headers:{Authorization:`Bearer ${e}`}});if(!s.ok)throw new Error(`couldn't fetch auth token: ${s.statusText}`);let o=await s.text();return new Te(o,t,r,n,a)}0&&(module.exports={GenerationError,ResponseError,builtinFontNames,builtinLineHeights,builtinMargins,builtinTextScales,builtinTools,formatEntry,parseEntry,register,remarkable});
@@ -1,4 +1,4 @@
1
- var $e=Object.create;var de=Object.defineProperty;var He=Object.getOwnPropertyDescriptor;var Je=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,qe=Object.prototype.hasOwnProperty;var B=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var ze=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of Je(r))!qe.call(e,i)&&i!==t&&de(e,i,{get:()=>r[i],enumerable:!(n=He(r,i))||n.enumerable});return e};var ce=(e,r,t)=>(t=e!=null?$e(Ve(e)):{},ze(r||!e||!e.__esModule?de(t,"default",{value:e,enumerable:!0}):t,e));var ye=B(V=>{"use strict";V.byteLength=We;V.toByteArray=Ze;V.fromByteArray=Qe;var A=[],E=[],Ge=typeof Uint8Array<"u"?Uint8Array:Array,te="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(U=0,pe=te.length;U<pe;++U)A[U]=te[U],E[te.charCodeAt(U)]=U;var U,pe;E["-".charCodeAt(0)]=62;E["_".charCodeAt(0)]=63;function me(e){var r=e.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=e.indexOf("=");t===-1&&(t=r);var n=t===r?0:4-t%4;return[t,n]}function We(e){var r=me(e),t=r[0],n=r[1];return(t+n)*3/4-n}function Ye(e,r,t){return(r+t)*3/4-t}function Ze(e){var r,t=me(e),n=t[0],i=t[1],o=new Ge(Ye(e,n,i)),s=0,a=i>0?n-4:n,f;for(f=0;f<a;f+=4)r=E[e.charCodeAt(f)]<<18|E[e.charCodeAt(f+1)]<<12|E[e.charCodeAt(f+2)]<<6|E[e.charCodeAt(f+3)],o[s++]=r>>16&255,o[s++]=r>>8&255,o[s++]=r&255;return i===2&&(r=E[e.charCodeAt(f)]<<2|E[e.charCodeAt(f+1)]>>4,o[s++]=r&255),i===1&&(r=E[e.charCodeAt(f)]<<10|E[e.charCodeAt(f+1)]<<4|E[e.charCodeAt(f+2)]>>2,o[s++]=r>>8&255,o[s++]=r&255),o}function Ke(e){return A[e>>18&63]+A[e>>12&63]+A[e>>6&63]+A[e&63]}function Xe(e,r,t){for(var n,i=[],o=r;o<t;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(Ke(n));return i.join("")}function Qe(e){for(var r,t=e.length,n=t%3,i=[],o=16383,s=0,a=t-n;s<a;s+=o)i.push(Xe(e,s,s+o>a?a:s+o));return n===1?(r=e[t-1],i.push(A[r>>2]+A[r<<4&63]+"==")):n===2&&(r=(e[t-2]<<8)+e[t-1],i.push(A[r>>10]+A[r>>4&63]+A[r<<2&63]+"=")),i.join("")}});var ae=B(d=>{"use strict";var Ee=d&&d.__rest||function(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)r.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(t[n[i]]=e[n[i]]);return t};Object.defineProperty(d,"__esModule",{value:!0});d.isSchema=d.isValidSchema=d.isDiscriminatorForm=d.isValuesForm=d.isPropertiesForm=d.isElementsForm=d.isEnumForm=d.isTypeForm=d.isRefForm=d.isEmptyForm=void 0;function yt(e){let{definitions:r,nullable:t,metadata:n}=e,i=Ee(e,["definitions","nullable","metadata"]);return Object.keys(i).length===0}d.isEmptyForm=yt;function Te(e){return"ref"in e}d.isRefForm=Te;function gt(e){return"type"in e}d.isTypeForm=gt;function Ae(e){return"enum"in e}d.isEnumForm=Ae;function Pe(e){return"elements"in e}d.isElementsForm=Pe;function se(e){return"properties"in e||"optionalProperties"in e}d.isPropertiesForm=se;function ke(e){return"values"in e}d.isValuesForm=ke;function Se(e){return"discriminator"in e}d.isDiscriminatorForm=Se;function C(e,r){if(r===void 0&&(r=e),e.definitions!==void 0){if(r!==e)return!1;for(let t of Object.values(e.definitions))if(!C(t,r))return!1}if(Te(e)&&!(e.ref in(r.definitions||{}))||Ae(e)&&(e.enum.length===0||e.enum.length!==new Set(e.enum).size))return!1;if(Pe(e))return C(e.elements,r);if(se(e)){for(let t of Object.values(e.properties||{}))if(!C(t,r))return!1;for(let t of Object.values(e.optionalProperties||{}))if(!C(t,r))return!1;for(let t of Object.keys(e.properties||{}))if(t in(e.optionalProperties||{}))return!1}if(ke(e))return C(e.values,r);if(Se(e)){for(let t of Object.values(e.mapping))if(!C(t,r)||!se(t)||t.nullable||e.discriminator in(t.properties||{})||e.discriminator in(t.optionalProperties||{}))return!1}return!0}d.isValidSchema=C;var ht=[[!1,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!0,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!0,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!0,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!0,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!0,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!1,!0,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!0,!1,!1,!1],[!1,!1,!1,!1,!0,!0,!0,!1,!1,!1],[!1,!1,!1,!1,!1,!1,!1,!0,!1,!1],[!1,!1,!1,!1,!1,!1,!1,!1,!0,!0]],bt=["boolean","float32","float64","int8","uint8","int16","uint16","int32","uint32","string","timestamp"];function M(e){if(typeof e!="object"||Array.isArray(e)||e===null)return!1;let r=e,{definitions:t=void 0,nullable:n=void 0,metadata:i=void 0,ref:o=void 0,type:s=void 0,enum:a=void 0,elements:f=void 0,properties:l=void 0,optionalProperties:u=void 0,additionalProperties:v=void 0,values:P=void 0,discriminator:c=void 0,mapping:k=void 0}=r,Q=Ee(r,["definitions","nullable","metadata","ref","type","enum","elements","properties","optionalProperties","additionalProperties","values","discriminator","mapping"]),Ne=[o!==void 0,s!==void 0,a!==void 0,f!==void 0,l!==void 0,u!==void 0,v!==void 0,P!==void 0,c!==void 0,k!==void 0],ee=!1;for(let T of ht)ee=ee||T.every((Be,je)=>Be===Ne[je]);if(!ee)return!1;if(t!==void 0){if(typeof t!="object"||Array.isArray(t)||t===null)return!1;for(let T of Object.values(t))if(!M(T))return!1}if(n!==void 0&&typeof n!="boolean"||i!==void 0&&(typeof i!="object"||Array.isArray(i)||i===null)||o!==void 0&&typeof o!="string"||s!==void 0&&(typeof s!="string"||!bt.includes(s))||a!==void 0&&(!Array.isArray(a)||!a.every(T=>typeof T=="string"))||f!==void 0&&!M(f))return!1;if(l!==void 0){if(typeof l!="object"||Array.isArray(l)||l===null)return!1;for(let T of Object.values(l))if(!M(T))return!1}if(u!==void 0){if(typeof u!="object"||Array.isArray(u)||u===null)return!1;for(let T of Object.values(u))if(!M(T))return!1}if(v!==void 0&&typeof v!="boolean"||P!==void 0&&!M(P)||c!==void 0&&typeof c!="string")return!1;if(k!==void 0){if(typeof k!="object"||Array.isArray(k)||k===null)return!1;for(let T of Object.values(k))if(!M(T))return!1}return Object.keys(Q).length===0}d.isSchema=M});var Oe=B(fe=>{"use strict";Object.defineProperty(fe,"__esModule",{value:!0});var xt=/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(\.\d+)?([zZ]|((\+|-)(\d{2}):(\d{2})))$/;function wt(e){let r=e.match(xt);if(r===null)return!1;let t=parseInt(r[1],10),n=parseInt(r[2],10),i=parseInt(r[3],10),o=parseInt(r[4],10),s=parseInt(r[5],10),a=parseInt(r[6],10);return!(n>12||i>vt(t,n)||o>23||s>59||a>60)}fe.default=wt;function vt(e,r){return r===2?Et(e)?29:28:Tt[r]}function Et(e){return e%4===0&&(e%100!==0||e%400===0)}var Tt=[0,31,0,31,30,31,30,31,31,30,31,30,31]});var Fe=B(O=>{"use strict";var At=O&&O.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(O,"__esModule",{value:!0});O.validate=O.MaxDepthExceededError=void 0;var Pt=At(Oe()),I=ae(),Y=class extends Error{};O.MaxDepthExceededError=Y;var Z=class extends Error{};function kt(e,r,t){let n={errors:[],instanceTokens:[],schemaTokens:[[]],root:e,config:t||{maxDepth:0,maxErrors:0}};try{L(n,e,r)}catch(i){if(!(i instanceof Z))throw i}return n.errors}O.validate=kt;function L(e,r,t,n){if(!(r.nullable&&t===null)){if(I.isRefForm(r)){if(e.schemaTokens.length===e.config.maxDepth)throw new Y;e.schemaTokens.push(["definitions",r.ref]),L(e,e.root.definitions[r.ref],t),e.schemaTokens.pop()}else if(I.isTypeForm(r)){switch(b(e,"type"),r.type){case"boolean":typeof t!="boolean"&&x(e);break;case"float32":case"float64":typeof t!="number"&&x(e);break;case"int8":D(e,t,-128,127);break;case"uint8":D(e,t,0,255);break;case"int16":D(e,t,-32768,32767);break;case"uint16":D(e,t,0,65535);break;case"int32":D(e,t,-2147483648,2147483647);break;case"uint32":D(e,t,0,4294967295);break;case"string":typeof t!="string"&&x(e);break;case"timestamp":typeof t!="string"?x(e):Pt.default(t)||x(e);break}w(e)}else if(I.isEnumForm(r))b(e,"enum"),(typeof t!="string"||!r.enum.includes(t))&&x(e),w(e);else if(I.isElementsForm(r)){if(b(e,"elements"),Array.isArray(t))for(let[i,o]of t.entries())R(e,i.toString()),L(e,r.elements,o),_(e);else x(e);w(e)}else if(I.isPropertiesForm(r))if(typeof t=="object"&&t!==null&&!Array.isArray(t)){if(r.properties!==void 0){b(e,"properties");for(let[i,o]of Object.entries(r.properties))b(e,i),t.hasOwnProperty(i)?(R(e,i),L(e,o,t[i]),_(e)):x(e),w(e);w(e)}if(r.optionalProperties!==void 0){b(e,"optionalProperties");for(let[i,o]of Object.entries(r.optionalProperties))b(e,i),t.hasOwnProperty(i)&&(R(e,i),L(e,o,t[i]),_(e)),w(e);w(e)}if(r.additionalProperties!==!0)for(let i of Object.keys(t)){let o=r.properties&&i in r.properties,s=r.optionalProperties&&i in r.optionalProperties;!o&&!s&&i!==n&&(R(e,i),x(e),_(e))}}else r.properties!==void 0?b(e,"properties"):b(e,"optionalProperties"),x(e),w(e);else if(I.isValuesForm(r)){if(b(e,"values"),typeof t=="object"&&t!==null&&!Array.isArray(t))for(let[i,o]of Object.entries(t))R(e,i),L(e,r.values,o),_(e);else x(e);w(e)}else if(I.isDiscriminatorForm(r))if(typeof t=="object"&&t!==null&&!Array.isArray(t))if(t.hasOwnProperty(r.discriminator)){let i=t[r.discriminator];typeof i=="string"?i in r.mapping?(b(e,"mapping"),b(e,i),L(e,r.mapping[i],t,r.discriminator),w(e),w(e)):(b(e,"mapping"),R(e,r.discriminator),x(e),_(e),w(e)):(b(e,"discriminator"),R(e,r.discriminator),x(e),_(e),w(e))}else b(e,"discriminator"),x(e),w(e);else b(e,"discriminator"),x(e),w(e)}}function D(e,r,t,n){(typeof r!="number"||!Number.isInteger(r)||r<t||r>n)&&x(e)}function R(e,r){e.instanceTokens.push(r)}function _(e){e.instanceTokens.pop()}function b(e,r){e.schemaTokens[e.schemaTokens.length-1].push(r)}function w(e){e.schemaTokens[e.schemaTokens.length-1].pop()}function x(e){if(e.errors.push({instancePath:[...e.instanceTokens],schemaPath:[...e.schemaTokens[e.schemaTokens.length-1]]}),e.errors.length===e.config.maxErrors)throw new Z}});var Ce=B(F=>{"use strict";var St=F&&F.__createBinding||(Object.create?function(e,r,t,n){n===void 0&&(n=t),Object.defineProperty(e,n,{enumerable:!0,get:function(){return r[t]}})}:function(e,r,t,n){n===void 0&&(n=t),e[n]=r[t]}),Ue=F&&F.__exportStar||function(e,r){for(var t in e)t!=="default"&&!r.hasOwnProperty(t)&&St(r,e,t)};Object.defineProperty(F,"__esModule",{value:!0});Ue(ae(),F);Ue(Fe(),F)});var Le=ce(ye());var q,et=new Uint8Array(16);function z(){if(!q&&(q=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!q))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return q(et)}var ge=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function tt(e){return typeof e=="string"&&ge.test(e)}var j=tt;var p=[];for(let e=0;e<256;++e)p.push((e+256).toString(16).slice(1));function $(e,r=0){return(p[e[r+0]]+p[e[r+1]]+p[e[r+2]]+p[e[r+3]]+"-"+p[e[r+4]]+p[e[r+5]]+"-"+p[e[r+6]]+p[e[r+7]]+"-"+p[e[r+8]]+p[e[r+9]]+"-"+p[e[r+10]]+p[e[r+11]]+p[e[r+12]]+p[e[r+13]]+p[e[r+14]]+p[e[r+15]]).toLowerCase()}function rt(e){if(!j(e))throw TypeError("Invalid UUID");let r,t=new Uint8Array(16);return t[0]=(r=parseInt(e.slice(0,8),16))>>>24,t[1]=r>>>16&255,t[2]=r>>>8&255,t[3]=r&255,t[4]=(r=parseInt(e.slice(9,13),16))>>>8,t[5]=r&255,t[6]=(r=parseInt(e.slice(14,18),16))>>>8,t[7]=r&255,t[8]=(r=parseInt(e.slice(19,23),16))>>>8,t[9]=r&255,t[10]=(r=parseInt(e.slice(24,36),16))/1099511627776&255,t[11]=r/4294967296&255,t[12]=r>>>24&255,t[13]=r>>>16&255,t[14]=r>>>8&255,t[15]=r&255,t}var re=rt;function nt(e){e=unescape(encodeURIComponent(e));let r=[];for(let t=0;t<e.length;++t)r.push(e.charCodeAt(t));return r}var it="6ba7b810-9dad-11d1-80b4-00c04fd430c8",ot="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function H(e,r,t){function n(i,o,s,a){var f;if(typeof i=="string"&&(i=nt(i)),typeof o=="string"&&(o=re(o)),((f=o)===null||f===void 0?void 0:f.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let l=new Uint8Array(16+i.length);if(l.set(o),l.set(i,o.length),l=t(l),l[6]=l[6]&15|r,l[8]=l[8]&63|128,s){a=a||0;for(let u=0;u<16;++u)s[a+u]=l[u];return s}return $(l)}try{n.name=e}catch{}return n.DNS=it,n.URL=ot,n}function st(e){if(typeof e=="string"){let r=unescape(encodeURIComponent(e));e=new Uint8Array(r.length);for(let t=0;t<r.length;++t)e[t]=r.charCodeAt(t)}return at(ft(lt(e),e.length*8))}function at(e){let r=[],t=e.length*32,n="0123456789abcdef";for(let i=0;i<t;i+=8){let o=e[i>>5]>>>i%32&255,s=parseInt(n.charAt(o>>>4&15)+n.charAt(o&15),16);r.push(s)}return r}function he(e){return(e+64>>>9<<4)+14+1}function ft(e,r){e[r>>5]|=128<<r%32,e[he(r)-1]=r;let t=1732584193,n=-271733879,i=-1732584194,o=271733878;for(let s=0;s<e.length;s+=16){let a=t,f=n,l=i,u=o;t=m(t,n,i,o,e[s],7,-680876936),o=m(o,t,n,i,e[s+1],12,-389564586),i=m(i,o,t,n,e[s+2],17,606105819),n=m(n,i,o,t,e[s+3],22,-1044525330),t=m(t,n,i,o,e[s+4],7,-176418897),o=m(o,t,n,i,e[s+5],12,1200080426),i=m(i,o,t,n,e[s+6],17,-1473231341),n=m(n,i,o,t,e[s+7],22,-45705983),t=m(t,n,i,o,e[s+8],7,1770035416),o=m(o,t,n,i,e[s+9],12,-1958414417),i=m(i,o,t,n,e[s+10],17,-42063),n=m(n,i,o,t,e[s+11],22,-1990404162),t=m(t,n,i,o,e[s+12],7,1804603682),o=m(o,t,n,i,e[s+13],12,-40341101),i=m(i,o,t,n,e[s+14],17,-1502002290),n=m(n,i,o,t,e[s+15],22,1236535329),t=y(t,n,i,o,e[s+1],5,-165796510),o=y(o,t,n,i,e[s+6],9,-1069501632),i=y(i,o,t,n,e[s+11],14,643717713),n=y(n,i,o,t,e[s],20,-373897302),t=y(t,n,i,o,e[s+5],5,-701558691),o=y(o,t,n,i,e[s+10],9,38016083),i=y(i,o,t,n,e[s+15],14,-660478335),n=y(n,i,o,t,e[s+4],20,-405537848),t=y(t,n,i,o,e[s+9],5,568446438),o=y(o,t,n,i,e[s+14],9,-1019803690),i=y(i,o,t,n,e[s+3],14,-187363961),n=y(n,i,o,t,e[s+8],20,1163531501),t=y(t,n,i,o,e[s+13],5,-1444681467),o=y(o,t,n,i,e[s+2],9,-51403784),i=y(i,o,t,n,e[s+7],14,1735328473),n=y(n,i,o,t,e[s+12],20,-1926607734),t=g(t,n,i,o,e[s+5],4,-378558),o=g(o,t,n,i,e[s+8],11,-2022574463),i=g(i,o,t,n,e[s+11],16,1839030562),n=g(n,i,o,t,e[s+14],23,-35309556),t=g(t,n,i,o,e[s+1],4,-1530992060),o=g(o,t,n,i,e[s+4],11,1272893353),i=g(i,o,t,n,e[s+7],16,-155497632),n=g(n,i,o,t,e[s+10],23,-1094730640),t=g(t,n,i,o,e[s+13],4,681279174),o=g(o,t,n,i,e[s],11,-358537222),i=g(i,o,t,n,e[s+3],16,-722521979),n=g(n,i,o,t,e[s+6],23,76029189),t=g(t,n,i,o,e[s+9],4,-640364487),o=g(o,t,n,i,e[s+12],11,-421815835),i=g(i,o,t,n,e[s+15],16,530742520),n=g(n,i,o,t,e[s+2],23,-995338651),t=h(t,n,i,o,e[s],6,-198630844),o=h(o,t,n,i,e[s+7],10,1126891415),i=h(i,o,t,n,e[s+14],15,-1416354905),n=h(n,i,o,t,e[s+5],21,-57434055),t=h(t,n,i,o,e[s+12],6,1700485571),o=h(o,t,n,i,e[s+3],10,-1894986606),i=h(i,o,t,n,e[s+10],15,-1051523),n=h(n,i,o,t,e[s+1],21,-2054922799),t=h(t,n,i,o,e[s+8],6,1873313359),o=h(o,t,n,i,e[s+15],10,-30611744),i=h(i,o,t,n,e[s+6],15,-1560198380),n=h(n,i,o,t,e[s+13],21,1309151649),t=h(t,n,i,o,e[s+4],6,-145523070),o=h(o,t,n,i,e[s+11],10,-1120210379),i=h(i,o,t,n,e[s+2],15,718787259),n=h(n,i,o,t,e[s+9],21,-343485551),t=S(t,a),n=S(n,f),i=S(i,l),o=S(o,u)}return[t,n,i,o]}function lt(e){if(e.length===0)return[];let r=e.length*8,t=new Uint32Array(he(r));for(let n=0;n<r;n+=8)t[n>>5]|=(e[n/8]&255)<<n%32;return t}function S(e,r){let t=(e&65535)+(r&65535);return(e>>16)+(r>>16)+(t>>16)<<16|t&65535}function ut(e,r){return e<<r|e>>>32-r}function G(e,r,t,n,i,o){return S(ut(S(S(r,e),S(n,o)),i),t)}function m(e,r,t,n,i,o,s){return G(r&t|~r&n,e,r,i,o,s)}function y(e,r,t,n,i,o,s){return G(r&n|t&~n,e,r,i,o,s)}function g(e,r,t,n,i,o,s){return G(r^t^n,e,r,i,o,s)}function h(e,r,t,n,i,o,s){return G(t^(r|~n),e,r,i,o,s)}var be=st;var or=H("v3",48,be);var dt=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ne={randomUUID:dt};function ct(e,r,t){if(ne.randomUUID&&!r&&!e)return ne.randomUUID();e=e||{};let n=e.random||(e.rng||z)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,r){t=t||0;for(let i=0;i<16;++i)r[t+i]=n[i];return r}return $(n)}var W=ct;function pt(e,r,t,n){switch(e){case 0:return r&t^~r&n;case 1:return r^t^n;case 2:return r&t^r&n^t&n;case 3:return r^t^n}}function ie(e,r){return e<<r|e>>>32-r}function mt(e){let r=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e=="string"){let s=unescape(encodeURIComponent(e));e=[];for(let a=0;a<s.length;++a)e.push(s.charCodeAt(a))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);let n=e.length/4+2,i=Math.ceil(n/16),o=new Array(i);for(let s=0;s<i;++s){let a=new Uint32Array(16);for(let f=0;f<16;++f)a[f]=e[s*64+f*4]<<24|e[s*64+f*4+1]<<16|e[s*64+f*4+2]<<8|e[s*64+f*4+3];o[s]=a}o[i-1][14]=(e.length-1)*8/Math.pow(2,32),o[i-1][14]=Math.floor(o[i-1][14]),o[i-1][15]=(e.length-1)*8&4294967295;for(let s=0;s<i;++s){let a=new Uint32Array(80);for(let c=0;c<16;++c)a[c]=o[s][c];for(let c=16;c<80;++c)a[c]=ie(a[c-3]^a[c-8]^a[c-14]^a[c-16],1);let f=t[0],l=t[1],u=t[2],v=t[3],P=t[4];for(let c=0;c<80;++c){let k=Math.floor(c/20),Q=ie(f,5)+pt(k,l,u,v)+P+r[k]+a[c]>>>0;P=v,v=u,u=ie(l,30)>>>0,l=f,f=Q}t[0]=t[0]+f>>>0,t[1]=t[1]+l>>>0,t[2]=t[2]+u>>>0,t[3]=t[3]+v>>>0,t[4]=t[4]+P>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,t[0]&255,t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,t[1]&255,t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,t[2]&255,t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,t[3]&255,t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,t[4]&255]}var xe=mt;var yr=H("v5",80,xe);function oe(e){return[...new Uint8Array(e)].map(r=>r.toString(16).padStart(2,"0")).join("")}function we(e){return new Uint8Array((e.match(/../g)??[]).map(r=>parseInt(r,16)))}function ve(e){let r=0;for(let i of e)r+=i.length;let t=new Uint8Array(r),n=0;for(let i of e)t.set(i,n),n+=i.length;return t}var Me=ce(Ce());function J(e,r){if((0,Me.validate)(e,r).length)throw new Error(`couldn't validate schema: ${JSON.stringify(r)} didn't match schema ${JSON.stringify(e)}`)}var Ie="3",De="https://webapp-prod.cloud.remarkable.engineering",Ot="https://internal.cloud.remarkable.com",Re="x-goog-generation",Ft="x-goog-if-generation-match",Ut="x-goog-content-length-range",zr=["Ballpoint","Ballpointv2","Brush","Calligraphy","ClearPage","EraseSection","Eraser","Fineliner","Finelinerv2","Highlighter","Highlighterv2","Marker","Markerv2","Paintbrush","Paintbrushv2","Pencilv2","SharpPencil","SharpPencilv2","SolidPen","ZoomTool"],Gr=["Maison Neue","EB Garamond","Noto Sans","Noto Serif","Noto Mono","Noto Sans UI"],Ct={xs:.7,sm:.8,md:1,lg:1.2,xl:1.5,xx:2},Mt={sm:50,md:125,rr:180,lg:200},It={df:-1,md:100,lg:150,xl:200},Rt={properties:{docID:{type:"string"},hash:{type:"string"}}},_t={properties:{relative_path:{type:"string"},url:{type:"string"},expires:{type:"timestamp"},method:{enum:["POST","GET","PUT","DELETE"]}},optionalProperties:{maxuploadsize_bytes:{type:"float64"}}},K={visibleName:{type:"string"},lastModified:{type:"string"}},X={version:{type:"int32"},pinned:{type:"boolean"},synced:{type:"boolean"},modified:{type:"boolean"},deleted:{type:"boolean"},metadatamodified:{type:"boolean"},parent:{type:"string"}},Lt={discriminator:"type",mapping:{CollectionType:{properties:K,optionalProperties:X},DocumentType:{properties:K,optionalProperties:{...X,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"}}}}},_e={id:{type:"string"},hash:{type:"string"}},Dt={discriminator:"type",mapping:{CollectionType:{properties:{...K,..._e},optionalProperties:X},DocumentType:{properties:{...K,..._e,fileType:{enum:["notebook","epub","pdf",""]}},optionalProperties:{...X,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"}}}}},N=class extends Error{constructor(t,n,i){super(i);this.status=t,this.statusText=n}},le=class extends Error{constructor(){super("Generation preconditions failed. This means the current state is out of date with the cloud and needs to be re-synced.")}};async function Wr(e,{deviceDesc:r="browser-chrome",uuid:t=W(),authHost:n=De,fetch:i=globalThis.fetch}={}){if(e.length!==8)throw new Error(`code should be length 8, but was ${e.length}`);let o=await i(`${n}/token/json/2/device/new`,{method:"POST",headers:{Authorization:"Bearer"},body:JSON.stringify({code:e,deviceDesc:r,deviceID:t})});if(o.ok)return await o.text();throw new N(o.status,o.statusText,"couldn't register api")}function Nt({hash:e,type:r,documentId:t,subfiles:n,size:i}){return`${e}:${r}:${t}:${n}:${i}
2
- `}function Bt(e){let[r,t,n,i,o]=e.split(":");if(r===void 0||t===void 0||n===void 0||i===void 0||o===void 0)throw new Error(`entries line didn't contain five fields: '${e}'`);if(t==="80000000")return{hash:r,type:t,documentId:n,subfiles:parseInt(i),size:BigInt(o)};if(t==="0"){if(i!=="0")throw new Error(`file type entry had nonzero number of subfiles: ${i}`);return{hash:r,type:t,documentId:n,subfiles:0,size:BigInt(o)}}else throw new Error(`entries line contained invalid type: ${t}`)}var ue=class{#a;#o;#e;#s;#t;constructor(r,t,n,i,o){this.#a=r,this.#o=t,this.#e=n,this.#s=i,this.#t=o}async#i(r,{body:t,method:n="POST",headers:i={}}){let o=await this.#o(r,{method:n,headers:{Authorization:`Bearer ${this.#a}`,...i},body:t});if(o.ok)return o;{let s=await o.text();throw new N(o.status,o.statusText,`failed reMarkable request: ${s}`)}}async#r({url:r,method:t,maxuploadsize_bytes:n},i,o={}){let s=n?{...o,[Ut]:`0,${n}`}:o,a=await this.#o(r,{method:t,body:i,headers:s});if(a.ok)return a;{let f=await a.text();throw new N(a.status,a.statusText,f)}}async#n(r,t,n){let i=t===void 0?"downloads":"uploads",o=n?`{ "http_method": "PUT", "relative_path": "${r}", "root_schema": "${n}", "generation": ${t} }`:JSON.stringify({http_method:"GET",relative_path:r}),a=await(await this.#i(`${this.#t}/sync/v2/signed-urls/${i}`,{body:o})).text(),f=JSON.parse(a);return J(_t,f),f}async getRootHash(){let r=await this.#n("root"),t=await this.#r(r),n=t.headers.get(Re);if(!n)throw new Error("no generation header in root hash");return[await t.text(),BigInt(n)]}async putRootHash(r,t){let n=await this.#n("root",t,r),i;try{i=await this.#r(n,r,{[Ft]:`${t}`})}catch(s){throw s instanceof N&&s.status===412?new le:s}let o=i.headers.get(Re);if(!o)throw new Error("no generation header in root hash");return BigInt(o)}async getBuffer(r){let t=await this.#n(r);return await(await this.#r(t)).arrayBuffer()}async getText(r){let t=await this.#e?.get(r);if(t)return t;{let n=await this.#n(r),o=await(await this.#r(n)).text();return await this.#e?.set(r,o),o}}async getMetadata(r){let t=await this.getText(r),n=JSON.parse(t);return J(Lt,n),n}async getEntries(r){let t=await this.getText(r),[n,...i]=t.slice(0,-1).split(`
1
+ var $e=Object.create;var de=Object.defineProperty;var He=Object.getOwnPropertyDescriptor;var Je=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,qe=Object.prototype.hasOwnProperty;var B=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var ze=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of Je(r))!qe.call(e,i)&&i!==t&&de(e,i,{get:()=>r[i],enumerable:!(n=He(r,i))||n.enumerable});return e};var ce=(e,r,t)=>(t=e!=null?$e(Ve(e)):{},ze(r||!e||!e.__esModule?de(t,"default",{value:e,enumerable:!0}):t,e));var ye=B(q=>{"use strict";q.byteLength=We;q.toByteArray=Ze;q.fromByteArray=Qe;var P=[],E=[],Ge=typeof Uint8Array<"u"?Uint8Array:Array,te="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(M=0,pe=te.length;M<pe;++M)P[M]=te[M],E[te.charCodeAt(M)]=M;var M,pe;E["-".charCodeAt(0)]=62;E["_".charCodeAt(0)]=63;function me(e){var r=e.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=e.indexOf("=");t===-1&&(t=r);var n=t===r?0:4-t%4;return[t,n]}function We(e){var r=me(e),t=r[0],n=r[1];return(t+n)*3/4-n}function Ye(e,r,t){return(r+t)*3/4-t}function Ze(e){var r,t=me(e),n=t[0],i=t[1],o=new Ge(Ye(e,n,i)),s=0,a=i>0?n-4:n,f;for(f=0;f<a;f+=4)r=E[e.charCodeAt(f)]<<18|E[e.charCodeAt(f+1)]<<12|E[e.charCodeAt(f+2)]<<6|E[e.charCodeAt(f+3)],o[s++]=r>>16&255,o[s++]=r>>8&255,o[s++]=r&255;return i===2&&(r=E[e.charCodeAt(f)]<<2|E[e.charCodeAt(f+1)]>>4,o[s++]=r&255),i===1&&(r=E[e.charCodeAt(f)]<<10|E[e.charCodeAt(f+1)]<<4|E[e.charCodeAt(f+2)]>>2,o[s++]=r>>8&255,o[s++]=r&255),o}function Ke(e){return P[e>>18&63]+P[e>>12&63]+P[e>>6&63]+P[e&63]}function Xe(e,r,t){for(var n,i=[],o=r;o<t;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(Ke(n));return i.join("")}function Qe(e){for(var r,t=e.length,n=t%3,i=[],o=16383,s=0,a=t-n;s<a;s+=o)i.push(Xe(e,s,s+o>a?a:s+o));return n===1?(r=e[t-1],i.push(P[r>>2]+P[r<<4&63]+"==")):n===2&&(r=(e[t-2]<<8)+e[t-1],i.push(P[r>>10]+P[r>>4&63]+P[r<<2&63]+"=")),i.join("")}});var ae=B(d=>{"use strict";var Ee=d&&d.__rest||function(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)r.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(t[n[i]]=e[n[i]]);return t};Object.defineProperty(d,"__esModule",{value:!0});d.isSchema=d.isValidSchema=d.isDiscriminatorForm=d.isValuesForm=d.isPropertiesForm=d.isElementsForm=d.isEnumForm=d.isTypeForm=d.isRefForm=d.isEmptyForm=void 0;function yt(e){let{definitions:r,nullable:t,metadata:n}=e,i=Ee(e,["definitions","nullable","metadata"]);return Object.keys(i).length===0}d.isEmptyForm=yt;function Te(e){return"ref"in e}d.isRefForm=Te;function gt(e){return"type"in e}d.isTypeForm=gt;function Pe(e){return"enum"in e}d.isEnumForm=Pe;function Ae(e){return"elements"in e}d.isElementsForm=Ae;function se(e){return"properties"in e||"optionalProperties"in e}d.isPropertiesForm=se;function ke(e){return"values"in e}d.isValuesForm=ke;function Se(e){return"discriminator"in e}d.isDiscriminatorForm=Se;function C(e,r){if(r===void 0&&(r=e),e.definitions!==void 0){if(r!==e)return!1;for(let t of Object.values(e.definitions))if(!C(t,r))return!1}if(Te(e)&&!(e.ref in(r.definitions||{}))||Pe(e)&&(e.enum.length===0||e.enum.length!==new Set(e.enum).size))return!1;if(Ae(e))return C(e.elements,r);if(se(e)){for(let t of Object.values(e.properties||{}))if(!C(t,r))return!1;for(let t of Object.values(e.optionalProperties||{}))if(!C(t,r))return!1;for(let t of Object.keys(e.properties||{}))if(t in(e.optionalProperties||{}))return!1}if(ke(e))return C(e.values,r);if(Se(e)){for(let t of Object.values(e.mapping))if(!C(t,r)||!se(t)||t.nullable||e.discriminator in(t.properties||{})||e.discriminator in(t.optionalProperties||{}))return!1}return!0}d.isValidSchema=C;var ht=[[!1,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!0,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!0,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!0,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!0,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!0,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!1,!0,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!0,!1,!1,!1],[!1,!1,!1,!1,!0,!0,!0,!1,!1,!1],[!1,!1,!1,!1,!1,!1,!1,!0,!1,!1],[!1,!1,!1,!1,!1,!1,!1,!1,!0,!0]],bt=["boolean","float32","float64","int8","uint8","int16","uint16","int32","uint32","string","timestamp"];function U(e){if(typeof e!="object"||Array.isArray(e)||e===null)return!1;let r=e,{definitions:t=void 0,nullable:n=void 0,metadata:i=void 0,ref:o=void 0,type:s=void 0,enum:a=void 0,elements:f=void 0,properties:l=void 0,optionalProperties:u=void 0,additionalProperties:v=void 0,values:A=void 0,discriminator:c=void 0,mapping:k=void 0}=r,Q=Ee(r,["definitions","nullable","metadata","ref","type","enum","elements","properties","optionalProperties","additionalProperties","values","discriminator","mapping"]),Ne=[o!==void 0,s!==void 0,a!==void 0,f!==void 0,l!==void 0,u!==void 0,v!==void 0,A!==void 0,c!==void 0,k!==void 0],ee=!1;for(let T of ht)ee=ee||T.every((Be,je)=>Be===Ne[je]);if(!ee)return!1;if(t!==void 0){if(typeof t!="object"||Array.isArray(t)||t===null)return!1;for(let T of Object.values(t))if(!U(T))return!1}if(n!==void 0&&typeof n!="boolean"||i!==void 0&&(typeof i!="object"||Array.isArray(i)||i===null)||o!==void 0&&typeof o!="string"||s!==void 0&&(typeof s!="string"||!bt.includes(s))||a!==void 0&&(!Array.isArray(a)||!a.every(T=>typeof T=="string"))||f!==void 0&&!U(f))return!1;if(l!==void 0){if(typeof l!="object"||Array.isArray(l)||l===null)return!1;for(let T of Object.values(l))if(!U(T))return!1}if(u!==void 0){if(typeof u!="object"||Array.isArray(u)||u===null)return!1;for(let T of Object.values(u))if(!U(T))return!1}if(v!==void 0&&typeof v!="boolean"||A!==void 0&&!U(A)||c!==void 0&&typeof c!="string")return!1;if(k!==void 0){if(typeof k!="object"||Array.isArray(k)||k===null)return!1;for(let T of Object.values(k))if(!U(T))return!1}return Object.keys(Q).length===0}d.isSchema=U});var Oe=B(fe=>{"use strict";Object.defineProperty(fe,"__esModule",{value:!0});var xt=/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(\.\d+)?([zZ]|((\+|-)(\d{2}):(\d{2})))$/;function wt(e){let r=e.match(xt);if(r===null)return!1;let t=parseInt(r[1],10),n=parseInt(r[2],10),i=parseInt(r[3],10),o=parseInt(r[4],10),s=parseInt(r[5],10),a=parseInt(r[6],10);return!(n>12||i>vt(t,n)||o>23||s>59||a>60)}fe.default=wt;function vt(e,r){return r===2?Et(e)?29:28:Tt[r]}function Et(e){return e%4===0&&(e%100!==0||e%400===0)}var Tt=[0,31,0,31,30,31,30,31,31,30,31,30,31]});var Fe=B(O=>{"use strict";var Pt=O&&O.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(O,"__esModule",{value:!0});O.validate=O.MaxDepthExceededError=void 0;var At=Pt(Oe()),I=ae(),Y=class extends Error{};O.MaxDepthExceededError=Y;var Z=class extends Error{};function kt(e,r,t){let n={errors:[],instanceTokens:[],schemaTokens:[[]],root:e,config:t||{maxDepth:0,maxErrors:0}};try{L(n,e,r)}catch(i){if(!(i instanceof Z))throw i}return n.errors}O.validate=kt;function L(e,r,t,n){if(!(r.nullable&&t===null)){if(I.isRefForm(r)){if(e.schemaTokens.length===e.config.maxDepth)throw new Y;e.schemaTokens.push(["definitions",r.ref]),L(e,e.root.definitions[r.ref],t),e.schemaTokens.pop()}else if(I.isTypeForm(r)){switch(b(e,"type"),r.type){case"boolean":typeof t!="boolean"&&x(e);break;case"float32":case"float64":typeof t!="number"&&x(e);break;case"int8":D(e,t,-128,127);break;case"uint8":D(e,t,0,255);break;case"int16":D(e,t,-32768,32767);break;case"uint16":D(e,t,0,65535);break;case"int32":D(e,t,-2147483648,2147483647);break;case"uint32":D(e,t,0,4294967295);break;case"string":typeof t!="string"&&x(e);break;case"timestamp":typeof t!="string"?x(e):At.default(t)||x(e);break}w(e)}else if(I.isEnumForm(r))b(e,"enum"),(typeof t!="string"||!r.enum.includes(t))&&x(e),w(e);else if(I.isElementsForm(r)){if(b(e,"elements"),Array.isArray(t))for(let[i,o]of t.entries())R(e,i.toString()),L(e,r.elements,o),_(e);else x(e);w(e)}else if(I.isPropertiesForm(r))if(typeof t=="object"&&t!==null&&!Array.isArray(t)){if(r.properties!==void 0){b(e,"properties");for(let[i,o]of Object.entries(r.properties))b(e,i),t.hasOwnProperty(i)?(R(e,i),L(e,o,t[i]),_(e)):x(e),w(e);w(e)}if(r.optionalProperties!==void 0){b(e,"optionalProperties");for(let[i,o]of Object.entries(r.optionalProperties))b(e,i),t.hasOwnProperty(i)&&(R(e,i),L(e,o,t[i]),_(e)),w(e);w(e)}if(r.additionalProperties!==!0)for(let i of Object.keys(t)){let o=r.properties&&i in r.properties,s=r.optionalProperties&&i in r.optionalProperties;!o&&!s&&i!==n&&(R(e,i),x(e),_(e))}}else r.properties!==void 0?b(e,"properties"):b(e,"optionalProperties"),x(e),w(e);else if(I.isValuesForm(r)){if(b(e,"values"),typeof t=="object"&&t!==null&&!Array.isArray(t))for(let[i,o]of Object.entries(t))R(e,i),L(e,r.values,o),_(e);else x(e);w(e)}else if(I.isDiscriminatorForm(r))if(typeof t=="object"&&t!==null&&!Array.isArray(t))if(t.hasOwnProperty(r.discriminator)){let i=t[r.discriminator];typeof i=="string"?i in r.mapping?(b(e,"mapping"),b(e,i),L(e,r.mapping[i],t,r.discriminator),w(e),w(e)):(b(e,"mapping"),R(e,r.discriminator),x(e),_(e),w(e)):(b(e,"discriminator"),R(e,r.discriminator),x(e),_(e),w(e))}else b(e,"discriminator"),x(e),w(e);else b(e,"discriminator"),x(e),w(e)}}function D(e,r,t,n){(typeof r!="number"||!Number.isInteger(r)||r<t||r>n)&&x(e)}function R(e,r){e.instanceTokens.push(r)}function _(e){e.instanceTokens.pop()}function b(e,r){e.schemaTokens[e.schemaTokens.length-1].push(r)}function w(e){e.schemaTokens[e.schemaTokens.length-1].pop()}function x(e){if(e.errors.push({instancePath:[...e.instanceTokens],schemaPath:[...e.schemaTokens[e.schemaTokens.length-1]]}),e.errors.length===e.config.maxErrors)throw new Z}});var Ce=B(F=>{"use strict";var St=F&&F.__createBinding||(Object.create?function(e,r,t,n){n===void 0&&(n=t),Object.defineProperty(e,n,{enumerable:!0,get:function(){return r[t]}})}:function(e,r,t,n){n===void 0&&(n=t),e[n]=r[t]}),Me=F&&F.__exportStar||function(e,r){for(var t in e)t!=="default"&&!r.hasOwnProperty(t)&&St(r,e,t)};Object.defineProperty(F,"__esModule",{value:!0});Me(ae(),F);Me(Fe(),F)});var Le=ce(ye());var z,et=new Uint8Array(16);function G(){if(!z&&(z=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!z))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return z(et)}var ge=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function tt(e){return typeof e=="string"&&ge.test(e)}var j=tt;var p=[];for(let e=0;e<256;++e)p.push((e+256).toString(16).slice(1));function $(e,r=0){return(p[e[r+0]]+p[e[r+1]]+p[e[r+2]]+p[e[r+3]]+"-"+p[e[r+4]]+p[e[r+5]]+"-"+p[e[r+6]]+p[e[r+7]]+"-"+p[e[r+8]]+p[e[r+9]]+"-"+p[e[r+10]]+p[e[r+11]]+p[e[r+12]]+p[e[r+13]]+p[e[r+14]]+p[e[r+15]]).toLowerCase()}function rt(e){if(!j(e))throw TypeError("Invalid UUID");let r,t=new Uint8Array(16);return t[0]=(r=parseInt(e.slice(0,8),16))>>>24,t[1]=r>>>16&255,t[2]=r>>>8&255,t[3]=r&255,t[4]=(r=parseInt(e.slice(9,13),16))>>>8,t[5]=r&255,t[6]=(r=parseInt(e.slice(14,18),16))>>>8,t[7]=r&255,t[8]=(r=parseInt(e.slice(19,23),16))>>>8,t[9]=r&255,t[10]=(r=parseInt(e.slice(24,36),16))/1099511627776&255,t[11]=r/4294967296&255,t[12]=r>>>24&255,t[13]=r>>>16&255,t[14]=r>>>8&255,t[15]=r&255,t}var re=rt;function nt(e){e=unescape(encodeURIComponent(e));let r=[];for(let t=0;t<e.length;++t)r.push(e.charCodeAt(t));return r}var it="6ba7b810-9dad-11d1-80b4-00c04fd430c8",ot="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function H(e,r,t){function n(i,o,s,a){var f;if(typeof i=="string"&&(i=nt(i)),typeof o=="string"&&(o=re(o)),((f=o)===null||f===void 0?void 0:f.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let l=new Uint8Array(16+i.length);if(l.set(o),l.set(i,o.length),l=t(l),l[6]=l[6]&15|r,l[8]=l[8]&63|128,s){a=a||0;for(let u=0;u<16;++u)s[a+u]=l[u];return s}return $(l)}try{n.name=e}catch{}return n.DNS=it,n.URL=ot,n}function st(e){if(typeof e=="string"){let r=unescape(encodeURIComponent(e));e=new Uint8Array(r.length);for(let t=0;t<r.length;++t)e[t]=r.charCodeAt(t)}return at(ft(lt(e),e.length*8))}function at(e){let r=[],t=e.length*32,n="0123456789abcdef";for(let i=0;i<t;i+=8){let o=e[i>>5]>>>i%32&255,s=parseInt(n.charAt(o>>>4&15)+n.charAt(o&15),16);r.push(s)}return r}function he(e){return(e+64>>>9<<4)+14+1}function ft(e,r){e[r>>5]|=128<<r%32,e[he(r)-1]=r;let t=1732584193,n=-271733879,i=-1732584194,o=271733878;for(let s=0;s<e.length;s+=16){let a=t,f=n,l=i,u=o;t=m(t,n,i,o,e[s],7,-680876936),o=m(o,t,n,i,e[s+1],12,-389564586),i=m(i,o,t,n,e[s+2],17,606105819),n=m(n,i,o,t,e[s+3],22,-1044525330),t=m(t,n,i,o,e[s+4],7,-176418897),o=m(o,t,n,i,e[s+5],12,1200080426),i=m(i,o,t,n,e[s+6],17,-1473231341),n=m(n,i,o,t,e[s+7],22,-45705983),t=m(t,n,i,o,e[s+8],7,1770035416),o=m(o,t,n,i,e[s+9],12,-1958414417),i=m(i,o,t,n,e[s+10],17,-42063),n=m(n,i,o,t,e[s+11],22,-1990404162),t=m(t,n,i,o,e[s+12],7,1804603682),o=m(o,t,n,i,e[s+13],12,-40341101),i=m(i,o,t,n,e[s+14],17,-1502002290),n=m(n,i,o,t,e[s+15],22,1236535329),t=y(t,n,i,o,e[s+1],5,-165796510),o=y(o,t,n,i,e[s+6],9,-1069501632),i=y(i,o,t,n,e[s+11],14,643717713),n=y(n,i,o,t,e[s],20,-373897302),t=y(t,n,i,o,e[s+5],5,-701558691),o=y(o,t,n,i,e[s+10],9,38016083),i=y(i,o,t,n,e[s+15],14,-660478335),n=y(n,i,o,t,e[s+4],20,-405537848),t=y(t,n,i,o,e[s+9],5,568446438),o=y(o,t,n,i,e[s+14],9,-1019803690),i=y(i,o,t,n,e[s+3],14,-187363961),n=y(n,i,o,t,e[s+8],20,1163531501),t=y(t,n,i,o,e[s+13],5,-1444681467),o=y(o,t,n,i,e[s+2],9,-51403784),i=y(i,o,t,n,e[s+7],14,1735328473),n=y(n,i,o,t,e[s+12],20,-1926607734),t=g(t,n,i,o,e[s+5],4,-378558),o=g(o,t,n,i,e[s+8],11,-2022574463),i=g(i,o,t,n,e[s+11],16,1839030562),n=g(n,i,o,t,e[s+14],23,-35309556),t=g(t,n,i,o,e[s+1],4,-1530992060),o=g(o,t,n,i,e[s+4],11,1272893353),i=g(i,o,t,n,e[s+7],16,-155497632),n=g(n,i,o,t,e[s+10],23,-1094730640),t=g(t,n,i,o,e[s+13],4,681279174),o=g(o,t,n,i,e[s],11,-358537222),i=g(i,o,t,n,e[s+3],16,-722521979),n=g(n,i,o,t,e[s+6],23,76029189),t=g(t,n,i,o,e[s+9],4,-640364487),o=g(o,t,n,i,e[s+12],11,-421815835),i=g(i,o,t,n,e[s+15],16,530742520),n=g(n,i,o,t,e[s+2],23,-995338651),t=h(t,n,i,o,e[s],6,-198630844),o=h(o,t,n,i,e[s+7],10,1126891415),i=h(i,o,t,n,e[s+14],15,-1416354905),n=h(n,i,o,t,e[s+5],21,-57434055),t=h(t,n,i,o,e[s+12],6,1700485571),o=h(o,t,n,i,e[s+3],10,-1894986606),i=h(i,o,t,n,e[s+10],15,-1051523),n=h(n,i,o,t,e[s+1],21,-2054922799),t=h(t,n,i,o,e[s+8],6,1873313359),o=h(o,t,n,i,e[s+15],10,-30611744),i=h(i,o,t,n,e[s+6],15,-1560198380),n=h(n,i,o,t,e[s+13],21,1309151649),t=h(t,n,i,o,e[s+4],6,-145523070),o=h(o,t,n,i,e[s+11],10,-1120210379),i=h(i,o,t,n,e[s+2],15,718787259),n=h(n,i,o,t,e[s+9],21,-343485551),t=S(t,a),n=S(n,f),i=S(i,l),o=S(o,u)}return[t,n,i,o]}function lt(e){if(e.length===0)return[];let r=e.length*8,t=new Uint32Array(he(r));for(let n=0;n<r;n+=8)t[n>>5]|=(e[n/8]&255)<<n%32;return t}function S(e,r){let t=(e&65535)+(r&65535);return(e>>16)+(r>>16)+(t>>16)<<16|t&65535}function ut(e,r){return e<<r|e>>>32-r}function W(e,r,t,n,i,o){return S(ut(S(S(r,e),S(n,o)),i),t)}function m(e,r,t,n,i,o,s){return W(r&t|~r&n,e,r,i,o,s)}function y(e,r,t,n,i,o,s){return W(r&n|t&~n,e,r,i,o,s)}function g(e,r,t,n,i,o,s){return W(r^t^n,e,r,i,o,s)}function h(e,r,t,n,i,o,s){return W(t^(r|~n),e,r,i,o,s)}var be=st;var or=H("v3",48,be);var dt=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ne={randomUUID:dt};function ct(e,r,t){if(ne.randomUUID&&!r&&!e)return ne.randomUUID();e=e||{};let n=e.random||(e.rng||G)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,r){t=t||0;for(let i=0;i<16;++i)r[t+i]=n[i];return r}return $(n)}var J=ct;function pt(e,r,t,n){switch(e){case 0:return r&t^~r&n;case 1:return r^t^n;case 2:return r&t^r&n^t&n;case 3:return r^t^n}}function ie(e,r){return e<<r|e>>>32-r}function mt(e){let r=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e=="string"){let s=unescape(encodeURIComponent(e));e=[];for(let a=0;a<s.length;++a)e.push(s.charCodeAt(a))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);let n=e.length/4+2,i=Math.ceil(n/16),o=new Array(i);for(let s=0;s<i;++s){let a=new Uint32Array(16);for(let f=0;f<16;++f)a[f]=e[s*64+f*4]<<24|e[s*64+f*4+1]<<16|e[s*64+f*4+2]<<8|e[s*64+f*4+3];o[s]=a}o[i-1][14]=(e.length-1)*8/Math.pow(2,32),o[i-1][14]=Math.floor(o[i-1][14]),o[i-1][15]=(e.length-1)*8&4294967295;for(let s=0;s<i;++s){let a=new Uint32Array(80);for(let c=0;c<16;++c)a[c]=o[s][c];for(let c=16;c<80;++c)a[c]=ie(a[c-3]^a[c-8]^a[c-14]^a[c-16],1);let f=t[0],l=t[1],u=t[2],v=t[3],A=t[4];for(let c=0;c<80;++c){let k=Math.floor(c/20),Q=ie(f,5)+pt(k,l,u,v)+A+r[k]+a[c]>>>0;A=v,v=u,u=ie(l,30)>>>0,l=f,f=Q}t[0]=t[0]+f>>>0,t[1]=t[1]+l>>>0,t[2]=t[2]+u>>>0,t[3]=t[3]+v>>>0,t[4]=t[4]+A>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,t[0]&255,t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,t[1]&255,t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,t[2]&255,t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,t[3]&255,t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,t[4]&255]}var xe=mt;var yr=H("v5",80,xe);function oe(e){return[...new Uint8Array(e)].map(r=>r.toString(16).padStart(2,"0")).join("")}function we(e){return new Uint8Array((e.match(/../g)??[]).map(r=>parseInt(r,16)))}function ve(e){let r=0;for(let i of e)r+=i.length;let t=new Uint8Array(r),n=0;for(let i of e)t.set(i,n),n+=i.length;return t}var Ue=ce(Ce());function V(e,r){if((0,Ue.validate)(e,r).length)throw new Error(`couldn't validate schema: ${JSON.stringify(r)} didn't match schema ${JSON.stringify(e)}`)}var Ie="3",De="https://webapp-prod.cloud.remarkable.engineering",Ot="https://internal.cloud.remarkable.com",Re="x-goog-generation",Ft="x-goog-if-generation-match",Mt="x-goog-content-length-range",zr=["Ballpoint","Ballpointv2","Brush","Calligraphy","ClearPage","EraseSection","Eraser","Fineliner","Finelinerv2","Highlighter","Highlighterv2","Marker","Markerv2","Paintbrush","Paintbrushv2","Pencilv2","SharpPencil","SharpPencilv2","SolidPen","ZoomTool"],Gr=["Maison Neue","EB Garamond","Noto Sans","Noto Serif","Noto Mono","Noto Sans UI"],Ct={xs:.7,sm:.8,md:1,lg:1.2,xl:1.5,xx:2},Ut={sm:50,md:125,rr:180,lg:200},It={df:-1,md:100,lg:150,xl:200},Rt={properties:{docID:{type:"string"},hash:{type:"string"}}},_t={properties:{relative_path:{type:"string"},url:{type:"string"},expires:{type:"timestamp"},method:{enum:["POST","GET","PUT","DELETE"]}},optionalProperties:{maxuploadsize_bytes:{type:"float64"}}},K={visibleName:{type:"string"},lastModified:{type:"string"}},X={version:{type:"int32"},pinned:{type:"boolean"},synced:{type:"boolean"},modified:{type:"boolean"},deleted:{type:"boolean"},metadatamodified:{type:"boolean"},parent:{type:"string"}},Lt={discriminator:"type",mapping:{CollectionType:{properties:K,optionalProperties:X},DocumentType:{properties:K,optionalProperties:{...X,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"}}}}},_e={id:{type:"string"},hash:{type:"string"}},Dt={discriminator:"type",mapping:{CollectionType:{properties:{...K,..._e},optionalProperties:X},DocumentType:{properties:{...K,..._e,fileType:{enum:["notebook","epub","pdf",""]}},optionalProperties:{...X,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"}}}}},N=class extends Error{constructor(t,n,i){super(i);this.status=t,this.statusText=n}},le=class extends Error{constructor(){super("Generation preconditions failed. This means the current state is out of date with the cloud and needs to be re-synced.")}};async function Wr(e,{deviceDesc:r="browser-chrome",uuid:t=J(),authHost:n=De,fetch:i=globalThis.fetch}={}){if(e.length!==8)throw new Error(`code should be length 8, but was ${e.length}`);let o=await i(`${n}/token/json/2/device/new`,{method:"POST",headers:{Authorization:"Bearer"},body:JSON.stringify({code:e,deviceDesc:r,deviceID:t})});if(o.ok)return await o.text();throw new N(o.status,o.statusText,"couldn't register api")}function Nt({hash:e,type:r,documentId:t,subfiles:n,size:i}){return`${e}:${r}:${t}:${n}:${i}
2
+ `}function Bt(e){let[r,t,n,i,o]=e.split(":");if(r===void 0||t===void 0||n===void 0||i===void 0||o===void 0)throw new Error(`entries line didn't contain five fields: '${e}'`);if(t==="80000000")return{hash:r,type:t,documentId:n,subfiles:parseInt(i),size:BigInt(o)};if(t==="0"){if(i!=="0")throw new Error(`file type entry had nonzero number of subfiles: ${i}`);return{hash:r,type:t,documentId:n,subfiles:0,size:BigInt(o)}}else throw new Error(`entries line contained invalid type: ${t}`)}var ue=class{#a;#o;#e;#s;#t;constructor(r,t,n,i,o){this.#a=r,this.#o=t,this.#e=n,this.#s=i,this.#t=o}async#i(r,{body:t,method:n="POST",headers:i={}}){let o=await this.#o(r,{method:n,headers:{Authorization:`Bearer ${this.#a}`,...i},body:t});if(o.ok)return o;{let s=await o.text();throw new N(o.status,o.statusText,`failed reMarkable request: ${s}`)}}async#r({url:r,method:t,maxuploadsize_bytes:n},i,o={}){let s=n?{...o,[Mt]:`0,${n}`}:o,a=await this.#o(r,{method:t,body:i,headers:s});if(a.ok)return a;{let f=await a.text();throw new N(a.status,a.statusText,f)}}async#n(r,t,n){let i=t===void 0?"downloads":"uploads",o=n?`{ "http_method": "PUT", "relative_path": "${r}", "root_schema": "${n}", "generation": ${t} }`:JSON.stringify({http_method:"GET",relative_path:r}),a=await(await this.#i(`${this.#t}/sync/v2/signed-urls/${i}`,{body:o})).text(),f=JSON.parse(a);return V(_t,f),f}async getRootHash(){let r=await this.#n("root"),t=await this.#r(r),n=t.headers.get(Re);if(!n)throw new Error("no generation header in root hash");return[await t.text(),BigInt(n)]}async putRootHash(r,t){let n=await this.#n("root",t,r),i;try{i=await this.#r(n,r,{[Ft]:`${t}`})}catch(s){throw s instanceof N&&s.status===412?new le:s}let o=i.headers.get(Re);if(!o)throw new Error("no generation header in root hash");return BigInt(o)}async getBuffer(r){let t=await this.#n(r);return await(await this.#r(t)).arrayBuffer()}async getText(r){let t=await this.#e?.get(r);if(t)return t;{let n=await this.#n(r),o=await(await this.#r(n)).text();return await this.#e?.set(r,o),o}}async getMetadata(r){let t=await this.getText(r),n=JSON.parse(t);return V(Lt,n),n}async getEntries(r){let t=await this.getText(r),[n,...i]=t.slice(0,-1).split(`
3
3
  `);if(n!==Ie)throw new Error(`got unexpected schema version: ${n}`);return i.map(Bt)}async#f(r,t){let n=await this.#n(r,null);await this.#r(n,t)}async putEntries(r,t){let n=new TextEncoder;t.sort((u,v)=>u.documentId.localeCompare(v.documentId));let i=ve(t.map(u=>we(u.hash))),o=await this.#s.digest("SHA-256",i),s=oe(o),a=t.map(Nt).join(""),f=`${Ie}
4
- ${a}`,l=n.encode(f);return await this.#f(s,l),await this.#e?.set(s,f),{hash:s,type:"80000000",documentId:r,subfiles:t.length,size:0n}}async putBuffer(r,t){let n=await this.#s.digest("SHA-256",t),i=oe(n);return await this.#f(i,t),{hash:i,type:"0",documentId:r,subfiles:0,size:BigInt(t.length)}}async putText(r,t){let n=new TextEncoder,i=await this.putBuffer(r,n.encode(t));return await this.#e?.set(i.hash,t),i}async#l(r,t,n,i,o){if(o.fileType!==n)throw new Error(`internal error: fileTypes don't match: ${n}, ${o.fileType}`);let s=W(),a=`${new Date().valueOf()}`,f=[];f.push(this.putBuffer(`${s}.${n}`,t));let l={type:"DocumentType",visibleName:r,version:0,parent:i,synced:!0,lastModified:a};f.push(this.putText(`${s}.metadata`,JSON.stringify(l))),f.push(this.putText(`${s}.content`,JSON.stringify(o)));let u=await Promise.all(f);return await this.putEntries(s,u)}async putEpub(r,t,{parent:n="",margins:i=125,orientation:o,textAlignment:s,textScale:a=1,lineHeight:f=-1,fontName:l="",cover:u="visited",lastTool:v}={}){let P={dummyDocument:!1,extraMetadata:{LastTool:v},fileType:"epub",pageCount:0,lastOpenedPage:0,lineHeight:typeof f=="string"?It[f]:f,margins:typeof i=="string"?Mt[i]:i,textScale:typeof a=="string"?Ct[a]:a,pages:[],coverPageNumber:u==="first"?0:-1,formatVersion:1,orientation:o,textAlignment:s,fontName:l};return await this.#l(r,t,"epub",n,P)}async putPdf(r,t,{parent:n="",orientation:i,cover:o="first",lastTool:s}={}){let a={dummyDocument:!1,extraMetadata:{LastTool:s},fileType:"pdf",pageCount:0,lastOpenedPage:0,lineHeight:-1,margins:125,textScale:1,pages:[],coverPageNumber:o==="first"?0:-1,formatVersion:1,orientation:i};return await this.#l(r,t,"pdf",n,a)}async syncComplete(r){let t=`{ "generation": ${r} }`;await this.#i(`${this.#t}/sync/v2/sync-complete`,{body:t})}async getEntriesMetadata(){let t=await(await this.#i(`${this.#t}/doc/v2/files`,{method:"GET",headers:{"rm-source":"RoR-Browser"}})).text(),n=JSON.parse(t);return J({elements:Dt},n),n}async#u(r,t,n){let o=new TextEncoder().encode(JSON.stringify({file_name:r})),a=await(await this.#i(`${this.#t}/doc/v2/files`,{body:t,headers:{"content-type":n,"rm-meta":(0,Le.fromByteArray)(o),"rm-source":"RoR-Browser"}})).text(),f=JSON.parse(a);return J(Rt,f),f}async uploadEpub(r,t){return await this.#u(r,t,"application/epub+zip")}async uploadPdf(r,t){return await this.#u(r,t,"application/pdf")}};async function Yr(e,{fetch:r=globalThis.fetch,cache:t,subtle:n=globalThis.crypto?.subtle,authHost:i=De,syncHost:o=Ot}={}){let s=await r(`${i}/token/json/2/user/new`,{method:"POST",headers:{Authorization:`Bearer ${e}`}});if(!s.ok)throw new Error(`couldn't fetch auth token: ${s.statusText}`);let a=await s.text();return new ue(a,r,t,n,o)}export{le as GenerationError,N as ResponseError,Gr as builtinFontNames,It as builtinLineHeights,Mt as builtinMargins,Ct as builtinTextScales,zr as builtinTools,Nt as formatEntry,Bt as parseEntry,Wr as register,Yr as remarkable};
4
+ ${a}`,l=n.encode(f);return await this.#f(s,l),await this.#e?.set(s,f),{hash:s,type:"80000000",documentId:r,subfiles:t.length,size:0n}}async putBuffer(r,t){let n=await this.#s.digest("SHA-256",t),i=oe(n);return await this.#f(i,t),{hash:i,type:"0",documentId:r,subfiles:0,size:BigInt(t.length)}}async putText(r,t){let n=new TextEncoder,i=await this.putBuffer(r,n.encode(t));return await this.#e?.set(i.hash,t),i}async putMetadata(r,t){return await this.putText(`${r}.metadata`,JSON.stringify(t))}async putCollection(r,t=""){let n=J(),i=`${new Date().valueOf()}`,o=[],s={type:"CollectionType",visibleName:r,version:0,parent:t,synced:!0,lastModified:i};o.push(this.putMetadata(n,s)),o.push(this.putText(`${n}.content`,"{}"));let a=await Promise.all(o);return await this.putEntries(n,a)}async#l(r,t,n,i,o){if(o.fileType!==n)throw new Error(`internal error: fileTypes don't match: ${n}, ${o.fileType}`);let s=J(),a=`${new Date().valueOf()}`,f=[];f.push(this.putBuffer(`${s}.${n}`,t));let l={type:"DocumentType",visibleName:r,version:0,parent:i,synced:!0,lastModified:a};f.push(this.putMetadata(s,l)),f.push(this.putText(`${s}.content`,JSON.stringify(o)));let u=await Promise.all(f);return await this.putEntries(s,u)}async putEpub(r,t,{parent:n="",margins:i=125,orientation:o,textAlignment:s,textScale:a=1,lineHeight:f=-1,fontName:l="",cover:u="visited",lastTool:v}={}){let A={dummyDocument:!1,extraMetadata:{LastTool:v},fileType:"epub",pageCount:0,lastOpenedPage:0,lineHeight:typeof f=="string"?It[f]:f,margins:typeof i=="string"?Ut[i]:i,textScale:typeof a=="string"?Ct[a]:a,pages:[],coverPageNumber:u==="first"?0:-1,formatVersion:1,orientation:o,textAlignment:s,fontName:l};return await this.#l(r,t,"epub",n,A)}async putPdf(r,t,{parent:n="",orientation:i,cover:o="first",lastTool:s}={}){let a={dummyDocument:!1,extraMetadata:{LastTool:s},fileType:"pdf",pageCount:0,lastOpenedPage:0,lineHeight:-1,margins:125,textScale:1,pages:[],coverPageNumber:o==="first"?0:-1,formatVersion:1,orientation:i};return await this.#l(r,t,"pdf",n,a)}async syncComplete(r){let t=`{ "generation": ${r} }`;await this.#i(`${this.#t}/sync/v2/sync-complete`,{body:t})}async getEntriesMetadata(){let t=await(await this.#i(`${this.#t}/doc/v2/files`,{method:"GET",headers:{"rm-source":"RoR-Browser"}})).text(),n=JSON.parse(t);return V({elements:Dt},n),n}async#u(r,t,n){let o=new TextEncoder().encode(JSON.stringify({file_name:r})),a=await(await this.#i(`${this.#t}/doc/v2/files`,{body:t,headers:{"content-type":n,"rm-meta":(0,Le.fromByteArray)(o),"rm-source":"RoR-Browser"}})).text(),f=JSON.parse(a);return V(Rt,f),f}async uploadEpub(r,t){return await this.#u(r,t,"application/epub+zip")}async uploadPdf(r,t){return await this.#u(r,t,"application/pdf")}};async function Yr(e,{fetch:r=globalThis.fetch,cache:t,subtle:n=globalThis.crypto?.subtle,authHost:i=De,syncHost:o=Ot}={}){let s=await r(`${i}/token/json/2/user/new`,{method:"POST",headers:{Authorization:`Bearer ${e}`}});if(!s.ok)throw new Error(`couldn't fetch auth token: ${s.statusText}`);let a=await s.text();return new ue(a,r,t,n,o)}export{le as GenerationError,N as ResponseError,Gr as builtinFontNames,It as builtinLineHeights,Ut as builtinMargins,Ct as builtinTextScales,zr as builtinTools,Nt as formatEntry,Bt as parseEntry,Wr as register,Yr as remarkable};
@@ -1,4 +1,4 @@
1
- var rmapi=(()=>{var Ge=Object.create;var V=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var Ye=Object.getOwnPropertyNames;var Ze=Object.getPrototypeOf,Ke=Object.prototype.hasOwnProperty;var B=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Xe=(e,r)=>{for(var t in r)V(e,t,{get:r[t],enumerable:!0})},ce=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of Ye(r))!Ke.call(e,i)&&i!==t&&V(e,i,{get:()=>r[i],enumerable:!(n=We(r,i))||n.enumerable});return e};var pe=(e,r,t)=>(t=e!=null?Ge(Ze(e)):{},ce(r||!e||!e.__esModule?V(t,"default",{value:e,enumerable:!0}):t,e)),Qe=e=>ce(V({},"__esModule",{value:!0}),e);var ge=B(q=>{"use strict";q.byteLength=tt;q.toByteArray=nt;q.fromByteArray=st;var A=[],E=[],et=typeof Uint8Array<"u"?Uint8Array:Array,ne="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(U=0,me=ne.length;U<me;++U)A[U]=ne[U],E[ne.charCodeAt(U)]=U;var U,me;E["-".charCodeAt(0)]=62;E["_".charCodeAt(0)]=63;function ye(e){var r=e.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=e.indexOf("=");t===-1&&(t=r);var n=t===r?0:4-t%4;return[t,n]}function tt(e){var r=ye(e),t=r[0],n=r[1];return(t+n)*3/4-n}function rt(e,r,t){return(r+t)*3/4-t}function nt(e){var r,t=ye(e),n=t[0],i=t[1],o=new et(rt(e,n,i)),s=0,a=i>0?n-4:n,f;for(f=0;f<a;f+=4)r=E[e.charCodeAt(f)]<<18|E[e.charCodeAt(f+1)]<<12|E[e.charCodeAt(f+2)]<<6|E[e.charCodeAt(f+3)],o[s++]=r>>16&255,o[s++]=r>>8&255,o[s++]=r&255;return i===2&&(r=E[e.charCodeAt(f)]<<2|E[e.charCodeAt(f+1)]>>4,o[s++]=r&255),i===1&&(r=E[e.charCodeAt(f)]<<10|E[e.charCodeAt(f+1)]<<4|E[e.charCodeAt(f+2)]>>2,o[s++]=r>>8&255,o[s++]=r&255),o}function it(e){return A[e>>18&63]+A[e>>12&63]+A[e>>6&63]+A[e&63]}function ot(e,r,t){for(var n,i=[],o=r;o<t;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(it(n));return i.join("")}function st(e){for(var r,t=e.length,n=t%3,i=[],o=16383,s=0,a=t-n;s<a;s+=o)i.push(ot(e,s,s+o>a?a:s+o));return n===1?(r=e[t-1],i.push(A[r>>2]+A[r<<4&63]+"==")):n===2&&(r=(e[t-2]<<8)+e[t-1],i.push(A[r>>10]+A[r>>4&63]+A[r<<2&63]+"=")),i.join("")}});var le=B(d=>{"use strict";var Te=d&&d.__rest||function(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)r.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(t[n[i]]=e[n[i]]);return t};Object.defineProperty(d,"__esModule",{value:!0});d.isSchema=d.isValidSchema=d.isDiscriminatorForm=d.isValuesForm=d.isPropertiesForm=d.isElementsForm=d.isEnumForm=d.isTypeForm=d.isRefForm=d.isEmptyForm=void 0;function Et(e){let{definitions:r,nullable:t,metadata:n}=e,i=Te(e,["definitions","nullable","metadata"]);return Object.keys(i).length===0}d.isEmptyForm=Et;function Ae(e){return"ref"in e}d.isRefForm=Ae;function Tt(e){return"type"in e}d.isTypeForm=Tt;function Pe(e){return"enum"in e}d.isEnumForm=Pe;function ke(e){return"elements"in e}d.isElementsForm=ke;function fe(e){return"properties"in e||"optionalProperties"in e}d.isPropertiesForm=fe;function Se(e){return"values"in e}d.isValuesForm=Se;function Oe(e){return"discriminator"in e}d.isDiscriminatorForm=Oe;function C(e,r){if(r===void 0&&(r=e),e.definitions!==void 0){if(r!==e)return!1;for(let t of Object.values(e.definitions))if(!C(t,r))return!1}if(Ae(e)&&!(e.ref in(r.definitions||{}))||Pe(e)&&(e.enum.length===0||e.enum.length!==new Set(e.enum).size))return!1;if(ke(e))return C(e.elements,r);if(fe(e)){for(let t of Object.values(e.properties||{}))if(!C(t,r))return!1;for(let t of Object.values(e.optionalProperties||{}))if(!C(t,r))return!1;for(let t of Object.keys(e.properties||{}))if(t in(e.optionalProperties||{}))return!1}if(Se(e))return C(e.values,r);if(Oe(e)){for(let t of Object.values(e.mapping))if(!C(t,r)||!fe(t)||t.nullable||e.discriminator in(t.properties||{})||e.discriminator in(t.optionalProperties||{}))return!1}return!0}d.isValidSchema=C;var At=[[!1,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!0,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!0,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!0,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!0,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!0,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!1,!0,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!0,!1,!1,!1],[!1,!1,!1,!1,!0,!0,!0,!1,!1,!1],[!1,!1,!1,!1,!1,!1,!1,!0,!1,!1],[!1,!1,!1,!1,!1,!1,!1,!1,!0,!0]],Pt=["boolean","float32","float64","int8","uint8","int16","uint16","int32","uint32","string","timestamp"];function M(e){if(typeof e!="object"||Array.isArray(e)||e===null)return!1;let r=e,{definitions:t=void 0,nullable:n=void 0,metadata:i=void 0,ref:o=void 0,type:s=void 0,enum:a=void 0,elements:f=void 0,properties:l=void 0,optionalProperties:u=void 0,additionalProperties:v=void 0,values:P=void 0,discriminator:c=void 0,mapping:k=void 0}=r,te=Te(r,["definitions","nullable","metadata","ref","type","enum","elements","properties","optionalProperties","additionalProperties","values","discriminator","mapping"]),Ve=[o!==void 0,s!==void 0,a!==void 0,f!==void 0,l!==void 0,u!==void 0,v!==void 0,P!==void 0,c!==void 0,k!==void 0],re=!1;for(let T of At)re=re||T.every((qe,ze)=>qe===Ve[ze]);if(!re)return!1;if(t!==void 0){if(typeof t!="object"||Array.isArray(t)||t===null)return!1;for(let T of Object.values(t))if(!M(T))return!1}if(n!==void 0&&typeof n!="boolean"||i!==void 0&&(typeof i!="object"||Array.isArray(i)||i===null)||o!==void 0&&typeof o!="string"||s!==void 0&&(typeof s!="string"||!Pt.includes(s))||a!==void 0&&(!Array.isArray(a)||!a.every(T=>typeof T=="string"))||f!==void 0&&!M(f))return!1;if(l!==void 0){if(typeof l!="object"||Array.isArray(l)||l===null)return!1;for(let T of Object.values(l))if(!M(T))return!1}if(u!==void 0){if(typeof u!="object"||Array.isArray(u)||u===null)return!1;for(let T of Object.values(u))if(!M(T))return!1}if(v!==void 0&&typeof v!="boolean"||P!==void 0&&!M(P)||c!==void 0&&typeof c!="string")return!1;if(k!==void 0){if(typeof k!="object"||Array.isArray(k)||k===null)return!1;for(let T of Object.values(k))if(!M(T))return!1}return Object.keys(te).length===0}d.isSchema=M});var Fe=B(ue=>{"use strict";Object.defineProperty(ue,"__esModule",{value:!0});var kt=/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(\.\d+)?([zZ]|((\+|-)(\d{2}):(\d{2})))$/;function St(e){let r=e.match(kt);if(r===null)return!1;let t=parseInt(r[1],10),n=parseInt(r[2],10),i=parseInt(r[3],10),o=parseInt(r[4],10),s=parseInt(r[5],10),a=parseInt(r[6],10);return!(n>12||i>Ot(t,n)||o>23||s>59||a>60)}ue.default=St;function Ot(e,r){return r===2?Ft(e)?29:28:Ut[r]}function Ft(e){return e%4===0&&(e%100!==0||e%400===0)}var Ut=[0,31,0,31,30,31,30,31,31,30,31,30,31]});var Ue=B(O=>{"use strict";var Ct=O&&O.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(O,"__esModule",{value:!0});O.validate=O.MaxDepthExceededError=void 0;var Mt=Ct(Fe()),I=le(),Z=class extends Error{};O.MaxDepthExceededError=Z;var K=class extends Error{};function It(e,r,t){let n={errors:[],instanceTokens:[],schemaTokens:[[]],root:e,config:t||{maxDepth:0,maxErrors:0}};try{L(n,e,r)}catch(i){if(!(i instanceof K))throw i}return n.errors}O.validate=It;function L(e,r,t,n){if(!(r.nullable&&t===null)){if(I.isRefForm(r)){if(e.schemaTokens.length===e.config.maxDepth)throw new Z;e.schemaTokens.push(["definitions",r.ref]),L(e,e.root.definitions[r.ref],t),e.schemaTokens.pop()}else if(I.isTypeForm(r)){switch(b(e,"type"),r.type){case"boolean":typeof t!="boolean"&&x(e);break;case"float32":case"float64":typeof t!="number"&&x(e);break;case"int8":N(e,t,-128,127);break;case"uint8":N(e,t,0,255);break;case"int16":N(e,t,-32768,32767);break;case"uint16":N(e,t,0,65535);break;case"int32":N(e,t,-2147483648,2147483647);break;case"uint32":N(e,t,0,4294967295);break;case"string":typeof t!="string"&&x(e);break;case"timestamp":typeof t!="string"?x(e):Mt.default(t)||x(e);break}w(e)}else if(I.isEnumForm(r))b(e,"enum"),(typeof t!="string"||!r.enum.includes(t))&&x(e),w(e);else if(I.isElementsForm(r)){if(b(e,"elements"),Array.isArray(t))for(let[i,o]of t.entries())R(e,i.toString()),L(e,r.elements,o),_(e);else x(e);w(e)}else if(I.isPropertiesForm(r))if(typeof t=="object"&&t!==null&&!Array.isArray(t)){if(r.properties!==void 0){b(e,"properties");for(let[i,o]of Object.entries(r.properties))b(e,i),t.hasOwnProperty(i)?(R(e,i),L(e,o,t[i]),_(e)):x(e),w(e);w(e)}if(r.optionalProperties!==void 0){b(e,"optionalProperties");for(let[i,o]of Object.entries(r.optionalProperties))b(e,i),t.hasOwnProperty(i)&&(R(e,i),L(e,o,t[i]),_(e)),w(e);w(e)}if(r.additionalProperties!==!0)for(let i of Object.keys(t)){let o=r.properties&&i in r.properties,s=r.optionalProperties&&i in r.optionalProperties;!o&&!s&&i!==n&&(R(e,i),x(e),_(e))}}else r.properties!==void 0?b(e,"properties"):b(e,"optionalProperties"),x(e),w(e);else if(I.isValuesForm(r)){if(b(e,"values"),typeof t=="object"&&t!==null&&!Array.isArray(t))for(let[i,o]of Object.entries(t))R(e,i),L(e,r.values,o),_(e);else x(e);w(e)}else if(I.isDiscriminatorForm(r))if(typeof t=="object"&&t!==null&&!Array.isArray(t))if(t.hasOwnProperty(r.discriminator)){let i=t[r.discriminator];typeof i=="string"?i in r.mapping?(b(e,"mapping"),b(e,i),L(e,r.mapping[i],t,r.discriminator),w(e),w(e)):(b(e,"mapping"),R(e,r.discriminator),x(e),_(e),w(e)):(b(e,"discriminator"),R(e,r.discriminator),x(e),_(e),w(e))}else b(e,"discriminator"),x(e),w(e);else b(e,"discriminator"),x(e),w(e)}}function N(e,r,t,n){(typeof r!="number"||!Number.isInteger(r)||r<t||r>n)&&x(e)}function R(e,r){e.instanceTokens.push(r)}function _(e){e.instanceTokens.pop()}function b(e,r){e.schemaTokens[e.schemaTokens.length-1].push(r)}function w(e){e.schemaTokens[e.schemaTokens.length-1].pop()}function x(e){if(e.errors.push({instancePath:[...e.instanceTokens],schemaPath:[...e.schemaTokens[e.schemaTokens.length-1]]}),e.errors.length===e.config.maxErrors)throw new K}});var Me=B(F=>{"use strict";var Rt=F&&F.__createBinding||(Object.create?function(e,r,t,n){n===void 0&&(n=t),Object.defineProperty(e,n,{enumerable:!0,get:function(){return r[t]}})}:function(e,r,t,n){n===void 0&&(n=t),e[n]=r[t]}),Ce=F&&F.__exportStar||function(e,r){for(var t in e)t!=="default"&&!r.hasOwnProperty(t)&&Rt(r,e,t)};Object.defineProperty(F,"__esModule",{value:!0});Ce(le(),F);Ce(Ue(),F)});var zt={};Xe(zt,{GenerationError:()=>ee,ResponseError:()=>D,builtinFontNames:()=>Bt,builtinLineHeights:()=>$e,builtinMargins:()=>je,builtinTextScales:()=>Be,builtinTools:()=>Nt,formatEntry:()=>He,parseEntry:()=>Je,register:()=>Vt,remarkable:()=>qt});var De=pe(ge());var z,at=new Uint8Array(16);function G(){if(!z&&(z=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!z))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return z(at)}var he=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function ft(e){return typeof e=="string"&&he.test(e)}var j=ft;var p=[];for(let e=0;e<256;++e)p.push((e+256).toString(16).slice(1));function $(e,r=0){return(p[e[r+0]]+p[e[r+1]]+p[e[r+2]]+p[e[r+3]]+"-"+p[e[r+4]]+p[e[r+5]]+"-"+p[e[r+6]]+p[e[r+7]]+"-"+p[e[r+8]]+p[e[r+9]]+"-"+p[e[r+10]]+p[e[r+11]]+p[e[r+12]]+p[e[r+13]]+p[e[r+14]]+p[e[r+15]]).toLowerCase()}function lt(e){if(!j(e))throw TypeError("Invalid UUID");let r,t=new Uint8Array(16);return t[0]=(r=parseInt(e.slice(0,8),16))>>>24,t[1]=r>>>16&255,t[2]=r>>>8&255,t[3]=r&255,t[4]=(r=parseInt(e.slice(9,13),16))>>>8,t[5]=r&255,t[6]=(r=parseInt(e.slice(14,18),16))>>>8,t[7]=r&255,t[8]=(r=parseInt(e.slice(19,23),16))>>>8,t[9]=r&255,t[10]=(r=parseInt(e.slice(24,36),16))/1099511627776&255,t[11]=r/4294967296&255,t[12]=r>>>24&255,t[13]=r>>>16&255,t[14]=r>>>8&255,t[15]=r&255,t}var ie=lt;function ut(e){e=unescape(encodeURIComponent(e));let r=[];for(let t=0;t<e.length;++t)r.push(e.charCodeAt(t));return r}var dt="6ba7b810-9dad-11d1-80b4-00c04fd430c8",ct="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function H(e,r,t){function n(i,o,s,a){var f;if(typeof i=="string"&&(i=ut(i)),typeof o=="string"&&(o=ie(o)),((f=o)===null||f===void 0?void 0:f.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let l=new Uint8Array(16+i.length);if(l.set(o),l.set(i,o.length),l=t(l),l[6]=l[6]&15|r,l[8]=l[8]&63|128,s){a=a||0;for(let u=0;u<16;++u)s[a+u]=l[u];return s}return $(l)}try{n.name=e}catch{}return n.DNS=dt,n.URL=ct,n}function pt(e){if(typeof e=="string"){let r=unescape(encodeURIComponent(e));e=new Uint8Array(r.length);for(let t=0;t<r.length;++t)e[t]=r.charCodeAt(t)}return mt(yt(gt(e),e.length*8))}function mt(e){let r=[],t=e.length*32,n="0123456789abcdef";for(let i=0;i<t;i+=8){let o=e[i>>5]>>>i%32&255,s=parseInt(n.charAt(o>>>4&15)+n.charAt(o&15),16);r.push(s)}return r}function be(e){return(e+64>>>9<<4)+14+1}function yt(e,r){e[r>>5]|=128<<r%32,e[be(r)-1]=r;let t=1732584193,n=-271733879,i=-1732584194,o=271733878;for(let s=0;s<e.length;s+=16){let a=t,f=n,l=i,u=o;t=m(t,n,i,o,e[s],7,-680876936),o=m(o,t,n,i,e[s+1],12,-389564586),i=m(i,o,t,n,e[s+2],17,606105819),n=m(n,i,o,t,e[s+3],22,-1044525330),t=m(t,n,i,o,e[s+4],7,-176418897),o=m(o,t,n,i,e[s+5],12,1200080426),i=m(i,o,t,n,e[s+6],17,-1473231341),n=m(n,i,o,t,e[s+7],22,-45705983),t=m(t,n,i,o,e[s+8],7,1770035416),o=m(o,t,n,i,e[s+9],12,-1958414417),i=m(i,o,t,n,e[s+10],17,-42063),n=m(n,i,o,t,e[s+11],22,-1990404162),t=m(t,n,i,o,e[s+12],7,1804603682),o=m(o,t,n,i,e[s+13],12,-40341101),i=m(i,o,t,n,e[s+14],17,-1502002290),n=m(n,i,o,t,e[s+15],22,1236535329),t=y(t,n,i,o,e[s+1],5,-165796510),o=y(o,t,n,i,e[s+6],9,-1069501632),i=y(i,o,t,n,e[s+11],14,643717713),n=y(n,i,o,t,e[s],20,-373897302),t=y(t,n,i,o,e[s+5],5,-701558691),o=y(o,t,n,i,e[s+10],9,38016083),i=y(i,o,t,n,e[s+15],14,-660478335),n=y(n,i,o,t,e[s+4],20,-405537848),t=y(t,n,i,o,e[s+9],5,568446438),o=y(o,t,n,i,e[s+14],9,-1019803690),i=y(i,o,t,n,e[s+3],14,-187363961),n=y(n,i,o,t,e[s+8],20,1163531501),t=y(t,n,i,o,e[s+13],5,-1444681467),o=y(o,t,n,i,e[s+2],9,-51403784),i=y(i,o,t,n,e[s+7],14,1735328473),n=y(n,i,o,t,e[s+12],20,-1926607734),t=g(t,n,i,o,e[s+5],4,-378558),o=g(o,t,n,i,e[s+8],11,-2022574463),i=g(i,o,t,n,e[s+11],16,1839030562),n=g(n,i,o,t,e[s+14],23,-35309556),t=g(t,n,i,o,e[s+1],4,-1530992060),o=g(o,t,n,i,e[s+4],11,1272893353),i=g(i,o,t,n,e[s+7],16,-155497632),n=g(n,i,o,t,e[s+10],23,-1094730640),t=g(t,n,i,o,e[s+13],4,681279174),o=g(o,t,n,i,e[s],11,-358537222),i=g(i,o,t,n,e[s+3],16,-722521979),n=g(n,i,o,t,e[s+6],23,76029189),t=g(t,n,i,o,e[s+9],4,-640364487),o=g(o,t,n,i,e[s+12],11,-421815835),i=g(i,o,t,n,e[s+15],16,530742520),n=g(n,i,o,t,e[s+2],23,-995338651),t=h(t,n,i,o,e[s],6,-198630844),o=h(o,t,n,i,e[s+7],10,1126891415),i=h(i,o,t,n,e[s+14],15,-1416354905),n=h(n,i,o,t,e[s+5],21,-57434055),t=h(t,n,i,o,e[s+12],6,1700485571),o=h(o,t,n,i,e[s+3],10,-1894986606),i=h(i,o,t,n,e[s+10],15,-1051523),n=h(n,i,o,t,e[s+1],21,-2054922799),t=h(t,n,i,o,e[s+8],6,1873313359),o=h(o,t,n,i,e[s+15],10,-30611744),i=h(i,o,t,n,e[s+6],15,-1560198380),n=h(n,i,o,t,e[s+13],21,1309151649),t=h(t,n,i,o,e[s+4],6,-145523070),o=h(o,t,n,i,e[s+11],10,-1120210379),i=h(i,o,t,n,e[s+2],15,718787259),n=h(n,i,o,t,e[s+9],21,-343485551),t=S(t,a),n=S(n,f),i=S(i,l),o=S(o,u)}return[t,n,i,o]}function gt(e){if(e.length===0)return[];let r=e.length*8,t=new Uint32Array(be(r));for(let n=0;n<r;n+=8)t[n>>5]|=(e[n/8]&255)<<n%32;return t}function S(e,r){let t=(e&65535)+(r&65535);return(e>>16)+(r>>16)+(t>>16)<<16|t&65535}function ht(e,r){return e<<r|e>>>32-r}function W(e,r,t,n,i,o){return S(ht(S(S(r,e),S(n,o)),i),t)}function m(e,r,t,n,i,o,s){return W(r&t|~r&n,e,r,i,o,s)}function y(e,r,t,n,i,o,s){return W(r&n|t&~n,e,r,i,o,s)}function g(e,r,t,n,i,o,s){return W(r^t^n,e,r,i,o,s)}function h(e,r,t,n,i,o,s){return W(t^(r|~n),e,r,i,o,s)}var xe=pt;var cr=H("v3",48,xe);var bt=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),oe={randomUUID:bt};function xt(e,r,t){if(oe.randomUUID&&!r&&!e)return oe.randomUUID();e=e||{};let n=e.random||(e.rng||G)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,r){t=t||0;for(let i=0;i<16;++i)r[t+i]=n[i];return r}return $(n)}var Y=xt;function wt(e,r,t,n){switch(e){case 0:return r&t^~r&n;case 1:return r^t^n;case 2:return r&t^r&n^t&n;case 3:return r^t^n}}function se(e,r){return e<<r|e>>>32-r}function vt(e){let r=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e=="string"){let s=unescape(encodeURIComponent(e));e=[];for(let a=0;a<s.length;++a)e.push(s.charCodeAt(a))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);let n=e.length/4+2,i=Math.ceil(n/16),o=new Array(i);for(let s=0;s<i;++s){let a=new Uint32Array(16);for(let f=0;f<16;++f)a[f]=e[s*64+f*4]<<24|e[s*64+f*4+1]<<16|e[s*64+f*4+2]<<8|e[s*64+f*4+3];o[s]=a}o[i-1][14]=(e.length-1)*8/Math.pow(2,32),o[i-1][14]=Math.floor(o[i-1][14]),o[i-1][15]=(e.length-1)*8&4294967295;for(let s=0;s<i;++s){let a=new Uint32Array(80);for(let c=0;c<16;++c)a[c]=o[s][c];for(let c=16;c<80;++c)a[c]=se(a[c-3]^a[c-8]^a[c-14]^a[c-16],1);let f=t[0],l=t[1],u=t[2],v=t[3],P=t[4];for(let c=0;c<80;++c){let k=Math.floor(c/20),te=se(f,5)+wt(k,l,u,v)+P+r[k]+a[c]>>>0;P=v,v=u,u=se(l,30)>>>0,l=f,f=te}t[0]=t[0]+f>>>0,t[1]=t[1]+l>>>0,t[2]=t[2]+u>>>0,t[3]=t[3]+v>>>0,t[4]=t[4]+P>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,t[0]&255,t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,t[1]&255,t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,t[2]&255,t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,t[3]&255,t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,t[4]&255]}var we=vt;var Er=H("v5",80,we);function ae(e){return[...new Uint8Array(e)].map(r=>r.toString(16).padStart(2,"0")).join("")}function ve(e){return new Uint8Array((e.match(/../g)??[]).map(r=>parseInt(r,16)))}function Ee(e){let r=0;for(let i of e)r+=i.length;let t=new Uint8Array(r),n=0;for(let i of e)t.set(i,n),n+=i.length;return t}var Ie=pe(Me());function J(e,r){if((0,Ie.validate)(e,r).length)throw new Error(`couldn't validate schema: ${JSON.stringify(r)} didn't match schema ${JSON.stringify(e)}`)}var Re="3",Ne="https://webapp-prod.cloud.remarkable.engineering",_t="https://internal.cloud.remarkable.com",_e="x-goog-generation",Lt="x-goog-if-generation-match",Dt="x-goog-content-length-range",Nt=["Ballpoint","Ballpointv2","Brush","Calligraphy","ClearPage","EraseSection","Eraser","Fineliner","Finelinerv2","Highlighter","Highlighterv2","Marker","Markerv2","Paintbrush","Paintbrushv2","Pencilv2","SharpPencil","SharpPencilv2","SolidPen","ZoomTool"],Bt=["Maison Neue","EB Garamond","Noto Sans","Noto Serif","Noto Mono","Noto Sans UI"],Be={xs:.7,sm:.8,md:1,lg:1.2,xl:1.5,xx:2},je={sm:50,md:125,rr:180,lg:200},$e={df:-1,md:100,lg:150,xl:200},jt={properties:{docID:{type:"string"},hash:{type:"string"}}},$t={properties:{relative_path:{type:"string"},url:{type:"string"},expires:{type:"timestamp"},method:{enum:["POST","GET","PUT","DELETE"]}},optionalProperties:{maxuploadsize_bytes:{type:"float64"}}},X={visibleName:{type:"string"},lastModified:{type:"string"}},Q={version:{type:"int32"},pinned:{type:"boolean"},synced:{type:"boolean"},modified:{type:"boolean"},deleted:{type:"boolean"},metadatamodified:{type:"boolean"},parent:{type:"string"}},Ht={discriminator:"type",mapping:{CollectionType:{properties:X,optionalProperties:Q},DocumentType:{properties:X,optionalProperties:{...Q,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"}}}}},Le={id:{type:"string"},hash:{type:"string"}},Jt={discriminator:"type",mapping:{CollectionType:{properties:{...X,...Le},optionalProperties:Q},DocumentType:{properties:{...X,...Le,fileType:{enum:["notebook","epub","pdf",""]}},optionalProperties:{...Q,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"}}}}},D=class extends Error{constructor(t,n,i){super(i);this.status=t,this.statusText=n}},ee=class extends Error{constructor(){super("Generation preconditions failed. This means the current state is out of date with the cloud and needs to be re-synced.")}};async function Vt(e,{deviceDesc:r="browser-chrome",uuid:t=Y(),authHost:n=Ne,fetch:i=globalThis.fetch}={}){if(e.length!==8)throw new Error(`code should be length 8, but was ${e.length}`);let o=await i(`${n}/token/json/2/device/new`,{method:"POST",headers:{Authorization:"Bearer"},body:JSON.stringify({code:e,deviceDesc:r,deviceID:t})});if(o.ok)return await o.text();throw new D(o.status,o.statusText,"couldn't register api")}function He({hash:e,type:r,documentId:t,subfiles:n,size:i}){return`${e}:${r}:${t}:${n}:${i}
2
- `}function Je(e){let[r,t,n,i,o]=e.split(":");if(r===void 0||t===void 0||n===void 0||i===void 0||o===void 0)throw new Error(`entries line didn't contain five fields: '${e}'`);if(t==="80000000")return{hash:r,type:t,documentId:n,subfiles:parseInt(i),size:BigInt(o)};if(t==="0"){if(i!=="0")throw new Error(`file type entry had nonzero number of subfiles: ${i}`);return{hash:r,type:t,documentId:n,subfiles:0,size:BigInt(o)}}else throw new Error(`entries line contained invalid type: ${t}`)}var de=class{#a;#o;#e;#s;#t;constructor(r,t,n,i,o){this.#a=r,this.#o=t,this.#e=n,this.#s=i,this.#t=o}async#i(r,{body:t,method:n="POST",headers:i={}}){let o=await this.#o(r,{method:n,headers:{Authorization:`Bearer ${this.#a}`,...i},body:t});if(o.ok)return o;{let s=await o.text();throw new D(o.status,o.statusText,`failed reMarkable request: ${s}`)}}async#r({url:r,method:t,maxuploadsize_bytes:n},i,o={}){let s=n?{...o,[Dt]:`0,${n}`}:o,a=await this.#o(r,{method:t,body:i,headers:s});if(a.ok)return a;{let f=await a.text();throw new D(a.status,a.statusText,f)}}async#n(r,t,n){let i=t===void 0?"downloads":"uploads",o=n?`{ "http_method": "PUT", "relative_path": "${r}", "root_schema": "${n}", "generation": ${t} }`:JSON.stringify({http_method:"GET",relative_path:r}),a=await(await this.#i(`${this.#t}/sync/v2/signed-urls/${i}`,{body:o})).text(),f=JSON.parse(a);return J($t,f),f}async getRootHash(){let r=await this.#n("root"),t=await this.#r(r),n=t.headers.get(_e);if(!n)throw new Error("no generation header in root hash");return[await t.text(),BigInt(n)]}async putRootHash(r,t){let n=await this.#n("root",t,r),i;try{i=await this.#r(n,r,{[Lt]:`${t}`})}catch(s){throw s instanceof D&&s.status===412?new ee:s}let o=i.headers.get(_e);if(!o)throw new Error("no generation header in root hash");return BigInt(o)}async getBuffer(r){let t=await this.#n(r);return await(await this.#r(t)).arrayBuffer()}async getText(r){let t=await this.#e?.get(r);if(t)return t;{let n=await this.#n(r),o=await(await this.#r(n)).text();return await this.#e?.set(r,o),o}}async getMetadata(r){let t=await this.getText(r),n=JSON.parse(t);return J(Ht,n),n}async getEntries(r){let t=await this.getText(r),[n,...i]=t.slice(0,-1).split(`
1
+ var rmapi=(()=>{var Ge=Object.create;var q=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var Ye=Object.getOwnPropertyNames;var Ze=Object.getPrototypeOf,Ke=Object.prototype.hasOwnProperty;var B=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Xe=(e,r)=>{for(var t in r)q(e,t,{get:r[t],enumerable:!0})},ce=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of Ye(r))!Ke.call(e,i)&&i!==t&&q(e,i,{get:()=>r[i],enumerable:!(n=We(r,i))||n.enumerable});return e};var pe=(e,r,t)=>(t=e!=null?Ge(Ze(e)):{},ce(r||!e||!e.__esModule?q(t,"default",{value:e,enumerable:!0}):t,e)),Qe=e=>ce(q({},"__esModule",{value:!0}),e);var ge=B(z=>{"use strict";z.byteLength=tt;z.toByteArray=nt;z.fromByteArray=st;var P=[],E=[],et=typeof Uint8Array<"u"?Uint8Array:Array,ne="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(M=0,me=ne.length;M<me;++M)P[M]=ne[M],E[ne.charCodeAt(M)]=M;var M,me;E["-".charCodeAt(0)]=62;E["_".charCodeAt(0)]=63;function ye(e){var r=e.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=e.indexOf("=");t===-1&&(t=r);var n=t===r?0:4-t%4;return[t,n]}function tt(e){var r=ye(e),t=r[0],n=r[1];return(t+n)*3/4-n}function rt(e,r,t){return(r+t)*3/4-t}function nt(e){var r,t=ye(e),n=t[0],i=t[1],o=new et(rt(e,n,i)),s=0,a=i>0?n-4:n,f;for(f=0;f<a;f+=4)r=E[e.charCodeAt(f)]<<18|E[e.charCodeAt(f+1)]<<12|E[e.charCodeAt(f+2)]<<6|E[e.charCodeAt(f+3)],o[s++]=r>>16&255,o[s++]=r>>8&255,o[s++]=r&255;return i===2&&(r=E[e.charCodeAt(f)]<<2|E[e.charCodeAt(f+1)]>>4,o[s++]=r&255),i===1&&(r=E[e.charCodeAt(f)]<<10|E[e.charCodeAt(f+1)]<<4|E[e.charCodeAt(f+2)]>>2,o[s++]=r>>8&255,o[s++]=r&255),o}function it(e){return P[e>>18&63]+P[e>>12&63]+P[e>>6&63]+P[e&63]}function ot(e,r,t){for(var n,i=[],o=r;o<t;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(it(n));return i.join("")}function st(e){for(var r,t=e.length,n=t%3,i=[],o=16383,s=0,a=t-n;s<a;s+=o)i.push(ot(e,s,s+o>a?a:s+o));return n===1?(r=e[t-1],i.push(P[r>>2]+P[r<<4&63]+"==")):n===2&&(r=(e[t-2]<<8)+e[t-1],i.push(P[r>>10]+P[r>>4&63]+P[r<<2&63]+"=")),i.join("")}});var le=B(d=>{"use strict";var Te=d&&d.__rest||function(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)r.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(t[n[i]]=e[n[i]]);return t};Object.defineProperty(d,"__esModule",{value:!0});d.isSchema=d.isValidSchema=d.isDiscriminatorForm=d.isValuesForm=d.isPropertiesForm=d.isElementsForm=d.isEnumForm=d.isTypeForm=d.isRefForm=d.isEmptyForm=void 0;function Et(e){let{definitions:r,nullable:t,metadata:n}=e,i=Te(e,["definitions","nullable","metadata"]);return Object.keys(i).length===0}d.isEmptyForm=Et;function Pe(e){return"ref"in e}d.isRefForm=Pe;function Tt(e){return"type"in e}d.isTypeForm=Tt;function Ae(e){return"enum"in e}d.isEnumForm=Ae;function ke(e){return"elements"in e}d.isElementsForm=ke;function fe(e){return"properties"in e||"optionalProperties"in e}d.isPropertiesForm=fe;function Se(e){return"values"in e}d.isValuesForm=Se;function Oe(e){return"discriminator"in e}d.isDiscriminatorForm=Oe;function C(e,r){if(r===void 0&&(r=e),e.definitions!==void 0){if(r!==e)return!1;for(let t of Object.values(e.definitions))if(!C(t,r))return!1}if(Pe(e)&&!(e.ref in(r.definitions||{}))||Ae(e)&&(e.enum.length===0||e.enum.length!==new Set(e.enum).size))return!1;if(ke(e))return C(e.elements,r);if(fe(e)){for(let t of Object.values(e.properties||{}))if(!C(t,r))return!1;for(let t of Object.values(e.optionalProperties||{}))if(!C(t,r))return!1;for(let t of Object.keys(e.properties||{}))if(t in(e.optionalProperties||{}))return!1}if(Se(e))return C(e.values,r);if(Oe(e)){for(let t of Object.values(e.mapping))if(!C(t,r)||!fe(t)||t.nullable||e.discriminator in(t.properties||{})||e.discriminator in(t.optionalProperties||{}))return!1}return!0}d.isValidSchema=C;var Pt=[[!1,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!0,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!0,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!0,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!0,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!0,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!1,!0,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!0,!1,!1,!1],[!1,!1,!1,!1,!0,!0,!0,!1,!1,!1],[!1,!1,!1,!1,!1,!1,!1,!0,!1,!1],[!1,!1,!1,!1,!1,!1,!1,!1,!0,!0]],At=["boolean","float32","float64","int8","uint8","int16","uint16","int32","uint32","string","timestamp"];function U(e){if(typeof e!="object"||Array.isArray(e)||e===null)return!1;let r=e,{definitions:t=void 0,nullable:n=void 0,metadata:i=void 0,ref:o=void 0,type:s=void 0,enum:a=void 0,elements:f=void 0,properties:l=void 0,optionalProperties:u=void 0,additionalProperties:v=void 0,values:A=void 0,discriminator:c=void 0,mapping:k=void 0}=r,te=Te(r,["definitions","nullable","metadata","ref","type","enum","elements","properties","optionalProperties","additionalProperties","values","discriminator","mapping"]),Ve=[o!==void 0,s!==void 0,a!==void 0,f!==void 0,l!==void 0,u!==void 0,v!==void 0,A!==void 0,c!==void 0,k!==void 0],re=!1;for(let T of Pt)re=re||T.every((qe,ze)=>qe===Ve[ze]);if(!re)return!1;if(t!==void 0){if(typeof t!="object"||Array.isArray(t)||t===null)return!1;for(let T of Object.values(t))if(!U(T))return!1}if(n!==void 0&&typeof n!="boolean"||i!==void 0&&(typeof i!="object"||Array.isArray(i)||i===null)||o!==void 0&&typeof o!="string"||s!==void 0&&(typeof s!="string"||!At.includes(s))||a!==void 0&&(!Array.isArray(a)||!a.every(T=>typeof T=="string"))||f!==void 0&&!U(f))return!1;if(l!==void 0){if(typeof l!="object"||Array.isArray(l)||l===null)return!1;for(let T of Object.values(l))if(!U(T))return!1}if(u!==void 0){if(typeof u!="object"||Array.isArray(u)||u===null)return!1;for(let T of Object.values(u))if(!U(T))return!1}if(v!==void 0&&typeof v!="boolean"||A!==void 0&&!U(A)||c!==void 0&&typeof c!="string")return!1;if(k!==void 0){if(typeof k!="object"||Array.isArray(k)||k===null)return!1;for(let T of Object.values(k))if(!U(T))return!1}return Object.keys(te).length===0}d.isSchema=U});var Fe=B(ue=>{"use strict";Object.defineProperty(ue,"__esModule",{value:!0});var kt=/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(\.\d+)?([zZ]|((\+|-)(\d{2}):(\d{2})))$/;function St(e){let r=e.match(kt);if(r===null)return!1;let t=parseInt(r[1],10),n=parseInt(r[2],10),i=parseInt(r[3],10),o=parseInt(r[4],10),s=parseInt(r[5],10),a=parseInt(r[6],10);return!(n>12||i>Ot(t,n)||o>23||s>59||a>60)}ue.default=St;function Ot(e,r){return r===2?Ft(e)?29:28:Mt[r]}function Ft(e){return e%4===0&&(e%100!==0||e%400===0)}var Mt=[0,31,0,31,30,31,30,31,31,30,31,30,31]});var Me=B(O=>{"use strict";var Ct=O&&O.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(O,"__esModule",{value:!0});O.validate=O.MaxDepthExceededError=void 0;var Ut=Ct(Fe()),I=le(),Z=class extends Error{};O.MaxDepthExceededError=Z;var K=class extends Error{};function It(e,r,t){let n={errors:[],instanceTokens:[],schemaTokens:[[]],root:e,config:t||{maxDepth:0,maxErrors:0}};try{L(n,e,r)}catch(i){if(!(i instanceof K))throw i}return n.errors}O.validate=It;function L(e,r,t,n){if(!(r.nullable&&t===null)){if(I.isRefForm(r)){if(e.schemaTokens.length===e.config.maxDepth)throw new Z;e.schemaTokens.push(["definitions",r.ref]),L(e,e.root.definitions[r.ref],t),e.schemaTokens.pop()}else if(I.isTypeForm(r)){switch(b(e,"type"),r.type){case"boolean":typeof t!="boolean"&&x(e);break;case"float32":case"float64":typeof t!="number"&&x(e);break;case"int8":N(e,t,-128,127);break;case"uint8":N(e,t,0,255);break;case"int16":N(e,t,-32768,32767);break;case"uint16":N(e,t,0,65535);break;case"int32":N(e,t,-2147483648,2147483647);break;case"uint32":N(e,t,0,4294967295);break;case"string":typeof t!="string"&&x(e);break;case"timestamp":typeof t!="string"?x(e):Ut.default(t)||x(e);break}w(e)}else if(I.isEnumForm(r))b(e,"enum"),(typeof t!="string"||!r.enum.includes(t))&&x(e),w(e);else if(I.isElementsForm(r)){if(b(e,"elements"),Array.isArray(t))for(let[i,o]of t.entries())R(e,i.toString()),L(e,r.elements,o),_(e);else x(e);w(e)}else if(I.isPropertiesForm(r))if(typeof t=="object"&&t!==null&&!Array.isArray(t)){if(r.properties!==void 0){b(e,"properties");for(let[i,o]of Object.entries(r.properties))b(e,i),t.hasOwnProperty(i)?(R(e,i),L(e,o,t[i]),_(e)):x(e),w(e);w(e)}if(r.optionalProperties!==void 0){b(e,"optionalProperties");for(let[i,o]of Object.entries(r.optionalProperties))b(e,i),t.hasOwnProperty(i)&&(R(e,i),L(e,o,t[i]),_(e)),w(e);w(e)}if(r.additionalProperties!==!0)for(let i of Object.keys(t)){let o=r.properties&&i in r.properties,s=r.optionalProperties&&i in r.optionalProperties;!o&&!s&&i!==n&&(R(e,i),x(e),_(e))}}else r.properties!==void 0?b(e,"properties"):b(e,"optionalProperties"),x(e),w(e);else if(I.isValuesForm(r)){if(b(e,"values"),typeof t=="object"&&t!==null&&!Array.isArray(t))for(let[i,o]of Object.entries(t))R(e,i),L(e,r.values,o),_(e);else x(e);w(e)}else if(I.isDiscriminatorForm(r))if(typeof t=="object"&&t!==null&&!Array.isArray(t))if(t.hasOwnProperty(r.discriminator)){let i=t[r.discriminator];typeof i=="string"?i in r.mapping?(b(e,"mapping"),b(e,i),L(e,r.mapping[i],t,r.discriminator),w(e),w(e)):(b(e,"mapping"),R(e,r.discriminator),x(e),_(e),w(e)):(b(e,"discriminator"),R(e,r.discriminator),x(e),_(e),w(e))}else b(e,"discriminator"),x(e),w(e);else b(e,"discriminator"),x(e),w(e)}}function N(e,r,t,n){(typeof r!="number"||!Number.isInteger(r)||r<t||r>n)&&x(e)}function R(e,r){e.instanceTokens.push(r)}function _(e){e.instanceTokens.pop()}function b(e,r){e.schemaTokens[e.schemaTokens.length-1].push(r)}function w(e){e.schemaTokens[e.schemaTokens.length-1].pop()}function x(e){if(e.errors.push({instancePath:[...e.instanceTokens],schemaPath:[...e.schemaTokens[e.schemaTokens.length-1]]}),e.errors.length===e.config.maxErrors)throw new K}});var Ue=B(F=>{"use strict";var Rt=F&&F.__createBinding||(Object.create?function(e,r,t,n){n===void 0&&(n=t),Object.defineProperty(e,n,{enumerable:!0,get:function(){return r[t]}})}:function(e,r,t,n){n===void 0&&(n=t),e[n]=r[t]}),Ce=F&&F.__exportStar||function(e,r){for(var t in e)t!=="default"&&!r.hasOwnProperty(t)&&Rt(r,e,t)};Object.defineProperty(F,"__esModule",{value:!0});Ce(le(),F);Ce(Me(),F)});var zt={};Xe(zt,{GenerationError:()=>ee,ResponseError:()=>D,builtinFontNames:()=>Bt,builtinLineHeights:()=>$e,builtinMargins:()=>je,builtinTextScales:()=>Be,builtinTools:()=>Nt,formatEntry:()=>He,parseEntry:()=>Je,register:()=>Vt,remarkable:()=>qt});var De=pe(ge());var G,at=new Uint8Array(16);function W(){if(!G&&(G=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!G))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return G(at)}var he=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function ft(e){return typeof e=="string"&&he.test(e)}var j=ft;var p=[];for(let e=0;e<256;++e)p.push((e+256).toString(16).slice(1));function $(e,r=0){return(p[e[r+0]]+p[e[r+1]]+p[e[r+2]]+p[e[r+3]]+"-"+p[e[r+4]]+p[e[r+5]]+"-"+p[e[r+6]]+p[e[r+7]]+"-"+p[e[r+8]]+p[e[r+9]]+"-"+p[e[r+10]]+p[e[r+11]]+p[e[r+12]]+p[e[r+13]]+p[e[r+14]]+p[e[r+15]]).toLowerCase()}function lt(e){if(!j(e))throw TypeError("Invalid UUID");let r,t=new Uint8Array(16);return t[0]=(r=parseInt(e.slice(0,8),16))>>>24,t[1]=r>>>16&255,t[2]=r>>>8&255,t[3]=r&255,t[4]=(r=parseInt(e.slice(9,13),16))>>>8,t[5]=r&255,t[6]=(r=parseInt(e.slice(14,18),16))>>>8,t[7]=r&255,t[8]=(r=parseInt(e.slice(19,23),16))>>>8,t[9]=r&255,t[10]=(r=parseInt(e.slice(24,36),16))/1099511627776&255,t[11]=r/4294967296&255,t[12]=r>>>24&255,t[13]=r>>>16&255,t[14]=r>>>8&255,t[15]=r&255,t}var ie=lt;function ut(e){e=unescape(encodeURIComponent(e));let r=[];for(let t=0;t<e.length;++t)r.push(e.charCodeAt(t));return r}var dt="6ba7b810-9dad-11d1-80b4-00c04fd430c8",ct="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function H(e,r,t){function n(i,o,s,a){var f;if(typeof i=="string"&&(i=ut(i)),typeof o=="string"&&(o=ie(o)),((f=o)===null||f===void 0?void 0:f.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let l=new Uint8Array(16+i.length);if(l.set(o),l.set(i,o.length),l=t(l),l[6]=l[6]&15|r,l[8]=l[8]&63|128,s){a=a||0;for(let u=0;u<16;++u)s[a+u]=l[u];return s}return $(l)}try{n.name=e}catch{}return n.DNS=dt,n.URL=ct,n}function pt(e){if(typeof e=="string"){let r=unescape(encodeURIComponent(e));e=new Uint8Array(r.length);for(let t=0;t<r.length;++t)e[t]=r.charCodeAt(t)}return mt(yt(gt(e),e.length*8))}function mt(e){let r=[],t=e.length*32,n="0123456789abcdef";for(let i=0;i<t;i+=8){let o=e[i>>5]>>>i%32&255,s=parseInt(n.charAt(o>>>4&15)+n.charAt(o&15),16);r.push(s)}return r}function be(e){return(e+64>>>9<<4)+14+1}function yt(e,r){e[r>>5]|=128<<r%32,e[be(r)-1]=r;let t=1732584193,n=-271733879,i=-1732584194,o=271733878;for(let s=0;s<e.length;s+=16){let a=t,f=n,l=i,u=o;t=m(t,n,i,o,e[s],7,-680876936),o=m(o,t,n,i,e[s+1],12,-389564586),i=m(i,o,t,n,e[s+2],17,606105819),n=m(n,i,o,t,e[s+3],22,-1044525330),t=m(t,n,i,o,e[s+4],7,-176418897),o=m(o,t,n,i,e[s+5],12,1200080426),i=m(i,o,t,n,e[s+6],17,-1473231341),n=m(n,i,o,t,e[s+7],22,-45705983),t=m(t,n,i,o,e[s+8],7,1770035416),o=m(o,t,n,i,e[s+9],12,-1958414417),i=m(i,o,t,n,e[s+10],17,-42063),n=m(n,i,o,t,e[s+11],22,-1990404162),t=m(t,n,i,o,e[s+12],7,1804603682),o=m(o,t,n,i,e[s+13],12,-40341101),i=m(i,o,t,n,e[s+14],17,-1502002290),n=m(n,i,o,t,e[s+15],22,1236535329),t=y(t,n,i,o,e[s+1],5,-165796510),o=y(o,t,n,i,e[s+6],9,-1069501632),i=y(i,o,t,n,e[s+11],14,643717713),n=y(n,i,o,t,e[s],20,-373897302),t=y(t,n,i,o,e[s+5],5,-701558691),o=y(o,t,n,i,e[s+10],9,38016083),i=y(i,o,t,n,e[s+15],14,-660478335),n=y(n,i,o,t,e[s+4],20,-405537848),t=y(t,n,i,o,e[s+9],5,568446438),o=y(o,t,n,i,e[s+14],9,-1019803690),i=y(i,o,t,n,e[s+3],14,-187363961),n=y(n,i,o,t,e[s+8],20,1163531501),t=y(t,n,i,o,e[s+13],5,-1444681467),o=y(o,t,n,i,e[s+2],9,-51403784),i=y(i,o,t,n,e[s+7],14,1735328473),n=y(n,i,o,t,e[s+12],20,-1926607734),t=g(t,n,i,o,e[s+5],4,-378558),o=g(o,t,n,i,e[s+8],11,-2022574463),i=g(i,o,t,n,e[s+11],16,1839030562),n=g(n,i,o,t,e[s+14],23,-35309556),t=g(t,n,i,o,e[s+1],4,-1530992060),o=g(o,t,n,i,e[s+4],11,1272893353),i=g(i,o,t,n,e[s+7],16,-155497632),n=g(n,i,o,t,e[s+10],23,-1094730640),t=g(t,n,i,o,e[s+13],4,681279174),o=g(o,t,n,i,e[s],11,-358537222),i=g(i,o,t,n,e[s+3],16,-722521979),n=g(n,i,o,t,e[s+6],23,76029189),t=g(t,n,i,o,e[s+9],4,-640364487),o=g(o,t,n,i,e[s+12],11,-421815835),i=g(i,o,t,n,e[s+15],16,530742520),n=g(n,i,o,t,e[s+2],23,-995338651),t=h(t,n,i,o,e[s],6,-198630844),o=h(o,t,n,i,e[s+7],10,1126891415),i=h(i,o,t,n,e[s+14],15,-1416354905),n=h(n,i,o,t,e[s+5],21,-57434055),t=h(t,n,i,o,e[s+12],6,1700485571),o=h(o,t,n,i,e[s+3],10,-1894986606),i=h(i,o,t,n,e[s+10],15,-1051523),n=h(n,i,o,t,e[s+1],21,-2054922799),t=h(t,n,i,o,e[s+8],6,1873313359),o=h(o,t,n,i,e[s+15],10,-30611744),i=h(i,o,t,n,e[s+6],15,-1560198380),n=h(n,i,o,t,e[s+13],21,1309151649),t=h(t,n,i,o,e[s+4],6,-145523070),o=h(o,t,n,i,e[s+11],10,-1120210379),i=h(i,o,t,n,e[s+2],15,718787259),n=h(n,i,o,t,e[s+9],21,-343485551),t=S(t,a),n=S(n,f),i=S(i,l),o=S(o,u)}return[t,n,i,o]}function gt(e){if(e.length===0)return[];let r=e.length*8,t=new Uint32Array(be(r));for(let n=0;n<r;n+=8)t[n>>5]|=(e[n/8]&255)<<n%32;return t}function S(e,r){let t=(e&65535)+(r&65535);return(e>>16)+(r>>16)+(t>>16)<<16|t&65535}function ht(e,r){return e<<r|e>>>32-r}function Y(e,r,t,n,i,o){return S(ht(S(S(r,e),S(n,o)),i),t)}function m(e,r,t,n,i,o,s){return Y(r&t|~r&n,e,r,i,o,s)}function y(e,r,t,n,i,o,s){return Y(r&n|t&~n,e,r,i,o,s)}function g(e,r,t,n,i,o,s){return Y(r^t^n,e,r,i,o,s)}function h(e,r,t,n,i,o,s){return Y(t^(r|~n),e,r,i,o,s)}var xe=pt;var cr=H("v3",48,xe);var bt=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),oe={randomUUID:bt};function xt(e,r,t){if(oe.randomUUID&&!r&&!e)return oe.randomUUID();e=e||{};let n=e.random||(e.rng||W)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,r){t=t||0;for(let i=0;i<16;++i)r[t+i]=n[i];return r}return $(n)}var J=xt;function wt(e,r,t,n){switch(e){case 0:return r&t^~r&n;case 1:return r^t^n;case 2:return r&t^r&n^t&n;case 3:return r^t^n}}function se(e,r){return e<<r|e>>>32-r}function vt(e){let r=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e=="string"){let s=unescape(encodeURIComponent(e));e=[];for(let a=0;a<s.length;++a)e.push(s.charCodeAt(a))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);let n=e.length/4+2,i=Math.ceil(n/16),o=new Array(i);for(let s=0;s<i;++s){let a=new Uint32Array(16);for(let f=0;f<16;++f)a[f]=e[s*64+f*4]<<24|e[s*64+f*4+1]<<16|e[s*64+f*4+2]<<8|e[s*64+f*4+3];o[s]=a}o[i-1][14]=(e.length-1)*8/Math.pow(2,32),o[i-1][14]=Math.floor(o[i-1][14]),o[i-1][15]=(e.length-1)*8&4294967295;for(let s=0;s<i;++s){let a=new Uint32Array(80);for(let c=0;c<16;++c)a[c]=o[s][c];for(let c=16;c<80;++c)a[c]=se(a[c-3]^a[c-8]^a[c-14]^a[c-16],1);let f=t[0],l=t[1],u=t[2],v=t[3],A=t[4];for(let c=0;c<80;++c){let k=Math.floor(c/20),te=se(f,5)+wt(k,l,u,v)+A+r[k]+a[c]>>>0;A=v,v=u,u=se(l,30)>>>0,l=f,f=te}t[0]=t[0]+f>>>0,t[1]=t[1]+l>>>0,t[2]=t[2]+u>>>0,t[3]=t[3]+v>>>0,t[4]=t[4]+A>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,t[0]&255,t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,t[1]&255,t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,t[2]&255,t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,t[3]&255,t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,t[4]&255]}var we=vt;var Er=H("v5",80,we);function ae(e){return[...new Uint8Array(e)].map(r=>r.toString(16).padStart(2,"0")).join("")}function ve(e){return new Uint8Array((e.match(/../g)??[]).map(r=>parseInt(r,16)))}function Ee(e){let r=0;for(let i of e)r+=i.length;let t=new Uint8Array(r),n=0;for(let i of e)t.set(i,n),n+=i.length;return t}var Ie=pe(Ue());function V(e,r){if((0,Ie.validate)(e,r).length)throw new Error(`couldn't validate schema: ${JSON.stringify(r)} didn't match schema ${JSON.stringify(e)}`)}var Re="3",Ne="https://webapp-prod.cloud.remarkable.engineering",_t="https://internal.cloud.remarkable.com",_e="x-goog-generation",Lt="x-goog-if-generation-match",Dt="x-goog-content-length-range",Nt=["Ballpoint","Ballpointv2","Brush","Calligraphy","ClearPage","EraseSection","Eraser","Fineliner","Finelinerv2","Highlighter","Highlighterv2","Marker","Markerv2","Paintbrush","Paintbrushv2","Pencilv2","SharpPencil","SharpPencilv2","SolidPen","ZoomTool"],Bt=["Maison Neue","EB Garamond","Noto Sans","Noto Serif","Noto Mono","Noto Sans UI"],Be={xs:.7,sm:.8,md:1,lg:1.2,xl:1.5,xx:2},je={sm:50,md:125,rr:180,lg:200},$e={df:-1,md:100,lg:150,xl:200},jt={properties:{docID:{type:"string"},hash:{type:"string"}}},$t={properties:{relative_path:{type:"string"},url:{type:"string"},expires:{type:"timestamp"},method:{enum:["POST","GET","PUT","DELETE"]}},optionalProperties:{maxuploadsize_bytes:{type:"float64"}}},X={visibleName:{type:"string"},lastModified:{type:"string"}},Q={version:{type:"int32"},pinned:{type:"boolean"},synced:{type:"boolean"},modified:{type:"boolean"},deleted:{type:"boolean"},metadatamodified:{type:"boolean"},parent:{type:"string"}},Ht={discriminator:"type",mapping:{CollectionType:{properties:X,optionalProperties:Q},DocumentType:{properties:X,optionalProperties:{...Q,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"}}}}},Le={id:{type:"string"},hash:{type:"string"}},Jt={discriminator:"type",mapping:{CollectionType:{properties:{...X,...Le},optionalProperties:Q},DocumentType:{properties:{...X,...Le,fileType:{enum:["notebook","epub","pdf",""]}},optionalProperties:{...Q,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"}}}}},D=class extends Error{constructor(t,n,i){super(i);this.status=t,this.statusText=n}},ee=class extends Error{constructor(){super("Generation preconditions failed. This means the current state is out of date with the cloud and needs to be re-synced.")}};async function Vt(e,{deviceDesc:r="browser-chrome",uuid:t=J(),authHost:n=Ne,fetch:i=globalThis.fetch}={}){if(e.length!==8)throw new Error(`code should be length 8, but was ${e.length}`);let o=await i(`${n}/token/json/2/device/new`,{method:"POST",headers:{Authorization:"Bearer"},body:JSON.stringify({code:e,deviceDesc:r,deviceID:t})});if(o.ok)return await o.text();throw new D(o.status,o.statusText,"couldn't register api")}function He({hash:e,type:r,documentId:t,subfiles:n,size:i}){return`${e}:${r}:${t}:${n}:${i}
2
+ `}function Je(e){let[r,t,n,i,o]=e.split(":");if(r===void 0||t===void 0||n===void 0||i===void 0||o===void 0)throw new Error(`entries line didn't contain five fields: '${e}'`);if(t==="80000000")return{hash:r,type:t,documentId:n,subfiles:parseInt(i),size:BigInt(o)};if(t==="0"){if(i!=="0")throw new Error(`file type entry had nonzero number of subfiles: ${i}`);return{hash:r,type:t,documentId:n,subfiles:0,size:BigInt(o)}}else throw new Error(`entries line contained invalid type: ${t}`)}var de=class{#a;#o;#e;#s;#t;constructor(r,t,n,i,o){this.#a=r,this.#o=t,this.#e=n,this.#s=i,this.#t=o}async#i(r,{body:t,method:n="POST",headers:i={}}){let o=await this.#o(r,{method:n,headers:{Authorization:`Bearer ${this.#a}`,...i},body:t});if(o.ok)return o;{let s=await o.text();throw new D(o.status,o.statusText,`failed reMarkable request: ${s}`)}}async#r({url:r,method:t,maxuploadsize_bytes:n},i,o={}){let s=n?{...o,[Dt]:`0,${n}`}:o,a=await this.#o(r,{method:t,body:i,headers:s});if(a.ok)return a;{let f=await a.text();throw new D(a.status,a.statusText,f)}}async#n(r,t,n){let i=t===void 0?"downloads":"uploads",o=n?`{ "http_method": "PUT", "relative_path": "${r}", "root_schema": "${n}", "generation": ${t} }`:JSON.stringify({http_method:"GET",relative_path:r}),a=await(await this.#i(`${this.#t}/sync/v2/signed-urls/${i}`,{body:o})).text(),f=JSON.parse(a);return V($t,f),f}async getRootHash(){let r=await this.#n("root"),t=await this.#r(r),n=t.headers.get(_e);if(!n)throw new Error("no generation header in root hash");return[await t.text(),BigInt(n)]}async putRootHash(r,t){let n=await this.#n("root",t,r),i;try{i=await this.#r(n,r,{[Lt]:`${t}`})}catch(s){throw s instanceof D&&s.status===412?new ee:s}let o=i.headers.get(_e);if(!o)throw new Error("no generation header in root hash");return BigInt(o)}async getBuffer(r){let t=await this.#n(r);return await(await this.#r(t)).arrayBuffer()}async getText(r){let t=await this.#e?.get(r);if(t)return t;{let n=await this.#n(r),o=await(await this.#r(n)).text();return await this.#e?.set(r,o),o}}async getMetadata(r){let t=await this.getText(r),n=JSON.parse(t);return V(Ht,n),n}async getEntries(r){let t=await this.getText(r),[n,...i]=t.slice(0,-1).split(`
3
3
  `);if(n!==Re)throw new Error(`got unexpected schema version: ${n}`);return i.map(Je)}async#f(r,t){let n=await this.#n(r,null);await this.#r(n,t)}async putEntries(r,t){let n=new TextEncoder;t.sort((u,v)=>u.documentId.localeCompare(v.documentId));let i=Ee(t.map(u=>ve(u.hash))),o=await this.#s.digest("SHA-256",i),s=ae(o),a=t.map(He).join(""),f=`${Re}
4
- ${a}`,l=n.encode(f);return await this.#f(s,l),await this.#e?.set(s,f),{hash:s,type:"80000000",documentId:r,subfiles:t.length,size:0n}}async putBuffer(r,t){let n=await this.#s.digest("SHA-256",t),i=ae(n);return await this.#f(i,t),{hash:i,type:"0",documentId:r,subfiles:0,size:BigInt(t.length)}}async putText(r,t){let n=new TextEncoder,i=await this.putBuffer(r,n.encode(t));return await this.#e?.set(i.hash,t),i}async#l(r,t,n,i,o){if(o.fileType!==n)throw new Error(`internal error: fileTypes don't match: ${n}, ${o.fileType}`);let s=Y(),a=`${new Date().valueOf()}`,f=[];f.push(this.putBuffer(`${s}.${n}`,t));let l={type:"DocumentType",visibleName:r,version:0,parent:i,synced:!0,lastModified:a};f.push(this.putText(`${s}.metadata`,JSON.stringify(l))),f.push(this.putText(`${s}.content`,JSON.stringify(o)));let u=await Promise.all(f);return await this.putEntries(s,u)}async putEpub(r,t,{parent:n="",margins:i=125,orientation:o,textAlignment:s,textScale:a=1,lineHeight:f=-1,fontName:l="",cover:u="visited",lastTool:v}={}){let P={dummyDocument:!1,extraMetadata:{LastTool:v},fileType:"epub",pageCount:0,lastOpenedPage:0,lineHeight:typeof f=="string"?$e[f]:f,margins:typeof i=="string"?je[i]:i,textScale:typeof a=="string"?Be[a]:a,pages:[],coverPageNumber:u==="first"?0:-1,formatVersion:1,orientation:o,textAlignment:s,fontName:l};return await this.#l(r,t,"epub",n,P)}async putPdf(r,t,{parent:n="",orientation:i,cover:o="first",lastTool:s}={}){let a={dummyDocument:!1,extraMetadata:{LastTool:s},fileType:"pdf",pageCount:0,lastOpenedPage:0,lineHeight:-1,margins:125,textScale:1,pages:[],coverPageNumber:o==="first"?0:-1,formatVersion:1,orientation:i};return await this.#l(r,t,"pdf",n,a)}async syncComplete(r){let t=`{ "generation": ${r} }`;await this.#i(`${this.#t}/sync/v2/sync-complete`,{body:t})}async getEntriesMetadata(){let t=await(await this.#i(`${this.#t}/doc/v2/files`,{method:"GET",headers:{"rm-source":"RoR-Browser"}})).text(),n=JSON.parse(t);return J({elements:Jt},n),n}async#u(r,t,n){let o=new TextEncoder().encode(JSON.stringify({file_name:r})),a=await(await this.#i(`${this.#t}/doc/v2/files`,{body:t,headers:{"content-type":n,"rm-meta":(0,De.fromByteArray)(o),"rm-source":"RoR-Browser"}})).text(),f=JSON.parse(a);return J(jt,f),f}async uploadEpub(r,t){return await this.#u(r,t,"application/epub+zip")}async uploadPdf(r,t){return await this.#u(r,t,"application/pdf")}};async function qt(e,{fetch:r=globalThis.fetch,cache:t,subtle:n=globalThis.crypto?.subtle,authHost:i=Ne,syncHost:o=_t}={}){let s=await r(`${i}/token/json/2/user/new`,{method:"POST",headers:{Authorization:`Bearer ${e}`}});if(!s.ok)throw new Error(`couldn't fetch auth token: ${s.statusText}`);let a=await s.text();return new de(a,r,t,n,o)}return Qe(zt);})();
4
+ ${a}`,l=n.encode(f);return await this.#f(s,l),await this.#e?.set(s,f),{hash:s,type:"80000000",documentId:r,subfiles:t.length,size:0n}}async putBuffer(r,t){let n=await this.#s.digest("SHA-256",t),i=ae(n);return await this.#f(i,t),{hash:i,type:"0",documentId:r,subfiles:0,size:BigInt(t.length)}}async putText(r,t){let n=new TextEncoder,i=await this.putBuffer(r,n.encode(t));return await this.#e?.set(i.hash,t),i}async putMetadata(r,t){return await this.putText(`${r}.metadata`,JSON.stringify(t))}async putCollection(r,t=""){let n=J(),i=`${new Date().valueOf()}`,o=[],s={type:"CollectionType",visibleName:r,version:0,parent:t,synced:!0,lastModified:i};o.push(this.putMetadata(n,s)),o.push(this.putText(`${n}.content`,"{}"));let a=await Promise.all(o);return await this.putEntries(n,a)}async#l(r,t,n,i,o){if(o.fileType!==n)throw new Error(`internal error: fileTypes don't match: ${n}, ${o.fileType}`);let s=J(),a=`${new Date().valueOf()}`,f=[];f.push(this.putBuffer(`${s}.${n}`,t));let l={type:"DocumentType",visibleName:r,version:0,parent:i,synced:!0,lastModified:a};f.push(this.putMetadata(s,l)),f.push(this.putText(`${s}.content`,JSON.stringify(o)));let u=await Promise.all(f);return await this.putEntries(s,u)}async putEpub(r,t,{parent:n="",margins:i=125,orientation:o,textAlignment:s,textScale:a=1,lineHeight:f=-1,fontName:l="",cover:u="visited",lastTool:v}={}){let A={dummyDocument:!1,extraMetadata:{LastTool:v},fileType:"epub",pageCount:0,lastOpenedPage:0,lineHeight:typeof f=="string"?$e[f]:f,margins:typeof i=="string"?je[i]:i,textScale:typeof a=="string"?Be[a]:a,pages:[],coverPageNumber:u==="first"?0:-1,formatVersion:1,orientation:o,textAlignment:s,fontName:l};return await this.#l(r,t,"epub",n,A)}async putPdf(r,t,{parent:n="",orientation:i,cover:o="first",lastTool:s}={}){let a={dummyDocument:!1,extraMetadata:{LastTool:s},fileType:"pdf",pageCount:0,lastOpenedPage:0,lineHeight:-1,margins:125,textScale:1,pages:[],coverPageNumber:o==="first"?0:-1,formatVersion:1,orientation:i};return await this.#l(r,t,"pdf",n,a)}async syncComplete(r){let t=`{ "generation": ${r} }`;await this.#i(`${this.#t}/sync/v2/sync-complete`,{body:t})}async getEntriesMetadata(){let t=await(await this.#i(`${this.#t}/doc/v2/files`,{method:"GET",headers:{"rm-source":"RoR-Browser"}})).text(),n=JSON.parse(t);return V({elements:Jt},n),n}async#u(r,t,n){let o=new TextEncoder().encode(JSON.stringify({file_name:r})),a=await(await this.#i(`${this.#t}/doc/v2/files`,{body:t,headers:{"content-type":n,"rm-meta":(0,De.fromByteArray)(o),"rm-source":"RoR-Browser"}})).text(),f=JSON.parse(a);return V(jt,f),f}async uploadEpub(r,t){return await this.#u(r,t,"application/epub+zip")}async uploadPdf(r,t){return await this.#u(r,t,"application/pdf")}};async function qt(e,{fetch:r=globalThis.fetch,cache:t,subtle:n=globalThis.crypto?.subtle,authHost:i=Ne,syncHost:o=_t}={}){let s=await r(`${i}/token/json/2/user/new`,{method:"POST",headers:{Authorization:`Bearer ${e}`}});if(!s.ok)throw new Error(`couldn't fetch auth token: ${s.statusText}`);let a=await s.text();return new de(a,r,t,n,o)}return Qe(zt);})();
package/dist/index.d.ts CHANGED
@@ -82,21 +82,21 @@ export interface UploadEntry {
82
82
  export interface CommonMetadata {
83
83
  /** name of content */
84
84
  visibleName: string;
85
- /** parent uuid or "" for root or "trash" */
85
+ /** parent uuid (documentId) or "" for root or "trash" */
86
86
  parent?: string;
87
87
  /** last modified time */
88
88
  lastModified: string;
89
- /** unsure */
89
+ /** unknown significance */
90
90
  version?: number;
91
- /** unsure */
91
+ /** unknown significance */
92
92
  pinned?: boolean;
93
- /** unsure */
93
+ /** unknown significance */
94
94
  synced?: boolean;
95
- /** unsure */
95
+ /** unknown significance */
96
96
  modified?: boolean;
97
97
  /** if file is deleted */
98
98
  deleted?: boolean;
99
- /** unsure */
99
+ /** unknown significance */
100
100
  metadatamodified?: boolean;
101
101
  }
102
102
  /** metadata for collection types */
@@ -368,6 +368,23 @@ export interface RemarkableApi {
368
368
  * This is similar to `putBuffer` but will also cache the upload.
369
369
  */
370
370
  putText(documentId: string, contents: string): Promise<FileEntry>;
371
+ /**
372
+ * put metadata into the cloud
373
+ *
374
+ * This is a small wrapper around {@link RemarkableApi.putText | `putText`}.
375
+ *
376
+ * @param documentId - this should be the documentId of the item that this is
377
+ * metadata for; it should not end in `.metadata`
378
+ * @param metadata - the metadata to upload
379
+ */
380
+ putMetadata(documentId: string, metadata: Metadata): Promise<FileEntry>;
381
+ /**
382
+ * create a new collection (folder)
383
+ *
384
+ * @param documentId - the name of the new folder
385
+ * @param parent - the documentId of the parent collection (folder)
386
+ */
387
+ putCollection(visibleName: string, parent?: string): Promise<CollectionEntry>;
371
388
  /**
372
389
  * upload an epub
373
390
  *
package/dist/index.js CHANGED
@@ -490,6 +490,29 @@ class Remarkable {
490
490
  await this.#cache?.set(entry.hash, contents);
491
491
  return entry;
492
492
  }
493
+ /** put metadata into the cloud */
494
+ async putMetadata(documentId, metadata) {
495
+ return await this.putText(`${documentId}.metadata`, JSON.stringify(metadata));
496
+ }
497
+ /** put a new collection (folder) */
498
+ async putCollection(visibleName, parent = "") {
499
+ const documentId = uuid4();
500
+ const lastModified = `${new Date().valueOf()}`;
501
+ const entryPromises = [];
502
+ // upload metadata
503
+ const metadata = {
504
+ type: "CollectionType",
505
+ visibleName,
506
+ version: 0,
507
+ parent,
508
+ synced: true,
509
+ lastModified,
510
+ };
511
+ entryPromises.push(this.putMetadata(documentId, metadata));
512
+ entryPromises.push(this.putText(`${documentId}.content`, "{}"));
513
+ const entries = await Promise.all(entryPromises);
514
+ return await this.putEntries(documentId, entries);
515
+ }
493
516
  /** upload a content file */
494
517
  async #putContent(visibleName, buffer, fileType, parent, content) {
495
518
  /* istanbul ignore if */
@@ -510,7 +533,7 @@ class Remarkable {
510
533
  synced: true,
511
534
  lastModified,
512
535
  };
513
- entryPromises.push(this.putText(`${documentId}.metadata`, JSON.stringify(metadata)));
536
+ entryPromises.push(this.putMetadata(documentId, metadata));
514
537
  entryPromises.push(this.putText(`${documentId}.content`, JSON.stringify(content)));
515
538
  // NOTE we technically get the entries a bit earlier, so could upload this
516
539
  // before all contents are uploaded, but this also saves us from uploading
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rmapi-js",
3
- "version": "2.0.0",
3
+ "version": "2.1.1",
4
4
  "description": "JavaScript implementation of the reMarkable 1.5 api",
5
5
  "repository": "git@github.com:erikbrinkman/rmapi-js.git",
6
6
  "author": "Erik Brinkman <erik.brinkman@gmail.com>",
@@ -95,6 +95,7 @@
95
95
  "node": true
96
96
  },
97
97
  "rules": {
98
+ "@typescript-eslint/no-inferrable-types": "off",
98
99
  "tsdoc/syntax": "error",
99
100
  "no-warning-comments": [
100
101
  "error",