@youasked/react 0.0.0-stage → 0.4.1

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 ADDED
@@ -0,0 +1,2062 @@
1
+ "use client";
2
+
3
+ // src/YouAsked.tsx
4
+ import { useCallback as useCallback2, useEffect as useEffect3, useMemo, useRef as useRef3, useState as useState3 } from "react";
5
+ import { createPortal } from "react-dom";
6
+
7
+ // src/client.ts
8
+ var YouAskedError = class extends Error {
9
+ constructor(code) {
10
+ super(code);
11
+ this.code = code;
12
+ }
13
+ };
14
+ var ANON_KEY = "youasked:anon";
15
+ var memoryAnon = null;
16
+ function randomId() {
17
+ if (typeof crypto !== "undefined" && "randomUUID" in crypto) return crypto.randomUUID();
18
+ return Math.random().toString(36).slice(2) + Math.random().toString(36).slice(2);
19
+ }
20
+ function anonId() {
21
+ try {
22
+ let id = localStorage.getItem(ANON_KEY);
23
+ if (!id) {
24
+ id = randomId();
25
+ localStorage.setItem(ANON_KEY, id);
26
+ }
27
+ return id;
28
+ } catch {
29
+ return memoryAnon ?? (memoryAnon = randomId());
30
+ }
31
+ }
32
+ function base64Url(text) {
33
+ const bytes = new TextEncoder().encode(text);
34
+ let bin = "";
35
+ for (const b of bytes) bin += String.fromCharCode(b);
36
+ return btoa(bin).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
37
+ }
38
+ function createClient({ appKey, apiUrl, user, signature }) {
39
+ const base2 = apiUrl.replace(/\/$/, "") + "/v1";
40
+ function headers(json) {
41
+ const h = { "x-youasked-key": appKey, "x-youasked-anon": anonId() };
42
+ if (user && user.id !== void 0 && user.id !== null && user.id !== "") {
43
+ h["x-youasked-user"] = base64Url(
44
+ JSON.stringify({ id: String(user.id), email: user.email ?? void 0, name: user.name ?? void 0 })
45
+ );
46
+ if (signature) h["x-youasked-sig"] = signature;
47
+ }
48
+ if (json) h["content-type"] = "application/json";
49
+ return h;
50
+ }
51
+ async function call(path, body, raw) {
52
+ const res = await fetch(base2 + path, {
53
+ method: body === void 0 && !raw ? "GET" : "POST",
54
+ headers: raw ? { ...headers(false), "content-type": raw.type } : headers(body !== void 0),
55
+ body: raw ?? (body === void 0 ? void 0 : JSON.stringify(body))
56
+ });
57
+ const data = await res.json().catch(() => ({}));
58
+ if (!res.ok) throw new YouAskedError(data.error ?? `http_${res.status}`);
59
+ return data;
60
+ }
61
+ return {
62
+ config: () => call("/config"),
63
+ list: (sort, status) => call(`/requests?sort=${sort}&status=${status}`).then((d) => d.requests),
64
+ similar: (q) => call(`/requests/similar?q=${encodeURIComponent(q)}`).then((d) => d.requests),
65
+ get: (id) => call(`/requests/${encodeURIComponent(id)}`),
66
+ create: (input) => call("/requests", input).then((d) => ({
67
+ ...d.request,
68
+ attachments: d.attachments ?? []
69
+ })),
70
+ upload: (image) => call("/uploads", void 0, image),
71
+ earlyAccess: (id) => call(`/requests/${encodeURIComponent(id)}/early-access`, {}),
72
+ whatsNewSeen: () => call("/whats-new/seen", {}),
73
+ vote: (id) => call(`/requests/${encodeURIComponent(id)}/vote`, {}),
74
+ comment: (id, body) => call(`/requests/${encodeURIComponent(id)}/comments`, { body }).then((d) => d.comment),
75
+ mine: () => call("/me/requests").then((d) => d.requests),
76
+ seen: (ids) => call("/notifications/seen", { ids })
77
+ };
78
+ }
79
+
80
+ // src/context.ts
81
+ import { createContext, useContext } from "react";
82
+ var QUIET_TOPICS = /* @__PURE__ */ new Set(["search", "locked"]);
83
+ function toRoute(o = {}) {
84
+ if (o.requestId) return { view: "detail", id: o.requestId };
85
+ const topic = o.topic?.trim() || void 0;
86
+ const placeholder = o.placeholder ?? (topic && !o.draft && !QUIET_TOPICS.has(topic) ? `What would make ${topic} better?` : void 0);
87
+ const scope = { topic, placeholder };
88
+ switch (o.view) {
89
+ case "new":
90
+ return { view: "home", draft: o.draft, focus: true, ...scope };
91
+ case "board":
92
+ return { view: "board" };
93
+ case "shipped":
94
+ return { view: "board", tab: "shipped" };
95
+ case "mine":
96
+ return { view: "mine" };
97
+ default:
98
+ return { view: "home", draft: o.draft, focus: Boolean(o.draft || topic), ...scope };
99
+ }
100
+ }
101
+ var YouAskedContext = createContext(null);
102
+ function useInternal() {
103
+ const ctx = useContext(YouAskedContext);
104
+ if (!ctx) throw new Error("YouAsked components must be rendered inside <YouAsked>\u2026</YouAsked>");
105
+ return ctx;
106
+ }
107
+ function useYouAsked() {
108
+ const { open, close, isOpen, unseenCount } = useInternal();
109
+ return { open, close, isOpen, unseenCount };
110
+ }
111
+ function openYouAsked(options) {
112
+ window.dispatchEvent(new CustomEvent("youasked:open", { detail: options ?? {} }));
113
+ }
114
+
115
+ // src/demo.ts
116
+ var MIN = 6e4;
117
+ var DAY = 24 * 60 * MIN;
118
+ var uploads = /* @__PURE__ */ new Map();
119
+ var wait = (ms = 380) => new Promise((r) => setTimeout(r, ms + Math.random() * ms * 0.5));
120
+ var WORDS = (s) => new Set(s.toLowerCase().split(/[^a-z0-9]+/).filter((w) => w.length > 2));
121
+ function createDemoClient(appName = "Acme") {
122
+ const t0 = Date.now();
123
+ let seq = 100;
124
+ const listeners = /* @__PURE__ */ new Set();
125
+ const answered = /* @__PURE__ */ new Set();
126
+ const seed = (n, title, body, votes, status, extra = {}) => ({
127
+ id: `demo_${n}`,
128
+ number: n,
129
+ title,
130
+ body,
131
+ status,
132
+ votes,
133
+ comments: extra.comments_?.length ?? 0,
134
+ shipNote: null,
135
+ shippedAt: null,
136
+ context: null,
137
+ creditName: null,
138
+ createdAt: t0 - (20 - n) * DAY,
139
+ voted: false,
140
+ mine: false,
141
+ comments_: [],
142
+ attachments_: [],
143
+ early: false,
144
+ ...extra
145
+ });
146
+ const team = (id, body, ago2) => ({ id, body, team: true, author: null, mine: false, createdAt: t0 - ago2 });
147
+ const store = [
148
+ seed(12, "Split a bill with my partner", "We share groceries and rent. Would love to tag an expense as 50/50 and see who owes who.", 14, "planned", {
149
+ comments_: [
150
+ { id: "c1", body: "Yes! Even just splitting one expense would help.", team: false, author: "Raj", mine: false, createdAt: t0 - 3 * DAY },
151
+ team("c2", "On the list for December. Would a simple \u201Cwho owes who\u201D total be enough to start?", 2 * DAY)
152
+ ]
153
+ }),
154
+ seed(13, "Monthly budget per category", "Set $400 for food and get a heads-up when I'm close.", 11, "in_progress"),
155
+ seed(7, "Dark mode for the charts", "", 8, "shipped", {
156
+ shipNote: "Charts now follow your theme. Settings \u2192 Appearance.",
157
+ shippedAt: t0 - 2 * DAY,
158
+ creditName: "Sam"
159
+ }),
160
+ seed(14, "Import my bank statement PDF", "Some of my older expenses never came through email.", 6, "open"),
161
+ seed(15, "Recurring expenses (Netflix, rent)", "", 4, "open"),
162
+ seed(16, "Widget for the home screen", "Just today's total would be enough.", 3, "open"),
163
+ seed(9, "Show which card I paid with", "", 5, "shipped", {
164
+ shipNote: "Each expense now shows the card's last 4 digits.",
165
+ shippedAt: t0 - 4 * 60 * MIN,
166
+ mine: true,
167
+ voted: true
168
+ }),
169
+ seed(17, "Export expenses to Excel", "For my accountant at tax time.", 2, "open", {
170
+ mine: true,
171
+ voted: true,
172
+ comments_: [team("c3", "Good one. Would a CSV that opens in Excel work, or do you need .xlsx?", 3 * 60 * MIN)]
173
+ })
174
+ ];
175
+ const find = (id) => store.find((r) => r.id === id);
176
+ const view = (r) => {
177
+ const { comments_, attachments_, early, ...rest } = r;
178
+ void comments_, attachments_, early;
179
+ return { ...rest, comments: r.comments_.length };
180
+ };
181
+ const notify = (n) => listeners.forEach((fn) => fn(n));
182
+ const teamReplies = [
183
+ "Thanks, this is useful. We've added it to the board. Roughly how often would you use it?",
184
+ "Love this one. Can you tell us what you do today instead?",
185
+ "Noted! The more votes it gets, the sooner it moves up."
186
+ ];
187
+ const scheduleReply = (r, delay) => {
188
+ if (answered.has(r.id)) return;
189
+ answered.add(r.id);
190
+ setTimeout(() => {
191
+ const c = team(`demo_c${++seq}`, teamReplies[seq % teamReplies.length], 0);
192
+ c.createdAt = Date.now();
193
+ r.comments_.push(c);
194
+ notify({ id: `demo_n${++seq}`, kind: "reply", requestId: r.id, title: r.title, shipNote: null, reply: c.body });
195
+ }, delay);
196
+ };
197
+ const shippedMine = store.filter((r) => r.status === "shipped");
198
+ const config = {
199
+ app: { name: appName },
200
+ watermark: false,
201
+ identified: true,
202
+ canCredit: true,
203
+ unseen: [],
204
+ whatsNew: {
205
+ total: shippedMine.length,
206
+ items: [...shippedMine].sort((a, b) => Number(b.mine) - Number(a.mine) || (b.shippedAt ?? 0) - (a.shippedAt ?? 0)).map((r) => ({ id: r.id, title: r.title, shipNote: r.shipNote, shippedAt: r.shippedAt ?? t0, mine: r.mine }))
207
+ }
208
+ };
209
+ return {
210
+ onNotice(fn) {
211
+ listeners.add(fn);
212
+ return () => listeners.delete(fn);
213
+ },
214
+ async config() {
215
+ await wait(200);
216
+ return config;
217
+ },
218
+ async list(sort, status) {
219
+ await wait();
220
+ const active = ["open", "planned", "in_progress"];
221
+ const rows = store.filter((r) => status === "all" ? true : status === "shipped" ? r.status === "shipped" : active.includes(r.status));
222
+ rows.sort(
223
+ (a, b) => status === "shipped" ? (b.shippedAt ?? 0) - (a.shippedAt ?? 0) : sort === "new" ? b.createdAt - a.createdAt : b.votes - a.votes || b.createdAt - a.createdAt
224
+ );
225
+ return rows.map(view);
226
+ },
227
+ async similar(q) {
228
+ await wait(250);
229
+ const words = WORDS(q);
230
+ if (!words.size) return [];
231
+ return store.filter((r) => r.status !== "declined").map((r) => ({ r, hits: [...WORDS(r.title)].filter((w) => words.has(w)).length })).filter((x) => x.hits >= 2 || x.hits === 1 && WORDS(x.r.title).size <= 2).sort((a, b) => b.hits - a.hits).slice(0, 3).map((x) => view(x.r));
232
+ },
233
+ async get(id) {
234
+ await wait();
235
+ const r = find(id);
236
+ if (!r) throw new YouAskedError("not_found");
237
+ return { request: view(r), comments: [...r.comments_], attachments: [...r.attachments_], earlyAccess: r.early };
238
+ },
239
+ async create(input) {
240
+ await wait(650);
241
+ const r = {
242
+ id: `demo_${++seq}`,
243
+ number: 20 + store.length,
244
+ title: input.title,
245
+ body: input.body === input.title ? "" : input.body,
246
+ status: "open",
247
+ votes: 1,
248
+ comments: 0,
249
+ shipNote: null,
250
+ shippedAt: null,
251
+ context: input.context ?? null,
252
+ creditName: null,
253
+ createdAt: Date.now(),
254
+ voted: true,
255
+ mine: true,
256
+ comments_: [],
257
+ attachments_: (input.attachments ?? []).map((id) => uploads.get(id)).filter(Boolean),
258
+ early: false
259
+ };
260
+ store.unshift(r);
261
+ scheduleReply(r, 5200);
262
+ return { ...view(r), attachments: r.attachments_ };
263
+ },
264
+ async upload(image) {
265
+ await wait(300);
266
+ const id = `demo_up${++seq}`;
267
+ const a = { id, url: URL.createObjectURL(image) };
268
+ uploads.set(id, a);
269
+ return a;
270
+ },
271
+ async vote(id) {
272
+ await wait(180);
273
+ const r = find(id);
274
+ r.voted = !r.voted;
275
+ r.votes += r.voted ? 1 : -1;
276
+ return { voted: r.voted, votes: r.votes };
277
+ },
278
+ async comment(id, body) {
279
+ await wait(300);
280
+ const r = find(id);
281
+ const c = { id: `demo_c${++seq}`, body, team: false, author: "You", mine: true, createdAt: Date.now() };
282
+ r.comments_.push(c);
283
+ if (r.mine) scheduleReply(r, 3800);
284
+ return c;
285
+ },
286
+ async earlyAccess(id) {
287
+ await wait(200);
288
+ const r = find(id);
289
+ r.early = !r.early;
290
+ return { earlyAccess: r.early };
291
+ },
292
+ async mine() {
293
+ await wait();
294
+ return store.filter((r) => r.mine || r.voted).map(view);
295
+ },
296
+ async seen() {
297
+ return { ok: true };
298
+ },
299
+ async whatsNewSeen() {
300
+ return { ok: true };
301
+ }
302
+ };
303
+ }
304
+
305
+ // src/icons.tsx
306
+ import { jsx, jsxs } from "react/jsx-runtime";
307
+ var base = {
308
+ viewBox: "0 0 24 24",
309
+ fill: "none",
310
+ stroke: "currentColor",
311
+ strokeWidth: 2.2,
312
+ strokeLinecap: "round",
313
+ strokeLinejoin: "round",
314
+ "aria-hidden": true
315
+ };
316
+ var IconUp = () => /* @__PURE__ */ jsx("svg", { ...base, strokeWidth: 2.6, children: /* @__PURE__ */ jsx("path", { d: "m6 15 6-6 6 6" }) });
317
+ var IconClose = () => /* @__PURE__ */ jsx("svg", { ...base, width: 20, height: 20, children: /* @__PURE__ */ jsx("path", { d: "M18 6 6 18M6 6l12 12" }) });
318
+ var IconBack = () => /* @__PURE__ */ jsx("svg", { ...base, width: 20, height: 20, children: /* @__PURE__ */ jsx("path", { d: "M15 18l-6-6 6-6" }) });
319
+ var IconChevron = () => /* @__PURE__ */ jsx("svg", { ...base, width: 18, height: 18, children: /* @__PURE__ */ jsx("path", { d: "m9 18 6-6-6-6" }) });
320
+ var IconPlus = () => /* @__PURE__ */ jsx("svg", { ...base, children: /* @__PURE__ */ jsx("path", { d: "M12 5v14M5 12h14" }) });
321
+ var IconCheck = () => /* @__PURE__ */ jsx("svg", { ...base, width: 13, height: 13, strokeWidth: 3, children: /* @__PURE__ */ jsx("path", { d: "M20 6 9 17l-5-5" }) });
322
+ var IconChat = () => /* @__PURE__ */ jsx("svg", { ...base, children: /* @__PURE__ */ jsx("path", { d: "M21 12a8 8 0 0 1-11.6 7.1L4 20l1-4.6A8 8 0 1 1 21 12Z" }) });
323
+ var IconSend = () => /* @__PURE__ */ jsx("svg", { ...base, strokeWidth: 2.6, children: /* @__PURE__ */ jsx("path", { d: "M12 19V5M5 12l7-7 7 7" }) });
324
+ var IconFrame = () => /* @__PURE__ */ jsxs("svg", { ...base, children: [
325
+ /* @__PURE__ */ jsx("path", { d: "M4 9V6a2 2 0 0 1 2-2h3M15 4h3a2 2 0 0 1 2 2v3M20 15v3a2 2 0 0 1-2 2h-3M9 20H6a2 2 0 0 1-2-2v-3" }),
326
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "2.2", fill: "currentColor", strokeWidth: 1 })
327
+ ] });
328
+ var IconSpark = () => /* @__PURE__ */ jsxs("svg", { ...base, children: [
329
+ /* @__PURE__ */ jsx("path", { d: "m12 3 1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9Z" }),
330
+ /* @__PURE__ */ jsx("path", { d: "M19 16v4M17 18h4" })
331
+ ] });
332
+ var IconIdea = () => /* @__PURE__ */ jsxs("svg", { ...base, children: [
333
+ /* @__PURE__ */ jsx("path", { d: "M12 3.5c-4.97 0-9 3.47-9 7.75 0 2.3 1.17 4.37 3.03 5.8L5.2 20.5l4.1-2.06c.86.2 1.76.31 2.7.31 4.97 0 9-3.47 9-7.75S16.97 3.5 12 3.5Z" }),
334
+ /* @__PURE__ */ jsx("path", { d: "M8.2 13.2 12 9.4l3.8 3.8", strokeWidth: 2.6 })
335
+ ] });
336
+
337
+ // src/styles.ts
338
+ var css = `
339
+ .ya-scope{--_bg:var(--ya-bg);--_fg:var(--ya-fg);--_accent:var(--ya-accent);--_accent-fg:var(--ya-accent-fg);
340
+ --_muted:var(--ya-muted,color-mix(in srgb,var(--ya-fg) 58%,var(--ya-bg)));
341
+ --_surface:var(--ya-surface,color-mix(in srgb,var(--ya-fg) 5%,var(--ya-bg)));
342
+ --_border:var(--ya-border,color-mix(in srgb,var(--ya-fg) 11%,var(--ya-bg)));
343
+ --_tint:color-mix(in srgb,var(--_accent) 12%,transparent);
344
+ --_radius:var(--ya-radius,14px);--_offset:var(--ya-offset,20px);--_green:#16a34a;--_amber:#c26a04;
345
+ font-family:var(--ya-font,inherit);color:var(--_fg);font-size:15px;line-height:1.45;letter-spacing:normal;text-align:left;-webkit-font-smoothing:antialiased;-webkit-tap-highlight-color:transparent}
346
+ .ya-scope[data-ya-mode=dark]{--_green:#3fd07f;--_amber:#f2a93b}
347
+ .ya-scope :where(*,*::before,*::after){box-sizing:border-box}
348
+ /* :where() keeps the reset at class-level specificity, so component rules below win. */
349
+ .ya-scope :where(button){font:inherit;color:inherit;background:none;border:0;margin:0;padding:0;cursor:pointer;text-align:inherit;letter-spacing:inherit}
350
+ .ya-scope :where(button:disabled){cursor:default}
351
+ .ya-scope :where(h2,h3,p,ul){margin:0;padding:0}
352
+ .ya-scope :focus-visible{outline:2px solid var(--_accent);outline-offset:2px}
353
+ .ya-scope :where(svg){display:block;flex:none}
354
+ .ya-inline{display:block}
355
+ .ya-overlay[hidden]{display:none}
356
+ span.ya-inline{display:inline-block}
357
+
358
+ /* ---------- overlay: bottom sheet on phones */
359
+ .ya-overlay{position:fixed;inset:0;z-index:2147483600;display:flex;align-items:flex-end;justify-content:center}
360
+ .ya-backdrop{position:absolute;inset:0;background:rgba(8,10,20,.42);animation:ya-fade .25s ease-out}
361
+ .ya-panel{position:relative;width:100%;max-width:520px;height:min(90vh,760px);height:min(90dvh,760px);background:var(--_bg);color:var(--_fg);
362
+ border-radius:calc(var(--_radius) + 10px) calc(var(--_radius) + 10px) 0 0;box-shadow:0 -10px 40px rgba(0,0,0,.18);
363
+ display:flex;flex-direction:column;overflow:hidden;animation:ya-sheet-in .42s cubic-bezier(.2,.9,.25,1);padding-bottom:env(safe-area-inset-bottom)}
364
+ .ya-panel:focus{outline:none}
365
+ .ya-grab-zone{flex:none;padding:7px 0 0;cursor:grab;touch-action:none}
366
+ .ya-grab{width:38px;height:5px;border-radius:3px;background:color-mix(in srgb,var(--_fg) 20%,var(--_bg));margin:0 auto}
367
+ .ya-overlay[data-closing] .ya-panel{animation:ya-sheet-out .2s ease-in forwards}
368
+ .ya-overlay[data-closing] .ya-backdrop{animation:ya-fade-out .2s ease-in forwards}
369
+
370
+ /* ---------- desktop: a panel anchored to the corner, like a chat window */
371
+ @media (min-width:640px){
372
+ .ya-overlay{align-items:flex-end;justify-content:flex-end;padding:0 20px calc(var(--_offset) + env(safe-area-inset-bottom))}
373
+ .ya-overlay[data-launcher]{padding-bottom:calc(var(--_offset) + 68px + env(safe-area-inset-bottom))}
374
+ .ya-overlay[data-pos=bottom-left]{justify-content:flex-start}
375
+ .ya-backdrop{background:transparent;animation:none}
376
+ .ya-panel{width:400px;max-width:calc(100vw - 40px);height:min(680px,calc(100vh - var(--_offset) - 110px));border-radius:calc(var(--_radius) + 8px);
377
+ box-shadow:0 0 0 1px var(--_border),0 24px 70px rgba(0,0,0,.22);padding-bottom:0;transform-origin:bottom right;animation:ya-pop-in .28s cubic-bezier(.16,1,.3,1)}
378
+ .ya-overlay[data-pos=bottom-left] .ya-panel{transform-origin:bottom left}
379
+ .ya-overlay[data-closing] .ya-panel{animation:ya-pop-out .18s ease-in forwards}
380
+ .ya-grab-zone{display:none}
381
+ }
382
+
383
+ /* ---------- header */
384
+ .ya-head{display:flex;align-items:center;gap:10px;padding:12px 12px 10px 18px;flex:none;touch-action:none}
385
+ .ya-head-back{padding-left:8px}
386
+ .ya-head-text{flex:1;min-width:0}
387
+ .ya-h{font-size:17px;font-weight:700;letter-spacing:-.015em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.25}
388
+ .ya-sub{font-size:12.5px;color:var(--_muted);margin-top:1px}
389
+ .ya-icon-btn{width:34px;height:34px;border-radius:999px;display:grid;place-items:center;color:var(--_muted);flex:none;background:var(--_surface)}
390
+ .ya-icon-btn:hover{color:var(--_fg)}
391
+ .ya-head-back .ya-icon-btn:first-child{background:none}
392
+ .ya-link{display:inline-flex;align-items:center;gap:2px;font-size:14px;font-weight:600;color:var(--_accent);padding:6px 8px;border-radius:10px;flex:none}
393
+ .ya-link svg{width:15px;height:15px}
394
+ .ya-link:hover{background:var(--_tint)}
395
+ .ya-avatar{display:block;flex:none;border-radius:24%;object-fit:cover;background:var(--_surface)}
396
+
397
+ /* ---------- body, lists */
398
+ .ya-body{flex:1;min-height:0;overflow-y:auto;padding:6px 16px 18px;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}
399
+ .ya-list{list-style:none;display:flex;flex-direction:column;gap:8px}
400
+ .ya-row{display:flex;gap:12px;align-items:center;padding:10px 12px;border-radius:var(--_radius);background:var(--_surface)}
401
+ .ya-row-sm{padding:8px 10px;gap:10px}
402
+ .ya-row-main{flex:1;min-width:0;display:block;padding:2px 0}
403
+ .ya-row-title{font-weight:600;font-size:15px;line-height:1.35;overflow-wrap:anywhere;display:block}
404
+ .ya-row-sm .ya-row-title{font-size:14.5px}
405
+ .ya-meta{display:flex;align-items:center;gap:8px;margin-top:5px;font-size:12.5px;color:var(--_muted);flex-wrap:wrap}
406
+ .ya-meta svg{width:13px;height:13px}
407
+ .ya-meta span{display:inline-flex;align-items:center;gap:4px}
408
+
409
+ .ya-vote{flex:none;width:46px;padding:6px 0 5px;border-radius:calc(var(--_radius) - 4px);background:var(--_bg);border:1px solid var(--_border);display:flex;flex-direction:column;align-items:center;font-weight:700;font-size:14px;line-height:1.2;color:var(--_fg);transition:transform .12s,background .15s,border-color .15s,color .15s;font-variant-numeric:tabular-nums}
410
+ .ya-vote-sm{width:40px;padding:4px 0 3px;font-size:13px}
411
+ .ya-vote svg{width:16px;height:16px}
412
+ .ya-vote-sm svg{width:14px;height:14px}
413
+ .ya-vote:hover{border-color:var(--_accent)}
414
+ .ya-vote[aria-pressed=true]{background:var(--_accent);border-color:var(--_accent);color:var(--_accent-fg)}
415
+ .ya-vote:active,.ya-bigvote:active,.ya-btn:active,.ya-fab:active,.ya-send:active,.ya-askbar:active,.ya-pillbtn:active,.ya-iconbtn:active{transform:scale(.95)}
416
+
417
+ .ya-pill{display:inline-flex;align-items:center;gap:5px;padding:2px 8px;border-radius:999px;font-size:12px;font-weight:650;background:var(--_bg);color:var(--_muted);white-space:nowrap}
418
+ .ya-pill[data-s=planned]{background:var(--_tint);color:var(--_accent)}
419
+ .ya-pill[data-s=in_progress]{background:color-mix(in srgb,var(--_amber) 16%,transparent);color:var(--_amber)}
420
+ .ya-pill[data-s=shipped]{background:color-mix(in srgb,var(--_green) 15%,transparent);color:var(--_green)}
421
+
422
+ /* ---------- home: chat */
423
+ .ya-chat{display:flex;flex-direction:column;gap:10px;padding-top:4px}
424
+ .ya-bubble{max-width:86%;padding:10px 14px;border-radius:20px;font-size:15px;line-height:1.4;overflow-wrap:anywhere;animation:ya-bubble .3s cubic-bezier(.2,.9,.3,1.2);display:flex;flex-direction:column;gap:6px;align-items:flex-start}
425
+ .ya-bubble b{font-weight:650}
426
+ .ya-bubble-in{align-self:flex-start;background:var(--_surface);border-bottom-left-radius:6px}
427
+ .ya-bubble-out{align-self:flex-end;background:var(--_accent);color:var(--_accent-fg);border-bottom-right-radius:6px;white-space:pre-wrap}
428
+ .ya-bubble-win{background:color-mix(in srgb,var(--_green) 12%,var(--_bg))}
429
+ .ya-bubble-error{background:color-mix(in srgb,#e5484d 12%,var(--_bg))}
430
+ .ya-bubble-link{font-size:14px;font-weight:650;color:var(--_accent);padding:2px 0}
431
+ .ya-bubble-img{display:block;width:100%;max-width:220px;border-radius:12px;margin-bottom:2px;box-shadow:0 0 0 1px color-mix(in srgb,var(--_accent-fg) 25%,transparent)}
432
+ .ya-bubble-news{position:relative;align-self:stretch;max-width:100%;gap:8px}
433
+ .ya-news{list-style:none;width:100%;display:flex;flex-direction:column}
434
+ .ya-news button{display:flex;align-items:center;gap:10px;width:100%;padding:8px 0;border-top:1px solid color-mix(in srgb,var(--_fg) 9%,transparent);text-align:left}
435
+ .ya-news li:first-child button{border-top:0}
436
+ .ya-news > li > button > svg:last-child{color:var(--_muted);width:16px;height:16px}
437
+ .ya-news-text{flex:1;min-width:0;display:flex;flex-direction:column}
438
+ .ya-news-title{font-size:14.5px;font-weight:600;line-height:1.3}
439
+ .ya-news-you{font-size:12px;font-weight:650;color:var(--_green)}
440
+ /* A short burst from the corner. Hidden by default, so reduced motion (animation off) shows nothing. */
441
+ .ya-confetti{position:absolute;top:14px;right:18px;width:0;height:0;pointer-events:none}
442
+ .ya-confetti i{position:absolute;left:-3px;top:-3px;width:6px;height:9px;border-radius:2px;opacity:0;animation:ya-confetti .95s cubic-bezier(.2,.7,.3,1) both}
443
+ .ya-typing{flex-direction:row;gap:4px;padding:14px 16px}
444
+ .ya-typing span{width:7px;height:7px;border-radius:50%;background:var(--_muted);animation:ya-dot 1s infinite ease-in-out}
445
+ .ya-typing span:nth-child(2){animation-delay:.15s}
446
+ .ya-typing span:nth-child(3){animation-delay:.3s}
447
+ .ya-chip{align-self:center;margin-top:6px;font-size:13.5px;font-weight:600;color:var(--_accent);padding:8px 14px;border-radius:999px;background:var(--_tint)}
448
+ .ya-section{margin-top:12px}
449
+ .ya-section-head{display:flex;align-items:center;justify-content:space-between;margin:0 0 8px}
450
+ .ya-section-head h3{font-size:13px;font-weight:650;color:var(--_muted)}
451
+ .ya-shipped{list-style:none;display:flex;flex-direction:column}
452
+ .ya-shipped button{display:flex;align-items:center;gap:10px;width:100%;padding:9px 2px;border-bottom:1px solid var(--_border)}
453
+ .ya-shipped li:last-child button{border-bottom:0}
454
+ .ya-shipped-dot{width:22px;height:22px;border-radius:50%;display:grid;place-items:center;background:color-mix(in srgb,var(--_green) 16%,transparent);color:var(--_green);flex:none}
455
+ .ya-shipped-title{flex:1;min-width:0;font-size:14.5px;font-weight:550;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
456
+ .ya-shipped-when{font-size:12.5px;color:var(--_muted);flex:none}
457
+ .ya-note{font-size:13.5px;color:var(--_muted);margin-top:10px}
458
+
459
+ .ya-composer-wrap{flex:none;padding:8px 12px 12px;background:var(--_bg);border-top:1px solid var(--_border)}
460
+ .ya-tray{padding:10px;margin-bottom:8px;border-radius:calc(var(--_radius) + 2px);background:var(--_tint);animation:ya-tray .22s cubic-bezier(.2,.9,.3,1)}
461
+ .ya-tray-h{font-size:13px;font-weight:650;margin:0 2px 8px}
462
+ .ya-tray .ya-row{background:var(--_bg)}
463
+ .ya-composer{display:flex;align-items:flex-end;gap:8px;padding:5px 5px 5px 16px;border-radius:24px;background:var(--_surface);border:1.5px solid transparent;transition:border-color .15s}
464
+ .ya-composer:focus-within{border-color:color-mix(in srgb,var(--_accent) 55%,transparent)}
465
+ .ya-composer-bar{flex:none;margin:8px 12px 12px}
466
+ .ya-composer-input{flex:1;min-width:0;border:0;outline:none;background:none;resize:none;font:inherit;font-size:16px;line-height:1.4;color:var(--_fg);padding:7px 0;margin:0;min-height:calc(1.4em + 14px);max-height:132px;overflow-y:auto}
467
+ .ya-composer-input::placeholder{color:var(--_muted);opacity:1}
468
+ .ya-composer-input:focus-visible{outline:none}
469
+ .ya-send{width:36px;height:36px;border-radius:50%;display:grid;place-items:center;background:var(--_accent);color:var(--_accent-fg);flex:none;transition:opacity .15s,transform .12s}
470
+ .ya-send svg{width:18px;height:18px}
471
+ .ya-send:disabled{opacity:.3}
472
+ .ya-shots{list-style:none;display:flex;flex-wrap:wrap;gap:6px;margin-bottom:8px;animation:ya-tray .22s cubic-bezier(.2,.9,.3,1)}
473
+ .ya-shot{display:flex;align-items:center;gap:8px;padding:4px 4px 4px 4px;border-radius:14px;background:var(--_surface);font-size:13px;font-weight:600;max-width:100%}
474
+ .ya-shot img{display:block;width:40px;height:40px;border-radius:10px;object-fit:cover;object-position:top;flex:none;box-shadow:0 0 0 1px var(--_border)}
475
+ .ya-shot span{padding-right:2px}
476
+ .ya-shot-x{width:24px;height:24px;border-radius:50%;display:grid;place-items:center;color:var(--_muted);flex:none}
477
+ .ya-shot-x:hover{color:var(--_fg);background:var(--_border)}
478
+ .ya-shot-x svg{width:13px;height:13px}
479
+ .ya-tools{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-top:8px;min-height:32px}
480
+ .ya-tool{display:inline-flex;align-items:center;gap:6px;height:32px;padding:0 12px 0 9px;border-radius:999px;background:var(--_tint);color:var(--_accent);font-size:13.5px;font-weight:650;transition:transform .12s,opacity .15s;flex:none}
481
+ .ya-tool svg{width:16px;height:16px}
482
+ .ya-tool:disabled{opacity:.4}
483
+ .ya-tool:active{transform:scale(.96)}
484
+ .ya-switch-row{display:inline-flex;align-items:center;gap:8px;font-size:13px;font-weight:600;color:var(--_muted);padding:4px 0 4px 8px;min-width:0;animation:ya-tray .2s ease-out}
485
+ .ya-switch-row[aria-checked=true]{color:var(--_fg)}
486
+ .ya-switch{position:relative;width:34px;height:20px;border-radius:999px;background:color-mix(in srgb,var(--_fg) 18%,var(--_bg));flex:none;transition:background .18s}
487
+ .ya-switch::after{content:"";position:absolute;top:2px;left:2px;width:16px;height:16px;border-radius:50%;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.3);transition:transform .2s cubic-bezier(.3,1.3,.5,1)}
488
+ [aria-checked=true] > .ya-switch{background:var(--_accent)}
489
+ [aria-checked=true] > .ya-switch::after{transform:translateX(14px)}
490
+ .ya-mark{text-align:center;font-size:11.5px;color:var(--_muted);margin-top:8px}
491
+
492
+
493
+ .ya-bubble-kicker{font-size:12.5px;font-weight:650;color:var(--_muted)}
494
+ .ya-detail-meta{display:flex;align-items:center;gap:8px}
495
+ .ya-ref{font-size:12px;font-weight:650;color:var(--_muted);font-variant-numeric:tabular-nums;letter-spacing:.02em}
496
+ .ya-thread{display:flex;flex-direction:column;gap:12px;margin-top:8px}
497
+ .ya-msg{display:flex;gap:8px;align-items:flex-end;max-width:92%}
498
+ .ya-msg .ya-avatar{border-radius:50%;margin-bottom:2px}
499
+ .ya-msg-body{display:flex;flex-direction:column;gap:3px;min-width:0}
500
+ .ya-msg-body .ya-bubble{max-width:100%;animation:none}
501
+ .ya-msg-out{align-self:flex-end;flex-direction:column;align-items:flex-end;gap:3px}
502
+ .ya-msg-out .ya-bubble{max-width:100%;animation:none}
503
+ .ya-msg-meta{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--_muted);padding:0 4px}
504
+ .ya-msg-meta b{color:var(--_fg);font-weight:650}
505
+ /* ---------- board, detail */
506
+ .ya-tabs{display:flex;gap:2px;margin:0 16px 8px;padding:3px;background:var(--_surface);border-radius:calc(var(--_radius) - 2px);flex:none}
507
+ .ya-tab{flex:1;padding:7px 0;border-radius:calc(var(--_radius) - 5px);font-size:14px;font-weight:600;color:var(--_muted);text-align:center;transition:background .15s,color .15s}
508
+ .ya-tab[aria-selected=true]{background:var(--_bg);color:var(--_fg);box-shadow:0 1px 3px rgba(0,0,0,.1)}
509
+ .ya-foot{padding:12px 16px 14px;border-top:1px solid var(--_border);display:flex;flex-direction:column;gap:9px;flex:none;background:var(--_bg)}
510
+ .ya-btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;height:48px;padding:0 18px;border-radius:var(--_radius);background:var(--_accent);color:var(--_accent-fg);font-weight:650;font-size:15px;width:100%;transition:opacity .15s,transform .12s;white-space:nowrap}
511
+ .ya-btn svg{width:18px;height:18px}
512
+ .ya-btn:disabled{opacity:.4}
513
+ .ya-btn-sm{height:38px;width:auto;padding:0 14px;font-size:14px;border-radius:calc(var(--_radius) - 3px)}
514
+ .ya-btn-ghost{background:var(--_surface);color:var(--_fg)}
515
+ .ya-callout{display:flex;gap:10px;align-items:flex-start;padding:12px 14px;border-radius:var(--_radius);font-size:14px;margin-top:14px;line-height:1.4;background:color-mix(in srgb,var(--_green) 12%,var(--_bg))}
516
+ .ya-callout svg{width:18px;height:18px;margin-top:1px;color:var(--_green)}
517
+ .ya-callout b{font-weight:650}
518
+ .ya-detail-title{font-size:21px;font-weight:700;letter-spacing:-.015em;margin:10px 0 8px;overflow-wrap:anywhere;line-height:1.28}
519
+ .ya-text{white-space:pre-wrap;overflow-wrap:anywhere;font-size:15px;color:var(--_fg)}
520
+ .ya-text-muted{color:var(--_muted)}
521
+ .ya-bigvote{margin-top:16px;display:inline-flex;align-items:center;gap:8px;height:40px;padding:0 16px 0 12px;border-radius:999px;border:1px solid var(--_border);font-weight:650;font-size:14.5px;transition:transform .12s,background .15s,color .15s;font-variant-numeric:tabular-nums}
522
+ .ya-bigvote svg{width:17px;height:17px}
523
+ .ya-bigvote[aria-pressed=true]{background:var(--_accent);border-color:var(--_accent);color:var(--_accent-fg)}
524
+ .ya-attachments{display:flex;flex-direction:column;gap:8px;margin-top:12px}
525
+ .ya-attachments a{display:block;border-radius:var(--_radius);overflow:hidden;box-shadow:0 0 0 1px var(--_border)}
526
+ .ya-attachments img{display:block;width:100%;height:auto;max-height:340px;object-fit:cover;object-position:top}
527
+ .ya-early{display:flex;align-items:center;gap:12px;width:100%;margin-top:12px;padding:10px 14px 10px 12px;border-radius:var(--_radius);background:var(--_surface);animation:ya-tray .22s cubic-bezier(.2,.9,.3,1)}
528
+ .ya-early .ya-card-icon{width:32px;height:32px}
529
+ .ya-early[aria-checked=true] .ya-card-icon{background:var(--_accent);color:var(--_accent-fg)}
530
+ .ya-credit{display:block;margin-top:2px;color:var(--_muted)}
531
+ .ya-section-h{font-size:13px;font-weight:650;color:var(--_muted);margin:26px 0 4px}
532
+ .ya-comment{padding:11px 0;border-bottom:1px solid var(--_border)}
533
+ .ya-comment:last-child{border-bottom:0}
534
+ .ya-comment-who{display:flex;align-items:center;gap:8px;font-size:13px;font-weight:650;margin-bottom:3px}
535
+ .ya-comment-who time{font-weight:400;color:var(--_muted)}
536
+ .ya-team{font-size:11px;font-weight:700;padding:1px 7px;border-radius:999px;background:var(--_accent);color:var(--_accent-fg)}
537
+ .ya-empty{text-align:center;padding:44px 16px;color:var(--_muted)}
538
+ .ya-empty b{display:block;color:var(--_fg);font-size:16px;margin-bottom:4px}
539
+ .ya-skel{height:58px;border-radius:var(--_radius);background:var(--_surface);animation:ya-pulse 1.3s ease-in-out infinite}
540
+
541
+ /* ---------- launcher, toast */
542
+ .ya-fab{position:fixed;z-index:2147483650;bottom:calc(var(--_offset) + env(safe-area-inset-bottom));right:20px;height:56px;min-width:56px;padding:0;border-radius:999px;background:var(--_accent);color:var(--_accent-fg);display:flex;align-items:center;justify-content:center;gap:8px;font-weight:650;font-size:15px;box-shadow:0 10px 30px color-mix(in srgb,var(--_accent) 35%,rgba(0,0,0,.25));transition:transform .15s}
543
+ .ya-fab-label{padding:0 20px 0 16px}
544
+ .ya-fab-icon{display:grid;place-items:center}
545
+ .ya-fab svg{width:26px;height:26px}
546
+ .ya-fab[data-open] svg{width:22px;height:22px}
547
+ .ya-fab[data-pos=bottom-left]{right:auto;left:20px}
548
+ .ya-fab .ya-dot{position:absolute;top:4px;right:4px}
549
+ .ya-fab-label .ya-dot{position:static}
550
+ @media (max-width:639px){.ya-fab[data-open]{display:none}}
551
+ .ya-dot{width:10px;height:10px;border-radius:50%;background:#ff3b30;box-shadow:0 0 0 2px var(--_bg)}
552
+
553
+ .ya-toast{position:fixed;z-index:2147483550;right:20px;bottom:calc(var(--_offset) + 68px + env(safe-area-inset-bottom));width:min(370px,calc(100vw - 32px));background:var(--_bg);color:var(--_fg);border:1px solid var(--_border);border-radius:calc(var(--_radius) + 6px);box-shadow:0 20px 60px rgba(0,0,0,.25);padding:16px 16px 14px;animation:ya-pop .45s cubic-bezier(.34,1.36,.64,1)}
554
+ .ya-toast[data-pos=bottom-left]{right:auto;left:20px}
555
+ .ya-toast[data-trigger=none]{bottom:calc(var(--_offset) + env(safe-area-inset-bottom))}
556
+ @media (max-width:480px){.ya-toast,.ya-toast[data-pos=bottom-left]{left:16px;right:16px;width:auto}}
557
+ .ya-toast-top{display:flex;align-items:center;justify-content:space-between;gap:8px}
558
+ .ya-toast-kicker{font-size:12.5px;font-weight:650;color:var(--_muted)}
559
+ .ya-toast-title{font-size:17px;font-weight:750;letter-spacing:-.01em;margin-top:3px;overflow-wrap:anywhere;line-height:1.3}
560
+ .ya-live{display:inline-flex;align-items:center;gap:6px;font-size:14px;font-weight:700;color:var(--_green)}
561
+ .ya-toast .ya-live{margin-top:8px}
562
+ .ya-live svg{width:15px;height:15px}
563
+ .ya-toast-note{font-size:13.5px;color:var(--_muted);margin-top:6px;overflow-wrap:anywhere}
564
+ .ya-toast-actions{display:flex;gap:8px;margin-top:12px}
565
+ .ya-toast-quote{color:var(--_fg);display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}
566
+ .ya-toast .ya-icon-btn{width:30px;height:30px;margin:-6px -6px 0 0;background:none}
567
+
568
+ /* ---------- inline entry points */
569
+ .ya-askbar{display:flex;align-items:center;gap:12px;width:100%;padding:8px 8px 8px 10px;border-radius:999px;background:var(--_bg);border:1px solid var(--_border);color:var(--_muted);font-size:15.5px;text-align:left;box-shadow:0 1px 2px rgba(0,0,0,.04);transition:border-color .15s,transform .12s}
570
+ .ya-askbar:hover{border-color:color-mix(in srgb,var(--_accent) 50%,var(--_border))}
571
+ .ya-askbar .ya-avatar{border-radius:30%}
572
+ .ya-askbar-glyph{width:30px;height:30px;border-radius:50%;display:grid;place-items:center;background:var(--_tint);color:var(--_accent);flex:none}
573
+ .ya-askbar-glyph svg{width:18px;height:18px}
574
+ .ya-askbar-text{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
575
+ .ya-askbar-send{width:34px;height:34px;border-radius:50%;display:grid;place-items:center;background:var(--_accent);color:var(--_accent-fg);flex:none}
576
+ .ya-askbar-send svg{width:17px;height:17px}
577
+ .ya-badge{min-width:20px;height:20px;padding:0 6px;border-radius:999px;background:#ff3b30;color:#fff;font-size:12px;font-weight:700;display:inline-grid;place-items:center;flex:none}
578
+
579
+ .ya-card{background:var(--_bg);border-radius:calc(var(--_radius) + 6px);padding:16px;display:flex;flex-direction:column;gap:12px}
580
+ .ya-card-head{display:flex;align-items:center;gap:12px}
581
+ .ya-card-icon{width:36px;height:36px;border-radius:30%;display:grid;place-items:center;background:var(--_tint);color:var(--_accent);flex:none}
582
+ .ya-card-icon svg{width:19px;height:19px}
583
+ .ya-card-title{font-size:16px;font-weight:700;letter-spacing:-.01em}
584
+ .ya-card-sub{font-size:13px;color:var(--_muted);margin-top:1px}
585
+ .ya-card-win{display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:var(--_radius);background:color-mix(in srgb,var(--_green) 12%,var(--_bg));font-size:14px;text-align:left}
586
+ .ya-card-win > span:nth-child(2){flex:1;min-width:0}
587
+ .ya-card-win b{font-weight:650}
588
+ .ya-card-actions{display:flex;gap:8px}
589
+ .ya-card-actions .ya-btn{flex:1}
590
+
591
+ .ya-pillbtn{display:inline-flex;align-items:center;gap:8px;height:40px;padding:0 16px 0 13px;border-radius:999px;background:var(--_tint);color:var(--_accent);font-weight:650;font-size:14.5px;transition:transform .12s}
592
+ .ya-pillbtn svg{width:18px;height:18px}
593
+ .ya-pillbtn .ya-badge{margin-right:-6px}
594
+ .ya-iconbtn{position:relative;width:40px;height:40px;border-radius:50%;display:grid;place-items:center;background:var(--_surface);color:var(--_fg);transition:transform .12s}
595
+ .ya-iconbtn svg{width:21px;height:21px}
596
+ .ya-iconbtn .ya-dot{position:absolute;top:1px;right:1px;width:9px;height:9px}
597
+ .ya-menurow{display:flex;align-items:center;gap:12px;width:100%;padding:12px 14px;border-radius:var(--_radius);background:var(--_bg);text-align:left;color:var(--_fg)}
598
+ .ya-menurow > svg{color:var(--_muted);width:17px;height:17px}
599
+ .ya-menurow .ya-card-icon{width:32px;height:32px}
600
+ .ya-menurow-text{flex:1;min-width:0;display:flex;flex-direction:column}
601
+ .ya-menurow-label{font-size:15.5px;font-weight:600}
602
+ .ya-menurow-sub{font-size:13px;color:var(--_muted)}
603
+
604
+ .ya-askabout{display:inline-flex;align-items:center;gap:6px;font-size:13.5px;line-height:1.3;color:var(--_muted);padding:2px 0;border-radius:6px;text-decoration:underline;text-decoration-color:transparent;text-underline-offset:3px;transition:color .15s,text-decoration-color .15s}
605
+ .ya-askabout svg{width:14px;height:14px;color:var(--_accent)}
606
+ .ya-askabout:hover{color:var(--_fg);text-decoration-color:currentColor}
607
+ .ya-askforit{display:inline-flex;align-items:center;flex-wrap:wrap;gap:4px 8px;font-size:14.5px;color:var(--_muted);padding:4px 0;text-align:left}
608
+ .ya-askforit b{white-space:nowrap;display:inline-flex;align-items:center;gap:1px;font-weight:650;color:var(--_accent);padding:3px 6px 3px 12px;border-radius:999px;background:var(--_tint);transition:transform .12s}
609
+ .ya-askforit b svg{width:15px;height:15px}
610
+ .ya-askforit:active b{transform:scale(.96)}
611
+
612
+ /* ---------- show us: draw on the page */
613
+ .ya-capture{position:fixed;inset:0;z-index:2147483640;animation:ya-fade .18s ease-out}
614
+ .ya-capture-sample{position:absolute;color:var(--_accent);width:0;height:0;overflow:hidden}
615
+ .ya-capture-surface{position:absolute;inset:0;background:rgba(8,10,20,.2);cursor:crosshair;touch-action:none;-webkit-user-select:none;user-select:none}
616
+ .ya-capture-box{position:absolute;border:3px solid var(--_accent);border-radius:8px;background:var(--_tint);box-shadow:0 0 0 2px rgba(255,255,255,.92);pointer-events:none}
617
+ .ya-capture-hint{position:absolute;top:calc(14px + env(safe-area-inset-top));left:50%;transform:translateX(-50%);max-width:calc(100vw - 24px);white-space:nowrap;padding:9px 16px;border-radius:999px;background:var(--_bg);color:var(--_fg);font-size:14px;font-weight:650;text-align:center;box-shadow:0 6px 24px rgba(0,0,0,.25);pointer-events:none;animation:ya-pop .35s cubic-bezier(.34,1.36,.64,1)}
618
+ .ya-capture-bar{position:absolute;left:50%;transform:translateX(-50%);bottom:calc(18px + env(safe-area-inset-bottom));display:flex;gap:8px;padding:8px;border-radius:calc(var(--_radius) + 8px);background:var(--_bg);box-shadow:0 10px 40px rgba(0,0,0,.3),0 0 0 1px var(--_border)}
619
+ .ya-capture-bar .ya-btn{min-width:84px}
620
+ .ya-capture[data-busy] .ya-capture-surface{cursor:progress}
621
+
622
+ .ya-embed{position:relative;display:flex;flex-direction:column;background:var(--_bg);border-radius:calc(var(--_radius) + 6px);overflow:hidden;border:1px solid var(--_border)}
623
+
624
+ .ya-sr{position:absolute!important;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
625
+
626
+ @keyframes ya-sheet-in{from{transform:translateY(100%)}}
627
+ @keyframes ya-sheet-out{to{transform:translateY(100%)}}
628
+ @keyframes ya-pop-in{from{transform:translateY(12px) scale(.96);opacity:0}}
629
+ @keyframes ya-pop-out{to{transform:translateY(8px) scale(.97);opacity:0}}
630
+ @keyframes ya-fade{from{opacity:0}}
631
+ @keyframes ya-fade-out{to{opacity:0}}
632
+ @keyframes ya-pop{from{transform:translateY(14px) scale(.96);opacity:0}}
633
+ @keyframes ya-bubble{from{transform:translateY(8px) scale(.97);opacity:0}}
634
+ @keyframes ya-tray{from{transform:translateY(6px);opacity:0}}
635
+ @keyframes ya-dot{0%,80%,100%{transform:translateY(0);opacity:.5}40%{transform:translateY(-4px);opacity:1}}
636
+ @keyframes ya-confetti{0%{opacity:1;transform:translate(0,0) rotate(0) scale(.6)}70%{opacity:1}100%{opacity:0;transform:translate(var(--x),var(--y)) rotate(var(--r)) scale(1)}}
637
+ @keyframes ya-pulse{50%{opacity:.5}}
638
+ @media (prefers-reduced-motion:reduce){.ya-scope *{animation:none!important;transition:none!important}}
639
+ `;
640
+ function injectStyles() {
641
+ if (typeof document === "undefined") return;
642
+ let el = document.getElementById("youasked-styles");
643
+ if (!el) {
644
+ el = document.createElement("style");
645
+ el.id = "youasked-styles";
646
+ document.head.appendChild(el);
647
+ }
648
+ if (el.textContent !== css) el.textContent = css;
649
+ }
650
+
651
+ // src/theme.ts
652
+ var DEFAULTS = {
653
+ light: { accent: "#2B4BEE", background: "#ffffff", foreground: "#141B2D", radius: "14px", fontFamily: "inherit" },
654
+ dark: { accent: "#7d93ff", background: "#161d31", foreground: "#F4F6FA", radius: "14px", fontFamily: "inherit" }
655
+ };
656
+ var probe = null;
657
+ function computeColor(value) {
658
+ if (typeof document === "undefined") return null;
659
+ if (!probe) {
660
+ probe = document.createElement("span");
661
+ probe.style.cssText = "position:absolute;width:0;height:0;overflow:hidden;pointer-events:none;";
662
+ probe.setAttribute("aria-hidden", "true");
663
+ }
664
+ if (!probe.isConnected) document.body.appendChild(probe);
665
+ probe.style.color = "";
666
+ probe.style.color = value;
667
+ if (!probe.style.color) return null;
668
+ return getComputedStyle(probe).color;
669
+ }
670
+ function luminance(rgb) {
671
+ const m = rgb?.match(/rgba?\(([\d.]+)[ ,]+([\d.]+)[ ,]+([\d.]+)(?:[ ,/]+([\d.]+%?))?/);
672
+ if (!m) return null;
673
+ if (m[4] !== void 0 && parseFloat(m[4]) === 0) return null;
674
+ const [r, g, b] = [m[1], m[2], m[3]].map((v) => {
675
+ const c = parseFloat(v) / 255;
676
+ return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
677
+ });
678
+ return 0.2126 * r + 0.7152 * g + 0.0722 * b;
679
+ }
680
+ function cssColor(raw) {
681
+ const v = raw.trim();
682
+ if (!v || typeof CSS === "undefined") return void 0;
683
+ if (CSS.supports("color", v)) return v;
684
+ if (CSS.supports("color", `hsl(${v})`)) return `hsl(${v})`;
685
+ return void 0;
686
+ }
687
+ function hostIsDark() {
688
+ const html = document.documentElement;
689
+ if (html.classList.contains("dark") || html.dataset.theme === "dark") return true;
690
+ if (html.classList.contains("light") || html.dataset.theme === "light") return false;
691
+ const lum = luminance(getComputedStyle(document.body).backgroundColor) ?? luminance(getComputedStyle(html).backgroundColor);
692
+ if (lum !== null) return lum < 0.35;
693
+ return window.matchMedia?.("(prefers-color-scheme: dark)").matches ?? false;
694
+ }
695
+ function readHost() {
696
+ const root = getComputedStyle(document.documentElement);
697
+ const v = (name) => cssColor(root.getPropertyValue(name));
698
+ const radius = root.getPropertyValue("--radius").trim();
699
+ return {
700
+ accent: v("--primary"),
701
+ accentForeground: v("--primary-foreground"),
702
+ background: v("--popover") ?? v("--card") ?? v("--background"),
703
+ foreground: v("--popover-foreground") ?? v("--card-foreground") ?? v("--foreground"),
704
+ muted: v("--muted-foreground"),
705
+ surface: v("--muted") ?? v("--secondary"),
706
+ border: v("--border"),
707
+ radius: radius && CSS.supports("border-radius", radius) ? radius : void 0,
708
+ fontFamily: getComputedStyle(document.body).fontFamily || void 0
709
+ };
710
+ }
711
+ function defined(obj) {
712
+ return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== void 0 && v !== ""));
713
+ }
714
+ function resolveTokens(appearance = {}) {
715
+ const mode = appearance.mode === "dark" || appearance.mode !== "light" && hostIsDark() ? "dark" : "light";
716
+ const host = appearance.inherit === false ? {} : readHost();
717
+ const { mode: _m, inherit: _i, radius, ...colours } = appearance;
718
+ const merged = {
719
+ ...DEFAULTS[mode],
720
+ ...defined(host),
721
+ ...defined(colours),
722
+ ...radius !== void 0 ? { radius: typeof radius === "number" ? `${radius}px` : radius } : {},
723
+ mode
724
+ };
725
+ if (!merged.accentForeground) {
726
+ const lum = luminance(computeColor(merged.accent));
727
+ const onWhite = lum === null ? Infinity : 1.05 / (lum + 0.05);
728
+ const onDark = lum === null ? 0 : (lum + 0.05) / 0.056;
729
+ merged.accentForeground = onDark > onWhite ? "#0d1220" : "#ffffff";
730
+ }
731
+ return merged;
732
+ }
733
+ function tokenStyle(t) {
734
+ const style = {
735
+ "--ya-accent": t.accent,
736
+ "--ya-accent-fg": t.accentForeground ?? "#fff",
737
+ "--ya-bg": t.background,
738
+ "--ya-fg": t.foreground,
739
+ "--ya-radius": t.radius
740
+ };
741
+ if (t.fontFamily && t.fontFamily !== "inherit") style["--ya-font"] = t.fontFamily;
742
+ if (t.muted) style["--ya-muted"] = t.muted;
743
+ if (t.surface) style["--ya-surface"] = t.surface;
744
+ if (t.border) style["--ya-border"] = t.border;
745
+ return style;
746
+ }
747
+
748
+ // src/shared.tsx
749
+ import { useCallback, useEffect, useRef, useState } from "react";
750
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
751
+ function useVote(client, initial) {
752
+ const [state, setState] = useState({ voted: initial.voted, votes: initial.votes });
753
+ const busy = useRef(false);
754
+ useEffect(() => setState({ voted: initial.voted, votes: initial.votes }), [initial.voted, initial.votes]);
755
+ const toggle = useCallback(async () => {
756
+ if (busy.current) return;
757
+ busy.current = true;
758
+ const before = state;
759
+ setState({ voted: !before.voted, votes: before.votes + (before.voted ? -1 : 1) });
760
+ try {
761
+ setState(await client.vote(initial.id));
762
+ } catch {
763
+ setState(before);
764
+ } finally {
765
+ busy.current = false;
766
+ }
767
+ }, [client, initial.id, state]);
768
+ return { ...state, toggle };
769
+ }
770
+ function VoteButton({ client, request, compact }) {
771
+ const { voted, votes, toggle } = useVote(client, request);
772
+ return /* @__PURE__ */ jsxs2(
773
+ "button",
774
+ {
775
+ type: "button",
776
+ className: compact ? "ya-vote ya-vote-sm" : "ya-vote",
777
+ "aria-pressed": voted,
778
+ "aria-label": `${voted ? "Remove vote" : "Upvote"}: ${request.title}. ${votes} ${votes === 1 ? "vote" : "votes"}`,
779
+ onClick: (e) => {
780
+ e.stopPropagation();
781
+ toggle();
782
+ },
783
+ children: [
784
+ /* @__PURE__ */ jsx2(IconUp, {}),
785
+ votes
786
+ ]
787
+ }
788
+ );
789
+ }
790
+ function BigVote({
791
+ client,
792
+ request,
793
+ onChange
794
+ }) {
795
+ const { voted, votes, toggle } = useVote(client, request);
796
+ useEffect(() => onChange?.(voted), [voted, onChange]);
797
+ return /* @__PURE__ */ jsxs2("button", { type: "button", className: "ya-bigvote", "aria-pressed": voted, onClick: toggle, children: [
798
+ /* @__PURE__ */ jsx2(IconUp, {}),
799
+ voted ? "Voted" : "Upvote",
800
+ " \xB7 ",
801
+ votes
802
+ ] });
803
+ }
804
+ var STATUS_LABEL = {
805
+ open: "Open",
806
+ planned: "Planned",
807
+ in_progress: "In progress",
808
+ shipped: "Shipped",
809
+ declined: "Not planned"
810
+ };
811
+ function StatusPill({ status }) {
812
+ return /* @__PURE__ */ jsxs2("span", { className: "ya-pill", "data-s": status, children: [
813
+ status === "shipped" && /* @__PURE__ */ jsx2(IconCheck, {}),
814
+ STATUS_LABEL[status]
815
+ ] });
816
+ }
817
+ function RequestRow({
818
+ client,
819
+ request,
820
+ onOpen,
821
+ compact
822
+ }) {
823
+ return /* @__PURE__ */ jsxs2("li", { className: compact ? "ya-row ya-row-sm" : "ya-row", children: [
824
+ /* @__PURE__ */ jsx2(VoteButton, { client, request, compact }),
825
+ /* @__PURE__ */ jsxs2("button", { type: "button", className: "ya-row-main", onClick: onOpen, children: [
826
+ /* @__PURE__ */ jsx2("span", { className: "ya-row-title", children: request.title }),
827
+ (request.status !== "open" || request.comments > 0 || request.mine) && /* @__PURE__ */ jsxs2("span", { className: "ya-meta", children: [
828
+ request.status !== "open" && /* @__PURE__ */ jsx2(StatusPill, { status: request.status }),
829
+ request.comments > 0 && /* @__PURE__ */ jsxs2("span", { children: [
830
+ /* @__PURE__ */ jsx2(IconChat, {}),
831
+ request.comments
832
+ ] }),
833
+ request.mine && /* @__PURE__ */ jsx2("span", { children: "You asked" })
834
+ ] })
835
+ ] })
836
+ ] });
837
+ }
838
+ function Skeleton({ rows = 3 }) {
839
+ return /* @__PURE__ */ jsx2("div", { className: "ya-list", "aria-label": "Loading", role: "status", children: Array.from({ length: rows }, (_, i) => /* @__PURE__ */ jsx2("div", { className: "ya-skel" }, i)) });
840
+ }
841
+ function useLoad(load, deps) {
842
+ const [data, setData] = useState(null);
843
+ const [error, setError] = useState(null);
844
+ useEffect(() => {
845
+ let alive = true;
846
+ setData(null);
847
+ setError(null);
848
+ load().then((d) => alive && setData(d)).catch((e) => alive && setError(e instanceof YouAskedError ? e.code : "network"));
849
+ return () => {
850
+ alive = false;
851
+ };
852
+ }, deps);
853
+ return { data, error, setData };
854
+ }
855
+ function errorText(code) {
856
+ switch (code) {
857
+ case "signature_required":
858
+ case "bad_signature":
859
+ return "We couldn't confirm who you are. Refresh the page and try again.";
860
+ case "slow_down":
861
+ return "That's a lot of requests in an hour. Try again a bit later.";
862
+ case "title_too_short":
863
+ return "Add a few more words so others know what you mean.";
864
+ case "network":
865
+ return "Couldn't reach the server. Check your connection and try again.";
866
+ default:
867
+ return "Something went wrong. Try again.";
868
+ }
869
+ }
870
+ function whatsNewHeading(total) {
871
+ return `${total} ${total === 1 ? "thing" : "things"} shipped since your last visit`;
872
+ }
873
+ function ago(t) {
874
+ const s = Math.max(0, Math.round((Date.now() - t) / 1e3));
875
+ if (s < 60) return "just now";
876
+ const m = Math.round(s / 60);
877
+ if (m < 60) return `${m}m ago`;
878
+ const h = Math.round(m / 60);
879
+ if (h < 24) return `${h}h ago`;
880
+ const d = Math.round(h / 24);
881
+ if (d < 30) return `${d}d ago`;
882
+ return new Date(t).toLocaleDateString(void 0, { month: "short", day: "numeric" });
883
+ }
884
+ function AppAvatar({ icon, size = 36 }) {
885
+ const [failed, setFailed] = useState(false);
886
+ if (!icon || failed) return null;
887
+ return /* @__PURE__ */ jsx2(
888
+ "img",
889
+ {
890
+ className: "ya-avatar",
891
+ src: icon,
892
+ alt: "",
893
+ width: size,
894
+ height: size,
895
+ style: { width: size, height: size },
896
+ onError: () => setFailed(true)
897
+ }
898
+ );
899
+ }
900
+ function Header({
901
+ title,
902
+ subtitle,
903
+ leading,
904
+ onBack,
905
+ onClose,
906
+ right
907
+ }) {
908
+ return /* @__PURE__ */ jsxs2("div", { className: onBack ? "ya-head ya-head-back" : "ya-head", children: [
909
+ onBack && /* @__PURE__ */ jsx2("button", { type: "button", className: "ya-icon-btn", onClick: onBack, "aria-label": "Back", children: /* @__PURE__ */ jsx2(IconBack, {}) }),
910
+ leading,
911
+ /* @__PURE__ */ jsxs2("div", { className: "ya-head-text", children: [
912
+ /* @__PURE__ */ jsx2("h2", { className: "ya-h", children: title }),
913
+ subtitle && /* @__PURE__ */ jsx2("p", { className: "ya-sub", children: subtitle })
914
+ ] }),
915
+ right,
916
+ onClose && /* @__PURE__ */ jsx2("button", { type: "button", className: "ya-icon-btn", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx2(IconClose, {}) })
917
+ ] });
918
+ }
919
+
920
+ // src/views.tsx
921
+ import { useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
922
+ import { Fragment, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
923
+ function Navigator({ route, setRoute, onClose }) {
924
+ switch (route.view) {
925
+ case "home":
926
+ return /* @__PURE__ */ jsx3(Home, { route, setRoute, onClose }, `${route.draft ?? ""}${route.focus ? "f" : ""}${route.topic ?? ""}`);
927
+ case "board":
928
+ return /* @__PURE__ */ jsx3(Board, { initialTab: route.tab, setRoute, onClose });
929
+ case "detail":
930
+ return /* @__PURE__ */ jsx3(Detail, { id: route.id, setRoute, onClose }, route.id);
931
+ case "mine":
932
+ return /* @__PURE__ */ jsx3(Mine, { setRoute, onClose });
933
+ }
934
+ }
935
+ function splitMessage(text) {
936
+ const t = text.trim();
937
+ if (t.length <= 120 && !t.includes("\n")) return { title: t, body: "" };
938
+ const first = t.split("\n")[0];
939
+ const sentence = first.match(/^(.{12,120}?[.!?])\s/)?.[1];
940
+ const title = (sentence ?? first).slice(0, 120).trim();
941
+ return { title, body: t };
942
+ }
943
+ function ReplyBubble({ notice, appName, onOpen }) {
944
+ return /* @__PURE__ */ jsxs3("div", { className: "ya-bubble ya-bubble-in", children: [
945
+ /* @__PURE__ */ jsxs3("span", { className: "ya-bubble-kicker", children: [
946
+ appName,
947
+ " replied about ",
948
+ notice.title
949
+ ] }),
950
+ /* @__PURE__ */ jsx3("span", { children: notice.reply }),
951
+ /* @__PURE__ */ jsx3("button", { type: "button", className: "ya-bubble-link", onClick: onOpen, children: "Reply" })
952
+ ] });
953
+ }
954
+ var MAX_SHOTS = 3;
955
+ function Confetti() {
956
+ const colors = ["var(--_accent)", "var(--_green)", "var(--_amber)", "#ff7eb3"];
957
+ return /* @__PURE__ */ jsx3("span", { className: "ya-confetti", "aria-hidden": "true", children: Array.from({ length: 14 }, (_, i) => {
958
+ const angle = Math.PI * (0.15 + i / 13 * 0.7) % Math.PI;
959
+ const dist = 38 + i % 4 * 14;
960
+ return /* @__PURE__ */ jsx3(
961
+ "i",
962
+ {
963
+ style: {
964
+ "--x": `${Math.round(Math.cos(angle) * dist * (i % 2 ? -1 : 1))}px`,
965
+ "--y": `${Math.round(-Math.sin(angle) * dist)}px`,
966
+ "--r": `${i * 67 % 360}deg`,
967
+ background: colors[i % colors.length],
968
+ animationDelay: `${i % 5 * 40}ms`
969
+ }
970
+ },
971
+ i
972
+ );
973
+ }) });
974
+ }
975
+ function Home({ route, setRoute, onClose }) {
976
+ const { client, config, appName, appIcon, greeting, markSeen, whatsNew, dismissWhatsNew, pointAtIt } = useInternal();
977
+ const top = useLoad(() => client.list("top", "active"), [client]);
978
+ const shipped = useLoad(() => client.list("new", "shipped"), [client]);
979
+ const [text, setText] = useState2(route.draft ?? "");
980
+ const [thread, setThread] = useState2([]);
981
+ const [similar, setSimilar] = useState2([]);
982
+ const [notices] = useState2(() => config?.unseen ?? []);
983
+ const [news] = useState2(() => whatsNew);
984
+ const [shots, setShots] = useState2([]);
985
+ const [shotError, setShotError] = useState2(null);
986
+ const [credit, setCredit] = useState2(false);
987
+ const urls = useRef2([]);
988
+ const inputRef = useRef2(null);
989
+ const bodyRef = useRef2(null);
990
+ const sending = thread.some((t) => t.kind === "typing");
991
+ useEffect2(() => {
992
+ if (notices.length) markSeen(notices.map((n) => n.id));
993
+ }, [notices, markSeen]);
994
+ useEffect2(() => {
995
+ if (news) dismissWhatsNew();
996
+ }, [news, dismissWhatsNew]);
997
+ const arrived = config?.unseen.filter((n) => n.kind === "reply" && !notices.some((o) => o.id === n.id)) ?? [];
998
+ const arrivedKey = arrived.map((n) => n.id).join(",");
999
+ useEffect2(() => {
1000
+ if (!arrived.length) return;
1001
+ setThread((th) => [...th, ...arrived.map((notice) => ({ kind: "reply", notice }))]);
1002
+ markSeen(arrived.map((n) => n.id));
1003
+ }, [arrivedKey]);
1004
+ useEffect2(() => () => urls.current.forEach((u) => URL.revokeObjectURL(u)), []);
1005
+ useEffect2(() => {
1006
+ if (!route.focus) return;
1007
+ const t = setTimeout(() => {
1008
+ const el = inputRef.current;
1009
+ if (!el) return;
1010
+ el.focus();
1011
+ el.setSelectionRange(el.value.length, el.value.length);
1012
+ }, 60);
1013
+ return () => clearTimeout(t);
1014
+ }, [route.focus]);
1015
+ useEffect2(() => {
1016
+ const el = inputRef.current;
1017
+ if (!el) return;
1018
+ el.style.height = "";
1019
+ if (text.includes("\n") || el.scrollHeight > el.clientHeight + 2) el.style.height = `${Math.min(el.scrollHeight, 132)}px`;
1020
+ }, [text]);
1021
+ useEffect2(() => {
1022
+ if (thread.length) bodyRef.current?.scrollTo({ top: bodyRef.current.scrollHeight, behavior: "smooth" });
1023
+ }, [thread]);
1024
+ useEffect2(() => {
1025
+ const q = text.trim();
1026
+ if (q.length < 4) {
1027
+ setSimilar([]);
1028
+ return;
1029
+ }
1030
+ let alive = true;
1031
+ const t = setTimeout(() => {
1032
+ client.similar(q).then((r) => alive && setSimilar(r.slice(0, 3))).catch(() => {
1033
+ });
1034
+ }, 350);
1035
+ return () => {
1036
+ alive = false;
1037
+ clearTimeout(t);
1038
+ };
1039
+ }, [client, text]);
1040
+ const point = async () => {
1041
+ setShotError(null);
1042
+ try {
1043
+ const blob = await pointAtIt();
1044
+ if (blob) {
1045
+ const url = URL.createObjectURL(blob);
1046
+ urls.current.push(url);
1047
+ setShots((s) => [...s, { blob, url }]);
1048
+ }
1049
+ } catch {
1050
+ setShotError("Couldn't capture this page. You can still describe it in words.");
1051
+ }
1052
+ inputRef.current?.focus({ preventScroll: true });
1053
+ };
1054
+ const send = async () => {
1055
+ const message = text.trim();
1056
+ if (message.length < 3 || sending) return;
1057
+ const attached = shots;
1058
+ const credited = credit && Boolean(config?.canCredit);
1059
+ setText("");
1060
+ setSimilar([]);
1061
+ setShots([]);
1062
+ setShotError(null);
1063
+ setCredit(false);
1064
+ setThread((th) => [...th, { kind: "out", text: message, images: attached.map((s) => s.url) }, { kind: "typing" }]);
1065
+ const { title, body } = splitMessage(message);
1066
+ try {
1067
+ const attachments = await Promise.all(attached.map((s) => client.upload(s.blob).then((a) => a.id)));
1068
+ const context = { path: location.pathname, topic: route.topic };
1069
+ const [request] = await Promise.all([
1070
+ client.create({ title, body, attachments, context, credit: credited }),
1071
+ new Promise((r) => setTimeout(r, 650))
1072
+ ]);
1073
+ setThread((th) => [...th.filter((t) => t.kind !== "typing"), { kind: "posted", request }]);
1074
+ } catch (err) {
1075
+ setThread((th) => [
1076
+ ...th.filter((t) => t.kind !== "typing" && !(t.kind === "out" && t.text === message)),
1077
+ { kind: "error", text: errorText(err instanceof YouAskedError ? err.code : "network") }
1078
+ ]);
1079
+ setText(message);
1080
+ setShots(attached);
1081
+ setCredit(credited);
1082
+ }
1083
+ };
1084
+ const chatting = thread.length > 0;
1085
+ const openRequest = (id) => setRoute({ view: "detail", id });
1086
+ const asking = route.topic && route.placeholder ? route.topic : null;
1087
+ const placeholder = route.placeholder ?? "Ask for a feature\u2026";
1088
+ const yours = news?.items.find((i) => i.mine);
1089
+ const listed = new Set(news?.items.map((i) => i.id));
1090
+ const shownNotices = notices.filter((n) => !(n.kind === "shipped" && listed.has(n.requestId)));
1091
+ return /* @__PURE__ */ jsxs3(Fragment, { children: [
1092
+ /* @__PURE__ */ jsx3(
1093
+ Header,
1094
+ {
1095
+ leading: /* @__PURE__ */ jsx3(AppAvatar, { icon: appIcon }),
1096
+ title: appName,
1097
+ subtitle: "Ideas, votes and what's new",
1098
+ onClose
1099
+ }
1100
+ ),
1101
+ /* @__PURE__ */ jsxs3("div", { className: "ya-body ya-chat", ref: bodyRef, children: [
1102
+ /* @__PURE__ */ jsx3("div", { className: "ya-bubble ya-bubble-in", children: asking ? `Let's talk about ${asking}. What's missing, or what bugs you?` : greeting ?? `Hey! What would make ${appName} better for you?` }),
1103
+ news && /* @__PURE__ */ jsxs3("div", { className: yours ? "ya-bubble ya-bubble-in ya-bubble-win ya-bubble-news" : "ya-bubble ya-bubble-in ya-bubble-news", children: [
1104
+ yours && /* @__PURE__ */ jsx3(Confetti, {}),
1105
+ /* @__PURE__ */ jsx3("span", { className: "ya-bubble-kicker", children: whatsNewHeading(news.total) }),
1106
+ /* @__PURE__ */ jsx3("ul", { className: "ya-news", children: news.items.map((i) => /* @__PURE__ */ jsx3("li", { children: /* @__PURE__ */ jsxs3("button", { type: "button", onClick: () => openRequest(i.id), children: [
1107
+ /* @__PURE__ */ jsx3("span", { className: "ya-shipped-dot", children: /* @__PURE__ */ jsx3(IconCheck, {}) }),
1108
+ /* @__PURE__ */ jsxs3("span", { className: "ya-news-text", children: [
1109
+ /* @__PURE__ */ jsx3("span", { className: "ya-news-title", children: i.title }),
1110
+ i.mine && /* @__PURE__ */ jsx3("span", { className: "ya-news-you", children: "You asked for this" })
1111
+ ] }),
1112
+ /* @__PURE__ */ jsx3(IconChevron, {})
1113
+ ] }) }, i.id)) }),
1114
+ yours && /* @__PURE__ */ jsx3("span", { children: "That one was yours. Thanks for asking." }),
1115
+ news.total > news.items.length && /* @__PURE__ */ jsxs3("button", { type: "button", className: "ya-bubble-link", onClick: () => setRoute({ view: "board", tab: "shipped" }), children: [
1116
+ "See all ",
1117
+ news.total
1118
+ ] })
1119
+ ] }),
1120
+ shownNotices.map(
1121
+ (n) => n.kind === "reply" ? /* @__PURE__ */ jsx3(ReplyBubble, { notice: n, appName, onOpen: () => openRequest(n.requestId) }, n.id) : /* @__PURE__ */ jsxs3("div", { className: "ya-bubble ya-bubble-in ya-bubble-win", children: [
1122
+ /* @__PURE__ */ jsxs3("span", { className: "ya-live", children: [
1123
+ /* @__PURE__ */ jsx3(IconCheck, {}),
1124
+ "It's live"
1125
+ ] }),
1126
+ /* @__PURE__ */ jsxs3("span", { children: [
1127
+ "You asked for ",
1128
+ /* @__PURE__ */ jsx3("b", { children: n.title }),
1129
+ ". ",
1130
+ n.shipNote ?? "Thanks for asking."
1131
+ ] }),
1132
+ /* @__PURE__ */ jsx3("button", { type: "button", className: "ya-bubble-link", onClick: () => openRequest(n.requestId), children: "See it" })
1133
+ ] }, n.id)
1134
+ ),
1135
+ !chatting && /* @__PURE__ */ jsxs3(Fragment, { children: [
1136
+ /* @__PURE__ */ jsx3(Section, { title: "Popular right now", action: "See all", onAction: () => setRoute({ view: "board" }), children: top.error ? /* @__PURE__ */ jsx3("p", { className: "ya-note", children: errorText(top.error) }) : !top.data ? /* @__PURE__ */ jsx3(Skeleton, { rows: 2 }) : top.data.length === 0 ? /* @__PURE__ */ jsx3("p", { className: "ya-note", children: "No requests yet. Yours could be the first." }) : /* @__PURE__ */ jsx3("ul", { className: "ya-list", children: top.data.slice(0, 3).map((r) => /* @__PURE__ */ jsx3(RequestRow, { client, request: r, compact: true, onOpen: () => openRequest(r.id) }, r.id)) }) }),
1137
+ shipped.data && shipped.data.length > 0 && /* @__PURE__ */ jsx3(Section, { title: "Recently shipped", action: "All", onAction: () => setRoute({ view: "board", tab: "shipped" }), children: /* @__PURE__ */ jsx3("ul", { className: "ya-shipped", children: shipped.data.slice(0, 3).map((r) => /* @__PURE__ */ jsx3("li", { children: /* @__PURE__ */ jsxs3("button", { type: "button", onClick: () => openRequest(r.id), children: [
1138
+ /* @__PURE__ */ jsx3("span", { className: "ya-shipped-dot", children: /* @__PURE__ */ jsx3(IconCheck, {}) }),
1139
+ /* @__PURE__ */ jsx3("span", { className: "ya-shipped-title", children: r.title }),
1140
+ /* @__PURE__ */ jsx3("span", { className: "ya-shipped-when", children: r.shippedAt ? ago(r.shippedAt) : "" })
1141
+ ] }) }, r.id)) }) })
1142
+ ] }),
1143
+ thread.map(
1144
+ (t, i) => t.kind === "out" ? /* @__PURE__ */ jsxs3("div", { className: "ya-bubble ya-bubble-out", children: [
1145
+ t.images?.map((src) => /* @__PURE__ */ jsx3("img", { className: "ya-bubble-img", src, alt: "Your screenshot" }, src)),
1146
+ t.text
1147
+ ] }, i) : t.kind === "typing" ? /* @__PURE__ */ jsxs3("div", { className: "ya-bubble ya-bubble-in ya-typing", "aria-label": "Posting", children: [
1148
+ /* @__PURE__ */ jsx3("span", {}),
1149
+ /* @__PURE__ */ jsx3("span", {}),
1150
+ /* @__PURE__ */ jsx3("span", {})
1151
+ ] }, i) : t.kind === "reply" ? /* @__PURE__ */ jsx3(ReplyBubble, { notice: t.notice, appName, onOpen: () => openRequest(t.notice.requestId) }, i) : t.kind === "posted" ? /* @__PURE__ */ jsxs3("div", { className: "ya-bubble ya-bubble-in", children: [
1152
+ /* @__PURE__ */ jsxs3("span", { children: [
1153
+ "Got it. ",
1154
+ /* @__PURE__ */ jsx3("b", { children: t.request.title }),
1155
+ " is on the board, and we'll tell you right here when it ships."
1156
+ ] }),
1157
+ /* @__PURE__ */ jsx3("button", { type: "button", className: "ya-bubble-link", onClick: () => openRequest(t.request.id), children: "View request" })
1158
+ ] }, i) : /* @__PURE__ */ jsx3("div", { className: "ya-bubble ya-bubble-in ya-bubble-error", role: "alert", children: t.text }, i)
1159
+ ),
1160
+ chatting && !sending && /* @__PURE__ */ jsx3("button", { type: "button", className: "ya-chip", onClick: () => setRoute({ view: "board" }), children: "See what others asked for" })
1161
+ ] }),
1162
+ /* @__PURE__ */ jsxs3("div", { className: "ya-composer-wrap", children: [
1163
+ similar.length > 0 && /* @__PURE__ */ jsxs3("div", { className: "ya-tray", "aria-live": "polite", children: [
1164
+ /* @__PURE__ */ jsx3("p", { className: "ya-tray-h", children: "Sounds like one of these. Vote instead?" }),
1165
+ /* @__PURE__ */ jsx3("ul", { className: "ya-list", children: similar.map((r) => /* @__PURE__ */ jsx3(RequestRow, { client, request: r, compact: true, onOpen: () => openRequest(r.id) }, r.id)) })
1166
+ ] }),
1167
+ shots.length > 0 && /* @__PURE__ */ jsx3("ul", { className: "ya-shots", "aria-label": "Screenshots", children: shots.map((s, i) => /* @__PURE__ */ jsxs3("li", { className: "ya-shot", children: [
1168
+ /* @__PURE__ */ jsx3("img", { src: s.url, alt: "" }),
1169
+ /* @__PURE__ */ jsxs3("span", { children: [
1170
+ "Screenshot",
1171
+ shots.length > 1 ? ` ${i + 1}` : ""
1172
+ ] }),
1173
+ /* @__PURE__ */ jsx3(
1174
+ "button",
1175
+ {
1176
+ type: "button",
1177
+ className: "ya-shot-x",
1178
+ "aria-label": `Remove screenshot${shots.length > 1 ? ` ${i + 1}` : ""}`,
1179
+ onClick: () => setShots((all) => all.filter((x) => x !== s)),
1180
+ children: /* @__PURE__ */ jsx3(IconClose, {})
1181
+ }
1182
+ )
1183
+ ] }, s.url)) }),
1184
+ /* @__PURE__ */ jsxs3(
1185
+ "form",
1186
+ {
1187
+ className: "ya-composer",
1188
+ onSubmit: (e) => {
1189
+ e.preventDefault();
1190
+ send();
1191
+ },
1192
+ children: [
1193
+ /* @__PURE__ */ jsx3(
1194
+ "textarea",
1195
+ {
1196
+ ref: inputRef,
1197
+ className: "ya-composer-input",
1198
+ rows: 1,
1199
+ value: text,
1200
+ onChange: (e) => setText(e.target.value),
1201
+ placeholder,
1202
+ "aria-label": asking ? placeholder : "Ask for a feature",
1203
+ maxLength: 2e3,
1204
+ onKeyDown: (e) => {
1205
+ if (e.key === "Enter" && !e.shiftKey) {
1206
+ e.preventDefault();
1207
+ send();
1208
+ }
1209
+ }
1210
+ }
1211
+ ),
1212
+ /* @__PURE__ */ jsx3("button", { type: "submit", className: "ya-send", disabled: text.trim().length < 3 || sending, "aria-label": "Send", children: /* @__PURE__ */ jsx3(IconSend, {}) })
1213
+ ]
1214
+ }
1215
+ ),
1216
+ /* @__PURE__ */ jsxs3("div", { className: "ya-tools", children: [
1217
+ /* @__PURE__ */ jsxs3(
1218
+ "button",
1219
+ {
1220
+ type: "button",
1221
+ className: "ya-tool",
1222
+ onClick: point,
1223
+ onPointerEnter: () => void import("./capture-FYZGL54F.js"),
1224
+ onFocus: () => void import("./capture-FYZGL54F.js"),
1225
+ disabled: sending || shots.length >= MAX_SHOTS,
1226
+ children: [
1227
+ /* @__PURE__ */ jsx3(IconFrame, {}),
1228
+ "Show us"
1229
+ ]
1230
+ }
1231
+ ),
1232
+ config?.canCredit && text.trim().length > 0 && /* @__PURE__ */ jsxs3("button", { type: "button", className: "ya-switch-row", role: "switch", "aria-checked": credit, onClick: () => setCredit((c) => !c), children: [
1233
+ "Credit me when it ships",
1234
+ /* @__PURE__ */ jsx3("span", { className: "ya-switch", "aria-hidden": "true" })
1235
+ ] })
1236
+ ] }),
1237
+ shotError && /* @__PURE__ */ jsx3("p", { className: "ya-note", role: "alert", children: shotError }),
1238
+ config?.watermark && /* @__PURE__ */ jsx3("p", { className: "ya-mark", children: "Feedback by YouAsked" })
1239
+ ] })
1240
+ ] });
1241
+ }
1242
+ function Section({
1243
+ title,
1244
+ action,
1245
+ onAction,
1246
+ children
1247
+ }) {
1248
+ return /* @__PURE__ */ jsxs3("section", { className: "ya-section", children: [
1249
+ /* @__PURE__ */ jsxs3("div", { className: "ya-section-head", children: [
1250
+ /* @__PURE__ */ jsx3("h3", { children: title }),
1251
+ action && /* @__PURE__ */ jsxs3("button", { type: "button", className: "ya-link", onClick: onAction, children: [
1252
+ action,
1253
+ /* @__PURE__ */ jsx3(IconChevron, {})
1254
+ ] })
1255
+ ] }),
1256
+ children
1257
+ ] });
1258
+ }
1259
+ var TABS = [
1260
+ { key: "top", label: "Top", sort: "top", status: "active" },
1261
+ { key: "new", label: "New", sort: "new", status: "active" },
1262
+ { key: "shipped", label: "Shipped", sort: "new", status: "shipped" }
1263
+ ];
1264
+ function Board({
1265
+ initialTab,
1266
+ setRoute,
1267
+ onClose
1268
+ }) {
1269
+ const { client, title } = useInternal();
1270
+ const [tab, setTab] = useState2(TABS.find((t) => t.key === initialTab) ?? TABS[0]);
1271
+ const { data, error } = useLoad(() => client.list(tab.sort, tab.status), [client, tab.key]);
1272
+ return /* @__PURE__ */ jsxs3(Fragment, { children: [
1273
+ /* @__PURE__ */ jsx3(
1274
+ Header,
1275
+ {
1276
+ title,
1277
+ onBack: () => setRoute({ view: "home" }),
1278
+ onClose,
1279
+ right: /* @__PURE__ */ jsx3("button", { type: "button", className: "ya-link", onClick: () => setRoute({ view: "mine" }), children: "Yours" })
1280
+ }
1281
+ ),
1282
+ /* @__PURE__ */ jsx3("div", { className: "ya-tabs", role: "tablist", "aria-label": "Sort requests", children: TABS.map((t) => /* @__PURE__ */ jsx3("button", { type: "button", role: "tab", className: "ya-tab", "aria-selected": tab.key === t.key, onClick: () => setTab(t), children: t.label }, t.key)) }),
1283
+ /* @__PURE__ */ jsx3("div", { className: "ya-body", children: error ? /* @__PURE__ */ jsx3("p", { className: "ya-empty", children: errorText(error) }) : !data ? /* @__PURE__ */ jsx3(Skeleton, {}) : data.length === 0 ? /* @__PURE__ */ jsxs3("div", { className: "ya-empty", children: [
1284
+ /* @__PURE__ */ jsx3("b", { children: tab.key === "shipped" ? "Nothing shipped yet" : "No requests yet" }),
1285
+ tab.key === "shipped" ? "Requests show up here once they're live." : "Tell us what you'd like next. Others can vote on it."
1286
+ ] }) : /* @__PURE__ */ jsx3("ul", { className: "ya-list", children: data.map((r) => /* @__PURE__ */ jsx3(RequestRow, { client, request: r, onOpen: () => setRoute({ view: "detail", id: r.id }) }, r.id)) }) }),
1287
+ /* @__PURE__ */ jsx3("div", { className: "ya-foot", children: /* @__PURE__ */ jsxs3("button", { type: "button", className: "ya-btn", onClick: () => setRoute({ view: "home", focus: true }), children: [
1288
+ /* @__PURE__ */ jsx3(IconPlus, {}),
1289
+ "Request a feature"
1290
+ ] }) })
1291
+ ] });
1292
+ }
1293
+ function Detail({ id, setRoute, onClose }) {
1294
+ const { client, config, markSeen, appName, appIcon } = useInternal();
1295
+ const { data, error, setData } = useLoad(() => client.get(id), [client, id]);
1296
+ const unseenHere = config?.unseen.filter((n) => n.requestId === id).map((n) => n.id).join(",") ?? "";
1297
+ const loaded = useRef2(false);
1298
+ loaded.current = Boolean(data);
1299
+ useEffect2(() => {
1300
+ if (!unseenHere) return;
1301
+ markSeen(unseenHere.split(","));
1302
+ if (loaded.current) {
1303
+ client.get(id).then((d) => setData(d)).catch(() => {
1304
+ });
1305
+ }
1306
+ }, [unseenHere, markSeen]);
1307
+ const [reply, setReply] = useState2("");
1308
+ const [sending, setSending] = useState2(false);
1309
+ const [replyError, setReplyError] = useState2(null);
1310
+ const [voted, setVoted] = useState2(null);
1311
+ const [early, setEarly] = useState2(false);
1312
+ useEffect2(() => setEarly(Boolean(data?.earlyAccess)), [data?.earlyAccess]);
1313
+ const toggleEarly = async () => {
1314
+ if (!data?.request) return;
1315
+ const before = early;
1316
+ setEarly(!before);
1317
+ try {
1318
+ setEarly((await client.earlyAccess(data.request.id)).earlyAccess);
1319
+ } catch {
1320
+ setEarly(before);
1321
+ }
1322
+ };
1323
+ useEffect2(() => {
1324
+ if (data?.redirect) setRoute({ view: "detail", id: data.redirect });
1325
+ }, [data?.redirect, setRoute]);
1326
+ const request = data?.request;
1327
+ const comments = data?.comments ?? [];
1328
+ const send = async (e) => {
1329
+ e.preventDefault();
1330
+ if (!reply.trim() || sending || !request) return;
1331
+ setSending(true);
1332
+ setReplyError(null);
1333
+ try {
1334
+ const c = await client.comment(request.id, reply);
1335
+ setData({ ...data, comments: [...comments, c], request: { ...request, comments: request.comments + 1 } });
1336
+ setReply("");
1337
+ } catch (err) {
1338
+ setReplyError(errorText(err instanceof YouAskedError ? err.code : "network"));
1339
+ } finally {
1340
+ setSending(false);
1341
+ }
1342
+ };
1343
+ return /* @__PURE__ */ jsxs3(Fragment, { children: [
1344
+ /* @__PURE__ */ jsx3(Header, { title: "", onBack: () => setRoute({ view: "board" }), onClose }),
1345
+ /* @__PURE__ */ jsx3("div", { className: "ya-body", children: error ? /* @__PURE__ */ jsx3("p", { className: "ya-empty", children: error === "not_found" ? "This request was removed." : errorText(error) }) : !request ? /* @__PURE__ */ jsx3(Skeleton, {}) : /* @__PURE__ */ jsxs3(Fragment, { children: [
1346
+ /* @__PURE__ */ jsxs3("div", { className: "ya-detail-meta", children: [
1347
+ request.status !== "open" && /* @__PURE__ */ jsx3(StatusPill, { status: request.status }),
1348
+ /* @__PURE__ */ jsxs3("span", { className: "ya-ref", children: [
1349
+ "YA-",
1350
+ request.number
1351
+ ] })
1352
+ ] }),
1353
+ /* @__PURE__ */ jsx3("h3", { className: "ya-detail-title", children: request.title }),
1354
+ request.body && request.body !== request.title && /* @__PURE__ */ jsx3("p", { className: "ya-text", children: request.body }),
1355
+ data?.attachments && data.attachments.length > 0 && /* @__PURE__ */ jsx3("div", { className: "ya-attachments", children: data.attachments.map((a) => /* @__PURE__ */ jsx3("a", { href: a.url, target: "_blank", rel: "noopener noreferrer", children: /* @__PURE__ */ jsx3("img", { src: a.url, alt: "Screenshot attached to this request", loading: "lazy" }) }, a.id)) }),
1356
+ /* @__PURE__ */ jsx3(BigVote, { client, request, onChange: setVoted }),
1357
+ (request.status === "planned" || request.status === "in_progress") && (voted ?? request.voted) && /* @__PURE__ */ jsxs3("button", { type: "button", className: "ya-early", role: "switch", "aria-checked": early, onClick: toggleEarly, children: [
1358
+ /* @__PURE__ */ jsx3("span", { className: "ya-card-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx3(IconSpark, {}) }),
1359
+ /* @__PURE__ */ jsxs3("span", { className: "ya-menurow-text", children: [
1360
+ /* @__PURE__ */ jsx3("span", { className: "ya-menurow-label", children: "Try it early" }),
1361
+ /* @__PURE__ */ jsx3("span", { className: "ya-menurow-sub", children: early ? "You're on the list. We'll let you in first." : "Get access before everyone else" })
1362
+ ] }),
1363
+ /* @__PURE__ */ jsx3("span", { className: "ya-switch", "aria-hidden": "true" })
1364
+ ] }),
1365
+ request.mine && request.status !== "shipped" && /* @__PURE__ */ jsx3("p", { className: "ya-note", children: "You asked for this. We'll tell you here when it ships." }),
1366
+ request.status === "shipped" && /* @__PURE__ */ jsxs3("div", { className: "ya-callout", "data-tone": "success", children: [
1367
+ /* @__PURE__ */ jsx3(IconCheck, {}),
1368
+ /* @__PURE__ */ jsxs3("span", { children: [
1369
+ /* @__PURE__ */ jsx3("b", { children: "It's live." }),
1370
+ request.shipNote ? ` ${request.shipNote}` : " Thanks for asking.",
1371
+ request.creditName && /* @__PURE__ */ jsxs3("span", { className: "ya-credit", children: [
1372
+ "Thanks to ",
1373
+ request.creditName,
1374
+ " for asking."
1375
+ ] })
1376
+ ] })
1377
+ ] }),
1378
+ /* @__PURE__ */ jsx3("p", { className: "ya-section-h", children: "Conversation" }),
1379
+ comments.length === 0 ? /* @__PURE__ */ jsx3("p", { className: "ya-text ya-text-muted", children: "No messages yet. Add details or ask a question below." }) : /* @__PURE__ */ jsx3("div", { className: "ya-thread", children: comments.map((c) => /* @__PURE__ */ jsx3(Message, { comment: c, appName, appIcon }, c.id)) })
1380
+ ] }) }),
1381
+ request && /* @__PURE__ */ jsxs3("form", { className: "ya-composer ya-composer-bar", onSubmit: send, children: [
1382
+ /* @__PURE__ */ jsx3(
1383
+ "textarea",
1384
+ {
1385
+ className: "ya-composer-input",
1386
+ rows: 1,
1387
+ value: reply,
1388
+ onChange: (e) => setReply(e.target.value),
1389
+ placeholder: "Message",
1390
+ "aria-label": "Message",
1391
+ maxLength: 1e3,
1392
+ onKeyDown: (e) => {
1393
+ if (e.key === "Enter" && !e.shiftKey) {
1394
+ e.preventDefault();
1395
+ e.currentTarget.form?.requestSubmit();
1396
+ }
1397
+ }
1398
+ }
1399
+ ),
1400
+ /* @__PURE__ */ jsx3("button", { type: "submit", className: "ya-send", disabled: !reply.trim() || sending, "aria-label": "Send comment", children: /* @__PURE__ */ jsx3(IconSend, {}) }),
1401
+ replyError && /* @__PURE__ */ jsx3("span", { className: "ya-sr", role: "alert", children: replyError })
1402
+ ] })
1403
+ ] });
1404
+ }
1405
+ function Message({ comment, appName, appIcon }) {
1406
+ const when = /* @__PURE__ */ jsx3("time", { dateTime: new Date(comment.createdAt).toISOString(), children: ago(comment.createdAt) });
1407
+ if (comment.mine) {
1408
+ return /* @__PURE__ */ jsxs3("div", { className: "ya-msg ya-msg-out", children: [
1409
+ /* @__PURE__ */ jsx3("div", { className: "ya-bubble ya-bubble-out", children: comment.body }),
1410
+ /* @__PURE__ */ jsx3("span", { className: "ya-msg-meta", children: when })
1411
+ ] });
1412
+ }
1413
+ return /* @__PURE__ */ jsxs3("div", { className: "ya-msg", children: [
1414
+ comment.team && appIcon ? /* @__PURE__ */ jsx3(AppAvatar, { icon: appIcon, size: 26 }) : null,
1415
+ /* @__PURE__ */ jsxs3("div", { className: "ya-msg-body", children: [
1416
+ /* @__PURE__ */ jsxs3("span", { className: "ya-msg-meta", children: [
1417
+ /* @__PURE__ */ jsx3("b", { children: comment.team ? appName : comment.author || "Someone" }),
1418
+ comment.team && /* @__PURE__ */ jsx3("span", { className: "ya-team", children: "Team" }),
1419
+ when
1420
+ ] }),
1421
+ /* @__PURE__ */ jsx3("div", { className: "ya-bubble ya-bubble-in", children: comment.body })
1422
+ ] })
1423
+ ] });
1424
+ }
1425
+ function Mine({ setRoute, onClose }) {
1426
+ const { client } = useInternal();
1427
+ const { data, error } = useLoad(() => client.mine(), [client]);
1428
+ return /* @__PURE__ */ jsxs3(Fragment, { children: [
1429
+ /* @__PURE__ */ jsx3(Header, { title: "Your requests", onBack: () => setRoute({ view: "board" }), onClose }),
1430
+ /* @__PURE__ */ jsx3("div", { className: "ya-body", children: error ? /* @__PURE__ */ jsx3("p", { className: "ya-empty", children: errorText(error) }) : !data ? /* @__PURE__ */ jsx3(Skeleton, {}) : data.length === 0 ? /* @__PURE__ */ jsxs3("div", { className: "ya-empty", children: [
1431
+ /* @__PURE__ */ jsx3("b", { children: "Nothing yet" }),
1432
+ "Requests you post or vote on show up here, with their status."
1433
+ ] }) : /* @__PURE__ */ jsx3("ul", { className: "ya-list", children: data.map((r) => /* @__PURE__ */ jsx3(RequestRow, { client, request: r, onOpen: () => setRoute({ view: "detail", id: r.id }) }, r.id)) }) }),
1434
+ /* @__PURE__ */ jsx3("div", { className: "ya-foot", children: /* @__PURE__ */ jsxs3("button", { type: "button", className: "ya-btn", onClick: () => setRoute({ view: "home", focus: true }), children: [
1435
+ /* @__PURE__ */ jsx3(IconPlus, {}),
1436
+ "Request a feature"
1437
+ ] }) })
1438
+ ] });
1439
+ }
1440
+
1441
+ // src/YouAsked.tsx
1442
+ import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1443
+ var DEFAULT_API_URL = "https://youasked-api.adenteo.workers.dev";
1444
+ function lastWhatsNew(key) {
1445
+ try {
1446
+ return key ? Number(localStorage.getItem(key)) || 0 : 0;
1447
+ } catch {
1448
+ return 0;
1449
+ }
1450
+ }
1451
+ function coveredBy(news, n) {
1452
+ return n.kind === "shipped" && Boolean(news?.items.some((i) => i.id === n.requestId));
1453
+ }
1454
+ function YouAsked({
1455
+ appKey = "",
1456
+ demo = false,
1457
+ cards = true,
1458
+ user,
1459
+ signature,
1460
+ ready = true,
1461
+ appearance,
1462
+ trigger = "floating",
1463
+ position = "bottom-right",
1464
+ label,
1465
+ appName,
1466
+ appIcon,
1467
+ greeting,
1468
+ title = "Feature requests",
1469
+ offset,
1470
+ apiUrl = DEFAULT_API_URL,
1471
+ children
1472
+ }) {
1473
+ const userId = user?.id;
1474
+ const userEmail = user?.email;
1475
+ const userName = user?.name;
1476
+ const client = useMemo(
1477
+ () => demo ? createDemoClient(appName) : createClient({ appKey, apiUrl, user: userId == null ? null : { id: userId, email: userEmail, name: userName }, signature }),
1478
+ [demo, appName, appKey, apiUrl, userId, userEmail, userName, signature]
1479
+ );
1480
+ const whatsNewKey = demo ? null : `youasked:whats-new:${appKey}:${userId ?? "anon"}`;
1481
+ const [mounted, setMounted] = useState3(false);
1482
+ const [route, setRoute] = useState3(null);
1483
+ const [config, setConfig] = useState3(null);
1484
+ const [whatsNew, setWhatsNew] = useState3(null);
1485
+ const [whatsNewToast, setWhatsNewToast] = useState3(false);
1486
+ const [capture, setCapture] = useState3(null);
1487
+ const tokens = useTokens(appearance, mounted);
1488
+ const openerRef = useRef3(null);
1489
+ const [detectedIcon, setDetectedIcon] = useState3(null);
1490
+ useEffect3(() => {
1491
+ if (appIcon === void 0) setDetectedIcon(findPageIcon());
1492
+ }, [appIcon]);
1493
+ useEffect3(() => {
1494
+ injectStyles();
1495
+ setMounted(true);
1496
+ }, []);
1497
+ useEffect3(() => {
1498
+ if (!ready) return;
1499
+ let alive = true;
1500
+ client.config().then((c) => {
1501
+ if (!alive) return;
1502
+ const seenAt = lastWhatsNew(whatsNewKey);
1503
+ const items = c.whatsNew?.items.filter((i) => i.shippedAt > seenAt) ?? [];
1504
+ const news = c.whatsNew && items.length ? { ...c.whatsNew, items } : null;
1505
+ setConfig(c);
1506
+ setWhatsNew(news);
1507
+ setWhatsNewToast(Boolean(news) && c.unseen.filter((n) => !coveredBy(news, n)).length === 0);
1508
+ }).catch(() => {
1509
+ });
1510
+ return () => {
1511
+ alive = false;
1512
+ };
1513
+ }, [client, ready]);
1514
+ useEffect3(() => {
1515
+ if (!("onNotice" in client)) return;
1516
+ return client.onNotice(
1517
+ (n) => setConfig((c) => c ? { ...c, unseen: [...c.unseen, n] } : c)
1518
+ );
1519
+ }, [client]);
1520
+ const dismissWhatsNew = useCallback2(() => {
1521
+ setWhatsNew(null);
1522
+ setWhatsNewToast(false);
1523
+ try {
1524
+ if (whatsNewKey) localStorage.setItem(whatsNewKey, String(Date.now()));
1525
+ } catch {
1526
+ }
1527
+ client.whatsNewSeen().catch(() => {
1528
+ });
1529
+ }, [client, whatsNewKey]);
1530
+ const pointAtIt = useCallback2(
1531
+ () => new Promise((resolve, reject) => {
1532
+ import("./capture-FYZGL54F.js").then(
1533
+ (m) => setCapture({ Layer: m.default, resolve }),
1534
+ (err) => reject(err)
1535
+ );
1536
+ }),
1537
+ []
1538
+ );
1539
+ const open = useCallback2((options) => {
1540
+ openerRef.current = document.activeElement;
1541
+ setRoute(toRoute(options));
1542
+ }, []);
1543
+ const close = useCallback2(() => {
1544
+ setRoute(null);
1545
+ openerRef.current?.focus?.({ preventScroll: true });
1546
+ }, []);
1547
+ useEffect3(() => {
1548
+ const onOpen = (e) => open(e.detail);
1549
+ window.addEventListener("youasked:open", onOpen);
1550
+ return () => window.removeEventListener("youasked:open", onOpen);
1551
+ }, [open]);
1552
+ const markSeen = useCallback2(
1553
+ (ids) => {
1554
+ if (!ids.length) return;
1555
+ setConfig((c) => c ? { ...c, unseen: c.unseen.filter((n) => !ids.includes(n.id)) } : c);
1556
+ client.seen(ids).catch(() => {
1557
+ });
1558
+ },
1559
+ [client]
1560
+ );
1561
+ const scopeStyle = useMemo(
1562
+ () => ({
1563
+ ...tokens ? tokenStyle(tokens) : {},
1564
+ ...offset !== void 0 ? { "--ya-offset": `${offset}px` } : {}
1565
+ }),
1566
+ [tokens, offset]
1567
+ );
1568
+ const unseen = config?.unseen ?? [];
1569
+ const value = useMemo(
1570
+ () => ({
1571
+ open,
1572
+ close,
1573
+ isOpen: route !== null,
1574
+ unseenCount: unseen.length,
1575
+ client,
1576
+ config,
1577
+ markSeen,
1578
+ whatsNew,
1579
+ dismissWhatsNew,
1580
+ pointAtIt,
1581
+ scope: { className: "ya-scope", style: scopeStyle, "data-ya-mode": tokens?.mode },
1582
+ appName: appName ?? config?.app.name ?? "us",
1583
+ appIcon: appIcon === false ? null : appIcon ?? detectedIcon,
1584
+ title,
1585
+ greeting
1586
+ }),
1587
+ [open, close, route, unseen.length, client, config, markSeen, whatsNew, dismissWhatsNew, pointAtIt, scopeStyle, tokens?.mode, appName, appIcon, detectedIcon, title, greeting]
1588
+ );
1589
+ const standing = unseen.filter((n) => !coveredBy(whatsNew, n));
1590
+ const notice = standing.find((n) => n.kind === "shipped") ?? standing.find((n) => n.kind === "reply");
1591
+ return /* @__PURE__ */ jsxs4(YouAskedContext.Provider, { value, children: [
1592
+ children,
1593
+ mounted && createPortal(
1594
+ /* @__PURE__ */ jsxs4("div", { className: "ya-scope", "data-ya-mode": tokens?.mode, "data-ya-skip": "", style: scopeStyle, children: [
1595
+ trigger === "floating" && !capture && /* @__PURE__ */ jsx4(
1596
+ Launcher,
1597
+ {
1598
+ position,
1599
+ label,
1600
+ isOpen: route !== null,
1601
+ badge: unseen.length > 0,
1602
+ onClick: () => route ? close() : open()
1603
+ }
1604
+ ),
1605
+ cards && !notice && whatsNewToast && whatsNew && route === null && /* @__PURE__ */ jsx4(
1606
+ WhatsNewToast,
1607
+ {
1608
+ news: whatsNew,
1609
+ position,
1610
+ trigger,
1611
+ onOpen: () => open(),
1612
+ onDismiss: dismissWhatsNew
1613
+ }
1614
+ ),
1615
+ cards && notice && route === null && /* @__PURE__ */ jsx4(
1616
+ ShippedToast,
1617
+ {
1618
+ notice,
1619
+ position,
1620
+ trigger,
1621
+ onOpen: () => {
1622
+ markSeen([notice.id]);
1623
+ open({ requestId: notice.requestId });
1624
+ },
1625
+ onDismiss: () => markSeen([notice.id])
1626
+ }
1627
+ ),
1628
+ route && /* @__PURE__ */ jsx4(
1629
+ Panel,
1630
+ {
1631
+ route,
1632
+ setRoute,
1633
+ onClose: close,
1634
+ position,
1635
+ hasLauncher: trigger === "floating",
1636
+ hidden: capture !== null
1637
+ }
1638
+ ),
1639
+ capture && /* @__PURE__ */ jsx4(
1640
+ capture.Layer,
1641
+ {
1642
+ onDone: (image) => {
1643
+ capture.resolve(image);
1644
+ setCapture(null);
1645
+ },
1646
+ onCancel: () => {
1647
+ capture.resolve(null);
1648
+ setCapture(null);
1649
+ }
1650
+ }
1651
+ )
1652
+ ] }),
1653
+ document.body
1654
+ )
1655
+ ] });
1656
+ }
1657
+ function findPageIcon() {
1658
+ const links = Array.from(document.querySelectorAll("link[rel~='icon'], link[rel~='apple-touch-icon']"));
1659
+ const touch = links.find((l) => l.rel.includes("apple-touch-icon") && l.href);
1660
+ if (touch) return touch.href;
1661
+ const large = links.filter((l) => l.href && !/\.svg(\?|$)/i.test(l.href) && !/\.ico(\?|$)/i.test(l.href)).map((l) => ({ l, size: Math.max(0, ...(l.sizes?.value ?? "").split(/\s+/).map((v) => parseInt(v, 10) || 0)) })).filter((x) => x.size >= 96).sort((a, b) => b.size - a.size)[0];
1662
+ return large?.l.href ?? null;
1663
+ }
1664
+ function useTokens(appearance, mounted) {
1665
+ const key = JSON.stringify(appearance ?? {});
1666
+ const [tokens, setTokens] = useState3(null);
1667
+ useEffect3(() => {
1668
+ if (!mounted) return;
1669
+ const parsed = JSON.parse(key);
1670
+ const update = () => setTokens(resolveTokens(parsed));
1671
+ update();
1672
+ const observer = new MutationObserver(update);
1673
+ observer.observe(document.documentElement, { attributes: true, attributeFilter: ["class", "data-theme", "style"] });
1674
+ const media = window.matchMedia?.("(prefers-color-scheme: dark)");
1675
+ media?.addEventListener?.("change", update);
1676
+ return () => {
1677
+ observer.disconnect();
1678
+ media?.removeEventListener?.("change", update);
1679
+ };
1680
+ }, [key, mounted]);
1681
+ return tokens;
1682
+ }
1683
+ function useMedia(query) {
1684
+ const [matches, setMatches] = useState3(() => typeof window !== "undefined" && window.matchMedia(query).matches);
1685
+ useEffect3(() => {
1686
+ const m = window.matchMedia(query);
1687
+ const on = () => setMatches(m.matches);
1688
+ on();
1689
+ m.addEventListener("change", on);
1690
+ return () => m.removeEventListener("change", on);
1691
+ }, [query]);
1692
+ return matches;
1693
+ }
1694
+ function Panel({
1695
+ route,
1696
+ setRoute,
1697
+ onClose,
1698
+ position,
1699
+ hasLauncher,
1700
+ hidden
1701
+ }) {
1702
+ const panelRef = useRef3(null);
1703
+ const backdropRef = useRef3(null);
1704
+ const [closing, setClosing] = useState3(false);
1705
+ const isSheet = useMedia("(max-width: 639px)");
1706
+ const reduceMotion = useMedia("(prefers-reduced-motion: reduce)");
1707
+ const hiddenRef = useRef3(hidden);
1708
+ hiddenRef.current = hidden;
1709
+ const drag = useRef3(null);
1710
+ const requestClose = useCallback2(() => {
1711
+ if (reduceMotion) return onClose();
1712
+ setClosing(true);
1713
+ setTimeout(onClose, 200);
1714
+ }, [onClose, reduceMotion]);
1715
+ useEffect3(() => {
1716
+ if (!isSheet) return;
1717
+ const html = document.documentElement;
1718
+ const previous = html.style.overflow;
1719
+ html.style.overflow = "hidden";
1720
+ return () => {
1721
+ html.style.overflow = previous;
1722
+ };
1723
+ }, [isSheet]);
1724
+ useEffect3(() => {
1725
+ panelRef.current?.focus({ preventScroll: true });
1726
+ }, []);
1727
+ useEffect3(() => {
1728
+ const onKey = (e) => {
1729
+ if (hiddenRef.current) return;
1730
+ if (e.key === "Escape") {
1731
+ e.stopPropagation();
1732
+ requestClose();
1733
+ }
1734
+ if (e.key === "Tab" && panelRef.current) trapFocus(e, panelRef.current);
1735
+ };
1736
+ document.addEventListener("keydown", onKey, true);
1737
+ return () => document.removeEventListener("keydown", onKey, true);
1738
+ }, [requestClose]);
1739
+ const onPointerDown = (e) => {
1740
+ if (!isSheet || e.button !== 0) return;
1741
+ const target = e.target;
1742
+ if (!target.closest(".ya-grab-zone, .ya-head") || target.closest("button, input, textarea, a")) return;
1743
+ const panel = panelRef.current;
1744
+ drag.current = { startY: e.clientY, lastY: e.clientY, lastT: performance.now(), v: 0, dy: 0 };
1745
+ panel.setPointerCapture(e.pointerId);
1746
+ panel.style.transition = "none";
1747
+ panel.style.animation = "none";
1748
+ };
1749
+ const onPointerMove = (e) => {
1750
+ const d = drag.current;
1751
+ if (!d) return;
1752
+ const panel = panelRef.current;
1753
+ const raw = e.clientY - d.startY;
1754
+ const dy = raw < 0 ? Math.max(-18, raw * 0.2) : raw;
1755
+ const now = performance.now();
1756
+ d.v = (e.clientY - d.lastY) / Math.max(1, now - d.lastT);
1757
+ d.lastY = e.clientY;
1758
+ d.lastT = now;
1759
+ d.dy = dy;
1760
+ panel.style.transform = `translateY(${dy}px)`;
1761
+ if (backdropRef.current) backdropRef.current.style.opacity = String(1 - Math.max(0, dy) / panel.offsetHeight);
1762
+ };
1763
+ const onPointerUp = () => {
1764
+ const d = drag.current;
1765
+ if (!d) return;
1766
+ drag.current = null;
1767
+ const panel = panelRef.current;
1768
+ const backdrop = backdropRef.current;
1769
+ const h = panel.offsetHeight;
1770
+ panel.style.transition = "transform .3s cubic-bezier(.2,.9,.3,1)";
1771
+ if (backdrop) backdrop.style.transition = "opacity .3s";
1772
+ if (d.dy > h * 0.25 || d.v > 0.5) {
1773
+ panel.style.transform = `translateY(${h}px)`;
1774
+ if (backdrop) backdrop.style.opacity = "0";
1775
+ setTimeout(onClose, 260);
1776
+ } else {
1777
+ panel.style.transform = "";
1778
+ if (backdrop) backdrop.style.opacity = "";
1779
+ }
1780
+ };
1781
+ return /* @__PURE__ */ jsxs4(
1782
+ "div",
1783
+ {
1784
+ className: "ya-overlay",
1785
+ "data-pos": position,
1786
+ "data-launcher": hasLauncher || void 0,
1787
+ "data-closing": closing || void 0,
1788
+ hidden,
1789
+ children: [
1790
+ /* @__PURE__ */ jsx4("div", { className: "ya-backdrop", ref: backdropRef, onClick: requestClose, "aria-hidden": "true" }),
1791
+ /* @__PURE__ */ jsxs4(
1792
+ "div",
1793
+ {
1794
+ className: "ya-panel",
1795
+ role: "dialog",
1796
+ "aria-modal": "true",
1797
+ "aria-label": "Feature requests",
1798
+ tabIndex: -1,
1799
+ ref: panelRef,
1800
+ onPointerDown,
1801
+ onPointerMove,
1802
+ onPointerUp,
1803
+ onPointerCancel: onPointerUp,
1804
+ children: [
1805
+ /* @__PURE__ */ jsx4("div", { className: "ya-grab-zone", "aria-hidden": "true", children: /* @__PURE__ */ jsx4("div", { className: "ya-grab" }) }),
1806
+ /* @__PURE__ */ jsx4(Navigator, { route, setRoute, onClose: requestClose })
1807
+ ]
1808
+ }
1809
+ )
1810
+ ]
1811
+ }
1812
+ );
1813
+ }
1814
+ function trapFocus(e, root) {
1815
+ const items = Array.from(
1816
+ root.querySelectorAll('button:not([disabled]), input, textarea, a[href], [tabindex]:not([tabindex="-1"])')
1817
+ ).filter((el) => el.offsetParent !== null);
1818
+ if (!items.length) return;
1819
+ const first = items[0];
1820
+ const last = items[items.length - 1];
1821
+ if (e.shiftKey && (document.activeElement === first || document.activeElement === root)) {
1822
+ e.preventDefault();
1823
+ last.focus();
1824
+ } else if (!e.shiftKey && document.activeElement === last) {
1825
+ e.preventDefault();
1826
+ first.focus();
1827
+ }
1828
+ }
1829
+ function Launcher({
1830
+ position,
1831
+ label,
1832
+ isOpen,
1833
+ badge,
1834
+ onClick
1835
+ }) {
1836
+ return /* @__PURE__ */ jsxs4(
1837
+ "button",
1838
+ {
1839
+ type: "button",
1840
+ className: label && !isOpen ? "ya-fab ya-fab-label" : "ya-fab",
1841
+ "data-pos": position,
1842
+ "data-open": isOpen || void 0,
1843
+ onClick,
1844
+ "aria-label": isOpen ? "Close feature requests" : label || "Feature requests",
1845
+ "aria-expanded": isOpen,
1846
+ children: [
1847
+ /* @__PURE__ */ jsx4("span", { className: "ya-fab-icon", children: isOpen ? /* @__PURE__ */ jsx4(IconClose, {}) : /* @__PURE__ */ jsx4(IconIdea, {}) }),
1848
+ label && !isOpen && /* @__PURE__ */ jsx4("span", { children: label }),
1849
+ badge && !isOpen && /* @__PURE__ */ jsx4("span", { className: "ya-dot", "aria-hidden": "true" })
1850
+ ]
1851
+ }
1852
+ );
1853
+ }
1854
+ function ShippedToast({
1855
+ notice,
1856
+ position,
1857
+ trigger,
1858
+ onOpen,
1859
+ onDismiss
1860
+ }) {
1861
+ return /* @__PURE__ */ jsx4("div", { className: "ya-toast", role: "status", "data-pos": position, "data-trigger": trigger, children: notice.kind === "reply" ? /* @__PURE__ */ jsxs4(Fragment2, { children: [
1862
+ /* @__PURE__ */ jsxs4("div", { className: "ya-toast-top", children: [
1863
+ /* @__PURE__ */ jsx4("p", { className: "ya-toast-kicker", children: "New reply about" }),
1864
+ /* @__PURE__ */ jsx4("button", { type: "button", className: "ya-icon-btn", onClick: onDismiss, "aria-label": "Dismiss", children: /* @__PURE__ */ jsx4(IconClose, {}) })
1865
+ ] }),
1866
+ /* @__PURE__ */ jsx4("p", { className: "ya-toast-title", children: notice.title }),
1867
+ /* @__PURE__ */ jsx4("p", { className: "ya-toast-note ya-toast-quote", children: notice.reply }),
1868
+ /* @__PURE__ */ jsxs4("div", { className: "ya-toast-actions", children: [
1869
+ /* @__PURE__ */ jsx4("button", { type: "button", className: "ya-btn ya-btn-sm", onClick: onOpen, children: "Reply" }),
1870
+ /* @__PURE__ */ jsx4("button", { type: "button", className: "ya-btn ya-btn-sm ya-btn-ghost", onClick: onDismiss, children: "Later" })
1871
+ ] })
1872
+ ] }) : /* @__PURE__ */ jsx4(ShippedBody, { notice, onOpen, onDismiss }) });
1873
+ }
1874
+ function WhatsNewToast({
1875
+ news,
1876
+ position,
1877
+ trigger,
1878
+ onOpen,
1879
+ onDismiss
1880
+ }) {
1881
+ const mine = news.items.some((i) => i.mine);
1882
+ return /* @__PURE__ */ jsxs4("div", { className: "ya-toast", role: "status", "data-pos": position, "data-trigger": trigger, children: [
1883
+ /* @__PURE__ */ jsxs4("div", { className: "ya-toast-top", children: [
1884
+ /* @__PURE__ */ jsx4("p", { className: "ya-toast-kicker", children: "What's new" }),
1885
+ /* @__PURE__ */ jsx4("button", { type: "button", className: "ya-icon-btn", onClick: onDismiss, "aria-label": "Dismiss", children: /* @__PURE__ */ jsx4(IconClose, {}) })
1886
+ ] }),
1887
+ /* @__PURE__ */ jsx4("p", { className: "ya-toast-title", children: whatsNewHeading(news.total) }),
1888
+ mine && /* @__PURE__ */ jsxs4("div", { className: "ya-live", children: [
1889
+ /* @__PURE__ */ jsx4(IconCheck, {}),
1890
+ "Including something you asked for"
1891
+ ] }),
1892
+ /* @__PURE__ */ jsxs4("div", { className: "ya-toast-actions", children: [
1893
+ /* @__PURE__ */ jsx4("button", { type: "button", className: "ya-btn ya-btn-sm", onClick: onOpen, children: "See what's new" }),
1894
+ /* @__PURE__ */ jsx4("button", { type: "button", className: "ya-btn ya-btn-sm ya-btn-ghost", onClick: onDismiss, children: "Not now" })
1895
+ ] })
1896
+ ] });
1897
+ }
1898
+ function ShippedBody({ notice, onOpen, onDismiss }) {
1899
+ return /* @__PURE__ */ jsxs4(Fragment2, { children: [
1900
+ /* @__PURE__ */ jsxs4("div", { className: "ya-toast-top", children: [
1901
+ /* @__PURE__ */ jsx4("p", { className: "ya-toast-kicker", children: "You asked for" }),
1902
+ /* @__PURE__ */ jsx4("button", { type: "button", className: "ya-icon-btn", onClick: onDismiss, "aria-label": "Dismiss", children: /* @__PURE__ */ jsx4(IconClose, {}) })
1903
+ ] }),
1904
+ /* @__PURE__ */ jsx4("p", { className: "ya-toast-title", children: notice.title }),
1905
+ /* @__PURE__ */ jsxs4("div", { className: "ya-live", children: [
1906
+ /* @__PURE__ */ jsx4(IconCheck, {}),
1907
+ "It's live"
1908
+ ] }),
1909
+ notice.shipNote && /* @__PURE__ */ jsx4("p", { className: "ya-toast-note", children: notice.shipNote }),
1910
+ /* @__PURE__ */ jsxs4("div", { className: "ya-toast-actions", children: [
1911
+ /* @__PURE__ */ jsx4("button", { type: "button", className: "ya-btn ya-btn-sm", onClick: onOpen, children: "See it" }),
1912
+ /* @__PURE__ */ jsx4("button", { type: "button", className: "ya-btn ya-btn-sm ya-btn-ghost", onClick: onDismiss, children: "Nice" })
1913
+ ] })
1914
+ ] });
1915
+ }
1916
+
1917
+ // src/entries.tsx
1918
+ import { useState as useState4 } from "react";
1919
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
1920
+ function useScope(className, style) {
1921
+ const { scope } = useInternal();
1922
+ return {
1923
+ className: `${scope.className} ya-inline${className ? ` ${className}` : ""}`,
1924
+ style: { ...scope.style, ...style },
1925
+ "data-ya-mode": scope["data-ya-mode"]
1926
+ };
1927
+ }
1928
+ function AskBar({ placeholder = "Ask for a feature\u2026", className, style }) {
1929
+ const { open, appIcon, unseenCount } = useInternal();
1930
+ return /* @__PURE__ */ jsx5("div", { ...useScope(className, style), children: /* @__PURE__ */ jsxs5("button", { type: "button", className: "ya-askbar", onClick: () => open({ view: "new" }), children: [
1931
+ appIcon ? /* @__PURE__ */ jsx5(AppAvatar, { icon: appIcon, size: 30 }) : /* @__PURE__ */ jsx5("span", { className: "ya-askbar-glyph", "aria-hidden": "true", children: /* @__PURE__ */ jsx5(IconIdea, {}) }),
1932
+ /* @__PURE__ */ jsx5("span", { className: "ya-askbar-text", children: placeholder }),
1933
+ unseenCount > 0 && /* @__PURE__ */ jsx5("span", { className: "ya-badge", children: unseenCount }),
1934
+ /* @__PURE__ */ jsx5("span", { className: "ya-askbar-send", "aria-hidden": "true", children: /* @__PURE__ */ jsx5(IconSend, {}) })
1935
+ ] }) });
1936
+ }
1937
+ function FeatureCard({
1938
+ heading = "Shape what's next",
1939
+ description = "Vote on ideas or suggest your own",
1940
+ limit = 3,
1941
+ className,
1942
+ style
1943
+ }) {
1944
+ const { client, open, config, markSeen } = useInternal();
1945
+ const { data } = useLoad(() => client.list("top", "active"), [client]);
1946
+ const notice = config?.unseen.find((n) => n.kind === "shipped");
1947
+ return /* @__PURE__ */ jsx5("div", { ...useScope(className, style), children: /* @__PURE__ */ jsxs5("section", { className: "ya-card", children: [
1948
+ /* @__PURE__ */ jsxs5("div", { className: "ya-card-head", children: [
1949
+ /* @__PURE__ */ jsx5("span", { className: "ya-card-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx5(IconIdea, {}) }),
1950
+ /* @__PURE__ */ jsxs5("div", { children: [
1951
+ /* @__PURE__ */ jsx5("h3", { className: "ya-card-title", children: heading }),
1952
+ /* @__PURE__ */ jsx5("p", { className: "ya-card-sub", children: description })
1953
+ ] })
1954
+ ] }),
1955
+ notice && /* @__PURE__ */ jsxs5(
1956
+ "button",
1957
+ {
1958
+ type: "button",
1959
+ className: "ya-card-win",
1960
+ onClick: () => {
1961
+ markSeen([notice.id]);
1962
+ open({ requestId: notice.requestId });
1963
+ },
1964
+ children: [
1965
+ /* @__PURE__ */ jsx5("span", { className: "ya-shipped-dot", children: /* @__PURE__ */ jsx5(IconCheck, {}) }),
1966
+ /* @__PURE__ */ jsxs5("span", { children: [
1967
+ "You asked for ",
1968
+ /* @__PURE__ */ jsx5("b", { children: notice.title }),
1969
+ ". It's live."
1970
+ ] }),
1971
+ /* @__PURE__ */ jsx5(IconChevron, {})
1972
+ ]
1973
+ }
1974
+ ),
1975
+ !data ? /* @__PURE__ */ jsx5(Skeleton, { rows: 2 }) : data.length > 0 ? /* @__PURE__ */ jsx5("ul", { className: "ya-list", children: data.slice(0, limit).map((r) => /* @__PURE__ */ jsx5(RequestRow, { client, request: r, compact: true, onOpen: () => open({ requestId: r.id }) }, r.id)) }) : null,
1976
+ /* @__PURE__ */ jsxs5("div", { className: "ya-card-actions", children: [
1977
+ /* @__PURE__ */ jsx5("button", { type: "button", className: "ya-btn ya-btn-sm", onClick: () => open({ view: "new" }), children: "Suggest an idea" }),
1978
+ data && data.length > limit && /* @__PURE__ */ jsxs5("button", { type: "button", className: "ya-btn ya-btn-sm ya-btn-ghost", onClick: () => open({ view: "board" }), children: [
1979
+ "See all ",
1980
+ data.length
1981
+ ] })
1982
+ ] })
1983
+ ] }) });
1984
+ }
1985
+ function RequestButton({
1986
+ variant = "pill",
1987
+ label = "Request a feature",
1988
+ sublabel = "Vote on what we build next",
1989
+ className,
1990
+ style
1991
+ }) {
1992
+ const { open, unseenCount } = useInternal();
1993
+ const scope = useScope(className, style);
1994
+ const badge = unseenCount > 0 && (variant === "icon" ? /* @__PURE__ */ jsx5("span", { className: "ya-dot", "aria-hidden": "true" }) : /* @__PURE__ */ jsx5("span", { className: "ya-badge", children: unseenCount }));
1995
+ if (variant === "icon") {
1996
+ return /* @__PURE__ */ jsx5("span", { ...scope, children: /* @__PURE__ */ jsxs5("button", { type: "button", className: "ya-iconbtn", onClick: () => open(), "aria-label": label, children: [
1997
+ /* @__PURE__ */ jsx5(IconIdea, {}),
1998
+ badge
1999
+ ] }) });
2000
+ }
2001
+ if (variant === "row") {
2002
+ return /* @__PURE__ */ jsx5("div", { ...scope, children: /* @__PURE__ */ jsxs5("button", { type: "button", className: "ya-menurow", onClick: () => open(), children: [
2003
+ /* @__PURE__ */ jsx5("span", { className: "ya-card-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx5(IconIdea, {}) }),
2004
+ /* @__PURE__ */ jsxs5("span", { className: "ya-menurow-text", children: [
2005
+ /* @__PURE__ */ jsx5("span", { className: "ya-menurow-label", children: label }),
2006
+ sublabel && /* @__PURE__ */ jsx5("span", { className: "ya-menurow-sub", children: sublabel })
2007
+ ] }),
2008
+ badge,
2009
+ /* @__PURE__ */ jsx5(IconChevron, {})
2010
+ ] }) });
2011
+ }
2012
+ return /* @__PURE__ */ jsx5("span", { ...scope, children: /* @__PURE__ */ jsxs5("button", { type: "button", className: "ya-pillbtn", onClick: () => open(), children: [
2013
+ /* @__PURE__ */ jsx5(IconIdea, {}),
2014
+ label,
2015
+ badge
2016
+ ] }) });
2017
+ }
2018
+ function AskAbout({
2019
+ topic,
2020
+ prompt,
2021
+ className,
2022
+ style
2023
+ }) {
2024
+ const { open } = useInternal();
2025
+ return /* @__PURE__ */ jsx5("span", { ...useScope(className, style), children: /* @__PURE__ */ jsxs5("button", { type: "button", className: "ya-askabout", onClick: () => open({ view: "new", topic }), children: [
2026
+ /* @__PURE__ */ jsx5(IconIdea, {}),
2027
+ prompt ?? `Want more from ${topic}?`
2028
+ ] }) });
2029
+ }
2030
+ function AskForIt({ query, className, style }) {
2031
+ const { open } = useInternal();
2032
+ const q = query.trim();
2033
+ const shown = q.length > 40 ? `${q.slice(0, 39).trimEnd()}\u2026` : q;
2034
+ return /* @__PURE__ */ jsx5("span", { ...useScope(className, style), children: /* @__PURE__ */ jsxs5("button", { type: "button", className: "ya-askforit", onClick: () => open({ view: "new", draft: q, topic: "search" }), children: [
2035
+ /* @__PURE__ */ jsx5("span", { children: shown ? `Can't find \u201C${shown}\u201D?` : "Can't find it?" }),
2036
+ /* @__PURE__ */ jsxs5("b", { children: [
2037
+ "Ask for it",
2038
+ /* @__PURE__ */ jsx5(IconChevron, {})
2039
+ ] })
2040
+ ] }) });
2041
+ }
2042
+ function FeatureBoard({
2043
+ start = "home",
2044
+ height = "min(720px, 80vh)",
2045
+ className,
2046
+ style
2047
+ }) {
2048
+ const [route, setRoute] = useState4(start === "board" ? { view: "board" } : { view: "home" });
2049
+ return /* @__PURE__ */ jsx5("div", { ...useScope(className, style), children: /* @__PURE__ */ jsx5("div", { className: "ya-embed", style: { height }, children: /* @__PURE__ */ jsx5(Navigator, { route, setRoute }) }) });
2050
+ }
2051
+ export {
2052
+ AskAbout,
2053
+ AskBar,
2054
+ AskForIt,
2055
+ DEFAULT_API_URL,
2056
+ FeatureBoard,
2057
+ FeatureCard,
2058
+ RequestButton,
2059
+ YouAsked,
2060
+ openYouAsked,
2061
+ useYouAsked
2062
+ };