@seedprotocol/feed 0.4.21 → 0.4.22

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/dist/index.js CHANGED
@@ -1,43 +1,43 @@
1
- import { BaseArweaveClient as De, getSeedsBySchemaName as We, withExcludeRevokedFilter as Se, EasClient as Te, getItemVersionsFromEas as He, getItemPropertiesFromEas as ze, pickLatestPropertyAttestationsByRefAndSchema as Ge, setSchemaUidForSchemaDefinition as Je, DEFAULT_ARWEAVE_GATEWAYS as Ee, client as L, DEFAULT_ARWEAVE_HOST as Xe } from "@seedprotocol/sdk";
2
- import { classifyMediaRef as on, getFeedItemStringField as cn, normalizeFeedItemFields as ln, resolveMediaRef as dn } from "@seedprotocol/sdk";
3
- import { gql as Ve } from "graphql-request";
4
- import b from "pluralize";
5
- import Ye from "rss-parser";
6
- import { generateJsonFeed as Ke, generateAtomFeed as qe } from "feedsmith";
7
- import { create as Ze } from "xmlbuilder2";
8
- import { createHash as Qe } from "crypto";
9
- import { promises as I } from "fs";
10
- import { join as U } from "path";
11
- import le from "image-size";
1
+ import { BaseArweaveClient as _e, isKnownArweaveGatewayHostname as Ve, getSeedsBySchemaName as Ke, withExcludeRevokedFilter as Ie, EasClient as $e, getItemVersionsFromEas as Ye, getItemPropertiesFromEas as qe, pickLatestPropertyAttestationsByRefAndSchema as Ze, setSchemaUidForSchemaDefinition as Qe, DEFAULT_ARWEAVE_GATEWAYS as Me, ensureReadGatewaySelected as et, client as L, DEFAULT_ARWEAVE_HOST as tt } from "@seedprotocol/sdk";
2
+ import { classifyMediaRef as En, getFeedItemStringField as _n, normalizeFeedItemFields as In, resolveMediaRef as $n } from "@seedprotocol/sdk";
3
+ import { gql as nt } from "graphql-request";
4
+ import U from "pluralize";
5
+ import rt from "rss-parser";
6
+ import { generateJsonFeed as ot, generateAtomFeed as st } from "feedsmith";
7
+ import { create as at } from "xmlbuilder2";
8
+ import { createHash as it } from "crypto";
9
+ import { promises as E } from "fs";
10
+ import { join as F } from "path";
11
+ import ue from "image-size";
12
12
  function j(t) {
13
- return `https://${De.getHost()}/${t}`;
13
+ return `https://${_e.getHost()}/${t}`;
14
14
  }
15
15
  function G() {
16
- const t = process.env.FEED_ITEM_URL_BASE?.trim() || "https://optimism-sepolia.easscan.org", e = process.env.FEED_ITEM_URL_PATH?.trim() || "attestation/view", n = process.env.FEED_SITE_URL?.trim() || "https://seedprotocol.io", s = process.env.FEED_EXPAND_RELATIONS?.toLowerCase() !== "false", r = parseInt(process.env.FEED_PAGE_SIZE || "25", 10), a = process.env.FEED_INCLUDE_DATA_URI_HTML_ITEMS?.toLowerCase() === "true" ? "include_items" : "omit_items";
17
- return { itemUrlBase: t, itemUrlPath: e, siteUrl: n, expandRelations: s, pageSize: r, richTextDataUriImages: a };
16
+ const t = process.env.FEED_ITEM_URL_BASE?.trim() || "https://optimism-sepolia.easscan.org", e = process.env.FEED_ITEM_URL_PATH?.trim() || "attestation/view", n = process.env.FEED_SITE_URL?.trim() || "https://seedprotocol.io", s = process.env.FEED_EXPAND_RELATIONS?.toLowerCase() !== "false", o = parseInt(process.env.FEED_PAGE_SIZE || "25", 10), i = process.env.FEED_INCLUDE_DATA_URI_HTML_ITEMS?.toLowerCase() === "true" ? "include_items" : "omit_items";
17
+ return { itemUrlBase: t, itemUrlPath: e, siteUrl: n, expandRelations: s, pageSize: o, richTextDataUriImages: i };
18
18
  }
