OverviewFilesCommitsIssuesDocsReleasesPeers

keet-deobfuscated / @holepunchto / keet-core / schema / spec / local / hyperdb / index.js

1894 lines · javascript ref:
const { IndexEncoder: e, c: n, b4a: t } = require("hyperdb/runtime"),
  { version: o, getEncoding: r, setVersion: c } = require("./messages.js"),
  l = { schema: o, db: 6 },
  d = require("../../../../lib/core/hyperdb/local/local.js"),
  s = new e([], { prefix: 0 })
function u(e) {
  return []
}
const i = r("@local/stats")
function a(e, n, t) {
  c(e)
  const o = { start: 0, end: t.byteLength, buffer: t }
  return i.decode(o)
}
function f(e) {
  return {}
}
const g = {
    name: "@local/stats",
    id: 0,
    version: 0,
    encodeKey: (e) => s.encode([]),
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      s.encodeRange({
        gt: e ? u(e) : null,
        lt: n ? u(n) : null,
        gte: t ? u(t) : null,
        lte: o ? u(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (i.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), i.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: a,
    reconstructKey: f,
    indexes: [],
    decodedVersion: 0,
  },
  y = new e([], { prefix: 1 })
function b(e) {
  return []
}
const p = r("@local/migration-status")
function m(e, n, t) {
  c(e)
  const o = { start: 0, end: t.byteLength, buffer: t }
  return p.decode(o)
}
function K(e) {
  return {}
}
const v = {
    name: "@local/migrations",
    id: 1,
    version: 0,
    encodeKey: (e) => y.encode([]),
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      y.encodeRange({
        gt: e ? b(e) : null,
        lt: n ? b(n) : null,
        gte: t ? b(t) : null,
        lte: o ? b(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (p.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), p.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: m,
    reconstructKey: K,
    indexes: [],
    decodedVersion: 0,
  },
  x = new e([], { prefix: 2 })
function h(e) {
  return []
}
const R = r("@local/room-migration-stats")
function w(e, n, t) {
  c(e)
  const o = { start: 0, end: t.byteLength, buffer: t }
  return R.decode(o)
}
function U(e) {
  return {}
}
const V = {
    name: "@local/room-migration-stats",
    id: 2,
    version: 0,
    encodeKey: (e) => x.encode([]),
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      x.encodeRange({
        gt: e ? h(e) : null,
        lt: n ? h(n) : null,
        gte: t ? h(t) : null,
        lte: o ? h(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (R.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), R.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: w,
    reconstructKey: U,
    indexes: [],
    decodedVersion: 0,
  },
  F = new e([e.BUFFER], { prefix: 3 })
function k(e) {
  const n = e.roomKey
  return void 0 === n ? [] : [n]
}
const B = r("@local/room-migration/hyperdb#3"),
  E = d.roomMigrationsTrigger
function I(e, n, t) {
  const o = F.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = B.decode(r)
  return ((l.roomKey = o[0]), l)
}
function T(e) {
  return { roomKey: F.decode(e)[0] }
}
const L = {
    name: "@local/room-migrations",
    id: 3,
    version: 0,
    encodeKey(e) {
      const n = [e.roomKey]
      return F.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      F.encodeRange({
        gt: e ? k(e) : null,
        lt: n ? k(n) : null,
        gte: t ? k(t) : null,
        lte: o ? k(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (B.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), B.encode(r, o), r.buffer)
    },
    trigger: E,
    reconstruct: I,
    reconstructKey: T,
    indexes: [],
    decodedVersion: 0,
  },
  N = new e([e.UINT, e.BUFFER], { prefix: 4 })
function D(e) {
  const n = [],
    t = e.priority
  if (void 0 === t) return n
  n.push(t)
  const o = e.roomKey
  return (void 0 === o || n.push(o), n)
}
const A = {
  name: "@local/room-migrations-by-priority",
  version: 0,
  id: 4,
  encodeKey: (e) => N.encode(D(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    N.encodeRange({
      gt: e ? D(e) : null,
      lt: n ? D(n) : null,
      gte: t ? D(t) : null,
      lte: o ? D(o) : null,
    }),
  encodeValue: (e) => A.collection.encodeKey(e),
  encodeIndexKeys: (e, n) => [N.encode([e.priority, e.roomKey])],
  reconstruct: (e, n) => n,
  offset: L.indexes.length,
  collection: L,
}
L.indexes.push(A)
const P = new e([], { prefix: 5 })
function M(e) {
  return []
}
const O = r("@local/identity-record")
function G(e, n, t) {
  c(e)
  const o = { start: 0, end: t.byteLength, buffer: t }
  return O.decode(o)
}
function S(e) {
  return {}
}
const q = {
    name: "@local/identity",
    id: 5,
    version: 0,
    encodeKey: (e) => P.encode([]),
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      P.encodeRange({
        gt: e ? M(e) : null,
        lt: n ? M(n) : null,
        gte: t ? M(t) : null,
        lte: o ? M(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (O.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), O.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: G,
    reconstructKey: S,
    indexes: [],
    decodedVersion: 0,
  },
  C = new e([e.BUFFER], { prefix: 6 })
function j(e) {
  const n = e.roomKey
  return void 0 === n ? [] : [n]
}
const W = r("@local/room/hyperdb#6"),
  z = d.roomsTrigger
function H(e, n, t) {
  const o = C.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = W.decode(r)
  return ((l.roomKey = o[0]), (Q.decodedVersion = l.version), l)
}
function J(e) {
  return { roomKey: C.decode(e)[0] }
}
const Q = {
    name: "@local/rooms",
    id: 6,
    version: 3,
    encodeKey(e) {
      const n = [e.roomKey]
      return C.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      C.encodeRange({
        gt: e ? j(e) : null,
        lt: n ? j(n) : null,
        gte: t ? j(t) : null,
        lte: o ? j(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (
        (o.version = n),
        W.preencode(r, o),
        (r.buffer = t.allocUnsafe(r.end)),
        W.encode(r, o),
        r.buffer
      )
    },
    trigger: z,
    reconstruct: H,
    reconstructKey: J,
    indexes: [],
    decodedVersion: 0,
  },
  X = new e([e.BUFFER], { prefix: 7 })
function Y(e) {
  const n = e.discoveryKey
  return void 0 === n ? [] : [n]
}
const Z = {
  name: "@local/rooms-by-discovery-key",
  version: 0,
  id: 7,
  encodeKey: (e) => X.encode(Y(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    X.encodeRange({
      gt: e ? Y(e) : null,
      lt: n ? Y(n) : null,
      gte: t ? Y(t) : null,
      lte: o ? Y(o) : null,
    }),
  encodeValue: (e) => Z.collection.encodeKey(e),
  encodeIndexKeys: (e, n) => [X.encode([e.discoveryKey])],
  reconstruct: (e, n) => n,
  offset: Q.indexes.length,
  collection: Q,
}
Q.indexes.push(Z)
const $ = new e([e.UINT, e.BUFFER], { prefix: 8 }),
  _ = d.roomsByTimestampMap
function ee(e) {
  const n = e.timestamp
  return void 0 === n ? [] : [n]
}
const ne = {
  name: "@local/rooms-by-timestamp",
  version: 0,
  id: 8,
  encodeKey: (e) => $.encode(ee(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    $.encodeRange({
      gt: e ? ee(e) : null,
      lt: n ? ee(n) : null,
      gte: t ? ee(t) : null,
      lte: o ? ee(o) : null,
    }),
  encodeValue: (e) => ne.collection.encodeKey(e),
  encodeIndexKeys(e, n) {
    const t = _(e, n),
      o = new Array(t.length)
    for (let n = 0; n < t.length; n++) {
      const r = t[n]
      o[n] = $.encode([r.timestamp, e.roomKey])
    }
    return o
  },
  reconstruct: (e, n) => n,
  offset: Q.indexes.length,
  collection: Q,
}
Q.indexes.push(ne)
const te = new e([e.UINT, e.UINT, e.BUFFER], { prefix: 9 }),
  oe = d.roomsByTypeAndTimestampMap
function re(e) {
  const n = [],
    t = e.type
  if (void 0 === t) return n
  n.push(t)
  const o = e.timestamp
  return (void 0 === o || n.push(o), n)
}
const ce = {
  name: "@local/rooms-by-type-and-timestamp",
  version: 0,
  id: 9,
  encodeKey: (e) => te.encode(re(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    te.encodeRange({
      gt: e ? re(e) : null,
      lt: n ? re(n) : null,
      gte: t ? re(t) : null,
      lte: o ? re(o) : null,
    }),
  encodeValue: (e) => ce.collection.encodeKey(e),
  encodeIndexKeys(e, n) {
    const t = oe(e, n),
      o = new Array(t.length)
    for (let n = 0; n < t.length; n++) {
      const r = t[n]
      o[n] = te.encode([r.type, r.timestamp, e.roomKey])
    }
    return o
  },
  reconstruct: (e, n) => n,
  offset: Q.indexes.length,
  collection: Q,
}
Q.indexes.push(ce)
const le = new e([e.BUFFER], { prefix: 10 })
function de(e) {
  const n = e.capabilities?.wakeupTopic
  return void 0 === n ? [] : [n]
}
const se = {
  name: "@local/rooms-by-wakeup-topic",
  version: 0,
  id: 10,
  encodeKey: (e) => le.encode(de(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    le.encodeRange({
      gt: e ? de(e) : null,
      lt: n ? de(n) : null,
      gte: t ? de(t) : null,
      lte: o ? de(o) : null,
    }),
  encodeValue: (e) => se.collection.encodeKey(e),
  encodeIndexKeys: (e, n) => [le.encode([e.capabilities.wakeupTopic])],
  reconstruct: (e, n) => n,
  offset: Q.indexes.length,
  collection: Q,
}
Q.indexes.push(se)
const ue = new e([e.BUFFER], { prefix: 11 })
function ie(e) {
  const n = e.capabilities?.mailboxKeyPair?.publicKey
  return void 0 === n ? [] : [n]
}
const ae = {
  name: "@local/rooms-by-mailbox",
  version: 0,
  id: 11,
  encodeKey: (e) => ue.encode(ie(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    ue.encodeRange({
      gt: e ? ie(e) : null,
      lt: n ? ie(n) : null,
      gte: t ? ie(t) : null,
      lte: o ? ie(o) : null,
    }),
  encodeValue: (e) => ae.collection.encodeKey(e),
  encodeIndexKeys: (e, n) => [ue.encode([e.capabilities.mailboxKeyPair.publicKey])],
  reconstruct: (e, n) => n,
  offset: Q.indexes.length,
  collection: Q,
}
Q.indexes.push(ae)
const fe = new e([e.BUFFER], { prefix: 12 })
function ge(e) {
  const n = e.capabilities?.discoveryKeyPair?.publicKey
  return void 0 === n ? [] : [n]
}
const ye = {
  name: "@local/rooms-by-discovery",
  version: 0,
  id: 12,
  encodeKey: (e) => fe.encode(ge(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    fe.encodeRange({
      gt: e ? ge(e) : null,
      lt: n ? ge(n) : null,
      gte: t ? ge(t) : null,
      lte: o ? ge(o) : null,
    }),
  encodeValue: (e) => ye.collection.encodeKey(e),
  encodeIndexKeys: (e, n) => [fe.encode([e.capabilities.discoveryKeyPair.publicKey])],
  reconstruct: (e, n) => n,
  offset: Q.indexes.length,
  collection: Q,
}
Q.indexes.push(ye)
const be = new e([e.BUFFER], { prefix: 13 })
function pe(e) {
  const n = e.roomKey
  return void 0 === n ? [] : [n]
}
const me = r("@local/room-preferences/hyperdb#13")
function Ke(e, n, t) {
  const o = be.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = me.decode(r)
  return ((l.roomKey = o[0]), l)
}
function ve(e) {
  return { roomKey: be.decode(e)[0] }
}
const xe = {
    name: "@local/room-preferences",
    id: 13,
    version: 0,
    encodeKey(e) {
      const n = [e.roomKey]
      return be.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      be.encodeRange({
        gt: e ? pe(e) : null,
        lt: n ? pe(n) : null,
        gte: t ? pe(t) : null,
        lte: o ? pe(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (me.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), me.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: Ke,
    reconstructKey: ve,
    indexes: [],
    decodedVersion: 0,
  },
  he = new e([e.BUFFER], { prefix: 14 })
function Re(e) {
  const n = e.mailbox
  return void 0 === n ? [] : [n]
}
const we = r("@local/writer/hyperdb#14")
function Ue(e, n, t) {
  const o = he.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = we.decode(r)
  return ((l.mailbox = o[0]), l)
}
function Ve(e) {
  return { mailbox: he.decode(e)[0] }
}
const Fe = {
    name: "@local/writers",
    id: 14,
    version: 0,
    encodeKey(e) {
      const n = [e.mailbox]
      return he.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      he.encodeRange({
        gt: e ? Re(e) : null,
        lt: n ? Re(n) : null,
        gte: t ? Re(t) : null,
        lte: o ? Re(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (we.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), we.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: Ue,
    reconstructKey: Ve,
    indexes: [],
    decodedVersion: 0,
  },
  ke = new e([e.BUFFER], { prefix: 15 }),
  Be = d.writersByWakeupTopicMap
function Ee(e) {
  const n = e.wakeupTopic
  return void 0 === n ? [] : [n]
}
const Ie = {
  name: "@local/writers-by-wakeup-topic",
  version: 0,
  id: 15,
  encodeKey: (e) => ke.encode(Ee(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    ke.encodeRange({
      gt: e ? Ee(e) : null,
      lt: n ? Ee(n) : null,
      gte: t ? Ee(t) : null,
      lte: o ? Ee(o) : null,
    }),
  encodeValue: (e) => Ie.collection.encodeKey(e),
  encodeIndexKeys(e, n) {
    const t = Be(e, n),
      o = new Array(t.length)
    for (let e = 0; e < t.length; e++) {
      const n = t[e]
      o[e] = ke.encode([n.wakeupTopic])
    }
    return o
  },
  reconstruct: (e, n) => n,
  offset: Fe.indexes.length,
  collection: Fe,
}
Fe.indexes.push(Ie)
const Te = new e([e.BUFFER], { prefix: 16 }),
  Le = d.writersByRoomKeyMap
function Ne(e) {
  const n = e.roomKey
  return void 0 === n ? [] : [n]
}
const De = {
  name: "@local/writers-by-room-key",
  version: 0,
  id: 16,
  encodeKey: (e) => Te.encode(Ne(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    Te.encodeRange({
      gt: e ? Ne(e) : null,
      lt: n ? Ne(n) : null,
      gte: t ? Ne(t) : null,
      lte: o ? Ne(o) : null,
    }),
  encodeValue: (e) => De.collection.encodeKey(e),
  encodeIndexKeys(e, n) {
    const t = Le(e, n),
      o = new Array(t.length)
    for (let e = 0; e < t.length; e++) {
      const n = t[e]
      o[e] = Te.encode([n.roomKey])
    }
    return o
  },
  reconstruct: (e, n) => n,
  offset: Fe.indexes.length,
  collection: Fe,
}
Fe.indexes.push(De)
const Ae = new e([e.BUFFER], { prefix: 17 })
function Pe(e) {
  const n = e.key
  return void 0 === n ? [] : [n]
}
const Me = r("@local/member/hyperdb#17")
function Oe(e, n, t) {
  const o = Ae.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = Me.decode(r)
  return ((l.key = o[0]), l)
}
function Ge(e) {
  return { key: Ae.decode(e)[0] }
}
const Se = {
    name: "@local/members",
    id: 17,
    version: 0,
    encodeKey(e) {
      const n = [e.key]
      return Ae.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      Ae.encodeRange({
        gt: e ? Pe(e) : null,
        lt: n ? Pe(n) : null,
        gte: t ? Pe(t) : null,
        lte: o ? Pe(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (Me.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), Me.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: Oe,
    reconstructKey: Ge,
    indexes: [],
    decodedVersion: 0,
  },
  qe = new e([e.BUFFER], { prefix: 18 })
function Ce(e) {
  const n = e.device?.key
  return void 0 === n ? [] : [n]
}
const je = r("@local/device/hyperdb#18")
function We(e, n, t) {
  const o = qe.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = je.decode(r)
  return ((l.device.key = o[0]), l)
}
function ze(e) {
  return { device: { key: qe.decode(e)[0] } }
}
const He = {
    name: "@local/devices",
    id: 18,
    version: 0,
    encodeKey(e) {
      const n = [e.device.key]
      return qe.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      qe.encodeRange({
        gt: e ? Ce(e) : null,
        lt: n ? Ce(n) : null,
        gte: t ? Ce(t) : null,
        lte: o ? Ce(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (je.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), je.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: We,
    reconstructKey: ze,
    indexes: [],
    decodedVersion: 0,
  },
  Je = new e([e.BUFFER], { prefix: 19 })
function Qe(e) {
  const n = e.memberKey
  return void 0 === n ? [] : [n]
}
const Xe = r("@keet-private-id/contact/hyperdb#19")
function Ye(e, n, t) {
  const o = Je.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = Xe.decode(r)
  return ((l.memberKey = o[0]), l)
}
function Ze(e) {
  return { memberKey: Je.decode(e)[0] }
}
const $e = {
    name: "@local/contacts",
    id: 19,
    version: 0,
    encodeKey(e) {
      const n = [e.memberKey]
      return Je.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      Je.encodeRange({
        gt: e ? Qe(e) : null,
        lt: n ? Qe(n) : null,
        gte: t ? Qe(t) : null,
        lte: o ? Qe(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (Xe.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), Xe.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: Ye,
    reconstructKey: Ze,
    indexes: [],
    decodedVersion: 0,
  },
  _e = new e([e.BUFFER], { prefix: 20 }),
  en = d.blockedContactsMap
function nn(e) {
  const n = e.memberKey
  return void 0 === n ? [] : [n]
}
const tn = {
  name: "@local/blocked-contacts",
  version: 0,
  id: 20,
  encodeKey: (e) => _e.encode(nn(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    _e.encodeRange({
      gt: e ? nn(e) : null,
      lt: n ? nn(n) : null,
      gte: t ? nn(t) : null,
      lte: o ? nn(o) : null,
    }),
  encodeValue: (e) => tn.collection.encodeKey(e),
  encodeIndexKeys(e, n) {
    const t = en(e, n),
      o = new Array(t.length)
    for (let e = 0; e < t.length; e++) {
      const n = t[e]
      o[e] = _e.encode([n.memberKey])
    }
    return o
  },
  reconstruct: (e, n) => n,
  offset: $e.indexes.length,
  collection: $e,
}
$e.indexes.push(tn)
const on = new e([e.UINT, e.UINT, e.UINT, e.BUFFER], { prefix: 21 })
function rn(e) {
  const n = [],
    t = e.priority
  if (void 0 === t) return n
  n.push(t)
  const o = e.timestamp
  if (void 0 === o) return n
  n.push(o)
  const r = e.type
  if (void 0 === r) return n
  n.push(r)
  const c = e.discoveryKey
  return (void 0 === c || n.push(c), n)
}
const cn = r("@local/task/hyperdb#21")
function ln(e, n, t) {
  const o = on.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = cn.decode(r)
  return ((l.priority = o[0]), (l.timestamp = o[1]), (l.type = o[2]), (l.discoveryKey = o[3]), l)
}
function dn(e) {
  const n = on.decode(e)
  return { priority: n[0], timestamp: n[1], type: n[2], discoveryKey: n[3] }
}
const sn = {
    name: "@local/tasks",
    id: 21,
    version: 0,
    encodeKey(e) {
      const n = [e.priority, e.timestamp, e.type, e.discoveryKey]
      return on.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      on.encodeRange({
        gt: e ? rn(e) : null,
        lt: n ? rn(n) : null,
        gte: t ? rn(t) : null,
        lte: o ? rn(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (cn.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), cn.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: ln,
    reconstructKey: dn,
    indexes: [],
    decodedVersion: 0,
  },
  un = new e([e.UINT, e.BUFFER], { prefix: 22 })
function an(e) {
  const n = [],
    t = e.type
  if (void 0 === t) return n
  n.push(t)
  const o = e.discoveryKey
  return (void 0 === o || n.push(o), n)
}
const fn = {
  name: "@local/tasks-by-type",
  version: 0,
  id: 22,
  encodeKey: (e) => un.encode(an(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    un.encodeRange({
      gt: e ? an(e) : null,
      lt: n ? an(n) : null,
      gte: t ? an(t) : null,
      lte: o ? an(o) : null,
    }),
  encodeValue: (e) => fn.collection.encodeKey(e),
  encodeIndexKeys: (e, n) => [un.encode([e.type, e.discoveryKey])],
  reconstruct: (e, n) => n,
  offset: sn.indexes.length,
  collection: sn,
}
sn.indexes.push(fn)
const gn = new e([e.BUFFER, e.UINT], { prefix: 23 })
function yn(e) {
  const n = [],
    t = e.file?.pointer?.externalBlob?.key
  if (void 0 === t) return n
  n.push(t)
  const o = e.file?.pointer?.externalBlob?.blob?.blockOffset
  return (void 0 === o || n.push(o), n)
}
const bn = r("@local/file/hyperdb#23")
function pn(e, n, t) {
  const o = gn.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = bn.decode(r)
  return (
    (l.file.pointer.externalBlob.key = o[0]),
    (l.file.pointer.externalBlob.blob.blockOffset = o[1]),
    (Kn.decodedVersion = l.version),
    l
  )
}
function mn(e) {
  return { file: { pointer: { externalBlob: { blob: { blockOffset: gn.decode(e)[1] } } } } }
}
const Kn = {
    name: "@local/blob-files",
    id: 23,
    version: 4,
    encodeKey(e) {
      const n = [e.file.pointer.externalBlob.key, e.file.pointer.externalBlob.blob.blockOffset]
      return gn.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      gn.encodeRange({
        gt: e ? yn(e) : null,
        lt: n ? yn(n) : null,
        gte: t ? yn(t) : null,
        lte: o ? yn(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (
        (o.version = n),
        bn.preencode(r, o),
        (r.buffer = t.allocUnsafe(r.end)),
        bn.encode(r, o),
        r.buffer
      )
    },
    trigger: null,
    reconstruct: pn,
    reconstructKey: mn,
    indexes: [],
    decodedVersion: 0,
  },
  vn = new e([e.BUFFER, e.STRING, e.UINT], { prefix: 24 })
function xn(e) {
  const n = [],
    t = e.file?.pointer?.externalDrive?.key
  if (void 0 === t) return n
  n.push(t)
  const o = e.file?.pointer?.externalDrive?.path
  if (void 0 === o) return n
  n.push(o)
  const r = e.file?.pointer?.externalDrive?.version
  return (void 0 === r || n.push(r), n)
}
const hn = r("@local/file/hyperdb#24")
function Rn(e, n, t) {
  const o = vn.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = hn.decode(r)
  return (
    (l.file.pointer.externalDrive.key = o[0]),
    (l.file.pointer.externalDrive.path = o[1]),
    (l.file.pointer.externalDrive.version = o[2]),
    (Un.decodedVersion = l.version),
    l
  )
}
function wn(e) {
  return { file: { pointer: { externalDrive: { version: vn.decode(e)[2] } } } }
}
const Un = {
    name: "@local/drive-files",
    id: 24,
    version: 4,
    encodeKey(e) {
      const n = [
        e.file.pointer.externalDrive.key,
        e.file.pointer.externalDrive.path,
        e.file.pointer.externalDrive.version,
      ]
      return vn.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      vn.encodeRange({
        gt: e ? xn(e) : null,
        lt: n ? xn(n) : null,
        gte: t ? xn(t) : null,
        lte: o ? xn(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (
        (o.version = n),
        hn.preencode(r, o),
        (r.buffer = t.allocUnsafe(r.end)),
        hn.encode(r, o),
        r.buffer
      )
    },
    trigger: null,
    reconstruct: Rn,
    reconstructKey: wn,
    indexes: [],
    decodedVersion: 0,
  },
  Vn = new e([e.BUFFER, e.BUFFER, e.UINT], { prefix: 25 })
function Fn(e) {
  const n = [],
    t = e.roomKey
  if (void 0 === t) return n
  n.push(t)
  const o = e.file?.pointer?.externalBlob?.key
  if (void 0 === o) return n
  n.push(o)
  const r = e.file?.pointer?.externalBlob?.blob?.blockOffset
  return (void 0 === r || n.push(r), n)
}
const kn = {
  name: "@local/blob-files-by-room",
  version: 0,
  id: 25,
  encodeKey: (e) => Vn.encode(Fn(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    Vn.encodeRange({
      gt: e ? Fn(e) : null,
      lt: n ? Fn(n) : null,
      gte: t ? Fn(t) : null,
      lte: o ? Fn(o) : null,
    }),
  encodeValue: (e) => kn.collection.encodeKey(e),
  encodeIndexKeys: (e, n) => [
    Vn.encode([
      e.roomKey,
      e.file.pointer.externalBlob.key,
      e.file.pointer.externalBlob.blob.blockOffset,
    ]),
  ],
  reconstruct: (e, n) => n,
  offset: Kn.indexes.length,
  collection: Kn,
}
Kn.indexes.push(kn)
const Bn = new e([e.BUFFER, e.BUFFER, e.STRING, e.UINT], { prefix: 26 })
function En(e) {
  const n = [],
    t = e.roomKey
  if (void 0 === t) return n
  n.push(t)
  const o = e.file?.pointer?.externalDrive?.key
  if (void 0 === o) return n
  n.push(o)
  const r = e.file?.pointer?.externalDrive?.path
  if (void 0 === r) return n
  n.push(r)
  const c = e.file?.pointer?.externalDrive?.version
  return (void 0 === c || n.push(c), n)
}
const In = {
  name: "@local/drive-files-by-room",
  version: 0,
  id: 26,
  encodeKey: (e) => Bn.encode(En(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    Bn.encodeRange({
      gt: e ? En(e) : null,
      lt: n ? En(n) : null,
      gte: t ? En(t) : null,
      lte: o ? En(o) : null,
    }),
  encodeValue: (e) => In.collection.encodeKey(e),
  encodeIndexKeys: (e, n) => [
    Bn.encode([
      e.roomKey,
      e.file.pointer.externalDrive.key,
      e.file.pointer.externalDrive.path,
      e.file.pointer.externalDrive.version,
    ]),
  ],
  reconstruct: (e, n) => n,
  offset: Un.indexes.length,
  collection: Un,
}
Un.indexes.push(In)
const Tn = new e([e.BUFFER], { prefix: 27 })
function Ln(e) {
  const n = e.discoveryPublicKey
  return void 0 === n ? [] : [n]
}
const Nn = r("@local/background-sync-room/hyperdb#27")
function Dn(e, n, t) {
  const o = Tn.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = Nn.decode(r)
  return ((l.discoveryPublicKey = o[0]), l)
}
function An(e) {
  return { discoveryPublicKey: Tn.decode(e)[0] }
}
const Pn = {
    name: "@local/background-sync",
    id: 27,
    version: 0,
    encodeKey(e) {
      const n = [e.discoveryPublicKey]
      return Tn.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      Tn.encodeRange({
        gt: e ? Ln(e) : null,
        lt: n ? Ln(n) : null,
        gte: t ? Ln(t) : null,
        lte: o ? Ln(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (Nn.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), Nn.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: Dn,
    reconstructKey: An,
    indexes: [],
    decodedVersion: 0,
  },
  Mn = new e([e.UINT, e.BUFFER], { prefix: 28 }),
  On = d.dirtyByTimestampMap
function Gn(e) {
  const n = e.timestamp
  return void 0 === n ? [] : [n]
}
const Sn = {
  name: "@local/background-sync-by-dirty",
  version: 0,
  id: 28,
  encodeKey: (e) => Mn.encode(Gn(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    Mn.encodeRange({
      gt: e ? Gn(e) : null,
      lt: n ? Gn(n) : null,
      gte: t ? Gn(t) : null,
      lte: o ? Gn(o) : null,
    }),
  encodeValue: (e) => Sn.collection.encodeKey(e),
  encodeIndexKeys(e, n) {
    const t = On(e, n),
      o = new Array(t.length)
    for (let n = 0; n < t.length; n++) {
      const r = t[n]
      o[n] = Mn.encode([r.timestamp, e.discoveryPublicKey])
    }
    return o
  },
  reconstruct: (e, n) => n,
  offset: Pn.indexes.length,
  collection: Pn,
}
Pn.indexes.push(Sn)
const qn = new e([e.BUFFER, e.BUFFER], { prefix: 29 })
function Cn(e) {
  const n = [],
    t = e.key
  if (void 0 === t) return n
  n.push(t)
  const o = e.responsePublicKey
  return (void 0 === o || n.push(o), n)
}
const jn = r("@local/writer-append/hyperdb#29")
function Wn(e, n, t) {
  const o = qn.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = jn.decode(r)
  return ((l.key = o[0]), (l.responsePublicKey = o[1]), l)
}
function zn(e) {
  const n = qn.decode(e)
  return { key: n[0], responsePublicKey: n[1] }
}
const Hn = {
    name: "@local/writer-appends",
    id: 29,
    version: 0,
    encodeKey(e) {
      const n = [e.key, e.responsePublicKey]
      return qn.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      qn.encodeRange({
        gt: e ? Cn(e) : null,
        lt: n ? Cn(n) : null,
        gte: t ? Cn(t) : null,
        lte: o ? Cn(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (jn.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), jn.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: Wn,
    reconstructKey: zn,
    indexes: [],
    decodedVersion: 0,
  },
  Jn = new e([e.BUFFER], { prefix: 30 })
function Qn(e) {
  const n = e.roomKey
  return void 0 === n ? [] : [n]
}
const Xn = r("@local/room-metadata/hyperdb#30")
function Yn(e, n, t) {
  const o = Jn.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = Xn.decode(r)
  return ((l.roomKey = o[0]), l)
}
function Zn(e) {
  return { roomKey: Jn.decode(e)[0] }
}
const $n = {
    name: "@local/room-metadata",
    id: 30,
    version: 0,
    encodeKey(e) {
      const n = [e.roomKey]
      return Jn.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      Jn.encodeRange({
        gt: e ? Qn(e) : null,
        lt: n ? Qn(n) : null,
        gte: t ? Qn(t) : null,
        lte: o ? Qn(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (Xn.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), Xn.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: Yn,
    reconstructKey: Zn,
    indexes: [],
    decodedVersion: 0,
  },
  _n = new e([], { prefix: 31 })
function et(e) {
  return []
}
const nt = r("@local/debug")
function tt(e, n, t) {
  c(e)
  const o = { start: 0, end: t.byteLength, buffer: t }
  return nt.decode(o)
}
function ot(e) {
  return {}
}
const rt = {
    name: "@local/debug",
    id: 31,
    version: 0,
    encodeKey: (e) => _n.encode([]),
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      _n.encodeRange({
        gt: e ? et(e) : null,
        lt: n ? et(n) : null,
        gte: t ? et(t) : null,
        lte: o ? et(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (nt.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), nt.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: tt,
    reconstructKey: ot,
    indexes: [],
    decodedVersion: 0,
  },
  ct = new e([e.BUFFER, e.BUFFER], { prefix: 32 }),
  lt = d.roomsByContactMap
function dt(e) {
  const n = e.contact
  return void 0 === n ? [] : [n]
}
const st = {
  name: "@local/rooms-by-contact",
  version: 1,
  id: 32,
  encodeKey: (e) => ct.encode(dt(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    ct.encodeRange({
      gt: e ? dt(e) : null,
      lt: n ? dt(n) : null,
      gte: t ? dt(t) : null,
      lte: o ? dt(o) : null,
    }),
  encodeValue: (e) => st.collection.encodeKey(e),
  encodeIndexKeys(e, n) {
    const t = lt(e, n),
      o = new Array(t.length)
    for (let n = 0; n < t.length; n++) {
      const r = t[n]
      o[n] = ct.encode([r.contact, e.roomKey])
    }
    return o
  },
  reconstruct: (e, n) => n,
  offset: Q.indexes.length,
  collection: Q,
}
Q.indexes.push(st)
const ut = new e([e.BUFFER], { prefix: 33 })
function it(e) {
  const n = e.roomKey
  return void 0 === n ? [] : [n]
}
const at = r("@local/unread/hyperdb#33")
function ft(e, n, t) {
  const o = ut.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = at.decode(r)
  return ((l.roomKey = o[0]), l)
}
function gt(e) {
  return { roomKey: ut.decode(e)[0] }
}
const yt = {
    name: "@local/unreads",
    id: 33,
    version: 0,
    encodeKey(e) {
      const n = [e.roomKey]
      return ut.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      ut.encodeRange({
        gt: e ? it(e) : null,
        lt: n ? it(n) : null,
        gte: t ? it(t) : null,
        lte: o ? it(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (at.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), at.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: ft,
    reconstructKey: gt,
    indexes: [],
    decodedVersion: 0,
  },
  bt = new e([], { prefix: 34 })
function pt(e) {
  return []
}
const mt = r("@local/hyperdht-record")
function Kt(e, n, t) {
  c(e)
  const o = { start: 0, end: t.byteLength, buffer: t }
  return mt.decode(o)
}
function vt(e) {
  return {}
}
const xt = {
    name: "@local/hyperdht",
    id: 34,
    version: 0,
    encodeKey: (e) => bt.encode([]),
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      bt.encodeRange({
        gt: e ? pt(e) : null,
        lt: n ? pt(n) : null,
        gte: t ? pt(t) : null,
        lte: o ? pt(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (mt.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), mt.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: Kt,
    reconstructKey: vt,
    indexes: [],
    decodedVersion: 0,
  },
  ht = new e([e.UINT], { prefix: 35 })
function Rt(e) {
  const n = e.timestamp
  return void 0 === n ? [] : [n]
}
const wt = r("@local/error-record/hyperdb#35")
function Ut(e, n, t) {
  const o = ht.decode(n)
  c(e)
  const r = { start: 0, end: t.byteLength, buffer: t },
    l = wt.decode(r)
  return ((l.timestamp = o[0]), l)
}
function Vt(e) {
  return { timestamp: ht.decode(e)[0] }
}
const Ft = {
    name: "@local/errors",
    id: 35,
    version: 0,
    encodeKey(e) {
      const n = [e.timestamp]
      return ht.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      ht.encodeRange({
        gt: e ? Rt(e) : null,
        lt: n ? Rt(n) : null,
        gte: t ? Rt(t) : null,
        lte: o ? Rt(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 0, buffer: null }
      return (wt.preencode(r, o), (r.buffer = t.allocUnsafe(r.end)), wt.encode(r, o), r.buffer)
    },
    trigger: null,
    reconstruct: Ut,
    reconstructKey: Vt,
    indexes: [],
    decodedVersion: 0,
  },
  kt = new e([e.STRING, e.UINT], { prefix: 36 })
function Bt(e) {
  const n = [],
    t = e.code
  if (void 0 === t) return n
  n.push(t)
  const o = e.timestamp
  return (void 0 === o || n.push(o), n)
}
const Et = {
  name: "@local/errors-by-code",
  version: 0,
  id: 36,
  encodeKey: (e) => kt.encode(Bt(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    kt.encodeRange({
      gt: e ? Bt(e) : null,
      lt: n ? Bt(n) : null,
      gte: t ? Bt(t) : null,
      lte: o ? Bt(o) : null,
    }),
  encodeValue: (e) => Et.collection.encodeKey(e),
  encodeIndexKeys: (e, n) => [kt.encode([e.code, e.timestamp])],
  reconstruct: (e, n) => n,
  offset: Ft.indexes.length,
  collection: Ft,
}
Ft.indexes.push(Et)
const It = new e([e.BUFFER], { prefix: 37 })
function Tt(e) {
  const n = e.roomKey
  return void 0 === n ? [] : [n]
}
const Lt = r("@local/file-stats/hyperdb#37")
function Nt(e, t, o) {
  const r = It.decode(t)
  c(e)
  const l = { start: 0, end: o.byteLength, buffer: o },
    d = n.uint.decode(l)
  if (0 !== d) throw new Error("Unknown collection type: " + d)
  At.decodedVersion = n.uint.decode(l)
  const s = Lt.decode(l)
  return ((s.roomKey = r[0]), s)
}
function Dt(e) {
  return { roomKey: It.decode(e)[0] }
}
const At = {
    name: "@local/file-stats",
    id: 37,
    version: 2,
    encodeKey(e) {
      const n = [e.roomKey]
      return It.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      It.encodeRange({
        gt: e ? Tt(e) : null,
        lt: n ? Tt(n) : null,
        gte: t ? Tt(t) : null,
        lte: o ? Tt(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 2, buffer: null }
      return (
        Lt.preencode(r, o),
        (r.buffer = t.allocUnsafe(r.end)),
        (r.buffer[r.start++] = 0),
        (r.buffer[r.start++] = n),
        Lt.encode(r, o),
        r.buffer
      )
    },
    trigger: null,
    reconstruct: Nt,
    reconstructKey: Dt,
    indexes: [],
    decodedVersion: 0,
  },
  Pt = new e([e.UINT, e.BUFFER], { prefix: 38 }),
  Mt = d.roomsByFavoriteAndTimestampMap
function Ot(e) {
  const n = e.timestamp
  return void 0 === n ? [] : [n]
}
const Gt = {
  name: "@local/rooms-by-favorite-and-timestamp",
  version: 3,
  id: 38,
  encodeKey: (e) => Pt.encode(Ot(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    Pt.encodeRange({
      gt: e ? Ot(e) : null,
      lt: n ? Ot(n) : null,
      gte: t ? Ot(t) : null,
      lte: o ? Ot(o) : null,
    }),
  encodeValue: (e) => Gt.collection.encodeKey(e),
  encodeIndexKeys(e, n) {
    const t = Mt(e, n),
      o = new Array(t.length)
    for (let n = 0; n < t.length; n++) {
      const r = t[n]
      o[n] = Pt.encode([r.timestamp, e.roomKey])
    }
    return o
  },
  reconstruct: (e, n) => n,
  offset: Q.indexes.length,
  collection: Q,
}
Q.indexes.push(Gt)
const St = new e([e.UINT, e.BUFFER, e.UINT], { prefix: 39 })
function qt(e) {
  const n = [],
    t = e.lastAccessed
  if (void 0 === t) return n
  n.push(t)
  const o = e.file?.pointer?.externalBlob?.key
  if (void 0 === o) return n
  n.push(o)
  const r = e.file?.pointer?.externalBlob?.blob?.blockOffset
  return (void 0 === r || n.push(r), n)
}
const Ct = {
  name: "@local/blob-files-by-last-accessed",
  version: 4,
  id: 39,
  encodeKey: (e) => St.encode(qt(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    St.encodeRange({
      gt: e ? qt(e) : null,
      lt: n ? qt(n) : null,
      gte: t ? qt(t) : null,
      lte: o ? qt(o) : null,
    }),
  encodeValue: (e) => Ct.collection.encodeKey(e),
  encodeIndexKeys: (e, n) => [
    St.encode([
      e.lastAccessed,
      e.file.pointer.externalBlob.key,
      e.file.pointer.externalBlob.blob.blockOffset,
    ]),
  ],
  reconstruct: (e, n) => n,
  offset: Kn.indexes.length,
  collection: Kn,
}
Kn.indexes.push(Ct)
const jt = new e([e.UINT, e.BUFFER, e.STRING, e.UINT], { prefix: 40 })
function Wt(e) {
  const n = [],
    t = e.lastAccessed
  if (void 0 === t) return n
  n.push(t)
  const o = e.file?.pointer?.externalDrive?.key
  if (void 0 === o) return n
  n.push(o)
  const r = e.file?.pointer?.externalDrive?.path
  if (void 0 === r) return n
  n.push(r)
  const c = e.file?.pointer?.externalDrive?.version
  return (void 0 === c || n.push(c), n)
}
const zt = {
  name: "@local/drive-files-by-last-accessed",
  version: 4,
  id: 40,
  encodeKey: (e) => jt.encode(Wt(e)),
  encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
    jt.encodeRange({
      gt: e ? Wt(e) : null,
      lt: n ? Wt(n) : null,
      gte: t ? Wt(t) : null,
      lte: o ? Wt(o) : null,
    }),
  encodeValue: (e) => zt.collection.encodeKey(e),
  encodeIndexKeys: (e, n) => [
    jt.encode([
      e.lastAccessed,
      e.file.pointer.externalDrive.key,
      e.file.pointer.externalDrive.path,
      e.file.pointer.externalDrive.version,
    ]),
  ],
  reconstruct: (e, n) => n,
  offset: Un.indexes.length,
  collection: Un,
}
Un.indexes.push(zt)
const Ht = new e([], { prefix: 41 })
function Jt(e) {
  return []
}
const Qt = r("@local/file-gc-info")
function Xt(e, t, o) {
  c(e)
  const r = { start: 0, end: o.byteLength, buffer: o },
    l = n.uint.decode(r)
  if (0 !== l) throw new Error("Unknown collection type: " + l)
  return ((Zt.decodedVersion = n.uint.decode(r)), Qt.decode(r))
}
function Yt(e) {
  return {}
}
const Zt = {
    name: "@local/file-gc-info",
    id: 41,
    version: 4,
    encodeKey: (e) => Ht.encode([]),
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      Ht.encodeRange({
        gt: e ? Jt(e) : null,
        lt: n ? Jt(n) : null,
        gte: t ? Jt(t) : null,
        lte: o ? Jt(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 2, buffer: null }
      return (
        Qt.preencode(r, o),
        (r.buffer = t.allocUnsafe(r.end)),
        (r.buffer[r.start++] = 0),
        (r.buffer[r.start++] = n),
        Qt.encode(r, o),
        r.buffer
      )
    },
    trigger: null,
    reconstruct: Xt,
    reconstructKey: Yt,
    indexes: [],
    decodedVersion: 0,
  },
  $t = new e([], { prefix: 42 })
function _t(e) {
  return []
}
const eo = r("@local/environment-record")
function no(e, t, o) {
  c(e)
  const r = { start: 0, end: o.byteLength, buffer: o },
    l = n.uint.decode(r)
  if (0 !== l) throw new Error("Unknown collection type: " + l)
  return ((oo.decodedVersion = n.uint.decode(r)), eo.decode(r))
}
function to(e) {
  return {}
}
const oo = {
    name: "@local/environment",
    id: 42,
    version: 5,
    encodeKey: (e) => $t.encode([]),
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      $t.encodeRange({
        gt: e ? _t(e) : null,
        lt: n ? _t(n) : null,
        gte: t ? _t(t) : null,
        lte: o ? _t(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 2, buffer: null }
      return (
        eo.preencode(r, o),
        (r.buffer = t.allocUnsafe(r.end)),
        (r.buffer[r.start++] = 0),
        (r.buffer[r.start++] = n),
        eo.encode(r, o),
        r.buffer
      )
    },
    trigger: null,
    reconstruct: no,
    reconstructKey: to,
    indexes: [],
    decodedVersion: 0,
  },
  ro = new e([], { prefix: 43 })
function co(e) {
  return []
}
const lo = r("@local/ota-actions")
function so(e, t, o) {
  c(e)
  const r = { start: 0, end: o.byteLength, buffer: o },
    l = n.uint.decode(r)
  if (0 !== l) throw new Error("Unknown collection type: " + l)
  return ((io.decodedVersion = n.uint.decode(r)), lo.decode(r))
}
function uo(e) {
  return {}
}
const io = {
    name: "@local/ota-actions",
    id: 43,
    version: 6,
    encodeKey: (e) => ro.encode([]),
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      ro.encodeRange({
        gt: e ? co(e) : null,
        lt: n ? co(n) : null,
        gte: t ? co(t) : null,
        lte: o ? co(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 2, buffer: null }
      return (
        lo.preencode(r, o),
        (r.buffer = t.allocUnsafe(r.end)),
        (r.buffer[r.start++] = 0),
        (r.buffer[r.start++] = n),
        lo.encode(r, o),
        r.buffer
      )
    },
    trigger: null,
    reconstruct: so,
    reconstructKey: uo,
    indexes: [],
    decodedVersion: 0,
  },
  ao = new e([e.BUFFER], { prefix: 44 })
function fo(e) {
  const n = e.deviceKey
  return void 0 === n ? [] : [n]
}
const go = r("@local/device-attestation/hyperdb#44")
function yo(e, t, o) {
  const r = ao.decode(t)
  c(e)
  const l = { start: 0, end: o.byteLength, buffer: o },
    d = n.uint.decode(l)
  if (0 !== d) throw new Error("Unknown collection type: " + d)
  po.decodedVersion = n.uint.decode(l)
  const s = go.decode(l)
  return ((s.deviceKey = r[0]), s)
}
function bo(e) {
  return { deviceKey: ao.decode(e)[0] }
}
const po = {
    name: "@local/device-attestations",
    id: 44,
    version: 6,
    encodeKey(e) {
      const n = [e.deviceKey]
      return ao.encode(n)
    },
    encodeKeyRange: ({ gt: e, lt: n, gte: t, lte: o } = {}) =>
      ao.encodeRange({
        gt: e ? fo(e) : null,
        lt: n ? fo(n) : null,
        gte: t ? fo(t) : null,
        lte: o ? fo(o) : null,
      }),
    encodeValue(e, n, o) {
      c(e)
      const r = { start: 0, end: 2, buffer: null }
      return (
        go.preencode(r, o),
        (r.buffer = t.allocUnsafe(r.end)),
        (r.buffer[r.start++] = 0),
        (r.buffer[r.start++] = n),
        go.encode(r, o),
        r.buffer
      )
    },
    trigger: null,
    reconstruct: yo,
    reconstructKey: bo,
    indexes: [],
    decodedVersion: 0,
  },
  mo = [
    g,
    v,
    V,
    L,
    q,
    Q,
    xe,
    Fe,
    Se,
    He,
    $e,
    sn,
    Kn,
    Un,
    Pn,
    Hn,
    $n,
    rt,
    yt,
    xt,
    Ft,
    At,
    Zt,
    oo,
    io,
    po,
  ],
  Ko = [A, Z, ne, ce, se, ae, ye, Ie, De, tn, fn, kn, In, Sn, st, Et, Gt, Ct, zt]
function vo(e) {
  switch (e) {
    case "@local/stats":
      return g
    case "@local/migrations":
      return v
    case "@local/room-migration-stats":
      return V
    case "@local/room-migrations":
      return L
    case "@local/identity":
      return q
    case "@local/rooms":
      return Q
    case "@local/room-preferences":
      return xe
    case "@local/writers":
      return Fe
    case "@local/members":
      return Se
    case "@local/devices":
      return He
    case "@local/contacts":
      return $e
    case "@local/tasks":
      return sn
    case "@local/blob-files":
      return Kn
    case "@local/drive-files":
      return Un
    case "@local/background-sync":
      return Pn
    case "@local/writer-appends":
      return Hn
    case "@local/room-metadata":
      return $n
    case "@local/debug":
      return rt
    case "@local/unreads":
      return yt
    case "@local/hyperdht":
      return xt
    case "@local/errors":
      return Ft
    case "@local/file-stats":
      return At
    case "@local/file-gc-info":
      return Zt
    case "@local/environment":
      return oo
    case "@local/ota-actions":
      return io
    case "@local/device-attestations":
      return po
    default:
      return null
  }
}
function xo(e) {
  switch (e) {
    case "@local/room-migrations-by-priority":
      return A
    case "@local/rooms-by-discovery-key":
      return Z
    case "@local/rooms-by-timestamp":
      return ne
    case "@local/rooms-by-type-and-timestamp":
      return ce
    case "@local/rooms-by-wakeup-topic":
      return se
    case "@local/rooms-by-mailbox":
      return ae
    case "@local/rooms-by-discovery":
      return ye
    case "@local/writers-by-wakeup-topic":
      return Ie
    case "@local/writers-by-room-key":
      return De
    case "@local/blocked-contacts":
      return tn
    case "@local/tasks-by-type":
      return fn
    case "@local/blob-files-by-room":
      return kn
    case "@local/drive-files-by-room":
      return In
    case "@local/background-sync-by-dirty":
      return Sn
    case "@local/rooms-by-contact":
      return st
    case "@local/errors-by-code":
      return Et
    case "@local/rooms-by-favorite-and-timestamp":
      return Gt
    case "@local/blob-files-by-last-accessed":
      return Ct
    case "@local/drive-files-by-last-accessed":
      return zt
    default:
      return null
  }
}
module.exports = {
  versions: l,
  collections: mo,
  indexes: Ko,
  resolveCollection: vo,
  resolveIndex: xo,
}