rmapi-js 3.0.1 → 3.1.0
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/CHANGELOG.md +7 -0
- package/bundle/rmapi-js.cjs.min.js +12 -12
- package/bundle/rmapi-js.esm.min.js +12 -12
- package/bundle/rmapi-js.iife.min.js +12 -12
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -0
- package/package.json +26 -26
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [3.1.0] - 2023-12-05
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- `createdTime` to `DocumentType` metadata, and permissive parsing of metadata
|
|
16
|
+
going forward.
|
|
17
|
+
|
|
11
18
|
## [3.0.0] - 2023-01-03
|
|
12
19
|
|
|
13
20
|
### Added
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`,r:"\r",t:" "},
|
|
3
|
-
`+
|
|
4
|
-
`+
|
|
5
|
-
`+a+"]":"["+f.join(",")+"]",
|
|
6
|
-
`+
|
|
7
|
-
`+
|
|
8
|
-
`+a+"}":"{"+f.join(",")+"}",E=a,i;default:}}Me.exports=function(e,t,r){var n;if(E="",X="",typeof r=="number")for(n=0;n<r;n+=1)X+=" ";else typeof r=="string"&&(X=r);if(I=t,t&&typeof t!="function"&&(typeof t!="object"||typeof t.length!="number"))throw new Error("JSON.stringify");return ee("",{"":e})}});var je=S(de=>{"use strict";de.parse=Fe();de.stringify=Ce()});var Ie=S((or,Be)=>{"use strict";var te=typeof JSON<"u"?JSON:je(),Ot=Array.isArray||function(e){return{}.toString.call(e)==="[object Array]"},St=Object.keys||function(e){var t=Object.prototype.hasOwnProperty||function(){return!0},r=[];for(var n in e)t.call(e,n)&&r.push(n);return r};Be.exports=function(e,t){t||(t={}),typeof t=="function"&&(t={cmp:t});var r=t.space||"";typeof r=="number"&&(r=Array(r+1).join(" "));var n=typeof t.cycles=="boolean"?t.cycles:!1,i=t.replacer||function(f,s){return s},o=t.cmp&&function(f){return function(s){return function(p,u){var g={key:p,value:s[p]},x={key:u,value:s[u]};return f(g,x)}}}(t.cmp),a=[];return function f(s,p,u,g){var x=r?`
|
|
9
|
-
`+new Array(g+1).join(r):"",F=r?": ":":";if(u&&u.toJSON&&typeof u.toJSON=="function"&&(u=u.toJSON()),u=i.call(s,p,u),u!==void 0){if(typeof u!="object"||u===null)return te.stringify(u);if(Ot(u)){for(var A=[],y=0;y<u.length;y++){var J=f(u,y,u[y],g+1)||te.stringify(null);A.push(x+r+J)}return"["+A.join(",")+x+"]"}if(a.indexOf(u)!==-1){if(n)return te.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}else a.push(u);for(var P=St(u).sort(o&&o(u)),A=[],y=0;y<P.length;y++){var p=P[y],m=f(u,p,u[p],g+1);if(m){var Y=te.stringify(p)+F+m;A.push(x+r+Y)}}return a.splice(a.indexOf(u),1),"{"+A.join(",")+x+"}"}}({"":e},"",e,0)}});var be=S(d=>{"use strict";var De=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 Ft(e){let{definitions:t,nullable:r,metadata:n}=e,i=De(e,["definitions","nullable","metadata"]);return Object.keys(i).length===0}d.isEmptyForm=Ft;function He(e){return"ref"in e}d.isRefForm=He;function Mt(e){return"type"in e}d.isTypeForm=Mt;function Ue(e){return"enum"in e}d.isEnumForm=Ue;function Je(e){return"elements"in e}d.isElementsForm=Je;function ge(e){return"properties"in e||"optionalProperties"in e}d.isPropertiesForm=ge;function qe(e){return"values"in e}d.isValuesForm=qe;function ze(e){return"discriminator"in e}d.isDiscriminatorForm=ze;function R(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(!R(r,t))return!1}if(He(e)&&!(e.ref in(t.definitions||{}))||Ue(e)&&(e.enum.length===0||e.enum.length!==new Set(e.enum).size))return!1;if(Je(e))return R(e.elements,t);if(ge(e)){for(let r of Object.values(e.properties||{}))if(!R(r,t))return!1;for(let r of Object.values(e.optionalProperties||{}))if(!R(r,t))return!1;for(let r of Object.keys(e.properties||{}))if(r in(e.optionalProperties||{}))return!1}if(qe(e))return R(e.values,t);if(ze(e)){for(let r of Object.values(e.mapping))if(!R(r,t)||!ge(r)||r.nullable||e.discriminator in(r.properties||{})||e.discriminator in(r.optionalProperties||{}))return!1}return!0}d.isValidSchema=R;var Ct=[[!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]],jt=["boolean","float32","float64","int8","uint8","int16","uint16","int32","uint32","string","timestamp"];function _(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:o=void 0,type:a=void 0,enum:f=void 0,elements:s=void 0,properties:p=void 0,optionalProperties:u=void 0,additionalProperties:g=void 0,values:x=void 0,discriminator:F=void 0,mapping:y=void 0}=t,J=De(t,["definitions","nullable","metadata","ref","type","enum","elements","properties","optionalProperties","additionalProperties","values","discriminator","mapping"]),P=[o!==void 0,a!==void 0,f!==void 0,s!==void 0,p!==void 0,u!==void 0,g!==void 0,x!==void 0,F!==void 0,y!==void 0],A=!1;for(let m of Ct)A=A||m.every((Y,q)=>Y===P[q]);if(!A)return!1;if(r!==void 0){if(typeof r!="object"||Array.isArray(r)||r===null)return!1;for(let m of Object.values(r))if(!_(m))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"||a!==void 0&&(typeof a!="string"||!jt.includes(a))||f!==void 0&&(!Array.isArray(f)||!f.every(m=>typeof m=="string"))||s!==void 0&&!_(s))return!1;if(p!==void 0){if(typeof p!="object"||Array.isArray(p)||p===null)return!1;for(let m of Object.values(p))if(!_(m))return!1}if(u!==void 0){if(typeof u!="object"||Array.isArray(u)||u===null)return!1;for(let m of Object.values(u))if(!_(m))return!1}if(g!==void 0&&typeof g!="boolean"||x!==void 0&&!_(x)||F!==void 0&&typeof F!="string")return!1;if(y!==void 0){if(typeof y!="object"||Array.isArray(y)||y===null)return!1;for(let m of Object.values(y))if(!_(m))return!1}return Object.keys(J).length===0}d.isSchema=_});var Ge=S(ve=>{"use strict";Object.defineProperty(ve,"__esModule",{value:!0});var Bt=/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(\.\d+)?([zZ]|((\+|-)(\d{2}):(\d{2})))$/;function It(e){let t=e.match(Bt);if(t===null)return!1;let r=parseInt(t[1],10),n=parseInt(t[2],10),i=parseInt(t[3],10),o=parseInt(t[4],10),a=parseInt(t[5],10),f=parseInt(t[6],10);return!(n>12||i>Rt(r,n)||o>23||a>59||f>60)}ve.default=It;function Rt(e,t){return t===2?_t(e)?29:28:Nt[t]}function _t(e){return e%4===0&&(e%100!==0||e%400===0)}var Nt=[0,31,0,31,30,31,30,31,31,30,31,30,31]});var Ve=S(C=>{"use strict";var $t=C&&C.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(C,"__esModule",{value:!0});C.validate=C.MaxDepthExceededError=void 0;var Lt=$t(Ge()),N=be(),ie=class extends Error{};C.MaxDepthExceededError=ie;var oe=class extends Error{};function Dt(e,t,r){let n={errors:[],instanceTokens:[],schemaTokens:[[]],root:e,config:r||{maxDepth:0,maxErrors:0}};try{D(n,e,t)}catch(i){if(!(i instanceof oe))throw i}return n.errors}C.validate=Dt;function D(e,t,r,n){if(!(t.nullable&&r===null)){if(N.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(N.isTypeForm(t)){switch(b(e,"type"),t.type){case"boolean":typeof r!="boolean"&&v(e);break;case"float32":case"float64":typeof r!="number"&&v(e);break;case"int8":U(e,r,-128,127);break;case"uint8":U(e,r,0,255);break;case"int16":U(e,r,-32768,32767);break;case"uint16":U(e,r,0,65535);break;case"int32":U(e,r,-2147483648,2147483647);break;case"uint32":U(e,r,0,4294967295);break;case"string":typeof r!="string"&&v(e);break;case"timestamp":typeof r!="string"?v(e):Lt.default(r)||v(e);break}w(e)}else if(N.isEnumForm(t))b(e,"enum"),(typeof r!="string"||!t.enum.includes(r))&&v(e),w(e);else if(N.isElementsForm(t)){if(b(e,"elements"),Array.isArray(r))for(let[i,o]of r.entries())$(e,i.toString()),D(e,t.elements,o),L(e);else v(e);w(e)}else if(N.isPropertiesForm(t))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){if(t.properties!==void 0){b(e,"properties");for(let[i,o]of Object.entries(t.properties))b(e,i),r.hasOwnProperty(i)?($(e,i),D(e,o,r[i]),L(e)):v(e),w(e);w(e)}if(t.optionalProperties!==void 0){b(e,"optionalProperties");for(let[i,o]of Object.entries(t.optionalProperties))b(e,i),r.hasOwnProperty(i)&&($(e,i),D(e,o,r[i]),L(e)),w(e);w(e)}if(t.additionalProperties!==!0)for(let i of Object.keys(r)){let o=t.properties&&i in t.properties,a=t.optionalProperties&&i in t.optionalProperties;!o&&!a&&i!==n&&($(e,i),v(e),L(e))}}else t.properties!==void 0?b(e,"properties"):b(e,"optionalProperties"),v(e),w(e);else if(N.isValuesForm(t)){if(b(e,"values"),typeof r=="object"&&r!==null&&!Array.isArray(r))for(let[i,o]of Object.entries(r))$(e,i),D(e,t.values,o),L(e);else v(e);w(e)}else if(N.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?(b(e,"mapping"),b(e,i),D(e,t.mapping[i],r,t.discriminator),w(e),w(e)):(b(e,"mapping"),$(e,t.discriminator),v(e),L(e),w(e)):(b(e,"discriminator"),$(e,t.discriminator),v(e),L(e),w(e))}else b(e,"discriminator"),v(e),w(e);else b(e,"discriminator"),v(e),w(e)}}function U(e,t,r,n){(typeof t!="number"||!Number.isInteger(t)||t<r||t>n)&&v(e)}function $(e,t){e.instanceTokens.push(t)}function L(e){e.instanceTokens.pop()}function b(e,t){e.schemaTokens[e.schemaTokens.length-1].push(t)}function w(e){e.schemaTokens[e.schemaTokens.length-1].pop()}function v(e){if(e.errors.push({instancePath:[...e.instanceTokens],schemaPath:[...e.schemaTokens[e.schemaTokens.length-1]]}),e.errors.length===e.config.maxErrors)throw new oe}});var Ze=S(j=>{"use strict";var Ht=j&&j.__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]}),Ye=j&&j.__exportStar||function(e,t){for(var r in e)r!=="default"&&!t.hasOwnProperty(r)&&Ht(t,e,r)};Object.defineProperty(j,"__esModule",{value:!0});Ye(be(),j);Ye(Ve(),j)});var Xt={};dt(Xt,{GenerationError:()=>fe,ResponseError:()=>H,builtinFontNames:()=>Gt,builtinLineHeights:()=>ot,builtinMargins:()=>it,builtinTextScales:()=>nt,builtinTools:()=>zt,formatEntry:()=>st,parseEntry:()=>at,register:()=>Wt,remarkable:()=>Qt});module.exports=yt(Xt);var et=z(Te()),tt=z(Ie());var Re=z(require("crypto")),ne=new Uint8Array(256),re=ne.length;function ye(){return re>ne.length-16&&(Re.default.randomFillSync(ne),re=0),ne.slice(re,re+=16)}var h=[];for(let e=0;e<256;++e)h.push((e+256).toString(16).slice(1));function _e(e,t=0){return(h[e[t+0]]+h[e[t+1]]+h[e[t+2]]+h[e[t+3]]+"-"+h[e[t+4]]+h[e[t+5]]+"-"+h[e[t+6]]+h[e[t+7]]+"-"+h[e[t+8]]+h[e[t+9]]+"-"+h[e[t+10]]+h[e[t+11]]+h[e[t+12]]+h[e[t+13]]+h[e[t+14]]+h[e[t+15]]).toLowerCase()}var Ne=z(require("crypto")),me={randomUUID:Ne.default.randomUUID};function kt(e,t,r){if(me.randomUUID&&!t&&!e)return me.randomUUID();e=e||{};let n=e.random||(e.rng||ye)();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 _e(n)}var G=kt;function he(e){return[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join("")}function $e(e){return new Uint8Array((e.match(/../g)??[]).map(t=>parseInt(t,16)))}function Le(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 Ke=z(Ze());function V(e,t){if((0,Ke.validate)(e,t).length)throw new Error(`couldn't validate schema: ${JSON.stringify(t)} didn't match schema ${JSON.stringify(e)}`)}var We="3",rt="https://webapp-prod.cloud.remarkable.engineering",Ut="https://internal.cloud.remarkable.com",Qe="x-goog-generation",Jt="x-goog-if-generation-match",qt="x-goog-content-length-range",zt=["Ballpoint","Ballpointv2","Brush","Calligraphy","ClearPage","EraseSection","Eraser","Fineliner","Finelinerv2","Highlighter","Highlighterv2","Marker","Markerv2","Paintbrush","Paintbrushv2","Pencilv2","SharpPencil","SharpPencilv2","SolidPen","ZoomTool"],Gt=["Maison Neue","EB Garamond","Noto Sans","Noto Serif","Noto Mono","Noto Sans UI"],nt={xs:.7,sm:.8,md:1,lg:1.2,xl:1.5,xx:2},it={sm:50,md:125,rr:180,lg:200},ot={df:-1,md:100,lg:150,xl:200},Vt={properties:{docID:{type:"string"},hash:{type:"string"}}},Yt={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"}},ae={version:{type:"int32"},pinned:{type:"boolean"},synced:{type:"boolean"},modified:{type:"boolean"},deleted:{type:"boolean"},metadatamodified:{type:"boolean"},parent:{type:"string"}},Zt={discriminator:"type",mapping:{CollectionType:{properties:se,optionalProperties:ae},DocumentType:{properties:se,optionalProperties:{...ae,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"}}}}},Xe={id:{type:"string"},hash:{type:"string"}},Kt={discriminator:"type",mapping:{CollectionType:{properties:{...se,...Xe},optionalProperties:ae},DocumentType:{properties:{...se,...Xe,fileType:{enum:["notebook","epub","pdf",""]}},optionalProperties:{...ae,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"}}}}},H=class extends Error{status;statusText;constructor(t,r,n){super(n),this.status=t,this.statusText=r}},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 Wt(e,{deviceDesc:t="browser-chrome",uuid:r=G(),authHost:n=rt,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:t,deviceID:r})});if(o.ok)return await o.text();throw new H(o.status,o.statusText,"couldn't register api")}function st({hash:e,type:t,documentId:r,subfiles:n,size:i}){return`${e}:${t}:${r}:${n}:${i}
|
|
10
|
-
`}function
|
|
11
|
-
`);if(n!==
|
|
12
|
-
${f}`,
|
|
1
|
+
"use strict";var Jr=Object.create;var pe=Object.defineProperty;var Gr=Object.getOwnPropertyDescriptor;var qr=Object.getOwnPropertyNames;var zr=Object.getPrototypeOf,Vr=Object.prototype.hasOwnProperty;var m=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Wr=(t,e)=>{for(var r in e)pe(t,r,{get:e[r],enumerable:!0})},rt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of qr(e))!Vr.call(t,o)&&o!==r&&pe(t,o,{get:()=>e[o],enumerable:!(n=Gr(e,o))||n.enumerable});return t};var ne=(t,e,r)=>(r=t!=null?Jr(zr(t)):{},rt(e||!t||!t.__esModule?pe(r,"default",{value:t,enumerable:!0}):r,t)),Yr=t=>rt(pe({},"__esModule",{value:!0}),t);var it=m(ce=>{"use strict";ce.byteLength=Xr;ce.toByteArray=Qr;ce.fromByteArray=rn;var I=[],F=[],Kr=typeof Uint8Array<"u"?Uint8Array:Array,$e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(N=0,nt=$e.length;N<nt;++N)I[N]=$e[N],F[$e.charCodeAt(N)]=N;var N,nt;F[45]=62;F[95]=63;function ot(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function Xr(t){var e=ot(t),r=e[0],n=e[1];return(r+n)*3/4-n}function Zr(t,e,r){return(e+r)*3/4-r}function Qr(t){var e,r=ot(t),n=r[0],o=r[1],i=new Kr(Zr(t,n,o)),a=0,f=o>0?n-4:n,s;for(s=0;s<f;s+=4)e=F[t.charCodeAt(s)]<<18|F[t.charCodeAt(s+1)]<<12|F[t.charCodeAt(s+2)]<<6|F[t.charCodeAt(s+3)],i[a++]=e>>16&255,i[a++]=e>>8&255,i[a++]=e&255;return o===2&&(e=F[t.charCodeAt(s)]<<2|F[t.charCodeAt(s+1)]>>4,i[a++]=e&255),o===1&&(e=F[t.charCodeAt(s)]<<10|F[t.charCodeAt(s+1)]<<4|F[t.charCodeAt(s+2)]>>2,i[a++]=e>>8&255,i[a++]=e&255),i}function en(t){return I[t>>18&63]+I[t>>12&63]+I[t>>6&63]+I[t&63]}function tn(t,e,r){for(var n,o=[],i=e;i<r;i+=3)n=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(t[i+2]&255),o.push(en(n));return o.join("")}function rn(t){for(var e,r=t.length,n=r%3,o=[],i=16383,a=0,f=r-n;a<f;a+=i)o.push(tn(t,a,a+i>f?f:a+i));return n===1?(e=t[r-1],o.push(I[e>>2]+I[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],o.push(I[e>>10]+I[e>>4&63]+I[e<<2&63]+"=")),o.join("")}});var lt=m((xo,ut)=>{"use strict";var ye,l,at={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
|
|
2
|
+
`,r:"\r",t:" "},Me;function R(t){throw{name:"SyntaxError",message:t,at:ye,text:Me}}function d(t){return t&&t!==l&&R("Expected '"+t+"' instead of '"+l+"'"),l=Me.charAt(ye),ye+=1,l}function st(){var t,e="";for(l==="-"&&(e="-",d("-"));l>="0"&&l<="9";)e+=l,d();if(l===".")for(e+=".";d()&&l>="0"&&l<="9";)e+=l;if(l==="e"||l==="E")for(e+=l,d(),(l==="-"||l==="+")&&(e+=l,d());l>="0"&&l<="9";)e+=l,d();return t=Number(e),isFinite(t)||R("Bad number"),t}function ft(){var t,e,r="",n;if(l==='"')for(;d();){if(l==='"')return d(),r;if(l==="\\")if(d(),l==="u"){for(n=0,e=0;e<4&&(t=parseInt(d(),16),!!isFinite(t));e+=1)n=n*16+t;r+=String.fromCharCode(n)}else if(typeof at[l]=="string")r+=at[l];else break;else r+=l}R("Bad string")}function $(){for(;l&&l<=" ";)d()}function nn(){switch(l){case"t":return d("t"),d("r"),d("u"),d("e"),!0;case"f":return d("f"),d("a"),d("l"),d("s"),d("e"),!1;case"n":return d("n"),d("u"),d("l"),d("l"),null;default:R("Unexpected '"+l+"'")}}function on(){var t=[];if(l==="["){if(d("["),$(),l==="]")return d("]"),t;for(;l;){if(t.push(de()),$(),l==="]")return d("]"),t;d(","),$()}}R("Bad array")}function an(){var t,e={};if(l==="{"){if(d("{"),$(),l==="}")return d("}"),e;for(;l;){if(t=ft(),$(),d(":"),Object.prototype.hasOwnProperty.call(e,t)&&R('Duplicate key "'+t+'"'),e[t]=de(),$(),l==="}")return d("}"),e;d(","),$()}}R("Bad object")}function de(){switch($(),l){case"{":return an();case"[":return on();case'"':return ft();case"-":return st();default:return l>="0"&&l<="9"?st():nn()}}ut.exports=function(t,e){var r;return Me=t,ye=0,l=" ",r=de(),$(),l&&R("Syntax error"),typeof e=="function"?function n(o,i){var a,f,s=o[i];if(s&&typeof s=="object")for(a in de)Object.prototype.hasOwnProperty.call(s,a)&&(f=n(s,a),typeof f>"u"?delete s[a]:s[a]=f);return e.call(o,i,s)}({"":r},""):r}});var ct=m((Ao,pt)=>{"use strict";var Re=/[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,T,ge,sn={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},U;function Be(t){return Re.lastIndex=0,Re.test(t)?'"'+t.replace(Re,function(e){var r=sn[e];return typeof r=="string"?r:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+t+'"'}function me(t,e){var r,n,o,i,a=T,f,s=e[t];switch(s&&typeof s=="object"&&typeof s.toJSON=="function"&&(s=s.toJSON(t)),typeof U=="function"&&(s=U.call(e,t,s)),typeof s){case"string":return Be(s);case"number":return isFinite(s)?String(s):"null";case"boolean":case"null":return String(s);case"object":if(!s)return"null";if(T+=ge,f=[],Object.prototype.toString.apply(s)==="[object Array]"){for(i=s.length,r=0;r<i;r+=1)f[r]=me(r,s)||"null";return o=f.length===0?"[]":T?`[
|
|
3
|
+
`+T+f.join(`,
|
|
4
|
+
`+T)+`
|
|
5
|
+
`+a+"]":"["+f.join(",")+"]",T=a,o}if(U&&typeof U=="object")for(i=U.length,r=0;r<i;r+=1)n=U[r],typeof n=="string"&&(o=me(n,s),o&&f.push(Be(n)+(T?": ":":")+o));else for(n in s)Object.prototype.hasOwnProperty.call(s,n)&&(o=me(n,s),o&&f.push(Be(n)+(T?": ":":")+o));return o=f.length===0?"{}":T?`{
|
|
6
|
+
`+T+f.join(`,
|
|
7
|
+
`+T)+`
|
|
8
|
+
`+a+"}":"{"+f.join(",")+"}",T=a,o;default:}}pt.exports=function(t,e,r){var n;if(T="",ge="",typeof r=="number")for(n=0;n<r;n+=1)ge+=" ";else typeof r=="string"&&(ge=r);if(U=e,e&&typeof e!="function"&&(typeof e!="object"||typeof e.length!="number"))throw new Error("JSON.stringify");return me("",{"":t})}});var yt=m(Ce=>{"use strict";Ce.parse=lt();Ce.stringify=ct()});var gt=m((So,dt)=>{var fn={}.toString;dt.exports=Array.isArray||function(t){return fn.call(t)=="[object Array]"}});var _e=m((Oo,ht)=>{"use strict";var mt=Object.prototype.toString;ht.exports=function(e){var r=mt.call(e),n=r==="[object Arguments]";return n||(n=r!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&mt.call(e.callee)==="[object Function]"),n}});var Ot=m((To,St)=>{"use strict";var Et;Object.keys||(oe=Object.prototype.hasOwnProperty,Ne=Object.prototype.toString,vt=_e(),Ue=Object.prototype.propertyIsEnumerable,bt=!Ue.call({toString:null},"toString"),wt=Ue.call(function(){},"prototype"),ie=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],he=function(t){var e=t.constructor;return e&&e.prototype===t},Pt={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},xt=function(){if(typeof window>"u")return!1;for(var t in window)try{if(!Pt["$"+t]&&oe.call(window,t)&&window[t]!==null&&typeof window[t]=="object")try{he(window[t])}catch{return!0}}catch{return!0}return!1}(),At=function(t){if(typeof window>"u"||!xt)return he(t);try{return he(t)}catch{return!1}},Et=function(e){var r=e!==null&&typeof e=="object",n=Ne.call(e)==="[object Function]",o=vt(e),i=r&&Ne.call(e)==="[object String]",a=[];if(!r&&!n&&!o)throw new TypeError("Object.keys called on a non-object");var f=wt&&n;if(i&&e.length>0&&!oe.call(e,0))for(var s=0;s<e.length;++s)a.push(String(s));if(o&&e.length>0)for(var y=0;y<e.length;++y)a.push(String(y));else for(var p in e)!(f&&p==="prototype")&&oe.call(e,p)&&a.push(String(p));if(bt)for(var g=At(e),u=0;u<ie.length;++u)!(g&&ie[u]==="constructor")&&oe.call(e,ie[u])&&a.push(ie[u]);return a});var oe,Ne,vt,Ue,bt,wt,ie,he,Pt,xt,At;St.exports=Et});var It=m((Fo,kt)=>{"use strict";var un=Array.prototype.slice,ln=_e(),Tt=Object.keys,ve=Tt?function(e){return Tt(e)}:Ot(),Ft=Object.keys;ve.shim=function(){if(Object.keys){var e=function(){var r=Object.keys(arguments);return r&&r.length===arguments.length}(1,2);e||(Object.keys=function(n){return ln(n)?Ft(un.call(n)):Ft(n)})}else Object.keys=ve;return Object.keys||ve};kt.exports=ve});var Mt=m((ko,$t)=>{"use strict";var pn="Function.prototype.bind called on incompatible ",cn=Object.prototype.toString,yn=Math.max,dn="[object Function]",jt=function(e,r){for(var n=[],o=0;o<e.length;o+=1)n[o]=e[o];for(var i=0;i<r.length;i+=1)n[i+e.length]=r[i];return n},gn=function(e,r){for(var n=[],o=r||0,i=0;o<e.length;o+=1,i+=1)n[i]=e[o];return n},mn=function(t,e){for(var r="",n=0;n<t.length;n+=1)r+=t[n],n+1<t.length&&(r+=e);return r};$t.exports=function(e){var r=this;if(typeof r!="function"||cn.apply(r)!==dn)throw new TypeError(pn+r);for(var n=gn(arguments,1),o,i=function(){if(this instanceof o){var p=r.apply(this,jt(n,arguments));return Object(p)===p?p:this}return r.apply(e,jt(n,arguments))},a=yn(0,r.length-n.length),f=[],s=0;s<a;s++)f[s]="$"+s;if(o=Function("binder","return function ("+mn(f,",")+"){ return binder.apply(this,arguments); }")(i),r.prototype){var y=function(){};y.prototype=r.prototype,o.prototype=new y,y.prototype=null}return o}});var be=m((Io,Rt)=>{"use strict";var hn=Mt();Rt.exports=Function.prototype.bind||hn});var Ct=m((jo,Bt)=>{"use strict";Bt.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var o=42;e[r]=o;for(r in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var i=Object.getOwnPropertySymbols(e);if(i.length!==1||i[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,r);if(a.value!==o||a.enumerable!==!0)return!1}return!0}});var Ut=m(($o,Nt)=>{"use strict";var _t=typeof Symbol<"u"&&Symbol,vn=Ct();Nt.exports=function(){return typeof _t!="function"||typeof Symbol!="function"||typeof _t("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:vn()}});var Ht=m((Mo,Lt)=>{"use strict";var Dt={foo:{}},bn=Object;Lt.exports=function(){return{__proto__:Dt}.foo===Dt.foo&&!({__proto__:null}instanceof bn)}});var Gt=m((Ro,Jt)=>{"use strict";var wn=Function.prototype.call,Pn=Object.prototype.hasOwnProperty,xn=be();Jt.exports=xn.call(wn,Pn)});var Q=m((Bo,Yt)=>{"use strict";var c,Z=SyntaxError,Wt=Function,X=TypeError,De=function(t){try{return Wt('"use strict"; return ('+t+").constructor;")()}catch{}},D=Object.getOwnPropertyDescriptor;if(D)try{D({},"")}catch{D=null}var Le=function(){throw new X},An=D?function(){try{return arguments.callee,Le}catch{try{return D(arguments,"callee").get}catch{return Le}}}():Le,Y=Ut()(),En=Ht()(),w=Object.getPrototypeOf||(En?function(t){return t.__proto__}:null),K={},Sn=typeof Uint8Array>"u"||!w?c:w(Uint8Array),L={"%AggregateError%":typeof AggregateError>"u"?c:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?c:ArrayBuffer,"%ArrayIteratorPrototype%":Y&&w?w([][Symbol.iterator]()):c,"%AsyncFromSyncIteratorPrototype%":c,"%AsyncFunction%":K,"%AsyncGenerator%":K,"%AsyncGeneratorFunction%":K,"%AsyncIteratorPrototype%":K,"%Atomics%":typeof Atomics>"u"?c:Atomics,"%BigInt%":typeof BigInt>"u"?c:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?c:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?c:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?c:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?c:Float32Array,"%Float64Array%":typeof Float64Array>"u"?c:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?c:FinalizationRegistry,"%Function%":Wt,"%GeneratorFunction%":K,"%Int8Array%":typeof Int8Array>"u"?c:Int8Array,"%Int16Array%":typeof Int16Array>"u"?c:Int16Array,"%Int32Array%":typeof Int32Array>"u"?c:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Y&&w?w(w([][Symbol.iterator]())):c,"%JSON%":typeof JSON=="object"?JSON:c,"%Map%":typeof Map>"u"?c:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Y||!w?c:w(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?c:Promise,"%Proxy%":typeof Proxy>"u"?c:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?c:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?c:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Y||!w?c:w(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?c:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Y&&w?w(""[Symbol.iterator]()):c,"%Symbol%":Y?Symbol:c,"%SyntaxError%":Z,"%ThrowTypeError%":An,"%TypedArray%":Sn,"%TypeError%":X,"%Uint8Array%":typeof Uint8Array>"u"?c:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?c:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?c:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?c:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?c:WeakMap,"%WeakRef%":typeof WeakRef>"u"?c:WeakRef,"%WeakSet%":typeof WeakSet>"u"?c:WeakSet};if(w)try{null.error}catch(t){qt=w(w(t)),L["%Error.prototype%"]=qt}var qt,On=function t(e){var r;if(e==="%AsyncFunction%")r=De("async function () {}");else if(e==="%GeneratorFunction%")r=De("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=De("async function* () {}");else if(e==="%AsyncGenerator%"){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var o=t("%AsyncGenerator%");o&&w&&(r=w(o.prototype))}return L[e]=r,r},zt={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ae=be(),we=Gt(),Tn=ae.call(Function.call,Array.prototype.concat),Fn=ae.call(Function.apply,Array.prototype.splice),Vt=ae.call(Function.call,String.prototype.replace),Pe=ae.call(Function.call,String.prototype.slice),kn=ae.call(Function.call,RegExp.prototype.exec),In=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,jn=/\\(\\)?/g,$n=function(e){var r=Pe(e,0,1),n=Pe(e,-1);if(r==="%"&&n!=="%")throw new Z("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new Z("invalid intrinsic syntax, expected opening `%`");var o=[];return Vt(e,In,function(i,a,f,s){o[o.length]=f?Vt(s,jn,"$1"):a||i}),o},Mn=function(e,r){var n=e,o;if(we(zt,n)&&(o=zt[n],n="%"+o[0]+"%"),we(L,n)){var i=L[n];if(i===K&&(i=On(n)),typeof i>"u"&&!r)throw new X("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:o,name:n,value:i}}throw new Z("intrinsic "+e+" does not exist!")};Yt.exports=function(e,r){if(typeof e!="string"||e.length===0)throw new X("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new X('"allowMissing" argument must be a boolean');if(kn(/^%?[^%]*%?$/,e)===null)throw new Z("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=$n(e),o=n.length>0?n[0]:"",i=Mn("%"+o+"%",r),a=i.name,f=i.value,s=!1,y=i.alias;y&&(o=y[0],Fn(n,Tn([0,1],y)));for(var p=1,g=!0;p<n.length;p+=1){var u=n[p],S=Pe(u,0,1),b=Pe(u,-1);if((S==='"'||S==="'"||S==="`"||b==='"'||b==="'"||b==="`")&&S!==b)throw new Z("property names with quotes must have matching quotes");if((u==="constructor"||!g)&&(s=!0),o+="."+u,a="%"+o+"%",we(L,a))f=L[a];else if(f!=null){if(!(u in f)){if(!r)throw new X("base intrinsic for "+e+" exists, but the property is not available.");return}if(D&&p+1>=n.length){var k=D(f,u);g=!!k,g&&"get"in k&&!("originalValue"in k.get)?f=k.get:f=f[u]}else g=we(f,u),f=f[u];g&&!s&&(L[a]=f)}}return f}});var Ge=m((Co,Kt)=>{"use strict";var Rn=Q(),He=Rn("%Object.defineProperty%",!0),Je=function(){if(He)try{return He({},"a",{value:1}),!0}catch{return!1}return!1};Je.hasArrayLengthDefineBug=function(){if(!Je())return null;try{return He([],"length",{value:1}).length!==1}catch{return!0}};Kt.exports=Je});var qe=m((_o,Xt)=>{"use strict";var Bn=Q(),xe=Bn("%Object.getOwnPropertyDescriptor%",!0);if(xe)try{xe([],"length")}catch{xe=null}Xt.exports=xe});var er=m((No,Qt)=>{"use strict";var Cn=Ge()(),ze=Q(),se=Cn&&ze("%Object.defineProperty%",!0);if(se)try{se({},"a",{value:1})}catch{se=!1}var _n=ze("%SyntaxError%"),ee=ze("%TypeError%"),Zt=qe();Qt.exports=function(e,r,n){if(!e||typeof e!="object"&&typeof e!="function")throw new ee("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new ee("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new ee("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new ee("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new ee("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new ee("`loose`, if provided, must be a boolean");var o=arguments.length>3?arguments[3]:null,i=arguments.length>4?arguments[4]:null,a=arguments.length>5?arguments[5]:null,f=arguments.length>6?arguments[6]:!1,s=!!Zt&&Zt(e,r);if(se)se(e,r,{configurable:a===null&&s?s.configurable:!a,enumerable:o===null&&s?s.enumerable:!o,value:n,writable:i===null&&s?s.writable:!i});else if(f||!o&&!i&&!a)e[r]=n;else throw new _n("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")}});var ar=m((Uo,ir)=>{"use strict";var or=Q(),tr=er(),Nn=Ge()(),rr=qe(),nr=or("%TypeError%"),Un=or("%Math.floor%");ir.exports=function(e,r){if(typeof e!="function")throw new nr("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||Un(r)!==r)throw new nr("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],o=!0,i=!0;if("length"in e&&rr){var a=rr(e,"length");a&&!a.configurable&&(o=!1),a&&!a.writable&&(i=!1)}return(o||i||!n)&&(Nn?tr(e,"length",r,!0,!0):tr(e,"length",r)),e}});var pr=m((Do,Ae)=>{"use strict";var Ve=be(),te=Q(),Dn=ar(),Ln=te("%TypeError%"),fr=te("%Function.prototype.apply%"),ur=te("%Function.prototype.call%"),lr=te("%Reflect.apply%",!0)||Ve.call(ur,fr),fe=te("%Object.defineProperty%",!0),Hn=te("%Math.max%");if(fe)try{fe({},"a",{value:1})}catch{fe=null}Ae.exports=function(e){if(typeof e!="function")throw new Ln("a function is required");var r=lr(Ve,ur,arguments);return Dn(r,1+Hn(0,e.length-(arguments.length-1)),!0)};var sr=function(){return lr(Ve,fr,arguments)};fe?fe(Ae.exports,"apply",{value:sr}):Ae.exports.apply=sr});var dr=m((Lo,yr)=>{"use strict";var Ee=(typeof JSON<"u"?JSON:yt()).stringify,Jn=gt(),Gn=It(),qn=pr(),cr=function(e,r){for(var n="",o=0;o<e;o+=1)n+=r;return n},zn=function(t,e,r){return r};yr.exports=function(e){var r=arguments.length>1?arguments[1]:void 0,n=r&&r.space||"";typeof n=="number"&&(n=cr(n," "));var o=!!r&&typeof r.cycles=="boolean"&&r.cycles,i=r&&r.replacer?qn(r.replacer):zn,a=typeof r=="function"?r:r&&r.cmp,f=a&&function(y){var p=a.length>2&&function(u){return y[u]};return function(g,u){return a({key:g,value:y[g]},{key:u,value:y[u]},p?{__proto__:null,get:p}:void 0)}},s=[];return function y(p,g,u,S){var b=n?`
|
|
9
|
+
`+cr(S,n):"",k=n?": ":":";if(u&&u.toJSON&&typeof u.toJSON=="function"&&(u=u.toJSON()),u=i(p,g,u),u!==void 0){if(typeof u!="object"||u===null)return Ee(u);if(Jn(u)){for(var j="",v=0;v<u.length;v++){var _=y(u,v,u[v],S+1)||Ee(null);j+=b+n+_,v+1<u.length&&(j+=",")}return"["+j+b+"]"}if(s.indexOf(u)!==-1){if(o)return Ee("__cycle__");throw new TypeError("Converting circular structure to JSON")}else s.push(u);for(var P=Gn(u).sort(f&&f(u)),j="",M=!1,v=0;v<P.length;v++){var g=P[v],tt=y(u,g,u[g],S+1);if(tt){var Hr=Ee(g)+k+tt;j+=(M?",":"")+b+n+Hr,M=!0}}return s.splice(s.indexOf(u),1),"{"+j+b+"}"}}({"":e},"",e,0)}});var Ze=m(h=>{"use strict";var wr=h&&h.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]]);return r};Object.defineProperty(h,"__esModule",{value:!0});h.isSchema=h.isValidSchema=h.isDiscriminatorForm=h.isValuesForm=h.isPropertiesForm=h.isElementsForm=h.isEnumForm=h.isTypeForm=h.isRefForm=h.isEmptyForm=void 0;function Wn(t){let{definitions:e,nullable:r,metadata:n}=t,o=wr(t,["definitions","nullable","metadata"]);return Object.keys(o).length===0}h.isEmptyForm=Wn;function Pr(t){return"ref"in t}h.isRefForm=Pr;function Yn(t){return"type"in t}h.isTypeForm=Yn;function xr(t){return"enum"in t}h.isEnumForm=xr;function Ar(t){return"elements"in t}h.isElementsForm=Ar;function Xe(t){return"properties"in t||"optionalProperties"in t}h.isPropertiesForm=Xe;function Er(t){return"values"in t}h.isValuesForm=Er;function Sr(t){return"discriminator"in t}h.isDiscriminatorForm=Sr;function H(t,e){if(e===void 0&&(e=t),t.definitions!==void 0){if(e!==t)return!1;for(let r of Object.values(t.definitions))if(!H(r,e))return!1}if(Pr(t)&&!(t.ref in(e.definitions||{}))||xr(t)&&(t.enum.length===0||t.enum.length!==new Set(t.enum).size))return!1;if(Ar(t))return H(t.elements,e);if(Xe(t)){for(let r of Object.values(t.properties||{}))if(!H(r,e))return!1;for(let r of Object.values(t.optionalProperties||{}))if(!H(r,e))return!1;for(let r of Object.keys(t.properties||{}))if(r in(t.optionalProperties||{}))return!1}if(Er(t))return H(t.values,e);if(Sr(t)){for(let r of Object.values(t.mapping))if(!H(r,e)||!Xe(r)||r.nullable||t.discriminator in(r.properties||{})||t.discriminator in(r.optionalProperties||{}))return!1}return!0}h.isValidSchema=H;var Kn=[[!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]],Xn=["boolean","float32","float64","int8","uint8","int16","uint16","int32","uint32","string","timestamp"];function J(t){if(typeof t!="object"||Array.isArray(t)||t===null)return!1;let e=t,{definitions:r=void 0,nullable:n=void 0,metadata:o=void 0,ref:i=void 0,type:a=void 0,enum:f=void 0,elements:s=void 0,properties:y=void 0,optionalProperties:p=void 0,additionalProperties:g=void 0,values:u=void 0,discriminator:S=void 0,mapping:b=void 0}=e,k=wr(e,["definitions","nullable","metadata","ref","type","enum","elements","properties","optionalProperties","additionalProperties","values","discriminator","mapping"]),v=[i!==void 0,a!==void 0,f!==void 0,s!==void 0,y!==void 0,p!==void 0,g!==void 0,u!==void 0,S!==void 0,b!==void 0],_=!1;for(let P of Kn)_=_||P.every((j,M)=>j===v[M]);if(!_)return!1;if(r!==void 0){if(typeof r!="object"||Array.isArray(r)||r===null)return!1;for(let P of Object.values(r))if(!J(P))return!1}if(n!==void 0&&typeof n!="boolean"||o!==void 0&&(typeof o!="object"||Array.isArray(o)||o===null)||i!==void 0&&typeof i!="string"||a!==void 0&&(typeof a!="string"||!Xn.includes(a))||f!==void 0&&(!Array.isArray(f)||!f.every(P=>typeof P=="string"))||s!==void 0&&!J(s))return!1;if(y!==void 0){if(typeof y!="object"||Array.isArray(y)||y===null)return!1;for(let P of Object.values(y))if(!J(P))return!1}if(p!==void 0){if(typeof p!="object"||Array.isArray(p)||p===null)return!1;for(let P of Object.values(p))if(!J(P))return!1}if(g!==void 0&&typeof g!="boolean"||u!==void 0&&!J(u)||S!==void 0&&typeof S!="string")return!1;if(b!==void 0){if(typeof b!="object"||Array.isArray(b)||b===null)return!1;for(let P of Object.values(b))if(!J(P))return!1}return Object.keys(k).length===0}h.isSchema=J});var Or=m(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});var Zn=/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(\.\d+)?([zZ]|((\+|-)(\d{2}):(\d{2})))$/;function Qn(t){let e=t.match(Zn);if(e===null)return!1;let r=parseInt(e[1],10),n=parseInt(e[2],10),o=parseInt(e[3],10),i=parseInt(e[4],10),a=parseInt(e[5],10),f=parseInt(e[6],10);return!(n>12||o>eo(r,n)||i>23||a>59||f>60)}Qe.default=Qn;function eo(t,e){return e===2?to(t)?29:28:ro[e]}function to(t){return t%4===0&&(t%100!==0||t%400===0)}var ro=[0,31,0,31,30,31,30,31,31,30,31,30,31]});var Tr=m(B=>{"use strict";var no=B&&B.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(B,"__esModule",{value:!0});B.validate=B.MaxDepthExceededError=void 0;var oo=no(Or()),G=Ze(),Te=class extends Error{};B.MaxDepthExceededError=Te;var Fe=class extends Error{};function io(t,e,r){let n={errors:[],instanceTokens:[],schemaTokens:[[]],root:t,config:r||{maxDepth:0,maxErrors:0}};try{V(n,t,e)}catch(o){if(!(o instanceof Fe))throw o}return n.errors}B.validate=io;function V(t,e,r,n){if(!(e.nullable&&r===null)){if(G.isRefForm(e)){if(t.schemaTokens.length===t.config.maxDepth)throw new Te;t.schemaTokens.push(["definitions",e.ref]),V(t,t.root.definitions[e.ref],r),t.schemaTokens.pop()}else if(G.isTypeForm(e)){switch(A(t,"type"),e.type){case"boolean":typeof r!="boolean"&&E(t);break;case"float32":case"float64":typeof r!="number"&&E(t);break;case"int8":re(t,r,-128,127);break;case"uint8":re(t,r,0,255);break;case"int16":re(t,r,-32768,32767);break;case"uint16":re(t,r,0,65535);break;case"int32":re(t,r,-2147483648,2147483647);break;case"uint32":re(t,r,0,4294967295);break;case"string":typeof r!="string"&&E(t);break;case"timestamp":typeof r!="string"?E(t):oo.default(r)||E(t);break}O(t)}else if(G.isEnumForm(e))A(t,"enum"),(typeof r!="string"||!e.enum.includes(r))&&E(t),O(t);else if(G.isElementsForm(e)){if(A(t,"elements"),Array.isArray(r))for(let[o,i]of r.entries())q(t,o.toString()),V(t,e.elements,i),z(t);else E(t);O(t)}else if(G.isPropertiesForm(e))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){if(e.properties!==void 0){A(t,"properties");for(let[o,i]of Object.entries(e.properties))A(t,o),r.hasOwnProperty(o)?(q(t,o),V(t,i,r[o]),z(t)):E(t),O(t);O(t)}if(e.optionalProperties!==void 0){A(t,"optionalProperties");for(let[o,i]of Object.entries(e.optionalProperties))A(t,o),r.hasOwnProperty(o)&&(q(t,o),V(t,i,r[o]),z(t)),O(t);O(t)}if(e.additionalProperties!==!0)for(let o of Object.keys(r)){let i=e.properties&&o in e.properties,a=e.optionalProperties&&o in e.optionalProperties;!i&&!a&&o!==n&&(q(t,o),E(t),z(t))}}else e.properties!==void 0?A(t,"properties"):A(t,"optionalProperties"),E(t),O(t);else if(G.isValuesForm(e)){if(A(t,"values"),typeof r=="object"&&r!==null&&!Array.isArray(r))for(let[o,i]of Object.entries(r))q(t,o),V(t,e.values,i),z(t);else E(t);O(t)}else if(G.isDiscriminatorForm(e))if(typeof r=="object"&&r!==null&&!Array.isArray(r))if(r.hasOwnProperty(e.discriminator)){let o=r[e.discriminator];typeof o=="string"?o in e.mapping?(A(t,"mapping"),A(t,o),V(t,e.mapping[o],r,e.discriminator),O(t),O(t)):(A(t,"mapping"),q(t,e.discriminator),E(t),z(t),O(t)):(A(t,"discriminator"),q(t,e.discriminator),E(t),z(t),O(t))}else A(t,"discriminator"),E(t),O(t);else A(t,"discriminator"),E(t),O(t)}}function re(t,e,r,n){(typeof e!="number"||!Number.isInteger(e)||e<r||e>n)&&E(t)}function q(t,e){t.instanceTokens.push(e)}function z(t){t.instanceTokens.pop()}function A(t,e){t.schemaTokens[t.schemaTokens.length-1].push(e)}function O(t){t.schemaTokens[t.schemaTokens.length-1].pop()}function E(t){if(t.errors.push({instancePath:[...t.instanceTokens],schemaPath:[...t.schemaTokens[t.schemaTokens.length-1]]}),t.errors.length===t.config.maxErrors)throw new Fe}});var kr=m(C=>{"use strict";var ao=C&&C.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Fr=C&&C.__exportStar||function(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&ao(e,t,r)};Object.defineProperty(C,"__esModule",{value:!0});Fr(Ze(),C);Fr(Tr(),C)});var bo={};Wr(bo,{GenerationError:()=>je,ResponseError:()=>W,builtinFontNames:()=>po,builtinLineHeights:()=>Ur,builtinMargins:()=>Nr,builtinTextScales:()=>_r,builtinTools:()=>lo,formatEntry:()=>Dr,parseEntry:()=>Lr,register:()=>ho,remarkable:()=>vo});module.exports=Yr(bo);var Rr=ne(it()),Br=ne(dr());var gr=ne(require("crypto")),Oe=new Uint8Array(256),Se=Oe.length;function We(){return Se>Oe.length-16&&(gr.default.randomFillSync(Oe),Se=0),Oe.slice(Se,Se+=16)}var x=[];for(let t=0;t<256;++t)x.push((t+256).toString(16).slice(1));function mr(t,e=0){return x[t[e+0]]+x[t[e+1]]+x[t[e+2]]+x[t[e+3]]+"-"+x[t[e+4]]+x[t[e+5]]+"-"+x[t[e+6]]+x[t[e+7]]+"-"+x[t[e+8]]+x[t[e+9]]+"-"+x[t[e+10]]+x[t[e+11]]+x[t[e+12]]+x[t[e+13]]+x[t[e+14]]+x[t[e+15]]}var hr=ne(require("crypto")),Ye={randomUUID:hr.default.randomUUID};function Vn(t,e,r){if(Ye.randomUUID&&!e&&!t)return Ye.randomUUID();t=t||{};let n=t.random||(t.rng||We)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){r=r||0;for(let o=0;o<16;++o)e[r+o]=n[o];return e}return mr(n)}var ue=Vn;function Ke(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}function vr(t){return new Uint8Array((t.match(/../g)??[]).map(e=>parseInt(e,16)))}function br(t){let e=0;for(let o of t)e+=o.length;let r=new Uint8Array(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return r}var Ir=ne(kr());function le(t,e){if((0,Ir.validate)(t,e).length)throw new Error(`couldn't validate schema: ${JSON.stringify(e)} didn't match schema ${JSON.stringify(t)}`)}var jr="3",Cr="https://webapp-prod.cloud.remarkable.engineering",so="https://internal.cloud.remarkable.com",$r="x-goog-generation",fo="x-goog-if-generation-match",uo="x-goog-content-length-range",lo=["Ballpoint","Ballpointv2","Brush","Calligraphy","ClearPage","EraseSection","Eraser","Fineliner","Finelinerv2","Highlighter","Highlighterv2","Marker","Markerv2","Paintbrush","Paintbrushv2","Pencilv2","SharpPencil","SharpPencilv2","SolidPen","ZoomTool"],po=["Maison Neue","EB Garamond","Noto Sans","Noto Serif","Noto Mono","Noto Sans UI"],_r={xs:.7,sm:.8,md:1,lg:1.2,xl:1.5,xx:2},Nr={sm:50,md:125,rr:180,lg:200},Ur={df:-1,md:100,lg:150,xl:200},co={properties:{docID:{type:"string"},hash:{type:"string"}}},yo={properties:{relative_path:{type:"string"},url:{type:"string"},expires:{type:"timestamp"},method:{enum:["POST","GET","PUT","DELETE"]}},optionalProperties:{maxuploadsize_bytes:{type:"float64"}}},ke={visibleName:{type:"string"},lastModified:{type:"string"}},Ie={version:{type:"int32"},pinned:{type:"boolean"},synced:{type:"boolean"},modified:{type:"boolean"},deleted:{type:"boolean"},metadatamodified:{type:"boolean"},parent:{type:"string"}},go={discriminator:"type",mapping:{CollectionType:{properties:ke,optionalProperties:Ie,additionalProperties:!0},DocumentType:{properties:ke,optionalProperties:{...Ie,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"},createdTime:{type:"string"}},additionalProperties:!0}}},Mr={id:{type:"string"},hash:{type:"string"}},mo={discriminator:"type",mapping:{CollectionType:{properties:{...ke,...Mr},optionalProperties:Ie,additionalProperties:!0},DocumentType:{properties:{...ke,...Mr,fileType:{enum:["notebook","epub","pdf",""]}},optionalProperties:{...Ie,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"},createdTime:{type:"string"}},additionalProperties:!0}}},W=class extends Error{status;statusText;constructor(e,r,n){super(n),this.status=e,this.statusText=r}},je=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 ho(t,{deviceDesc:e="browser-chrome",uuid:r=ue(),authHost:n=Cr,fetch:o=globalThis.fetch}={}){if(t.length!==8)throw new Error(`code should be length 8, but was ${t.length}`);let i=await o(`${n}/token/json/2/device/new`,{method:"POST",headers:{Authorization:"Bearer"},body:JSON.stringify({code:t,deviceDesc:e,deviceID:r})});if(i.ok)return await i.text();throw new W(i.status,i.statusText,"couldn't register api")}function Dr({hash:t,type:e,documentId:r,subfiles:n,size:o}){return`${t}:${e}:${r}:${n}:${o}
|
|
10
|
+
`}function Lr(t){let[e,r,n,o,i]=t.split(":");if(e===void 0||r===void 0||n===void 0||o===void 0||i===void 0)throw new Error(`entries line didn't contain five fields: '${t}'`);if(r==="80000000")return{hash:e,type:r,documentId:n,subfiles:parseInt(o),size:BigInt(i)};if(r==="0"){if(o!=="0")throw new Error(`file type entry had nonzero number of subfiles: ${o}`);return{hash:e,type:r,documentId:n,subfiles:0,size:BigInt(i)}}else throw new Error(`entries line contained invalid type: ${r}`)}var et=class{#u;#s;#f;#r;#n;#e=new Map;#t=null;constructor(e,r,n,o,i,a){this.#u=e,this.#s=r,this.#f=n,this.#r=o,this.#n=i;for(let[f,s]of a)this.#e.set(f,Promise.resolve(s))}async#o(e,{body:r,method:n="POST",headers:o={}}){let i=await this.#s(e,{method:n,headers:{Authorization:`Bearer ${this.#u}`,...o},body:r});if(i.ok)return i;{let a=await i.text();throw new W(i.status,i.statusText,`failed reMarkable request: ${a}`)}}async#i({url:e,method:r,maxuploadsize_bytes:n},o,i={}){let a=n?{...i,[uo]:`0,${n}`}:i,f=await this.#s(e,{method:r,body:o,headers:a});if(f.ok)return f;{let s=await f.text();throw new W(f.status,f.statusText,s)}}async#a(e,r,n){let o=r===void 0?"downloads":"uploads",i=n&&r!==null&&r!==void 0?`{ "http_method": "PUT", "relative_path": "${e}", "root_schema": "${n}", "generation": ${r} }`:JSON.stringify({http_method:"GET",relative_path:e}),f=await(await this.#o(`${this.#r}/sync/v2/signed-urls/${o}`,{body:i})).text(),s=JSON.parse(f);return le(yo,s),s}async getRootHash({cache:e=!0}={}){if(e)for(;this.#t;)try{let[i,a]=await this.#t;return[i,a]}catch{}let r=(async()=>{try{let i=await this.#a("root"),a=await this.#i(i),f=a.headers.get($r);if(f)return[await a.text(),BigInt(f)];throw new Error("no generation header in root hash")}catch(i){throw this.#t=null,i}})();this.#t=r;let[n,o]=await r;return[n,o]}async putRootHash(e,r){let n=await this.#a("root",r,e),o;try{o=await this.#i(n,e,{[fo]:`${r}`})}catch(f){throw f instanceof W&&f.status===412?(this.#t=null,new je):f}let i=o.headers.get($r);if(!i)throw new Error("no generation header in root hash");let a=BigInt(i);return this.#t=Promise.resolve([e,a]),a}async#l(e){let r=this.#e.get(e);for(;r;)try{let o=await r;if(o)return o;r=void 0}catch{r=this.#e.get(e)}let n=(async()=>{let o=await this.#a(e);return await(await this.#i(o)).arrayBuffer()})();return this.#e.set(e,n.then(o=>o.byteLength<this.#n?o:null,o=>{throw this.#e.delete(e),o})),await n}async getBuffer(e){let r=await this.#l(e);return r.byteLength<this.#n?r.slice(0):r}async getText(e){let r=await this.#l(e);return new TextDecoder().decode(r)}async getJson(e){let r=await this.getText(e);return JSON.parse(r)}async getMetadata(e){let r=await this.getJson(e);return le(go,r),r}async getEntries(e){if(e===void 0){let[i]=await this.getRootHash({cache:!0});e=i}let r=await this.getText(e),[n,...o]=r.slice(0,-1).split(`
|
|
11
|
+
`);if(n!==jr)throw new Error(`got unexpected schema version: ${n}`);return o.map(Lr)}async#p(e,r){let n=this.#e.get(e);if(n)try{await n;return}catch{}let o=(async()=>{try{let i=await this.#a(e,null);return await this.#i(i,r),r.byteLength<this.#n?r:null}catch(i){throw this.#e.delete(e),i}})();this.#e.set(e,o),await o}async putEntries(e,r){let n=new TextEncoder;r.sort((p,g)=>p.documentId.localeCompare(g.documentId));let o=br(r.map(p=>vr(p.hash))),i=await this.#f.digest("SHA-256",o),a=Ke(i),f=r.map(Dr).join(""),s=`${jr}
|
|
12
|
+
${f}`,y=n.encode(s);return await this.#p(a,y),{hash:a,type:"80000000",documentId:e,subfiles:r.length,size:0n}}async putBuffer(e,r){let n=await this.#f.digest("SHA-256",r),o=Ke(n);return await this.#p(o,r),{hash:o,type:"0",documentId:e,subfiles:0,size:BigInt(r.byteLength)}}async putText(e,r){let n=new TextEncoder;return await this.putBuffer(e,n.encode(r))}async putJson(e,r){return await this.putText(e,(0,Br.default)(r))}async putMetadata(e,r){return await this.putJson(`${e}.metadata`,r)}async putCollection(e,r=""){let n=ue(),o=`${new Date().valueOf()}`,i=[],a={type:"CollectionType",visibleName:e,version:0,parent:r,synced:!0,lastModified:o};i.push(this.putMetadata(n,a)),i.push(this.putText(`${n}.content`,"{}"));let f=await Promise.all(i);return await this.putEntries(n,f)}async#c(e,r,n,o,i){if(i.fileType!==n)throw new Error(`internal error: fileTypes don't match: ${n}, ${i.fileType}`);let a=ue(),f=`${new Date().valueOf()}`,s=[];s.push(this.putBuffer(`${a}.${n}`,r));let y={type:"DocumentType",visibleName:e,version:0,parent:o,synced:!0,lastModified:f};s.push(this.putMetadata(a,y)),s.push(this.putText(`${a}.content`,JSON.stringify(i)));let p=await Promise.all(s);return await this.putEntries(a,p)}async putEpub(e,r,{parent:n="",margins:o=125,orientation:i,textAlignment:a,textScale:f=1,lineHeight:s=-1,fontName:y="",cover:p="visited",lastTool:g}={}){let u={dummyDocument:!1,extraMetadata:{LastTool:g},fileType:"epub",pageCount:0,lastOpenedPage:0,lineHeight:typeof s=="string"?Ur[s]:s,margins:typeof o=="string"?Nr[o]:o,textScale:typeof f=="string"?_r[f]:f,pages:[],coverPageNumber:p==="first"?0:-1,formatVersion:1,orientation:i,textAlignment:a,fontName:y};return await this.#c(e,r,"epub",n,u)}async putPdf(e,r,{parent:n="",orientation:o,cover:i="first",lastTool:a}={}){let f={dummyDocument:!1,extraMetadata:{LastTool:a},fileType:"pdf",pageCount:0,lastOpenedPage:0,lineHeight:-1,margins:125,textScale:1,pages:[],coverPageNumber:i==="first"?0:-1,formatVersion:1,orientation:o};return await this.#c(e,r,"pdf",n,f)}async syncComplete(e){let r=`{ "generation": ${e} }`;await this.#o(`${this.#r}/sync/v2/sync-complete`,{body:r})}async#y(e,r,n){let{hash:o}=await this.putEntries("",r),i=await this.putRootHash(o,e);if(n)try{return await this.syncComplete(i),!0}catch{return!1}else return!1}async create(e,{cache:r=!0,sync:n=!0}={}){let[o,i]=await this.getRootHash({cache:r}),a=await this.getEntries(o);return a.push(e),await this.#y(i,a,n)}async move(e,r,{cache:n=!0,sync:o=!0}={}){let[i,a]=await this.getRootHash({cache:n}),f=await this.getEntries(i);if(!(!r||r==="trash")){let v=f.find(M=>M.documentId===r);if(v){if(v.type!=="80000000")throw new Error(`destination id was a raw file: ${r}`)}else throw new Error(`destination id not found: ${r}`);let _=await this.getEntries(v.hash),[P]=_.filter(M=>M.documentId===`${r}.metadata`);if(!P)throw new Error(`destination id didn't have metadata: ${r}`);if((await this.getMetadata(P.hash)).type!=="CollectionType")throw new Error(`destination id wasn't a collection: ${r}`)}let s=f.findIndex(v=>v.documentId===e);if(s===-1)throw new Error(`document not found: ${e}`);let[y]=f.splice(s,1);if(y.type!=="80000000")throw new Error(`document was a raw file: ${e}`);let p=await this.getEntries(y.hash),g=p.findIndex(v=>v.documentId===`${e}.metadata`);if(g===-1)throw new Error(`document didn't have metadata: ${e}`);let[u]=p.splice(g,1),S=await this.getMetadata(u.hash);S.parent=r;let b=await this.putMetadata(e,S);p.push(b);let k=await this.putEntries(e,p);return f.push(k),await this.#y(a,f,o)}async getEntriesMetadata(){let r=await(await this.#o(`${this.#r}/doc/v2/files`,{method:"GET",headers:{"rm-source":"RoR-Browser"}})).text(),n=JSON.parse(r);return le({elements:mo},n),n}async#d(e,r,n){let i=new TextEncoder().encode(JSON.stringify({file_name:e})),f=await(await this.#o(`${this.#r}/doc/v2/files`,{body:r,headers:{"content-type":n,"rm-meta":(0,Rr.fromByteArray)(i),"rm-source":"RoR-Browser"}})).text(),s=JSON.parse(f);return le(co,s),s}async uploadEpub(e,r){return await this.#d(e,r,"application/epub+zip")}async uploadPdf(e,r){return await this.#d(e,r,"application/pdf")}async getCache(){let e=[];for(let[o,i]of this.#e)e.push(i.then(a=>[o,a],()=>[o,null]));let r=await Promise.all(e),n=new Map;for(let[o,i]of r)i&&n.set(o,i);return n}};async function vo(t,{fetch:e=globalThis.fetch,subtle:r=globalThis.crypto?.subtle,authHost:n=Cr,syncHost:o=so,cacheLimitBytes:i=1048576,initCache:a=[]}={}){if(!r)throw new Error("subtle was missing, try specifying it manually");let f=await e(`${n}/token/json/2/user/new`,{method:"POST",headers:{Authorization:`Bearer ${t}`}});if(!f.ok)throw new Error(`couldn't fetch auth token: ${f.statusText}`);let s=await f.text();return new et(s,e,r,o,i,a)}0&&(module.exports={GenerationError,ResponseError,builtinFontNames,builtinLineHeights,builtinMargins,builtinTextScales,builtinTools,formatEntry,parseEntry,register,remarkable});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
`,r:"\r",t:" "},
|
|
3
|
-
`+
|
|
4
|
-
`+
|
|
5
|
-
`+a+"]":"["+f.join(",")+"]",
|
|
6
|
-
`+
|
|
7
|
-
`+
|
|
8
|
-
`+a+"}":"{"+f.join(",")+"}",E=a,i;default:}}ke.exports=function(e,t,r){var n;if(E="",W="",typeof r=="number")for(n=0;n<r;n+=1)W+=" ";else typeof r=="string"&&(W=r);if(R=t,t&&typeof t!="function"&&(typeof t!="object"||typeof t.length!="number"))throw new Error("JSON.stringify");return Q("",{"":e})}});var Me=S(le=>{"use strict";le.parse=Se();le.stringify=Fe()});var je=S((Wt,Ce)=>{"use strict";var X=typeof JSON<"u"?JSON:Me(),ht=Array.isArray||function(e){return{}.toString.call(e)==="[object Array]"},gt=Object.keys||function(e){var t=Object.prototype.hasOwnProperty||function(){return!0},r=[];for(var n in e)t.call(e,n)&&r.push(n);return r};Ce.exports=function(e,t){t||(t={}),typeof t=="function"&&(t={cmp:t});var r=t.space||"";typeof r=="number"&&(r=Array(r+1).join(" "));var n=typeof t.cycles=="boolean"?t.cycles:!1,i=t.replacer||function(f,s){return s},o=t.cmp&&function(f){return function(s){return function(p,u){var g={key:p,value:s[p]},x={key:u,value:s[u]};return f(g,x)}}}(t.cmp),a=[];return function f(s,p,u,g){var x=r?`
|
|
9
|
-
`+new Array(g+1).join(r):"",F=r?": ":":";if(u&&u.toJSON&&typeof u.toJSON=="function"&&(u=u.toJSON()),u=i.call(s,p,u),u!==void 0){if(typeof u!="object"||u===null)return X.stringify(u);if(ht(u)){for(var A=[],y=0;y<u.length;y++){var J=f(u,y,u[y],g+1)||X.stringify(null);A.push(x+r+J)}return"["+A.join(",")+x+"]"}if(a.indexOf(u)!==-1){if(n)return X.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}else a.push(u);for(var P=gt(u).sort(o&&o(u)),A=[],y=0;y<P.length;y++){var p=P[y],m=f(u,p,u[p],g+1);if(m){var G=X.stringify(p)+F+m;A.push(x+r+G)}}return a.splice(a.indexOf(u),1),"{"+A.join(",")+x+"}"}}({"":e},"",e,0)}});var me=S(d=>{"use strict";var _e=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 xt(e){let{definitions:t,nullable:r,metadata:n}=e,i=_e(e,["definitions","nullable","metadata"]);return Object.keys(i).length===0}d.isEmptyForm=xt;function Ne(e){return"ref"in e}d.isRefForm=Ne;function Et(e){return"type"in e}d.isTypeForm=Et;function $e(e){return"enum"in e}d.isEnumForm=$e;function Le(e){return"elements"in e}d.isElementsForm=Le;function ye(e){return"properties"in e||"optionalProperties"in e}d.isPropertiesForm=ye;function De(e){return"values"in e}d.isValuesForm=De;function He(e){return"discriminator"in e}d.isDiscriminatorForm=He;function I(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(!I(r,t))return!1}if(Ne(e)&&!(e.ref in(t.definitions||{}))||$e(e)&&(e.enum.length===0||e.enum.length!==new Set(e.enum).size))return!1;if(Le(e))return I(e.elements,t);if(ye(e)){for(let r of Object.values(e.properties||{}))if(!I(r,t))return!1;for(let r of Object.values(e.optionalProperties||{}))if(!I(r,t))return!1;for(let r of Object.keys(e.properties||{}))if(r in(e.optionalProperties||{}))return!1}if(De(e))return I(e.values,t);if(He(e)){for(let r of Object.values(e.mapping))if(!I(r,t)||!ye(r)||r.nullable||e.discriminator in(r.properties||{})||e.discriminator in(r.optionalProperties||{}))return!1}return!0}d.isValidSchema=I;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]],Tt=["boolean","float32","float64","int8","uint8","int16","uint16","int32","uint32","string","timestamp"];function _(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:o=void 0,type:a=void 0,enum:f=void 0,elements:s=void 0,properties:p=void 0,optionalProperties:u=void 0,additionalProperties:g=void 0,values:x=void 0,discriminator:F=void 0,mapping:y=void 0}=t,J=_e(t,["definitions","nullable","metadata","ref","type","enum","elements","properties","optionalProperties","additionalProperties","values","discriminator","mapping"]),P=[o!==void 0,a!==void 0,f!==void 0,s!==void 0,p!==void 0,u!==void 0,g!==void 0,x!==void 0,F!==void 0,y!==void 0],A=!1;for(let m of Pt)A=A||m.every((G,V)=>G===P[V]);if(!A)return!1;if(r!==void 0){if(typeof r!="object"||Array.isArray(r)||r===null)return!1;for(let m of Object.values(r))if(!_(m))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"||a!==void 0&&(typeof a!="string"||!Tt.includes(a))||f!==void 0&&(!Array.isArray(f)||!f.every(m=>typeof m=="string"))||s!==void 0&&!_(s))return!1;if(p!==void 0){if(typeof p!="object"||Array.isArray(p)||p===null)return!1;for(let m of Object.values(p))if(!_(m))return!1}if(u!==void 0){if(typeof u!="object"||Array.isArray(u)||u===null)return!1;for(let m of Object.values(u))if(!_(m))return!1}if(g!==void 0&&typeof g!="boolean"||x!==void 0&&!_(x)||F!==void 0&&typeof F!="string")return!1;if(y!==void 0){if(typeof y!="object"||Array.isArray(y)||y===null)return!1;for(let m of Object.values(y))if(!_(m))return!1}return Object.keys(J).length===0}d.isSchema=_});var Ue=S(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});var At=/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(\.\d+)?([zZ]|((\+|-)(\d{2}):(\d{2})))$/;function Ot(e){let t=e.match(At);if(t===null)return!1;let r=parseInt(t[1],10),n=parseInt(t[2],10),i=parseInt(t[3],10),o=parseInt(t[4],10),a=parseInt(t[5],10),f=parseInt(t[6],10);return!(n>12||i>St(r,n)||o>23||a>59||f>60)}he.default=Ot;function St(e,t){return t===2?kt(e)?29:28:Ft[t]}function kt(e){return e%4===0&&(e%100!==0||e%400===0)}var Ft=[0,31,0,31,30,31,30,31,31,30,31,30,31]});var Je=S(C=>{"use strict";var Mt=C&&C.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(C,"__esModule",{value:!0});C.validate=C.MaxDepthExceededError=void 0;var Ct=Mt(Ue()),N=me(),te=class extends Error{};C.MaxDepthExceededError=te;var re=class extends Error{};function jt(e,t,r){let n={errors:[],instanceTokens:[],schemaTokens:[[]],root:e,config:r||{maxDepth:0,maxErrors:0}};try{D(n,e,t)}catch(i){if(!(i instanceof re))throw i}return n.errors}C.validate=jt;function D(e,t,r,n){if(!(t.nullable&&r===null)){if(N.isRefForm(t)){if(e.schemaTokens.length===e.config.maxDepth)throw new te;e.schemaTokens.push(["definitions",t.ref]),D(e,e.root.definitions[t.ref],r),e.schemaTokens.pop()}else if(N.isTypeForm(t)){switch(b(e,"type"),t.type){case"boolean":typeof r!="boolean"&&w(e);break;case"float32":case"float64":typeof r!="number"&&w(e);break;case"int8":H(e,r,-128,127);break;case"uint8":H(e,r,0,255);break;case"int16":H(e,r,-32768,32767);break;case"uint16":H(e,r,0,65535);break;case"int32":H(e,r,-2147483648,2147483647);break;case"uint32":H(e,r,0,4294967295);break;case"string":typeof r!="string"&&w(e);break;case"timestamp":typeof r!="string"?w(e):Ct.default(r)||w(e);break}v(e)}else if(N.isEnumForm(t))b(e,"enum"),(typeof r!="string"||!t.enum.includes(r))&&w(e),v(e);else if(N.isElementsForm(t)){if(b(e,"elements"),Array.isArray(r))for(let[i,o]of r.entries())$(e,i.toString()),D(e,t.elements,o),L(e);else w(e);v(e)}else if(N.isPropertiesForm(t))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){if(t.properties!==void 0){b(e,"properties");for(let[i,o]of Object.entries(t.properties))b(e,i),r.hasOwnProperty(i)?($(e,i),D(e,o,r[i]),L(e)):w(e),v(e);v(e)}if(t.optionalProperties!==void 0){b(e,"optionalProperties");for(let[i,o]of Object.entries(t.optionalProperties))b(e,i),r.hasOwnProperty(i)&&($(e,i),D(e,o,r[i]),L(e)),v(e);v(e)}if(t.additionalProperties!==!0)for(let i of Object.keys(r)){let o=t.properties&&i in t.properties,a=t.optionalProperties&&i in t.optionalProperties;!o&&!a&&i!==n&&($(e,i),w(e),L(e))}}else t.properties!==void 0?b(e,"properties"):b(e,"optionalProperties"),w(e),v(e);else if(N.isValuesForm(t)){if(b(e,"values"),typeof r=="object"&&r!==null&&!Array.isArray(r))for(let[i,o]of Object.entries(r))$(e,i),D(e,t.values,o),L(e);else w(e);v(e)}else if(N.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?(b(e,"mapping"),b(e,i),D(e,t.mapping[i],r,t.discriminator),v(e),v(e)):(b(e,"mapping"),$(e,t.discriminator),w(e),L(e),v(e)):(b(e,"discriminator"),$(e,t.discriminator),w(e),L(e),v(e))}else b(e,"discriminator"),w(e),v(e);else b(e,"discriminator"),w(e),v(e)}}function H(e,t,r,n){(typeof t!="number"||!Number.isInteger(t)||t<r||t>n)&&w(e)}function $(e,t){e.instanceTokens.push(t)}function L(e){e.instanceTokens.pop()}function b(e,t){e.schemaTokens[e.schemaTokens.length-1].push(t)}function v(e){e.schemaTokens[e.schemaTokens.length-1].pop()}function w(e){if(e.errors.push({instancePath:[...e.instanceTokens],schemaPath:[...e.schemaTokens[e.schemaTokens.length-1]]}),e.errors.length===e.config.maxErrors)throw new re}});var qe=S(j=>{"use strict";var Bt=j&&j.__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]}),Ve=j&&j.__exportStar||function(e,t){for(var r in e)r!=="default"&&!t.hasOwnProperty(r)&&Bt(t,e,r)};Object.defineProperty(j,"__esModule",{value:!0});Ve(me(),j);Ve(Je(),j)});var Ke=oe(Ee()),We=oe(je());var ee,bt=new Uint8Array(16);function ce(){if(!ee&&(ee=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ee))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ee(bt)}var h=[];for(let e=0;e<256;++e)h.push((e+256).toString(16).slice(1));function Be(e,t=0){return(h[e[t+0]]+h[e[t+1]]+h[e[t+2]]+h[e[t+3]]+"-"+h[e[t+4]]+h[e[t+5]]+"-"+h[e[t+6]]+h[e[t+7]]+"-"+h[e[t+8]]+h[e[t+9]]+"-"+h[e[t+10]]+h[e[t+11]]+h[e[t+12]]+h[e[t+13]]+h[e[t+14]]+h[e[t+15]]).toLowerCase()}var wt=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),pe={randomUUID:wt};function vt(e,t,r){if(pe.randomUUID&&!t&&!e)return pe.randomUUID();e=e||{};let n=e.random||(e.rng||ce)();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 Be(n)}var q=vt;function de(e){return[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join("")}function Re(e){return new Uint8Array((e.match(/../g)??[]).map(t=>parseInt(t,16)))}function Ie(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 ze=oe(qe());function z(e,t){if((0,ze.validate)(e,t).length)throw new Error(`couldn't validate schema: ${JSON.stringify(t)} didn't match schema ${JSON.stringify(e)}`)}var Ge="3",Qe="https://webapp-prod.cloud.remarkable.engineering",Rt="https://internal.cloud.remarkable.com",Ye="x-goog-generation",It="x-goog-if-generation-match",_t="x-goog-content-length-range",gr=["Ballpoint","Ballpointv2","Brush","Calligraphy","ClearPage","EraseSection","Eraser","Fineliner","Finelinerv2","Highlighter","Highlighterv2","Marker","Markerv2","Paintbrush","Paintbrushv2","Pencilv2","SharpPencil","SharpPencilv2","SolidPen","ZoomTool"],br=["Maison Neue","EB Garamond","Noto Sans","Noto Serif","Noto Mono","Noto Sans UI"],Nt={xs:.7,sm:.8,md:1,lg:1.2,xl:1.5,xx:2},$t={sm:50,md:125,rr:180,lg:200},Lt={df:-1,md:100,lg:150,xl:200},Dt={properties:{docID:{type:"string"},hash:{type:"string"}}},Ht={properties:{relative_path:{type:"string"},url:{type:"string"},expires:{type:"timestamp"},method:{enum:["POST","GET","PUT","DELETE"]}},optionalProperties:{maxuploadsize_bytes:{type:"float64"}}},ne={visibleName:{type:"string"},lastModified:{type:"string"}},ie={version:{type:"int32"},pinned:{type:"boolean"},synced:{type:"boolean"},modified:{type:"boolean"},deleted:{type:"boolean"},metadatamodified:{type:"boolean"},parent:{type:"string"}},Ut={discriminator:"type",mapping:{CollectionType:{properties:ne,optionalProperties:ie},DocumentType:{properties:ne,optionalProperties:{...ie,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"}}}}},Ze={id:{type:"string"},hash:{type:"string"}},Jt={discriminator:"type",mapping:{CollectionType:{properties:{...ne,...Ze},optionalProperties:ie},DocumentType:{properties:{...ne,...Ze,fileType:{enum:["notebook","epub","pdf",""]}},optionalProperties:{...ie,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"}}}}},U=class extends Error{status;statusText;constructor(t,r,n){super(n),this.status=t,this.statusText=r}},ge=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:t="browser-chrome",uuid:r=q(),authHost:n=Qe,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:t,deviceID:r})});if(o.ok)return await o.text();throw new U(o.status,o.statusText,"couldn't register api")}function Vt({hash:e,type:t,documentId:r,subfiles:n,size:i}){return`${e}:${t}:${r}:${n}:${i}
|
|
10
|
-
`}function
|
|
11
|
-
`);if(n!==
|
|
12
|
-
${f}`,
|
|
1
|
+
var Rr=Object.create;var et=Object.defineProperty;var Br=Object.getOwnPropertyDescriptor;var Cr=Object.getOwnPropertyNames;var _r=Object.getPrototypeOf,Ur=Object.prototype.hasOwnProperty;var m=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Nr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Cr(e))!Ur.call(t,o)&&o!==r&&et(t,o,{get:()=>e[o],enumerable:!(n=Br(e,o))||n.enumerable});return t};var Fe=(t,e,r)=>(r=t!=null?Rr(_r(t)):{},Nr(e||!t||!t.__esModule?et(r,"default",{value:t,enumerable:!0}):r,t));var nt=m(le=>{"use strict";le.byteLength=Lr;le.toByteArray=Jr;le.fromByteArray=Vr;var I=[],F=[],Dr=typeof Uint8Array<"u"?Uint8Array:Array,ke="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(U=0,tt=ke.length;U<tt;++U)I[U]=ke[U],F[ke.charCodeAt(U)]=U;var U,tt;F[45]=62;F[95]=63;function rt(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function Lr(t){var e=rt(t),r=e[0],n=e[1];return(r+n)*3/4-n}function Hr(t,e,r){return(e+r)*3/4-r}function Jr(t){var e,r=rt(t),n=r[0],o=r[1],i=new Dr(Hr(t,n,o)),a=0,f=o>0?n-4:n,s;for(s=0;s<f;s+=4)e=F[t.charCodeAt(s)]<<18|F[t.charCodeAt(s+1)]<<12|F[t.charCodeAt(s+2)]<<6|F[t.charCodeAt(s+3)],i[a++]=e>>16&255,i[a++]=e>>8&255,i[a++]=e&255;return o===2&&(e=F[t.charCodeAt(s)]<<2|F[t.charCodeAt(s+1)]>>4,i[a++]=e&255),o===1&&(e=F[t.charCodeAt(s)]<<10|F[t.charCodeAt(s+1)]<<4|F[t.charCodeAt(s+2)]>>2,i[a++]=e>>8&255,i[a++]=e&255),i}function Gr(t){return I[t>>18&63]+I[t>>12&63]+I[t>>6&63]+I[t&63]}function qr(t,e,r){for(var n,o=[],i=e;i<r;i+=3)n=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(t[i+2]&255),o.push(Gr(n));return o.join("")}function Vr(t){for(var e,r=t.length,n=r%3,o=[],i=16383,a=0,f=r-n;a<f;a+=i)o.push(qr(t,a,a+i>f?f:a+i));return n===1?(e=t[r-1],o.push(I[e>>2]+I[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],o.push(I[e>>10]+I[e>>4&63]+I[e<<2&63]+"=")),o.join("")}});var ft=m((yo,st)=>{"use strict";var pe,l,ot={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
|
|
2
|
+
`,r:"\r",t:" "},Ie;function R(t){throw{name:"SyntaxError",message:t,at:pe,text:Ie}}function d(t){return t&&t!==l&&R("Expected '"+t+"' instead of '"+l+"'"),l=Ie.charAt(pe),pe+=1,l}function it(){var t,e="";for(l==="-"&&(e="-",d("-"));l>="0"&&l<="9";)e+=l,d();if(l===".")for(e+=".";d()&&l>="0"&&l<="9";)e+=l;if(l==="e"||l==="E")for(e+=l,d(),(l==="-"||l==="+")&&(e+=l,d());l>="0"&&l<="9";)e+=l,d();return t=Number(e),isFinite(t)||R("Bad number"),t}function at(){var t,e,r="",n;if(l==='"')for(;d();){if(l==='"')return d(),r;if(l==="\\")if(d(),l==="u"){for(n=0,e=0;e<4&&(t=parseInt(d(),16),!!isFinite(t));e+=1)n=n*16+t;r+=String.fromCharCode(n)}else if(typeof ot[l]=="string")r+=ot[l];else break;else r+=l}R("Bad string")}function $(){for(;l&&l<=" ";)d()}function zr(){switch(l){case"t":return d("t"),d("r"),d("u"),d("e"),!0;case"f":return d("f"),d("a"),d("l"),d("s"),d("e"),!1;case"n":return d("n"),d("u"),d("l"),d("l"),null;default:R("Unexpected '"+l+"'")}}function Wr(){var t=[];if(l==="["){if(d("["),$(),l==="]")return d("]"),t;for(;l;){if(t.push(ce()),$(),l==="]")return d("]"),t;d(","),$()}}R("Bad array")}function Yr(){var t,e={};if(l==="{"){if(d("{"),$(),l==="}")return d("}"),e;for(;l;){if(t=at(),$(),d(":"),Object.prototype.hasOwnProperty.call(e,t)&&R('Duplicate key "'+t+'"'),e[t]=ce(),$(),l==="}")return d("}"),e;d(","),$()}}R("Bad object")}function ce(){switch($(),l){case"{":return Yr();case"[":return Wr();case'"':return at();case"-":return it();default:return l>="0"&&l<="9"?it():zr()}}st.exports=function(t,e){var r;return Ie=t,pe=0,l=" ",r=ce(),$(),l&&R("Syntax error"),typeof e=="function"?function n(o,i){var a,f,s=o[i];if(s&&typeof s=="object")for(a in ce)Object.prototype.hasOwnProperty.call(s,a)&&(f=n(s,a),typeof f>"u"?delete s[a]:s[a]=f);return e.call(o,i,s)}({"":r},""):r}});var lt=m((go,ut)=>{"use strict";var je=/[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,T,ye,Kr={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},N;function $e(t){return je.lastIndex=0,je.test(t)?'"'+t.replace(je,function(e){var r=Kr[e];return typeof r=="string"?r:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+t+'"'}function de(t,e){var r,n,o,i,a=T,f,s=e[t];switch(s&&typeof s=="object"&&typeof s.toJSON=="function"&&(s=s.toJSON(t)),typeof N=="function"&&(s=N.call(e,t,s)),typeof s){case"string":return $e(s);case"number":return isFinite(s)?String(s):"null";case"boolean":case"null":return String(s);case"object":if(!s)return"null";if(T+=ye,f=[],Object.prototype.toString.apply(s)==="[object Array]"){for(i=s.length,r=0;r<i;r+=1)f[r]=de(r,s)||"null";return o=f.length===0?"[]":T?`[
|
|
3
|
+
`+T+f.join(`,
|
|
4
|
+
`+T)+`
|
|
5
|
+
`+a+"]":"["+f.join(",")+"]",T=a,o}if(N&&typeof N=="object")for(i=N.length,r=0;r<i;r+=1)n=N[r],typeof n=="string"&&(o=de(n,s),o&&f.push($e(n)+(T?": ":":")+o));else for(n in s)Object.prototype.hasOwnProperty.call(s,n)&&(o=de(n,s),o&&f.push($e(n)+(T?": ":":")+o));return o=f.length===0?"{}":T?`{
|
|
6
|
+
`+T+f.join(`,
|
|
7
|
+
`+T)+`
|
|
8
|
+
`+a+"}":"{"+f.join(",")+"}",T=a,o;default:}}ut.exports=function(t,e,r){var n;if(T="",ye="",typeof r=="number")for(n=0;n<r;n+=1)ye+=" ";else typeof r=="string"&&(ye=r);if(N=e,e&&typeof e!="function"&&(typeof e!="object"||typeof e.length!="number"))throw new Error("JSON.stringify");return de("",{"":t})}});var pt=m(Me=>{"use strict";Me.parse=ft();Me.stringify=lt()});var yt=m((ho,ct)=>{var Xr={}.toString;ct.exports=Array.isArray||function(t){return Xr.call(t)=="[object Array]"}});var Re=m((vo,gt)=>{"use strict";var dt=Object.prototype.toString;gt.exports=function(e){var r=dt.call(e),n=r==="[object Arguments]";return n||(n=r!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&dt.call(e.callee)==="[object Function]"),n}});var Et=m((bo,At)=>{"use strict";var xt;Object.keys||(ne=Object.prototype.hasOwnProperty,Be=Object.prototype.toString,mt=Re(),Ce=Object.prototype.propertyIsEnumerable,ht=!Ce.call({toString:null},"toString"),vt=Ce.call(function(){},"prototype"),oe=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],ge=function(t){var e=t.constructor;return e&&e.prototype===t},bt={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},wt=function(){if(typeof window>"u")return!1;for(var t in window)try{if(!bt["$"+t]&&ne.call(window,t)&&window[t]!==null&&typeof window[t]=="object")try{ge(window[t])}catch{return!0}}catch{return!0}return!1}(),Pt=function(t){if(typeof window>"u"||!wt)return ge(t);try{return ge(t)}catch{return!1}},xt=function(e){var r=e!==null&&typeof e=="object",n=Be.call(e)==="[object Function]",o=mt(e),i=r&&Be.call(e)==="[object String]",a=[];if(!r&&!n&&!o)throw new TypeError("Object.keys called on a non-object");var f=vt&&n;if(i&&e.length>0&&!ne.call(e,0))for(var s=0;s<e.length;++s)a.push(String(s));if(o&&e.length>0)for(var y=0;y<e.length;++y)a.push(String(y));else for(var p in e)!(f&&p==="prototype")&&ne.call(e,p)&&a.push(String(p));if(ht)for(var g=Pt(e),u=0;u<oe.length;++u)!(g&&oe[u]==="constructor")&&ne.call(e,oe[u])&&a.push(oe[u]);return a});var ne,Be,mt,Ce,ht,vt,oe,ge,bt,wt,Pt;At.exports=xt});var Ft=m((wo,Tt)=>{"use strict";var Zr=Array.prototype.slice,Qr=Re(),St=Object.keys,me=St?function(e){return St(e)}:Et(),Ot=Object.keys;me.shim=function(){if(Object.keys){var e=function(){var r=Object.keys(arguments);return r&&r.length===arguments.length}(1,2);e||(Object.keys=function(n){return Qr(n)?Ot(Zr.call(n)):Ot(n)})}else Object.keys=me;return Object.keys||me};Tt.exports=me});var jt=m((Po,It)=>{"use strict";var en="Function.prototype.bind called on incompatible ",tn=Object.prototype.toString,rn=Math.max,nn="[object Function]",kt=function(e,r){for(var n=[],o=0;o<e.length;o+=1)n[o]=e[o];for(var i=0;i<r.length;i+=1)n[i+e.length]=r[i];return n},on=function(e,r){for(var n=[],o=r||0,i=0;o<e.length;o+=1,i+=1)n[i]=e[o];return n},an=function(t,e){for(var r="",n=0;n<t.length;n+=1)r+=t[n],n+1<t.length&&(r+=e);return r};It.exports=function(e){var r=this;if(typeof r!="function"||tn.apply(r)!==nn)throw new TypeError(en+r);for(var n=on(arguments,1),o,i=function(){if(this instanceof o){var p=r.apply(this,kt(n,arguments));return Object(p)===p?p:this}return r.apply(e,kt(n,arguments))},a=rn(0,r.length-n.length),f=[],s=0;s<a;s++)f[s]="$"+s;if(o=Function("binder","return function ("+an(f,",")+"){ return binder.apply(this,arguments); }")(i),r.prototype){var y=function(){};y.prototype=r.prototype,o.prototype=new y,y.prototype=null}return o}});var he=m((xo,$t)=>{"use strict";var sn=jt();$t.exports=Function.prototype.bind||sn});var Rt=m((Ao,Mt)=>{"use strict";Mt.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var o=42;e[r]=o;for(r in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var i=Object.getOwnPropertySymbols(e);if(i.length!==1||i[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,r);if(a.value!==o||a.enumerable!==!0)return!1}return!0}});var _t=m((Eo,Ct)=>{"use strict";var Bt=typeof Symbol<"u"&&Symbol,fn=Rt();Ct.exports=function(){return typeof Bt!="function"||typeof Symbol!="function"||typeof Bt("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:fn()}});var Dt=m((So,Nt)=>{"use strict";var Ut={foo:{}},un=Object;Nt.exports=function(){return{__proto__:Ut}.foo===Ut.foo&&!({__proto__:null}instanceof un)}});var Ht=m((Oo,Lt)=>{"use strict";var ln=Function.prototype.call,pn=Object.prototype.hasOwnProperty,cn=he();Lt.exports=cn.call(ln,pn)});var Z=m((To,zt)=>{"use strict";var c,X=SyntaxError,Vt=Function,K=TypeError,_e=function(t){try{return Vt('"use strict"; return ('+t+").constructor;")()}catch{}},D=Object.getOwnPropertyDescriptor;if(D)try{D({},"")}catch{D=null}var Ue=function(){throw new K},yn=D?function(){try{return arguments.callee,Ue}catch{try{return D(arguments,"callee").get}catch{return Ue}}}():Ue,W=_t()(),dn=Dt()(),w=Object.getPrototypeOf||(dn?function(t){return t.__proto__}:null),Y={},gn=typeof Uint8Array>"u"||!w?c:w(Uint8Array),L={"%AggregateError%":typeof AggregateError>"u"?c:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?c:ArrayBuffer,"%ArrayIteratorPrototype%":W&&w?w([][Symbol.iterator]()):c,"%AsyncFromSyncIteratorPrototype%":c,"%AsyncFunction%":Y,"%AsyncGenerator%":Y,"%AsyncGeneratorFunction%":Y,"%AsyncIteratorPrototype%":Y,"%Atomics%":typeof Atomics>"u"?c:Atomics,"%BigInt%":typeof BigInt>"u"?c:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?c:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?c:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?c:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?c:Float32Array,"%Float64Array%":typeof Float64Array>"u"?c:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?c:FinalizationRegistry,"%Function%":Vt,"%GeneratorFunction%":Y,"%Int8Array%":typeof Int8Array>"u"?c:Int8Array,"%Int16Array%":typeof Int16Array>"u"?c:Int16Array,"%Int32Array%":typeof Int32Array>"u"?c:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":W&&w?w(w([][Symbol.iterator]())):c,"%JSON%":typeof JSON=="object"?JSON:c,"%Map%":typeof Map>"u"?c:Map,"%MapIteratorPrototype%":typeof Map>"u"||!W||!w?c:w(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?c:Promise,"%Proxy%":typeof Proxy>"u"?c:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?c:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?c:Set,"%SetIteratorPrototype%":typeof Set>"u"||!W||!w?c:w(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?c:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":W&&w?w(""[Symbol.iterator]()):c,"%Symbol%":W?Symbol:c,"%SyntaxError%":X,"%ThrowTypeError%":yn,"%TypedArray%":gn,"%TypeError%":K,"%Uint8Array%":typeof Uint8Array>"u"?c:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?c:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?c:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?c:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?c:WeakMap,"%WeakRef%":typeof WeakRef>"u"?c:WeakRef,"%WeakSet%":typeof WeakSet>"u"?c:WeakSet};if(w)try{null.error}catch(t){Jt=w(w(t)),L["%Error.prototype%"]=Jt}var Jt,mn=function t(e){var r;if(e==="%AsyncFunction%")r=_e("async function () {}");else if(e==="%GeneratorFunction%")r=_e("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=_e("async function* () {}");else if(e==="%AsyncGenerator%"){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var o=t("%AsyncGenerator%");o&&w&&(r=w(o.prototype))}return L[e]=r,r},Gt={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ie=he(),ve=Ht(),hn=ie.call(Function.call,Array.prototype.concat),vn=ie.call(Function.apply,Array.prototype.splice),qt=ie.call(Function.call,String.prototype.replace),be=ie.call(Function.call,String.prototype.slice),bn=ie.call(Function.call,RegExp.prototype.exec),wn=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Pn=/\\(\\)?/g,xn=function(e){var r=be(e,0,1),n=be(e,-1);if(r==="%"&&n!=="%")throw new X("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new X("invalid intrinsic syntax, expected opening `%`");var o=[];return qt(e,wn,function(i,a,f,s){o[o.length]=f?qt(s,Pn,"$1"):a||i}),o},An=function(e,r){var n=e,o;if(ve(Gt,n)&&(o=Gt[n],n="%"+o[0]+"%"),ve(L,n)){var i=L[n];if(i===Y&&(i=mn(n)),typeof i>"u"&&!r)throw new K("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:o,name:n,value:i}}throw new X("intrinsic "+e+" does not exist!")};zt.exports=function(e,r){if(typeof e!="string"||e.length===0)throw new K("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new K('"allowMissing" argument must be a boolean');if(bn(/^%?[^%]*%?$/,e)===null)throw new X("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=xn(e),o=n.length>0?n[0]:"",i=An("%"+o+"%",r),a=i.name,f=i.value,s=!1,y=i.alias;y&&(o=y[0],vn(n,hn([0,1],y)));for(var p=1,g=!0;p<n.length;p+=1){var u=n[p],S=be(u,0,1),b=be(u,-1);if((S==='"'||S==="'"||S==="`"||b==='"'||b==="'"||b==="`")&&S!==b)throw new X("property names with quotes must have matching quotes");if((u==="constructor"||!g)&&(s=!0),o+="."+u,a="%"+o+"%",ve(L,a))f=L[a];else if(f!=null){if(!(u in f)){if(!r)throw new K("base intrinsic for "+e+" exists, but the property is not available.");return}if(D&&p+1>=n.length){var k=D(f,u);g=!!k,g&&"get"in k&&!("originalValue"in k.get)?f=k.get:f=f[u]}else g=ve(f,u),f=f[u];g&&!s&&(L[a]=f)}}return f}});var Le=m((Fo,Wt)=>{"use strict";var En=Z(),Ne=En("%Object.defineProperty%",!0),De=function(){if(Ne)try{return Ne({},"a",{value:1}),!0}catch{return!1}return!1};De.hasArrayLengthDefineBug=function(){if(!De())return null;try{return Ne([],"length",{value:1}).length!==1}catch{return!0}};Wt.exports=De});var He=m((ko,Yt)=>{"use strict";var Sn=Z(),we=Sn("%Object.getOwnPropertyDescriptor%",!0);if(we)try{we([],"length")}catch{we=null}Yt.exports=we});var Zt=m((Io,Xt)=>{"use strict";var On=Le()(),Je=Z(),ae=On&&Je("%Object.defineProperty%",!0);if(ae)try{ae({},"a",{value:1})}catch{ae=!1}var Tn=Je("%SyntaxError%"),Q=Je("%TypeError%"),Kt=He();Xt.exports=function(e,r,n){if(!e||typeof e!="object"&&typeof e!="function")throw new Q("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new Q("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Q("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Q("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Q("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Q("`loose`, if provided, must be a boolean");var o=arguments.length>3?arguments[3]:null,i=arguments.length>4?arguments[4]:null,a=arguments.length>5?arguments[5]:null,f=arguments.length>6?arguments[6]:!1,s=!!Kt&&Kt(e,r);if(ae)ae(e,r,{configurable:a===null&&s?s.configurable:!a,enumerable:o===null&&s?s.enumerable:!o,value:n,writable:i===null&&s?s.writable:!i});else if(f||!o&&!i&&!a)e[r]=n;else throw new Tn("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")}});var or=m((jo,nr)=>{"use strict";var rr=Z(),Qt=Zt(),Fn=Le()(),er=He(),tr=rr("%TypeError%"),kn=rr("%Math.floor%");nr.exports=function(e,r){if(typeof e!="function")throw new tr("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||kn(r)!==r)throw new tr("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],o=!0,i=!0;if("length"in e&&er){var a=er(e,"length");a&&!a.configurable&&(o=!1),a&&!a.writable&&(i=!1)}return(o||i||!n)&&(Fn?Qt(e,"length",r,!0,!0):Qt(e,"length",r)),e}});var ur=m(($o,Pe)=>{"use strict";var Ge=he(),ee=Z(),In=or(),jn=ee("%TypeError%"),ar=ee("%Function.prototype.apply%"),sr=ee("%Function.prototype.call%"),fr=ee("%Reflect.apply%",!0)||Ge.call(sr,ar),se=ee("%Object.defineProperty%",!0),$n=ee("%Math.max%");if(se)try{se({},"a",{value:1})}catch{se=null}Pe.exports=function(e){if(typeof e!="function")throw new jn("a function is required");var r=fr(Ge,sr,arguments);return In(r,1+$n(0,e.length-(arguments.length-1)),!0)};var ir=function(){return fr(Ge,ar,arguments)};se?se(Pe.exports,"apply",{value:ir}):Pe.exports.apply=ir});var cr=m((Mo,pr)=>{"use strict";var xe=(typeof JSON<"u"?JSON:pt()).stringify,Mn=yt(),Rn=Ft(),Bn=ur(),lr=function(e,r){for(var n="",o=0;o<e;o+=1)n+=r;return n},Cn=function(t,e,r){return r};pr.exports=function(e){var r=arguments.length>1?arguments[1]:void 0,n=r&&r.space||"";typeof n=="number"&&(n=lr(n," "));var o=!!r&&typeof r.cycles=="boolean"&&r.cycles,i=r&&r.replacer?Bn(r.replacer):Cn,a=typeof r=="function"?r:r&&r.cmp,f=a&&function(y){var p=a.length>2&&function(u){return y[u]};return function(g,u){return a({key:g,value:y[g]},{key:u,value:y[u]},p?{__proto__:null,get:p}:void 0)}},s=[];return function y(p,g,u,S){var b=n?`
|
|
9
|
+
`+lr(S,n):"",k=n?": ":":";if(u&&u.toJSON&&typeof u.toJSON=="function"&&(u=u.toJSON()),u=i(p,g,u),u!==void 0){if(typeof u!="object"||u===null)return xe(u);if(Mn(u)){for(var j="",v=0;v<u.length;v++){var _=y(u,v,u[v],S+1)||xe(null);j+=b+n+_,v+1<u.length&&(j+=",")}return"["+j+b+"]"}if(s.indexOf(u)!==-1){if(o)return xe("__cycle__");throw new TypeError("Converting circular structure to JSON")}else s.push(u);for(var P=Rn(u).sort(f&&f(u)),j="",M=!1,v=0;v<P.length;v++){var g=P[v],Qe=y(u,g,u[g],S+1);if(Qe){var Mr=xe(g)+k+Qe;j+=(M?",":"")+b+n+Mr,M=!0}}return s.splice(s.indexOf(u),1),"{"+j+b+"}"}}({"":e},"",e,0)}});var Ye=m(h=>{"use strict";var mr=h&&h.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]]);return r};Object.defineProperty(h,"__esModule",{value:!0});h.isSchema=h.isValidSchema=h.isDiscriminatorForm=h.isValuesForm=h.isPropertiesForm=h.isElementsForm=h.isEnumForm=h.isTypeForm=h.isRefForm=h.isEmptyForm=void 0;function Dn(t){let{definitions:e,nullable:r,metadata:n}=t,o=mr(t,["definitions","nullable","metadata"]);return Object.keys(o).length===0}h.isEmptyForm=Dn;function hr(t){return"ref"in t}h.isRefForm=hr;function Ln(t){return"type"in t}h.isTypeForm=Ln;function vr(t){return"enum"in t}h.isEnumForm=vr;function br(t){return"elements"in t}h.isElementsForm=br;function We(t){return"properties"in t||"optionalProperties"in t}h.isPropertiesForm=We;function wr(t){return"values"in t}h.isValuesForm=wr;function Pr(t){return"discriminator"in t}h.isDiscriminatorForm=Pr;function H(t,e){if(e===void 0&&(e=t),t.definitions!==void 0){if(e!==t)return!1;for(let r of Object.values(t.definitions))if(!H(r,e))return!1}if(hr(t)&&!(t.ref in(e.definitions||{}))||vr(t)&&(t.enum.length===0||t.enum.length!==new Set(t.enum).size))return!1;if(br(t))return H(t.elements,e);if(We(t)){for(let r of Object.values(t.properties||{}))if(!H(r,e))return!1;for(let r of Object.values(t.optionalProperties||{}))if(!H(r,e))return!1;for(let r of Object.keys(t.properties||{}))if(r in(t.optionalProperties||{}))return!1}if(wr(t))return H(t.values,e);if(Pr(t)){for(let r of Object.values(t.mapping))if(!H(r,e)||!We(r)||r.nullable||t.discriminator in(r.properties||{})||t.discriminator in(r.optionalProperties||{}))return!1}return!0}h.isValidSchema=H;var Hn=[[!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]],Jn=["boolean","float32","float64","int8","uint8","int16","uint16","int32","uint32","string","timestamp"];function J(t){if(typeof t!="object"||Array.isArray(t)||t===null)return!1;let e=t,{definitions:r=void 0,nullable:n=void 0,metadata:o=void 0,ref:i=void 0,type:a=void 0,enum:f=void 0,elements:s=void 0,properties:y=void 0,optionalProperties:p=void 0,additionalProperties:g=void 0,values:u=void 0,discriminator:S=void 0,mapping:b=void 0}=e,k=mr(e,["definitions","nullable","metadata","ref","type","enum","elements","properties","optionalProperties","additionalProperties","values","discriminator","mapping"]),v=[i!==void 0,a!==void 0,f!==void 0,s!==void 0,y!==void 0,p!==void 0,g!==void 0,u!==void 0,S!==void 0,b!==void 0],_=!1;for(let P of Hn)_=_||P.every((j,M)=>j===v[M]);if(!_)return!1;if(r!==void 0){if(typeof r!="object"||Array.isArray(r)||r===null)return!1;for(let P of Object.values(r))if(!J(P))return!1}if(n!==void 0&&typeof n!="boolean"||o!==void 0&&(typeof o!="object"||Array.isArray(o)||o===null)||i!==void 0&&typeof i!="string"||a!==void 0&&(typeof a!="string"||!Jn.includes(a))||f!==void 0&&(!Array.isArray(f)||!f.every(P=>typeof P=="string"))||s!==void 0&&!J(s))return!1;if(y!==void 0){if(typeof y!="object"||Array.isArray(y)||y===null)return!1;for(let P of Object.values(y))if(!J(P))return!1}if(p!==void 0){if(typeof p!="object"||Array.isArray(p)||p===null)return!1;for(let P of Object.values(p))if(!J(P))return!1}if(g!==void 0&&typeof g!="boolean"||u!==void 0&&!J(u)||S!==void 0&&typeof S!="string")return!1;if(b!==void 0){if(typeof b!="object"||Array.isArray(b)||b===null)return!1;for(let P of Object.values(b))if(!J(P))return!1}return Object.keys(k).length===0}h.isSchema=J});var xr=m(Ke=>{"use strict";Object.defineProperty(Ke,"__esModule",{value:!0});var Gn=/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(\.\d+)?([zZ]|((\+|-)(\d{2}):(\d{2})))$/;function qn(t){let e=t.match(Gn);if(e===null)return!1;let r=parseInt(e[1],10),n=parseInt(e[2],10),o=parseInt(e[3],10),i=parseInt(e[4],10),a=parseInt(e[5],10),f=parseInt(e[6],10);return!(n>12||o>Vn(r,n)||i>23||a>59||f>60)}Ke.default=qn;function Vn(t,e){return e===2?zn(t)?29:28:Wn[e]}function zn(t){return t%4===0&&(t%100!==0||t%400===0)}var Wn=[0,31,0,31,30,31,30,31,31,30,31,30,31]});var Ar=m(B=>{"use strict";var Yn=B&&B.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(B,"__esModule",{value:!0});B.validate=B.MaxDepthExceededError=void 0;var Kn=Yn(xr()),G=Ye(),Ee=class extends Error{};B.MaxDepthExceededError=Ee;var Se=class extends Error{};function Xn(t,e,r){let n={errors:[],instanceTokens:[],schemaTokens:[[]],root:t,config:r||{maxDepth:0,maxErrors:0}};try{z(n,t,e)}catch(o){if(!(o instanceof Se))throw o}return n.errors}B.validate=Xn;function z(t,e,r,n){if(!(e.nullable&&r===null)){if(G.isRefForm(e)){if(t.schemaTokens.length===t.config.maxDepth)throw new Ee;t.schemaTokens.push(["definitions",e.ref]),z(t,t.root.definitions[e.ref],r),t.schemaTokens.pop()}else if(G.isTypeForm(e)){switch(A(t,"type"),e.type){case"boolean":typeof r!="boolean"&&E(t);break;case"float32":case"float64":typeof r!="number"&&E(t);break;case"int8":te(t,r,-128,127);break;case"uint8":te(t,r,0,255);break;case"int16":te(t,r,-32768,32767);break;case"uint16":te(t,r,0,65535);break;case"int32":te(t,r,-2147483648,2147483647);break;case"uint32":te(t,r,0,4294967295);break;case"string":typeof r!="string"&&E(t);break;case"timestamp":typeof r!="string"?E(t):Kn.default(r)||E(t);break}O(t)}else if(G.isEnumForm(e))A(t,"enum"),(typeof r!="string"||!e.enum.includes(r))&&E(t),O(t);else if(G.isElementsForm(e)){if(A(t,"elements"),Array.isArray(r))for(let[o,i]of r.entries())q(t,o.toString()),z(t,e.elements,i),V(t);else E(t);O(t)}else if(G.isPropertiesForm(e))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){if(e.properties!==void 0){A(t,"properties");for(let[o,i]of Object.entries(e.properties))A(t,o),r.hasOwnProperty(o)?(q(t,o),z(t,i,r[o]),V(t)):E(t),O(t);O(t)}if(e.optionalProperties!==void 0){A(t,"optionalProperties");for(let[o,i]of Object.entries(e.optionalProperties))A(t,o),r.hasOwnProperty(o)&&(q(t,o),z(t,i,r[o]),V(t)),O(t);O(t)}if(e.additionalProperties!==!0)for(let o of Object.keys(r)){let i=e.properties&&o in e.properties,a=e.optionalProperties&&o in e.optionalProperties;!i&&!a&&o!==n&&(q(t,o),E(t),V(t))}}else e.properties!==void 0?A(t,"properties"):A(t,"optionalProperties"),E(t),O(t);else if(G.isValuesForm(e)){if(A(t,"values"),typeof r=="object"&&r!==null&&!Array.isArray(r))for(let[o,i]of Object.entries(r))q(t,o),z(t,e.values,i),V(t);else E(t);O(t)}else if(G.isDiscriminatorForm(e))if(typeof r=="object"&&r!==null&&!Array.isArray(r))if(r.hasOwnProperty(e.discriminator)){let o=r[e.discriminator];typeof o=="string"?o in e.mapping?(A(t,"mapping"),A(t,o),z(t,e.mapping[o],r,e.discriminator),O(t),O(t)):(A(t,"mapping"),q(t,e.discriminator),E(t),V(t),O(t)):(A(t,"discriminator"),q(t,e.discriminator),E(t),V(t),O(t))}else A(t,"discriminator"),E(t),O(t);else A(t,"discriminator"),E(t),O(t)}}function te(t,e,r,n){(typeof e!="number"||!Number.isInteger(e)||e<r||e>n)&&E(t)}function q(t,e){t.instanceTokens.push(e)}function V(t){t.instanceTokens.pop()}function A(t,e){t.schemaTokens[t.schemaTokens.length-1].push(e)}function O(t){t.schemaTokens[t.schemaTokens.length-1].pop()}function E(t){if(t.errors.push({instancePath:[...t.instanceTokens],schemaPath:[...t.schemaTokens[t.schemaTokens.length-1]]}),t.errors.length===t.config.maxErrors)throw new Se}});var Sr=m(C=>{"use strict";var Zn=C&&C.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Er=C&&C.__exportStar||function(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&Zn(e,t,r)};Object.defineProperty(C,"__esModule",{value:!0});Er(Ye(),C);Er(Ar(),C)});var Ir=Fe(nt()),jr=Fe(cr());var Ae,_n=new Uint8Array(16);function qe(){if(!Ae&&(Ae=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ae))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ae(_n)}var x=[];for(let t=0;t<256;++t)x.push((t+256).toString(16).slice(1));function yr(t,e=0){return x[t[e+0]]+x[t[e+1]]+x[t[e+2]]+x[t[e+3]]+"-"+x[t[e+4]]+x[t[e+5]]+"-"+x[t[e+6]]+x[t[e+7]]+"-"+x[t[e+8]]+x[t[e+9]]+"-"+x[t[e+10]]+x[t[e+11]]+x[t[e+12]]+x[t[e+13]]+x[t[e+14]]+x[t[e+15]]}var Un=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Ve={randomUUID:Un};function Nn(t,e,r){if(Ve.randomUUID&&!e&&!t)return Ve.randomUUID();t=t||{};let n=t.random||(t.rng||qe)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){r=r||0;for(let o=0;o<16;++o)e[r+o]=n[o];return e}return yr(n)}var fe=Nn;function ze(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}function dr(t){return new Uint8Array((t.match(/../g)??[]).map(e=>parseInt(e,16)))}function gr(t){let e=0;for(let o of t)e+=o.length;let r=new Uint8Array(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return r}var Or=Fe(Sr());function ue(t,e){if((0,Or.validate)(t,e).length)throw new Error(`couldn't validate schema: ${JSON.stringify(e)} didn't match schema ${JSON.stringify(t)}`)}var Tr="3",$r="https://webapp-prod.cloud.remarkable.engineering",Qn="https://internal.cloud.remarkable.com",Fr="x-goog-generation",eo="x-goog-if-generation-match",to="x-goog-content-length-range",Qo=["Ballpoint","Ballpointv2","Brush","Calligraphy","ClearPage","EraseSection","Eraser","Fineliner","Finelinerv2","Highlighter","Highlighterv2","Marker","Markerv2","Paintbrush","Paintbrushv2","Pencilv2","SharpPencil","SharpPencilv2","SolidPen","ZoomTool"],ei=["Maison Neue","EB Garamond","Noto Sans","Noto Serif","Noto Mono","Noto Sans UI"],ro={xs:.7,sm:.8,md:1,lg:1.2,xl:1.5,xx:2},no={sm:50,md:125,rr:180,lg:200},oo={df:-1,md:100,lg:150,xl:200},io={properties:{docID:{type:"string"},hash:{type:"string"}}},ao={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"}},Te={version:{type:"int32"},pinned:{type:"boolean"},synced:{type:"boolean"},modified:{type:"boolean"},deleted:{type:"boolean"},metadatamodified:{type:"boolean"},parent:{type:"string"}},so={discriminator:"type",mapping:{CollectionType:{properties:Oe,optionalProperties:Te,additionalProperties:!0},DocumentType:{properties:Oe,optionalProperties:{...Te,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"},createdTime:{type:"string"}},additionalProperties:!0}}},kr={id:{type:"string"},hash:{type:"string"}},fo={discriminator:"type",mapping:{CollectionType:{properties:{...Oe,...kr},optionalProperties:Te,additionalProperties:!0},DocumentType:{properties:{...Oe,...kr,fileType:{enum:["notebook","epub","pdf",""]}},optionalProperties:{...Te,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"},createdTime:{type:"string"}},additionalProperties:!0}}},re=class extends Error{status;statusText;constructor(e,r,n){super(n),this.status=e,this.statusText=r}},Xe=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 ti(t,{deviceDesc:e="browser-chrome",uuid:r=fe(),authHost:n=$r,fetch:o=globalThis.fetch}={}){if(t.length!==8)throw new Error(`code should be length 8, but was ${t.length}`);let i=await o(`${n}/token/json/2/device/new`,{method:"POST",headers:{Authorization:"Bearer"},body:JSON.stringify({code:t,deviceDesc:e,deviceID:r})});if(i.ok)return await i.text();throw new re(i.status,i.statusText,"couldn't register api")}function uo({hash:t,type:e,documentId:r,subfiles:n,size:o}){return`${t}:${e}:${r}:${n}:${o}
|
|
10
|
+
`}function lo(t){let[e,r,n,o,i]=t.split(":");if(e===void 0||r===void 0||n===void 0||o===void 0||i===void 0)throw new Error(`entries line didn't contain five fields: '${t}'`);if(r==="80000000")return{hash:e,type:r,documentId:n,subfiles:parseInt(o),size:BigInt(i)};if(r==="0"){if(o!=="0")throw new Error(`file type entry had nonzero number of subfiles: ${o}`);return{hash:e,type:r,documentId:n,subfiles:0,size:BigInt(i)}}else throw new Error(`entries line contained invalid type: ${r}`)}var Ze=class{#u;#s;#f;#r;#n;#e=new Map;#t=null;constructor(e,r,n,o,i,a){this.#u=e,this.#s=r,this.#f=n,this.#r=o,this.#n=i;for(let[f,s]of a)this.#e.set(f,Promise.resolve(s))}async#o(e,{body:r,method:n="POST",headers:o={}}){let i=await this.#s(e,{method:n,headers:{Authorization:`Bearer ${this.#u}`,...o},body:r});if(i.ok)return i;{let a=await i.text();throw new re(i.status,i.statusText,`failed reMarkable request: ${a}`)}}async#i({url:e,method:r,maxuploadsize_bytes:n},o,i={}){let a=n?{...i,[to]:`0,${n}`}:i,f=await this.#s(e,{method:r,body:o,headers:a});if(f.ok)return f;{let s=await f.text();throw new re(f.status,f.statusText,s)}}async#a(e,r,n){let o=r===void 0?"downloads":"uploads",i=n&&r!==null&&r!==void 0?`{ "http_method": "PUT", "relative_path": "${e}", "root_schema": "${n}", "generation": ${r} }`:JSON.stringify({http_method:"GET",relative_path:e}),f=await(await this.#o(`${this.#r}/sync/v2/signed-urls/${o}`,{body:i})).text(),s=JSON.parse(f);return ue(ao,s),s}async getRootHash({cache:e=!0}={}){if(e)for(;this.#t;)try{let[i,a]=await this.#t;return[i,a]}catch{}let r=(async()=>{try{let i=await this.#a("root"),a=await this.#i(i),f=a.headers.get(Fr);if(f)return[await a.text(),BigInt(f)];throw new Error("no generation header in root hash")}catch(i){throw this.#t=null,i}})();this.#t=r;let[n,o]=await r;return[n,o]}async putRootHash(e,r){let n=await this.#a("root",r,e),o;try{o=await this.#i(n,e,{[eo]:`${r}`})}catch(f){throw f instanceof re&&f.status===412?(this.#t=null,new Xe):f}let i=o.headers.get(Fr);if(!i)throw new Error("no generation header in root hash");let a=BigInt(i);return this.#t=Promise.resolve([e,a]),a}async#l(e){let r=this.#e.get(e);for(;r;)try{let o=await r;if(o)return o;r=void 0}catch{r=this.#e.get(e)}let n=(async()=>{let o=await this.#a(e);return await(await this.#i(o)).arrayBuffer()})();return this.#e.set(e,n.then(o=>o.byteLength<this.#n?o:null,o=>{throw this.#e.delete(e),o})),await n}async getBuffer(e){let r=await this.#l(e);return r.byteLength<this.#n?r.slice(0):r}async getText(e){let r=await this.#l(e);return new TextDecoder().decode(r)}async getJson(e){let r=await this.getText(e);return JSON.parse(r)}async getMetadata(e){let r=await this.getJson(e);return ue(so,r),r}async getEntries(e){if(e===void 0){let[i]=await this.getRootHash({cache:!0});e=i}let r=await this.getText(e),[n,...o]=r.slice(0,-1).split(`
|
|
11
|
+
`);if(n!==Tr)throw new Error(`got unexpected schema version: ${n}`);return o.map(lo)}async#p(e,r){let n=this.#e.get(e);if(n)try{await n;return}catch{}let o=(async()=>{try{let i=await this.#a(e,null);return await this.#i(i,r),r.byteLength<this.#n?r:null}catch(i){throw this.#e.delete(e),i}})();this.#e.set(e,o),await o}async putEntries(e,r){let n=new TextEncoder;r.sort((p,g)=>p.documentId.localeCompare(g.documentId));let o=gr(r.map(p=>dr(p.hash))),i=await this.#f.digest("SHA-256",o),a=ze(i),f=r.map(uo).join(""),s=`${Tr}
|
|
12
|
+
${f}`,y=n.encode(s);return await this.#p(a,y),{hash:a,type:"80000000",documentId:e,subfiles:r.length,size:0n}}async putBuffer(e,r){let n=await this.#f.digest("SHA-256",r),o=ze(n);return await this.#p(o,r),{hash:o,type:"0",documentId:e,subfiles:0,size:BigInt(r.byteLength)}}async putText(e,r){let n=new TextEncoder;return await this.putBuffer(e,n.encode(r))}async putJson(e,r){return await this.putText(e,(0,jr.default)(r))}async putMetadata(e,r){return await this.putJson(`${e}.metadata`,r)}async putCollection(e,r=""){let n=fe(),o=`${new Date().valueOf()}`,i=[],a={type:"CollectionType",visibleName:e,version:0,parent:r,synced:!0,lastModified:o};i.push(this.putMetadata(n,a)),i.push(this.putText(`${n}.content`,"{}"));let f=await Promise.all(i);return await this.putEntries(n,f)}async#c(e,r,n,o,i){if(i.fileType!==n)throw new Error(`internal error: fileTypes don't match: ${n}, ${i.fileType}`);let a=fe(),f=`${new Date().valueOf()}`,s=[];s.push(this.putBuffer(`${a}.${n}`,r));let y={type:"DocumentType",visibleName:e,version:0,parent:o,synced:!0,lastModified:f};s.push(this.putMetadata(a,y)),s.push(this.putText(`${a}.content`,JSON.stringify(i)));let p=await Promise.all(s);return await this.putEntries(a,p)}async putEpub(e,r,{parent:n="",margins:o=125,orientation:i,textAlignment:a,textScale:f=1,lineHeight:s=-1,fontName:y="",cover:p="visited",lastTool:g}={}){let u={dummyDocument:!1,extraMetadata:{LastTool:g},fileType:"epub",pageCount:0,lastOpenedPage:0,lineHeight:typeof s=="string"?oo[s]:s,margins:typeof o=="string"?no[o]:o,textScale:typeof f=="string"?ro[f]:f,pages:[],coverPageNumber:p==="first"?0:-1,formatVersion:1,orientation:i,textAlignment:a,fontName:y};return await this.#c(e,r,"epub",n,u)}async putPdf(e,r,{parent:n="",orientation:o,cover:i="first",lastTool:a}={}){let f={dummyDocument:!1,extraMetadata:{LastTool:a},fileType:"pdf",pageCount:0,lastOpenedPage:0,lineHeight:-1,margins:125,textScale:1,pages:[],coverPageNumber:i==="first"?0:-1,formatVersion:1,orientation:o};return await this.#c(e,r,"pdf",n,f)}async syncComplete(e){let r=`{ "generation": ${e} }`;await this.#o(`${this.#r}/sync/v2/sync-complete`,{body:r})}async#y(e,r,n){let{hash:o}=await this.putEntries("",r),i=await this.putRootHash(o,e);if(n)try{return await this.syncComplete(i),!0}catch{return!1}else return!1}async create(e,{cache:r=!0,sync:n=!0}={}){let[o,i]=await this.getRootHash({cache:r}),a=await this.getEntries(o);return a.push(e),await this.#y(i,a,n)}async move(e,r,{cache:n=!0,sync:o=!0}={}){let[i,a]=await this.getRootHash({cache:n}),f=await this.getEntries(i);if(!(!r||r==="trash")){let v=f.find(M=>M.documentId===r);if(v){if(v.type!=="80000000")throw new Error(`destination id was a raw file: ${r}`)}else throw new Error(`destination id not found: ${r}`);let _=await this.getEntries(v.hash),[P]=_.filter(M=>M.documentId===`${r}.metadata`);if(!P)throw new Error(`destination id didn't have metadata: ${r}`);if((await this.getMetadata(P.hash)).type!=="CollectionType")throw new Error(`destination id wasn't a collection: ${r}`)}let s=f.findIndex(v=>v.documentId===e);if(s===-1)throw new Error(`document not found: ${e}`);let[y]=f.splice(s,1);if(y.type!=="80000000")throw new Error(`document was a raw file: ${e}`);let p=await this.getEntries(y.hash),g=p.findIndex(v=>v.documentId===`${e}.metadata`);if(g===-1)throw new Error(`document didn't have metadata: ${e}`);let[u]=p.splice(g,1),S=await this.getMetadata(u.hash);S.parent=r;let b=await this.putMetadata(e,S);p.push(b);let k=await this.putEntries(e,p);return f.push(k),await this.#y(a,f,o)}async getEntriesMetadata(){let r=await(await this.#o(`${this.#r}/doc/v2/files`,{method:"GET",headers:{"rm-source":"RoR-Browser"}})).text(),n=JSON.parse(r);return ue({elements:fo},n),n}async#d(e,r,n){let i=new TextEncoder().encode(JSON.stringify({file_name:e})),f=await(await this.#o(`${this.#r}/doc/v2/files`,{body:r,headers:{"content-type":n,"rm-meta":(0,Ir.fromByteArray)(i),"rm-source":"RoR-Browser"}})).text(),s=JSON.parse(f);return ue(io,s),s}async uploadEpub(e,r){return await this.#d(e,r,"application/epub+zip")}async uploadPdf(e,r){return await this.#d(e,r,"application/pdf")}async getCache(){let e=[];for(let[o,i]of this.#e)e.push(i.then(a=>[o,a],()=>[o,null]));let r=await Promise.all(e),n=new Map;for(let[o,i]of r)i&&n.set(o,i);return n}};async function ri(t,{fetch:e=globalThis.fetch,subtle:r=globalThis.crypto?.subtle,authHost:n=$r,syncHost:o=Qn,cacheLimitBytes:i=1048576,initCache:a=[]}={}){if(!r)throw new Error("subtle was missing, try specifying it manually");let f=await e(`${n}/token/json/2/user/new`,{method:"POST",headers:{Authorization:`Bearer ${t}`}});if(!f.ok)throw new Error(`couldn't fetch auth token: ${f.statusText}`);let s=await f.text();return new Ze(s,e,r,o,i,a)}export{Xe as GenerationError,re as ResponseError,ei as builtinFontNames,oo as builtinLineHeights,no as builtinMargins,ro as builtinTextScales,Qo as builtinTools,uo as formatEntry,lo as parseEntry,ti as register,ri as remarkable};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";(()=>{var
|
|
2
|
-
`,r:"\r",t:" "},
|
|
3
|
-
`+
|
|
4
|
-
`+
|
|
5
|
-
`+a+"]":"["+f.join(",")+"]",
|
|
6
|
-
`+
|
|
7
|
-
`+
|
|
8
|
-
`+a+"}":"{"+f.join(",")+"}",E=a,i;default:}}ke.exports=function(e,t,r){var n;if(E="",W="",typeof r=="number")for(n=0;n<r;n+=1)W+=" ";else typeof r=="string"&&(W=r);if(R=t,t&&typeof t!="function"&&(typeof t!="object"||typeof t.length!="number"))throw new Error("JSON.stringify");return Q("",{"":e})}});var Me=S(le=>{"use strict";le.parse=Se();le.stringify=Fe()});var je=S((Wt,Ce)=>{"use strict";var X=typeof JSON<"u"?JSON:Me(),ht=Array.isArray||function(e){return{}.toString.call(e)==="[object Array]"},gt=Object.keys||function(e){var t=Object.prototype.hasOwnProperty||function(){return!0},r=[];for(var n in e)t.call(e,n)&&r.push(n);return r};Ce.exports=function(e,t){t||(t={}),typeof t=="function"&&(t={cmp:t});var r=t.space||"";typeof r=="number"&&(r=Array(r+1).join(" "));var n=typeof t.cycles=="boolean"?t.cycles:!1,i=t.replacer||function(f,s){return s},o=t.cmp&&function(f){return function(s){return function(p,u){var g={key:p,value:s[p]},x={key:u,value:s[u]};return f(g,x)}}}(t.cmp),a=[];return function f(s,p,u,g){var x=r?`
|
|
9
|
-
`+new Array(g+1).join(r):"",F=r?": ":":";if(u&&u.toJSON&&typeof u.toJSON=="function"&&(u=u.toJSON()),u=i.call(s,p,u),u!==void 0){if(typeof u!="object"||u===null)return X.stringify(u);if(ht(u)){for(var A=[],y=0;y<u.length;y++){var J=f(u,y,u[y],g+1)||X.stringify(null);A.push(x+r+J)}return"["+A.join(",")+x+"]"}if(a.indexOf(u)!==-1){if(n)return X.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}else a.push(u);for(var P=gt(u).sort(o&&o(u)),A=[],y=0;y<P.length;y++){var p=P[y],m=f(u,p,u[p],g+1);if(m){var G=X.stringify(p)+F+m;A.push(x+r+G)}}return a.splice(a.indexOf(u),1),"{"+A.join(",")+x+"}"}}({"":e},"",e,0)}});var me=S(d=>{"use strict";var _e=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 xt(e){let{definitions:t,nullable:r,metadata:n}=e,i=_e(e,["definitions","nullable","metadata"]);return Object.keys(i).length===0}d.isEmptyForm=xt;function Ne(e){return"ref"in e}d.isRefForm=Ne;function Et(e){return"type"in e}d.isTypeForm=Et;function $e(e){return"enum"in e}d.isEnumForm=$e;function Le(e){return"elements"in e}d.isElementsForm=Le;function ye(e){return"properties"in e||"optionalProperties"in e}d.isPropertiesForm=ye;function De(e){return"values"in e}d.isValuesForm=De;function He(e){return"discriminator"in e}d.isDiscriminatorForm=He;function I(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(!I(r,t))return!1}if(Ne(e)&&!(e.ref in(t.definitions||{}))||$e(e)&&(e.enum.length===0||e.enum.length!==new Set(e.enum).size))return!1;if(Le(e))return I(e.elements,t);if(ye(e)){for(let r of Object.values(e.properties||{}))if(!I(r,t))return!1;for(let r of Object.values(e.optionalProperties||{}))if(!I(r,t))return!1;for(let r of Object.keys(e.properties||{}))if(r in(e.optionalProperties||{}))return!1}if(De(e))return I(e.values,t);if(He(e)){for(let r of Object.values(e.mapping))if(!I(r,t)||!ye(r)||r.nullable||e.discriminator in(r.properties||{})||e.discriminator in(r.optionalProperties||{}))return!1}return!0}d.isValidSchema=I;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]],Tt=["boolean","float32","float64","int8","uint8","int16","uint16","int32","uint32","string","timestamp"];function _(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:o=void 0,type:a=void 0,enum:f=void 0,elements:s=void 0,properties:p=void 0,optionalProperties:u=void 0,additionalProperties:g=void 0,values:x=void 0,discriminator:F=void 0,mapping:y=void 0}=t,J=_e(t,["definitions","nullable","metadata","ref","type","enum","elements","properties","optionalProperties","additionalProperties","values","discriminator","mapping"]),P=[o!==void 0,a!==void 0,f!==void 0,s!==void 0,p!==void 0,u!==void 0,g!==void 0,x!==void 0,F!==void 0,y!==void 0],A=!1;for(let m of Pt)A=A||m.every((G,V)=>G===P[V]);if(!A)return!1;if(r!==void 0){if(typeof r!="object"||Array.isArray(r)||r===null)return!1;for(let m of Object.values(r))if(!_(m))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"||a!==void 0&&(typeof a!="string"||!Tt.includes(a))||f!==void 0&&(!Array.isArray(f)||!f.every(m=>typeof m=="string"))||s!==void 0&&!_(s))return!1;if(p!==void 0){if(typeof p!="object"||Array.isArray(p)||p===null)return!1;for(let m of Object.values(p))if(!_(m))return!1}if(u!==void 0){if(typeof u!="object"||Array.isArray(u)||u===null)return!1;for(let m of Object.values(u))if(!_(m))return!1}if(g!==void 0&&typeof g!="boolean"||x!==void 0&&!_(x)||F!==void 0&&typeof F!="string")return!1;if(y!==void 0){if(typeof y!="object"||Array.isArray(y)||y===null)return!1;for(let m of Object.values(y))if(!_(m))return!1}return Object.keys(J).length===0}d.isSchema=_});var Ue=S(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});var At=/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(\.\d+)?([zZ]|((\+|-)(\d{2}):(\d{2})))$/;function Ot(e){let t=e.match(At);if(t===null)return!1;let r=parseInt(t[1],10),n=parseInt(t[2],10),i=parseInt(t[3],10),o=parseInt(t[4],10),a=parseInt(t[5],10),f=parseInt(t[6],10);return!(n>12||i>St(r,n)||o>23||a>59||f>60)}he.default=Ot;function St(e,t){return t===2?kt(e)?29:28:Ft[t]}function kt(e){return e%4===0&&(e%100!==0||e%400===0)}var Ft=[0,31,0,31,30,31,30,31,31,30,31,30,31]});var Je=S(C=>{"use strict";var Mt=C&&C.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(C,"__esModule",{value:!0});C.validate=C.MaxDepthExceededError=void 0;var Ct=Mt(Ue()),N=me(),te=class extends Error{};C.MaxDepthExceededError=te;var re=class extends Error{};function jt(e,t,r){let n={errors:[],instanceTokens:[],schemaTokens:[[]],root:e,config:r||{maxDepth:0,maxErrors:0}};try{D(n,e,t)}catch(i){if(!(i instanceof re))throw i}return n.errors}C.validate=jt;function D(e,t,r,n){if(!(t.nullable&&r===null)){if(N.isRefForm(t)){if(e.schemaTokens.length===e.config.maxDepth)throw new te;e.schemaTokens.push(["definitions",t.ref]),D(e,e.root.definitions[t.ref],r),e.schemaTokens.pop()}else if(N.isTypeForm(t)){switch(b(e,"type"),t.type){case"boolean":typeof r!="boolean"&&w(e);break;case"float32":case"float64":typeof r!="number"&&w(e);break;case"int8":H(e,r,-128,127);break;case"uint8":H(e,r,0,255);break;case"int16":H(e,r,-32768,32767);break;case"uint16":H(e,r,0,65535);break;case"int32":H(e,r,-2147483648,2147483647);break;case"uint32":H(e,r,0,4294967295);break;case"string":typeof r!="string"&&w(e);break;case"timestamp":typeof r!="string"?w(e):Ct.default(r)||w(e);break}v(e)}else if(N.isEnumForm(t))b(e,"enum"),(typeof r!="string"||!t.enum.includes(r))&&w(e),v(e);else if(N.isElementsForm(t)){if(b(e,"elements"),Array.isArray(r))for(let[i,o]of r.entries())$(e,i.toString()),D(e,t.elements,o),L(e);else w(e);v(e)}else if(N.isPropertiesForm(t))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){if(t.properties!==void 0){b(e,"properties");for(let[i,o]of Object.entries(t.properties))b(e,i),r.hasOwnProperty(i)?($(e,i),D(e,o,r[i]),L(e)):w(e),v(e);v(e)}if(t.optionalProperties!==void 0){b(e,"optionalProperties");for(let[i,o]of Object.entries(t.optionalProperties))b(e,i),r.hasOwnProperty(i)&&($(e,i),D(e,o,r[i]),L(e)),v(e);v(e)}if(t.additionalProperties!==!0)for(let i of Object.keys(r)){let o=t.properties&&i in t.properties,a=t.optionalProperties&&i in t.optionalProperties;!o&&!a&&i!==n&&($(e,i),w(e),L(e))}}else t.properties!==void 0?b(e,"properties"):b(e,"optionalProperties"),w(e),v(e);else if(N.isValuesForm(t)){if(b(e,"values"),typeof r=="object"&&r!==null&&!Array.isArray(r))for(let[i,o]of Object.entries(r))$(e,i),D(e,t.values,o),L(e);else w(e);v(e)}else if(N.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?(b(e,"mapping"),b(e,i),D(e,t.mapping[i],r,t.discriminator),v(e),v(e)):(b(e,"mapping"),$(e,t.discriminator),w(e),L(e),v(e)):(b(e,"discriminator"),$(e,t.discriminator),w(e),L(e),v(e))}else b(e,"discriminator"),w(e),v(e);else b(e,"discriminator"),w(e),v(e)}}function H(e,t,r,n){(typeof t!="number"||!Number.isInteger(t)||t<r||t>n)&&w(e)}function $(e,t){e.instanceTokens.push(t)}function L(e){e.instanceTokens.pop()}function b(e,t){e.schemaTokens[e.schemaTokens.length-1].push(t)}function v(e){e.schemaTokens[e.schemaTokens.length-1].pop()}function w(e){if(e.errors.push({instancePath:[...e.instanceTokens],schemaPath:[...e.schemaTokens[e.schemaTokens.length-1]]}),e.errors.length===e.config.maxErrors)throw new re}});var qe=S(j=>{"use strict";var Bt=j&&j.__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]}),Ve=j&&j.__exportStar||function(e,t){for(var r in e)r!=="default"&&!t.hasOwnProperty(r)&&Bt(t,e,r)};Object.defineProperty(j,"__esModule",{value:!0});Ve(me(),j);Ve(Je(),j)});var Ke=oe(Ee()),We=oe(je());var ee,bt=new Uint8Array(16);function ce(){if(!ee&&(ee=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ee))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ee(bt)}var h=[];for(let e=0;e<256;++e)h.push((e+256).toString(16).slice(1));function Be(e,t=0){return(h[e[t+0]]+h[e[t+1]]+h[e[t+2]]+h[e[t+3]]+"-"+h[e[t+4]]+h[e[t+5]]+"-"+h[e[t+6]]+h[e[t+7]]+"-"+h[e[t+8]]+h[e[t+9]]+"-"+h[e[t+10]]+h[e[t+11]]+h[e[t+12]]+h[e[t+13]]+h[e[t+14]]+h[e[t+15]]).toLowerCase()}var wt=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),pe={randomUUID:wt};function vt(e,t,r){if(pe.randomUUID&&!t&&!e)return pe.randomUUID();e=e||{};let n=e.random||(e.rng||ce)();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 Be(n)}var q=vt;function de(e){return[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join("")}function Re(e){return new Uint8Array((e.match(/../g)??[]).map(t=>parseInt(t,16)))}function Ie(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 ze=oe(qe());function z(e,t){if((0,ze.validate)(e,t).length)throw new Error(`couldn't validate schema: ${JSON.stringify(t)} didn't match schema ${JSON.stringify(e)}`)}var Ge="3",Qe="https://webapp-prod.cloud.remarkable.engineering",Rt="https://internal.cloud.remarkable.com",Ye="x-goog-generation",It="x-goog-if-generation-match",_t="x-goog-content-length-range",gr=["Ballpoint","Ballpointv2","Brush","Calligraphy","ClearPage","EraseSection","Eraser","Fineliner","Finelinerv2","Highlighter","Highlighterv2","Marker","Markerv2","Paintbrush","Paintbrushv2","Pencilv2","SharpPencil","SharpPencilv2","SolidPen","ZoomTool"],br=["Maison Neue","EB Garamond","Noto Sans","Noto Serif","Noto Mono","Noto Sans UI"],Nt={xs:.7,sm:.8,md:1,lg:1.2,xl:1.5,xx:2},$t={sm:50,md:125,rr:180,lg:200},Lt={df:-1,md:100,lg:150,xl:200},Dt={properties:{docID:{type:"string"},hash:{type:"string"}}},Ht={properties:{relative_path:{type:"string"},url:{type:"string"},expires:{type:"timestamp"},method:{enum:["POST","GET","PUT","DELETE"]}},optionalProperties:{maxuploadsize_bytes:{type:"float64"}}},ne={visibleName:{type:"string"},lastModified:{type:"string"}},ie={version:{type:"int32"},pinned:{type:"boolean"},synced:{type:"boolean"},modified:{type:"boolean"},deleted:{type:"boolean"},metadatamodified:{type:"boolean"},parent:{type:"string"}},Ut={discriminator:"type",mapping:{CollectionType:{properties:ne,optionalProperties:ie},DocumentType:{properties:ne,optionalProperties:{...ie,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"}}}}},Ze={id:{type:"string"},hash:{type:"string"}},Jt={discriminator:"type",mapping:{CollectionType:{properties:{...ne,...Ze},optionalProperties:ie},DocumentType:{properties:{...ne,...Ze,fileType:{enum:["notebook","epub","pdf",""]}},optionalProperties:{...ie,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"}}}}},U=class extends Error{status;statusText;constructor(t,r,n){super(n),this.status=t,this.statusText=r}},ge=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:t="browser-chrome",uuid:r=q(),authHost:n=Qe,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:t,deviceID:r})});if(o.ok)return await o.text();throw new U(o.status,o.statusText,"couldn't register api")}function Vt({hash:e,type:t,documentId:r,subfiles:n,size:i}){return`${e}:${t}:${r}:${n}:${i}
|
|
10
|
-
`}function
|
|
11
|
-
`);if(n!==
|
|
12
|
-
${f}`,
|
|
1
|
+
"use strict";(()=>{var Rr=Object.create;var et=Object.defineProperty;var Br=Object.getOwnPropertyDescriptor;var Cr=Object.getOwnPropertyNames;var _r=Object.getPrototypeOf,Ur=Object.prototype.hasOwnProperty;var m=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Nr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Cr(e))!Ur.call(t,o)&&o!==r&&et(t,o,{get:()=>e[o],enumerable:!(n=Br(e,o))||n.enumerable});return t};var Fe=(t,e,r)=>(r=t!=null?Rr(_r(t)):{},Nr(e||!t||!t.__esModule?et(r,"default",{value:t,enumerable:!0}):r,t));var nt=m(le=>{"use strict";le.byteLength=Lr;le.toByteArray=Jr;le.fromByteArray=Vr;var I=[],F=[],Dr=typeof Uint8Array<"u"?Uint8Array:Array,ke="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(U=0,tt=ke.length;U<tt;++U)I[U]=ke[U],F[ke.charCodeAt(U)]=U;var U,tt;F[45]=62;F[95]=63;function rt(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function Lr(t){var e=rt(t),r=e[0],n=e[1];return(r+n)*3/4-n}function Hr(t,e,r){return(e+r)*3/4-r}function Jr(t){var e,r=rt(t),n=r[0],o=r[1],i=new Dr(Hr(t,n,o)),a=0,f=o>0?n-4:n,s;for(s=0;s<f;s+=4)e=F[t.charCodeAt(s)]<<18|F[t.charCodeAt(s+1)]<<12|F[t.charCodeAt(s+2)]<<6|F[t.charCodeAt(s+3)],i[a++]=e>>16&255,i[a++]=e>>8&255,i[a++]=e&255;return o===2&&(e=F[t.charCodeAt(s)]<<2|F[t.charCodeAt(s+1)]>>4,i[a++]=e&255),o===1&&(e=F[t.charCodeAt(s)]<<10|F[t.charCodeAt(s+1)]<<4|F[t.charCodeAt(s+2)]>>2,i[a++]=e>>8&255,i[a++]=e&255),i}function Gr(t){return I[t>>18&63]+I[t>>12&63]+I[t>>6&63]+I[t&63]}function qr(t,e,r){for(var n,o=[],i=e;i<r;i+=3)n=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(t[i+2]&255),o.push(Gr(n));return o.join("")}function Vr(t){for(var e,r=t.length,n=r%3,o=[],i=16383,a=0,f=r-n;a<f;a+=i)o.push(qr(t,a,a+i>f?f:a+i));return n===1?(e=t[r-1],o.push(I[e>>2]+I[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],o.push(I[e>>10]+I[e>>4&63]+I[e<<2&63]+"=")),o.join("")}});var ft=m((yo,st)=>{"use strict";var pe,l,ot={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
|
|
2
|
+
`,r:"\r",t:" "},Ie;function R(t){throw{name:"SyntaxError",message:t,at:pe,text:Ie}}function d(t){return t&&t!==l&&R("Expected '"+t+"' instead of '"+l+"'"),l=Ie.charAt(pe),pe+=1,l}function it(){var t,e="";for(l==="-"&&(e="-",d("-"));l>="0"&&l<="9";)e+=l,d();if(l===".")for(e+=".";d()&&l>="0"&&l<="9";)e+=l;if(l==="e"||l==="E")for(e+=l,d(),(l==="-"||l==="+")&&(e+=l,d());l>="0"&&l<="9";)e+=l,d();return t=Number(e),isFinite(t)||R("Bad number"),t}function at(){var t,e,r="",n;if(l==='"')for(;d();){if(l==='"')return d(),r;if(l==="\\")if(d(),l==="u"){for(n=0,e=0;e<4&&(t=parseInt(d(),16),!!isFinite(t));e+=1)n=n*16+t;r+=String.fromCharCode(n)}else if(typeof ot[l]=="string")r+=ot[l];else break;else r+=l}R("Bad string")}function $(){for(;l&&l<=" ";)d()}function zr(){switch(l){case"t":return d("t"),d("r"),d("u"),d("e"),!0;case"f":return d("f"),d("a"),d("l"),d("s"),d("e"),!1;case"n":return d("n"),d("u"),d("l"),d("l"),null;default:R("Unexpected '"+l+"'")}}function Wr(){var t=[];if(l==="["){if(d("["),$(),l==="]")return d("]"),t;for(;l;){if(t.push(ce()),$(),l==="]")return d("]"),t;d(","),$()}}R("Bad array")}function Yr(){var t,e={};if(l==="{"){if(d("{"),$(),l==="}")return d("}"),e;for(;l;){if(t=at(),$(),d(":"),Object.prototype.hasOwnProperty.call(e,t)&&R('Duplicate key "'+t+'"'),e[t]=ce(),$(),l==="}")return d("}"),e;d(","),$()}}R("Bad object")}function ce(){switch($(),l){case"{":return Yr();case"[":return Wr();case'"':return at();case"-":return it();default:return l>="0"&&l<="9"?it():zr()}}st.exports=function(t,e){var r;return Ie=t,pe=0,l=" ",r=ce(),$(),l&&R("Syntax error"),typeof e=="function"?function n(o,i){var a,f,s=o[i];if(s&&typeof s=="object")for(a in ce)Object.prototype.hasOwnProperty.call(s,a)&&(f=n(s,a),typeof f>"u"?delete s[a]:s[a]=f);return e.call(o,i,s)}({"":r},""):r}});var lt=m((go,ut)=>{"use strict";var je=/[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,T,ye,Kr={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},N;function $e(t){return je.lastIndex=0,je.test(t)?'"'+t.replace(je,function(e){var r=Kr[e];return typeof r=="string"?r:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+t+'"'}function de(t,e){var r,n,o,i,a=T,f,s=e[t];switch(s&&typeof s=="object"&&typeof s.toJSON=="function"&&(s=s.toJSON(t)),typeof N=="function"&&(s=N.call(e,t,s)),typeof s){case"string":return $e(s);case"number":return isFinite(s)?String(s):"null";case"boolean":case"null":return String(s);case"object":if(!s)return"null";if(T+=ye,f=[],Object.prototype.toString.apply(s)==="[object Array]"){for(i=s.length,r=0;r<i;r+=1)f[r]=de(r,s)||"null";return o=f.length===0?"[]":T?`[
|
|
3
|
+
`+T+f.join(`,
|
|
4
|
+
`+T)+`
|
|
5
|
+
`+a+"]":"["+f.join(",")+"]",T=a,o}if(N&&typeof N=="object")for(i=N.length,r=0;r<i;r+=1)n=N[r],typeof n=="string"&&(o=de(n,s),o&&f.push($e(n)+(T?": ":":")+o));else for(n in s)Object.prototype.hasOwnProperty.call(s,n)&&(o=de(n,s),o&&f.push($e(n)+(T?": ":":")+o));return o=f.length===0?"{}":T?`{
|
|
6
|
+
`+T+f.join(`,
|
|
7
|
+
`+T)+`
|
|
8
|
+
`+a+"}":"{"+f.join(",")+"}",T=a,o;default:}}ut.exports=function(t,e,r){var n;if(T="",ye="",typeof r=="number")for(n=0;n<r;n+=1)ye+=" ";else typeof r=="string"&&(ye=r);if(N=e,e&&typeof e!="function"&&(typeof e!="object"||typeof e.length!="number"))throw new Error("JSON.stringify");return de("",{"":t})}});var pt=m(Me=>{"use strict";Me.parse=ft();Me.stringify=lt()});var yt=m((ho,ct)=>{var Xr={}.toString;ct.exports=Array.isArray||function(t){return Xr.call(t)=="[object Array]"}});var Re=m((vo,gt)=>{"use strict";var dt=Object.prototype.toString;gt.exports=function(e){var r=dt.call(e),n=r==="[object Arguments]";return n||(n=r!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&dt.call(e.callee)==="[object Function]"),n}});var Et=m((bo,At)=>{"use strict";var xt;Object.keys||(ne=Object.prototype.hasOwnProperty,Be=Object.prototype.toString,mt=Re(),Ce=Object.prototype.propertyIsEnumerable,ht=!Ce.call({toString:null},"toString"),vt=Ce.call(function(){},"prototype"),oe=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],ge=function(t){var e=t.constructor;return e&&e.prototype===t},bt={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},wt=function(){if(typeof window>"u")return!1;for(var t in window)try{if(!bt["$"+t]&&ne.call(window,t)&&window[t]!==null&&typeof window[t]=="object")try{ge(window[t])}catch{return!0}}catch{return!0}return!1}(),Pt=function(t){if(typeof window>"u"||!wt)return ge(t);try{return ge(t)}catch{return!1}},xt=function(e){var r=e!==null&&typeof e=="object",n=Be.call(e)==="[object Function]",o=mt(e),i=r&&Be.call(e)==="[object String]",a=[];if(!r&&!n&&!o)throw new TypeError("Object.keys called on a non-object");var f=vt&&n;if(i&&e.length>0&&!ne.call(e,0))for(var s=0;s<e.length;++s)a.push(String(s));if(o&&e.length>0)for(var y=0;y<e.length;++y)a.push(String(y));else for(var p in e)!(f&&p==="prototype")&&ne.call(e,p)&&a.push(String(p));if(ht)for(var g=Pt(e),u=0;u<oe.length;++u)!(g&&oe[u]==="constructor")&&ne.call(e,oe[u])&&a.push(oe[u]);return a});var ne,Be,mt,Ce,ht,vt,oe,ge,bt,wt,Pt;At.exports=xt});var Ft=m((wo,Tt)=>{"use strict";var Zr=Array.prototype.slice,Qr=Re(),St=Object.keys,me=St?function(e){return St(e)}:Et(),Ot=Object.keys;me.shim=function(){if(Object.keys){var e=function(){var r=Object.keys(arguments);return r&&r.length===arguments.length}(1,2);e||(Object.keys=function(n){return Qr(n)?Ot(Zr.call(n)):Ot(n)})}else Object.keys=me;return Object.keys||me};Tt.exports=me});var jt=m((Po,It)=>{"use strict";var en="Function.prototype.bind called on incompatible ",tn=Object.prototype.toString,rn=Math.max,nn="[object Function]",kt=function(e,r){for(var n=[],o=0;o<e.length;o+=1)n[o]=e[o];for(var i=0;i<r.length;i+=1)n[i+e.length]=r[i];return n},on=function(e,r){for(var n=[],o=r||0,i=0;o<e.length;o+=1,i+=1)n[i]=e[o];return n},an=function(t,e){for(var r="",n=0;n<t.length;n+=1)r+=t[n],n+1<t.length&&(r+=e);return r};It.exports=function(e){var r=this;if(typeof r!="function"||tn.apply(r)!==nn)throw new TypeError(en+r);for(var n=on(arguments,1),o,i=function(){if(this instanceof o){var p=r.apply(this,kt(n,arguments));return Object(p)===p?p:this}return r.apply(e,kt(n,arguments))},a=rn(0,r.length-n.length),f=[],s=0;s<a;s++)f[s]="$"+s;if(o=Function("binder","return function ("+an(f,",")+"){ return binder.apply(this,arguments); }")(i),r.prototype){var y=function(){};y.prototype=r.prototype,o.prototype=new y,y.prototype=null}return o}});var he=m((xo,$t)=>{"use strict";var sn=jt();$t.exports=Function.prototype.bind||sn});var Rt=m((Ao,Mt)=>{"use strict";Mt.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var o=42;e[r]=o;for(r in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var i=Object.getOwnPropertySymbols(e);if(i.length!==1||i[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,r);if(a.value!==o||a.enumerable!==!0)return!1}return!0}});var _t=m((Eo,Ct)=>{"use strict";var Bt=typeof Symbol<"u"&&Symbol,fn=Rt();Ct.exports=function(){return typeof Bt!="function"||typeof Symbol!="function"||typeof Bt("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:fn()}});var Dt=m((So,Nt)=>{"use strict";var Ut={foo:{}},un=Object;Nt.exports=function(){return{__proto__:Ut}.foo===Ut.foo&&!({__proto__:null}instanceof un)}});var Ht=m((Oo,Lt)=>{"use strict";var ln=Function.prototype.call,pn=Object.prototype.hasOwnProperty,cn=he();Lt.exports=cn.call(ln,pn)});var Z=m((To,zt)=>{"use strict";var c,X=SyntaxError,Vt=Function,K=TypeError,_e=function(t){try{return Vt('"use strict"; return ('+t+").constructor;")()}catch{}},D=Object.getOwnPropertyDescriptor;if(D)try{D({},"")}catch{D=null}var Ue=function(){throw new K},yn=D?function(){try{return arguments.callee,Ue}catch{try{return D(arguments,"callee").get}catch{return Ue}}}():Ue,W=_t()(),dn=Dt()(),w=Object.getPrototypeOf||(dn?function(t){return t.__proto__}:null),Y={},gn=typeof Uint8Array>"u"||!w?c:w(Uint8Array),L={"%AggregateError%":typeof AggregateError>"u"?c:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?c:ArrayBuffer,"%ArrayIteratorPrototype%":W&&w?w([][Symbol.iterator]()):c,"%AsyncFromSyncIteratorPrototype%":c,"%AsyncFunction%":Y,"%AsyncGenerator%":Y,"%AsyncGeneratorFunction%":Y,"%AsyncIteratorPrototype%":Y,"%Atomics%":typeof Atomics>"u"?c:Atomics,"%BigInt%":typeof BigInt>"u"?c:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?c:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?c:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?c:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?c:Float32Array,"%Float64Array%":typeof Float64Array>"u"?c:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?c:FinalizationRegistry,"%Function%":Vt,"%GeneratorFunction%":Y,"%Int8Array%":typeof Int8Array>"u"?c:Int8Array,"%Int16Array%":typeof Int16Array>"u"?c:Int16Array,"%Int32Array%":typeof Int32Array>"u"?c:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":W&&w?w(w([][Symbol.iterator]())):c,"%JSON%":typeof JSON=="object"?JSON:c,"%Map%":typeof Map>"u"?c:Map,"%MapIteratorPrototype%":typeof Map>"u"||!W||!w?c:w(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?c:Promise,"%Proxy%":typeof Proxy>"u"?c:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?c:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?c:Set,"%SetIteratorPrototype%":typeof Set>"u"||!W||!w?c:w(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?c:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":W&&w?w(""[Symbol.iterator]()):c,"%Symbol%":W?Symbol:c,"%SyntaxError%":X,"%ThrowTypeError%":yn,"%TypedArray%":gn,"%TypeError%":K,"%Uint8Array%":typeof Uint8Array>"u"?c:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?c:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?c:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?c:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?c:WeakMap,"%WeakRef%":typeof WeakRef>"u"?c:WeakRef,"%WeakSet%":typeof WeakSet>"u"?c:WeakSet};if(w)try{null.error}catch(t){Jt=w(w(t)),L["%Error.prototype%"]=Jt}var Jt,mn=function t(e){var r;if(e==="%AsyncFunction%")r=_e("async function () {}");else if(e==="%GeneratorFunction%")r=_e("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=_e("async function* () {}");else if(e==="%AsyncGenerator%"){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var o=t("%AsyncGenerator%");o&&w&&(r=w(o.prototype))}return L[e]=r,r},Gt={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ie=he(),ve=Ht(),hn=ie.call(Function.call,Array.prototype.concat),vn=ie.call(Function.apply,Array.prototype.splice),qt=ie.call(Function.call,String.prototype.replace),be=ie.call(Function.call,String.prototype.slice),bn=ie.call(Function.call,RegExp.prototype.exec),wn=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Pn=/\\(\\)?/g,xn=function(e){var r=be(e,0,1),n=be(e,-1);if(r==="%"&&n!=="%")throw new X("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new X("invalid intrinsic syntax, expected opening `%`");var o=[];return qt(e,wn,function(i,a,f,s){o[o.length]=f?qt(s,Pn,"$1"):a||i}),o},An=function(e,r){var n=e,o;if(ve(Gt,n)&&(o=Gt[n],n="%"+o[0]+"%"),ve(L,n)){var i=L[n];if(i===Y&&(i=mn(n)),typeof i>"u"&&!r)throw new K("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:o,name:n,value:i}}throw new X("intrinsic "+e+" does not exist!")};zt.exports=function(e,r){if(typeof e!="string"||e.length===0)throw new K("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new K('"allowMissing" argument must be a boolean');if(bn(/^%?[^%]*%?$/,e)===null)throw new X("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=xn(e),o=n.length>0?n[0]:"",i=An("%"+o+"%",r),a=i.name,f=i.value,s=!1,y=i.alias;y&&(o=y[0],vn(n,hn([0,1],y)));for(var p=1,g=!0;p<n.length;p+=1){var u=n[p],S=be(u,0,1),b=be(u,-1);if((S==='"'||S==="'"||S==="`"||b==='"'||b==="'"||b==="`")&&S!==b)throw new X("property names with quotes must have matching quotes");if((u==="constructor"||!g)&&(s=!0),o+="."+u,a="%"+o+"%",ve(L,a))f=L[a];else if(f!=null){if(!(u in f)){if(!r)throw new K("base intrinsic for "+e+" exists, but the property is not available.");return}if(D&&p+1>=n.length){var k=D(f,u);g=!!k,g&&"get"in k&&!("originalValue"in k.get)?f=k.get:f=f[u]}else g=ve(f,u),f=f[u];g&&!s&&(L[a]=f)}}return f}});var Le=m((Fo,Wt)=>{"use strict";var En=Z(),Ne=En("%Object.defineProperty%",!0),De=function(){if(Ne)try{return Ne({},"a",{value:1}),!0}catch{return!1}return!1};De.hasArrayLengthDefineBug=function(){if(!De())return null;try{return Ne([],"length",{value:1}).length!==1}catch{return!0}};Wt.exports=De});var He=m((ko,Yt)=>{"use strict";var Sn=Z(),we=Sn("%Object.getOwnPropertyDescriptor%",!0);if(we)try{we([],"length")}catch{we=null}Yt.exports=we});var Zt=m((Io,Xt)=>{"use strict";var On=Le()(),Je=Z(),ae=On&&Je("%Object.defineProperty%",!0);if(ae)try{ae({},"a",{value:1})}catch{ae=!1}var Tn=Je("%SyntaxError%"),Q=Je("%TypeError%"),Kt=He();Xt.exports=function(e,r,n){if(!e||typeof e!="object"&&typeof e!="function")throw new Q("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new Q("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Q("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Q("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Q("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Q("`loose`, if provided, must be a boolean");var o=arguments.length>3?arguments[3]:null,i=arguments.length>4?arguments[4]:null,a=arguments.length>5?arguments[5]:null,f=arguments.length>6?arguments[6]:!1,s=!!Kt&&Kt(e,r);if(ae)ae(e,r,{configurable:a===null&&s?s.configurable:!a,enumerable:o===null&&s?s.enumerable:!o,value:n,writable:i===null&&s?s.writable:!i});else if(f||!o&&!i&&!a)e[r]=n;else throw new Tn("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")}});var or=m((jo,nr)=>{"use strict";var rr=Z(),Qt=Zt(),Fn=Le()(),er=He(),tr=rr("%TypeError%"),kn=rr("%Math.floor%");nr.exports=function(e,r){if(typeof e!="function")throw new tr("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||kn(r)!==r)throw new tr("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],o=!0,i=!0;if("length"in e&&er){var a=er(e,"length");a&&!a.configurable&&(o=!1),a&&!a.writable&&(i=!1)}return(o||i||!n)&&(Fn?Qt(e,"length",r,!0,!0):Qt(e,"length",r)),e}});var ur=m(($o,Pe)=>{"use strict";var Ge=he(),ee=Z(),In=or(),jn=ee("%TypeError%"),ar=ee("%Function.prototype.apply%"),sr=ee("%Function.prototype.call%"),fr=ee("%Reflect.apply%",!0)||Ge.call(sr,ar),se=ee("%Object.defineProperty%",!0),$n=ee("%Math.max%");if(se)try{se({},"a",{value:1})}catch{se=null}Pe.exports=function(e){if(typeof e!="function")throw new jn("a function is required");var r=fr(Ge,sr,arguments);return In(r,1+$n(0,e.length-(arguments.length-1)),!0)};var ir=function(){return fr(Ge,ar,arguments)};se?se(Pe.exports,"apply",{value:ir}):Pe.exports.apply=ir});var cr=m((Mo,pr)=>{"use strict";var xe=(typeof JSON<"u"?JSON:pt()).stringify,Mn=yt(),Rn=Ft(),Bn=ur(),lr=function(e,r){for(var n="",o=0;o<e;o+=1)n+=r;return n},Cn=function(t,e,r){return r};pr.exports=function(e){var r=arguments.length>1?arguments[1]:void 0,n=r&&r.space||"";typeof n=="number"&&(n=lr(n," "));var o=!!r&&typeof r.cycles=="boolean"&&r.cycles,i=r&&r.replacer?Bn(r.replacer):Cn,a=typeof r=="function"?r:r&&r.cmp,f=a&&function(y){var p=a.length>2&&function(u){return y[u]};return function(g,u){return a({key:g,value:y[g]},{key:u,value:y[u]},p?{__proto__:null,get:p}:void 0)}},s=[];return function y(p,g,u,S){var b=n?`
|
|
9
|
+
`+lr(S,n):"",k=n?": ":":";if(u&&u.toJSON&&typeof u.toJSON=="function"&&(u=u.toJSON()),u=i(p,g,u),u!==void 0){if(typeof u!="object"||u===null)return xe(u);if(Mn(u)){for(var j="",v=0;v<u.length;v++){var _=y(u,v,u[v],S+1)||xe(null);j+=b+n+_,v+1<u.length&&(j+=",")}return"["+j+b+"]"}if(s.indexOf(u)!==-1){if(o)return xe("__cycle__");throw new TypeError("Converting circular structure to JSON")}else s.push(u);for(var P=Rn(u).sort(f&&f(u)),j="",M=!1,v=0;v<P.length;v++){var g=P[v],Qe=y(u,g,u[g],S+1);if(Qe){var Mr=xe(g)+k+Qe;j+=(M?",":"")+b+n+Mr,M=!0}}return s.splice(s.indexOf(u),1),"{"+j+b+"}"}}({"":e},"",e,0)}});var Ye=m(h=>{"use strict";var mr=h&&h.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]]);return r};Object.defineProperty(h,"__esModule",{value:!0});h.isSchema=h.isValidSchema=h.isDiscriminatorForm=h.isValuesForm=h.isPropertiesForm=h.isElementsForm=h.isEnumForm=h.isTypeForm=h.isRefForm=h.isEmptyForm=void 0;function Dn(t){let{definitions:e,nullable:r,metadata:n}=t,o=mr(t,["definitions","nullable","metadata"]);return Object.keys(o).length===0}h.isEmptyForm=Dn;function hr(t){return"ref"in t}h.isRefForm=hr;function Ln(t){return"type"in t}h.isTypeForm=Ln;function vr(t){return"enum"in t}h.isEnumForm=vr;function br(t){return"elements"in t}h.isElementsForm=br;function We(t){return"properties"in t||"optionalProperties"in t}h.isPropertiesForm=We;function wr(t){return"values"in t}h.isValuesForm=wr;function Pr(t){return"discriminator"in t}h.isDiscriminatorForm=Pr;function H(t,e){if(e===void 0&&(e=t),t.definitions!==void 0){if(e!==t)return!1;for(let r of Object.values(t.definitions))if(!H(r,e))return!1}if(hr(t)&&!(t.ref in(e.definitions||{}))||vr(t)&&(t.enum.length===0||t.enum.length!==new Set(t.enum).size))return!1;if(br(t))return H(t.elements,e);if(We(t)){for(let r of Object.values(t.properties||{}))if(!H(r,e))return!1;for(let r of Object.values(t.optionalProperties||{}))if(!H(r,e))return!1;for(let r of Object.keys(t.properties||{}))if(r in(t.optionalProperties||{}))return!1}if(wr(t))return H(t.values,e);if(Pr(t)){for(let r of Object.values(t.mapping))if(!H(r,e)||!We(r)||r.nullable||t.discriminator in(r.properties||{})||t.discriminator in(r.optionalProperties||{}))return!1}return!0}h.isValidSchema=H;var Hn=[[!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]],Jn=["boolean","float32","float64","int8","uint8","int16","uint16","int32","uint32","string","timestamp"];function J(t){if(typeof t!="object"||Array.isArray(t)||t===null)return!1;let e=t,{definitions:r=void 0,nullable:n=void 0,metadata:o=void 0,ref:i=void 0,type:a=void 0,enum:f=void 0,elements:s=void 0,properties:y=void 0,optionalProperties:p=void 0,additionalProperties:g=void 0,values:u=void 0,discriminator:S=void 0,mapping:b=void 0}=e,k=mr(e,["definitions","nullable","metadata","ref","type","enum","elements","properties","optionalProperties","additionalProperties","values","discriminator","mapping"]),v=[i!==void 0,a!==void 0,f!==void 0,s!==void 0,y!==void 0,p!==void 0,g!==void 0,u!==void 0,S!==void 0,b!==void 0],_=!1;for(let P of Hn)_=_||P.every((j,M)=>j===v[M]);if(!_)return!1;if(r!==void 0){if(typeof r!="object"||Array.isArray(r)||r===null)return!1;for(let P of Object.values(r))if(!J(P))return!1}if(n!==void 0&&typeof n!="boolean"||o!==void 0&&(typeof o!="object"||Array.isArray(o)||o===null)||i!==void 0&&typeof i!="string"||a!==void 0&&(typeof a!="string"||!Jn.includes(a))||f!==void 0&&(!Array.isArray(f)||!f.every(P=>typeof P=="string"))||s!==void 0&&!J(s))return!1;if(y!==void 0){if(typeof y!="object"||Array.isArray(y)||y===null)return!1;for(let P of Object.values(y))if(!J(P))return!1}if(p!==void 0){if(typeof p!="object"||Array.isArray(p)||p===null)return!1;for(let P of Object.values(p))if(!J(P))return!1}if(g!==void 0&&typeof g!="boolean"||u!==void 0&&!J(u)||S!==void 0&&typeof S!="string")return!1;if(b!==void 0){if(typeof b!="object"||Array.isArray(b)||b===null)return!1;for(let P of Object.values(b))if(!J(P))return!1}return Object.keys(k).length===0}h.isSchema=J});var xr=m(Ke=>{"use strict";Object.defineProperty(Ke,"__esModule",{value:!0});var Gn=/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(\.\d+)?([zZ]|((\+|-)(\d{2}):(\d{2})))$/;function qn(t){let e=t.match(Gn);if(e===null)return!1;let r=parseInt(e[1],10),n=parseInt(e[2],10),o=parseInt(e[3],10),i=parseInt(e[4],10),a=parseInt(e[5],10),f=parseInt(e[6],10);return!(n>12||o>Vn(r,n)||i>23||a>59||f>60)}Ke.default=qn;function Vn(t,e){return e===2?zn(t)?29:28:Wn[e]}function zn(t){return t%4===0&&(t%100!==0||t%400===0)}var Wn=[0,31,0,31,30,31,30,31,31,30,31,30,31]});var Ar=m(B=>{"use strict";var Yn=B&&B.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(B,"__esModule",{value:!0});B.validate=B.MaxDepthExceededError=void 0;var Kn=Yn(xr()),G=Ye(),Ee=class extends Error{};B.MaxDepthExceededError=Ee;var Se=class extends Error{};function Xn(t,e,r){let n={errors:[],instanceTokens:[],schemaTokens:[[]],root:t,config:r||{maxDepth:0,maxErrors:0}};try{z(n,t,e)}catch(o){if(!(o instanceof Se))throw o}return n.errors}B.validate=Xn;function z(t,e,r,n){if(!(e.nullable&&r===null)){if(G.isRefForm(e)){if(t.schemaTokens.length===t.config.maxDepth)throw new Ee;t.schemaTokens.push(["definitions",e.ref]),z(t,t.root.definitions[e.ref],r),t.schemaTokens.pop()}else if(G.isTypeForm(e)){switch(A(t,"type"),e.type){case"boolean":typeof r!="boolean"&&E(t);break;case"float32":case"float64":typeof r!="number"&&E(t);break;case"int8":te(t,r,-128,127);break;case"uint8":te(t,r,0,255);break;case"int16":te(t,r,-32768,32767);break;case"uint16":te(t,r,0,65535);break;case"int32":te(t,r,-2147483648,2147483647);break;case"uint32":te(t,r,0,4294967295);break;case"string":typeof r!="string"&&E(t);break;case"timestamp":typeof r!="string"?E(t):Kn.default(r)||E(t);break}O(t)}else if(G.isEnumForm(e))A(t,"enum"),(typeof r!="string"||!e.enum.includes(r))&&E(t),O(t);else if(G.isElementsForm(e)){if(A(t,"elements"),Array.isArray(r))for(let[o,i]of r.entries())q(t,o.toString()),z(t,e.elements,i),V(t);else E(t);O(t)}else if(G.isPropertiesForm(e))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){if(e.properties!==void 0){A(t,"properties");for(let[o,i]of Object.entries(e.properties))A(t,o),r.hasOwnProperty(o)?(q(t,o),z(t,i,r[o]),V(t)):E(t),O(t);O(t)}if(e.optionalProperties!==void 0){A(t,"optionalProperties");for(let[o,i]of Object.entries(e.optionalProperties))A(t,o),r.hasOwnProperty(o)&&(q(t,o),z(t,i,r[o]),V(t)),O(t);O(t)}if(e.additionalProperties!==!0)for(let o of Object.keys(r)){let i=e.properties&&o in e.properties,a=e.optionalProperties&&o in e.optionalProperties;!i&&!a&&o!==n&&(q(t,o),E(t),V(t))}}else e.properties!==void 0?A(t,"properties"):A(t,"optionalProperties"),E(t),O(t);else if(G.isValuesForm(e)){if(A(t,"values"),typeof r=="object"&&r!==null&&!Array.isArray(r))for(let[o,i]of Object.entries(r))q(t,o),z(t,e.values,i),V(t);else E(t);O(t)}else if(G.isDiscriminatorForm(e))if(typeof r=="object"&&r!==null&&!Array.isArray(r))if(r.hasOwnProperty(e.discriminator)){let o=r[e.discriminator];typeof o=="string"?o in e.mapping?(A(t,"mapping"),A(t,o),z(t,e.mapping[o],r,e.discriminator),O(t),O(t)):(A(t,"mapping"),q(t,e.discriminator),E(t),V(t),O(t)):(A(t,"discriminator"),q(t,e.discriminator),E(t),V(t),O(t))}else A(t,"discriminator"),E(t),O(t);else A(t,"discriminator"),E(t),O(t)}}function te(t,e,r,n){(typeof e!="number"||!Number.isInteger(e)||e<r||e>n)&&E(t)}function q(t,e){t.instanceTokens.push(e)}function V(t){t.instanceTokens.pop()}function A(t,e){t.schemaTokens[t.schemaTokens.length-1].push(e)}function O(t){t.schemaTokens[t.schemaTokens.length-1].pop()}function E(t){if(t.errors.push({instancePath:[...t.instanceTokens],schemaPath:[...t.schemaTokens[t.schemaTokens.length-1]]}),t.errors.length===t.config.maxErrors)throw new Se}});var Sr=m(C=>{"use strict";var Zn=C&&C.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Er=C&&C.__exportStar||function(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&Zn(e,t,r)};Object.defineProperty(C,"__esModule",{value:!0});Er(Ye(),C);Er(Ar(),C)});var Ir=Fe(nt()),jr=Fe(cr());var Ae,_n=new Uint8Array(16);function qe(){if(!Ae&&(Ae=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ae))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ae(_n)}var x=[];for(let t=0;t<256;++t)x.push((t+256).toString(16).slice(1));function yr(t,e=0){return x[t[e+0]]+x[t[e+1]]+x[t[e+2]]+x[t[e+3]]+"-"+x[t[e+4]]+x[t[e+5]]+"-"+x[t[e+6]]+x[t[e+7]]+"-"+x[t[e+8]]+x[t[e+9]]+"-"+x[t[e+10]]+x[t[e+11]]+x[t[e+12]]+x[t[e+13]]+x[t[e+14]]+x[t[e+15]]}var Un=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Ve={randomUUID:Un};function Nn(t,e,r){if(Ve.randomUUID&&!e&&!t)return Ve.randomUUID();t=t||{};let n=t.random||(t.rng||qe)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){r=r||0;for(let o=0;o<16;++o)e[r+o]=n[o];return e}return yr(n)}var fe=Nn;function ze(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}function dr(t){return new Uint8Array((t.match(/../g)??[]).map(e=>parseInt(e,16)))}function gr(t){let e=0;for(let o of t)e+=o.length;let r=new Uint8Array(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return r}var Or=Fe(Sr());function ue(t,e){if((0,Or.validate)(t,e).length)throw new Error(`couldn't validate schema: ${JSON.stringify(e)} didn't match schema ${JSON.stringify(t)}`)}var Tr="3",$r="https://webapp-prod.cloud.remarkable.engineering",Qn="https://internal.cloud.remarkable.com",Fr="x-goog-generation",eo="x-goog-if-generation-match",to="x-goog-content-length-range",Qo=["Ballpoint","Ballpointv2","Brush","Calligraphy","ClearPage","EraseSection","Eraser","Fineliner","Finelinerv2","Highlighter","Highlighterv2","Marker","Markerv2","Paintbrush","Paintbrushv2","Pencilv2","SharpPencil","SharpPencilv2","SolidPen","ZoomTool"],ei=["Maison Neue","EB Garamond","Noto Sans","Noto Serif","Noto Mono","Noto Sans UI"],ro={xs:.7,sm:.8,md:1,lg:1.2,xl:1.5,xx:2},no={sm:50,md:125,rr:180,lg:200},oo={df:-1,md:100,lg:150,xl:200},io={properties:{docID:{type:"string"},hash:{type:"string"}}},ao={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"}},Te={version:{type:"int32"},pinned:{type:"boolean"},synced:{type:"boolean"},modified:{type:"boolean"},deleted:{type:"boolean"},metadatamodified:{type:"boolean"},parent:{type:"string"}},so={discriminator:"type",mapping:{CollectionType:{properties:Oe,optionalProperties:Te,additionalProperties:!0},DocumentType:{properties:Oe,optionalProperties:{...Te,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"},createdTime:{type:"string"}},additionalProperties:!0}}},kr={id:{type:"string"},hash:{type:"string"}},fo={discriminator:"type",mapping:{CollectionType:{properties:{...Oe,...kr},optionalProperties:Te,additionalProperties:!0},DocumentType:{properties:{...Oe,...kr,fileType:{enum:["notebook","epub","pdf",""]}},optionalProperties:{...Te,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"},createdTime:{type:"string"}},additionalProperties:!0}}},re=class extends Error{status;statusText;constructor(e,r,n){super(n),this.status=e,this.statusText=r}},Xe=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 ti(t,{deviceDesc:e="browser-chrome",uuid:r=fe(),authHost:n=$r,fetch:o=globalThis.fetch}={}){if(t.length!==8)throw new Error(`code should be length 8, but was ${t.length}`);let i=await o(`${n}/token/json/2/device/new`,{method:"POST",headers:{Authorization:"Bearer"},body:JSON.stringify({code:t,deviceDesc:e,deviceID:r})});if(i.ok)return await i.text();throw new re(i.status,i.statusText,"couldn't register api")}function uo({hash:t,type:e,documentId:r,subfiles:n,size:o}){return`${t}:${e}:${r}:${n}:${o}
|
|
10
|
+
`}function lo(t){let[e,r,n,o,i]=t.split(":");if(e===void 0||r===void 0||n===void 0||o===void 0||i===void 0)throw new Error(`entries line didn't contain five fields: '${t}'`);if(r==="80000000")return{hash:e,type:r,documentId:n,subfiles:parseInt(o),size:BigInt(i)};if(r==="0"){if(o!=="0")throw new Error(`file type entry had nonzero number of subfiles: ${o}`);return{hash:e,type:r,documentId:n,subfiles:0,size:BigInt(i)}}else throw new Error(`entries line contained invalid type: ${r}`)}var Ze=class{#u;#s;#f;#r;#n;#e=new Map;#t=null;constructor(e,r,n,o,i,a){this.#u=e,this.#s=r,this.#f=n,this.#r=o,this.#n=i;for(let[f,s]of a)this.#e.set(f,Promise.resolve(s))}async#o(e,{body:r,method:n="POST",headers:o={}}){let i=await this.#s(e,{method:n,headers:{Authorization:`Bearer ${this.#u}`,...o},body:r});if(i.ok)return i;{let a=await i.text();throw new re(i.status,i.statusText,`failed reMarkable request: ${a}`)}}async#i({url:e,method:r,maxuploadsize_bytes:n},o,i={}){let a=n?{...i,[to]:`0,${n}`}:i,f=await this.#s(e,{method:r,body:o,headers:a});if(f.ok)return f;{let s=await f.text();throw new re(f.status,f.statusText,s)}}async#a(e,r,n){let o=r===void 0?"downloads":"uploads",i=n&&r!==null&&r!==void 0?`{ "http_method": "PUT", "relative_path": "${e}", "root_schema": "${n}", "generation": ${r} }`:JSON.stringify({http_method:"GET",relative_path:e}),f=await(await this.#o(`${this.#r}/sync/v2/signed-urls/${o}`,{body:i})).text(),s=JSON.parse(f);return ue(ao,s),s}async getRootHash({cache:e=!0}={}){if(e)for(;this.#t;)try{let[i,a]=await this.#t;return[i,a]}catch{}let r=(async()=>{try{let i=await this.#a("root"),a=await this.#i(i),f=a.headers.get(Fr);if(f)return[await a.text(),BigInt(f)];throw new Error("no generation header in root hash")}catch(i){throw this.#t=null,i}})();this.#t=r;let[n,o]=await r;return[n,o]}async putRootHash(e,r){let n=await this.#a("root",r,e),o;try{o=await this.#i(n,e,{[eo]:`${r}`})}catch(f){throw f instanceof re&&f.status===412?(this.#t=null,new Xe):f}let i=o.headers.get(Fr);if(!i)throw new Error("no generation header in root hash");let a=BigInt(i);return this.#t=Promise.resolve([e,a]),a}async#l(e){let r=this.#e.get(e);for(;r;)try{let o=await r;if(o)return o;r=void 0}catch{r=this.#e.get(e)}let n=(async()=>{let o=await this.#a(e);return await(await this.#i(o)).arrayBuffer()})();return this.#e.set(e,n.then(o=>o.byteLength<this.#n?o:null,o=>{throw this.#e.delete(e),o})),await n}async getBuffer(e){let r=await this.#l(e);return r.byteLength<this.#n?r.slice(0):r}async getText(e){let r=await this.#l(e);return new TextDecoder().decode(r)}async getJson(e){let r=await this.getText(e);return JSON.parse(r)}async getMetadata(e){let r=await this.getJson(e);return ue(so,r),r}async getEntries(e){if(e===void 0){let[i]=await this.getRootHash({cache:!0});e=i}let r=await this.getText(e),[n,...o]=r.slice(0,-1).split(`
|
|
11
|
+
`);if(n!==Tr)throw new Error(`got unexpected schema version: ${n}`);return o.map(lo)}async#p(e,r){let n=this.#e.get(e);if(n)try{await n;return}catch{}let o=(async()=>{try{let i=await this.#a(e,null);return await this.#i(i,r),r.byteLength<this.#n?r:null}catch(i){throw this.#e.delete(e),i}})();this.#e.set(e,o),await o}async putEntries(e,r){let n=new TextEncoder;r.sort((p,g)=>p.documentId.localeCompare(g.documentId));let o=gr(r.map(p=>dr(p.hash))),i=await this.#f.digest("SHA-256",o),a=ze(i),f=r.map(uo).join(""),s=`${Tr}
|
|
12
|
+
${f}`,y=n.encode(s);return await this.#p(a,y),{hash:a,type:"80000000",documentId:e,subfiles:r.length,size:0n}}async putBuffer(e,r){let n=await this.#f.digest("SHA-256",r),o=ze(n);return await this.#p(o,r),{hash:o,type:"0",documentId:e,subfiles:0,size:BigInt(r.byteLength)}}async putText(e,r){let n=new TextEncoder;return await this.putBuffer(e,n.encode(r))}async putJson(e,r){return await this.putText(e,(0,jr.default)(r))}async putMetadata(e,r){return await this.putJson(`${e}.metadata`,r)}async putCollection(e,r=""){let n=fe(),o=`${new Date().valueOf()}`,i=[],a={type:"CollectionType",visibleName:e,version:0,parent:r,synced:!0,lastModified:o};i.push(this.putMetadata(n,a)),i.push(this.putText(`${n}.content`,"{}"));let f=await Promise.all(i);return await this.putEntries(n,f)}async#c(e,r,n,o,i){if(i.fileType!==n)throw new Error(`internal error: fileTypes don't match: ${n}, ${i.fileType}`);let a=fe(),f=`${new Date().valueOf()}`,s=[];s.push(this.putBuffer(`${a}.${n}`,r));let y={type:"DocumentType",visibleName:e,version:0,parent:o,synced:!0,lastModified:f};s.push(this.putMetadata(a,y)),s.push(this.putText(`${a}.content`,JSON.stringify(i)));let p=await Promise.all(s);return await this.putEntries(a,p)}async putEpub(e,r,{parent:n="",margins:o=125,orientation:i,textAlignment:a,textScale:f=1,lineHeight:s=-1,fontName:y="",cover:p="visited",lastTool:g}={}){let u={dummyDocument:!1,extraMetadata:{LastTool:g},fileType:"epub",pageCount:0,lastOpenedPage:0,lineHeight:typeof s=="string"?oo[s]:s,margins:typeof o=="string"?no[o]:o,textScale:typeof f=="string"?ro[f]:f,pages:[],coverPageNumber:p==="first"?0:-1,formatVersion:1,orientation:i,textAlignment:a,fontName:y};return await this.#c(e,r,"epub",n,u)}async putPdf(e,r,{parent:n="",orientation:o,cover:i="first",lastTool:a}={}){let f={dummyDocument:!1,extraMetadata:{LastTool:a},fileType:"pdf",pageCount:0,lastOpenedPage:0,lineHeight:-1,margins:125,textScale:1,pages:[],coverPageNumber:i==="first"?0:-1,formatVersion:1,orientation:o};return await this.#c(e,r,"pdf",n,f)}async syncComplete(e){let r=`{ "generation": ${e} }`;await this.#o(`${this.#r}/sync/v2/sync-complete`,{body:r})}async#y(e,r,n){let{hash:o}=await this.putEntries("",r),i=await this.putRootHash(o,e);if(n)try{return await this.syncComplete(i),!0}catch{return!1}else return!1}async create(e,{cache:r=!0,sync:n=!0}={}){let[o,i]=await this.getRootHash({cache:r}),a=await this.getEntries(o);return a.push(e),await this.#y(i,a,n)}async move(e,r,{cache:n=!0,sync:o=!0}={}){let[i,a]=await this.getRootHash({cache:n}),f=await this.getEntries(i);if(!(!r||r==="trash")){let v=f.find(M=>M.documentId===r);if(v){if(v.type!=="80000000")throw new Error(`destination id was a raw file: ${r}`)}else throw new Error(`destination id not found: ${r}`);let _=await this.getEntries(v.hash),[P]=_.filter(M=>M.documentId===`${r}.metadata`);if(!P)throw new Error(`destination id didn't have metadata: ${r}`);if((await this.getMetadata(P.hash)).type!=="CollectionType")throw new Error(`destination id wasn't a collection: ${r}`)}let s=f.findIndex(v=>v.documentId===e);if(s===-1)throw new Error(`document not found: ${e}`);let[y]=f.splice(s,1);if(y.type!=="80000000")throw new Error(`document was a raw file: ${e}`);let p=await this.getEntries(y.hash),g=p.findIndex(v=>v.documentId===`${e}.metadata`);if(g===-1)throw new Error(`document didn't have metadata: ${e}`);let[u]=p.splice(g,1),S=await this.getMetadata(u.hash);S.parent=r;let b=await this.putMetadata(e,S);p.push(b);let k=await this.putEntries(e,p);return f.push(k),await this.#y(a,f,o)}async getEntriesMetadata(){let r=await(await this.#o(`${this.#r}/doc/v2/files`,{method:"GET",headers:{"rm-source":"RoR-Browser"}})).text(),n=JSON.parse(r);return ue({elements:fo},n),n}async#d(e,r,n){let i=new TextEncoder().encode(JSON.stringify({file_name:e})),f=await(await this.#o(`${this.#r}/doc/v2/files`,{body:r,headers:{"content-type":n,"rm-meta":(0,Ir.fromByteArray)(i),"rm-source":"RoR-Browser"}})).text(),s=JSON.parse(f);return ue(io,s),s}async uploadEpub(e,r){return await this.#d(e,r,"application/epub+zip")}async uploadPdf(e,r){return await this.#d(e,r,"application/pdf")}async getCache(){let e=[];for(let[o,i]of this.#e)e.push(i.then(a=>[o,a],()=>[o,null]));let r=await Promise.all(e),n=new Map;for(let[o,i]of r)i&&n.set(o,i);return n}};async function ri(t,{fetch:e=globalThis.fetch,subtle:r=globalThis.crypto?.subtle,authHost:n=$r,syncHost:o=Qn,cacheLimitBytes:i=1048576,initCache:a=[]}={}){if(!r)throw new Error("subtle was missing, try specifying it manually");let f=await e(`${n}/token/json/2/user/new`,{method:"POST",headers:{Authorization:`Bearer ${t}`}});if(!f.ok)throw new Error(`couldn't fetch auth token: ${f.statusText}`);let s=await f.text();return new Ze(s,e,r,o,i,a)}})();
|
package/dist/index.d.ts
CHANGED
|
@@ -112,6 +112,8 @@ export interface DocumentTypeMetadata extends CommonMetadata {
|
|
|
112
112
|
lastOpened?: string;
|
|
113
113
|
/** last opened page for documents */
|
|
114
114
|
lastOpenedPage?: number;
|
|
115
|
+
/** created time */
|
|
116
|
+
createdTime?: string;
|
|
115
117
|
}
|
|
116
118
|
/**
|
|
117
119
|
* metadata for a document or collection (folder)
|
package/dist/index.js
CHANGED
|
@@ -156,6 +156,7 @@ const metadataSchema = {
|
|
|
156
156
|
CollectionType: {
|
|
157
157
|
properties: commonProperties,
|
|
158
158
|
optionalProperties: commonOptionalProperties,
|
|
159
|
+
additionalProperties: true,
|
|
159
160
|
},
|
|
160
161
|
DocumentType: {
|
|
161
162
|
properties: commonProperties,
|
|
@@ -163,7 +164,9 @@ const metadataSchema = {
|
|
|
163
164
|
...commonOptionalProperties,
|
|
164
165
|
lastOpened: { type: "string" },
|
|
165
166
|
lastOpenedPage: { type: "int32" },
|
|
167
|
+
createdTime: { type: "string" },
|
|
166
168
|
},
|
|
169
|
+
additionalProperties: true,
|
|
167
170
|
},
|
|
168
171
|
},
|
|
169
172
|
};
|
|
@@ -180,6 +183,7 @@ const metadataEntrySchema = {
|
|
|
180
183
|
...baseMetadataProperties,
|
|
181
184
|
},
|
|
182
185
|
optionalProperties: commonOptionalProperties,
|
|
186
|
+
additionalProperties: true,
|
|
183
187
|
},
|
|
184
188
|
DocumentType: {
|
|
185
189
|
properties: {
|
|
@@ -191,7 +195,9 @@ const metadataEntrySchema = {
|
|
|
191
195
|
...commonOptionalProperties,
|
|
192
196
|
lastOpened: { type: "string" },
|
|
193
197
|
lastOpenedPage: { type: "int32" },
|
|
198
|
+
createdTime: { type: "string" },
|
|
194
199
|
},
|
|
200
|
+
additionalProperties: true,
|
|
195
201
|
},
|
|
196
202
|
},
|
|
197
203
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rmapi-js",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
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>",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./dist/**/*.js",
|
|
18
18
|
"./dist/**/*.d.ts"
|
|
19
19
|
],
|
|
20
|
-
"packageManager": "yarn@3.
|
|
20
|
+
"packageManager": "yarn@3.6.1",
|
|
21
21
|
"scripts": {
|
|
22
22
|
"doc": "pnpify typedoc",
|
|
23
23
|
"fmt": "pnpify prettier --cache --write 'src/*.ts' '*.json'",
|
|
@@ -31,35 +31,35 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"ajv": "^8.12.0",
|
|
33
33
|
"base64-js": "^1.5.1",
|
|
34
|
-
"json-stable-stringify": "^1.0
|
|
34
|
+
"json-stable-stringify": "^1.1.0",
|
|
35
35
|
"jtd": "^0.1.1",
|
|
36
|
-
"uuid": "^9.0.
|
|
36
|
+
"uuid": "^9.0.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@babel/core": "^7.
|
|
40
|
-
"@babel/preset-env": "^7.
|
|
41
|
-
"@babel/preset-typescript": "^7.
|
|
42
|
-
"@types/babel__core": "^7.20.
|
|
43
|
-
"@types/babel__preset-env": "^7.9.
|
|
44
|
-
"@types/jest": "^29.5.
|
|
45
|
-
"@types/json-stable-stringify": "^1.0.
|
|
46
|
-
"@types/node": "^20.
|
|
47
|
-
"@types/uuid": "^9.0.
|
|
48
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
49
|
-
"@typescript-eslint/parser": "^6.
|
|
50
|
-
"@yarnpkg/pnpify": "^4.0.
|
|
51
|
-
"babel-jest": "^29.
|
|
52
|
-
"esbuild": "^0.
|
|
53
|
-
"eslint": "^8.
|
|
54
|
-
"eslint-config-prettier": "^
|
|
55
|
-
"eslint-plugin-jest": "^27.
|
|
39
|
+
"@babel/core": "^7.23.5",
|
|
40
|
+
"@babel/preset-env": "^7.23.5",
|
|
41
|
+
"@babel/preset-typescript": "^7.23.3",
|
|
42
|
+
"@types/babel__core": "^7.20.5",
|
|
43
|
+
"@types/babel__preset-env": "^7.9.6",
|
|
44
|
+
"@types/jest": "^29.5.10",
|
|
45
|
+
"@types/json-stable-stringify": "^1.0.36",
|
|
46
|
+
"@types/node": "^20.10.3",
|
|
47
|
+
"@types/uuid": "^9.0.7",
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "^6.13.2",
|
|
49
|
+
"@typescript-eslint/parser": "^6.13.2",
|
|
50
|
+
"@yarnpkg/pnpify": "^4.0.1",
|
|
51
|
+
"babel-jest": "^29.7.0",
|
|
52
|
+
"esbuild": "^0.19.8",
|
|
53
|
+
"eslint": "^8.55.0",
|
|
54
|
+
"eslint-config-prettier": "^9.1.0",
|
|
55
|
+
"eslint-plugin-jest": "^27.6.0",
|
|
56
56
|
"eslint-plugin-spellcheck": "^0.0.20",
|
|
57
57
|
"eslint-plugin-tsdoc": "^0.2.17",
|
|
58
|
-
"jest": "^29.
|
|
59
|
-
"prettier": "^3.
|
|
60
|
-
"prettier-plugin-organize-imports": "^3.2.
|
|
61
|
-
"typedoc": "^0.
|
|
62
|
-
"typescript": "^5.
|
|
58
|
+
"jest": "^29.7.0",
|
|
59
|
+
"prettier": "^3.1.0",
|
|
60
|
+
"prettier-plugin-organize-imports": "^3.2.4",
|
|
61
|
+
"typedoc": "^0.25.4",
|
|
62
|
+
"typescript": "^5.3.2"
|
|
63
63
|
},
|
|
64
64
|
"prettier": {
|
|
65
65
|
"plugins": [
|