@tetsuo-ai/marketplace-react 0.4.0 → 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.
Files changed (88) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/README.md +93 -47
  3. package/dist/chunk-7NKRSPPN.js +227 -0
  4. package/dist/chunk-7NKRSPPN.js.map +1 -0
  5. package/dist/{chunk-BNILOX3O.js → chunk-CDDHUFMG.js} +38 -6
  6. package/dist/chunk-CDDHUFMG.js.map +1 -0
  7. package/dist/chunk-FIDFPM5A.cjs +40 -0
  8. package/dist/chunk-FIDFPM5A.cjs.map +1 -0
  9. package/dist/chunk-IJKWKY4H.cjs +1370 -0
  10. package/dist/chunk-IJKWKY4H.cjs.map +1 -0
  11. package/dist/chunk-JTSG5FGC.cjs +397 -0
  12. package/dist/chunk-JTSG5FGC.cjs.map +1 -0
  13. package/dist/chunk-ONC6L3IX.cjs +97 -0
  14. package/dist/chunk-ONC6L3IX.cjs.map +1 -0
  15. package/dist/chunk-R76EUYDI.cjs +233 -0
  16. package/dist/chunk-R76EUYDI.cjs.map +1 -0
  17. package/dist/chunk-RG5JZ6JL.js +378 -0
  18. package/dist/chunk-RG5JZ6JL.js.map +1 -0
  19. package/dist/components/index.cjs +158 -1513
  20. package/dist/components/index.cjs.map +1 -1
  21. package/dist/components/index.d.cts +2 -2
  22. package/dist/components/index.d.ts +2 -2
  23. package/dist/components/index.js +2 -2
  24. package/dist/hooks/index.cjs +693 -457
  25. package/dist/hooks/index.cjs.map +1 -1
  26. package/dist/hooks/index.d.cts +109 -28
  27. package/dist/hooks/index.d.ts +109 -28
  28. package/dist/hooks/index.js +659 -178
  29. package/dist/hooks/index.js.map +1 -1
  30. package/dist/{index-DQ3Xovkq.d.ts → index-BAyr1ODZ.d.ts} +76 -6
  31. package/dist/{index-UxuvIlmD.d.cts → index-C20NVU7_.d.cts} +76 -6
  32. package/dist/index.cjs +284 -1752
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.cts +7 -8
  35. package/dist/index.d.ts +7 -8
  36. package/dist/index.js +64 -4
  37. package/dist/index.js.map +1 -1
  38. package/dist/signers/index.cjs +22 -161
  39. package/dist/signers/index.cjs.map +1 -1
  40. package/dist/signers/index.d.cts +16 -11
  41. package/dist/signers/index.d.ts +16 -11
  42. package/dist/signers/index.js +1 -1
  43. package/dist/testing/index.d.cts +1 -1
  44. package/dist/testing/index.d.ts +1 -1
  45. package/dist/theme/agenc-tailwind-preset.cjs +134 -108
  46. package/dist/{types-jvISR6bc.d.cts → types-B10rndEI.d.cts} +16 -7
  47. package/dist/{types-jvISR6bc.d.ts → types-B10rndEI.d.ts} +16 -7
  48. package/dist/{useAgentTrackRecord-BCvRHYM2.d.cts → useAgentTrackRecord-Ch7gHTFj.d.cts} +40 -3
  49. package/dist/{useAgentTrackRecord-BCvRHYM2.d.ts → useAgentTrackRecord-Ch7gHTFj.d.ts} +40 -3
  50. package/package.json +6 -3
  51. package/src/components/GuaranteedBadge.tsx +73 -0
  52. package/src/components/HireCheckoutModal.tsx +5 -2
  53. package/src/components/index.ts +4 -0
  54. package/src/components/strings.ts +8 -0
  55. package/src/hooks/index.ts +14 -0
  56. package/src/hooks/internal.ts +179 -22
  57. package/src/hooks/useAgentTrackRecord.ts +5 -2
  58. package/src/hooks/useCompletionBond.ts +191 -0
  59. package/src/hooks/useDispute.ts +46 -9
  60. package/src/hooks/useHire.ts +113 -23
  61. package/src/hooks/useHumanlessHireFlow.ts +335 -115
  62. package/src/hooks/useListing.ts +2 -2
  63. package/src/hooks/useListings.ts +2 -2
  64. package/src/hooks/useRateHire.ts +32 -5
  65. package/src/hooks/useReferrerEarnings.ts +4 -1
  66. package/src/hooks/useSubmissionReview.ts +95 -32
  67. package/src/hooks/useTaskActivation.ts +51 -9
  68. package/src/hooks/useTaskGuarantee.ts +123 -0
  69. package/src/hooks/useTaskLifecycle.ts +104 -24
  70. package/src/hooks/useTaskStatus.ts +121 -26
  71. package/src/hooks/useTaskWork.ts +76 -12
  72. package/src/hooks/useWalletSigner.ts +11 -16
  73. package/src/index.ts +5 -0
  74. package/src/provider/AgencProvider.tsx +95 -3
  75. package/src/provider/referrer.ts +1 -1
  76. package/src/signers/README.md +13 -7
  77. package/src/signers/index.ts +6 -1
  78. package/src/signers/strings.ts +13 -1
  79. package/src/signers/types.ts +16 -5
  80. package/src/signers/wallet-account.ts +115 -29
  81. package/src/signers/wallet-adapter.ts +38 -4
  82. package/src/theme/agenc-tailwind-preset.cjs +134 -108
  83. package/src/types.ts +32 -3
  84. package/dist/chunk-BNILOX3O.js.map +0 -1
  85. package/dist/chunk-BTAVED7S.js +0 -226
  86. package/dist/chunk-BTAVED7S.js.map +0 -1
  87. package/dist/chunk-ON6XR4XO.js +0 -128
  88. package/dist/chunk-ON6XR4XO.js.map +0 -1
