Walrus blob · mainnet
On-chain registration not yet visible.
The aggregator served this blob, but we couldn't locate a matching BlobRegistered event in our scan window. It may not be certified yet, or live further back than we paged.
Lifecycle data is unavailable until the blob registration is visible on-chain.
import { s as z, u as I, r as l, j as e, L as M, Z as K, S as _, M as O, C as S, X as U } from "./index-D2Aa5IqW.js";
import { A as X } from "./arrow-left-DxwzzBOA.js";
import { P as E } from "./plus-ClwFeOK9.js";
import { S as q } from "./search-BWrjsT1c.js";
import { T as F } from "./tag-B_gwl4YJ.js";
import { P as J } from "./pencil-BoDbvb7F.js";
import { T as Y } from "./trash-2-BS_D5fDN.js";
import { C as T } from "./check-DCCEq3Mm.js";
const P = "toolhub_snippets_v1";
function Z() {
try {
if (typeof crypto < "u" && crypto.randomUUID) return crypto.randomUUID();
} catch {
}
return "sn_" + Date.now().toString(36) + Math.random().toString(36).slice(2, 8);
}
function $(i) {
const s = /* @__PURE__ */ new Set(), o = [];
for (const p of i.split(",")) {
const c = p.trim();
c && !s.has(c) && (s.add(c), o.push(c));
}
return o;
}
const G = [{ id: "ex1", title: "\u30E1\u30FC\u30EB\u6328\u62F6\uFF08\u30D3\u30B8\u30CD\u30B9\uFF09", body: `\u3044\u3064\u3082\u5927\u5909\u304A\u4E16\u8A71\u306B\u306A\u3063\u3066\u304A\u308A\u307E\u3059\u3002
\u682A\u5F0F\u4F1A\u793E\u25CB\u25CB\u306E\u25B3\u25B3\u3067\u3054\u3056\u3044\u307E\u3059\u3002`, tags: ["\u30E1\u30FC\u30EB", "\u6328\u62F6"], createdAt: "", updatedAt: "" }, { id: "ex2", title: "\u30AA\u30D5\u30A3\u30B9\u4F4F\u6240", body: "\u3012100-0001 \u6771\u4EAC\u90FD\u5343\u4EE3\u7530\u533A\u5343\u4EE3\u75301-1-1 \u25CB\u25CB\u30D3\u30EB5F", tags: ["\u4F4F\u6240", "\u4F1A\u793E"], createdAt: "", updatedAt: "" }, { id: "ex3", title: "\u632F\u8FBC\u5148\u53E3\u5EA7", body: "\u25CB\u25CB\u9280\u884C \u25B3\u25B3\u652F\u5E97 \u666E\u901A 1234567 \u30AB)\u25CB\u25CB", tags: ["\u53E3\u5EA7", "\u7D4C\u7406"], createdAt: "", updatedAt: "" }, { id: "ex4", title: "\u6253\u3061\u5408\u308F\u305B\u65E5\u7A0B\u8ABF\u6574", body: `\u304A\u6253\u3061\u5408\u308F\u305B\u306E\u65E5\u7A0B\u306B\u3064\u304D\u307E\u3057\u3066\u3001\u4E0B\u8A18\u3044\u305A\u308C\u304B\u3067\u3054\u90FD\u5408\u3044\u304B\u304C\u3067\u3057\u3087\u3046\u304B\u3002
\u30FB\u3007\u6708\u3007\u65E5\uFF08\u3007\uFF0910:00\u301C
\u30FB\u3007\u6708\u3007\u65E5\uFF08\u3007\uFF0914:00\u301C`, tags: ["\u30E1\u30FC\u30EB", "\u65E5\u7A0B"], createdAt: "", updatedAt: "" }];
function Q() {
try {
const i = localStorage.getItem(z(P));
if (i === null) return [];
const s = JSON.parse(i);
return Array.isArray(s) ? s.filter((o) => o && typeof o.id == "string" && typeof o.title == "string" && typeof o.body == "string") : [];
} catch {
return [];
}
}
function B(i) {
try {
localStorage.setItem(z(P), JSON.stringify(i));
} catch (s) {
console.error("[snippet-manager] save failed", s);
}
}
async function H(i) {
try {
if (navigator.clipboard && window.isSecureContext) return await navigator.clipboard.writeText(i), true;
} catch {
}
try {
const s = document.createElement("textarea");
s.value = i, s.style.position = "fixed", s.style.opacity = "0", document.body.appendChild(s), s.focus(), s.select();
const o = document.execCommand("copy");
return document.body.removeChild(s), o;
} catch {
return false;
}
}
const A = { id: null, title: "", body: "", tagsRaw: "" };
function ne() {
const { theme: i, toggleTheme: s } = I(), [o, p] = l.useState(() => Q()), [c, k] = l.useState(""), [x, j] = l.useState(null), [n, d] = l.useState(null), [v, w] = l.useState(null), g = l.useRef(null), h = l.useRef(null);
l.useEffect(() => {
B(o);
}, [o]), l.useEffect(() => {
var _a;
(_a = g.current) == null ? void 0 : _a.focus();
}, []);
const b = (t) => {
w(t), h.current && window.clearTimeout(h.current), h.current = window.setTimeout(() => w(null), 1400);
}, N = l.useMemo(() => {
const t = /* @__PURE__ */ new Map();
for (const r of o) for (const a of r.tags) t.set(a, (t.get(a) ?? 0) + 1);
return [...t.entries()].sort((r, a) => a[1] - r[1]).map(([r]) => r);
}, [o]), m = l.useMemo(() => {
const t = c.trim().toLowerCase();
return o.filter((r) => x && !r.tags.includes(x) ? false : t ? r.title.toLowerCase().includes(t) || r.body.toLowerCase().includes(t) || r.tags.some((a) => a.toLowerCase().includes(t)) : true);
}, [o, c, x]), C = async (t) => {
const r = await H(t.body);
b(r ? "Copied!" : "\u30B3\u30D4\u30FC\u306B\u5931\u6557\u3057\u307E\u3057\u305F");
}, R = (t) => {
p((r) => r.filter((a) => a.id !== t)), b("\u524A\u9664\u3057\u307E\u3057\u305F");
}, D = () => {
if (!n) return;
const t = n.title.trim(), r = n.body;
if (!t && !r.trim()) {
d(null);
return;
}
const a = $(n.tagsRaw), y = (/* @__PURE__ */ new Date()).toISOString();
if (n.id) p((f) => f.map((u) => u.id === n.id ? { ...u, title: t, body: r, tags: a, updatedAt: y } : u)), b("\u66F4\u65B0\u3057\u307E\u3057\u305F");
else {
const f = { id: Z(), title: t, body: r, tags: a, createdAt: y, updatedAt: y };
p((u) => [f, ...u]), b("\u8FFD\u52A0\u3057\u307E\u3057\u305F");
}
d(null);
};
l.useEffect(() => {
const t = (r) => {
var _a, _b, _c, _d;
const a = document.activeElement, y = a && (a.tagName === "INPUT" || a.tagName === "TEXTAREA" || a.isContentEditable);
if ((r.metaKey || r.ctrlKey) && r.key.toLowerCase() === "k") {
r.preventDefault(), (_a = g.current) == null ? void 0 : _a.focus(), (_b = g.current) == null ? void 0 : _b.select();
return;
}
if (r.key === "/" && !y && !n) {
r.preventDefault(), (_c = g.current) == null ? void 0 : _c.focus();
return;
}
if (r.key === "Escape") {
if (n) {
d(null);
return;
}
document.activeElement === g.current && (c ? k("") : (_d = g.current) == null ? void 0 : _d.blur());
}
};
return window.addEventListener("keydown", t), () => window.removeEventListener("keydown", t);
}, [n, c]);
const L = (t) => {
t.key === "Enter" && m.length > 0 && (t.preventDefault(), C(m[0]));
};
return e.jsxs("div", { className: "min-h-screen bg-gray-50 dark:bg-[#0b0b0d] text-gray-900 dark:text-gray-100", children: [e.jsx("header", { className: "sticky top-0 z-20 backdrop-blur bg-gray-50/80 dark:bg-[#0b0b0d]/80 border-b border-gray-200 dark:border-gray-800", children: e.jsxs("div", { className: "max-w-4xl mx-auto px-4 py-3 flex items-center gap-3", children: [e.jsx(M, { to: "/", className: "p-2 -ml-2 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-800 transition-colors", title: "\u30CF\u30D6\u3078\u623B\u308B", children: e.jsx(X, { size: 18 }) }), e.jsxs("div", { className: "flex items-center gap-2 flex-1", children: [e.jsx(K, { size: 20, className: "text-amber-500" }), e.jsx("h1", { className: "font-bold tracking-tight", children: "\u5B9A\u578B\u6587\u30B9\u30C8\u30C3\u30AF" })] }), e.jsxs("button", { onClick: () => d({ ...A }), className: "flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-gray-900 dark:bg-white text-white dark:text-gray-900 text-sm font-bold hover:opacity-90 transition-opacity", children: [e.jsx(E, { size: 16 }), " \u8FFD\u52A0"] }), e.jsx("button", { onClick: s, className: "p-2 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-800 transition-colors", title: "\u30C6\u30FC\u30DE\u5207\u66FF", children: i === "dark" ? e.jsx(_, { size: 18 }) : e.jsx(O, { size: 18 }) })] }) }), e.jsxs("main", { className: "max-w-4xl mx-auto px-4 py-5", children: [e.jsxs("div", { className: "relative mb-3", children: [e.jsx(q, { size: 18, className: "absolute left-3 top-1/2 -translate-y-1/2 text-gray-400" }), e.jsx("input", { ref: g, value: c, onChange: (t) => k(t.target.value), onKeyDown: L, placeholder: "\u691C\u7D22\u2026\uFF08Enter \u3067\u5148\u982D\u3092\u30B3\u30D4\u30FC\uFF09", className: "w-full pl-10 pr-24 py-3 rounded-xl bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-800 outline-none focus:border-gray-400 dark:focus:border-gray-600 transition-colors text-[15px]" }), e.jsx("kbd", { className: "hidden sm:flex items-center gap-1 absolute right-3 top-1/2 -translate-y-1/2 text-[11px] text-gray-400 border border-gray-300 dark:border-gray-700 rounded px-1.5 py-0.5", children: "\u2318K / /" })] }), N.length > 0 && e.jsxs("div", { className: "flex flex-wrap gap-1.5 mb-5", children: [e.jsx("button", { onClick: () => j(null), className: `text-xs px-2.5 py-1 rounded-full border transition-colors ${x === null ? "bg-gray-900 dark:bg-white text-white dark:text-gray-900 border-transparent" : "border-gray-300 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:border-gray-400"}`, children: "\u3059\u3079\u3066" }), N.map((t) => e.jsxs("button", { onClick: () => j(x === t ? null : t), className: `flex items-center gap-1 text-xs px-2.5 py-1 rounded-full border transition-colors ${x === t ? "bg-amber-500 text-white border-transparent" : "border-gray-300 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:border-gray-400"}`, children: [e.jsx(F, { size: 11 }), " ", t] }, t))] }), o.length === 0 ? e.jsxs("div", { children: [e.jsxs("div", { className: "flex items-center gap-2 text-xs text-gray-500 mb-3 bg-gray-100/70 dark:bg-gray-800/50 rounded-lg px-3 py-2", children: [e.jsx(S, { size: 14, className: "opacity-60" }), e.jsxs("span", { children: ["\u3053\u308C\u306F\u4F7F\u3044\u65B9\u306E", e.jsx("span", { className: "font-bold", children: "\u4F8B" }), "\u3067\u3059\uFF08\u4FDD\u5B58\u3055\u308C\u3066\u3044\u307E\u305B\u3093\uFF09\u3002\u300C", e.jsx("span", { className: "font-bold", children: "\u8FFD\u52A0" }), "\u300D\u3067\u81EA\u5206\u306E\u5B9A\u578B\u6587\u3092\u767B\u9332\u3059\u308B\u3068\u3001\u3053\u306E\u898B\u672C\u306F\u6D88\u3048\u307E\u3059\u3002"] })] }), e.jsx("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3 select-none", children: G.map((t) => e.jsxs("div", { className: "relative rounded-xl bg-white dark:bg-gray-900 border border-dashed border-gray-300 dark:border-gray-700 p-4 opacity-60", children: [e.jsx("span", { className: "absolute top-2 right-2 text-[10px] font-bold text-gray-400 border border-gray-300 dark:border-gray-600 rounded px-1.5 py-0.5", children: "\u4F8B" }), e.jsx("h3", { className: "font-bold text-[15px] truncate pr-8", children: t.title }), e.jsx("p", { className: "mt-1.5 text-sm text-gray-600 dark:text-gray-400 whitespace-pre-wrap line-clamp-3", children: t.body }), t.tags.length > 0 && e.jsx("div", { className: "mt-2.5 flex flex-wrap gap-1", children: t.tags.map((r) => e.jsxs("span", { className: "text-[11px] text-gray-500 bg-gray-100 dark:bg-gray-800 rounded px-1.5 py-0.5", children: ["#", r] }, r)) })] }, t.id)) }), e.jsx("div", { className: "text-center mt-6", children: e.jsxs("button", { onClick: () => d({ ...A }), className: "inline-flex items-center gap-1.5 px-4 py-2 rounded-lg bg-gray-900 dark:bg-white text-white dark:text-gray-900 text-sm font-bold hover:opacity-90", children: [e.jsx(E, { size: 16 }), " \u81EA\u5206\u306E\u5B9A\u578B\u6587\u3092\u8FFD\u52A0"] }) })] }) : m.length === 0 ? e.jsxs("div", { className: "text-center py-24 text-gray-400", children: [e.jsx(S, { size: 36, className: "mx-auto mb-3 opacity-40" }), e.jsx("p", { className: "text-sm", children: "\u4E00\u81F4\u3059\u308B\u5B9A\u578B\u6587\u304C\u3042\u308A\u307E\u305B\u3093\u3002" })] }) : e.jsx("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: m.map((t, r) => e.jsxs("div", { onClick: () => C(t), className: "group relative text-left rounded-xl bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-800 p-4 cursor-pointer hover:border-amber-400 dark:hover:border-amber-500/60 hover:shadow-sm transition-all active:scale-[0.99]", title: "\u30AF\u30EA\u30C3\u30AF\u3067\u30B3\u30D4\u30FC", children: [r === 0 && c.trim() !== "" && e.jsx("span", { className: "absolute -top-2 left-3 text-[10px] font-bold bg-amber-500 text-white rounded px-1.5 py-0.5", children: "Enter" }), e.jsxs("div", { className: "flex items-start justify-between gap-2", children: [e.jsx("h3", { className: "font-bold text-[15px] truncate pr-1", children: t.title || "(\u7121\u984C)" }), e.jsxs("div", { className: "flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity shrink-0", children: [e.jsx("button", { onClick: (a) => {
a.stopPropagation(), d({ id: t.id, title: t.title, body: t.body, tagsRaw: t.tags.join(", ") });
}, className: "p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-500", title: "\u7DE8\u96C6", children: e.jsx(J, { size: 14 }) }), e.jsx("button", { onClick: (a) => {
a.stopPropagation(), R(t.id);
}, className: "p-1 rounded hover:bg-red-50 dark:hover:bg-red-900/30 text-gray-500 hover:text-red-500", title: "\u524A\u9664", children: e.jsx(Y, { size: 14 }) })] })] }), e.jsx("p", { className: "mt-1.5 text-sm text-gray-600 dark:text-gray-400 whitespace-pre-wrap line-clamp-3", children: t.body }), t.tags.length > 0 && e.jsx("div", { className: "mt-2.5 flex flex-wrap gap-1", children: t.tags.map((a) => e.jsxs("span", { className: "text-[11px] text-gray-500 dark:text-gray-500 bg-gray-100 dark:bg-gray-800 rounded px-1.5 py-0.5", children: ["#", a] }, a)) })] }, t.id)) })] }), n && e.jsx("div", { className: "fixed inset-0 z-40 flex items-end sm:items-center justify-center bg-black/50 backdrop-blur-sm p-0 sm:p-4", onClick: () => d(null), children: e.jsxs("div", { className: "w-full sm:max-w-lg bg-white dark:bg-gray-900 rounded-t-2xl sm:rounded-2xl border border-gray-200 dark:border-gray-800 shadow-2xl", onClick: (t) => t.stopPropagation(), children: [e.jsxs("div", { className: "flex items-center justify-between px-5 py-3 border-b border-gray-200 dark:border-gray-800", children: [e.jsx("h2", { className: "font-bold", children: n.id ? "\u30B9\u30CB\u30DA\u30C3\u30C8\u3092\u7DE8\u96C6" : "\u30B9\u30CB\u30DA\u30C3\u30C8\u3092\u8FFD\u52A0" }), e.jsx("button", { onClick: () => d(null), className: "p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-500", children: e.jsx(U, { size: 18 }) })] }), e.jsxs("div", { className: "p-5 space-y-3", children: [e.jsxs("div", { children: [e.jsx("label", { className: "block text-xs font-bold text-gray-500 mb-1", children: "\u30BF\u30A4\u30C8\u30EB" }), e.jsx("input", { autoFocus: true, value: n.title, onChange: (t) => d({ ...n, title: t.target.value }), placeholder: "\u4F8B\uFF1A\u30E1\u30FC\u30EB\u6328\u62F6\uFF08\u30D3\u30B8\u30CD\u30B9\uFF09", className: "w-full px-3 py-2 rounded-lg bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 outline-none focus:border-gray-400 text-sm" })] }), e.jsxs("div", { children: [e.jsx("label", { className: "block text-xs font-bold text-gray-500 mb-1", children: "\u672C\u6587\uFF08\u30B3\u30D4\u30FC\u3055\u308C\u308B\u5185\u5BB9\uFF09" }), e.jsx("textarea", { value: n.body, onChange: (t) => d({ ...n, body: t.target.value }), rows: 6, placeholder: "\u3053\u3053\u306B\u5B9A\u578B\u6587\u3092\u5165\u529B\u2026", className: "w-full px-3 py-2 rounded-lg bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 outline-none focus:border-gray-400 text-sm resize-y font-mono" })] }), e.jsxs("div", { children: [e.jsx("label", { className: "block text-xs font-bold text-gray-500 mb-1", children: "\u30BF\u30B0\uFF08\u30AB\u30F3\u30DE\u533A\u5207\u308A\uFF09" }), e.jsx("input", { value: n.tagsRaw, onChange: (t) => d({ ...n, tagsRaw: t.target.value }), placeholder: "\u4F8B\uFF1A\u30E1\u30FC\u30EB, \u6328\u62F6", className: "w-full px-3 py-2 rounded-lg bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 outline-none focus:border-gray-400 text-sm" })] })] }), e.jsxs("div", { className: "flex items-center justify-end gap-2 px-5 py-3 border-t border-gray-200 dark:border-gray-800", children: [e.jsx("button", { onClick: () => d(null), className: "px-4 py-2 rounded-lg text-sm font-bold text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800", children: "\u30AD\u30E3\u30F3\u30BB\u30EB" }), e.jsxs("button", { onClick: D, className: "flex items-center gap-1.5 px-4 py-2 rounded-lg bg-gray-900 dark:bg-white text-white dark:text-gray-900 text-sm font-bold hover:opacity-90", children: [e.jsx(T, { size: 16 }), " \u4FDD\u5B58"] })] })] }) }), v && e.jsxs("div", { className: "fixed bottom-6 left-1/2 -translate-x-1/2 z-50 flex items-center gap-2 bg-gray-900 dark:bg-white text-white dark:text-gray-900 px-4 py-2 rounded-full shadow-lg text-sm font-bold animate-[fadeIn_0.12s_ease-out]", children: [e.jsx(T, { size: 16, className: "text-green-400 dark:text-green-600" }), " ", v] })] });
}
export {
ne as default
};