19
- const et = /^(.+?)([A-Z][a-zA-Z]+)Ids$/;
20
- function oe(t) {
21
- const e = et.exec(t);
19
+ const ct = /^(.+?)([A-Z][a-zA-Z]+)Ids$/;
20
+ function le(t) {
21
+ const e = ct.exec(t);
22
22
  if (e) {
23
23
  const n = e[1];
24
- if (n) return b(n);
24
+ if (n) return U(n);
25
25
  }
26
26
  if (t.endsWith("_ids")) {
27
27
  const n = t.slice(0, -4), s = n.split("_").filter(Boolean);
28
28
  if (s.length >= 2) {
29
- const r = s[0];
30
- return r.endsWith("s") ? r : b(r);
29
+ const o = s[0];
30
+ return o.endsWith("s") ? o : U(o);
31
31
  }
32
- return b(n);
32
+ return U(n);
33
33
  }
34
34
  return t;
35
35
  }
36
- function Ae(t, e) {
36
+ function Fe(t, e) {
37
37
  for (const n of Object.keys(t))
38
- n !== e && oe(n) === e && delete t[n];
38
+ n !== e && le(n) === e && delete t[n];
39
39
  }
40
- function Ie(t) {
40
+ function be(t) {
41
41
  if (Array.isArray(t) || typeof t != "string") return t;
42
42
  const e = t.trim();
43
43
  if (!e.startsWith("[")) return t;
@@ -48,7 +48,7 @@ function Ie(t) {
48
48
  }
49
49
  return t;
50
50
  }
51
- function tt(t) {
51
+ function lt(t) {
52
52
  const e = t.storageTransactionId ?? t.storage_transaction_id;
53
53
  if (e && typeof e == "string" && e.trim())
54
54
  try {
@@ -56,52 +56,52 @@ function tt(t) {
56
56
  } catch {
57
57
  }
58
58
  }
59
- const nt = /* @__PURE__ */ new Set(["html", "file", "json"]), _e = "_feedFieldStorageModels", $e = "_feedListElementStorageModels";
60
- function Z(t) {
59
+ const dt = /* @__PURE__ */ new Set(["html", "file", "json"]), Ue = "_feedFieldStorageModels", ve = "_feedListElementStorageModels";
60
+ function Q(t) {
61
61
  return t.trim().toLowerCase();
62
62
  }
63
63
  function B(t) {
64
- return nt.has(Z(t));
64
+ return dt.has(Q(t));
65
65
  }
66
- function de(t) {
67
- const e = Z(t);
66
+ function he(t) {
67
+ const e = Q(t);
68
68
  return e === "html" ? 0 : e === "file" ? 1 : e === "json" ? 2 : 99;
69
69
  }
70
- function Q(t) {
71
- const e = t[_e];
70
+ function ee(t) {
71
+ const e = t[Ue];
72
72
  if (e !== null && typeof e == "object" && !Array.isArray(e))
73
73
  return e;
74
74
  }
75
- function ee(t) {
76
- const e = t[$e];
75
+ function te(t) {
76
+ const e = t[ve];
77
77
  if (e !== null && typeof e == "object" && !Array.isArray(e))
78
78
  return e;
79
79
  }
80
- function fe(t, e, n) {
81
- const s = Z(n);
82
- let r = Q(t);
83
- r || (r = {}, t[_e] = r), r[e] = s;
80
+ function ge(t, e, n) {
81
+ const s = Q(n);
82
+ let o = ee(t);
83
+ o || (o = {}, t[Ue] = o), o[e] = s;
84
84
  }
85
- function rt(t, e, n) {
86
- let s = ee(t);
87
- s || (s = {}, t[$e] = s), s[e] = n.map(Z);
85
+ function ft(t, e, n) {
86
+ let s = te(t);
87
+ s || (s = {}, t[ve] = s), s[e] = n.map(Q);
88
88
  }
89
- const at = ["html", "Html", "body", "Body", "content", "Content"], st = 2e6;
90
- function Me(t) {
89
+ const ut = ["html", "Html", "body", "Body", "content", "Content"], ht = 8e6;
90
+ function xe(t) {
91
91
  const e = t.trim();
92
92
  if (!e.startsWith("http://") && !e.startsWith("https://")) return !1;
93
93
  try {
94
- const n = new URL(e), s = n.hostname.toLowerCase(), r = De.getHost().toLowerCase();
95
- if (s !== r && !s.endsWith("arweave.net")) return !1;
96
- const a = n.pathname.replace(/^\//, "").split("/").filter(Boolean);
97
- if (a.length !== 1) return !1;
98
- const o = a[0];
99
- return /^[A-Za-z0-9_-]{43}$/.test(o);
94
+ const n = new URL(e), s = n.hostname.toLowerCase(), o = _e.getHost().toLowerCase();
95
+ if (s !== o && !Ve(s)) return !1;
96
+ const i = n.pathname.replace(/^\//, "").split("/").filter(Boolean);
97
+ if (i.length !== 1) return !1;
98
+ const r = i[0];
99
+ return /^[A-Za-z0-9_-]{43}$/.test(r);
100
100
  } catch {
101
101
  return !1;
102
102
  }
103
103
  }
104
- async function Fe(t) {
104
+ async function ke(t) {
105
105
  try {
106
106
  const e = await fetch(t, {
107
107
  headers: { Accept: "text/html, text/plain, text/markdown, application/json, */*" },
@@ -111,58 +111,58 @@ async function Fe(t) {
111
111
  const n = e.headers.get("content-type") ?? "";
112
112
  if (/^(image|video|audio)\//i.test(n)) return null;
113
113
  const s = await e.arrayBuffer();
114
- if (s.byteLength > st) return null;
115
- const r = new TextDecoder("utf-8", { fatal: !1 }).decode(s);
116
- return r.length === 0 || r.includes("\0") ? null : r;
114
+ if (s.byteLength > ht) return null;
115
+ const o = new TextDecoder("utf-8", { fatal: !1 }).decode(s);
116
+ return o.length === 0 || o.includes("\0") ? null : o;
117
117
  } catch {
118
118
  return null;
119
119
  }
120
120
  }
121
- async function ot(t, e) {
121
+ async function gt(t, e) {
122
122
  const n = t[e];
123
- if (typeof n != "string" || n.trim() === "" || !Me(n)) return;
124
- const s = await Fe(n);
123
+ if (typeof n != "string" || n.trim() === "" || !xe(n)) return;
124
+ const s = await ke(n);
125
125
  s !== null && (t[e] = s);
126
126
  }
127
- async function it(t) {
127
+ async function pt(t) {
128
128
  for (const e of t) {
129
- const n = /* @__PURE__ */ new Set([...at]), s = Q(e);
129
+ const n = /* @__PURE__ */ new Set([...ut]), s = ee(e);
130
130
  if (s)
131
- for (const [a, o] of Object.entries(s))
132
- B(o) && n.add(a);
133
- for (const a of n)
134
- await ot(e, a);
135
- const r = ee(e);
136
- if (r)
137
- for (const [a, o] of Object.entries(r)) {
138
- const i = e[a];
139
- if (!Array.isArray(i)) continue;
140
- const c = Math.min(o.length, i.length);
141
- for (let d = 0; d < c; d++) {
142
- if (!B(o[d])) continue;
143
- const f = i[d];
144
- if (typeof f != "string" || !Me(f)) continue;
145
- const p = await Fe(f);
146
- p !== null && (i[d] = p);
131
+ for (const [i, r] of Object.entries(s))
132
+ B(r) && n.add(i);
133
+ for (const i of n)
134
+ await gt(e, i);
135
+ const o = te(e);
136
+ if (o)
137
+ for (const [i, r] of Object.entries(o)) {
138
+ const a = e[i];
139
+ if (!Array.isArray(a)) continue;
140
+ const c = Math.min(r.length, a.length);
141
+ for (let l = 0; l < c; l++) {
142
+ if (!B(r[l])) continue;
143
+ const d = a[l];
144
+ if (typeof d != "string" || !xe(d)) continue;
145
+ const h = await ke(d);
146
+ h !== null && (a[l] = h);
147
147
  }
148
148
  }
149
149
  }
150
150
  }
151
- function ct(t) {
151
+ function mt(t) {
152
152
  const e = typeof t == "string" ? t.trim() : "";
153
153
  if (!e)
154
154
  return { ok: !1, reason: "empty" };
155
155
  let n;
156
156
  try {
157
157
  n = JSON.parse(e);
158
- } catch (r) {
159
- return { ok: !1, reason: "parse", error: r };
158
+ } catch (o) {
159
+ return { ok: !1, reason: "parse", error: o };
160
160
  }
161
161
  return !Array.isArray(n) || n.length === 0 || !n[0]?.value ? { ok: !1, reason: "shape" } : { ok: !0, metadata: n[0].value };
162
162
  }
163
- const J = "image", N = [
163
+ const J = "image", O = [
164
164
  "0x0000000000000000000000000000000000000000000000000000000000000020"
165
- ], Ue = Ve`
165
+ ], Re = nt`
166
166
  query GetSeeds($where: AttestationWhereInput!, $take: Int, $skip: Int) {
167
167
  itemSeeds: attestations(where: $where, orderBy: [{ timeCreated: desc }], take: $take, skip: $skip) {
168
168
  id
@@ -180,123 +180,123 @@ const J = "image", N = [
180
180
  isOffchain
181
181
  }
182
182
  }
183
- `, H = (t) => t.replace(/_([a-z])/g, (e, n) => n.toUpperCase()), lt = (t) => {
184
- const e = new Date(t * 1e3), n = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], s = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], r = n[e.getUTCDay()], a = s[e.getUTCMonth()], o = e.getUTCFullYear(), i = e.getUTCDate().toString().padStart(2, "0"), c = e.getUTCHours().toString().padStart(2, "0"), d = e.getUTCMinutes().toString().padStart(2, "0"), f = e.getUTCSeconds().toString().padStart(2, "0");
185
- return `${r}, ${i} ${a} ${o} ${c}:${d}:${f} GMT`;
186
- }, dt = (t) => t === "image" ? "images" : t === "post" ? "posts" : t.toLowerCase() + "s", ft = (t) => {
183
+ `, W = (t) => t.replace(/_([a-z])/g, (e, n) => n.toUpperCase()), yt = (t) => {
184
+ const e = new Date(t * 1e3), n = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], s = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], o = n[e.getUTCDay()], i = s[e.getUTCMonth()], r = e.getUTCFullYear(), a = e.getUTCDate().toString().padStart(2, "0"), c = e.getUTCHours().toString().padStart(2, "0"), l = e.getUTCMinutes().toString().padStart(2, "0"), d = e.getUTCSeconds().toString().padStart(2, "0");
185
+ return `${o}, ${a} ${i} ${r} ${c}:${l}:${d} GMT`;
186
+ }, wt = (t) => t === "image" ? "images" : t === "post" ? "posts" : t.toLowerCase() + "s", Ct = (t) => {
187
187
  const [e, n, s] = t.split("_");
188
188
  if (!e || !n) return null;
189
- const r = s === "ids";
190
- return { propertyName: e.endsWith("s") ? e : e + "s", modelName: n, isList: r };
191
- }, ne = (t, e, n, s) => {
192
- const { itemUrlBase: r, itemUrlPath: a, siteUrl: o } = s;
189
+ const o = s === "ids";
190
+ return { propertyName: e.endsWith("s") ? e : e + "s", modelName: n, isList: o };
191
+ }, oe = (t, e, n, s) => {
192
+ const { itemUrlBase: o, itemUrlPath: i, siteUrl: r } = s;
193
193
  !t.title && !t.Title ? (t.title = e, t.Title = e) : t.title && !t.Title ? t.Title = t.title : t.Title && !t.title && (t.title = t.Title);
194
- const i = t.storage_transaction_id && typeof t.storage_transaction_id == "string" && t.storage_transaction_id.trim() !== "" && t.storage_transaction_id !== "undefined" && t.storage_transaction_id !== e ? t.storage_transaction_id.trim() : null, c = t.storageTransactionId && typeof t.storageTransactionId == "string" && t.storageTransactionId.trim() !== "" && t.storageTransactionId !== "undefined" && t.storageTransactionId !== e ? t.storageTransactionId.trim() : null, d = i || c, f = dt(n), p = e && typeof e == "string" && e.trim() !== "" ? e : "unknown";
195
- let w;
196
- if (d && d !== e && d.length > 0)
194
+ const a = t.storage_transaction_id && typeof t.storage_transaction_id == "string" && t.storage_transaction_id.trim() !== "" && t.storage_transaction_id !== "undefined" && t.storage_transaction_id !== e ? t.storage_transaction_id.trim() : null, c = t.storageTransactionId && typeof t.storageTransactionId == "string" && t.storageTransactionId.trim() !== "" && t.storageTransactionId !== "undefined" && t.storageTransactionId !== e ? t.storageTransactionId.trim() : null, l = a || c, d = wt(n), h = e && typeof e == "string" && e.trim() !== "" ? e : "unknown";
195
+ let g;
196
+ if (l && l !== e && l.length > 0)
197
197
  try {
198
- w = j(d);
199
- } catch (m) {
200
- console.error("[feed] [setFeedItemDefaults] Error generating Arweave URL:", m), r != null ? w = `${r.replace(/\/$/, "")}/${(a ?? "attestation/view").replace(/^\//, "")}/${p}` : w = `${o.replace(/\/$/, "")}/${f}/${p}`;
198
+ g = j(l);
199
+ } catch (p) {
200
+ console.error("[feed] [setFeedItemDefaults] Error generating Arweave URL:", p), o != null ? g = `${o.replace(/\/$/, "")}/${(i ?? "attestation/view").replace(/^\//, "")}/${h}` : g = `${r.replace(/\/$/, "")}/${d}/${h}`;
201
201
  }
202
202
  else
203
- r != null ? w = `${r.replace(/\/$/, "")}/${(a ?? "attestation/view").replace(/^\//, "")}/${p}` : w = `${o.replace(/\/$/, "")}/${f}/${p}`;
204
- const h = t.link || t.Link;
205
- !h || h === "undefined" || typeof h == "string" && h.trim() === "" ? (t.link = w, t.Link = w) : ((!t.link || t.link === "undefined") && (t.link = h), (!t.Link || t.Link === "undefined") && (t.Link = h));
206
- const C = t.guid || t.Guid;
207
- if (!C || C === "undefined" || typeof C == "string" && C.trim() === "" ? (t.guid = t.link || w, t.Guid = t.guid) : ((!t.guid || t.guid === "undefined") && (t.guid = C), (!t.Guid || t.Guid === "undefined") && (t.Guid = C)), t.timeCreated && !t.pubDate && !t.PubDate) {
208
- const m = lt(t.timeCreated);
209
- t.pubDate = m, t.PubDate = m;
203
+ o != null ? g = `${o.replace(/\/$/, "")}/${(i ?? "attestation/view").replace(/^\//, "")}/${h}` : g = `${r.replace(/\/$/, "")}/${d}/${h}`;
204
+ const f = t.link || t.Link;
205
+ !f || f === "undefined" || typeof f == "string" && f.trim() === "" ? (t.link = g, t.Link = g) : ((!t.link || t.link === "undefined") && (t.link = f), (!t.Link || t.Link === "undefined") && (t.Link = f));
206
+ const y = t.guid || t.Guid;
207
+ if (!y || y === "undefined" || typeof y == "string" && y.trim() === "" ? (t.guid = t.link || g, t.Guid = t.guid) : ((!t.guid || t.guid === "undefined") && (t.guid = y), (!t.Guid || t.Guid === "undefined") && (t.Guid = y)), t.timeCreated && !t.pubDate && !t.PubDate) {
208
+ const p = yt(t.timeCreated);
209
+ t.pubDate = p, t.PubDate = p;
210
210
  } else t.pubDate && !t.PubDate ? t.PubDate = t.pubDate : t.PubDate && !t.pubDate && (t.pubDate = t.PubDate);
211
211
  !t.seedUid && !t.SeedUid ? (t.seedUid = e, t.SeedUid = e) : t.seedUid && !t.SeedUid ? t.SeedUid = t.seedUid : t.SeedUid && !t.seedUid && (t.seedUid = t.SeedUid), t.attester && !t.Attester ? t.Attester = t.attester : t.Attester && !t.attester && (t.attester = t.Attester);
212
- }, F = /* @__PURE__ */ new Map(), Y = /* @__PURE__ */ new Set(), ie = /* @__PURE__ */ new Map(), $ = /* @__PURE__ */ new Map(), X = /* @__PURE__ */ new Map(), be = /* @__PURE__ */ new Map();
213
- function ht() {
214
- F.clear(), Y.clear(), ie.clear(), $.clear(), X.clear(), be.clear();
212
+ }, M = /* @__PURE__ */ new Map(), Y = /* @__PURE__ */ new Set(), de = /* @__PURE__ */ new Map(), $ = /* @__PURE__ */ new Map(), V = /* @__PURE__ */ new Map(), Le = /* @__PURE__ */ new Map();
213
+ function St() {
214
+ M.clear(), Y.clear(), de.clear(), $.clear(), V.clear(), Le.clear();
215
215
  }
216
- const ut = async (t, e) => {
217
- const n = ct(t.decodedDataJson);
216
+ const Dt = async (t, e) => {
217
+ const n = mt(t.decodedDataJson);
218
218
  if (!n.ok) {
219
- const { id: m, refUID: y, schemaId: l } = t;
219
+ const { id: p, refUID: w, schemaId: u } = t;
220
220
  n.reason === "empty" ? console.warn(
221
221
  "[feed] [processItemProperty] empty decodedDataJson for property:",
222
- m,
223
- y,
224
- l
222
+ p,
223
+ w,
224
+ u
225
225
  ) : n.reason === "parse" ? console.warn(
226
226
  "[feed] [processItemProperty] failed to parse decodedDataJson for property:",
227
- m,
228
- y,
229
- l,
227
+ p,
228
+ w,
229
+ u,
230
230
  n.error
231
231
  ) : console.warn(
232
232
  "[feed] [processItemProperty] invalid decodedDataJson structure for property:",
233
- m,
234
- y,
235
- l
233
+ p,
234
+ w,
235
+ u
236
236
  );
237
237
  return;
238
238
  }
239
239
  const s = n.metadata;
240
- let r = s.name;
241
- if (!r)
240
+ let o = s.name;
241
+ if (!o)
242
242
  return;
243
- const a = t.schemaId;
244
- Je({
245
- text: r,
246
- schemaUid: a
243
+ const i = t.schemaId;
244
+ Qe({
245
+ text: o,
246
+ schemaUid: i
247
247
  });
248
- let o = !1, i = !1;
249
- const c = s.type, d = (c === "bytes32" || c === "bytes32[]") && r !== "storage_transaction_id" && r !== "storage_provider_transaction_id", f = !d && (r.endsWith("_id") || r.endsWith("_ids")) && r !== "storage_transaction_id" && r !== "storage_provider_transaction_id";
250
- if (d || f)
251
- if (o = !0, Array.isArray(s.value)) {
252
- if (i = !0, f) {
253
- const m = ft(r);
254
- m && (r = m.propertyName);
248
+ let r = !1, a = !1;
249
+ const c = s.type, l = (c === "bytes32" || c === "bytes32[]") && o !== "storage_transaction_id" && o !== "storage_provider_transaction_id", d = !l && (o.endsWith("_id") || o.endsWith("_ids")) && o !== "storage_transaction_id" && o !== "storage_provider_transaction_id";
250
+ if (l || d)
251
+ if (r = !0, Array.isArray(s.value)) {
252
+ if (a = !0, d) {
253
+ const p = Ct(o);
254
+ p && (o = p.propertyName);
255
255
  }
256
- s.value.forEach((m) => {
257
- N.includes(m) || Y.add(m);
256
+ s.value.forEach((p) => {
257
+ O.includes(p) || Y.add(p);
258
258
  });
259
- } else N.includes(s.value) || Y.add(s.value);
260
- let p = s.value;
261
- o && i && Array.isArray(p) ? p = p.map((m) => String(m)) : typeof p != "string" && (p = JSON.stringify(p)), o && !i && e.find((y) => y.id === s.value)?.schema?.schemaNames, o && i && e.filter(
262
- (y) => Array.isArray(s.value) && s.value.includes(y.id)
259
+ } else O.includes(s.value) || Y.add(s.value);
260
+ let h = s.value;
261
+ r && a && Array.isArray(h) ? h = h.map((p) => String(p)) : typeof h != "string" && (h = JSON.stringify(h)), r && !a && e.find((w) => w.id === s.value)?.schema?.schemaNames, r && a && e.filter(
262
+ (w) => Array.isArray(s.value) && s.value.includes(w.id)
263
263
  ).length > 0;
264
- const w = ie.get(t.refUID);
265
- if (!w)
264
+ const g = de.get(t.refUID);
265
+ if (!g)
266
266
  return;
267
- const h = $.get(w) || {};
268
- h[r] = p;
269
- const C = H(r);
270
- C !== r && (h[C] = p), $.set(w, h);
271
- }, he = async (t) => {
272
- const e = t.map((o) => o.id);
273
- for (let o = 0; o < t.length; o++) {
274
- const i = t[o];
275
- if (!i) continue;
276
- e.push(i.id);
277
- const c = i.schema?.schemaNames?.[0]?.name ?? "unknown";
278
- F.set(i.id, c), $.has(i.id) || $.set(i.id, {
279
- seedUid: i.id,
280
- timeCreated: i.timeCreated,
281
- attester: i.attester
267
+ const f = $.get(g) || {};
268
+ f[o] = h;
269
+ const y = W(o);
270
+ y !== o && (f[y] = h), $.set(g, f);
271
+ }, pe = async (t) => {
272
+ const e = t.map((r) => r.id);
273
+ for (let r = 0; r < t.length; r++) {
274
+ const a = t[r];
275
+ if (!a) continue;
276
+ e.push(a.id);
277
+ const c = a.schema?.schemaNames?.[0]?.name ?? "unknown";
278
+ M.set(a.id, c), $.has(a.id) || $.set(a.id, {
279
+ seedUid: a.id,
280
+ timeCreated: a.timeCreated,
281
+ attester: a.attester
282
282
  });
283
283
  }
284
- const n = await He({ seedUids: e });
285
- for (let o = 0; o < n.length; o++) {
286
- const i = n[o], c = i.refUID;
287
- ie.set(i.id, c);
288
- const d = X.get(c) || [];
289
- X.set(c, [...d, i]);
284
+ const n = await Ye({ seedUids: e });
285
+ for (let r = 0; r < n.length; r++) {
286
+ const a = n[r], c = a.refUID;
287
+ de.set(a.id, c);
288
+ const l = V.get(c) || [];
289
+ V.set(c, [...l, a]);
290
290
  }
291
291
  const s = [];
292
- for (const [o, i] of X.entries()) {
293
- const d = [...i].sort((f, p) => p.timeCreated - f.timeCreated)[0];
294
- d && (s.push(d.id), be.set(o, d.id));
295
- }
296
- const r = await ze({ versionUids: s }), a = Ge(r);
297
- for (let o = 0; o < a.length; o++)
298
- await ut(a[o], t);
299
- }, ve = /* @__PURE__ */ new Set([
292
+ for (const [r, a] of V.entries()) {
293
+ const l = [...a].sort((d, h) => h.timeCreated - d.timeCreated)[0];
294
+ l && (s.push(l.id), Le.set(r, l.id));
295
+ }
296
+ const o = await qe({ versionUids: s }), i = Ze(o);
297
+ for (let r = 0; r < i.length; r++)
298
+ await Dt(i[r], t);
299
+ }, Pe = /* @__PURE__ */ new Set([
300
300
  "seedUid",
301
301
  "SeedUid",
302
302
  "timeCreated",
@@ -307,69 +307,69 @@ const ut = async (t, e) => {
307
307
  "storageTransactionId",
308
308
  "storageProviderTransactionId"
309
309
  ]);
310
- function gt(t) {
310
+ function At(t) {
311
311
  const e = Array.from($.entries()).filter(
312
- ([n]) => F.get(n) === t
312
+ ([n]) => M.get(n) === t
313
313
  );
314
314
  for (const [, n] of e) {
315
315
  const s = Object.keys(n).filter(
316
- (r) => !r.startsWith("_") && !ve.has(r)
316
+ (o) => !o.startsWith("_") && !Pe.has(o)
317
317
  );
318
- for (const r of s) {
319
- let a = n[r];
320
- const o = Ie(a);
321
- if (o !== a && Array.isArray(o) && (n[r] = o, a = o), Array.isArray(a)) {
322
- const c = a;
318
+ for (const o of s) {
319
+ let i = n[o];
320
+ const r = be(i);
321
+ if (r !== i && Array.isArray(r) && (n[o] = r, i = r), Array.isArray(i)) {
322
+ const c = i;
323
323
  if (!c.some(
324
- (h) => typeof h == "string" && !N.includes(h) && $.has(h)
324
+ (f) => typeof f == "string" && !O.includes(f) && $.has(f)
325
325
  )) continue;
326
- const f = [], p = [];
327
- let w = !1;
328
- for (const h of c) {
329
- if (typeof h != "string" || N.includes(h)) {
330
- f.push(String(h)), p.push("unknown");
326
+ const d = [], h = [];
327
+ let g = !1;
328
+ for (const f of c) {
329
+ if (typeof f != "string" || O.includes(f)) {
330
+ d.push(String(f)), h.push("unknown");
331
331
  continue;
332
332
  }
333
- const C = F.get(h) ?? "unknown";
334
- if (C === J) {
335
- f.push(h), p.push(J);
333
+ const y = M.get(f) ?? "unknown";
334
+ if (y === J) {
335
+ d.push(f), h.push(J);
336
336
  continue;
337
337
  }
338
- const m = $.get(h), y = m?.storageTransactionId ?? m?.storage_transaction_id;
339
- if (y && typeof y == "string" && y.trim())
338
+ const p = $.get(f), w = p?.storageTransactionId ?? p?.storage_transaction_id;
339
+ if (w && typeof w == "string" && w.trim())
340
340
  try {
341
- f.push(j(y)), p.push(C), w = !0;
341
+ d.push(j(w)), h.push(y), g = !0;
342
342
  } catch {
343
- f.push(h), p.push(C);
343
+ d.push(f), h.push(y);
344
344
  }
345
345
  else
346
- f.push(h), p.push(C);
346
+ d.push(f), h.push(y);
347
347
  }
348
- if (w) {
349
- const h = oe(r);
350
- if (n[h] = f, rt(n, h, p), Ae(n, h), h !== r) {
351
- delete n[r];
352
- const C = H(r);
353
- C !== r && delete n[C];
348
+ if (g) {
349
+ const f = le(o);
350
+ if (n[f] = d, ft(n, f, h), Fe(n, f), f !== o) {
351
+ delete n[o];
352
+ const y = W(o);
353
+ y !== o && delete n[y];
354
354
  }
355
355
  }
356
- } else if (typeof a == "string") {
357
- if (N.includes(a) || !$.has(a)) continue;
358
- const c = $.get(a);
359
- if (F.get(a) === J)
356
+ } else if (typeof i == "string") {
357
+ if (O.includes(i) || !$.has(i)) continue;
358
+ const c = $.get(i);
359
+ if (M.get(i) === J)
360
360
  continue;
361
- const d = c?.storageTransactionId ?? c?.storage_transaction_id;
362
- if (d && typeof d == "string" && d.trim())
361
+ const l = c?.storageTransactionId ?? c?.storage_transaction_id;
362
+ if (l && typeof l == "string" && l.trim())
363
363
  try {
364
- const f = r.endsWith("_id") ? r.replace(/_id$/, "") : r;
365
- n[f] = j(d);
366
- const p = F.get(a) ?? "unknown";
367
- fe(n, f, p);
368
- const w = H(f);
369
- if (w !== f && fe(n, w, p), f !== r) {
370
- delete n[r];
371
- const h = H(r);
372
- h !== r && delete n[h];
364
+ const d = o.endsWith("_id") ? o.replace(/_id$/, "") : o;
365
+ n[d] = j(l);
366
+ const h = M.get(i) ?? "unknown";
367
+ ge(n, d, h);
368
+ const g = W(d);
369
+ if (g !== d && ge(n, g, h), d !== o) {
370
+ delete n[o];
371
+ const f = W(o);
372
+ f !== o && delete n[f];
373
373
  }
374
374
  } catch {
375
375
  }
@@ -377,88 +377,88 @@ function gt(t) {
377
377
  }
378
378
  }
379
379
  }
380
- function pt(t, e, n) {
380
+ function Tt(t, e, n) {
381
381
  if (!n) return;
382
382
  const s = Array.from($.entries()).filter(
383
- ([r]) => F.get(r) === t
383
+ ([o]) => M.get(o) === t
384
384
  );
385
- for (const [, r] of s) {
386
- const a = Object.keys(r).filter(
387
- (o) => !o.startsWith("_") && !ve.has(o)
385
+ for (const [, o] of s) {
386
+ const i = Object.keys(o).filter(
387
+ (r) => !r.startsWith("_") && !Pe.has(r)
388
388
  );
389
- for (const o of a) {
390
- let i = r[o];
391
- const c = Ie(i);
392
- c !== i && Array.isArray(c) && (r[o] = c, i = c);
393
- const d = Array.isArray(i), f = d ? i : [i], p = [];
394
- let w = !1;
395
- for (const h of f) {
396
- if (typeof h != "string" || N.includes(h)) {
397
- p.push(h);
389
+ for (const r of i) {
390
+ let a = o[r];
391
+ const c = be(a);
392
+ c !== a && Array.isArray(c) && (o[r] = c, a = c);
393
+ const l = Array.isArray(a), d = l ? a : [a], h = [];
394
+ let g = !1;
395
+ for (const f of d) {
396
+ if (typeof f != "string" || O.includes(f)) {
397
+ h.push(f);
398
398
  continue;
399
399
  }
400
- const C = $.get(h);
401
- if (!C) {
402
- p.push(h);
400
+ const y = $.get(f);
401
+ if (!y) {
402
+ h.push(f);
403
403
  continue;
404
404
  }
405
- const m = C?.storageTransactionId ?? C?.storage_transaction_id;
406
- if (F.get(h) === J) {
407
- const g = F.get(h) ?? "unknown", D = { ...C };
408
- ne(D, h, g, e), tt(D), p.push(D), w = !0;
405
+ const p = y?.storageTransactionId ?? y?.storage_transaction_id;
406
+ if (M.get(f) === J) {
407
+ const C = M.get(f) ?? "unknown", S = { ...y };
408
+ oe(S, f, C, e), lt(S), h.push(S), g = !0;
409
409
  continue;
410
410
  }
411
- if (m && typeof m == "string" && m.trim()) {
412
- p.push(h);
411
+ if (p && typeof p == "string" && p.trim()) {
412
+ h.push(f);
413
413
  continue;
414
414
  }
415
- const l = F.get(h) ?? "unknown", u = { ...C };
416
- ne(u, h, l, e), p.push(u), w = !0;
415
+ const u = M.get(f) ?? "unknown", m = { ...y };
416
+ oe(m, f, u, e), h.push(m), g = !0;
417
417
  }
418
- if (w) {
419
- const h = d ? oe(o) : o.endsWith("_id") ? o.replace(/_id$/, "") : o;
420
- if (r[h] = d ? p : p[0], Ae(r, h), h !== o) {
421
- delete r[o];
422
- const C = H(o);
423
- C !== o && delete r[C];
418
+ if (g) {
419
+ const f = l ? le(r) : r.endsWith("_id") ? r.replace(/_id$/, "") : r;
420
+ if (o[f] = l ? h : h[0], Fe(o, f), f !== r) {
421
+ delete o[r];
422
+ const y = W(r);
423
+ y !== r && delete o[y];
424
424
  }
425
425
  }
426
426
  }
427
427
  }
428
428
  }
429
- async function ke(t, e, n) {
430
- ht(), await he(e);
431
- const s = Te.getEasClient(), r = Array.from(Y), { itemSeeds: a } = await s.request(Ue, {
432
- where: Se({
429
+ async function Ne(t, e, n) {
430
+ St(), await pe(e);
431
+ const s = $e.getEasClient(), o = Array.from(Y), { itemSeeds: i } = await s.request(Re, {
432
+ where: Ie({
433
433
  id: {
434
- in: r
434
+ in: o
435
435
  }
436
436
  }),
437
- take: r.length || 1,
437
+ take: o.length || 1,
438
438
  skip: 0
439
439
  });
440
- await he(a ?? []), gt(t);
441
- const o = G(), i = {
442
- itemUrlBase: o.itemUrlBase,
443
- itemUrlPath: o.itemUrlPath,
444
- siteUrl: o.siteUrl
440
+ await pe(i ?? []), At(t);
441
+ const r = G(), a = {
442
+ itemUrlBase: r.itemUrlBase,
443
+ itemUrlPath: r.itemUrlPath,
444
+ siteUrl: r.siteUrl
445
445
  };
446
- pt(
446
+ Tt(
447
447
  t,
448
- i,
448
+ a,
449
449
  n
450
450
  );
451
- const c = Array.from($.entries()).filter(([d]) => F.get(d) === t).map(([, d]) => {
452
- const f = d.seedUid || d.SeedUid;
453
- return ne(d, f, t, i), d;
451
+ const c = Array.from($.entries()).filter(([l]) => M.get(l) === t).map(([, l]) => {
452
+ const d = l.seedUid || l.SeedUid;
453
+ return oe(l, d, t, a), l;
454
454
  });
455
- return await it(c), c;
455
+ return await pt(c), c;
456
456
  }
457
- const te = async (t, e) => {
458
- const n = G(), s = e?.limit ?? 100, r = e?.skip ?? 0, a = await We(t, s, r);
459
- return ke(t, a, n.expandRelations !== !1);
460
- }, mt = async (t, e, n) => {
461
- const s = G(), r = new Date(e, n - 1, 1), a = new Date(e, n, 0, 23, 59, 59), o = Math.floor(r.getTime() / 1e3), i = Math.floor(a.getTime() / 1e3) + 1, c = Se({
457
+ const ne = async (t, e) => {
458
+ const n = G(), s = e?.limit ?? 100, o = e?.skip ?? 0, i = await Ke(t, s, o);
459
+ return await Ne(t, i, n.expandRelations !== !1);
460
+ }, Et = async (t, e, n) => {
461
+ const s = G(), o = new Date(e, n - 1, 1), i = new Date(e, n, 0, 23, 59, 59), r = Math.floor(o.getTime() / 1e3), a = Math.floor(i.getTime() / 1e3) + 1, c = Ie({
462
462
  AND: [
463
463
  {
464
464
  schema: {
@@ -472,24 +472,24 @@ const te = async (t, e) => {
472
472
  }
473
473
  },
474
474
  {
475
- timeCreated: { gte: o, lt: i }
475
+ timeCreated: { gte: r, lt: a }
476
476
  }
477
477
  ]
478
- }), d = Te.getEasClient(), { itemSeeds: f } = await d.request(Ue, {
478
+ }), l = $e.getEasClient(), { itemSeeds: d } = await l.request(Re, {
479
479
  where: c,
480
480
  take: 1e3,
481
481
  skip: 0
482
482
  });
483
- return ke(t, f ?? [], s.expandRelations !== !1);
483
+ return Ne(t, d ?? [], s.expandRelations !== !1);
484
484
  };
485
- function yt(t) {
485
+ function _t(t) {
486
486
  try {
487
487
  return JSON.parse(JSON.stringify(t));
488
488
  } catch {
489
489
  return { ...t };
490
490
  }
491
491
  }
492
- const wt = new Ye({
492
+ const It = new rt({
493
493
  customFields: {
494
494
  item: [
495
495
  "featureImage",
@@ -500,20 +500,25 @@ const wt = new Ye({
500
500
  ]
501
501
  }
502
502
  });
503
- async function Qt(t) {
504
- const e = await wt.parseString(t);
503
+ async function yn(t) {
504
+ const e = await It.parseString(t);
505
505
  return {
506
506
  title: e.title,
507
507
  link: e.link,
508
508
  description: e.description,
509
- items: (e.items ?? []).map(yt)
509
+ items: (e.items ?? []).map(_t)
510
510
  };
511
511
  }
512
- const z = "http://purl.org/dc/elements/1.1/", K = "http://purl.org/rss/1.0/modules/content/", x = "http://search.yahoo.com/mrss/", Ct = /* @__PURE__ */ new Set(["Title", "Link", "Guid", "PubDate", "SeedUid"]);
513
- function Dt(t, e) {
514
- return Ct.has(t) ? t.charAt(0).toLowerCase() + t.slice(1) in e : !1;
512
+ const H = "http://purl.org/dc/elements/1.1/", q = "http://purl.org/rss/1.0/modules/content/", R = "http://search.yahoo.com/mrss/", $t = {
513
+ publication: {
514
+ prefix: "publication",
515
+ uri: "https://seedprotocol.io/ns/publication/1.0"
516
+ }
517
+ }, Mt = "https://seedprotocol.io/ns/relations", me = /* @__PURE__ */ new Set(["xml", "xmlns", "dc", "media", "content", "atom", "fh"]), Ft = /* @__PURE__ */ new Set(["Title", "Link", "Guid", "PubDate", "SeedUid"]);
518
+ function bt(t, e) {
519
+ return Ft.has(t) ? t.charAt(0).toLowerCase() + t.slice(1) in e : !1;
515
520
  }
516
- const ue = [
521
+ const se = [
517
522
  "title",
518
523
  "link",
519
524
  "description",
@@ -537,7 +542,7 @@ const ue = [
537
542
  "media:category",
538
543
  "media:group"
539
544
  ];
540
- function re(t) {
545
+ function ae(t) {
541
546
  if (t instanceof Date)
542
547
  return t.toUTCString();
543
548
  if (typeof t == "string") {
@@ -546,261 +551,334 @@ function re(t) {
546
551
  }
547
552
  return String(t);
548
553
  }
549
- function St(t) {
554
+ function Ut(t) {
550
555
  return /[<>&]|]]>/.test(t);
551
556
  }
552
- function _(t, e) {
557
+ function I(t, e) {
553
558
  const n = String(e);
554
559
  if (n !== "")
555
- if (St(n))
560
+ if (Ut(n))
556
561
  if (n.includes("]]>")) {
557
562
  const s = n.split("]]>");
558
- for (let r = 0; r < s.length; r++)
559
- t.dat(s[r]), r < s.length - 1 && t.txt("]]>");
563
+ for (let o = 0; o < s.length; o++)
564
+ t.dat(s[o]), o < s.length - 1 && t.txt("]]>");
560
565
  } else
561
566
  t.dat(n);
562
567
  else
563
568
  t.txt(n);
564
569
  }
565
- function P(t) {
570
+ function b(t) {
566
571
  return t !== null && typeof t == "object" && !Array.isArray(t) && !(t instanceof Date);
567
572
  }
568
- const Tt = 4;
569
- function R(t, e, n, s, r = 0) {
570
- const a = t.ele(n);
571
- for (const [o, i] of Object.entries(e)) {
572
- if (i == null || o.startsWith("_") || o === "items") continue;
573
- if (r >= Tt) {
574
- const d = a.ele(o);
575
- _(d, typeof i == "object" ? JSON.stringify(i) : String(i));
573
+ const vt = 4, xt = /* @__PURE__ */ new Set([
574
+ ...se,
575
+ "guid",
576
+ "source",
577
+ "dc",
578
+ "content",
579
+ "content:encoded",
580
+ "items"
581
+ ]);
582
+ function kt(t) {
583
+ return t.endsWith("s") && t.length > 1 ? t.slice(0, -1) : t;
584
+ }
585
+ function Rt(t) {
586
+ return t.trim().replace(/[^A-Za-z0-9_.-]+/g, "_").replace(/^[^A-Za-z_]+/, "").replace(/^$/, "rel").toLowerCase();
587
+ }
588
+ function Lt(t, e) {
589
+ if (!e.has(t) && !me.has(t))
590
+ return e.add(t), t;
591
+ let n = 2;
592
+ for (; ; ) {
593
+ const s = `${t}${n}`;
594
+ if (!e.has(s) && !me.has(s))
595
+ return e.add(s), s;
596
+ n += 1;
597
+ }
598
+ }
599
+ function ye(t) {
600
+ return Array.isArray(t) && t.length > 0 && t.every((e) => b(e));
601
+ }
602
+ function Pt(t) {
603
+ const e = { ...$t }, n = new Set(
604
+ Object.values(e).map((i) => i.prefix)
605
+ ), s = /* @__PURE__ */ new Set();
606
+ for (const i of t)
607
+ for (const [r, a] of Object.entries(i)) {
608
+ const c = r === "author" && b(a) || r === "authors" && ye(a);
609
+ r.startsWith("_") || xt.has(r) && !c || (b(a) || ye(a)) && s.add(kt(r));
610
+ }
611
+ const o = [...s].sort();
612
+ for (const i of o) {
613
+ if (e[i]) continue;
614
+ const r = Rt(i), a = Lt(r, n);
615
+ e[i] = {
616
+ prefix: a,
617
+ uri: `${Mt}/${i}/1.0`
618
+ };
619
+ }
620
+ return e;
621
+ }
622
+ function X(t, e) {
623
+ if (t in e) return e[t];
624
+ if (t.endsWith("s") && t.length > 1) {
625
+ const n = t.slice(0, -1);
626
+ if (n in e) return e[n];
627
+ }
628
+ }
629
+ function we(t, e) {
630
+ return e ? `${e.prefix}:${t}` : t;
631
+ }
632
+ function P(t, e, n, s, o = 0, i) {
633
+ const r = t.ele(n);
634
+ for (const [a, c] of Object.entries(e)) {
635
+ if (c == null || a.startsWith("_") || a === "items") continue;
636
+ const l = we(a, i);
637
+ if (o >= vt) {
638
+ const h = r.ele(l);
639
+ I(h, typeof c == "object" ? JSON.stringify(c) : String(c));
576
640
  continue;
577
641
  }
578
- if (Array.isArray(i)) {
579
- const d = o.endsWith("s") && o.length > 1 ? o.slice(0, -1) : o;
580
- for (const f of i)
642
+ if (Array.isArray(c)) {
643
+ const h = a.endsWith("s") && a.length > 1 ? a.slice(0, -1) : a, g = we(h, i);
644
+ for (const f of c)
581
645
  if (f != null)
582
- if (P(f))
583
- R(a, f, d, !1, r + 1);
646
+ if (b(f))
647
+ P(r, f, g, !1, o + 1, i);
584
648
  else {
585
- const p = a.ele(d);
586
- _(p, String(f));
649
+ const y = r.ele(g);
650
+ I(y, String(f));
587
651
  }
588
652
  continue;
589
653
  }
590
- if (P(i)) {
591
- R(a, i, o, !1, r + 1);
654
+ if (b(c)) {
655
+ P(
656
+ r,
657
+ c,
658
+ l,
659
+ !1,
660
+ o + 1,
661
+ i
662
+ );
592
663
  continue;
593
664
  }
594
- const c = a.ele(o);
595
- _(c, String(i));
665
+ const d = r.ele(l);
666
+ I(d, String(c));
596
667
  }
597
668
  if (s) {
598
- const o = e.name ?? e.seedUid;
599
- o && t.ele(z, "creator").txt(String(o));
669
+ const a = e.name ?? e.seedUid;
670
+ a && t.ele(H, "creator").txt(String(a));
600
671
  }
601
672
  }
602
- function ge(t, e, n, s) {
673
+ function Ce(t, e, n, s, o) {
603
674
  if (n == null || e.startsWith("_") || e === "items") return;
604
675
  if (e === "guid") {
605
- const a = n, o = a?.value ?? String(n);
606
- if (!o) return;
607
- const i = {};
608
- typeof a?.isPermaLink == "boolean" && (i.isPermaLink = a.isPermaLink ? "true" : "false");
609
- const c = t.ele("guid", i);
610
- _(c, o);
676
+ const r = n, a = r?.value ?? String(n);
677
+ if (!a) return;
678
+ const c = {};
679
+ typeof r?.isPermaLink == "boolean" && (c.isPermaLink = r.isPermaLink ? "true" : "false");
680
+ const l = t.ele("guid", c);
681
+ I(l, a);
611
682
  return;
612
683
  }
613
684
  if (e === "source" && n !== null && typeof n == "object") {
614
- const a = n, o = a.title ?? String(n);
615
- if (!o) return;
616
- const i = a.url ? { url: a.url } : {};
617
- t.ele("source", i).txt(o);
685
+ const r = n, a = r.title ?? String(n);
686
+ if (!a) return;
687
+ const c = r.url ? { url: r.url } : {};
688
+ t.ele("source", c).txt(a);
618
689
  return;
619
690
  }
620
691
  if (e === "enclosures" && Array.isArray(n)) {
621
- for (const a of n)
622
- if (a && typeof a == "object" && "url" in a) {
623
- const o = {
624
- url: String(a.url),
625
- type: String(a.type ?? "application/octet-stream")
692
+ for (const r of n)
693
+ if (r && typeof r == "object" && "url" in r) {
694
+ const a = {
695
+ url: String(r.url),
696
+ type: String(r.type ?? "application/octet-stream")
626
697
  };
627
- a.length != null && (o.length = String(a.length)), t.ele("enclosure", o);
698
+ r.length != null && (a.length = String(r.length)), t.ele("enclosure", a);
628
699
  }
629
700
  return;
630
701
  }
631
702
  if (e === "dc" && n !== null && typeof n == "object") {
632
- const a = n;
633
- for (const [o, i] of Object.entries(a))
634
- if (i != null)
635
- if (Array.isArray(i)) {
636
- for (const c of i)
637
- if (c != null) {
638
- const d = t.ele(z, o);
639
- c instanceof Date ? d.txt(c.toISOString()) : _(d, String(c));
703
+ const r = n;
704
+ for (const [a, c] of Object.entries(r))
705
+ if (c != null)
706
+ if (Array.isArray(c)) {
707
+ for (const l of c)
708
+ if (l != null) {
709
+ const d = t.ele(H, a);
710
+ l instanceof Date ? d.txt(l.toISOString()) : I(d, String(l));
640
711
  }
641
712
  } else {
642
- const c = t.ele(z, o);
643
- i instanceof Date ? c.txt(i.toISOString()) : _(c, String(i));
713
+ const l = t.ele(H, a);
714
+ c instanceof Date ? l.txt(c.toISOString()) : I(l, String(c));
644
715
  }
645
716
  return;
646
717
  }
647
718
  if (e === "content:encoded") {
648
- const a = t.ele(K, "encoded");
649
- _(a, String(n));
719
+ const r = t.ele(q, "encoded");
720
+ I(r, String(n));
650
721
  return;
651
722
  }
652
723
  if (e === "content" && typeof n == "string" && !("content:encoded" in s)) {
653
- const a = t.ele(K, "encoded");
654
- _(a, String(n));
724
+ const r = t.ele(q, "encoded");
725
+ I(r, String(n));
655
726
  return;
656
727
  }
657
728
  if (e === "content") return;
729
+ if (e === "media:group" && Array.isArray(n)) {
730
+ for (const r of n)
731
+ if (r && typeof r == "object") {
732
+ const a = t.ele(R, "group");
733
+ for (const [c, l] of Object.entries(r))
734
+ if (l != null && c.startsWith("media:")) {
735
+ const d = c.slice(6);
736
+ if (Array.isArray(l)) {
737
+ for (const h of l)
738
+ if (h && typeof h == "object") {
739
+ const g = a.ele(R, d);
740
+ for (const [f, y] of Object.entries(h))
741
+ y != null && (f === "url" || f === "value" ? I(g, String(y)) : g.att(f, String(y)));
742
+ }
743
+ } else typeof l == "string" && I(a.ele(R, d), l);
744
+ }
745
+ }
746
+ return;
747
+ }
658
748
  if (e.startsWith("media:") && Array.isArray(n)) {
659
- const a = e.slice(6);
660
- for (const o of n) {
661
- if (o === null || typeof o != "object") continue;
662
- const i = {};
663
- let c = null;
664
- for (const [f, p] of Object.entries(o))
665
- p != null && (f === "value" ? c = String(p) : i[f] = String(p));
666
- const d = t.ele(x, a, i);
667
- c !== null && _(d, c);
749
+ const r = e.slice(6);
750
+ for (const a of n) {
751
+ if (a === null || typeof a != "object") continue;
752
+ const c = {};
753
+ let l = null;
754
+ for (const [h, g] of Object.entries(a))
755
+ g != null && (h === "value" ? l = String(g) : c[h] = String(g));
756
+ const d = t.ele(R, r, c);
757
+ l !== null && I(d, l);
668
758
  }
669
759
  return;
670
760
  }
671
761
  if (e.startsWith("media:") && typeof n == "string") {
672
- const a = e.slice(6), o = t.ele(x, a);
673
- _(o, n);
674
- return;
675
- }
676
- if (e === "media:group" && Array.isArray(n)) {
677
- for (const a of n)
678
- if (a && typeof a == "object") {
679
- const o = t.ele(x, "group");
680
- for (const [i, c] of Object.entries(a))
681
- if (c != null && i.startsWith("media:")) {
682
- const d = i.slice(6);
683
- if (Array.isArray(c)) {
684
- for (const f of c)
685
- if (f && typeof f == "object") {
686
- const p = o.ele(x, d);
687
- for (const [w, h] of Object.entries(f))
688
- h != null && (w === "url" || w === "value" ? _(p, String(h)) : p.att(w, String(h)));
689
- }
690
- } else typeof c == "string" && _(o.ele(x, d), c);
691
- }
692
- }
762
+ const r = e.slice(6), a = t.ele(R, r);
763
+ I(a, n);
693
764
  return;
694
765
  }
695
766
  if (n instanceof Date) {
696
- t.ele(e).txt(re(n));
767
+ t.ele(e).txt(ae(n));
697
768
  return;
698
769
  }
699
- if (e === "author" && P(n)) {
700
- R(t, n, "author", !0);
770
+ if (e === "author" && b(n)) {
771
+ const r = X(e, o);
772
+ P(t, n, "author", !0, 0, r);
701
773
  return;
702
774
  }
703
775
  if (e === "authors" && Array.isArray(n)) {
776
+ const r = X(e, o);
704
777
  for (const a of n)
705
- if (a && P(a))
706
- R(t, a, "author", !0);
778
+ if (a && b(a))
779
+ P(t, a, "author", !0, 0, r);
707
780
  else {
708
- const o = typeof a == "string" ? a : a && typeof a == "object" && "name" in a ? `${a.email ?? ""} (${a.name ?? ""})`.trim() || a.name : String(a);
709
- o && t.ele("author").txt(o);
781
+ const c = typeof a == "string" ? a : a && typeof a == "object" && "name" in a ? `${a.email ?? ""} (${a.name ?? ""})`.trim() || a.name : String(a);
782
+ c && t.ele("author").txt(c);
710
783
  }
711
784
  return;
712
785
  }
713
786
  if (e === "categories" && Array.isArray(n)) {
714
- for (const a of n) {
715
- const o = a && typeof a == "object" && "name" in a ? a.name : String(a);
716
- if (o) {
717
- const i = a && typeof a == "object" && "domain" in a && a.domain ? { domain: a.domain } : {};
718
- t.ele("category", i).txt(o);
787
+ for (const r of n) {
788
+ const a = r && typeof r == "object" && "name" in r ? r.name : String(r);
789
+ if (a) {
790
+ const c = r && typeof r == "object" && "domain" in r && r.domain ? { domain: r.domain } : {};
791
+ t.ele("category", c).txt(a);
719
792
  }
720
793
  }
721
794
  return;
722
795
  }
723
- if (Array.isArray(n) && n.length > 0 && n.every((a) => P(a))) {
724
- const a = e.endsWith("s") ? e.slice(0, -1) : e;
725
- for (const o of n)
726
- o && R(t, o, a, !1);
796
+ if (Array.isArray(n) && n.length > 0 && n.every((r) => b(r))) {
797
+ const r = e.endsWith("s") ? e.slice(0, -1) : e, a = X(e, o);
798
+ for (const c of n)
799
+ c && P(t, c, r, !1, 0, a);
727
800
  return;
728
801
  }
729
- if (Array.isArray(n) && n.every((a) => typeof a == "string")) {
730
- const a = e.endsWith("s") ? e.slice(0, -1) : e;
731
- for (const o of n)
732
- if (o) {
733
- const i = t.ele(a);
734
- _(i, o);
802
+ if (Array.isArray(n) && n.every((r) => typeof r == "string")) {
803
+ const r = e.endsWith("s") ? e.slice(0, -1) : e;
804
+ for (const a of n)
805
+ if (a) {
806
+ const c = t.ele(r);
807
+ I(c, a);
735
808
  }
736
809
  return;
737
810
  }
738
- if (P(n)) {
739
- R(t, n, e, !1);
811
+ if (b(n)) {
812
+ const r = X(e, o);
813
+ P(t, n, e, !1, 0, r);
740
814
  return;
741
815
  }
742
- const r = t.ele(e);
743
- _(r, String(n));
816
+ const i = t.ele(e);
817
+ I(i, String(n));
744
818
  }
745
- const pe = "http://www.w3.org/2005/Atom", me = "http://purl.org/syndication/history/1.0";
746
- function Et(t) {
747
- const e = Ze({ version: "1.0", encoding: "UTF-8" }), n = {
748
- "xmlns:dc": z,
749
- "xmlns:content": K,
750
- "xmlns:media": x,
751
- "xmlns:atom": pe
819
+ const Se = "http://www.w3.org/2005/Atom", De = "http://purl.org/syndication/history/1.0";
820
+ function Nt(t) {
821
+ const e = at({ version: "1.0", encoding: "UTF-8" }), n = Pt(t.items), s = Object.values(n).reduce(
822
+ (c, l) => (c[`xmlns:${l.prefix}`] = l.uri, c),
823
+ {}
824
+ ), o = {
825
+ "xmlns:dc": H,
826
+ "xmlns:content": q,
827
+ "xmlns:media": R,
828
+ "xmlns:atom": Se,
829
+ ...s
752
830
  };
753
- t.isArchive && (n["xmlns:fh"] = me);
754
- const r = e.ele("rss", { version: "2.0", ...n }).ele("channel", {
755
- "xmlns:dc": z,
756
- "xmlns:content": K,
757
- "xmlns:media": x
831
+ t.isArchive && (o["xmlns:fh"] = De);
832
+ const r = e.ele("rss", { version: "2.0", ...o }).ele("channel", {
833
+ "xmlns:dc": H,
834
+ "xmlns:content": q,
835
+ "xmlns:media": R
758
836
  });
759
- if (r.ele("title").txt(t.title), t.link && r.ele("link").txt(t.link), r.ele("description").txt(t.description), t.language && r.ele("language").txt(t.language), t.copyright && r.ele("copyright").txt(t.copyright), t.webMaster && r.ele("webMaster").txt(t.webMaster), t.pubDate && r.ele("pubDate").txt(re(t.pubDate)), t.lastBuildDate && r.ele("lastBuildDate").txt(re(t.lastBuildDate)), t.links?.length)
760
- for (const o of t.links) {
761
- const i = { rel: o.rel, href: o.href };
762
- o.type && (i.type = o.type), r.ele(pe, "link", i);
837
+ if (r.ele("title").txt(t.title), t.link && r.ele("link").txt(t.link), r.ele("description").txt(t.description), t.language && r.ele("language").txt(t.language), t.copyright && r.ele("copyright").txt(t.copyright), t.webMaster && r.ele("webMaster").txt(t.webMaster), t.pubDate && r.ele("pubDate").txt(ae(t.pubDate)), t.lastBuildDate && r.ele("lastBuildDate").txt(ae(t.lastBuildDate)), t.links?.length)
838
+ for (const c of t.links) {
839
+ const l = { rel: c.rel, href: c.href };
840
+ c.type && (l.type = c.type), r.ele(Se, "link", l);
763
841
  }
764
- t.isArchive && r.ele(me, "archive");
765
- const a = new Set(ue);
766
- for (const o of t.items) {
767
- const i = r.ele("item"), c = /* @__PURE__ */ new Set();
768
- for (const f of ue)
769
- f in o && (ge(i, f, o[f], o), c.add(f));
770
- const d = Object.keys(o).filter(
771
- (f) => !c.has(f) && !a.has(f) && !f.startsWith("_") && !Dt(f, o)
842
+ t.isArchive && r.ele(De, "archive");
843
+ const a = new Set(se);
844
+ for (const c of t.items) {
845
+ const l = r.ele("item"), d = /* @__PURE__ */ new Set();
846
+ for (const g of se)
847
+ g in c && (Ce(l, g, c[g], c, n), d.add(g));
848
+ const h = Object.keys(c).filter(
849
+ (g) => !d.has(g) && !a.has(g) && !g.startsWith("_") && !bt(g, c)
772
850
  ).sort();
773
- for (const f of d)
774
- ge(i, f, o[f], o);
851
+ for (const g of h)
852
+ Ce(l, g, c[g], c, n);
775
853
  }
776
854
  return e.end({ prettyPrint: !0 });
777
855
  }
778
- function ae(t, e, n) {
856
+ function ie(t, e, n) {
779
857
  return n?.archive ? `${t}:${e}:archive-${n.archive.year}-${n.archive.month}` : n?.page != null && n.page > 1 ? `${t}:${e}:page-${n.page}` : `${t}:${e}`;
780
858
  }
781
- function xe(t) {
782
- return `"${Qe("md5").update(t).digest("hex").substring(0, 16)}"`;
859
+ function Oe(t) {
860
+ return `"${it("md5").update(t).digest("hex").substring(0, 16)}"`;
783
861
  }
784
- function At(t, e, n, s) {
785
- const r = `${t}-${e}-${n}-${s}`;
786
- return xe(r);
862
+ function Ot(t, e, n, s) {
863
+ const o = `${t}-${e}-${n}-${s}`;
864
+ return Oe(o);
787
865
  }
788
- function It(t, e, n, s) {
789
- const r = `${t}-${e}-${n}-${s}`;
790
- return xe(r);
866
+ function jt(t, e, n, s) {
867
+ const o = `${t}-${e}-${n}-${s}`;
868
+ return Oe(o);
791
869
  }
792
- function _t(t, e) {
870
+ function Bt(t, e) {
793
871
  const n = (s) => s.replace(/^"|"$/g, "");
794
872
  return n(t) === n(e);
795
873
  }
796
- function $t(t) {
874
+ function zt(t) {
797
875
  return t ? t.split(",").map((e) => e.trim()).filter((e) => e.length > 0) : [];
798
876
  }
799
- function Le(t, e) {
800
- const n = $t(t);
801
- return n.length === 0 ? !1 : n.includes("*") ? !0 : n.some((s) => _t(s, e));
877
+ function je(t, e) {
878
+ const n = zt(t);
879
+ return n.length === 0 ? !1 : n.includes("*") ? !0 : n.some((s) => Bt(s, e));
802
880
  }
803
- class Mt {
881
+ class Wt {
804
882
  feedDataCache = /* @__PURE__ */ new Map();
805
883
  feedContentCache = /* @__PURE__ */ new Map();
806
884
  imageMetadataCache = /* @__PURE__ */ new Map();
@@ -821,41 +899,41 @@ class Mt {
821
899
  */
822
900
  setFeedData(e, n) {
823
901
  const s = Math.floor(Date.now() / 1e3);
824
- let r = 0, a = "";
902
+ let o = 0, i = "";
825
903
  for (const c of n) {
826
- const d = c.timeCreated;
827
- d && d > r && (r = d, a = c.id || c.seedUid || c.SeedUid || "");
904
+ const l = c.timeCreated;
905
+ l && l > o && (o = l, i = c.id || c.seedUid || c.SeedUid || "");
828
906
  }
829
- r === 0 && (r = s);
830
- const o = At(e, "data", r, n.length), i = {
907
+ o === 0 && (o = s);
908
+ const r = Ot(e, "data", o, n.length), a = {
831
909
  items: [...n],
832
910
  // Create a copy
833
- lastProcessedTimestamp: r,
834
- lastProcessedItemId: a,
911
+ lastProcessedTimestamp: o,
912
+ lastProcessedItemId: i,
835
913
  lastUpdated: s,
836
- etag: o
914
+ etag: r
837
915
  };
838
- this.feedDataCache.set(e, i);
916
+ this.feedDataCache.set(e, a);
839
917
  }
840
918
  /**
841
919
  * Get cached feed content for a schema and format
842
920
  */
843
921
  getFeedContent(e, n, s) {
844
- const r = ae(e, n, s), a = this.feedContentCache.get(r);
845
- return a ? Math.floor(Date.now() / 1e3) > a.expiresAt ? (this.feedContentCache.delete(r), null) : a : null;
922
+ const o = ie(e, n, s), i = this.feedContentCache.get(o);
923
+ return i ? Math.floor(Date.now() / 1e3) > i.expiresAt ? (this.feedContentCache.delete(o), null) : i : null;
846
924
  }
847
925
  /**
848
926
  * Set cached feed content for a schema and format
849
927
  */
850
- setFeedContent(e, n, s, r, a, o) {
851
- const i = ae(e, n, a), c = Math.floor(Date.now() / 1e3), d = o ?? this.config.ttl, f = c + d, p = It(e, n, c, s.length), w = {
928
+ setFeedContent(e, n, s, o, i, r) {
929
+ const a = ie(e, n, i), c = Math.floor(Date.now() / 1e3), l = r ?? this.config.ttl, d = c + l, h = jt(e, n, c, s.length), g = {
852
930
  content: s,
853
- contentType: r,
854
- etag: p,
931
+ contentType: o,
932
+ etag: h,
855
933
  lastModified: c,
856
- expiresAt: f
934
+ expiresAt: d
857
935
  };
858
- this.feedContentCache.set(i, w);
936
+ this.feedContentCache.set(a, g);
859
937
  }
860
938
  /**
861
939
  * Clear feed data cache for a schema
@@ -883,12 +961,12 @@ class Mt {
883
961
  * Set cached image metadata for a transaction ID
884
962
  */
885
963
  setImageMetadata(e, n) {
886
- const s = Math.floor(Date.now() / 1e3), r = this.config.imageMetadata?.ttl || 604800, a = s + r, o = {
964
+ const s = Math.floor(Date.now() / 1e3), o = this.config.imageMetadata?.ttl || 604800, i = s + o, r = {
887
965
  metadata: n,
888
966
  cachedAt: s,
889
- expiresAt: a
967
+ expiresAt: i
890
968
  };
891
- this.imageMetadataCache.set(e, o);
969
+ this.imageMetadataCache.set(e, r);
892
970
  }
893
971
  /**
894
972
  * Clear all caches
@@ -903,14 +981,14 @@ class Mt {
903
981
  async withRefreshLock(e, n) {
904
982
  const s = this.refreshLocks.get(e);
905
983
  s && (await s, this.getFeedData(e));
906
- const r = (async () => {
984
+ const o = (async () => {
907
985
  try {
908
986
  return await n();
909
987
  } finally {
910
988
  this.refreshLocks.delete(e);
911
989
  }
912
990
  })();
913
- return this.refreshLocks.set(e, r), r;
991
+ return this.refreshLocks.set(e, o), o;
914
992
  }
915
993
  /**
916
994
  * Update configuration
@@ -930,7 +1008,7 @@ class Mt {
930
1008
  };
931
1009
  }
932
1010
  }
933
- class Ft {
1011
+ class Ht {
934
1012
  cacheDir;
935
1013
  config;
936
1014
  constructor(e) {
@@ -943,7 +1021,7 @@ class Ft {
943
1021
  */
944
1022
  async ensureCacheDir() {
945
1023
  try {
946
- await I.mkdir(this.cacheDir, { recursive: !0 });
1024
+ await E.mkdir(this.cacheDir, { recursive: !0 });
947
1025
  } catch (e) {
948
1026
  if (e.code !== "EEXIST")
949
1027
  throw e;
@@ -953,29 +1031,29 @@ class Ft {
953
1031
  * Get file path for feed data
954
1032
  */
955
1033
  getFeedDataPath(e) {
956
- return U(this.cacheDir, `${e}.json`);
1034
+ return F(this.cacheDir, `${e}.json`);
957
1035
  }
958
1036
  /**
959
1037
  * Get file path for feed content
960
1038
  */
961
1039
  getFeedContentPath(e, n, s) {
962
- const a = ae(e, n, s).replace(/:/g, "-");
963
- return U(this.cacheDir, `${a}.json`);
1040
+ const i = ie(e, n, s).replace(/:/g, "-");
1041
+ return F(this.cacheDir, `${i}.json`);
964
1042
  }
965
1043
  /**
966
1044
  * Get file path for image metadata
967
1045
  */
968
1046
  getImageMetadataPath(e) {
969
- const n = U(this.cacheDir, "image-metadata");
970
- return U(n, `${e}.json`);
1047
+ const n = F(this.cacheDir, "image-metadata");
1048
+ return F(n, `${e}.json`);
971
1049
  }
972
1050
  /**
973
1051
  * Ensure image metadata directory exists
974
1052
  */
975
1053
  async ensureImageMetadataDir() {
976
1054
  try {
977
- const e = U(this.cacheDir, "image-metadata");
978
- await I.mkdir(e, { recursive: !0 });
1055
+ const e = F(this.cacheDir, "image-metadata");
1056
+ await E.mkdir(e, { recursive: !0 });
979
1057
  } catch (e) {
980
1058
  if (e.code !== "EEXIST")
981
1059
  throw e;
@@ -986,8 +1064,8 @@ class Ft {
986
1064
  */
987
1065
  async getFeedData(e) {
988
1066
  try {
989
- const n = this.getFeedDataPath(e), s = await I.readFile(n, "utf-8"), r = JSON.parse(s);
990
- return Math.floor(Date.now() / 1e3) - r.lastUpdated > this.config.ttl ? (await this.clearFeedData(e), null) : r;
1067
+ const n = this.getFeedDataPath(e), s = await E.readFile(n, "utf-8"), o = JSON.parse(s);
1068
+ return Math.floor(Date.now() / 1e3) - o.lastUpdated > this.config.ttl ? (await this.clearFeedData(e), null) : o;
991
1069
  } catch (n) {
992
1070
  return n.code === "ENOENT" || console.error(`Error reading feed data cache for ${e}:`, n), null;
993
1071
  }
@@ -999,7 +1077,7 @@ class Ft {
999
1077
  try {
1000
1078
  await this.ensureCacheDir();
1001
1079
  const s = this.getFeedDataPath(e);
1002
- await I.writeFile(s, JSON.stringify(n, null, 2), "utf-8");
1080
+ await E.writeFile(s, JSON.stringify(n, null, 2), "utf-8");
1003
1081
  } catch (s) {
1004
1082
  console.error(`Error writing feed data cache for ${e}:`, s);
1005
1083
  }
@@ -1009,27 +1087,27 @@ class Ft {
1009
1087
  */
1010
1088
  async getFeedContent(e, n, s) {
1011
1089
  try {
1012
- const r = this.getFeedContentPath(e, n, s), a = await I.readFile(r, "utf-8"), o = JSON.parse(a);
1013
- return Math.floor(Date.now() / 1e3) > o.expiresAt ? (await this.clearFeedContent(e, n, s), null) : o;
1014
- } catch (r) {
1015
- return r.code === "ENOENT" || console.error(
1090
+ const o = this.getFeedContentPath(e, n, s), i = await E.readFile(o, "utf-8"), r = JSON.parse(i);
1091
+ return Math.floor(Date.now() / 1e3) > r.expiresAt ? (await this.clearFeedContent(e, n, s), null) : r;
1092
+ } catch (o) {
1093
+ return o.code === "ENOENT" || console.error(
1016
1094
  `Error reading feed content cache for ${e}:${n}:`,
1017
- r
1095
+ o
1018
1096
  ), null;
1019
1097
  }
1020
1098
  }
1021
1099
  /**
1022
1100
  * Set cached feed content for a schema and format
1023
1101
  */
1024
- async setFeedContent(e, n, s, r) {
1102
+ async setFeedContent(e, n, s, o) {
1025
1103
  try {
1026
1104
  await this.ensureCacheDir();
1027
- const a = this.getFeedContentPath(e, n, r);
1028
- await I.writeFile(a, JSON.stringify(s, null, 2), "utf-8");
1029
- } catch (a) {
1105
+ const i = this.getFeedContentPath(e, n, o);
1106
+ await E.writeFile(i, JSON.stringify(s, null, 2), "utf-8");
1107
+ } catch (i) {
1030
1108
  console.error(
1031
1109
  `Error writing feed content cache for ${e}:${n}:`,
1032
- a
1110
+ i
1033
1111
  );
1034
1112
  }
1035
1113
  }
@@ -1039,7 +1117,7 @@ class Ft {
1039
1117
  async clearFeedData(e) {
1040
1118
  try {
1041
1119
  const n = this.getFeedDataPath(e);
1042
- await I.unlink(n);
1120
+ await E.unlink(n);
1043
1121
  } catch (n) {
1044
1122
  n.code !== "ENOENT" && console.error(`Error clearing feed data cache for ${e}:`, n);
1045
1123
  }
@@ -1049,12 +1127,12 @@ class Ft {
1049
1127
  */
1050
1128
  async clearFeedContent(e, n, s) {
1051
1129
  try {
1052
- const r = this.getFeedContentPath(e, n, s);
1053
- await I.unlink(r);
1054
- } catch (r) {
1055
- r.code !== "ENOENT" && console.error(
1130
+ const o = this.getFeedContentPath(e, n, s);
1131
+ await E.unlink(o);
1132
+ } catch (o) {
1133
+ o.code !== "ENOENT" && console.error(
1056
1134
  `Error clearing feed content cache for ${e}:${n}:`,
1057
- r
1135
+ o
1058
1136
  );
1059
1137
  }
1060
1138
  }
@@ -1063,9 +1141,9 @@ class Ft {
1063
1141
  */
1064
1142
  async clearAllContentCache(e) {
1065
1143
  try {
1066
- const n = await I.readdir(this.cacheDir), s = `${e}-`, r = ".json";
1067
- for (const a of n)
1068
- a.startsWith(s) && a.endsWith(r) && a !== `${e}.json` && await I.unlink(U(this.cacheDir, a));
1144
+ const n = await E.readdir(this.cacheDir), s = `${e}-`, o = ".json";
1145
+ for (const i of n)
1146
+ i.startsWith(s) && i.endsWith(o) && i !== `${e}.json` && await E.unlink(F(this.cacheDir, i));
1069
1147
  } catch (n) {
1070
1148
  console.error(`Error clearing all content cache for ${e}:`, n);
1071
1149
  }
@@ -1075,8 +1153,8 @@ class Ft {
1075
1153
  */
1076
1154
  async getImageMetadata(e) {
1077
1155
  try {
1078
- const n = this.getImageMetadataPath(e), s = await I.readFile(n, "utf-8"), r = JSON.parse(s);
1079
- return Math.floor(Date.now() / 1e3) > r.expiresAt ? (await this.clearImageMetadata(e), null) : r.metadata;
1156
+ const n = this.getImageMetadataPath(e), s = await E.readFile(n, "utf-8"), o = JSON.parse(s);
1157
+ return Math.floor(Date.now() / 1e3) > o.expiresAt ? (await this.clearImageMetadata(e), null) : o.metadata;
1080
1158
  } catch (n) {
1081
1159
  return n.code === "ENOENT" || console.error(`Error reading image metadata cache for ${e}:`, n), null;
1082
1160
  }
@@ -1087,12 +1165,12 @@ class Ft {
1087
1165
  async setImageMetadata(e, n) {
1088
1166
  try {
1089
1167
  await this.ensureImageMetadataDir();
1090
- const s = this.getImageMetadataPath(e), r = Math.floor(Date.now() / 1e3), a = this.config.imageMetadata?.ttl || 604800, o = r + a, i = {
1168
+ const s = this.getImageMetadataPath(e), o = Math.floor(Date.now() / 1e3), i = this.config.imageMetadata?.ttl || 604800, r = o + i, a = {
1091
1169
  metadata: n,
1092
- cachedAt: r,
1093
- expiresAt: o
1170
+ cachedAt: o,
1171
+ expiresAt: r
1094
1172
  };
1095
- await I.writeFile(s, JSON.stringify(i, null, 2), "utf-8");
1173
+ await E.writeFile(s, JSON.stringify(a, null, 2), "utf-8");
1096
1174
  } catch (s) {
1097
1175
  console.error(`Error writing image metadata cache for ${e}:`, s);
1098
1176
  }
@@ -1103,7 +1181,7 @@ class Ft {
1103
1181
  async clearImageMetadata(e) {
1104
1182
  try {
1105
1183
  const n = this.getImageMetadataPath(e);
1106
- await I.unlink(n);
1184
+ await E.unlink(n);
1107
1185
  } catch (n) {
1108
1186
  n.code !== "ENOENT" && console.error(`Error clearing image metadata cache for ${e}:`, n);
1109
1187
  }
@@ -1113,14 +1191,14 @@ class Ft {
1113
1191
  */
1114
1192
  async clearAll() {
1115
1193
  try {
1116
- const e = await I.readdir(this.cacheDir);
1194
+ const e = await E.readdir(this.cacheDir);
1117
1195
  for (const s of e)
1118
- s.endsWith(".json") && await I.unlink(U(this.cacheDir, s));
1119
- const n = U(this.cacheDir, "image-metadata");
1196
+ s.endsWith(".json") && await E.unlink(F(this.cacheDir, s));
1197
+ const n = F(this.cacheDir, "image-metadata");
1120
1198
  try {
1121
- const s = await I.readdir(n);
1122
- for (const r of s)
1123
- r.endsWith(".json") && await I.unlink(U(n, r));
1199
+ const s = await E.readdir(n);
1200
+ for (const o of s)
1201
+ o.endsWith(".json") && await E.unlink(F(n, o));
1124
1202
  } catch {
1125
1203
  }
1126
1204
  } catch (e) {
@@ -1128,7 +1206,7 @@ class Ft {
1128
1206
  }
1129
1207
  }
1130
1208
  }
1131
- class Ut {
1209
+ class Gt {
1132
1210
  memoryCache;
1133
1211
  fileCache;
1134
1212
  config;
@@ -1139,7 +1217,7 @@ class Ut {
1139
1217
  errors: 0
1140
1218
  };
1141
1219
  constructor(e) {
1142
- this.config = e, this.memoryCache = new Mt(e), this.fileCache = new Ft(e);
1220
+ this.config = e, this.memoryCache = new Wt(e), this.fileCache = new Ht(e);
1143
1221
  }
1144
1222
  /**
1145
1223
  * Get cached feed data for a schema
@@ -1177,18 +1255,18 @@ class Ut {
1177
1255
  if (!this.config.enabled)
1178
1256
  return null;
1179
1257
  try {
1180
- let r = this.memoryCache.getFeedContent(e, n, s);
1181
- return r ? (this.stats.hits++, r) : (r = await this.fileCache.getFeedContent(e, n, s), r ? (this.memoryCache.setFeedContent(
1258
+ let o = this.memoryCache.getFeedContent(e, n, s);
1259
+ return o ? (this.stats.hits++, o) : (o = await this.fileCache.getFeedContent(e, n, s), o ? (this.memoryCache.setFeedContent(
1182
1260
  e,
1183
1261
  n,
1184
- r.content,
1185
- r.contentType,
1262
+ o.content,
1263
+ o.contentType,
1186
1264
  s
1187
- ), this.stats.hits++, r) : (this.stats.misses++, null));
1188
- } catch (r) {
1265
+ ), this.stats.hits++, o) : (this.stats.misses++, null));
1266
+ } catch (o) {
1189
1267
  return console.error(
1190
1268
  `Error getting feed content cache for ${e}:${n}:`,
1191
- r
1269
+ o
1192
1270
  ), this.stats.errors++, null;
1193
1271
  }
1194
1272
  }
@@ -1196,24 +1274,24 @@ class Ut {
1196
1274
  * Set cached feed content for a schema and format
1197
1275
  * Updates both memory and file cache
1198
1276
  */
1199
- async setFeedContent(e, n, s, r, a) {
1277
+ async setFeedContent(e, n, s, o, i) {
1200
1278
  if (this.config.enabled)
1201
1279
  try {
1202
- let o;
1203
- a?.archive ? o = this.config.archiveTtl ?? 86400 : a?.page != null && a.page > 1 && (o = this.config.pageTtl ?? 300), this.memoryCache.setFeedContent(
1280
+ let r;
1281
+ i?.archive ? r = this.config.archiveTtl ?? 86400 : i?.page != null && i.page > 1 && (r = this.config.pageTtl ?? 300), this.memoryCache.setFeedContent(
1204
1282
  e,
1205
1283
  n,
1206
1284
  s,
1207
- r,
1208
- a,
1209
- o
1285
+ o,
1286
+ i,
1287
+ r
1210
1288
  );
1211
- const i = this.memoryCache.getFeedContent(e, n, a);
1212
- i && await this.fileCache.setFeedContent(e, n, i, a);
1213
- } catch (o) {
1289
+ const a = this.memoryCache.getFeedContent(e, n, i);
1290
+ a && await this.fileCache.setFeedContent(e, n, a, i);
1291
+ } catch (r) {
1214
1292
  console.error(
1215
1293
  `Error setting feed content cache for ${e}:${n}:`,
1216
- o
1294
+ r
1217
1295
  ), this.stats.errors++;
1218
1296
  }
1219
1297
  }
@@ -1242,27 +1320,27 @@ class Ut {
1242
1320
  */
1243
1321
  mergeItems(e, n) {
1244
1322
  const s = /* @__PURE__ */ new Map();
1245
- for (const a of e) {
1246
- const o = a.id || a.seedUid || a.SeedUid || "";
1247
- o && s.set(o, a);
1323
+ for (const i of e) {
1324
+ const r = i.id || i.seedUid || i.SeedUid || "";
1325
+ r && s.set(r, i);
1248
1326
  }
1249
- for (const a of n) {
1250
- const o = a.id || a.seedUid || a.SeedUid || "";
1251
- o ? s.set(o, a) : s.set(`temp-${Date.now()}-${Math.random()}`, a);
1327
+ for (const i of n) {
1328
+ const r = i.id || i.seedUid || i.SeedUid || "";
1329
+ r ? s.set(r, i) : s.set(`temp-${Date.now()}-${Math.random()}`, i);
1252
1330
  }
1253
- const r = Array.from(s.values());
1254
- return r.sort((a, o) => {
1255
- const i = a.timeCreated || 0;
1256
- return (o.timeCreated || 0) - i;
1257
- }), r;
1331
+ const o = Array.from(s.values());
1332
+ return o.sort((i, r) => {
1333
+ const a = i.timeCreated || 0;
1334
+ return (r.timeCreated || 0) - a;
1335
+ }), o;
1258
1336
  }
1259
1337
  /**
1260
1338
  * Filter items to only include those newer than the given timestamp
1261
1339
  */
1262
1340
  filterNewItems(e, n) {
1263
1341
  return e.filter((s) => {
1264
- const r = s.timeCreated;
1265
- return r && r > n;
1342
+ const o = s.timeCreated;
1343
+ return o && o > n;
1266
1344
  });
1267
1345
  }
1268
1346
  /**
@@ -1318,33 +1396,33 @@ class Ut {
1318
1396
  };
1319
1397
  }
1320
1398
  }
1321
- function ce() {
1322
- const t = parseInt(process.env.CACHE_TTL || "3600", 10), e = process.env.CACHE_DIR || "./cache", n = process.env.CACHE_ENABLED === "false" || process.env.CACHE_ENABLED === "0" || process.env.CACHE_ENABLED === "no" || process.env.CACHE_ENABLED === "off", s = process.env.CACHE_ENABLED === "true" || process.env.CACHE_ENABLED === "1" || process.env.CACHE_ENABLED === "yes", r = process.env.NODE_ENV === "development";
1323
- let a;
1324
- n ? a = !1 : s ? a = !0 : r ? a = !1 : a = !0;
1325
- const o = process.env.CACHE_BACKGROUND_REFRESH === "true", i = parseInt(
1399
+ function fe() {
1400
+ const t = parseInt(process.env.CACHE_TTL || "3600", 10), e = process.env.CACHE_DIR || "./cache", n = process.env.CACHE_ENABLED === "false" || process.env.CACHE_ENABLED === "0" || process.env.CACHE_ENABLED === "no" || process.env.CACHE_ENABLED === "off", s = process.env.CACHE_ENABLED === "true" || process.env.CACHE_ENABLED === "1" || process.env.CACHE_ENABLED === "yes", o = process.env.NODE_ENV === "development";
1401
+ let i;
1402
+ n ? i = !1 : s ? i = !0 : o ? i = !1 : i = !0;
1403
+ const r = process.env.CACHE_BACKGROUND_REFRESH === "true", a = parseInt(
1326
1404
  process.env.CACHE_REFRESH_INTERVAL || "300",
1327
1405
  10
1328
1406
  );
1329
- a || console.log(`⚠️ Cache is DISABLED (${n ? "CACHE_ENABLED=false" : r ? "NODE_ENV=development" : "CACHE_ENABLED=false"})`);
1330
- const c = process.env.IMAGE_METADATA_ENABLED !== "false", d = parseInt(process.env.IMAGE_METADATA_TTL || "604800", 10), f = process.env.IMAGE_METADATA_GATEWAYS ? process.env.IMAGE_METADATA_GATEWAYS.split(",").map((m) => m.trim()) : [...Ee], p = parseInt(process.env.IMAGE_METADATA_TIMEOUT || "5000", 10), w = {
1407
+ i || console.log(`⚠️ Cache is DISABLED (${n ? "CACHE_ENABLED=false" : o ? "NODE_ENV=development" : "CACHE_ENABLED=false"})`);
1408
+ const c = process.env.IMAGE_METADATA_ENABLED !== "false", l = parseInt(process.env.IMAGE_METADATA_TTL || "604800", 10), d = process.env.IMAGE_METADATA_GATEWAYS ? process.env.IMAGE_METADATA_GATEWAYS.split(",").map((p) => p.trim()) : [...Me], h = parseInt(process.env.IMAGE_METADATA_TIMEOUT || "5000", 10), g = {
1331
1409
  enabled: c,
1332
- ttl: d,
1333
- gateways: f,
1334
- timeout: p
1335
- }, h = parseInt(process.env.CACHE_PAGE_TTL || "300", 10), C = parseInt(process.env.CACHE_ARCHIVE_TTL || "86400", 10);
1410
+ ttl: l,
1411
+ gateways: d,
1412
+ timeout: h
1413
+ }, f = parseInt(process.env.CACHE_PAGE_TTL || "300", 10), y = parseInt(process.env.CACHE_ARCHIVE_TTL || "86400", 10);
1336
1414
  return {
1337
1415
  ttl: t,
1338
1416
  cacheDir: e,
1339
- enabled: a,
1340
- backgroundRefresh: o,
1341
- refreshInterval: i,
1342
- imageMetadata: w,
1343
- pageTtl: h,
1344
- archiveTtl: C
1417
+ enabled: i,
1418
+ backgroundRefresh: r,
1419
+ refreshInterval: a,
1420
+ imageMetadata: g,
1421
+ pageTtl: f,
1422
+ archiveTtl: y
1345
1423
  };
1346
1424
  }
1347
- class ye {
1425
+ class Ae {
1348
1426
  config;
1349
1427
  constructor(e) {
1350
1428
  this.config = e;
@@ -1353,14 +1431,16 @@ class ye {
1353
1431
  * Detect if an Arweave transaction ID links to an image and extract metadata
1354
1432
  */
1355
1433
  async detectImage(e) {
1356
- const n = this.config.gateways || [...Ee];
1434
+ await et().catch(() => {
1435
+ });
1436
+ const n = this.config.gateways || [...Me];
1357
1437
  for (const s of n)
1358
1438
  try {
1359
- const r = `https://${s}/${e}`, a = await this.getImageMetadata(r);
1360
- if (a.isImage)
1361
- return a;
1362
- } catch (r) {
1363
- console.warn(`Failed to fetch from gateway ${s} for transaction ${e}:`, r);
1439
+ const o = `https://${s}/${e}`, i = await this.getImageMetadata(o);
1440
+ if (i.isImage)
1441
+ return i;
1442
+ } catch (o) {
1443
+ console.warn(`Failed to fetch from gateway ${s} for transaction ${e}:`, o);
1364
1444
  continue;
1365
1445
  }
1366
1446
  return {
@@ -1376,30 +1456,30 @@ class ye {
1376
1456
  const n = await this.fetchWithTimeout(e, { method: "HEAD" });
1377
1457
  if (!n.ok)
1378
1458
  return { isImage: !1, url: e };
1379
- const s = n.headers.get("content-type") || "", r = n.headers.get("content-length");
1459
+ const s = n.headers.get("content-type") || "", o = n.headers.get("content-length");
1380
1460
  if (!this.isImageContentType(s))
1381
1461
  return {
1382
1462
  isImage: !1,
1383
1463
  url: e,
1384
1464
  mimeType: s || void 0,
1385
- size: r ? parseInt(r, 10) : void 0
1465
+ size: o ? parseInt(o, 10) : void 0
1386
1466
  };
1387
- const a = await this.fetchWithTimeout(e, {
1467
+ const i = await this.fetchWithTimeout(e, {
1388
1468
  headers: {
1389
1469
  Range: "bytes=0-8192"
1390
1470
  // First 8KB should be enough for most image headers
1391
1471
  }
1392
1472
  });
1393
- if (!a.ok)
1394
- return await this.getImageMetadataFromFullRequest(e, s, r);
1395
- const o = Buffer.from(await a.arrayBuffer()), i = this.extractImageDimensions(o, s), c = this.getImageFormat(s, o);
1473
+ if (!i.ok)
1474
+ return await this.getImageMetadataFromFullRequest(e, s, o);
1475
+ const r = Buffer.from(await i.arrayBuffer()), a = this.extractImageDimensions(r, s), c = this.getImageFormat(s, r);
1396
1476
  return {
1397
1477
  isImage: !0,
1398
1478
  url: e,
1399
1479
  mimeType: s,
1400
- width: i.width,
1401
- height: i.height,
1402
- size: r ? parseInt(r, 10) : void 0,
1480
+ width: a.width,
1481
+ height: a.height,
1482
+ size: o ? parseInt(o, 10) : void 0,
1403
1483
  format: c
1404
1484
  };
1405
1485
  } catch (n) {
@@ -1411,21 +1491,21 @@ class ye {
1411
1491
  */
1412
1492
  async getImageMetadataFromFullRequest(e, n, s) {
1413
1493
  try {
1414
- const r = await this.fetchWithTimeout(e);
1415
- if (!r.ok)
1494
+ const o = await this.fetchWithTimeout(e);
1495
+ if (!o.ok)
1416
1496
  return { isImage: !1, url: e };
1417
- const a = Buffer.from(await r.arrayBuffer()), o = this.extractImageDimensions(a, n), i = this.getImageFormat(n, a);
1497
+ const i = Buffer.from(await o.arrayBuffer()), r = this.extractImageDimensions(i, n), a = this.getImageFormat(n, i);
1418
1498
  return {
1419
1499
  isImage: !0,
1420
1500
  url: e,
1421
1501
  mimeType: n,
1422
- width: o.width,
1423
- height: o.height,
1424
- size: a.length,
1425
- format: i
1502
+ width: r.width,
1503
+ height: r.height,
1504
+ size: i.length,
1505
+ format: a
1426
1506
  };
1427
- } catch (r) {
1428
- return console.warn(`Error in full request for ${e}:`, r), { isImage: !1, url: e };
1507
+ } catch (o) {
1508
+ return console.warn(`Error in full request for ${e}:`, o), { isImage: !1, url: e };
1429
1509
  }
1430
1510
  }
1431
1511
  /**
@@ -1439,7 +1519,7 @@ class ye {
1439
1519
  */
1440
1520
  extractImageDimensions(e, n) {
1441
1521
  try {
1442
- const s = le(e);
1522
+ const s = ue(e);
1443
1523
  if (s.width && s.height)
1444
1524
  return {
1445
1525
  width: s.width,
@@ -1457,12 +1537,12 @@ class ye {
1457
1537
  if (e) {
1458
1538
  const s = e.toLowerCase().match(/image\/([^;]+)/);
1459
1539
  if (s && s[1]) {
1460
- const r = s[1].toLowerCase();
1461
- return r === "jpeg" ? "jpeg" : r === "png" ? "png" : r === "gif" ? "gif" : r === "webp" ? "webp" : r === "svg+xml" ? "svg" : r;
1540
+ const o = s[1].toLowerCase();
1541
+ return o === "jpeg" ? "jpeg" : o === "png" ? "png" : o === "gif" ? "gif" : o === "webp" ? "webp" : o === "svg+xml" ? "svg" : o;
1462
1542
  }
1463
1543
  }
1464
1544
  try {
1465
- const s = le(n);
1545
+ const s = ue(n);
1466
1546
  if (s.type)
1467
1547
  return s.type.toLowerCase();
1468
1548
  } catch {
@@ -1472,19 +1552,19 @@ class ye {
1472
1552
  * Fetch with timeout
1473
1553
  */
1474
1554
  async fetchWithTimeout(e, n = {}) {
1475
- const s = new AbortController(), r = setTimeout(() => s.abort(), this.config.timeout);
1555
+ const s = new AbortController(), o = setTimeout(() => s.abort(), this.config.timeout);
1476
1556
  try {
1477
- const a = await fetch(e, {
1557
+ const i = await fetch(e, {
1478
1558
  ...n,
1479
1559
  signal: s.signal
1480
1560
  });
1481
- return clearTimeout(r), a;
1482
- } catch (a) {
1483
- throw clearTimeout(r), a instanceof Error && a.name === "AbortError" ? new Error(`Request timeout after ${this.config.timeout}ms`) : a;
1561
+ return clearTimeout(o), i;
1562
+ } catch (i) {
1563
+ throw clearTimeout(o), i instanceof Error && i.name === "AbortError" ? new Error(`Request timeout after ${this.config.timeout}ms`) : i;
1484
1564
  }
1485
1565
  }
1486
1566
  }
1487
- function se(t, e) {
1567
+ function ce(t, e) {
1488
1568
  for (const n of e) {
1489
1569
  const s = t[n];
1490
1570
  if (typeof s == "string" && s.trim() !== "")
@@ -1492,83 +1572,83 @@ function se(t, e) {
1492
1572
  }
1493
1573
  return "";
1494
1574
  }
1495
- const Pe = ["summary", "Summary", "description", "Description", "text", "Text"], Re = ["html", "Html", "body", "Body", "content", "Content"], bt = ["summary", "Summary", "description", "Description", "text", "Text"];
1496
- function we(t, e) {
1497
- const n = de(t.model) - de(e.model);
1575
+ const Be = ["summary", "Summary", "description", "Description", "text", "Text"], ze = ["html", "Html", "body", "Body", "content", "Content"], Xt = ["summary", "Summary", "description", "Description", "text", "Text"];
1576
+ function Te(t, e) {
1577
+ const n = he(t.model) - he(e.model);
1498
1578
  if (n !== 0) return n;
1499
1579
  const s = t.key.localeCompare(e.key);
1500
1580
  return s !== 0 ? s : t.index - e.index;
1501
1581
  }
1502
- function vt(t) {
1503
- const e = Q(t), n = ee(t);
1582
+ function Jt(t) {
1583
+ const e = ee(t), n = te(t);
1504
1584
  let s = null;
1505
1585
  if (e)
1506
- for (const [r, a] of Object.entries(e)) {
1507
- if (!B(a)) continue;
1508
- const o = t[r];
1509
- if (typeof o != "string" || o.trim() === "") continue;
1510
- const i = { model: a, key: r, index: 0, value: o };
1511
- (!s || we(i, s) < 0) && (s = i);
1586
+ for (const [o, i] of Object.entries(e)) {
1587
+ if (!B(i)) continue;
1588
+ const r = t[o];
1589
+ if (typeof r != "string" || r.trim() === "") continue;
1590
+ const a = { model: i, key: o, index: 0, value: r };
1591
+ (!s || Te(a, s) < 0) && (s = a);
1512
1592
  }
1513
1593
  if (n)
1514
- for (const [r, a] of Object.entries(n)) {
1515
- const o = t[r];
1516
- if (!Array.isArray(o)) continue;
1517
- const i = Math.min(a.length, o.length);
1518
- for (let c = 0; c < i; c++) {
1519
- const d = a[c];
1520
- if (!B(d)) continue;
1521
- const f = o[c];
1522
- if (typeof f != "string" || f.trim() === "") continue;
1523
- const p = { model: d, key: r, index: c, value: f };
1524
- (!s || we(p, s) < 0) && (s = p);
1594
+ for (const [o, i] of Object.entries(n)) {
1595
+ const r = t[o];
1596
+ if (!Array.isArray(r)) continue;
1597
+ const a = Math.min(i.length, r.length);
1598
+ for (let c = 0; c < a; c++) {
1599
+ const l = i[c];
1600
+ if (!B(l)) continue;
1601
+ const d = r[c];
1602
+ if (typeof d != "string" || d.trim() === "") continue;
1603
+ const h = { model: l, key: o, index: c, value: d };
1604
+ (!s || Te(h, s) < 0) && (s = h);
1525
1605
  }
1526
1606
  }
1527
1607
  return s?.value ?? "";
1528
1608
  }
1529
- function kt(t) {
1530
- return se(t, Pe);
1609
+ function Vt(t) {
1610
+ return ce(t, Be);
1531
1611
  }
1532
- function xt(t) {
1533
- const e = vt(t);
1612
+ function Kt(t) {
1613
+ const e = Jt(t);
1534
1614
  if (e !== "") return e;
1535
- const n = se(t, Re);
1536
- return n !== "" ? n : se(t, bt);
1615
+ const n = ce(t, ze);
1616
+ return n !== "" ? n : ce(t, Xt);
1537
1617
  }
1538
- function q(t) {
1618
+ function Z(t) {
1539
1619
  return typeof t != "string" ? !1 : t.includes("data:image/") && t.includes(";base64,");
1540
1620
  }
1541
- function Lt(t) {
1542
- const e = Q(t);
1621
+ function Yt(t) {
1622
+ const e = ee(t);
1543
1623
  if (e) {
1544
- for (const [s, r] of Object.entries(e))
1545
- if (B(r) && q(t[s]))
1624
+ for (const [s, o] of Object.entries(e))
1625
+ if (B(o) && Z(t[s]))
1546
1626
  return !0;
1547
1627
  }
1548
- const n = ee(t);
1628
+ const n = te(t);
1549
1629
  if (n)
1550
- for (const [s, r] of Object.entries(n)) {
1551
- const a = t[s];
1552
- if (!Array.isArray(a)) continue;
1553
- const o = Math.min(r.length, a.length);
1554
- for (let i = 0; i < o; i++)
1555
- if (B(r[i]) && q(a[i]))
1630
+ for (const [s, o] of Object.entries(n)) {
1631
+ const i = t[s];
1632
+ if (!Array.isArray(i)) continue;
1633
+ const r = Math.min(o.length, i.length);
1634
+ for (let a = 0; a < r; a++)
1635
+ if (B(o[a]) && Z(i[a]))
1556
1636
  return !0;
1557
1637
  }
1558
1638
  return !1;
1559
1639
  }
1560
- function Pt(t) {
1561
- if (Lt(t)) return !0;
1562
- for (const e of Re)
1563
- if (q(t[e])) return !0;
1564
- for (const e of Pe)
1565
- if (q(t[e])) return !0;
1640
+ function qt(t) {
1641
+ if (Yt(t)) return !0;
1642
+ for (const e of ze)
1643
+ if (Z(t[e])) return !0;
1644
+ for (const e of Be)
1645
+ if (Z(t[e])) return !0;
1566
1646
  return !1;
1567
1647
  }
1568
- function Rt(t, e = "omit_items") {
1569
- return e === "include_items" ? [...t] : t.filter((n) => !Pt(n));
1648
+ function Zt(t, e = "omit_items") {
1649
+ return e === "include_items" ? [...t] : t.filter((n) => !qt(n));
1570
1650
  }
1571
- function Ot(t) {
1651
+ function Qt(t) {
1572
1652
  if (t != null) {
1573
1653
  if (typeof t == "string") {
1574
1654
  if (t.startsWith("http://") || t.startsWith("https://")) return t;
@@ -1591,41 +1671,145 @@ function Ot(t) {
1591
1671
  }
1592
1672
  }
1593
1673
  }
1594
- let O, k = null, V = null;
1595
- function Oe() {
1596
- if (!V) {
1597
- const t = ce();
1598
- V = new Ut(t);
1674
+ function re(t) {
1675
+ if (typeof t == "number" && Number.isFinite(t) && t > 0) return t;
1676
+ if (typeof t == "string") {
1677
+ const e = Number(t);
1678
+ if (Number.isFinite(e) && e > 0) return e;
1679
+ }
1680
+ }
1681
+ function We(t) {
1682
+ if (Array.isArray(t)) {
1683
+ for (const n of t) {
1684
+ const s = We(n);
1685
+ if (s) return s;
1686
+ }
1687
+ return;
1688
+ }
1689
+ const e = Qt(t);
1690
+ if (e) {
1691
+ if (t && typeof t == "object" && !Array.isArray(t)) {
1692
+ const n = t, s = typeof n.mimeType == "string" && n.mimeType || typeof n.type == "string" && n.type || typeof n.contentType == "string" && n.contentType || void 0;
1693
+ return {
1694
+ url: e,
1695
+ mimeType: s,
1696
+ width: re(n.width),
1697
+ height: re(n.height),
1698
+ size: re(n.size ?? n.fileSize),
1699
+ format: typeof n.format == "string" ? n.format : void 0
1700
+ };
1701
+ }
1702
+ return { url: e };
1703
+ }
1704
+ }
1705
+ function en(t) {
1706
+ if (t._hasImage && t._imageMetadata && typeof t._imageMetadata == "object") {
1707
+ const n = t._imageMetadata;
1708
+ if (n.url)
1709
+ return {
1710
+ url: n.url,
1711
+ mimeType: n.mimeType,
1712
+ width: n.width,
1713
+ height: n.height,
1714
+ size: n.size,
1715
+ format: n.format
1716
+ };
1717
+ }
1718
+ const e = [
1719
+ "feature_image",
1720
+ "featureImage",
1721
+ "image",
1722
+ "images",
1723
+ "cover_image",
1724
+ "coverImage",
1725
+ "thumbnail",
1726
+ "thumbnail_image",
1727
+ "thumbnailImage"
1728
+ ];
1729
+ for (const n of e) {
1730
+ if (!(n in t)) continue;
1731
+ const s = We(t[n]);
1732
+ if (s) return s;
1733
+ }
1734
+ }
1735
+ function tn(t, e, n, s, o, i) {
1736
+ const r = n.mimeType || "image/jpeg";
1737
+ t.enclosures = [
1738
+ {
1739
+ url: n.url,
1740
+ type: r,
1741
+ ...n.size ? { length: n.size } : {}
1742
+ }
1743
+ ];
1744
+ const a = {
1745
+ url: n.url,
1746
+ type: r,
1747
+ medium: "image"
1748
+ };
1749
+ n.width && (a.width = n.width), n.height && (a.height = n.height), n.size && (a.fileSize = n.size), n.format && (a.format = n.format), t["media:content"] = [a];
1750
+ const c = { url: n.url };
1751
+ n.width && (c.width = n.width), n.height && (c.height = n.height), t["media:thumbnail"] = [c], e.title && (t["media:title"] = e.title);
1752
+ const l = e.description || e.summary || e.title || "";
1753
+ if (l && (t["media:description"] = l), e.title) {
1754
+ const d = [];
1755
+ d.push(...String(e.title).toLowerCase().split(/\s+/).filter((h) => h.length > 3)), e.description && d.push(...String(e.description).toLowerCase().split(/\s+/).filter((h) => h.length > 3)), d.length > 0 && (t["media:keywords"] = [...new Set(d)].slice(0, 10).join(", "));
1756
+ }
1757
+ if (Array.isArray(e.authors) && e.authors.length > 0 ? t["media:credit"] = e.authors.map((d) => ({
1758
+ value: d.name || d.displayName || "Unknown",
1759
+ role: "author"
1760
+ })) : o && (t["media:credit"] = [{ value: o.name, role: "author" }]), i && (t["media:copyright"] = i), s && (t["media:category"] = [
1761
+ {
1762
+ value: s,
1763
+ scheme: "http://www.schema.org/"
1764
+ }
1765
+ ]), t["media:group"] = [
1766
+ {
1767
+ "media:content": [a],
1768
+ "media:thumbnail": [c],
1769
+ "media:title": e.title || "Untitled",
1770
+ "media:description": l
1771
+ }
1772
+ ], n.url && typeof e.content == "string" && e.content.trim() !== "" && !e.content.includes(n.url)) {
1773
+ const d = `<img src="${n.url}" alt="${e.title || ""}"${n.width ? ` width="${n.width}"` : ""}${n.height ? ` height="${n.height}"` : ""} />`;
1774
+ t["content:encoded"] = `${d}
1775
+ ${e.content}`;
1776
+ }
1777
+ }
1778
+ let N, x = null, K = null;
1779
+ function He() {
1780
+ if (!K) {
1781
+ const t = fe();
1782
+ K = new Gt(t);
1599
1783
  }
1600
- return V;
1784
+ return K;
1601
1785
  }
1602
- function en() {
1603
- V = null;
1786
+ function wn() {
1787
+ K = null;
1604
1788
  }
1605
- const Nt = async () => {
1606
- if (k)
1607
- return k;
1608
- if (!O)
1609
- return k = (async () => {
1789
+ const nn = async () => {
1790
+ if (x)
1791
+ return x;
1792
+ if (!N)
1793
+ return x = (async () => {
1610
1794
  try {
1611
1795
  console.log("Initializing Seed Protocol client..."), await L.init({ config: {
1612
1796
  endpoints: {
1613
1797
  filePaths: "app-files",
1614
1798
  files: "/app-files"
1615
1799
  },
1616
- arweaveDomain: Xe
1617
- }, addresses: [] }), console.log("✅ Seed Protocol client initialized successfully"), O = L, k = null;
1800
+ arweaveDomain: tt
1801
+ }, addresses: [] }), console.log("✅ Seed Protocol client initialized successfully"), N = L, x = null;
1618
1802
  } catch (t) {
1619
- throw console.error("❌ Failed to initialize Seed Protocol client:", t), k = null, t;
1803
+ throw console.error("❌ Failed to initialize Seed Protocol client:", t), x = null, t;
1620
1804
  }
1621
- })(), k;
1622
- }, jt = async () => O || (k ? (await k, O) : (await Nt(), O)), tn = async () => {
1805
+ })(), x;
1806
+ }, rn = async () => N || (x ? (await x, N) : (await nn(), N)), Cn = async () => {
1623
1807
  try {
1624
1808
  console.log("Tearing down Seed Protocol client..."), typeof L.stop == "function" && (await L.stop(), console.log("✅ Seed Protocol client stopped")), typeof L.unload == "function" && (await L.unload(), console.log("✅ Seed Protocol client unloaded")), console.log("✅ Seed Protocol client teardown complete");
1625
1809
  } catch (t) {
1626
1810
  console.error("❌ Failed to teardown Seed Protocol client:", t);
1627
1811
  }
1628
- }, E = {
1812
+ }, T = {
1629
1813
  title: "Seed Protocol",
1630
1814
  description: "Content published via Seed Protocol",
1631
1815
  siteUrl: "https://seedprotocol.io",
@@ -1638,265 +1822,224 @@ const Nt = async () => {
1638
1822
  link: "https://seedprotocol.io"
1639
1823
  }
1640
1824
  };
1641
- async function Ce(t, e, n) {
1825
+ async function Ee(t, e, n) {
1642
1826
  const s = t.filter(
1643
- (i) => i.storageTransactionId || i.storage_transaction_id
1827
+ (a) => a.storageTransactionId || a.storage_transaction_id
1644
1828
  );
1645
1829
  if (s.length === 0)
1646
1830
  return t;
1647
1831
  console.log(`Enriching ${s.length} items with image metadata`);
1648
- const r = s.map(async (i) => {
1649
- const c = i.storageTransactionId || i.storage_transaction_id;
1650
- if (!c) return i;
1832
+ const o = s.map(async (a) => {
1833
+ const c = a.storageTransactionId || a.storage_transaction_id;
1834
+ if (!c) return a;
1651
1835
  try {
1652
- let d = await n.getImageMetadata(c);
1653
- return d || (console.log(`Detecting image for transaction ${c}`), d = await e.detectImage(c), await n.setImageMetadata(c, d)), d.isImage && (i._imageMetadata = d, i._hasImage = !0), i;
1654
- } catch (d) {
1655
- return console.warn(`Error enriching item with transaction ${c}:`, d), i;
1836
+ let l = await n.getImageMetadata(c);
1837
+ return l || (console.log(`Detecting image for transaction ${c}`), l = await e.detectImage(c), await n.setImageMetadata(c, l)), l.isImage && (a._imageMetadata = l, a._hasImage = !0), a;
1838
+ } catch (l) {
1839
+ return console.warn(`Error enriching item with transaction ${c}:`, l), a;
1656
1840
  }
1657
- }), a = await Promise.all(r), o = /* @__PURE__ */ new Map();
1658
- return a.forEach((i) => {
1659
- const c = i.id || i.seedUid || i.SeedUid || "";
1660
- c && o.set(c, i);
1661
- }), t.map((i) => {
1662
- const c = i.id || i.seedUid || i.SeedUid || "";
1663
- return o.get(c) || i;
1841
+ }), i = await Promise.all(o), r = /* @__PURE__ */ new Map();
1842
+ return i.forEach((a) => {
1843
+ const c = a.id || a.seedUid || a.SeedUid || "";
1844
+ c && r.set(c, a);
1845
+ }), t.map((a) => {
1846
+ const c = a.id || a.seedUid || a.SeedUid || "";
1847
+ return r.get(c) || a;
1664
1848
  });
1665
1849
  }
1666
- function Bt(t, e) {
1667
- const { schemaName: n, siteUrl: s, itemUrlBase: r, itemUrlPath: a, richTextDataUriImages: o = "omit_items" } = e;
1668
- return Rt(
1850
+ function on(t, e) {
1851
+ const { schemaName: n, siteUrl: s, itemUrlBase: o, itemUrlPath: i, richTextDataUriImages: r = "omit_items" } = e;
1852
+ return Zt(
1669
1853
  t,
1670
- o
1854
+ r
1671
1855
  ).map((c) => {
1672
- const d = c.id || c.seedUid || c.SeedUid || c.storageTransactionId || c.storage_transaction_id, f = r != null ? `${r.replace(/\/$/, "")}/${(a ?? "attestation/view").replace(/^\//, "")}/${d}` : `${s}/${b(n)}/${d}`, p = c.link || c.Link || c.import_url || c.importUrl || f;
1673
- let w;
1856
+ const l = c.id || c.seedUid || c.SeedUid || c.storageTransactionId || c.storage_transaction_id, d = o != null ? `${o.replace(/\/$/, "")}/${(i ?? "attestation/view").replace(/^\//, "")}/${l}` : `${s}/${U(n)}/${l}`, h = c.link || c.Link || c.import_url || c.importUrl || d;
1857
+ let g;
1674
1858
  if (c.pubDate || c.PubDate) {
1675
- const y = c.pubDate || c.PubDate;
1676
- w = new Date(y);
1859
+ const w = c.pubDate || c.PubDate;
1860
+ g = new Date(w);
1677
1861
  } else if (c.timeCreated)
1678
- w = new Date(c.timeCreated * 1e3);
1862
+ g = new Date(c.timeCreated * 1e3);
1679
1863
  else if (c.publishedAt || c.createdAt || c.updatedAt) {
1680
- const y = c.publishedAt || c.createdAt || c.updatedAt;
1681
- w = y && typeof y == "object" && y.constructor === Date ? y : new Date(y);
1864
+ const w = c.publishedAt || c.createdAt || c.updatedAt;
1865
+ g = w && typeof w == "object" && w.constructor === Date ? w : new Date(w);
1682
1866
  } else
1683
- w = /* @__PURE__ */ new Date();
1684
- const h = kt(c), C = xt(c), m = {
1867
+ g = /* @__PURE__ */ new Date();
1868
+ const f = Vt(c), y = Kt(c), p = {
1685
1869
  ...c,
1686
1870
  // Preserve all dynamic properties first
1687
1871
  // Map to standard feed fields
1688
- id: d,
1872
+ id: l,
1689
1873
  title: c.title || c.Title || "Untitled",
1690
- link: p,
1691
- description: h,
1692
- content: C,
1693
- pubDate: w,
1694
- date: w,
1874
+ link: h,
1875
+ description: f,
1876
+ content: y,
1877
+ pubDate: g,
1878
+ date: g,
1695
1879
  // Map guid - use full URL when available for proper permalink
1696
- guid: c.guid || c.Guid || c.link || c.Link || p
1880
+ guid: c.guid || c.Guid || c.link || c.Link || h
1697
1881
  };
1698
- if (typeof m.html == "string" && m.Html === void 0 && (m.Html = m.html), typeof m.Html == "string" && m.html === void 0 && (m.html = m.Html), typeof m.body == "string" && m.Body === void 0 && (m.Body = m.body), typeof m.Body == "string" && m.body === void 0 && (m.body = m.Body), c._imageMetadata && c._hasImage) {
1699
- const y = c._imageMetadata;
1700
- m._imageMetadata = y, m._hasImage = !0;
1882
+ if (typeof p.html == "string" && p.Html === void 0 && (p.Html = p.html), typeof p.Html == "string" && p.html === void 0 && (p.html = p.Html), typeof p.body == "string" && p.Body === void 0 && (p.Body = p.body), typeof p.Body == "string" && p.body === void 0 && (p.body = p.Body), c._imageMetadata && c._hasImage) {
1883
+ const w = c._imageMetadata;
1884
+ p._imageMetadata = w, p._hasImage = !0;
1701
1885
  }
1702
- return Object.keys(m).forEach((y) => {
1703
- const l = m[y];
1704
- if (typeof l == "string" && /date|time|published|created|updated/i.test(y) && y !== "pubDate" && y !== "date") {
1705
- const u = new Date(l);
1706
- isNaN(u.getTime()) || (m[y] = u);
1886
+ return Object.keys(p).forEach((w) => {
1887
+ const u = p[w];
1888
+ if (typeof u == "string" && /date|time|published|created|updated/i.test(w) && w !== "pubDate" && w !== "date") {
1889
+ const m = new Date(u);
1890
+ isNaN(m.getTime()) || (p[w] = m);
1707
1891
  }
1708
- }), m;
1892
+ }), p;
1709
1893
  });
1710
1894
  }
1711
- const Ne = (t, e, n, s, r, a, o, i) => {
1712
- const c = b(e), d = `${E.siteUrl}/${c}/${n}`, f = s ? `${d}?v=${s}` : d, p = `${E.title} - ${Wt(c)}`, w = /* @__PURE__ */ new Date(), h = G(), C = [];
1713
- if (r) {
1714
- const y = r.baseUrl.replace(/\?.*$/, ""), l = y.includes("?") ? "&" : "?";
1715
- r.hasNext && C.push({ rel: "next", href: `${y}${l}page=${r.page + 1}` }), r.page > 1 && (C.push({ rel: "previous", href: `${y}${l}page=${r.page - 1}` }), C.push({ rel: "first", href: `${y}${l}page=1` }));
1716
- }
1717
- if (a?.length)
1718
- for (const y of a)
1719
- C.push({ rel: y.rel, href: y.href });
1720
- const m = Bt(t, {
1895
+ const Ge = (t, e, n, s, o, i, r, a) => {
1896
+ const c = U(e), l = `${T.siteUrl}/${c}/${n}`, d = s ? `${l}?v=${s}` : l, h = `${T.title} - ${sn(c)}`, g = /* @__PURE__ */ new Date(), f = G(), y = [];
1897
+ if (o) {
1898
+ const w = o.baseUrl.replace(/\?.*$/, ""), u = w.includes("?") ? "&" : "?";
1899
+ o.hasNext && y.push({ rel: "next", href: `${w}${u}page=${o.page + 1}` }), o.page > 1 && (y.push({ rel: "previous", href: `${w}${u}page=${o.page - 1}` }), y.push({ rel: "first", href: `${w}${u}page=1` }));
1900
+ }
1901
+ if (i?.length)
1902
+ for (const w of i)
1903
+ y.push({ rel: w.rel, href: w.href });
1904
+ const p = on(t, {
1721
1905
  schemaName: e,
1722
- siteUrl: E.siteUrl,
1723
- itemUrlBase: h.itemUrlBase,
1724
- itemUrlPath: h.itemUrlPath,
1725
- richTextDataUriImages: i?.richTextDataUriImages ?? h.richTextDataUriImages
1906
+ siteUrl: T.siteUrl,
1907
+ itemUrlBase: f.itemUrlBase,
1908
+ itemUrlPath: f.itemUrlPath,
1909
+ richTextDataUriImages: a?.richTextDataUriImages ?? f.richTextDataUriImages
1726
1910
  });
1727
1911
  switch (n) {
1728
1912
  case "atom": {
1729
- const y = [
1730
- { href: f, rel: "self" },
1731
- { href: E.siteUrl }
1913
+ const w = [
1914
+ { href: d, rel: "self" },
1915
+ { href: T.siteUrl }
1732
1916
  ];
1733
- for (const u of C)
1734
- y.push({
1735
- href: u.href,
1736
- rel: u.rel,
1737
- type: u.type
1917
+ for (const m of y)
1918
+ w.push({
1919
+ href: m.href,
1920
+ rel: m.rel,
1921
+ type: m.type
1738
1922
  });
1739
- const l = {
1740
- id: f,
1741
- title: p,
1742
- updated: w,
1743
- links: y,
1744
- subtitle: E.description,
1745
- rights: E.copyright,
1746
- author: E.author ? {
1747
- name: E.author.name,
1748
- email: E.author.email,
1749
- uri: E.author.link
1923
+ const u = {
1924
+ id: d,
1925
+ title: h,
1926
+ updated: g,
1927
+ links: w,
1928
+ subtitle: T.description,
1929
+ rights: T.copyright,
1930
+ author: T.author ? {
1931
+ name: T.author.name,
1932
+ email: T.author.email,
1933
+ uri: T.author.link
1750
1934
  } : void 0,
1751
- entries: m.map((u) => {
1752
- const g = {
1753
- id: u.id || u.link,
1754
- title: u.title || "Untitled",
1755
- updated: u.date || u.pubDate || w,
1756
- links: u.link ? [{ href: u.link }] : [],
1757
- ...u
1935
+ entries: p.map((m) => {
1936
+ const C = {
1937
+ id: m.id || m.link,
1938
+ title: m.title || "Untitled",
1939
+ updated: m.date || m.pubDate || g,
1940
+ links: m.link ? [{ href: m.link }] : [],
1941
+ ...m
1758
1942
  // Preserve all dynamic properties
1759
1943
  };
1760
- if (u.content && (g.content = u.content), u.description && (g.summary = u.description), u._imageMetadata && u._hasImage) {
1761
- const D = u._imageMetadata;
1762
- if (g.links || (g.links = []), g.links.push({
1763
- href: D.url,
1944
+ if (m.content && (C.content = m.content), m.description && (C.summary = m.description), m._imageMetadata && m._hasImage) {
1945
+ const S = m._imageMetadata;
1946
+ if (C.links || (C.links = []), C.links.push({
1947
+ href: S.url,
1764
1948
  rel: "enclosure",
1765
- type: D.mimeType || "image/jpeg",
1766
- length: D.size
1767
- }), D.url && g.content && !g.content.includes(D.url)) {
1768
- const T = `<img src="${D.url}" alt="${u.title || ""}"${D.width ? ` width="${D.width}"` : ""}${D.height ? ` height="${D.height}"` : ""} />`;
1769
- g.content = typeof g.content == "string" ? `${T}
1770
- ${g.content}` : { type: "html", value: `${T}
1771
- ${g.content.value || g.content}` };
1949
+ type: S.mimeType || "image/jpeg",
1950
+ length: S.size
1951
+ }), S.url && C.content && !C.content.includes(S.url)) {
1952
+ const D = `<img src="${S.url}" alt="${m.title || ""}"${S.width ? ` width="${S.width}"` : ""}${S.height ? ` height="${S.height}"` : ""} />`;
1953
+ C.content = typeof C.content == "string" ? `${D}
1954
+ ${C.content}` : { type: "html", value: `${D}
1955
+ ${C.content.value || C.content}` };
1772
1956
  }
1773
1957
  }
1774
- return g;
1958
+ return C;
1775
1959
  })
1776
1960
  };
1777
- return Promise.resolve(qe(l));
1961
+ return Promise.resolve(st(u));
1778
1962
  }
1779
1963
  case "json": {
1780
- const y = r?.hasNext ? `${r.baseUrl.replace(/\?.*$/, "")}?page=${r.page + 1}` : void 0, l = {
1781
- title: p,
1782
- home_page_url: E.siteUrl,
1783
- feed_url: f,
1784
- ...y && { next_url: y },
1785
- description: E.description,
1786
- author: E.author ? {
1787
- name: E.author.name,
1788
- url: E.author.link
1964
+ const w = o?.hasNext ? `${o.baseUrl.replace(/\?.*$/, "")}?page=${o.page + 1}` : void 0, u = {
1965
+ title: h,
1966
+ home_page_url: T.siteUrl,
1967
+ feed_url: d,
1968
+ ...w && { next_url: w },
1969
+ description: T.description,
1970
+ author: T.author ? {
1971
+ name: T.author.name,
1972
+ url: T.author.link
1789
1973
  } : void 0,
1790
- items: m.map((g) => {
1791
- const D = {
1792
- id: g.id || g.link,
1793
- ...g
1974
+ items: p.map((C) => {
1975
+ const S = {
1976
+ id: C.id || C.link,
1977
+ ...C
1794
1978
  // Preserve all dynamic properties
1795
1979
  };
1796
- if (g.title && (D.title = g.title), g.link && (D.url = g.link), g.content && (D.content_html = g.content), g.description && (D.summary = g.description), (g.date || g.pubDate) && (D.date_published = g.date || g.pubDate), g._imageMetadata && g._hasImage) {
1797
- const T = g._imageMetadata;
1798
- if (D.image = T.url, D.attachments || (D.attachments = []), D.attachments.push({
1799
- url: T.url,
1800
- mime_type: T.mimeType || "image/jpeg",
1801
- size_in_bytes: T.size,
1802
- title: g.title || "Image"
1803
- }), T.url && D.content_html && !D.content_html.includes(T.url)) {
1804
- const M = `<img src="${T.url}" alt="${g.title || ""}"${T.width ? ` width="${T.width}"` : ""}${T.height ? ` height="${T.height}"` : ""} />`;
1805
- D.content_html = `${M}
1806
- ${D.content_html}`;
1980
+ if (C.title && (S.title = C.title), C.link && (S.url = C.link), C.content && (S.content_html = C.content), C.description && (S.summary = C.description), (C.date || C.pubDate) && (S.date_published = C.date || C.pubDate), C._imageMetadata && C._hasImage) {
1981
+ const D = C._imageMetadata;
1982
+ if (S.image = D.url, S.attachments || (S.attachments = []), S.attachments.push({
1983
+ url: D.url,
1984
+ mime_type: D.mimeType || "image/jpeg",
1985
+ size_in_bytes: D.size,
1986
+ title: C.title || "Image"
1987
+ }), D.url && S.content_html && !S.content_html.includes(D.url)) {
1988
+ const k = `<img src="${D.url}" alt="${C.title || ""}"${D.width ? ` width="${D.width}"` : ""}${D.height ? ` height="${D.height}"` : ""} />`;
1989
+ S.content_html = `${k}
1990
+ ${S.content_html}`;
1807
1991
  }
1808
1992
  }
1809
- return D;
1993
+ return S;
1810
1994
  })
1811
- }, u = Ke(l);
1812
- return Promise.resolve(typeof u == "string" ? u : JSON.stringify(u));
1995
+ }, m = ot(u);
1996
+ return Promise.resolve(typeof m == "string" ? m : JSON.stringify(m));
1813
1997
  }
1814
1998
  case "rss":
1815
1999
  default: {
1816
- const y = {
1817
- title: p,
1818
- link: E.siteUrl,
1819
- description: E.description,
1820
- links: C.length ? C.map((l) => ({ rel: l.rel, href: l.href, type: l.type })) : void 0,
1821
- isArchive: o ?? !1,
1822
- language: E.language,
1823
- copyright: E.copyright,
1824
- webMaster: E.author?.email,
1825
- pubDate: w,
1826
- lastBuildDate: w,
1827
- items: m.map((l) => {
1828
- const u = {
1829
- ...l
2000
+ const w = {
2001
+ title: h,
2002
+ link: T.siteUrl,
2003
+ description: T.description,
2004
+ links: y.length ? y.map((u) => ({ rel: u.rel, href: u.href, type: u.type })) : void 0,
2005
+ isArchive: r ?? !1,
2006
+ language: T.language,
2007
+ copyright: T.copyright,
2008
+ webMaster: T.author?.email,
2009
+ pubDate: g,
2010
+ lastBuildDate: g,
2011
+ items: p.map((u) => {
2012
+ const m = {
2013
+ ...u
1830
2014
  // Preserve all dynamic properties
1831
2015
  };
1832
- if (l.title && (u.title = l.title), l.link && (u.link = l.link), l.description && (u.description = l.description), (l.date || l.pubDate) && (u.pubDate = l.date || l.pubDate), l.guid ? u.guid = {
1833
- value: l.guid,
1834
- isPermaLink: typeof l.guid == "string" && (l.guid.startsWith("http://") || l.guid.startsWith("https://"))
1835
- } : l.id && (u.guid = {
1836
- value: l.id,
1837
- isPermaLink: typeof l.id == "string" && (l.id.startsWith("http://") || l.id.startsWith("https://"))
1838
- }), l._imageMetadata && l._hasImage) {
1839
- const g = l._imageMetadata;
1840
- u.enclosures = [{
1841
- url: g.url,
1842
- type: g.mimeType || "image/jpeg",
1843
- length: g.size
1844
- }];
1845
- const D = {
1846
- url: g.url,
1847
- type: g.mimeType || "image/jpeg",
1848
- medium: "image"
1849
- // image, video, audio, document
1850
- };
1851
- g.width && (D.width = g.width), g.height && (D.height = g.height), g.size && (D.fileSize = g.size), g.format && (D.format = g.format), u["media:content"] = [D];
1852
- const T = {
1853
- url: g.url
1854
- };
1855
- g.width && (T.width = g.width), g.height && (T.height = g.height), u["media:thumbnail"] = [T], l.title && (u["media:title"] = l.title);
1856
- const M = l.description || l.summary || l.title || "";
1857
- if (M && (u["media:description"] = M), l.title) {
1858
- const S = [];
1859
- l.title && S.push(...l.title.toLowerCase().split(/\s+/).filter((A) => A.length > 3)), l.description && S.push(...l.description.toLowerCase().split(/\s+/).filter((A) => A.length > 3)), S.length > 0 && (u["media:keywords"] = [...new Set(S)].slice(0, 10).join(", "));
1860
- }
1861
- if (l.authors && Array.isArray(l.authors) && l.authors.length > 0 ? u["media:credit"] = l.authors.map((S) => ({
1862
- value: S.name || S.displayName || "Unknown",
1863
- role: "author"
1864
- })) : E.author && (u["media:credit"] = [{
1865
- value: E.author.name,
1866
- role: "author"
1867
- }]), E.copyright && (u["media:copyright"] = E.copyright), e && (u["media:category"] = [{
1868
- value: e,
1869
- scheme: "http://www.schema.org/"
1870
- }]), u["media:group"] = [{
1871
- "media:content": [D],
1872
- "media:thumbnail": [T],
1873
- "media:title": l.title || "Untitled",
1874
- "media:description": M
1875
- }], g.url && l.content && !l.content.includes(g.url)) {
1876
- const S = `<img src="${g.url}" alt="${l.title || ""}"${g.width ? ` width="${g.width}"` : ""}${g.height ? ` height="${g.height}"` : ""} />`;
1877
- u["content:encoded"] = `${S}
1878
- ${l.content}`;
1879
- }
1880
- }
1881
- if (typeof l.content == "string" && l.content.trim() !== "" && u["content:encoded"] === void 0 && (u["content:encoded"] = l.content), !u.enclosures && (l.feature_image || l.featureImage || l.image)) {
1882
- const g = l.feature_image || l.featureImage || l.image, D = Ot(g);
1883
- D && (u.enclosures = [{
1884
- url: D,
1885
- type: "image/jpeg"
1886
- }]);
2016
+ u.title && (m.title = u.title), u.link && (m.link = u.link), u.description && (m.description = u.description), (u.date || u.pubDate) && (m.pubDate = u.date || u.pubDate), u.guid ? m.guid = {
2017
+ value: u.guid,
2018
+ isPermaLink: typeof u.guid == "string" && (u.guid.startsWith("http://") || u.guid.startsWith("https://"))
2019
+ } : u.id && (m.guid = {
2020
+ value: u.id,
2021
+ isPermaLink: typeof u.id == "string" && (u.id.startsWith("http://") || u.id.startsWith("https://"))
2022
+ });
2023
+ const C = en(u);
2024
+ if (C && tn(
2025
+ m,
2026
+ u,
2027
+ C,
2028
+ e,
2029
+ T.author,
2030
+ T.copyright
2031
+ ), typeof u.content == "string" && u.content.trim() !== "" && m["content:encoded"] === void 0 && (m["content:encoded"] = u.content), m.dc = {}, (u.date || u.pubDate) && (m.dc.date = u.date || u.pubDate), u.timeCreated) {
2032
+ const S = new Date(u.timeCreated * 1e3);
2033
+ m.dc.dates || (m.dc.dates = []), m.dc.dates.push(S);
1887
2034
  }
1888
- if (u.dc = {}, (l.date || l.pubDate) && (u.dc.date = l.date || l.pubDate), l.timeCreated) {
1889
- const g = new Date(l.timeCreated * 1e3);
1890
- u.dc.dates || (u.dc.dates = []), u.dc.dates.push(g);
1891
- }
1892
- return (l.seedUid || l.SeedUid) && (u.dc.identifier || (u.dc.identifier = []), u.dc.identifier.push(l.seedUid || l.SeedUid)), (l.storageTransactionId || l.storage_transaction_id) && (u.dc.identifier || (u.dc.identifier = []), u.dc.identifier.push(l.storageTransactionId || l.storage_transaction_id)), (l.import_url || l.importUrl) && (u.dc.source = l.import_url || l.importUrl), (l.seedUid || l.SeedUid) && (u.seedUid = l.seedUid || l.SeedUid), (l.storageTransactionId || l.storage_transaction_id) && (u.storageTransactionId = l.storageTransactionId || l.storage_transaction_id), l.timeCreated && (u.timeCreated = l.timeCreated), u;
2035
+ return (u.seedUid || u.SeedUid) && (m.dc.identifier || (m.dc.identifier = []), m.dc.identifier.push(u.seedUid || u.SeedUid)), (u.storageTransactionId || u.storage_transaction_id) && (m.dc.identifier || (m.dc.identifier = []), m.dc.identifier.push(u.storageTransactionId || u.storage_transaction_id)), (u.import_url || u.importUrl) && (m.dc.source = u.import_url || u.importUrl), (u.seedUid || u.SeedUid) && (m.seedUid = u.seedUid || u.SeedUid), (u.storageTransactionId || u.storage_transaction_id) && (m.storageTransactionId = u.storageTransactionId || u.storage_transaction_id), u.timeCreated && (m.timeCreated = u.timeCreated), m;
1893
2036
  })
1894
2037
  };
1895
- return Promise.resolve(Et(y));
2038
+ return Promise.resolve(Nt(w));
1896
2039
  }
1897
2040
  }
1898
2041
  };
1899
- function je(t) {
2042
+ function Xe(t) {
1900
2043
  switch (t) {
1901
2044
  case "atom":
1902
2045
  return "application/atom+xml; charset=utf-8";
@@ -1907,16 +2050,16 @@ function je(t) {
1907
2050
  return "application/rss+xml; charset=utf-8";
1908
2051
  }
1909
2052
  }
1910
- function Be(t) {
2053
+ function Je(t) {
1911
2054
  const e = t.toLowerCase();
1912
2055
  return ["rss", "atom", "json"].includes(e) ? e : null;
1913
2056
  }
1914
- function Wt(t) {
2057
+ function sn(t) {
1915
2058
  return t.charAt(0).toUpperCase() + t.slice(1);
1916
2059
  }
1917
- async function nn(t, e, n, s, r) {
1918
- const a = Be(e);
1919
- if (!a)
2060
+ async function Sn(t, e, n, s, o) {
2061
+ const i = Je(e);
2062
+ if (!i)
1920
2063
  return new Response(
1921
2064
  JSON.stringify({ error: `Invalid feed format: ${e}` }),
1922
2065
  {
@@ -1924,123 +2067,123 @@ async function nn(t, e, n, s, r) {
1924
2067
  headers: { "Content-Type": "application/json" }
1925
2068
  }
1926
2069
  );
1927
- const o = b.singular(t.toLowerCase()), i = b(o), c = G(), d = Math.max(1, r ?? 1), f = c.pageSize, p = (d - 1) * f, w = d > 1 ? { page: d } : void 0;
1928
- console.log(`Schema name: ${o}`), console.log(`Collection name: ${i}`);
1929
- const h = Oe(), C = ce();
2070
+ const r = U.singular(t.toLowerCase()), a = U(r), c = G(), l = Math.max(1, o ?? 1), d = c.pageSize, h = (l - 1) * d, g = l > 1 ? { page: l } : void 0;
2071
+ console.log(`Schema name: ${r}`), console.log(`Collection name: ${a}`);
2072
+ const f = He(), y = fe();
1930
2073
  try {
1931
- if (C.enabled) {
1932
- const S = await h.getFeedContent(o, a, w);
1933
- if (S)
1934
- return n && Le(n, S.etag) ? (console.log(`Cache hit with ETag match for ${o}:${a} - returning 304`), new Response(null, {
2074
+ if (y.enabled) {
2075
+ const A = await f.getFeedContent(r, i, g);
2076
+ if (A)
2077
+ return n && je(n, A.etag) ? (console.log(`Cache hit with ETag match for ${r}:${i} - returning 304`), new Response(null, {
1935
2078
  status: 304,
1936
2079
  headers: {
1937
- ETag: S.etag,
1938
- "Last-Modified": new Date(S.lastModified * 1e3).toUTCString(),
2080
+ ETag: A.etag,
2081
+ "Last-Modified": new Date(A.lastModified * 1e3).toUTCString(),
1939
2082
  "Cache-Control": "public, max-age=3600, s-maxage=3600, must-revalidate"
1940
2083
  }
1941
- })) : (console.log(`Cache hit for ${o}:${a}`), new Response(S.content, {
2084
+ })) : (console.log(`Cache hit for ${r}:${i}`), new Response(A.content, {
1942
2085
  status: 200,
1943
2086
  headers: {
1944
- "Content-Type": S.contentType,
1945
- ETag: S.etag,
1946
- "Last-Modified": new Date(S.lastModified * 1e3).toUTCString(),
2087
+ "Content-Type": A.contentType,
2088
+ ETag: A.etag,
2089
+ "Last-Modified": new Date(A.lastModified * 1e3).toUTCString(),
1947
2090
  "Cache-Control": "public, max-age=3600, s-maxage=3600, must-revalidate",
1948
- "X-Feed-Schema": o,
1949
- "X-Feed-Format": a,
2091
+ "X-Feed-Schema": r,
2092
+ "X-Feed-Format": i,
1950
2093
  "X-Cache": "HIT"
1951
2094
  }
1952
2095
  }));
1953
2096
  }
1954
- console.log(`Cache miss for ${o}:${a} - fetching items`);
1955
- const m = async () => {
1956
- const S = await te(o, { limit: f, skip: p });
1957
- if (C.imageMetadata?.enabled) {
1958
- const A = new ye({
1959
- gateways: C.imageMetadata.gateways,
1960
- timeout: C.imageMetadata.timeout
2097
+ console.log(`Cache miss for ${r}:${i} - fetching items`);
2098
+ const p = async () => {
2099
+ const A = await ne(r, { limit: d, skip: h });
2100
+ if (y.imageMetadata?.enabled) {
2101
+ const _ = new Ae({
2102
+ gateways: y.imageMetadata.gateways,
2103
+ timeout: y.imageMetadata.timeout
1961
2104
  });
1962
- return Ce(S, A, h);
2105
+ return Ee(A, _, f);
1963
2106
  }
1964
- return S;
1965
- }, y = C.enabled && d === 1 ? await h.withRefreshLock(o, async () => {
1966
- const S = await h.getFeedData(o);
1967
- let A;
1968
- if (S) {
1969
- console.log(`Incremental fetch: last processed timestamp: ${S.lastProcessedTimestamp}`);
1970
- const v = await te(o, { limit: f, skip: 0 }), W = h.filterNewItems(v, S.lastProcessedTimestamp);
1971
- W.length > 0 ? (console.log(`Found ${W.length} new items, merging with ${S.items.length} cached items`), A = h.mergeItems(S.items, W).slice(0, f)) : A = S.items;
2107
+ return A;
2108
+ }, w = y.enabled && l === 1 ? await f.withRefreshLock(r, async () => {
2109
+ const A = await f.getFeedData(r);
2110
+ let _;
2111
+ if (A) {
2112
+ console.log(`Incremental fetch: last processed timestamp: ${A.lastProcessedTimestamp}`);
2113
+ const v = await ne(r, { limit: d, skip: 0 }), z = f.filterNewItems(v, A.lastProcessedTimestamp);
2114
+ z.length > 0 ? (console.log(`Found ${z.length} new items, merging with ${A.items.length} cached items`), _ = f.mergeItems(A.items, z).slice(0, d)) : _ = A.items;
1972
2115
  } else {
1973
2116
  console.log("Cold cache - fetching page 1");
1974
- const v = await jt();
1975
- v && console.log(`Client initialized: ${v.isInitialized()}`), A = await te(o, { limit: f, skip: 0 }), console.log(`Found ${A.length} feed items for schema ${o}`);
2117
+ const v = await rn();
2118
+ v && console.log(`Client initialized: ${v.isInitialized()}`), _ = await ne(r, { limit: d, skip: 0 }), console.log(`Found ${_.length} feed items for schema ${r}`);
1976
2119
  }
1977
- if (C.imageMetadata?.enabled) {
1978
- const v = new ye({
1979
- gateways: C.imageMetadata.gateways,
1980
- timeout: C.imageMetadata.timeout
1981
- }), W = await Ce(A, v, h);
1982
- return await h.setFeedData(o, A), W;
2120
+ if (y.imageMetadata?.enabled) {
2121
+ const v = new Ae({
2122
+ gateways: y.imageMetadata.gateways,
2123
+ timeout: y.imageMetadata.timeout
2124
+ }), z = await Ee(_, v, f);
2125
+ return await f.setFeedData(r, _), z;
1983
2126
  }
1984
- return await h.setFeedData(o, A), A;
1985
- }) : await m(), l = `${E.feedUrl}/${i}/${a}`, u = y.length === f, g = [];
1986
- if (d === 1) {
1987
- const S = /* @__PURE__ */ new Date(), A = new Date(S.getFullYear(), S.getMonth() - 1, 1);
1988
- g.push({
2127
+ return await f.setFeedData(r, _), _;
2128
+ }) : await p(), u = `${T.feedUrl}/${a}/${i}`, m = w.length === d, C = [];
2129
+ if (l === 1) {
2130
+ const A = /* @__PURE__ */ new Date(), _ = new Date(A.getFullYear(), A.getMonth() - 1, 1);
2131
+ C.push({
1989
2132
  rel: "prev-archive",
1990
- href: `${E.feedUrl}/${i}/archive/${A.getFullYear()}/${A.getMonth() + 1}/${a}`
2133
+ href: `${T.feedUrl}/${a}/archive/${_.getFullYear()}/${_.getMonth() + 1}/${i}`
1991
2134
  });
1992
2135
  }
1993
- const T = await Ne(
1994
- y,
1995
- o,
1996
- a,
2136
+ const D = await Ge(
2137
+ w,
2138
+ r,
2139
+ i,
1997
2140
  s,
1998
2141
  {
1999
- page: d,
2000
- pageSize: f,
2001
- hasNext: u,
2002
- baseUrl: l
2142
+ page: l,
2143
+ pageSize: d,
2144
+ hasNext: m,
2145
+ baseUrl: u
2003
2146
  },
2004
- g.length ? g : void 0,
2147
+ C.length ? C : void 0,
2005
2148
  !1
2006
- ), M = je(a);
2007
- if (C.enabled) {
2008
- await h.setFeedContent(o, a, T, M, w);
2009
- const S = await h.getFeedContent(o, a, w), A = S?.etag || "", v = S?.lastModified || Math.floor(Date.now() / 1e3);
2010
- return new Response(T, {
2149
+ ), k = Xe(i);
2150
+ if (y.enabled) {
2151
+ await f.setFeedContent(r, i, D, k, g);
2152
+ const A = await f.getFeedContent(r, i, g), _ = A?.etag || "", v = A?.lastModified || Math.floor(Date.now() / 1e3);
2153
+ return new Response(D, {
2011
2154
  status: 200,
2012
2155
  headers: {
2013
- "Content-Type": M,
2014
- ETag: A,
2156
+ "Content-Type": k,
2157
+ ETag: _,
2015
2158
  "Last-Modified": new Date(v * 1e3).toUTCString(),
2016
2159
  "Cache-Control": "public, max-age=3600, s-maxage=3600, must-revalidate",
2017
- "X-Feed-Schema": o,
2018
- "X-Feed-Format": a,
2160
+ "X-Feed-Schema": r,
2161
+ "X-Feed-Format": i,
2019
2162
  "X-Cache": "MISS"
2020
2163
  }
2021
2164
  });
2022
2165
  }
2023
- return new Response(T, {
2166
+ return new Response(D, {
2024
2167
  status: 200,
2025
2168
  headers: {
2026
- "Content-Type": M,
2169
+ "Content-Type": k,
2027
2170
  "Cache-Control": "public, max-age=3600, s-maxage=3600",
2028
- "X-Feed-Schema": o,
2029
- "X-Feed-Format": a
2171
+ "X-Feed-Schema": r,
2172
+ "X-Feed-Format": i
2030
2173
  }
2031
2174
  });
2032
- } catch (m) {
2033
- if (console.error("Feed generation error:", m), C.enabled) {
2034
- const y = await h.getFeedContent(o, a, w);
2035
- if (y)
2036
- return console.log("Serving stale cache due to error"), new Response(y.content, {
2175
+ } catch (p) {
2176
+ if (console.error("Feed generation error:", p), y.enabled) {
2177
+ const w = await f.getFeedContent(r, i, g);
2178
+ if (w)
2179
+ return console.log("Serving stale cache due to error"), new Response(w.content, {
2037
2180
  status: 200,
2038
2181
  headers: {
2039
- "Content-Type": y.contentType,
2040
- ETag: y.etag,
2182
+ "Content-Type": w.contentType,
2183
+ ETag: w.etag,
2041
2184
  "Cache-Control": "public, max-age=3600, s-maxage=3600, must-revalidate",
2042
- "X-Feed-Schema": o,
2043
- "X-Feed-Format": a,
2185
+ "X-Feed-Schema": r,
2186
+ "X-Feed-Format": i,
2044
2187
  "X-Cache": "STALE",
2045
2188
  Warning: '299 - "Cache is stale"'
2046
2189
  }
@@ -2049,7 +2192,7 @@ async function nn(t, e, n, s, r) {
2049
2192
  return new Response(
2050
2193
  JSON.stringify({
2051
2194
  error: "Failed to generate feed",
2052
- message: m instanceof Error ? m.message : "Unknown error"
2195
+ message: p instanceof Error ? p.message : "Unknown error"
2053
2196
  }),
2054
2197
  {
2055
2198
  status: 500,
@@ -2058,7 +2201,7 @@ async function nn(t, e, n, s, r) {
2058
2201
  );
2059
2202
  }
2060
2203
  }
2061
- async function rn(t, e, n, s, r, a) {
2204
+ async function Dn(t, e, n, s, o, i) {
2062
2205
  if (e < 1970 || e > 2100)
2063
2206
  return new Response(
2064
2207
  JSON.stringify({ error: `Invalid year: ${e}` }),
@@ -2069,108 +2212,108 @@ async function rn(t, e, n, s, r, a) {
2069
2212
  JSON.stringify({ error: `Invalid month: ${n}` }),
2070
2213
  { status: 400, headers: { "Content-Type": "application/json" } }
2071
2214
  );
2072
- const o = Be(s);
2073
- if (!o)
2215
+ const r = Je(s);
2216
+ if (!r)
2074
2217
  return new Response(
2075
2218
  JSON.stringify({ error: `Invalid feed format: ${s}` }),
2076
2219
  { status: 400, headers: { "Content-Type": "application/json" } }
2077
2220
  );
2078
- const i = b.singular(t.toLowerCase()), c = b(i), d = { archive: { year: e, month: n } }, f = Oe(), p = ce();
2221
+ const a = U.singular(t.toLowerCase()), c = U(a), l = { archive: { year: e, month: n } }, d = He(), h = fe();
2079
2222
  try {
2080
- if (p.enabled) {
2081
- const T = await f.getFeedContent(i, o, d);
2082
- if (T)
2083
- return r && Le(r, T.etag) ? new Response(null, {
2223
+ if (h.enabled) {
2224
+ const D = await d.getFeedContent(a, r, l);
2225
+ if (D)
2226
+ return o && je(o, D.etag) ? new Response(null, {
2084
2227
  status: 304,
2085
2228
  headers: {
2086
- ETag: T.etag,
2087
- "Last-Modified": new Date(T.lastModified * 1e3).toUTCString(),
2229
+ ETag: D.etag,
2230
+ "Last-Modified": new Date(D.lastModified * 1e3).toUTCString(),
2088
2231
  "Cache-Control": "public, max-age=86400, s-maxage=86400, must-revalidate"
2089
2232
  }
2090
- }) : new Response(T.content, {
2233
+ }) : new Response(D.content, {
2091
2234
  status: 200,
2092
2235
  headers: {
2093
- "Content-Type": T.contentType,
2094
- ETag: T.etag,
2095
- "Last-Modified": new Date(T.lastModified * 1e3).toUTCString(),
2236
+ "Content-Type": D.contentType,
2237
+ ETag: D.etag,
2238
+ "Last-Modified": new Date(D.lastModified * 1e3).toUTCString(),
2096
2239
  "Cache-Control": "public, max-age=86400, s-maxage=86400, must-revalidate",
2097
- "X-Feed-Schema": i,
2098
- "X-Feed-Format": o,
2240
+ "X-Feed-Schema": a,
2241
+ "X-Feed-Format": r,
2099
2242
  "X-Cache": "HIT"
2100
2243
  }
2101
2244
  });
2102
2245
  }
2103
- const w = await mt(i, e, n), h = `${E.feedUrl}/${c}/${o}`, C = `${E.feedUrl}/${c}/archive`, m = [
2104
- { rel: "prev-archive", href: `${C}/${n === 1 ? e - 1 : e}/${n === 1 ? 12 : n - 1}/${o}` },
2105
- { rel: "current", href: h }
2106
- ], y = n === 12 ? e + 1 : e, l = n === 12 ? 1 : n + 1, u = /* @__PURE__ */ new Date();
2107
- (y < u.getFullYear() || y === u.getFullYear() && l <= u.getMonth() + 1) && m.push({ rel: "next-archive", href: `${C}/${y}/${l}/${o}` });
2108
- const g = await Ne(
2109
- w,
2110
- i,
2111
- o,
2246
+ const g = await Et(a, e, n), f = `${T.feedUrl}/${c}/${r}`, y = `${T.feedUrl}/${c}/archive`, p = [
2247
+ { rel: "prev-archive", href: `${y}/${n === 1 ? e - 1 : e}/${n === 1 ? 12 : n - 1}/${r}` },
2248
+ { rel: "current", href: f }
2249
+ ], w = n === 12 ? e + 1 : e, u = n === 12 ? 1 : n + 1, m = /* @__PURE__ */ new Date();
2250
+ (w < m.getFullYear() || w === m.getFullYear() && u <= m.getMonth() + 1) && p.push({ rel: "next-archive", href: `${y}/${w}/${u}/${r}` });
2251
+ const C = await Ge(
2252
+ g,
2112
2253
  a,
2254
+ r,
2255
+ i,
2113
2256
  void 0,
2114
- m,
2257
+ p,
2115
2258
  !0
2116
- ), D = je(o);
2117
- if (p.enabled) {
2118
- await f.setFeedContent(i, o, g, D, d);
2119
- const T = await f.getFeedContent(i, o, d), M = T?.etag || "", S = T?.lastModified || Math.floor(Date.now() / 1e3);
2120
- return new Response(g, {
2259
+ ), S = Xe(r);
2260
+ if (h.enabled) {
2261
+ await d.setFeedContent(a, r, C, S, l);
2262
+ const D = await d.getFeedContent(a, r, l), k = D?.etag || "", A = D?.lastModified || Math.floor(Date.now() / 1e3);
2263
+ return new Response(C, {
2121
2264
  status: 200,
2122
2265
  headers: {
2123
- "Content-Type": D,
2124
- ETag: M,
2125
- "Last-Modified": new Date(S * 1e3).toUTCString(),
2266
+ "Content-Type": S,
2267
+ ETag: k,
2268
+ "Last-Modified": new Date(A * 1e3).toUTCString(),
2126
2269
  "Cache-Control": "public, max-age=86400, s-maxage=86400, must-revalidate",
2127
- "X-Feed-Schema": i,
2128
- "X-Feed-Format": o,
2270
+ "X-Feed-Schema": a,
2271
+ "X-Feed-Format": r,
2129
2272
  "X-Cache": "MISS"
2130
2273
  }
2131
2274
  });
2132
2275
  }
2133
- return new Response(g, {
2276
+ return new Response(C, {
2134
2277
  status: 200,
2135
2278
  headers: {
2136
- "Content-Type": D,
2279
+ "Content-Type": S,
2137
2280
  "Cache-Control": "public, max-age=86400, s-maxage=86400",
2138
- "X-Feed-Schema": i,
2139
- "X-Feed-Format": o
2281
+ "X-Feed-Schema": a,
2282
+ "X-Feed-Format": r
2140
2283
  }
2141
2284
  });
2142
- } catch (w) {
2143
- return console.error("Archive feed generation error:", w), new Response(
2285
+ } catch (g) {
2286
+ return console.error("Archive feed generation error:", g), new Response(
2144
2287
  JSON.stringify({
2145
2288
  error: "Failed to generate archive feed",
2146
- message: w instanceof Error ? w.message : "Unknown error"
2289
+ message: g instanceof Error ? g.message : "Unknown error"
2147
2290
  }),
2148
2291
  { status: 500, headers: { "Content-Type": "application/json" } }
2149
2292
  );
2150
2293
  }
2151
2294
  }
2152
2295
  export {
2153
- nt as FEED_RICH_BODY_STORAGE_SCHEMAS,
2154
- on as classifyMediaRef,
2155
- Ne as createFeed,
2156
- tt as enrichImageSeedCloneForFeed,
2157
- Pt as feedItemRichTextContainsDataUriImage,
2158
- Rt as filterItemsByRichTextDataUriImagePolicy,
2159
- jt as getClient,
2160
- cn as getFeedItemStringField,
2161
- te as getFeedItemsBySchemaName,
2162
- mt as getFeedItemsBySchemaNameForMonth,
2163
- rn as handleArchiveFeedRequest,
2164
- nn as handleFeedRequest,
2165
- Nt as initializeSeedClient,
2296
+ dt as FEED_RICH_BODY_STORAGE_SCHEMAS,
2297
+ En as classifyMediaRef,
2298
+ Ge as createFeed,
2299
+ lt as enrichImageSeedCloneForFeed,
2300
+ qt as feedItemRichTextContainsDataUriImage,
2301
+ Zt as filterItemsByRichTextDataUriImagePolicy,
2302
+ rn as getClient,
2303
+ _n as getFeedItemStringField,
2304
+ ne as getFeedItemsBySchemaName,
2305
+ Et as getFeedItemsBySchemaNameForMonth,
2306
+ Dn as handleArchiveFeedRequest,
2307
+ Sn as handleFeedRequest,
2308
+ nn as initializeSeedClient,
2166
2309
  B as isFeedRichBodyStorageSchema,
2167
2310
  G as loadFeedConfig,
2168
- ln as normalizeFeedItemFields,
2169
- Qt as parseRssString,
2170
- xt as pickFeedItemContent,
2171
- kt as pickFeedItemDescription,
2172
- en as resetCacheManager,
2173
- dn as resolveMediaRef,
2174
- tn as teardownSeedClient
2311
+ In as normalizeFeedItemFields,
2312
+ yn as parseRssString,
2313
+ Kt as pickFeedItemContent,
2314
+ Vt as pickFeedItemDescription,
2315
+ wn as resetCacheManager,
2316
+ $n as resolveMediaRef,
2317
+ Cn as teardownSeedClient
2175
2318
  };
2176
2319
  //# sourceMappingURL=index.js.map