@appsolutely-io/waypoint 0.1.1-next.0 → 0.1.1-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -0
- package/dist/{block-reply-DN4RiLL0.d.cts → block-reply-r8u-DNmZ.d.cts} +15 -3
- package/dist/{block-reply-Dtof9ild.d.ts → block-reply-z8El20nD.d.ts} +15 -3
- package/dist/{blocks-UJ7GUJHD.js → blocks-2ABWECKG.js} +1 -1
- package/dist/{blocks-25YOJ5SS.cjs → blocks-7453YTYJ.cjs} +1 -1
- package/dist/{chunk-W6Y7H56X.js → chunk-5Q3INHKA.js} +1 -1
- package/dist/chunk-A3YOSFLE.cjs +1 -0
- package/dist/{chunk-Q6BD2YL3.cjs → chunk-BRUQ75G3.cjs} +1 -1
- package/dist/{chunk-SD2KAIVE.js → chunk-D4Q46KWA.js} +1 -1
- package/dist/chunk-IPI4O4LP.js +1 -0
- package/dist/chunk-QFBAOEPD.js +1 -0
- package/dist/chunk-RZ3AGK3U.cjs +1 -0
- package/dist/{chunk-4ZGW4HM4.cjs → chunk-XTKUDSDK.cjs} +1 -1
- package/dist/{confirmation-view-OMWHUYVC.cjs → confirmation-view-5BZ2PP7J.cjs} +1 -1
- package/dist/{confirmation-view-CICNJJIO.js → confirmation-view-Z5JHY2F5.js} +1 -1
- package/dist/{flows-panel-YEJ36RTY.js → flows-panel-2SCPYZ3X.js} +1 -1
- package/dist/{flows-panel-AIULKYOS.cjs → flows-panel-HQYJMOP4.cjs} +1 -1
- package/dist/{form-extras-QYE32TUY.cjs → form-extras-RNMBCYV7.cjs} +1 -1
- package/dist/{form-extras-SBBOMJS2.js → form-extras-X3B3JCMH.js} +1 -1
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.d.cts +3 -3
- package/dist/hooks/index.d.ts +3 -3
- package/dist/hooks/index.js +1 -1
- package/dist/{i18n-DPNfYTMG.d.cts → i18n-WC9f-h_q.d.cts} +3 -0
- package/dist/{i18n-DPNfYTMG.d.ts → i18n-WC9f-h_q.d.ts} +3 -0
- package/dist/markdown-5NUOCOGY.js +23 -0
- package/dist/{markdown-BSRKJFFE.cjs → markdown-CG7NXI7X.cjs} +17 -11
- package/dist/{message-actions-F6SPLTT7.cjs → message-actions-ORBVYGNE.cjs} +1 -1
- package/dist/{message-actions-3HGE6VTS.js → message-actions-XNBBFHGW.js} +1 -1
- package/dist/messages/en/index.cjs +1 -1
- package/dist/messages/en/index.js +1 -1
- package/dist/messages/index.d.cts +3 -3
- package/dist/messages/index.d.ts +3 -3
- package/dist/messages/zh-Hans/index.cjs +1 -1
- package/dist/messages/zh-Hans/index.js +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.d.cts +8 -6
- package/dist/react/index.d.ts +8 -6
- package/dist/react/index.js +1 -1
- package/dist/{recovery-panel-VOKVDDZD.js → recovery-panel-6EBUMANX.js} +1 -1
- package/dist/{recovery-panel-OWY2CWOH.cjs → recovery-panel-EQIIV7TT.cjs} +3 -3
- package/dist/{reply-controls-5CWIAKIG.js → reply-controls-HUYHUO3W.js} +1 -1
- package/dist/{reply-controls-CPWB4VBK.cjs → reply-controls-LGY2RKRJ.cjs} +1 -1
- package/dist/skin-antd/index.d.cts +3 -3
- package/dist/skin-antd/index.d.ts +3 -3
- package/dist/{step-name-BdkYnb5g.d.ts → step-name-BlgVvshf.d.ts} +1 -1
- package/dist/{step-name-3hQ6CCGr.d.cts → step-name-CB3d3kkP.d.cts} +1 -1
- package/dist/styles.css +15 -0
- package/dist/testing/index.cjs +1 -1
- package/dist/testing/index.d.cts +3 -3
- package/dist/testing/index.d.ts +3 -3
- package/dist/testing/index.js +1 -1
- package/etc/hooks.api.md +9 -0
- package/etc/messages.api.md +3 -0
- package/etc/react.api.md +9 -0
- package/etc/skin-antd.api.md +9 -0
- package/etc/testing.api.md +9 -0
- package/package.json +2 -1
- package/dist/chunk-M3UENQ6L.cjs +0 -1
- package/dist/chunk-RHBDQGD4.js +0 -1
- package/dist/chunk-TGL3DR2K.js +0 -1
- package/dist/chunk-UYR3UEIW.cjs +0 -1
- package/dist/markdown-ETLB66BK.js +0 -17
package/README.md
CHANGED
|
@@ -47,6 +47,8 @@ import "@appsolutely-io/waypoint/styles.css";
|
|
|
47
47
|
|
|
48
48
|
Omit the skin for neutral controls. `@appsolutely-io/waypoint/skin-default` exports the neutral token values. Importing core requires no UI peer. `/testing` additionally needs React, React DOM and Testing Library; install those only when using that helper.
|
|
49
49
|
|
|
50
|
+
From 500 messages the transcript mounts only the messages within about 1,200 px of the visible part, with a spacer for each run of the others at their measured heights (a message not yet measured counts as the average of those that were). The messages are a [WAI-ARIA feed](https://www.w3.org/TR/wai-aria-1.2/#feed): each one is an article that can take focus and gives its place among all of them with `aria-posinset` and `aria-setsize`, and the keys of the [feed pattern](https://www.w3.org/WAI/ARIA/apg/patterns/feed/) work: Page Down and Page Up move focus to the next and previous message, mounting it first when it is not, and Control+End and Control+Home move focus past the end and the start of the feed. Whether a screen reader reading on past the mounted messages makes the transcript mount more has not been tested with NVDA or VoiceOver; those keys and the outline reach every message. The transcript still rests pinned at the latest message, Back to latest returns there, the outline and a link to a message's anchor mount the message before showing it, the message holding focus stays mounted however far the transcript scrolls, and a message that arrives while the reader is scrolled up leaves the message being read where it was, also when it makes the transcript start mounting only a window. Announcements of new messages come from the client, so they do not depend on what is mounted. The trade-off: the browser's find in page searches only the mounted messages, so in a conversation of 500 messages or more, text far from the visible part is found only once it is scrolled near. The outline lists every message, and its filter ("Filter messages") searches the visible text of every message, mounted or not, and says how many match; a link in the filtered list shows its message. The texts it searches are made from each message's text in idle moments once the outline opens, once for each version of a message, so a keystroke never waits for all of them: until every text is made the filter says "Searching…" (`chat.outlineSearching`) and lists the matches found so far. The filter applies once typing pauses, and it ignores case in the chat's language (so "STRASSE" finds "Straße"), the Unicode normal form, and the accents of the Latin, Greek and Cyrillic scripts (so "cafe" finds "café").
|
|
51
|
+
|
|
50
52
|
## Preview locally
|
|
51
53
|
|
|
52
54
|
In a checkout of this repository:
|
|
@@ -128,6 +130,39 @@ function PlanActions({ client }) {
|
|
|
128
130
|
|
|
129
131
|
Each language is its own entry (`/messages/en`, `/messages/zh-Hans`), so a host ships only the text it shows; a host with its own wording passes its own catalogue. A key the catalogue lacks throws in development and shows the key itself in production. `stepName(t, planLabels, step)` names a plan step the way the web chat does. `problemView(problem)` gives a problem's words (`key`), its one action (`retry` or `refresh`, worded `chat.retry` and `chat.problem.refresh`) and the `code` and `id` the chat shows behind "Details"; `replyRowView(snapshot.replyState, { canStop: client.canStopReply(), canRetry: client.canRetryReply() })` gives the reply row's words and its buttons (Stop, Keep waiting, Retry), each wired to the client method of the same name (`retry` is `retryReply()`).
|
|
130
132
|
|
|
133
|
+
A list follows the conversation one message at a time: `useWaypointMessage(id, client)` renders its row again only when that message changes, so a streamed delta renders the row being written and no other. `useWaypointSelector(selector, isEqual, client)` selects any part of the snapshot; a selector that builds a new array or object each time needs an `isEqual` that compares its contents, or the component renders on every change:
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
import { FlatList, Text } from "react-native";
|
|
137
|
+
import {
|
|
138
|
+
useWaypointMessage,
|
|
139
|
+
useWaypointSelector,
|
|
140
|
+
} from "@appsolutely-io/waypoint/hooks";
|
|
141
|
+
|
|
142
|
+
const sameIds = (a: string[], b: string[]) =>
|
|
143
|
+
a.length === b.length && a.every((id, index) => id === b[index]);
|
|
144
|
+
|
|
145
|
+
function Row({ id, client }) {
|
|
146
|
+
const message = useWaypointMessage(id, client);
|
|
147
|
+
return <Text>{message?.content}</Text>;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function Transcript({ client }) {
|
|
151
|
+
const ids = useWaypointSelector(
|
|
152
|
+
(snapshot) => snapshot.conversation?.messages.map((m) => m.id) ?? [],
|
|
153
|
+
sameIds,
|
|
154
|
+
client,
|
|
155
|
+
);
|
|
156
|
+
return (
|
|
157
|
+
<FlatList
|
|
158
|
+
data={ids}
|
|
159
|
+
keyExtractor={(id) => id}
|
|
160
|
+
renderItem={({ item }) => <Row id={item} client={client} />}
|
|
161
|
+
/>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
131
166
|
### Part data
|
|
132
167
|
|
|
133
168
|
Each part receives a copy of its own data as `data`, typed by its name (`PartData`, `PartDataMap`; `PartProps<"stepRow">` for one part). Parts not listed receive none.
|
|
@@ -238,6 +273,8 @@ On `agreement-expired` for its current agreement, the client closes the stream,
|
|
|
238
273
|
|
|
239
274
|
`npm run lint`, `npm run typecheck`, `npm test -- tests/protocol tests/conformance tests/core tests/react tests/skin-antd tests/package`, `npm run build`, `npm run api:check`, `npm run size` and `npm run test:consumer` are local/CI gates. `npm run test:native` checks the local build; CI's consumer check invokes `scripts/native-smoke.mjs` against the installed packed core for both npm and pnpm. Focused tests use at most two workers; `npm run test:browser` uses one. `npm run api:update` intentionally regenerates reports after a reviewed API change; check mode never blesses an uncommitted change. CI exercises lowest and latest optional peers.
|
|
240
275
|
|
|
276
|
+
`npm run perf` measures the chat in the playground with headless Chromium (install it once with `npx playwright install chromium`): histories of 200, 1,000 and 5,000 messages (initial render, DOM nodes, heap after garbage collection, event listeners, long tasks, the latency of each key typed in the composer, the React commits while typing, and sending one message until its reply finishes) one streamed reply of about 15,000 tokens at 200 tokens a second after 40 messages (time to first text, long tasks, dropped frames and commits while it streams), the same reply with each paragraph citing a link definition given at its end (`refstream:15000`), and, at 5,000 messages, opening the outline and typing the first key of its filter at once (`filter:5000`: the time to open, the key's event latency, the time until the filter says how many match, and the long tasks of each). Name scenarios to run fewer (`npm run perf -- long:1000 stream:3000`), add `--runs 3` for the median of three, and `--json <file>` to keep every run. Each scenario prints the 1-minute load it ran at; above 40, with no `--runs`, it runs three times and prints the median. The playground's `?perfMessages=N`, `?perfTokens=N` and `?perfRate=N` put the same load on it by hand.
|
|
277
|
+
|
|
241
278
|
`waypoint-conformance <test-base-url> [--app-host]` runs HTTP scenarios against an isolated scripted service. The fixture's session and script endpoints answer 404 outside explicit test mode. No production database or model credential is needed. Profile-specific service behavior remains the application's responsibility.
|
|
242
279
|
|
|
243
280
|
The protocol documents (this README and `docs/`) state requirements in plain English ("must", "never", "only"), binding as written. [The reply protocol](docs/reply-protocol.md), which covers stopping a reply and the other reply features a host can offer, uses the capitalised key words; the others do not use the capitalised key words of [BCP 14](https://www.rfc-editor.org/info/bcp14) ([RFC 2119](https://www.rfc-editor.org/rfc/rfc2119), [RFC 8174](https://www.rfc-editor.org/rfc/rfc8174)). The schema uses [JSON Schema 2020-12](https://json-schema.org/draft/2020-12). YAML parsing uses [js-yaml's JSON schema](https://github.com/nodeca/js-yaml), rejecting duplicate keys, aliases and executable tags. API snapshots use [API Extractor reports](https://api-extractor.com/pages/setup/configure_api_report/). The antd skin follows its [token and algorithm APIs](https://ant.design/docs/react/customize-theme/).
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { W as WaypointClient, b as ClientSnapshot, x as KeepChangesReviewResult, L as ReplyOutcome } from './form-fill-C32AHxSr.cjs';
|
|
2
|
+
import { a3 as Message, ad as PlanState, Z as IntentKind, ac as PlanRecord, ag as Reply, B as Block } from './generated-C9tbjwK0.cjs';
|
|
2
3
|
import { d as IntentOverlay, c as IntentNotice, I as IntentAlert } from './intent-BQPPows1.cjs';
|
|
3
|
-
import {
|
|
4
|
-
import { M as MessageKey } from './i18n-DPNfYTMG.cjs';
|
|
4
|
+
import { M as MessageKey } from './i18n-WC9f-h_q.cjs';
|
|
5
5
|
|
|
6
6
|
declare function useWaypointSnapshot(client?: WaypointClient): ClientSnapshot;
|
|
7
|
+
/**
|
|
8
|
+
* Part of the client's snapshot: the component renders again only when the
|
|
9
|
+
* selected value changes, by `isEqual` (`Object.is` unless given), not on
|
|
10
|
+
* every change to the snapshot, such as each delta of a reply.
|
|
11
|
+
*/
|
|
12
|
+
declare function useWaypointSelector<T>(selector: (snapshot: ClientSnapshot) => T, isEqual?: (a: T, b: T) => boolean, client?: WaypointClient): T;
|
|
13
|
+
/**
|
|
14
|
+
* One message of the conversation shown: the component renders again only
|
|
15
|
+
* when that message changes (a delta into it, a new status), so a list can
|
|
16
|
+
* give each row its own subscription.
|
|
17
|
+
*/
|
|
18
|
+
declare function useWaypointMessage(messageId: string, client?: WaypointClient): Message | undefined;
|
|
7
19
|
|
|
8
20
|
interface ViewMessage {
|
|
9
21
|
key: MessageKey;
|
|
@@ -166,4 +178,4 @@ declare function cardReplyId(conversationId: string, messageId: string, blockId:
|
|
|
166
178
|
/** The card answer lock every renderer uses. */
|
|
167
179
|
declare function useBlockReply(client?: WaypointClient): BlockReply;
|
|
168
180
|
|
|
169
|
-
export { type ActionEntry as A, type BlockAnswer as B, type KeepSheet as K, type PlanView as P, type StepStatus as S, type Tone as T, type ViewMessage as V, type ActionId as a, type BlockReply as b, type KeepSheetView as c, type PlanViewAlert as d, type PlanViewInput as e, type PlanViewStatus as f, cardReplyId as g, usePlanView as h,
|
|
181
|
+
export { type ActionEntry as A, type BlockAnswer as B, type KeepSheet as K, type PlanView as P, type StepStatus as S, type Tone as T, type ViewMessage as V, type ActionId as a, type BlockReply as b, type KeepSheetView as c, type PlanViewAlert as d, type PlanViewInput as e, type PlanViewStatus as f, cardReplyId as g, usePlanView as h, useWaypointMessage as i, useWaypointSelector as j, keepSheet as k, useWaypointSnapshot as l, type BlockSummary as m, noticeMessages as n, planView as p, useBlockReply as u };
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { W as WaypointClient, b as ClientSnapshot, x as KeepChangesReviewResult, L as ReplyOutcome } from './form-fill-Dp3ut1_Y.js';
|
|
2
|
+
import { a3 as Message, ad as PlanState, Z as IntentKind, ac as PlanRecord, ag as Reply, B as Block } from './generated-C9tbjwK0.js';
|
|
2
3
|
import { d as IntentOverlay, c as IntentNotice, I as IntentAlert } from './intent-BuvqEU3Q.js';
|
|
3
|
-
import {
|
|
4
|
-
import { M as MessageKey } from './i18n-DPNfYTMG.js';
|
|
4
|
+
import { M as MessageKey } from './i18n-WC9f-h_q.js';
|
|
5
5
|
|
|
6
6
|
declare function useWaypointSnapshot(client?: WaypointClient): ClientSnapshot;
|
|
7
|
+
/**
|
|
8
|
+
* Part of the client's snapshot: the component renders again only when the
|
|
9
|
+
* selected value changes, by `isEqual` (`Object.is` unless given), not on
|
|
10
|
+
* every change to the snapshot, such as each delta of a reply.
|
|
11
|
+
*/
|
|
12
|
+
declare function useWaypointSelector<T>(selector: (snapshot: ClientSnapshot) => T, isEqual?: (a: T, b: T) => boolean, client?: WaypointClient): T;
|
|
13
|
+
/**
|
|
14
|
+
* One message of the conversation shown: the component renders again only
|
|
15
|
+
* when that message changes (a delta into it, a new status), so a list can
|
|
16
|
+
* give each row its own subscription.
|
|
17
|
+
*/
|
|
18
|
+
declare function useWaypointMessage(messageId: string, client?: WaypointClient): Message | undefined;
|
|
7
19
|
|
|
8
20
|
interface ViewMessage {
|
|
9
21
|
key: MessageKey;
|
|
@@ -166,4 +178,4 @@ declare function cardReplyId(conversationId: string, messageId: string, blockId:
|
|
|
166
178
|
/** The card answer lock every renderer uses. */
|
|
167
179
|
declare function useBlockReply(client?: WaypointClient): BlockReply;
|
|
168
180
|
|
|
169
|
-
export { type ActionEntry as A, type BlockAnswer as B, type KeepSheet as K, type PlanView as P, type StepStatus as S, type Tone as T, type ViewMessage as V, type ActionId as a, type BlockReply as b, type KeepSheetView as c, type PlanViewAlert as d, type PlanViewInput as e, type PlanViewStatus as f, cardReplyId as g, usePlanView as h,
|
|
181
|
+
export { type ActionEntry as A, type BlockAnswer as B, type KeepSheet as K, type PlanView as P, type StepStatus as S, type Tone as T, type ViewMessage as V, type ActionId as a, type BlockReply as b, type KeepSheetView as c, type PlanViewAlert as d, type PlanViewInput as e, type PlanViewStatus as f, cardReplyId as g, usePlanView as h, useWaypointMessage as i, useWaypointSelector as j, keepSheet as k, useWaypointSnapshot as l, type BlockSummary as m, noticeMessages as n, planView as p, useBlockReply as u };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as f}from"./chunk-MEKDQDSV.js";import{a as h}from"./chunk-
|
|
1
|
+
import{a as f}from"./chunk-MEKDQDSV.js";import{a as h}from"./chunk-D4Q46KWA.js";import{a as B,b as x}from"./chunk-PFR2J5BV.js";import{J as v,q as P,y as g}from"./chunk-IPI4O4LP.js";import{a as S}from"./chunk-FQSWQLRW.js";import{a as w}from"./chunk-C3VS33WJ.js";import"./chunk-OWT55N6J.js";import"./chunk-QFBAOEPD.js";import"./chunk-RZZDQWC2.js";import"./chunk-M63QOANE.js";import"./chunk-L4PFFRDE.js";import"./chunk-T5XF2R74.js";import"./chunk-K73VV7KA.js";import"./chunk-5TBO732O.js";import{useId as N,useState as q}from"react";import{Fragment as U,jsx as e,jsxs as u}from"react/jsx-runtime";P(B,x);var A=a=>Array.isArray(a)?a.length>0:String(a??"").trim()!=="",F={"compare-and-set":"chat.block.undoCompareAndSet","archive-created":"chat.block.undoArchiveCreated"},y=a=>a>=200&&a<300,I=(a,d)=>a("chat.block.status",{status:a(`chat.block.state.${d}`)});function V({record:a,slots:d,view:i,changesShown:k}){let{format:r,extraUrlSchemes:b,planLabels:c}=g();return a.plan.kind!=="immediate"?e("p",{children:I(r,a.state)}):e("ol",{children:a.plan.steps.map((t,m)=>{let o=a.outcomes.find(s=>s.stepId===t.id),l=t.undo.startsWith("inverse:")?"chat.block.undoInverse":F[t.undo];return e(v,{name:"planNode",slots:d,data:i?{view:i}:void 0,children:e("li",{children:u(v,{name:"stepRow",slots:d,data:{step:{id:t.id,operation:t.operation,resource:t.resource,view:t.view,tier:t.tier,undo:t.undo,stepUp:t.stepUp}},children:[e("strong",{children:w(r,c,{index:m+1,resource:t.resource})}),k?null:e("dl",{children:t.fields.map((s,n)=>u("div",{children:[e("dt",{children:c?.field?.(t.resource,s)||r("chat.fieldName",{index:n+1})}),u("dd",{children:[e(f,{value:t.before?.[s],t:r})," ",e("span",{"aria-hidden":"true",children:"\u2192"}),e("span",{className:"wp-sr-only",children:r("chat.changesTo")})," ",e(f,{value:t.after?.[s],t:r})]})]},s))}),u("ul",{className:"wp-step-facts",children:[e("li",{children:r(t.tier==="sensitive"?"chat.block.tierSensitive":"chat.block.tierLow")}),t.undo==="none"?e("li",{children:e("strong",{children:r("chat.irreversible")})}):l?e("li",{children:r(l)}):null,t.stepUp?e("li",{children:r("chat.verify")}):null,o&&!y(o.status)?e("li",{"data-tone":"danger",children:e("strong",{children:r("chat.block.status",{status:r("chat.block.outcomeFailed")})})}):e("li",{children:o?r("chat.block.status",{status:r("chat.block.outcomeDone")}):I(r,a.state)}),o?.reason&&!y(o.status)?e("li",{"data-tone":"danger",children:o.reason}):null,o?.retryable!==void 0&&!y(o.status)?e("li",{children:r(o.retryable?"chat.block.retryable":"chat.block.notRetryable")}):null,S(t.view,b)?e("li",{children:e("a",{href:t.view,children:r("chat.view")})}):null]})]})})},t.id)})})}var C=(a,d)=>a.id===d.blockId?a.body?.actions?.find(i=>"actionId"in d&&i.id===d.actionId)?.label:(a.body?.blocks??[]).map(i=>C(i,d)).find(Boolean);function J({block:a}){let{format:d}=g(),i=a.answer&&C(a,a.answer);return e("p",{children:i?d("chat.block.answeredWith",{answer:i}):d("chat.block.answered")})}function R({block:a,onReply:d,disabled:i}){let k=N(),{format:r,primitives:b}=g(),c=a.body,[t,m]=q(()=>a.type==="form"?Object.fromEntries((c?.fields??[]).filter(o=>typeof o.value=="string").map(o=>[o.name,o.value])):{});switch(a.type){case"form.fill":{let l=a.body?.values;return!l||typeof l!="object"||Array.isArray(l)||Object.values(l).some(s=>!s||typeof s!="object")?e("p",{children:a.fallback}):e("dl",{children:Object.entries(l).map(([s,n])=>u("div",{children:[e("dt",{children:typeof n.label=="string"?n.label:s}),u("dd",{children:[e("p",{children:typeof n.value=="string"?n.value:JSON.stringify(n.value)}),e("p",{children:r(n.validation?.status==="valid"?"form.valid":"form.invalid")}),n.validation?.messages?.map((p,M)=>e("p",{children:p},M)),n.validation?.guidance&&e("p",{children:n.validation.guidance})]})]},s))})}case"table":return e("div",{"data-scroll-region":"",tabIndex:0,role:"region","aria-label":r("chat.scrollRegion"),children:u("table",{children:[e("thead",{children:e("tr",{children:(c.columns??[]).map((o,l)=>e("th",{children:o},l))})}),e("tbody",{children:(c.rows??[]).map((o,l)=>e("tr",{children:o.map((s,n)=>e("td",{children:String(s)},n))},l))})]})});case"diff":return u("dl",{children:[e("dt",{children:r("chat.before")}),e("dd",{children:e(f,{value:c.before,t:r})}),e("dt",{children:r("chat.after")}),e("dd",{children:e(f,{value:c.after,t:r})})]});case"form":{let o=c.fields??[],l=o.some(n=>n.required&&!A(t[n.name])),s=()=>{!i&&!l&&d({kind:"form",blockId:a.id,values:t})};return u("form",{onSubmit:n=>{n.preventDefault(),s()},children:[o.map(n=>e(b.input,{label:n.required?r("chat.block.required",{label:n.label}):n.label,required:n.required,value:String(t[n.name]??""),disabled:i,onChange:p=>m({...t,[n.name]:p})},n.name)),e(h,{disabled:i,blocked:l,reason:r("chat.block.requiredMissing"),onPress:s})]})}case"choice":{let o=!A(t.answer),l=()=>{!i&&!o&&d({kind:"form",blockId:a.id,values:t})};return u("fieldset",{disabled:i,children:[c.mode==="text"?e(b.input,{label:a.fallback,value:String(t.answer??""),onChange:s=>m({answer:s})}):u(U,{children:[e("legend",{children:a.fallback}),e("div",{children:(c.options??[]).map(s=>u("label",{children:[e("input",{type:c.mode==="multi"?"checkbox":"radio",name:k,disabled:i,checked:c.mode==="multi"?(t.answer??[]).includes(s):t.answer===s,onChange:n=>m({answer:c.mode==="multi"?n.target.checked?[...t.answer??[],s]:(t.answer??[]).filter(p=>p!==s):s})}),s]},s))})]}),e(h,{disabled:i,blocked:o,reason:r("chat.block.answerMissing"),onPress:l})]})}case"plan":return e("p",{children:a.fallback});default:return e("p",{children:a.fallback})}}export{J as Answered,V as PlanSteps,R as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkXWDB2LS3cjs = require('./chunk-XWDB2LS3.cjs');var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkXWDB2LS3cjs = require('./chunk-XWDB2LS3.cjs');var _chunkXTKUDSDKcjs = require('./chunk-XTKUDSDK.cjs');var _chunkVGGJGRNKcjs = require('./chunk-VGGJGRNK.cjs');var _chunkA3YOSFLEcjs = require('./chunk-A3YOSFLE.cjs');var _chunkFBADWFRRcjs = require('./chunk-FBADWFRR.cjs');var _chunkTODYQ3SGcjs = require('./chunk-TODYQ3SG.cjs');require('./chunk-QS3MKZOY.cjs');require('./chunk-RZ3AGK3U.cjs');require('./chunk-4BWV3SEL.cjs');require('./chunk-GT6PI4CT.cjs');require('./chunk-3KV7TDDR.cjs');require('./chunk-Q7BULGQG.cjs');require('./chunk-XSHOLIC7.cjs');require('./chunk-II26UWZM.cjs');var _react = require('react');var _jsxruntime = require('react/jsx-runtime');_chunkA3YOSFLEcjs.q.call(void 0, _chunkVGGJGRNKcjs.a,_chunkVGGJGRNKcjs.b);var A=a=>Array.isArray(a)?a.length>0:String(_nullishCoalesce(a, () => (""))).trim()!=="",F={"compare-and-set":"chat.block.undoCompareAndSet","archive-created":"chat.block.undoArchiveCreated"},y=a=>a>=200&&a<300,I=(a,d)=>a("chat.block.status",{status:a(`chat.block.state.${d}`)});function V({record:a,slots:d,view:i,changesShown:k}){let{format:r,extraUrlSchemes:b,planLabels:c}=_chunkA3YOSFLEcjs.y.call(void 0, );return a.plan.kind!=="immediate"?_jsxruntime.jsx.call(void 0, "p",{children:I(r,a.state)}):_jsxruntime.jsx.call(void 0, "ol",{children:a.plan.steps.map((t,m)=>{let o=a.outcomes.find(s=>s.stepId===t.id),l=t.undo.startsWith("inverse:")?"chat.block.undoInverse":F[t.undo];return _jsxruntime.jsx.call(void 0, _chunkA3YOSFLEcjs.J,{name:"planNode",slots:d,data:i?{view:i}:void 0,children:_jsxruntime.jsx.call(void 0, "li",{children:_jsxruntime.jsxs.call(void 0, _chunkA3YOSFLEcjs.J,{name:"stepRow",slots:d,data:{step:{id:t.id,operation:t.operation,resource:t.resource,view:t.view,tier:t.tier,undo:t.undo,stepUp:t.stepUp}},children:[_jsxruntime.jsx.call(void 0, "strong",{children:_chunkTODYQ3SGcjs.a.call(void 0, r,c,{index:m+1,resource:t.resource})}),k?null:_jsxruntime.jsx.call(void 0, "dl",{children:t.fields.map((s,n)=>_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "dt",{children:_optionalChain([c, 'optionalAccess', _ => _.field, 'optionalCall', _2 => _2(t.resource,s)])||r("chat.fieldName",{index:n+1})}),_jsxruntime.jsxs.call(void 0, "dd",{children:[_jsxruntime.jsx.call(void 0, _chunkXWDB2LS3cjs.a,{value:_optionalChain([t, 'access', _3 => _3.before, 'optionalAccess', _4 => _4[s]]),t:r})," ",_jsxruntime.jsx.call(void 0, "span",{"aria-hidden":"true",children:"\u2192"}),_jsxruntime.jsx.call(void 0, "span",{className:"wp-sr-only",children:r("chat.changesTo")})," ",_jsxruntime.jsx.call(void 0, _chunkXWDB2LS3cjs.a,{value:_optionalChain([t, 'access', _5 => _5.after, 'optionalAccess', _6 => _6[s]]),t:r})]})]},s))}),_jsxruntime.jsxs.call(void 0, "ul",{className:"wp-step-facts",children:[_jsxruntime.jsx.call(void 0, "li",{children:r(t.tier==="sensitive"?"chat.block.tierSensitive":"chat.block.tierLow")}),t.undo==="none"?_jsxruntime.jsx.call(void 0, "li",{children:_jsxruntime.jsx.call(void 0, "strong",{children:r("chat.irreversible")})}):l?_jsxruntime.jsx.call(void 0, "li",{children:r(l)}):null,t.stepUp?_jsxruntime.jsx.call(void 0, "li",{children:r("chat.verify")}):null,o&&!y(o.status)?_jsxruntime.jsx.call(void 0, "li",{"data-tone":"danger",children:_jsxruntime.jsx.call(void 0, "strong",{children:r("chat.block.status",{status:r("chat.block.outcomeFailed")})})}):_jsxruntime.jsx.call(void 0, "li",{children:o?r("chat.block.status",{status:r("chat.block.outcomeDone")}):I(r,a.state)}),_optionalChain([o, 'optionalAccess', _7 => _7.reason])&&!y(o.status)?_jsxruntime.jsx.call(void 0, "li",{"data-tone":"danger",children:o.reason}):null,_optionalChain([o, 'optionalAccess', _8 => _8.retryable])!==void 0&&!y(o.status)?_jsxruntime.jsx.call(void 0, "li",{children:r(o.retryable?"chat.block.retryable":"chat.block.notRetryable")}):null,_chunkFBADWFRRcjs.a.call(void 0, t.view,b)?_jsxruntime.jsx.call(void 0, "li",{children:_jsxruntime.jsx.call(void 0, "a",{href:t.view,children:r("chat.view")})}):null]})]})})},t.id)})})}var C=(a,d)=>a.id===d.blockId?_optionalChain([a, 'access', _9 => _9.body, 'optionalAccess', _10 => _10.actions, 'optionalAccess', _11 => _11.find, 'call', _12 => _12(i=>"actionId"in d&&i.id===d.actionId), 'optionalAccess', _13 => _13.label]):(_nullishCoalesce(_optionalChain([a, 'access', _14 => _14.body, 'optionalAccess', _15 => _15.blocks]), () => ([]))).map(i=>C(i,d)).find(Boolean);function J({block:a}){let{format:d}=_chunkA3YOSFLEcjs.y.call(void 0, ),i=a.answer&&C(a,a.answer);return _jsxruntime.jsx.call(void 0, "p",{children:i?d("chat.block.answeredWith",{answer:i}):d("chat.block.answered")})}function R({block:a,onReply:d,disabled:i}){let k=_react.useId.call(void 0, ),{format:r,primitives:b}=_chunkA3YOSFLEcjs.y.call(void 0, ),c=a.body,[t,m]=_react.useState.call(void 0, ()=>a.type==="form"?Object.fromEntries((_nullishCoalesce(_optionalChain([c, 'optionalAccess', _16 => _16.fields]), () => ([]))).filter(o=>typeof o.value=="string").map(o=>[o.name,o.value])):{});switch(a.type){case"form.fill":{let l=_optionalChain([a, 'access', _17 => _17.body, 'optionalAccess', _18 => _18.values]);return!l||typeof l!="object"||Array.isArray(l)||Object.values(l).some(s=>!s||typeof s!="object")?_jsxruntime.jsx.call(void 0, "p",{children:a.fallback}):_jsxruntime.jsx.call(void 0, "dl",{children:Object.entries(l).map(([s,n])=>_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "dt",{children:typeof n.label=="string"?n.label:s}),_jsxruntime.jsxs.call(void 0, "dd",{children:[_jsxruntime.jsx.call(void 0, "p",{children:typeof n.value=="string"?n.value:JSON.stringify(n.value)}),_jsxruntime.jsx.call(void 0, "p",{children:r(_optionalChain([n, 'access', _19 => _19.validation, 'optionalAccess', _20 => _20.status])==="valid"?"form.valid":"form.invalid")}),_optionalChain([n, 'access', _21 => _21.validation, 'optionalAccess', _22 => _22.messages, 'optionalAccess', _23 => _23.map, 'call', _24 => _24((p,M)=>_jsxruntime.jsx.call(void 0, "p",{children:p},M))]),_optionalChain([n, 'access', _25 => _25.validation, 'optionalAccess', _26 => _26.guidance])&&_jsxruntime.jsx.call(void 0, "p",{children:n.validation.guidance})]})]},s))})}case"table":return _jsxruntime.jsx.call(void 0, "div",{"data-scroll-region":"",tabIndex:0,role:"region","aria-label":r("chat.scrollRegion"),children:_jsxruntime.jsxs.call(void 0, "table",{children:[_jsxruntime.jsx.call(void 0, "thead",{children:_jsxruntime.jsx.call(void 0, "tr",{children:(_nullishCoalesce(c.columns, () => ([]))).map((o,l)=>_jsxruntime.jsx.call(void 0, "th",{children:o},l))})}),_jsxruntime.jsx.call(void 0, "tbody",{children:(_nullishCoalesce(c.rows, () => ([]))).map((o,l)=>_jsxruntime.jsx.call(void 0, "tr",{children:o.map((s,n)=>_jsxruntime.jsx.call(void 0, "td",{children:String(s)},n))},l))})]})});case"diff":return _jsxruntime.jsxs.call(void 0, "dl",{children:[_jsxruntime.jsx.call(void 0, "dt",{children:r("chat.before")}),_jsxruntime.jsx.call(void 0, "dd",{children:_jsxruntime.jsx.call(void 0, _chunkXWDB2LS3cjs.a,{value:c.before,t:r})}),_jsxruntime.jsx.call(void 0, "dt",{children:r("chat.after")}),_jsxruntime.jsx.call(void 0, "dd",{children:_jsxruntime.jsx.call(void 0, _chunkXWDB2LS3cjs.a,{value:c.after,t:r})})]});case"form":{let o=_nullishCoalesce(c.fields, () => ([])),l=o.some(n=>n.required&&!A(t[n.name])),s=()=>{!i&&!l&&d({kind:"form",blockId:a.id,values:t})};return _jsxruntime.jsxs.call(void 0, "form",{onSubmit:n=>{n.preventDefault(),s()},children:[o.map(n=>_jsxruntime.jsx.call(void 0, b.input,{label:n.required?r("chat.block.required",{label:n.label}):n.label,required:n.required,value:String(_nullishCoalesce(t[n.name], () => (""))),disabled:i,onChange:p=>m({...t,[n.name]:p})},n.name)),_jsxruntime.jsx.call(void 0, _chunkXTKUDSDKcjs.a,{disabled:i,blocked:l,reason:r("chat.block.requiredMissing"),onPress:s})]})}case"choice":{let o=!A(t.answer),l=()=>{!i&&!o&&d({kind:"form",blockId:a.id,values:t})};return _jsxruntime.jsxs.call(void 0, "fieldset",{disabled:i,children:[c.mode==="text"?_jsxruntime.jsx.call(void 0, b.input,{label:a.fallback,value:String(_nullishCoalesce(t.answer, () => (""))),onChange:s=>m({answer:s})}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "legend",{children:a.fallback}),_jsxruntime.jsx.call(void 0, "div",{children:(_nullishCoalesce(c.options, () => ([]))).map(s=>_jsxruntime.jsxs.call(void 0, "label",{children:[_jsxruntime.jsx.call(void 0, "input",{type:c.mode==="multi"?"checkbox":"radio",name:k,disabled:i,checked:c.mode==="multi"?(_nullishCoalesce(t.answer, () => ([]))).includes(s):t.answer===s,onChange:n=>m({answer:c.mode==="multi"?n.target.checked?[..._nullishCoalesce(t.answer, () => ([])),s]:(_nullishCoalesce(t.answer, () => ([]))).filter(p=>p!==s):s})}),s]},s))})]}),_jsxruntime.jsx.call(void 0, _chunkXTKUDSDKcjs.a,{disabled:i,blocked:o,reason:r("chat.block.answerMissing"),onPress:l})]})}case"plan":return _jsxruntime.jsx.call(void 0, "p",{children:a.fallback});default:return _jsxruntime.jsx.call(void 0, "p",{children:a.fallback})}}exports.Answered = J; exports.PlanSteps = V; exports.default = R;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{H as G,J,b as H,e as q,k as X,m as $,n as z,u as V,v as j,x as L,y as O}from"./chunk-
|
|
1
|
+
import{H as G,J,b as H,e as q,k as X,m as $,n as z,u as V,v as j,x as L,y as O}from"./chunk-IPI4O4LP.js";import{useEffect as te,useId as re,useRef as R,useState as K}from"react";import{jsx as B,jsxs as Q}from"react/jsx-runtime";function U({children:e,label:u,onRegenerate:w,disabled:y,reason:d,slots:h,wrapper:c}){let r=re(),S=L(),[N,p]=K(!1),[f,P]=K(!1),x=R(!1),l=R(!1),m=R(!1),F=R(null),v=R(void 0),i=()=>{clearTimeout(v.current),v.current=void 0};return te(()=>i,[]),Q("div",{ref:c,className:"wp-field-parent",style:{colorScheme:S},onClickCapture:b=>{let n=!!F.current&&H(F.current,b.target);n&&(m.current=!0),$(b,b.currentTarget,()=>{n&&(m.current=!1,!l.current&&!x.current&&(i(),p(!1)))})},onPointerEnter:()=>{x.current=!0,i(),p(!0)},onPointerLeave:()=>{x.current=!1,i(),v.current=setTimeout(()=>{!l.current&&!m.current&&p(!1)},400)},onFocus:()=>{l.current=!0,m.current=!1,i(),p(!0),P(!0)},onBlur:b=>{H(b.currentTarget,b.relatedTarget)||(l.current=!1,P(!1),!x.current&&!m.current&&(i(),p(!1)))},children:[e,Q("span",{ref:F,className:"wp-field-adornment",hidden:!N,children:[B(J,{name:"fieldAdornment",slots:h,label:u,onPress:d?void 0:w,disabled:y,"aria-disabled":d?!0:void 0,describedBy:d?r:void 0,children:B("button",{type:"button","aria-label":u,disabled:y,"aria-disabled":d?!0:void 0,"aria-describedby":d?r:void 0,onClick:()=>{d||w()},children:u})}),d?B("span",{id:r,className:"wp-sr-only",children:d}):null]}),B("span",{role:"status",className:"wp-sr-only",children:N&&f?u:""})]})}import{useEffect as Y,useId as Z,useRef as D,useState as I,useSyncExternalStore as ne}from"react";import{Fragment as ee,jsx as t,jsxs as C}from"react/jsx-runtime";var W=V(()=>import("./form-extras-X3B3JCMH.js"));function _(){let e=j(W);return Y(()=>W.request(),[]),e}var oe=e=>{let u=e.trim()===""?NaN:Number(e);return Number.isFinite(u)?u:void 0};function se(e){return ne(e.subscribe,e.getSnapshot,e.getSnapshot)}function Fe({session:e,onRegenerate:u,slots:w,renderField:y}){let d=se(e),{fields:h,pending:c}=d,{format:r,primitives:S}=O(),N=Z(),p=_(),f=p.status==="ready"?p.module:void 0,P=S.input,x=S.checkbox,l=Object.values(h).some(n=>n.localInvalid),[m,F]=I(""),v=D(new Map),i=D(""),b=q(()=>[v.current.get(i.current)?.querySelector("input,textarea,select,button,[tabindex]")]);return C(ee,{children:[Object.entries(h).map(([n,o],M)=>{let T=`${N}-${M}`,k=o.validation?.status==="invalid"||!!o.localInvalid,g=o.value,A={label:o.label,invalid:k,describedBy:T};return C(U,{reason:f?l?r("form.fixFirst"):c?r("form.revertWait"):void 0:r(p.status==="failed"?"form.toolsFailed":"form.toolsLoading"),label:r("form.regenerate",{field:o.label}),slots:w,onRegenerate:()=>u(n),wrapper:a=>v.current.set(n,a),children:[y?y({name:n,label:o.label,value:g,onChange:a=>e.edit(n,a),invalid:k,describedBy:T}):typeof g=="string"?t(P,{...A,value:g,onChange:a=>e.edit(n,a)}):typeof g=="number"?t(P,{...A,type:"number",value:o.localText??String(g),onChange:a=>{let s=oe(a);s===void 0?e.markEdited(n,a):e.edit(n,s)}}):typeof g=="boolean"?t(x,{...A,checked:g,onChange:a=>e.edit(n,a)}):C("div",{children:[o.label,": ",f?t(f.Value,{value:g,t:r}):null," ",r("form.editInForm")]}),C("div",{id:T,className:k?"wp-invalid":void 0,children:[k?t("strong",{children:r("form.invalid")}):null,o.localInvalid?t("p",{children:r("form.number")}):null,o.validation?.messages.map((a,s)=>t("p",{children:a},s)),o.validation?.guidance&&t("p",{children:o.validation.guidance})]}),t("div",{onFocus:a=>{i.current=n,b(a)},children:o.replacement&&f?t(f.Suggestion,{name:n,draft:o,session:e,t:r,primitives:S,onReplace:()=>F(f.attentionText(e.getSnapshot(),r))}):null})]},n)}),f?t(f.FieldsStatus,{text:m}):null]})}function ye({session:e,open:u,onClose:w,field:y,source:d,attachments:h}){let{format:c,primitives:r}=O(),[S,N]=I(""),[p,f]=I(""),[P,x]=I(""),l=_(),m=l.status==="ready"?l.module:void 0,F=D(null),v=D(0),i=D(void 0),b=r.button,n=r.drawer,o=r.textarea,M=z(),T=Z();Y(()=>(v.current++,()=>{v.current++,e.cancel()}),[u,e,y]);let k=()=>{v.current++,e.cancel(),w()},g=s=>s.some(E=>E.type.startsWith("image/"))?(i.current?i.current([...s]):x(c(h?"form.imagesNow":"form.imagesHere")),!0):!1,A=q(()=>[F.current?.querySelector("textarea")]),a=L();return C(X,{as:n,open:u,label:c("form.title"),onClose:k,closeLabel:c("chat.close"),...M,children:[C("div",{ref:F,style:{colorScheme:a},onPasteCapture:s=>{g(Array.from(s.clipboardData.files))&&h&&i.current&&s.preventDefault()},onDragOver:s=>{s.dataTransfer.types.includes("Files")&&s.preventDefault()},onDrop:s=>{if(!s.dataTransfer.files.length)return;s.preventDefault();let E=Array.from(s.dataTransfer.files);g(E)||i.current?.(E)},children:[t("p",{children:c("chat.message")}),t(o,{label:c("chat.message"),value:S,onChange:N}),t("p",{children:c("form.references")}),t(o,{label:c("form.references"),value:p,onChange:f})]}),m?null:t("p",{role:"status",children:P}),m?t(m.PopupBody,{session:e,open:u,field:y,source:d,attachments:h,text:S,references:p,scope:v,upload:i,messageField:()=>F.current?.querySelector("textarea")??null}):C(ee,{children:[l.status==="failed"||l.status==="loading"&&l.retrying?t(G,{retrying:l.status==="loading",onRetry:()=>W.request(!0),onFocus:A}):null,t(b,{"aria-disabled":!0,"aria-describedby":T,children:c("form.generate")}),t("span",{id:T,children:c(l.status==="failed"?"form.toolsFailed":"form.toolsLoading")})]})]})}export{U as a,se as b,Fe as c,ye as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3;var _chunkFBADWFRRcjs = require('./chunk-FBADWFRR.cjs');var _chunkQS3MKZOYcjs = require('./chunk-QS3MKZOY.cjs');var _chunkRZ3AGK3Ucjs = require('./chunk-RZ3AGK3U.cjs');var _chunk4BWV3SELcjs = require('./chunk-4BWV3SEL.cjs');var _chunkGT6PI4CTcjs = require('./chunk-GT6PI4CT.cjs');var _chunk3KV7TDDRcjs = require('./chunk-3KV7TDDR.cjs');var _react = require('react');var lt=new WeakMap;function J(e){let t=e.activeElement;for(;_optionalChain([t, 'optionalAccess', _2 => _2.shadowRoot, 'optionalAccess', _3 => _3.activeElement]);)t=t.shadowRoot.activeElement;return t}function q(e,t){let n=t;for(;n;){if(n===e)return!0;n=_nullishCoalesce(n.parentNode, () => ((n instanceof ShadowRoot?n.host:null)))}return!1}function Pe(e){return _nullishCoalesce(_optionalChain([e, 'access', _4 => _4.composedPath, 'optionalCall', _5 => _5(), 'access', _6 => _6[0]]), () => (e.target))}var Wt=new WeakMap,Mr=0;function bo(e){let t=new Set,n=[],r=s=>{t.has(s)||s.hasAttribute("inert")||(s.setAttribute("inert",e.mark),e.set.push(s))};for(let s=e.drawer;;){t.add(s);let i=s instanceof Element?s.assignedSlot:null;i&&s.parentNode&&n.push(s.parentNode);let d=_nullishCoalesce(i, () => (s.parentNode));if(!d||d.nodeType===Node.DOCUMENT_NODE)break;n.push(d),s=d instanceof ShadowRoot?d.host:d}for(let s of n)for(let i of s.children)r(i);if(typeof MutationObserver=="function"){e.watch=new MutationObserver(s=>{for(let i of s)for(let d of i.addedNodes)d instanceof Element&&r(d)});for(let s of n)e.watch.observe(s,{childList:!0})}}function vo(e){_optionalChain([e, 'access', _7 => _7.watch, 'optionalAccess', _8 => _8.disconnect, 'call', _9 => _9()]),e.watch=void 0;for(let t of e.set)t.getAttribute("inert")===e.mark&&t.removeAttribute("inert");e.set=[]}function $t(e){let t=e.ownerDocument,n=_nullishCoalesce(Wt.get(t), () => ([]));Wt.set(t,n);let r=n.at(-1);r&&vo(r);let s={drawer:_nullishCoalesce(e.closest("[data-wp-modal-root]"), () => (e)),mark:`waypoint-${++Mr}`,set:[]};return n.push(s),bo(s),()=>{let i=n.indexOf(s);if(i<0)return;vo(s),n.splice(i,1);let d=n.at(-1);i===n.length&&d&&bo(d)}}var zt='a[href], button, input, select, textarea, summary, iframe, [tabindex], [contenteditable]:not([contenteditable="false"])';function ie(e){return e instanceof HTMLElement&&e.isConnected&&e.matches(zt)&&!e.matches('input[type="hidden"], :disabled')&&!e.closest("[hidden], [inert]")&&(typeof e.checkVisibility!="function"||e.checkVisibility({visibilityProperty:!0}))}function Rr(e,t){for(let n=e;n;){if(n instanceof Element&&ie(n))return n;if(n===t)return null;n=_nullishCoalesce(n.parentNode, () => ((n instanceof ShadowRoot?n.host:null)))}return null}function Fr(e){return q(e,J(e.ownerDocument))}var qt=e=>{let t=J(e);return!t||t===e.body};function Te(e){let t=lt.get(e);if(t)return t;let n={origins:new Set,last:null};return t=n,lt.set(e,n),e.addEventListener("focusin",r=>{let s=Pe(r);n.last=s,n.disabled=null;for(let i of n.origins)!q(i.root,s)&&!i.owned.some(d=>q(d,s))&&(i.valid=!1,n.origins.delete(i))},!0),e.addEventListener("focusout",r=>{let s=Pe(r);r.relatedTarget||queueMicrotask(()=>{if(!_optionalChain([s, 'optionalAccess', _10 => _10.isConnected])||!qt(e))return;if(s.matches(":disabled"))return void(n.disabled=s);let i=_optionalChain([Wt, 'access', _11 => _11.get, 'call', _12 => _12(e), 'optionalAccess', _13 => _13.at, 'call', _14 => _14(-1), 'optionalAccess', _15 => _15.drawer]);if(!(i&&q(i,s))){n.last=null;for(let d of n.origins)d.valid=!1;n.origins.clear()}})},!0),e.addEventListener("pointerdown",()=>{n.last&&!n.last.isConnected&&qt(e)&&(n.last=null)},!0),n}function de(e){e&&(e.valid=!1,_optionalChain([lt, 'access', _16 => _16.get, 'call', _17 => _17(e.root.ownerDocument), 'optionalAccess', _18 => _18.origins, 'access', _19 => _19.delete, 'call', _20 => _20(e)]))}function ko(e){let t=lt.get(e.ownerDocument);if(t)for(let n of t.origins)q(e,n.root)&&de(n)}function jt(e){Te(e)}function Vt(e,t,n,r){let s="nativeEvent"in e?e.nativeEvent:e,i=Pe(s);if(!q(t,i))return;let d={owner:n,action:r,root:t,control:_nullishCoalesce(Rr(i,t), () => (i)),owned:[],valid:!0};return Te(t.ownerDocument).origins.add(d),d}var xo=new WeakMap;function Co(e){let t=J(e.ownerDocument);t&&q(e,t)&&(Te(e.ownerDocument).last=t,xo.set(e,t))}function Kt(e,t){if(!e)return!1;let{last:n}=Te(t);return!!n&&(q(e,n)||xo.get(e)===n)&&(!n.isConnected||n===Te(t).disabled)&&qt(t)}function te(e,t){let{root:n,origin:r,removed:s}=t;if(!e||!e.isConnected)return!1;let i=n.ownerDocument;if(Te(i),t.stillCurrent&&!t.stillCurrent()||!(r?r.valid&&r.owner===t.owner&&(Fr(n)||Kt(_nullishCoalesce(s, () => (r.control)),i)):Kt(s,i)||t.enterModal===!0&&e===n&&e.matches(_chunkGT6PI4CTcjs.c)))return!1;e.focus({preventScroll:_nullishCoalesce(t.preventScroll, () => (!1))});let a=J(i)===e;return a?Te(i).last=e:_optionalChain([t, 'access', _21 => _21.missed, 'optionalCall', _22 => _22()]),a}var yo=new WeakMap,wo=e=>{let t=yo.get(e);return t||yo.set(e,t=new Set),t};function _t(e){let t=_react.useRef.call(void 0, null),n=_react.useRef.call(void 0, {});return _react.useLayoutEffect.call(void 0, ()=>{jt(document);let r=wo(document),s=n.current;return()=>{r.delete(s)}},[]),_react.useLayoutEffect.call(void 0, ()=>{let r=wo(document),s=t.current;if(!s||s.isConnected)return void r.delete(n.current);if(!Kt(s,document))return t.current=null,void r.delete(n.current);let i=e().find(d=>_optionalChain([d, 'optionalAccess', _23 => _23.isConnected]));if(!(i instanceof HTMLElement))return void r.add(n.current);t.current=null,r.delete(n.current),te(i,{root:i,owner:"",removed:s})}),r=>{t.current=r.target}}var _jsxruntime = require('react/jsx-runtime');var Xt=_react.createContext.call(void 0, null),_e= exports.g =()=>_react.useContext.call(void 0, Xt),So=new WeakMap,Or=0;function ue(e,t){let n=So.get(e);return n===void 0&&So.set(e,n=++Or),`${n}:${t}`}function Eo(e,t,n,r,s=i=>i){let i=_react.useRef.call(void 0, null),d=_react.useRef.call(void 0, t);d.current=t;let a=_react.useRef.call(void 0, s);a.current=s,_react.useEffect.call(void 0, ()=>{let g=e.current;if(g)return jt(g.ownerDocument),()=>ko(g)},[e]);let u=_react.useMemo.call(void 0, ()=>({root:()=>e.current,owner:()=>d.current,ownerOf:g=>a.current(g),originFor(g,f){let m=i.current,b=e.current;return m&&b?Vt(m,b,_nullishCoalesce(f, () => (d.current)),g):void 0},composer:()=>n.current,transcript:()=>r.current}),[e,n,r,t]),p=g=>{let f=g.nativeEvent;i.current=f,Po(()=>{i.current===f&&(i.current=null)})};return{value:u,captureProps:{onClickCapture:p,onKeyDownCapture:p,onPointerDownCapture:p}}}function Qt(e,t,n){let[r,s]=_react.useState.call(void 0, {active:e,conversationId:t});r.active!==e&&s({active:e,conversationId:t});let i=e&&r.active&&r.conversationId!==t,d=_react.useRef.call(void 0, n);return d.current=n,_react.useEffect.call(void 0, ()=>{i&&d.current()},[i]),i}var Po=e=>setTimeout(e,0);function Ar(e){return!!_optionalChain([e, 'optionalAccess', _24 => _24.closest, 'call', _25 => _25('textarea, select, [contenteditable]:not([contenteditable="false"]), input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]):not([type="image"])')])}function To(e){if(!e)return!1;let t=J(e.ownerDocument);return q(e,t)&&!Ar(t)}function Y(e,t,n){let{origin:r,removed:s,fallback:i}=n,d=_optionalChain([e, 'optionalAccess', _26 => _26.root, 'call', _27 => _27()]),a=(g,f)=>!!d&&(!!r||!!s)&&te(g,{root:d,origin:r,removed:s,owner:n.owner,stillCurrent:n.stillCurrent,preventScroll:!0,missed:f}),u=!1,p=a(t,()=>u=!0);return!p&&u&&i&&i!==t&&(p=a(i)),(!n.keep||!p)&&de(r),p}function Jt(e,t,n,r){_optionalChain([t, 'access', _28 => _28.current, 'optionalAccess', _29 => _29.element])!==e&&(t.current={element:e,opener:J(e.ownerDocument)}),_optionalChain([r, 'optionalCall', _30 => _30()]),te(e,{root:e,owner:"",enterModal:!0,stillCurrent:n})}function Zt(e,t,n){let r=e.current;r&&queueMicrotask(()=>{if(e.current!==r)return;let s=_optionalChain([n, 'optionalCall', _31 => _31()]),i=ie(r.opener)?r.opener:s,d={root:r.element,owner:"",removed:r.element,stillCurrent:t,preventScroll:!0};te(i,{...d,missed:()=>{s!==i&&te(s,d)}}),r.element.isConnected||(e.current=void 0)})}function en({as:e,focusInto:t,restoreFocus:n,...r}){let s=_react.useRef.call(void 0, void 0),i=_react.useRef.call(void 0, void 0);return _react.useEffect.call(void 0, ()=>()=>{_optionalChain([s, 'access', _32 => _32.current, 'optionalCall', _33 => _33()]),s.current=void 0},[]),_jsxruntime.jsx.call(void 0, e,{...r,focusInto:d=>{if(_optionalChain([s, 'access', _34 => _34.current, 'optionalCall', _35 => _35()]),t){let a=!1,u=()=>{s.current=$t(d),a=!0};t(d,u),a||u()}else Jt(d,i,void 0,()=>{s.current=$t(d)})},restoreFocus:d=>{Co(d),_optionalChain([s, 'access', _36 => _36.current, 'optionalCall', _37 => _37()]),s.current=void 0,n?n(d):Zt(i)}})}function tn(e,t,n){let r=_e(),s=_react.useRef.call(void 0, void 0),i=_react.useRef.call(void 0, void 0),d=_react.useRef.call(void 0, t);d.current=t;let a=_react.useRef.call(void 0, n);return a.current=n,_react.useMemo.call(void 0, ()=>r?{focusInto(u,p){let g=r.owner(),f=r.originFor(`drawer:${e}`,g);if(s.current={origin:f,key:g},!f){Jt(u,i,()=>r.owner()===g&&(_nullishCoalesce(_optionalChain([d, 'access', _38 => _38.current, 'optionalCall', _39 => _39()]), () => (!0))),p);return}i.current=void 0,Y(r,u,{origin:f,owner:g,stillCurrent:()=>r.owner()===g&&(_nullishCoalesce(_optionalChain([d, 'access', _40 => _40.current, 'optionalCall', _41 => _41()]), () => (!0))),keep:!0})},restoreFocus(u){let p=s.current;if(s.current=void 0,!p)return;if(!p.origin){Zt(i,()=>r.owner()===p.key,()=>{let f=_optionalChain([a, 'access', _42 => _42.current, 'optionalCall', _43 => _43()]);return ie(_nullishCoalesce(f, () => (null)))?f:r.transcript()});return}let g={origin:p.origin,key:p.key};queueMicrotask(()=>Dr(r,u,g,_optionalChain([a, 'access', _44 => _44.current, 'optionalCall', _45 => _45()])))},release(){let u=s.current;s.current=void 0,de(_optionalChain([u, 'optionalAccess', _46 => _46.origin]))}}:{},[r,e])}function Dr(e,t,n,r){let s=J(t.ownerDocument);if(!q(t,s)&&s&&s!==t.ownerDocument.body)return de(n.origin);let i=n.origin.control,d=ie(_nullishCoalesce(r, () => (null)))?r:e.transcript(),a=ie(i)?i:d;Y(e,a,{origin:n.origin,owner:n.key,stillCurrent:()=>e.owner()===n.key,removed:t,fallback:d})}var ct=null;function _s(e,t,n){let r=Vt(e.nativeEvent,t,"form-field","open");if(!r)return _optionalChain([n, 'optionalCall', _47 => _47()]);let s={origin:r,claimed:!1,settled:n};ct=s,Po(()=>{ct===s&&(ct=null),s.claimed||(de(r),_optionalChain([s, 'access', _48 => _48.settled, 'optionalCall', _49 => _49()]))})}function Gs(){let e=_react.useRef.call(void 0, void 0),t=_react.useRef.call(void 0, void 0);return _react.useMemo.call(void 0, ()=>({focusInto(n){let r=_nullishCoalesce(ct, () => (void 0));if(e.current=r,!r){Jt(n,t);return}t.current=void 0;let s=r.origin;r.claimed=!0,s.owned.push(n),te(n,{root:s.root,origin:s,owner:s.owner,preventScroll:!0})},restoreFocus(n){let r=e.current;if(e.current=void 0,!r){Zt(t);return}queueMicrotask(()=>{Br(n,r.origin),_optionalChain([r, 'access', _50 => _50.settled, 'optionalCall', _51 => _51()])})}}),[])}function Br(e,t){let n=[...t.root.querySelectorAll("*")].find(ie),r={root:e,origin:t,removed:e,owner:t.owner,preventScroll:!0},s=!ie(t.control);s||te(t.control,{...r,missed:()=>s=!0}),s&&n&&n!==t.control&&te(n,r),de(t)}var Ur=/[--]/g;function nn(e,t=120){let n=e.replace(Ur,"").replace(/\s+/g," ").trim();if(!n||typeof Intl.Segmenter!="function")return;let r=[];for(let s of new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(n)){if(r.length===t)return`${r.join("")}\u2026`;r.push(s.segment)}return n}var ke= (_class =class{constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this); }__init() {this.policy=[]}__init2() {this.byId=new Map}begin(t,n,r){if(t!==this.owner||n.length!==this.policy.length||n.some((d,a)=>d!==this.policy[a])){let d=this.byId.size>0;return this.owner=t,this.policy=n,this.byId=new Map,d}if(!this.byId.size)return!1;let s=new Map(r.map(d=>[d.id,d.source])),i=!1;for(let[d,a]of this.byId)(!s.has(d)||s.get(d)!==a.source)&&(this.byId.delete(d),i=!0);return i}get(t,n,r){let s=this.byId.get(t);if(s&&s.source===n)return s.value;let i=r(n);return this.byId.set(t,{source:n,value:i}),i}peek(t,n){let r=this.byId.get(t);return r&&r.source===n?r.value:void 0}entries(){return[...this.byId].map(([t,n])=>({id:t,source:n.source}))}}, _class),dt=class extends ke{};var Wr=/[̀-ͯ᪰-᷀-᷿⃐-︠-︯]/g;function on(e,t){let n=qr(t);return e.normalize("NFKD").toLocaleUpperCase(n).toLocaleLowerCase(n).normalize("NFD").replace(Wr,"").normalize("NFC").replace(/\s+/g," ").trim()}function qr(e){if(e)try{return Intl.getCanonicalLocales(e)[0]}catch (e2){return}}var Kr=8,ut= (_class2 =class{constructor() { _class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this);_class2.prototype.__init5.call(this);_class2.prototype.__init6.call(this);_class2.prototype.__init7.call(this);_class2.prototype.__init8.call(this);_class2.prototype.__init9.call(this);_class2.prototype.__init10.call(this); }__init3() {this.texts=new ke}__init4() {this.shown=[]}__init5() {this.make=()=>""}__init6() {this.cursor=0}__init7() {this.version=0}__init8() {this.listeners=new Set}sync(t,n,r,s){(this.texts.begin(t,n,r)||r!==this.shown)&&(this.cursor=0),this.shown=r,this.make=s}textOf(t,n){return this.texts.peek(t,n)}complete(){for(;this.cursor<this.shown.length;this.cursor++){let{id:t,source:n}=this.shown[this.cursor];if(this.texts.peek(t,n)===void 0)return!1}return!0}start(){if(this.pending||this.complete())return;let t=n=>{this.pending=void 0;let r=performance.now()+Kr,s=n?()=>n.timeRemaining()>1:()=>performance.now()<r,i=!1;do{if(this.complete())break;let{id:d,source:a,message:u}=this.shown[this.cursor];this.texts.get(d,a,()=>this.make(u)),i=!0}while(s());if(i){this.version++;for(let d of this.listeners)d()}this.start()};if(typeof requestIdleCallback=="function"){let n=requestIdleCallback(t,{timeout:200});this.pending=()=>cancelIdleCallback(n)}else{let n=setTimeout(t,0);this.pending=()=>clearTimeout(n)}}stop(){_optionalChain([this, 'access', _52 => _52.pending, 'optionalCall', _53 => _53()]),this.pending=void 0}__init9() {this.subscribe=t=>(this.listeners.add(t),()=>this.listeners.delete(t))}__init10() {this.snapshot=()=>this.version}}, _class2);var Fo=24,rn=150,zr=100,jr=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "]),Vr="[data-message-id]",We=e=>Math.max(0,e.scrollHeight-e.clientHeight),Lo=e=>e.scrollHeight-e.clientHeight-e.scrollTop,ft=()=>performance.now(),_r=e=>typeof requestAnimationFrame=="function"?requestAnimationFrame(e):setTimeout(e,16),sn=e=>[...e.querySelectorAll(Vr)].filter(t=>t.closest(".wp-transcript")===e),pt=e=>e.getAttribute("data-message-id");function Io(e,t,n,r,s){let[i,d]=_react.useState.call(void 0, !0),a=_react.useRef.call(void 0, {pinned:!0,token:void 0,expected:[],lastTop:0,sizeFrame:!1,anchor:void 0,shown:void 0}).current,u=c=>{a.pinned=c,d(c)},p=()=>{clearTimeout(_optionalChain([a, 'access', _54 => _54.token, 'optionalAccess', _55 => _55.timer])),a.token=void 0},g=(c,C)=>{let E=Math.min(Math.max(0,C),We(c));a.expected.push({top:E,at:ft()}),typeof c.scrollTo=="function"?c.scrollTo({top:E,behavior:"instant"}):c.scrollTop=E,a.lastTop=c.scrollTop},f=c=>{let C=c.getBoundingClientRect().top,E=sn(c),L=E.find(R=>R.getBoundingClientRect().bottom>C+.5);a.anchor=L&&{id:pt(L),offset:L.getBoundingClientRect().top-C,order:E.map(pt)}},m=c=>{let C=a.anchor;if(!C)return f(c);let E=new Map(sn(c).map(y=>[pt(y),y])),L=C.order.indexOf(C.id),R=_nullishCoalesce(_nullishCoalesce(E.get(C.id), () => (C.order.slice(L+1).map(y=>E.get(y)).find(Boolean))), () => (C.order.slice(0,Math.max(0,L)).reverse().map(y=>E.get(y)).find(Boolean)));if(!R)g(c,0);else{let y=R.getBoundingClientRect().top-c.getBoundingClientRect().top-C.offset;Math.abs(y)>.5&&g(c,c.scrollTop+y)}f(c)},b=()=>{let c=e.current;c&&(a.token&&!a.token.used&&!a.token.held&&p(),a.pinned?Lo(c)>.5&&g(c,We(c)):m(c))},A=_react.useRef.call(void 0, b);return A.current=b,_react.useLayoutEffect.call(void 0, ()=>{let c=r===0;(n!==a.shown||c)&&(a.shown=n,a.anchor=void 0,p(),a.pinned||u(!0)),b()},[s,n,r]),_react.useLayoutEffect.call(void 0, ()=>{let c=e.current;if(!c)return;let C=c.ownerDocument,E=w=>{clearTimeout(w.timer);let k=()=>{if(a.token!==w||w.held)return;let x=ft()-Math.max(w.lastInput,w.lastScroll);x>=rn?a.token=void 0:w.timer=setTimeout(k,rn-x)};w.timer=setTimeout(k,rn)},L=w=>{let k=a.token??={used:!1,held:!1,lastInput:0,lastScroll:0};k.lastInput=ft(),w&&(k.held=!0),E(k)},R=()=>{let w=a.token;_optionalChain([w, 'optionalAccess', _56 => _56.held])&&(w.held=!1,E(w))},y=()=>L(),P=()=>L(!0),S=w=>{jr.has(w.key)&&q(c,J(C))&&L()},N=()=>{let w=c.scrollTop,k=a.lastTop;a.lastTop=w;let x=ft();a.expected=a.expected.filter(Fe=>x-Fe.at<zr);let _=a.expected.findIndex(Fe=>Math.abs(Fe.top-w)<=1),Z=a.token,W=We(c),pe=Math.abs(w-W)<=1&&k>W+.5,Se=_>=0||!Z||pe||a.sizeFrame&&Math.abs(w-W)<=1;_>=0&&a.expected.splice(0,_+1),Se||(Z.used=!0,Z.lastScroll=x,E(Z),w<k-.5?u(!1):w>k+.5&&Lo(c)<=Fo&&!a.pinned&&u(!0)),a.pinned||f(c)};c.addEventListener("wheel",y,{passive:!0}),c.addEventListener("touchstart",P,{passive:!0}),c.addEventListener("touchmove",y,{passive:!0}),c.addEventListener("pointerdown",P),c.addEventListener("keydown",S),c.addEventListener("scroll",N,{passive:!0});for(let w of["pointerup","pointercancel","touchend","touchcancel"])C.addEventListener(w,R,!0);let v=typeof ResizeObserver=="function"?new ResizeObserver(()=>{a.sizeFrame=!0,_r(()=>a.sizeFrame=!1),A.current()}):void 0;return _optionalChain([v, 'optionalAccess', _57 => _57.observe, 'call', _58 => _58(c)]),t.current&&_optionalChain([v, 'optionalAccess', _59 => _59.observe, 'call', _60 => _60(t.current)]),()=>{c.removeEventListener("wheel",y),c.removeEventListener("touchstart",P),c.removeEventListener("touchmove",y),c.removeEventListener("pointerdown",P),c.removeEventListener("keydown",S),c.removeEventListener("scroll",N);for(let w of["pointerup","pointercancel","touchend","touchcancel"])C.removeEventListener(w,R,!0);_optionalChain([v, 'optionalAccess', _61 => _61.disconnect, 'call', _62 => _62()]),p()}},[e,t]),{pinned:i,anchorId:()=>a.pinned?void 0:_optionalChain([a, 'access', _63 => _63.anchor, 'optionalAccess', _64 => _64.id]),toLatest(){let c=e.current;c&&(p(),g(c,We(c)),u(!0))},toMessage(c){let C=e.current,E=C&&sn(C).find(y=>pt(y)===c);if(!C||!E)return;p();let L=Math.min(We(C),C.scrollTop+E.getBoundingClientRect().top-C.getBoundingClientRect().top);g(C,L);let R=We(C)-L<=Fo;return u(R),R||f(C),E}}}var Gr=500,Yr=1200,Xr=160;function No(e,t,n,r=Yr){let s=e.length;if(!s)return[0,-1];if(n){let g=s-1,f=e[g];for(;g>0&&f<t.height+r;)f+=e[--g];return[g,s-1]}let i=t.top-r,d=t.top+t.height+r,a=0,u=-1,p=s-1;for(let g=0;g<s;g++){let f=a+e[g];if(u<0&&f>i&&(u=g),a>=d){p=g-1;break}a=f}return u<0?No(e,t,!0,r):[u,Math.max(u,p)]}function Qr(e,[t,n],r=[]){let s=new Set;for(let u=t;u<=n;u++)s.add(u);for(let u of r)u>=0&&u<e.length&&s.add(u);let i=[],d=0,a=0;for(let u=0;u<e.length;u++)if(s.has(u)){d&&(i.push({kind:"gap",from:a,to:u-1,height:d}),d=0);let p=i.at(-1);_optionalChain([p, 'optionalAccess', _65 => _65.kind])==="rows"&&p.to===u-1?p.to=u:i.push({kind:"rows",from:u,to:u})}else d||(a=u),d+=e[u];return d&&i.push({kind:"gap",from:a,to:e.length-1,height:d}),i}var gt="article[data-message-id]";function Oo(e,t,n,r,s){let i=n.length>=Gr,d=_react.useRef.call(void 0, new Map).current,a=_react.useRef.call(void 0, {top:0,height:0}),u=_react.useRef.call(void 0, i);u.current=i;let[,p]=_react.useState.call(void 0, 0),[,g]=_react.useState.call(void 0, 0),[f,m]=_react.useState.call(void 0, ),[b,A]=_react.useState.call(void 0, );if(d.size>n.length*2){let y=new Set(n);for(let P of d.keys())y.has(P)||d.delete(P)}let c=0;for(let y of d.values())c+=y;let C=d.size?c/d.size:Xr,E=i?n.map(y=>_nullishCoalesce(d.get(y), () => (C))):[],L=i?[f,_optionalChain([b, 'optionalAccess', _66 => _66.id]),s].filter(y=>y!==void 0).map(y=>n.indexOf(y)):[],R=i?Qr(E,No(E,a.current,r),L):n.length?[{kind:"rows",from:0,to:n.length-1}]:[];return _react.useLayoutEffect.call(void 0, ()=>{let y=e.current;if(!y)return;let P,S=()=>{P=void 0;let w=a.current,k={top:y.scrollTop,height:y.clientHeight};Math.abs(w.top-k.top)<1&&w.height===k.height||(a.current=k,u.current&&p(x=>x+1))},N=()=>{P===void 0&&(P=typeof requestAnimationFrame=="function"?requestAnimationFrame(S):setTimeout(S,16))};S(),y.addEventListener("scroll",N,{passive:!0});let v=typeof ResizeObserver=="function"?new ResizeObserver(N):void 0;return _optionalChain([v, 'optionalAccess', _67 => _67.observe, 'call', _68 => _68(y)]),()=>{y.removeEventListener("scroll",N),_optionalChain([v, 'optionalAccess', _69 => _69.disconnect, 'call', _70 => _70()]),P!==void 0&&(typeof cancelAnimationFrame=="function"?cancelAnimationFrame:clearTimeout)(P)}},[e]),_react.useLayoutEffect.call(void 0, ()=>{let y=t.current;if(!i||!y)return;let P=v=>_nullishCoalesce(_optionalChain([(v instanceof Element?v.closest(gt):null), 'optionalAccess', _71 => _71.getAttribute, 'call', _72 => _72("data-message-id")]), () => (void 0)),S=v=>m(P(v.target)),N=v=>{y.contains(v.relatedTarget)||m(void 0)};return y.addEventListener("focusin",S),y.addEventListener("focusout",N),()=>{y.removeEventListener("focusin",S),y.removeEventListener("focusout",N)}},[t,i]),_react.useLayoutEffect.call(void 0, ()=>{let y=t.current;if(!y)return;let P=!1,S=[...y.children],N=S.map(v=>v.getBoundingClientRect());for(let v=0;v<S.length;v++){let w=S[v];if(!w.matches(gt))continue;let k=N[v+1],x=k?k.top-N[v].top:N[v].height,_=w.getAttribute("data-message-id");x>0&&Math.abs((_nullishCoalesce(d.get(_), () => (-1)))-x)>1&&(d.set(_,x),P=!0)}P&&i&&g(v=>v+1)}),_react.useLayoutEffect.call(void 0, ()=>{if(!b||![..._nullishCoalesce(_optionalChain([t, 'access', _73 => _73.current, 'optionalAccess', _74 => _74.querySelectorAll, 'call', _75 => _75(gt)]), () => ([]))].some(S=>S.getAttribute("data-message-id")===b.id))return;A(void 0),b.then();let P=e.current;P&&(a.current={top:P.scrollTop,height:P.clientHeight},p(S=>S+1))},[b,t,e]),{windowed:i,busy:b!==void 0,segments:R,reveal(y,P){let S=[..._nullishCoalesce(_optionalChain([t, 'access', _76 => _76.current, 'optionalAccess', _77 => _77.querySelectorAll, 'call', _78 => _78(gt)]), () => ([]))].some(N=>N.getAttribute("data-message-id")===y);!i||S||!n.includes(y)?P():A({id:y,then:P})}}}var Jr=1e3,Zr=e=>`\u2068${e}\u2069`,Bo=()=>typeof requestAnimationFrame=="function",es=e=>Bo()?requestAnimationFrame(e):setTimeout(e,16),ln=e=>{Bo()?cancelAnimationFrame(e):clearTimeout(e)};function Ao(e){if(e.role!=="assistant")return;let t=e.status;if(t==null)return"arrived";if(t==="completed")return"completed";if(t==="failed"||t==="unavailable")return"failed"}function Ho(e,t,n,r,s){let[i,d]=_react.useState.call(void 0, ""),a=_react.useRef.call(void 0, {baselineFor:void 0,baseline:new Set,announced:new Map,writing:new Set,held:void 0,pending:new Map,batchFor:void 0,timer:void 0,frame:void 0,showing:0,batchShowing:0,client:void 0}).current,u=_react.useRef.call(void 0, {conversation:t,excerptOf:n,t:r});u.current={conversation:t,excerptOf:n,t:r};let p=(m,b)=>{let A=a.announced.get(m),c=!!A&&(A.has("completed")||A.has("failed"));return b==="arrived"?!c&&!_optionalChain([A, 'optionalAccess', _79 => _79.has, 'call', _80 => _80("arrived")])&&!a.writing.has(m):!c},g=()=>{a.timer=void 0;let m=[...a.pending],b=a.batchFor,A=a.batchShowing;a.pending.clear(),a.frame!==void 0&&ln(a.frame),d(""),a.frame=es(()=>{a.frame=void 0,A===a.showing&&f(m,b)})},f=(m,b)=>{let A=_optionalChain([s, 'optionalAccess', _81 => _81.current]);if(_optionalChain([A, 'optionalAccess', _82 => _82.closest, 'call', _83 => _83("[inert]")])){for(let[k,x]of m)a.pending.set(k,x);a.held??=new MutationObserver(()=>{A.closest("[inert]")||(_optionalChain([a, 'access', _84 => _84.held, 'optionalAccess', _85 => _85.disconnect, 'call', _86 => _86()]),a.held=void 0,g())}),a.held.observe(A.ownerDocument.documentElement,{attributes:!0,attributeFilter:["inert"],subtree:!0});return}let{conversation:c,excerptOf:C,t:E}=u.current;if(!c||c.id!==b)return;let L=new Map(c.messages.map(k=>[k.id,k])),R=m.flatMap(([k])=>{let x=L.get(k),_=x&&Ao(x);return x&&_&&p(k,_)?[{id:k,stage:_,message:x}]:[]});if(!R.length)return;let y=new Map(c.messages.map((k,x)=>[k.id,x]));R.sort((k,x)=>y.get(k.id)-y.get(x.id));let P=R.length,S=R.filter(k=>k.stage==="failed").length,N=R.filter(k=>k.stage==="completed"),v=k=>{let x=C(k);return x===void 0?void 0:Zr(x)},w;if(P===1){let[k]=R,x=k.stage==="completed"?v(k.message):void 0;w=k.stage==="failed"?E("chat.arrivalFailed"):x!==void 0?E("chat.arrivalExcerpt",{excerpt:x}):E("chat.arrival")}else if(N.length===P){let k=v(N.at(-1).message);w=k!==void 0?E("chat.arrivalMany",{count:P,excerpt:k}):E("chat.arrivalManyPlain",{count:P})}else S===P?w=E("chat.arrivalAllFailed",{count:P}):S?w=E("chat.arrivalManyFailed",{count:P,failed:S}):w=E("chat.arrivalManyPlain",{count:P});for(let k of R){let x=_nullishCoalesce(a.announced.get(k.id), () => (new Set));x.add(k.stage),a.announced.set(k.id,x)}d(w)};return _react.useEffect.call(void 0, ()=>{if(a.client!==e&&(a.client=e,a.baselineFor=void 0),!t){a.baselineFor=void 0;return}if(a.baselineFor!==t.id){a.baselineFor=t.id,a.showing++,a.baseline=new Set(t.messages.map(m=>m.id)),a.announced.clear(),a.writing.clear(),a.pending.clear(),clearTimeout(a.timer),a.timer=void 0,a.frame!==void 0&&ln(a.frame),a.frame=void 0;return}for(let m of t.messages){if(a.baseline.has(m.id))continue;m.status==="writing"&&a.writing.add(m.id);let b=Ao(m);!b||!p(m.id,b)||(a.pending.size||(a.batchFor=t.id,a.batchShowing=a.showing),a.pending.set(m.id,b))}a.pending.size&&a.timer===void 0&&(a.timer=setTimeout(g,Jr))},[e,t]),_react.useEffect.call(void 0, ()=>()=>{clearTimeout(a.timer),a.frame!==void 0&&ln(a.frame),_optionalChain([a, 'access', _87 => _87.held, 'optionalAccess', _88 => _88.disconnect, 'call', _89 => _89()])},[a]),i}function Uo(e,t){let[n,r]=_react.useState.call(void 0, !1),s=_react.useRef.call(void 0, e);return _react.useEffect.call(void 0, ()=>{let i=t.current;if(!i||typeof MutationObserver!="function")return;let d=()=>r(!!i.closest("[inert]"));d();let a=new MutationObserver(d);return a.observe(i.ownerDocument.documentElement,{attributes:!0,attributeFilter:["inert"],subtree:!0}),()=>a.disconnect()},[t]),n||(s.current=e),s.current}var ts={"form.valid":"Valid","form.invalid":"Invalid","form.title":"Fill this form","form.closeHint":"Closing discards this fill; the reply stays in the conversation.","form.generate":"Generate draft","form.references":"Reference links","form.attachment":"Private attachment","form.regenerate":"Regenerate {field}","form.replace":"Replace your edit?","form.marker":"Form","form.filter":"Filter by topic","form.all":"All topics","form.threads":"Sub-threads","form.return":"Back to form or record","form.unlinked":"Saved, not linked","form.toolsLoading":"Draft tools are still loading.","form.toolsFailed":"Draft tools couldn't load. Retry first.","form.fixFirst":"Fix the highlighted fields first.","form.number":"Enter a number.","form.editInForm":"Edit this value in the form.","form.imagesNow":"Images can't be attached right now.","form.imagesHere":"Images can't be attached here.","chat.title":"Conversation","chat.empty":"Start a conversation","chat.message":"Message","chat.send":"Send","chat.sending":"Sending","chat.pendingSending":"Sending\u2026","chat.pendingFailed":"Not sent","chat.planUnavailable":"The plan's steps could not be loaded.","chat.arrival":"New reply","chat.arrivalExcerpt":"New reply: {excerpt}","chat.arrivalFailed":"A reply could not be completed.","chat.arrivalMany":"{count} new replies. Latest: {excerpt}","chat.arrivalManyPlain":"{count} new replies","chat.arrivalManyFailed":"{count} new replies; {failed} could not be completed.","chat.arrivalAllFailed":"{count} replies could not be completed.","chat.transcript":"Messages","chat.outlineItem":"{role}, message {position}: {excerpt}","chat.outlineItemPlain":"{role}, message {position}","chat.roleUser":"You","chat.roleAssistant":"Assistant","chat.messageLoading":"Loading message\u2026","chat.messageUnavailable":"This message cannot be shown right now.","chat.changesTo":"changes to","chat.stepName":"Change {index}","chat.stepNamed":"{name} {index}","chat.fieldName":"Value {index}","chat.scrollRegion":"Scrollable content","chat.conversationReadFailed":"This conversation could not be loaded.","chat.conversationsFailed":"Your conversations could not be loaded.","chat.messagesUnavailable":"Some messages cannot be shown right now.",unsupportedContent:"Some content cannot be shown here. Contact the site administrator.","chat.failure":"The request could not be completed.","chat.update":"This chat needs an update.","chat.conversationUnavailable":"This conversation is unavailable. Reload to continue; this does not stop a server turn.","chat.reload":"Reload conversation","chat.retry":"Retry","chat.withdraw":"Withdraw","chat.restored":"Withdrawn messages","chat.restoredEdit":"Edit","chat.restoredDiscard":"Discard","chat.dismiss":"Dismiss","chat.latest":"Back to latest","chat.latestNew":"{count, plural, one {Back to latest, # new reply} other {Back to latest, # new replies}}","chat.outline":"Message outline","chat.outlineFilter":"Filter messages","chat.outlineMatches":"{count, plural, =0 {No messages match} one {# message matches} other {# messages match}}","chat.outlineSearching":"Searching\u2026","chat.rail":"Conversations","chat.close":"Close","chat.quota":"Usage","chat.actions":"Actions","chat.panels":"Extra panels","chat.submit":"Submit","chat.confirm":"Confirm","chat.cancel":"Cancel","chat.stop":"Stop","chat.planChanged":"The plan changed; confirm again.","chat.stopped":"The plan was stopped. Start a new plan to continue.","chat.scheduleUnavailable":"Scheduling is unavailable in this chat.","chat.start":"Start time","chat.end":"End time","chat.view":"View change","chat.irreversible":"Cannot be undone","chat.stepUp":"{count, plural, one {# verification prompt} other {# verification prompts}}","chat.stepUpLabel":"Verification code","chat.plan":"Plan","chat.favourite":"Favourite","chat.run":"Run","chat.flows":"Saved requests","flow.favourites":"Favourites","flow.most-used":"Most used","flow.recent":"Recent","flow.presets":"Presets","reply.writing":"Writing","reply.stopped":"Stopped","chat.sources":"Sources ({count})","chat.source":"Source {index}: {title}","reply.unavailable":"Reply unavailable","reply.failed":"Reply failed","reply.overdue":"Reply overdue","chat.loading":"Loading","chat.before":"Before","chat.after":"After","chat.undo":"Undo","chat.verify":"Verification required","chat.startupLoading":"Loading this conversation\u2026"},bt={en:{},zh:{}};function Wo(e,t){Object.assign(bt.en,e),Object.assign(bt.zh,t)}var ns={"form.valid":"\u6709\u6548","form.invalid":"\u65E0\u6548","form.title":"\u586B\u5199\u6B64\u8868\u5355","form.closeHint":"\u5173\u95ED\u5C06\u4E22\u5F03\u672C\u6B21\u586B\u5145\uFF1B\u56DE\u590D\u4ECD\u4FDD\u7559\u5728\u5BF9\u8BDD\u4E2D\u3002","form.generate":"\u751F\u6210\u8349\u7A3F","form.references":"\u53C2\u8003\u94FE\u63A5","form.attachment":"\u79C1\u6709\u9644\u4EF6","form.regenerate":"\u91CD\u65B0\u751F\u6210{field}","form.replace":"\u66FF\u6362\u4F60\u7684\u4FEE\u6539\u5417\uFF1F","form.marker":"\u8868\u5355","form.filter":"\u6309\u4E3B\u9898\u7B5B\u9009","form.all":"\u6240\u6709\u4E3B\u9898","form.threads":"\u5B50\u5BF9\u8BDD","form.return":"\u8FD4\u56DE\u8868\u5355\u6216\u8BB0\u5F55","form.unlinked":"\u5DF2\u4FDD\u5B58\uFF0C\u672A\u5173\u8054","form.toolsLoading":"\u8349\u7A3F\u5DE5\u5177\u4ECD\u5728\u52A0\u8F7D\u3002","form.toolsFailed":"\u8349\u7A3F\u5DE5\u5177\u65E0\u6CD5\u52A0\u8F7D\uFF0C\u8BF7\u5148\u91CD\u8BD5\u3002","form.fixFirst":"\u8BF7\u5148\u4FEE\u6B63\u6807\u51FA\u7684\u5B57\u6BB5\u3002","form.number":"\u8BF7\u8F93\u5165\u6570\u5B57\u3002","form.editInForm":"\u8BF7\u5728\u8868\u5355\u4E2D\u7F16\u8F91\u6B64\u503C\u3002","form.imagesNow":"\u73B0\u5728\u65E0\u6CD5\u9644\u52A0\u56FE\u7247\u3002","form.imagesHere":"\u6B64\u5904\u65E0\u6CD5\u9644\u52A0\u56FE\u7247\u3002","chat.title":"\u5BF9\u8BDD","chat.empty":"\u5F00\u59CB\u5BF9\u8BDD","chat.message":"\u6D88\u606F","chat.send":"\u53D1\u9001","chat.sending":"\u6B63\u5728\u53D1\u9001","chat.pendingSending":"\u6B63\u5728\u53D1\u9001\u2026\u2026","chat.pendingFailed":"\u672A\u53D1\u9001","chat.planUnavailable":"\u65E0\u6CD5\u52A0\u8F7D\u6B64\u8BA1\u5212\u7684\u6B65\u9AA4\u3002","chat.arrival":"\u6536\u5230\u65B0\u56DE\u590D","chat.arrivalExcerpt":"\u6536\u5230\u65B0\u56DE\u590D\uFF1A{excerpt}","chat.arrivalFailed":"\u6709\u4E00\u6761\u56DE\u590D\u672A\u80FD\u5B8C\u6210\u3002","chat.arrivalMany":"\u6536\u5230 {count} \u6761\u65B0\u56DE\u590D\u3002\u6700\u65B0\u4E00\u6761\uFF1A{excerpt}","chat.arrivalManyPlain":"\u6536\u5230 {count} \u6761\u65B0\u56DE\u590D","chat.arrivalManyFailed":"\u6536\u5230 {count} \u6761\u65B0\u56DE\u590D\uFF0C\u5176\u4E2D {failed} \u6761\u672A\u80FD\u5B8C\u6210\u3002","chat.arrivalAllFailed":"{count} \u6761\u56DE\u590D\u672A\u80FD\u5B8C\u6210\u3002","chat.transcript":"\u6D88\u606F","chat.outlineItem":"{role}\uFF0C\u7B2C {position} \u6761\uFF1A{excerpt}","chat.outlineItemPlain":"{role}\uFF0C\u7B2C {position} \u6761","chat.roleUser":"\u4F60","chat.roleAssistant":"\u52A9\u624B","chat.messageLoading":"\u6B63\u5728\u52A0\u8F7D\u6D88\u606F\u2026\u2026","chat.messageUnavailable":"\u6682\u65F6\u65E0\u6CD5\u663E\u793A\u6B64\u6D88\u606F\u3002","chat.changesTo":"\u6539\u4E3A","chat.stepName":"\u66F4\u6539 {index}","chat.stepNamed":"{name} {index}","chat.fieldName":"\u503C {index}","chat.scrollRegion":"\u53EF\u6EDA\u52A8\u5185\u5BB9","chat.conversationReadFailed":"\u65E0\u6CD5\u52A0\u8F7D\u6B64\u5BF9\u8BDD\u3002","chat.conversationsFailed":"\u65E0\u6CD5\u52A0\u8F7D\u4F60\u7684\u5BF9\u8BDD\u5217\u8868\u3002","chat.messagesUnavailable":"\u90E8\u5206\u6D88\u606F\u6682\u65F6\u65E0\u6CD5\u663E\u793A\u3002",unsupportedContent:"\u6B64\u5904\u65E0\u6CD5\u663E\u793A\u90E8\u5206\u5185\u5BB9\u3002\u8BF7\u8054\u7CFB\u7AD9\u70B9\u7BA1\u7406\u5458\u3002","chat.failure":"\u65E0\u6CD5\u5B8C\u6210\u8BF7\u6C42\u3002","chat.update":"\u6B64\u5BF9\u8BDD\u9700\u8981\u66F4\u65B0\u540E\u624D\u80FD\u7EE7\u7EED\u4F7F\u7528\u3002","chat.conversationUnavailable":"\u6B64\u5BF9\u8BDD\u6682\u65F6\u65E0\u6CD5\u4F7F\u7528\u3002\u8BF7\u91CD\u65B0\u52A0\u8F7D\u540E\u7EE7\u7EED\uFF1B\u91CD\u65B0\u52A0\u8F7D\u4E0D\u4F1A\u505C\u6B62\u670D\u52A1\u5668\u6B63\u5728\u5904\u7406\u7684\u56DE\u590D\u3002","chat.reload":"\u91CD\u65B0\u52A0\u8F7D\u5BF9\u8BDD","chat.retry":"\u91CD\u8BD5","chat.withdraw":"\u64A4\u56DE","chat.restored":"\u5DF2\u64A4\u56DE\u7684\u6D88\u606F","chat.restoredEdit":"\u7F16\u8F91","chat.restoredDiscard":"\u4E22\u5F03","chat.dismiss":"\u5173\u95ED","chat.latest":"\u56DE\u5230\u6700\u65B0\u6D88\u606F","chat.latestNew":"{count, plural, other {\u56DE\u5230\u6700\u65B0\u6D88\u606F\uFF0C# \u6761\u65B0\u56DE\u590D}}","chat.outline":"\u6D88\u606F\u5927\u7EB2","chat.outlineFilter":"\u7B5B\u9009\u6D88\u606F","chat.outlineMatches":"{count, plural, =0 {\u6CA1\u6709\u5339\u914D\u7684\u6D88\u606F} other {# \u6761\u6D88\u606F\u5339\u914D}}","chat.outlineSearching":"\u6B63\u5728\u641C\u7D22\u2026","chat.rail":"\u5BF9\u8BDD\u5217\u8868","chat.close":"\u5173\u95ED","chat.quota":"\u4F7F\u7528\u91CF","chat.actions":"\u64CD\u4F5C","chat.panels":"\u9644\u52A0\u9762\u677F","chat.submit":"\u63D0\u4EA4","chat.confirm":"\u786E\u8BA4","chat.cancel":"\u53D6\u6D88","chat.stop":"\u505C\u6B62","chat.planChanged":"\u8BA1\u5212\u5DF2\u66F4\u6539\uFF0C\u8BF7\u91CD\u65B0\u786E\u8BA4\u3002","chat.stopped":"\u8BA1\u5212\u5DF2\u505C\u6B62\u3002\u8BF7\u521B\u5EFA\u65B0\u8BA1\u5212\u4EE5\u7EE7\u7EED\u3002","chat.scheduleUnavailable":"\u6B64\u804A\u5929\u4E0D\u652F\u6301\u6392\u671F\u3002","chat.start":"\u5F00\u59CB\u65F6\u95F4","chat.end":"\u7ED3\u675F\u65F6\u95F4","chat.view":"\u67E5\u770B\u4FEE\u6539","chat.irreversible":"\u65E0\u6CD5\u64A4\u9500","chat.stepUp":"{count, plural, other {# \u6B21\u9A8C\u8BC1}}","chat.stepUpLabel":"\u9A8C\u8BC1\u7801","chat.plan":"\u8BA1\u5212","chat.favourite":"\u6536\u85CF","chat.run":"\u8FD0\u884C","chat.flows":"\u5DF2\u4FDD\u5B58\u7684\u8BF7\u6C42","flow.favourites":"\u6536\u85CF","flow.most-used":"\u6700\u5E38\u7528","flow.recent":"\u6700\u8FD1","flow.presets":"\u9884\u8BBE","reply.writing":"\u6B63\u5728\u56DE\u590D","reply.stopped":"\u5DF2\u505C\u6B62","chat.sources":"\u6765\u6E90\uFF08{count}\uFF09","chat.source":"\u6765\u6E90 {index}\uFF1A{title}","reply.unavailable":"\u65E0\u6CD5\u56DE\u590D","reply.failed":"\u56DE\u590D\u5931\u8D25","reply.overdue":"\u56DE\u590D\u5DF2\u8D85\u65F6","chat.loading":"\u52A0\u8F7D\u4E2D","chat.before":"\u4FEE\u6539\u524D","chat.after":"\u4FEE\u6539\u540E","chat.undo":"\u64A4\u9500","chat.verify":"\u9700\u8981\u9A8C\u8BC1","chat.startupLoading":"\u6B63\u5728\u52A0\u8F7D\u6B64\u5BF9\u8BDD\u2026"},os=/^(tw|hk|mo)$/,rs=/^(zh|cmn)$/,ss=/^([a-z]{2,3}(-[a-z]{3}){0,3}|[a-z]{4,8})(-[a-z]{4})?(-([a-z]{2}|\d{3}))?(-([a-z\d]{5,8}|\d[a-z\d]{3}))*(-[\da-wyz](-[a-z\d]{2,8})+)*(-x(-[a-z\d]{1,8})+)?$/,as=/^zh-(hakka|min|xiang)\b/;function un(e="en"){let t={catalogue:"en",lang:"en"},n=e.toLowerCase();if(!ss.test(n)||as.test(n))return t;let r=n.split("-"),s=r[0],i=1;for(;/^[a-z]{3}$/.test(r[i]);)s=r[i++];if(rs.test(s)){let d=r[i];return(/^[a-z]{4}$/.test(d)?d==="hans":!os.test(d))?{catalogue:"zh",lang:e}:t}return s==="en"?{catalogue:"en",lang:e}:t}function Ge(e="en"){let t=un(e),n=t.catalogue==="zh",r=n?ns:ts,s=n?bt.zh:bt.en,i=_chunkQS3MKZOYcjs.b.call(void 0, t.lang,n),d=new Map;return(a,u)=>{let p=d.get(a);if(!p){let g=_nullishCoalesce(r[a], () => (s[a]));if(g===void 0)return"";p=new (0, _chunkQS3MKZOYcjs.a)(g,i),d.set(a,p)}return String(p.format(u))}}var fn=new Set,ls=e=>(fn.add(e),()=>fn.delete(e));function Me(e){let t=r=>{n.load=r;for(let s of fn)s()},n={load:{status:"idle"},request(r){let{status:s}=n.load;s!=="idle"&&!(r&&s==="failed")||(t({status:"loading",...s==="failed"&&{retrying:!0}}),e().then(i=>t({status:"ready",module:i}),()=>t({status:"failed"})))}};return n}function xe(e){return _react.useSyncExternalStore.call(void 0, ls,()=>e.load,()=>e.load)}var Ye=Me(()=>Promise.resolve().then(() => _interopRequireWildcard(require("./markdown-CG7NXI7X.cjs")))),wn=_react.createContext.call(void 0, null),er=_react.createContext.call(void 0, void 0),tr=_react.createContext.call(void 0, void 0);function ps({id:e}){let t=_react.useContext.call(void 0, wn);return _react.useEffect.call(void 0, ()=>(_optionalChain([t, 'optionalAccess', _90 => _90.report, 'call', _91 => _91(e,!0)]),()=>_optionalChain([t, 'optionalAccess', _92 => _92.report, 'call', _93 => _93(e,!1)])),[t,e]),null}function ms(){let e=xe(Ye);return e.status==="ready"?e.module:void 0}var qe=e=>`wp${_react.useId.call(void 0, ).replace(/[^\w-]/g,"")}-${e}`,pn=Me(()=>Promise.resolve().then(() => _interopRequireWildcard(require("./recovery-panel-EQIIV7TT.cjs")))),hs=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./confirmation-view-5BZ2PP7J.cjs")))),gn=Me(()=>Promise.resolve().then(() => _interopRequireWildcard(require("./blocks-7453YTYJ.cjs")))),qo=Me(()=>Promise.resolve().then(() => _interopRequireWildcard(require("./reply-controls-LGY2RKRJ.cjs"))));function gs(e){let t=xe(qo);return _react.useEffect.call(void 0, ()=>qo.request(),[]),t.status==="ready"?_jsxruntime.jsx.call(void 0, t.module.ReplyControls,{...e}):null}var Ko=Me(()=>Promise.resolve().then(() => _interopRequireWildcard(require("./message-actions-ORBVYGNE.cjs"))));function bs(e){let t=xe(Ko);return _react.useEffect.call(void 0, ()=>Ko.request(),[]),t.status==="ready"?_jsxruntime.jsx.call(void 0, t.module.MessageActions,{...e}):null}var mn=Me(()=>Promise.resolve().then(() => _interopRequireWildcard(require("./flows-panel-HQYJMOP4.cjs"))));function kn(){let e=xe(gn);return _react.useEffect.call(void 0, ()=>gn.request(),[]),e}function vs({block:e}){let t=kn();return t.status==="ready"?_jsxruntime.jsx.call(void 0, t.module.Answered,{block:e}):null}function ys(e){let{format:t}=$(),n=kn(),r=_jsxruntime.jsx.call(void 0, "p",{children:e.block.fallback});if(n.status==="failed")return r;if(n.status!=="ready")return _jsxruntime.jsx.call(void 0, "p",{children:t("chat.messageLoading")});let s=n.module.default;return _jsxruntime.jsx.call(void 0, Xe,{resetKey:e.block.id,fallback:r,children:_jsxruntime.jsx.call(void 0, s,{...e})})}var le=_react.createContext.call(void 0, null);function ws({children:e,onPress:t,disabled:n,label:r,...s}){return _jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:t,disabled:n,"aria-label":r,...s,children:e})}function ks({value:e,onChange:t,label:n,inputRef:r,onKeyDown:s,disabled:i,describedBy:d}){return _jsxruntime.jsx.call(void 0, "textarea",{ref:r,disabled:i,value:e,onChange:a=>_optionalChain([t, 'optionalCall', _94 => _94(a.target.value)]),"aria-label":n,"aria-describedby":d,onKeyDown:s})}function $o({value:e,onChange:t,label:n,type:r="text",disabled:s,invalid:i,describedBy:d,required:a}){return _jsxruntime.jsxs.call(void 0, "label",{children:[n,_jsxruntime.jsx.call(void 0, "input",{type:r,value:e,disabled:s,"aria-invalid":i,"aria-describedby":d,"aria-required":a||void 0,onChange:u=>t(u.target.value)})]})}function xs({checked:e,onChange:t,label:n,disabled:r,invalid:s,describedBy:i}){return _jsxruntime.jsxs.call(void 0, "label",{className:"wp-check",children:[_jsxruntime.jsx.call(void 0, "input",{type:"checkbox",checked:e,disabled:r,"aria-invalid":s,"aria-describedby":i,onChange:d=>t(d.target.checked)}),n]})}function Cs({children:e,open:t,label:n,onClose:r,closeLabel:s,focusInto:i,restoreFocus:d}){let a=_nullishCoalesce(_optionalChain([_react.useContext.call(void 0, le), 'optionalAccess', _95 => _95.format]), () => (Ge())),u=_react.useRef.call(void 0, null),p=_react.useRef.call(void 0, i),g=_react.useRef.call(void 0, d);p.current=i,g.current=d,_react.useLayoutEffect.call(void 0, ()=>{let m=u.current;if(!(!t||!m))return _optionalChain([p, 'access', _96 => _96.current, 'optionalCall', _97 => _97(m)]),()=>_optionalChain([g, 'access', _98 => _98.current, 'optionalCall', _99 => _99(m)])},[t]);let f=_react.useId.call(void 0, );return t?_jsxruntime.jsxs.call(void 0, "div",{ref:u,className:"wp-drawer",tabIndex:-1,role:"dialog","aria-modal":"true","aria-labelledby":f,onKeyDown:m=>{m.key==="Escape"&&r()},children:[_jsxruntime.jsxs.call(void 0, "div",{className:"wp-drawer-header",children:[_jsxruntime.jsx.call(void 0, "h2",{id:f,children:n}),_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:r,"aria-label":_nullishCoalesce(s, () => (a("chat.close"))),children:_jsxruntime.jsx.call(void 0, "span",{"aria-hidden":"true",children:"\xD7"})})]}),_jsxruntime.jsx.call(void 0, "div",{className:"wp-drawer-body",children:e})]}):null}var nr={button:ws,textarea:ks,input:$o,checkbox:xs,datePicker:e=>_jsxruntime.jsx.call(void 0, $o,{...e,type:"datetime-local"}),drawer:Cs},zo="(prefers-color-scheme: dark)";function Ss(){return _react.useSyncExternalStore.call(void 0, e=>{let t=_optionalChain([globalThis, 'access', _100 => _100.matchMedia, 'optionalCall', _101 => _101(zo)]);return _optionalChain([t, 'optionalAccess', _102 => _102.addEventListener, 'call', _103 => _103("change",e)]),()=>_optionalChain([t, 'optionalAccess', _104 => _104.removeEventListener, 'call', _105 => _105("change",e)])},()=>_optionalChain([globalThis, 'access', _106 => _106.matchMedia, 'optionalCall', _107 => _107(zo), 'access', _108 => _108.matches])?"dark":"light",()=>"light")}function Es(e,t){let n=s=>!!s&&typeof s=="object"&&Object.getPrototypeOf(s)===Object.prototype,r=Object.keys(e);return r.length===Object.keys(t).length&&r.every(s=>{let i=e[s],d=t[s];return Object.is(i,d)||n(i)&&n(d)&&_chunkRZ3AGK3Ucjs.h.call(void 0, i,d)})}function bn(e,t=_chunkRZ3AGK3Ucjs.h){let n=_react.useRef.call(void 0, e),r=n.current;return r!==e&&!(r&&e&&t(r,e))&&(n.current=e),n.current}function Ps(e){let{children:t,...n}=e,r=bn(n,Es),s=bn(_optionalChain([e, 'access', _109 => _109.useThemeTokens, 'optionalCall', _110 => _110()]),(m,b)=>m.scheme===b.scheme&&_chunkRZ3AGK3Ucjs.h.call(void 0, m.tokens,b.tokens)),i=e.theme===void 0&&s&&(e.colorScheme===void 0||e.colorScheme===s.scheme)?"host":"waypoint",d=Ss(),a=_nullishCoalesce(_nullishCoalesce(e.colorScheme, () => (_optionalChain([s, 'optionalAccess', _111 => _111.scheme]))), () => (d)),u=_react.useMemo.call(void 0, ()=>_nullishCoalesce(r.format, () => (Ge(r.locale))),[r.format,r.locale]),p=_react.useMemo.call(void 0, ()=>({...r,colorScheme:a,format:u,lang:r.format?_nullishCoalesce(r.locale, () => ("en")):un(r.locale).lang,tokens:{...a==="dark"?_chunk4BWV3SELcjs.b:_chunk4BWV3SELcjs.a,...i==="host"?s.tokens:r.theme},primitives:{...nr,...r.primitives}}),[r,u,a,i,s]),g=e.wrapper,f=_jsxruntime.jsx.call(void 0, _chunkRZ3AGK3Ucjs.d.Provider,{value:e.client,children:_jsxruntime.jsx.call(void 0, le.Provider,{value:p,children:t})});return g?_jsxruntime.jsx.call(void 0, g,{colorScheme:a,tokens:p.tokens,tokenSource:i,children:f}):f}function Aa(){return _nullishCoalesce(_optionalChain([_react.useContext.call(void 0, le), 'optionalAccess', _112 => _112.colorScheme]), () => ("light"))}function $(){let e=_react.useContext.call(void 0, le);if(!e)throw new Error("WaypointProvider is required");return e}function Da(){return $().client}function Ba(e){let t=_react.useContext.call(void 0, le),n=_nullishCoalesce(e, () => (_optionalChain([t, 'optionalAccess', _113 => _113.client]))),r=_chunkRZ3AGK3Ucjs.e.call(void 0, e);return{conversationId:r.conversationId,conversation:r.conversation,refresh:n.refresh,editMessage:n.editMessage,regenerate:n.regenerate,selectVersion:n.selectVersion,switchConversation:n.switchConversation}}function Ha(e){let t=_react.useContext.call(void 0, le),n=_nullishCoalesce(e, () => (_optionalChain([t, 'optionalAccess', _114 => _114.client]))),r=_chunkRZ3AGK3Ucjs.f.call(void 0, ({draft:s,sending:i,hints:d})=>({draft:s,sending:i,hints:d}),_chunkRZ3AGK3Ucjs.h,e);return{draft:r.draft,sending:r.sending,hints:r.hints,setDraft:n.setDraft,send:n.send,retry:n.retry,withdraw:n.withdraw,dismiss:n.dismiss}}function Ua(e){let t=_react.useContext.call(void 0, le),n=_nullishCoalesce(e, () => (_optionalChain([t, 'optionalAccess', _115 => _115.client]))),r=_chunkRZ3AGK3Ucjs.f.call(void 0, i=>i.plan,Object.is,e),{view:s}=_chunkRZ3AGK3Ucjs.i.call(void 0, e);return{plan:r,setPlan:n.setPlan,reply:n.reply,view:s}}function Wa(e){let t=_react.useContext.call(void 0, le),n=_nullishCoalesce(e, () => (_optionalChain([t, 'optionalAccess', _116 => _116.client]))),r=_chunkRZ3AGK3Ucjs.f.call(void 0, ({flows:s,flowTab:i})=>({flows:s,flowTab:i}),_chunkRZ3AGK3Ucjs.h,e);return{flows:r.flows,tab:r.flowTab,load:n.loadFlows,select:n.selectFlowTab,setFavourite:n.setFavourite,run:n.runFlow}}var qa=["bubble","composer","transcript","replyRow","stepRow","planNode","widgetFrame","confirmBar","confirmation","topBar","rail","flowTabs","quotaStrip","failedSendControls","emptyState","messageActions","extraPanels","actionBar","stepUpPrompt","fieldAdornment","recoveryPanel","stepStatusRow","recoveryActions"];function or({action:e,onPress:t,label:n}){let{format:r,primitives:s}=$(),i=s.button,d=_react.useId.call(void 0, );return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, i,{"data-action":e.id,"aria-disabled":e.available?void 0:!0,"aria-describedby":e.reasonKey?d:void 0,"aria-busy":e.busy?!0:void 0,onPress:e.available?()=>t(e.id):void 0,children:_nullishCoalesce(n, () => ((e.countedLabelKey&&e.labelValues?r(e.countedLabelKey,e.labelValues):r(e.labelKey))))}),e.reasonKey?_jsxruntime.jsx.call(void 0, "span",{id:d,"data-reason":e.id,children:r(e.reasonKey,e.reasonValues)}):null]})}function jo(e){let t=_react.useRef.call(void 0, !1),[n,r]=_react.useState.call(void 0, !1),s=()=>{t.current=!1,r(!1)};return{busy:n,press:()=>{t.current||(t.current=!0,r(!0),e().then(s,s))}}}function Vo({problem:e,refresh:t}){let n=_chunkRZ3AGK3Ucjs.l.call(void 0, e),r=_react.useMemo.call(void 0, ()=>Date.now()+(_nullishCoalesce(e.retryAfter, () => (0)))*1e3,[e]),[s,i]=_react.useState.call(void 0, 0),d=e.code==="rate-limited"&&Date.now()<r;return _react.useEffect.call(void 0, ()=>{if(!d)return;let a=setTimeout(()=>i(u=>u+1),Math.max(r-Date.now(),1));return()=>clearTimeout(a)},[d,r,s]),n?_jsxruntime.jsx.call(void 0, or,{action:{id:"status",labelKey:n==="retry"?"chat.retry":"chat.problem.refresh",available:!d&&!t.busy,busy:t.busy,...d&&{reasonKey:"chat.problem.rateLimited"}},onPress:t.press}):null}function _o({problem:e}){let{format:t}=$();return t("chat.problem.details")?_jsxruntime.jsxs.call(void 0, "details",{"data-problem-details":"",children:[_jsxruntime.jsx.call(void 0, "summary",{children:t("chat.problem.details")}),_jsxruntime.jsx.call(void 0, "p",{children:t("chat.problem.code",{code:e.code})}),_jsxruntime.jsx.call(void 0, "p",{children:t("chat.problem.reference",{id:e.id})})]}):null}var vt=e=>e.status==="loading"&&!!e.retrying;function vn(e){let{format:t,primitives:n}=$(),r=e.retrying||void 0;return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "p",{role:"alert",onFocus:e.onFocus,children:[t("chat.failure")," ",_jsxruntime.jsx.call(void 0, n.button,{"aria-disabled":r,"aria-busy":r,onPress:()=>{r||e.onRetry()},children:t("chat.retry")})]}),_jsxruntime.jsx.call(void 0, "span",{role:"status",children:r?t("chat.loading"):""})]})}function Ts(e){let{format:t}=$(),n=xe(pn);_react.useEffect.call(void 0, ()=>pn.request(),[]);let r=_react.useRef.call(void 0, null),s=_t(()=>[_optionalChain([r, 'access', _117 => _117.current, 'optionalAccess', _118 => _118.querySelector, 'call', _119 => _119("h3")])]),i=n.status==="ready"&&n.module.default;return _jsxruntime.jsx.call(void 0, "div",{ref:r,tabIndex:-1,"data-recovery":"",children:i?_jsxruntime.jsx.call(void 0, i,{...e}):n.status==="failed"||vt(n)?_jsxruntime.jsx.call(void 0, vn,{retrying:vt(n),onRetry:()=>pn.request(!0),onFocus:s}):_jsxruntime.jsx.call(void 0, "p",{children:t("chat.loading")})})}function Go(e){return{id:e.id,type:e.type,answered:!!e.answered}}function Yo(e){return{id:e.id,content:e.content,failure:e.failure?{code:e.failure.code}:null}}function K({name:e,slots:t,children:n,...r}){let i=_optionalChain([_react.useContext.call(void 0, le), 'optionalAccess', _120 => _120.parts, 'optionalAccess', _121 => _121[e]]),d=_optionalChain([t, 'optionalAccess', _122 => _122[e]]),a=d?d({...r,children:n}):i?_jsxruntime.jsx.call(void 0, i,{...r,children:n}):n;return _jsxruntime.jsx.call(void 0, "div",{"data-part":e,children:a})}var Xe= (_class3 =class extends _react.Component{constructor(...args) { super(...args); _class3.prototype.__init11.call(this); }__init11() {this.state={}}static getDerivedStateFromError(){return{failedKey:""}}componentDidCatch(){this.setState({failedKey:this.props.resetKey})}render(){let{failedKey:t}=this.state;return t===""||t===this.props.resetKey?this.props.fallback:this.props.children}}, _class3);function Ms({text:e,writing:t,sources:n}){let r=$(),s=r.format,i=_react.useContext.call(void 0, wn),d=_react.useId.call(void 0, ),a=_nullishCoalesce(_react.useContext.call(void 0, er), () => (d)),u=_react.useContext.call(void 0, tr),p=i?_jsxruntime.jsx.call(void 0, ps,{id:a}):_jsxruntime.jsx.call(void 0, "p",{children:s("chat.messageUnavailable")}),g=xe(Ye);if(_react.useEffect.call(void 0, ()=>{Ye.request(!0)},[e]),g.status==="failed")return p;if(g.status!=="ready")return _jsxruntime.jsx.call(void 0, "p",{children:s("chat.messageLoading")});let f=g.module.default;return _jsxruntime.jsx.call(void 0, Xe,{resetKey:`${e}:${_nullishCoalesce(_optionalChain([i, 'optionalAccess', _123 => _123.retry]), () => (0))}`,fallback:p,children:_jsxruntime.jsx.call(void 0, f,{text:e,writing:t,lang:r.lang,sources:n,sourceNames:{list:m=>s("chat.sources",{count:m}),item:(m,b)=>s("chat.source",{index:m,title:b})},images:r.markdownImages,extraSchemes:r.extraUrlSchemes,scrollLabel:s("chat.scrollRegion"),cached:u})})}function rr(e){let t=_optionalChain([$, 'call', _124 => _124(), 'access', _125 => _125.renderers, 'optionalAccess', _126 => _126.markdown]);return t?_jsxruntime.jsx.call(void 0, t,{text:e.text}):_jsxruntime.jsx.call(void 0, Ms,{...e})}function Rs(e,t){return{text:t(_chunkRZ3AGK3Ucjs.m.call(void 0, e).key)||t("chat.failure")}}function Fs({block:e,onReply:t,disabled:n}){let{format:r,primitives:s,extraUrlSchemes:i}=$(),d=s.button,a=e.body;switch(e.type){case"form.fill":case"table":case"diff":case"form":case"choice":case"plan":return _jsxruntime.jsx.call(void 0, ys,{block:e,onReply:t,disabled:n});case"markdown":return _jsxruntime.jsx.call(void 0, rr,{text:String(_nullishCoalesce(a.text, () => ("")))});case"notice":return _jsxruntime.jsx.call(void 0, "p",{children:String(_nullishCoalesce(a.text, () => ("")))});case"card":return _jsxruntime.jsxs.call(void 0, "section",{children:[_jsxruntime.jsx.call(void 0, "h3",{children:String(_nullishCoalesce(a.title, () => ("")))}),(_nullishCoalesce(a.blocks, () => ([]))).map(u=>_jsxruntime.jsx.call(void 0, yn,{block:u,disabled:n,onReply:t},u.id))]});case"details":return _jsxruntime.jsxs.call(void 0, "details",{children:[_jsxruntime.jsx.call(void 0, "summary",{children:String(_nullishCoalesce(a.summary, () => ("")))}),(_nullishCoalesce(a.blocks, () => ([]))).map(u=>_jsxruntime.jsx.call(void 0, yn,{block:u,disabled:n,onReply:t},u.id))]});case"list":return _jsxruntime.jsx.call(void 0, "ul",{children:(_nullishCoalesce(a.items, () => ([]))).map((u,p)=>_jsxruntime.jsx.call(void 0, "li",{children:u},p))});case"route-link":{let u=String(_nullishCoalesce(a.route, () => ("")));return _chunkFBADWFRRcjs.a.call(void 0, u,i)?_jsxruntime.jsx.call(void 0, "a",{href:u,children:String(_nullishCoalesce(a.label, () => (r("chat.view"))))}):_jsxruntime.jsx.call(void 0, "span",{children:e.fallback})}case"buttons":return _jsxruntime.jsx.call(void 0, "div",{children:(_nullishCoalesce(a.actions, () => ([]))).map(u=>_jsxruntime.jsx.call(void 0, d,{disabled:n,onPress:()=>t({kind:"action",blockId:e.id,actionId:u.id}),children:u.label},u.id))});default:return _jsxruntime.jsx.call(void 0, "p",{children:e.fallback})}}var Ls=["markdown","form.fill","card","details","list","table","form","choice","buttons","diff","plan","route-link","notice"].map(e=>({type:e,render:Fs}));function yn(e){let{widgets:t,format:n}=$(),r=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _127 => _127.find, 'call', _128 => _128(i=>i.type===e.block.type)]), () => (Ls.find(i=>i.type===e.block.type)));if(!r)return _jsxruntime.jsx.call(void 0, "div",{"data-fallback":"true",children:_jsxruntime.jsx.call(void 0, "p",{children:_optionalChain([e, 'access', _129 => _129.block, 'access', _130 => _130.fallback, 'optionalAccess', _131 => _131.trim, 'call', _132 => _132()])?e.block.fallback:n("unsupportedContent")})});let s=r.render;return _jsxruntime.jsx.call(void 0, s,{...e})}function Is(e){let{format:t,primitives:n}=$(),r=kn(),s=n.button,i=_react.useRef.call(void 0, null),[d,a]=_react.useState.call(void 0, 0),u=_react.useRef.call(void 0, null);_react.useLayoutEffect.call(void 0, ()=>{let f=i.current;te(f,{root:f,owner:"",removed:u.current})});let p=_jsxruntime.jsxs.call(void 0, "p",{role:"alert",children:[t("chat.planUnavailable"),_jsxruntime.jsx.call(void 0, s,{onPress:()=>{u.current=document.activeElement,a(d+1),gn.request(!0)},children:t("chat.retry")})]}),g=r.status==="ready"&&r.module.PlanSteps;return _jsxruntime.jsx.call(void 0, "div",{ref:i,tabIndex:-1,children:g?_jsxruntime.jsx.call(void 0, Xe,{resetKey:`${e.record.id}:${d}`,fallback:p,children:_jsxruntime.jsx.call(void 0, g,{...e})}):r.status==="failed"?p:_jsxruntime.jsx.call(void 0, "p",{children:t("chat.messageLoading")})})}function Ka(e){let t=_react.useContext.call(void 0, le);return e.client?_jsxruntime.jsx.call(void 0, Ps,{...e,client:e.client,children:_jsxruntime.jsx.call(void 0, Jo,{...e})}):t?_jsxruntime.jsx.call(void 0, Jo,{...e}):_jsxruntime.jsx.call(void 0, "section",{className:"waypoint",dir:_nullishCoalesce(e.dir, () => ("ltr")),children:_jsxruntime.jsx.call(void 0, "p",{children:Ge(e.locale)("chat.empty")})})}var Ns='input, textarea, select, [contenteditable]:not([contenteditable="false"]), [role="textbox"], [role="combobox"], [role="listbox"], [role="grid"], [role="slider"], [role="spinbutton"]',Xo="\uE000",Os=150,As=()=>()=>{},Qo=()=>0;function Ds({messages:e,excerpts:t,anchor:n,open:r,onToggle:s,onNavigate:i,query:d,onQuery:a,search:u,sourceOf:p,lang:g}){let{format:f,primitives:m}=$(),b=m.button,A=m.input,c=qe("outline"),C=qe("outline-status"),[E,L]=_react.useState.call(void 0, d);_react.useEffect.call(void 0, ()=>{let S=setTimeout(()=>L(d),Os);return()=>clearTimeout(S)},[d]);let R=r&&d.trim()&&E.trim()?on(E,g):"";_react.useSyncExternalStore.call(void 0, R?u.subscribe:As,R?u.snapshot:Qo,Qo);let y=r?e.flatMap((S,N)=>!R||_optionalChain([u, 'access', _133 => _133.textOf, 'call', _134 => _134(S.id,p(S)), 'optionalAccess', _135 => _135.includes, 'call', _136 => _136(R)])?[{message:S,index:N}]:[]):[],P=!!R&&!u.complete();return _jsxruntime.jsxs.call(void 0, "nav",{"aria-label":f("chat.outline"),"data-outline":"",className:"wp-outline",children:[_jsxruntime.jsx.call(void 0, b,{"aria-expanded":r,"aria-controls":c,onPress:s,children:f("chat.outline")}),r?_jsxruntime.jsxs.call(void 0, "div",{"data-outline-filter":"",children:[_jsxruntime.jsx.call(void 0, A,{type:"search",label:f("chat.outlineFilter"),value:d,onChange:a,describedBy:C}),_jsxruntime.jsx.call(void 0, "p",{id:C,role:"status",children:R?P?f("chat.outlineSearching"):f("chat.outlineMatches",{count:y.length}):null})]}):null,_jsxruntime.jsx.call(void 0, "ol",{id:c,hidden:!r,role:"list",children:r?y.map(({message:S,index:N})=>{let v={role:f(S.role==="user"?"chat.roleUser":"chat.roleAssistant"),position:N+1},w=t[N],k=w===void 0?void 0:f("chat.outlineItem",{...v,excerpt:Xo}).split(Xo);return _jsxruntime.jsx.call(void 0, "li",{children:_jsxruntime.jsx.call(void 0, "a",{href:`#${n(S.id)}`,"data-outline-link":S.id,onClick:x=>{x.preventDefault(),i(S.id)},children:k?k.length===2?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[k[0],_jsxruntime.jsx.call(void 0, "bdi",{children:w}),k[1]]}):_jsxruntime.jsx.call(void 0, "bdi",{children:f("chat.outlineItem",{...v,excerpt:w})}):f("chat.outlineItemPlain",v)})},S.id)}):null})]})}function Bs({label:e,closeLabel:t,onClose:n,skipRestore:r,onFocusWithin:s,children:i}){let d=$().primitives.drawer,a=tn("rail"),u=_react.useRef.call(void 0, void 0),p=_react.useRef.call(void 0, s);return p.current=s,_jsxruntime.jsx.call(void 0, en,{as:d,open:!0,label:e,closeLabel:t,onClose:n,focusInto:g=>{let f=m=>p.current(Pe(m));g.addEventListener("focusin",f),u.current={element:g,listener:f},_optionalChain([a, 'access', _137 => _137.focusInto, 'optionalCall', _138 => _138(g)])},restoreFocus:g=>{let f=u.current;u.current=void 0,_optionalChain([f, 'optionalAccess', _139 => _139.element, 'access', _140 => _140.removeEventListener, 'call', _141 => _141("focusin",f.listener)]),r()?_optionalChain([a, 'access', _142 => _142.release, 'optionalCall', _143 => _143()]):_optionalChain([a, 'access', _144 => _144.restoreFocus, 'optionalCall', _145 => _145(g)])},children:i})}var sr=e=>_optionalChain([e, 'access', _146 => _146.sources, 'optionalAccess', _147 => _147.length])?`${e.content}\0${JSON.stringify(e.sources)}`:e.content;function ar({slots:e,message:t}){let{client:n}=$();return _jsxruntime.jsx.call(void 0, K,{name:"messageActions",slots:e,data:{message:{id:t.id,role:t.role,status:t.status,versionIndex:t.versionIndex,versionCount:t.versionCount}},children:_jsxruntime.jsx.call(void 0, bs,{client:n,message:t})})}var Hs=_react.memo.call(void 0, function({message:t,slots:n,anchorId:r,writing:s,bodyUnavailable:i,disabled:d,answered:a,actions:u,rows:p,posInSet:g,setSize:f}){let m=$().format,b=_react.useMemo.call(void 0, ()=>{let c=sr(t);return C=>p.parses.get(t.id,c,C)},[p,t]),A=m(t.role==="user"?"chat.roleUser":"chat.roleAssistant");return _jsxruntime.jsxs.call(void 0, "article",{id:r,tabIndex:-1,"data-message-id":t.id,"data-role":t.role,"aria-busy":s?!0:void 0,"aria-posinset":g,"aria-setsize":f,"aria-label":A,"data-body-unavailable":i?"":void 0,children:[_jsxruntime.jsxs.call(void 0, K,{name:"bubble",slots:n,data:{message:{id:t.id,role:t.role,content:t.content,status:t.status,versionIndex:t.versionIndex,versionCount:t.versionCount,blocks:t.blocks.map(Go)}},children:[_jsxruntime.jsx.call(void 0, "span",{"data-sender":"","aria-hidden":"true",children:A}),_jsxruntime.jsx.call(void 0, er.Provider,{value:t.id,children:_jsxruntime.jsx.call(void 0, tr.Provider,{value:b,children:_jsxruntime.jsx.call(void 0, rr,{text:t.content,writing:s,sources:t.sources})})}),s?_jsxruntime.jsx.call(void 0, "span",{"data-writing":"","aria-hidden":"true",children:m("reply.writing")}):t.status==="stopped"?_jsxruntime.jsx.call(void 0, "span",{"data-stopped":"",children:m("reply.stopped")}):t.status==="failed"||t.status==="unavailable"?_jsxruntime.jsx.call(void 0, "span",{"data-reply-ended":t.status,children:m(`reply.${t.status}`)}):null,t.blocks.map((c,C)=>{let E=a[C]==="1";return _jsxruntime.jsx.call(void 0, K,{name:"widgetFrame",slots:n,data:{block:Go(c)},children:_jsxruntime.jsxs.call(void 0, "div",{"data-open-card":c.type==="card"&&!E?"true":void 0,children:[_jsxruntime.jsx.call(void 0, yn,{block:c,disabled:d||E,onReply:p.respond(c,t.id)}),c.answered?_jsxruntime.jsx.call(void 0, vs,{block:c}):null]})},c.id)})]}),u?_jsxruntime.jsx.call(void 0, ar,{slots:n,message:t}):null]})});function Jo({slots:e,features:t,layout:n="panel",shortcuts:r,conversations:s=[],conversationSource:i,quota:d,onStop:a,suggestions:u=[]}){let p=bn(e),g=_react.useId.call(void 0, ),f=$(),{client:m,format:b,tokens:A}=f,c=_chunkRZ3AGK3Ucjs.e.call(void 0, ),C=_react.useRef.call(void 0, null),E=_react.useRef.call(void 0, null),L=_react.useRef.call(void 0, null),R=_react.useRef.call(void 0, null),y=_react.useRef.call(void 0, new Set).current,[,P]=_react.useState.call(void 0, 0),[S,N]=_react.useState.call(void 0, 0),v=_react.useMemo.call(void 0, ()=>({retry:S,report(o,h){y.has(o)!==h&&(h?y.add(o):y.delete(o),P(T=>T+1))}}),[S,y]),{isAnswered:w,reply:k}=_chunkRZ3AGK3Ucjs.k.call(void 0, m),x=_react.useRef.call(void 0, null),_=_react.useRef.call(void 0, null),Z=_react.useRef.call(void 0, new Set),[W,pe]=_react.useState.call(void 0, 0),[Se,Fe]=_react.useState.call(void 0, !1),[Cn,Sn]=_react.useState.call(void 0, ),wt=jo(()=>m.refresh()),En=jo(()=>m.refresh()),kt=_chunkRZ3AGK3Ucjs.i.call(void 0, m),ee=f.primitives.button,ir=f.primitives.textarea,Pn=!!(_optionalChain([p, 'optionalAccess', _148 => _148.extraPanels])||_optionalChain([f, 'access', _149 => _149.parts, 'optionalAccess', _150 => _150.extraPanels])),Tn=qe("hint"),Ze=qe("pending"),et=o=>(_optionalChain([c, 'access', _151 => _151.conversation, 'optionalAccess', _152 => _152.mode])!=="form-fill"||o==="form-fill"||o==="widgets")&&c.capabilities.includes(o)&&(!t||t.includes(o)),[lr,xt]=_react.useState.call(void 0, "loading"),Mn=()=>{xt(o=>o==="failed"?"retrying":"loading"),m.loadFlows().then(()=>xt("done"),()=>xt("failed"))};_react.useEffect.call(void 0, Mn,[m]),_react.useEffect.call(void 0, ()=>{let o=()=>Ye.request();if(typeof requestIdleCallback=="function"){let T=requestIdleCallback(o,{timeout:1e3});return()=>cancelIdleCallback(T)}let h=setTimeout(o,0);return()=>clearTimeout(h)},[]);let[,cr]=_react.useState.call(void 0, !1);_react.useEffect.call(void 0, ()=>{Promise.resolve().then(() => _interopRequireWildcard(require("./problem-messages-THONMXFZ.cjs"))).then(o=>{Wo(o.problemEnglish,o.problemSimplifiedChinese),cr(!0)})},[]);let I=Eo(C,ue(m,c.conversationId),E,L,o=>ue(m,o)),D=_nullishCoalesce(_optionalChain([c, 'access', _153 => _153.conversation, 'optionalAccess', _154 => _154.messages]), () => ([])),oe=_optionalChain([c, 'access', _155 => _155.conversation, 'optionalAccess', _156 => _156.id]),[Ke,Ct]=_react.useState.call(void 0, {open:!1,query:""});Ke.conversationId!==oe&&Ct({conversationId:oe,open:!1,query:""});let Le=Ke.conversationId===oe&&Ke.open,Rn=`wp${g.replace(/[^\w-]/g,"")}`,St=o=>`${Rn}-${o.replace(/[^A-Za-z0-9-]/gu,h=>`_${h.codePointAt(0)}_`)}`,me=Io(L,R,oe,D.length,c),he=_react.useMemo.call(void 0, ()=>D.map(o=>o.id),[D]),Ie=Oo(L,R,he,me.pinned,me.anchorId()),Fn=()=>{let o=decodeURIComponent(location.hash.slice(1)),h=o.startsWith(`${Rn}-`)?he.find(T=>St(T)===o):void 0;h&&Ie.reveal(h,()=>me.toMessage(h))},Ln=_react.useRef.call(void 0, Fn);Ln.current=Fn;let In=Ie.windowed;_react.useEffect.call(void 0, ()=>{if(!In||typeof location>"u")return;let o=()=>Ln.current();return o(),addEventListener("hashchange",o),()=>removeEventListener("hashchange",o)},[In]);let dr=o=>{let h=o.target,T=h.closest("article[data-message-id], article[data-pending-id]");if(!T||h.closest(Ns))return;let O=o.currentTarget,B=I.value.originFor("feed"),H=I.value.owner();if(o.ctrlKey&&(o.key==="Home"||o.key==="End")){let Be=o.key==="Home",rt=[...(_nullishCoalesce(O.closest(".waypoint"), () => (O.ownerDocument.body))).querySelectorAll(zt)].filter(st=>!O.contains(st)&&ie(st)&&st.tabIndex>=0&&!!(O.compareDocumentPosition(st)&(Be?Node.DOCUMENT_POSITION_PRECEDING:Node.DOCUMENT_POSITION_FOLLOWING))),no=Be?rt.at(-1):rt[0];if(!no)return;o.preventDefault(),Y(I.value,no,{origin:B,owner:H});return}if(o.key!=="PageDown"&&o.key!=="PageUp"||o.ctrlKey||o.altKey||o.metaKey||o.shiftKey)return;let U=c.pending.map(Be=>Be.id),G=T.getAttribute("data-message-id"),ae=G!==null?he.indexOf(G):he.length+U.indexOf(T.getAttribute("data-pending-id")),z=ae+(o.key==="PageDown"?1:-1);if(ae<0||z<0||z>=he.length+U.length)return;if(o.preventDefault(),z>=he.length){let Be=U[z-he.length],At=[...O.querySelectorAll("article[data-pending-id]")].find(rt=>rt.getAttribute("data-pending-id")===Be);At&&Y(I.value,At,{origin:B,owner:H});return}let we=he[z];Ie.reveal(we,()=>Y(I.value,me.toMessage(we),{origin:B,owner:H}))},Et=_react.useRef.call(void 0, void 0),ur=o=>{let h=o.target,T=D.map(G=>G.id),O={owner:I.value.owner(),shown:oe,order:T},B=h.closest("[data-outline-link]"),H=h.closest("[data-back-to-latest]"),U=h.closest("article[data-message-id]");Et.current=B?{...O,kind:"link",id:B.getAttribute("data-outline-link"),element:B}:H?{...O,kind:"latest",element:H}:U&&q(L.current,U)?{...O,kind:"message",id:U.getAttribute("data-message-id"),element:U}:void 0};_react.useLayoutEffect.call(void 0, ()=>{let o=Et.current;if(!o||o.element.isConnected)return;Et.current=void 0;let h=L.current,T=_optionalChain([h, 'optionalAccess', _157 => _157.parentElement]),O=(H,U)=>{let G=new Map;for(let z of _nullishCoalesce(_optionalChain([U, 'optionalAccess', _158 => _158.querySelectorAll, 'call', _159 => _159(`[${H}]`)]), () => ([])))G.set(z.getAttribute(H),z);let ae=o.order.indexOf(o.id);for(let z=ae+1;z<o.order.length;z++){let we=G.get(o.order[z]);if(we)return we}for(let z=ae-1;z>=0;z--){let we=G.get(o.order[z]);if(we)return we}},B=o.kind==="message"?_nullishCoalesce(O("data-message-id",h), () => (h)):o.kind==="link"?_nullishCoalesce(_nullishCoalesce(O("data-outline-link",T), () => (_optionalChain([T, 'optionalAccess', _160 => _160.querySelector, 'call', _161 => _161("nav[data-outline] [aria-expanded]")]))), () => (h)):h;Y(I.value,B,{owner:o.owner,stillCurrent:()=>I.value.owner()===o.owner&&_optionalChain([m, 'access', _162 => _162.getSnapshot, 'call', _163 => _163(), 'access', _164 => _164.conversation, 'optionalAccess', _165 => _165.id])===o.shown,removed:o.element,fallback:h})});let Nn=s.length>0||!!i,[re,fr]=_react.useState.call(void 0, !1),[Ne,$e]=_react.useState.call(void 0, !1),On=qe("rail"),pr=Qt(Ne,I.value.owner(),()=>$e(!1)),Pt=_react.useRef.call(void 0, void 0),Tt=_react.useRef.call(void 0, !1),tt=_react.useRef.call(void 0, !1),mr=()=>{let o=Tt.current||tt.current;return Tt.current=!1,o};_react.useLayoutEffect.call(void 0, ()=>{let o=C.current;if(!o||typeof ResizeObserver!="function")return;let h=()=>{let O=o.getBoundingClientRect().width,B=parseFloat(getComputedStyle(o).fontSize)||16;fr(O>0&&O<40*B)},T=new ResizeObserver(h);return T.observe(o),h(),()=>T.disconnect()},[]);let An=_react.useRef.call(void 0, re);_react.useLayoutEffect.call(void 0, ()=>{An.current&&!re&&Ne&&(tt.current=!0,$e(!1)),An.current=re},[re,Ne]),_react.useLayoutEffect.call(void 0, ()=>{if(!tt.current||Ne)return;tt.current=!1;let o=Pt.current;if(Pt.current=void 0,!o||o.element.isConnected)return;let h=_optionalChain([C, 'access', _166 => _166.current, 'optionalAccess', _167 => _167.querySelector, 'call', _168 => _168('[data-part="rail"] nav')]),T=o.id?_optionalChain([[..._nullishCoalesce(_optionalChain([h, 'optionalAccess', _169 => _169.querySelectorAll, 'call', _170 => _170("[data-conversation-id]")]), () => ([]))], 'access', _171 => _171.find, 'call', _172 => _172(O=>O.getAttribute("data-conversation-id")===o.id), 'optionalAccess', _173 => _173.querySelector, 'call', _174 => _174("button")]):void 0;Y(I.value,_nullishCoalesce(_nullishCoalesce(T, () => (h)), () => (L.current)),{owner:o.owner,stillCurrent:()=>I.value.owner()===o.owner,removed:o.element,fallback:L.current})});let nt=_react.useRef.call(void 0, void 0),Dn=I.value.owner();me.pinned||!D.length?nt.current=void 0:_optionalChain([nt, 'access', _175 => _175.current, 'optionalAccess', _176 => _176.owner])!==Dn&&(nt.current={owner:Dn,ids:new Set(D.map(o=>o.id))});let Bn=nt.current,Hn=Bn?D.filter(o=>o.role==="assistant"&&!Bn.ids.has(o.id)).length:0,ge=ms(),be=!!(_optionalChain([f, 'access', _177 => _177.renderers, 'optionalAccess', _178 => _178.markdown])||_optionalChain([f, 'access', _179 => _179.parts, 'optionalAccess', _180 => _180.bubble])||_optionalChain([f, 'access', _181 => _181.parts, 'optionalAccess', _182 => _182.transcript])||_optionalChain([p, 'optionalAccess', _183 => _183.bubble])||_optionalChain([p, 'optionalAccess', _184 => _184.transcript])),Mt=_react.useRef.call(void 0, new dt).current;Mt.begin(ue(m,_nullishCoalesce(oe, () => (""))),[be,f.messageExcerpt,ge,_optionalChain([f, 'access', _185 => _185.markdownImages, 'optionalAccess', _186 => _186.origin]),_optionalChain([f, 'access', _187 => _187.markdownImages, 'optionalAccess', _188 => _188.allow]),_optionalChain([f, 'access', _189 => _189.extraUrlSchemes, 'optionalAccess', _190 => _190.join, 'call', _191 => _191(" ")])],D.map(o=>({id:o.id,source:be?o:o.content})));let Un=_react.useRef.call(void 0, new ke).current;Un.begin(ue(m,_nullishCoalesce(oe, () => (""))),[ge,_optionalChain([f, 'access', _192 => _192.markdownImages, 'optionalAccess', _193 => _193.origin]),_optionalChain([f, 'access', _194 => _194.markdownImages, 'optionalAccess', _195 => _195.allow]),_optionalChain([f, 'access', _196 => _196.extraUrlSchemes, 'optionalAccess', _197 => _197.join, 'call', _198 => _198(" ")])],D.map(o=>({id:o.id,source:o.content})));let Wn=(o,h)=>Un.get(o.id,o.content,T=>h.visibleText(T,{images:f.markdownImages,extraSchemes:f.extraUrlSchemes})),qn=o=>{if(be)return Mt.get(o.id,o,h=>{let T=_optionalChain([f, 'access', _199 => _199.messageExcerpt, 'optionalCall', _200 => _200(h)]);return T===void 0?void 0:nn(T)});if(ge)return Mt.get(o.id,o.content,()=>nn(Wn(o,ge)))},Rt=_react.useRef.call(void 0, new ke).current,hr=_react.useMemo.call(void 0, ()=>D.map(o=>({id:o.id,source:sr(o)})),[D]);Rt.begin(ue(m,_nullishCoalesce(oe, () => (""))),[ge,_optionalChain([f, 'access', _201 => _201.extraUrlSchemes, 'optionalAccess', _202 => _202.join, 'call', _203 => _203(" ")]),S],hr);let gr=Le?D.map(qn):[],ze=_react.useRef.call(void 0, new ut).current,br=o=>be?o:o.content,vr=_react.useMemo.call(void 0, ()=>D.map(o=>({id:o.id,source:be?o:o.content,message:o})),[D,be]);ze.sync(ue(m,_nullishCoalesce(oe, () => (""))),[be,!!f.messageExcerpt,ge,_optionalChain([f, 'access', _204 => _204.markdownImages, 'optionalAccess', _205 => _205.origin]),_optionalChain([f, 'access', _206 => _206.markdownImages, 'optionalAccess', _207 => _207.allow]),_optionalChain([f, 'access', _208 => _208.extraUrlSchemes, 'optionalAccess', _209 => _209.join, 'call', _210 => _210(" ")]),f.lang],vr,o=>on(be?_nullishCoalesce(_optionalChain([f, 'access', _211 => _211.messageExcerpt, 'optionalCall', _212 => _212(o)]), () => ("")):ge?Wn(o,ge):o.content,f.lang)),_react.useEffect.call(void 0, ()=>{Le&&ze.start()}),_react.useEffect.call(void 0, ()=>Le?()=>ze.stop():void 0,[Le,ze]);let Kn=_react.useRef.call(void 0, null),yr=Ho(m,c.conversation,qn,b,Kn),Ee=qe("flows"),$n=_react.useRef.call(void 0, ""),zn=_t(()=>{let o=_optionalChain([C, 'access', _213 => _213.current, 'optionalAccess', _214 => _214.querySelector, 'call', _215 => _215(`[id="${Ee}-panel"]`)]);return[_optionalChain([o, 'optionalAccess', _216 => _216.querySelector, 'call', _217 => _217(`[data-flow="${$n.current}"] button`)]),o]}),je=xe(mn),jn=et("flows");_react.useEffect.call(void 0, ()=>{jn&&mn.request()},[jn]);let[Ve,Vn]=_react.useState.call(void 0, void 0),_n=(o,h={})=>{let T=m,O=I.value.owner(),B=ue(T,`flow:${o}`),H=I.value.originFor("run-flow",B);Vn(void 0),T.runFlow(o,h).then(U=>{let G=U&&ue(T,U);Y(I.value,E.current,{origin:H,owner:B,stillCurrent:()=>!!G&&I.value.owner()===G&&_optionalChain([T, 'access', _218 => _218.getSnapshot, 'call', _219 => _219(), 'access', _220 => _220.conversation, 'optionalAccess', _221 => _221.id])===U})},()=>{de(H),Vn({id:o,owner:O,values:h})})},Oe=c.replyState,Ae=D.at(-1),Gn=Oe==="writing"&&_optionalChain([Ae, 'optionalAccess', _222 => _222.status])==="writing"?Ae.id:void 0,wr=_optionalChain([Ae, 'optionalAccess', _223 => _223.role])==="assistant"&&(Ae.status==="failed"||Ae.status==="unavailable")&&Oe===Ae.status,Yn=_react.useRef.call(void 0, null),Ft=Uo(Oe,Yn),Xn=(o,h)=>T=>{let O=J(document),B=_chunkRZ3AGK3Ucjs.j.call(void 0, c.conversationId,h,o.id,T),H=!Z.current.has(B);Z.current.add(B),k(o,T,h).then(U=>{H&&Z.current.delete(B);let G=m.getSnapshot();_optionalChain([U, 'optionalAccess', _224 => _224.accepted])===!1&&_optionalChain([U, 'access', _225 => _225.problem, 'optionalAccess', _226 => _226.code])==="refused"&&_optionalChain([G, 'access', _227 => _227.conversation, 'optionalAccess', _228 => _228.messages, 'access', _229 => _229.find, 'call', _230 => _230(ae=>ae.id===h), 'optionalAccess', _231 => _231.blocks, 'access', _232 => _232.find, 'call', _233 => _233(ae=>ae.id===o.id), 'optionalAccess', _234 => _234.answered])&&(_.current=G.problem),x.current=O,pe(ae=>ae+1)})};_react.useLayoutEffect.call(void 0, ()=>{let o=x.current,h=I.value.root();x.current=null,o&&h&&te(ie(o)?o:I.value.composer(),{root:h,owner:"",removed:o})},[W]);let Qn=!!c.problem&&c.problem===_.current,ve=c.problem&&!Z.current.has(c.problem.id)?_nullishCoalesce(_optionalChain([f, 'access', _235 => _235.problemText, 'optionalCall', _236 => _236(c.problem,{answeredElsewhere:Qn})]), () => ((Qn?{text:b("chat.problem.answered")||b("chat.failure")}:Rs(c.problem,b)))):null,se=c.plan,Q=kt.view,ot=ve&&_optionalChain([c, 'access', _237 => _237.problem, 'optionalAccess', _238 => _238.id])!=="conversation-unavailable"&&!(_optionalChain([c, 'access', _239 => _239.problem, 'optionalAccess', _240 => _240.code])==="stopped"&&_optionalChain([Q, 'optionalAccess', _241 => _241.status]))&&!_optionalChain([c, 'access', _242 => _242.problem, 'optionalAccess', _243 => _243.confirmation])&&!(c.conversationUnavailable&&_optionalChain([c, 'access', _244 => _244.problem, 'optionalAccess', _245 => _245.id])==="conversation-read")?c.problem:void 0,De=ot&&c.pending.some(o=>o.failure&&o.id===ot.id)?ot:void 0,Lt=De?void 0:ot,It=_optionalChain([Q, 'optionalAccess', _246 => _246.actions, 'access', _247 => _247.find, 'call', _248 => _248(o=>o.id==="confirm")]),Jn=_optionalChain([Q, 'optionalAccess', _249 => _249.actions, 'access', _250 => _250.find, 'call', _251 => _251(o=>o.id==="stop")]),ye=_chunk3KV7TDDRcjs.l.call(void 0, se,c.conversationId),kr=o=>{if(Se)return;let h=m.getSnapshot();if(_optionalChain([_chunk3KV7TDDRcjs.l.call(void 0, h.plan,h.conversationId), 'optionalAccess', _252 => _252.token])!==o){Sn(o);return}Sn(void 0),Fe(!0),m.confirmPlan().finally(()=>Fe(!1))},Zn=c.confirmationRefusal,xr=_optionalChain([Zn, 'optionalAccess', _253 => _253.token])===_optionalChain([ye, 'optionalAccess', _254 => _254.token])&&_optionalChain([Zn, 'optionalAccess', _255 => _255.problemId])===_optionalChain([c, 'access', _256 => _256.problem, 'optionalAccess', _257 => _257.id])?_optionalChain([c, 'access', _258 => _258.problem, 'optionalAccess', _259 => _259.confirmation, 'optionalAccess', _260 => _260.reason]):void 0,Cr=Cn!==void 0&&Cn!==_optionalChain([ye, 'optionalAccess', _261 => _261.token]),Sr=re?"section":"aside",Er=_optionalChain([se, 'optionalAccess', _262 => _262.state])==="awaiting-confirmation"&&!_optionalChain([Q, 'optionalAccess', _263 => _263.readOnly])&&ye!==void 0,Nt=et("plans")&&se?_jsxruntime.jsxs.call(void 0, Sr,{"aria-label":b("chat.plan"),"data-plan":"",children:[_jsxruntime.jsx.call(void 0, Is,{record:se,slots:p,view:Q,changesShown:Er}),_jsxruntime.jsxs.call(void 0, K,{name:"confirmBar",slots:p,data:Q?{view:Q,actions:Q.actions.filter(o=>Q.status?o.id==="confirm":o.id==="confirm"||o.id==="stop")}:void 0,children:[se.state==="awaiting-confirmation"&&!_optionalChain([Q, 'optionalAccess', _264 => _264.readOnly])?_jsxruntime.jsx.call(void 0, K,{name:"confirmation",slots:p,data:ye&&{confirmation:ye},children:_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, hs,{record:ye,planId:se.id,entry:It&&(Se?{...It,available:!1,busy:!0}:It),onConfirm:()=>ye&&kr(ye.token),refusal:xr,override:f.problemText&&ve,replaced:Cr})})}):null,!_optionalChain([Q, 'optionalAccess', _265 => _265.status])&&Jn?_jsxruntime.jsx.call(void 0, or,{action:Jn,onPress:_nullishCoalesce(a, () => ((()=>m.stopPlan())))}):null]}),_optionalChain([Q, 'optionalAccess', _266 => _266.status])?_jsxruntime.jsx.call(void 0, Ts,{view:Q,onPress:kt.press,slots:p,sheet:kt.sheet,hide:["confirm"]}):null]}):null,eo=D.at(-1),Ot=re&&Nt&&!c.pending.length&&_optionalChain([eo, 'optionalAccess', _267 => _267.blocks, 'access', _268 => _268.some, 'call', _269 => _269(o=>o.type==="plan"&&_optionalChain([o, 'access', _270 => _270.body, 'optionalAccess', _271 => _271.planId])===_optionalChain([se, 'optionalAccess', _272 => _272.id]))])?eo:void 0,to=_react.useRef.call(void 0, Xn);to.current=Xn;let Pr=_react.useMemo.call(void 0, ()=>({respond:(o,h)=>T=>to.current(o,h)(T),parses:Rt}),[Rt]),Tr=o=>o.blocks.map(h=>w(h,o.id)?"1":"0").join("");return _jsxruntime.jsx.call(void 0, Xt.Provider,{value:I.value,children:_jsxruntime.jsx.call(void 0, "section",{ref:C,className:"waypoint",dir:_nullishCoalesce(f.dir, () => ("ltr")),lang:f.lang,"data-layout":n,"data-color-scheme":_nullishCoalesce(f.colorScheme, () => ("light")),"data-custom-theme":f.theme?"":void 0,style:{..._chunk4BWV3SELcjs.c.call(void 0, A),colorScheme:_nullishCoalesce(f.colorScheme, () => ("light"))},...I.captureProps,onKeyDown:o=>{_optionalChain([r, 'optionalAccess', _273 => _273.focusComposer])===!1||o.key!==(_nullishCoalesce(_optionalChain([r, 'optionalAccess', _274 => _274.focusComposer]), () => ("/")))||!q(o.currentTarget,Pe(o.nativeEvent))||!To(o.currentTarget)||o.currentTarget.querySelector(_chunkGT6PI4CTcjs.b)||(o.preventDefault(),_optionalChain([E, 'access', _275 => _275.current, 'optionalAccess', _276 => _276.focus, 'call', _277 => _277()]))},children:_jsxruntime.jsxs.call(void 0, "div",{className:"wp-shell","data-has-aside":et("plans")&&se||Pn?"":void 0,"data-has-rail":Nn||_optionalChain([p, 'optionalAccess', _278 => _278.rail])||_optionalChain([f, 'access', _279 => _279.parts, 'optionalAccess', _280 => _280.rail])?"":void 0,children:[re?null:_jsxruntime.jsx.call(void 0, K,{name:"rail",slots:p,children:_jsxruntime.jsx.call(void 0, hn,{conversations:s,source:i})}),_jsxruntime.jsxs.call(void 0, "main",{children:[_jsxruntime.jsxs.call(void 0, K,{name:"topBar",slots:p,children:[re&&Nn?_jsxruntime.jsx.call(void 0, "span",{"data-rail-toggle":"",children:_jsxruntime.jsx.call(void 0, ee,{"aria-expanded":Ne,"aria-controls":On,onPress:()=>$e(o=>!o),children:b("chat.rail")})}):null,_jsxruntime.jsx.call(void 0, "h2",{children:_optionalChain([c, 'access', _281 => _281.conversation, 'optionalAccess', _282 => _282.title])||b("chat.title")})]}),re&&Ne&&!pr?_jsxruntime.jsx.call(void 0, Bs,{label:b("chat.rail"),closeLabel:b("chat.close"),onClose:()=>$e(!1),skipRestore:mr,onFocusWithin:o=>{let h=o.closest("[data-conversation-id]");Pt.current={element:o,id:_nullishCoalesce(_optionalChain([h, 'optionalAccess', _283 => _283.getAttribute, 'call', _284 => _284("data-conversation-id")]), () => (void 0)),owner:I.value.owner()}},children:_jsxruntime.jsx.call(void 0, "div",{id:On,children:_jsxruntime.jsx.call(void 0, hn,{conversations:s,source:i,onChoose:()=>{let o=I.value.originFor("rail-choice");Tt.current=!0,Y(I.value,_optionalChain([C, 'access', _285 => _285.current, 'optionalAccess', _286 => _286.querySelector, 'call', _287 => _287("[data-rail-toggle] button")]),{origin:o,owner:I.value.owner()}),$e(!1)}})})}):null,_jsxruntime.jsx.call(void 0, K,{name:"transcript",slots:p,children:_jsxruntime.jsxs.call(void 0, "div",{onFocusCapture:ur,children:[D.length?_jsxruntime.jsx.call(void 0, Ds,{messages:D,excerpts:gr,anchor:St,open:Le,onToggle:()=>Ct({conversationId:oe,open:!Le,query:Ke.query}),query:Ke.query,onQuery:o=>Ct({conversationId:oe,open:!0,query:o}),search:ze,sourceOf:br,lang:f.lang,onNavigate:o=>{let h=I.value.originFor("outline"),T=I.value.owner();Ie.reveal(o,()=>Y(I.value,me.toMessage(o),{origin:h,owner:T}))}}):null,_jsxruntime.jsx.call(void 0, "div",{ref:L,className:"wp-transcript",role:"region","aria-label":b("chat.transcript"),tabIndex:-1,children:_jsxruntime.jsx.call(void 0, wn.Provider,{value:v,children:_jsxruntime.jsxs.call(void 0, "div",{ref:R,role:D.length?"feed":void 0,"aria-busy":Ie.busy?!0:void 0,onKeyDown:D.length?o=>dr(o):void 0,children:[!c.conversation&&!c.conversationUnavailable&&!c.problem?_jsxruntime.jsx.call(void 0, "p",{children:b("chat.startupLoading")}):D.length?null:_jsxruntime.jsx.call(void 0, K,{name:"emptyState",slots:p,children:_jsxruntime.jsx.call(void 0, "p",{children:b("chat.empty")})}),Ie.segments.flatMap(o=>o.kind==="gap"?_jsxruntime.jsx.call(void 0, "div",{"data-transcript-gap":"","aria-hidden":"true",style:{blockSize:o.height}},`gap-${o.from}`):D.slice(o.from,o.to+1).map((h,T)=>_jsxruntime.jsx.call(void 0, Hs,{posInSet:o.from+T+1,setSize:D.length+c.pending.length,message:h,slots:p,anchorId:St(h.id),writing:h.id===Gn,bodyUnavailable:y.has(h.id)&&!h.blocks.length,disabled:c.conversationUnavailable,answered:Tr(h),actions:h!==Ot,rows:Pr},h.id))),c.pending.map((o,h)=>_jsxruntime.jsxs.call(void 0, "article",{"data-role":"pending","data-pending-id":o.id,tabIndex:-1,"aria-posinset":D.length+h+1,"aria-setsize":D.length+c.pending.length,"aria-label":b("chat.roleUser"),children:[_jsxruntime.jsxs.call(void 0, K,{name:"bubble",slots:p,data:{pending:Yo(o)},children:[_jsxruntime.jsx.call(void 0, "span",{"data-sender":"","aria-hidden":"true",children:b("chat.roleUser")}),_jsxruntime.jsx.call(void 0, "p",{children:o.content})]}),_jsxruntime.jsx.call(void 0, "p",{id:`${Ze}-${o.id}`,"data-pending-status":o.failure?"failed":"sending",children:b(o.failure?"chat.pendingFailed":"chat.pendingSending")}),_optionalChain([De, 'optionalAccess', _288 => _288.id])===o.id&&ve?_jsxruntime.jsxs.call(void 0, "p",{role:"alert",children:[ve.text,_nullishCoalesce(ve.action, () => ((!f.problemText&&_chunkRZ3AGK3Ucjs.l.call(void 0, De)==="refresh"?_jsxruntime.jsx.call(void 0, Vo,{problem:De,refresh:En}):null)))]},c.announcement):null,o.failure?_jsxruntime.jsxs.call(void 0, K,{name:"failedSendControls",slots:p,data:{pending:Yo(o)},children:[_jsxruntime.jsx.call(void 0, ee,{"aria-describedby":`${Ze}-${o.id}`,disabled:c.conversationUnavailable||c.sending,onPress:()=>{m.retry(o.id)},children:b("chat.retry")}),_jsxruntime.jsx.call(void 0, ee,{"aria-describedby":`${Ze}-${o.id}`,disabled:c.withdrawing.includes(o.id),onPress:()=>{m.withdraw(o.id)},children:b("chat.withdraw")}),_jsxruntime.jsx.call(void 0, ee,{"aria-describedby":`${Ze}-${o.id}`,onPress:()=>{m.dismiss(o.id)},children:b("chat.dismiss")})]}):null,_optionalChain([De, 'optionalAccess', _289 => _289.id])===o.id?_jsxruntime.jsx.call(void 0, _o,{problem:De},c.announcement):null]},o.id))]})})}),y.size?_jsxruntime.jsxs.call(void 0, "p",{role:"alert","data-render-failure":"",children:[b("chat.messagesUnavailable"),_jsxruntime.jsx.call(void 0, ee,{onPress:()=>{Ye.request(!0),N(o=>o+1)},children:b("chat.retry")})]}):null,me.pinned?null:_jsxruntime.jsx.call(void 0, "div",{"data-back-to-latest":"",children:_jsxruntime.jsx.call(void 0, ee,{onPress:()=>{let o=I.value.originFor("latest");me.toLatest(),Y(I.value,L.current,{origin:o,owner:I.value.owner()})},children:Hn?b("chat.latestNew",{count:Hn}):b("chat.latest")})})]})}),_jsxruntime.jsxs.call(void 0, K,{name:"replyRow",slots:p,children:[_jsxruntime.jsx.call(void 0, "div",{ref:Yn,role:"status","data-reply-state":Oe,children:Ft==="none"||wr?null:_jsxruntime.jsx.call(void 0, "p",{className:Ft==="writing"&&Gn?"wp-sr-only":void 0,children:b(`reply.${Ft}`)})}),Oe!=="none"||c.toolSteps.length?_jsxruntime.jsx.call(void 0, gs,{client:m,row:Oe}):null]}),re?Nt:null,Ot?_jsxruntime.jsx.call(void 0, ar,{slots:p,message:Ot}):null,et("flows")?_jsxruntime.jsx.call(void 0, K,{name:"flowTabs",slots:p,children:_jsxruntime.jsxs.call(void 0, "nav",{"aria-label":b("chat.flows"),children:[_jsxruntime.jsx.call(void 0, "div",{role:"tablist",onKeyDown:o=>{let h=c.flowTabs,T=h.findIndex(H=>_chunk3KV7TDDRcjs.f.call(void 0, H)===c.flowTab),O;if(o.key==="Home")O=0;else if(o.key==="End")O=h.length-1;else if(o.key==="ArrowRight"||o.key==="ArrowLeft"){let H=getComputedStyle(o.currentTarget).direction,U=o.key==="ArrowRight"!=((H==="rtl"||H==="ltr"?H:f.dir)==="rtl");O=(T+(U?1:h.length-1))%h.length}else return;let B=o.currentTarget;!q(B,Pe(o.nativeEvent))||!q(B,J(B.ownerDocument))||(o.preventDefault(),m.selectFlowTab(h[O]),_optionalChain([o, 'access', _290 => _290.currentTarget, 'access', _291 => _291.querySelectorAll, 'call', _292 => _292('[role="tab"]'), 'access', _293 => _293[O], 'optionalAccess', _294 => _294.focus, 'call', _295 => _295()]))},children:c.flowTabs.map(o=>_jsxruntime.jsx.call(void 0, ee,{id:`${Ee}-${_chunk3KV7TDDRcjs.f.call(void 0, o)}`,"aria-controls":`${Ee}-panel`,role:"tab","aria-selected":c.flowTab===_chunk3KV7TDDRcjs.f.call(void 0, o),tabIndex:c.flowTab===_chunk3KV7TDDRcjs.f.call(void 0, o)?0:-1,label:typeof o=="string"?b(`flow.${o}`):_nullishCoalesce(_optionalChain([f, 'access', _296 => _296.flowTabLabel, 'optionalCall', _297 => _297(o.labelKey)]), () => (o.labelKey)),onPress:()=>m.selectFlowTab(o),children:typeof o=="string"?b(`flow.${o}`):_nullishCoalesce(_optionalChain([f, 'access', _298 => _298.flowTabLabel, 'optionalCall', _299 => _299(o.labelKey)]), () => (o.labelKey))},_chunk3KV7TDDRcjs.f.call(void 0, o)))}),Ve&&Ve.owner===I.value.owner()?_jsxruntime.jsx.call(void 0, vn,{onFocus:o=>{$n.current=Ve.id,zn(o)},onRetry:()=>_n(Ve.id,Ve.values)}):null,je.status==="ready"?_jsxruntime.jsx.call(void 0, je.module.FlowPanel,{id:`${Ee}-panel`,labelledBy:`${Ee}-${c.flowTab}`,flows:c.flows[c.flowTab],all:c.flows,list:lr,onRetryList:Mn,onRunFlow:_n}):_jsxruntime.jsx.call(void 0, "div",{id:`${Ee}-panel`,role:"tabpanel","aria-labelledby":`${Ee}-${c.flowTab}`,tabIndex:-1,onFocus:zn,children:je.status==="failed"||vt(je)?_jsxruntime.jsx.call(void 0, vn,{retrying:vt(je),onRetry:()=>mn.request(!0)}):_jsxruntime.jsx.call(void 0, "p",{children:b("chat.loading")})})]})}):null,c.restored.length?_jsxruntime.jsx.call(void 0, "section",{"aria-label":b("chat.restored"),children:c.restored.map(o=>_jsxruntime.jsxs.call(void 0, "article",{children:[_jsxruntime.jsx.call(void 0, "p",{children:o.content}),_jsxruntime.jsx.call(void 0, ee,{onPress:()=>{m.editRestored(o.id)},children:b("chat.restoredEdit")}),_jsxruntime.jsx.call(void 0, ee,{onPress:()=>{m.discardRestored(o.id)},children:b("chat.restoredDiscard")})]},o.id))}):null,_jsxruntime.jsxs.call(void 0, K,{name:"composer",slots:p,data:{sending:c.sending},disabled:c.conversationUnavailable,value:c.draft,onChange:o=>{m.setDraft(o)},children:[_jsxruntime.jsx.call(void 0, ir,{inputRef:E,disabled:c.conversationUnavailable,value:c.draft,onChange:o=>{m.setDraft(o)},label:b("chat.message"),describedBy:c.hints.length?c.hints.map((o,h)=>`${Tn}-${h}`).join(" "):void 0,onKeyDown:o=>{_optionalChain([r, 'optionalAccess', _300 => _300.send])!==!1&&o.key===(_nullishCoalesce(_optionalChain([r, 'optionalAccess', _301 => _301.send]), () => ("Enter")))&&!o.shiftKey&&!o.nativeEvent.isComposing&&o.keyCode!==229&&(o.preventDefault(),m.send())}}),_jsxruntime.jsx.call(void 0, ee,{disabled:c.conversationUnavailable||!c.draft.trim()||c.sending,onPress:()=>{m.send()},children:b(c.sending?"chat.sending":"chat.send")}),c.hints.map((o,h)=>_jsxruntime.jsx.call(void 0, "p",{id:`${Tn}-${h}`,children:o},h))]}),_jsxruntime.jsx.call(void 0, K,{name:"actionBar",slots:p,children:u.map(o=>_jsxruntime.jsx.call(void 0, ee,{onPress:()=>{m.setDraft(o)},children:o},o))}),_jsxruntime.jsx.call(void 0, K,{name:"stepUpPrompt",slots:p,data:_optionalChain([se, 'optionalAccess', _302 => _302.plan, 'access', _303 => _303.kind])==="immediate"&&se.plan.stage==="final"?{stepUpCount:se.plan.stepUpCount}:void 0}),_jsxruntime.jsx.call(void 0, K,{name:"quotaStrip",slots:p,children:d}),_jsxruntime.jsx.call(void 0, "div",{ref:Kn,className:"wp-sr",role:"status","data-announcements":"",children:yr}),_jsxruntime.jsxs.call(void 0, "div",{role:"alert","data-announcement":c.announcement,children:[c.conversationUnavailable&&_jsxruntime.jsxs.call(void 0, "span",{children:[b("chat.conversationUnavailable"),_jsxruntime.jsx.call(void 0, ee,{onPress:wt.press,"aria-busy":wt.busy||void 0,"aria-disabled":wt.busy||void 0,children:b("chat.reload")})]}),Lt&&ve?_jsxruntime.jsxs.call(void 0, "span",{children:[ve.text,_nullishCoalesce(ve.action, () => ((c.problem&&!f.problemText?_jsxruntime.jsx.call(void 0, Vo,{problem:c.problem,refresh:En}):null)))]},c.announcement):null]}),Lt?_jsxruntime.jsx.call(void 0, _o,{problem:Lt},c.announcement):null]}),re?null:Nt,Pn?_jsxruntime.jsx.call(void 0, K,{name:"extraPanels",slots:p}):null]})})})}function $a({title:e,body:t,busy:n=!1,onProceed:r,onCancel:s}){let i=_react.useContext.call(void 0, le),d=_nullishCoalesce(_optionalChain([i, 'optionalAccess', _304 => _304.format]), () => (Ge())),a=_nullishCoalesce(_optionalChain([i, 'optionalAccess', _305 => _305.primitives]), () => (nr)),u=a.drawer,p=tn("confirm-sheet"),g=Qt(!0,_optionalChain([_e, 'call', _306 => _306(), 'optionalAccess', _307 => _307.owner, 'call', _308 => _308()]),s),f=a.button;return g?null:_jsxruntime.jsxs.call(void 0, en,{as:u,open:!0,label:e,onClose:s,closeLabel:d("chat.close"),...p,children:[_jsxruntime.jsx.call(void 0, "p",{children:t}),_jsxruntime.jsx.call(void 0, f,{disabled:n,onPress:r,children:d("chat.confirm")}),_jsxruntime.jsx.call(void 0, f,{onPress:s,children:d("chat.cancel")})]})}function hn({conversations:e,source:t,onChoose:n}){let{client:r,format:s,primitives:i,extraUrlSchemes:d}=$(),{conversationId:a}=_react.useSyncExternalStore.call(void 0, r.subscribe,r.getSnapshot,r.getSnapshot),[u,p]=_react.useState.call(void 0, ""),[g,f]=_react.useState.call(void 0, []),[m,b]=_react.useState.call(void 0, !1),[A,c]=_react.useState.call(void 0, 0),[C,E]=_react.useState.call(void 0, new Map);_react.useEffect.call(void 0, ()=>{if(!t)return;let v=!0;return b(!1),Promise.resolve().then(()=>t.list(u||void 0)).then(w=>{v&&(f(w),E(k=>new Map([...k,...w.filter(x=>x.subject).map(x=>[x.subject.key,x.subject])])))}).catch(()=>{v&&b(!0)}),()=>{v=!1}},[t,u,a,A]);let L=t?g:e,R=t?C:new Map(L.filter(v=>v.subject).map(v=>[v.subject.key,v.subject])),y=new Map;for(let v of L){let w=_nullishCoalesce(_optionalChain([v, 'access', _309 => _309.subject, 'optionalAccess', _310 => _310.key]), () => (""));u&&w!==u||y.set(w,[..._nullishCoalesce(y.get(w), () => ([])),v])}let P=i.button,S=_e(),N=v=>_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, P,{"aria-current":v.id===a?"page":void 0,onPress:()=>{_optionalChain([n, 'optionalCall', _311 => _311()]);let w=_nullishCoalesce(_optionalChain([S, 'optionalAccess', _312 => _312.ownerOf, 'call', _313 => _313(v.id)]), () => (v.id)),k=_optionalChain([S, 'optionalAccess', _314 => _314.originFor, 'call', _315 => _315("switch",w)]);r.switchConversation(v.id).then(x=>Y(S,_optionalChain([S, 'optionalAccess', _316 => _316.composer, 'call', _317 => _317()]),{origin:k,owner:w,stillCurrent:()=>x.kind==="loaded"&&_optionalChain([S, 'optionalAccess', _318 => _318.owner, 'call', _319 => _319()])===w&&_optionalChain([r, 'access', _320 => _320.getSnapshot, 'call', _321 => _321(), 'access', _322 => _322.conversation, 'optionalAccess', _323 => _323.id])===v.id}))},children:v.title}),v.mode==="form-fill"&&_jsxruntime.jsx.call(void 0, "span",{children:s("form.marker")}),_optionalChain([v, 'access', _324 => _324.subject, 'optionalAccess', _325 => _325.state])==="unlinked"&&_jsxruntime.jsx.call(void 0, "span",{children:s("form.unlinked")}),_optionalChain([v, 'access', _326 => _326.subject, 'optionalAccess', _327 => _327.route])&&_chunkFBADWFRRcjs.a.call(void 0, v.subject.route,d)&&_jsxruntime.jsx.call(void 0, "a",{href:v.subject.route,children:s("form.return")})]});return _jsxruntime.jsxs.call(void 0, "nav",{className:"wp-rail","aria-label":s("chat.rail"),tabIndex:-1,children:[R.size>0&&_jsxruntime.jsxs.call(void 0, "label",{children:[s("form.filter"),_jsxruntime.jsxs.call(void 0, "select",{value:u,onChange:v=>p(v.target.value),children:[_jsxruntime.jsx.call(void 0, "option",{value:"",children:s("form.all")}),[...R].map(([v,w])=>_jsxruntime.jsx.call(void 0, "option",{value:v,children:w.label},v))]})]}),m&&_jsxruntime.jsxs.call(void 0, "p",{role:"alert",children:[s("chat.conversationsFailed")," ",_jsxruntime.jsx.call(void 0, P,{onPress:()=>c(v=>v+1),children:s("chat.retry")})]}),[...y].map(([v,w])=>{let k=new Set,x=W=>{if(k.has(W.id))return null;k.add(W.id);let pe=w.filter(Se=>Se.parentConversationId===W.id&&!k.has(Se.id));return _jsxruntime.jsxs.call(void 0, "li",{"data-conversation-id":W.id,children:[N(W),pe.length>0&&_jsxruntime.jsxs.call(void 0, "details",{children:[_jsxruntime.jsx.call(void 0, "summary",{children:s("form.threads")}),_jsxruntime.jsx.call(void 0, "ul",{children:pe.map(x)})]})]},W.id)},Z=w.filter(W=>!W.parentConversationId||!w.some(pe=>pe.id===W.parentConversationId)).map(x);for(let W of w)k.has(W.id)||Z.push(x(W));return _jsxruntime.jsxs.call(void 0, "section",{children:[v&&_jsxruntime.jsx.call(void 0, "h3",{children:w[0].subject.label}),_jsxruntime.jsx.call(void 0, "ul",{children:Z})]},v)})]})}exports.a = J; exports.b = q; exports.c = ie; exports.d = de; exports.e = _t; exports.f = Xt; exports.g = _e; exports.h = Qt; exports.i = Ar; exports.j = Y; exports.k = en; exports.l = tn; exports.m = _s; exports.n = Gs; exports.o = hn; exports.p = ts; exports.q = Wo; exports.r = ns; exports.s = un; exports.t = Ge; exports.u = Me; exports.v = xe; exports.w = Ps; exports.x = Aa; exports.y = $; exports.z = Da; exports.A = Ba; exports.B = Ha; exports.C = Ua; exports.D = Wa; exports.E = qa; exports.F = or; exports.G = jo; exports.H = vn; exports.I = Ts; exports.J = K; exports.K = Rs; exports.L = Ls; exports.M = yn; exports.N = Is; exports.O = Ka; exports.P = $a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkA3YOSFLEcjs = require('./chunk-A3YOSFLE.cjs');var _react = require('react');var _jsxruntime = require('react/jsx-runtime');function U({children:e,label:u,onRegenerate:w,disabled:y,reason:d,slots:h,wrapper:c}){let r=_react.useId.call(void 0, ),S=_chunkA3YOSFLEcjs.x.call(void 0, ),[N,p]=_react.useState.call(void 0, !1),[f,P]=_react.useState.call(void 0, !1),x=_react.useRef.call(void 0, !1),l=_react.useRef.call(void 0, !1),m=_react.useRef.call(void 0, !1),F=_react.useRef.call(void 0, null),v=_react.useRef.call(void 0, void 0),i=()=>{clearTimeout(v.current),v.current=void 0};return _react.useEffect.call(void 0, ()=>i,[]),_jsxruntime.jsxs.call(void 0, "div",{ref:c,className:"wp-field-parent",style:{colorScheme:S},onClickCapture:b=>{let n=!!F.current&&_chunkA3YOSFLEcjs.b.call(void 0, F.current,b.target);n&&(m.current=!0),_chunkA3YOSFLEcjs.m.call(void 0, b,b.currentTarget,()=>{n&&(m.current=!1,!l.current&&!x.current&&(i(),p(!1)))})},onPointerEnter:()=>{x.current=!0,i(),p(!0)},onPointerLeave:()=>{x.current=!1,i(),v.current=setTimeout(()=>{!l.current&&!m.current&&p(!1)},400)},onFocus:()=>{l.current=!0,m.current=!1,i(),p(!0),P(!0)},onBlur:b=>{_chunkA3YOSFLEcjs.b.call(void 0, b.currentTarget,b.relatedTarget)||(l.current=!1,P(!1),!x.current&&!m.current&&(i(),p(!1)))},children:[e,_jsxruntime.jsxs.call(void 0, "span",{ref:F,className:"wp-field-adornment",hidden:!N,children:[_jsxruntime.jsx.call(void 0, _chunkA3YOSFLEcjs.J,{name:"fieldAdornment",slots:h,label:u,onPress:d?void 0:w,disabled:y,"aria-disabled":d?!0:void 0,describedBy:d?r:void 0,children:_jsxruntime.jsx.call(void 0, "button",{type:"button","aria-label":u,disabled:y,"aria-disabled":d?!0:void 0,"aria-describedby":d?r:void 0,onClick:()=>{d||w()},children:u})}),d?_jsxruntime.jsx.call(void 0, "span",{id:r,className:"wp-sr-only",children:d}):null]}),_jsxruntime.jsx.call(void 0, "span",{role:"status",className:"wp-sr-only",children:N&&f?u:""})]})}var W=_chunkA3YOSFLEcjs.u.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./form-extras-RNMBCYV7.cjs"))));function _(){let e=_chunkA3YOSFLEcjs.v.call(void 0, W);return _react.useEffect.call(void 0, ()=>W.request(),[]),e}var oe=e=>{let u=e.trim()===""?NaN:Number(e);return Number.isFinite(u)?u:void 0};function se(e){return _react.useSyncExternalStore.call(void 0, e.subscribe,e.getSnapshot,e.getSnapshot)}function Fe({session:e,onRegenerate:u,slots:w,renderField:y}){let d=se(e),{fields:h,pending:c}=d,{format:r,primitives:S}=_chunkA3YOSFLEcjs.y.call(void 0, ),N=_react.useId.call(void 0, ),p=_(),f=p.status==="ready"?p.module:void 0,P=S.input,x=S.checkbox,l=Object.values(h).some(n=>n.localInvalid),[m,F]=_react.useState.call(void 0, ""),v=_react.useRef.call(void 0, new Map),i=_react.useRef.call(void 0, ""),b=_chunkA3YOSFLEcjs.e.call(void 0, ()=>[_optionalChain([v, 'access', _2 => _2.current, 'access', _3 => _3.get, 'call', _4 => _4(i.current), 'optionalAccess', _5 => _5.querySelector, 'call', _6 => _6("input,textarea,select,button,[tabindex]")])]);return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[Object.entries(h).map(([n,o],M)=>{let T=`${N}-${M}`,k=_optionalChain([o, 'access', _7 => _7.validation, 'optionalAccess', _8 => _8.status])==="invalid"||!!o.localInvalid,g=o.value,A={label:o.label,invalid:k,describedBy:T};return _jsxruntime.jsxs.call(void 0, U,{reason:f?l?r("form.fixFirst"):c?r("form.revertWait"):void 0:r(p.status==="failed"?"form.toolsFailed":"form.toolsLoading"),label:r("form.regenerate",{field:o.label}),slots:w,onRegenerate:()=>u(n),wrapper:a=>v.current.set(n,a),children:[y?y({name:n,label:o.label,value:g,onChange:a=>e.edit(n,a),invalid:k,describedBy:T}):typeof g=="string"?_jsxruntime.jsx.call(void 0, P,{...A,value:g,onChange:a=>e.edit(n,a)}):typeof g=="number"?_jsxruntime.jsx.call(void 0, P,{...A,type:"number",value:_nullishCoalesce(o.localText, () => (String(g))),onChange:a=>{let s=oe(a);s===void 0?e.markEdited(n,a):e.edit(n,s)}}):typeof g=="boolean"?_jsxruntime.jsx.call(void 0, x,{...A,checked:g,onChange:a=>e.edit(n,a)}):_jsxruntime.jsxs.call(void 0, "div",{children:[o.label,": ",f?_jsxruntime.jsx.call(void 0, f.Value,{value:g,t:r}):null," ",r("form.editInForm")]}),_jsxruntime.jsxs.call(void 0, "div",{id:T,className:k?"wp-invalid":void 0,children:[k?_jsxruntime.jsx.call(void 0, "strong",{children:r("form.invalid")}):null,o.localInvalid?_jsxruntime.jsx.call(void 0, "p",{children:r("form.number")}):null,_optionalChain([o, 'access', _9 => _9.validation, 'optionalAccess', _10 => _10.messages, 'access', _11 => _11.map, 'call', _12 => _12((a,s)=>_jsxruntime.jsx.call(void 0, "p",{children:a},s))]),_optionalChain([o, 'access', _13 => _13.validation, 'optionalAccess', _14 => _14.guidance])&&_jsxruntime.jsx.call(void 0, "p",{children:o.validation.guidance})]}),_jsxruntime.jsx.call(void 0, "div",{onFocus:a=>{i.current=n,b(a)},children:o.replacement&&f?_jsxruntime.jsx.call(void 0, f.Suggestion,{name:n,draft:o,session:e,t:r,primitives:S,onReplace:()=>F(f.attentionText(e.getSnapshot(),r))}):null})]},n)}),f?_jsxruntime.jsx.call(void 0, f.FieldsStatus,{text:m}):null]})}function ye({session:e,open:u,onClose:w,field:y,source:d,attachments:h}){let{format:c,primitives:r}=_chunkA3YOSFLEcjs.y.call(void 0, ),[S,N]=_react.useState.call(void 0, ""),[p,f]=_react.useState.call(void 0, ""),[P,x]=_react.useState.call(void 0, ""),l=_(),m=l.status==="ready"?l.module:void 0,F=_react.useRef.call(void 0, null),v=_react.useRef.call(void 0, 0),i=_react.useRef.call(void 0, void 0),b=r.button,n=r.drawer,o=r.textarea,M=_chunkA3YOSFLEcjs.n.call(void 0, ),T=_react.useId.call(void 0, );_react.useEffect.call(void 0, ()=>(v.current++,()=>{v.current++,e.cancel()}),[u,e,y]);let k=()=>{v.current++,e.cancel(),w()},g=s=>s.some(E=>E.type.startsWith("image/"))?(i.current?i.current([...s]):x(c(h?"form.imagesNow":"form.imagesHere")),!0):!1,A=_chunkA3YOSFLEcjs.e.call(void 0, ()=>[_optionalChain([F, 'access', _15 => _15.current, 'optionalAccess', _16 => _16.querySelector, 'call', _17 => _17("textarea")])]),a=_chunkA3YOSFLEcjs.x.call(void 0, );return _jsxruntime.jsxs.call(void 0, _chunkA3YOSFLEcjs.k,{as:n,open:u,label:c("form.title"),onClose:k,closeLabel:c("chat.close"),...M,children:[_jsxruntime.jsxs.call(void 0, "div",{ref:F,style:{colorScheme:a},onPasteCapture:s=>{g(Array.from(s.clipboardData.files))&&h&&i.current&&s.preventDefault()},onDragOver:s=>{s.dataTransfer.types.includes("Files")&&s.preventDefault()},onDrop:s=>{if(!s.dataTransfer.files.length)return;s.preventDefault();let E=Array.from(s.dataTransfer.files);g(E)||_optionalChain([i, 'access', _18 => _18.current, 'optionalCall', _19 => _19(E)])},children:[_jsxruntime.jsx.call(void 0, "p",{children:c("chat.message")}),_jsxruntime.jsx.call(void 0, o,{label:c("chat.message"),value:S,onChange:N}),_jsxruntime.jsx.call(void 0, "p",{children:c("form.references")}),_jsxruntime.jsx.call(void 0, o,{label:c("form.references"),value:p,onChange:f})]}),m?null:_jsxruntime.jsx.call(void 0, "p",{role:"status",children:P}),m?_jsxruntime.jsx.call(void 0, m.PopupBody,{session:e,open:u,field:y,source:d,attachments:h,text:S,references:p,scope:v,upload:i,messageField:()=>_nullishCoalesce(_optionalChain([F, 'access', _20 => _20.current, 'optionalAccess', _21 => _21.querySelector, 'call', _22 => _22("textarea")]), () => (null))}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[l.status==="failed"||l.status==="loading"&&l.retrying?_jsxruntime.jsx.call(void 0, _chunkA3YOSFLEcjs.H,{retrying:l.status==="loading",onRetry:()=>W.request(!0),onFocus:A}):null,_jsxruntime.jsx.call(void 0, b,{"aria-disabled":!0,"aria-describedby":T,children:c("form.generate")}),_jsxruntime.jsx.call(void 0, "span",{id:T,children:c(l.status==="failed"?"form.toolsFailed":"form.toolsLoading")})]})]})}exports.a = U; exports.b = se; exports.c = Fe; exports.d = ye;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{y as s}from"./chunk-
|
|
1
|
+
import{y as s}from"./chunk-IPI4O4LP.js";import{useId as c}from"react";import{Fragment as m,jsx as t,jsxs as f}from"react/jsx-runtime";function h({disabled:o,blocked:e,reason:a,label:d,onPress:r}){let{format:b,primitives:u}=s(),l=u.button,i=c(),n=e&&!o;return f(m,{children:[t(l,{disabled:o,"aria-disabled":n||void 0,"aria-describedby":n?i:void 0,onPress:r,children:d??b("chat.submit")}),n?t("span",{id:i,"data-reason":"submit",children:a}):null]})}export{h as a};
|