@appsolutely-io/waypoint 0.1.1-next.0 → 0.1.1-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -0
- package/dist/{block-reply-DN4RiLL0.d.cts → block-reply-r8u-DNmZ.d.cts} +15 -3
- package/dist/{block-reply-Dtof9ild.d.ts → block-reply-z8El20nD.d.ts} +15 -3
- package/dist/{blocks-UJ7GUJHD.js → blocks-2ABWECKG.js} +1 -1
- package/dist/{blocks-25YOJ5SS.cjs → blocks-7453YTYJ.cjs} +1 -1
- package/dist/{chunk-W6Y7H56X.js → chunk-5Q3INHKA.js} +1 -1
- package/dist/chunk-A3YOSFLE.cjs +1 -0
- package/dist/{chunk-Q6BD2YL3.cjs → chunk-BRUQ75G3.cjs} +1 -1
- package/dist/{chunk-SD2KAIVE.js → chunk-D4Q46KWA.js} +1 -1
- package/dist/chunk-IPI4O4LP.js +1 -0
- package/dist/chunk-QFBAOEPD.js +1 -0
- package/dist/chunk-RZ3AGK3U.cjs +1 -0
- package/dist/{chunk-4ZGW4HM4.cjs → chunk-XTKUDSDK.cjs} +1 -1
- package/dist/{confirmation-view-OMWHUYVC.cjs → confirmation-view-5BZ2PP7J.cjs} +1 -1
- package/dist/{confirmation-view-CICNJJIO.js → confirmation-view-Z5JHY2F5.js} +1 -1
- package/dist/{flows-panel-YEJ36RTY.js → flows-panel-2SCPYZ3X.js} +1 -1
- package/dist/{flows-panel-AIULKYOS.cjs → flows-panel-HQYJMOP4.cjs} +1 -1
- package/dist/{form-extras-QYE32TUY.cjs → form-extras-RNMBCYV7.cjs} +1 -1
- package/dist/{form-extras-SBBOMJS2.js → form-extras-X3B3JCMH.js} +1 -1
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.d.cts +3 -3
- package/dist/hooks/index.d.ts +3 -3
- package/dist/hooks/index.js +1 -1
- package/dist/{i18n-DPNfYTMG.d.cts → i18n-WC9f-h_q.d.cts} +3 -0
- package/dist/{i18n-DPNfYTMG.d.ts → i18n-WC9f-h_q.d.ts} +3 -0
- package/dist/markdown-5NUOCOGY.js +23 -0
- package/dist/{markdown-BSRKJFFE.cjs → markdown-CG7NXI7X.cjs} +17 -11
- package/dist/{message-actions-F6SPLTT7.cjs → message-actions-ORBVYGNE.cjs} +1 -1
- package/dist/{message-actions-3HGE6VTS.js → message-actions-XNBBFHGW.js} +1 -1
- package/dist/messages/en/index.cjs +1 -1
- package/dist/messages/en/index.js +1 -1
- package/dist/messages/index.d.cts +3 -3
- package/dist/messages/index.d.ts +3 -3
- package/dist/messages/zh-Hans/index.cjs +1 -1
- package/dist/messages/zh-Hans/index.js +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.d.cts +8 -6
- package/dist/react/index.d.ts +8 -6
- package/dist/react/index.js +1 -1
- package/dist/{recovery-panel-VOKVDDZD.js → recovery-panel-6EBUMANX.js} +1 -1
- package/dist/{recovery-panel-OWY2CWOH.cjs → recovery-panel-EQIIV7TT.cjs} +3 -3
- package/dist/{reply-controls-5CWIAKIG.js → reply-controls-HUYHUO3W.js} +1 -1
- package/dist/{reply-controls-CPWB4VBK.cjs → reply-controls-LGY2RKRJ.cjs} +1 -1
- package/dist/skin-antd/index.d.cts +3 -3
- package/dist/skin-antd/index.d.ts +3 -3
- package/dist/{step-name-BdkYnb5g.d.ts → step-name-BlgVvshf.d.ts} +1 -1
- package/dist/{step-name-3hQ6CCGr.d.cts → step-name-CB3d3kkP.d.cts} +1 -1
- package/dist/styles.css +15 -0
- package/dist/testing/index.cjs +1 -1
- package/dist/testing/index.d.cts +3 -3
- package/dist/testing/index.d.ts +3 -3
- package/dist/testing/index.js +1 -1
- package/etc/hooks.api.md +9 -0
- package/etc/messages.api.md +3 -0
- package/etc/react.api.md +9 -0
- package/etc/skin-antd.api.md +9 -0
- package/etc/testing.api.md +9 -0
- package/package.json +2 -1
- package/dist/chunk-M3UENQ6L.cjs +0 -1
- package/dist/chunk-RHBDQGD4.js +0 -1
- package/dist/chunk-TGL3DR2K.js +0 -1
- package/dist/chunk-UYR3UEIW.cjs +0 -1
- package/dist/markdown-ETLB66BK.js +0 -17
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as at}from"./chunk-FQSWQLRW.js";import{a as oo,b as ro}from"./chunk-OWT55N6J.js";import{d as uo,e as Bt,f as it,h as Ue,i as Ht,j as fo,k as po,l as Ut,m as mo}from"./chunk-QFBAOEPD.js";import{a as io,b as lo,c as co}from"./chunk-RZZDQWC2.js";import{b as so,c as ao}from"./chunk-M63QOANE.js";import{f as He,l as Dt}from"./chunk-L4PFFRDE.js";import{useLayoutEffect as ho,useRef as go}from"react";var lt=new WeakMap;function J(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t}function q(e,t){let n=t;for(;n;){if(n===e)return!0;n=n.parentNode??(n instanceof ShadowRoot?n.host:null)}return!1}function Pe(e){return e.composedPath?.()[0]??e.target}var Wt=new WeakMap,Mr=0;function bo(e){let t=new Set,n=[],r=s=>{t.has(s)||s.hasAttribute("inert")||(s.setAttribute("inert",e.mark),e.set.push(s))};for(let s=e.drawer;;){t.add(s);let i=s instanceof Element?s.assignedSlot:null;i&&s.parentNode&&n.push(s.parentNode);let d=i??s.parentNode;if(!d||d.nodeType===Node.DOCUMENT_NODE)break;n.push(d),s=d instanceof ShadowRoot?d.host:d}for(let s of n)for(let i of s.children)r(i);if(typeof MutationObserver=="function"){e.watch=new MutationObserver(s=>{for(let i of s)for(let d of i.addedNodes)d instanceof Element&&r(d)});for(let s of n)e.watch.observe(s,{childList:!0})}}function vo(e){e.watch?.disconnect(),e.watch=void 0;for(let t of e.set)t.getAttribute("inert")===e.mark&&t.removeAttribute("inert");e.set=[]}function $t(e){let t=e.ownerDocument,n=Wt.get(t)??[];Wt.set(t,n);let r=n.at(-1);r&&vo(r);let s={drawer:e.closest("[data-wp-modal-root]")??e,mark:`waypoint-${++Mr}`,set:[]};return n.push(s),bo(s),()=>{let i=n.indexOf(s);if(i<0)return;vo(s),n.splice(i,1);let d=n.at(-1);i===n.length&&d&&bo(d)}}var zt='a[href], button, input, select, textarea, summary, iframe, [tabindex], [contenteditable]:not([contenteditable="false"])';function ie(e){return e instanceof HTMLElement&&e.isConnected&&e.matches(zt)&&!e.matches('input[type="hidden"], :disabled')&&!e.closest("[hidden], [inert]")&&(typeof e.checkVisibility!="function"||e.checkVisibility({visibilityProperty:!0}))}function Rr(e,t){for(let n=e;n;){if(n instanceof Element&&ie(n))return n;if(n===t)return null;n=n.parentNode??(n instanceof ShadowRoot?n.host:null)}return null}function Fr(e){return q(e,J(e.ownerDocument))}var qt=e=>{let t=J(e);return!t||t===e.body};function Te(e){let t=lt.get(e);if(t)return t;let n={origins:new Set,last:null};return t=n,lt.set(e,n),e.addEventListener("focusin",r=>{let s=Pe(r);n.last=s,n.disabled=null;for(let i of n.origins)!q(i.root,s)&&!i.owned.some(d=>q(d,s))&&(i.valid=!1,n.origins.delete(i))},!0),e.addEventListener("focusout",r=>{let s=Pe(r);r.relatedTarget||queueMicrotask(()=>{if(!s?.isConnected||!qt(e))return;if(s.matches(":disabled"))return void(n.disabled=s);let i=Wt.get(e)?.at(-1)?.drawer;if(!(i&&q(i,s))){n.last=null;for(let d of n.origins)d.valid=!1;n.origins.clear()}})},!0),e.addEventListener("pointerdown",()=>{n.last&&!n.last.isConnected&&qt(e)&&(n.last=null)},!0),n}function de(e){e&&(e.valid=!1,lt.get(e.root.ownerDocument)?.origins.delete(e))}function ko(e){let t=lt.get(e.ownerDocument);if(t)for(let n of t.origins)q(e,n.root)&&de(n)}function jt(e){Te(e)}function Vt(e,t,n,r){let s="nativeEvent"in e?e.nativeEvent:e,i=Pe(s);if(!q(t,i))return;let d={owner:n,action:r,root:t,control:Rr(i,t)??i,owned:[],valid:!0};return Te(t.ownerDocument).origins.add(d),d}var xo=new WeakMap;function Co(e){let t=J(e.ownerDocument);t&&q(e,t)&&(Te(e.ownerDocument).last=t,xo.set(e,t))}function Kt(e,t){if(!e)return!1;let{last:n}=Te(t);return!!n&&(q(e,n)||xo.get(e)===n)&&(!n.isConnected||n===Te(t).disabled)&&qt(t)}function te(e,t){let{root:n,origin:r,removed:s}=t;if(!e||!e.isConnected)return!1;let i=n.ownerDocument;if(Te(i),t.stillCurrent&&!t.stillCurrent()||!(r?r.valid&&r.owner===t.owner&&(Fr(n)||Kt(s??r.control,i)):Kt(s,i)||t.enterModal===!0&&e===n&&e.matches(ao)))return!1;e.focus({preventScroll:t.preventScroll??!1});let a=J(i)===e;return a?Te(i).last=e:t.missed?.(),a}var yo=new WeakMap,wo=e=>{let t=yo.get(e);return t||yo.set(e,t=new Set),t};function _t(e){let t=go(null),n=go({});return ho(()=>{jt(document);let r=wo(document),s=n.current;return()=>{r.delete(s)}},[]),ho(()=>{let r=wo(document),s=t.current;if(!s||s.isConnected)return void r.delete(n.current);if(!Kt(s,document))return t.current=null,void r.delete(n.current);let i=e().find(d=>d?.isConnected);if(!(i instanceof HTMLElement))return void r.add(n.current);t.current=null,r.delete(n.current),te(i,{root:i,owner:"",removed:s})}),r=>{t.current=r.target}}import{createContext as Lr,useContext as Ir,useEffect as Gt,useMemo as Yt,useRef as ne,useState as Nr}from"react";import{jsx as Hr}from"react/jsx-runtime";var Xt=Lr(null),_e=()=>Ir(Xt),So=new WeakMap,Or=0;function ue(e,t){let n=So.get(e);return n===void 0&&So.set(e,n=++Or),`${n}:${t}`}function Eo(e,t,n,r,s=i=>i){let i=ne(null),d=ne(t);d.current=t;let a=ne(s);a.current=s,Gt(()=>{let g=e.current;if(g)return jt(g.ownerDocument),()=>ko(g)},[e]);let u=Yt(()=>({root:()=>e.current,owner:()=>d.current,ownerOf:g=>a.current(g),originFor(g,f){let m=i.current,b=e.current;return m&&b?Vt(m,b,f??d.current,g):void 0},composer:()=>n.current,transcript:()=>r.current}),[e,n,r,t]),p=g=>{let f=g.nativeEvent;i.current=f,Po(()=>{i.current===f&&(i.current=null)})};return{value:u,captureProps:{onClickCapture:p,onKeyDownCapture:p,onPointerDownCapture:p}}}function Qt(e,t,n){let[r,s]=Nr({active:e,conversationId:t});r.active!==e&&s({active:e,conversationId:t});let i=e&&r.active&&r.conversationId!==t,d=ne(n);return d.current=n,Gt(()=>{i&&d.current()},[i]),i}var Po=e=>setTimeout(e,0);function Ar(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 To(e){if(!e)return!1;let t=J(e.ownerDocument);return q(e,t)&&!Ar(t)}function Y(e,t,n){let{origin:r,removed:s,fallback:i}=n,d=e?.root(),a=(g,f)=>!!d&&(!!r||!!s)&&te(g,{root:d,origin:r,removed:s,owner:n.owner,stillCurrent:n.stillCurrent,preventScroll:!0,missed:f}),u=!1,p=a(t,()=>u=!0);return!p&&u&&i&&i!==t&&(p=a(i)),(!n.keep||!p)&&de(r),p}function Jt(e,t,n,r){t.current?.element!==e&&(t.current={element:e,opener:J(e.ownerDocument)}),r?.(),te(e,{root:e,owner:"",enterModal:!0,stillCurrent:n})}function Zt(e,t,n){let r=e.current;r&&queueMicrotask(()=>{if(e.current!==r)return;let s=n?.(),i=ie(r.opener)?r.opener:s,d={root:r.element,owner:"",removed:r.element,stillCurrent:t,preventScroll:!0};te(i,{...d,missed:()=>{s!==i&&te(s,d)}}),r.element.isConnected||(e.current=void 0)})}function en({as:e,focusInto:t,restoreFocus:n,...r}){let s=ne(void 0),i=ne(void 0);return Gt(()=>()=>{s.current?.(),s.current=void 0},[]),Hr(e,{...r,focusInto:d=>{if(s.current?.(),t){let a=!1,u=()=>{s.current=$t(d),a=!0};t(d,u),a||u()}else Jt(d,i,void 0,()=>{s.current=$t(d)})},restoreFocus:d=>{Co(d),s.current?.(),s.current=void 0,n?n(d):Zt(i)}})}function tn(e,t,n){let r=_e(),s=ne(void 0),i=ne(void 0),d=ne(t);d.current=t;let a=ne(n);return a.current=n,Yt(()=>r?{focusInto(u,p){let g=r.owner(),f=r.originFor(`drawer:${e}`,g);if(s.current={origin:f,key:g},!f){Jt(u,i,()=>r.owner()===g&&(d.current?.()??!0),p);return}i.current=void 0,Y(r,u,{origin:f,owner:g,stillCurrent:()=>r.owner()===g&&(d.current?.()??!0),keep:!0})},restoreFocus(u){let p=s.current;if(s.current=void 0,!p)return;if(!p.origin){Zt(i,()=>r.owner()===p.key,()=>{let f=a.current?.();return ie(f??null)?f:r.transcript()});return}let g={origin:p.origin,key:p.key};queueMicrotask(()=>Dr(r,u,g,a.current?.()))},release(){let u=s.current;s.current=void 0,de(u?.origin)}}:{},[r,e])}function Dr(e,t,n,r){let s=J(t.ownerDocument);if(!q(t,s)&&s&&s!==t.ownerDocument.body)return de(n.origin);let i=n.origin.control,d=ie(r??null)?r:e.transcript(),a=ie(i)?i:d;Y(e,a,{origin:n.origin,owner:n.key,stillCurrent:()=>e.owner()===n.key,removed:t,fallback:d})}var ct=null;function _s(e,t,n){let r=Vt(e.nativeEvent,t,"form-field","open");if(!r)return n?.();let s={origin:r,claimed:!1,settled:n};ct=s,Po(()=>{ct===s&&(ct=null),s.claimed||(de(r),s.settled?.())})}function Gs(){let e=ne(void 0),t=ne(void 0);return Yt(()=>({focusInto(n){let r=ct??void 0;if(e.current=r,!r){Jt(n,t);return}t.current=void 0;let s=r.origin;r.claimed=!0,s.owned.push(n),te(n,{root:s.root,origin:s,owner:s.owner,preventScroll:!0})},restoreFocus(n){let r=e.current;if(e.current=void 0,!r){Zt(t);return}queueMicrotask(()=>{Br(n,r.origin),r.settled?.()})}}),[])}function Br(e,t){let n=[...t.root.querySelectorAll("*")].find(ie),r={root:e,origin:t,removed:e,owner:t.owner,preventScroll:!0},s=!ie(t.control);s||te(t.control,{...r,missed:()=>s=!0}),s&&n&&n!==t.control&&te(n,r),de(t)}import{useEffect as Us,useState as Je,useSyncExternalStore as Ws}from"react";import{createContext as yt,memo as cs,useContext as X,useEffect as V,useLayoutEffect as Re,useMemo as fe,useRef as F,useState as j,useId as Qe,useSyncExternalStore as Zo,lazy as ds,Suspense as us,Component as fs}from"react";var Ur=/[--]/g;function nn(e,t=120){let n=e.replace(Ur,"").replace(/\s+/g," ").trim();if(!n||typeof Intl.Segmenter!="function")return;let r=[];for(let s of new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(n)){if(r.length===t)return`${r.join("")}\u2026`;r.push(s.segment)}return n}var ke=class{owner;policy=[];byId=new Map;begin(t,n,r){if(t!==this.owner||n.length!==this.policy.length||n.some((d,a)=>d!==this.policy[a])){let d=this.byId.size>0;return this.owner=t,this.policy=n,this.byId=new Map,d}if(!this.byId.size)return!1;let s=new Map(r.map(d=>[d.id,d.source])),i=!1;for(let[d,a]of this.byId)(!s.has(d)||s.get(d)!==a.source)&&(this.byId.delete(d),i=!0);return i}get(t,n,r){let s=this.byId.get(t);if(s&&s.source===n)return s.value;let i=r(n);return this.byId.set(t,{source:n,value:i}),i}peek(t,n){let r=this.byId.get(t);return r&&r.source===n?r.value:void 0}entries(){return[...this.byId].map(([t,n])=>({id:t,source:n.source}))}},dt=class extends ke{};var Wr=/[̀-ͯ᪰-᷀-᷿⃐-︠-︯]/g;function on(e,t){let n=qr(t);return e.normalize("NFKD").toLocaleUpperCase(n).toLocaleLowerCase(n).normalize("NFD").replace(Wr,"").normalize("NFC").replace(/\s+/g," ").trim()}function qr(e){if(e)try{return Intl.getCanonicalLocales(e)[0]}catch{return}}var Kr=8,ut=class{texts=new ke;shown=[];make=()=>"";cursor=0;pending;version=0;listeners=new Set;sync(t,n,r,s){(this.texts.begin(t,n,r)||r!==this.shown)&&(this.cursor=0),this.shown=r,this.make=s}textOf(t,n){return this.texts.peek(t,n)}complete(){for(;this.cursor<this.shown.length;this.cursor++){let{id:t,source:n}=this.shown[this.cursor];if(this.texts.peek(t,n)===void 0)return!1}return!0}start(){if(this.pending||this.complete())return;let t=n=>{this.pending=void 0;let r=performance.now()+Kr,s=n?()=>n.timeRemaining()>1:()=>performance.now()<r,i=!1;do{if(this.complete())break;let{id:d,source:a,message:u}=this.shown[this.cursor];this.texts.get(d,a,()=>this.make(u)),i=!0}while(s());if(i){this.version++;for(let d of this.listeners)d()}this.start()};if(typeof requestIdleCallback=="function"){let n=requestIdleCallback(t,{timeout:200});this.pending=()=>cancelIdleCallback(n)}else{let n=setTimeout(t,0);this.pending=()=>clearTimeout(n)}}stop(){this.pending?.(),this.pending=void 0}subscribe=t=>(this.listeners.add(t),()=>this.listeners.delete(t));snapshot=()=>this.version};import{useLayoutEffect as Mo,useRef as Ro,useState as $r}from"react";var Fo=24,rn=150,zr=100,jr=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "]),Vr="[data-message-id]",We=e=>Math.max(0,e.scrollHeight-e.clientHeight),Lo=e=>e.scrollHeight-e.clientHeight-e.scrollTop,ft=()=>performance.now(),_r=e=>typeof requestAnimationFrame=="function"?requestAnimationFrame(e):setTimeout(e,16),sn=e=>[...e.querySelectorAll(Vr)].filter(t=>t.closest(".wp-transcript")===e),pt=e=>e.getAttribute("data-message-id");function Io(e,t,n,r,s){let[i,d]=$r(!0),a=Ro({pinned:!0,token:void 0,expected:[],lastTop:0,sizeFrame:!1,anchor:void 0,shown:void 0}).current,u=c=>{a.pinned=c,d(c)},p=()=>{clearTimeout(a.token?.timer),a.token=void 0},g=(c,C)=>{let E=Math.min(Math.max(0,C),We(c));a.expected.push({top:E,at:ft()}),typeof c.scrollTo=="function"?c.scrollTo({top:E,behavior:"instant"}):c.scrollTop=E,a.lastTop=c.scrollTop},f=c=>{let C=c.getBoundingClientRect().top,E=sn(c),L=E.find(R=>R.getBoundingClientRect().bottom>C+.5);a.anchor=L&&{id:pt(L),offset:L.getBoundingClientRect().top-C,order:E.map(pt)}},m=c=>{let C=a.anchor;if(!C)return f(c);let E=new Map(sn(c).map(y=>[pt(y),y])),L=C.order.indexOf(C.id),R=E.get(C.id)??C.order.slice(L+1).map(y=>E.get(y)).find(Boolean)??C.order.slice(0,Math.max(0,L)).reverse().map(y=>E.get(y)).find(Boolean);if(!R)g(c,0);else{let y=R.getBoundingClientRect().top-c.getBoundingClientRect().top-C.offset;Math.abs(y)>.5&&g(c,c.scrollTop+y)}f(c)},b=()=>{let c=e.current;c&&(a.token&&!a.token.used&&!a.token.held&&p(),a.pinned?Lo(c)>.5&&g(c,We(c)):m(c))},A=Ro(b);return A.current=b,Mo(()=>{let c=r===0;(n!==a.shown||c)&&(a.shown=n,a.anchor=void 0,p(),a.pinned||u(!0)),b()},[s,n,r]),Mo(()=>{let c=e.current;if(!c)return;let C=c.ownerDocument,E=w=>{clearTimeout(w.timer);let k=()=>{if(a.token!==w||w.held)return;let x=ft()-Math.max(w.lastInput,w.lastScroll);x>=rn?a.token=void 0:w.timer=setTimeout(k,rn-x)};w.timer=setTimeout(k,rn)},L=w=>{let k=a.token??={used:!1,held:!1,lastInput:0,lastScroll:0};k.lastInput=ft(),w&&(k.held=!0),E(k)},R=()=>{let w=a.token;w?.held&&(w.held=!1,E(w))},y=()=>L(),P=()=>L(!0),S=w=>{jr.has(w.key)&&q(c,J(C))&&L()},N=()=>{let w=c.scrollTop,k=a.lastTop;a.lastTop=w;let x=ft();a.expected=a.expected.filter(Fe=>x-Fe.at<zr);let _=a.expected.findIndex(Fe=>Math.abs(Fe.top-w)<=1),Z=a.token,W=We(c),pe=Math.abs(w-W)<=1&&k>W+.5,Se=_>=0||!Z||pe||a.sizeFrame&&Math.abs(w-W)<=1;_>=0&&a.expected.splice(0,_+1),Se||(Z.used=!0,Z.lastScroll=x,E(Z),w<k-.5?u(!1):w>k+.5&&Lo(c)<=Fo&&!a.pinned&&u(!0)),a.pinned||f(c)};c.addEventListener("wheel",y,{passive:!0}),c.addEventListener("touchstart",P,{passive:!0}),c.addEventListener("touchmove",y,{passive:!0}),c.addEventListener("pointerdown",P),c.addEventListener("keydown",S),c.addEventListener("scroll",N,{passive:!0});for(let w of["pointerup","pointercancel","touchend","touchcancel"])C.addEventListener(w,R,!0);let v=typeof ResizeObserver=="function"?new ResizeObserver(()=>{a.sizeFrame=!0,_r(()=>a.sizeFrame=!1),A.current()}):void 0;return v?.observe(c),t.current&&v?.observe(t.current),()=>{c.removeEventListener("wheel",y),c.removeEventListener("touchstart",P),c.removeEventListener("touchmove",y),c.removeEventListener("pointerdown",P),c.removeEventListener("keydown",S),c.removeEventListener("scroll",N);for(let w of["pointerup","pointercancel","touchend","touchcancel"])C.removeEventListener(w,R,!0);v?.disconnect(),p()}},[e,t]),{pinned:i,anchorId:()=>a.pinned?void 0:a.anchor?.id,toLatest(){let c=e.current;c&&(p(),g(c,We(c)),u(!0))},toMessage(c){let C=e.current,E=C&&sn(C).find(y=>pt(y)===c);if(!C||!E)return;p();let L=Math.min(We(C),C.scrollTop+E.getBoundingClientRect().top-C.getBoundingClientRect().top);g(C,L);let R=We(C)-L<=Fo;return u(R),R||f(C),E}}}import{useLayoutEffect as mt,useRef as an,useState as ht}from"react";var Gr=500,Yr=1200,Xr=160;function No(e,t,n,r=Yr){let s=e.length;if(!s)return[0,-1];if(n){let g=s-1,f=e[g];for(;g>0&&f<t.height+r;)f+=e[--g];return[g,s-1]}let i=t.top-r,d=t.top+t.height+r,a=0,u=-1,p=s-1;for(let g=0;g<s;g++){let f=a+e[g];if(u<0&&f>i&&(u=g),a>=d){p=g-1;break}a=f}return u<0?No(e,t,!0,r):[u,Math.max(u,p)]}function Qr(e,[t,n],r=[]){let s=new Set;for(let u=t;u<=n;u++)s.add(u);for(let u of r)u>=0&&u<e.length&&s.add(u);let i=[],d=0,a=0;for(let u=0;u<e.length;u++)if(s.has(u)){d&&(i.push({kind:"gap",from:a,to:u-1,height:d}),d=0);let p=i.at(-1);p?.kind==="rows"&&p.to===u-1?p.to=u:i.push({kind:"rows",from:u,to:u})}else d||(a=u),d+=e[u];return d&&i.push({kind:"gap",from:a,to:e.length-1,height:d}),i}var gt="article[data-message-id]";function Oo(e,t,n,r,s){let i=n.length>=Gr,d=an(new Map).current,a=an({top:0,height:0}),u=an(i);u.current=i;let[,p]=ht(0),[,g]=ht(0),[f,m]=ht(),[b,A]=ht();if(d.size>n.length*2){let y=new Set(n);for(let P of d.keys())y.has(P)||d.delete(P)}let c=0;for(let y of d.values())c+=y;let C=d.size?c/d.size:Xr,E=i?n.map(y=>d.get(y)??C):[],L=i?[f,b?.id,s].filter(y=>y!==void 0).map(y=>n.indexOf(y)):[],R=i?Qr(E,No(E,a.current,r),L):n.length?[{kind:"rows",from:0,to:n.length-1}]:[];return mt(()=>{let y=e.current;if(!y)return;let P,S=()=>{P=void 0;let w=a.current,k={top:y.scrollTop,height:y.clientHeight};Math.abs(w.top-k.top)<1&&w.height===k.height||(a.current=k,u.current&&p(x=>x+1))},N=()=>{P===void 0&&(P=typeof requestAnimationFrame=="function"?requestAnimationFrame(S):setTimeout(S,16))};S(),y.addEventListener("scroll",N,{passive:!0});let v=typeof ResizeObserver=="function"?new ResizeObserver(N):void 0;return v?.observe(y),()=>{y.removeEventListener("scroll",N),v?.disconnect(),P!==void 0&&(typeof cancelAnimationFrame=="function"?cancelAnimationFrame:clearTimeout)(P)}},[e]),mt(()=>{let y=t.current;if(!i||!y)return;let P=v=>(v instanceof Element?v.closest(gt):null)?.getAttribute("data-message-id")??void 0,S=v=>m(P(v.target)),N=v=>{y.contains(v.relatedTarget)||m(void 0)};return y.addEventListener("focusin",S),y.addEventListener("focusout",N),()=>{y.removeEventListener("focusin",S),y.removeEventListener("focusout",N)}},[t,i]),mt(()=>{let y=t.current;if(!y)return;let P=!1,S=[...y.children],N=S.map(v=>v.getBoundingClientRect());for(let v=0;v<S.length;v++){let w=S[v];if(!w.matches(gt))continue;let k=N[v+1],x=k?k.top-N[v].top:N[v].height,_=w.getAttribute("data-message-id");x>0&&Math.abs((d.get(_)??-1)-x)>1&&(d.set(_,x),P=!0)}P&&i&&g(v=>v+1)}),mt(()=>{if(!b||![...t.current?.querySelectorAll(gt)??[]].some(S=>S.getAttribute("data-message-id")===b.id))return;A(void 0),b.then();let P=e.current;P&&(a.current={top:P.scrollTop,height:P.clientHeight},p(S=>S+1))},[b,t,e]),{windowed:i,busy:b!==void 0,segments:R,reveal(y,P){let S=[...t.current?.querySelectorAll(gt)??[]].some(N=>N.getAttribute("data-message-id")===y);!i||S||!n.includes(y)?P():A({id:y,then:P})}}}import{useEffect as cn,useRef as dn,useState as Do}from"react";var Jr=1e3,Zr=e=>`\u2068${e}\u2069`,Bo=()=>typeof requestAnimationFrame=="function",es=e=>Bo()?requestAnimationFrame(e):setTimeout(e,16),ln=e=>{Bo()?cancelAnimationFrame(e):clearTimeout(e)};function Ao(e){if(e.role!=="assistant")return;let t=e.status;if(t==null)return"arrived";if(t==="completed")return"completed";if(t==="failed"||t==="unavailable")return"failed"}function Ho(e,t,n,r,s){let[i,d]=Do(""),a=dn({baselineFor:void 0,baseline:new Set,announced:new Map,writing:new Set,held:void 0,pending:new Map,batchFor:void 0,timer:void 0,frame:void 0,showing:0,batchShowing:0,client:void 0}).current,u=dn({conversation:t,excerptOf:n,t:r});u.current={conversation:t,excerptOf:n,t:r};let p=(m,b)=>{let A=a.announced.get(m),c=!!A&&(A.has("completed")||A.has("failed"));return b==="arrived"?!c&&!A?.has("arrived")&&!a.writing.has(m):!c},g=()=>{a.timer=void 0;let m=[...a.pending],b=a.batchFor,A=a.batchShowing;a.pending.clear(),a.frame!==void 0&&ln(a.frame),d(""),a.frame=es(()=>{a.frame=void 0,A===a.showing&&f(m,b)})},f=(m,b)=>{let A=s?.current;if(A?.closest("[inert]")){for(let[k,x]of m)a.pending.set(k,x);a.held??=new MutationObserver(()=>{A.closest("[inert]")||(a.held?.disconnect(),a.held=void 0,g())}),a.held.observe(A.ownerDocument.documentElement,{attributes:!0,attributeFilter:["inert"],subtree:!0});return}let{conversation:c,excerptOf:C,t:E}=u.current;if(!c||c.id!==b)return;let L=new Map(c.messages.map(k=>[k.id,k])),R=m.flatMap(([k])=>{let x=L.get(k),_=x&&Ao(x);return x&&_&&p(k,_)?[{id:k,stage:_,message:x}]:[]});if(!R.length)return;let y=new Map(c.messages.map((k,x)=>[k.id,x]));R.sort((k,x)=>y.get(k.id)-y.get(x.id));let P=R.length,S=R.filter(k=>k.stage==="failed").length,N=R.filter(k=>k.stage==="completed"),v=k=>{let x=C(k);return x===void 0?void 0:Zr(x)},w;if(P===1){let[k]=R,x=k.stage==="completed"?v(k.message):void 0;w=k.stage==="failed"?E("chat.arrivalFailed"):x!==void 0?E("chat.arrivalExcerpt",{excerpt:x}):E("chat.arrival")}else if(N.length===P){let k=v(N.at(-1).message);w=k!==void 0?E("chat.arrivalMany",{count:P,excerpt:k}):E("chat.arrivalManyPlain",{count:P})}else S===P?w=E("chat.arrivalAllFailed",{count:P}):S?w=E("chat.arrivalManyFailed",{count:P,failed:S}):w=E("chat.arrivalManyPlain",{count:P});for(let k of R){let x=a.announced.get(k.id)??new Set;x.add(k.stage),a.announced.set(k.id,x)}d(w)};return cn(()=>{if(a.client!==e&&(a.client=e,a.baselineFor=void 0),!t){a.baselineFor=void 0;return}if(a.baselineFor!==t.id){a.baselineFor=t.id,a.showing++,a.baseline=new Set(t.messages.map(m=>m.id)),a.announced.clear(),a.writing.clear(),a.pending.clear(),clearTimeout(a.timer),a.timer=void 0,a.frame!==void 0&&ln(a.frame),a.frame=void 0;return}for(let m of t.messages){if(a.baseline.has(m.id))continue;m.status==="writing"&&a.writing.add(m.id);let b=Ao(m);!b||!p(m.id,b)||(a.pending.size||(a.batchFor=t.id,a.batchShowing=a.showing),a.pending.set(m.id,b))}a.pending.size&&a.timer===void 0&&(a.timer=setTimeout(g,Jr))},[e,t]),cn(()=>()=>{clearTimeout(a.timer),a.frame!==void 0&&ln(a.frame),a.held?.disconnect()},[a]),i}function Uo(e,t){let[n,r]=Do(!1),s=dn(e);return cn(()=>{let i=t.current;if(!i||typeof MutationObserver!="function")return;let d=()=>r(!!i.closest("[inert]"));d();let a=new MutationObserver(d);return a.observe(i.ownerDocument.documentElement,{attributes:!0,attributeFilter:["inert"],subtree:!0}),()=>a.disconnect()},[t]),n||(s.current=e),s.current}var ts={"form.valid":"Valid","form.invalid":"Invalid","form.title":"Fill this form","form.closeHint":"Closing discards this fill; the reply stays in the conversation.","form.generate":"Generate draft","form.references":"Reference links","form.attachment":"Private attachment","form.regenerate":"Regenerate {field}","form.replace":"Replace your edit?","form.marker":"Form","form.filter":"Filter by topic","form.all":"All topics","form.threads":"Sub-threads","form.return":"Back to form or record","form.unlinked":"Saved, not linked","form.toolsLoading":"Draft tools are still loading.","form.toolsFailed":"Draft tools couldn't load. Retry first.","form.fixFirst":"Fix the highlighted fields first.","form.number":"Enter a number.","form.editInForm":"Edit this value in the form.","form.imagesNow":"Images can't be attached right now.","form.imagesHere":"Images can't be attached here.","chat.title":"Conversation","chat.empty":"Start a conversation","chat.message":"Message","chat.send":"Send","chat.sending":"Sending","chat.pendingSending":"Sending\u2026","chat.pendingFailed":"Not sent","chat.planUnavailable":"The plan's steps could not be loaded.","chat.arrival":"New reply","chat.arrivalExcerpt":"New reply: {excerpt}","chat.arrivalFailed":"A reply could not be completed.","chat.arrivalMany":"{count} new replies. Latest: {excerpt}","chat.arrivalManyPlain":"{count} new replies","chat.arrivalManyFailed":"{count} new replies; {failed} could not be completed.","chat.arrivalAllFailed":"{count} replies could not be completed.","chat.transcript":"Messages","chat.outlineItem":"{role}, message {position}: {excerpt}","chat.outlineItemPlain":"{role}, message {position}","chat.roleUser":"You","chat.roleAssistant":"Assistant","chat.messageLoading":"Loading message\u2026","chat.messageUnavailable":"This message cannot be shown right now.","chat.changesTo":"changes to","chat.stepName":"Change {index}","chat.stepNamed":"{name} {index}","chat.fieldName":"Value {index}","chat.scrollRegion":"Scrollable content","chat.conversationReadFailed":"This conversation could not be loaded.","chat.conversationsFailed":"Your conversations could not be loaded.","chat.messagesUnavailable":"Some messages cannot be shown right now.",unsupportedContent:"Some content cannot be shown here. Contact the site administrator.","chat.failure":"The request could not be completed.","chat.update":"This chat needs an update.","chat.conversationUnavailable":"This conversation is unavailable. Reload to continue; this does not stop a server turn.","chat.reload":"Reload conversation","chat.retry":"Retry","chat.withdraw":"Withdraw","chat.restored":"Withdrawn messages","chat.restoredEdit":"Edit","chat.restoredDiscard":"Discard","chat.dismiss":"Dismiss","chat.latest":"Back to latest","chat.latestNew":"{count, plural, one {Back to latest, # new reply} other {Back to latest, # new replies}}","chat.outline":"Message outline","chat.outlineFilter":"Filter messages","chat.outlineMatches":"{count, plural, =0 {No messages match} one {# message matches} other {# messages match}}","chat.outlineSearching":"Searching\u2026","chat.rail":"Conversations","chat.close":"Close","chat.quota":"Usage","chat.actions":"Actions","chat.panels":"Extra panels","chat.submit":"Submit","chat.confirm":"Confirm","chat.cancel":"Cancel","chat.stop":"Stop","chat.planChanged":"The plan changed; confirm again.","chat.stopped":"The plan was stopped. Start a new plan to continue.","chat.scheduleUnavailable":"Scheduling is unavailable in this chat.","chat.start":"Start time","chat.end":"End time","chat.view":"View change","chat.irreversible":"Cannot be undone","chat.stepUp":"{count, plural, one {# verification prompt} other {# verification prompts}}","chat.stepUpLabel":"Verification code","chat.plan":"Plan","chat.favourite":"Favourite","chat.run":"Run","chat.flows":"Saved requests","flow.favourites":"Favourites","flow.most-used":"Most used","flow.recent":"Recent","flow.presets":"Presets","reply.writing":"Writing","reply.stopped":"Stopped","chat.sources":"Sources ({count})","chat.source":"Source {index}: {title}","reply.unavailable":"Reply unavailable","reply.failed":"Reply failed","reply.overdue":"Reply overdue","chat.loading":"Loading","chat.before":"Before","chat.after":"After","chat.undo":"Undo","chat.verify":"Verification required","chat.startupLoading":"Loading this conversation\u2026"},bt={en:{},zh:{}};function Wo(e,t){Object.assign(bt.en,e),Object.assign(bt.zh,t)}var ns={"form.valid":"\u6709\u6548","form.invalid":"\u65E0\u6548","form.title":"\u586B\u5199\u6B64\u8868\u5355","form.closeHint":"\u5173\u95ED\u5C06\u4E22\u5F03\u672C\u6B21\u586B\u5145\uFF1B\u56DE\u590D\u4ECD\u4FDD\u7559\u5728\u5BF9\u8BDD\u4E2D\u3002","form.generate":"\u751F\u6210\u8349\u7A3F","form.references":"\u53C2\u8003\u94FE\u63A5","form.attachment":"\u79C1\u6709\u9644\u4EF6","form.regenerate":"\u91CD\u65B0\u751F\u6210{field}","form.replace":"\u66FF\u6362\u4F60\u7684\u4FEE\u6539\u5417\uFF1F","form.marker":"\u8868\u5355","form.filter":"\u6309\u4E3B\u9898\u7B5B\u9009","form.all":"\u6240\u6709\u4E3B\u9898","form.threads":"\u5B50\u5BF9\u8BDD","form.return":"\u8FD4\u56DE\u8868\u5355\u6216\u8BB0\u5F55","form.unlinked":"\u5DF2\u4FDD\u5B58\uFF0C\u672A\u5173\u8054","form.toolsLoading":"\u8349\u7A3F\u5DE5\u5177\u4ECD\u5728\u52A0\u8F7D\u3002","form.toolsFailed":"\u8349\u7A3F\u5DE5\u5177\u65E0\u6CD5\u52A0\u8F7D\uFF0C\u8BF7\u5148\u91CD\u8BD5\u3002","form.fixFirst":"\u8BF7\u5148\u4FEE\u6B63\u6807\u51FA\u7684\u5B57\u6BB5\u3002","form.number":"\u8BF7\u8F93\u5165\u6570\u5B57\u3002","form.editInForm":"\u8BF7\u5728\u8868\u5355\u4E2D\u7F16\u8F91\u6B64\u503C\u3002","form.imagesNow":"\u73B0\u5728\u65E0\u6CD5\u9644\u52A0\u56FE\u7247\u3002","form.imagesHere":"\u6B64\u5904\u65E0\u6CD5\u9644\u52A0\u56FE\u7247\u3002","chat.title":"\u5BF9\u8BDD","chat.empty":"\u5F00\u59CB\u5BF9\u8BDD","chat.message":"\u6D88\u606F","chat.send":"\u53D1\u9001","chat.sending":"\u6B63\u5728\u53D1\u9001","chat.pendingSending":"\u6B63\u5728\u53D1\u9001\u2026\u2026","chat.pendingFailed":"\u672A\u53D1\u9001","chat.planUnavailable":"\u65E0\u6CD5\u52A0\u8F7D\u6B64\u8BA1\u5212\u7684\u6B65\u9AA4\u3002","chat.arrival":"\u6536\u5230\u65B0\u56DE\u590D","chat.arrivalExcerpt":"\u6536\u5230\u65B0\u56DE\u590D\uFF1A{excerpt}","chat.arrivalFailed":"\u6709\u4E00\u6761\u56DE\u590D\u672A\u80FD\u5B8C\u6210\u3002","chat.arrivalMany":"\u6536\u5230 {count} \u6761\u65B0\u56DE\u590D\u3002\u6700\u65B0\u4E00\u6761\uFF1A{excerpt}","chat.arrivalManyPlain":"\u6536\u5230 {count} \u6761\u65B0\u56DE\u590D","chat.arrivalManyFailed":"\u6536\u5230 {count} \u6761\u65B0\u56DE\u590D\uFF0C\u5176\u4E2D {failed} \u6761\u672A\u80FD\u5B8C\u6210\u3002","chat.arrivalAllFailed":"{count} \u6761\u56DE\u590D\u672A\u80FD\u5B8C\u6210\u3002","chat.transcript":"\u6D88\u606F","chat.outlineItem":"{role}\uFF0C\u7B2C {position} \u6761\uFF1A{excerpt}","chat.outlineItemPlain":"{role}\uFF0C\u7B2C {position} \u6761","chat.roleUser":"\u4F60","chat.roleAssistant":"\u52A9\u624B","chat.messageLoading":"\u6B63\u5728\u52A0\u8F7D\u6D88\u606F\u2026\u2026","chat.messageUnavailable":"\u6682\u65F6\u65E0\u6CD5\u663E\u793A\u6B64\u6D88\u606F\u3002","chat.changesTo":"\u6539\u4E3A","chat.stepName":"\u66F4\u6539 {index}","chat.stepNamed":"{name} {index}","chat.fieldName":"\u503C {index}","chat.scrollRegion":"\u53EF\u6EDA\u52A8\u5185\u5BB9","chat.conversationReadFailed":"\u65E0\u6CD5\u52A0\u8F7D\u6B64\u5BF9\u8BDD\u3002","chat.conversationsFailed":"\u65E0\u6CD5\u52A0\u8F7D\u4F60\u7684\u5BF9\u8BDD\u5217\u8868\u3002","chat.messagesUnavailable":"\u90E8\u5206\u6D88\u606F\u6682\u65F6\u65E0\u6CD5\u663E\u793A\u3002",unsupportedContent:"\u6B64\u5904\u65E0\u6CD5\u663E\u793A\u90E8\u5206\u5185\u5BB9\u3002\u8BF7\u8054\u7CFB\u7AD9\u70B9\u7BA1\u7406\u5458\u3002","chat.failure":"\u65E0\u6CD5\u5B8C\u6210\u8BF7\u6C42\u3002","chat.update":"\u6B64\u5BF9\u8BDD\u9700\u8981\u66F4\u65B0\u540E\u624D\u80FD\u7EE7\u7EED\u4F7F\u7528\u3002","chat.conversationUnavailable":"\u6B64\u5BF9\u8BDD\u6682\u65F6\u65E0\u6CD5\u4F7F\u7528\u3002\u8BF7\u91CD\u65B0\u52A0\u8F7D\u540E\u7EE7\u7EED\uFF1B\u91CD\u65B0\u52A0\u8F7D\u4E0D\u4F1A\u505C\u6B62\u670D\u52A1\u5668\u6B63\u5728\u5904\u7406\u7684\u56DE\u590D\u3002","chat.reload":"\u91CD\u65B0\u52A0\u8F7D\u5BF9\u8BDD","chat.retry":"\u91CD\u8BD5","chat.withdraw":"\u64A4\u56DE","chat.restored":"\u5DF2\u64A4\u56DE\u7684\u6D88\u606F","chat.restoredEdit":"\u7F16\u8F91","chat.restoredDiscard":"\u4E22\u5F03","chat.dismiss":"\u5173\u95ED","chat.latest":"\u56DE\u5230\u6700\u65B0\u6D88\u606F","chat.latestNew":"{count, plural, other {\u56DE\u5230\u6700\u65B0\u6D88\u606F\uFF0C# \u6761\u65B0\u56DE\u590D}}","chat.outline":"\u6D88\u606F\u5927\u7EB2","chat.outlineFilter":"\u7B5B\u9009\u6D88\u606F","chat.outlineMatches":"{count, plural, =0 {\u6CA1\u6709\u5339\u914D\u7684\u6D88\u606F} other {# \u6761\u6D88\u606F\u5339\u914D}}","chat.outlineSearching":"\u6B63\u5728\u641C\u7D22\u2026","chat.rail":"\u5BF9\u8BDD\u5217\u8868","chat.close":"\u5173\u95ED","chat.quota":"\u4F7F\u7528\u91CF","chat.actions":"\u64CD\u4F5C","chat.panels":"\u9644\u52A0\u9762\u677F","chat.submit":"\u63D0\u4EA4","chat.confirm":"\u786E\u8BA4","chat.cancel":"\u53D6\u6D88","chat.stop":"\u505C\u6B62","chat.planChanged":"\u8BA1\u5212\u5DF2\u66F4\u6539\uFF0C\u8BF7\u91CD\u65B0\u786E\u8BA4\u3002","chat.stopped":"\u8BA1\u5212\u5DF2\u505C\u6B62\u3002\u8BF7\u521B\u5EFA\u65B0\u8BA1\u5212\u4EE5\u7EE7\u7EED\u3002","chat.scheduleUnavailable":"\u6B64\u804A\u5929\u4E0D\u652F\u6301\u6392\u671F\u3002","chat.start":"\u5F00\u59CB\u65F6\u95F4","chat.end":"\u7ED3\u675F\u65F6\u95F4","chat.view":"\u67E5\u770B\u4FEE\u6539","chat.irreversible":"\u65E0\u6CD5\u64A4\u9500","chat.stepUp":"{count, plural, other {# \u6B21\u9A8C\u8BC1}}","chat.stepUpLabel":"\u9A8C\u8BC1\u7801","chat.plan":"\u8BA1\u5212","chat.favourite":"\u6536\u85CF","chat.run":"\u8FD0\u884C","chat.flows":"\u5DF2\u4FDD\u5B58\u7684\u8BF7\u6C42","flow.favourites":"\u6536\u85CF","flow.most-used":"\u6700\u5E38\u7528","flow.recent":"\u6700\u8FD1","flow.presets":"\u9884\u8BBE","reply.writing":"\u6B63\u5728\u56DE\u590D","reply.stopped":"\u5DF2\u505C\u6B62","chat.sources":"\u6765\u6E90\uFF08{count}\uFF09","chat.source":"\u6765\u6E90 {index}\uFF1A{title}","reply.unavailable":"\u65E0\u6CD5\u56DE\u590D","reply.failed":"\u56DE\u590D\u5931\u8D25","reply.overdue":"\u56DE\u590D\u5DF2\u8D85\u65F6","chat.loading":"\u52A0\u8F7D\u4E2D","chat.before":"\u4FEE\u6539\u524D","chat.after":"\u4FEE\u6539\u540E","chat.undo":"\u64A4\u9500","chat.verify":"\u9700\u8981\u9A8C\u8BC1","chat.startupLoading":"\u6B63\u5728\u52A0\u8F7D\u6B64\u5BF9\u8BDD\u2026"},os=/^(tw|hk|mo)$/,rs=/^(zh|cmn)$/,ss=/^([a-z]{2,3}(-[a-z]{3}){0,3}|[a-z]{4,8})(-[a-z]{4})?(-([a-z]{2}|\d{3}))?(-([a-z\d]{5,8}|\d[a-z\d]{3}))*(-[\da-wyz](-[a-z\d]{2,8})+)*(-x(-[a-z\d]{1,8})+)?$/,as=/^zh-(hakka|min|xiang)\b/;function un(e="en"){let t={catalogue:"en",lang:"en"},n=e.toLowerCase();if(!ss.test(n)||as.test(n))return t;let r=n.split("-"),s=r[0],i=1;for(;/^[a-z]{3}$/.test(r[i]);)s=r[i++];if(rs.test(s)){let d=r[i];return(/^[a-z]{4}$/.test(d)?d==="hans":!os.test(d))?{catalogue:"zh",lang:e}:t}return s==="en"?{catalogue:"en",lang:e}:t}function Ge(e="en"){let t=un(e),n=t.catalogue==="zh",r=n?ns:ts,s=n?bt.zh:bt.en,i=ro(t.lang,n),d=new Map;return(a,u)=>{let p=d.get(a);if(!p){let g=r[a]??s[a];if(g===void 0)return"";p=new oo(g,i),d.set(a,p)}return String(p.format(u))}}import{useSyncExternalStore as is}from"react";var fn=new Set,ls=e=>(fn.add(e),()=>fn.delete(e));function Me(e){let t=r=>{n.load=r;for(let s of fn)s()},n={load:{status:"idle"},request(r){let{status:s}=n.load;s!=="idle"&&!(r&&s==="failed")||(t({status:"loading",...s==="failed"&&{retrying:!0}}),e().then(i=>t({status:"ready",module:i}),()=>t({status:"failed"})))}};return n}function xe(e){return is(ls,()=>e.load,()=>e.load)}import{Fragment as xn,jsx as l,jsxs as M}from"react/jsx-runtime";var Ye=Me(()=>import("./markdown-5NUOCOGY.js")),wn=yt(null),er=yt(void 0),tr=yt(void 0);function ps({id:e}){let t=X(wn);return V(()=>(t?.report(e,!0),()=>t?.report(e,!1)),[t,e]),null}function ms(){let e=xe(Ye);return e.status==="ready"?e.module:void 0}var qe=e=>`wp${Qe().replace(/[^\w-]/g,"")}-${e}`,pn=Me(()=>import("./recovery-panel-6EBUMANX.js")),hs=ds(()=>import("./confirmation-view-Z5JHY2F5.js")),gn=Me(()=>import("./blocks-2ABWECKG.js")),qo=Me(()=>import("./reply-controls-HUYHUO3W.js"));function gs(e){let t=xe(qo);return V(()=>qo.request(),[]),t.status==="ready"?l(t.module.ReplyControls,{...e}):null}var Ko=Me(()=>import("./message-actions-XNBBFHGW.js"));function bs(e){let t=xe(Ko);return V(()=>Ko.request(),[]),t.status==="ready"?l(t.module.MessageActions,{...e}):null}var mn=Me(()=>import("./flows-panel-2SCPYZ3X.js"));function kn(){let e=xe(gn);return V(()=>gn.request(),[]),e}function vs({block:e}){let t=kn();return t.status==="ready"?l(t.module.Answered,{block:e}):null}function ys(e){let{format:t}=$(),n=kn(),r=l("p",{children:e.block.fallback});if(n.status==="failed")return r;if(n.status!=="ready")return l("p",{children:t("chat.messageLoading")});let s=n.module.default;return l(Xe,{resetKey:e.block.id,fallback:r,children:l(s,{...e})})}var le=yt(null);function ws({children:e,onPress:t,disabled:n,label:r,...s}){return l("button",{type:"button",onClick:t,disabled:n,"aria-label":r,...s,children:e})}function ks({value:e,onChange:t,label:n,inputRef:r,onKeyDown:s,disabled:i,describedBy:d}){return l("textarea",{ref:r,disabled:i,value:e,onChange:a=>t?.(a.target.value),"aria-label":n,"aria-describedby":d,onKeyDown:s})}function $o({value:e,onChange:t,label:n,type:r="text",disabled:s,invalid:i,describedBy:d,required:a}){return M("label",{children:[n,l("input",{type:r,value:e,disabled:s,"aria-invalid":i,"aria-describedby":d,"aria-required":a||void 0,onChange:u=>t(u.target.value)})]})}function xs({checked:e,onChange:t,label:n,disabled:r,invalid:s,describedBy:i}){return M("label",{className:"wp-check",children:[l("input",{type:"checkbox",checked:e,disabled:r,"aria-invalid":s,"aria-describedby":i,onChange:d=>t(d.target.checked)}),n]})}function Cs({children:e,open:t,label:n,onClose:r,closeLabel:s,focusInto:i,restoreFocus:d}){let a=X(le)?.format??Ge(),u=F(null),p=F(i),g=F(d);p.current=i,g.current=d,Re(()=>{let m=u.current;if(!(!t||!m))return p.current?.(m),()=>g.current?.(m)},[t]);let f=Qe();return t?M("div",{ref:u,className:"wp-drawer",tabIndex:-1,role:"dialog","aria-modal":"true","aria-labelledby":f,onKeyDown:m=>{m.key==="Escape"&&r()},children:[M("div",{className:"wp-drawer-header",children:[l("h2",{id:f,children:n}),l("button",{type:"button",onClick:r,"aria-label":s??a("chat.close"),children:l("span",{"aria-hidden":"true",children:"\xD7"})})]}),l("div",{className:"wp-drawer-body",children:e})]}):null}var nr={button:ws,textarea:ks,input:$o,checkbox:xs,datePicker:e=>l($o,{...e,type:"datetime-local"}),drawer:Cs},zo="(prefers-color-scheme: dark)";function Ss(){return Zo(e=>{let t=globalThis.matchMedia?.(zo);return t?.addEventListener("change",e),()=>t?.removeEventListener("change",e)},()=>globalThis.matchMedia?.(zo).matches?"dark":"light",()=>"light")}function Es(e,t){let n=s=>!!s&&typeof s=="object"&&Object.getPrototypeOf(s)===Object.prototype,r=Object.keys(e);return r.length===Object.keys(t).length&&r.every(s=>{let i=e[s],d=t[s];return Object.is(i,d)||n(i)&&n(d)&&Ue(i,d)})}function bn(e,t=Ue){let n=F(e),r=n.current;return r!==e&&!(r&&e&&t(r,e))&&(n.current=e),n.current}function Ps(e){let{children:t,...n}=e,r=bn(n,Es),s=bn(e.useThemeTokens?.(),(m,b)=>m.scheme===b.scheme&&Ue(m.tokens,b.tokens)),i=e.theme===void 0&&s&&(e.colorScheme===void 0||e.colorScheme===s.scheme)?"host":"waypoint",d=Ss(),a=e.colorScheme??s?.scheme??d,u=fe(()=>r.format??Ge(r.locale),[r.format,r.locale]),p=fe(()=>({...r,colorScheme:a,format:u,lang:r.format?r.locale??"en":un(r.locale).lang,tokens:{...a==="dark"?lo:io,...i==="host"?s.tokens:r.theme},primitives:{...nr,...r.primitives}}),[r,u,a,i,s]),g=e.wrapper,f=l(uo.Provider,{value:e.client,children:l(le.Provider,{value:p,children:t})});return g?l(g,{colorScheme:a,tokens:p.tokens,tokenSource:i,children:f}):f}function Aa(){return X(le)?.colorScheme??"light"}function $(){let e=X(le);if(!e)throw new Error("WaypointProvider is required");return e}function Da(){return $().client}function Ba(e){let t=X(le),n=e??t?.client,r=Bt(e);return{conversationId:r.conversationId,conversation:r.conversation,refresh:n.refresh,editMessage:n.editMessage,regenerate:n.regenerate,selectVersion:n.selectVersion,switchConversation:n.switchConversation}}function Ha(e){let t=X(le),n=e??t?.client,r=it(({draft:s,sending:i,hints:d})=>({draft:s,sending:i,hints:d}),Ue,e);return{draft:r.draft,sending:r.sending,hints:r.hints,setDraft:n.setDraft,send:n.send,retry:n.retry,withdraw:n.withdraw,dismiss:n.dismiss}}function Ua(e){let t=X(le),n=e??t?.client,r=it(i=>i.plan,Object.is,e),{view:s}=Ht(e);return{plan:r,setPlan:n.setPlan,reply:n.reply,view:s}}function Wa(e){let t=X(le),n=e??t?.client,r=it(({flows:s,flowTab:i})=>({flows:s,flowTab:i}),Ue,e);return{flows:r.flows,tab:r.flowTab,load:n.loadFlows,select:n.selectFlowTab,setFavourite:n.setFavourite,run:n.runFlow}}var qa=["bubble","composer","transcript","replyRow","stepRow","planNode","widgetFrame","confirmBar","confirmation","topBar","rail","flowTabs","quotaStrip","failedSendControls","emptyState","messageActions","extraPanels","actionBar","stepUpPrompt","fieldAdornment","recoveryPanel","stepStatusRow","recoveryActions"];function or({action:e,onPress:t,label:n}){let{format:r,primitives:s}=$(),i=s.button,d=Qe();return M(xn,{children:[l(i,{"data-action":e.id,"aria-disabled":e.available?void 0:!0,"aria-describedby":e.reasonKey?d:void 0,"aria-busy":e.busy?!0:void 0,onPress:e.available?()=>t(e.id):void 0,children:n??(e.countedLabelKey&&e.labelValues?r(e.countedLabelKey,e.labelValues):r(e.labelKey))}),e.reasonKey?l("span",{id:d,"data-reason":e.id,children:r(e.reasonKey,e.reasonValues)}):null]})}function jo(e){let t=F(!1),[n,r]=j(!1),s=()=>{t.current=!1,r(!1)};return{busy:n,press:()=>{t.current||(t.current=!0,r(!0),e().then(s,s))}}}function Vo({problem:e,refresh:t}){let n=Ut(e),r=fe(()=>Date.now()+(e.retryAfter??0)*1e3,[e]),[s,i]=j(0),d=e.code==="rate-limited"&&Date.now()<r;return V(()=>{if(!d)return;let a=setTimeout(()=>i(u=>u+1),Math.max(r-Date.now(),1));return()=>clearTimeout(a)},[d,r,s]),n?l(or,{action:{id:"status",labelKey:n==="retry"?"chat.retry":"chat.problem.refresh",available:!d&&!t.busy,busy:t.busy,...d&&{reasonKey:"chat.problem.rateLimited"}},onPress:t.press}):null}function _o({problem:e}){let{format:t}=$();return t("chat.problem.details")?M("details",{"data-problem-details":"",children:[l("summary",{children:t("chat.problem.details")}),l("p",{children:t("chat.problem.code",{code:e.code})}),l("p",{children:t("chat.problem.reference",{id:e.id})})]}):null}var vt=e=>e.status==="loading"&&!!e.retrying;function vn(e){let{format:t,primitives:n}=$(),r=e.retrying||void 0;return M(xn,{children:[M("p",{role:"alert",onFocus:e.onFocus,children:[t("chat.failure")," ",l(n.button,{"aria-disabled":r,"aria-busy":r,onPress:()=>{r||e.onRetry()},children:t("chat.retry")})]}),l("span",{role:"status",children:r?t("chat.loading"):""})]})}function Ts(e){let{format:t}=$(),n=xe(pn);V(()=>pn.request(),[]);let r=F(null),s=_t(()=>[r.current?.querySelector("h3")]),i=n.status==="ready"&&n.module.default;return l("div",{ref:r,tabIndex:-1,"data-recovery":"",children:i?l(i,{...e}):n.status==="failed"||vt(n)?l(vn,{retrying:vt(n),onRetry:()=>pn.request(!0),onFocus:s}):l("p",{children:t("chat.loading")})})}function Go(e){return{id:e.id,type:e.type,answered:!!e.answered}}function Yo(e){return{id:e.id,content:e.content,failure:e.failure?{code:e.failure.code}:null}}function K({name:e,slots:t,children:n,...r}){let i=X(le)?.parts?.[e],d=t?.[e],a=d?d({...r,children:n}):i?l(i,{...r,children:n}):n;return l("div",{"data-part":e,children:a})}var Xe=class extends fs{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 Ms({text:e,writing:t,sources:n}){let r=$(),s=r.format,i=X(wn),d=Qe(),a=X(er)??d,u=X(tr),p=i?l(ps,{id:a}):l("p",{children:s("chat.messageUnavailable")}),g=xe(Ye);if(V(()=>{Ye.request(!0)},[e]),g.status==="failed")return p;if(g.status!=="ready")return l("p",{children:s("chat.messageLoading")});let f=g.module.default;return l(Xe,{resetKey:`${e}:${i?.retry??0}`,fallback:p,children:l(f,{text:e,writing:t,lang:r.lang,sources:n,sourceNames:{list:m=>s("chat.sources",{count:m}),item:(m,b)=>s("chat.source",{index:m,title:b})},images:r.markdownImages,extraSchemes:r.extraUrlSchemes,scrollLabel:s("chat.scrollRegion"),cached:u})})}function rr(e){let t=$().renderers?.markdown;return t?l(t,{text:e.text}):l(Ms,{...e})}function Rs(e,t){return{text:t(mo(e).key)||t("chat.failure")}}function Fs({block:e,onReply:t,disabled:n}){let{format:r,primitives:s,extraUrlSchemes:i}=$(),d=s.button,a=e.body;switch(e.type){case"form.fill":case"table":case"diff":case"form":case"choice":case"plan":return l(ys,{block:e,onReply:t,disabled:n});case"markdown":return l(rr,{text:String(a.text??"")});case"notice":return l("p",{children:String(a.text??"")});case"card":return M("section",{children:[l("h3",{children:String(a.title??"")}),(a.blocks??[]).map(u=>l(yn,{block:u,disabled:n,onReply:t},u.id))]});case"details":return M("details",{children:[l("summary",{children:String(a.summary??"")}),(a.blocks??[]).map(u=>l(yn,{block:u,disabled:n,onReply:t},u.id))]});case"list":return l("ul",{children:(a.items??[]).map((u,p)=>l("li",{children:u},p))});case"route-link":{let u=String(a.route??"");return at(u,i)?l("a",{href:u,children:String(a.label??r("chat.view"))}):l("span",{children:e.fallback})}case"buttons":return l("div",{children:(a.actions??[]).map(u=>l(d,{disabled:n,onPress:()=>t({kind:"action",blockId:e.id,actionId:u.id}),children:u.label},u.id))});default:return l("p",{children:e.fallback})}}var Ls=["markdown","form.fill","card","details","list","table","form","choice","buttons","diff","plan","route-link","notice"].map(e=>({type:e,render:Fs}));function yn(e){let{widgets:t,format:n}=$(),r=t?.find(i=>i.type===e.block.type)??Ls.find(i=>i.type===e.block.type);if(!r)return l("div",{"data-fallback":"true",children:l("p",{children:e.block.fallback?.trim()?e.block.fallback:n("unsupportedContent")})});let s=r.render;return l(s,{...e})}function Is(e){let{format:t,primitives:n}=$(),r=kn(),s=n.button,i=F(null),[d,a]=j(0),u=F(null);Re(()=>{let f=i.current;te(f,{root:f,owner:"",removed:u.current})});let p=M("p",{role:"alert",children:[t("chat.planUnavailable"),l(s,{onPress:()=>{u.current=document.activeElement,a(d+1),gn.request(!0)},children:t("chat.retry")})]}),g=r.status==="ready"&&r.module.PlanSteps;return l("div",{ref:i,tabIndex:-1,children:g?l(Xe,{resetKey:`${e.record.id}:${d}`,fallback:p,children:l(g,{...e})}):r.status==="failed"?p:l("p",{children:t("chat.messageLoading")})})}function Ka(e){let t=X(le);return e.client?l(Ps,{...e,client:e.client,children:l(Jo,{...e})}):t?l(Jo,{...e}):l("section",{className:"waypoint",dir:e.dir??"ltr",children:l("p",{children:Ge(e.locale)("chat.empty")})})}var Ns='input, textarea, select, [contenteditable]:not([contenteditable="false"]), [role="textbox"], [role="combobox"], [role="listbox"], [role="grid"], [role="slider"], [role="spinbutton"]',Xo="\uE000",Os=150,As=()=>()=>{},Qo=()=>0;function Ds({messages:e,excerpts:t,anchor:n,open:r,onToggle:s,onNavigate:i,query:d,onQuery:a,search:u,sourceOf:p,lang:g}){let{format:f,primitives:m}=$(),b=m.button,A=m.input,c=qe("outline"),C=qe("outline-status"),[E,L]=j(d);V(()=>{let S=setTimeout(()=>L(d),Os);return()=>clearTimeout(S)},[d]);let R=r&&d.trim()&&E.trim()?on(E,g):"";Zo(R?u.subscribe:As,R?u.snapshot:Qo,Qo);let y=r?e.flatMap((S,N)=>!R||u.textOf(S.id,p(S))?.includes(R)?[{message:S,index:N}]:[]):[],P=!!R&&!u.complete();return M("nav",{"aria-label":f("chat.outline"),"data-outline":"",className:"wp-outline",children:[l(b,{"aria-expanded":r,"aria-controls":c,onPress:s,children:f("chat.outline")}),r?M("div",{"data-outline-filter":"",children:[l(A,{type:"search",label:f("chat.outlineFilter"),value:d,onChange:a,describedBy:C}),l("p",{id:C,role:"status",children:R?P?f("chat.outlineSearching"):f("chat.outlineMatches",{count:y.length}):null})]}):null,l("ol",{id:c,hidden:!r,role:"list",children:r?y.map(({message:S,index:N})=>{let v={role:f(S.role==="user"?"chat.roleUser":"chat.roleAssistant"),position:N+1},w=t[N],k=w===void 0?void 0:f("chat.outlineItem",{...v,excerpt:Xo}).split(Xo);return l("li",{children:l("a",{href:`#${n(S.id)}`,"data-outline-link":S.id,onClick:x=>{x.preventDefault(),i(S.id)},children:k?k.length===2?M(xn,{children:[k[0],l("bdi",{children:w}),k[1]]}):l("bdi",{children:f("chat.outlineItem",{...v,excerpt:w})}):f("chat.outlineItemPlain",v)})},S.id)}):null})]})}function Bs({label:e,closeLabel:t,onClose:n,skipRestore:r,onFocusWithin:s,children:i}){let d=$().primitives.drawer,a=tn("rail"),u=F(void 0),p=F(s);return p.current=s,l(en,{as:d,open:!0,label:e,closeLabel:t,onClose:n,focusInto:g=>{let f=m=>p.current(Pe(m));g.addEventListener("focusin",f),u.current={element:g,listener:f},a.focusInto?.(g)},restoreFocus:g=>{let f=u.current;u.current=void 0,f?.element.removeEventListener("focusin",f.listener),r()?a.release?.():a.restoreFocus?.(g)},children:i})}var sr=e=>e.sources?.length?`${e.content}\0${JSON.stringify(e.sources)}`:e.content;function ar({slots:e,message:t}){let{client:n}=$();return l(K,{name:"messageActions",slots:e,data:{message:{id:t.id,role:t.role,status:t.status,versionIndex:t.versionIndex,versionCount:t.versionCount}},children:l(bs,{client:n,message:t})})}var Hs=cs(function({message:t,slots:n,anchorId:r,writing:s,bodyUnavailable:i,disabled:d,answered:a,actions:u,rows:p,posInSet:g,setSize:f}){let m=$().format,b=fe(()=>{let c=sr(t);return C=>p.parses.get(t.id,c,C)},[p,t]),A=m(t.role==="user"?"chat.roleUser":"chat.roleAssistant");return M("article",{id:r,tabIndex:-1,"data-message-id":t.id,"data-role":t.role,"aria-busy":s?!0:void 0,"aria-posinset":g,"aria-setsize":f,"aria-label":A,"data-body-unavailable":i?"":void 0,children:[M(K,{name:"bubble",slots:n,data:{message:{id:t.id,role:t.role,content:t.content,status:t.status,versionIndex:t.versionIndex,versionCount:t.versionCount,blocks:t.blocks.map(Go)}},children:[l("span",{"data-sender":"","aria-hidden":"true",children:A}),l(er.Provider,{value:t.id,children:l(tr.Provider,{value:b,children:l(rr,{text:t.content,writing:s,sources:t.sources})})}),s?l("span",{"data-writing":"","aria-hidden":"true",children:m("reply.writing")}):t.status==="stopped"?l("span",{"data-stopped":"",children:m("reply.stopped")}):t.status==="failed"||t.status==="unavailable"?l("span",{"data-reply-ended":t.status,children:m(`reply.${t.status}`)}):null,t.blocks.map((c,C)=>{let E=a[C]==="1";return l(K,{name:"widgetFrame",slots:n,data:{block:Go(c)},children:M("div",{"data-open-card":c.type==="card"&&!E?"true":void 0,children:[l(yn,{block:c,disabled:d||E,onReply:p.respond(c,t.id)}),c.answered?l(vs,{block:c}):null]})},c.id)})]}),u?l(ar,{slots:n,message:t}):null]})});function Jo({slots:e,features:t,layout:n="panel",shortcuts:r,conversations:s=[],conversationSource:i,quota:d,onStop:a,suggestions:u=[]}){let p=bn(e),g=Qe(),f=$(),{client:m,format:b,tokens:A}=f,c=Bt(),C=F(null),E=F(null),L=F(null),R=F(null),y=F(new Set).current,[,P]=j(0),[S,N]=j(0),v=fe(()=>({retry:S,report(o,h){y.has(o)!==h&&(h?y.add(o):y.delete(o),P(T=>T+1))}}),[S,y]),{isAnswered:w,reply:k}=po(m),x=F(null),_=F(null),Z=F(new Set),[W,pe]=j(0),[Se,Fe]=j(!1),[Cn,Sn]=j(),wt=jo(()=>m.refresh()),En=jo(()=>m.refresh()),kt=Ht(m),ee=f.primitives.button,ir=f.primitives.textarea,Pn=!!(p?.extraPanels||f.parts?.extraPanels),Tn=qe("hint"),Ze=qe("pending"),et=o=>(c.conversation?.mode!=="form-fill"||o==="form-fill"||o==="widgets")&&c.capabilities.includes(o)&&(!t||t.includes(o)),[lr,xt]=j("loading"),Mn=()=>{xt(o=>o==="failed"?"retrying":"loading"),m.loadFlows().then(()=>xt("done"),()=>xt("failed"))};V(Mn,[m]),V(()=>{let o=()=>Ye.request();if(typeof requestIdleCallback=="function"){let T=requestIdleCallback(o,{timeout:1e3});return()=>cancelIdleCallback(T)}let h=setTimeout(o,0);return()=>clearTimeout(h)},[]);let[,cr]=j(!1);V(()=>{import("./problem-messages-Z5QGO6RE.js").then(o=>{Wo(o.problemEnglish,o.problemSimplifiedChinese),cr(!0)})},[]);let I=Eo(C,ue(m,c.conversationId),E,L,o=>ue(m,o)),D=c.conversation?.messages??[],oe=c.conversation?.id,[Ke,Ct]=j({open:!1,query:""});Ke.conversationId!==oe&&Ct({conversationId:oe,open:!1,query:""});let Le=Ke.conversationId===oe&&Ke.open,Rn=`wp${g.replace(/[^\w-]/g,"")}`,St=o=>`${Rn}-${o.replace(/[^A-Za-z0-9-]/gu,h=>`_${h.codePointAt(0)}_`)}`,me=Io(L,R,oe,D.length,c),he=fe(()=>D.map(o=>o.id),[D]),Ie=Oo(L,R,he,me.pinned,me.anchorId()),Fn=()=>{let o=decodeURIComponent(location.hash.slice(1)),h=o.startsWith(`${Rn}-`)?he.find(T=>St(T)===o):void 0;h&&Ie.reveal(h,()=>me.toMessage(h))},Ln=F(Fn);Ln.current=Fn;let In=Ie.windowed;V(()=>{if(!In||typeof location>"u")return;let o=()=>Ln.current();return o(),addEventListener("hashchange",o),()=>removeEventListener("hashchange",o)},[In]);let dr=o=>{let h=o.target,T=h.closest("article[data-message-id], article[data-pending-id]");if(!T||h.closest(Ns))return;let O=o.currentTarget,B=I.value.originFor("feed"),H=I.value.owner();if(o.ctrlKey&&(o.key==="Home"||o.key==="End")){let Be=o.key==="Home",rt=[...(O.closest(".waypoint")??O.ownerDocument.body).querySelectorAll(zt)].filter(st=>!O.contains(st)&&ie(st)&&st.tabIndex>=0&&!!(O.compareDocumentPosition(st)&(Be?Node.DOCUMENT_POSITION_PRECEDING:Node.DOCUMENT_POSITION_FOLLOWING))),no=Be?rt.at(-1):rt[0];if(!no)return;o.preventDefault(),Y(I.value,no,{origin:B,owner:H});return}if(o.key!=="PageDown"&&o.key!=="PageUp"||o.ctrlKey||o.altKey||o.metaKey||o.shiftKey)return;let U=c.pending.map(Be=>Be.id),G=T.getAttribute("data-message-id"),ae=G!==null?he.indexOf(G):he.length+U.indexOf(T.getAttribute("data-pending-id")),z=ae+(o.key==="PageDown"?1:-1);if(ae<0||z<0||z>=he.length+U.length)return;if(o.preventDefault(),z>=he.length){let Be=U[z-he.length],At=[...O.querySelectorAll("article[data-pending-id]")].find(rt=>rt.getAttribute("data-pending-id")===Be);At&&Y(I.value,At,{origin:B,owner:H});return}let we=he[z];Ie.reveal(we,()=>Y(I.value,me.toMessage(we),{origin:B,owner:H}))},Et=F(void 0),ur=o=>{let h=o.target,T=D.map(G=>G.id),O={owner:I.value.owner(),shown:oe,order:T},B=h.closest("[data-outline-link]"),H=h.closest("[data-back-to-latest]"),U=h.closest("article[data-message-id]");Et.current=B?{...O,kind:"link",id:B.getAttribute("data-outline-link"),element:B}:H?{...O,kind:"latest",element:H}:U&&q(L.current,U)?{...O,kind:"message",id:U.getAttribute("data-message-id"),element:U}:void 0};Re(()=>{let o=Et.current;if(!o||o.element.isConnected)return;Et.current=void 0;let h=L.current,T=h?.parentElement,O=(H,U)=>{let G=new Map;for(let z of U?.querySelectorAll(`[${H}]`)??[])G.set(z.getAttribute(H),z);let ae=o.order.indexOf(o.id);for(let z=ae+1;z<o.order.length;z++){let we=G.get(o.order[z]);if(we)return we}for(let z=ae-1;z>=0;z--){let we=G.get(o.order[z]);if(we)return we}},B=o.kind==="message"?O("data-message-id",h)??h:o.kind==="link"?O("data-outline-link",T)??T?.querySelector("nav[data-outline] [aria-expanded]")??h:h;Y(I.value,B,{owner:o.owner,stillCurrent:()=>I.value.owner()===o.owner&&m.getSnapshot().conversation?.id===o.shown,removed:o.element,fallback:h})});let Nn=s.length>0||!!i,[re,fr]=j(!1),[Ne,$e]=j(!1),On=qe("rail"),pr=Qt(Ne,I.value.owner(),()=>$e(!1)),Pt=F(void 0),Tt=F(!1),tt=F(!1),mr=()=>{let o=Tt.current||tt.current;return Tt.current=!1,o};Re(()=>{let o=C.current;if(!o||typeof ResizeObserver!="function")return;let h=()=>{let O=o.getBoundingClientRect().width,B=parseFloat(getComputedStyle(o).fontSize)||16;fr(O>0&&O<40*B)},T=new ResizeObserver(h);return T.observe(o),h(),()=>T.disconnect()},[]);let An=F(re);Re(()=>{An.current&&!re&&Ne&&(tt.current=!0,$e(!1)),An.current=re},[re,Ne]),Re(()=>{if(!tt.current||Ne)return;tt.current=!1;let o=Pt.current;if(Pt.current=void 0,!o||o.element.isConnected)return;let h=C.current?.querySelector('[data-part="rail"] nav'),T=o.id?[...h?.querySelectorAll("[data-conversation-id]")??[]].find(O=>O.getAttribute("data-conversation-id")===o.id)?.querySelector("button"):void 0;Y(I.value,T??h??L.current,{owner:o.owner,stillCurrent:()=>I.value.owner()===o.owner,removed:o.element,fallback:L.current})});let nt=F(void 0),Dn=I.value.owner();me.pinned||!D.length?nt.current=void 0:nt.current?.owner!==Dn&&(nt.current={owner:Dn,ids:new Set(D.map(o=>o.id))});let Bn=nt.current,Hn=Bn?D.filter(o=>o.role==="assistant"&&!Bn.ids.has(o.id)).length:0,ge=ms(),be=!!(f.renderers?.markdown||f.parts?.bubble||f.parts?.transcript||p?.bubble||p?.transcript),Mt=F(new dt).current;Mt.begin(ue(m,oe??""),[be,f.messageExcerpt,ge,f.markdownImages?.origin,f.markdownImages?.allow,f.extraUrlSchemes?.join(" ")],D.map(o=>({id:o.id,source:be?o:o.content})));let Un=F(new ke).current;Un.begin(ue(m,oe??""),[ge,f.markdownImages?.origin,f.markdownImages?.allow,f.extraUrlSchemes?.join(" ")],D.map(o=>({id:o.id,source:o.content})));let Wn=(o,h)=>Un.get(o.id,o.content,T=>h.visibleText(T,{images:f.markdownImages,extraSchemes:f.extraUrlSchemes})),qn=o=>{if(be)return Mt.get(o.id,o,h=>{let T=f.messageExcerpt?.(h);return T===void 0?void 0:nn(T)});if(ge)return Mt.get(o.id,o.content,()=>nn(Wn(o,ge)))},Rt=F(new ke).current,hr=fe(()=>D.map(o=>({id:o.id,source:sr(o)})),[D]);Rt.begin(ue(m,oe??""),[ge,f.extraUrlSchemes?.join(" "),S],hr);let gr=Le?D.map(qn):[],ze=F(new ut).current,br=o=>be?o:o.content,vr=fe(()=>D.map(o=>({id:o.id,source:be?o:o.content,message:o})),[D,be]);ze.sync(ue(m,oe??""),[be,!!f.messageExcerpt,ge,f.markdownImages?.origin,f.markdownImages?.allow,f.extraUrlSchemes?.join(" "),f.lang],vr,o=>on(be?f.messageExcerpt?.(o)??"":ge?Wn(o,ge):o.content,f.lang)),V(()=>{Le&&ze.start()}),V(()=>Le?()=>ze.stop():void 0,[Le,ze]);let Kn=F(null),yr=Ho(m,c.conversation,qn,b,Kn),Ee=qe("flows"),$n=F(""),zn=_t(()=>{let o=C.current?.querySelector(`[id="${Ee}-panel"]`);return[o?.querySelector(`[data-flow="${$n.current}"] button`),o]}),je=xe(mn),jn=et("flows");V(()=>{jn&&mn.request()},[jn]);let[Ve,Vn]=j(void 0),_n=(o,h={})=>{let T=m,O=I.value.owner(),B=ue(T,`flow:${o}`),H=I.value.originFor("run-flow",B);Vn(void 0),T.runFlow(o,h).then(U=>{let G=U&&ue(T,U);Y(I.value,E.current,{origin:H,owner:B,stillCurrent:()=>!!G&&I.value.owner()===G&&T.getSnapshot().conversation?.id===U})},()=>{de(H),Vn({id:o,owner:O,values:h})})},Oe=c.replyState,Ae=D.at(-1),Gn=Oe==="writing"&&Ae?.status==="writing"?Ae.id:void 0,wr=Ae?.role==="assistant"&&(Ae.status==="failed"||Ae.status==="unavailable")&&Oe===Ae.status,Yn=F(null),Ft=Uo(Oe,Yn),Xn=(o,h)=>T=>{let O=J(document),B=fo(c.conversationId,h,o.id,T),H=!Z.current.has(B);Z.current.add(B),k(o,T,h).then(U=>{H&&Z.current.delete(B);let G=m.getSnapshot();U?.accepted===!1&&U.problem?.code==="refused"&&G.conversation?.messages.find(ae=>ae.id===h)?.blocks.find(ae=>ae.id===o.id)?.answered&&(_.current=G.problem),x.current=O,pe(ae=>ae+1)})};Re(()=>{let o=x.current,h=I.value.root();x.current=null,o&&h&&te(ie(o)?o:I.value.composer(),{root:h,owner:"",removed:o})},[W]);let Qn=!!c.problem&&c.problem===_.current,ve=c.problem&&!Z.current.has(c.problem.id)?f.problemText?.(c.problem,{answeredElsewhere:Qn})??(Qn?{text:b("chat.problem.answered")||b("chat.failure")}:Rs(c.problem,b)):null,se=c.plan,Q=kt.view,ot=ve&&c.problem?.id!=="conversation-unavailable"&&!(c.problem?.code==="stopped"&&Q?.status)&&!c.problem?.confirmation&&!(c.conversationUnavailable&&c.problem?.id==="conversation-read")?c.problem:void 0,De=ot&&c.pending.some(o=>o.failure&&o.id===ot.id)?ot:void 0,Lt=De?void 0:ot,It=Q?.actions.find(o=>o.id==="confirm"),Jn=Q?.actions.find(o=>o.id==="stop"),ye=Dt(se,c.conversationId),kr=o=>{if(Se)return;let h=m.getSnapshot();if(Dt(h.plan,h.conversationId)?.token!==o){Sn(o);return}Sn(void 0),Fe(!0),m.confirmPlan().finally(()=>Fe(!1))},Zn=c.confirmationRefusal,xr=Zn?.token===ye?.token&&Zn?.problemId===c.problem?.id?c.problem?.confirmation?.reason:void 0,Cr=Cn!==void 0&&Cn!==ye?.token,Sr=re?"section":"aside",Er=se?.state==="awaiting-confirmation"&&!Q?.readOnly&&ye!==void 0,Nt=et("plans")&&se?M(Sr,{"aria-label":b("chat.plan"),"data-plan":"",children:[l(Is,{record:se,slots:p,view:Q,changesShown:Er}),M(K,{name:"confirmBar",slots:p,data:Q?{view:Q,actions:Q.actions.filter(o=>Q.status?o.id==="confirm":o.id==="confirm"||o.id==="stop")}:void 0,children:[se.state==="awaiting-confirmation"&&!Q?.readOnly?l(K,{name:"confirmation",slots:p,data:ye&&{confirmation:ye},children:l(us,{fallback:null,children:l(hs,{record:ye,planId:se.id,entry:It&&(Se?{...It,available:!1,busy:!0}:It),onConfirm:()=>ye&&kr(ye.token),refusal:xr,override:f.problemText&&ve,replaced:Cr})})}):null,!Q?.status&&Jn?l(or,{action:Jn,onPress:a??(()=>m.stopPlan())}):null]}),Q?.status?l(Ts,{view:Q,onPress:kt.press,slots:p,sheet:kt.sheet,hide:["confirm"]}):null]}):null,eo=D.at(-1),Ot=re&&Nt&&!c.pending.length&&eo?.blocks.some(o=>o.type==="plan"&&o.body?.planId===se?.id)?eo:void 0,to=F(Xn);to.current=Xn;let Pr=fe(()=>({respond:(o,h)=>T=>to.current(o,h)(T),parses:Rt}),[Rt]),Tr=o=>o.blocks.map(h=>w(h,o.id)?"1":"0").join("");return l(Xt.Provider,{value:I.value,children:l("section",{ref:C,className:"waypoint",dir:f.dir??"ltr",lang:f.lang,"data-layout":n,"data-color-scheme":f.colorScheme??"light","data-custom-theme":f.theme?"":void 0,style:{...co(A),colorScheme:f.colorScheme??"light"},...I.captureProps,onKeyDown:o=>{r?.focusComposer===!1||o.key!==(r?.focusComposer??"/")||!q(o.currentTarget,Pe(o.nativeEvent))||!To(o.currentTarget)||o.currentTarget.querySelector(so)||(o.preventDefault(),E.current?.focus())},children:M("div",{className:"wp-shell","data-has-aside":et("plans")&&se||Pn?"":void 0,"data-has-rail":Nn||p?.rail||f.parts?.rail?"":void 0,children:[re?null:l(K,{name:"rail",slots:p,children:l(hn,{conversations:s,source:i})}),M("main",{children:[M(K,{name:"topBar",slots:p,children:[re&&Nn?l("span",{"data-rail-toggle":"",children:l(ee,{"aria-expanded":Ne,"aria-controls":On,onPress:()=>$e(o=>!o),children:b("chat.rail")})}):null,l("h2",{children:c.conversation?.title||b("chat.title")})]}),re&&Ne&&!pr?l(Bs,{label:b("chat.rail"),closeLabel:b("chat.close"),onClose:()=>$e(!1),skipRestore:mr,onFocusWithin:o=>{let h=o.closest("[data-conversation-id]");Pt.current={element:o,id:h?.getAttribute("data-conversation-id")??void 0,owner:I.value.owner()}},children:l("div",{id:On,children:l(hn,{conversations:s,source:i,onChoose:()=>{let o=I.value.originFor("rail-choice");Tt.current=!0,Y(I.value,C.current?.querySelector("[data-rail-toggle] button"),{origin:o,owner:I.value.owner()}),$e(!1)}})})}):null,l(K,{name:"transcript",slots:p,children:M("div",{onFocusCapture:ur,children:[D.length?l(Ds,{messages:D,excerpts:gr,anchor:St,open:Le,onToggle:()=>Ct({conversationId:oe,open:!Le,query:Ke.query}),query:Ke.query,onQuery:o=>Ct({conversationId:oe,open:!0,query:o}),search:ze,sourceOf:br,lang:f.lang,onNavigate:o=>{let h=I.value.originFor("outline"),T=I.value.owner();Ie.reveal(o,()=>Y(I.value,me.toMessage(o),{origin:h,owner:T}))}}):null,l("div",{ref:L,className:"wp-transcript",role:"region","aria-label":b("chat.transcript"),tabIndex:-1,children:l(wn.Provider,{value:v,children:M("div",{ref:R,role:D.length?"feed":void 0,"aria-busy":Ie.busy?!0:void 0,onKeyDown:D.length?o=>dr(o):void 0,children:[!c.conversation&&!c.conversationUnavailable&&!c.problem?l("p",{children:b("chat.startupLoading")}):D.length?null:l(K,{name:"emptyState",slots:p,children:l("p",{children:b("chat.empty")})}),Ie.segments.flatMap(o=>o.kind==="gap"?l("div",{"data-transcript-gap":"","aria-hidden":"true",style:{blockSize:o.height}},`gap-${o.from}`):D.slice(o.from,o.to+1).map((h,T)=>l(Hs,{posInSet:o.from+T+1,setSize:D.length+c.pending.length,message:h,slots:p,anchorId:St(h.id),writing:h.id===Gn,bodyUnavailable:y.has(h.id)&&!h.blocks.length,disabled:c.conversationUnavailable,answered:Tr(h),actions:h!==Ot,rows:Pr},h.id))),c.pending.map((o,h)=>M("article",{"data-role":"pending","data-pending-id":o.id,tabIndex:-1,"aria-posinset":D.length+h+1,"aria-setsize":D.length+c.pending.length,"aria-label":b("chat.roleUser"),children:[M(K,{name:"bubble",slots:p,data:{pending:Yo(o)},children:[l("span",{"data-sender":"","aria-hidden":"true",children:b("chat.roleUser")}),l("p",{children:o.content})]}),l("p",{id:`${Ze}-${o.id}`,"data-pending-status":o.failure?"failed":"sending",children:b(o.failure?"chat.pendingFailed":"chat.pendingSending")}),De?.id===o.id&&ve?M("p",{role:"alert",children:[ve.text,ve.action??(!f.problemText&&Ut(De)==="refresh"?l(Vo,{problem:De,refresh:En}):null)]},c.announcement):null,o.failure?M(K,{name:"failedSendControls",slots:p,data:{pending:Yo(o)},children:[l(ee,{"aria-describedby":`${Ze}-${o.id}`,disabled:c.conversationUnavailable||c.sending,onPress:()=>{m.retry(o.id)},children:b("chat.retry")}),l(ee,{"aria-describedby":`${Ze}-${o.id}`,disabled:c.withdrawing.includes(o.id),onPress:()=>{m.withdraw(o.id)},children:b("chat.withdraw")}),l(ee,{"aria-describedby":`${Ze}-${o.id}`,onPress:()=>{m.dismiss(o.id)},children:b("chat.dismiss")})]}):null,De?.id===o.id?l(_o,{problem:De},c.announcement):null]},o.id))]})})}),y.size?M("p",{role:"alert","data-render-failure":"",children:[b("chat.messagesUnavailable"),l(ee,{onPress:()=>{Ye.request(!0),N(o=>o+1)},children:b("chat.retry")})]}):null,me.pinned?null:l("div",{"data-back-to-latest":"",children:l(ee,{onPress:()=>{let o=I.value.originFor("latest");me.toLatest(),Y(I.value,L.current,{origin:o,owner:I.value.owner()})},children:Hn?b("chat.latestNew",{count:Hn}):b("chat.latest")})})]})}),M(K,{name:"replyRow",slots:p,children:[l("div",{ref:Yn,role:"status","data-reply-state":Oe,children:Ft==="none"||wr?null:l("p",{className:Ft==="writing"&&Gn?"wp-sr-only":void 0,children:b(`reply.${Ft}`)})}),Oe!=="none"||c.toolSteps.length?l(gs,{client:m,row:Oe}):null]}),re?Nt:null,Ot?l(ar,{slots:p,message:Ot}):null,et("flows")?l(K,{name:"flowTabs",slots:p,children:M("nav",{"aria-label":b("chat.flows"),children:[l("div",{role:"tablist",onKeyDown:o=>{let h=c.flowTabs,T=h.findIndex(H=>He(H)===c.flowTab),O;if(o.key==="Home")O=0;else if(o.key==="End")O=h.length-1;else if(o.key==="ArrowRight"||o.key==="ArrowLeft"){let H=getComputedStyle(o.currentTarget).direction,U=o.key==="ArrowRight"!=((H==="rtl"||H==="ltr"?H:f.dir)==="rtl");O=(T+(U?1:h.length-1))%h.length}else return;let B=o.currentTarget;!q(B,Pe(o.nativeEvent))||!q(B,J(B.ownerDocument))||(o.preventDefault(),m.selectFlowTab(h[O]),o.currentTarget.querySelectorAll('[role="tab"]')[O]?.focus())},children:c.flowTabs.map(o=>l(ee,{id:`${Ee}-${He(o)}`,"aria-controls":`${Ee}-panel`,role:"tab","aria-selected":c.flowTab===He(o),tabIndex:c.flowTab===He(o)?0:-1,label:typeof o=="string"?b(`flow.${o}`):f.flowTabLabel?.(o.labelKey)??o.labelKey,onPress:()=>m.selectFlowTab(o),children:typeof o=="string"?b(`flow.${o}`):f.flowTabLabel?.(o.labelKey)??o.labelKey},He(o)))}),Ve&&Ve.owner===I.value.owner()?l(vn,{onFocus:o=>{$n.current=Ve.id,zn(o)},onRetry:()=>_n(Ve.id,Ve.values)}):null,je.status==="ready"?l(je.module.FlowPanel,{id:`${Ee}-panel`,labelledBy:`${Ee}-${c.flowTab}`,flows:c.flows[c.flowTab],all:c.flows,list:lr,onRetryList:Mn,onRunFlow:_n}):l("div",{id:`${Ee}-panel`,role:"tabpanel","aria-labelledby":`${Ee}-${c.flowTab}`,tabIndex:-1,onFocus:zn,children:je.status==="failed"||vt(je)?l(vn,{retrying:vt(je),onRetry:()=>mn.request(!0)}):l("p",{children:b("chat.loading")})})]})}):null,c.restored.length?l("section",{"aria-label":b("chat.restored"),children:c.restored.map(o=>M("article",{children:[l("p",{children:o.content}),l(ee,{onPress:()=>{m.editRestored(o.id)},children:b("chat.restoredEdit")}),l(ee,{onPress:()=>{m.discardRestored(o.id)},children:b("chat.restoredDiscard")})]},o.id))}):null,M(K,{name:"composer",slots:p,data:{sending:c.sending},disabled:c.conversationUnavailable,value:c.draft,onChange:o=>{m.setDraft(o)},children:[l(ir,{inputRef:E,disabled:c.conversationUnavailable,value:c.draft,onChange:o=>{m.setDraft(o)},label:b("chat.message"),describedBy:c.hints.length?c.hints.map((o,h)=>`${Tn}-${h}`).join(" "):void 0,onKeyDown:o=>{r?.send!==!1&&o.key===(r?.send??"Enter")&&!o.shiftKey&&!o.nativeEvent.isComposing&&o.keyCode!==229&&(o.preventDefault(),m.send())}}),l(ee,{disabled:c.conversationUnavailable||!c.draft.trim()||c.sending,onPress:()=>{m.send()},children:b(c.sending?"chat.sending":"chat.send")}),c.hints.map((o,h)=>l("p",{id:`${Tn}-${h}`,children:o},h))]}),l(K,{name:"actionBar",slots:p,children:u.map(o=>l(ee,{onPress:()=>{m.setDraft(o)},children:o},o))}),l(K,{name:"stepUpPrompt",slots:p,data:se?.plan.kind==="immediate"&&se.plan.stage==="final"?{stepUpCount:se.plan.stepUpCount}:void 0}),l(K,{name:"quotaStrip",slots:p,children:d}),l("div",{ref:Kn,className:"wp-sr",role:"status","data-announcements":"",children:yr}),M("div",{role:"alert","data-announcement":c.announcement,children:[c.conversationUnavailable&&M("span",{children:[b("chat.conversationUnavailable"),l(ee,{onPress:wt.press,"aria-busy":wt.busy||void 0,"aria-disabled":wt.busy||void 0,children:b("chat.reload")})]}),Lt&&ve?M("span",{children:[ve.text,ve.action??(c.problem&&!f.problemText?l(Vo,{problem:c.problem,refresh:En}):null)]},c.announcement):null]}),Lt?l(_o,{problem:Lt},c.announcement):null]}),re?null:Nt,Pn?l(K,{name:"extraPanels",slots:p}):null]})})})}function $a({title:e,body:t,busy:n=!1,onProceed:r,onCancel:s}){let i=X(le),d=i?.format??Ge(),a=i?.primitives??nr,u=a.drawer,p=tn("confirm-sheet"),g=Qt(!0,_e()?.owner(),s),f=a.button;return g?null:M(en,{as:u,open:!0,label:e,onClose:s,closeLabel:d("chat.close"),...p,children:[l("p",{children:t}),l(f,{disabled:n,onPress:r,children:d("chat.confirm")}),l(f,{onPress:s,children:d("chat.cancel")})]})}import{Fragment as qs,jsx as ce,jsxs as Ce}from"react/jsx-runtime";function hn({conversations:e,source:t,onChoose:n}){let{client:r,format:s,primitives:i,extraUrlSchemes:d}=$(),{conversationId:a}=Ws(r.subscribe,r.getSnapshot,r.getSnapshot),[u,p]=Je(""),[g,f]=Je([]),[m,b]=Je(!1),[A,c]=Je(0),[C,E]=Je(new Map);Us(()=>{if(!t)return;let v=!0;return b(!1),Promise.resolve().then(()=>t.list(u||void 0)).then(w=>{v&&(f(w),E(k=>new Map([...k,...w.filter(x=>x.subject).map(x=>[x.subject.key,x.subject])])))}).catch(()=>{v&&b(!0)}),()=>{v=!1}},[t,u,a,A]);let L=t?g:e,R=t?C:new Map(L.filter(v=>v.subject).map(v=>[v.subject.key,v.subject])),y=new Map;for(let v of L){let w=v.subject?.key??"";u&&w!==u||y.set(w,[...y.get(w)??[],v])}let P=i.button,S=_e(),N=v=>Ce(qs,{children:[ce(P,{"aria-current":v.id===a?"page":void 0,onPress:()=>{n?.();let w=S?.ownerOf(v.id)??v.id,k=S?.originFor("switch",w);r.switchConversation(v.id).then(x=>Y(S,S?.composer(),{origin:k,owner:w,stillCurrent:()=>x.kind==="loaded"&&S?.owner()===w&&r.getSnapshot().conversation?.id===v.id}))},children:v.title}),v.mode==="form-fill"&&ce("span",{children:s("form.marker")}),v.subject?.state==="unlinked"&&ce("span",{children:s("form.unlinked")}),v.subject?.route&&at(v.subject.route,d)&&ce("a",{href:v.subject.route,children:s("form.return")})]});return Ce("nav",{className:"wp-rail","aria-label":s("chat.rail"),tabIndex:-1,children:[R.size>0&&Ce("label",{children:[s("form.filter"),Ce("select",{value:u,onChange:v=>p(v.target.value),children:[ce("option",{value:"",children:s("form.all")}),[...R].map(([v,w])=>ce("option",{value:v,children:w.label},v))]})]}),m&&Ce("p",{role:"alert",children:[s("chat.conversationsFailed")," ",ce(P,{onPress:()=>c(v=>v+1),children:s("chat.retry")})]}),[...y].map(([v,w])=>{let k=new Set,x=W=>{if(k.has(W.id))return null;k.add(W.id);let pe=w.filter(Se=>Se.parentConversationId===W.id&&!k.has(Se.id));return Ce("li",{"data-conversation-id":W.id,children:[N(W),pe.length>0&&Ce("details",{children:[ce("summary",{children:s("form.threads")}),ce("ul",{children:pe.map(x)})]})]},W.id)},Z=w.filter(W=>!W.parentConversationId||!w.some(pe=>pe.id===W.parentConversationId)).map(x);for(let W of w)k.has(W.id)||Z.push(x(W));return Ce("section",{children:[v&&ce("h3",{children:w[0].subject.label}),ce("ul",{children:Z})]},v)})]})}export{J as a,q as b,ie as c,de as d,_t as e,Xt as f,_e as g,Qt as h,Ar as i,Y as j,en as k,tn as l,_s as m,Gs as n,hn as o,ts as p,Wo as q,ns as r,un as s,Ge as t,Me as u,xe as v,Ps as w,Aa as x,$ as y,Da as z,Ba as A,Ha as B,Ua as C,Wa as D,qa as E,or as F,jo as G,vn as H,Ts as I,K as J,Rs as K,Ls as L,yn as M,Is as N,Ka as O,$a as P};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{l as A}from"./chunk-L4PFFRDE.js";var o=e=>`chat.recovery.${e}`,G=["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"],z={...Object.fromEntries(G.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")},Q=new Set(["leftUnconfirmed"]),Z={leaveCompletedByKeep:o("leaveCompletedByKeep"),leaveCoveredByKeep:o("leaveCoveredByKeep"),keptElsewhere:o("keptAlready")};function ee(e){let n=[],t=(s,c)=>{s&&!n.some(u=>u.key===s)&&n.push(c?{key:s,values:c}:{key:s})};for(let s of e.keys??[])t(z[s],Q.has(s)&&typeof e.count=="number"?{count:e.count}:void 0);e.requestKey&&t(o(e.requestKey));let a=s=>{s!==void 0&&t(o(s?"requestedIntentApplied":"requestedIntentNotApplied"))};a(e.requestedTargetApplied);let r=e.savedDisposition;r&&t(o(r.phase==="left-known"?"leftKnown":"leftUnconfirmed"),r.phase==="left-known"?void 0:{count:r.count});let i=e.finalHistory;return i&&(i.relation&&t(Z[i.relation]),i.keptFact?.keepEffect==="forward-closed"&&t(o("keptForwardClosed")),a(i.requestedTargetApplied),i.contradictedAfterSeal?.length&&t(o("laterReportAfterKeep"))),n}var ne={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"},O={stop:4,"cancel-initial":3,"cancel-review":3,keep:2,leave:1},V={stop:"stop",decline:"cancel-initial",leave:"leave",keep:"keep"},T={stop:o("checkIntentStatus"),"cancel-initial":o("checkIntentStatus"),"cancel-review":o("checkIntentStatus"),leave:o("checkSavedChoice"),keep:o("checkKeepStatus")},te={capabilityMissing:null,keepNoDecision:null,sealed:null,keepBlockedActive:o("keepReasonActive"),keepBlockedUnknown:o("keepReasonUnknown"),loading:o("actionLoading"),intentUnavailable:o("keepReasonUnavailable")},ae=new Set(["proposal","initial-review","cancelled"]),oe=new Set(["forward-active","readback","left-reopened","left-unconfirmed","completed","left-known"]),se=new Set(["forward-active","readback","left-reopened"]),re=new Set(["readback","left-reopened"]),b=(e,n,t)=>t?{id:e,labelKey:n,available:!1,reasonKey:t}:{id:e,labelKey:n,available:!0};function ie(e,n){let t=B(e,n),a=t?[t]:[];return n.state==="running"&&a.push(b("stop","chat.stop")),a}function B(e,n){let t=A(n,e.conversationId);if(n.state!=="awaiting-confirmation"||!t)return;let r={...b("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?{...r,schedule:!0}:r}function le(e,n){let a=n.recovery.phase,r=[],i=a==="initial-review"&&B(e,n);if(i&&r.push(i),(a==="proposal"||a==="initial-review"||a==="forward-active")&&r.push(b("stop","chat.stop")),(a==="proposal"||a==="initial-review")&&r.push(b("decline","chat.cancel")),se.has(a)&&r.push(b("leave",o("leave"),e.capabilities.includes("plan-leave")?void 0:o("capabilityMissing"))),oe.has(a)){let s=e.keepReview;if(!("disabled"in s))r.push(b("keep",o("keepChanges")));else{let c=te[s.disabled];c&&r.push(b("keep",o("keepChanges"),c))}}if(re.has(a))for(let s of["undoSelected","continue"])r.push(b(s,o(s),o("notAvailableYet")));return r}function W(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,r=W(e,t);if(t){let s=r?{id:"status",labelKey:T[t.kind],available:!1,reasonKey:o("retryAfterSeconds"),reasonValues:r}:{id:"status",labelKey:T[t.kind],available:!0,busy:t.delivery==="sending"},c=!1;a=a.map(u=>V[u.id]===t.kind?(c=!0,s):u),c||(a=[...a,s])}let i=[...t?[t.kind]:[],...e.pending].map(s=>O[s]);if(i.length){let s=Math.max(...i);a=a.map(c=>{if(c.id==="status")return c;let u=V[c.id],l=c.id==="confirm"?0:u?O[u]:void 0;if(l===void 0||l>s)return c;let p=u&&e.pending.includes(u);return{...c,available:!1,reasonKey:o("intentPendingReason"),...p?{busy:!0}:{}}})}return e.conversationUnavailable&&(a=a.map(s=>({...s,available:!1,reasonKey:o("refreshConversation")}))),a}function U(e,n){let t=e.recovery,a=t.steps??[],r=s=>a.filter(c=>c.truth===s).length,i=(s,c)=>c?{key:o(s),values:c}:{key:o(s)};if(t.sealed)return{label:i("keptKnown"),tone:"neutral",attention:!1};switch(t.phase){case"proposal":return{label:i("statusProposal"),tone:"neutral",attention:!1};case"initial-review":return{label:i("heading"),tone:"neutral",attention:!1};case"forward-active":return{label:i(n?.kind==="stop"?"stopping":"currentRunning"),tone:"progress",attention:!1};case"readback":case"left-reopened":return{label:i("heading"),tone:"warning",attention:!0};case"completed":return{label:i("statusCompleted"),tone:"success",attention:!1};case"cancelled":return{label:i(r("done")?"currentStopped":"cancelledNoChanges"),tone:"neutral",attention:!1};case"left-known":return{label:i("leftKnown"),tone:"neutral",attention:!1};case"left-unconfirmed":return{label:i("leftUnconfirmed",{count:r("unknown")}),tone:"warning",attention:!1}}}function D(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"||!U(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,r=e.notice&&(e.notice.planId??n.id)===n.id?ee(e.notice):[],i=e.alert,s=W(e,a),c=a?.lastProblem?.key,u=i&&a?{serial:i.serial,..."restoreFocus"in i?{restoreFocus:!0}:{action:i.action},...c&&x[c]?{message:{key:x[c]}}:{},retryAvailable:!s&&!e.conversationUnavailable,...e.conversationUnavailable?{retryReasonKey:o("refreshConversation")}:s?{retryReasonKey:o("retryAfterSeconds"),retryValues:s}:{}}:i&&"restoreFocus"in i?{serial:i.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:[]},ie(e,n),void 0),pending:[],conversationUnavailable:e.conversationUnavailable};let l=n.recovery,p=new Map(n.plan.kind==="immediate"?n.plan.steps.map((f,R)=>[f.id,{index:R+1,resource:f.resource}]):[]),v=new Set(l.contradictedAfterSeal??[]),h=l.phase==="forward-active",k=(l.steps??[]).map((f,R)=>({stepId:f.stepId,index:p.get(f.stepId)?.index??R+1,...p.get(f.stepId)?.resource!==void 0&&{resource:p.get(f.stepId).resource},truth:f.truth,textKey:o(f.truth==="done"?"done":f.truth==="not-done"?"notDone":h?"stepNotKnownYet":"unknown"),...l.sealed&&v.has(f.stepId)?{lateReport:"contradicted"}:{}})),g=[],w=k.filter(f=>f.truth==="unknown").length,I=k.filter(f=>f.truth==="not-done").length;!l.steps?.length&&!ae.has(l.phase)&&g.push({key:o("stepsNotKnownYet")});let m=!1;!l.sealed&&!h&&w&&(g.push({key:o("stepsUnknown"),values:{count:w}}),m=!0),!l.sealed&&l.phase==="completed"&&I&&(g.push({key:o("stepsNotDone"),values:{count:I}}),m=!0),l.sealed&&v.size&&(g.push({key:o("laterReportAfterKeep")}),m=!0);let d=l.winner;d?.kind==="stop"?(g.push({key:o(ne[d.cause])}),l.phase==="readback"&&g.push({key:o("stopped")})):d&&g.push({key:o(d.kind==="leave"?"winnerLeave":d.kind==="keep"?"winnerKeep":"winnerCancel")});let y=U(n,a);return{planId:n.id,status:{dataStatus:l.phase,wireState:n.state,label:y.label,tone:y.tone,attention:y.attention||m,...l.sealed?{result:"kept"}:{}},intent:a?{kind:a.kind,status:a.delivery}:null,steps:k,lines:g,notice:r,alert:u,actions:N(e,le(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 ce,useContext as de,useRef as pe,useSyncExternalStore as q}from"react";var ue=ce(null);function S(e){let n=de(ue),t=e??n;if(!t)throw new Error("A client is required");return t}function Ae(e){let n=S(e);return q(n.subscribe,n.getSnapshot,n.getSnapshot)}function K(e,n=Object.is,t){let a=S(t),r=pe(void 0),i=()=>{let s=a.getSnapshot(),c=r.current;if(c&&c.snapshot===s&&c.selector===e)return c.value;let u=e(s);return c&&n(c.value,u)?(r.current={snapshot:s,selector:e,value:c.value},c.value):(r.current={snapshot:s,selector:e,value:u},u)};return q(a.subscribe,i,i)}var _=new WeakMap;function fe(e,n){let t=_.get(e);return t||(t=new Map(e.map(a=>[a.id,a])),_.set(e,t)),t.get(n)}function Ce(e,n){return K(t=>t.conversation?fe(t.conversation.messages,e):void 0,Object.is,n)}function j(e,n){let t=Object.keys(e);return t.length===Object.keys(n).length&&t.every(a=>Object.is(e[a],n[a]))}import{useCallback as F,useEffect as M,useState as P}from"react";var ye={disabled:"keepNoDecision"};function Ve(e){let n=S(e),t=K(d=>({plan:d.plan,intentOverlays:d.intentOverlays,conversationId:d.conversationId,capabilities:d.capabilities,conversationUnavailable:d.conversationUnavailable,intentNotice:d.intentNotice,intentAlert:d.intentAlert,planReadOnly:d.planReadOnly,keepReview:d.plan?n.keepChangesReview(d.plan.id):ye}),(d,y)=>j({...d,keepReview:0},{...y,keepReview:0})&&JSON.stringify(d.keepReview)===JSON.stringify(y.keepReview),n),a=t.plan,[r,i]=P([]),[s,c]=P(()=>Date.now()),[u,l]=P(null),p=a?.id;M(()=>{i([]),l(null)},[p]);let v=p?t.intentOverlays[p]:void 0,h=v?.retryAt;M(()=>{if(h===void 0)return;let d=h-Date.now();if(d<=0)return;let y=setTimeout(()=>c(Date.now()),d);return()=>clearTimeout(y)},[h]);let k=A(a,t.conversationId)?.expiresAt;M(()=>{if(!k)return;let d=Date.parse(k)-Date.now();if(!(d>0))return;let y=setTimeout(()=>c(Date.now()),d+1);return()=>clearTimeout(y)},[k]);let g=D({plan:a,capabilities:t.capabilities,conversationUnavailable:t.conversationUnavailable,overlay:v,notice:t.intentNotice,alert:t.intentAlert,keepReview:t.keepReview,pending:r,now:Math.max(s,Date.now()),conversationId:t.conversationId,readOnly:t.planReadOnly}),w=F((d,y)=>{i(f=>[...f,d]),y.finally(()=>i(f=>f.filter(R=>R!==d)))},[]),I=F(d=>{if(p)switch(d){case"confirm":n.confirmPlan();return;case"stop":{n.stopPlan(p);let y=n.getSnapshot();!y.planReadOnly&&!y.intentOverlays[p]&&w("stop",n.checkIntentStatus(p));return}case"decline":w("cancel-initial",n.declinePlan());return;case"leave":w("leave",n.leavePlan(p));return;case"keep":{let y=n.keepChangesReview(p);"disabled"in y||l(y);return}case"status":case"retry":n.checkIntentStatus(p);return}},[p,n,w]),m=u&&g?{...L(u,g),onProceed:()=>{let d=u;l(null),w("keep",n.keepChanges(d))},onCancel:()=>l(null)}:null;return{view:g,press:I,sheet:m}}import{useCallback as C,useSyncExternalStore as ge}from"react";var Y=new WeakMap,ve=e=>{let n=Y.get(e);return n||Y.set(e,n={cards:new Map,listeners:new Set}),n},$=(e,n,t)=>JSON.stringify([e,n,t]),E=new WeakMap,H=e=>{E.delete(e.cards);for(let n of e.listeners)n()},we=128,J=(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")},X=e=>J(e,2166136261)+J(e,731459039),he=e=>JSON.stringify(e,(n,t)=>t&&typeof t=="object"&&!Array.isArray(t)?Object.fromEntries(Object.entries(t).sort(([a],[r])=>a<r?-1:1)):t),ke=e=>e.replace(/[^\w.~-]/g,n=>`%${(n.charCodeAt(0)+65536).toString(16).slice(1)}`);function be(e,n,t,a){let r=`card:${[e,n,t].map(ke).join(":")}:${X(he(a))}`;return r.length<=we?r:`card~${X(r)}`}function Be(e){let n=S(e),t=K(l=>l.conversationId,Object.is,n),a=ve(n),r=C(l=>(a.listeners.add(l),()=>a.listeners.delete(l)),[a]),i=C(()=>{let l=E.get(a.cards);l||E.set(a.cards,l=new Map);let p=l.get(t);return p||(p=new Set([...a.cards.values()].filter(v=>v.conversationId===t).map(v=>v.blockId)),l.set(t,p)),p},[a,t]),s=ge(r,i,i),c=C((l,p,v="")=>{let h=$(t,v,l.id);if(a.cards.has(h))return Promise.resolve();let k={...p,blockId:typeof p.blockId=="string"?p.blockId:l.id,clientReplyId:be(t,v,l.id,p)};a.cards.set(h,{conversationId:t,blockId:l.id}),H(a);let g=()=>{a.cards.delete(h),H(a)};return n.replyOutcome(k).then(w=>(w.accepted||g(),w),g)},[n,a,t]),u=C((l,p="")=>!!l.answered||a.cards.has($(t,p,l.id)),[a,t,s]);return{answered:s,isAnswered:u,reply:c}}var me={"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"},Se=e=>e.code==="replaced"?"refresh":["retryable","rate-limited","unavailable","agreement-expired"].includes(e.code)?"retry":void 0;function De(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":me[e.code]??"chat.failure",r=Se(e);return{key:a,...r&&{action:r},code:e.code,id:e.id}}function Le(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{ee as a,D as b,L as c,ue as d,Ae as e,K as f,Ce as g,j as h,Ve as i,be as j,Be as k,Se as l,De as m,Le as n};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunk3KV7TDDRcjs = require('./chunk-3KV7TDDR.cjs');var o=e=>`chat.recovery.${e}`,G=["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"],z={...Object.fromEntries(G.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")},Q=new Set(["leftUnconfirmed"]),Z={leaveCompletedByKeep:o("leaveCompletedByKeep"),leaveCoveredByKeep:o("leaveCoveredByKeep"),keptElsewhere:o("keptAlready")};function ee(e){let n=[],t=(s,c)=>{s&&!n.some(u=>u.key===s)&&n.push(c?{key:s,values:c}:{key:s})};for(let s of _nullishCoalesce(e.keys, () => ([])))t(z[s],Q.has(s)&&typeof e.count=="number"?{count:e.count}:void 0);e.requestKey&&t(o(e.requestKey));let a=s=>{s!==void 0&&t(o(s?"requestedIntentApplied":"requestedIntentNotApplied"))};a(e.requestedTargetApplied);let r=e.savedDisposition;r&&t(o(r.phase==="left-known"?"leftKnown":"leftUnconfirmed"),r.phase==="left-known"?void 0:{count:r.count});let i=e.finalHistory;return i&&(i.relation&&t(Z[i.relation]),_optionalChain([i, 'access', _2 => _2.keptFact, 'optionalAccess', _3 => _3.keepEffect])==="forward-closed"&&t(o("keptForwardClosed")),a(i.requestedTargetApplied),_optionalChain([i, 'access', _4 => _4.contradictedAfterSeal, 'optionalAccess', _5 => _5.length])&&t(o("laterReportAfterKeep"))),n}var ne={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"},O={stop:4,"cancel-initial":3,"cancel-review":3,keep:2,leave:1},V={stop:"stop",decline:"cancel-initial",leave:"leave",keep:"keep"},T={stop:o("checkIntentStatus"),"cancel-initial":o("checkIntentStatus"),"cancel-review":o("checkIntentStatus"),leave:o("checkSavedChoice"),keep:o("checkKeepStatus")},te={capabilityMissing:null,keepNoDecision:null,sealed:null,keepBlockedActive:o("keepReasonActive"),keepBlockedUnknown:o("keepReasonUnknown"),loading:o("actionLoading"),intentUnavailable:o("keepReasonUnavailable")},ae=new Set(["proposal","initial-review","cancelled"]),oe=new Set(["forward-active","readback","left-reopened","left-unconfirmed","completed","left-known"]),se=new Set(["forward-active","readback","left-reopened"]),re=new Set(["readback","left-reopened"]),b=(e,n,t)=>t?{id:e,labelKey:n,available:!1,reasonKey:t}:{id:e,labelKey:n,available:!0};function ie(e,n){let t=B(e,n),a=t?[t]:[];return n.state==="running"&&a.push(b("stop","chat.stop")),a}function B(e,n){let t=_chunk3KV7TDDRcjs.l.call(void 0, n,e.conversationId);if(n.state!=="awaiting-confirmation"||!t)return;let r={...b("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?{...r,schedule:!0}:r}function le(e,n){let a=n.recovery.phase,r=[],i=a==="initial-review"&&B(e,n);if(i&&r.push(i),(a==="proposal"||a==="initial-review"||a==="forward-active")&&r.push(b("stop","chat.stop")),(a==="proposal"||a==="initial-review")&&r.push(b("decline","chat.cancel")),se.has(a)&&r.push(b("leave",o("leave"),e.capabilities.includes("plan-leave")?void 0:o("capabilityMissing"))),oe.has(a)){let s=e.keepReview;if(!("disabled"in s))r.push(b("keep",o("keepChanges")));else{let c=te[s.disabled];c&&r.push(b("keep",o("keepChanges"),c))}}if(re.has(a))for(let s of["undoSelected","continue"])r.push(b(s,o(s),o("notAvailableYet")));return r}function W(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,r=W(e,t);if(t){let s=r?{id:"status",labelKey:T[t.kind],available:!1,reasonKey:o("retryAfterSeconds"),reasonValues:r}:{id:"status",labelKey:T[t.kind],available:!0,busy:t.delivery==="sending"},c=!1;a=a.map(u=>V[u.id]===t.kind?(c=!0,s):u),c||(a=[...a,s])}let i=[...t?[t.kind]:[],...e.pending].map(s=>O[s]);if(i.length){let s=Math.max(...i);a=a.map(c=>{if(c.id==="status")return c;let u=V[c.id],l=c.id==="confirm"?0:u?O[u]:void 0;if(l===void 0||l>s)return c;let p=u&&e.pending.includes(u);return{...c,available:!1,reasonKey:o("intentPendingReason"),...p?{busy:!0}:{}}})}return e.conversationUnavailable&&(a=a.map(s=>({...s,available:!1,reasonKey:o("refreshConversation")}))),a}function U(e,n){let t=e.recovery,a=_nullishCoalesce(t.steps, () => ([])),r=s=>a.filter(c=>c.truth===s).length,i=(s,c)=>c?{key:o(s),values:c}:{key:o(s)};if(t.sealed)return{label:i("keptKnown"),tone:"neutral",attention:!1};switch(t.phase){case"proposal":return{label:i("statusProposal"),tone:"neutral",attention:!1};case"initial-review":return{label:i("heading"),tone:"neutral",attention:!1};case"forward-active":return{label:i(_optionalChain([n, 'optionalAccess', _9 => _9.kind])==="stop"?"stopping":"currentRunning"),tone:"progress",attention:!1};case"readback":case"left-reopened":return{label:i("heading"),tone:"warning",attention:!0};case"completed":return{label:i("statusCompleted"),tone:"success",attention:!1};case"cancelled":return{label:i(r("done")?"currentStopped":"cancelledNoChanges"),tone:"neutral",attention:!1};case"left-known":return{label:i("leftKnown"),tone:"neutral",attention:!1};case"left-unconfirmed":return{label:i("leftUnconfirmed",{count:r("unknown")}),tone:"warning",attention:!1}}}function D(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"||!U(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,r=e.notice&&(_nullishCoalesce(e.notice.planId, () => (n.id)))===n.id?ee(e.notice):[],i=e.alert,s=W(e,a),c=_optionalChain([a, 'optionalAccess', _10 => _10.lastProblem, 'optionalAccess', _11 => _11.key]),u=i&&a?{serial:i.serial,..."restoreFocus"in i?{restoreFocus:!0}:{action:i.action},...c&&x[c]?{message:{key:x[c]}}:{},retryAvailable:!s&&!e.conversationUnavailable,...e.conversationUnavailable?{retryReasonKey:o("refreshConversation")}:s?{retryReasonKey:o("retryAfterSeconds"),retryValues:s}:{}}:i&&"restoreFocus"in i?{serial:i.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:[]},ie(e,n),void 0),pending:[],conversationUnavailable:e.conversationUnavailable};let l=n.recovery,p=new Map(n.plan.kind==="immediate"?n.plan.steps.map((f,R)=>[f.id,{index:R+1,resource:f.resource}]):[]),v=new Set(_nullishCoalesce(l.contradictedAfterSeal, () => ([]))),h=l.phase==="forward-active",k=(_nullishCoalesce(l.steps, () => ([]))).map((f,R)=>({stepId:f.stepId,index:_nullishCoalesce(_optionalChain([p, 'access', _12 => _12.get, 'call', _13 => _13(f.stepId), 'optionalAccess', _14 => _14.index]), () => (R+1)),..._optionalChain([p, 'access', _15 => _15.get, 'call', _16 => _16(f.stepId), 'optionalAccess', _17 => _17.resource])!==void 0&&{resource:p.get(f.stepId).resource},truth:f.truth,textKey:o(f.truth==="done"?"done":f.truth==="not-done"?"notDone":h?"stepNotKnownYet":"unknown"),...l.sealed&&v.has(f.stepId)?{lateReport:"contradicted"}:{}})),g=[],w=k.filter(f=>f.truth==="unknown").length,I=k.filter(f=>f.truth==="not-done").length;!_optionalChain([l, 'access', _18 => _18.steps, 'optionalAccess', _19 => _19.length])&&!ae.has(l.phase)&&g.push({key:o("stepsNotKnownYet")});let m=!1;!l.sealed&&!h&&w&&(g.push({key:o("stepsUnknown"),values:{count:w}}),m=!0),!l.sealed&&l.phase==="completed"&&I&&(g.push({key:o("stepsNotDone"),values:{count:I}}),m=!0),l.sealed&&v.size&&(g.push({key:o("laterReportAfterKeep")}),m=!0);let d=l.winner;_optionalChain([d, 'optionalAccess', _20 => _20.kind])==="stop"?(g.push({key:o(ne[d.cause])}),l.phase==="readback"&&g.push({key:o("stopped")})):d&&g.push({key:o(d.kind==="leave"?"winnerLeave":d.kind==="keep"?"winnerKeep":"winnerCancel")});let y=U(n,a);return{planId:n.id,status:{dataStatus:l.phase,wireState:n.state,label:y.label,tone:y.tone,attention:y.attention||m,...l.sealed?{result:"kept"}:{}},intent:a?{kind:a.kind,status:a.delivery}:null,steps:k,lines:g,notice:r,alert:u,actions:N(e,le(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 ue=_react.createContext.call(void 0, null);function S(e){let n=_react.useContext.call(void 0, ue),t=_nullishCoalesce(e, () => (n));if(!t)throw new Error("A client is required");return t}function Ae(e){let n=S(e);return _react.useSyncExternalStore.call(void 0, n.subscribe,n.getSnapshot,n.getSnapshot)}function K(e,n=Object.is,t){let a=S(t),r=_react.useRef.call(void 0, void 0),i=()=>{let s=a.getSnapshot(),c=r.current;if(c&&c.snapshot===s&&c.selector===e)return c.value;let u=e(s);return c&&n(c.value,u)?(r.current={snapshot:s,selector:e,value:c.value},c.value):(r.current={snapshot:s,selector:e,value:u},u)};return _react.useSyncExternalStore.call(void 0, a.subscribe,i,i)}var _=new WeakMap;function fe(e,n){let t=_.get(e);return t||(t=new Map(e.map(a=>[a.id,a])),_.set(e,t)),t.get(n)}function Ce(e,n){return K(t=>t.conversation?fe(t.conversation.messages,e):void 0,Object.is,n)}function j(e,n){let t=Object.keys(e);return t.length===Object.keys(n).length&&t.every(a=>Object.is(e[a],n[a]))}var ye={disabled:"keepNoDecision"};function Ve(e){let n=S(e),t=K(d=>({plan:d.plan,intentOverlays:d.intentOverlays,conversationId:d.conversationId,capabilities:d.capabilities,conversationUnavailable:d.conversationUnavailable,intentNotice:d.intentNotice,intentAlert:d.intentAlert,planReadOnly:d.planReadOnly,keepReview:d.plan?n.keepChangesReview(d.plan.id):ye}),(d,y)=>j({...d,keepReview:0},{...y,keepReview:0})&&JSON.stringify(d.keepReview)===JSON.stringify(y.keepReview),n),a=t.plan,[r,i]=_react.useState.call(void 0, []),[s,c]=_react.useState.call(void 0, ()=>Date.now()),[u,l]=_react.useState.call(void 0, null),p=_optionalChain([a, 'optionalAccess', _23 => _23.id]);_react.useEffect.call(void 0, ()=>{i([]),l(null)},[p]);let v=p?t.intentOverlays[p]:void 0,h=_optionalChain([v, 'optionalAccess', _24 => _24.retryAt]);_react.useEffect.call(void 0, ()=>{if(h===void 0)return;let d=h-Date.now();if(d<=0)return;let y=setTimeout(()=>c(Date.now()),d);return()=>clearTimeout(y)},[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 d=Date.parse(k)-Date.now();if(!(d>0))return;let y=setTimeout(()=>c(Date.now()),d+1);return()=>clearTimeout(y)},[k]);let g=D({plan:a,capabilities:t.capabilities,conversationUnavailable:t.conversationUnavailable,overlay:v,notice:t.intentNotice,alert:t.intentAlert,keepReview:t.keepReview,pending:r,now:Math.max(s,Date.now()),conversationId:t.conversationId,readOnly:t.planReadOnly}),w=_react.useCallback.call(void 0, (d,y)=>{i(f=>[...f,d]),y.finally(()=>i(f=>f.filter(R=>R!==d)))},[]),I=_react.useCallback.call(void 0, d=>{if(p)switch(d){case"confirm":n.confirmPlan();return;case"stop":{n.stopPlan(p);let y=n.getSnapshot();!y.planReadOnly&&!y.intentOverlays[p]&&w("stop",n.checkIntentStatus(p));return}case"decline":w("cancel-initial",n.declinePlan());return;case"leave":w("leave",n.leavePlan(p));return;case"keep":{let y=n.keepChangesReview(p);"disabled"in y||l(y);return}case"status":case"retry":n.checkIntentStatus(p);return}},[p,n,w]),m=u&&g?{...L(u,g),onProceed:()=>{let d=u;l(null),w("keep",n.keepChanges(d))},onCancel:()=>l(null)}:null;return{view:g,press:I,sheet:m}}var Y=new WeakMap,ve=e=>{let n=Y.get(e);return n||Y.set(e,n={cards:new Map,listeners:new Set}),n},$=(e,n,t)=>JSON.stringify([e,n,t]),E=new WeakMap,H=e=>{E.delete(e.cards);for(let n of e.listeners)n()},we=128,J=(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")},X=e=>J(e,2166136261)+J(e,731459039),he=e=>JSON.stringify(e,(n,t)=>t&&typeof t=="object"&&!Array.isArray(t)?Object.fromEntries(Object.entries(t).sort(([a],[r])=>a<r?-1:1)):t),ke=e=>e.replace(/[^\w.~-]/g,n=>`%${(n.charCodeAt(0)+65536).toString(16).slice(1)}`);function be(e,n,t,a){let r=`card:${[e,n,t].map(ke).join(":")}:${X(he(a))}`;return r.length<=we?r:`card~${X(r)}`}function Be(e){let n=S(e),t=K(l=>l.conversationId,Object.is,n),a=ve(n),r=_react.useCallback.call(void 0, l=>(a.listeners.add(l),()=>a.listeners.delete(l)),[a]),i=_react.useCallback.call(void 0, ()=>{let l=E.get(a.cards);l||E.set(a.cards,l=new Map);let p=l.get(t);return p||(p=new Set([...a.cards.values()].filter(v=>v.conversationId===t).map(v=>v.blockId)),l.set(t,p)),p},[a,t]),s=_react.useSyncExternalStore.call(void 0, r,i,i),c=_react.useCallback.call(void 0, (l,p,v="")=>{let h=$(t,v,l.id);if(a.cards.has(h))return Promise.resolve();let k={...p,blockId:typeof p.blockId=="string"?p.blockId:l.id,clientReplyId:be(t,v,l.id,p)};a.cards.set(h,{conversationId:t,blockId:l.id}),H(a);let g=()=>{a.cards.delete(h),H(a)};return n.replyOutcome(k).then(w=>(w.accepted||g(),w),g)},[n,a,t]),u=_react.useCallback.call(void 0, (l,p="")=>!!l.answered||a.cards.has($(t,p,l.id)),[a,t,s]);return{answered:s,isAnswered:u,reply:c}}var me={"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"},Se= exports.l =e=>e.code==="replaced"?"refresh":["retryable","rate-limited","unavailable","agreement-expired"].includes(e.code)?"retry":void 0;function De(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(me[e.code], () => ("chat.failure")),r=Se(e);return{key:a,...r&&{action:r},code:e.code,id:e.id}}function Le(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 = ee; exports.b = D; exports.c = L; exports.d = ue; exports.e = Ae; exports.f = K; exports.g = Ce; exports.h = j; exports.i = Ve; exports.j = be; exports.k = Be; exports.l = Se; exports.m = De; exports.n = Le;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _chunkA3YOSFLEcjs = require('./chunk-A3YOSFLE.cjs');var _react = require('react');var _jsxruntime = require('react/jsx-runtime');function h({disabled:o,blocked:e,reason:a,label:d,onPress:r}){let{format:b,primitives:u}=_chunkA3YOSFLEcjs.y.call(void 0, ),l=u.button,i=_react.useId.call(void 0, ),n=e&&!o;return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, l,{disabled:o,"aria-disabled":n||void 0,"aria-describedby":n?i:void 0,onPress:r,children:_nullishCoalesce(d, () => (b("chat.submit")))}),n?_jsxruntime.jsx.call(void 0, "span",{id:i,"data-reason":"submit",children:a}):null]})}exports.a = h;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var
|
|
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 _chunkA3YOSFLEcjs = require('./chunk-A3YOSFLE.cjs');require('./chunk-FBADWFRR.cjs');var _chunkQS3MKZOYcjs = require('./chunk-QS3MKZOY.cjs');require('./chunk-RZ3AGK3U.cjs');require('./chunk-4BWV3SEL.cjs');require('./chunk-GT6PI4CT.cjs');require('./chunk-3KV7TDDR.cjs');require('./chunk-Q7BULGQG.cjs');require('./chunk-XSHOLIC7.cjs');require('./chunk-II26UWZM.cjs');var _react = require('react');var V={"chat.confirmation.heading":"Review these changes","chat.confirmation.apply":"Apply these changes","chat.confirmation.schedule":"Schedule these changes","chat.confirmation.applyCount":"{count, plural, =0 {Apply these changes} one {Apply # change} other {Apply # changes}}","chat.confirmation.scheduleCount":"{count, plural, =0 {Schedule these changes} one {Schedule # change} other {Schedule # changes}}","chat.confirmation.unavailable":"This plan can't be confirmed in this app. Ask the site administrator to update it.","chat.confirmation.expired":"This confirmation has expired. Ask for the plan again to review it.","chat.confirmation.used":"This confirmation was already used. Check the plan's status below before doing anything else.","chat.confirmation.changed":"This plan changed. Review it again before you confirm.","chat.confirmation.mismatch":"This confirmation belongs to a different plan. Open the current plan and review it.","chat.confirmation.irreversible":"This change cannot be undone.","chat.confirmation.before":"Before","chat.confirmation.after":"After","chat.confirmation.refresh":"Refresh","chat.confirmation.verifications":"{count, plural, one {# verification is needed} other {# verifications are needed}}.","chat.confirmation.expires":"Valid until {time}","chat.confirmation.showAll":"Show all {count} items"},z={"chat.confirmation.heading":"\u8BF7\u6838\u5BF9\u4EE5\u4E0B\u4FEE\u6539","chat.confirmation.apply":"\u5E94\u7528\u8FD9\u4E9B\u4FEE\u6539","chat.confirmation.schedule":"\u5B89\u6392\u6267\u884C\u8FD9\u4E9B\u4FEE\u6539","chat.confirmation.applyCount":"{count, plural, =0 {\u5E94\u7528\u8FD9\u4E9B\u4FEE\u6539} other {\u5E94\u7528 # \u9879\u4FEE\u6539}}","chat.confirmation.scheduleCount":"{count, plural, =0 {\u5B89\u6392\u6267\u884C\u8FD9\u4E9B\u4FEE\u6539} other {\u5B89\u6392\u6267\u884C # \u9879\u4FEE\u6539}}","chat.confirmation.unavailable":"\u6B64\u5E94\u7528\u65E0\u6CD5\u786E\u8BA4\u8FD9\u4E2A\u8BA1\u5212\u3002\u8BF7\u8054\u7CFB\u7F51\u7AD9\u7BA1\u7406\u5458\u66F4\u65B0\u5E94\u7528\u3002","chat.confirmation.expired":"\u6B64\u786E\u8BA4\u5DF2\u8FC7\u671F\u3002\u8BF7\u91CD\u65B0\u83B7\u53D6\u8BA1\u5212\u540E\u518D\u6838\u5BF9\u3002","chat.confirmation.used":"\u6B64\u786E\u8BA4\u5DF2\u7ECF\u4F7F\u7528\u8FC7\u3002\u8BF7\u5148\u68C0\u67E5\u4E0B\u65B9\u7684\u8BA1\u5212\u72B6\u6001\uFF0C\u518D\u8FDB\u884C\u5176\u4ED6\u64CD\u4F5C\u3002","chat.confirmation.changed":"\u8BA1\u5212\u5DF2\u6709\u53D8\u5316\u3002\u8BF7\u91CD\u65B0\u6838\u5BF9\u540E\u518D\u786E\u8BA4\u3002","chat.confirmation.mismatch":"\u6B64\u786E\u8BA4\u5C5E\u4E8E\u53E6\u4E00\u4E2A\u8BA1\u5212\u3002\u8BF7\u6253\u5F00\u5F53\u524D\u8BA1\u5212\u5E76\u91CD\u65B0\u6838\u5BF9\u3002","chat.confirmation.irreversible":"\u6B64\u4FEE\u6539\u65E0\u6CD5\u64A4\u9500\u3002","chat.confirmation.before":"\u4FEE\u6539\u524D","chat.confirmation.after":"\u4FEE\u6539\u540E","chat.confirmation.refresh":"\u5237\u65B0","chat.confirmation.verifications":"\u9700\u8981\u5B8C\u6210 {count} \u6B21\u9A8C\u8BC1\u3002","chat.confirmation.expires":"\u6709\u6548\u671F\u81F3 {time}","chat.confirmation.showAll":"\u663E\u793A\u5168\u90E8 {count} \u9879"};var _jsxruntime = require('react/jsx-runtime');_chunkA3YOSFLEcjs.q.call(void 0, V,z);var v=10,j={expired:"chat.confirmation.expired",used:"chat.confirmation.used",stale:"chat.confirmation.changed",mismatch:"chat.confirmation.mismatch"};function nn({record:e,planId:l,entry:m,onConfirm:D,refusal:s,override:d,replaced:A}){let{format:i,primitives:O,locale:R,client:S}=_chunkA3YOSFLEcjs.y.call(void 0, ),p=_chunkA3YOSFLEcjs.G.call(void 0, ()=>Promise.all([S.refresh(),S.readPlan()])),U=O.button,a=_react.useId.call(void 0, ),[k,_]=_react.useState.call(void 0, !1),T=_react.useRef.call(void 0, null),u=_optionalChain([e, 'optionalAccess', _2 => _2.token]),h=_optionalChain([_chunkA3YOSFLEcjs.g.call(void 0, ), 'optionalAccess', _3 => _3.owner, 'call', _4 => _4()]),[g,q]=_react.useState.call(void 0, {token:u,owner:h}),[$,E]=_react.useState.call(void 0, !1);(g.token!==u||g.owner!==h)&&(q({token:u,owner:h}),E(g.owner===h));let f=_chunkA3YOSFLEcjs.g.call(void 0, ),b=_react.useRef.call(void 0, void 0),L=_react.useRef.call(void 0, l);L.current=l,_react.useLayoutEffect.call(void 0, ()=>{let t=b.current;!t||t.element.isConnected||!f||(b.current=void 0,_chunkA3YOSFLEcjs.j.call(void 0, f,T.current,{owner:t.key,stillCurrent:()=>f.owner()===t.key&&L.current===t.planId,removed:t.element}))});let G=_jsxruntime.jsx.call(void 0, "h3",{id:`${a}-heading`,ref:T,tabIndex:-1,children:i("chat.confirmation.heading")}),M=(t,y)=>_jsxruntime.jsxs.call(void 0, "section",{"data-confirmation":"","aria-labelledby":`${a}-heading`,"aria-describedby":y,onFocus:X=>{b.current={element:X.target,planId:l,key:_nullishCoalesce(_optionalChain([f, 'optionalAccess', _5 => _5.owner, 'call', _6 => _6()]), () => (""))}},children:[G,t]}),J=t=>_jsxruntime.jsx.call(void 0, "p",{role:"status",children:t});if(!e)return M(_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "p",{children:i("chat.confirmation.unavailable")}),J($?i("chat.confirmation.changed"):null)]}));let Q=k||e.items.length<=v?e.items:e.items.slice(0,v),c=A||$&&!s?"chat.confirmation.changed":s?_nullishCoalesce(j[s], () => ("chat.problem.refused")):void 0,W=!c&&_optionalChain([m, 'optionalAccess', _7 => _7.reasonKey])==="chat.confirmation.expired";return M(_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "p",{id:`${a}-summary`,children:e.heading}),_jsxruntime.jsx.call(void 0, "ol",{id:`${a}-items`,children:Q.map((t,y)=>_jsxruntime.jsxs.call(void 0, "li",{children:[_jsxruntime.jsx.call(void 0, "p",{children:t.label}),_jsxruntime.jsxs.call(void 0, "dl",{children:[t.before!==void 0?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "dt",{children:i("chat.confirmation.before")}),_jsxruntime.jsx.call(void 0, "dd",{children:t.before})]}):null,t.after!==void 0?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "dt",{children:i("chat.confirmation.after")}),_jsxruntime.jsx.call(void 0, "dd",{children:t.after})]}):null]}),t.note?_jsxruntime.jsx.call(void 0, "p",{children:t.note}):null]},y))}),e.items.length>v?_jsxruntime.jsx.call(void 0, "button",{type:"button","aria-expanded":k,"aria-controls":`${a}-items`,onClick:()=>_(t=>!t),children:i("chat.confirmation.showAll",{count:e.items.length})}):null,_jsxruntime.jsx.call(void 0, "p",{id:`${a}-dates`,children:e.schedule?`${e.schedule.startText} \u2013 ${e.schedule.endText}`:""}),e.irreversible?_jsxruntime.jsx.call(void 0, "p",{children:_jsxruntime.jsx.call(void 0, "strong",{children:i("chat.confirmation.irreversible")})}):null,_jsxruntime.jsx.call(void 0, "p",{children:e.undo}),e.verificationCount>0?_jsxruntime.jsx.call(void 0, "p",{children:i("chat.confirmation.verifications",{count:e.verificationCount})}):null,_jsxruntime.jsx.call(void 0, "p",{children:_jsxruntime.jsx.call(void 0, "time",{"data-expires":"",dateTime:e.expiresAt,children:i("chat.confirmation.expires",{time:new Date(e.expiresAt).toLocaleString(_chunkQS3MKZOYcjs.b.call(void 0, _nullishCoalesce(R, () => ("en")),_chunkA3YOSFLEcjs.s.call(void 0, R).catalogue==="zh"))})})}),m?_jsxruntime.jsx.call(void 0, _chunkA3YOSFLEcjs.F,{action:m,label:e.actionLabel,onPress:()=>{E(!1),D()}}):null,_jsxruntime.jsx.call(void 0, "p",{role:"status",children:c&&s&&!A&&d?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[d.text,d.action]}):c?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[i(c),c!=="chat.confirmation.expired"&&c!=="chat.problem.refused"?_jsxruntime.jsx.call(void 0, U,{onPress:p.press,"aria-busy":p.busy||void 0,"aria-disabled":p.busy||void 0,children:i("chat.confirmation.refresh")}):null]}):W?_jsxruntime.jsx.call(void 0, "span",{className:"wp-sr",children:i("chat.confirmation.expired")}):null})]}),`${a}-summary ${a}-dates`)}exports.default = nn;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as P,G as H,g as x,j as I,q as K,s as N,y as B}from"./chunk-
|
|
1
|
+
import{F as P,G as H,g as x,j as I,q as K,s as N,y as B}from"./chunk-IPI4O4LP.js";import"./chunk-FQSWQLRW.js";import{b as F}from"./chunk-OWT55N6J.js";import"./chunk-QFBAOEPD.js";import"./chunk-RZZDQWC2.js";import"./chunk-M63QOANE.js";import"./chunk-L4PFFRDE.js";import"./chunk-T5XF2R74.js";import"./chunk-K73VV7KA.js";import"./chunk-5TBO732O.js";import{useId as Y,useLayoutEffect as Z,useRef as w,useState as C}from"react";var V={"chat.confirmation.heading":"Review these changes","chat.confirmation.apply":"Apply these changes","chat.confirmation.schedule":"Schedule these changes","chat.confirmation.applyCount":"{count, plural, =0 {Apply these changes} one {Apply # change} other {Apply # changes}}","chat.confirmation.scheduleCount":"{count, plural, =0 {Schedule these changes} one {Schedule # change} other {Schedule # changes}}","chat.confirmation.unavailable":"This plan can't be confirmed in this app. Ask the site administrator to update it.","chat.confirmation.expired":"This confirmation has expired. Ask for the plan again to review it.","chat.confirmation.used":"This confirmation was already used. Check the plan's status below before doing anything else.","chat.confirmation.changed":"This plan changed. Review it again before you confirm.","chat.confirmation.mismatch":"This confirmation belongs to a different plan. Open the current plan and review it.","chat.confirmation.irreversible":"This change cannot be undone.","chat.confirmation.before":"Before","chat.confirmation.after":"After","chat.confirmation.refresh":"Refresh","chat.confirmation.verifications":"{count, plural, one {# verification is needed} other {# verifications are needed}}.","chat.confirmation.expires":"Valid until {time}","chat.confirmation.showAll":"Show all {count} items"},z={"chat.confirmation.heading":"\u8BF7\u6838\u5BF9\u4EE5\u4E0B\u4FEE\u6539","chat.confirmation.apply":"\u5E94\u7528\u8FD9\u4E9B\u4FEE\u6539","chat.confirmation.schedule":"\u5B89\u6392\u6267\u884C\u8FD9\u4E9B\u4FEE\u6539","chat.confirmation.applyCount":"{count, plural, =0 {\u5E94\u7528\u8FD9\u4E9B\u4FEE\u6539} other {\u5E94\u7528 # \u9879\u4FEE\u6539}}","chat.confirmation.scheduleCount":"{count, plural, =0 {\u5B89\u6392\u6267\u884C\u8FD9\u4E9B\u4FEE\u6539} other {\u5B89\u6392\u6267\u884C # \u9879\u4FEE\u6539}}","chat.confirmation.unavailable":"\u6B64\u5E94\u7528\u65E0\u6CD5\u786E\u8BA4\u8FD9\u4E2A\u8BA1\u5212\u3002\u8BF7\u8054\u7CFB\u7F51\u7AD9\u7BA1\u7406\u5458\u66F4\u65B0\u5E94\u7528\u3002","chat.confirmation.expired":"\u6B64\u786E\u8BA4\u5DF2\u8FC7\u671F\u3002\u8BF7\u91CD\u65B0\u83B7\u53D6\u8BA1\u5212\u540E\u518D\u6838\u5BF9\u3002","chat.confirmation.used":"\u6B64\u786E\u8BA4\u5DF2\u7ECF\u4F7F\u7528\u8FC7\u3002\u8BF7\u5148\u68C0\u67E5\u4E0B\u65B9\u7684\u8BA1\u5212\u72B6\u6001\uFF0C\u518D\u8FDB\u884C\u5176\u4ED6\u64CD\u4F5C\u3002","chat.confirmation.changed":"\u8BA1\u5212\u5DF2\u6709\u53D8\u5316\u3002\u8BF7\u91CD\u65B0\u6838\u5BF9\u540E\u518D\u786E\u8BA4\u3002","chat.confirmation.mismatch":"\u6B64\u786E\u8BA4\u5C5E\u4E8E\u53E6\u4E00\u4E2A\u8BA1\u5212\u3002\u8BF7\u6253\u5F00\u5F53\u524D\u8BA1\u5212\u5E76\u91CD\u65B0\u6838\u5BF9\u3002","chat.confirmation.irreversible":"\u6B64\u4FEE\u6539\u65E0\u6CD5\u64A4\u9500\u3002","chat.confirmation.before":"\u4FEE\u6539\u524D","chat.confirmation.after":"\u4FEE\u6539\u540E","chat.confirmation.refresh":"\u5237\u65B0","chat.confirmation.verifications":"\u9700\u8981\u5B8C\u6210 {count} \u6B21\u9A8C\u8BC1\u3002","chat.confirmation.expires":"\u6709\u6548\u671F\u81F3 {time}","chat.confirmation.showAll":"\u663E\u793A\u5168\u90E8 {count} \u9879"};import{Fragment as r,jsx as n,jsxs as o}from"react/jsx-runtime";K(V,z);var v=10,j={expired:"chat.confirmation.expired",used:"chat.confirmation.used",stale:"chat.confirmation.changed",mismatch:"chat.confirmation.mismatch"};function nn({record:e,planId:l,entry:m,onConfirm:D,refusal:s,override:d,replaced:A}){let{format:i,primitives:O,locale:R,client:S}=B(),p=H(()=>Promise.all([S.refresh(),S.readPlan()])),U=O.button,a=Y(),[k,_]=C(!1),T=w(null),u=e?.token,h=x()?.owner(),[g,q]=C({token:u,owner:h}),[$,E]=C(!1);(g.token!==u||g.owner!==h)&&(q({token:u,owner:h}),E(g.owner===h));let f=x(),b=w(void 0),L=w(l);L.current=l,Z(()=>{let t=b.current;!t||t.element.isConnected||!f||(b.current=void 0,I(f,T.current,{owner:t.key,stillCurrent:()=>f.owner()===t.key&&L.current===t.planId,removed:t.element}))});let G=n("h3",{id:`${a}-heading`,ref:T,tabIndex:-1,children:i("chat.confirmation.heading")}),M=(t,y)=>o("section",{"data-confirmation":"","aria-labelledby":`${a}-heading`,"aria-describedby":y,onFocus:X=>{b.current={element:X.target,planId:l,key:f?.owner()??""}},children:[G,t]}),J=t=>n("p",{role:"status",children:t});if(!e)return M(o(r,{children:[n("p",{children:i("chat.confirmation.unavailable")}),J($?i("chat.confirmation.changed"):null)]}));let Q=k||e.items.length<=v?e.items:e.items.slice(0,v),c=A||$&&!s?"chat.confirmation.changed":s?j[s]??"chat.problem.refused":void 0,W=!c&&m?.reasonKey==="chat.confirmation.expired";return M(o(r,{children:[n("p",{id:`${a}-summary`,children:e.heading}),n("ol",{id:`${a}-items`,children:Q.map((t,y)=>o("li",{children:[n("p",{children:t.label}),o("dl",{children:[t.before!==void 0?o(r,{children:[n("dt",{children:i("chat.confirmation.before")}),n("dd",{children:t.before})]}):null,t.after!==void 0?o(r,{children:[n("dt",{children:i("chat.confirmation.after")}),n("dd",{children:t.after})]}):null]}),t.note?n("p",{children:t.note}):null]},y))}),e.items.length>v?n("button",{type:"button","aria-expanded":k,"aria-controls":`${a}-items`,onClick:()=>_(t=>!t),children:i("chat.confirmation.showAll",{count:e.items.length})}):null,n("p",{id:`${a}-dates`,children:e.schedule?`${e.schedule.startText} \u2013 ${e.schedule.endText}`:""}),e.irreversible?n("p",{children:n("strong",{children:i("chat.confirmation.irreversible")})}):null,n("p",{children:e.undo}),e.verificationCount>0?n("p",{children:i("chat.confirmation.verifications",{count:e.verificationCount})}):null,n("p",{children:n("time",{"data-expires":"",dateTime:e.expiresAt,children:i("chat.confirmation.expires",{time:new Date(e.expiresAt).toLocaleString(F(R??"en",N(R).catalogue==="zh"))})})}),m?n(P,{action:m,label:e.actionLabel,onPress:()=>{E(!1),D()}}):null,n("p",{role:"status",children:c&&s&&!A&&d?o(r,{children:[d.text,d.action]}):c?o(r,{children:[i(c),c!=="chat.confirmation.expired"&&c!=="chat.problem.refused"?n(U,{onPress:p.press,"aria-busy":p.busy||void 0,"aria-disabled":p.busy||void 0,children:i("chat.confirmation.refresh")}):null]}):W?n("span",{className:"wp-sr",children:i("chat.confirmation.expired")}):null})]}),`${a}-summary ${a}-dates`)}export{nn as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as _}from"./chunk-
|
|
1
|
+
import{a as _}from"./chunk-D4Q46KWA.js";import{a as V,b as W}from"./chunk-PFR2J5BV.js";import{H as L,e as D,h as N,k as O,l as B,q as T,y as q}from"./chunk-IPI4O4LP.js";import"./chunk-FQSWQLRW.js";import"./chunk-OWT55N6J.js";import{e as G}from"./chunk-QFBAOEPD.js";import"./chunk-RZZDQWC2.js";import{a as H}from"./chunk-M63QOANE.js";import"./chunk-L4PFFRDE.js";import"./chunk-T5XF2R74.js";import"./chunk-K73VV7KA.js";import"./chunk-5TBO732O.js";import{useEffect as j,useRef as v,useState as h}from"react";import{jsx as t,jsxs as M}from"react/jsx-runtime";T(V,W);function oe({id:c,labelledBy:m,flows:a,all:r,list:l,onRetryList:k,onRunFlow:p}){let{client:s,format:b,primitives:S}=q(),y=S.button,e=v(null),[o,i]=h(void 0),[u,E]=h(new Set),[g,F]=h(void 0),R=v(!1),d=(n,P)=>{u.has(n)||(E(f=>new Set(f).add(n)),F(f=>f?.id===n?f:void 0),s.setFavourite(n,P).then(()=>F(f=>f?.id===n?void 0:f),()=>F({id:n,value:P})).finally(()=>E(f=>{let A=new Set(f);return A.delete(n),A})))},w=v(r);j(()=>{w.current!==r&&(w.current=r,!o&&R.current&&(R.current=!1,s.prepareFlow()))},[r,o,s]);let x=v(0),z=D(()=>{let n=e.current?.querySelectorAll("li")??[];return[n[x.current]?.querySelector("button"),n[x.current-1]?.querySelector("button"),e.current]}),C=v(void 0),J=D(()=>[[...e.current?.querySelectorAll("li[data-flow]")??[]].find(n=>n.getAttribute("data-flow")===C.current)?.querySelector("button"),e.current]),K=!a?.length;return M("div",{ref:e,id:c,role:"tabpanel","aria-labelledby":m,tabIndex:K?0:-1,onFocus:n=>{if(n.target.closest(H)||n.target.closest("[data-favourite-failure]"))return;let P=n.target.closest("li");x.current=P?[...P.parentElement?.children??[]].indexOf(P):0,z(n)},children:[g?t("div",{"data-favourite-failure":"",children:t(L,{retrying:u.has(g.id),onFocus:n=>{C.current=g.id,J(n)},onRetry:()=>d(g.id,g.value)})}):null,a?.length?t("ul",{children:a.map(n=>M("li",{"data-flow":n.id,children:[t(y,{onPress:()=>{if(!s.canPrepareFlow())return p(n.id);R.current=!0,i(n)},children:n.title}),t(y,{label:b("chat.block.favourite",{title:n.title}),"aria-pressed":n.favourite===!0,"aria-busy":u.has(n.id)||void 0,onPress:()=>d(n.id,!n.favourite),children:t("span",{"aria-hidden":"true",children:n.favourite?"\u2605":"\u2606"})})]},n.id))}):l==="failed"||l==="retrying"?t(L,{retrying:l==="retrying",onRetry:k}):t("p",{children:b(l==="loading"&&!a?"chat.block.flowsLoading":"chat.block.flowsEmpty")}),o?t(Q,{flow:o,prepare:()=>s.prepareFlow(o.id),onRun:n=>{p(o.id,n),i(void 0)},onCancel:()=>{i(void 0),s.prepareFlow()},panel:()=>e.current},o.id):null]})}function Q({flow:c,prepare:m,onRun:a,onCancel:r,panel:l}){let{format:k,primitives:p}=q(),s=B("flow-parameters",void 0,l),b=v(r);b.current=r;let S=N(!0,G().conversationId,r),[y,e]=h(void 0),[o,i]=h(),[u,E]=h(0),g=v(a);g.current=a;let F=v(null),R=D(()=>[F.current?.querySelector("input,button"),F.current]);return j(()=>{let d=!0;return m().then(w=>{if(d){if(!w)return i("failed");i(void 0),w.parameters.length?e(w):g.current({})}},w=>{d&&(w?.id==="flow-prepare"?b.current():i("failed"))}),()=>{d=!1}},[u]),S?null:t(O,{as:p.drawer,open:!0,label:c.title,onClose:r,closeLabel:k("chat.close"),...s,children:t("div",{ref:F,onFocus:R,tabIndex:-1,children:o?t(L,{retrying:o==="retrying",onRetry:()=>{i("retrying"),E(d=>d+1)}}):y?t(X,{parameters:y.parameters,onRun:d=>a(d),onCancel:r}):t("p",{role:"status",children:k("chat.block.flowLoading")})})})}var U=(c,m)=>c.type==="boolean"?!0:m!==void 0&&m!=="";function X({parameters:c,onRun:m,onCancel:a}){let{format:r,primitives:l}=q(),k=l.checkbox,[p,s]=h(()=>Object.fromEntries(c.map(e=>[e.name,e.default??(e.type==="boolean"?!1:void 0)]))),b=c.some(e=>e.required&&!U(e,p[e.name])),S=()=>{b||m(p)},y=(e,o)=>s(i=>({...i,[e]:o}));return M("form",{className:"wp-flow-form",onSubmit:e=>{e.preventDefault(),S()},children:[c.map(e=>{let o=e.required?r("chat.block.required",{label:e.label}):e.label,i=p[e.name];return e.type==="boolean"?t(k,{label:o,checked:i===!0,onChange:u=>y(e.name,u)},e.name):t(l.input,{label:o,type:e.type==="number"?"number":"text",required:e.required,value:i===void 0?"":String(i),onChange:u=>y(e.name,e.type==="number"?u.trim()===""||!Number.isFinite(Number(u))?void 0:Number(u):u===""?void 0:u)},e.name)}),M("div",{className:"wp-actions",children:[t(_,{disabled:!1,blocked:b,reason:r("chat.block.runMissing"),label:r("chat.block.run"),onPress:S}),t(l.button,{onPress:a,children:r("chat.cancel")})]})]})}export{Q as FlowDrawer,oe as FlowPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var
|
|
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 _chunkXTKUDSDKcjs = require('./chunk-XTKUDSDK.cjs');var _chunkVGGJGRNKcjs = require('./chunk-VGGJGRNK.cjs');var _chunkA3YOSFLEcjs = require('./chunk-A3YOSFLE.cjs');require('./chunk-FBADWFRR.cjs');require('./chunk-QS3MKZOY.cjs');var _chunkRZ3AGK3Ucjs = require('./chunk-RZ3AGK3U.cjs');require('./chunk-4BWV3SEL.cjs');var _chunkGT6PI4CTcjs = require('./chunk-GT6PI4CT.cjs');require('./chunk-3KV7TDDR.cjs');require('./chunk-Q7BULGQG.cjs');require('./chunk-XSHOLIC7.cjs');require('./chunk-II26UWZM.cjs');var _react = require('react');var _jsxruntime = require('react/jsx-runtime');_chunkA3YOSFLEcjs.q.call(void 0, _chunkVGGJGRNKcjs.a,_chunkVGGJGRNKcjs.b);function oe({id:c,labelledBy:m,flows:a,all:r,list:l,onRetryList:k,onRunFlow:p}){let{client:s,format:b,primitives:S}=_chunkA3YOSFLEcjs.y.call(void 0, ),y=S.button,e=_react.useRef.call(void 0, null),[o,i]=_react.useState.call(void 0, void 0),[u,E]=_react.useState.call(void 0, new Set),[g,F]=_react.useState.call(void 0, void 0),R=_react.useRef.call(void 0, !1),d=(n,P)=>{u.has(n)||(E(f=>new Set(f).add(n)),F(f=>_optionalChain([f, 'optionalAccess', _2 => _2.id])===n?f:void 0),s.setFavourite(n,P).then(()=>F(f=>_optionalChain([f, 'optionalAccess', _3 => _3.id])===n?void 0:f),()=>F({id:n,value:P})).finally(()=>E(f=>{let A=new Set(f);return A.delete(n),A})))},w=_react.useRef.call(void 0, r);_react.useEffect.call(void 0, ()=>{w.current!==r&&(w.current=r,!o&&R.current&&(R.current=!1,s.prepareFlow()))},[r,o,s]);let x=_react.useRef.call(void 0, 0),z=_chunkA3YOSFLEcjs.e.call(void 0, ()=>{let n=_nullishCoalesce(_optionalChain([e, 'access', _4 => _4.current, 'optionalAccess', _5 => _5.querySelectorAll, 'call', _6 => _6("li")]), () => ([]));return[_optionalChain([n, 'access', _7 => _7[x.current], 'optionalAccess', _8 => _8.querySelector, 'call', _9 => _9("button")]),_optionalChain([n, 'access', _10 => _10[x.current-1], 'optionalAccess', _11 => _11.querySelector, 'call', _12 => _12("button")]),e.current]}),C=_react.useRef.call(void 0, void 0),J=_chunkA3YOSFLEcjs.e.call(void 0, ()=>[_optionalChain([[..._nullishCoalesce(_optionalChain([e, 'access', _13 => _13.current, 'optionalAccess', _14 => _14.querySelectorAll, 'call', _15 => _15("li[data-flow]")]), () => ([]))], 'access', _16 => _16.find, 'call', _17 => _17(n=>n.getAttribute("data-flow")===C.current), 'optionalAccess', _18 => _18.querySelector, 'call', _19 => _19("button")]),e.current]),K=!_optionalChain([a, 'optionalAccess', _20 => _20.length]);return _jsxruntime.jsxs.call(void 0, "div",{ref:e,id:c,role:"tabpanel","aria-labelledby":m,tabIndex:K?0:-1,onFocus:n=>{if(n.target.closest(_chunkGT6PI4CTcjs.a)||n.target.closest("[data-favourite-failure]"))return;let P=n.target.closest("li");x.current=P?[..._nullishCoalesce(_optionalChain([P, 'access', _21 => _21.parentElement, 'optionalAccess', _22 => _22.children]), () => ([]))].indexOf(P):0,z(n)},children:[g?_jsxruntime.jsx.call(void 0, "div",{"data-favourite-failure":"",children:_jsxruntime.jsx.call(void 0, _chunkA3YOSFLEcjs.H,{retrying:u.has(g.id),onFocus:n=>{C.current=g.id,J(n)},onRetry:()=>d(g.id,g.value)})}):null,_optionalChain([a, 'optionalAccess', _23 => _23.length])?_jsxruntime.jsx.call(void 0, "ul",{children:a.map(n=>_jsxruntime.jsxs.call(void 0, "li",{"data-flow":n.id,children:[_jsxruntime.jsx.call(void 0, y,{onPress:()=>{if(!s.canPrepareFlow())return p(n.id);R.current=!0,i(n)},children:n.title}),_jsxruntime.jsx.call(void 0, y,{label:b("chat.block.favourite",{title:n.title}),"aria-pressed":n.favourite===!0,"aria-busy":u.has(n.id)||void 0,onPress:()=>d(n.id,!n.favourite),children:_jsxruntime.jsx.call(void 0, "span",{"aria-hidden":"true",children:n.favourite?"\u2605":"\u2606"})})]},n.id))}):l==="failed"||l==="retrying"?_jsxruntime.jsx.call(void 0, _chunkA3YOSFLEcjs.H,{retrying:l==="retrying",onRetry:k}):_jsxruntime.jsx.call(void 0, "p",{children:b(l==="loading"&&!a?"chat.block.flowsLoading":"chat.block.flowsEmpty")}),o?_jsxruntime.jsx.call(void 0, Q,{flow:o,prepare:()=>s.prepareFlow(o.id),onRun:n=>{p(o.id,n),i(void 0)},onCancel:()=>{i(void 0),s.prepareFlow()},panel:()=>e.current},o.id):null]})}function Q({flow:c,prepare:m,onRun:a,onCancel:r,panel:l}){let{format:k,primitives:p}=_chunkA3YOSFLEcjs.y.call(void 0, ),s=_chunkA3YOSFLEcjs.l.call(void 0, "flow-parameters",void 0,l),b=_react.useRef.call(void 0, r);b.current=r;let S=_chunkA3YOSFLEcjs.h.call(void 0, !0,_chunkRZ3AGK3Ucjs.e.call(void 0, ).conversationId,r),[y,e]=_react.useState.call(void 0, void 0),[o,i]=_react.useState.call(void 0, ),[u,E]=_react.useState.call(void 0, 0),g=_react.useRef.call(void 0, a);g.current=a;let F=_react.useRef.call(void 0, null),R=_chunkA3YOSFLEcjs.e.call(void 0, ()=>[_optionalChain([F, 'access', _24 => _24.current, 'optionalAccess', _25 => _25.querySelector, 'call', _26 => _26("input,button")]),F.current]);return _react.useEffect.call(void 0, ()=>{let d=!0;return m().then(w=>{if(d){if(!w)return i("failed");i(void 0),w.parameters.length?e(w):g.current({})}},w=>{d&&(_optionalChain([w, 'optionalAccess', _27 => _27.id])==="flow-prepare"?b.current():i("failed"))}),()=>{d=!1}},[u]),S?null:_jsxruntime.jsx.call(void 0, _chunkA3YOSFLEcjs.k,{as:p.drawer,open:!0,label:c.title,onClose:r,closeLabel:k("chat.close"),...s,children:_jsxruntime.jsx.call(void 0, "div",{ref:F,onFocus:R,tabIndex:-1,children:o?_jsxruntime.jsx.call(void 0, _chunkA3YOSFLEcjs.H,{retrying:o==="retrying",onRetry:()=>{i("retrying"),E(d=>d+1)}}):y?_jsxruntime.jsx.call(void 0, X,{parameters:y.parameters,onRun:d=>a(d),onCancel:r}):_jsxruntime.jsx.call(void 0, "p",{role:"status",children:k("chat.block.flowLoading")})})})}var U=(c,m)=>c.type==="boolean"?!0:m!==void 0&&m!=="";function X({parameters:c,onRun:m,onCancel:a}){let{format:r,primitives:l}=_chunkA3YOSFLEcjs.y.call(void 0, ),k=l.checkbox,[p,s]=_react.useState.call(void 0, ()=>Object.fromEntries(c.map(e=>[e.name,_nullishCoalesce(e.default, () => ((e.type==="boolean"?!1:void 0)))]))),b=c.some(e=>e.required&&!U(e,p[e.name])),S=()=>{b||m(p)},y=(e,o)=>s(i=>({...i,[e]:o}));return _jsxruntime.jsxs.call(void 0, "form",{className:"wp-flow-form",onSubmit:e=>{e.preventDefault(),S()},children:[c.map(e=>{let o=e.required?r("chat.block.required",{label:e.label}):e.label,i=p[e.name];return e.type==="boolean"?_jsxruntime.jsx.call(void 0, k,{label:o,checked:i===!0,onChange:u=>y(e.name,u)},e.name):_jsxruntime.jsx.call(void 0, l.input,{label:o,type:e.type==="number"?"number":"text",required:e.required,value:i===void 0?"":String(i),onChange:u=>y(e.name,e.type==="number"?u.trim()===""||!Number.isFinite(Number(u))?void 0:Number(u):u===""?void 0:u)},e.name)}),_jsxruntime.jsxs.call(void 0, "div",{className:"wp-actions",children:[_jsxruntime.jsx.call(void 0, _chunkXTKUDSDKcjs.a,{disabled:!1,blocked:b,reason:r("chat.block.runMissing"),label:r("chat.block.run"),onPress:S}),_jsxruntime.jsx.call(void 0, l.button,{onPress:a,children:r("chat.cancel")})]})]})}exports.FlowDrawer = Q; exports.FlowPanel = oe;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkXWDB2LS3cjs = require('./chunk-XWDB2LS3.cjs');var _chunkVGGJGRNKcjs = require('./chunk-VGGJGRNK.cjs');var _chunkUYR3UEIWcjs = require('./chunk-UYR3UEIW.cjs');require('./chunk-FBADWFRR.cjs');require('./chunk-QS3MKZOY.cjs');require('./chunk-M3UENQ6L.cjs');require('./chunk-4BWV3SEL.cjs');require('./chunk-GT6PI4CT.cjs');require('./chunk-3KV7TDDR.cjs');require('./chunk-Q7BULGQG.cjs');require('./chunk-XSHOLIC7.cjs');require('./chunk-II26UWZM.cjs');var _react = require('react');var be={"form.generating":"Generating draft\u2026","form.ready":"Draft ready{choice, plural, =0 {} one {, # field needs your choice} other {, # fields need your choice}}{invalid, plural, =0 {} one {, # field needs attention} other {, # fields need attention}}","form.attention":"{count, plural, one {# field needs attention} other {# fields need attention}}","form.reverted":"Fill reverted.","form.revert":"Revert this fill ({fields})","form.revertWait":"Wait for the draft to finish.","form.suggested":"Suggested value for {field}","form.replaceIt":"Replace","form.keepMine":"Keep mine","form.attach":"Attach images","form.remove":"Remove {name}","form.uploading":"{count, plural, one {Uploading # image\u2026} other {Uploading # images\u2026}}","form.attached":"{count, plural, one {# image attached} other {# images attached}}","form.attachFailed":"{name} could not be attached.","form.removeFailed":"{name} could not be removed.","form.onlyImages":"Only images can be attached.","form.busy":"Wait for the current upload to finish.","form.unusable":"The draft could not be used."},ye={"form.generating":"\u6B63\u5728\u751F\u6210\u8349\u7A3F\u2026\u2026","form.ready":"\u8349\u7A3F\u5DF2\u5C31\u7EEA{choice, plural, =0 {} other {\uFF0C# \u4E2A\u5B57\u6BB5\u9700\u8981\u4F60\u9009\u62E9}}{invalid, plural, =0 {} other {\uFF0C# \u4E2A\u5B57\u6BB5\u9700\u8981\u5904\u7406}}","form.attention":"{count} \u4E2A\u5B57\u6BB5\u9700\u8981\u5904\u7406","form.reverted":"\u5DF2\u64A4\u9500\u672C\u6B21\u586B\u5145\u3002","form.revert":"\u64A4\u9500\u672C\u6B21\u586B\u5145\uFF08{fields}\uFF09","form.revertWait":"\u8BF7\u7B49\u5F85\u8349\u7A3F\u5B8C\u6210\u3002","form.suggested":"{field}\u7684\u5EFA\u8BAE\u503C","form.replaceIt":"\u66FF\u6362","form.keepMine":"\u4FDD\u7559\u6211\u7684","form.attach":"\u9644\u52A0\u56FE\u7247","form.remove":"\u79FB\u9664{name}","form.uploading":"\u6B63\u5728\u4E0A\u4F20 {count} \u5F20\u56FE\u7247\u2026\u2026","form.attached":"\u5DF2\u9644\u52A0 {count} \u5F20\u56FE\u7247","form.attachFailed":"\u65E0\u6CD5\u9644\u52A0{name}\u3002","form.removeFailed":"\u65E0\u6CD5\u79FB\u9664{name}\u3002","form.onlyImages":"\u53EA\u80FD\u9644\u52A0\u56FE\u7247\u3002","form.busy":"\u8BF7\u7B49\u5F85\u5F53\u524D\u4E0A\u4F20\u5B8C\u6210\u3002","form.unusable":"\u65E0\u6CD5\u4F7F\u7528\u6B64\u8349\u7A3F\u3002"};var _jsxruntime = require('react/jsx-runtime');_chunkUYR3UEIWcjs.q.call(void 0, be,ye);_chunkUYR3UEIWcjs.q.call(void 0, _chunkVGGJGRNKcjs.a,_chunkVGGJGRNKcjs.b);var xe=100,Se=new WeakMap;function Re(e){let n=Se.get(e);return n||(n=new Map,Se.set(e,n)),n}function ce(e){for(let[n,t]of e){if(e.size<=xe)break;t.inFlight===0&&e.delete(n)}}var Ce=e=>Object.values(e.fields).filter(n=>_optionalChain([n, 'access', _2 => _2.validation, 'optionalAccess', _3 => _3.status])==="invalid"||n.localInvalid).length;function $e({name:e,draft:n,session:t,t:c,primitives:l,onReplace:A}){let m=l.button,a=n.replacement,u=a.validation.status==="invalid",d=_react.useId.call(void 0, );return _jsxruntime.jsxs.call(void 0, "div",{role:"group","aria-labelledby":d,"data-suggestion":"",children:[_jsxruntime.jsx.call(void 0, "p",{id:d,children:c("form.suggested",{field:n.label})}),_jsxruntime.jsx.call(void 0, "div",{children:_jsxruntime.jsx.call(void 0, _chunkXWDB2LS3cjs.a,{value:a.value,t:c})}),a.validation.messages.length?_jsxruntime.jsxs.call(void 0, "div",{className:u?"wp-invalid":void 0,children:[u?_jsxruntime.jsx.call(void 0, "strong",{children:c("form.invalid")}):null,a.validation.messages.map((r,s)=>_jsxruntime.jsx.call(void 0, "p",{children:r},s))]}):null,_jsxruntime.jsxs.call(void 0, "div",{className:"wp-actions",children:[_jsxruntime.jsx.call(void 0, m,{onPress:()=>{t.replace(e,a.revision)&&A()},children:c("form.replaceIt")}),_jsxruntime.jsx.call(void 0, m,{onPress:()=>t.cancelReplacement(e),children:c("form.keepMine")})]})]})}function Ge({text:e}){return _jsxruntime.jsx.call(void 0, "span",{role:"status",className:"wp-sr-only",children:e})}var Ue=(e,n)=>{let t=Ce(e);return t?n("form.attention",{count:t}):""};function Fe({B:e,reason:n,onPress:t,children:c}){let l=_react.useId.call(void 0, );return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, e,{"aria-disabled":n?!0:void 0,"aria-describedby":n?l:void 0,onPress:n?void 0:t,children:c}),n?_jsxruntime.jsx.call(void 0, "span",{id:l,children:n}):null]})}var Te=(e,n)=>{let t=n;for(let c=2;e.some(l=>l.name===t);c++)t=`${n} (${c})`;return t};async function ke(e,n){let{t,attachments:c}=e;if(!n.length)return;let l=n.filter(r=>r.type.startsWith("image/")),A=l.length<n.length?t("form.onlyImages"):"",m=(...r)=>e.say([...r,A].filter(Boolean).join(" "));if(!l.length)return m();if(!c)return m(t("form.imagesHere"));if(!e.claim())return m(t("form.busy"));let a=e.scope();m(t("form.uploading",{count:l.length}));let u=[],d=[];for(let r of l)try{let s=await c.upload(r);u.push({reference:s,name:r.name||"image"})}catch (e2){d.push(r.name||"image")}if(a!==e.scope()){await Promise.allSettled(u.map(r=>c.remove(r.reference)));return}e.setFiles(r=>{let s=[...r];for(let C of u)s.some(h=>h.reference===C.reference)||s.push({...C,name:Te(s,C.name)});return s}),e.release(),m(u.length?t("form.attached",{count:u.length}):"",...d.map(r=>t("form.attachFailed",{name:r})))}function je({control:e}){let{session:n,t,primitives:c,attachments:l,files:A,accepted:m,sent:a}=e,u=c.button,d=_react.useSyncExternalStore.call(void 0, n.subscribe,n.getSnapshot,n.getSnapshot),r=_react.useId.call(void 0, ),s=e.removalBlocked(),C=_react.useRef.call(void 0, null),h=_react.useRef.call(void 0, null),O=_react.useRef.call(void 0, null),w=_react.useRef.call(void 0, null),H=_react.useRef.call(void 0, void 0);_react.useLayoutEffect.call(void 0, ()=>{m&&m!==H.current&&e.say(t("form.generating")),H.current=m},[m,e,t]);let _=_react.useRef.call(void 0, d.pending);_react.useLayoutEffect.call(void 0, ()=>{let o=_.current&&!d.pending;if(_.current=d.pending,!o||!a)return;let p=_optionalChain([d, 'access', _4 => _4.fills, 'optionalAccess', _5 => _5.some, 'call', _6 => _6(M=>M.id===a)]),j=Object.values(d.fields).filter(M=>_optionalChain([M, 'access', _7 => _7.replacement, 'optionalAccess', _8 => _8.fill])===a).length;(p||j)&&e.say(t("form.ready",{choice:j,invalid:Ce(d)}))},[d,a,e,t]);let K=_react.useRef.call(void 0, 0),T=o=>{let p=_nullishCoalesce(_optionalChain([o, 'optionalAccess', _9 => _9.querySelectorAll, 'call', _10 => _10("button")]), () => ([]));return[p[K.current],p[K.current-1]]},L=o=>{K.current=[...o.currentTarget.querySelectorAll("button")].indexOf(o.target)},D=_chunkUYR3UEIWcjs.e.call(void 0, ()=>[...T(O.current),_optionalChain([h, 'access', _11 => _11.current, 'optionalAccess', _12 => _12.querySelector, 'call', _13 => _13("button")])]),ee=_chunkUYR3UEIWcjs.e.call(void 0, ()=>[...T(w.current),e.messageField()]),z=_chunkUYR3UEIWcjs.e.call(void 0, ()=>[e.messageField()]),te=o=>o.map(p=>_nullishCoalesce(_optionalChain([d, 'access', _14 => _14.fields, 'access', _15 => _15[p], 'optionalAccess', _16 => _16.label]), () => (p))).join(", "),ne=o=>{if(!l)return;if(e.removalBlocked())return e.say(t("form.revertWait"));if(!e.claim())return e.say(t("form.busy"));let p=e.scope();l.remove(o.reference).then(()=>{p===e.scope()&&(e.setFiles(j=>j.filter(M=>M.reference!==o.reference)),e.release())},()=>{p===e.scope()&&(e.release(),e.say(t("form.removeFailed",{name:o.name})))})};return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "p",{role:"status",className:"wp-form-status",children:e.status}),_jsxruntime.jsx.call(void 0, "div",{onFocus:z,children:e.unusable&&e.unusable===a?_jsxruntime.jsxs.call(void 0, "p",{role:"alert",children:[t("form.unusable")," ",_jsxruntime.jsx.call(void 0, Fe,{B:u,reason:e.blocked,onPress:e.generate,children:t("chat.retry")})]}):null}),_jsxruntime.jsx.call(void 0, "div",{ref:w,onFocus:o=>{L(o),ee(o)},children:(_nullishCoalesce(d.fills, () => ([]))).map(o=>_jsxruntime.jsx.call(void 0, Fe,{B:u,reason:d.pending?t("form.revertWait"):void 0,onPress:()=>{n.revert(o.id)&&e.say(t("form.reverted"))},children:t("form.revert",{fields:te(o.fields)})},o.id))}),l?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "input",{ref:C,type:"file",accept:"image/*",multiple:!0,hidden:!0,onChange:o=>{let p=[..._nullishCoalesce(o.target.files, () => ([]))];o.target.value="",ke(e,p)}}),_jsxruntime.jsx.call(void 0, "div",{ref:h,children:_jsxruntime.jsx.call(void 0, u,{onPress:()=>_optionalChain([C, 'access', _17 => _17.current, 'optionalAccess', _18 => _18.click, 'call', _19 => _19()]),children:t("form.attach")})}),s&&A.length?_jsxruntime.jsx.call(void 0, "span",{id:r,className:"wp-sr-only",children:t("form.revertWait")}):null,_jsxruntime.jsx.call(void 0, "ul",{ref:O,onFocus:o=>{L(o),D(o)},className:"wp-attachments",children:A.map(o=>_jsxruntime.jsxs.call(void 0, "li",{children:[_jsxruntime.jsx.call(void 0, "span",{children:o.name}),_jsxruntime.jsx.call(void 0, u,{"aria-disabled":s||void 0,"aria-describedby":s?r:void 0,onPress:()=>ne(o),children:t("form.remove",{name:o.name})})]},o.reference))})]}):null]})}function _e({session:e,open:n,field:t,source:c,attachments:l,text:A,references:m,scope:a,upload:u,messageField:d}){let{client:r,format:s,primitives:C}=_chunkUYR3UEIWcjs.y.call(void 0, ),h=_react.useSyncExternalStore.call(void 0, r.subscribe,r.getSnapshot,r.getSnapshot),O=_react.useSyncExternalStore.call(void 0, e.subscribe,e.getSnapshot,e.getSnapshot),{pending:w}=O,[H,_]=_react.useState.call(void 0, []),[K,T]=_react.useState.call(void 0, !1),[L,D]=_react.useState.call(void 0, !1),[ee,z]=_react.useState.call(void 0, !1),[te,ne]=_react.useState.call(void 0, ""),[o,p]=_react.useState.call(void 0, void 0),[j,M]=_react.useState.call(void 0, void 0),[Pe,le]=_react.useState.call(void 0, void 0),$=_react.useRef.call(void 0, !1),G=_react.useRef.call(void 0, !1),b=Re(r),J=_react.useRef.call(void 0, void 0),y=_react.useRef.call(void 0, void 0),Ae=_react.useRef.call(void 0, 0),Be=_react.useId.call(void 0, ),re=_react.useId.call(void 0, ),we=()=>`${h.conversationId}:${Be}:${++Ae.current}`,ue=C.button;_react.useEffect.call(void 0, ()=>($.current=!1,G.current=!1,T(!1),D(!1),()=>{y.current=void 0}),[n,e,t]),_react.useEffect.call(void 0, ()=>{if(_optionalChain([h, 'access', _20 => _20.conversation, 'optionalAccess', _21 => _21.mode])==="form-fill"){for(let g of h.conversation.messages)for(let I of g.blocks)if(I.type==="form.fill"){let q=_optionalChain([I, 'access', _22 => _22.body, 'optionalAccess', _23 => _23.requestId]);!e.receive(I.body)&&q===_optionalChain([y, 'access', _24 => _24.current, 'optionalAccess', _25 => _25.request, 'access', _26 => _26.requestId])&&e.getSnapshot().pending&&(e.failRequest(q),y.current=void 0,le(q))}}},[h.conversation,e]);let oe=async(g=!1)=>{if($.current||G.current||!n||e.getSnapshot().pending&&!g||g&&(!_optionalChain([y, 'access', _27 => _27.current, 'optionalAccess', _28 => _28.failed])||y.current.conversationId!==r.getSnapshot().conversationId))return;$.current=!0,D(!0),z(!1),le(void 0);let I=a.current,q,E;try{await r.ready;let S=r.getSnapshot();if(g&&_optionalChain([y, 'access', _29 => _29.current, 'optionalAccess', _30 => _30.conversationId])!==S.conversationId)return;let me=k=>k.field===t&&k.conversationId===S.conversationId,ie=t?_nullishCoalesce([...b.values()].find(me), () => ((J.current&&me(J.current)?J.current:void 0))):void 0,V=_nullishCoalesce(_optionalChain([S, 'access', _31 => _31.conversation, 'optionalAccess', _32 => _32.subject]), () => (_optionalChain([ie, 'optionalAccess', _33 => _33.subject])));if(S.protocol!=="1.1"||!S.capabilities.includes("form-fill")||(S.conversation?S.conversation.mode!=="form-fill":!ie)||!V)throw new Error("Form unavailable");if(I!==a.current)return;if(g&&(E=_optionalChain([y, 'access', _34 => _34.current, 'optionalAccess', _35 => _35.creationAttempt]),E&&(E.inFlight++,ce(b))),t&&!g){if(!c)throw new Error("Subthreads unavailable");let k=_nullishCoalesce(_nullishCoalesce(_optionalChain([S, 'access', _36 => _36.conversation, 'optionalAccess', _37 => _37.parentConversationId]), () => (_optionalChain([ie, 'optionalAccess', _38 => _38.parent]))), () => (S.conversationId)),W=JSON.stringify([k,t]);q=W,b.has(W)||b.set(W,{id:we(),parent:k,field:t,subject:V,inFlight:0});let f=b.get(W);if(E=f,f.inFlight++,ce(b),!f.conversationId){let Q=await c.create({protocol:S.protocol,title:t,mode:"form-fill",subject:V,parentConversationId:k,field:t,clientCreationId:f.id});if(Q.mode!=="form-fill"||Q.parentConversationId!==k||_optionalChain([Q, 'access', _39 => _39.subject, 'optionalAccess', _40 => _40.key])!==V.key)throw new Error("Invalid child");f.conversationId=Q.id}if(I!==a.current||r.getSnapshot().conversationId!==S.conversationId)return;J.current=f;let N=r.getSnapshot(),R=N.conversationId===f.conversationId&&_optionalChain([N, 'access', _41 => _41.conversation, 'optionalAccess', _42 => _42.id])===f.conversationId&&N.status==="open"&&!N.conversationUnavailable&&_optionalChain([N, 'access', _43 => _43.problem, 'optionalAccess', _44 => _44.id])!=="conversation-read"?{kind:"loaded",conversationId:f.conversationId,conversation:N.conversation}:await r.switchConversation(f.conversationId);if(I!==a.current||r.getSnapshot().conversationId!==f.conversationId)return;if(_optionalChain([R, 'optionalAccess', _45 => _45.kind])==="missing"&&R.conversationId===f.conversationId&&b.get(W)===f&&b.delete(W),_optionalChain([R, 'optionalAccess', _46 => _46.kind])!=="loaded"||R.conversationId!==f.conversationId||R.conversation.id!==f.conversationId||R.conversation.mode!=="form-fill"||_optionalChain([R, 'access', _47 => _47.conversation, 'access', _48 => _48.subject, 'optionalAccess', _49 => _49.key])!==f.subject.key)throw new Error("Child unavailable")}if(I!==a.current)return;let Me={text:A,field:_nullishCoalesce(t, () => (_optionalChain([r, 'access', _50 => _50.getSnapshot, 'call', _51 => _51(), 'access', _52 => _52.conversation, 'optionalAccess', _53 => _53.field]))),references:m.split(/\r?\n/).filter(Boolean),attachments:H.map(k=>k.reference)};g||(y.current={request:e.begin(Me),conversationId:r.getSnapshot().conversationId,creationKey:q,creationAttempt:E});let x=y.current,X=x.request;x.failed=!1,p(X.requestId);let Ee=await r.reply({kind:"form-fill",clientReplyId:X.requestId,request:X});if(I!==a.current)return;if(!Ee)throw x.failed=!0,new Error("Form send failed");M(X.requestId),x.creationKey&&b.get(x.creationKey)===x.creationAttempt&&b.delete(x.creationKey)}catch (e3){I===a.current&&z(!0)}finally{E&&(E.inFlight--,ce(b)),I===a.current&&($.current=!1,D(!1))}},F=Object.values(O.fields).some(g=>g.localInvalid)?s("form.fixFirst"):K?s("form.busy"):void 0,fe={session:e,t:s,primitives:C,attachments:l,files:H,setFiles:_,removalBlocked:()=>$.current||e.getSnapshot().pending,claim:()=>G.current?!1:(G.current=!0,T(!0),!0),release:()=>{G.current=!1,T(!1)},scope:()=>a.current,accepted:w?j:void 0,sent:o,generate:()=>{F||oe()},say:ne,status:te,unusable:Pe,blocked:F,messageField:d};return u.current=g=>{ke(fe,g)},_react.useEffect.call(void 0, ()=>()=>u.current=void 0,[u]),_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, je,{control:fe}),w&&_jsxruntime.jsx.call(void 0, "p",{children:s("form.closeHint")}),ee&&_jsxruntime.jsx.call(void 0, "p",{role:"alert",children:s("chat.failure")}),w&&_optionalChain([y, 'access', _54 => _54.current, 'optionalAccess', _55 => _55.failed])&&_jsxruntime.jsx.call(void 0, ue,{disabled:L||y.current.conversationId!==h.conversationId,"aria-disabled":F?!0:void 0,"aria-describedby":F?re:void 0,onPress:()=>{F||oe(!0)},children:s("chat.retry")}),_jsxruntime.jsx.call(void 0, ue,{disabled:L||w||!h.capabilities.includes("form-fill"),"aria-disabled":F?!0:void 0,"aria-describedby":F?re:void 0,onPress:()=>{F||oe()},children:s("form.generate")}),F?_jsxruntime.jsx.call(void 0, "span",{id:re,children:F}):null]})}exports.FieldsStatus = Ge; exports.PopupBody = _e; exports.Suggestion = $e; exports.Value = _chunkXWDB2LS3cjs.a; exports.attentionText = Ue;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkXWDB2LS3cjs = require('./chunk-XWDB2LS3.cjs');var _chunkVGGJGRNKcjs = require('./chunk-VGGJGRNK.cjs');var _chunkA3YOSFLEcjs = require('./chunk-A3YOSFLE.cjs');require('./chunk-FBADWFRR.cjs');require('./chunk-QS3MKZOY.cjs');require('./chunk-RZ3AGK3U.cjs');require('./chunk-4BWV3SEL.cjs');require('./chunk-GT6PI4CT.cjs');require('./chunk-3KV7TDDR.cjs');require('./chunk-Q7BULGQG.cjs');require('./chunk-XSHOLIC7.cjs');require('./chunk-II26UWZM.cjs');var _react = require('react');var be={"form.generating":"Generating draft\u2026","form.ready":"Draft ready{choice, plural, =0 {} one {, # field needs your choice} other {, # fields need your choice}}{invalid, plural, =0 {} one {, # field needs attention} other {, # fields need attention}}","form.attention":"{count, plural, one {# field needs attention} other {# fields need attention}}","form.reverted":"Fill reverted.","form.revert":"Revert this fill ({fields})","form.revertWait":"Wait for the draft to finish.","form.suggested":"Suggested value for {field}","form.replaceIt":"Replace","form.keepMine":"Keep mine","form.attach":"Attach images","form.remove":"Remove {name}","form.uploading":"{count, plural, one {Uploading # image\u2026} other {Uploading # images\u2026}}","form.attached":"{count, plural, one {# image attached} other {# images attached}}","form.attachFailed":"{name} could not be attached.","form.removeFailed":"{name} could not be removed.","form.onlyImages":"Only images can be attached.","form.busy":"Wait for the current upload to finish.","form.unusable":"The draft could not be used."},ye={"form.generating":"\u6B63\u5728\u751F\u6210\u8349\u7A3F\u2026\u2026","form.ready":"\u8349\u7A3F\u5DF2\u5C31\u7EEA{choice, plural, =0 {} other {\uFF0C# \u4E2A\u5B57\u6BB5\u9700\u8981\u4F60\u9009\u62E9}}{invalid, plural, =0 {} other {\uFF0C# \u4E2A\u5B57\u6BB5\u9700\u8981\u5904\u7406}}","form.attention":"{count} \u4E2A\u5B57\u6BB5\u9700\u8981\u5904\u7406","form.reverted":"\u5DF2\u64A4\u9500\u672C\u6B21\u586B\u5145\u3002","form.revert":"\u64A4\u9500\u672C\u6B21\u586B\u5145\uFF08{fields}\uFF09","form.revertWait":"\u8BF7\u7B49\u5F85\u8349\u7A3F\u5B8C\u6210\u3002","form.suggested":"{field}\u7684\u5EFA\u8BAE\u503C","form.replaceIt":"\u66FF\u6362","form.keepMine":"\u4FDD\u7559\u6211\u7684","form.attach":"\u9644\u52A0\u56FE\u7247","form.remove":"\u79FB\u9664{name}","form.uploading":"\u6B63\u5728\u4E0A\u4F20 {count} \u5F20\u56FE\u7247\u2026\u2026","form.attached":"\u5DF2\u9644\u52A0 {count} \u5F20\u56FE\u7247","form.attachFailed":"\u65E0\u6CD5\u9644\u52A0{name}\u3002","form.removeFailed":"\u65E0\u6CD5\u79FB\u9664{name}\u3002","form.onlyImages":"\u53EA\u80FD\u9644\u52A0\u56FE\u7247\u3002","form.busy":"\u8BF7\u7B49\u5F85\u5F53\u524D\u4E0A\u4F20\u5B8C\u6210\u3002","form.unusable":"\u65E0\u6CD5\u4F7F\u7528\u6B64\u8349\u7A3F\u3002"};var _jsxruntime = require('react/jsx-runtime');_chunkA3YOSFLEcjs.q.call(void 0, be,ye);_chunkA3YOSFLEcjs.q.call(void 0, _chunkVGGJGRNKcjs.a,_chunkVGGJGRNKcjs.b);var xe=100,Se=new WeakMap;function Re(e){let n=Se.get(e);return n||(n=new Map,Se.set(e,n)),n}function ce(e){for(let[n,t]of e){if(e.size<=xe)break;t.inFlight===0&&e.delete(n)}}var Ce=e=>Object.values(e.fields).filter(n=>_optionalChain([n, 'access', _2 => _2.validation, 'optionalAccess', _3 => _3.status])==="invalid"||n.localInvalid).length;function $e({name:e,draft:n,session:t,t:c,primitives:l,onReplace:A}){let m=l.button,a=n.replacement,u=a.validation.status==="invalid",d=_react.useId.call(void 0, );return _jsxruntime.jsxs.call(void 0, "div",{role:"group","aria-labelledby":d,"data-suggestion":"",children:[_jsxruntime.jsx.call(void 0, "p",{id:d,children:c("form.suggested",{field:n.label})}),_jsxruntime.jsx.call(void 0, "div",{children:_jsxruntime.jsx.call(void 0, _chunkXWDB2LS3cjs.a,{value:a.value,t:c})}),a.validation.messages.length?_jsxruntime.jsxs.call(void 0, "div",{className:u?"wp-invalid":void 0,children:[u?_jsxruntime.jsx.call(void 0, "strong",{children:c("form.invalid")}):null,a.validation.messages.map((r,s)=>_jsxruntime.jsx.call(void 0, "p",{children:r},s))]}):null,_jsxruntime.jsxs.call(void 0, "div",{className:"wp-actions",children:[_jsxruntime.jsx.call(void 0, m,{onPress:()=>{t.replace(e,a.revision)&&A()},children:c("form.replaceIt")}),_jsxruntime.jsx.call(void 0, m,{onPress:()=>t.cancelReplacement(e),children:c("form.keepMine")})]})]})}function Ge({text:e}){return _jsxruntime.jsx.call(void 0, "span",{role:"status",className:"wp-sr-only",children:e})}var Ue=(e,n)=>{let t=Ce(e);return t?n("form.attention",{count:t}):""};function Fe({B:e,reason:n,onPress:t,children:c}){let l=_react.useId.call(void 0, );return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, e,{"aria-disabled":n?!0:void 0,"aria-describedby":n?l:void 0,onPress:n?void 0:t,children:c}),n?_jsxruntime.jsx.call(void 0, "span",{id:l,children:n}):null]})}var Te=(e,n)=>{let t=n;for(let c=2;e.some(l=>l.name===t);c++)t=`${n} (${c})`;return t};async function ke(e,n){let{t,attachments:c}=e;if(!n.length)return;let l=n.filter(r=>r.type.startsWith("image/")),A=l.length<n.length?t("form.onlyImages"):"",m=(...r)=>e.say([...r,A].filter(Boolean).join(" "));if(!l.length)return m();if(!c)return m(t("form.imagesHere"));if(!e.claim())return m(t("form.busy"));let a=e.scope();m(t("form.uploading",{count:l.length}));let u=[],d=[];for(let r of l)try{let s=await c.upload(r);u.push({reference:s,name:r.name||"image"})}catch (e2){d.push(r.name||"image")}if(a!==e.scope()){await Promise.allSettled(u.map(r=>c.remove(r.reference)));return}e.setFiles(r=>{let s=[...r];for(let C of u)s.some(h=>h.reference===C.reference)||s.push({...C,name:Te(s,C.name)});return s}),e.release(),m(u.length?t("form.attached",{count:u.length}):"",...d.map(r=>t("form.attachFailed",{name:r})))}function je({control:e}){let{session:n,t,primitives:c,attachments:l,files:A,accepted:m,sent:a}=e,u=c.button,d=_react.useSyncExternalStore.call(void 0, n.subscribe,n.getSnapshot,n.getSnapshot),r=_react.useId.call(void 0, ),s=e.removalBlocked(),C=_react.useRef.call(void 0, null),h=_react.useRef.call(void 0, null),O=_react.useRef.call(void 0, null),w=_react.useRef.call(void 0, null),H=_react.useRef.call(void 0, void 0);_react.useLayoutEffect.call(void 0, ()=>{m&&m!==H.current&&e.say(t("form.generating")),H.current=m},[m,e,t]);let _=_react.useRef.call(void 0, d.pending);_react.useLayoutEffect.call(void 0, ()=>{let o=_.current&&!d.pending;if(_.current=d.pending,!o||!a)return;let p=_optionalChain([d, 'access', _4 => _4.fills, 'optionalAccess', _5 => _5.some, 'call', _6 => _6(M=>M.id===a)]),j=Object.values(d.fields).filter(M=>_optionalChain([M, 'access', _7 => _7.replacement, 'optionalAccess', _8 => _8.fill])===a).length;(p||j)&&e.say(t("form.ready",{choice:j,invalid:Ce(d)}))},[d,a,e,t]);let K=_react.useRef.call(void 0, 0),T=o=>{let p=_nullishCoalesce(_optionalChain([o, 'optionalAccess', _9 => _9.querySelectorAll, 'call', _10 => _10("button")]), () => ([]));return[p[K.current],p[K.current-1]]},L=o=>{K.current=[...o.currentTarget.querySelectorAll("button")].indexOf(o.target)},D=_chunkA3YOSFLEcjs.e.call(void 0, ()=>[...T(O.current),_optionalChain([h, 'access', _11 => _11.current, 'optionalAccess', _12 => _12.querySelector, 'call', _13 => _13("button")])]),ee=_chunkA3YOSFLEcjs.e.call(void 0, ()=>[...T(w.current),e.messageField()]),z=_chunkA3YOSFLEcjs.e.call(void 0, ()=>[e.messageField()]),te=o=>o.map(p=>_nullishCoalesce(_optionalChain([d, 'access', _14 => _14.fields, 'access', _15 => _15[p], 'optionalAccess', _16 => _16.label]), () => (p))).join(", "),ne=o=>{if(!l)return;if(e.removalBlocked())return e.say(t("form.revertWait"));if(!e.claim())return e.say(t("form.busy"));let p=e.scope();l.remove(o.reference).then(()=>{p===e.scope()&&(e.setFiles(j=>j.filter(M=>M.reference!==o.reference)),e.release())},()=>{p===e.scope()&&(e.release(),e.say(t("form.removeFailed",{name:o.name})))})};return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "p",{role:"status",className:"wp-form-status",children:e.status}),_jsxruntime.jsx.call(void 0, "div",{onFocus:z,children:e.unusable&&e.unusable===a?_jsxruntime.jsxs.call(void 0, "p",{role:"alert",children:[t("form.unusable")," ",_jsxruntime.jsx.call(void 0, Fe,{B:u,reason:e.blocked,onPress:e.generate,children:t("chat.retry")})]}):null}),_jsxruntime.jsx.call(void 0, "div",{ref:w,onFocus:o=>{L(o),ee(o)},children:(_nullishCoalesce(d.fills, () => ([]))).map(o=>_jsxruntime.jsx.call(void 0, Fe,{B:u,reason:d.pending?t("form.revertWait"):void 0,onPress:()=>{n.revert(o.id)&&e.say(t("form.reverted"))},children:t("form.revert",{fields:te(o.fields)})},o.id))}),l?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "input",{ref:C,type:"file",accept:"image/*",multiple:!0,hidden:!0,onChange:o=>{let p=[..._nullishCoalesce(o.target.files, () => ([]))];o.target.value="",ke(e,p)}}),_jsxruntime.jsx.call(void 0, "div",{ref:h,children:_jsxruntime.jsx.call(void 0, u,{onPress:()=>_optionalChain([C, 'access', _17 => _17.current, 'optionalAccess', _18 => _18.click, 'call', _19 => _19()]),children:t("form.attach")})}),s&&A.length?_jsxruntime.jsx.call(void 0, "span",{id:r,className:"wp-sr-only",children:t("form.revertWait")}):null,_jsxruntime.jsx.call(void 0, "ul",{ref:O,onFocus:o=>{L(o),D(o)},className:"wp-attachments",children:A.map(o=>_jsxruntime.jsxs.call(void 0, "li",{children:[_jsxruntime.jsx.call(void 0, "span",{children:o.name}),_jsxruntime.jsx.call(void 0, u,{"aria-disabled":s||void 0,"aria-describedby":s?r:void 0,onPress:()=>ne(o),children:t("form.remove",{name:o.name})})]},o.reference))})]}):null]})}function _e({session:e,open:n,field:t,source:c,attachments:l,text:A,references:m,scope:a,upload:u,messageField:d}){let{client:r,format:s,primitives:C}=_chunkA3YOSFLEcjs.y.call(void 0, ),h=_react.useSyncExternalStore.call(void 0, r.subscribe,r.getSnapshot,r.getSnapshot),O=_react.useSyncExternalStore.call(void 0, e.subscribe,e.getSnapshot,e.getSnapshot),{pending:w}=O,[H,_]=_react.useState.call(void 0, []),[K,T]=_react.useState.call(void 0, !1),[L,D]=_react.useState.call(void 0, !1),[ee,z]=_react.useState.call(void 0, !1),[te,ne]=_react.useState.call(void 0, ""),[o,p]=_react.useState.call(void 0, void 0),[j,M]=_react.useState.call(void 0, void 0),[Pe,le]=_react.useState.call(void 0, void 0),$=_react.useRef.call(void 0, !1),G=_react.useRef.call(void 0, !1),b=Re(r),J=_react.useRef.call(void 0, void 0),y=_react.useRef.call(void 0, void 0),Ae=_react.useRef.call(void 0, 0),Be=_react.useId.call(void 0, ),re=_react.useId.call(void 0, ),we=()=>`${h.conversationId}:${Be}:${++Ae.current}`,ue=C.button;_react.useEffect.call(void 0, ()=>($.current=!1,G.current=!1,T(!1),D(!1),()=>{y.current=void 0}),[n,e,t]),_react.useEffect.call(void 0, ()=>{if(_optionalChain([h, 'access', _20 => _20.conversation, 'optionalAccess', _21 => _21.mode])==="form-fill"){for(let g of h.conversation.messages)for(let I of g.blocks)if(I.type==="form.fill"){let q=_optionalChain([I, 'access', _22 => _22.body, 'optionalAccess', _23 => _23.requestId]);!e.receive(I.body)&&q===_optionalChain([y, 'access', _24 => _24.current, 'optionalAccess', _25 => _25.request, 'access', _26 => _26.requestId])&&e.getSnapshot().pending&&(e.failRequest(q),y.current=void 0,le(q))}}},[h.conversation,e]);let oe=async(g=!1)=>{if($.current||G.current||!n||e.getSnapshot().pending&&!g||g&&(!_optionalChain([y, 'access', _27 => _27.current, 'optionalAccess', _28 => _28.failed])||y.current.conversationId!==r.getSnapshot().conversationId))return;$.current=!0,D(!0),z(!1),le(void 0);let I=a.current,q,E;try{await r.ready;let S=r.getSnapshot();if(g&&_optionalChain([y, 'access', _29 => _29.current, 'optionalAccess', _30 => _30.conversationId])!==S.conversationId)return;let me=k=>k.field===t&&k.conversationId===S.conversationId,ie=t?_nullishCoalesce([...b.values()].find(me), () => ((J.current&&me(J.current)?J.current:void 0))):void 0,V=_nullishCoalesce(_optionalChain([S, 'access', _31 => _31.conversation, 'optionalAccess', _32 => _32.subject]), () => (_optionalChain([ie, 'optionalAccess', _33 => _33.subject])));if(S.protocol!=="1.1"||!S.capabilities.includes("form-fill")||(S.conversation?S.conversation.mode!=="form-fill":!ie)||!V)throw new Error("Form unavailable");if(I!==a.current)return;if(g&&(E=_optionalChain([y, 'access', _34 => _34.current, 'optionalAccess', _35 => _35.creationAttempt]),E&&(E.inFlight++,ce(b))),t&&!g){if(!c)throw new Error("Subthreads unavailable");let k=_nullishCoalesce(_nullishCoalesce(_optionalChain([S, 'access', _36 => _36.conversation, 'optionalAccess', _37 => _37.parentConversationId]), () => (_optionalChain([ie, 'optionalAccess', _38 => _38.parent]))), () => (S.conversationId)),W=JSON.stringify([k,t]);q=W,b.has(W)||b.set(W,{id:we(),parent:k,field:t,subject:V,inFlight:0});let f=b.get(W);if(E=f,f.inFlight++,ce(b),!f.conversationId){let Q=await c.create({protocol:S.protocol,title:t,mode:"form-fill",subject:V,parentConversationId:k,field:t,clientCreationId:f.id});if(Q.mode!=="form-fill"||Q.parentConversationId!==k||_optionalChain([Q, 'access', _39 => _39.subject, 'optionalAccess', _40 => _40.key])!==V.key)throw new Error("Invalid child");f.conversationId=Q.id}if(I!==a.current||r.getSnapshot().conversationId!==S.conversationId)return;J.current=f;let N=r.getSnapshot(),R=N.conversationId===f.conversationId&&_optionalChain([N, 'access', _41 => _41.conversation, 'optionalAccess', _42 => _42.id])===f.conversationId&&N.status==="open"&&!N.conversationUnavailable&&_optionalChain([N, 'access', _43 => _43.problem, 'optionalAccess', _44 => _44.id])!=="conversation-read"?{kind:"loaded",conversationId:f.conversationId,conversation:N.conversation}:await r.switchConversation(f.conversationId);if(I!==a.current||r.getSnapshot().conversationId!==f.conversationId)return;if(_optionalChain([R, 'optionalAccess', _45 => _45.kind])==="missing"&&R.conversationId===f.conversationId&&b.get(W)===f&&b.delete(W),_optionalChain([R, 'optionalAccess', _46 => _46.kind])!=="loaded"||R.conversationId!==f.conversationId||R.conversation.id!==f.conversationId||R.conversation.mode!=="form-fill"||_optionalChain([R, 'access', _47 => _47.conversation, 'access', _48 => _48.subject, 'optionalAccess', _49 => _49.key])!==f.subject.key)throw new Error("Child unavailable")}if(I!==a.current)return;let Me={text:A,field:_nullishCoalesce(t, () => (_optionalChain([r, 'access', _50 => _50.getSnapshot, 'call', _51 => _51(), 'access', _52 => _52.conversation, 'optionalAccess', _53 => _53.field]))),references:m.split(/\r?\n/).filter(Boolean),attachments:H.map(k=>k.reference)};g||(y.current={request:e.begin(Me),conversationId:r.getSnapshot().conversationId,creationKey:q,creationAttempt:E});let x=y.current,X=x.request;x.failed=!1,p(X.requestId);let Ee=await r.reply({kind:"form-fill",clientReplyId:X.requestId,request:X});if(I!==a.current)return;if(!Ee)throw x.failed=!0,new Error("Form send failed");M(X.requestId),x.creationKey&&b.get(x.creationKey)===x.creationAttempt&&b.delete(x.creationKey)}catch (e3){I===a.current&&z(!0)}finally{E&&(E.inFlight--,ce(b)),I===a.current&&($.current=!1,D(!1))}},F=Object.values(O.fields).some(g=>g.localInvalid)?s("form.fixFirst"):K?s("form.busy"):void 0,fe={session:e,t:s,primitives:C,attachments:l,files:H,setFiles:_,removalBlocked:()=>$.current||e.getSnapshot().pending,claim:()=>G.current?!1:(G.current=!0,T(!0),!0),release:()=>{G.current=!1,T(!1)},scope:()=>a.current,accepted:w?j:void 0,sent:o,generate:()=>{F||oe()},say:ne,status:te,unusable:Pe,blocked:F,messageField:d};return u.current=g=>{ke(fe,g)},_react.useEffect.call(void 0, ()=>()=>u.current=void 0,[u]),_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, je,{control:fe}),w&&_jsxruntime.jsx.call(void 0, "p",{children:s("form.closeHint")}),ee&&_jsxruntime.jsx.call(void 0, "p",{role:"alert",children:s("chat.failure")}),w&&_optionalChain([y, 'access', _54 => _54.current, 'optionalAccess', _55 => _55.failed])&&_jsxruntime.jsx.call(void 0, ue,{disabled:L||y.current.conversationId!==h.conversationId,"aria-disabled":F?!0:void 0,"aria-describedby":F?re:void 0,onPress:()=>{F||oe(!0)},children:s("chat.retry")}),_jsxruntime.jsx.call(void 0, ue,{disabled:L||w||!h.capabilities.includes("form-fill"),"aria-disabled":F?!0:void 0,"aria-describedby":F?re:void 0,onPress:()=>{F||oe()},children:s("form.generate")}),F?_jsxruntime.jsx.call(void 0, "span",{id:re,children:F}):null]})}exports.FieldsStatus = Ge; exports.PopupBody = _e; exports.Suggestion = $e; exports.Value = _chunkXWDB2LS3cjs.a; exports.attentionText = Ue;
|