@sanity/debug-live-sync-tags
1.0.131.0.14
dist/Tool-CrHhZ0Wk.js+
dist/Tool-CrHhZ0Wk.jsNew file+455
Index: package/dist/Tool-CrHhZ0Wk.js
===================================================================
--- package/dist/Tool-CrHhZ0Wk.js
+++ package/dist/Tool-CrHhZ0Wk.js
@@ -0,0 +1,455 @@
+import { Activity, Fragment, startTransition, useEffect, useState } from "react";
+import { useClient, useDataset, useProjectId } from "sanity";
+import { c } from "react/compiler-runtime";
+import "@sanity/client";
+import { Checkbox, Flex, Label, Stack } from "@sanity/ui";
+import { styled } from "styled-components";
+import { jsx, jsxs } from "react/jsx-runtime";
+const Layout = styled(Flex).withConfig({
+ displayName: "Layout",
+ componentId: "sc-5hc50s-0"
+})`height:100%;width:100%;`, Sidebar = styled(Stack).withConfig({
+ displayName: "Sidebar",
+ componentId: "sc-5hc50s-1"
+})`flex-shrink:0;width:200px;padding:16px;border-right:1px solid var(--card-border-color,#ddd);overflow-y:auto;`, Main = styled.div.withConfig({
+ displayName: "Main",
+ componentId: "sc-5hc50s-2"
+})`flex:1;min-width:0;overflow:auto;`, StyledTable = styled.table.withConfig({
+ displayName: "StyledTable",
+ componentId: "sc-5hc50s-3"
+})`width:100%;border-collapse:collapse;font-family:monospace;font-size:13px;thead{position:sticky;top:0;z-index:1;background:var(--card-bg-color,#fff);box-shadow:inset 0 -2px 0 var(--card-border-color,#ddd);}th,td{padding:4px 8px;text-align:left;vertical-align:top;white-space:nowrap;}th{font-weight:600;}`, TagGrid = styled.div.withConfig({
+ displayName: "TagGrid",
+ componentId: "sc-5hc50s-4"
+})`display:grid;grid-template-columns:auto 1fr;gap:0 12px;`;
+function EventTable(t0) {
+ let $ = c(15), { events, findResolvedTag, showTimestamp, showEventId } = t0, t1, t2;
+ if ($[0] !== events || $[1] !== findResolvedTag || $[2] !== showEventId || $[3] !== showTimestamp) {
+ t2 = Symbol.for("react.early_return_sentinel");
+ bb0: {
+ let rows = Array.from(events.values());
+ if (rows.length === 0) {
+ t2 = null;
+ break bb0;
+ }
+ let t3;
+ $[6] === showTimestamp ? t3 = $[7] : (t3 = showTimestamp && /* @__PURE__ */ jsx("th", { children: "time" }), $[6] = showTimestamp, $[7] = t3);
+ let t4;
+ $[8] === showEventId ? t4 = $[9] : (t4 = showEventId && /* @__PURE__ */ jsx("th", { children: "id" }), $[8] = showEventId, $[9] = t4);
+ let t5, t6;
+ $[10] === Symbol.for("react.memo_cache_sentinel") ? (t5 = /* @__PURE__ */ jsx("th", { children: "type" }), t6 = /* @__PURE__ */ jsx("th", { children: "tags" }), $[10] = t5, $[11] = t6) : (t5 = $[10], t6 = $[11]);
+ let t7;
+ $[12] !== t3 || $[13] !== t4 ? (t7 = /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
+ t3,
+ t4,
+ t5,
+ t6
+ ] }) }), $[12] = t3, $[13] = t4, $[14] = t7) : t7 = $[14], t1 = /* @__PURE__ */ jsxs(StyledTable, { children: [t7, /* @__PURE__ */ jsx("tbody", { children: rows.map((event, i) => {
+ let tags = "tags" in event ? event.tags : [], time = new Date(event.timestamp).toLocaleTimeString(), eventId = "id" in event ? event.id : null, bg = i % 2 == 0 ? void 0 : "color-mix(in srgb, var(--card-border-color, #ddd) 15%, transparent)";
+ return /* @__PURE__ */ jsxs("tr", {
+ style: { background: bg },
+ children: [
+ showTimestamp && /* @__PURE__ */ jsx("td", { children: time }),
+ showEventId && /* @__PURE__ */ jsx("td", { children: eventId }),
+ /* @__PURE__ */ jsx("td", {
+ style: { fontWeight: 600 },
+ children: event.type
+ }),
+ /* @__PURE__ */ jsx("td", {
+ style: { whiteSpace: "normal" },
+ children: tags.length > 0 && /* @__PURE__ */ jsx(TagGrid, { children: tags.map((tag) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
+ title: tag,
+ children: tag
+ }), /* @__PURE__ */ jsx("span", { children: findResolvedTag(tag) })] }, tag)) })
+ })
+ ]
+ }, event.timestamp);
+ }) })] });
+ }
+ $[0] = events, $[1] = findResolvedTag, $[2] = showEventId, $[3] = showTimestamp, $[4] = t1, $[5] = t2;
+ } else t1 = $[4], t2 = $[5];
+ return t2 === Symbol.for("react.early_return_sentinel") ? t1 : t2;
+}
+function Tool() {
+ let $ = c(81), t0;
+ $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = { apiVersion: "2026-03-17" }, $[0] = t0) : t0 = $[0];
+ let client = useClient(t0), projectId = useProjectId(), dataset = useDataset(), [liveEvents, setLiveEvents] = useState(_temp), [liveEventsIncludingAllDocuments, setLiveEventsIncludingAllDocuments] = useState(_temp2), t1;
+ $[1] === client.live ? t1 = $[2] : (t1 = () => {
+ let subscription = client.live.events({ tag: "debug-live-sync-tags" }).subscribe({
+ next: (event) => {
+ startTransition(() => setLiveEvents((prev) => {
+ let next = new Map(prev);
+ return next.set("id" in event ? event.id : (/* @__PURE__ */ new Date()).toJSON(), {
+ ...event,
+ timestamp: (/* @__PURE__ */ new Date()).toJSON()
+ }), next;
+ }));
+ },
+ error: console.error
+ });
+ return () => subscription.unsubscribe();
+ }, $[1] = client.live, $[2] = t1);
+ let t2;
+ $[3] === client ? t2 = $[4] : (t2 = [client], $[3] = client, $[4] = t2), useEffect(t1, t2);
+ let t3;
+ $[5] === client.live ? t3 = $[6] : (t3 = () => {
+ let subscription_0 = client.live.events({
+ tag: "debug-live-sync-tags",
+ includeDrafts: !0
+ }).subscribe({
+ next: (event_0) => {
+ startTransition(() => setLiveEventsIncludingAllDocuments((prev_0) => {
+ let next_0 = new Map(prev_0);
+ return next_0.set("id" in event_0 ? event_0.id : (/* @__PURE__ */ new Date()).toJSON(), {
+ ...event_0,
+ timestamp: (/* @__PURE__ */ new Date()).toJSON()
+ }), next_0;
+ }));
+ },
+ error: console.error
+ });
+ return () => subscription_0.unsubscribe();
+ }, $[5] = client.live, $[6] = t3);
+ let t4;
+ $[7] === client ? t4 = $[8] : (t4 = [client], $[7] = client, $[8] = t4), useEffect(t3, t4);
+ let [syncTagForEverything, setSyncTagForEverything] = useState(null), [allDocumentTypes, setAllDocumentTypes] = useState(_temp3), t5, t6;
+ $[9] === client ? (t5 = $[10], t6 = $[11]) : (t5 = () => {
+ let controller = new AbortController();
+ return client.fetch("array::unique(*._type)", {}, {
+ signal: controller.signal,
+ returnQuery: !1,
+ tag: "debug-live-sync-tags",
+ filterResponse: !1
+ }).then((t7) => {
+ let { result, syncTags } = t7;
+ controller.signal.aborted || (setSyncTagForEverything(syncTags?.[0] ?? null), setAllDocumentTypes((prev_1) => {
+ let next_1 = new Map(prev_1);
+ for (let type of result) next_1.has(type) || next_1.set(type, null);
+ return next_1;
+ }));
+ }).catch(console.error), () => controller.abort();
+ }, t6 = [client], $[9] = client, $[10] = t5, $[11] = t6), useEffect(t5, t6);
+ let [whichList, setWhichList] = useState("liveEvents"), [showTimestamp, setShowTimestamp] = useState(!0), [showEventId, setShowEventId] = useState(!1), unknownDocumentTypes;
+ if ($[12] !== allDocumentTypes) {
+ unknownDocumentTypes = [];
+ for (let [documentType, resolvedDocumentType] of allDocumentTypes.entries()) resolvedDocumentType === null && unknownDocumentTypes.push(documentType);
+ $[12] = allDocumentTypes, $[13] = unknownDocumentTypes;
+ } else unknownDocumentTypes = $[13];
+ let t7;
+ $[14] === Symbol.for("react.memo_cache_sentinel") ? (t7 = (documentType_0, resolvedDocumentType_0) => startTransition(() => setAllDocumentTypes((prev_2) => {
+ let next_2 = new Map(prev_2);
+ return next_2.set(documentType_0, resolvedDocumentType_0), next_2;
+ })), $[14] = t7) : t7 = $[14];
+ let setDocumentType = t7, findResolvedTag = function findResolvedTag(tag) {
+ if (tag === syncTagForEverything) return "any:*";
+ for (let [documentType_1, resolvedDocumentType_1] of allDocumentTypes.entries()) if (resolvedDocumentType_1 === tag) return `type:${documentType_1}`;
+ for (let [documentId, resolvedDocumentId] of documentIdToTagMap.entries()) if (resolvedDocumentId === tag) return `id:${documentId}`;
+ for (let [slug, resolvedSlug] of documentSlugToTagMap.entries()) if (resolvedSlug === tag) return `slug:${slug}`;
+ return tag;
+ }, t8;
+ $[15] === allDocumentTypes ? t8 = $[16] : (t8 = Array.from(allDocumentTypes.keys()), $[15] = allDocumentTypes, $[16] = t8);
+ let allDocumentTypesArray = t8, [t9, setDocumentIdToTagMap] = useState(_temp4), documentIdToTagMap = t9, unknownDocumentIds = [];
+ for (let [documentId_0, tag_0] of documentIdToTagMap.entries()) tag_0 === null && unknownDocumentIds.push(documentId_0);
+ let t10;
+ $[17] === setDocumentIdToTagMap ? t10 = $[18] : (t10 = (documentId_1, tag_1) => startTransition(() => setDocumentIdToTagMap((prev_3) => {
+ let next_3 = new Map(prev_3);
+ return next_3.set(documentId_1, tag_1), next_3;
+ })), $[17] = setDocumentIdToTagMap, $[18] = t10);
+ let setDocumentIdTag = t10, [t11, setDocumentSlugToTagMap] = useState(_temp5), documentSlugToTagMap = t11, unknownDocumentSlugs = [];
+ for (let [slug_0, tag_2] of documentSlugToTagMap.entries()) tag_2 === null && unknownDocumentSlugs.push(slug_0);
+ let t12;
+ $[19] === setDocumentSlugToTagMap ? t12 = $[20] : (t12 = (slug_1, tag_3) => startTransition(() => setDocumentSlugToTagMap((prev_4) => {
+ let next_4 = new Map(prev_4);
+ return next_4.set(slug_1, tag_3), next_4;
+ })), $[19] = setDocumentSlugToTagMap, $[20] = t12);
+ let setDocumentSlugTag = t12, t13;
+ $[21] !== allDocumentTypesArray || $[22] !== client || $[23] !== setDocumentIdToTagMap || $[24] !== setDocumentSlugToTagMap ? (t13 = () => {
+ if (allDocumentTypesArray.length === 0) return;
+ let listener = client.listen("*[_type in $type]", { type: allDocumentTypesArray }, {
+ events: ["mutation"],
+ includePreviousRevision: !1,
+ includeResult: !0,
+ includeAllVersions: !0,
+ includeMutations: !1,
+ tag: "debug-live-sync-tags"
+ }).subscribe({
+ next: (event_1) => {
+ startTransition(() => {
+ setDocumentIdToTagMap((prev_5) => {
+ if (prev_5.has(event_1.documentId)) return prev_5;
+ let next_5 = new Map(prev_5);
+ return next_5.set(event_1.documentId, null), next_5;
+ });
+ let slugField = event_1.result?.slug, slug_2 = slugField && typeof slugField == "object" && "current" in slugField && typeof slugField.current == "string" ? slugField.current : null;
+ slug_2 && setDocumentSlugToTagMap((prev_6) => {
+ if (prev_6.has(slug_2)) return prev_6;
+ let next_6 = new Map(prev_6);
+ return next_6.set(slug_2, null), next_6;
+ });
+ });
+ },
+ error: console.error
+ });
+ return () => listener.unsubscribe();
+ }, $[21] = allDocumentTypesArray, $[22] = client, $[23] = setDocumentIdToTagMap, $[24] = setDocumentSlugToTagMap, $[25] = t13) : t13 = $[25];
+ let t14;
+ $[26] !== allDocumentTypesArray || $[27] !== client ? (t14 = [client, allDocumentTypesArray], $[26] = allDocumentTypesArray, $[27] = client, $[28] = t14) : t14 = $[28], useEffect(t13, t14);
+ let t15 = whichList === "liveEventsIncludingAllDocuments", t16;
+ $[29] === Symbol.for("react.memo_cache_sentinel") ? (t16 = () => setWhichList(_temp6), $[29] = t16) : t16 = $[29];
+ let t17;
+ $[30] === t15 ? t17 = $[31] : (t17 = /* @__PURE__ */ jsx(Checkbox, {
+ checked: t15,
+ onChange: t16
+ }), $[30] = t15, $[31] = t17);
+ let t18;
+ $[32] === Symbol.for("react.memo_cache_sentinel") ? (t18 = /* @__PURE__ */ jsx(Label, {
+ size: 1,
+ children: "Include all documents"
+ }), $[32] = t18) : t18 = $[32];
+ let t19;
+ $[33] === t17 ? t19 = $[34] : (t19 = /* @__PURE__ */ jsxs(Flex, {
+ as: "label",
+ align: "center",
+ gap: 2,
+ children: [t17, t18]
+ }), $[33] = t17, $[34] = t19);
+ let t20;
+ $[35] === Symbol.for("react.memo_cache_sentinel") ? (t20 = () => setShowTimestamp(_temp7), $[35] = t20) : t20 = $[35];
+ let t21;
+ $[36] === showTimestamp ? t21 = $[37] : (t21 = /* @__PURE__ */ jsx(Checkbox, {
+ checked: showTimestamp,
+ onChange: t20
+ }), $[36] = showTimestamp, $[37] = t21);
+ let t22;
+ $[38] === Symbol.for("react.memo_cache_sentinel") ? (t22 = /* @__PURE__ */ jsx(Label, {
+ size: 1,
+ children: "Show timestamp"
+ }), $[38] = t22) : t22 = $[38];
+ let t23;
+ $[39] === t21 ? t23 = $[40] : (t23 = /* @__PURE__ */ jsxs(Flex, {
+ as: "label",
+ align: "center",
+ gap: 2,
+ children: [t21, t22]
+ }), $[39] = t21, $[40] = t23);
+ let t24;
+ $[41] === Symbol.for("react.memo_cache_sentinel") ? (t24 = () => setShowEventId(_temp8), $[41] = t24) : t24 = $[41];
+ let t25;
+ $[42] === showEventId ? t25 = $[43] : (t25 = /* @__PURE__ */ jsx(Checkbox, {
+ checked: showEventId,
+ onChange: t24
+ }), $[42] = showEventId, $[43] = t25);
+ let t26;
+ $[44] === Symbol.for("react.memo_cache_sentinel") ? (t26 = /* @__PURE__ */ jsx(Label, {
+ size: 1,
+ children: "Show event ID"
+ }), $[44] = t26) : t26 = $[44];
+ let t27;
+ $[45] === t25 ? t27 = $[46] : (t27 = /* @__PURE__ */ jsxs(Flex, {
+ as: "label",
+ align: "center",
+ gap: 2,
+ children: [t25, t26]
+ }), $[45] = t25, $[46] = t27);
+ let t28;
+ $[47] !== t19 || $[48] !== t23 || $[49] !== t27 ? (t28 = /* @__PURE__ */ jsxs(Sidebar, {
+ gap: 4,
+ children: [
+ t19,
+ t23,
+ t27
+ ]
+ }), $[47] = t19, $[48] = t23, $[49] = t27, $[50] = t28) : t28 = $[50];
+ let t29 = whichList === "liveEvents" ? "visible" : "hidden", t30;
+ $[51] !== findResolvedTag || $[52] !== liveEvents || $[53] !== showEventId || $[54] !== showTimestamp ? (t30 = /* @__PURE__ */ jsx(EventTable, {
+ events: liveEvents,
+ findResolvedTag,
+ showTimestamp,
+ showEventId
+ }), $[51] = findResolvedTag, $[52] = liveEvents, $[53] = showEventId, $[54] = showTimestamp, $[55] = t30) : t30 = $[55];
+ let t31;
+ $[56] !== t29 || $[57] !== t30 ? (t31 = /* @__PURE__ */ jsx(Activity, {
+ mode: t29,
+ children: t30
+ }), $[56] = t29, $[57] = t30, $[58] = t31) : t31 = $[58];
+ let t32 = whichList === "liveEventsIncludingAllDocuments" ? "visible" : "hidden", t33;
+ $[59] !== findResolvedTag || $[60] !== liveEventsIncludingAllDocuments || $[61] !== showEventId || $[62] !== showTimestamp ? (t33 = /* @__PURE__ */ jsx(EventTable, {
+ events: liveEventsIncludingAllDocuments,
+ findResolvedTag,
+ showTimestamp,
+ showEventId
+ }), $[59] = findResolvedTag, $[60] = liveEventsIncludingAllDocuments, $[61] = showEventId, $[62] = showTimestamp, $[63] = t33) : t33 = $[63];
+ let t34;
+ $[64] !== t32 || $[65] !== t33 ? (t34 = /* @__PURE__ */ jsx(Activity, {
+ mode: t32,
+ children: t33
+ }), $[64] = t32, $[65] = t33, $[66] = t34) : t34 = $[66];
+ let t35;
+ $[67] !== t31 || $[68] !== t34 ? (t35 = /* @__PURE__ */ jsxs(Main, { children: [t31, t34] }), $[67] = t31, $[68] = t34, $[69] = t35) : t35 = $[69];
+ let t36;
+ $[70] !== client || $[71] !== dataset || $[72] !== projectId || $[73] !== unknownDocumentTypes ? (t36 = unknownDocumentTypes.map((unknownDocumentType) => /* @__PURE__ */ jsx(ResolveDocumentType, {
+ projectId,
+ dataset,
+ documentType: unknownDocumentType,
+ client,
+ setDocumentType
+ }, unknownDocumentType)), $[70] = client, $[71] = dataset, $[72] = projectId, $[73] = unknownDocumentTypes, $[74] = t36) : t36 = $[74];
+ let t37 = unknownDocumentIds.map((unknownDocumentId) => /* @__PURE__ */ jsx(ResolveDocumentId, {
+ projectId,
+ dataset,
+ documentId: unknownDocumentId,
+ client,
+ setDocumentIdTag
+ }, unknownDocumentId)), t38 = unknownDocumentSlugs.map((unknownSlug) => /* @__PURE__ */ jsx(ResolveDocumentSlug, {
+ projectId,
+ dataset,
+ slug: unknownSlug,
+ client,
+ setDocumentSlugTag
+ }, unknownSlug)), t39;
+ return $[75] !== t28 || $[76] !== t35 || $[77] !== t36 || $[78] !== t37 || $[79] !== t38 ? (t39 = /* @__PURE__ */ jsxs(Layout, { children: [
+ t28,
+ t35,
+ t36,
+ t37,
+ t38
+ ] }), $[75] = t28, $[76] = t35, $[77] = t36, $[78] = t37, $[79] = t38, $[80] = t39) : t39 = $[80], t39;
+}
+function _temp8(prev_9) {
+ return !prev_9;
+}
+function _temp7(prev_8) {
+ return !prev_8;
+}
+function _temp6(prev_7) {
+ return prev_7 === "liveEvents" ? "liveEventsIncludingAllDocuments" : "liveEvents";
+}
+function _temp5() {
+ return /* @__PURE__ */ new Map();
+}
+function _temp4() {
+ return /* @__PURE__ */ new Map();
+}
+function _temp3() {
+ return /* @__PURE__ */ new Map();
+}
+function _temp2() {
+ return /* @__PURE__ */ new Map();
+}
+function _temp() {
+ return /* @__PURE__ */ new Map();
+}
+function ResolveDocumentType(t0) {
+ let $ = c(7), { projectId, dataset, documentType, client, setDocumentType } = t0, t1, t2;
+ return $[0] !== client || $[1] !== dataset || $[2] !== documentType || $[3] !== projectId || $[4] !== setDocumentType ? (t1 = () => {
+ let localStorageKey = `debug-live-sync-tags-resolved-document-type-${projectId}-${dataset}-${documentType}`, localStorageValue = localStorage.getItem(localStorageKey);
+ if (localStorageValue && typeof localStorageValue == "string") {
+ setDocumentType(documentType, localStorageValue);
+ return;
+ }
+ let controller = new AbortController();
+ return client.fetch("count(*[_type == $type])", { type: documentType }, {
+ filterResponse: !1,
+ perspective: "published",
+ returnQuery: !1,
+ resultSourceMap: !1,
+ stega: !1,
+ useCdn: !0
+ }).then((t3) => {
+ let { syncTags } = t3;
+ if (!controller.signal.aborted) {
+ if (!Array.isArray(syncTags)) throw TypeError("syncTags is not an array", { cause: {
+ syncTags,
+ documentType
+ } });
+ if (syncTags.length !== 1) throw TypeError("syncTags is not an array of exactly one item", { cause: {
+ syncTags,
+ documentType
+ } });
+ setDocumentType(documentType, syncTags[0]), localStorage.setItem(localStorageKey, syncTags[0]);
+ }
+ }), () => controller.abort();
+ }, t2 = [
+ documentType,
+ client,
+ dataset,
+ setDocumentType,
+ projectId
+ ], $[0] = client, $[1] = dataset, $[2] = documentType, $[3] = projectId, $[4] = setDocumentType, $[5] = t1, $[6] = t2) : (t1 = $[5], t2 = $[6]), useEffect(t1, t2), null;
+}
+function ResolveDocumentId(t0) {
+ let $ = c(7), { projectId, dataset, documentId, client, setDocumentIdTag } = t0, t1, t2;
+ return $[0] !== client || $[1] !== dataset || $[2] !== documentId || $[3] !== projectId || $[4] !== setDocumentIdTag ? (t1 = () => {
+ let localStorageKey = `debug-live-sync-tags-resolved-document-id-${projectId}-${dataset}-${documentId}`, localStorageValue = localStorage.getItem(localStorageKey);
+ if (localStorageValue && typeof localStorageValue == "string") {
+ setDocumentIdTag(documentId, localStorageValue);
+ return;
+ }
+ let controller = new AbortController();
+ return client.fetch("count(*[_id == $id])", { id: documentId }, {
+ filterResponse: !1,
+ returnQuery: !1,
+ resultSourceMap: !1,
+ stega: !1,
+ useCdn: !0
+ }).then((t3) => {
+ let { syncTags } = t3;
+ if (!controller.signal.aborted) {
+ if (!Array.isArray(syncTags)) throw TypeError("syncTags is not an array", { cause: {
+ syncTags,
+ documentId
+ } });
+ if (syncTags.length !== 1) throw TypeError("syncTags is not an array of exactly one item", { cause: {
+ syncTags,
+ documentId
+ } });
+ setDocumentIdTag(documentId, syncTags[0]), localStorage.setItem(localStorageKey, syncTags[0]);
+ }
+ }), () => controller.abort();
+ }, t2 = [
+ documentId,
+ client,
+ dataset,
+ setDocumentIdTag,
+ projectId
+ ], $[0] = client, $[1] = dataset, $[2] = documentId, $[3] = projectId, $[4] = setDocumentIdTag, $[5] = t1, $[6] = t2) : (t1 = $[5], t2 = $[6]), useEffect(t1, t2), null;
+}
+function ResolveDocumentSlug(t0) {
+ let $ = c(7), { projectId, dataset, slug, client, setDocumentSlugTag } = t0, t1, t2;
+ return $[0] !== client || $[1] !== dataset || $[2] !== projectId || $[3] !== setDocumentSlugTag || $[4] !== slug ? (t1 = () => {
+ let localStorageKey = `debug-live-sync-tags-resolved-document-slug-${projectId}-${dataset}-${slug}`, localStorageValue = localStorage.getItem(localStorageKey);
+ if (localStorageValue && typeof localStorageValue == "string") {
+ setDocumentSlugTag(slug, localStorageValue);
+ return;
+ }
+ let controller = new AbortController();
+ return client.fetch("count(*[slug.current == $slug])", { slug }, {
+ filterResponse: !1,
+ returnQuery: !1,
+ resultSourceMap: !1,
+ stega: !1,
+ useCdn: !0
+ }).then((t3) => {
+ let { syncTags } = t3;
+ if (!controller.signal.aborted) {
+ if (!Array.isArray(syncTags)) throw TypeError("syncTags is not an array", { cause: {
+ syncTags,
+ slug
+ } });
+ if (syncTags.length !== 1) throw TypeError("syncTags is not an array of exactly one item", { cause: {
+ syncTags,
+ slug
+ } });
+ setDocumentSlugTag(slug, syncTags[0]), localStorage.setItem(localStorageKey, syncTags[0]);
+ }
+ }), () => controller.abort();
+ }, t2 = [
+ slug,
+ client,
+ dataset,
+ setDocumentSlugTag,
+ projectId
+ ], $[0] = client, $[1] = dataset, $[2] = projectId, $[3] = setDocumentSlugTag, $[4] = slug, $[5] = t1, $[6] = t2) : (t1 = $[5], t2 = $[6]), useEffect(t1, t2), null;
+}
+export { Tool as default };
+
+//# sourceMappingURL=Tool-CrHhZ0Wk.js.map
\ No newline at end of file