@@ -0,0 +1,1370 @@
1
+ 'use strict';
2
+
3
+ var chunkJTSG5FGC_cjs = require('./chunk-JTSG5FGC.cjs');
4
+ var chunkFIDFPM5A_cjs = require('./chunk-FIDFPM5A.cjs');
5
+ var marketplaceSdk = require('@tetsuo-ai/marketplace-sdk');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+ var react = require('react');
8
+ var reactQuery = require('@tanstack/react-query');
9
+
10
+ // src/theme/index.ts
11
+ var AGENC_THEME_CLASS = "agenc";
12
+ var AGENC_TOKENS_CSS_PATH = "@tetsuo-ai/marketplace-react/theme.css";
13
+ function resolveThemeClassName(unstyled, extra) {
14
+ if (unstyled) {
15
+ return extra && extra.trim() !== "" ? extra : void 0;
16
+ }
17
+ const composed = [AGENC_THEME_CLASS, extra].filter((part) => Boolean(part && part.trim() !== "")).join(" ");
18
+ return composed === "" ? void 0 : composed;
19
+ }
20
+ function agencThemeStyleTag() {
21
+ return `:root,.${AGENC_THEME_CLASS}{--agenc-void:#0A0612;--agenc-surface:#16102A;--agenc-surface-2:#221638;--agenc-surface-3:#2E1A4A;--agenc-violet:#7B3FFF;--agenc-magenta:#FF2E93;--agenc-orange:#FF6B1A;--agenc-cyan:#48C8EF;--agenc-text:#F5F0FF;--agenc-text-muted:#B8A8D9;--agenc-text-dim:#6E5C8F;--agenc-success:#3FFFA0;--agenc-warning:#FFC53F;--agenc-danger:#FF3D3D;--agenc-border:#2E1A4A;--agenc-border-strong:#4A2E7A;--agenc-radius-sm:4px;--agenc-radius:8px;--agenc-radius-lg:12px;--agenc-radius-pill:9999px;}`;
22
+ }
23
+
24
+ // src/components/strings.ts
25
+ var EN_COMPONENT_STRINGS = {
26
+ // Shared / cross-component.
27
+ "components.common.loading": "Loading\u2026",
28
+ "components.common.empty": "Nothing to show yet.",
29
+ "components.common.error": "Something went wrong.",
30
+ "components.common.retry": "Retry",
31
+ "components.common.close": "Close",
32
+ "components.common.verified": "Verified",
33
+ "components.common.unverified": "Unverified",
34
+ "components.common.sol": "SOL",
35
+ "components.common.lamports": "lamports",
36
+ // ListingCard.
37
+ "components.listingCard.priceLabel": "Price",
38
+ "components.listingCard.byProvider": "by {provider}",
39
+ "components.listingCard.untitled": "Untitled service",
40
+ "components.listingCard.hires": "{count} hires",
41
+ "components.listingCard.category": "Category",
42
+ // ListingGrid.
43
+ "components.listingGrid.empty": "No listings match your filters yet.",
44
+ "components.listingGrid.loadMore": "Load more",
45
+ "components.listingGrid.error": "Could not load listings.",
46
+ // HireButton / Checkout.
47
+ "components.hire.cta": "Hire",
48
+ "components.hire.ctaPrice": "Hire \u2014 {price}",
49
+ "components.hire.checkoutTitle": "Confirm hire",
50
+ "components.hire.priceLabel": "You pay",
51
+ "components.hire.escrowNote": "Funds are held in protocol escrow and released to the provider only when you accept the result.",
52
+ "components.hire.confirm": "Confirm and fund escrow",
53
+ "components.hire.cancel": "Cancel",
54
+ "components.hire.pending": "Confirming\u2026",
55
+ "components.hire.success": "Escrow funded.",
56
+ "components.hire.successDetail": "Your task is created. Track it below.",
57
+ "components.hire.viewTask": "View task",
58
+ "components.hire.errorTitle": "Hire failed",
59
+ "components.hire.moderationAttested": "Moderation attested",
60
+ "components.hire.moderationPending": "Moderation pending",
61
+ "components.hire.moderationIssues": "Moderation issues found",
62
+ "components.hire.notConnected": "Connect a wallet to hire.",
63
+ // Referrer disclosure.
64
+ "components.referrer.disclosure": "This site earns a referral fee.",
65
+ "components.referrer.disclosurePending": "Referral fee is not active for this hire.",
66
+ "components.referrer.feeBps": "{bps} bps",
67
+ // TaskTimeline.
68
+ "components.taskTimeline.title": "Task progress",
69
+ "components.taskTimeline.empty": "No task to track yet.",
70
+ "components.taskTimeline.status.Open": "Open",
71
+ "components.taskTimeline.status.InProgress": "In progress",
72
+ "components.taskTimeline.status.PendingValidation": "Pending review",
73
+ "components.taskTimeline.status.Completed": "Completed",
74
+ "components.taskTimeline.status.Cancelled": "Cancelled",
75
+ "components.taskTimeline.status.Disputed": "Disputed",
76
+ "components.taskTimeline.status.RejectFrozen": "Rejected (frozen)",
77
+ // ReviewPanel.
78
+ "components.review.title": "Review submission",
79
+ "components.review.noSubmission": "Awaiting the worker's submission.",
80
+ "components.review.accept": "Accept and release escrow",
81
+ "components.review.reject": "Reject",
82
+ "components.review.requestChanges": "Request changes",
83
+ "components.review.accepted": "Result accepted. Escrow released.",
84
+ "components.review.rejected": "Result rejected.",
85
+ "components.review.changesRequested": "Changes requested.",
86
+ "components.review.pending": "Submitting\u2026",
87
+ "components.review.errorTitle": "Review action failed",
88
+ // DisputeBanner.
89
+ "components.dispute.title": "This task is in dispute.",
90
+ "components.dispute.body": "A dispute has been opened. A protocol resolver decides the outcome; funds stay in escrow until then.",
91
+ "components.dispute.initiate": "Open a dispute",
92
+ "components.dispute.pending": "Opening dispute\u2026",
93
+ "components.dispute.opened": "Dispute opened.",
94
+ "components.dispute.none": "No open dispute.",
95
+ "components.dispute.errorTitle": "Could not open dispute",
96
+ // ProviderCard.
97
+ "components.provider.title": "Provider",
98
+ "components.provider.completionRate": "Completion rate",
99
+ "components.provider.disputeRate": "Dispute rate",
100
+ "components.provider.completions": "{count} completed",
101
+ "components.provider.disputes": "{count} disputes",
102
+ "components.provider.provisional": "provisional",
103
+ "components.provider.noData": "No track record yet.",
104
+ "components.provider.unavailable": "Track record is unavailable on this read transport.",
105
+ // Domain trust (P7.3) — VERIFIED is an on-chain attestation; CLAIMED is the
106
+ // operator's self-reported metadata. The copy keeps them distinct so a buyer
107
+ // never reads an unverified claim as a proven one.
108
+ "components.provider.verifiedDomain": "Verified: {domain}",
109
+ "components.provider.verifiedDomainLabel": "Verified domain {domain}",
110
+ "components.provider.claimedDomain": "Claims: {domain}",
111
+ "components.provider.claimedDomainLabel": "Claimed domain {domain} (not verified on-chain)",
112
+ // GuaranteedBadge (WP-H3 Guaranteed Hire). The detail copy is deliberately
113
+ // phase-1-honest: the buyer is refunded (escrow) and the worker FORFEITS the
114
+ // bond — it does NOT say the buyer receives the bond, because a forfeited
115
+ // bond pays the protocol treasury until phase 2 redirects it.
116
+ "components.guarantee.badge": "Guaranteed \u2014 worker has 25% at stake",
117
+ "components.guarantee.detail": "Worker has 25% at stake \u2014 if the result fails review you're refunded and the worker forfeits the bond.",
118
+ // PoweredByAgenC.
119
+ "components.poweredBy.label": "Powered by AgenC",
120
+ "components.poweredBy.trustLink": "Learn how this works"
121
+ };
122
+ var COMPONENT_CATALOG = {
123
+ ...chunkFIDFPM5A_cjs.EN_STRINGS,
124
+ ...EN_COMPONENT_STRINGS
125
+ };
126
+
127
+ // src/components/format.ts
128
+ function tc(id, vars, options) {
129
+ return chunkFIDFPM5A_cjs.t(id, vars, { catalog: COMPONENT_CATALOG, ...options });
130
+ }
131
+ var LAMPORTS_PER_SOL = 1000000000n;
132
+ function formatSol(lamports) {
133
+ const negative = lamports < 0n;
134
+ const abs = negative ? -lamports : lamports;
135
+ const whole = abs / LAMPORTS_PER_SOL;
136
+ const frac = abs % LAMPORTS_PER_SOL;
137
+ let out;
138
+ if (frac === 0n) {
139
+ out = whole.toString();
140
+ } else {
141
+ const fracStr = frac.toString().padStart(9, "0").replace(/0+$/, "");
142
+ out = `${whole.toString()}.${fracStr}`;
143
+ }
144
+ return negative ? `-${out}` : out;
145
+ }
146
+ function formatPriceSol(lamports, options) {
147
+ return `${formatSol(lamports)} ${chunkFIDFPM5A_cjs.t("components.common.sol", void 0, {
148
+ catalog: COMPONENT_CATALOG,
149
+ ...options
150
+ })}`;
151
+ }
152
+ function truncateAddress(value, head = 4, tail = 4) {
153
+ if (value === null || value === void 0) return "";
154
+ const s = String(value);
155
+ if (s.length <= head + tail + 1) return s;
156
+ return `${s.slice(0, head)}\u2026${s.slice(-tail)}`;
157
+ }
158
+ function decodeListingName(listing) {
159
+ try {
160
+ return marketplaceSdk.values.decodeListingName(Uint8Array.from(listing.name));
161
+ } catch {
162
+ return "";
163
+ }
164
+ }
165
+ function decodeListingCategory(listing) {
166
+ try {
167
+ return marketplaceSdk.values.decodeListingCategory(Uint8Array.from(listing.category));
168
+ } catch {
169
+ return "";
170
+ }
171
+ }
172
+ function decodeListingTags(listing) {
173
+ try {
174
+ return marketplaceSdk.values.decodeListingTags(Uint8Array.from(listing.tags));
175
+ } catch {
176
+ return [];
177
+ }
178
+ }
179
+ function toHex(bytes) {
180
+ let out = "";
181
+ for (let i = 0; i < bytes.length; i++) {
182
+ out += bytes[i].toString(16).padStart(2, "0");
183
+ }
184
+ return out;
185
+ }
186
+ function formatRate(rate, fallback = "\u2014") {
187
+ if (rate === null || Number.isNaN(rate)) return fallback;
188
+ const pct = Math.round(rate * 100);
189
+ return `${pct}%`;
190
+ }
191
+ function cx(...parts) {
192
+ return parts.filter((p) => Boolean(p)).join(" ");
193
+ }
194
+ function elementClass(base, unstyled, extra) {
195
+ if (unstyled) return extra && extra.trim() !== "" ? extra : void 0;
196
+ return cx(base, extra) || void 0;
197
+ }
198
+ function rootClass(base, unstyled, extra) {
199
+ if (unstyled) return extra && extra.trim() !== "" ? extra : void 0;
200
+ return cx(AGENC_THEME_CLASS, base, extra) || void 0;
201
+ }
202
+ var STATE_STRING = {
203
+ loading: "components.common.loading",
204
+ empty: "components.common.empty",
205
+ error: "components.common.error"
206
+ };
207
+ function StateMessage({
208
+ kind,
209
+ message,
210
+ onRetry,
211
+ role,
212
+ unstyled,
213
+ className
214
+ }) {
215
+ const text = message ?? tc(STATE_STRING[kind]);
216
+ const resolvedRole = role ?? (kind === "error" ? "alert" : "status");
217
+ return /* @__PURE__ */ jsxRuntime.jsxs(
218
+ "div",
219
+ {
220
+ className: elementClass(`agenc-state agenc-state--${kind}`, unstyled, className),
221
+ role: resolvedRole,
222
+ "aria-live": kind === "error" ? "assertive" : "polite",
223
+ "aria-busy": kind === "loading" ? true : void 0,
224
+ children: [
225
+ kind === "loading" ? /* @__PURE__ */ jsxRuntime.jsx(Spinner, { unstyled }) : null,
226
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: unstyled ? void 0 : "agenc-state__text", children: text }),
227
+ onRetry && kind !== "loading" ? /* @__PURE__ */ jsxRuntime.jsx(Button, { unstyled, variant: "ghost", onClick: onRetry, children: tc("components.common.retry") }) : null
228
+ ]
229
+ }
230
+ );
231
+ }
232
+ function Spinner({ label, unstyled, className }) {
233
+ return /* @__PURE__ */ jsxRuntime.jsx(
234
+ "span",
235
+ {
236
+ className: elementClass("agenc-spinner", unstyled, className),
237
+ role: "status",
238
+ "aria-live": "polite",
239
+ children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: unstyled ? void 0 : "agenc-visually-hidden", children: label ?? tc("components.common.loading") })
240
+ }
241
+ );
242
+ }
243
+ function Badge({
244
+ tone = "neutral",
245
+ children,
246
+ label,
247
+ unstyled,
248
+ className
249
+ }) {
250
+ return /* @__PURE__ */ jsxRuntime.jsx(
251
+ "span",
252
+ {
253
+ className: elementClass(
254
+ `agenc-badge agenc-badge--${tone}`,
255
+ unstyled,
256
+ className
257
+ ),
258
+ title: label,
259
+ "aria-label": label,
260
+ children
261
+ }
262
+ );
263
+ }
264
+ function Button({
265
+ variant = "primary",
266
+ loading = false,
267
+ unstyled,
268
+ className,
269
+ children,
270
+ disabled,
271
+ type,
272
+ ...rest
273
+ }) {
274
+ return /* @__PURE__ */ jsxRuntime.jsxs(
275
+ "button",
276
+ {
277
+ type: type ?? "button",
278
+ className: elementClass(
279
+ `agenc-button agenc-button--${variant}`,
280
+ unstyled,
281
+ className
282
+ ),
283
+ disabled: disabled || loading,
284
+ "aria-busy": loading || void 0,
285
+ ...rest,
286
+ children: [
287
+ loading ? /* @__PURE__ */ jsxRuntime.jsx(Spinner, { unstyled }) : null,
288
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: unstyled ? void 0 : "agenc-button__label", children })
289
+ ]
290
+ }
291
+ );
292
+ }
293
+ function moderationStateOf(moderation) {
294
+ if (!moderation) return "pending";
295
+ return moderation.metadataValid ? "attested" : "issues";
296
+ }
297
+ var MODERATION_TONE = {
298
+ attested: "success",
299
+ pending: "neutral",
300
+ issues: "warning"
301
+ };
302
+ var MODERATION_STRING = {
303
+ attested: "components.hire.moderationAttested",
304
+ pending: "components.hire.moderationPending",
305
+ // Distinct from `pending` ("Moderation pending") so a buyer can textually
306
+ // tell "we found problems" apart from "we haven't checked", not just by tone.
307
+ issues: "components.hire.moderationIssues"
308
+ };
309
+ function ModerationBadge({
310
+ moderation,
311
+ state,
312
+ unstyled,
313
+ className
314
+ }) {
315
+ const resolved = state ?? moderationStateOf(moderation);
316
+ const label = tc(MODERATION_STRING[resolved]);
317
+ const issues = resolved === "issues" && moderation?.metadataIssues?.length ? moderation.metadataIssues.join("; ") : void 0;
318
+ return /* @__PURE__ */ jsxRuntime.jsx(
319
+ Badge,
320
+ {
321
+ tone: MODERATION_TONE[resolved],
322
+ unstyled,
323
+ className,
324
+ label: issues ?? label,
325
+ children: label
326
+ }
327
+ );
328
+ }
329
+ function VerifiedBadge({
330
+ verified,
331
+ unstyled,
332
+ className
333
+ }) {
334
+ return /* @__PURE__ */ jsxRuntime.jsx(
335
+ Badge,
336
+ {
337
+ tone: verified ? "success" : "neutral",
338
+ unstyled,
339
+ className,
340
+ children: verified ? tc("components.common.verified") : tc("components.common.unverified")
341
+ }
342
+ );
343
+ }
344
+ function GuaranteedBadge({
345
+ task,
346
+ guarantee,
347
+ guaranteeReader,
348
+ unstyled,
349
+ className
350
+ }) {
351
+ const overridden = guarantee !== void 0;
352
+ const read = chunkJTSG5FGC_cjs.useTaskGuarantee(overridden ? null : task, {
353
+ guaranteeReader,
354
+ enabled: !overridden
355
+ });
356
+ const resolved = overridden ? guarantee : read.guarantee;
357
+ if (!resolved?.guaranteed) return null;
358
+ return /* @__PURE__ */ jsxRuntime.jsx(
359
+ Badge,
360
+ {
361
+ tone: "success",
362
+ unstyled,
363
+ className,
364
+ label: tc("components.guarantee.detail"),
365
+ children: tc("components.guarantee.badge")
366
+ }
367
+ );
368
+ }
369
+ var FOCUSABLE_SELECTOR = [
370
+ "a[href]",
371
+ "button:not([disabled])",
372
+ "textarea:not([disabled])",
373
+ "input:not([disabled])",
374
+ "select:not([disabled])",
375
+ '[tabindex]:not([tabindex="-1"])'
376
+ ].join(",");
377
+ function focusableWithin(container) {
378
+ return Array.from(
379
+ container.querySelectorAll(FOCUSABLE_SELECTOR)
380
+ ).filter((el) => el.offsetParent !== null || el === document.activeElement);
381
+ }
382
+ function useFocusTrap(containerRef, active, onEscape) {
383
+ react.useEffect(() => {
384
+ if (!active) return;
385
+ const container = containerRef.current;
386
+ if (!container) return;
387
+ const previouslyFocused = document.activeElement instanceof HTMLElement ? document.activeElement : null;
388
+ const initial = focusableWithin(container)[0] ?? container;
389
+ initial.focus();
390
+ function onKeyDown(event) {
391
+ if (event.key === "Escape") {
392
+ event.stopPropagation();
393
+ onEscape?.();
394
+ return;
395
+ }
396
+ if (event.key !== "Tab") return;
397
+ const focusable = focusableWithin(container);
398
+ if (focusable.length === 0) {
399
+ event.preventDefault();
400
+ container.focus();
401
+ return;
402
+ }
403
+ const first = focusable[0];
404
+ const last = focusable[focusable.length - 1];
405
+ const activeEl = document.activeElement;
406
+ if (event.shiftKey) {
407
+ if (activeEl === first || activeEl === container) {
408
+ event.preventDefault();
409
+ last.focus();
410
+ }
411
+ } else if (activeEl === last) {
412
+ event.preventDefault();
413
+ first.focus();
414
+ }
415
+ }
416
+ function onFocusIn(event) {
417
+ const target = event.target;
418
+ if (!(target instanceof Node)) return;
419
+ if (container.contains(target)) return;
420
+ event.stopPropagation();
421
+ const focusable = focusableWithin(container);
422
+ (focusable[0] ?? container).focus();
423
+ }
424
+ container.addEventListener("keydown", onKeyDown);
425
+ document.addEventListener("focusin", onFocusIn);
426
+ return () => {
427
+ container.removeEventListener("keydown", onKeyDown);
428
+ document.removeEventListener("focusin", onFocusIn);
429
+ previouslyFocused?.focus();
430
+ };
431
+ }, [containerRef, active, onEscape]);
432
+ }
433
+ function Modal({
434
+ open,
435
+ onClose,
436
+ title,
437
+ children,
438
+ footer,
439
+ disableEscapeClose = false,
440
+ disableOverlayClose = false,
441
+ hideCloseButton = false,
442
+ closeLabel,
443
+ unstyled,
444
+ className
445
+ }) {
446
+ const dialogRef = react.useRef(null);
447
+ const titleId = react.useId();
448
+ const bodyId = react.useId();
449
+ useFocusTrap(dialogRef, open, () => {
450
+ if (!disableEscapeClose) onClose();
451
+ });
452
+ if (!open) return null;
453
+ const overlayClass = rootClass("agenc-modal", unstyled, className);
454
+ return /* @__PURE__ */ jsxRuntime.jsx(
455
+ "div",
456
+ {
457
+ className: overlayClass,
458
+ onMouseDown: (event) => {
459
+ if (disableOverlayClose) return;
460
+ if (event.target === event.currentTarget) onClose();
461
+ },
462
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
463
+ "div",
464
+ {
465
+ className: unstyled ? void 0 : "agenc-modal__dialog",
466
+ ref: dialogRef,
467
+ role: "dialog",
468
+ "aria-modal": "true",
469
+ "aria-labelledby": titleId,
470
+ "aria-describedby": bodyId,
471
+ tabIndex: -1,
472
+ children: [
473
+ /* @__PURE__ */ jsxRuntime.jsxs("header", { className: unstyled ? void 0 : "agenc-modal__header", children: [
474
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { id: titleId, className: unstyled ? void 0 : "agenc-modal__title", children: title }),
475
+ hideCloseButton ? null : /* @__PURE__ */ jsxRuntime.jsx(
476
+ "button",
477
+ {
478
+ type: "button",
479
+ className: unstyled ? void 0 : "agenc-modal__close",
480
+ "aria-label": closeLabel ?? tc("components.common.close"),
481
+ onClick: onClose,
482
+ children: /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", children: "\xD7" })
483
+ }
484
+ )
485
+ ] }),
486
+ /* @__PURE__ */ jsxRuntime.jsx("div", { id: bodyId, className: unstyled ? void 0 : "agenc-modal__body", children }),
487
+ footer ? /* @__PURE__ */ jsxRuntime.jsx("footer", { className: unstyled ? void 0 : "agenc-modal__footer", children: footer }) : null
488
+ ]
489
+ }
490
+ )
491
+ }
492
+ );
493
+ }
494
+ function ListingCard({
495
+ listing,
496
+ moderation,
497
+ onHire,
498
+ onSelect,
499
+ hidePrice = false,
500
+ unstyled,
501
+ className
502
+ }) {
503
+ const { account } = listing;
504
+ const name = decodeListingName(account) || tc("components.listingCard.untitled");
505
+ const category = decodeListingCategory(account);
506
+ const price = formatPriceSol(account.price);
507
+ const provider = truncateAddress(account.providerAgent);
508
+ const hires = account.totalHires;
509
+ const cardClass = rootClass("agenc-listing-card", unstyled, className);
510
+ const selectable = Boolean(onSelect);
511
+ const heading = /* @__PURE__ */ jsxRuntime.jsx("h3", { className: unstyled ? void 0 : "agenc-listing-card__title", children: name });
512
+ return /* @__PURE__ */ jsxRuntime.jsxs(
513
+ "article",
514
+ {
515
+ className: cardClass,
516
+ "aria-label": name,
517
+ children: [
518
+ /* @__PURE__ */ jsxRuntime.jsxs("header", { className: unstyled ? void 0 : "agenc-listing-card__header", children: [
519
+ selectable ? /* @__PURE__ */ jsxRuntime.jsx(
520
+ "button",
521
+ {
522
+ type: "button",
523
+ className: unstyled ? void 0 : "agenc-listing-card__title-button",
524
+ onClick: () => onSelect?.(listing),
525
+ children: heading
526
+ }
527
+ ) : heading,
528
+ /* @__PURE__ */ jsxRuntime.jsx(ModerationBadge, { moderation, unstyled })
529
+ ] }),
530
+ /* @__PURE__ */ jsxRuntime.jsxs("dl", { className: unstyled ? void 0 : "agenc-listing-card__meta", children: [
531
+ category ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: unstyled ? void 0 : "agenc-listing-card__meta-row", children: [
532
+ /* @__PURE__ */ jsxRuntime.jsx("dt", { children: tc("components.listingCard.category") }),
533
+ /* @__PURE__ */ jsxRuntime.jsx("dd", { children: /* @__PURE__ */ jsxRuntime.jsx(Badge, { tone: "info", unstyled, children: category }) })
534
+ ] }) : null,
535
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: unstyled ? void 0 : "agenc-listing-card__meta-row", children: [
536
+ /* @__PURE__ */ jsxRuntime.jsx("dt", { children: tc("components.listingCard.byProvider", { provider }) }),
537
+ /* @__PURE__ */ jsxRuntime.jsx("dd", { children: tc("components.listingCard.hires", { count: String(hires) }) })
538
+ ] })
539
+ ] }),
540
+ /* @__PURE__ */ jsxRuntime.jsxs("footer", { className: unstyled ? void 0 : "agenc-listing-card__footer", children: [
541
+ hidePrice ? null : /* @__PURE__ */ jsxRuntime.jsxs("p", { className: unstyled ? void 0 : "agenc-listing-card__price", children: [
542
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: unstyled ? void 0 : "agenc-listing-card__price-label", children: tc("components.listingCard.priceLabel") }),
543
+ " ",
544
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: unstyled ? void 0 : "agenc-listing-card__price-value", children: price })
545
+ ] }),
546
+ onHire ? /* @__PURE__ */ jsxRuntime.jsx(
547
+ Button,
548
+ {
549
+ unstyled,
550
+ variant: "primary",
551
+ onClick: () => onHire(listing),
552
+ children: tc("components.hire.cta")
553
+ }
554
+ ) : null
555
+ ] })
556
+ ]
557
+ }
558
+ );
559
+ }
560
+ function ListingGrid({
561
+ listings,
562
+ isLoading = false,
563
+ error = null,
564
+ hasMore = false,
565
+ onLoadMore,
566
+ onRetry,
567
+ onHire,
568
+ onSelect,
569
+ moderationByPda,
570
+ emptyMessage,
571
+ unstyled,
572
+ className
573
+ }) {
574
+ const gridClass = rootClass("agenc-listing-grid", unstyled, className);
575
+ if (error) {
576
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: gridClass, children: /* @__PURE__ */ jsxRuntime.jsx(
577
+ StateMessage,
578
+ {
579
+ kind: "error",
580
+ message: tc("components.listingGrid.error"),
581
+ onRetry,
582
+ unstyled
583
+ }
584
+ ) });
585
+ }
586
+ if (isLoading && listings.length === 0) {
587
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: gridClass, children: /* @__PURE__ */ jsxRuntime.jsx(StateMessage, { kind: "loading", unstyled }) });
588
+ }
589
+ if (listings.length === 0) {
590
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: gridClass, children: /* @__PURE__ */ jsxRuntime.jsx(
591
+ StateMessage,
592
+ {
593
+ kind: "empty",
594
+ message: emptyMessage ?? tc("components.listingGrid.empty"),
595
+ unstyled
596
+ }
597
+ ) });
598
+ }
599
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: gridClass, children: [
600
+ /* @__PURE__ */ jsxRuntime.jsx(
601
+ "ul",
602
+ {
603
+ className: unstyled ? void 0 : "agenc-listing-grid__list",
604
+ children: listings.map((listing) => /* @__PURE__ */ jsxRuntime.jsx(
605
+ "li",
606
+ {
607
+ className: unstyled ? void 0 : "agenc-listing-grid__item",
608
+ children: /* @__PURE__ */ jsxRuntime.jsx(
609
+ ListingCard,
610
+ {
611
+ listing,
612
+ moderation: moderationByPda?.[String(listing.address)] ?? null,
613
+ onHire,
614
+ onSelect,
615
+ unstyled
616
+ }
617
+ )
618
+ },
619
+ String(listing.address)
620
+ ))
621
+ }
622
+ ),
623
+ hasMore && onLoadMore ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: unstyled ? void 0 : "agenc-listing-grid__more", children: /* @__PURE__ */ jsxRuntime.jsx(
624
+ "button",
625
+ {
626
+ type: "button",
627
+ className: unstyled ? void 0 : "agenc-button agenc-button--secondary",
628
+ onClick: onLoadMore,
629
+ children: tc("components.listingGrid.loadMore")
630
+ }
631
+ ) }) : null
632
+ ] });
633
+ }
634
+ function ReferrerDisclosure({
635
+ referrer,
636
+ live = false,
637
+ showFee = true,
638
+ unstyled,
639
+ className
640
+ }) {
641
+ const text = live ? tc("components.referrer.disclosure") : tc("components.referrer.disclosurePending");
642
+ return /* @__PURE__ */ jsxRuntime.jsxs(
643
+ "p",
644
+ {
645
+ className: unstyled ? className : cx("agenc-referrer-disclosure", className),
646
+ role: "note",
647
+ children: [
648
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: text }),
649
+ showFee ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: unstyled ? void 0 : "agenc-referrer-disclosure__fee", children: [
650
+ " ",
651
+ tc("components.referrer.feeBps", { bps: String(referrer.feeBps) })
652
+ ] }) : null
653
+ ]
654
+ }
655
+ );
656
+ }
657
+ function HireCheckoutModal({
658
+ open,
659
+ onClose,
660
+ listing,
661
+ onConfirm,
662
+ status = "idle",
663
+ error = null,
664
+ taskPda = null,
665
+ onViewTask,
666
+ moderation,
667
+ referrer,
668
+ referrerLive = false,
669
+ connected = true,
670
+ unstyled,
671
+ className
672
+ }) {
673
+ const pending = status === "pending";
674
+ const success = status === "success";
675
+ const price = formatPriceSol(listing.account.price);
676
+ const [submitting, setSubmitting] = react.useState(false);
677
+ const submittingRef = react.useRef(false);
678
+ react.useEffect(() => {
679
+ if (!open || !pending) {
680
+ submittingRef.current = false;
681
+ setSubmitting(false);
682
+ }
683
+ }, [open, pending]);
684
+ const handleConfirm = react.useCallback(() => {
685
+ if (submittingRef.current) return;
686
+ submittingRef.current = true;
687
+ setSubmitting(true);
688
+ let result;
689
+ try {
690
+ result = onConfirm();
691
+ } catch {
692
+ submittingRef.current = false;
693
+ setSubmitting(false);
694
+ return;
695
+ }
696
+ if (result && typeof result.then === "function") {
697
+ const releaseLatch = () => {
698
+ submittingRef.current = false;
699
+ setSubmitting(false);
700
+ };
701
+ void Promise.resolve(result).then(releaseLatch, releaseLatch);
702
+ }
703
+ }, [onConfirm]);
704
+ const confirmDisabled = !connected || pending || submitting;
705
+ const lockClose = pending || submitting;
706
+ const footer = success ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
707
+ taskPda && onViewTask ? /* @__PURE__ */ jsxRuntime.jsx(
708
+ Button,
709
+ {
710
+ unstyled,
711
+ variant: "primary",
712
+ onClick: () => onViewTask(taskPda),
713
+ children: tc("components.hire.viewTask")
714
+ }
715
+ ) : null,
716
+ /* @__PURE__ */ jsxRuntime.jsx(Button, { unstyled, variant: "secondary", onClick: onClose, children: tc("components.common.close") })
717
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
718
+ /* @__PURE__ */ jsxRuntime.jsx(
719
+ Button,
720
+ {
721
+ unstyled,
722
+ variant: "secondary",
723
+ onClick: onClose,
724
+ disabled: pending || submitting,
725
+ children: tc("components.hire.cancel")
726
+ }
727
+ ),
728
+ /* @__PURE__ */ jsxRuntime.jsx(
729
+ Button,
730
+ {
731
+ unstyled,
732
+ variant: "primary",
733
+ loading: pending || submitting,
734
+ disabled: confirmDisabled,
735
+ onClick: handleConfirm,
736
+ children: pending || submitting ? tc("components.hire.pending") : tc("components.hire.confirm")
737
+ }
738
+ )
739
+ ] });
740
+ return /* @__PURE__ */ jsxRuntime.jsx(
741
+ Modal,
742
+ {
743
+ open,
744
+ onClose,
745
+ title: tc("components.hire.checkoutTitle"),
746
+ footer,
747
+ disableEscapeClose: lockClose,
748
+ disableOverlayClose: lockClose,
749
+ hideCloseButton: lockClose,
750
+ unstyled,
751
+ className,
752
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: unstyled ? void 0 : "agenc-checkout", children: [
753
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: unstyled ? void 0 : "agenc-checkout__row", children: [
754
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: unstyled ? void 0 : "agenc-checkout__price-label", children: tc("components.hire.priceLabel") }),
755
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: unstyled ? void 0 : "agenc-checkout__price", children: price })
756
+ ] }),
757
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: unstyled ? void 0 : "agenc-checkout__moderation", children: /* @__PURE__ */ jsxRuntime.jsx(ModerationBadge, { moderation, unstyled }) }),
758
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: unstyled ? void 0 : "agenc-checkout__escrow-note", children: tc("components.hire.escrowNote") }),
759
+ referrer ? /* @__PURE__ */ jsxRuntime.jsx(
760
+ ReferrerDisclosure,
761
+ {
762
+ referrer,
763
+ live: referrerLive,
764
+ unstyled
765
+ }
766
+ ) : null,
767
+ /* @__PURE__ */ jsxRuntime.jsxs(
768
+ "div",
769
+ {
770
+ className: unstyled ? void 0 : "agenc-checkout__status",
771
+ role: "status",
772
+ "aria-live": "polite",
773
+ children: [
774
+ pending ? tc("components.hire.pending") : null,
775
+ success ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
776
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: tc("components.hire.success") }),
777
+ " ",
778
+ tc("components.hire.successDetail")
779
+ ] }) : null
780
+ ]
781
+ }
782
+ ),
783
+ error ? /* @__PURE__ */ jsxRuntime.jsxs(
784
+ "div",
785
+ {
786
+ className: unstyled ? void 0 : "agenc-checkout__error",
787
+ role: "alert",
788
+ "aria-live": "assertive",
789
+ children: [
790
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: tc("components.hire.errorTitle") }),
791
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: error.message })
792
+ ]
793
+ }
794
+ ) : null,
795
+ !connected && !success ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: unstyled ? void 0 : "agenc-checkout__hint", children: tc("components.hire.notConnected") }) : null
796
+ ] })
797
+ }
798
+ );
799
+ }
800
+ function HireButton({
801
+ listing,
802
+ buildHireInput,
803
+ onHired,
804
+ onViewTask,
805
+ showPriceInLabel = true,
806
+ label,
807
+ unstyled,
808
+ className
809
+ }) {
810
+ const ctx = chunkJTSG5FGC_cjs.useAgencContext();
811
+ const { hire, status, error, taskPda, reset } = chunkJTSG5FGC_cjs.useHire();
812
+ const { connected } = chunkJTSG5FGC_cjs.useWalletSigner();
813
+ const [open, setOpen] = react.useState(false);
814
+ const inFlightRef = react.useRef(false);
815
+ const capability = ctx.resolveReferrerCapability();
816
+ const close = react.useCallback(() => {
817
+ setOpen(false);
818
+ inFlightRef.current = false;
819
+ reset();
820
+ }, [reset]);
821
+ const confirm = react.useCallback(async () => {
822
+ if (inFlightRef.current) return;
823
+ inFlightRef.current = true;
824
+ try {
825
+ const input = buildHireInput(listing);
826
+ const result = await hire(input);
827
+ onHired?.(result.taskPda);
828
+ } finally {
829
+ inFlightRef.current = false;
830
+ }
831
+ }, [buildHireInput, hire, listing, onHired]);
832
+ const buttonLabel = label ?? (showPriceInLabel ? tc("components.hire.ctaPrice", {
833
+ price: formatPriceSol(listing.account.price)
834
+ }) : tc("components.hire.cta"));
835
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
836
+ /* @__PURE__ */ jsxRuntime.jsx(
837
+ Button,
838
+ {
839
+ unstyled,
840
+ className,
841
+ variant: "primary",
842
+ onClick: () => setOpen(true),
843
+ children: buttonLabel
844
+ }
845
+ ),
846
+ /* @__PURE__ */ jsxRuntime.jsx(
847
+ HireCheckoutModal,
848
+ {
849
+ open,
850
+ onClose: close,
851
+ listing,
852
+ onConfirm: confirm,
853
+ status,
854
+ error,
855
+ taskPda,
856
+ onViewTask,
857
+ referrer: ctx.referrer,
858
+ referrerLive: capability.live,
859
+ connected,
860
+ unstyled
861
+ }
862
+ )
863
+ ] });
864
+ }
865
+ var HAPPY_PATH = [
866
+ { status: marketplaceSdk.TaskStatus.Open, stringId: "components.taskTimeline.status.Open" },
867
+ {
868
+ status: marketplaceSdk.TaskStatus.InProgress,
869
+ stringId: "components.taskTimeline.status.InProgress"
870
+ },
871
+ {
872
+ status: marketplaceSdk.TaskStatus.PendingValidation,
873
+ stringId: "components.taskTimeline.status.PendingValidation"
874
+ },
875
+ {
876
+ status: marketplaceSdk.TaskStatus.Completed,
877
+ stringId: "components.taskTimeline.status.Completed"
878
+ }
879
+ ];
880
+ var OFF_PATH = {
881
+ [marketplaceSdk.TaskStatus.Cancelled]: {
882
+ stringId: "components.taskTimeline.status.Cancelled",
883
+ tone: "cancelled"
884
+ },
885
+ [marketplaceSdk.TaskStatus.Disputed]: {
886
+ stringId: "components.taskTimeline.status.Disputed",
887
+ tone: "disputed"
888
+ },
889
+ [marketplaceSdk.TaskStatus.RejectFrozen]: {
890
+ stringId: "components.taskTimeline.status.RejectFrozen",
891
+ tone: "rejected"
892
+ }
893
+ };
894
+ function happyIndex(status) {
895
+ return HAPPY_PATH.findIndex((s) => s.status === status);
896
+ }
897
+ function TaskTimeline({
898
+ status,
899
+ isLoading = false,
900
+ error = null,
901
+ onRetry,
902
+ unstyled,
903
+ className
904
+ }) {
905
+ const timelineClass = rootClass("agenc-timeline", unstyled, className);
906
+ if (error) {
907
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: timelineClass, children: /* @__PURE__ */ jsxRuntime.jsx(StateMessage, { kind: "error", onRetry, unstyled }) });
908
+ }
909
+ if (isLoading && status === null) {
910
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: timelineClass, children: /* @__PURE__ */ jsxRuntime.jsx(StateMessage, { kind: "loading", unstyled }) });
911
+ }
912
+ if (status === null) {
913
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: timelineClass, children: /* @__PURE__ */ jsxRuntime.jsx(
914
+ StateMessage,
915
+ {
916
+ kind: "empty",
917
+ message: tc("components.taskTimeline.empty"),
918
+ unstyled
919
+ }
920
+ ) });
921
+ }
922
+ const offPath = OFF_PATH[status];
923
+ const currentIndex = offPath ? -1 : happyIndex(status);
924
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: timelineClass, "aria-label": tc("components.taskTimeline.title"), children: [
925
+ /* @__PURE__ */ jsxRuntime.jsx("ol", { className: unstyled ? void 0 : "agenc-timeline__list", children: HAPPY_PATH.map((stage, index) => {
926
+ const done = currentIndex > index;
927
+ const current = currentIndex === index;
928
+ const state = done ? "done" : current ? "current" : "upcoming";
929
+ return /* @__PURE__ */ jsxRuntime.jsxs(
930
+ "li",
931
+ {
932
+ className: unstyled ? void 0 : cx("agenc-timeline__step", `agenc-timeline__step--${state}`),
933
+ "aria-current": current ? "step" : void 0,
934
+ children: [
935
+ /* @__PURE__ */ jsxRuntime.jsx(
936
+ "span",
937
+ {
938
+ className: unstyled ? void 0 : "agenc-timeline__marker",
939
+ "aria-hidden": "true"
940
+ }
941
+ ),
942
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: unstyled ? void 0 : "agenc-timeline__label", children: tc(stage.stringId) })
943
+ ]
944
+ },
945
+ stage.status
946
+ );
947
+ }) }),
948
+ offPath ? /* @__PURE__ */ jsxRuntime.jsx(
949
+ "p",
950
+ {
951
+ className: unstyled ? void 0 : cx(
952
+ "agenc-timeline__terminal",
953
+ `agenc-timeline__terminal--${offPath.tone}`
954
+ ),
955
+ role: "status",
956
+ children: tc(offPath.stringId)
957
+ }
958
+ ) : null
959
+ ] });
960
+ }
961
+ var SUCCESS_STRING = {
962
+ accept: "components.review.accepted",
963
+ reject: "components.review.rejected",
964
+ requestChanges: "components.review.changesRequested"
965
+ };
966
+ function ReviewPanel({
967
+ hasSubmission = false,
968
+ onAccept,
969
+ onReject,
970
+ onRequestChanges,
971
+ status = "idle",
972
+ error = null,
973
+ settledAction,
974
+ unstyled,
975
+ className
976
+ }) {
977
+ const panelClass = rootClass("agenc-review", unstyled, className);
978
+ const pending = status === "pending";
979
+ const success = status === "success";
980
+ return /* @__PURE__ */ jsxRuntime.jsxs(
981
+ "section",
982
+ {
983
+ className: panelClass,
984
+ "aria-label": tc("components.review.title"),
985
+ children: [
986
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: unstyled ? void 0 : "agenc-review__title", children: tc("components.review.title") }),
987
+ !hasSubmission ? /* @__PURE__ */ jsxRuntime.jsx(
988
+ StateMessage,
989
+ {
990
+ kind: "empty",
991
+ message: tc("components.review.noSubmission"),
992
+ unstyled
993
+ }
994
+ ) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: unstyled ? void 0 : "agenc-review__actions", children: [
995
+ /* @__PURE__ */ jsxRuntime.jsx(
996
+ Button,
997
+ {
998
+ unstyled,
999
+ variant: "primary",
1000
+ loading: pending,
1001
+ disabled: pending || !onAccept,
1002
+ onClick: onAccept,
1003
+ children: tc("components.review.accept")
1004
+ }
1005
+ ),
1006
+ /* @__PURE__ */ jsxRuntime.jsx(
1007
+ Button,
1008
+ {
1009
+ unstyled,
1010
+ variant: "secondary",
1011
+ disabled: pending || !onRequestChanges,
1012
+ onClick: onRequestChanges,
1013
+ children: tc("components.review.requestChanges")
1014
+ }
1015
+ ),
1016
+ /* @__PURE__ */ jsxRuntime.jsx(
1017
+ Button,
1018
+ {
1019
+ unstyled,
1020
+ variant: "danger",
1021
+ disabled: pending || !onReject,
1022
+ onClick: onReject,
1023
+ children: tc("components.review.reject")
1024
+ }
1025
+ )
1026
+ ] }),
1027
+ /* @__PURE__ */ jsxRuntime.jsxs(
1028
+ "div",
1029
+ {
1030
+ className: unstyled ? void 0 : "agenc-review__status",
1031
+ role: "status",
1032
+ "aria-live": "polite",
1033
+ children: [
1034
+ pending ? tc("components.review.pending") : null,
1035
+ success && settledAction ? tc(SUCCESS_STRING[settledAction]) : null
1036
+ ]
1037
+ }
1038
+ ),
1039
+ error ? /* @__PURE__ */ jsxRuntime.jsxs(
1040
+ "div",
1041
+ {
1042
+ className: unstyled ? void 0 : "agenc-review__error",
1043
+ role: "alert",
1044
+ "aria-live": "assertive",
1045
+ children: [
1046
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: tc("components.review.errorTitle") }),
1047
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: error.message })
1048
+ ]
1049
+ }
1050
+ ) : null
1051
+ ]
1052
+ }
1053
+ );
1054
+ }
1055
+ function DisputeBanner({
1056
+ disputeOpen = false,
1057
+ onInitiate,
1058
+ status = "idle",
1059
+ error = null,
1060
+ unstyled,
1061
+ className
1062
+ }) {
1063
+ const bannerClass = rootClass(
1064
+ cx(
1065
+ "agenc-dispute",
1066
+ disputeOpen ? "agenc-dispute--open" : "agenc-dispute--none"
1067
+ ),
1068
+ unstyled,
1069
+ className
1070
+ );
1071
+ const pending = status === "pending";
1072
+ const opened = status === "success";
1073
+ if (disputeOpen) {
1074
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: bannerClass, role: "alert", children: [
1075
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { className: unstyled ? void 0 : "agenc-dispute__title", children: tc("components.dispute.title") }),
1076
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: unstyled ? void 0 : "agenc-dispute__body", children: tc("components.dispute.body") })
1077
+ ] });
1078
+ }
1079
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: bannerClass, role: "region", "aria-label": tc("components.dispute.none"), children: [
1080
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: unstyled ? void 0 : "agenc-dispute__none", children: tc("components.dispute.none") }),
1081
+ onInitiate ? /* @__PURE__ */ jsxRuntime.jsx(
1082
+ Button,
1083
+ {
1084
+ unstyled,
1085
+ variant: "secondary",
1086
+ loading: pending,
1087
+ disabled: pending,
1088
+ onClick: onInitiate,
1089
+ children: pending ? tc("components.dispute.pending") : tc("components.dispute.initiate")
1090
+ }
1091
+ ) : null,
1092
+ /* @__PURE__ */ jsxRuntime.jsx(
1093
+ "div",
1094
+ {
1095
+ className: unstyled ? void 0 : "agenc-dispute__status",
1096
+ role: "status",
1097
+ "aria-live": "polite",
1098
+ children: opened ? tc("components.dispute.opened") : null
1099
+ }
1100
+ ),
1101
+ error ? /* @__PURE__ */ jsxRuntime.jsxs(
1102
+ "div",
1103
+ {
1104
+ className: unstyled ? void 0 : "agenc-dispute__error",
1105
+ role: "alert",
1106
+ "aria-live": "assertive",
1107
+ children: [
1108
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: tc("components.dispute.errorTitle") }),
1109
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: error.message })
1110
+ ]
1111
+ }
1112
+ ) : null
1113
+ ] });
1114
+ }
1115
+ var UNVERIFIED = Object.freeze({
1116
+ verified: false
1117
+ });
1118
+ function evaluateAgentVerification(account, nowSeconds) {
1119
+ if (!account) return UNVERIFIED;
1120
+ if (account.revoked) return UNVERIFIED;
1121
+ if (account.expiresAt !== 0n && nowSeconds >= account.expiresAt) {
1122
+ return UNVERIFIED;
1123
+ }
1124
+ return {
1125
+ verified: true,
1126
+ domain: account.verifiedDomain,
1127
+ method: account.method,
1128
+ verifiedBy: account.verifiedBy,
1129
+ verifiedAt: account.verifiedAt,
1130
+ expiresAt: account.expiresAt,
1131
+ revoked: false
1132
+ };
1133
+ }
1134
+ function defaultNow() {
1135
+ return BigInt(Math.floor(Date.now() / 1e3));
1136
+ }
1137
+ function agentVerificationReaderFromRpc(rpc, options) {
1138
+ const now = options?.now ?? defaultNow;
1139
+ return async (agentPda) => {
1140
+ const [pda] = await marketplaceSdk.findAgentVerificationPda({ agent: agentPda });
1141
+ const maybe = await marketplaceSdk.fetchMaybeAgentVerification(rpc, pda);
1142
+ return evaluateAgentVerification(maybe.exists ? maybe.data : null, now());
1143
+ };
1144
+ }
1145
+ function useAgentVerification(agentPda, options) {
1146
+ const reader = options?.reader;
1147
+ const enabled = (options?.enabled ?? true) && Boolean(agentPda) && Boolean(reader);
1148
+ const query = reactQuery.useQuery({
1149
+ queryKey: ["agenc", "agentVerification", agentPda ? String(agentPda) : ""],
1150
+ enabled,
1151
+ queryFn: async () => {
1152
+ return reader(agentPda);
1153
+ }
1154
+ });
1155
+ const verification = query.error ? UNVERIFIED : query.data ?? UNVERIFIED;
1156
+ return {
1157
+ verification,
1158
+ verified: verification.verified,
1159
+ isLoading: query.isLoading && enabled,
1160
+ error: query.error ?? null,
1161
+ refetch: () => void query.refetch()
1162
+ };
1163
+ }
1164
+ function VerifiedDomainBadge({
1165
+ domain,
1166
+ unstyled
1167
+ }) {
1168
+ return /* @__PURE__ */ jsxRuntime.jsx(
1169
+ Badge,
1170
+ {
1171
+ tone: "success",
1172
+ unstyled,
1173
+ className: unstyled ? void 0 : "agenc-provider__domain agenc-provider__domain--verified",
1174
+ label: tc("components.provider.verifiedDomainLabel", { domain }),
1175
+ children: tc("components.provider.verifiedDomain", { domain })
1176
+ }
1177
+ );
1178
+ }
1179
+ function ClaimedDomainBadge({
1180
+ domain,
1181
+ unstyled
1182
+ }) {
1183
+ return /* @__PURE__ */ jsxRuntime.jsx(
1184
+ Badge,
1185
+ {
1186
+ tone: "neutral",
1187
+ unstyled,
1188
+ className: unstyled ? void 0 : "agenc-provider__domain agenc-provider__domain--claimed",
1189
+ label: tc("components.provider.claimedDomainLabel", { domain }),
1190
+ children: tc("components.provider.claimedDomain", { domain })
1191
+ }
1192
+ );
1193
+ }
1194
+ function ProviderCard({
1195
+ agent,
1196
+ trackRecord,
1197
+ verification = UNVERIFIED,
1198
+ operatorDomain,
1199
+ verified = false,
1200
+ isLoading = false,
1201
+ error = null,
1202
+ onRetry,
1203
+ unstyled,
1204
+ className
1205
+ }) {
1206
+ const cardClass = rootClass("agenc-provider", unstyled, className);
1207
+ const isVerified = verification.verified || verification === UNVERIFIED && verified;
1208
+ const verifiedDomain = verification.verified ? verification.domain : null;
1209
+ const claimed = typeof operatorDomain === "string" && operatorDomain.trim() !== "" ? operatorDomain.trim() : null;
1210
+ const domainBadge = verifiedDomain ? /* @__PURE__ */ jsxRuntime.jsx(VerifiedDomainBadge, { domain: verifiedDomain, unstyled }) : claimed ? /* @__PURE__ */ jsxRuntime.jsx(ClaimedDomainBadge, { domain: claimed, unstyled }) : null;
1211
+ const header = /* @__PURE__ */ jsxRuntime.jsxs("header", { className: unstyled ? void 0 : "agenc-provider__header", children: [
1212
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: unstyled ? void 0 : "agenc-provider__id", children: [
1213
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: unstyled ? void 0 : "agenc-provider__label", children: tc("components.provider.title") }),
1214
+ agent ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: unstyled ? void 0 : "agenc-provider__pda", children: truncateAddress(agent) }) : null
1215
+ ] }),
1216
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: unstyled ? void 0 : "agenc-provider__badges", children: [
1217
+ domainBadge,
1218
+ /* @__PURE__ */ jsxRuntime.jsx(VerifiedBadge, { verified: isVerified, unstyled })
1219
+ ] })
1220
+ ] });
1221
+ if (error) {
1222
+ return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: cardClass, "aria-label": tc("components.provider.title"), children: [
1223
+ header,
1224
+ /* @__PURE__ */ jsxRuntime.jsx(
1225
+ StateMessage,
1226
+ {
1227
+ kind: "error",
1228
+ message: tc("components.provider.unavailable"),
1229
+ onRetry,
1230
+ unstyled
1231
+ }
1232
+ )
1233
+ ] });
1234
+ }
1235
+ if (isLoading && trackRecord === null) {
1236
+ return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: cardClass, "aria-label": tc("components.provider.title"), children: [
1237
+ header,
1238
+ /* @__PURE__ */ jsxRuntime.jsx(StateMessage, { kind: "loading", unstyled })
1239
+ ] });
1240
+ }
1241
+ if (trackRecord === null) {
1242
+ return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: cardClass, "aria-label": tc("components.provider.title"), children: [
1243
+ header,
1244
+ /* @__PURE__ */ jsxRuntime.jsx(
1245
+ StateMessage,
1246
+ {
1247
+ kind: "empty",
1248
+ message: tc("components.provider.noData"),
1249
+ unstyled
1250
+ }
1251
+ )
1252
+ ] });
1253
+ }
1254
+ const provisional = trackRecord.partial;
1255
+ return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: cardClass, "aria-label": tc("components.provider.title"), children: [
1256
+ header,
1257
+ /* @__PURE__ */ jsxRuntime.jsxs("dl", { className: unstyled ? void 0 : "agenc-provider__stats", children: [
1258
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: unstyled ? void 0 : "agenc-provider__stat", children: [
1259
+ /* @__PURE__ */ jsxRuntime.jsx("dt", { children: tc("components.provider.completionRate") }),
1260
+ /* @__PURE__ */ jsxRuntime.jsxs("dd", { children: [
1261
+ formatRate(trackRecord.completionRate),
1262
+ provisional ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: unstyled ? void 0 : "agenc-provider__provisional", children: [
1263
+ " ",
1264
+ "(",
1265
+ tc("components.provider.provisional"),
1266
+ ")"
1267
+ ] }) : null
1268
+ ] })
1269
+ ] }),
1270
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: unstyled ? void 0 : "agenc-provider__stat", children: [
1271
+ /* @__PURE__ */ jsxRuntime.jsx("dt", { children: tc("components.provider.disputeRate") }),
1272
+ /* @__PURE__ */ jsxRuntime.jsxs("dd", { children: [
1273
+ formatRate(trackRecord.disputeRate),
1274
+ provisional ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: unstyled ? void 0 : "agenc-provider__provisional", children: [
1275
+ " ",
1276
+ "(",
1277
+ tc("components.provider.provisional"),
1278
+ ")"
1279
+ ] }) : null
1280
+ ] })
1281
+ ] }),
1282
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: unstyled ? void 0 : "agenc-provider__stat", children: [
1283
+ /* @__PURE__ */ jsxRuntime.jsx("dt", { children: tc("components.provider.completions", {
1284
+ count: String(trackRecord.completions)
1285
+ }) }),
1286
+ /* @__PURE__ */ jsxRuntime.jsx("dd", { children: tc("components.provider.disputes", {
1287
+ count: String(trackRecord.disputesLost)
1288
+ }) })
1289
+ ] })
1290
+ ] })
1291
+ ] });
1292
+ }
1293
+ var DEFAULT_TRUST_HREF = "https://agenc.tech/trust";
1294
+ var SAFE_HREF_SCHEMES = /* @__PURE__ */ new Set(["http:", "https:", "mailto:"]);
1295
+ function safeHref(href) {
1296
+ try {
1297
+ const url = new URL(href, DEFAULT_TRUST_HREF);
1298
+ return SAFE_HREF_SCHEMES.has(url.protocol) ? href : DEFAULT_TRUST_HREF;
1299
+ } catch {
1300
+ return DEFAULT_TRUST_HREF;
1301
+ }
1302
+ }
1303
+ function PoweredByAgenC({
1304
+ href = DEFAULT_TRUST_HREF,
1305
+ newTab = true,
1306
+ label,
1307
+ unstyled,
1308
+ className
1309
+ }) {
1310
+ const linkClass = rootClass("agenc-powered-by", unstyled, className);
1311
+ return /* @__PURE__ */ jsxRuntime.jsx(
1312
+ "a",
1313
+ {
1314
+ className: linkClass,
1315
+ href: safeHref(href),
1316
+ target: newTab ? "_blank" : void 0,
1317
+ rel: newTab ? "noopener noreferrer" : void 0,
1318
+ "aria-label": `${label ?? tc("components.poweredBy.label")} \u2014 ${tc(
1319
+ "components.poweredBy.trustLink"
1320
+ )}`,
1321
+ children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: unstyled ? void 0 : "agenc-powered-by__label", children: label ?? tc("components.poweredBy.label") })
1322
+ }
1323
+ );
1324
+ }
1325
+
1326
+ exports.AGENC_THEME_CLASS = AGENC_THEME_CLASS;
1327
+ exports.AGENC_TOKENS_CSS_PATH = AGENC_TOKENS_CSS_PATH;
1328
+ exports.Badge = Badge;
1329
+ exports.Button = Button;
1330
+ exports.COMPONENT_CATALOG = COMPONENT_CATALOG;
1331
+ exports.DEFAULT_TRUST_HREF = DEFAULT_TRUST_HREF;
1332
+ exports.DisputeBanner = DisputeBanner;
1333
+ exports.EN_COMPONENT_STRINGS = EN_COMPONENT_STRINGS;
1334
+ exports.GuaranteedBadge = GuaranteedBadge;
1335
+ exports.HireButton = HireButton;
1336
+ exports.HireCheckoutModal = HireCheckoutModal;
1337
+ exports.ListingCard = ListingCard;
1338
+ exports.ListingGrid = ListingGrid;
1339
+ exports.Modal = Modal;
1340
+ exports.ModerationBadge = ModerationBadge;
1341
+ exports.PoweredByAgenC = PoweredByAgenC;
1342
+ exports.ProviderCard = ProviderCard;
1343
+ exports.ReferrerDisclosure = ReferrerDisclosure;
1344
+ exports.ReviewPanel = ReviewPanel;
1345
+ exports.Spinner = Spinner;
1346
+ exports.StateMessage = StateMessage;
1347
+ exports.TaskTimeline = TaskTimeline;
1348
+ exports.UNVERIFIED = UNVERIFIED;
1349
+ exports.VerifiedBadge = VerifiedBadge;
1350
+ exports.agencThemeStyleTag = agencThemeStyleTag;
1351
+ exports.agentVerificationReaderFromRpc = agentVerificationReaderFromRpc;
1352
+ exports.cx = cx;
1353
+ exports.decodeListingCategory = decodeListingCategory;
1354
+ exports.decodeListingName = decodeListingName;
1355
+ exports.decodeListingTags = decodeListingTags;
1356
+ exports.elementClass = elementClass;
1357
+ exports.evaluateAgentVerification = evaluateAgentVerification;
1358
+ exports.formatPriceSol = formatPriceSol;
1359
+ exports.formatRate = formatRate;
1360
+ exports.formatSol = formatSol;
1361
+ exports.moderationStateOf = moderationStateOf;
1362
+ exports.resolveThemeClassName = resolveThemeClassName;
1363
+ exports.rootClass = rootClass;
1364
+ exports.tc = tc;
1365
+ exports.toHex = toHex;
1366
+ exports.truncateAddress = truncateAddress;
1367
+ exports.useAgentVerification = useAgentVerification;
1368
+ exports.useFocusTrap = useFocusTrap;
1369
+ //# sourceMappingURL=chunk-IJKWKY4H.cjs.map
1370
+ //# sourceMappingURL=chunk-IJKWKY4H.cjs.map