@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.
Files changed (63) hide show
  1. package/README.md +37 -0
  2. package/dist/{block-reply-DN4RiLL0.d.cts → block-reply-r8u-DNmZ.d.cts} +15 -3
  3. package/dist/{block-reply-Dtof9ild.d.ts → block-reply-z8El20nD.d.ts} +15 -3
  4. package/dist/{blocks-UJ7GUJHD.js → blocks-2ABWECKG.js} +1 -1
  5. package/dist/{blocks-25YOJ5SS.cjs → blocks-7453YTYJ.cjs} +1 -1
  6. package/dist/{chunk-W6Y7H56X.js → chunk-5Q3INHKA.js} +1 -1
  7. package/dist/chunk-A3YOSFLE.cjs +1 -0
  8. package/dist/{chunk-Q6BD2YL3.cjs → chunk-BRUQ75G3.cjs} +1 -1
  9. package/dist/{chunk-SD2KAIVE.js → chunk-D4Q46KWA.js} +1 -1
  10. package/dist/chunk-IPI4O4LP.js +1 -0
  11. package/dist/chunk-QFBAOEPD.js +1 -0
  12. package/dist/chunk-RZ3AGK3U.cjs +1 -0
  13. package/dist/{chunk-4ZGW4HM4.cjs → chunk-XTKUDSDK.cjs} +1 -1
  14. package/dist/{confirmation-view-OMWHUYVC.cjs → confirmation-view-5BZ2PP7J.cjs} +1 -1
  15. package/dist/{confirmation-view-CICNJJIO.js → confirmation-view-Z5JHY2F5.js} +1 -1
  16. package/dist/{flows-panel-YEJ36RTY.js → flows-panel-2SCPYZ3X.js} +1 -1
  17. package/dist/{flows-panel-AIULKYOS.cjs → flows-panel-HQYJMOP4.cjs} +1 -1
  18. package/dist/{form-extras-QYE32TUY.cjs → form-extras-RNMBCYV7.cjs} +1 -1
  19. package/dist/{form-extras-SBBOMJS2.js → form-extras-X3B3JCMH.js} +1 -1
  20. package/dist/hooks/index.cjs +1 -1
  21. package/dist/hooks/index.d.cts +3 -3
  22. package/dist/hooks/index.d.ts +3 -3
  23. package/dist/hooks/index.js +1 -1
  24. package/dist/{i18n-DPNfYTMG.d.cts → i18n-WC9f-h_q.d.cts} +3 -0
  25. package/dist/{i18n-DPNfYTMG.d.ts → i18n-WC9f-h_q.d.ts} +3 -0
  26. package/dist/markdown-5NUOCOGY.js +23 -0
  27. package/dist/{markdown-BSRKJFFE.cjs → markdown-CG7NXI7X.cjs} +17 -11
  28. package/dist/{message-actions-F6SPLTT7.cjs → message-actions-ORBVYGNE.cjs} +1 -1
  29. package/dist/{message-actions-3HGE6VTS.js → message-actions-XNBBFHGW.js} +1 -1
  30. package/dist/messages/en/index.cjs +1 -1
  31. package/dist/messages/en/index.js +1 -1
  32. package/dist/messages/index.d.cts +3 -3
  33. package/dist/messages/index.d.ts +3 -3
  34. package/dist/messages/zh-Hans/index.cjs +1 -1
  35. package/dist/messages/zh-Hans/index.js +1 -1
  36. package/dist/react/index.cjs +1 -1
  37. package/dist/react/index.d.cts +8 -6
  38. package/dist/react/index.d.ts +8 -6
  39. package/dist/react/index.js +1 -1
  40. package/dist/{recovery-panel-VOKVDDZD.js → recovery-panel-6EBUMANX.js} +1 -1
  41. package/dist/{recovery-panel-OWY2CWOH.cjs → recovery-panel-EQIIV7TT.cjs} +3 -3
  42. package/dist/{reply-controls-5CWIAKIG.js → reply-controls-HUYHUO3W.js} +1 -1
  43. package/dist/{reply-controls-CPWB4VBK.cjs → reply-controls-LGY2RKRJ.cjs} +1 -1
  44. package/dist/skin-antd/index.d.cts +3 -3
  45. package/dist/skin-antd/index.d.ts +3 -3
  46. package/dist/{step-name-BdkYnb5g.d.ts → step-name-BlgVvshf.d.ts} +1 -1
  47. package/dist/{step-name-3hQ6CCGr.d.cts → step-name-CB3d3kkP.d.cts} +1 -1
  48. package/dist/styles.css +15 -0
  49. package/dist/testing/index.cjs +1 -1
  50. package/dist/testing/index.d.cts +3 -3
  51. package/dist/testing/index.d.ts +3 -3
  52. package/dist/testing/index.js +1 -1
  53. package/etc/hooks.api.md +9 -0
  54. package/etc/messages.api.md +3 -0
  55. package/etc/react.api.md +9 -0
  56. package/etc/skin-antd.api.md +9 -0
  57. package/etc/testing.api.md +9 -0
  58. package/package.json +2 -1
  59. package/dist/chunk-M3UENQ6L.cjs +0 -1
  60. package/dist/chunk-RHBDQGD4.js +0 -1
  61. package/dist/chunk-TGL3DR2K.js +0 -1
  62. package/dist/chunk-UYR3UEIW.cjs +0 -1
  63. package/dist/markdown-ETLB66BK.js +0 -17
