@youasked/react 0.0.0-stage → 0.5.0

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