@@ -1 +0,0 @@
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 _chunk3KV7TDDRcjs = require('./chunk-3KV7TDDR.cjs');var o=e=>`chat.recovery.${e}`,H=["alreadyClosedByWinner","alreadyKept","alreadyStoppedNeedsDecision","cancelStarted","cancelledNoChanges","capabilityMissing","currentStopped","initialTargetSettled","initialTargetStopped","intentSuperseded","keepReasonChanged","keptForwardClosed","leaveCompletedByKeep","leaveCoveredByKeep","leaveNeedsReview","leaveSafetyNeedsReview","leftKnown","leftUnconfirmed","planClosedKept","reviewTargetSettled","reviewTargetStopped","stopped","stoppedNoChanges","acknowledgmentAhead","cancelCoveredByLeaveSafety","cancelCoveredByStopNoChanges","cancelDefeatedByStop","choiceReplacedByStop","initialTargetClosed","keepDefeatedByWinner","leaveDefeatedByWinner","leaveNoDecision","leaveSafetyAlreadyStopped","reopenedEvidence"],X={...Object.fromEntries(H.map(e=>[e,o(e)])),alreadyClosed:o("alreadyClosedByWinner"),acknowledgmentStale:o("keepReasonChanged"),intentConflict:o("intentTargetChanged"),invalidTarget:o("intentTargetChanged"),intentUnavailable:o("keepReasonUnavailable"),keepBlockedActive:o("keepReasonActive"),keepBlockedUnknown:o("keepReasonUnknown"),keepBlockedReview:o("keepReasonPreview"),keepNoDecision:o("keepReasonNoSource"),planSealed:o("alreadyKept"),keptElsewhere:o("keptAlready")},x={...Object.fromEntries(["stopNotSent","stopNotSentElsewhere","stopUnconfirmed","leaveNotSent","leaveUnconfirmed","keepNotSent","keepUnconfirmed"].map(e=>[e,o(e)])),cancelInitialNotSent:o("cancelNotSent"),cancelInitialUnconfirmed:o("cancelUnconfirmed"),cancelReviewNotSent:o("reviewCancelNotSent"),cancelReviewUnconfirmed:o("reviewCancelUnconfirmed"),stopRefused:o("requestRefused"),cancelInitialRefused:o("requestRefused"),cancelReviewRefused:o("requestRefused"),leaveRefused:o("requestRefused"),keepRefused:o("requestRefused")},G=new Set(["leftUnconfirmed"]),J={leaveCompletedByKeep:o("leaveCompletedByKeep"),leaveCoveredByKeep:o("leaveCoveredByKeep"),keptElsewhere:o("keptAlready")};function z(e){let n=[],t=(r,c)=>{r&&!n.some(f=>f.key===r)&&n.push(c?{key:r,values:c}:{key:r})};for(let r of _nullishCoalesce(e.keys, () => ([])))t(X[r],G.has(r)&&typeof e.count=="number"?{count:e.count}:void 0);e.requestKey&&t(o(e.requestKey));let a=r=>{r!==void 0&&t(o(r?"requestedIntentApplied":"requestedIntentNotApplied"))};a(e.requestedTargetApplied);let i=e.savedDisposition;i&&t(o(i.phase==="left-known"?"leftKnown":"leftUnconfirmed"),i.phase==="left-known"?void 0:{count:i.count});let l=e.finalHistory;return l&&(l.relation&&t(J[l.relation]),_optionalChain([l, 'access', _2 => _2.keptFact, 'optionalAccess', _3 => _3.keepEffect])==="forward-closed"&&t(o("keptForwardClosed")),a(l.requestedTargetApplied),_optionalChain([l, 'access', _4 => _4.contradictedAfterSeal, 'optionalAccess', _5 => _5.length])&&t(o("laterReportAfterKeep"))),n}var Q={user:"winnerStopUser","connection-lost":"winnerStopConnection","renewal-refused":"winnerStopRenewal","step-failed":"winnerStopStep","step-up-failed":"winnerStopStepUp","identity-lost":"winnerStopIdentity","attribution-missing":"winnerStopAttribution","plan-changed":"winnerStopChanged","adapter-configuration":"winnerStopAdapter"},V={stop:4,"cancel-initial":3,"cancel-review":3,keep:2,leave:1},U={stop:"stop",decline:"cancel-initial",leave:"leave",keep:"keep"},O={stop:o("checkIntentStatus"),"cancel-initial":o("checkIntentStatus"),"cancel-review":o("checkIntentStatus"),leave:o("checkSavedChoice"),keep:o("checkKeepStatus")},Z={capabilityMissing:null,keepNoDecision:null,sealed:null,keepBlockedActive:o("keepReasonActive"),keepBlockedUnknown:o("keepReasonUnknown"),loading:o("actionLoading"),intentUnavailable:o("keepReasonUnavailable")},ee=new Set(["proposal","initial-review","cancelled"]),ne=new Set(["forward-active","readback","left-reopened","left-unconfirmed","completed","left-known"]),te=new Set(["forward-active","readback","left-reopened"]),ae=new Set(["readback","left-reopened"]),m=(e,n,t)=>t?{id:e,labelKey:n,available:!1,reasonKey:t}:{id:e,labelKey:n,available:!0};function oe(e,n){let t=T(e,n),a=t?[t]:[];return n.state==="running"&&a.push(m("stop","chat.stop")),a}function T(e,n){let t=_chunk3KV7TDDRcjs.l.call(void 0, n,e.conversationId);if(n.state!=="awaiting-confirmation"||!t)return;let i={...m("confirm",t.schedule?"chat.confirmation.schedule":"chat.confirmation.apply",e.now>=Date.parse(t.expiresAt)?"chat.confirmation.expired":void 0),countedLabelKey:t.schedule?"chat.confirmation.scheduleCount":"chat.confirmation.applyCount",labelValues:{count:t.items.length}};return t.schedule?{...i,schedule:!0}:i}function re(e,n){let a=n.recovery.phase,i=[],l=a==="initial-review"&&T(e,n);if(l&&i.push(l),(a==="proposal"||a==="initial-review"||a==="forward-active")&&i.push(m("stop","chat.stop")),(a==="proposal"||a==="initial-review")&&i.push(m("decline","chat.cancel")),te.has(a)&&i.push(m("leave",o("leave"),e.capabilities.includes("plan-leave")?void 0:o("capabilityMissing"))),ne.has(a)){let r=e.keepReview;if(!("disabled"in r))i.push(m("keep",o("keepChanges")));else{let c=Z[r.disabled];c&&i.push(m("keep",o("keepChanges"),c))}}if(ae.has(a))for(let r of["undoSelected","continue"])i.push(m(r,o(r),o("notAvailableYet")));return i}function D(e,n){if(!(_optionalChain([n, 'optionalAccess', _6 => _6.retryAt])===void 0||_optionalChain([n, 'access', _7 => _7.lastProblem, 'optionalAccess', _8 => _8.cause])!=="rate-limited"||e.now>=n.retryAt))return{seconds:Math.ceil((n.retryAt-e.now)/1e3)}}function N(e,n,t){let a=n,i=D(e,t);if(t){let r=i?{id:"status",labelKey:O[t.kind],available:!1,reasonKey:o("retryAfterSeconds"),reasonValues:i}:{id:"status",labelKey:O[t.kind],available:!0,busy:t.delivery==="sending"},c=!1;a=a.map(f=>U[f.id]===t.kind?(c=!0,r):f),c||(a=[...a,r])}let l=[...t?[t.kind]:[],...e.pending].map(r=>V[r]);if(l.length){let r=Math.max(...l);a=a.map(c=>{if(c.id==="status")return c;let f=U[c.id],s=c.id==="confirm"?0:f?V[f]:void 0;if(s===void 0||s>r)return c;let d=f&&e.pending.includes(f);return{...c,available:!1,reasonKey:o("intentPendingReason"),...d?{busy:!0}:{}}})}return e.conversationUnavailable&&(a=a.map(r=>({...r,available:!1,reasonKey:o("refreshConversation")}))),a}function B(e,n){let t=e.recovery,a=_nullishCoalesce(t.steps, () => ([])),i=r=>a.filter(c=>c.truth===r).length,l=(r,c)=>c?{key:o(r),values:c}:{key:o(r)};if(t.sealed)return{label:l("keptKnown"),tone:"neutral",attention:!1};switch(t.phase){case"proposal":return{label:l("statusProposal"),tone:"neutral",attention:!1};case"initial-review":return{label:l("heading"),tone:"neutral",attention:!1};case"forward-active":return{label:l(_optionalChain([n, 'optionalAccess', _9 => _9.kind])==="stop"?"stopping":"currentRunning"),tone:"progress",attention:!1};case"readback":case"left-reopened":return{label:l("heading"),tone:"warning",attention:!0};case"completed":return{label:l("statusCompleted"),tone:"success",attention:!1};case"cancelled":return{label:l(i("done")?"currentStopped":"cancelledNoChanges"),tone:"neutral",attention:!1};case"left-known":return{label:l("leftKnown"),tone:"neutral",attention:!1};case"left-unconfirmed":return{label:l("leftUnconfirmed",{count:i("unknown")}),tone:"warning",attention:!1}}}function W(e){let n=e.plan;if(!n)return null;let t=!!n.recovery&&e.capabilities.includes("plan-recovery");if(n.recovery&&(e.readOnly||!t||n.recovery.profile!=="plan-recovery-v1"||!B(n,void 0)))return{planId:n.id,status:{dataStatus:n.recovery.phase,wireState:n.state,label:{key:o("heading")},tone:"neutral",attention:!1},intent:null,steps:[],lines:[{key:o("updateToControl")},{key:`chat.block.state.${n.state}`}],notice:[],alert:null,actions:[],pending:[],conversationUnavailable:e.conversationUnavailable,readOnly:!0};let a=e.overlay&&e.overlay.planId===n.id?e.overlay:void 0,i=e.notice&&(_nullishCoalesce(e.notice.planId, () => (n.id)))===n.id?z(e.notice):[],l=e.alert,r=D(e,a),c=_optionalChain([a, 'optionalAccess', _10 => _10.lastProblem, 'optionalAccess', _11 => _11.key]),f=l&&a?{serial:l.serial,..."restoreFocus"in l?{restoreFocus:!0}:{action:l.action},...c&&x[c]?{message:{key:x[c]}}:{},retryAvailable:!r&&!e.conversationUnavailable,...e.conversationUnavailable?{retryReasonKey:o("refreshConversation")}:r?{retryReasonKey:o("retryAfterSeconds"),retryValues:r}:{}}:l&&"restoreFocus"in l?{serial:l.serial,restoreFocus:!0,retryAvailable:!0}:null;if(!t)return{planId:n.id,status:null,intent:null,steps:[],lines:[],notice:[],alert:null,actions:N({...e,pending:[]},oe(e,n),void 0),pending:[],conversationUnavailable:e.conversationUnavailable};let s=n.recovery,d=new Map(n.plan.kind==="immediate"?n.plan.steps.map((p,S)=>[p.id,{index:S+1,resource:p.resource}]):[]),w=new Set(_nullishCoalesce(s.contradictedAfterSeal, () => ([]))),h=s.phase==="forward-active",k=(_nullishCoalesce(s.steps, () => ([]))).map((p,S)=>({stepId:p.stepId,index:_nullishCoalesce(_optionalChain([d, 'access', _12 => _12.get, 'call', _13 => _13(p.stepId), 'optionalAccess', _14 => _14.index]), () => (S+1)),..._optionalChain([d, 'access', _15 => _15.get, 'call', _16 => _16(p.stepId), 'optionalAccess', _17 => _17.resource])!==void 0&&{resource:d.get(p.stepId).resource},truth:p.truth,textKey:o(p.truth==="done"?"done":p.truth==="not-done"?"notDone":h?"stepNotKnownYet":"unknown"),...s.sealed&&w.has(p.stepId)?{lateReport:"contradicted"}:{}})),y=[],v=k.filter(p=>p.truth==="unknown").length,K=k.filter(p=>p.truth==="not-done").length;!_optionalChain([s, 'access', _18 => _18.steps, 'optionalAccess', _19 => _19.length])&&!ee.has(s.phase)&&y.push({key:o("stepsNotKnownYet")});let b=!1;!s.sealed&&!h&&v&&(y.push({key:o("stepsUnknown"),values:{count:v}}),b=!0),!s.sealed&&s.phase==="completed"&&K&&(y.push({key:o("stepsNotDone"),values:{count:K}}),b=!0),s.sealed&&w.size&&(y.push({key:o("laterReportAfterKeep")}),b=!0);let u=s.winner;_optionalChain([u, 'optionalAccess', _20 => _20.kind])==="stop"?(y.push({key:o(Q[u.cause])}),s.phase==="readback"&&y.push({key:o("stopped")})):u&&y.push({key:o(u.kind==="leave"?"winnerLeave":u.kind==="keep"?"winnerKeep":"winnerCancel")});let g=B(n,a);return{planId:n.id,status:{dataStatus:s.phase,wireState:n.state,label:g.label,tone:g.tone,attention:g.attention||b,...s.sealed?{result:"kept"}:{}},intent:a?{kind:a.kind,status:a.delivery}:null,steps:k,lines:y,notice:i,alert:f,actions:N(e,re(e,n),a),pending:e.pending,conversationUnavailable:e.conversationUnavailable}}function L(e,n){let t=e.review==="forward-only"?[{key:o("confirmKeepForwardOnly")},{key:o("keepRemainingSteps"),values:{count:e.remaining}}]:[{key:o("confirmEndRetention")}],a=n.conversationUnavailable?o("refreshConversation"):_optionalChain([n, 'access', _21 => _21.status, 'optionalAccess', _22 => _22.result])==="kept"?o("alreadyKept"):n.intent||n.pending.length?o("intentPendingReason"):void 0;return{messages:t,proceed:a?{available:!1,reasonKey:a}:{available:!0}}}var _react = require('react');var ce=_react.createContext.call(void 0, null);function R(e){let n=_react.useContext.call(void 0, ce),t=_nullishCoalesce(e, () => (n));if(!t)throw new Error("A client is required");return t}function I(e){let n=R(e);return _react.useSyncExternalStore.call(void 0, n.subscribe,n.getSnapshot,n.getSnapshot)}function Ie(e){let n=R(e),t=I(n),a=t.plan,[i,l]=_react.useState.call(void 0, []),[r,c]=_react.useState.call(void 0, ()=>Date.now()),[f,s]=_react.useState.call(void 0, null),d=_optionalChain([a, 'optionalAccess', _23 => _23.id]);_react.useEffect.call(void 0, ()=>{l([]),s(null)},[d]);let w=d?t.intentOverlays[d]:void 0,h=_optionalChain([w, 'optionalAccess', _24 => _24.retryAt]);_react.useEffect.call(void 0, ()=>{if(h===void 0)return;let u=h-Date.now();if(u<=0)return;let g=setTimeout(()=>c(Date.now()),u);return()=>clearTimeout(g)},[h]);let k=_optionalChain([_chunk3KV7TDDRcjs.l.call(void 0, a,t.conversationId), 'optionalAccess', _25 => _25.expiresAt]);_react.useEffect.call(void 0, ()=>{if(!k)return;let u=Date.parse(k)-Date.now();if(!(u>0))return;let g=setTimeout(()=>c(Date.now()),u+1);return()=>clearTimeout(g)},[k]);let y=W({plan:a,capabilities:t.capabilities,conversationUnavailable:t.conversationUnavailable,overlay:w,notice:t.intentNotice,alert:t.intentAlert,keepReview:a?n.keepChangesReview(a.id):{disabled:"keepNoDecision"},pending:i,now:Math.max(r,Date.now()),conversationId:t.conversationId,readOnly:t.planReadOnly}),v=_react.useCallback.call(void 0, (u,g)=>{l(p=>[...p,u]),g.finally(()=>l(p=>p.filter(S=>S!==u)))},[]),K=_react.useCallback.call(void 0, u=>{if(d)switch(u){case"confirm":n.confirmPlan();return;case"stop":{n.stopPlan(d);let g=n.getSnapshot();!g.planReadOnly&&!g.intentOverlays[d]&&v("stop",n.checkIntentStatus(d));return}case"decline":v("cancel-initial",n.declinePlan());return;case"leave":v("leave",n.leavePlan(d));return;case"keep":{let g=n.keepChangesReview(d);"disabled"in g||s(g);return}case"status":case"retry":n.checkIntentStatus(d);return}},[d,n,v]),b=f&&y?{...L(f,y),onProceed:()=>{let u=f;s(null),v("keep",n.keepChanges(u))},onCancel:()=>s(null)}:null;return{view:y,press:K,sheet:b}}var q=new WeakMap,pe=e=>{let n=q.get(e);return n||q.set(e,n={cards:new Map,listeners:new Set}),n},F=(e,n,t)=>JSON.stringify([e,n,t]),E=new WeakMap,Y=e=>{E.delete(e.cards);for(let n of e.listeners)n()},ue=128,$=(e,n)=>{let t=n;for(let a=0;a<e.length;a++)t^=e.charCodeAt(a),t=Math.imul(t,16777619)>>>0;return t.toString(16).padStart(8,"0")},j=e=>$(e,2166136261)+$(e,731459039),fe=e=>JSON.stringify(e,(n,t)=>t&&typeof t=="object"&&!Array.isArray(t)?Object.fromEntries(Object.entries(t).sort(([a],[i])=>a<i?-1:1)):t),ye=e=>e.replace(/[^\w.~-]/g,n=>`%${(n.charCodeAt(0)+65536).toString(16).slice(1)}`);function ge(e,n,t,a){let i=`card:${[e,n,t].map(ye).join(":")}:${j(fe(a))}`;return i.length<=ue?i:`card~${j(i)}`}function Ee(e){let n=R(e),{conversationId:t}=I(n),a=pe(n),i=_react.useCallback.call(void 0, s=>(a.listeners.add(s),()=>a.listeners.delete(s)),[a]),l=_react.useCallback.call(void 0, ()=>{let s=E.get(a.cards);s||E.set(a.cards,s=new Map);let d=s.get(t);return d||(d=new Set([...a.cards.values()].filter(w=>w.conversationId===t).map(w=>w.blockId)),s.set(t,d)),d},[a,t]),r=_react.useSyncExternalStore.call(void 0, i,l,l),c=_react.useCallback.call(void 0, (s,d,w="")=>{let h=F(t,w,s.id);if(a.cards.has(h))return Promise.resolve();let k={...d,blockId:typeof d.blockId=="string"?d.blockId:s.id,clientReplyId:ge(t,w,s.id,d)};a.cards.set(h,{conversationId:t,blockId:s.id}),Y(a);let y=()=>{a.cards.delete(h),Y(a)};return n.replyOutcome(k).then(v=>(v.accepted||y(),v),y)},[n,a,t]),f=_react.useCallback.call(void 0, (s,d="")=>!!s.answered||a.cards.has(F(t,d,s.id)),[a,t,r]);return{answered:r,isAnswered:f,reply:c}}var we={"sign-in":"chat.problem.signIn",retryable:"chat.problem.retryable","rate-limited":"chat.problem.rateLimited",refused:"chat.problem.refused",closed:"chat.problem.closed",full:"chat.problem.full",declined:"chat.problem.declined",unavailable:"chat.problem.unavailable","step-up-cancelled":"chat.problem.stepUp","invalid-read":"chat.problem.invalid","invalid-plan":"chat.problem.invalid","plan-changed":"chat.planChanged","update-required":"chat.update",mismatch:"chat.problem.mismatch","agreement-expired":"chat.problem.agreement","in-doubt":"chat.problem.inDoubt",replaced:"chat.problem.replaced","needs-attention":"chat.problem.needsAttention",stopped:"chat.stopped"},ve= exports.i =e=>e.code==="replaced"?"refresh":["retryable","rate-limited","unavailable","agreement-expired"].includes(e.code)?"retry":void 0;function Ve(e,n={}){let t=e.id==="conversation-read"&&(e.code==="unavailable"||e.code==="retryable"),a=e.id==="conversation-unavailable"?"chat.conversationUnavailable":t?"chat.conversationReadFailed":n.answeredElsewhere?"chat.problem.answered":_nullishCoalesce(we[e.code], () => ("chat.failure")),i=ve(e);return{key:a,...i&&{action:i},code:e.code,id:e.id}}function Ue(e,n={}){if(e==="none")return{actions:[]};let t={id:"retry",labelKey:"chat.retry"};return{key:`reply.${e}`,actions:e==="overdue"?[{id:"keepWaiting",labelKey:"chat.reply.keepWaiting"},t]:e==="writing"?n.canStop?[{id:"stop",labelKey:"chat.reply.stop"}]:[]:n.canRetry===!1?[]:[t]}}exports.a = z; exports.b = W; exports.c = L; exports.d = ce; exports.e = I; exports.f = Ie; exports.g = ge; exports.h = Ee; exports.i = ve; exports.j = Ve; exports.k = Ue;
@@ -1 +0,0 @@
1
- import{l as A}from"./chunk-L4PFFRDE.js";var o=e=>`chat.recovery.${e}`,H=["alreadyClosedByWinner","alreadyKept","alreadyStoppedNeedsDecision","cancelStarted","cancelledNoChanges","capabilityMissing","currentStopped","initialTargetSettled","initialTargetStopped","intentSuperseded","keepReasonChanged","keptForwardClosed","leaveCompletedByKeep","leaveCoveredByKeep","leaveNeedsReview","leaveSafetyNeedsReview","leftKnown","leftUnconfirmed","planClosedKept","reviewTargetSettled","reviewTargetStopped","stopped","stoppedNoChanges","acknowledgmentAhead","cancelCoveredByLeaveSafety","cancelCoveredByStopNoChanges","cancelDefeatedByStop","choiceReplacedByStop","initialTargetClosed","keepDefeatedByWinner","leaveDefeatedByWinner","leaveNoDecision","leaveSafetyAlreadyStopped","reopenedEvidence"],X={...Object.fromEntries(H.map(e=>[e,o(e)])),alreadyClosed:o("alreadyClosedByWinner"),acknowledgmentStale:o("keepReasonChanged"),intentConflict:o("intentTargetChanged"),invalidTarget:o("intentTargetChanged"),intentUnavailable:o("keepReasonUnavailable"),keepBlockedActive:o("keepReasonActive"),keepBlockedUnknown:o("keepReasonUnknown"),keepBlockedReview:o("keepReasonPreview"),keepNoDecision:o("keepReasonNoSource"),planSealed:o("alreadyKept"),keptElsewhere:o("keptAlready")},x={...Object.fromEntries(["stopNotSent","stopNotSentElsewhere","stopUnconfirmed","leaveNotSent","leaveUnconfirmed","keepNotSent","keepUnconfirmed"].map(e=>[e,o(e)])),cancelInitialNotSent:o("cancelNotSent"),cancelInitialUnconfirmed:o("cancelUnconfirmed"),cancelReviewNotSent:o("reviewCancelNotSent"),cancelReviewUnconfirmed:o("reviewCancelUnconfirmed"),stopRefused:o("requestRefused"),cancelInitialRefused:o("requestRefused"),cancelReviewRefused:o("requestRefused"),leaveRefused:o("requestRefused"),keepRefused:o("requestRefused")},G=new Set(["leftUnconfirmed"]),J={leaveCompletedByKeep:o("leaveCompletedByKeep"),leaveCoveredByKeep:o("leaveCoveredByKeep"),keptElsewhere:o("keptAlready")};function z(e){let n=[],t=(r,c)=>{r&&!n.some(f=>f.key===r)&&n.push(c?{key:r,values:c}:{key:r})};for(let r of e.keys??[])t(X[r],G.has(r)&&typeof e.count=="number"?{count:e.count}:void 0);e.requestKey&&t(o(e.requestKey));let a=r=>{r!==void 0&&t(o(r?"requestedIntentApplied":"requestedIntentNotApplied"))};a(e.requestedTargetApplied);let i=e.savedDisposition;i&&t(o(i.phase==="left-known"?"leftKnown":"leftUnconfirmed"),i.phase==="left-known"?void 0:{count:i.count});let l=e.finalHistory;return l&&(l.relation&&t(J[l.relation]),l.keptFact?.keepEffect==="forward-closed"&&t(o("keptForwardClosed")),a(l.requestedTargetApplied),l.contradictedAfterSeal?.length&&t(o("laterReportAfterKeep"))),n}var Q={user:"winnerStopUser","connection-lost":"winnerStopConnection","renewal-refused":"winnerStopRenewal","step-failed":"winnerStopStep","step-up-failed":"winnerStopStepUp","identity-lost":"winnerStopIdentity","attribution-missing":"winnerStopAttribution","plan-changed":"winnerStopChanged","adapter-configuration":"winnerStopAdapter"},V={stop:4,"cancel-initial":3,"cancel-review":3,keep:2,leave:1},U={stop:"stop",decline:"cancel-initial",leave:"leave",keep:"keep"},O={stop:o("checkIntentStatus"),"cancel-initial":o("checkIntentStatus"),"cancel-review":o("checkIntentStatus"),leave:o("checkSavedChoice"),keep:o("checkKeepStatus")},Z={capabilityMissing:null,keepNoDecision:null,sealed:null,keepBlockedActive:o("keepReasonActive"),keepBlockedUnknown:o("keepReasonUnknown"),loading:o("actionLoading"),intentUnavailable:o("keepReasonUnavailable")},ee=new Set(["proposal","initial-review","cancelled"]),ne=new Set(["forward-active","readback","left-reopened","left-unconfirmed","completed","left-known"]),te=new Set(["forward-active","readback","left-reopened"]),ae=new Set(["readback","left-reopened"]),m=(e,n,t)=>t?{id:e,labelKey:n,available:!1,reasonKey:t}:{id:e,labelKey:n,available:!0};function oe(e,n){let t=T(e,n),a=t?[t]:[];return n.state==="running"&&a.push(m("stop","chat.stop")),a}function T(e,n){let t=A(n,e.conversationId);if(n.state!=="awaiting-confirmation"||!t)return;let i={...m("confirm",t.schedule?"chat.confirmation.schedule":"chat.confirmation.apply",e.now>=Date.parse(t.expiresAt)?"chat.confirmation.expired":void 0),countedLabelKey:t.schedule?"chat.confirmation.scheduleCount":"chat.confirmation.applyCount",labelValues:{count:t.items.length}};return t.schedule?{...i,schedule:!0}:i}function re(e,n){let a=n.recovery.phase,i=[],l=a==="initial-review"&&T(e,n);if(l&&i.push(l),(a==="proposal"||a==="initial-review"||a==="forward-active")&&i.push(m("stop","chat.stop")),(a==="proposal"||a==="initial-review")&&i.push(m("decline","chat.cancel")),te.has(a)&&i.push(m("leave",o("leave"),e.capabilities.includes("plan-leave")?void 0:o("capabilityMissing"))),ne.has(a)){let r=e.keepReview;if(!("disabled"in r))i.push(m("keep",o("keepChanges")));else{let c=Z[r.disabled];c&&i.push(m("keep",o("keepChanges"),c))}}if(ae.has(a))for(let r of["undoSelected","continue"])i.push(m(r,o(r),o("notAvailableYet")));return i}function D(e,n){if(!(n?.retryAt===void 0||n.lastProblem?.cause!=="rate-limited"||e.now>=n.retryAt))return{seconds:Math.ceil((n.retryAt-e.now)/1e3)}}function N(e,n,t){let a=n,i=D(e,t);if(t){let r=i?{id:"status",labelKey:O[t.kind],available:!1,reasonKey:o("retryAfterSeconds"),reasonValues:i}:{id:"status",labelKey:O[t.kind],available:!0,busy:t.delivery==="sending"},c=!1;a=a.map(f=>U[f.id]===t.kind?(c=!0,r):f),c||(a=[...a,r])}let l=[...t?[t.kind]:[],...e.pending].map(r=>V[r]);if(l.length){let r=Math.max(...l);a=a.map(c=>{if(c.id==="status")return c;let f=U[c.id],s=c.id==="confirm"?0:f?V[f]:void 0;if(s===void 0||s>r)return c;let d=f&&e.pending.includes(f);return{...c,available:!1,reasonKey:o("intentPendingReason"),...d?{busy:!0}:{}}})}return e.conversationUnavailable&&(a=a.map(r=>({...r,available:!1,reasonKey:o("refreshConversation")}))),a}function B(e,n){let t=e.recovery,a=t.steps??[],i=r=>a.filter(c=>c.truth===r).length,l=(r,c)=>c?{key:o(r),values:c}:{key:o(r)};if(t.sealed)return{label:l("keptKnown"),tone:"neutral",attention:!1};switch(t.phase){case"proposal":return{label:l("statusProposal"),tone:"neutral",attention:!1};case"initial-review":return{label:l("heading"),tone:"neutral",attention:!1};case"forward-active":return{label:l(n?.kind==="stop"?"stopping":"currentRunning"),tone:"progress",attention:!1};case"readback":case"left-reopened":return{label:l("heading"),tone:"warning",attention:!0};case"completed":return{label:l("statusCompleted"),tone:"success",attention:!1};case"cancelled":return{label:l(i("done")?"currentStopped":"cancelledNoChanges"),tone:"neutral",attention:!1};case"left-known":return{label:l("leftKnown"),tone:"neutral",attention:!1};case"left-unconfirmed":return{label:l("leftUnconfirmed",{count:i("unknown")}),tone:"warning",attention:!1}}}function W(e){let n=e.plan;if(!n)return null;let t=!!n.recovery&&e.capabilities.includes("plan-recovery");if(n.recovery&&(e.readOnly||!t||n.recovery.profile!=="plan-recovery-v1"||!B(n,void 0)))return{planId:n.id,status:{dataStatus:n.recovery.phase,wireState:n.state,label:{key:o("heading")},tone:"neutral",attention:!1},intent:null,steps:[],lines:[{key:o("updateToControl")},{key:`chat.block.state.${n.state}`}],notice:[],alert:null,actions:[],pending:[],conversationUnavailable:e.conversationUnavailable,readOnly:!0};let a=e.overlay&&e.overlay.planId===n.id?e.overlay:void 0,i=e.notice&&(e.notice.planId??n.id)===n.id?z(e.notice):[],l=e.alert,r=D(e,a),c=a?.lastProblem?.key,f=l&&a?{serial:l.serial,..."restoreFocus"in l?{restoreFocus:!0}:{action:l.action},...c&&x[c]?{message:{key:x[c]}}:{},retryAvailable:!r&&!e.conversationUnavailable,...e.conversationUnavailable?{retryReasonKey:o("refreshConversation")}:r?{retryReasonKey:o("retryAfterSeconds"),retryValues:r}:{}}:l&&"restoreFocus"in l?{serial:l.serial,restoreFocus:!0,retryAvailable:!0}:null;if(!t)return{planId:n.id,status:null,intent:null,steps:[],lines:[],notice:[],alert:null,actions:N({...e,pending:[]},oe(e,n),void 0),pending:[],conversationUnavailable:e.conversationUnavailable};let s=n.recovery,d=new Map(n.plan.kind==="immediate"?n.plan.steps.map((p,S)=>[p.id,{index:S+1,resource:p.resource}]):[]),w=new Set(s.contradictedAfterSeal??[]),h=s.phase==="forward-active",k=(s.steps??[]).map((p,S)=>({stepId:p.stepId,index:d.get(p.stepId)?.index??S+1,...d.get(p.stepId)?.resource!==void 0&&{resource:d.get(p.stepId).resource},truth:p.truth,textKey:o(p.truth==="done"?"done":p.truth==="not-done"?"notDone":h?"stepNotKnownYet":"unknown"),...s.sealed&&w.has(p.stepId)?{lateReport:"contradicted"}:{}})),y=[],v=k.filter(p=>p.truth==="unknown").length,K=k.filter(p=>p.truth==="not-done").length;!s.steps?.length&&!ee.has(s.phase)&&y.push({key:o("stepsNotKnownYet")});let b=!1;!s.sealed&&!h&&v&&(y.push({key:o("stepsUnknown"),values:{count:v}}),b=!0),!s.sealed&&s.phase==="completed"&&K&&(y.push({key:o("stepsNotDone"),values:{count:K}}),b=!0),s.sealed&&w.size&&(y.push({key:o("laterReportAfterKeep")}),b=!0);let u=s.winner;u?.kind==="stop"?(y.push({key:o(Q[u.cause])}),s.phase==="readback"&&y.push({key:o("stopped")})):u&&y.push({key:o(u.kind==="leave"?"winnerLeave":u.kind==="keep"?"winnerKeep":"winnerCancel")});let g=B(n,a);return{planId:n.id,status:{dataStatus:s.phase,wireState:n.state,label:g.label,tone:g.tone,attention:g.attention||b,...s.sealed?{result:"kept"}:{}},intent:a?{kind:a.kind,status:a.delivery}:null,steps:k,lines:y,notice:i,alert:f,actions:N(e,re(e,n),a),pending:e.pending,conversationUnavailable:e.conversationUnavailable}}function L(e,n){let t=e.review==="forward-only"?[{key:o("confirmKeepForwardOnly")},{key:o("keepRemainingSteps"),values:{count:e.remaining}}]:[{key:o("confirmEndRetention")}],a=n.conversationUnavailable?o("refreshConversation"):n.status?.result==="kept"?o("alreadyKept"):n.intent||n.pending.length?o("intentPendingReason"):void 0;return{messages:t,proceed:a?{available:!1,reasonKey:a}:{available:!0}}}import{createContext as se,useContext as ie,useSyncExternalStore as le}from"react";var ce=se(null);function R(e){let n=ie(ce),t=e??n;if(!t)throw new Error("A client is required");return t}function I(e){let n=R(e);return le(n.subscribe,n.getSnapshot,n.getSnapshot)}import{useCallback as _,useEffect as M,useState as P}from"react";function Ie(e){let n=R(e),t=I(n),a=t.plan,[i,l]=P([]),[r,c]=P(()=>Date.now()),[f,s]=P(null),d=a?.id;M(()=>{l([]),s(null)},[d]);let w=d?t.intentOverlays[d]:void 0,h=w?.retryAt;M(()=>{if(h===void 0)return;let u=h-Date.now();if(u<=0)return;let g=setTimeout(()=>c(Date.now()),u);return()=>clearTimeout(g)},[h]);let k=A(a,t.conversationId)?.expiresAt;M(()=>{if(!k)return;let u=Date.parse(k)-Date.now();if(!(u>0))return;let g=setTimeout(()=>c(Date.now()),u+1);return()=>clearTimeout(g)},[k]);let y=W({plan:a,capabilities:t.capabilities,conversationUnavailable:t.conversationUnavailable,overlay:w,notice:t.intentNotice,alert:t.intentAlert,keepReview:a?n.keepChangesReview(a.id):{disabled:"keepNoDecision"},pending:i,now:Math.max(r,Date.now()),conversationId:t.conversationId,readOnly:t.planReadOnly}),v=_((u,g)=>{l(p=>[...p,u]),g.finally(()=>l(p=>p.filter(S=>S!==u)))},[]),K=_(u=>{if(d)switch(u){case"confirm":n.confirmPlan();return;case"stop":{n.stopPlan(d);let g=n.getSnapshot();!g.planReadOnly&&!g.intentOverlays[d]&&v("stop",n.checkIntentStatus(d));return}case"decline":v("cancel-initial",n.declinePlan());return;case"leave":v("leave",n.leavePlan(d));return;case"keep":{let g=n.keepChangesReview(d);"disabled"in g||s(g);return}case"status":case"retry":n.checkIntentStatus(d);return}},[d,n,v]),b=f&&y?{...L(f,y),onProceed:()=>{let u=f;s(null),v("keep",n.keepChanges(u))},onCancel:()=>s(null)}:null;return{view:y,press:K,sheet:b}}import{useCallback as C,useSyncExternalStore as de}from"react";var q=new WeakMap,pe=e=>{let n=q.get(e);return n||q.set(e,n={cards:new Map,listeners:new Set}),n},F=(e,n,t)=>JSON.stringify([e,n,t]),E=new WeakMap,Y=e=>{E.delete(e.cards);for(let n of e.listeners)n()},ue=128,$=(e,n)=>{let t=n;for(let a=0;a<e.length;a++)t^=e.charCodeAt(a),t=Math.imul(t,16777619)>>>0;return t.toString(16).padStart(8,"0")},j=e=>$(e,2166136261)+$(e,731459039),fe=e=>JSON.stringify(e,(n,t)=>t&&typeof t=="object"&&!Array.isArray(t)?Object.fromEntries(Object.entries(t).sort(([a],[i])=>a<i?-1:1)):t),ye=e=>e.replace(/[^\w.~-]/g,n=>`%${(n.charCodeAt(0)+65536).toString(16).slice(1)}`);function ge(e,n,t,a){let i=`card:${[e,n,t].map(ye).join(":")}:${j(fe(a))}`;return i.length<=ue?i:`card~${j(i)}`}function Ee(e){let n=R(e),{conversationId:t}=I(n),a=pe(n),i=C(s=>(a.listeners.add(s),()=>a.listeners.delete(s)),[a]),l=C(()=>{let s=E.get(a.cards);s||E.set(a.cards,s=new Map);let d=s.get(t);return d||(d=new Set([...a.cards.values()].filter(w=>w.conversationId===t).map(w=>w.blockId)),s.set(t,d)),d},[a,t]),r=de(i,l,l),c=C((s,d,w="")=>{let h=F(t,w,s.id);if(a.cards.has(h))return Promise.resolve();let k={...d,blockId:typeof d.blockId=="string"?d.blockId:s.id,clientReplyId:ge(t,w,s.id,d)};a.cards.set(h,{conversationId:t,blockId:s.id}),Y(a);let y=()=>{a.cards.delete(h),Y(a)};return n.replyOutcome(k).then(v=>(v.accepted||y(),v),y)},[n,a,t]),f=C((s,d="")=>!!s.answered||a.cards.has(F(t,d,s.id)),[a,t,r]);return{answered:r,isAnswered:f,reply:c}}var we={"sign-in":"chat.problem.signIn",retryable:"chat.problem.retryable","rate-limited":"chat.problem.rateLimited",refused:"chat.problem.refused",closed:"chat.problem.closed",full:"chat.problem.full",declined:"chat.problem.declined",unavailable:"chat.problem.unavailable","step-up-cancelled":"chat.problem.stepUp","invalid-read":"chat.problem.invalid","invalid-plan":"chat.problem.invalid","plan-changed":"chat.planChanged","update-required":"chat.update",mismatch:"chat.problem.mismatch","agreement-expired":"chat.problem.agreement","in-doubt":"chat.problem.inDoubt",replaced:"chat.problem.replaced","needs-attention":"chat.problem.needsAttention",stopped:"chat.stopped"},ve=e=>e.code==="replaced"?"refresh":["retryable","rate-limited","unavailable","agreement-expired"].includes(e.code)?"retry":void 0;function Ve(e,n={}){let t=e.id==="conversation-read"&&(e.code==="unavailable"||e.code==="retryable"),a=e.id==="conversation-unavailable"?"chat.conversationUnavailable":t?"chat.conversationReadFailed":n.answeredElsewhere?"chat.problem.answered":we[e.code]??"chat.failure",i=ve(e);return{key:a,...i&&{action:i},code:e.code,id:e.id}}function Ue(e,n={}){if(e==="none")return{actions:[]};let t={id:"retry",labelKey:"chat.retry"};return{key:`reply.${e}`,actions:e==="overdue"?[{id:"keepWaiting",labelKey:"chat.reply.keepWaiting"},t]:e==="writing"?n.canStop?[{id:"stop",labelKey:"chat.reply.stop"}]:[]:n.canRetry===!1?[]:[t]}}export{z as a,W as b,L as c,ce as d,I as e,Ie as f,ge as g,Ee as h,ve as i,Ve as j,Ue as k};
@@ -1 +0,0 @@
1
- import{a as Ge}from"./chunk-FQSWQLRW.js";import{a as Rn,b as Fn}from"./chunk-OWT55N6J.js";import{d as On,e as Me,f as wt,g as Bn,h as Hn,i as kt,j as Un}from"./chunk-RHBDQGD4.js";import{a as Nn,b as Dn,c as An}from"./chunk-RZZDQWC2.js";import{b as Ln,c as In}from"./chunk-M63QOANE.js";import{f as Te,l as yt}from"./chunk-L4PFFRDE.js";import{useLayoutEffect as $n,useRef as Wn}from"react";var Xe=new WeakMap;function V(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t}function O(e,t){let n=t;for(;n;){if(n===e)return!0;n=n.parentNode??(n instanceof ShadowRoot?n.host:null)}return!1}function ve(e){return e.composedPath?.()[0]??e.target}var Ct=new WeakMap,Kr=0;function Kn(e){let t=new Set,n=[],o=a=>{t.has(a)||a.hasAttribute("inert")||(a.setAttribute("inert",e.mark),e.set.push(a))};for(let a=e.drawer;;){t.add(a);let l=a instanceof Element?a.assignedSlot:null;l&&a.parentNode&&n.push(a.parentNode);let c=l??a.parentNode;if(!c||c.nodeType===Node.DOCUMENT_NODE)break;n.push(c),a=c instanceof ShadowRoot?c.host:c}for(let a of n)for(let l of a.children)o(l);if(typeof MutationObserver=="function"){e.watch=new MutationObserver(a=>{for(let l of a)for(let c of l.addedNodes)c instanceof Element&&o(c)});for(let a of n)e.watch.observe(a,{childList:!0})}}function qn(e){e.watch?.disconnect(),e.watch=void 0;for(let t of e.set)t.getAttribute("inert")===e.mark&&t.removeAttribute("inert");e.set=[]}function Et(e){let t=e.ownerDocument,n=Ct.get(t)??[];Ct.set(t,n);let o=n.at(-1);o&&qn(o);let a={drawer:e.closest("[data-wp-modal-root]")??e,mark:`waypoint-${++Kr}`,set:[]};return n.push(a),Kn(a),()=>{let l=n.indexOf(a);if(l<0)return;qn(a),n.splice(l,1);let c=n.at(-1);l===n.length&&c&&Kn(c)}}var qr='a[href], button, input, select, textarea, summary, iframe, [tabindex], [contenteditable]:not([contenteditable="false"])';function oe(e){return e instanceof HTMLElement&&e.isConnected&&e.matches(qr)&&!e.matches('input[type="hidden"], :disabled')&&!e.closest("[hidden], [inert]")&&(typeof e.checkVisibility!="function"||e.checkVisibility({visibilityProperty:!0}))}function zr(e,t){for(let n=e;n;){if(n instanceof Element&&oe(n))return n;if(n===t)return null;n=n.parentNode??(n instanceof ShadowRoot?n.host:null)}return null}function jr(e){return O(e,V(e.ownerDocument))}var xt=e=>{let t=V(e);return!t||t===e.body};function ye(e){let t=Xe.get(e);if(t)return t;let n={origins:new Set,last:null};return t=n,Xe.set(e,n),e.addEventListener("focusin",o=>{let a=ve(o);n.last=a,n.disabled=null;for(let l of n.origins)!O(l.root,a)&&!l.owned.some(c=>O(c,a))&&(l.valid=!1,n.origins.delete(l))},!0),e.addEventListener("focusout",o=>{let a=ve(o);o.relatedTarget||queueMicrotask(()=>{if(!a?.isConnected||!xt(e))return;if(a.matches(":disabled"))return void(n.disabled=a);let l=Ct.get(e)?.at(-1)?.drawer;if(!(l&&O(l,a))){n.last=null;for(let c of n.origins)c.valid=!1;n.origins.clear()}})},!0),e.addEventListener("pointerdown",()=>{n.last&&!n.last.isConnected&&xt(e)&&(n.last=null)},!0),n}function ce(e){e&&(e.valid=!1,Xe.get(e.root.ownerDocument)?.origins.delete(e))}function Vn(e){let t=Xe.get(e.ownerDocument);if(t)for(let n of t.origins)O(e,n.root)&&ce(n)}function St(e){ye(e)}function Tt(e,t,n,o){let a="nativeEvent"in e?e.nativeEvent:e,l=ve(a);if(!O(t,l))return;let c={owner:n,action:o,root:t,control:zr(l,t)??l,owned:[],valid:!0};return ye(t.ownerDocument).origins.add(c),c}var _n=new WeakMap;function Gn(e){let t=V(e.ownerDocument);t&&O(e,t)&&(ye(e.ownerDocument).last=t,_n.set(e,t))}function Pt(e,t){if(!e)return!1;let{last:n}=ye(t);return!!n&&(O(e,n)||_n.get(e)===n)&&(!n.isConnected||n===ye(t).disabled)&&xt(t)}function X(e,t){let{root:n,origin:o,removed:a}=t;if(!e||!e.isConnected)return!1;let l=n.ownerDocument;if(ye(l),t.stillCurrent&&!t.stillCurrent()||!(o?o.valid&&o.owner===t.owner&&(jr(n)||Pt(a??o.control,l)):Pt(a,l)||t.enterModal===!0&&e===n&&e.matches(In)))return!1;e.focus({preventScroll:t.preventScroll??!1});let s=V(l)===e;return s?ye(l).last=e:t.missed?.(),s}var zn=new WeakMap,jn=e=>{let t=zn.get(e);return t||zn.set(e,t=new Set),t};function Mt(e){let t=Wn(null),n=Wn({});return $n(()=>{St(document);let o=jn(document),a=n.current;return()=>{o.delete(a)}},[]),$n(()=>{let o=jn(document),a=t.current;if(!a||a.isConnected)return void o.delete(n.current);if(!Pt(a,document))return t.current=null,void o.delete(n.current);let l=e().find(c=>c?.isConnected);if(!(l instanceof HTMLElement))return void o.add(n.current);t.current=null,o.delete(n.current),X(l,{root:l,owner:"",removed:a})}),o=>{t.current=o.target}}import{createContext as Vr,useContext as _r,useEffect as Rt,useMemo as Ft,useRef as Y,useState as Gr}from"react";import{jsx as Qr}from"react/jsx-runtime";var Lt=Vr(null),Ae=()=>_r(Lt),Xn=new WeakMap,Xr=0;function Re(e,t){let n=Xn.get(e);return n===void 0&&Xn.set(e,n=++Xr),`${n}:${t}`}function Yn(e,t,n,o,a=l=>l){let l=Y(null),c=Y(t);c.current=t;let s=Y(a);s.current=a,Rt(()=>{let u=e.current;if(u)return St(u.ownerDocument),()=>Vn(u)},[e]);let h=Ft(()=>({root:()=>e.current,owner:()=>c.current,ownerOf:u=>s.current(u),originFor(u,p){let f=l.current,M=e.current;return f&&M?Tt(f,M,p??c.current,u):void 0},composer:()=>n.current,transcript:()=>o.current}),[e,n,o,t]),b=u=>{let p=u.nativeEvent;l.current=p,Zn(()=>{l.current===p&&(l.current=null)})};return{value:h,captureProps:{onClickCapture:b,onKeyDownCapture:b,onPointerDownCapture:b}}}function It(e,t,n){let[o,a]=Gr({active:e,conversationId:t});o.active!==e&&a({active:e,conversationId:t});let l=e&&o.active&&o.conversationId!==t,c=Y(n);return c.current=n,Rt(()=>{l&&c.current()},[l]),l}var Zn=e=>setTimeout(e,0);function Yr(e){return!!e?.closest('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 Jn(e){if(!e)return!1;let t=V(e.ownerDocument);return O(e,t)&&!Yr(t)}function ee(e,t,n){let{origin:o,removed:a,fallback:l}=n,c=e?.root(),s=(u,p)=>!!c&&(!!o||!!a)&&X(u,{root:c,origin:o,removed:a,owner:n.owner,stillCurrent:n.stillCurrent,preventScroll:!0,missed:p}),h=!1,b=s(t,()=>h=!0);return!b&&h&&l&&l!==t&&(b=s(l)),(!n.keep||!b)&&ce(o),b}function Nt(e,t,n,o){t.current?.element!==e&&(t.current={element:e,opener:V(e.ownerDocument)}),o?.(),X(e,{root:e,owner:"",enterModal:!0,stillCurrent:n})}function Dt(e,t,n){let o=e.current;o&&queueMicrotask(()=>{if(e.current!==o)return;let a=n?.(),l=oe(o.opener)?o.opener:a,c={root:o.element,owner:"",removed:o.element,stillCurrent:t,preventScroll:!0};X(l,{...c,missed:()=>{a!==l&&X(a,c)}}),o.element.isConnected||(e.current=void 0)})}function At({as:e,focusInto:t,restoreFocus:n,...o}){let a=Y(void 0),l=Y(void 0);return Rt(()=>()=>{a.current?.(),a.current=void 0},[]),Qr(e,{...o,focusInto:c=>{if(a.current?.(),t){let s=!1,h=()=>{a.current=Et(c),s=!0};t(c,h),s||h()}else Nt(c,l,void 0,()=>{a.current=Et(c)})},restoreFocus:c=>{Gn(c),a.current?.(),a.current=void 0,n?n(c):Dt(l)}})}function Ot(e,t,n){let o=Ae(),a=Y(void 0),l=Y(void 0),c=Y(t);c.current=t;let s=Y(n);return s.current=n,Ft(()=>o?{focusInto(h,b){let u=o.owner(),p=o.originFor(`drawer:${e}`,u);if(a.current={origin:p,key:u},!p){Nt(h,l,()=>o.owner()===u&&(c.current?.()??!0),b);return}l.current=void 0,ee(o,h,{origin:p,owner:u,stillCurrent:()=>o.owner()===u&&(c.current?.()??!0),keep:!0})},restoreFocus(h){let b=a.current;if(a.current=void 0,!b)return;if(!b.origin){Dt(l,()=>o.owner()===b.key,()=>{let p=s.current?.();return oe(p??null)?p:o.transcript()});return}let u={origin:b.origin,key:b.key};queueMicrotask(()=>Zr(o,h,u,s.current?.()))},release(){let h=a.current;a.current=void 0,ce(h?.origin)}}:{},[o,e])}function Zr(e,t,n,o){let a=V(t.ownerDocument);if(!O(t,a)&&a&&a!==t.ownerDocument.body)return ce(n.origin);let l=n.origin.control,c=oe(o??null)?o:e.transcript(),s=oe(l)?l:c;ee(e,s,{origin:n.origin,owner:n.key,stillCurrent:()=>e.owner()===n.key,removed:t,fallback:c})}var Ye=null;function Zo(e,t,n){let o=Tt(e.nativeEvent,t,"form-field","open");if(!o)return n?.();let a={origin:o,claimed:!1,settled:n};Ye=a,Zn(()=>{Ye===a&&(Ye=null),a.claimed||(ce(o),a.settled?.())})}function Jo(){let e=Y(void 0),t=Y(void 0);return Ft(()=>({focusInto(n){let o=Ye??void 0;if(e.current=o,!o){Nt(n,t);return}t.current=void 0;let a=o.origin;o.claimed=!0,a.owned.push(n),X(n,{root:a.root,origin:a,owner:a.owner,preventScroll:!0})},restoreFocus(n){let o=e.current;if(e.current=void 0,!o){Dt(t);return}queueMicrotask(()=>{Jr(n,o.origin),o.settled?.()})}}),[])}function Jr(e,t){let n=[...t.root.querySelectorAll("*")].find(oe),o={root:e,origin:t,removed:e,owner:t.owner,preventScroll:!0},a=!oe(t.control);a||X(t.control,{...o,missed:()=>a=!0}),a&&n&&n!==t.control&&X(n,o),ce(t)}import{useEffect as qo,useState as $e,useSyncExternalStore as zo}from"react";import{createContext as Zt,useContext as _,useEffect as ae,useLayoutEffect as ke,useMemo as Jt,useRef as S,useState as K,useId as Ue,useSyncExternalStore as vo,lazy as yo,Suspense as wo,Component as ko}from"react";var eo=/[‪-‮⁦-⁩]/g;function Bt(e,t=120){let n=e.replace(eo,"").replace(/\s+/g," ").trim();if(!n||typeof Intl.Segmenter!="function")return;let o=[];for(let a of new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(n)){if(o.length===t)return`${o.join("")}\u2026`;o.push(a.segment)}return n}var Ze=class{owner;policy=[];byId=new Map;begin(t,n,o){if(t!==this.owner||n.length!==this.policy.length||n.some((l,c)=>l!==this.policy[c])){this.owner=t,this.policy=n,this.byId=new Map;return}if(!this.byId.size)return;let a=new Map(o.map(l=>[l.id,l.source]));for(let[l,c]of this.byId)(!a.has(l)||a.get(l)!==c.source)&&this.byId.delete(l)}get(t,n,o){let a=this.byId.get(t);if(a&&a.source===n)return a.value;let l=o(n);return this.byId.set(t,{source:n,value:l}),l}entries(){return[...this.byId].map(([t,n])=>({id:t,source:n.source}))}};import{useLayoutEffect as Qn,useRef as er,useState as to}from"react";var tr=24,Ht=150,no=100,ro=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "]),oo="[data-message-id]",Fe=e=>Math.max(0,e.scrollHeight-e.clientHeight),nr=e=>e.scrollHeight-e.clientHeight-e.scrollTop,Je=()=>performance.now(),ao=e=>typeof requestAnimationFrame=="function"?requestAnimationFrame(e):setTimeout(e,16),Ut=e=>[...e.querySelectorAll(oo)].filter(t=>t.closest(".wp-transcript")===e),Qe=e=>e.getAttribute("data-message-id");function rr(e,t,n,o,a){let[l,c]=to(!0),s=er({pinned:!0,token:void 0,expected:[],lastTop:0,sizeFrame:!1,anchor:void 0,shown:void 0}).current,h=m=>{s.pinned=m,c(m)},b=()=>{clearTimeout(s.token?.timer),s.token=void 0},u=(m,P)=>{let C=Math.min(Math.max(0,P),Fe(m));s.expected.push({top:C,at:Je()}),typeof m.scrollTo=="function"?m.scrollTo({top:C,behavior:"instant"}):m.scrollTop=C,s.lastTop=m.scrollTop},p=m=>{let P=m.getBoundingClientRect().top,C=Ut(m),L=C.find(E=>E.getBoundingClientRect().bottom>P+.5);s.anchor=L&&{id:Qe(L),offset:L.getBoundingClientRect().top-P,order:C.map(Qe)}},f=m=>{let P=s.anchor;if(!P)return p(m);let C=new Map(Ut(m).map(R=>[Qe(R),R])),L=P.order.indexOf(P.id),E=C.get(P.id)??P.order.slice(L+1).map(R=>C.get(R)).find(Boolean)??P.order.slice(0,Math.max(0,L)).reverse().map(R=>C.get(R)).find(Boolean);if(!E)u(m,0);else{let R=E.getBoundingClientRect().top-m.getBoundingClientRect().top-P.offset;Math.abs(R)>.5&&u(m,m.scrollTop+R)}p(m)},M=()=>{let m=e.current;m&&(s.token&&!s.token.used&&!s.token.held&&b(),s.pinned?nr(m)>.5&&u(m,Fe(m)):f(m))},d=er(M);return d.current=M,Qn(()=>{let m=o===0;(n!==s.shown||m)&&(s.shown=n,s.anchor=void 0,b(),s.pinned||h(!0)),M()},[a,n,o]),Qn(()=>{let m=e.current;if(!m)return;let P=m.ownerDocument,C=v=>{clearTimeout(v.timer);let y=()=>{if(s.token!==v||v.held)return;let k=Je()-Math.max(v.lastInput,v.lastScroll);k>=Ht?s.token=void 0:v.timer=setTimeout(y,Ht-k)};v.timer=setTimeout(y,Ht)},L=v=>{let y=s.token??={used:!1,held:!1,lastInput:0,lastScroll:0};y.lastInput=Je(),v&&(y.held=!0),C(y)},E=()=>{let v=s.token;v?.held&&(v.held=!1,C(v))},R=()=>L(),N=()=>L(!0),W=v=>{ro.has(v.key)&&O(m,V(P))&&L()},se=()=>{let v=m.scrollTop,y=s.lastTop;s.lastTop=v;let k=Je();s.expected=s.expected.filter(Ce=>k-Ce.at<no);let q=s.expected.findIndex(Ce=>Math.abs(Ce.top-v)<=1),ie=s.token,D=Fe(m),le=Math.abs(v-D)<=1&&y>D+.5,he=q>=0||!ie||le||s.sizeFrame&&Math.abs(v-D)<=1;q>=0&&s.expected.splice(0,q+1),he||(ie.used=!0,ie.lastScroll=k,C(ie),v<y-.5?h(!1):v>y+.5&&nr(m)<=tr&&!s.pinned&&h(!0)),s.pinned||p(m)};m.addEventListener("wheel",R,{passive:!0}),m.addEventListener("touchstart",N,{passive:!0}),m.addEventListener("touchmove",R,{passive:!0}),m.addEventListener("pointerdown",N),m.addEventListener("keydown",W),m.addEventListener("scroll",se,{passive:!0});for(let v of["pointerup","pointercancel","touchend","touchcancel"])P.addEventListener(v,E,!0);let w=typeof ResizeObserver=="function"?new ResizeObserver(()=>{s.sizeFrame=!0,ao(()=>s.sizeFrame=!1),d.current()}):void 0;return w?.observe(m),t.current&&w?.observe(t.current),()=>{m.removeEventListener("wheel",R),m.removeEventListener("touchstart",N),m.removeEventListener("touchmove",R),m.removeEventListener("pointerdown",N),m.removeEventListener("keydown",W),m.removeEventListener("scroll",se);for(let v of["pointerup","pointercancel","touchend","touchcancel"])P.removeEventListener(v,E,!0);w?.disconnect(),b()}},[e,t]),{pinned:l,toLatest(){let m=e.current;m&&(b(),u(m,Fe(m)),h(!0))},toMessage(m){let P=e.current,C=P&&Ut(P).find(R=>Qe(R)===m);if(!P||!C)return;b();let L=Math.min(Fe(P),P.scrollTop+C.getBoundingClientRect().top-P.getBoundingClientRect().top);u(P,L);let E=Fe(P)-L<=tr;return h(E),E||p(P),C}}}import{useEffect as Wt,useRef as Kt,useState as ar}from"react";var so=1e3,io=e=>`\u2068${e}\u2069`,sr=()=>typeof requestAnimationFrame=="function",lo=e=>sr()?requestAnimationFrame(e):setTimeout(e,16),$t=e=>{sr()?cancelAnimationFrame(e):clearTimeout(e)};function or(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 ir(e,t,n,o,a){let[l,c]=ar(""),s=Kt({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,h=Kt({conversation:t,excerptOf:n,t:o});h.current={conversation:t,excerptOf:n,t:o};let b=(f,M)=>{let d=s.announced.get(f),m=!!d&&(d.has("completed")||d.has("failed"));return M==="arrived"?!m&&!d?.has("arrived")&&!s.writing.has(f):!m},u=()=>{s.timer=void 0;let f=[...s.pending],M=s.batchFor,d=s.batchShowing;s.pending.clear(),s.frame!==void 0&&$t(s.frame),c(""),s.frame=lo(()=>{s.frame=void 0,d===s.showing&&p(f,M)})},p=(f,M)=>{let d=a?.current;if(d?.closest("[inert]")){for(let[y,k]of f)s.pending.set(y,k);s.held??=new MutationObserver(()=>{d.closest("[inert]")||(s.held?.disconnect(),s.held=void 0,u())}),s.held.observe(d.ownerDocument.documentElement,{attributes:!0,attributeFilter:["inert"],subtree:!0});return}let{conversation:m,excerptOf:P,t:C}=h.current;if(!m||m.id!==M)return;let L=new Map(m.messages.map(y=>[y.id,y])),E=f.flatMap(([y])=>{let k=L.get(y),q=k&&or(k);return k&&q&&b(y,q)?[{id:y,stage:q,message:k}]:[]});if(!E.length)return;let R=new Map(m.messages.map((y,k)=>[y.id,k]));E.sort((y,k)=>R.get(y.id)-R.get(k.id));let N=E.length,W=E.filter(y=>y.stage==="failed").length,se=E.filter(y=>y.stage==="completed"),w=y=>{let k=P(y);return k===void 0?void 0:io(k)},v;if(N===1){let[y]=E,k=y.stage==="completed"?w(y.message):void 0;v=y.stage==="failed"?C("chat.arrivalFailed"):k!==void 0?C("chat.arrivalExcerpt",{excerpt:k}):C("chat.arrival")}else if(se.length===N){let y=w(se.at(-1).message);v=y!==void 0?C("chat.arrivalMany",{count:N,excerpt:y}):C("chat.arrivalManyPlain",{count:N})}else W===N?v=C("chat.arrivalAllFailed",{count:N}):W?v=C("chat.arrivalManyFailed",{count:N,failed:W}):v=C("chat.arrivalManyPlain",{count:N});for(let y of E){let k=s.announced.get(y.id)??new Set;k.add(y.stage),s.announced.set(y.id,k)}c(v)};return Wt(()=>{if(s.client!==e&&(s.client=e,s.baselineFor=void 0),!t){s.baselineFor=void 0;return}if(s.baselineFor!==t.id){s.baselineFor=t.id,s.showing++,s.baseline=new Set(t.messages.map(f=>f.id)),s.announced.clear(),s.writing.clear(),s.pending.clear(),clearTimeout(s.timer),s.timer=void 0,s.frame!==void 0&&$t(s.frame),s.frame=void 0;return}for(let f of t.messages){if(s.baseline.has(f.id))continue;f.status==="writing"&&s.writing.add(f.id);let M=or(f);!M||!b(f.id,M)||(s.pending.size||(s.batchFor=t.id,s.batchShowing=s.showing),s.pending.set(f.id,M))}s.pending.size&&s.timer===void 0&&(s.timer=setTimeout(u,so))},[e,t]),Wt(()=>()=>{clearTimeout(s.timer),s.frame!==void 0&&$t(s.frame),s.held?.disconnect()},[s]),l}function lr(e,t){let[n,o]=ar(!1),a=Kt(e);return Wt(()=>{let l=t.current;if(!l||typeof MutationObserver!="function")return;let c=()=>o(!!l.closest("[inert]"));c();let s=new MutationObserver(c);return s.observe(l.ownerDocument.documentElement,{attributes:!0,attributeFilter:["inert"],subtree:!0}),()=>s.disconnect()},[t]),n||(a.current=e),a.current}var co={"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.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"},et={en:{},zh:{}};function cr(e,t){Object.assign(et.en,e),Object.assign(et.zh,t)}var uo={"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.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"},fo=/^(tw|hk|mo)$/,po=/^(zh|cmn)$/,mo=/^([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})+)?$/,ho=/^zh-(hakka|min|xiang)\b/;function qt(e="en"){let t={catalogue:"en",lang:"en"},n=e.toLowerCase();if(!mo.test(n)||ho.test(n))return t;let o=n.split("-"),a=o[0],l=1;for(;/^[a-z]{3}$/.test(o[l]);)a=o[l++];if(po.test(a)){let c=o[l];return(/^[a-z]{4}$/.test(c)?c==="hans":!fo.test(c))?{catalogue:"zh",lang:e}:t}return a==="en"?{catalogue:"en",lang:e}:t}function Oe(e="en"){let t=qt(e),n=t.catalogue==="zh",o=n?uo:co,a=n?et.zh:et.en,l=Fn(t.lang,n),c=new Map;return(s,h)=>{let b=c.get(s);if(!b){let u=o[s]??a[s];if(u===void 0)return"";b=new Rn(u,l),c.set(s,b)}return String(b.format(h))}}import{useSyncExternalStore as go}from"react";var zt=new Set,bo=e=>(zt.add(e),()=>zt.delete(e));function we(e){let t=o=>{n.load=o;for(let a of zt)a()},n={load:{status:"idle"},request(o){let{status:a}=n.load;a!=="idle"&&!(o&&a==="failed")||(t({status:"loading",...a==="failed"&&{retrying:!0}}),e().then(l=>t({status:"ready",module:l}),()=>t({status:"failed"})))}};return n}function pe(e){return go(bo,()=>e.load,()=>e.load)}import{Fragment as tn,jsx as i,jsxs as x}from"react/jsx-runtime";var tt=we(()=>import("./markdown-ETLB66BK.js")),Qt=Zt(null),kr=Zt(void 0);function Co({id:e}){let t=_(Qt);return ae(()=>(t?.report(e,!0),()=>t?.report(e,!1)),[t,e]),null}function xo(){let e=pe(tt);return e.status==="ready"?e.module:void 0}var Be=e=>`wp${Ue().replace(/[^\w-]/g,"")}-${e}`,jt=we(()=>import("./recovery-panel-VOKVDDZD.js")),Po=yo(()=>import("./confirmation-view-CICNJJIO.js")),Gt=we(()=>import("./blocks-UJ7GUJHD.js")),dr=we(()=>import("./reply-controls-5CWIAKIG.js"));function Eo(e){let t=pe(dr);return ae(()=>dr.request(),[]),t.status==="ready"?i(t.module.ReplyControls,{...e}):null}var ur=we(()=>import("./message-actions-3HGE6VTS.js"));function So(e){let t=pe(ur);return ae(()=>ur.request(),[]),t.status==="ready"?i(t.module.MessageActions,{...e}):null}var Vt=we(()=>import("./flows-panel-YEJ36RTY.js"));function en(){let e=pe(Gt);return ae(()=>Gt.request(),[]),e}function To({block:e}){let t=en();return t.status==="ready"?i(t.module.Answered,{block:e}):null}function Mo(e){let{format:t}=U(),n=en(),o=i("p",{children:e.block.fallback});if(n.status==="failed")return o;if(n.status!=="ready")return i("p",{children:t("chat.messageLoading")});let a=n.module.default;return i(He,{resetKey:e.block.id,fallback:o,children:i(a,{...e})})}var te=Zt(null);function Ro({children:e,onPress:t,disabled:n,label:o,...a}){return i("button",{type:"button",onClick:t,disabled:n,"aria-label":o,...a,children:e})}function Fo({value:e,onChange:t,label:n,inputRef:o,onKeyDown:a,disabled:l,describedBy:c}){return i("textarea",{ref:o,disabled:l,value:e,onChange:s=>t?.(s.target.value),"aria-label":n,"aria-describedby":c,onKeyDown:a})}function fr({value:e,onChange:t,label:n,type:o="text",disabled:a,invalid:l,describedBy:c,required:s}){return x("label",{children:[n,i("input",{type:o,value:e,disabled:a,"aria-invalid":l,"aria-describedby":c,"aria-required":s||void 0,onChange:h=>t(h.target.value)})]})}function Lo({checked:e,onChange:t,label:n,disabled:o,invalid:a,describedBy:l}){return x("label",{className:"wp-check",children:[i("input",{type:"checkbox",checked:e,disabled:o,"aria-invalid":a,"aria-describedby":l,onChange:c=>t(c.target.checked)}),n]})}function Io({children:e,open:t,label:n,onClose:o,closeLabel:a,focusInto:l,restoreFocus:c}){let s=_(te)?.format??Oe(),h=S(null),b=S(l),u=S(c);b.current=l,u.current=c,ke(()=>{let f=h.current;if(!(!t||!f))return b.current?.(f),()=>u.current?.(f)},[t]);let p=Ue();return t?x("div",{ref:h,className:"wp-drawer",tabIndex:-1,role:"dialog","aria-modal":"true","aria-labelledby":p,onKeyDown:f=>{f.key==="Escape"&&o()},children:[x("div",{className:"wp-drawer-header",children:[i("h2",{id:p,children:n}),i("button",{type:"button",onClick:o,"aria-label":a??s("chat.close"),children:i("span",{"aria-hidden":"true",children:"\xD7"})})]}),i("div",{className:"wp-drawer-body",children:e})]}):null}var Cr={button:Ro,textarea:Fo,input:fr,checkbox:Lo,datePicker:e=>i(fr,{...e,type:"datetime-local"}),drawer:Io},pr="(prefers-color-scheme: dark)";function No(){return vo(e=>{let t=globalThis.matchMedia?.(pr);return t?.addEventListener("change",e),()=>t?.removeEventListener("change",e)},()=>globalThis.matchMedia?.(pr).matches?"dark":"light",()=>"light")}function Do(e){let t=e.useThemeTokens?.(),n=e.theme===void 0&&t&&(e.colorScheme===void 0||e.colorScheme===t.scheme)?"host":"waypoint",o=No(),a=e.colorScheme??t?.scheme??o,l=Jt(()=>({...e,colorScheme:a,format:e.format??Oe(e.locale),lang:e.format?e.locale??"en":qt(e.locale).lang,tokens:{...a==="dark"?Dn:Nn,...n==="host"?t.tokens:e.theme},primitives:{...Cr,...e.primitives}}),[e,a,n,t]),c=e.wrapper,s=i(On.Provider,{value:e.client,children:i(te.Provider,{value:l,children:e.children})});return c?i(c,{colorScheme:a,tokens:l.tokens,tokenSource:n,children:s}):s}function Ia(){return _(te)?.colorScheme??"light"}function U(){let e=_(te);if(!e)throw new Error("WaypointProvider is required");return e}function Na(){return U().client}function Da(e){let t=_(te),n=e??t?.client,o=Me(e);return{conversationId:o.conversationId,conversation:o.conversation,refresh:n.refresh,editMessage:n.editMessage,regenerate:n.regenerate,selectVersion:n.selectVersion,switchConversation:n.switchConversation}}function Aa(e){let t=_(te),n=e??t?.client,o=Me(e);return{draft:o.draft,sending:o.sending,hints:o.hints,setDraft:n.setDraft,send:n.send,retry:n.retry,withdraw:n.withdraw,dismiss:n.dismiss}}function Oa(e){let t=_(te),n=e??t?.client,o=Me(e),{view:a}=wt(e);return{plan:o.plan,setPlan:n.setPlan,reply:n.reply,view:a}}function Ba(e){let t=_(te),n=e??t?.client,o=Me(e);return{flows:o.flows,tab:o.flowTab,load:n.loadFlows,select:n.selectFlowTab,setFavourite:n.setFavourite,run:n.runFlow}}var Ha=["bubble","composer","transcript","replyRow","stepRow","planNode","widgetFrame","confirmBar","confirmation","topBar","rail","flowTabs","quotaStrip","failedSendControls","emptyState","messageActions","extraPanels","actionBar","stepUpPrompt","fieldAdornment","recoveryPanel","stepStatusRow","recoveryActions"];function xr({action:e,onPress:t,label:n}){let{format:o,primitives:a}=U(),l=a.button,c=Ue();return x(tn,{children:[i(l,{"data-action":e.id,"aria-disabled":e.available?void 0:!0,"aria-describedby":e.reasonKey?c:void 0,"aria-busy":e.busy?!0:void 0,onPress:e.available?()=>t(e.id):void 0,children:n??(e.countedLabelKey&&e.labelValues?o(e.countedLabelKey,e.labelValues):o(e.labelKey))}),e.reasonKey?i("span",{id:c,"data-reason":e.id,children:o(e.reasonKey,e.reasonValues)}):null]})}function mr(e){let t=S(!1),[n,o]=K(!1),a=()=>{t.current=!1,o(!1)};return{busy:n,press:()=>{t.current||(t.current=!0,o(!0),e().then(a,a))}}}function hr({problem:e,refresh:t}){let n=kt(e),o=Jt(()=>Date.now()+(e.retryAfter??0)*1e3,[e]),[a,l]=K(0),c=e.code==="rate-limited"&&Date.now()<o;return ae(()=>{if(!c)return;let s=setTimeout(()=>l(h=>h+1),Math.max(o-Date.now(),1));return()=>clearTimeout(s)},[c,o,a]),n?i(xr,{action:{id:"status",labelKey:n==="retry"?"chat.retry":"chat.problem.refresh",available:!c&&!t.busy,busy:t.busy,...c&&{reasonKey:"chat.problem.rateLimited"}},onPress:t.press}):null}function gr({problem:e}){let{format:t}=U();return t("chat.problem.details")?x("details",{"data-problem-details":"",children:[i("summary",{children:t("chat.problem.details")}),i("p",{children:t("chat.problem.code",{code:e.code})}),i("p",{children:t("chat.problem.reference",{id:e.id})})]}):null}var nt=e=>e.status==="loading"&&!!e.retrying;function Xt(e){let{format:t,primitives:n}=U(),o=e.retrying||void 0;return x(tn,{children:[x("p",{role:"alert",onFocus:e.onFocus,children:[t("chat.failure")," ",i(n.button,{"aria-disabled":o,"aria-busy":o,onPress:()=>{o||e.onRetry()},children:t("chat.retry")})]}),i("span",{role:"status",children:o?t("chat.loading"):""})]})}function Ao(e){let{format:t}=U(),n=pe(jt);ae(()=>jt.request(),[]);let o=S(null),a=Mt(()=>[o.current?.querySelector("h3")]),l=n.status==="ready"&&n.module.default;return i("div",{ref:o,tabIndex:-1,"data-recovery":"",children:l?i(l,{...e}):n.status==="failed"||nt(n)?i(Xt,{retrying:nt(n),onRetry:()=>jt.request(!0),onFocus:a}):i("p",{children:t("chat.loading")})})}function br(e){return{id:e.id,type:e.type,answered:!!e.answered}}function vr(e){return{id:e.id,content:e.content,failure:e.failure?{code:e.failure.code}:null}}function B({name:e,slots:t,children:n,...o}){let l=_(te)?.parts?.[e],c=t?.[e],s=c?c({...o,children:n}):l?i(l,{...o,children:n}):n;return i("div",{"data-part":e,children:s})}var He=class extends ko{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}};function Oo({text:e,writing:t,sources:n}){let o=U(),a=o.format,l=_(Qt),c=Ue(),s=_(kr)??c,h=l?i(Co,{id:s}):i("p",{children:a("chat.messageUnavailable")}),b=pe(tt);if(ae(()=>{tt.request(!0)},[e]),b.status==="failed")return h;if(b.status!=="ready")return i("p",{children:a("chat.messageLoading")});let u=b.module.default;return i(He,{resetKey:`${e}:${l?.retry??0}`,fallback:h,children:i(u,{text:e,writing:t,lang:o.lang,sources:n,sourceNames:{list:p=>a("chat.sources",{count:p}),item:(p,f)=>a("chat.source",{index:p,title:f})},images:o.markdownImages,extraSchemes:o.extraUrlSchemes,scrollLabel:a("chat.scrollRegion")})})}function Pr(e){let t=U().renderers?.markdown;return t?i(t,{text:e.text}):i(Oo,{...e})}function Bo(e,t){return{text:t(Un(e).key)||t("chat.failure")}}function Ho({block:e,onReply:t,disabled:n}){let{format:o,primitives:a,extraUrlSchemes:l}=U(),c=a.button,s=e.body;switch(e.type){case"form.fill":case"table":case"diff":case"form":case"choice":case"plan":return i(Mo,{block:e,onReply:t,disabled:n});case"markdown":return i(Pr,{text:String(s.text??"")});case"notice":return i("p",{children:String(s.text??"")});case"card":return x("section",{children:[i("h3",{children:String(s.title??"")}),(s.blocks??[]).map(h=>i(Yt,{block:h,disabled:n,onReply:t},h.id))]});case"details":return x("details",{children:[i("summary",{children:String(s.summary??"")}),(s.blocks??[]).map(h=>i(Yt,{block:h,disabled:n,onReply:t},h.id))]});case"list":return i("ul",{children:(s.items??[]).map((h,b)=>i("li",{children:h},b))});case"route-link":{let h=String(s.route??"");return Ge(h,l)?i("a",{href:h,children:String(s.label??o("chat.view"))}):i("span",{children:e.fallback})}case"buttons":return i("div",{children:(s.actions??[]).map(h=>i(c,{disabled:n,onPress:()=>t({kind:"action",blockId:e.id,actionId:h.id}),children:h.label},h.id))});default:return i("p",{children:e.fallback})}}var Uo=["markdown","form.fill","card","details","list","table","form","choice","buttons","diff","plan","route-link","notice"].map(e=>({type:e,render:Ho}));function Yt(e){let{widgets:t,format:n}=U(),o=t?.find(l=>l.type===e.block.type)??Uo.find(l=>l.type===e.block.type);if(!o)return i("div",{"data-fallback":"true",children:i("p",{children:e.block.fallback?.trim()?e.block.fallback:n("unsupportedContent")})});let a=o.render;return i(a,{...e})}function $o(e){let{format:t,primitives:n}=U(),o=en(),a=n.button,l=S(null),[c,s]=K(0),h=S(null);ke(()=>{let p=l.current;X(p,{root:p,owner:"",removed:h.current})});let b=x("p",{role:"alert",children:[t("chat.planUnavailable"),i(a,{onPress:()=>{h.current=document.activeElement,s(c+1),Gt.request(!0)},children:t("chat.retry")})]}),u=o.status==="ready"&&o.module.PlanSteps;return i("div",{ref:l,tabIndex:-1,children:u?i(He,{resetKey:`${e.record.id}:${c}`,fallback:b,children:i(u,{...e})}):o.status==="failed"?b:i("p",{children:t("chat.messageLoading")})})}function Ua(e){let t=_(te);return e.client?i(Do,{...e,client:e.client,children:i(wr,{...e})}):t?i(wr,{...e}):i("section",{className:"waypoint",dir:e.dir??"ltr",children:i("p",{children:Oe(e.locale)("chat.empty")})})}var yr="\uE000";function Wo({messages:e,excerpts:t,anchor:n,open:o,onToggle:a,onNavigate:l}){let{format:c,primitives:s}=U(),h=s.button,b=Be("outline");return x("nav",{"aria-label":c("chat.outline"),"data-outline":"",className:"wp-outline",children:[i(h,{"aria-expanded":o,"aria-controls":b,onPress:a,children:c("chat.outline")}),i("ol",{id:b,hidden:!o,role:"list",children:o?e.map((u,p)=>{let f={role:c(u.role==="user"?"chat.roleUser":"chat.roleAssistant"),position:p+1},M=t[p],d=M===void 0?void 0:c("chat.outlineItem",{...f,excerpt:yr}).split(yr);return i("li",{children:i("a",{href:`#${n(u.id)}`,"data-outline-link":u.id,onClick:m=>{m.preventDefault(),l(u.id)},children:d?d.length===2?x(tn,{children:[d[0],i("bdi",{children:M}),d[1]]}):i("bdi",{children:c("chat.outlineItem",{...f,excerpt:M})}):c("chat.outlineItemPlain",f)})},u.id)}):null})]})}function Ko({label:e,closeLabel:t,onClose:n,skipRestore:o,onFocusWithin:a,children:l}){let c=U().primitives.drawer,s=Ot("rail"),h=S(void 0),b=S(a);return b.current=a,i(At,{as:c,open:!0,label:e,closeLabel:t,onClose:n,focusInto:u=>{let p=f=>b.current(ve(f));u.addEventListener("focusin",p),h.current={element:u,listener:p},s.focusInto?.(u)},restoreFocus:u=>{let p=h.current;h.current=void 0,p?.element.removeEventListener("focusin",p.listener),o()?s.release?.():s.restoreFocus?.(u)},children:l})}function wr({slots:e,features:t,layout:n="panel",shortcuts:o,conversations:a=[],conversationSource:l,quota:c,onStop:s,suggestions:h=[]}){let b=Ue(),u=U(),{client:p,format:f,tokens:M}=u,d=Me(),m=S(null),P=S(null),C=S(null),L=S(null),E=S(new Set).current,[,R]=K(0),[N,W]=K(0),se=Jt(()=>({retry:N,report(r,g){E.has(r)!==g&&(g?E.add(r):E.delete(r),R(F=>F+1))}}),[N,E]),{isAnswered:w,reply:v}=Hn(p),y=S(null),k=S(null),q=S(new Set),[ie,D]=K(0),[le,he]=K(!1),[Ce,nn]=K(),rt=mr(()=>p.refresh()),rn=mr(()=>p.refresh()),ot=wt(p),G=u.primitives.button,Er=u.primitives.textarea,on=!!(e?.extraPanels||u.parts?.extraPanels),an=Be("hint"),We=Be("pending"),Ke=r=>(d.conversation?.mode!=="form-fill"||r==="form-fill"||r==="widgets")&&d.capabilities.includes(r)&&(!t||t.includes(r)),[Sr,at]=K("loading"),sn=()=>{at(r=>r==="failed"?"retrying":"loading"),p.loadFlows().then(()=>at("done"),()=>at("failed"))};ae(sn,[p]);let[,Tr]=K(!1);ae(()=>{import("./problem-messages-Z5QGO6RE.js").then(r=>{cr(r.problemEnglish,r.problemSimplifiedChinese),Tr(!0)})},[]);let T=Yn(m,Re(p,d.conversationId),P,C,r=>Re(p,r)),z=d.conversation?.messages??[],ge=d.conversation?.id,[st,ln]=K({open:!1});st.conversationId!==ge&&ln({conversationId:ge,open:!1});let it=st.conversationId===ge&&st.open,Mr=`wp${b.replace(/[^\w-]/g,"")}`,cn=r=>`${Mr}-${r.replace(/[^A-Za-z0-9-]/gu,g=>`_${g.codePointAt(0)}_`)}`,qe=rr(C,L,ge,z.length,d),lt=S(void 0),Rr=r=>{let g=r.target,F=z.map(Q=>Q.id),I={owner:T.value.owner(),shown:ge,order:F},A=g.closest("[data-outline-link]"),H=g.closest("[data-back-to-latest]"),$=g.closest("article[data-message-id]");lt.current=A?{...I,kind:"link",id:A.getAttribute("data-outline-link"),element:A}:H?{...I,kind:"latest",element:H}:$&&O(C.current,$)?{...I,kind:"message",id:$.getAttribute("data-message-id"),element:$}:void 0};ke(()=>{let r=lt.current;if(!r||r.element.isConnected)return;lt.current=void 0;let g=C.current,F=g?.parentElement,I=(H,$)=>{let Q=new Map;for(let re of $?.querySelectorAll(`[${H}]`)??[])Q.set(re.getAttribute(H),re);let fe=r.order.indexOf(r.id);for(let re=fe+1;re<r.order.length;re++){let De=Q.get(r.order[re]);if(De)return De}for(let re=fe-1;re>=0;re--){let De=Q.get(r.order[re]);if(De)return De}},A=r.kind==="message"?I("data-message-id",g)??g:r.kind==="link"?I("data-outline-link",F)??F?.querySelector("nav[data-outline] [aria-expanded]")??g:g;ee(T.value,A,{owner:r.owner,stillCurrent:()=>T.value.owner()===r.owner&&p.getSnapshot().conversation?.id===r.shown,removed:r.element,fallback:g})});let dn=a.length>0||!!l,[Z,Fr]=K(!1),[xe,Le]=K(!1),un=Be("rail"),Lr=It(xe,T.value.owner(),()=>Le(!1)),ct=S(void 0),dt=S(!1),ze=S(!1),Ir=()=>{let r=dt.current||ze.current;return dt.current=!1,r};ke(()=>{let r=m.current;if(!r||typeof ResizeObserver!="function")return;let g=()=>{let I=r.getBoundingClientRect().width,A=parseFloat(getComputedStyle(r).fontSize)||16;Fr(I>0&&I<40*A)},F=new ResizeObserver(g);return F.observe(r),g(),()=>F.disconnect()},[]);let fn=S(Z);ke(()=>{fn.current&&!Z&&xe&&(ze.current=!0,Le(!1)),fn.current=Z},[Z,xe]),ke(()=>{if(!ze.current||xe)return;ze.current=!1;let r=ct.current;if(ct.current=void 0,!r||r.element.isConnected)return;let g=m.current?.querySelector('[data-part="rail"] nav'),F=r.id?[...g?.querySelectorAll("[data-conversation-id]")??[]].find(I=>I.getAttribute("data-conversation-id")===r.id)?.querySelector("button"):void 0;ee(T.value,F??g??C.current,{owner:r.owner,stillCurrent:()=>T.value.owner()===r.owner,removed:r.element,fallback:C.current})});let je=S(void 0),pn=T.value.owner();qe.pinned||!z.length?je.current=void 0:je.current?.owner!==pn&&(je.current={owner:pn,ids:new Set(z.map(r=>r.id))});let mn=je.current,hn=mn?z.filter(r=>r.role==="assistant"&&!mn.ids.has(r.id)).length:0,ut=xo(),ft=!!(u.renderers?.markdown||u.parts?.bubble||u.parts?.transcript||e?.bubble||e?.transcript),pt=S(new Ze).current;pt.begin(Re(p,ge??""),[ft,u.messageExcerpt,ut,u.markdownImages?.origin,u.markdownImages?.allow,u.extraUrlSchemes?.join(" ")],z.map(r=>({id:r.id,source:ft?r:r.content})));let gn=r=>{if(ft)return pt.get(r.id,r,g=>{let F=u.messageExcerpt?.(g);return F===void 0?void 0:Bt(F)});if(ut)return pt.get(r.id,r.content,g=>Bt(ut.visibleText(g,{images:u.markdownImages,extraSchemes:u.extraUrlSchemes})))},Nr=it?z.map(gn):[],bn=S(null),Dr=ir(p,d.conversation,gn,f,bn),be=Be("flows"),vn=S(""),yn=Mt(()=>{let r=m.current?.querySelector(`[id="${be}-panel"]`);return[r?.querySelector(`[data-flow="${vn.current}"] button`),r]}),Ie=pe(Vt),wn=Ke("flows");ae(()=>{wn&&Vt.request()},[wn]);let[Ne,kn]=K(void 0),Cn=(r,g={})=>{let F=p,I=T.value.owner(),A=Re(F,`flow:${r}`),H=T.value.originFor("run-flow",A);kn(void 0),F.runFlow(r,g).then($=>{let Q=$&&Re(F,$);ee(T.value,P.current,{origin:H,owner:A,stillCurrent:()=>!!Q&&T.value.owner()===Q&&F.getSnapshot().conversation?.id===$})},()=>{ce(H),kn({id:r,owner:I,values:g})})},Pe=d.replyState,Ee=z.at(-1),Ve=Pe==="writing"&&Ee?.status==="writing"?Ee.id:void 0,Ar=Ee?.role==="assistant"&&(Ee.status==="failed"||Ee.status==="unavailable")&&Pe===Ee.status,xn=S(null),mt=lr(Pe,xn),Or=(r,g)=>F=>{let I=V(document),A=Bn(d.conversationId,g,r.id,F),H=!q.current.has(A);q.current.add(A),v(r,F,g).then($=>{H&&q.current.delete(A);let Q=p.getSnapshot();$?.accepted===!1&&$.problem?.code==="refused"&&Q.conversation?.messages.find(fe=>fe.id===g)?.blocks.find(fe=>fe.id===r.id)?.answered&&(k.current=Q.problem),y.current=I,D(fe=>fe+1)})};ke(()=>{let r=y.current,g=T.value.root();y.current=null,r&&g&&X(oe(r)?r:T.value.composer(),{root:g,owner:"",removed:r})},[ie]);let Pn=!!d.problem&&d.problem===k.current,de=d.problem&&!q.current.has(d.problem.id)?u.problemText?.(d.problem,{answeredElsewhere:Pn})??(Pn?{text:f("chat.problem.answered")||f("chat.failure")}:Bo(d.problem,f)):null,J=d.plan,j=ot.view,_e=de&&d.problem?.id!=="conversation-unavailable"&&!(d.problem?.code==="stopped"&&j?.status)&&!d.problem?.confirmation&&!(d.conversationUnavailable&&d.problem?.id==="conversation-read")?d.problem:void 0,Se=_e&&d.pending.some(r=>r.failure&&r.id===_e.id)?_e:void 0,ht=Se?void 0:_e,gt=j?.actions.find(r=>r.id==="confirm"),En=j?.actions.find(r=>r.id==="stop"),ue=yt(J,d.conversationId),Br=r=>{if(le)return;let g=p.getSnapshot();if(yt(g.plan,g.conversationId)?.token!==r){nn(r);return}nn(void 0),he(!0),p.confirmPlan().finally(()=>he(!1))},Sn=d.confirmationRefusal,Hr=Sn?.token===ue?.token&&Sn?.problemId===d.problem?.id?d.problem?.confirmation?.reason:void 0,Ur=Ce!==void 0&&Ce!==ue?.token,$r=Z?"section":"aside",Wr=J?.state==="awaiting-confirmation"&&!j?.readOnly&&ue!==void 0,bt=Ke("plans")&&J?x($r,{"aria-label":f("chat.plan"),"data-plan":"",children:[i($o,{record:J,slots:e,view:j,changesShown:Wr}),x(B,{name:"confirmBar",slots:e,data:j?{view:j,actions:j.actions.filter(r=>j.status?r.id==="confirm":r.id==="confirm"||r.id==="stop")}:void 0,children:[J.state==="awaiting-confirmation"&&!j?.readOnly?i(B,{name:"confirmation",slots:e,data:ue&&{confirmation:ue},children:i(wo,{fallback:null,children:i(Po,{record:ue,planId:J.id,entry:gt&&(le?{...gt,available:!1,busy:!0}:gt),onConfirm:()=>ue&&Br(ue.token),refusal:Hr,override:u.problemText&&de,replaced:Ur})})}):null,!j?.status&&En?i(xr,{action:En,onPress:s??(()=>p.stopPlan())}):null]}),j?.status?i(Ao,{view:j,onPress:ot.press,slots:e,sheet:ot.sheet,hide:["confirm"]}):null]}):null,Tn=z.at(-1),vt=Z&&bt&&!d.pending.length&&Tn?.blocks.some(r=>r.type==="plan"&&r.body?.planId===J?.id)?Tn:void 0,Mn=r=>i(B,{name:"messageActions",slots:e,data:{message:{id:r.id,role:r.role,status:r.status,versionIndex:r.versionIndex,versionCount:r.versionCount}},children:i(So,{client:p,message:r})});return i(Lt.Provider,{value:T.value,children:i("section",{ref:m,className:"waypoint",dir:u.dir??"ltr",lang:u.lang,"data-layout":n,"data-color-scheme":u.colorScheme??"light","data-custom-theme":u.theme?"":void 0,style:{...An(M),colorScheme:u.colorScheme??"light"},...T.captureProps,onKeyDown:r=>{o?.focusComposer===!1||r.key!==(o?.focusComposer??"/")||!O(r.currentTarget,ve(r.nativeEvent))||!Jn(r.currentTarget)||r.currentTarget.querySelector(Ln)||(r.preventDefault(),P.current?.focus())},children:x("div",{className:"wp-shell","data-has-aside":Ke("plans")&&J||on?"":void 0,"data-has-rail":dn||e?.rail||u.parts?.rail?"":void 0,children:[Z?null:i(B,{name:"rail",slots:e,children:i(_t,{conversations:a,source:l})}),x("main",{children:[x(B,{name:"topBar",slots:e,children:[Z&&dn?i("span",{"data-rail-toggle":"",children:i(G,{"aria-expanded":xe,"aria-controls":un,onPress:()=>Le(r=>!r),children:f("chat.rail")})}):null,i("h2",{children:d.conversation?.title||f("chat.title")})]}),Z&&xe&&!Lr?i(Ko,{label:f("chat.rail"),closeLabel:f("chat.close"),onClose:()=>Le(!1),skipRestore:Ir,onFocusWithin:r=>{let g=r.closest("[data-conversation-id]");ct.current={element:r,id:g?.getAttribute("data-conversation-id")??void 0,owner:T.value.owner()}},children:i("div",{id:un,children:i(_t,{conversations:a,source:l,onChoose:()=>{let r=T.value.originFor("rail-choice");dt.current=!0,ee(T.value,m.current?.querySelector("[data-rail-toggle] button"),{origin:r,owner:T.value.owner()}),Le(!1)}})})}):null,i(B,{name:"transcript",slots:e,children:x("div",{onFocusCapture:Rr,children:[z.length?i(Wo,{messages:z,excerpts:Nr,anchor:cn,open:it,onToggle:()=>ln({conversationId:ge,open:!it}),onNavigate:r=>{let g=T.value.originFor("outline");ee(T.value,qe.toMessage(r),{origin:g,owner:T.value.owner()})}}):null,i("div",{ref:C,className:"wp-transcript",role:"region","aria-label":f("chat.transcript"),tabIndex:-1,children:i(Qt.Provider,{value:se,children:x("div",{ref:L,children:[!d.conversation&&!d.conversationUnavailable&&!d.problem?i("p",{children:f("chat.startupLoading")}):z.length?null:i(B,{name:"emptyState",slots:e,children:i("p",{children:f("chat.empty")})}),z.map(r=>x("article",{id:cn(r.id),tabIndex:-1,"data-message-id":r.id,"data-role":r.role,"aria-busy":r.id===Ve?!0:void 0,"aria-label":f(r.role==="user"?"chat.roleUser":"chat.roleAssistant"),"data-body-unavailable":E.has(r.id)&&!r.blocks.length?"":void 0,children:[x(B,{name:"bubble",slots:e,data:{message:{id:r.id,role:r.role,content:r.content,status:r.status,versionIndex:r.versionIndex,versionCount:r.versionCount,blocks:r.blocks.map(br)}},children:[i("span",{"data-sender":"","aria-hidden":"true",children:f(r.role==="user"?"chat.roleUser":"chat.roleAssistant")}),i(kr.Provider,{value:r.id,children:i(Pr,{text:r.content,writing:r.id===Ve,sources:r.sources})}),r.id===Ve?i("span",{"data-writing":"","aria-hidden":"true",children:f("reply.writing")}):r.status==="stopped"?i("span",{"data-stopped":"",children:f("reply.stopped")}):r.status==="failed"||r.status==="unavailable"?i("span",{"data-reply-ended":r.status,children:f(`reply.${r.status}`)}):null,r.blocks.map(g=>i(B,{name:"widgetFrame",slots:e,data:{block:br(g)},children:x("div",{"data-open-card":g.type==="card"&&!w(g,r.id)?"true":void 0,children:[i(Yt,{block:g,disabled:d.conversationUnavailable||w(g,r.id),onReply:Or(g,r.id)}),g.answered?i(To,{block:g}):null]})},g.id))]}),r===vt?null:Mn(r)]},r.id)),d.pending.map(r=>x("article",{"data-role":"pending","aria-label":f("chat.roleUser"),children:[x(B,{name:"bubble",slots:e,data:{pending:vr(r)},children:[i("span",{"data-sender":"","aria-hidden":"true",children:f("chat.roleUser")}),i("p",{children:r.content})]}),i("p",{id:`${We}-${r.id}`,"data-pending-status":r.failure?"failed":"sending",children:f(r.failure?"chat.pendingFailed":"chat.pendingSending")}),Se?.id===r.id&&de?x("p",{role:"alert",children:[de.text,de.action??(!u.problemText&&kt(Se)==="refresh"?i(hr,{problem:Se,refresh:rn}):null)]},d.announcement):null,r.failure?x(B,{name:"failedSendControls",slots:e,data:{pending:vr(r)},children:[i(G,{"aria-describedby":`${We}-${r.id}`,disabled:d.conversationUnavailable||d.sending,onPress:()=>{p.retry(r.id)},children:f("chat.retry")}),i(G,{"aria-describedby":`${We}-${r.id}`,disabled:d.withdrawing.includes(r.id),onPress:()=>{p.withdraw(r.id)},children:f("chat.withdraw")}),i(G,{"aria-describedby":`${We}-${r.id}`,onPress:()=>{p.dismiss(r.id)},children:f("chat.dismiss")})]}):null,Se?.id===r.id?i(gr,{problem:Se},d.announcement):null]},r.id))]})})}),E.size?x("p",{role:"alert","data-render-failure":"",children:[f("chat.messagesUnavailable"),i(G,{onPress:()=>{tt.request(!0),W(r=>r+1)},children:f("chat.retry")})]}):null,qe.pinned?null:i("div",{"data-back-to-latest":"",children:i(G,{onPress:()=>{let r=T.value.originFor("latest");qe.toLatest(),ee(T.value,C.current,{origin:r,owner:T.value.owner()})},children:hn?f("chat.latestNew",{count:hn}):f("chat.latest")})})]})}),x(B,{name:"replyRow",slots:e,children:[i("div",{ref:xn,role:"status","data-reply-state":Pe,children:mt==="none"||Ar?null:i("p",{className:mt==="writing"&&Ve?"wp-sr-only":void 0,children:f(`reply.${mt}`)})}),Pe!=="none"||d.toolSteps.length?i(Eo,{client:p,row:Pe}):null]}),Z?bt:null,vt?Mn(vt):null,Ke("flows")?i(B,{name:"flowTabs",slots:e,children:x("nav",{"aria-label":f("chat.flows"),children:[i("div",{role:"tablist",onKeyDown:r=>{let g=d.flowTabs,F=g.findIndex(H=>Te(H)===d.flowTab),I;if(r.key==="Home")I=0;else if(r.key==="End")I=g.length-1;else if(r.key==="ArrowRight"||r.key==="ArrowLeft"){let H=getComputedStyle(r.currentTarget).direction,$=r.key==="ArrowRight"!=((H==="rtl"||H==="ltr"?H:u.dir)==="rtl");I=(F+($?1:g.length-1))%g.length}else return;let A=r.currentTarget;!O(A,ve(r.nativeEvent))||!O(A,V(A.ownerDocument))||(r.preventDefault(),p.selectFlowTab(g[I]),r.currentTarget.querySelectorAll('[role="tab"]')[I]?.focus())},children:d.flowTabs.map(r=>i(G,{id:`${be}-${Te(r)}`,"aria-controls":`${be}-panel`,role:"tab","aria-selected":d.flowTab===Te(r),tabIndex:d.flowTab===Te(r)?0:-1,label:typeof r=="string"?f(`flow.${r}`):u.flowTabLabel?.(r.labelKey)??r.labelKey,onPress:()=>p.selectFlowTab(r),children:typeof r=="string"?f(`flow.${r}`):u.flowTabLabel?.(r.labelKey)??r.labelKey},Te(r)))}),Ne&&Ne.owner===T.value.owner()?i(Xt,{onFocus:r=>{vn.current=Ne.id,yn(r)},onRetry:()=>Cn(Ne.id,Ne.values)}):null,Ie.status==="ready"?i(Ie.module.FlowPanel,{id:`${be}-panel`,labelledBy:`${be}-${d.flowTab}`,flows:d.flows[d.flowTab],all:d.flows,list:Sr,onRetryList:sn,onRunFlow:Cn}):i("div",{id:`${be}-panel`,role:"tabpanel","aria-labelledby":`${be}-${d.flowTab}`,tabIndex:-1,onFocus:yn,children:Ie.status==="failed"||nt(Ie)?i(Xt,{retrying:nt(Ie),onRetry:()=>Vt.request(!0)}):i("p",{children:f("chat.loading")})})]})}):null,d.restored.length?i("section",{"aria-label":f("chat.restored"),children:d.restored.map(r=>x("article",{children:[i("p",{children:r.content}),i(G,{onPress:()=>{p.editRestored(r.id)},children:f("chat.restoredEdit")}),i(G,{onPress:()=>{p.discardRestored(r.id)},children:f("chat.restoredDiscard")})]},r.id))}):null,x(B,{name:"composer",slots:e,data:{sending:d.sending},disabled:d.conversationUnavailable,value:d.draft,onChange:r=>{p.setDraft(r)},children:[i(Er,{inputRef:P,disabled:d.conversationUnavailable,value:d.draft,onChange:r=>{p.setDraft(r)},label:f("chat.message"),describedBy:d.hints.length?d.hints.map((r,g)=>`${an}-${g}`).join(" "):void 0,onKeyDown:r=>{o?.send!==!1&&r.key===(o?.send??"Enter")&&!r.shiftKey&&!r.nativeEvent.isComposing&&r.keyCode!==229&&(r.preventDefault(),p.send())}}),i(G,{disabled:d.conversationUnavailable||!d.draft.trim()||d.sending,onPress:()=>{p.send()},children:f(d.sending?"chat.sending":"chat.send")}),d.hints.map((r,g)=>i("p",{id:`${an}-${g}`,children:r},g))]}),i(B,{name:"actionBar",slots:e,children:h.map(r=>i(G,{onPress:()=>{p.setDraft(r)},children:r},r))}),i(B,{name:"stepUpPrompt",slots:e,data:J?.plan.kind==="immediate"&&J.plan.stage==="final"?{stepUpCount:J.plan.stepUpCount}:void 0}),i(B,{name:"quotaStrip",slots:e,children:c}),i("div",{ref:bn,className:"wp-sr",role:"status","data-announcements":"",children:Dr}),x("div",{role:"alert","data-announcement":d.announcement,children:[d.conversationUnavailable&&x("span",{children:[f("chat.conversationUnavailable"),i(G,{onPress:rt.press,"aria-busy":rt.busy||void 0,"aria-disabled":rt.busy||void 0,children:f("chat.reload")})]}),ht&&de?x("span",{children:[de.text,de.action??(d.problem&&!u.problemText?i(hr,{problem:d.problem,refresh:rn}):null)]},d.announcement):null]}),ht?i(gr,{problem:ht},d.announcement):null]}),Z?null:bt,on?i(B,{name:"extraPanels",slots:e}):null]})})})}function $a({title:e,body:t,busy:n=!1,onProceed:o,onCancel:a}){let l=_(te),c=l?.format??Oe(),s=l?.primitives??Cr,h=s.drawer,b=Ot("confirm-sheet"),u=It(!0,Ae()?.owner(),a),p=s.button;return u?null:x(At,{as:h,open:!0,label:e,onClose:a,closeLabel:c("chat.close"),...b,children:[i("p",{children:t}),i(p,{disabled:n,onPress:o,children:c("chat.confirm")}),i(p,{onPress:a,children:c("chat.cancel")})]})}import{Fragment as jo,jsx as ne,jsxs as me}from"react/jsx-runtime";function _t({conversations:e,source:t,onChoose:n}){let{client:o,format:a,primitives:l,extraUrlSchemes:c}=U(),{conversationId:s}=zo(o.subscribe,o.getSnapshot,o.getSnapshot),[h,b]=$e(""),[u,p]=$e([]),[f,M]=$e(!1),[d,m]=$e(0),[P,C]=$e(new Map);qo(()=>{if(!t)return;let w=!0;return M(!1),Promise.resolve().then(()=>t.list(h||void 0)).then(v=>{w&&(p(v),C(y=>new Map([...y,...v.filter(k=>k.subject).map(k=>[k.subject.key,k.subject])])))}).catch(()=>{w&&M(!0)}),()=>{w=!1}},[t,h,s,d]);let L=t?u:e,E=t?P:new Map(L.filter(w=>w.subject).map(w=>[w.subject.key,w.subject])),R=new Map;for(let w of L){let v=w.subject?.key??"";h&&v!==h||R.set(v,[...R.get(v)??[],w])}let N=l.button,W=Ae(),se=w=>me(jo,{children:[ne(N,{"aria-current":w.id===s?"page":void 0,onPress:()=>{n?.();let v=W?.ownerOf(w.id)??w.id,y=W?.originFor("switch",v);o.switchConversation(w.id).then(k=>ee(W,W?.composer(),{origin:y,owner:v,stillCurrent:()=>k.kind==="loaded"&&W?.owner()===v&&o.getSnapshot().conversation?.id===w.id}))},children:w.title}),w.mode==="form-fill"&&ne("span",{children:a("form.marker")}),w.subject?.state==="unlinked"&&ne("span",{children:a("form.unlinked")}),w.subject?.route&&Ge(w.subject.route,c)&&ne("a",{href:w.subject.route,children:a("form.return")})]});return me("nav",{className:"wp-rail","aria-label":a("chat.rail"),tabIndex:-1,children:[E.size>0&&me("label",{children:[a("form.filter"),me("select",{value:h,onChange:w=>b(w.target.value),children:[ne("option",{value:"",children:a("form.all")}),[...E].map(([w,v])=>ne("option",{value:w,children:v.label},w))]})]}),f&&me("p",{role:"alert",children:[a("chat.conversationsFailed")," ",ne(N,{onPress:()=>m(w=>w+1),children:a("chat.retry")})]}),[...R].map(([w,v])=>{let y=new Set,k=D=>{if(y.has(D.id))return null;y.add(D.id);let le=v.filter(he=>he.parentConversationId===D.id&&!y.has(he.id));return me("li",{"data-conversation-id":D.id,children:[se(D),le.length>0&&me("details",{children:[ne("summary",{children:a("form.threads")}),ne("ul",{children:le.map(k)})]})]},D.id)},ie=v.filter(D=>!D.parentConversationId||!v.some(le=>le.id===D.parentConversationId)).map(k);for(let D of v)y.has(D.id)||ie.push(k(D));return me("section",{children:[w&&ne("h3",{children:v[0].subject.label}),ne("ul",{children:ie})]},w)})]})}export{V as a,O as b,oe as c,ce as d,Mt as e,Lt as f,Ae as g,It as h,Yr as i,ee as j,At as k,Ot as l,Zo as m,Jo as n,_t as o,co as p,cr as q,uo as r,qt as s,Oe as t,we as u,pe as v,Do as w,Ia as x,U as y,Na as z,Da as A,Aa as B,Oa as C,Ba as D,Ha as E,xr as F,mr as G,Xt as H,Ao as I,B as J,Bo as K,Uo as L,Yt as M,$o as N,Ua as O,$a as P};
@@ -1 +0,0 @@
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 _chunkFBADWFRRcjs = require('./chunk-FBADWFRR.cjs');var _chunkQS3MKZOYcjs = require('./chunk-QS3MKZOY.cjs');var _chunkM3UENQ6Lcjs = require('./chunk-M3UENQ6L.cjs');var _chunk4BWV3SELcjs = require('./chunk-4BWV3SEL.cjs');var _chunkGT6PI4CTcjs = require('./chunk-GT6PI4CT.cjs');var _chunk3KV7TDDRcjs = require('./chunk-3KV7TDDR.cjs');var _react = require('react');var Xe=new WeakMap;function V(e){let t=e.activeElement;for(;_optionalChain([t, 'optionalAccess', _2 => _2.shadowRoot, 'optionalAccess', _3 => _3.activeElement]);)t=t.shadowRoot.activeElement;return t}function O(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 ve(e){return _nullishCoalesce(_optionalChain([e, 'access', _4 => _4.composedPath, 'optionalCall', _5 => _5(), 'access', _6 => _6[0]]), () => (e.target))}var Ct=new WeakMap,Kr=0;function Kn(e){let t=new Set,n=[],o=a=>{t.has(a)||a.hasAttribute("inert")||(a.setAttribute("inert",e.mark),e.set.push(a))};for(let a=e.drawer;;){t.add(a);let l=a instanceof Element?a.assignedSlot:null;l&&a.parentNode&&n.push(a.parentNode);let c=_nullishCoalesce(l, () => (a.parentNode));if(!c||c.nodeType===Node.DOCUMENT_NODE)break;n.push(c),a=c instanceof ShadowRoot?c.host:c}for(let a of n)for(let l of a.children)o(l);if(typeof MutationObserver=="function"){e.watch=new MutationObserver(a=>{for(let l of a)for(let c of l.addedNodes)c instanceof Element&&o(c)});for(let a of n)e.watch.observe(a,{childList:!0})}}function qn(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 Et(e){let t=e.ownerDocument,n=_nullishCoalesce(Ct.get(t), () => ([]));Ct.set(t,n);let o=n.at(-1);o&&qn(o);let a={drawer:_nullishCoalesce(e.closest("[data-wp-modal-root]"), () => (e)),mark:`waypoint-${++Kr}`,set:[]};return n.push(a),Kn(a),()=>{let l=n.indexOf(a);if(l<0)return;qn(a),n.splice(l,1);let c=n.at(-1);l===n.length&&c&&Kn(c)}}var qr='a[href], button, input, select, textarea, summary, iframe, [tabindex], [contenteditable]:not([contenteditable="false"])';function oe(e){return e instanceof HTMLElement&&e.isConnected&&e.matches(qr)&&!e.matches('input[type="hidden"], :disabled')&&!e.closest("[hidden], [inert]")&&(typeof e.checkVisibility!="function"||e.checkVisibility({visibilityProperty:!0}))}function zr(e,t){for(let n=e;n;){if(n instanceof Element&&oe(n))return n;if(n===t)return null;n=_nullishCoalesce(n.parentNode, () => ((n instanceof ShadowRoot?n.host:null)))}return null}function jr(e){return O(e,V(e.ownerDocument))}var xt=e=>{let t=V(e);return!t||t===e.body};function ye(e){let t=Xe.get(e);if(t)return t;let n={origins:new Set,last:null};return t=n,Xe.set(e,n),e.addEventListener("focusin",o=>{let a=ve(o);n.last=a,n.disabled=null;for(let l of n.origins)!O(l.root,a)&&!l.owned.some(c=>O(c,a))&&(l.valid=!1,n.origins.delete(l))},!0),e.addEventListener("focusout",o=>{let a=ve(o);o.relatedTarget||queueMicrotask(()=>{if(!_optionalChain([a, 'optionalAccess', _10 => _10.isConnected])||!xt(e))return;if(a.matches(":disabled"))return void(n.disabled=a);let l=_optionalChain([Ct, 'access', _11 => _11.get, 'call', _12 => _12(e), 'optionalAccess', _13 => _13.at, 'call', _14 => _14(-1), 'optionalAccess', _15 => _15.drawer]);if(!(l&&O(l,a))){n.last=null;for(let c of n.origins)c.valid=!1;n.origins.clear()}})},!0),e.addEventListener("pointerdown",()=>{n.last&&!n.last.isConnected&&xt(e)&&(n.last=null)},!0),n}function ce(e){e&&(e.valid=!1,_optionalChain([Xe, 'access', _16 => _16.get, 'call', _17 => _17(e.root.ownerDocument), 'optionalAccess', _18 => _18.origins, 'access', _19 => _19.delete, 'call', _20 => _20(e)]))}function Vn(e){let t=Xe.get(e.ownerDocument);if(t)for(let n of t.origins)O(e,n.root)&&ce(n)}function St(e){ye(e)}function Tt(e,t,n,o){let a="nativeEvent"in e?e.nativeEvent:e,l=ve(a);if(!O(t,l))return;let c={owner:n,action:o,root:t,control:_nullishCoalesce(zr(l,t), () => (l)),owned:[],valid:!0};return ye(t.ownerDocument).origins.add(c),c}var _n=new WeakMap;function Gn(e){let t=V(e.ownerDocument);t&&O(e,t)&&(ye(e.ownerDocument).last=t,_n.set(e,t))}function Pt(e,t){if(!e)return!1;let{last:n}=ye(t);return!!n&&(O(e,n)||_n.get(e)===n)&&(!n.isConnected||n===ye(t).disabled)&&xt(t)}function X(e,t){let{root:n,origin:o,removed:a}=t;if(!e||!e.isConnected)return!1;let l=n.ownerDocument;if(ye(l),t.stillCurrent&&!t.stillCurrent()||!(o?o.valid&&o.owner===t.owner&&(jr(n)||Pt(_nullishCoalesce(a, () => (o.control)),l)):Pt(a,l)||t.enterModal===!0&&e===n&&e.matches(_chunkGT6PI4CTcjs.c)))return!1;e.focus({preventScroll:_nullishCoalesce(t.preventScroll, () => (!1))});let s=V(l)===e;return s?ye(l).last=e:_optionalChain([t, 'access', _21 => _21.missed, 'optionalCall', _22 => _22()]),s}var zn=new WeakMap,jn=e=>{let t=zn.get(e);return t||zn.set(e,t=new Set),t};function Mt(e){let t=_react.useRef.call(void 0, null),n=_react.useRef.call(void 0, {});return _react.useLayoutEffect.call(void 0, ()=>{St(document);let o=jn(document),a=n.current;return()=>{o.delete(a)}},[]),_react.useLayoutEffect.call(void 0, ()=>{let o=jn(document),a=t.current;if(!a||a.isConnected)return void o.delete(n.current);if(!Pt(a,document))return t.current=null,void o.delete(n.current);let l=e().find(c=>_optionalChain([c, 'optionalAccess', _23 => _23.isConnected]));if(!(l instanceof HTMLElement))return void o.add(n.current);t.current=null,o.delete(n.current),X(l,{root:l,owner:"",removed:a})}),o=>{t.current=o.target}}var _jsxruntime = require('react/jsx-runtime');var Lt=_react.createContext.call(void 0, null),Ae= exports.g =()=>_react.useContext.call(void 0, Lt),Xn=new WeakMap,Xr=0;function Re(e,t){let n=Xn.get(e);return n===void 0&&Xn.set(e,n=++Xr),`${n}:${t}`}function Yn(e,t,n,o,a=l=>l){let l=_react.useRef.call(void 0, null),c=_react.useRef.call(void 0, t);c.current=t;let s=_react.useRef.call(void 0, a);s.current=a,_react.useEffect.call(void 0, ()=>{let u=e.current;if(u)return St(u.ownerDocument),()=>Vn(u)},[e]);let h=_react.useMemo.call(void 0, ()=>({root:()=>e.current,owner:()=>c.current,ownerOf:u=>s.current(u),originFor(u,p){let f=l.current,M=e.current;return f&&M?Tt(f,M,_nullishCoalesce(p, () => (c.current)),u):void 0},composer:()=>n.current,transcript:()=>o.current}),[e,n,o,t]),b=u=>{let p=u.nativeEvent;l.current=p,Zn(()=>{l.current===p&&(l.current=null)})};return{value:h,captureProps:{onClickCapture:b,onKeyDownCapture:b,onPointerDownCapture:b}}}function It(e,t,n){let[o,a]=_react.useState.call(void 0, {active:e,conversationId:t});o.active!==e&&a({active:e,conversationId:t});let l=e&&o.active&&o.conversationId!==t,c=_react.useRef.call(void 0, n);return c.current=n,_react.useEffect.call(void 0, ()=>{l&&c.current()},[l]),l}var Zn=e=>setTimeout(e,0);function Yr(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 Jn(e){if(!e)return!1;let t=V(e.ownerDocument);return O(e,t)&&!Yr(t)}function ee(e,t,n){let{origin:o,removed:a,fallback:l}=n,c=_optionalChain([e, 'optionalAccess', _26 => _26.root, 'call', _27 => _27()]),s=(u,p)=>!!c&&(!!o||!!a)&&X(u,{root:c,origin:o,removed:a,owner:n.owner,stillCurrent:n.stillCurrent,preventScroll:!0,missed:p}),h=!1,b=s(t,()=>h=!0);return!b&&h&&l&&l!==t&&(b=s(l)),(!n.keep||!b)&&ce(o),b}function Nt(e,t,n,o){_optionalChain([t, 'access', _28 => _28.current, 'optionalAccess', _29 => _29.element])!==e&&(t.current={element:e,opener:V(e.ownerDocument)}),_optionalChain([o, 'optionalCall', _30 => _30()]),X(e,{root:e,owner:"",enterModal:!0,stillCurrent:n})}function Dt(e,t,n){let o=e.current;o&&queueMicrotask(()=>{if(e.current!==o)return;let a=_optionalChain([n, 'optionalCall', _31 => _31()]),l=oe(o.opener)?o.opener:a,c={root:o.element,owner:"",removed:o.element,stillCurrent:t,preventScroll:!0};X(l,{...c,missed:()=>{a!==l&&X(a,c)}}),o.element.isConnected||(e.current=void 0)})}function At({as:e,focusInto:t,restoreFocus:n,...o}){let a=_react.useRef.call(void 0, void 0),l=_react.useRef.call(void 0, void 0);return _react.useEffect.call(void 0, ()=>()=>{_optionalChain([a, 'access', _32 => _32.current, 'optionalCall', _33 => _33()]),a.current=void 0},[]),_jsxruntime.jsx.call(void 0, e,{...o,focusInto:c=>{if(_optionalChain([a, 'access', _34 => _34.current, 'optionalCall', _35 => _35()]),t){let s=!1,h=()=>{a.current=Et(c),s=!0};t(c,h),s||h()}else Nt(c,l,void 0,()=>{a.current=Et(c)})},restoreFocus:c=>{Gn(c),_optionalChain([a, 'access', _36 => _36.current, 'optionalCall', _37 => _37()]),a.current=void 0,n?n(c):Dt(l)}})}function Ot(e,t,n){let o=Ae(),a=_react.useRef.call(void 0, void 0),l=_react.useRef.call(void 0, void 0),c=_react.useRef.call(void 0, t);c.current=t;let s=_react.useRef.call(void 0, n);return s.current=n,_react.useMemo.call(void 0, ()=>o?{focusInto(h,b){let u=o.owner(),p=o.originFor(`drawer:${e}`,u);if(a.current={origin:p,key:u},!p){Nt(h,l,()=>o.owner()===u&&(_nullishCoalesce(_optionalChain([c, 'access', _38 => _38.current, 'optionalCall', _39 => _39()]), () => (!0))),b);return}l.current=void 0,ee(o,h,{origin:p,owner:u,stillCurrent:()=>o.owner()===u&&(_nullishCoalesce(_optionalChain([c, 'access', _40 => _40.current, 'optionalCall', _41 => _41()]), () => (!0))),keep:!0})},restoreFocus(h){let b=a.current;if(a.current=void 0,!b)return;if(!b.origin){Dt(l,()=>o.owner()===b.key,()=>{let p=_optionalChain([s, 'access', _42 => _42.current, 'optionalCall', _43 => _43()]);return oe(_nullishCoalesce(p, () => (null)))?p:o.transcript()});return}let u={origin:b.origin,key:b.key};queueMicrotask(()=>Zr(o,h,u,_optionalChain([s, 'access', _44 => _44.current, 'optionalCall', _45 => _45()])))},release(){let h=a.current;a.current=void 0,ce(_optionalChain([h, 'optionalAccess', _46 => _46.origin]))}}:{},[o,e])}function Zr(e,t,n,o){let a=V(t.ownerDocument);if(!O(t,a)&&a&&a!==t.ownerDocument.body)return ce(n.origin);let l=n.origin.control,c=oe(_nullishCoalesce(o, () => (null)))?o:e.transcript(),s=oe(l)?l:c;ee(e,s,{origin:n.origin,owner:n.key,stillCurrent:()=>e.owner()===n.key,removed:t,fallback:c})}var Ye=null;function Zo(e,t,n){let o=Tt(e.nativeEvent,t,"form-field","open");if(!o)return _optionalChain([n, 'optionalCall', _47 => _47()]);let a={origin:o,claimed:!1,settled:n};Ye=a,Zn(()=>{Ye===a&&(Ye=null),a.claimed||(ce(o),_optionalChain([a, 'access', _48 => _48.settled, 'optionalCall', _49 => _49()]))})}function Jo(){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 o=_nullishCoalesce(Ye, () => (void 0));if(e.current=o,!o){Nt(n,t);return}t.current=void 0;let a=o.origin;o.claimed=!0,a.owned.push(n),X(n,{root:a.root,origin:a,owner:a.owner,preventScroll:!0})},restoreFocus(n){let o=e.current;if(e.current=void 0,!o){Dt(t);return}queueMicrotask(()=>{Jr(n,o.origin),_optionalChain([o, 'access', _50 => _50.settled, 'optionalCall', _51 => _51()])})}}),[])}function Jr(e,t){let n=[...t.root.querySelectorAll("*")].find(oe),o={root:e,origin:t,removed:e,owner:t.owner,preventScroll:!0},a=!oe(t.control);a||X(t.control,{...o,missed:()=>a=!0}),a&&n&&n!==t.control&&X(n,o),ce(t)}var eo=/[‪-‮⁦-⁩]/g;function Bt(e,t=120){let n=e.replace(eo,"").replace(/\s+/g," ").trim();if(!n||typeof Intl.Segmenter!="function")return;let o=[];for(let a of new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(n)){if(o.length===t)return`${o.join("")}\u2026`;o.push(a.segment)}return n}var Ze= (_class =class{constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this); }__init() {this.policy=[]}__init2() {this.byId=new Map}begin(t,n,o){if(t!==this.owner||n.length!==this.policy.length||n.some((l,c)=>l!==this.policy[c])){this.owner=t,this.policy=n,this.byId=new Map;return}if(!this.byId.size)return;let a=new Map(o.map(l=>[l.id,l.source]));for(let[l,c]of this.byId)(!a.has(l)||a.get(l)!==c.source)&&this.byId.delete(l)}get(t,n,o){let a=this.byId.get(t);if(a&&a.source===n)return a.value;let l=o(n);return this.byId.set(t,{source:n,value:l}),l}entries(){return[...this.byId].map(([t,n])=>({id:t,source:n.source}))}}, _class);var tr=24,Ht=150,no=100,ro=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "]),oo="[data-message-id]",Fe=e=>Math.max(0,e.scrollHeight-e.clientHeight),nr=e=>e.scrollHeight-e.clientHeight-e.scrollTop,Je=()=>performance.now(),ao=e=>typeof requestAnimationFrame=="function"?requestAnimationFrame(e):setTimeout(e,16),Ut=e=>[...e.querySelectorAll(oo)].filter(t=>t.closest(".wp-transcript")===e),Qe=e=>e.getAttribute("data-message-id");function rr(e,t,n,o,a){let[l,c]=_react.useState.call(void 0, !0),s=_react.useRef.call(void 0, {pinned:!0,token:void 0,expected:[],lastTop:0,sizeFrame:!1,anchor:void 0,shown:void 0}).current,h=m=>{s.pinned=m,c(m)},b=()=>{clearTimeout(_optionalChain([s, 'access', _52 => _52.token, 'optionalAccess', _53 => _53.timer])),s.token=void 0},u=(m,P)=>{let C=Math.min(Math.max(0,P),Fe(m));s.expected.push({top:C,at:Je()}),typeof m.scrollTo=="function"?m.scrollTo({top:C,behavior:"instant"}):m.scrollTop=C,s.lastTop=m.scrollTop},p=m=>{let P=m.getBoundingClientRect().top,C=Ut(m),L=C.find(E=>E.getBoundingClientRect().bottom>P+.5);s.anchor=L&&{id:Qe(L),offset:L.getBoundingClientRect().top-P,order:C.map(Qe)}},f=m=>{let P=s.anchor;if(!P)return p(m);let C=new Map(Ut(m).map(R=>[Qe(R),R])),L=P.order.indexOf(P.id),E=_nullishCoalesce(_nullishCoalesce(C.get(P.id), () => (P.order.slice(L+1).map(R=>C.get(R)).find(Boolean))), () => (P.order.slice(0,Math.max(0,L)).reverse().map(R=>C.get(R)).find(Boolean)));if(!E)u(m,0);else{let R=E.getBoundingClientRect().top-m.getBoundingClientRect().top-P.offset;Math.abs(R)>.5&&u(m,m.scrollTop+R)}p(m)},M=()=>{let m=e.current;m&&(s.token&&!s.token.used&&!s.token.held&&b(),s.pinned?nr(m)>.5&&u(m,Fe(m)):f(m))},d=_react.useRef.call(void 0, M);return d.current=M,_react.useLayoutEffect.call(void 0, ()=>{let m=o===0;(n!==s.shown||m)&&(s.shown=n,s.anchor=void 0,b(),s.pinned||h(!0)),M()},[a,n,o]),_react.useLayoutEffect.call(void 0, ()=>{let m=e.current;if(!m)return;let P=m.ownerDocument,C=v=>{clearTimeout(v.timer);let y=()=>{if(s.token!==v||v.held)return;let k=Je()-Math.max(v.lastInput,v.lastScroll);k>=Ht?s.token=void 0:v.timer=setTimeout(y,Ht-k)};v.timer=setTimeout(y,Ht)},L=v=>{let y=s.token??={used:!1,held:!1,lastInput:0,lastScroll:0};y.lastInput=Je(),v&&(y.held=!0),C(y)},E=()=>{let v=s.token;_optionalChain([v, 'optionalAccess', _54 => _54.held])&&(v.held=!1,C(v))},R=()=>L(),N=()=>L(!0),W=v=>{ro.has(v.key)&&O(m,V(P))&&L()},se=()=>{let v=m.scrollTop,y=s.lastTop;s.lastTop=v;let k=Je();s.expected=s.expected.filter(Ce=>k-Ce.at<no);let q=s.expected.findIndex(Ce=>Math.abs(Ce.top-v)<=1),ie=s.token,D=Fe(m),le=Math.abs(v-D)<=1&&y>D+.5,he=q>=0||!ie||le||s.sizeFrame&&Math.abs(v-D)<=1;q>=0&&s.expected.splice(0,q+1),he||(ie.used=!0,ie.lastScroll=k,C(ie),v<y-.5?h(!1):v>y+.5&&nr(m)<=tr&&!s.pinned&&h(!0)),s.pinned||p(m)};m.addEventListener("wheel",R,{passive:!0}),m.addEventListener("touchstart",N,{passive:!0}),m.addEventListener("touchmove",R,{passive:!0}),m.addEventListener("pointerdown",N),m.addEventListener("keydown",W),m.addEventListener("scroll",se,{passive:!0});for(let v of["pointerup","pointercancel","touchend","touchcancel"])P.addEventListener(v,E,!0);let w=typeof ResizeObserver=="function"?new ResizeObserver(()=>{s.sizeFrame=!0,ao(()=>s.sizeFrame=!1),d.current()}):void 0;return _optionalChain([w, 'optionalAccess', _55 => _55.observe, 'call', _56 => _56(m)]),t.current&&_optionalChain([w, 'optionalAccess', _57 => _57.observe, 'call', _58 => _58(t.current)]),()=>{m.removeEventListener("wheel",R),m.removeEventListener("touchstart",N),m.removeEventListener("touchmove",R),m.removeEventListener("pointerdown",N),m.removeEventListener("keydown",W),m.removeEventListener("scroll",se);for(let v of["pointerup","pointercancel","touchend","touchcancel"])P.removeEventListener(v,E,!0);_optionalChain([w, 'optionalAccess', _59 => _59.disconnect, 'call', _60 => _60()]),b()}},[e,t]),{pinned:l,toLatest(){let m=e.current;m&&(b(),u(m,Fe(m)),h(!0))},toMessage(m){let P=e.current,C=P&&Ut(P).find(R=>Qe(R)===m);if(!P||!C)return;b();let L=Math.min(Fe(P),P.scrollTop+C.getBoundingClientRect().top-P.getBoundingClientRect().top);u(P,L);let E=Fe(P)-L<=tr;return h(E),E||p(P),C}}}var so=1e3,io=e=>`\u2068${e}\u2069`,sr=()=>typeof requestAnimationFrame=="function",lo=e=>sr()?requestAnimationFrame(e):setTimeout(e,16),$t=e=>{sr()?cancelAnimationFrame(e):clearTimeout(e)};function or(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 ir(e,t,n,o,a){let[l,c]=_react.useState.call(void 0, ""),s=_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,h=_react.useRef.call(void 0, {conversation:t,excerptOf:n,t:o});h.current={conversation:t,excerptOf:n,t:o};let b=(f,M)=>{let d=s.announced.get(f),m=!!d&&(d.has("completed")||d.has("failed"));return M==="arrived"?!m&&!_optionalChain([d, 'optionalAccess', _61 => _61.has, 'call', _62 => _62("arrived")])&&!s.writing.has(f):!m},u=()=>{s.timer=void 0;let f=[...s.pending],M=s.batchFor,d=s.batchShowing;s.pending.clear(),s.frame!==void 0&&$t(s.frame),c(""),s.frame=lo(()=>{s.frame=void 0,d===s.showing&&p(f,M)})},p=(f,M)=>{let d=_optionalChain([a, 'optionalAccess', _63 => _63.current]);if(_optionalChain([d, 'optionalAccess', _64 => _64.closest, 'call', _65 => _65("[inert]")])){for(let[y,k]of f)s.pending.set(y,k);s.held??=new MutationObserver(()=>{d.closest("[inert]")||(_optionalChain([s, 'access', _66 => _66.held, 'optionalAccess', _67 => _67.disconnect, 'call', _68 => _68()]),s.held=void 0,u())}),s.held.observe(d.ownerDocument.documentElement,{attributes:!0,attributeFilter:["inert"],subtree:!0});return}let{conversation:m,excerptOf:P,t:C}=h.current;if(!m||m.id!==M)return;let L=new Map(m.messages.map(y=>[y.id,y])),E=f.flatMap(([y])=>{let k=L.get(y),q=k&&or(k);return k&&q&&b(y,q)?[{id:y,stage:q,message:k}]:[]});if(!E.length)return;let R=new Map(m.messages.map((y,k)=>[y.id,k]));E.sort((y,k)=>R.get(y.id)-R.get(k.id));let N=E.length,W=E.filter(y=>y.stage==="failed").length,se=E.filter(y=>y.stage==="completed"),w=y=>{let k=P(y);return k===void 0?void 0:io(k)},v;if(N===1){let[y]=E,k=y.stage==="completed"?w(y.message):void 0;v=y.stage==="failed"?C("chat.arrivalFailed"):k!==void 0?C("chat.arrivalExcerpt",{excerpt:k}):C("chat.arrival")}else if(se.length===N){let y=w(se.at(-1).message);v=y!==void 0?C("chat.arrivalMany",{count:N,excerpt:y}):C("chat.arrivalManyPlain",{count:N})}else W===N?v=C("chat.arrivalAllFailed",{count:N}):W?v=C("chat.arrivalManyFailed",{count:N,failed:W}):v=C("chat.arrivalManyPlain",{count:N});for(let y of E){let k=_nullishCoalesce(s.announced.get(y.id), () => (new Set));k.add(y.stage),s.announced.set(y.id,k)}c(v)};return _react.useEffect.call(void 0, ()=>{if(s.client!==e&&(s.client=e,s.baselineFor=void 0),!t){s.baselineFor=void 0;return}if(s.baselineFor!==t.id){s.baselineFor=t.id,s.showing++,s.baseline=new Set(t.messages.map(f=>f.id)),s.announced.clear(),s.writing.clear(),s.pending.clear(),clearTimeout(s.timer),s.timer=void 0,s.frame!==void 0&&$t(s.frame),s.frame=void 0;return}for(let f of t.messages){if(s.baseline.has(f.id))continue;f.status==="writing"&&s.writing.add(f.id);let M=or(f);!M||!b(f.id,M)||(s.pending.size||(s.batchFor=t.id,s.batchShowing=s.showing),s.pending.set(f.id,M))}s.pending.size&&s.timer===void 0&&(s.timer=setTimeout(u,so))},[e,t]),_react.useEffect.call(void 0, ()=>()=>{clearTimeout(s.timer),s.frame!==void 0&&$t(s.frame),_optionalChain([s, 'access', _69 => _69.held, 'optionalAccess', _70 => _70.disconnect, 'call', _71 => _71()])},[s]),l}function lr(e,t){let[n,o]=_react.useState.call(void 0, !1),a=_react.useRef.call(void 0, e);return _react.useEffect.call(void 0, ()=>{let l=t.current;if(!l||typeof MutationObserver!="function")return;let c=()=>o(!!l.closest("[inert]"));c();let s=new MutationObserver(c);return s.observe(l.ownerDocument.documentElement,{attributes:!0,attributeFilter:["inert"],subtree:!0}),()=>s.disconnect()},[t]),n||(a.current=e),a.current}var co={"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.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"},et={en:{},zh:{}};function cr(e,t){Object.assign(et.en,e),Object.assign(et.zh,t)}var uo={"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.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"},fo=/^(tw|hk|mo)$/,po=/^(zh|cmn)$/,mo=/^([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})+)?$/,ho=/^zh-(hakka|min|xiang)\b/;function qt(e="en"){let t={catalogue:"en",lang:"en"},n=e.toLowerCase();if(!mo.test(n)||ho.test(n))return t;let o=n.split("-"),a=o[0],l=1;for(;/^[a-z]{3}$/.test(o[l]);)a=o[l++];if(po.test(a)){let c=o[l];return(/^[a-z]{4}$/.test(c)?c==="hans":!fo.test(c))?{catalogue:"zh",lang:e}:t}return a==="en"?{catalogue:"en",lang:e}:t}function Oe(e="en"){let t=qt(e),n=t.catalogue==="zh",o=n?uo:co,a=n?et.zh:et.en,l=_chunkQS3MKZOYcjs.b.call(void 0, t.lang,n),c=new Map;return(s,h)=>{let b=c.get(s);if(!b){let u=_nullishCoalesce(o[s], () => (a[s]));if(u===void 0)return"";b=new (0, _chunkQS3MKZOYcjs.a)(u,l),c.set(s,b)}return String(b.format(h))}}var zt=new Set,bo=e=>(zt.add(e),()=>zt.delete(e));function we(e){let t=o=>{n.load=o;for(let a of zt)a()},n={load:{status:"idle"},request(o){let{status:a}=n.load;a!=="idle"&&!(o&&a==="failed")||(t({status:"loading",...a==="failed"&&{retrying:!0}}),e().then(l=>t({status:"ready",module:l}),()=>t({status:"failed"})))}};return n}function pe(e){return _react.useSyncExternalStore.call(void 0, bo,()=>e.load,()=>e.load)}var tt=we(()=>Promise.resolve().then(() => _interopRequireWildcard(require("./markdown-BSRKJFFE.cjs")))),Qt=_react.createContext.call(void 0, null),kr=_react.createContext.call(void 0, void 0);function Co({id:e}){let t=_react.useContext.call(void 0, Qt);return _react.useEffect.call(void 0, ()=>(_optionalChain([t, 'optionalAccess', _72 => _72.report, 'call', _73 => _73(e,!0)]),()=>_optionalChain([t, 'optionalAccess', _74 => _74.report, 'call', _75 => _75(e,!1)])),[t,e]),null}function xo(){let e=pe(tt);return e.status==="ready"?e.module:void 0}var Be=e=>`wp${_react.useId.call(void 0, ).replace(/[^\w-]/g,"")}-${e}`,jt=we(()=>Promise.resolve().then(() => _interopRequireWildcard(require("./recovery-panel-OWY2CWOH.cjs")))),Po=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./confirmation-view-OMWHUYVC.cjs")))),Gt=we(()=>Promise.resolve().then(() => _interopRequireWildcard(require("./blocks-25YOJ5SS.cjs")))),dr=we(()=>Promise.resolve().then(() => _interopRequireWildcard(require("./reply-controls-CPWB4VBK.cjs"))));function Eo(e){let t=pe(dr);return _react.useEffect.call(void 0, ()=>dr.request(),[]),t.status==="ready"?_jsxruntime.jsx.call(void 0, t.module.ReplyControls,{...e}):null}var ur=we(()=>Promise.resolve().then(() => _interopRequireWildcard(require("./message-actions-F6SPLTT7.cjs"))));function So(e){let t=pe(ur);return _react.useEffect.call(void 0, ()=>ur.request(),[]),t.status==="ready"?_jsxruntime.jsx.call(void 0, t.module.MessageActions,{...e}):null}var Vt=we(()=>Promise.resolve().then(() => _interopRequireWildcard(require("./flows-panel-AIULKYOS.cjs"))));function en(){let e=pe(Gt);return _react.useEffect.call(void 0, ()=>Gt.request(),[]),e}function To({block:e}){let t=en();return t.status==="ready"?_jsxruntime.jsx.call(void 0, t.module.Answered,{block:e}):null}function Mo(e){let{format:t}=U(),n=en(),o=_jsxruntime.jsx.call(void 0, "p",{children:e.block.fallback});if(n.status==="failed")return o;if(n.status!=="ready")return _jsxruntime.jsx.call(void 0, "p",{children:t("chat.messageLoading")});let a=n.module.default;return _jsxruntime.jsx.call(void 0, He,{resetKey:e.block.id,fallback:o,children:_jsxruntime.jsx.call(void 0, a,{...e})})}var te=_react.createContext.call(void 0, null);function Ro({children:e,onPress:t,disabled:n,label:o,...a}){return _jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:t,disabled:n,"aria-label":o,...a,children:e})}function Fo({value:e,onChange:t,label:n,inputRef:o,onKeyDown:a,disabled:l,describedBy:c}){return _jsxruntime.jsx.call(void 0, "textarea",{ref:o,disabled:l,value:e,onChange:s=>_optionalChain([t, 'optionalCall', _76 => _76(s.target.value)]),"aria-label":n,"aria-describedby":c,onKeyDown:a})}function fr({value:e,onChange:t,label:n,type:o="text",disabled:a,invalid:l,describedBy:c,required:s}){return _jsxruntime.jsxs.call(void 0, "label",{children:[n,_jsxruntime.jsx.call(void 0, "input",{type:o,value:e,disabled:a,"aria-invalid":l,"aria-describedby":c,"aria-required":s||void 0,onChange:h=>t(h.target.value)})]})}function Lo({checked:e,onChange:t,label:n,disabled:o,invalid:a,describedBy:l}){return _jsxruntime.jsxs.call(void 0, "label",{className:"wp-check",children:[_jsxruntime.jsx.call(void 0, "input",{type:"checkbox",checked:e,disabled:o,"aria-invalid":a,"aria-describedby":l,onChange:c=>t(c.target.checked)}),n]})}function Io({children:e,open:t,label:n,onClose:o,closeLabel:a,focusInto:l,restoreFocus:c}){let s=_nullishCoalesce(_optionalChain([_react.useContext.call(void 0, te), 'optionalAccess', _77 => _77.format]), () => (Oe())),h=_react.useRef.call(void 0, null),b=_react.useRef.call(void 0, l),u=_react.useRef.call(void 0, c);b.current=l,u.current=c,_react.useLayoutEffect.call(void 0, ()=>{let f=h.current;if(!(!t||!f))return _optionalChain([b, 'access', _78 => _78.current, 'optionalCall', _79 => _79(f)]),()=>_optionalChain([u, 'access', _80 => _80.current, 'optionalCall', _81 => _81(f)])},[t]);let p=_react.useId.call(void 0, );return t?_jsxruntime.jsxs.call(void 0, "div",{ref:h,className:"wp-drawer",tabIndex:-1,role:"dialog","aria-modal":"true","aria-labelledby":p,onKeyDown:f=>{f.key==="Escape"&&o()},children:[_jsxruntime.jsxs.call(void 0, "div",{className:"wp-drawer-header",children:[_jsxruntime.jsx.call(void 0, "h2",{id:p,children:n}),_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:o,"aria-label":_nullishCoalesce(a, () => (s("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 Cr={button:Ro,textarea:Fo,input:fr,checkbox:Lo,datePicker:e=>_jsxruntime.jsx.call(void 0, fr,{...e,type:"datetime-local"}),drawer:Io},pr="(prefers-color-scheme: dark)";function No(){return _react.useSyncExternalStore.call(void 0, e=>{let t=_optionalChain([globalThis, 'access', _82 => _82.matchMedia, 'optionalCall', _83 => _83(pr)]);return _optionalChain([t, 'optionalAccess', _84 => _84.addEventListener, 'call', _85 => _85("change",e)]),()=>_optionalChain([t, 'optionalAccess', _86 => _86.removeEventListener, 'call', _87 => _87("change",e)])},()=>_optionalChain([globalThis, 'access', _88 => _88.matchMedia, 'optionalCall', _89 => _89(pr), 'access', _90 => _90.matches])?"dark":"light",()=>"light")}function Do(e){let t=_optionalChain([e, 'access', _91 => _91.useThemeTokens, 'optionalCall', _92 => _92()]),n=e.theme===void 0&&t&&(e.colorScheme===void 0||e.colorScheme===t.scheme)?"host":"waypoint",o=No(),a=_nullishCoalesce(_nullishCoalesce(e.colorScheme, () => (_optionalChain([t, 'optionalAccess', _93 => _93.scheme]))), () => (o)),l=_react.useMemo.call(void 0, ()=>({...e,colorScheme:a,format:_nullishCoalesce(e.format, () => (Oe(e.locale))),lang:e.format?_nullishCoalesce(e.locale, () => ("en")):qt(e.locale).lang,tokens:{...a==="dark"?_chunk4BWV3SELcjs.b:_chunk4BWV3SELcjs.a,...n==="host"?t.tokens:e.theme},primitives:{...Cr,...e.primitives}}),[e,a,n,t]),c=e.wrapper,s=_jsxruntime.jsx.call(void 0, _chunkM3UENQ6Lcjs.d.Provider,{value:e.client,children:_jsxruntime.jsx.call(void 0, te.Provider,{value:l,children:e.children})});return c?_jsxruntime.jsx.call(void 0, c,{colorScheme:a,tokens:l.tokens,tokenSource:n,children:s}):s}function Ia(){return _nullishCoalesce(_optionalChain([_react.useContext.call(void 0, te), 'optionalAccess', _94 => _94.colorScheme]), () => ("light"))}function U(){let e=_react.useContext.call(void 0, te);if(!e)throw new Error("WaypointProvider is required");return e}function Na(){return U().client}function Da(e){let t=_react.useContext.call(void 0, te),n=_nullishCoalesce(e, () => (_optionalChain([t, 'optionalAccess', _95 => _95.client]))),o=_chunkM3UENQ6Lcjs.e.call(void 0, e);return{conversationId:o.conversationId,conversation:o.conversation,refresh:n.refresh,editMessage:n.editMessage,regenerate:n.regenerate,selectVersion:n.selectVersion,switchConversation:n.switchConversation}}function Aa(e){let t=_react.useContext.call(void 0, te),n=_nullishCoalesce(e, () => (_optionalChain([t, 'optionalAccess', _96 => _96.client]))),o=_chunkM3UENQ6Lcjs.e.call(void 0, e);return{draft:o.draft,sending:o.sending,hints:o.hints,setDraft:n.setDraft,send:n.send,retry:n.retry,withdraw:n.withdraw,dismiss:n.dismiss}}function Oa(e){let t=_react.useContext.call(void 0, te),n=_nullishCoalesce(e, () => (_optionalChain([t, 'optionalAccess', _97 => _97.client]))),o=_chunkM3UENQ6Lcjs.e.call(void 0, e),{view:a}=_chunkM3UENQ6Lcjs.f.call(void 0, e);return{plan:o.plan,setPlan:n.setPlan,reply:n.reply,view:a}}function Ba(e){let t=_react.useContext.call(void 0, te),n=_nullishCoalesce(e, () => (_optionalChain([t, 'optionalAccess', _98 => _98.client]))),o=_chunkM3UENQ6Lcjs.e.call(void 0, e);return{flows:o.flows,tab:o.flowTab,load:n.loadFlows,select:n.selectFlowTab,setFavourite:n.setFavourite,run:n.runFlow}}var Ha=["bubble","composer","transcript","replyRow","stepRow","planNode","widgetFrame","confirmBar","confirmation","topBar","rail","flowTabs","quotaStrip","failedSendControls","emptyState","messageActions","extraPanels","actionBar","stepUpPrompt","fieldAdornment","recoveryPanel","stepStatusRow","recoveryActions"];function xr({action:e,onPress:t,label:n}){let{format:o,primitives:a}=U(),l=a.button,c=_react.useId.call(void 0, );return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, l,{"data-action":e.id,"aria-disabled":e.available?void 0:!0,"aria-describedby":e.reasonKey?c:void 0,"aria-busy":e.busy?!0:void 0,onPress:e.available?()=>t(e.id):void 0,children:_nullishCoalesce(n, () => ((e.countedLabelKey&&e.labelValues?o(e.countedLabelKey,e.labelValues):o(e.labelKey))))}),e.reasonKey?_jsxruntime.jsx.call(void 0, "span",{id:c,"data-reason":e.id,children:o(e.reasonKey,e.reasonValues)}):null]})}function mr(e){let t=_react.useRef.call(void 0, !1),[n,o]=_react.useState.call(void 0, !1),a=()=>{t.current=!1,o(!1)};return{busy:n,press:()=>{t.current||(t.current=!0,o(!0),e().then(a,a))}}}function hr({problem:e,refresh:t}){let n=_chunkM3UENQ6Lcjs.i.call(void 0, e),o=_react.useMemo.call(void 0, ()=>Date.now()+(_nullishCoalesce(e.retryAfter, () => (0)))*1e3,[e]),[a,l]=_react.useState.call(void 0, 0),c=e.code==="rate-limited"&&Date.now()<o;return _react.useEffect.call(void 0, ()=>{if(!c)return;let s=setTimeout(()=>l(h=>h+1),Math.max(o-Date.now(),1));return()=>clearTimeout(s)},[c,o,a]),n?_jsxruntime.jsx.call(void 0, xr,{action:{id:"status",labelKey:n==="retry"?"chat.retry":"chat.problem.refresh",available:!c&&!t.busy,busy:t.busy,...c&&{reasonKey:"chat.problem.rateLimited"}},onPress:t.press}):null}function gr({problem:e}){let{format:t}=U();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 nt=e=>e.status==="loading"&&!!e.retrying;function Xt(e){let{format:t,primitives:n}=U(),o=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":o,"aria-busy":o,onPress:()=>{o||e.onRetry()},children:t("chat.retry")})]}),_jsxruntime.jsx.call(void 0, "span",{role:"status",children:o?t("chat.loading"):""})]})}function Ao(e){let{format:t}=U(),n=pe(jt);_react.useEffect.call(void 0, ()=>jt.request(),[]);let o=_react.useRef.call(void 0, null),a=Mt(()=>[_optionalChain([o, 'access', _99 => _99.current, 'optionalAccess', _100 => _100.querySelector, 'call', _101 => _101("h3")])]),l=n.status==="ready"&&n.module.default;return _jsxruntime.jsx.call(void 0, "div",{ref:o,tabIndex:-1,"data-recovery":"",children:l?_jsxruntime.jsx.call(void 0, l,{...e}):n.status==="failed"||nt(n)?_jsxruntime.jsx.call(void 0, Xt,{retrying:nt(n),onRetry:()=>jt.request(!0),onFocus:a}):_jsxruntime.jsx.call(void 0, "p",{children:t("chat.loading")})})}function br(e){return{id:e.id,type:e.type,answered:!!e.answered}}function vr(e){return{id:e.id,content:e.content,failure:e.failure?{code:e.failure.code}:null}}function B({name:e,slots:t,children:n,...o}){let l=_optionalChain([_react.useContext.call(void 0, te), 'optionalAccess', _102 => _102.parts, 'optionalAccess', _103 => _103[e]]),c=_optionalChain([t, 'optionalAccess', _104 => _104[e]]),s=c?c({...o,children:n}):l?_jsxruntime.jsx.call(void 0, l,{...o,children:n}):n;return _jsxruntime.jsx.call(void 0, "div",{"data-part":e,children:s})}var He= (_class2 =class extends _react.Component{constructor(...args) { super(...args); _class2.prototype.__init3.call(this); }__init3() {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}}, _class2);function Oo({text:e,writing:t,sources:n}){let o=U(),a=o.format,l=_react.useContext.call(void 0, Qt),c=_react.useId.call(void 0, ),s=_nullishCoalesce(_react.useContext.call(void 0, kr), () => (c)),h=l?_jsxruntime.jsx.call(void 0, Co,{id:s}):_jsxruntime.jsx.call(void 0, "p",{children:a("chat.messageUnavailable")}),b=pe(tt);if(_react.useEffect.call(void 0, ()=>{tt.request(!0)},[e]),b.status==="failed")return h;if(b.status!=="ready")return _jsxruntime.jsx.call(void 0, "p",{children:a("chat.messageLoading")});let u=b.module.default;return _jsxruntime.jsx.call(void 0, He,{resetKey:`${e}:${_nullishCoalesce(_optionalChain([l, 'optionalAccess', _105 => _105.retry]), () => (0))}`,fallback:h,children:_jsxruntime.jsx.call(void 0, u,{text:e,writing:t,lang:o.lang,sources:n,sourceNames:{list:p=>a("chat.sources",{count:p}),item:(p,f)=>a("chat.source",{index:p,title:f})},images:o.markdownImages,extraSchemes:o.extraUrlSchemes,scrollLabel:a("chat.scrollRegion")})})}function Pr(e){let t=_optionalChain([U, 'call', _106 => _106(), 'access', _107 => _107.renderers, 'optionalAccess', _108 => _108.markdown]);return t?_jsxruntime.jsx.call(void 0, t,{text:e.text}):_jsxruntime.jsx.call(void 0, Oo,{...e})}function Bo(e,t){return{text:t(_chunkM3UENQ6Lcjs.j.call(void 0, e).key)||t("chat.failure")}}function Ho({block:e,onReply:t,disabled:n}){let{format:o,primitives:a,extraUrlSchemes:l}=U(),c=a.button,s=e.body;switch(e.type){case"form.fill":case"table":case"diff":case"form":case"choice":case"plan":return _jsxruntime.jsx.call(void 0, Mo,{block:e,onReply:t,disabled:n});case"markdown":return _jsxruntime.jsx.call(void 0, Pr,{text:String(_nullishCoalesce(s.text, () => ("")))});case"notice":return _jsxruntime.jsx.call(void 0, "p",{children:String(_nullishCoalesce(s.text, () => ("")))});case"card":return _jsxruntime.jsxs.call(void 0, "section",{children:[_jsxruntime.jsx.call(void 0, "h3",{children:String(_nullishCoalesce(s.title, () => ("")))}),(_nullishCoalesce(s.blocks, () => ([]))).map(h=>_jsxruntime.jsx.call(void 0, Yt,{block:h,disabled:n,onReply:t},h.id))]});case"details":return _jsxruntime.jsxs.call(void 0, "details",{children:[_jsxruntime.jsx.call(void 0, "summary",{children:String(_nullishCoalesce(s.summary, () => ("")))}),(_nullishCoalesce(s.blocks, () => ([]))).map(h=>_jsxruntime.jsx.call(void 0, Yt,{block:h,disabled:n,onReply:t},h.id))]});case"list":return _jsxruntime.jsx.call(void 0, "ul",{children:(_nullishCoalesce(s.items, () => ([]))).map((h,b)=>_jsxruntime.jsx.call(void 0, "li",{children:h},b))});case"route-link":{let h=String(_nullishCoalesce(s.route, () => ("")));return _chunkFBADWFRRcjs.a.call(void 0, h,l)?_jsxruntime.jsx.call(void 0, "a",{href:h,children:String(_nullishCoalesce(s.label, () => (o("chat.view"))))}):_jsxruntime.jsx.call(void 0, "span",{children:e.fallback})}case"buttons":return _jsxruntime.jsx.call(void 0, "div",{children:(_nullishCoalesce(s.actions, () => ([]))).map(h=>_jsxruntime.jsx.call(void 0, c,{disabled:n,onPress:()=>t({kind:"action",blockId:e.id,actionId:h.id}),children:h.label},h.id))});default:return _jsxruntime.jsx.call(void 0, "p",{children:e.fallback})}}var Uo=["markdown","form.fill","card","details","list","table","form","choice","buttons","diff","plan","route-link","notice"].map(e=>({type:e,render:Ho}));function Yt(e){let{widgets:t,format:n}=U(),o=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _109 => _109.find, 'call', _110 => _110(l=>l.type===e.block.type)]), () => (Uo.find(l=>l.type===e.block.type)));if(!o)return _jsxruntime.jsx.call(void 0, "div",{"data-fallback":"true",children:_jsxruntime.jsx.call(void 0, "p",{children:_optionalChain([e, 'access', _111 => _111.block, 'access', _112 => _112.fallback, 'optionalAccess', _113 => _113.trim, 'call', _114 => _114()])?e.block.fallback:n("unsupportedContent")})});let a=o.render;return _jsxruntime.jsx.call(void 0, a,{...e})}function $o(e){let{format:t,primitives:n}=U(),o=en(),a=n.button,l=_react.useRef.call(void 0, null),[c,s]=_react.useState.call(void 0, 0),h=_react.useRef.call(void 0, null);_react.useLayoutEffect.call(void 0, ()=>{let p=l.current;X(p,{root:p,owner:"",removed:h.current})});let b=_jsxruntime.jsxs.call(void 0, "p",{role:"alert",children:[t("chat.planUnavailable"),_jsxruntime.jsx.call(void 0, a,{onPress:()=>{h.current=document.activeElement,s(c+1),Gt.request(!0)},children:t("chat.retry")})]}),u=o.status==="ready"&&o.module.PlanSteps;return _jsxruntime.jsx.call(void 0, "div",{ref:l,tabIndex:-1,children:u?_jsxruntime.jsx.call(void 0, He,{resetKey:`${e.record.id}:${c}`,fallback:b,children:_jsxruntime.jsx.call(void 0, u,{...e})}):o.status==="failed"?b:_jsxruntime.jsx.call(void 0, "p",{children:t("chat.messageLoading")})})}function Ua(e){let t=_react.useContext.call(void 0, te);return e.client?_jsxruntime.jsx.call(void 0, Do,{...e,client:e.client,children:_jsxruntime.jsx.call(void 0, wr,{...e})}):t?_jsxruntime.jsx.call(void 0, wr,{...e}):_jsxruntime.jsx.call(void 0, "section",{className:"waypoint",dir:_nullishCoalesce(e.dir, () => ("ltr")),children:_jsxruntime.jsx.call(void 0, "p",{children:Oe(e.locale)("chat.empty")})})}var yr="\uE000";function Wo({messages:e,excerpts:t,anchor:n,open:o,onToggle:a,onNavigate:l}){let{format:c,primitives:s}=U(),h=s.button,b=Be("outline");return _jsxruntime.jsxs.call(void 0, "nav",{"aria-label":c("chat.outline"),"data-outline":"",className:"wp-outline",children:[_jsxruntime.jsx.call(void 0, h,{"aria-expanded":o,"aria-controls":b,onPress:a,children:c("chat.outline")}),_jsxruntime.jsx.call(void 0, "ol",{id:b,hidden:!o,role:"list",children:o?e.map((u,p)=>{let f={role:c(u.role==="user"?"chat.roleUser":"chat.roleAssistant"),position:p+1},M=t[p],d=M===void 0?void 0:c("chat.outlineItem",{...f,excerpt:yr}).split(yr);return _jsxruntime.jsx.call(void 0, "li",{children:_jsxruntime.jsx.call(void 0, "a",{href:`#${n(u.id)}`,"data-outline-link":u.id,onClick:m=>{m.preventDefault(),l(u.id)},children:d?d.length===2?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[d[0],_jsxruntime.jsx.call(void 0, "bdi",{children:M}),d[1]]}):_jsxruntime.jsx.call(void 0, "bdi",{children:c("chat.outlineItem",{...f,excerpt:M})}):c("chat.outlineItemPlain",f)})},u.id)}):null})]})}function Ko({label:e,closeLabel:t,onClose:n,skipRestore:o,onFocusWithin:a,children:l}){let c=U().primitives.drawer,s=Ot("rail"),h=_react.useRef.call(void 0, void 0),b=_react.useRef.call(void 0, a);return b.current=a,_jsxruntime.jsx.call(void 0, At,{as:c,open:!0,label:e,closeLabel:t,onClose:n,focusInto:u=>{let p=f=>b.current(ve(f));u.addEventListener("focusin",p),h.current={element:u,listener:p},_optionalChain([s, 'access', _115 => _115.focusInto, 'optionalCall', _116 => _116(u)])},restoreFocus:u=>{let p=h.current;h.current=void 0,_optionalChain([p, 'optionalAccess', _117 => _117.element, 'access', _118 => _118.removeEventListener, 'call', _119 => _119("focusin",p.listener)]),o()?_optionalChain([s, 'access', _120 => _120.release, 'optionalCall', _121 => _121()]):_optionalChain([s, 'access', _122 => _122.restoreFocus, 'optionalCall', _123 => _123(u)])},children:l})}function wr({slots:e,features:t,layout:n="panel",shortcuts:o,conversations:a=[],conversationSource:l,quota:c,onStop:s,suggestions:h=[]}){let b=_react.useId.call(void 0, ),u=U(),{client:p,format:f,tokens:M}=u,d=_chunkM3UENQ6Lcjs.e.call(void 0, ),m=_react.useRef.call(void 0, null),P=_react.useRef.call(void 0, null),C=_react.useRef.call(void 0, null),L=_react.useRef.call(void 0, null),E=_react.useRef.call(void 0, new Set).current,[,R]=_react.useState.call(void 0, 0),[N,W]=_react.useState.call(void 0, 0),se=_react.useMemo.call(void 0, ()=>({retry:N,report(r,g){E.has(r)!==g&&(g?E.add(r):E.delete(r),R(F=>F+1))}}),[N,E]),{isAnswered:w,reply:v}=_chunkM3UENQ6Lcjs.h.call(void 0, p),y=_react.useRef.call(void 0, null),k=_react.useRef.call(void 0, null),q=_react.useRef.call(void 0, new Set),[ie,D]=_react.useState.call(void 0, 0),[le,he]=_react.useState.call(void 0, !1),[Ce,nn]=_react.useState.call(void 0, ),rt=mr(()=>p.refresh()),rn=mr(()=>p.refresh()),ot=_chunkM3UENQ6Lcjs.f.call(void 0, p),G=u.primitives.button,Er=u.primitives.textarea,on=!!(_optionalChain([e, 'optionalAccess', _124 => _124.extraPanels])||_optionalChain([u, 'access', _125 => _125.parts, 'optionalAccess', _126 => _126.extraPanels])),an=Be("hint"),We=Be("pending"),Ke=r=>(_optionalChain([d, 'access', _127 => _127.conversation, 'optionalAccess', _128 => _128.mode])!=="form-fill"||r==="form-fill"||r==="widgets")&&d.capabilities.includes(r)&&(!t||t.includes(r)),[Sr,at]=_react.useState.call(void 0, "loading"),sn=()=>{at(r=>r==="failed"?"retrying":"loading"),p.loadFlows().then(()=>at("done"),()=>at("failed"))};_react.useEffect.call(void 0, sn,[p]);let[,Tr]=_react.useState.call(void 0, !1);_react.useEffect.call(void 0, ()=>{Promise.resolve().then(() => _interopRequireWildcard(require("./problem-messages-THONMXFZ.cjs"))).then(r=>{cr(r.problemEnglish,r.problemSimplifiedChinese),Tr(!0)})},[]);let T=Yn(m,Re(p,d.conversationId),P,C,r=>Re(p,r)),z=_nullishCoalesce(_optionalChain([d, 'access', _129 => _129.conversation, 'optionalAccess', _130 => _130.messages]), () => ([])),ge=_optionalChain([d, 'access', _131 => _131.conversation, 'optionalAccess', _132 => _132.id]),[st,ln]=_react.useState.call(void 0, {open:!1});st.conversationId!==ge&&ln({conversationId:ge,open:!1});let it=st.conversationId===ge&&st.open,Mr=`wp${b.replace(/[^\w-]/g,"")}`,cn=r=>`${Mr}-${r.replace(/[^A-Za-z0-9-]/gu,g=>`_${g.codePointAt(0)}_`)}`,qe=rr(C,L,ge,z.length,d),lt=_react.useRef.call(void 0, void 0),Rr=r=>{let g=r.target,F=z.map(Q=>Q.id),I={owner:T.value.owner(),shown:ge,order:F},A=g.closest("[data-outline-link]"),H=g.closest("[data-back-to-latest]"),$=g.closest("article[data-message-id]");lt.current=A?{...I,kind:"link",id:A.getAttribute("data-outline-link"),element:A}:H?{...I,kind:"latest",element:H}:$&&O(C.current,$)?{...I,kind:"message",id:$.getAttribute("data-message-id"),element:$}:void 0};_react.useLayoutEffect.call(void 0, ()=>{let r=lt.current;if(!r||r.element.isConnected)return;lt.current=void 0;let g=C.current,F=_optionalChain([g, 'optionalAccess', _133 => _133.parentElement]),I=(H,$)=>{let Q=new Map;for(let re of _nullishCoalesce(_optionalChain([$, 'optionalAccess', _134 => _134.querySelectorAll, 'call', _135 => _135(`[${H}]`)]), () => ([])))Q.set(re.getAttribute(H),re);let fe=r.order.indexOf(r.id);for(let re=fe+1;re<r.order.length;re++){let De=Q.get(r.order[re]);if(De)return De}for(let re=fe-1;re>=0;re--){let De=Q.get(r.order[re]);if(De)return De}},A=r.kind==="message"?_nullishCoalesce(I("data-message-id",g), () => (g)):r.kind==="link"?_nullishCoalesce(_nullishCoalesce(I("data-outline-link",F), () => (_optionalChain([F, 'optionalAccess', _136 => _136.querySelector, 'call', _137 => _137("nav[data-outline] [aria-expanded]")]))), () => (g)):g;ee(T.value,A,{owner:r.owner,stillCurrent:()=>T.value.owner()===r.owner&&_optionalChain([p, 'access', _138 => _138.getSnapshot, 'call', _139 => _139(), 'access', _140 => _140.conversation, 'optionalAccess', _141 => _141.id])===r.shown,removed:r.element,fallback:g})});let dn=a.length>0||!!l,[Z,Fr]=_react.useState.call(void 0, !1),[xe,Le]=_react.useState.call(void 0, !1),un=Be("rail"),Lr=It(xe,T.value.owner(),()=>Le(!1)),ct=_react.useRef.call(void 0, void 0),dt=_react.useRef.call(void 0, !1),ze=_react.useRef.call(void 0, !1),Ir=()=>{let r=dt.current||ze.current;return dt.current=!1,r};_react.useLayoutEffect.call(void 0, ()=>{let r=m.current;if(!r||typeof ResizeObserver!="function")return;let g=()=>{let I=r.getBoundingClientRect().width,A=parseFloat(getComputedStyle(r).fontSize)||16;Fr(I>0&&I<40*A)},F=new ResizeObserver(g);return F.observe(r),g(),()=>F.disconnect()},[]);let fn=_react.useRef.call(void 0, Z);_react.useLayoutEffect.call(void 0, ()=>{fn.current&&!Z&&xe&&(ze.current=!0,Le(!1)),fn.current=Z},[Z,xe]),_react.useLayoutEffect.call(void 0, ()=>{if(!ze.current||xe)return;ze.current=!1;let r=ct.current;if(ct.current=void 0,!r||r.element.isConnected)return;let g=_optionalChain([m, 'access', _142 => _142.current, 'optionalAccess', _143 => _143.querySelector, 'call', _144 => _144('[data-part="rail"] nav')]),F=r.id?_optionalChain([[..._nullishCoalesce(_optionalChain([g, 'optionalAccess', _145 => _145.querySelectorAll, 'call', _146 => _146("[data-conversation-id]")]), () => ([]))], 'access', _147 => _147.find, 'call', _148 => _148(I=>I.getAttribute("data-conversation-id")===r.id), 'optionalAccess', _149 => _149.querySelector, 'call', _150 => _150("button")]):void 0;ee(T.value,_nullishCoalesce(_nullishCoalesce(F, () => (g)), () => (C.current)),{owner:r.owner,stillCurrent:()=>T.value.owner()===r.owner,removed:r.element,fallback:C.current})});let je=_react.useRef.call(void 0, void 0),pn=T.value.owner();qe.pinned||!z.length?je.current=void 0:_optionalChain([je, 'access', _151 => _151.current, 'optionalAccess', _152 => _152.owner])!==pn&&(je.current={owner:pn,ids:new Set(z.map(r=>r.id))});let mn=je.current,hn=mn?z.filter(r=>r.role==="assistant"&&!mn.ids.has(r.id)).length:0,ut=xo(),ft=!!(_optionalChain([u, 'access', _153 => _153.renderers, 'optionalAccess', _154 => _154.markdown])||_optionalChain([u, 'access', _155 => _155.parts, 'optionalAccess', _156 => _156.bubble])||_optionalChain([u, 'access', _157 => _157.parts, 'optionalAccess', _158 => _158.transcript])||_optionalChain([e, 'optionalAccess', _159 => _159.bubble])||_optionalChain([e, 'optionalAccess', _160 => _160.transcript])),pt=_react.useRef.call(void 0, new Ze).current;pt.begin(Re(p,_nullishCoalesce(ge, () => (""))),[ft,u.messageExcerpt,ut,_optionalChain([u, 'access', _161 => _161.markdownImages, 'optionalAccess', _162 => _162.origin]),_optionalChain([u, 'access', _163 => _163.markdownImages, 'optionalAccess', _164 => _164.allow]),_optionalChain([u, 'access', _165 => _165.extraUrlSchemes, 'optionalAccess', _166 => _166.join, 'call', _167 => _167(" ")])],z.map(r=>({id:r.id,source:ft?r:r.content})));let gn=r=>{if(ft)return pt.get(r.id,r,g=>{let F=_optionalChain([u, 'access', _168 => _168.messageExcerpt, 'optionalCall', _169 => _169(g)]);return F===void 0?void 0:Bt(F)});if(ut)return pt.get(r.id,r.content,g=>Bt(ut.visibleText(g,{images:u.markdownImages,extraSchemes:u.extraUrlSchemes})))},Nr=it?z.map(gn):[],bn=_react.useRef.call(void 0, null),Dr=ir(p,d.conversation,gn,f,bn),be=Be("flows"),vn=_react.useRef.call(void 0, ""),yn=Mt(()=>{let r=_optionalChain([m, 'access', _170 => _170.current, 'optionalAccess', _171 => _171.querySelector, 'call', _172 => _172(`[id="${be}-panel"]`)]);return[_optionalChain([r, 'optionalAccess', _173 => _173.querySelector, 'call', _174 => _174(`[data-flow="${vn.current}"] button`)]),r]}),Ie=pe(Vt),wn=Ke("flows");_react.useEffect.call(void 0, ()=>{wn&&Vt.request()},[wn]);let[Ne,kn]=_react.useState.call(void 0, void 0),Cn=(r,g={})=>{let F=p,I=T.value.owner(),A=Re(F,`flow:${r}`),H=T.value.originFor("run-flow",A);kn(void 0),F.runFlow(r,g).then($=>{let Q=$&&Re(F,$);ee(T.value,P.current,{origin:H,owner:A,stillCurrent:()=>!!Q&&T.value.owner()===Q&&_optionalChain([F, 'access', _175 => _175.getSnapshot, 'call', _176 => _176(), 'access', _177 => _177.conversation, 'optionalAccess', _178 => _178.id])===$})},()=>{ce(H),kn({id:r,owner:I,values:g})})},Pe=d.replyState,Ee=z.at(-1),Ve=Pe==="writing"&&_optionalChain([Ee, 'optionalAccess', _179 => _179.status])==="writing"?Ee.id:void 0,Ar=_optionalChain([Ee, 'optionalAccess', _180 => _180.role])==="assistant"&&(Ee.status==="failed"||Ee.status==="unavailable")&&Pe===Ee.status,xn=_react.useRef.call(void 0, null),mt=lr(Pe,xn),Or=(r,g)=>F=>{let I=V(document),A=_chunkM3UENQ6Lcjs.g.call(void 0, d.conversationId,g,r.id,F),H=!q.current.has(A);q.current.add(A),v(r,F,g).then($=>{H&&q.current.delete(A);let Q=p.getSnapshot();_optionalChain([$, 'optionalAccess', _181 => _181.accepted])===!1&&_optionalChain([$, 'access', _182 => _182.problem, 'optionalAccess', _183 => _183.code])==="refused"&&_optionalChain([Q, 'access', _184 => _184.conversation, 'optionalAccess', _185 => _185.messages, 'access', _186 => _186.find, 'call', _187 => _187(fe=>fe.id===g), 'optionalAccess', _188 => _188.blocks, 'access', _189 => _189.find, 'call', _190 => _190(fe=>fe.id===r.id), 'optionalAccess', _191 => _191.answered])&&(k.current=Q.problem),y.current=I,D(fe=>fe+1)})};_react.useLayoutEffect.call(void 0, ()=>{let r=y.current,g=T.value.root();y.current=null,r&&g&&X(oe(r)?r:T.value.composer(),{root:g,owner:"",removed:r})},[ie]);let Pn=!!d.problem&&d.problem===k.current,de=d.problem&&!q.current.has(d.problem.id)?_nullishCoalesce(_optionalChain([u, 'access', _192 => _192.problemText, 'optionalCall', _193 => _193(d.problem,{answeredElsewhere:Pn})]), () => ((Pn?{text:f("chat.problem.answered")||f("chat.failure")}:Bo(d.problem,f)))):null,J=d.plan,j=ot.view,_e=de&&_optionalChain([d, 'access', _194 => _194.problem, 'optionalAccess', _195 => _195.id])!=="conversation-unavailable"&&!(_optionalChain([d, 'access', _196 => _196.problem, 'optionalAccess', _197 => _197.code])==="stopped"&&_optionalChain([j, 'optionalAccess', _198 => _198.status]))&&!_optionalChain([d, 'access', _199 => _199.problem, 'optionalAccess', _200 => _200.confirmation])&&!(d.conversationUnavailable&&_optionalChain([d, 'access', _201 => _201.problem, 'optionalAccess', _202 => _202.id])==="conversation-read")?d.problem:void 0,Se=_e&&d.pending.some(r=>r.failure&&r.id===_e.id)?_e:void 0,ht=Se?void 0:_e,gt=_optionalChain([j, 'optionalAccess', _203 => _203.actions, 'access', _204 => _204.find, 'call', _205 => _205(r=>r.id==="confirm")]),En=_optionalChain([j, 'optionalAccess', _206 => _206.actions, 'access', _207 => _207.find, 'call', _208 => _208(r=>r.id==="stop")]),ue=_chunk3KV7TDDRcjs.l.call(void 0, J,d.conversationId),Br=r=>{if(le)return;let g=p.getSnapshot();if(_optionalChain([_chunk3KV7TDDRcjs.l.call(void 0, g.plan,g.conversationId), 'optionalAccess', _209 => _209.token])!==r){nn(r);return}nn(void 0),he(!0),p.confirmPlan().finally(()=>he(!1))},Sn=d.confirmationRefusal,Hr=_optionalChain([Sn, 'optionalAccess', _210 => _210.token])===_optionalChain([ue, 'optionalAccess', _211 => _211.token])&&_optionalChain([Sn, 'optionalAccess', _212 => _212.problemId])===_optionalChain([d, 'access', _213 => _213.problem, 'optionalAccess', _214 => _214.id])?_optionalChain([d, 'access', _215 => _215.problem, 'optionalAccess', _216 => _216.confirmation, 'optionalAccess', _217 => _217.reason]):void 0,Ur=Ce!==void 0&&Ce!==_optionalChain([ue, 'optionalAccess', _218 => _218.token]),$r=Z?"section":"aside",Wr=_optionalChain([J, 'optionalAccess', _219 => _219.state])==="awaiting-confirmation"&&!_optionalChain([j, 'optionalAccess', _220 => _220.readOnly])&&ue!==void 0,bt=Ke("plans")&&J?_jsxruntime.jsxs.call(void 0, $r,{"aria-label":f("chat.plan"),"data-plan":"",children:[_jsxruntime.jsx.call(void 0, $o,{record:J,slots:e,view:j,changesShown:Wr}),_jsxruntime.jsxs.call(void 0, B,{name:"confirmBar",slots:e,data:j?{view:j,actions:j.actions.filter(r=>j.status?r.id==="confirm":r.id==="confirm"||r.id==="stop")}:void 0,children:[J.state==="awaiting-confirmation"&&!_optionalChain([j, 'optionalAccess', _221 => _221.readOnly])?_jsxruntime.jsx.call(void 0, B,{name:"confirmation",slots:e,data:ue&&{confirmation:ue},children:_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, Po,{record:ue,planId:J.id,entry:gt&&(le?{...gt,available:!1,busy:!0}:gt),onConfirm:()=>ue&&Br(ue.token),refusal:Hr,override:u.problemText&&de,replaced:Ur})})}):null,!_optionalChain([j, 'optionalAccess', _222 => _222.status])&&En?_jsxruntime.jsx.call(void 0, xr,{action:En,onPress:_nullishCoalesce(s, () => ((()=>p.stopPlan())))}):null]}),_optionalChain([j, 'optionalAccess', _223 => _223.status])?_jsxruntime.jsx.call(void 0, Ao,{view:j,onPress:ot.press,slots:e,sheet:ot.sheet,hide:["confirm"]}):null]}):null,Tn=z.at(-1),vt=Z&&bt&&!d.pending.length&&_optionalChain([Tn, 'optionalAccess', _224 => _224.blocks, 'access', _225 => _225.some, 'call', _226 => _226(r=>r.type==="plan"&&_optionalChain([r, 'access', _227 => _227.body, 'optionalAccess', _228 => _228.planId])===_optionalChain([J, 'optionalAccess', _229 => _229.id]))])?Tn:void 0,Mn=r=>_jsxruntime.jsx.call(void 0, B,{name:"messageActions",slots:e,data:{message:{id:r.id,role:r.role,status:r.status,versionIndex:r.versionIndex,versionCount:r.versionCount}},children:_jsxruntime.jsx.call(void 0, So,{client:p,message:r})});return _jsxruntime.jsx.call(void 0, Lt.Provider,{value:T.value,children:_jsxruntime.jsx.call(void 0, "section",{ref:m,className:"waypoint",dir:_nullishCoalesce(u.dir, () => ("ltr")),lang:u.lang,"data-layout":n,"data-color-scheme":_nullishCoalesce(u.colorScheme, () => ("light")),"data-custom-theme":u.theme?"":void 0,style:{..._chunk4BWV3SELcjs.c.call(void 0, M),colorScheme:_nullishCoalesce(u.colorScheme, () => ("light"))},...T.captureProps,onKeyDown:r=>{_optionalChain([o, 'optionalAccess', _230 => _230.focusComposer])===!1||r.key!==(_nullishCoalesce(_optionalChain([o, 'optionalAccess', _231 => _231.focusComposer]), () => ("/")))||!O(r.currentTarget,ve(r.nativeEvent))||!Jn(r.currentTarget)||r.currentTarget.querySelector(_chunkGT6PI4CTcjs.b)||(r.preventDefault(),_optionalChain([P, 'access', _232 => _232.current, 'optionalAccess', _233 => _233.focus, 'call', _234 => _234()]))},children:_jsxruntime.jsxs.call(void 0, "div",{className:"wp-shell","data-has-aside":Ke("plans")&&J||on?"":void 0,"data-has-rail":dn||_optionalChain([e, 'optionalAccess', _235 => _235.rail])||_optionalChain([u, 'access', _236 => _236.parts, 'optionalAccess', _237 => _237.rail])?"":void 0,children:[Z?null:_jsxruntime.jsx.call(void 0, B,{name:"rail",slots:e,children:_jsxruntime.jsx.call(void 0, _t,{conversations:a,source:l})}),_jsxruntime.jsxs.call(void 0, "main",{children:[_jsxruntime.jsxs.call(void 0, B,{name:"topBar",slots:e,children:[Z&&dn?_jsxruntime.jsx.call(void 0, "span",{"data-rail-toggle":"",children:_jsxruntime.jsx.call(void 0, G,{"aria-expanded":xe,"aria-controls":un,onPress:()=>Le(r=>!r),children:f("chat.rail")})}):null,_jsxruntime.jsx.call(void 0, "h2",{children:_optionalChain([d, 'access', _238 => _238.conversation, 'optionalAccess', _239 => _239.title])||f("chat.title")})]}),Z&&xe&&!Lr?_jsxruntime.jsx.call(void 0, Ko,{label:f("chat.rail"),closeLabel:f("chat.close"),onClose:()=>Le(!1),skipRestore:Ir,onFocusWithin:r=>{let g=r.closest("[data-conversation-id]");ct.current={element:r,id:_nullishCoalesce(_optionalChain([g, 'optionalAccess', _240 => _240.getAttribute, 'call', _241 => _241("data-conversation-id")]), () => (void 0)),owner:T.value.owner()}},children:_jsxruntime.jsx.call(void 0, "div",{id:un,children:_jsxruntime.jsx.call(void 0, _t,{conversations:a,source:l,onChoose:()=>{let r=T.value.originFor("rail-choice");dt.current=!0,ee(T.value,_optionalChain([m, 'access', _242 => _242.current, 'optionalAccess', _243 => _243.querySelector, 'call', _244 => _244("[data-rail-toggle] button")]),{origin:r,owner:T.value.owner()}),Le(!1)}})})}):null,_jsxruntime.jsx.call(void 0, B,{name:"transcript",slots:e,children:_jsxruntime.jsxs.call(void 0, "div",{onFocusCapture:Rr,children:[z.length?_jsxruntime.jsx.call(void 0, Wo,{messages:z,excerpts:Nr,anchor:cn,open:it,onToggle:()=>ln({conversationId:ge,open:!it}),onNavigate:r=>{let g=T.value.originFor("outline");ee(T.value,qe.toMessage(r),{origin:g,owner:T.value.owner()})}}):null,_jsxruntime.jsx.call(void 0, "div",{ref:C,className:"wp-transcript",role:"region","aria-label":f("chat.transcript"),tabIndex:-1,children:_jsxruntime.jsx.call(void 0, Qt.Provider,{value:se,children:_jsxruntime.jsxs.call(void 0, "div",{ref:L,children:[!d.conversation&&!d.conversationUnavailable&&!d.problem?_jsxruntime.jsx.call(void 0, "p",{children:f("chat.startupLoading")}):z.length?null:_jsxruntime.jsx.call(void 0, B,{name:"emptyState",slots:e,children:_jsxruntime.jsx.call(void 0, "p",{children:f("chat.empty")})}),z.map(r=>_jsxruntime.jsxs.call(void 0, "article",{id:cn(r.id),tabIndex:-1,"data-message-id":r.id,"data-role":r.role,"aria-busy":r.id===Ve?!0:void 0,"aria-label":f(r.role==="user"?"chat.roleUser":"chat.roleAssistant"),"data-body-unavailable":E.has(r.id)&&!r.blocks.length?"":void 0,children:[_jsxruntime.jsxs.call(void 0, B,{name:"bubble",slots:e,data:{message:{id:r.id,role:r.role,content:r.content,status:r.status,versionIndex:r.versionIndex,versionCount:r.versionCount,blocks:r.blocks.map(br)}},children:[_jsxruntime.jsx.call(void 0, "span",{"data-sender":"","aria-hidden":"true",children:f(r.role==="user"?"chat.roleUser":"chat.roleAssistant")}),_jsxruntime.jsx.call(void 0, kr.Provider,{value:r.id,children:_jsxruntime.jsx.call(void 0, Pr,{text:r.content,writing:r.id===Ve,sources:r.sources})}),r.id===Ve?_jsxruntime.jsx.call(void 0, "span",{"data-writing":"","aria-hidden":"true",children:f("reply.writing")}):r.status==="stopped"?_jsxruntime.jsx.call(void 0, "span",{"data-stopped":"",children:f("reply.stopped")}):r.status==="failed"||r.status==="unavailable"?_jsxruntime.jsx.call(void 0, "span",{"data-reply-ended":r.status,children:f(`reply.${r.status}`)}):null,r.blocks.map(g=>_jsxruntime.jsx.call(void 0, B,{name:"widgetFrame",slots:e,data:{block:br(g)},children:_jsxruntime.jsxs.call(void 0, "div",{"data-open-card":g.type==="card"&&!w(g,r.id)?"true":void 0,children:[_jsxruntime.jsx.call(void 0, Yt,{block:g,disabled:d.conversationUnavailable||w(g,r.id),onReply:Or(g,r.id)}),g.answered?_jsxruntime.jsx.call(void 0, To,{block:g}):null]})},g.id))]}),r===vt?null:Mn(r)]},r.id)),d.pending.map(r=>_jsxruntime.jsxs.call(void 0, "article",{"data-role":"pending","aria-label":f("chat.roleUser"),children:[_jsxruntime.jsxs.call(void 0, B,{name:"bubble",slots:e,data:{pending:vr(r)},children:[_jsxruntime.jsx.call(void 0, "span",{"data-sender":"","aria-hidden":"true",children:f("chat.roleUser")}),_jsxruntime.jsx.call(void 0, "p",{children:r.content})]}),_jsxruntime.jsx.call(void 0, "p",{id:`${We}-${r.id}`,"data-pending-status":r.failure?"failed":"sending",children:f(r.failure?"chat.pendingFailed":"chat.pendingSending")}),_optionalChain([Se, 'optionalAccess', _245 => _245.id])===r.id&&de?_jsxruntime.jsxs.call(void 0, "p",{role:"alert",children:[de.text,_nullishCoalesce(de.action, () => ((!u.problemText&&_chunkM3UENQ6Lcjs.i.call(void 0, Se)==="refresh"?_jsxruntime.jsx.call(void 0, hr,{problem:Se,refresh:rn}):null)))]},d.announcement):null,r.failure?_jsxruntime.jsxs.call(void 0, B,{name:"failedSendControls",slots:e,data:{pending:vr(r)},children:[_jsxruntime.jsx.call(void 0, G,{"aria-describedby":`${We}-${r.id}`,disabled:d.conversationUnavailable||d.sending,onPress:()=>{p.retry(r.id)},children:f("chat.retry")}),_jsxruntime.jsx.call(void 0, G,{"aria-describedby":`${We}-${r.id}`,disabled:d.withdrawing.includes(r.id),onPress:()=>{p.withdraw(r.id)},children:f("chat.withdraw")}),_jsxruntime.jsx.call(void 0, G,{"aria-describedby":`${We}-${r.id}`,onPress:()=>{p.dismiss(r.id)},children:f("chat.dismiss")})]}):null,_optionalChain([Se, 'optionalAccess', _246 => _246.id])===r.id?_jsxruntime.jsx.call(void 0, gr,{problem:Se},d.announcement):null]},r.id))]})})}),E.size?_jsxruntime.jsxs.call(void 0, "p",{role:"alert","data-render-failure":"",children:[f("chat.messagesUnavailable"),_jsxruntime.jsx.call(void 0, G,{onPress:()=>{tt.request(!0),W(r=>r+1)},children:f("chat.retry")})]}):null,qe.pinned?null:_jsxruntime.jsx.call(void 0, "div",{"data-back-to-latest":"",children:_jsxruntime.jsx.call(void 0, G,{onPress:()=>{let r=T.value.originFor("latest");qe.toLatest(),ee(T.value,C.current,{origin:r,owner:T.value.owner()})},children:hn?f("chat.latestNew",{count:hn}):f("chat.latest")})})]})}),_jsxruntime.jsxs.call(void 0, B,{name:"replyRow",slots:e,children:[_jsxruntime.jsx.call(void 0, "div",{ref:xn,role:"status","data-reply-state":Pe,children:mt==="none"||Ar?null:_jsxruntime.jsx.call(void 0, "p",{className:mt==="writing"&&Ve?"wp-sr-only":void 0,children:f(`reply.${mt}`)})}),Pe!=="none"||d.toolSteps.length?_jsxruntime.jsx.call(void 0, Eo,{client:p,row:Pe}):null]}),Z?bt:null,vt?Mn(vt):null,Ke("flows")?_jsxruntime.jsx.call(void 0, B,{name:"flowTabs",slots:e,children:_jsxruntime.jsxs.call(void 0, "nav",{"aria-label":f("chat.flows"),children:[_jsxruntime.jsx.call(void 0, "div",{role:"tablist",onKeyDown:r=>{let g=d.flowTabs,F=g.findIndex(H=>_chunk3KV7TDDRcjs.f.call(void 0, H)===d.flowTab),I;if(r.key==="Home")I=0;else if(r.key==="End")I=g.length-1;else if(r.key==="ArrowRight"||r.key==="ArrowLeft"){let H=getComputedStyle(r.currentTarget).direction,$=r.key==="ArrowRight"!=((H==="rtl"||H==="ltr"?H:u.dir)==="rtl");I=(F+($?1:g.length-1))%g.length}else return;let A=r.currentTarget;!O(A,ve(r.nativeEvent))||!O(A,V(A.ownerDocument))||(r.preventDefault(),p.selectFlowTab(g[I]),_optionalChain([r, 'access', _247 => _247.currentTarget, 'access', _248 => _248.querySelectorAll, 'call', _249 => _249('[role="tab"]'), 'access', _250 => _250[I], 'optionalAccess', _251 => _251.focus, 'call', _252 => _252()]))},children:d.flowTabs.map(r=>_jsxruntime.jsx.call(void 0, G,{id:`${be}-${_chunk3KV7TDDRcjs.f.call(void 0, r)}`,"aria-controls":`${be}-panel`,role:"tab","aria-selected":d.flowTab===_chunk3KV7TDDRcjs.f.call(void 0, r),tabIndex:d.flowTab===_chunk3KV7TDDRcjs.f.call(void 0, r)?0:-1,label:typeof r=="string"?f(`flow.${r}`):_nullishCoalesce(_optionalChain([u, 'access', _253 => _253.flowTabLabel, 'optionalCall', _254 => _254(r.labelKey)]), () => (r.labelKey)),onPress:()=>p.selectFlowTab(r),children:typeof r=="string"?f(`flow.${r}`):_nullishCoalesce(_optionalChain([u, 'access', _255 => _255.flowTabLabel, 'optionalCall', _256 => _256(r.labelKey)]), () => (r.labelKey))},_chunk3KV7TDDRcjs.f.call(void 0, r)))}),Ne&&Ne.owner===T.value.owner()?_jsxruntime.jsx.call(void 0, Xt,{onFocus:r=>{vn.current=Ne.id,yn(r)},onRetry:()=>Cn(Ne.id,Ne.values)}):null,Ie.status==="ready"?_jsxruntime.jsx.call(void 0, Ie.module.FlowPanel,{id:`${be}-panel`,labelledBy:`${be}-${d.flowTab}`,flows:d.flows[d.flowTab],all:d.flows,list:Sr,onRetryList:sn,onRunFlow:Cn}):_jsxruntime.jsx.call(void 0, "div",{id:`${be}-panel`,role:"tabpanel","aria-labelledby":`${be}-${d.flowTab}`,tabIndex:-1,onFocus:yn,children:Ie.status==="failed"||nt(Ie)?_jsxruntime.jsx.call(void 0, Xt,{retrying:nt(Ie),onRetry:()=>Vt.request(!0)}):_jsxruntime.jsx.call(void 0, "p",{children:f("chat.loading")})})]})}):null,d.restored.length?_jsxruntime.jsx.call(void 0, "section",{"aria-label":f("chat.restored"),children:d.restored.map(r=>_jsxruntime.jsxs.call(void 0, "article",{children:[_jsxruntime.jsx.call(void 0, "p",{children:r.content}),_jsxruntime.jsx.call(void 0, G,{onPress:()=>{p.editRestored(r.id)},children:f("chat.restoredEdit")}),_jsxruntime.jsx.call(void 0, G,{onPress:()=>{p.discardRestored(r.id)},children:f("chat.restoredDiscard")})]},r.id))}):null,_jsxruntime.jsxs.call(void 0, B,{name:"composer",slots:e,data:{sending:d.sending},disabled:d.conversationUnavailable,value:d.draft,onChange:r=>{p.setDraft(r)},children:[_jsxruntime.jsx.call(void 0, Er,{inputRef:P,disabled:d.conversationUnavailable,value:d.draft,onChange:r=>{p.setDraft(r)},label:f("chat.message"),describedBy:d.hints.length?d.hints.map((r,g)=>`${an}-${g}`).join(" "):void 0,onKeyDown:r=>{_optionalChain([o, 'optionalAccess', _257 => _257.send])!==!1&&r.key===(_nullishCoalesce(_optionalChain([o, 'optionalAccess', _258 => _258.send]), () => ("Enter")))&&!r.shiftKey&&!r.nativeEvent.isComposing&&r.keyCode!==229&&(r.preventDefault(),p.send())}}),_jsxruntime.jsx.call(void 0, G,{disabled:d.conversationUnavailable||!d.draft.trim()||d.sending,onPress:()=>{p.send()},children:f(d.sending?"chat.sending":"chat.send")}),d.hints.map((r,g)=>_jsxruntime.jsx.call(void 0, "p",{id:`${an}-${g}`,children:r},g))]}),_jsxruntime.jsx.call(void 0, B,{name:"actionBar",slots:e,children:h.map(r=>_jsxruntime.jsx.call(void 0, G,{onPress:()=>{p.setDraft(r)},children:r},r))}),_jsxruntime.jsx.call(void 0, B,{name:"stepUpPrompt",slots:e,data:_optionalChain([J, 'optionalAccess', _259 => _259.plan, 'access', _260 => _260.kind])==="immediate"&&J.plan.stage==="final"?{stepUpCount:J.plan.stepUpCount}:void 0}),_jsxruntime.jsx.call(void 0, B,{name:"quotaStrip",slots:e,children:c}),_jsxruntime.jsx.call(void 0, "div",{ref:bn,className:"wp-sr",role:"status","data-announcements":"",children:Dr}),_jsxruntime.jsxs.call(void 0, "div",{role:"alert","data-announcement":d.announcement,children:[d.conversationUnavailable&&_jsxruntime.jsxs.call(void 0, "span",{children:[f("chat.conversationUnavailable"),_jsxruntime.jsx.call(void 0, G,{onPress:rt.press,"aria-busy":rt.busy||void 0,"aria-disabled":rt.busy||void 0,children:f("chat.reload")})]}),ht&&de?_jsxruntime.jsxs.call(void 0, "span",{children:[de.text,_nullishCoalesce(de.action, () => ((d.problem&&!u.problemText?_jsxruntime.jsx.call(void 0, hr,{problem:d.problem,refresh:rn}):null)))]},d.announcement):null]}),ht?_jsxruntime.jsx.call(void 0, gr,{problem:ht},d.announcement):null]}),Z?null:bt,on?_jsxruntime.jsx.call(void 0, B,{name:"extraPanels",slots:e}):null]})})})}function $a({title:e,body:t,busy:n=!1,onProceed:o,onCancel:a}){let l=_react.useContext.call(void 0, te),c=_nullishCoalesce(_optionalChain([l, 'optionalAccess', _261 => _261.format]), () => (Oe())),s=_nullishCoalesce(_optionalChain([l, 'optionalAccess', _262 => _262.primitives]), () => (Cr)),h=s.drawer,b=Ot("confirm-sheet"),u=It(!0,_optionalChain([Ae, 'call', _263 => _263(), 'optionalAccess', _264 => _264.owner, 'call', _265 => _265()]),a),p=s.button;return u?null:_jsxruntime.jsxs.call(void 0, At,{as:h,open:!0,label:e,onClose:a,closeLabel:c("chat.close"),...b,children:[_jsxruntime.jsx.call(void 0, "p",{children:t}),_jsxruntime.jsx.call(void 0, p,{disabled:n,onPress:o,children:c("chat.confirm")}),_jsxruntime.jsx.call(void 0, p,{onPress:a,children:c("chat.cancel")})]})}function _t({conversations:e,source:t,onChoose:n}){let{client:o,format:a,primitives:l,extraUrlSchemes:c}=U(),{conversationId:s}=_react.useSyncExternalStore.call(void 0, o.subscribe,o.getSnapshot,o.getSnapshot),[h,b]=_react.useState.call(void 0, ""),[u,p]=_react.useState.call(void 0, []),[f,M]=_react.useState.call(void 0, !1),[d,m]=_react.useState.call(void 0, 0),[P,C]=_react.useState.call(void 0, new Map);_react.useEffect.call(void 0, ()=>{if(!t)return;let w=!0;return M(!1),Promise.resolve().then(()=>t.list(h||void 0)).then(v=>{w&&(p(v),C(y=>new Map([...y,...v.filter(k=>k.subject).map(k=>[k.subject.key,k.subject])])))}).catch(()=>{w&&M(!0)}),()=>{w=!1}},[t,h,s,d]);let L=t?u:e,E=t?P:new Map(L.filter(w=>w.subject).map(w=>[w.subject.key,w.subject])),R=new Map;for(let w of L){let v=_nullishCoalesce(_optionalChain([w, 'access', _266 => _266.subject, 'optionalAccess', _267 => _267.key]), () => (""));h&&v!==h||R.set(v,[..._nullishCoalesce(R.get(v), () => ([])),w])}let N=l.button,W=Ae(),se=w=>_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, N,{"aria-current":w.id===s?"page":void 0,onPress:()=>{_optionalChain([n, 'optionalCall', _268 => _268()]);let v=_nullishCoalesce(_optionalChain([W, 'optionalAccess', _269 => _269.ownerOf, 'call', _270 => _270(w.id)]), () => (w.id)),y=_optionalChain([W, 'optionalAccess', _271 => _271.originFor, 'call', _272 => _272("switch",v)]);o.switchConversation(w.id).then(k=>ee(W,_optionalChain([W, 'optionalAccess', _273 => _273.composer, 'call', _274 => _274()]),{origin:y,owner:v,stillCurrent:()=>k.kind==="loaded"&&_optionalChain([W, 'optionalAccess', _275 => _275.owner, 'call', _276 => _276()])===v&&_optionalChain([o, 'access', _277 => _277.getSnapshot, 'call', _278 => _278(), 'access', _279 => _279.conversation, 'optionalAccess', _280 => _280.id])===w.id}))},children:w.title}),w.mode==="form-fill"&&_jsxruntime.jsx.call(void 0, "span",{children:a("form.marker")}),_optionalChain([w, 'access', _281 => _281.subject, 'optionalAccess', _282 => _282.state])==="unlinked"&&_jsxruntime.jsx.call(void 0, "span",{children:a("form.unlinked")}),_optionalChain([w, 'access', _283 => _283.subject, 'optionalAccess', _284 => _284.route])&&_chunkFBADWFRRcjs.a.call(void 0, w.subject.route,c)&&_jsxruntime.jsx.call(void 0, "a",{href:w.subject.route,children:a("form.return")})]});return _jsxruntime.jsxs.call(void 0, "nav",{className:"wp-rail","aria-label":a("chat.rail"),tabIndex:-1,children:[E.size>0&&_jsxruntime.jsxs.call(void 0, "label",{children:[a("form.filter"),_jsxruntime.jsxs.call(void 0, "select",{value:h,onChange:w=>b(w.target.value),children:[_jsxruntime.jsx.call(void 0, "option",{value:"",children:a("form.all")}),[...E].map(([w,v])=>_jsxruntime.jsx.call(void 0, "option",{value:w,children:v.label},w))]})]}),f&&_jsxruntime.jsxs.call(void 0, "p",{role:"alert",children:[a("chat.conversationsFailed")," ",_jsxruntime.jsx.call(void 0, N,{onPress:()=>m(w=>w+1),children:a("chat.retry")})]}),[...R].map(([w,v])=>{let y=new Set,k=D=>{if(y.has(D.id))return null;y.add(D.id);let le=v.filter(he=>he.parentConversationId===D.id&&!y.has(he.id));return _jsxruntime.jsxs.call(void 0, "li",{"data-conversation-id":D.id,children:[se(D),le.length>0&&_jsxruntime.jsxs.call(void 0, "details",{children:[_jsxruntime.jsx.call(void 0, "summary",{children:a("form.threads")}),_jsxruntime.jsx.call(void 0, "ul",{children:le.map(k)})]})]},D.id)},ie=v.filter(D=>!D.parentConversationId||!v.some(le=>le.id===D.parentConversationId)).map(k);for(let D of v)y.has(D.id)||ie.push(k(D));return _jsxruntime.jsxs.call(void 0, "section",{children:[w&&_jsxruntime.jsx.call(void 0, "h3",{children:v[0].subject.label}),_jsxruntime.jsx.call(void 0, "ul",{children:ie})]},w)})]})}exports.a = V; exports.b = O; exports.c = oe; exports.d = ce; exports.e = Mt; exports.f = Lt; exports.g = Ae; exports.h = It; exports.i = Yr; exports.j = ee; exports.k = At; exports.l = Ot; exports.m = Zo; exports.n = Jo; exports.o = _t; exports.p = co; exports.q = cr; exports.r = uo; exports.s = qt; exports.t = Oe; exports.u = we; exports.v = pe; exports.w = Do; exports.x = Ia; exports.y = U; exports.z = Na; exports.A = Da; exports.B = Aa; exports.C = Oa; exports.D = Ba; exports.E = Ha; exports.F = xr; exports.G = mr; exports.H = Xt; exports.I = Ao; exports.J = B; exports.K = Bo; exports.L = Uo; exports.M = Yt; exports.N = $o; exports.O = Ua; exports.P = $a;