@agent-dock/cli 0.3.6 → 0.3.7

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.
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ImageLightbox-6D7xjwqD.js","assets/index-CFj59-Ku.js","assets/syntax-highlighter-d-DuIo_w.js","assets/index-BaSVfeZs.css","assets/ImageLightbox-cV5bVqLR.css","assets/PromptEditor-CX3eQM-7.js"])))=>i.map(i=>d[i]);
2
- var MM=e=>{throw TypeError(e)};var g1=(e,t,n)=>t.has(e)||MM("Cannot "+n);var H=(e,t,n)=>(g1(e,t,"read from private field"),n?n.call(e):t.get(e)),Ve=(e,t,n)=>t.has(e)?MM("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),be=(e,t,n,r)=>(g1(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),nn=(e,t,n)=>(g1(e,t,"access private method"),n);var j0=(e,t,n,r)=>({set _(i){be(e,t,i,n)},get _(){return H(e,t,r)}});import{j as d,r as _G,c as CG}from"./index-CFj59-Ku.js";import{r as m,c as z0,g as ts,R as Ne,a as _a,H as kG,t as $M,P as NG}from"./syntax-highlighter-d-DuIo_w.js";function EG(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in e)){const s=Object.getOwnPropertyDescriptor(r,i);s&&Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}const o4=m.createContext(void 0),Ln=e=>{const t=m.useContext(o4);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},jG=({client:e,children:t})=>(m.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),d.jsx(o4.Provider,{value:e,children:t})),zG={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)};var ql,eN,B5,MG=(B5=class{constructor(){Ve(this,ql,zG);Ve(this,eN,!1)}setTimeoutProvider(e){be(this,ql,e)}setTimeout(e,t){return H(this,ql).setTimeout(e,t)}clearTimeout(e){H(this,ql).clearTimeout(e)}setInterval(e,t){return H(this,ql).setInterval(e,t)}clearInterval(e){H(this,ql).clearInterval(e)}},ql=new WeakMap,eN=new WeakMap,B5);const du=new MG;function $G(e){setTimeout(e,0)}const IG=typeof window>"u"||"Deno"in globalThis;function Zi(){}function RG(e,t){return typeof e=="function"?e(t):e}function a4(e){return typeof e=="number"&&e>=0&&e!==1/0}function l4(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Xn(e,t){return typeof e=="function"?e(t):e}function IM(e,t){const{type:n="all",exact:r,fetchStatus:i,predicate:s,queryKey:o,stale:a}=e;if(o){if(r){if(t.queryHash!==tN(o,t.options))return!1}else if(!Qh(t.queryKey,o))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||i&&i!==t.state.fetchStatus||s&&!s(t))}function RM(e,t){const{exact:n,status:r,predicate:i,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return!1;if(n){if(ed(t.options.mutationKey)!==ed(s))return!1}else if(!Qh(t.options.mutationKey,s))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function tN(e,t){return((t==null?void 0:t.queryKeyHashFn)||ed)(e)}function ed(e){return JSON.stringify(e,(t,n)=>c_(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function Qh(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(Array.isArray(e)&&Array.isArray(t)){if(t.length>e.length)return!1;for(let r=0;r<t.length;r++)if(!Qh(e[r],t[r]))return!1;return!0}const n=Object.keys(t);for(const r of n)if(!Qh(e[r],t[r]))return!1;return!0}return!1}const c4=Object.prototype.hasOwnProperty;function u4(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=OM(e)&&OM(t);if(!r&&!(c_(e)&&c_(t)))return t;const i=(r?e:Object.keys(e)).length,s=r?t:Object.keys(t),o=s.length,a=r?new Array(o):{};let l=0;for(let c=0;c<o;c++){const u=r?c:s[c],h=e[u],f=t[u];if(h===f){a[u]=h,(r?c<i:c4.call(e,u))&&l++;continue}if(h===null||f===null||typeof h!="object"||typeof f!="object"){a[u]=f;continue}const p=u4(h,f,n+1);a[u]=p,p===h&&l++}return i===o&&l===i?e:a}function zv(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n of Object.keys(e))if(!c4.call(t,n)||e[n]!==t[n])return!1;return!0}function OM(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function c_(e){if(!PM(e))return!1;const t=Object.getPrototypeOf(e),n=t==null?void 0:t.constructor;if(n===void 0)return!0;if(typeof n!="function")return!1;const r=n.prototype;return!(!PM(r)||!r.hasOwnProperty("isPrototypeOf")||t!==Object.prototype)}function PM(e){return Object.prototype.toString.call(e)==="[object Object]"}function OG(e){return new Promise(t=>{du.setTimeout(t,e)})}function u_(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?u4(e,t):t}function PG(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(-n):r}function TG(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,n):r}const nN=Symbol();function d4(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===nN?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function rN(e,t){return typeof e=="function"?e(...t):!!e}const iN=Symbol();function AG(e,t,n,r){let i=!1,s;return Object.defineProperties(e,{[iN]:{value:r},signal:{enumerable:!0,get:()=>(s??(s=t()),i||(i=!0,s.aborted?n():s.addEventListener("abort",n,{once:!0})),s)}}),e}let DG=()=>IG;const sN=()=>DG();var wf=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},bu,Ul,yh,H5,LG=(H5=class extends wf{constructor(){super();Ve(this,bu);Ve(this,Ul);Ve(this,yh);be(this,yh,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){H(this,Ul)||this.setEventListener(H(this,yh))}onUnsubscribe(){var t;this.hasListeners()||((t=H(this,Ul))==null||t.call(this),be(this,Ul,void 0))}setEventListener(t){var n;be(this,yh,t),(n=H(this,Ul))==null||n.call(this),be(this,Ul,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){H(this,bu)!==t&&(be(this,bu,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof H(this,bu)=="boolean"?H(this,bu):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},bu=new WeakMap,Ul=new WeakMap,yh=new WeakMap,H5);const oN=new LG,FG=$G;function BG(){let e=[],t=0,n=a=>{a()},r=a=>{a()},i=FG;const s=a=>{t?e.push(a):i(()=>{n(a)})},o=()=>{const a=e;e=[],a.length&&i(()=>{r(()=>{a.forEach(l=>{n(l)})})})};return{batch:a=>{let l;t++;try{l=a()}finally{t--,t||o()}return l},batchCalls:a=>(...l)=>{s(()=>{a(...l)})},schedule:s,setNotifyFunction:a=>{n=a},setBatchNotifyFunction:a=>{r=a},setScheduler:a=>{i=a}}}const Ar=BG();var wh,Kl,Sh,V5,HG=(V5=class extends wf{constructor(){super();Ve(this,wh,!0);Ve(this,Kl);Ve(this,Sh);be(this,Sh,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){H(this,Kl)||this.setEventListener(H(this,Sh))}onUnsubscribe(){var t;this.hasListeners()||((t=H(this,Kl))==null||t.call(this),be(this,Kl,void 0))}setEventListener(t){var n;be(this,Sh,t),(n=H(this,Kl))==null||n.call(this),be(this,Kl,t(this.setOnline.bind(this)))}setOnline(t){H(this,wh)!==t&&(be(this,wh,t),this.listeners.forEach(n=>{n(t)}))}isOnline(){return H(this,wh)}},wh=new WeakMap,Kl=new WeakMap,Sh=new WeakMap,V5);const xx=new HG;function VG(e){return Math.min(1e3*2**e,3e4)}function h4(e){return(e??"online")==="online"?xx.isOnline():!0}var d_=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function f4(e){let t=!1,n=0,r,i="pending",s,o;const a=new Promise((y,w)=>{s=y,o=w});a.catch(Zi);const l=()=>i!=="pending",c=y=>{var w;if(!l()){const S=new d_(y);x(S),(w=e.onCancel)==null||w.call(e,S)}},u=()=>{t=!0},h=()=>{t=!1},f=()=>oN.isFocused()&&(e.networkMode==="always"||xx.isOnline())&&e.canRun(),p=()=>h4(e.networkMode)&&e.canRun(),g=y=>{l()||(r==null||r(),i="resolved",s(y))},x=y=>{l()||(r==null||r(),i="rejected",o(y))},v=y=>new Promise(w=>{var S;r=C=>{(l()||y())&&w(C)},(S=e.onPause)==null||S.call(e)}).then(()=>{var w;r=void 0,l()||(w=e.onContinue)==null||w.call(e)}),b=()=>{if(l())return;let y;const w=n===0?e.initialPromise:void 0;try{y=w??e.fn()}catch(S){y=Promise.reject(S)}Promise.resolve(y).then(g).catch(S=>{var z;if(l())return;const C=e.retry??(sN()?0:3),_=e.retryDelay??VG,k=typeof _=="function"?_(n,S):_,j=C===!0||typeof C=="number"&&n<C||typeof C=="function"&&C(n,S);if(t||!j){x(S);return}n++,(z=e.onFail)==null||z.call(e,n,S),OG(k).then(()=>l()||f()?void 0:v(f)).then(()=>{t?x(S):b()})})};return{promise:a,status:()=>i,cancel:c,continue:()=>(r==null||r(),a),cancelRetry:u,continueRetry:h,canStart:p,start:()=>(p()?b():v(p).then(b),a)}}var yu,W5,p4=(W5=class{constructor(){Ve(this,yu)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),a4(this.gcTime)&&be(this,yu,du.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(sN()?1/0:3e5))}clearGcTimeout(){H(this,yu)!==void 0&&(du.clearTimeout(H(this,yu)),be(this,yu,void 0))}},yu=new WeakMap,W5);function WG(e){return{onFetch:(t,n)=>{var u,h,f,p,g;const r=t.options,i=(f=(h=(u=t.fetchOptions)==null?void 0:u.meta)==null?void 0:h.fetchMore)==null?void 0:f.direction,s=((p=t.state.data)==null?void 0:p.pages)||[],o=((g=t.state.data)==null?void 0:g.pageParams)||[];let a={pages:[],pageParams:[]},l=0;const c=async()=>{let x=!1;const v=t,b=S=>{AG(S,()=>t.signal,()=>x=!0,v[iN])},y=d4(t.options,t.fetchOptions),w=async(S,C,_)=>{if(x)return Promise.reject(t.signal.reason);if(C==null&&S.pages.length)return Promise.resolve(S);const j=(()=>{const $={client:t.client,queryKey:t.queryKey,pageParam:C,direction:_?"backward":"forward",meta:t.options.meta};return b($),$})(),z=await y(j),{maxPages:N}=t.options,I=_?TG:PG;return{pages:I(S.pages,z,N),pageParams:I(S.pageParams,C,N)}};if(i&&s.length){const S=i==="backward",C=S?m4:h_,_={pages:s,pageParams:o};a=await w(_,C(r,_),S)}else{const S=e??s.length;do{const C=l===0?o[0]===void 0?r.initialPageParam:o[0]:h_(r,a);if(l>0&&C==null)break;a=await w(a,C),l++}while(l<S)}return a};t.options.persister?t.fetchFn=()=>{var x,v;return(v=(x=t.options).persister)==null?void 0:v.call(x,c,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=c}}}function h_(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function m4(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}function qG(e,t){return t?h_(e,t)!=null:!1}function UG(e,t){return!t||!e.getPreviousPageParam?!1:m4(e,t)!=null}var _h,wu,Ch,Gs,Su,Yr,Ta,pg,_u,Co,Ia,q5,KG=(q5=class extends p4{constructor(t){super();Ve(this,Co);Ve(this,_h);Ve(this,wu);Ve(this,Ch);Ve(this,Gs);Ve(this,Su);Ve(this,Yr);Ve(this,Ta);Ve(this,pg);Ve(this,_u);be(this,_u,!1),be(this,pg,t.defaultOptions),this.setOptions(t.options),this.observers=[],be(this,Su,t.client),be(this,Gs,H(this,Su).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,be(this,wu,AM(this.options)),this.state=t.state??H(this,wu),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return H(this,_h)}get promise(){var t;return(t=H(this,Yr))==null?void 0:t.promise}setOptions(t){if(this.options={...H(this,pg),...t},t!=null&&t._type&&be(this,_h,t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=AM(this.options);n.data!==void 0&&(this.setState(TM(n.data,n.dataUpdatedAt)),be(this,wu,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&H(this,Gs).remove(this)}setData(t,n){const r=u_(this.state.data,t,this.options);return nn(this,Co,Ia).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t){nn(this,Co,Ia).call(this,{type:"setState",state:t})}cancel(t){var r,i;const n=(r=H(this,Yr))==null?void 0:r.promise;return(i=H(this,Yr))==null||i.cancel(t),n?n.then(Zi).catch(Zi):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return H(this,wu)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>Xn(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===nN||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.state.data===void 0?!1:this.getObserversCount()>0?this.observers.some(t=>Xn(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!l4(this.state.dataUpdatedAt,t)}onFocus(){var t,n;(t=this.observers.find(r=>r.shouldFetchOnWindowFocus()))==null||t.refetch({cancelRefetch:!1}),(n=H(this,Yr))==null||n.continue()}onOnline(){var t,n;(t=this.observers.find(r=>r.shouldFetchOnReconnect()))==null||t.refetch({cancelRefetch:!1}),(n=H(this,Yr))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),H(this,Gs).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){const n=this.observers.indexOf(t);n!==-1&&(this.observers.splice(n,1),this.observers.length||(H(this,Yr)&&(H(this,_u)||this.state.fetchStatus==="paused"&&this.state.status==="pending"?H(this,Yr).cancel({revert:!0}):H(this,Yr).cancelRetry()),this.scheduleGc()),H(this,Gs).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||nn(this,Co,Ia).call(this,{type:"invalidate"})}async fetch(t,n){var u,h,f,p;if(this.state.fetchStatus!=="idle"&&((u=H(this,Yr))==null?void 0:u.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(H(this,Yr)&&H(this,Ta))return H(this,Yr).continueRetry(),H(this,Ta)}if(t&&this.setOptions(t),!this.options.queryFn){const g=this.observers.find(x=>x.options.queryFn);g&&this.setOptions(g.options)}const r=new AbortController,i=g=>{Object.defineProperties(g,{[iN]:{value:r.signal,enumerable:!0},signal:{enumerable:!0,get:()=>(be(this,_u,!0),r.signal)}})},s=()=>{const g=d4(this.options,n),v=(()=>{const b={client:H(this,Su),queryKey:this.queryKey,meta:this.meta};return i(b),b})();return be(this,_u,!1),this.options.persister?this.options.persister(g,v,this):g(v)},a=(()=>{const g={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:H(this,Su),state:this.state,fetchFn:s};return i(g),g})();(h=H(this,_h)==="infinite"?WG(this.options.pages):this.options.behavior)==null||h.onFetch(a,this),be(this,Ch,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((f=a.fetchOptions)==null?void 0:f.meta))&&nn(this,Co,Ia).call(this,{type:"fetch",meta:(p=a.fetchOptions)==null?void 0:p.meta});const l=be(this,Yr,f4({initialPromise:n==null?void 0:n.initialPromise,fn:a.fetchFn,onCancel:g=>{g instanceof d_&&g.revert&&this.setState({...H(this,Ch),fetchStatus:"idle"}),r.abort()},onFail:(g,x)=>{nn(this,Co,Ia).call(this,{type:"failed",failureCount:g,error:x})},onPause:()=>{nn(this,Co,Ia).call(this,{type:"pause"})},onContinue:()=>{nn(this,Co,Ia).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0})),c=(async()=>{var g,x,v,b,y,w,S,C;try{const _=await l.promise;if(_===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(_),(x=(g=H(this,Gs).config).onSuccess)==null||x.call(g,_,this),(b=(v=H(this,Gs).config).onSettled)==null||b.call(v,_,this.state.error,this),_}catch(_){if(_ instanceof d_){if(_.silent){if(H(this,Yr)!==l&&H(this,Ta))return H(this,Ta);throw _}else if(_.revert){if(this.state.data===void 0)throw _;return this.state.data}}throw nn(this,Co,Ia).call(this,{type:"error",error:_}),(w=(y=H(this,Gs).config).onError)==null||w.call(y,_,this),(C=(S=H(this,Gs).config).onSettled)==null||C.call(S,this.state.data,_,this),_}finally{H(this,Yr)===l&&(be(this,Yr,void 0),be(this,Ta,void 0)),this.scheduleGc()}})();return be(this,Ta,c),l.start(),c}},_h=new WeakMap,wu=new WeakMap,Ch=new WeakMap,Gs=new WeakMap,Su=new WeakMap,Yr=new WeakMap,Ta=new WeakMap,pg=new WeakMap,_u=new WeakMap,Co=new WeakSet,Ia=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...g4(r.data,this.options),fetchMeta:t.meta??null};case"success":const i={...r,...TM(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return be(this,Ch,t.manual?i:void 0),i;case"error":const s=t.error;return{...r,error:s,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),Ar.batch(()=>{this.observers.slice().forEach(r=>{r.onQueryUpdate()}),H(this,Gs).notify({query:this,type:"updated",action:t})})},q5);function g4(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:h4(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function TM(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function AM(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Ki,mn,mg,Gi,Cu,kh,Aa,gg,Nh,Eh,ku,Nu,Gl,jh,kn,Pp,f_,p_,m_,g_,v_,x_,b_,y_,U5,v4=(U5=class extends wf{constructor(t,n){super();Ve(this,kn);Ve(this,Ki);Ve(this,mn);Ve(this,mg);Ve(this,Gi);Ve(this,Cu);Ve(this,kh);Ve(this,Aa);Ve(this,gg);Ve(this,Nh);Ve(this,Eh);Ve(this,ku);Ve(this,Nu);Ve(this,Gl);Ve(this,jh,new Set);this.options=n,be(this,Ki,t),be(this,Aa,null),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(H(this,mn).addObserver(this),DM(H(this,mn),this.options)?nn(this,kn,Pp).call(this):this.updateResult(),nn(this,kn,v_).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return w_(H(this,mn),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return w_(H(this,mn),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,nn(this,kn,x_).call(this),nn(this,kn,b_).call(this),H(this,mn).removeObserver(this)}setOptions(t){const n=this.options,r=H(this,mn);if(this.options=H(this,Ki).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Xn(this.options.enabled,H(this,mn))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");nn(this,kn,y_).call(this),H(this,mn).setOptions(this.options),n._defaulted&&!zv(this.options,n)&&H(this,Ki).getQueryCache().notify({type:"observerOptionsUpdated",query:H(this,mn),observer:this});const i=this.hasListeners();i&&LM(H(this,mn),r,this.options,n)&&nn(this,kn,Pp).call(this),this.updateResult(),i&&(H(this,mn)!==r||Xn(this.options.enabled,H(this,mn))!==Xn(n.enabled,H(this,mn))||Xn(this.options.staleTime,H(this,mn))!==Xn(n.staleTime,H(this,mn)))&&nn(this,kn,p_).call(this);const s=nn(this,kn,m_).call(this);i&&(H(this,mn)!==r||Xn(this.options.enabled,H(this,mn))!==Xn(n.enabled,H(this,mn))||s!==H(this,Gl))&&nn(this,kn,g_).call(this,s)}getOptimisticResult(t){const n=H(this,Ki).getQueryCache().build(H(this,Ki),t),r=this.createResult(n,t);return zv(this.getCurrentResult(),r)||(be(this,Gi,r),be(this,kh,this.options),be(this,Cu,H(this,mn).state)),r}getCurrentResult(){return H(this,Gi)}trackResult(t,n){return new Proxy(t,{get:(r,i)=>(this.trackProp(i),n==null||n(i),Reflect.get(r,i))})}trackProp(t){H(this,jh).add(t)}getCurrentQuery(){return H(this,mn)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=H(this,Ki).defaultQueryOptions(t),r=H(this,Ki).getQueryCache().build(H(this,Ki),n);let i=()=>{},s;const o=new Promise(a=>{s=a,i=H(this,Ki).getQueryCache().subscribe(l=>{l.type==="updated"&&l.query.queryHash===r.queryHash&&r.state.data!==void 0&&(i(),a(this.createResult(r,n)))})});return Promise.race([r.fetch(n).then(()=>{const a=this.createResult(r,n);return s==null||s(a),a}).finally(()=>{i()}),o])}fetch(t){return nn(this,kn,Pp).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),H(this,Gi)))}createResult(t,n){var _;const r=H(this,mn),i=this.options,s=H(this,Gi),o=H(this,Cu),a=H(this,kh),l=t!==r?t.state:H(this,mg),{state:c}=t;let u={...c},h=!1,f;if(n._optimisticResults){const k=this.hasListeners(),j=!k&&DM(t,n),z=k&&LM(t,r,n,i);(j||z)&&(u={...u,...g4(c.data,t.options)}),n._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:p,errorUpdatedAt:g,status:x}=u;f=u.data;let v=!1;if(n.placeholderData!==void 0&&f===void 0&&x==="pending"){let k;s!=null&&s.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData)?(k=s.data,v=!0):k=typeof n.placeholderData=="function"?n.placeholderData((_=H(this,Eh))==null?void 0:_.state.data,H(this,Eh)):n.placeholderData,k!==void 0&&(x="success",f=u_(s==null?void 0:s.data,k,n),h=!0)}if(n.select&&f!==void 0&&!v)if(s&&f===(o==null?void 0:o.data)&&n.select===H(this,gg))f=H(this,Nh);else try{be(this,gg,n.select),f=n.select(f),f=u_(s==null?void 0:s.data,f,n),be(this,Nh,f),be(this,Aa,null)}catch(k){be(this,Aa,k)}else f===void 0&&be(this,Aa,null);H(this,Aa)&&(p=H(this,Aa),f=H(this,Nh),g=(s==null?void 0:s.error)===p?s.errorUpdatedAt:Date.now(),x="error",h=!1);const b=u.fetchStatus==="fetching",y=x==="pending",w=x==="error",S=y&&b,C=f!==void 0;return{status:x,fetchStatus:u.fetchStatus,isPending:y,isSuccess:x==="success",isError:w,isInitialLoading:S,isLoading:S,data:f,dataUpdatedAt:u.dataUpdatedAt,error:p,errorUpdatedAt:g,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:u.dataUpdateCount>l.dataUpdateCount||u.errorUpdateCount>l.errorUpdateCount,isFetching:b,isRefetching:b&&!y,isLoadingError:w&&!C,isPaused:u.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:w&&C,isStale:aN(t,n),refetch:this.refetch,isEnabled:Xn(n.enabled,t)!==!1}}updateResult(){const t=H(this,Gi),n=this.createResult(H(this,mn),this.options);if(be(this,Cu,H(this,mn).state),be(this,kh,this.options),H(this,Cu).data!==void 0&&be(this,Eh,H(this,mn)),zv(n,t))return;be(this,Gi,n);const i=(()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,o=typeof s=="function"?s():s;if(o==="all"||!o&&!H(this,jh).size||this.options.throwOnError&&H(this,Gi).error!==t.error)return!0;for(const a of o??H(this,jh))if(H(this,Gi)[a]!==t[a])return!0;return!1})();Ar.batch(()=>{i&&this.listeners.forEach(s=>{s(H(this,Gi))}),H(this,Ki).getQueryCache().notify({query:H(this,mn),type:"observerResultsUpdated"})})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&nn(this,kn,v_).call(this)}},Ki=new WeakMap,mn=new WeakMap,mg=new WeakMap,Gi=new WeakMap,Cu=new WeakMap,kh=new WeakMap,Aa=new WeakMap,gg=new WeakMap,Nh=new WeakMap,Eh=new WeakMap,ku=new WeakMap,Nu=new WeakMap,Gl=new WeakMap,jh=new WeakMap,kn=new WeakSet,Pp=function(t){nn(this,kn,y_).call(this);let n=H(this,mn).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Zi)),n},f_=function(t){return!sN()&&Xn(this.options.enabled,H(this,mn))!==!1&&a4(t)},p_=function(){nn(this,kn,x_).call(this);const t=Xn(this.options.staleTime,H(this,mn));if(H(this,Gi).isStale||!nn(this,kn,f_).call(this,t))return;const n=l4(H(this,Gi).dataUpdatedAt,t)+1;be(this,ku,du.setTimeout(()=>{H(this,Gi).isStale||this.updateResult()},n))},m_=function(){return Xn(this.options.refetchInterval,H(this,mn))??!1},g_=function(t){nn(this,kn,b_).call(this),be(this,Gl,t),!(H(this,Gl)===0||!nn(this,kn,f_).call(this,H(this,Gl)))&&be(this,Nu,du.setInterval(()=>{(this.options.refetchIntervalInBackground||oN.isFocused())&&nn(this,kn,Pp).call(this)},H(this,Gl)))},v_=function(){nn(this,kn,p_).call(this),nn(this,kn,g_).call(this,nn(this,kn,m_).call(this))},x_=function(){H(this,ku)!==void 0&&(du.clearTimeout(H(this,ku)),be(this,ku,void 0))},b_=function(){H(this,Nu)!==void 0&&(du.clearInterval(H(this,Nu)),be(this,Nu,void 0))},y_=function(){const t=H(this,Ki).getQueryCache().build(H(this,Ki),this.options);if(t===H(this,mn))return;const n=H(this,mn);be(this,mn,t),be(this,mg,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},U5);function GG(e,t){return Xn(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&Xn(t.retryOnMount,e)===!1)}function DM(e,t){return GG(e,t)||e.state.data!==void 0&&w_(e,t,t.refetchOnMount)}function w_(e,t,n){if(Xn(t.enabled,e)!==!1&&Xn(t.staleTime,e)!=="static"){const r=Xn(n,e);return r==="always"||r!==!1&&aN(e,t)}return!1}function LM(e,t,n,r){return(e!==t||Xn(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&aN(e,n)}function aN(e,t){return Xn(t.enabled,e)!==!1&&e.isStaleByTime(Xn(t.staleTime,e))}var YG=class extends v4{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type="infinite",super.setOptions(e)}getOptimisticResult(e){return e._type="infinite",super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){var p,g;const{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:s,isError:o,isRefetchError:a}=r,l=(g=(p=n.fetchMeta)==null?void 0:p.fetchMore)==null?void 0:g.direction,c=o&&l==="forward",u=i&&l==="forward",h=o&&l==="backward",f=i&&l==="backward";return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:qG(t,n.data),hasPreviousPage:UG(t,n.data),isFetchNextPageError:c,isFetchingNextPage:u,isFetchPreviousPageError:h,isFetchingPreviousPage:f,isRefetchError:a&&!c&&!h,isRefetching:s&&!u&&!f}}},vg,Qo,ji,Eu,ea,Il,K5,ZG=(K5=class extends p4{constructor(t){super();Ve(this,ea);Ve(this,vg);Ve(this,Qo);Ve(this,ji);Ve(this,Eu);be(this,vg,t.client),this.mutationId=t.mutationId,be(this,ji,t.mutationCache),be(this,Qo,[]),this.state=t.state||x4(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){H(this,Qo).includes(t)||(H(this,Qo).push(t),this.clearGcTimeout(),H(this,ji).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){be(this,Qo,H(this,Qo).filter(n=>n!==t)),this.scheduleGc(),H(this,ji).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){H(this,Qo).length||(this.state.status==="pending"?this.scheduleGc():H(this,ji).remove(this))}continue(){var t;return((t=H(this,Eu))==null?void 0:t.continue())??(this.state.status==="pending"?this.execute(this.state.variables):Promise.resolve())}async execute(t){var a,l,c,u,h,f,p,g,x,v,b,y,w,S,C,_,k,j;const n=()=>{nn(this,ea,Il).call(this,{type:"continue"})},r={client:H(this,vg),meta:this.options.meta,mutationKey:this.options.mutationKey},i=be(this,Eu,f4({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(z,N)=>{nn(this,ea,Il).call(this,{type:"failed",failureCount:z,error:N})},onPause:()=>{nn(this,ea,Il).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>H(this,ji).canRun(this)})),s=this.state.status==="pending",o=!i.canStart();try{if(s)n();else{nn(this,ea,Il).call(this,{type:"pending",variables:t,isPaused:o}),H(this,ji).config.onMutate&&await H(this,ji).config.onMutate(t,this,r);const N=await((l=(a=this.options).onMutate)==null?void 0:l.call(a,t,r));N!==this.state.context&&nn(this,ea,Il).call(this,{type:"pending",context:N,variables:t,isPaused:o})}this.state.isPaused&&i.canStart()&&n();const z=await i.start();return await((u=(c=H(this,ji).config).onSuccess)==null?void 0:u.call(c,z,t,this.state.context,this,r)),await((f=(h=this.options).onSuccess)==null?void 0:f.call(h,z,t,this.state.context,r)),await((g=(p=H(this,ji).config).onSettled)==null?void 0:g.call(p,z,null,this.state.variables,this.state.context,this,r)),await((v=(x=this.options).onSettled)==null?void 0:v.call(x,z,null,t,this.state.context,r)),nn(this,ea,Il).call(this,{type:"success",data:z}),z}catch(z){try{await((y=(b=H(this,ji).config).onError)==null?void 0:y.call(b,z,t,this.state.context,this,r))}catch(N){Promise.reject(N)}try{await((S=(w=this.options).onError)==null?void 0:S.call(w,z,t,this.state.context,r))}catch(N){Promise.reject(N)}try{await((_=(C=H(this,ji).config).onSettled)==null?void 0:_.call(C,void 0,z,this.state.variables,this.state.context,this,r))}catch(N){Promise.reject(N)}try{await((j=(k=this.options).onSettled)==null?void 0:j.call(k,void 0,z,t,this.state.context,r))}catch(N){Promise.reject(N)}throw nn(this,ea,Il).call(this,{type:"error",error:z}),z}finally{H(this,Eu)===i&&be(this,Eu,void 0),H(this,ji).runNext(this)}}},vg=new WeakMap,Qo=new WeakMap,ji=new WeakMap,Eu=new WeakMap,ea=new WeakSet,Il=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Ar.batch(()=>{H(this,Qo).forEach(r=>{r.onMutationUpdate(t)}),H(this,ji).notify({mutation:this,type:"updated",action:t})})},K5);function x4(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Yl,ko,xg,G5,XG=(G5=class extends wf{constructor(t={}){super();Ve(this,Yl);Ve(this,ko);Ve(this,xg);this.config=t,be(this,Yl,new Set),be(this,ko,new Map),be(this,xg,0)}build(t,n,r){const i=new ZG({client:t,mutationCache:this,mutationId:++j0(this,xg)._,options:t.defaultMutationOptions(n),state:r});return this.add(i),i}add(t){H(this,Yl).add(t);const n=M0(t);if(typeof n=="string"){const r=H(this,ko).get(n);r?r.push(t):H(this,ko).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(H(this,Yl).delete(t)){const n=M0(t);if(typeof n=="string"){const r=H(this,ko).get(n);if(r)if(r.length>1){const i=r.indexOf(t);i!==-1&&r.splice(i,1)}else r[0]===t&&H(this,ko).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){var r;const n=M0(t);if(typeof n=="string"){const i=(r=H(this,ko).get(n))==null?void 0:r.find(s=>s.state.status==="pending");return!i||i===t}else return!0}runNext(t){var r,i;const n=M0(t);return typeof n=="string"?((i=(r=H(this,ko).get(n))==null?void 0:r.find(s=>s!==t&&s.state.isPaused))==null?void 0:i.continue())??Promise.resolve():Promise.resolve()}clear(){Ar.batch(()=>{const t=this.getAll();H(this,Yl).clear(),H(this,ko).clear(),t.forEach(n=>{this.notify({type:"removed",mutation:n})})})}getAll(){return Array.from(H(this,Yl))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>RM(n,r))}findAll(t={}){return this.getAll().filter(n=>RM(t,n))}notify(t){Ar.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Ar.batch(()=>Promise.all(t.map(n=>n.continue().catch(Zi))))}},Yl=new WeakMap,ko=new WeakMap,xg=new WeakMap,G5);function M0(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Da,Zl,zi,bg,ca,Tp,S_,Y5,JG=(Y5=class extends wf{constructor(n,r){super();Ve(this,ca);Ve(this,Da);Ve(this,Zl);Ve(this,zi);Ve(this,bg);be(this,Da,n),this.setOptions(r),this.bindMethods(),nn(this,ca,Tp).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var i;const r=this.options;this.options=H(this,Da).defaultMutationOptions(n),zv(this.options,r)||H(this,Da).getMutationCache().notify({type:"observerOptionsUpdated",mutation:H(this,zi),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&ed(r.mutationKey)!==ed(this.options.mutationKey)?this.reset():((i=H(this,zi))==null?void 0:i.state.status)==="pending"&&H(this,zi).setOptions(this.options)}onSubscribe(){this.listeners.size===1&&H(this,zi)&&(H(this,zi).addObserver(this),nn(this,ca,Tp).call(this))}onUnsubscribe(){var n;this.hasListeners()||(n=H(this,zi))==null||n.removeObserver(this)}onMutationUpdate(n){nn(this,ca,Tp).call(this),nn(this,ca,S_).call(this,n)}getCurrentResult(){return H(this,Zl)}reset(){var n;(n=H(this,zi))==null||n.removeObserver(this),be(this,zi,void 0),nn(this,ca,Tp).call(this),nn(this,ca,S_).call(this)}mutate(n,r){var i;return be(this,bg,r),(i=H(this,zi))==null||i.removeObserver(this),be(this,zi,H(this,Da).getMutationCache().build(H(this,Da),this.options)),H(this,zi).addObserver(this),H(this,zi).execute(n)}},Da=new WeakMap,Zl=new WeakMap,zi=new WeakMap,bg=new WeakMap,ca=new WeakSet,Tp=function(){var r;const n=((r=H(this,zi))==null?void 0:r.state)??x4();be(this,Zl,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},S_=function(n){Ar.batch(()=>{var i,s,o,a;const r=H(this,bg);if(r&&this.hasListeners()){const l=H(this,Zl).variables,c=H(this,Zl).context,u={client:H(this,Da),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(i=r.onSuccess)==null||i.call(r,n.data,l,c,u)}catch(h){Promise.reject(h)}try{(s=r.onSettled)==null||s.call(r,n.data,null,l,c,u)}catch(h){Promise.reject(h)}}else if((n==null?void 0:n.type)==="error"){try{(o=r.onError)==null||o.call(r,n.error,l,c,u)}catch(h){Promise.reject(h)}try{(a=r.onSettled)==null||a.call(r,void 0,n.error,l,c,u)}catch(h){Promise.reject(h)}}}this.listeners.forEach(l=>{l(H(this,Zl))})})},Y5),ta,Z5,QG=(Z5=class extends wf{constructor(t={}){super();Ve(this,ta);this.config=t,be(this,ta,new Map)}build(t,n,r){const i=n.queryKey,s=n.queryHash??tN(i,n);let o=this.get(s);return o||(o=new KG({client:t,queryKey:i,queryHash:s,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(i)}),this.add(o)),o}add(t){H(this,ta).has(t.queryHash)||(H(this,ta).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){H(this,ta).get(t.queryHash)===t&&(t.destroy(),H(this,ta).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Ar.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return H(this,ta).get(t)}getAll(){return[...H(this,ta).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>IM(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>IM(t,r)):n}notify(t){Ar.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Ar.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Ar.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},ta=new WeakMap,Z5),sr,Xl,Jl,zh,Mh,Ql,$h,Ih,X5,eY=(X5=class{constructor(e={}){Ve(this,sr);Ve(this,Xl);Ve(this,Jl);Ve(this,zh);Ve(this,Mh);Ve(this,Ql);Ve(this,$h);Ve(this,Ih);be(this,sr,e.queryCache||new QG),be(this,Xl,e.mutationCache||new XG),be(this,Jl,e.defaultOptions||{}),be(this,zh,new Map),be(this,Mh,new Map),be(this,Ql,0)}mount(){j0(this,Ql)._++,H(this,Ql)===1&&(be(this,$h,oN.subscribe(async e=>{e&&(await this.resumePausedMutations(),H(this,sr).onFocus())})),be(this,Ih,xx.subscribe(async e=>{e&&(await this.resumePausedMutations(),H(this,sr).onOnline())})))}unmount(){var e,t;j0(this,Ql)._--,H(this,Ql)===0&&((e=H(this,$h))==null||e.call(this),be(this,$h,void 0),(t=H(this,Ih))==null||t.call(this),be(this,Ih,void 0))}isFetching(e){return H(this,sr).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return H(this,Xl).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=H(this,sr).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=H(this,sr).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Xn(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return H(this,sr).findAll(e).map(({queryKey:t,state:n})=>[t,n.data])}setQueryData(e,t,n){var o;const r=this.defaultQueryOptions({queryKey:e}),i=(o=H(this,sr).get(r.queryHash))==null?void 0:o.state.data,s=RG(t,i);if(s!==void 0)return H(this,sr).build(this,r).setData(s,{...n,manual:!0})}setQueriesData(e,t,n){return Ar.batch(()=>H(this,sr).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=H(this,sr).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=H(this,sr);Ar.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=H(this,sr);return Ar.batch(()=>{const r=n.findAll(e),i=new Set(r);return r.forEach(s=>{s.reset()}),this.refetchQueries({type:"active",predicate:s=>i.has(s)},t)})}cancelQueries(e,t={}){const n={revert:!0,...t},r=Ar.batch(()=>H(this,sr).findAll(e).map(i=>i.cancel(n)));return Promise.all(r).then(Zi).catch(Zi)}invalidateQueries(e,t={}){return Ar.batch(()=>(H(this,sr).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=Ar.batch(()=>H(this,sr).findAll(e).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let s=i.fetch(void 0,n);const o=i.state.fetchStatus==="paused";return(!n.throwOnError||o)&&(s=s.catch(Zi)),o?Promise.resolve():s}));return Promise.all(r).then(Zi)}async query(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=H(this,sr).build(this,t),r=n.isStaleByTime(Xn(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=H(this,sr).build(this,t);return n.isStaleByTime(Xn(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Zi).catch(Zi)}infiniteQuery(e){return e._type="infinite",this.query(e)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Zi).catch(Zi)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return xx.isOnline()?H(this,Xl).resumePausedMutations():Promise.resolve()}getQueryCache(){return H(this,sr)}getMutationCache(){return H(this,Xl)}getDefaultOptions(){return H(this,Jl)}setDefaultOptions(e){be(this,Jl,e)}setQueryDefaults(e,t){H(this,zh).set(ed(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...H(this,zh).values()],n={};return t.forEach(r=>{Qh(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){H(this,Mh).set(ed(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...H(this,Mh).values()],n={};return t.forEach(r=>{Qh(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...H(this,Jl).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=tN(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===nN&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...H(this,Jl).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){H(this,sr).clear(),H(this,Xl).clear()}},sr=new WeakMap,Xl=new WeakMap,Jl=new WeakMap,zh=new WeakMap,Mh=new WeakMap,Ql=new WeakMap,$h=new WeakMap,Ih=new WeakMap,X5);const b4=m.createContext(!1),tY=()=>m.useContext(b4);b4.Provider;function nY(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}const rY=m.createContext(nY()),iY=()=>m.useContext(rY),sY=(e,t,n)=>{const r=(n==null?void 0:n.state.status)==="error"&&typeof e.throwOnError=="function"?rN(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},oY=e=>{m.useEffect(()=>{e.clearReset()},[e])},aY=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||rN(n,[e.error,r])),lY=e=>{if(e.suspense){const n=i=>i==="static"?i:Math.max(i??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...i)=>n(r(...i)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},cY=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,uY=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function y4(e,t,n){const r=tY(),i=iY(),s=Ln(),o=s.defaultQueryOptions(e),a=s.getQueryCache().get(o.queryHash),l=e.subscribed!==!1;o._optimisticResults=r?"isRestoring":l?"optimistic":void 0,lY(o),sY(o,i,a),oY(i);const[c]=m.useState(()=>new t(s,o)),u=c.getOptimisticResult(o);m.useEffect(()=>{c.setOptions(o)},[o,c]);const h=!r&&l;if(m.useSyncExternalStore(m.useCallback(f=>{const p=h?c.subscribe(Ar.batchCalls(f)):Zi;return c.updateResult(),p},[c,h]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),cY(o,u))throw uY(o,c,i);if(aY({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:a,suspense:o.suspense}))throw u.error;return o.notifyOnChangeProps?u:c.trackResult(u)}function Et(e,t){return y4(e,v4)}function yt(e,t){const n=Ln(),[r]=m.useState(()=>new JG(n,e));m.useEffect(()=>{r.setOptions(e)},[r,e]);const i=m.useSyncExternalStore(m.useCallback(o=>r.subscribe(Ar.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),s=m.useCallback((...o)=>{r.mutate(o[0],o[1]).catch(Zi)},[r]);if(i.error&&rN(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:s,mutateAsync:i.mutate}}function dY(e,t){return y4(e,YG)}const hY="modulepreload",fY=function(e){return"/"+e},FM={},w4=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){let o=function(c){return Promise.all(c.map(u=>Promise.resolve(u).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=o(n.map(c=>{if(c=fY(c),c in FM)return;FM[c]=!0;const u=c.endsWith(".css"),h=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${h}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":hY,u||(f.as="script"),f.crossOrigin="",f.href=c,l&&f.setAttribute("nonce",l),document.head.appendChild(f),u)return new Promise((p,g)=>{f.addEventListener("load",p),f.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${c}`)))})}))}function s(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return i.then(o=>{for(const a of o||[])a.status==="rejected"&&s(a.reason);return t().catch(s)})};function lN({open:e,children:t,ms:n=180}){const r=m.useRef(t),[i,s]=m.useState(e);return e&&(r.current=t),m.useEffect(()=>{if(e){s(!0);return}const o=window.setTimeout(()=>s(!1),n);return()=>window.clearTimeout(o)},[e,n]),!e&&!i?null:d.jsx("div",{style:{display:"contents"},...e?{}:{"data-closing":""},children:e?t:r.current})}let Bl=null;const bx=new Set,pY=e=>(bx.add(e),()=>{bx.delete(e)}),BM=()=>Bl;function xr(e,t){if(!((Bl==null?void 0:Bl.kind)===e&&Bl.sessionId===(t==null?void 0:t.sessionId))){Bl={kind:e,...t!=null&&t.sessionId?{sessionId:t.sessionId}:{}};for(const n of bx)n()}}function Ni(){if(Bl!==null){Bl=null;for(const e of bx)e()}}function mY(){return m.useSyncExternalStore(pY,BM,BM)}function gY({dialogs:e}){const t=mY();return d.jsx(d.Fragment,{children:Object.keys(e).map(n=>{const r=(t==null?void 0:t.kind)===n,i=e[n],s=r?typeof i=="function"?i(t.sessionId):i:null;return d.jsx(lN,{open:r,children:s},n)})})}const vY=e=>(t,n)=>{const r=m.useRef(!1);e(()=>()=>{r.current=!1},[]),e(()=>{if(!r.current)r.current=!0;else return t()},n)},iu=e=>typeof e=="function",cN=e=>typeof e=="number"&&!Number.isNaN(e),xY=e=>typeof e>"u",bY=e=>e!=null,yY=e=>bY(e)&&iu(e.then),bn=e=>{const t=m.useRef(e);t.current=m.useMemo(()=>e,[e]);const n=m.useRef(void 0);return n.current||(n.current=function(...r){return t.current.apply(this,r)}),n.current},Pu=vY(m.useEffect);function HM(e,t){if(e===t)return!0;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function Lg(e){const t=m.useRef(e);return t.current=e,t}const Fg=e=>{const t=Lg(e);m.useEffect(()=>()=>{t.current()},[])};var v1,VM;function uN(){if(VM)return v1;VM=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return v1=e,v1}var x1,WM;function wY(){if(WM)return x1;WM=1;var e=typeof z0=="object"&&z0&&z0.Object===Object&&z0;return x1=e,x1}var b1,qM;function S4(){if(qM)return b1;qM=1;var e=wY(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return b1=n,b1}var y1,UM;function SY(){if(UM)return y1;UM=1;var e=S4(),t=function(){return e.Date.now()};return y1=t,y1}var w1,KM;function _Y(){if(KM)return w1;KM=1;var e=/\s/;function t(n){for(var r=n.length;r--&&e.test(n.charAt(r)););return r}return w1=t,w1}var S1,GM;function CY(){if(GM)return S1;GM=1;var e=_Y(),t=/^\s+/;function n(r){return r&&r.slice(0,e(r)+1).replace(t,"")}return S1=n,S1}var _1,YM;function _4(){if(YM)return _1;YM=1;var e=S4(),t=e.Symbol;return _1=t,_1}var C1,ZM;function kY(){if(ZM)return C1;ZM=1;var e=_4(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,i=e?e.toStringTag:void 0;function s(o){var a=n.call(o,i),l=o[i];try{o[i]=void 0;var c=!0}catch{}var u=r.call(o);return c&&(a?o[i]=l:delete o[i]),u}return C1=s,C1}var k1,XM;function NY(){if(XM)return k1;XM=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return k1=n,k1}var N1,JM;function EY(){if(JM)return N1;JM=1;var e=_4(),t=kY(),n=NY(),r="[object Null]",i="[object Undefined]",s=e?e.toStringTag:void 0;function o(a){return a==null?a===void 0?i:r:s&&s in Object(a)?t(a):n(a)}return N1=o,N1}var E1,QM;function jY(){if(QM)return E1;QM=1;function e(t){return t!=null&&typeof t=="object"}return E1=e,E1}var j1,e$;function zY(){if(e$)return j1;e$=1;var e=EY(),t=jY(),n="[object Symbol]";function r(i){return typeof i=="symbol"||t(i)&&e(i)==n}return j1=r,j1}var z1,t$;function MY(){if(t$)return z1;t$=1;var e=CY(),t=uN(),n=zY(),r=NaN,i=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,o=/^0o[0-7]+$/i,a=parseInt;function l(c){if(typeof c=="number")return c;if(n(c))return r;if(t(c)){var u=typeof c.valueOf=="function"?c.valueOf():c;c=t(u)?u+"":u}if(typeof c!="string")return c===0?c:+c;c=e(c);var h=s.test(c);return h||o.test(c)?a(c.slice(2),h?2:8):i.test(c)?r:+c}return z1=l,z1}var M1,n$;function C4(){if(n$)return M1;n$=1;var e=uN(),t=SY(),n=MY(),r="Expected a function",i=Math.max,s=Math.min;function o(a,l,c){var u,h,f,p,g,x,v=0,b=!1,y=!1,w=!0;if(typeof a!="function")throw new TypeError(r);l=n(l)||0,e(c)&&(b=!!c.leading,y="maxWait"in c,f=y?i(n(c.maxWait)||0,l):f,w="trailing"in c?!!c.trailing:w);function S(R){var E=u,M=h;return u=h=void 0,v=R,p=a.apply(M,E),p}function C(R){return v=R,g=setTimeout(j,l),b?S(R):p}function _(R){var E=R-x,M=R-v,P=l-E;return y?s(P,f-M):P}function k(R){var E=R-x,M=R-v;return x===void 0||E>=l||E<0||y&&M>=f}function j(){var R=t();if(k(R))return z(R);g=setTimeout(j,_(R))}function z(R){return g=void 0,w&&u?S(R):(u=h=void 0,p)}function N(){g!==void 0&&clearTimeout(g),v=0,u=x=h=g=void 0}function I(){return g===void 0?p:z(t())}function $(){var R=t(),E=k(R);if(u=arguments,h=this,x=R,E){if(g===void 0)return C(x);if(y)return clearTimeout(g),g=setTimeout(j,l),S(x)}return g===void 0&&(g=setTimeout(j,l)),p}return $.cancel=N,$.flush=I,$}return M1=o,M1}var $Y=C4();const IY=ts($Y),k4=!!(typeof window<"u"&&window.document&&window.document.createElement);var $1,r$;function RY(){if(r$)return $1;r$=1;var e=C4(),t=uN(),n="Expected a function";function r(i,s,o){var a=!0,l=!0;if(typeof i!="function")throw new TypeError(n);return t(o)&&(a="leading"in o?!!o.leading:a,l="trailing"in o?!!o.trailing:l),e(i,s,{leading:a,maxWait:s,trailing:l})}return $1=r,$1}var OY=RY();const PY=ts(OY),Db=e=>{m.useEffect(()=>{const t=e==null?void 0:e();if(!yY(t))return t},[])};function N4(e,t){if(!k4)return;if(!e)return t;let n;return iu(e)?n=e():"current"in e?n=e.current:n=e,n}const TY=e=>(n,r,i)=>{const s=m.useRef(!1),o=m.useRef([]),a=m.useRef([]),l=m.useRef(void 0);e(()=>{var c;const h=(Array.isArray(i)?i:[i]).map(f=>N4(f));if(!s.current){s.current=!0,o.current=h,a.current=r,l.current=n();return}(h.length!==o.current.length||!HM(o.current,h)||!HM(a.current,r))&&((c=l.current)===null||c===void 0||c.call(l),o.current=h,a.current=r,l.current=n())}),Fg(()=>{var c;(c=l.current)===null||c===void 0||c.call(l),s.current=!1})},AY=TY(m.useEffect);var Mv={exports:{}},DY=Mv.exports,i$;function E4(){return i$||(i$=1,(function(e,t){(function(n,r){e.exports=r()})(DY,(function(){var n=1e3,r=6e4,i=36e5,s="millisecond",o="second",a="minute",l="hour",c="day",u="week",h="month",f="quarter",p="year",g="date",x="Invalid Date",v=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,b=/\[([^\]]+)]|YYYY|YY|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,y={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(E){var M=["th","st","nd","rd"],P=E%100;return"["+E+(M[(P-20)%10]||M[P]||M[0])+"]"}},w=function(E,M,P){var A=String(E);return!A||A.length>=M?E:""+Array(M+1-A.length).join(P)+E},S={s:w,z:function(E){var M=-E.utcOffset(),P=Math.abs(M),A=Math.floor(P/60),D=P%60;return(M<=0?"+":"-")+w(A,2,"0")+":"+w(D,2,"0")},m:function E(M,P){if(M.date()<P.date())return-E(P,M);var A=12*(P.year()-M.year())+(P.month()-M.month()),D=M.clone().add(A,h),F=P-D<0,O=M.clone().add(A+(F?-1:1),h);return+(-(A+(P-D)/(F?D-O:O-D))||0)},a:function(E){return E<0?Math.ceil(E)||0:Math.floor(E)},p:function(E){return{M:h,y:p,w:u,d:c,D:g,h:l,m:a,s:o,ms:s,Q:f}[E]||String(E||"").toLowerCase().replace(/s$/,"")},u:function(E){return E===void 0}},C="en",_={};_[C]=y;var k="$isDayjsObject",j=function(E){return E instanceof $||!(!E||!E[k])},z=function E(M,P,A){var D;if(!M)return C;if(typeof M=="string"){var F=M.toLowerCase();_[F]&&(D=F),P&&(_[F]=P,D=F);var O=M.split("-");if(!D&&O.length>1)return E(O[0])}else{var B=M.name;_[B]=M,D=B}return!A&&D&&(C=D),D||!A&&C},N=function(E,M){if(j(E))return E.clone();var P=typeof M=="object"?M:{};return P.date=E,P.args=arguments,new $(P)},I=S;I.l=z,I.i=j,I.w=function(E,M){return N(E,{locale:M.$L,utc:M.$u,x:M.$x,$offset:M.$offset})};var $=(function(){function E(P){this.$L=z(P.locale,null,!0),this.parse(P),this.$x=this.$x||P.x||{},this[k]=!0}var M=E.prototype;return M.parse=function(P){this.$d=(function(A){var D=A.date,F=A.utc;if(D===null)return new Date(NaN);if(I.u(D))return new Date;if(D instanceof Date)return new Date(D);if(typeof D=="string"&&!/Z$/i.test(D)){var O=D.match(v);if(O){var B=O[2]-1||0,V=(O[7]||"0").substring(0,3);return F?new Date(Date.UTC(O[1],B,O[3]||1,O[4]||0,O[5]||0,O[6]||0,V)):new Date(O[1],B,O[3]||1,O[4]||0,O[5]||0,O[6]||0,V)}}return new Date(D)})(P),this.init()},M.init=function(){var P=this.$d;this.$y=P.getFullYear(),this.$M=P.getMonth(),this.$D=P.getDate(),this.$W=P.getDay(),this.$H=P.getHours(),this.$m=P.getMinutes(),this.$s=P.getSeconds(),this.$ms=P.getMilliseconds()},M.$utils=function(){return I},M.isValid=function(){return this.$d.toString()!==x},M.isSame=function(P,A){var D=N(P);return this.startOf(A)<=D&&D<=this.endOf(A)},M.isAfter=function(P,A){return N(P)<this.startOf(A)},M.isBefore=function(P,A){return this.endOf(A)<N(P)},M.$g=function(P,A,D){return I.u(P)?this[A]:this.set(D,P)},M.unix=function(){return Math.floor(this.valueOf()/1e3)},M.valueOf=function(){return this.$d.getTime()},M.startOf=function(P,A){var D=this,F=!!I.u(A)||A,O=I.p(P),B=function(ae,ne){var re=I.w(D.$u?Date.UTC(D.$y,ne,ae):new Date(D.$y,ne,ae),D);return F?re:re.endOf(c)},V=function(ae,ne){return I.w(D.toDate()[ae].apply(D.toDate("s"),(F?[0,0,0,0]:[23,59,59,999]).slice(ne)),D)},T=this.$W,W=this.$M,L=this.$D,q="set"+(this.$u?"UTC":"");switch(O){case p:return F?B(1,0):B(31,11);case h:return F?B(1,W):B(0,W+1);case u:var X=this.$locale().weekStart||0,J=(T<X?T+7:T)-X;return B(F?L-J:L+(6-J),W);case c:case g:return V(q+"Hours",0);case l:return V(q+"Minutes",1);case a:return V(q+"Seconds",2);case o:return V(q+"Milliseconds",3);default:return this.clone()}},M.endOf=function(P){return this.startOf(P,!1)},M.$set=function(P,A){var D,F=I.p(P),O="set"+(this.$u?"UTC":""),B=(D={},D[c]=O+"Date",D[g]=O+"Date",D[h]=O+"Month",D[p]=O+"FullYear",D[l]=O+"Hours",D[a]=O+"Minutes",D[o]=O+"Seconds",D[s]=O+"Milliseconds",D)[F],V=F===c?this.$D+(A-this.$W):A;if(F===h||F===p){var T=this.clone().set(g,1);T.$d[B](V),T.init(),this.$d=T.set(g,Math.min(this.$D,T.daysInMonth())).$d}else B&&this.$d[B](V);return this.init(),this},M.set=function(P,A){return this.clone().$set(P,A)},M.get=function(P){return this[I.p(P)]()},M.add=function(P,A){var D,F=this;P=Number(P);var O=I.p(A),B=function(W){var L=N(F);return I.w(L.date(L.date()+Math.round(W*P)),F)};if(O===h)return this.set(h,this.$M+P);if(O===p)return this.set(p,this.$y+P);if(O===c)return B(1);if(O===u)return B(7);var V=(D={},D[a]=r,D[l]=i,D[o]=n,D)[O]||1,T=this.$d.getTime()+P*V;return I.w(T,this)},M.subtract=function(P,A){return this.add(-1*P,A)},M.format=function(P){var A=this,D=this.$locale();if(!this.isValid())return D.invalidDate||x;var F=P||"YYYY-MM-DDTHH:mm:ssZ",O=I.z(this),B=this.$H,V=this.$m,T=this.$M,W=D.weekdays,L=D.months,q=D.meridiem,X=function(ne,re,ie,G){return ne&&(ne[re]||ne(A,F))||ie[re].slice(0,G)},J=function(ne){return I.s(B%12||12,ne,"0")},ae=q||function(ne,re,ie){var G=ne<12?"AM":"PM";return ie?G.toLowerCase():G};return F.replace(b,(function(ne,re){return re||(function(ie){switch(ie){case"YY":return String(A.$y).slice(-2);case"YYYY":return I.s(A.$y,4,"0");case"M":return T+1;case"MM":return I.s(T+1,2,"0");case"MMM":return X(D.monthsShort,T,L,3);case"MMMM":return X(L,T);case"D":return A.$D;case"DD":return I.s(A.$D,2,"0");case"d":return String(A.$W);case"dd":return X(D.weekdaysMin,A.$W,W,2);case"ddd":return X(D.weekdaysShort,A.$W,W,3);case"dddd":return W[A.$W];case"H":return String(B);case"HH":return I.s(B,2,"0");case"h":return J(1);case"hh":return J(2);case"a":return ae(B,V,!0);case"A":return ae(B,V,!1);case"m":return String(V);case"mm":return I.s(V,2,"0");case"s":return String(A.$s);case"ss":return I.s(A.$s,2,"0");case"SSS":return I.s(A.$ms,3,"0");case"Z":return O}return null})(ne)||O.replace(":","")}))},M.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},M.diff=function(P,A,D){var F,O=this,B=I.p(A),V=N(P),T=(V.utcOffset()-this.utcOffset())*r,W=this-V,L=function(){return I.m(O,V)};switch(B){case p:F=L()/12;break;case h:F=L();break;case f:F=L()/3;break;case u:F=(W-T)/6048e5;break;case c:F=(W-T)/864e5;break;case l:F=W/i;break;case a:F=W/r;break;case o:F=W/n;break;default:F=W}return D?F:I.a(F)},M.daysInMonth=function(){return this.endOf(h).$D},M.$locale=function(){return _[this.$L]},M.locale=function(P,A){if(!P)return this.$L;var D=this.clone(),F=z(P,A,!0);return F&&(D.$L=F),D},M.clone=function(){return I.w(this.$d,this)},M.toDate=function(){return new Date(this.valueOf())},M.toJSON=function(){return this.isValid()?this.toISOString():null},M.toISOString=function(){return this.$d.toISOString()},M.toString=function(){return this.$d.toUTCString()},E})(),R=$.prototype;return N.prototype=R,[["$ms",s],["$s",o],["$m",a],["$H",l],["$W",c],["$M",h],["$y",p],["$D",g]].forEach((function(E){R[E[1]]=function(M){return this.$g(M,E[0],E[1])}})),N.extend=function(E,M){return E.$i||(E(M,$,N),E.$i=!0),N},N.locale=z,N.isDayjs=j,N.unix=function(E){return N(1e3*E)},N.en=_[C],N.Ls=_,N.p={},N}))})(Mv)),Mv.exports}var LY=E4();const Tr=ts(LY),I1=e=>{if(!e)return 0;const t=Tr(e).valueOf()-Date.now();return t<0?0:t},FY=e=>({days:Math.floor(e/864e5),hours:Math.floor(e/36e5)%24,minutes:Math.floor(e/6e4)%60,seconds:Math.floor(e/1e3)%60,milliseconds:Math.floor(e)%1e3}),BY=(e={})=>{const{leftTime:t,targetDate:n,interval:r=1e3,onEnd:i}=e||{},s=m.useMemo(()=>cN(t)&&t>0?Date.now()+t:void 0,[t]),o="leftTime"in e?s:n,[a,l]=m.useState(()=>I1(o)),c=Lg(i);m.useEffect(()=>{if(!o){l(0);return}l(I1(o));const h=setInterval(()=>{var f;const p=I1(o);l(p),p===0&&(clearInterval(h),(f=c.current)===null||f===void 0||f.call(c))},r);return()=>clearInterval(h)},[o,r]);const u=m.useMemo(()=>FY(a),[a]);return[a,u]};function HY(){const e=(typeof global>"u"?"undefined":typeof global)=="object"&&global&&global.Object===Object&&global,t=typeof self=="object"&&self&&self.Object===Object&&self;return e||t}HY()||(global.Date=Date);function VY(e,t){var n;const r=Lg(e),i=(n=t==null?void 0:t.wait)!==null&&n!==void 0?n:1e3,s=m.useMemo(()=>IY((...o)=>r.current(...o),i,t),[]);return Fg(()=>{s.cancel()}),{run:s,cancel:s.cancel,flush:s.flush}}function WY(e,t){const[n,r]=m.useState(e),{run:i}=VY(()=>{r(e)},t);return m.useEffect(()=>{i()},[e]),n}function yr(e,t,n={}){const{enable:r=!0}=n,i=Lg(t);AY(()=>{if(!r)return;const s=N4(n.target,window);if(!(s!=null&&s.addEventListener))return;const o=l=>i.current(l),a=Array.isArray(e)?e:[e];return a.forEach(l=>{s.addEventListener(l,o,{capture:n.capture,once:n.once,passive:n.passive})}),()=>{a.forEach(l=>{s.removeEventListener(l,o,{capture:n.capture})})}},[e,n.capture,n.once,n.passive,r],n.target)}var j4=(function(){if(typeof Map<"u")return Map;function e(t,n){var r=-1;return t.some(function(i,s){return i[0]===n?(r=s,!0):!1}),r}return(function(){function t(){this.__entries__=[]}return Object.defineProperty(t.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),t.prototype.get=function(n){var r=e(this.__entries__,n),i=this.__entries__[r];return i&&i[1]},t.prototype.set=function(n,r){var i=e(this.__entries__,n);~i?this.__entries__[i][1]=r:this.__entries__.push([n,r])},t.prototype.delete=function(n){var r=this.__entries__,i=e(r,n);~i&&r.splice(i,1)},t.prototype.has=function(n){return!!~e(this.__entries__,n)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(n,r){r===void 0&&(r=null);for(var i=0,s=this.__entries__;i<s.length;i++){var o=s[i];n.call(r,o[1],o[0])}},t})()})(),__=typeof window<"u"&&typeof document<"u"&&window.document===document,yx=(function(){return typeof global<"u"&&global.Math===Math?global:typeof self<"u"&&self.Math===Math?self:typeof window<"u"&&window.Math===Math?window:Function("return this")()})(),qY=(function(){return typeof requestAnimationFrame=="function"?requestAnimationFrame.bind(yx):function(e){return setTimeout(function(){return e(Date.now())},1e3/60)}})(),UY=2;function KY(e,t){var n=!1,r=!1,i=0;function s(){n&&(n=!1,e()),r&&a()}function o(){qY(s)}function a(){var l=Date.now();if(n){if(l-i<UY)return;r=!0}else n=!0,r=!1,setTimeout(o,t);i=l}return a}var GY=20,YY=["top","right","bottom","left","width","height","size","weight"],ZY=typeof MutationObserver<"u",XY=(function(){function e(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=KY(this.refresh.bind(this),GY)}return e.prototype.addObserver=function(t){~this.observers_.indexOf(t)||this.observers_.push(t),this.connected_||this.connect_()},e.prototype.removeObserver=function(t){var n=this.observers_,r=n.indexOf(t);~r&&n.splice(r,1),!n.length&&this.connected_&&this.disconnect_()},e.prototype.refresh=function(){var t=this.updateObservers_();t&&this.refresh()},e.prototype.updateObservers_=function(){var t=this.observers_.filter(function(n){return n.gatherActive(),n.hasActive()});return t.forEach(function(n){return n.broadcastActive()}),t.length>0},e.prototype.connect_=function(){!__||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),ZY?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},e.prototype.disconnect_=function(){!__||!this.connected_||(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},e.prototype.onTransitionEnd_=function(t){var n=t.propertyName,r=n===void 0?"":n,i=YY.some(function(s){return!!~r.indexOf(s)});i&&this.refresh()},e.getInstance=function(){return this.instance_||(this.instance_=new e),this.instance_},e.instance_=null,e})(),z4=(function(e,t){for(var n=0,r=Object.keys(t);n<r.length;n++){var i=r[n];Object.defineProperty(e,i,{value:t[i],enumerable:!1,writable:!1,configurable:!0})}return e}),ef=(function(e){var t=e&&e.ownerDocument&&e.ownerDocument.defaultView;return t||yx}),M4=Lb(0,0,0,0);function wx(e){return parseFloat(e)||0}function s$(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return t.reduce(function(r,i){var s=e["border-"+i+"-width"];return r+wx(s)},0)}function JY(e){for(var t=["top","right","bottom","left"],n={},r=0,i=t;r<i.length;r++){var s=i[r],o=e["padding-"+s];n[s]=wx(o)}return n}function QY(e){var t=e.getBBox();return Lb(0,0,t.width,t.height)}function eZ(e){var t=e.clientWidth,n=e.clientHeight;if(!t&&!n)return M4;var r=ef(e).getComputedStyle(e),i=JY(r),s=i.left+i.right,o=i.top+i.bottom,a=wx(r.width),l=wx(r.height);if(r.boxSizing==="border-box"&&(Math.round(a+s)!==t&&(a-=s$(r,"left","right")+s),Math.round(l+o)!==n&&(l-=s$(r,"top","bottom")+o)),!nZ(e)){var c=Math.round(a+s)-t,u=Math.round(l+o)-n;Math.abs(c)!==1&&(a-=c),Math.abs(u)!==1&&(l-=u)}return Lb(i.left,i.top,a,l)}var tZ=(function(){return typeof SVGGraphicsElement<"u"?function(e){return e instanceof ef(e).SVGGraphicsElement}:function(e){return e instanceof ef(e).SVGElement&&typeof e.getBBox=="function"}})();function nZ(e){return e===ef(e).document.documentElement}function rZ(e){return __?tZ(e)?QY(e):eZ(e):M4}function iZ(e){var t=e.x,n=e.y,r=e.width,i=e.height,s=typeof DOMRectReadOnly<"u"?DOMRectReadOnly:Object,o=Object.create(s.prototype);return z4(o,{x:t,y:n,width:r,height:i,top:n,right:t+r,bottom:i+n,left:t}),o}function Lb(e,t,n,r){return{x:e,y:t,width:n,height:r}}var sZ=(function(){function e(t){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=Lb(0,0,0,0),this.target=t}return e.prototype.isActive=function(){var t=rZ(this.target);return this.contentRect_=t,t.width!==this.broadcastWidth||t.height!==this.broadcastHeight},e.prototype.broadcastRect=function(){var t=this.contentRect_;return this.broadcastWidth=t.width,this.broadcastHeight=t.height,t},e})(),oZ=(function(){function e(t,n){var r=iZ(n);z4(this,{target:t,contentRect:r})}return e})(),aZ=(function(){function e(t,n,r){if(this.activeObservations_=[],this.observations_=new j4,typeof t!="function")throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=t,this.controller_=n,this.callbackCtx_=r}return e.prototype.observe=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element>"u"||!(Element instanceof Object))){if(!(t instanceof ef(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var n=this.observations_;n.has(t)||(n.set(t,new sZ(t)),this.controller_.addObserver(this),this.controller_.refresh())}},e.prototype.unobserve=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element>"u"||!(Element instanceof Object))){if(!(t instanceof ef(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var n=this.observations_;n.has(t)&&(n.delete(t),n.size||this.controller_.removeObserver(this))}},e.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},e.prototype.gatherActive=function(){var t=this;this.clearActive(),this.observations_.forEach(function(n){n.isActive()&&t.activeObservations_.push(n)})},e.prototype.broadcastActive=function(){if(this.hasActive()){var t=this.callbackCtx_,n=this.activeObservations_.map(function(r){return new oZ(r.target,r.broadcastRect())});this.callback_.call(t,n,t),this.clearActive()}},e.prototype.clearActive=function(){this.activeObservations_.splice(0)},e.prototype.hasActive=function(){return this.activeObservations_.length>0},e})(),$4=typeof WeakMap<"u"?new WeakMap:new j4,I4=(function(){function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var n=XY.getInstance(),r=new aZ(t,n,this);$4.set(this,r)}return e})();["observe","unobserve","disconnect"].forEach(function(e){I4.prototype[e]=function(){var t;return(t=$4.get(this))[e].apply(t,arguments)}});var lZ=(function(){return typeof yx.ResizeObserver<"u"?yx.ResizeObserver:I4})();const dN=(e,t,n={})=>{const r=bn(e),i=m.useRef(null),s=m.useCallback(()=>{i.current&&clearInterval(i.current)},[]);return m.useEffect(()=>{if(!(!cN(t)||t<0))return n.immediate&&r(),i.current=setInterval(r,t),s},[t,n.immediate]),s},o$="AHOOKS_SYNC_STORAGE_EVENT_NAME",cZ=e=>(n,r={})=>{let i;const{listenStorageChange:s=!1,getInitialValueInEffect:o=!1}=r,a=iu(r.serializer)?r.serializer:JSON.stringify,l=iu(r.deserializer)?r.deserializer:JSON.parse,c=iu(r.onError)?r.onError:console.error;try{i=e()}catch(y){c(y)}const u=()=>{try{const y=i==null?void 0:i.getItem(n);if(y)return l(y)}catch(y){c(y)}return h()};function h(){return iu(r.defaultValue)?r.defaultValue():r.defaultValue}const[f,p]=m.useState(()=>o?h():u());Db(()=>{o&&p(u())});const g=m.useRef(f);g.current=f,Pu(()=>{const y=u();Object.is(y,g.current)||(g.current=y,p(y))},[n]);const x=y=>{const w=g.current,S=iu(y)?y(w):y;if(!Object.is(S,w)){s||(g.current=S,p(S));try{let C;const _=i==null?void 0:i.getItem(n);xY(S)?(C=null,i==null||i.removeItem(n)):(C=a(S),i==null||i.setItem(n,C)),dispatchEvent(new CustomEvent(o$,{detail:{key:n,newValue:C,oldValue:_,storageArea:i}}))}catch(C){c(C)}}},v=y=>{if(y.key!==n||y.storageArea!==i)return;const w=u();Object.is(w,g.current)||(g.current=w,p(w))},b=y=>{v(y.detail)};return yr("storage",v,{enable:s}),yr(o$,b,{enable:s}),[f,bn(x)]},th=cZ(()=>k4?localStorage:void 0);function uZ(e,t){var n;const r=Lg(e),i=(n=t==null?void 0:t.wait)!==null&&n!==void 0?n:1e3,s=m.useMemo(()=>PY((...o)=>r.current(...o),i,t),[]);return Fg(()=>{s.cancel()}),{run:s,cancel:s.cancel,flush:s.flush}}function dZ(e,t){const[n,r]=m.useState(e),{run:i}=uZ(()=>{r(e)},t);return m.useEffect(()=>{i()},[e]),n}const hZ=(e,t)=>{const n=bn(e),r=m.useRef(null),i=m.useCallback(()=>{r.current&&clearTimeout(r.current)},[]);return m.useEffect(()=>{if(!(!cN(t)||t<0))return r.current=setTimeout(n,t),i},[t]),i};/**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ImageLightbox-9uMpMBH0.js","assets/index-BdLrsg1L.js","assets/syntax-highlighter-d-DuIo_w.js","assets/index-Ba38sRJf.css","assets/ImageLightbox-cV5bVqLR.css","assets/PromptEditor-B1iVLwZz.js"])))=>i.map(i=>d[i]);
2
+ var MM=e=>{throw TypeError(e)};var g1=(e,t,n)=>t.has(e)||MM("Cannot "+n);var H=(e,t,n)=>(g1(e,t,"read from private field"),n?n.call(e):t.get(e)),Ve=(e,t,n)=>t.has(e)?MM("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),be=(e,t,n,r)=>(g1(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),nn=(e,t,n)=>(g1(e,t,"access private method"),n);var j0=(e,t,n,r)=>({set _(i){be(e,t,i,n)},get _(){return H(e,t,r)}});import{j as d,r as _G,c as CG}from"./index-BdLrsg1L.js";import{r as m,c as z0,g as ts,R as Ne,a as _a,H as kG,t as $M,P as NG}from"./syntax-highlighter-d-DuIo_w.js";function EG(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in e)){const s=Object.getOwnPropertyDescriptor(r,i);s&&Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}const o4=m.createContext(void 0),Ln=e=>{const t=m.useContext(o4);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},jG=({client:e,children:t})=>(m.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),d.jsx(o4.Provider,{value:e,children:t})),zG={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)};var ql,eN,B5,MG=(B5=class{constructor(){Ve(this,ql,zG);Ve(this,eN,!1)}setTimeoutProvider(e){be(this,ql,e)}setTimeout(e,t){return H(this,ql).setTimeout(e,t)}clearTimeout(e){H(this,ql).clearTimeout(e)}setInterval(e,t){return H(this,ql).setInterval(e,t)}clearInterval(e){H(this,ql).clearInterval(e)}},ql=new WeakMap,eN=new WeakMap,B5);const du=new MG;function $G(e){setTimeout(e,0)}const IG=typeof window>"u"||"Deno"in globalThis;function Zi(){}function RG(e,t){return typeof e=="function"?e(t):e}function a4(e){return typeof e=="number"&&e>=0&&e!==1/0}function l4(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Xn(e,t){return typeof e=="function"?e(t):e}function IM(e,t){const{type:n="all",exact:r,fetchStatus:i,predicate:s,queryKey:o,stale:a}=e;if(o){if(r){if(t.queryHash!==tN(o,t.options))return!1}else if(!Qh(t.queryKey,o))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||i&&i!==t.state.fetchStatus||s&&!s(t))}function RM(e,t){const{exact:n,status:r,predicate:i,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return!1;if(n){if(ed(t.options.mutationKey)!==ed(s))return!1}else if(!Qh(t.options.mutationKey,s))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function tN(e,t){return((t==null?void 0:t.queryKeyHashFn)||ed)(e)}function ed(e){return JSON.stringify(e,(t,n)=>c_(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function Qh(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(Array.isArray(e)&&Array.isArray(t)){if(t.length>e.length)return!1;for(let r=0;r<t.length;r++)if(!Qh(e[r],t[r]))return!1;return!0}const n=Object.keys(t);for(const r of n)if(!Qh(e[r],t[r]))return!1;return!0}return!1}const c4=Object.prototype.hasOwnProperty;function u4(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=OM(e)&&OM(t);if(!r&&!(c_(e)&&c_(t)))return t;const i=(r?e:Object.keys(e)).length,s=r?t:Object.keys(t),o=s.length,a=r?new Array(o):{};let l=0;for(let c=0;c<o;c++){const u=r?c:s[c],h=e[u],f=t[u];if(h===f){a[u]=h,(r?c<i:c4.call(e,u))&&l++;continue}if(h===null||f===null||typeof h!="object"||typeof f!="object"){a[u]=f;continue}const p=u4(h,f,n+1);a[u]=p,p===h&&l++}return i===o&&l===i?e:a}function zv(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n of Object.keys(e))if(!c4.call(t,n)||e[n]!==t[n])return!1;return!0}function OM(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function c_(e){if(!PM(e))return!1;const t=Object.getPrototypeOf(e),n=t==null?void 0:t.constructor;if(n===void 0)return!0;if(typeof n!="function")return!1;const r=n.prototype;return!(!PM(r)||!r.hasOwnProperty("isPrototypeOf")||t!==Object.prototype)}function PM(e){return Object.prototype.toString.call(e)==="[object Object]"}function OG(e){return new Promise(t=>{du.setTimeout(t,e)})}function u_(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?u4(e,t):t}function PG(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(-n):r}function TG(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,n):r}const nN=Symbol();function d4(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===nN?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function rN(e,t){return typeof e=="function"?e(...t):!!e}const iN=Symbol();function AG(e,t,n,r){let i=!1,s;return Object.defineProperties(e,{[iN]:{value:r},signal:{enumerable:!0,get:()=>(s??(s=t()),i||(i=!0,s.aborted?n():s.addEventListener("abort",n,{once:!0})),s)}}),e}let DG=()=>IG;const sN=()=>DG();var wf=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},bu,Ul,yh,H5,LG=(H5=class extends wf{constructor(){super();Ve(this,bu);Ve(this,Ul);Ve(this,yh);be(this,yh,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){H(this,Ul)||this.setEventListener(H(this,yh))}onUnsubscribe(){var t;this.hasListeners()||((t=H(this,Ul))==null||t.call(this),be(this,Ul,void 0))}setEventListener(t){var n;be(this,yh,t),(n=H(this,Ul))==null||n.call(this),be(this,Ul,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){H(this,bu)!==t&&(be(this,bu,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof H(this,bu)=="boolean"?H(this,bu):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},bu=new WeakMap,Ul=new WeakMap,yh=new WeakMap,H5);const oN=new LG,FG=$G;function BG(){let e=[],t=0,n=a=>{a()},r=a=>{a()},i=FG;const s=a=>{t?e.push(a):i(()=>{n(a)})},o=()=>{const a=e;e=[],a.length&&i(()=>{r(()=>{a.forEach(l=>{n(l)})})})};return{batch:a=>{let l;t++;try{l=a()}finally{t--,t||o()}return l},batchCalls:a=>(...l)=>{s(()=>{a(...l)})},schedule:s,setNotifyFunction:a=>{n=a},setBatchNotifyFunction:a=>{r=a},setScheduler:a=>{i=a}}}const Ar=BG();var wh,Kl,Sh,V5,HG=(V5=class extends wf{constructor(){super();Ve(this,wh,!0);Ve(this,Kl);Ve(this,Sh);be(this,Sh,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){H(this,Kl)||this.setEventListener(H(this,Sh))}onUnsubscribe(){var t;this.hasListeners()||((t=H(this,Kl))==null||t.call(this),be(this,Kl,void 0))}setEventListener(t){var n;be(this,Sh,t),(n=H(this,Kl))==null||n.call(this),be(this,Kl,t(this.setOnline.bind(this)))}setOnline(t){H(this,wh)!==t&&(be(this,wh,t),this.listeners.forEach(n=>{n(t)}))}isOnline(){return H(this,wh)}},wh=new WeakMap,Kl=new WeakMap,Sh=new WeakMap,V5);const xx=new HG;function VG(e){return Math.min(1e3*2**e,3e4)}function h4(e){return(e??"online")==="online"?xx.isOnline():!0}var d_=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function f4(e){let t=!1,n=0,r,i="pending",s,o;const a=new Promise((y,w)=>{s=y,o=w});a.catch(Zi);const l=()=>i!=="pending",c=y=>{var w;if(!l()){const S=new d_(y);x(S),(w=e.onCancel)==null||w.call(e,S)}},u=()=>{t=!0},h=()=>{t=!1},f=()=>oN.isFocused()&&(e.networkMode==="always"||xx.isOnline())&&e.canRun(),p=()=>h4(e.networkMode)&&e.canRun(),g=y=>{l()||(r==null||r(),i="resolved",s(y))},x=y=>{l()||(r==null||r(),i="rejected",o(y))},v=y=>new Promise(w=>{var S;r=C=>{(l()||y())&&w(C)},(S=e.onPause)==null||S.call(e)}).then(()=>{var w;r=void 0,l()||(w=e.onContinue)==null||w.call(e)}),b=()=>{if(l())return;let y;const w=n===0?e.initialPromise:void 0;try{y=w??e.fn()}catch(S){y=Promise.reject(S)}Promise.resolve(y).then(g).catch(S=>{var z;if(l())return;const C=e.retry??(sN()?0:3),_=e.retryDelay??VG,k=typeof _=="function"?_(n,S):_,j=C===!0||typeof C=="number"&&n<C||typeof C=="function"&&C(n,S);if(t||!j){x(S);return}n++,(z=e.onFail)==null||z.call(e,n,S),OG(k).then(()=>l()||f()?void 0:v(f)).then(()=>{t?x(S):b()})})};return{promise:a,status:()=>i,cancel:c,continue:()=>(r==null||r(),a),cancelRetry:u,continueRetry:h,canStart:p,start:()=>(p()?b():v(p).then(b),a)}}var yu,W5,p4=(W5=class{constructor(){Ve(this,yu)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),a4(this.gcTime)&&be(this,yu,du.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(sN()?1/0:3e5))}clearGcTimeout(){H(this,yu)!==void 0&&(du.clearTimeout(H(this,yu)),be(this,yu,void 0))}},yu=new WeakMap,W5);function WG(e){return{onFetch:(t,n)=>{var u,h,f,p,g;const r=t.options,i=(f=(h=(u=t.fetchOptions)==null?void 0:u.meta)==null?void 0:h.fetchMore)==null?void 0:f.direction,s=((p=t.state.data)==null?void 0:p.pages)||[],o=((g=t.state.data)==null?void 0:g.pageParams)||[];let a={pages:[],pageParams:[]},l=0;const c=async()=>{let x=!1;const v=t,b=S=>{AG(S,()=>t.signal,()=>x=!0,v[iN])},y=d4(t.options,t.fetchOptions),w=async(S,C,_)=>{if(x)return Promise.reject(t.signal.reason);if(C==null&&S.pages.length)return Promise.resolve(S);const j=(()=>{const $={client:t.client,queryKey:t.queryKey,pageParam:C,direction:_?"backward":"forward",meta:t.options.meta};return b($),$})(),z=await y(j),{maxPages:N}=t.options,I=_?TG:PG;return{pages:I(S.pages,z,N),pageParams:I(S.pageParams,C,N)}};if(i&&s.length){const S=i==="backward",C=S?m4:h_,_={pages:s,pageParams:o};a=await w(_,C(r,_),S)}else{const S=e??s.length;do{const C=l===0?o[0]===void 0?r.initialPageParam:o[0]:h_(r,a);if(l>0&&C==null)break;a=await w(a,C),l++}while(l<S)}return a};t.options.persister?t.fetchFn=()=>{var x,v;return(v=(x=t.options).persister)==null?void 0:v.call(x,c,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=c}}}function h_(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function m4(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}function qG(e,t){return t?h_(e,t)!=null:!1}function UG(e,t){return!t||!e.getPreviousPageParam?!1:m4(e,t)!=null}var _h,wu,Ch,Gs,Su,Yr,Ta,pg,_u,Co,Ia,q5,KG=(q5=class extends p4{constructor(t){super();Ve(this,Co);Ve(this,_h);Ve(this,wu);Ve(this,Ch);Ve(this,Gs);Ve(this,Su);Ve(this,Yr);Ve(this,Ta);Ve(this,pg);Ve(this,_u);be(this,_u,!1),be(this,pg,t.defaultOptions),this.setOptions(t.options),this.observers=[],be(this,Su,t.client),be(this,Gs,H(this,Su).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,be(this,wu,AM(this.options)),this.state=t.state??H(this,wu),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return H(this,_h)}get promise(){var t;return(t=H(this,Yr))==null?void 0:t.promise}setOptions(t){if(this.options={...H(this,pg),...t},t!=null&&t._type&&be(this,_h,t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=AM(this.options);n.data!==void 0&&(this.setState(TM(n.data,n.dataUpdatedAt)),be(this,wu,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&H(this,Gs).remove(this)}setData(t,n){const r=u_(this.state.data,t,this.options);return nn(this,Co,Ia).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t){nn(this,Co,Ia).call(this,{type:"setState",state:t})}cancel(t){var r,i;const n=(r=H(this,Yr))==null?void 0:r.promise;return(i=H(this,Yr))==null||i.cancel(t),n?n.then(Zi).catch(Zi):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return H(this,wu)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>Xn(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===nN||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.state.data===void 0?!1:this.getObserversCount()>0?this.observers.some(t=>Xn(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!l4(this.state.dataUpdatedAt,t)}onFocus(){var t,n;(t=this.observers.find(r=>r.shouldFetchOnWindowFocus()))==null||t.refetch({cancelRefetch:!1}),(n=H(this,Yr))==null||n.continue()}onOnline(){var t,n;(t=this.observers.find(r=>r.shouldFetchOnReconnect()))==null||t.refetch({cancelRefetch:!1}),(n=H(this,Yr))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),H(this,Gs).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){const n=this.observers.indexOf(t);n!==-1&&(this.observers.splice(n,1),this.observers.length||(H(this,Yr)&&(H(this,_u)||this.state.fetchStatus==="paused"&&this.state.status==="pending"?H(this,Yr).cancel({revert:!0}):H(this,Yr).cancelRetry()),this.scheduleGc()),H(this,Gs).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||nn(this,Co,Ia).call(this,{type:"invalidate"})}async fetch(t,n){var u,h,f,p;if(this.state.fetchStatus!=="idle"&&((u=H(this,Yr))==null?void 0:u.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(H(this,Yr)&&H(this,Ta))return H(this,Yr).continueRetry(),H(this,Ta)}if(t&&this.setOptions(t),!this.options.queryFn){const g=this.observers.find(x=>x.options.queryFn);g&&this.setOptions(g.options)}const r=new AbortController,i=g=>{Object.defineProperties(g,{[iN]:{value:r.signal,enumerable:!0},signal:{enumerable:!0,get:()=>(be(this,_u,!0),r.signal)}})},s=()=>{const g=d4(this.options,n),v=(()=>{const b={client:H(this,Su),queryKey:this.queryKey,meta:this.meta};return i(b),b})();return be(this,_u,!1),this.options.persister?this.options.persister(g,v,this):g(v)},a=(()=>{const g={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:H(this,Su),state:this.state,fetchFn:s};return i(g),g})();(h=H(this,_h)==="infinite"?WG(this.options.pages):this.options.behavior)==null||h.onFetch(a,this),be(this,Ch,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((f=a.fetchOptions)==null?void 0:f.meta))&&nn(this,Co,Ia).call(this,{type:"fetch",meta:(p=a.fetchOptions)==null?void 0:p.meta});const l=be(this,Yr,f4({initialPromise:n==null?void 0:n.initialPromise,fn:a.fetchFn,onCancel:g=>{g instanceof d_&&g.revert&&this.setState({...H(this,Ch),fetchStatus:"idle"}),r.abort()},onFail:(g,x)=>{nn(this,Co,Ia).call(this,{type:"failed",failureCount:g,error:x})},onPause:()=>{nn(this,Co,Ia).call(this,{type:"pause"})},onContinue:()=>{nn(this,Co,Ia).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0})),c=(async()=>{var g,x,v,b,y,w,S,C;try{const _=await l.promise;if(_===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(_),(x=(g=H(this,Gs).config).onSuccess)==null||x.call(g,_,this),(b=(v=H(this,Gs).config).onSettled)==null||b.call(v,_,this.state.error,this),_}catch(_){if(_ instanceof d_){if(_.silent){if(H(this,Yr)!==l&&H(this,Ta))return H(this,Ta);throw _}else if(_.revert){if(this.state.data===void 0)throw _;return this.state.data}}throw nn(this,Co,Ia).call(this,{type:"error",error:_}),(w=(y=H(this,Gs).config).onError)==null||w.call(y,_,this),(C=(S=H(this,Gs).config).onSettled)==null||C.call(S,this.state.data,_,this),_}finally{H(this,Yr)===l&&(be(this,Yr,void 0),be(this,Ta,void 0)),this.scheduleGc()}})();return be(this,Ta,c),l.start(),c}},_h=new WeakMap,wu=new WeakMap,Ch=new WeakMap,Gs=new WeakMap,Su=new WeakMap,Yr=new WeakMap,Ta=new WeakMap,pg=new WeakMap,_u=new WeakMap,Co=new WeakSet,Ia=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...g4(r.data,this.options),fetchMeta:t.meta??null};case"success":const i={...r,...TM(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return be(this,Ch,t.manual?i:void 0),i;case"error":const s=t.error;return{...r,error:s,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),Ar.batch(()=>{this.observers.slice().forEach(r=>{r.onQueryUpdate()}),H(this,Gs).notify({query:this,type:"updated",action:t})})},q5);function g4(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:h4(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function TM(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function AM(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Ki,mn,mg,Gi,Cu,kh,Aa,gg,Nh,Eh,ku,Nu,Gl,jh,kn,Pp,f_,p_,m_,g_,v_,x_,b_,y_,U5,v4=(U5=class extends wf{constructor(t,n){super();Ve(this,kn);Ve(this,Ki);Ve(this,mn);Ve(this,mg);Ve(this,Gi);Ve(this,Cu);Ve(this,kh);Ve(this,Aa);Ve(this,gg);Ve(this,Nh);Ve(this,Eh);Ve(this,ku);Ve(this,Nu);Ve(this,Gl);Ve(this,jh,new Set);this.options=n,be(this,Ki,t),be(this,Aa,null),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(H(this,mn).addObserver(this),DM(H(this,mn),this.options)?nn(this,kn,Pp).call(this):this.updateResult(),nn(this,kn,v_).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return w_(H(this,mn),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return w_(H(this,mn),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,nn(this,kn,x_).call(this),nn(this,kn,b_).call(this),H(this,mn).removeObserver(this)}setOptions(t){const n=this.options,r=H(this,mn);if(this.options=H(this,Ki).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Xn(this.options.enabled,H(this,mn))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");nn(this,kn,y_).call(this),H(this,mn).setOptions(this.options),n._defaulted&&!zv(this.options,n)&&H(this,Ki).getQueryCache().notify({type:"observerOptionsUpdated",query:H(this,mn),observer:this});const i=this.hasListeners();i&&LM(H(this,mn),r,this.options,n)&&nn(this,kn,Pp).call(this),this.updateResult(),i&&(H(this,mn)!==r||Xn(this.options.enabled,H(this,mn))!==Xn(n.enabled,H(this,mn))||Xn(this.options.staleTime,H(this,mn))!==Xn(n.staleTime,H(this,mn)))&&nn(this,kn,p_).call(this);const s=nn(this,kn,m_).call(this);i&&(H(this,mn)!==r||Xn(this.options.enabled,H(this,mn))!==Xn(n.enabled,H(this,mn))||s!==H(this,Gl))&&nn(this,kn,g_).call(this,s)}getOptimisticResult(t){const n=H(this,Ki).getQueryCache().build(H(this,Ki),t),r=this.createResult(n,t);return zv(this.getCurrentResult(),r)||(be(this,Gi,r),be(this,kh,this.options),be(this,Cu,H(this,mn).state)),r}getCurrentResult(){return H(this,Gi)}trackResult(t,n){return new Proxy(t,{get:(r,i)=>(this.trackProp(i),n==null||n(i),Reflect.get(r,i))})}trackProp(t){H(this,jh).add(t)}getCurrentQuery(){return H(this,mn)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=H(this,Ki).defaultQueryOptions(t),r=H(this,Ki).getQueryCache().build(H(this,Ki),n);let i=()=>{},s;const o=new Promise(a=>{s=a,i=H(this,Ki).getQueryCache().subscribe(l=>{l.type==="updated"&&l.query.queryHash===r.queryHash&&r.state.data!==void 0&&(i(),a(this.createResult(r,n)))})});return Promise.race([r.fetch(n).then(()=>{const a=this.createResult(r,n);return s==null||s(a),a}).finally(()=>{i()}),o])}fetch(t){return nn(this,kn,Pp).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),H(this,Gi)))}createResult(t,n){var _;const r=H(this,mn),i=this.options,s=H(this,Gi),o=H(this,Cu),a=H(this,kh),l=t!==r?t.state:H(this,mg),{state:c}=t;let u={...c},h=!1,f;if(n._optimisticResults){const k=this.hasListeners(),j=!k&&DM(t,n),z=k&&LM(t,r,n,i);(j||z)&&(u={...u,...g4(c.data,t.options)}),n._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:p,errorUpdatedAt:g,status:x}=u;f=u.data;let v=!1;if(n.placeholderData!==void 0&&f===void 0&&x==="pending"){let k;s!=null&&s.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData)?(k=s.data,v=!0):k=typeof n.placeholderData=="function"?n.placeholderData((_=H(this,Eh))==null?void 0:_.state.data,H(this,Eh)):n.placeholderData,k!==void 0&&(x="success",f=u_(s==null?void 0:s.data,k,n),h=!0)}if(n.select&&f!==void 0&&!v)if(s&&f===(o==null?void 0:o.data)&&n.select===H(this,gg))f=H(this,Nh);else try{be(this,gg,n.select),f=n.select(f),f=u_(s==null?void 0:s.data,f,n),be(this,Nh,f),be(this,Aa,null)}catch(k){be(this,Aa,k)}else f===void 0&&be(this,Aa,null);H(this,Aa)&&(p=H(this,Aa),f=H(this,Nh),g=(s==null?void 0:s.error)===p?s.errorUpdatedAt:Date.now(),x="error",h=!1);const b=u.fetchStatus==="fetching",y=x==="pending",w=x==="error",S=y&&b,C=f!==void 0;return{status:x,fetchStatus:u.fetchStatus,isPending:y,isSuccess:x==="success",isError:w,isInitialLoading:S,isLoading:S,data:f,dataUpdatedAt:u.dataUpdatedAt,error:p,errorUpdatedAt:g,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:u.dataUpdateCount>l.dataUpdateCount||u.errorUpdateCount>l.errorUpdateCount,isFetching:b,isRefetching:b&&!y,isLoadingError:w&&!C,isPaused:u.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:w&&C,isStale:aN(t,n),refetch:this.refetch,isEnabled:Xn(n.enabled,t)!==!1}}updateResult(){const t=H(this,Gi),n=this.createResult(H(this,mn),this.options);if(be(this,Cu,H(this,mn).state),be(this,kh,this.options),H(this,Cu).data!==void 0&&be(this,Eh,H(this,mn)),zv(n,t))return;be(this,Gi,n);const i=(()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,o=typeof s=="function"?s():s;if(o==="all"||!o&&!H(this,jh).size||this.options.throwOnError&&H(this,Gi).error!==t.error)return!0;for(const a of o??H(this,jh))if(H(this,Gi)[a]!==t[a])return!0;return!1})();Ar.batch(()=>{i&&this.listeners.forEach(s=>{s(H(this,Gi))}),H(this,Ki).getQueryCache().notify({query:H(this,mn),type:"observerResultsUpdated"})})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&nn(this,kn,v_).call(this)}},Ki=new WeakMap,mn=new WeakMap,mg=new WeakMap,Gi=new WeakMap,Cu=new WeakMap,kh=new WeakMap,Aa=new WeakMap,gg=new WeakMap,Nh=new WeakMap,Eh=new WeakMap,ku=new WeakMap,Nu=new WeakMap,Gl=new WeakMap,jh=new WeakMap,kn=new WeakSet,Pp=function(t){nn(this,kn,y_).call(this);let n=H(this,mn).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Zi)),n},f_=function(t){return!sN()&&Xn(this.options.enabled,H(this,mn))!==!1&&a4(t)},p_=function(){nn(this,kn,x_).call(this);const t=Xn(this.options.staleTime,H(this,mn));if(H(this,Gi).isStale||!nn(this,kn,f_).call(this,t))return;const n=l4(H(this,Gi).dataUpdatedAt,t)+1;be(this,ku,du.setTimeout(()=>{H(this,Gi).isStale||this.updateResult()},n))},m_=function(){return Xn(this.options.refetchInterval,H(this,mn))??!1},g_=function(t){nn(this,kn,b_).call(this),be(this,Gl,t),!(H(this,Gl)===0||!nn(this,kn,f_).call(this,H(this,Gl)))&&be(this,Nu,du.setInterval(()=>{(this.options.refetchIntervalInBackground||oN.isFocused())&&nn(this,kn,Pp).call(this)},H(this,Gl)))},v_=function(){nn(this,kn,p_).call(this),nn(this,kn,g_).call(this,nn(this,kn,m_).call(this))},x_=function(){H(this,ku)!==void 0&&(du.clearTimeout(H(this,ku)),be(this,ku,void 0))},b_=function(){H(this,Nu)!==void 0&&(du.clearInterval(H(this,Nu)),be(this,Nu,void 0))},y_=function(){const t=H(this,Ki).getQueryCache().build(H(this,Ki),this.options);if(t===H(this,mn))return;const n=H(this,mn);be(this,mn,t),be(this,mg,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},U5);function GG(e,t){return Xn(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&Xn(t.retryOnMount,e)===!1)}function DM(e,t){return GG(e,t)||e.state.data!==void 0&&w_(e,t,t.refetchOnMount)}function w_(e,t,n){if(Xn(t.enabled,e)!==!1&&Xn(t.staleTime,e)!=="static"){const r=Xn(n,e);return r==="always"||r!==!1&&aN(e,t)}return!1}function LM(e,t,n,r){return(e!==t||Xn(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&aN(e,n)}function aN(e,t){return Xn(t.enabled,e)!==!1&&e.isStaleByTime(Xn(t.staleTime,e))}var YG=class extends v4{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type="infinite",super.setOptions(e)}getOptimisticResult(e){return e._type="infinite",super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){var p,g;const{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:s,isError:o,isRefetchError:a}=r,l=(g=(p=n.fetchMeta)==null?void 0:p.fetchMore)==null?void 0:g.direction,c=o&&l==="forward",u=i&&l==="forward",h=o&&l==="backward",f=i&&l==="backward";return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:qG(t,n.data),hasPreviousPage:UG(t,n.data),isFetchNextPageError:c,isFetchingNextPage:u,isFetchPreviousPageError:h,isFetchingPreviousPage:f,isRefetchError:a&&!c&&!h,isRefetching:s&&!u&&!f}}},vg,Qo,ji,Eu,ea,Il,K5,ZG=(K5=class extends p4{constructor(t){super();Ve(this,ea);Ve(this,vg);Ve(this,Qo);Ve(this,ji);Ve(this,Eu);be(this,vg,t.client),this.mutationId=t.mutationId,be(this,ji,t.mutationCache),be(this,Qo,[]),this.state=t.state||x4(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){H(this,Qo).includes(t)||(H(this,Qo).push(t),this.clearGcTimeout(),H(this,ji).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){be(this,Qo,H(this,Qo).filter(n=>n!==t)),this.scheduleGc(),H(this,ji).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){H(this,Qo).length||(this.state.status==="pending"?this.scheduleGc():H(this,ji).remove(this))}continue(){var t;return((t=H(this,Eu))==null?void 0:t.continue())??(this.state.status==="pending"?this.execute(this.state.variables):Promise.resolve())}async execute(t){var a,l,c,u,h,f,p,g,x,v,b,y,w,S,C,_,k,j;const n=()=>{nn(this,ea,Il).call(this,{type:"continue"})},r={client:H(this,vg),meta:this.options.meta,mutationKey:this.options.mutationKey},i=be(this,Eu,f4({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(z,N)=>{nn(this,ea,Il).call(this,{type:"failed",failureCount:z,error:N})},onPause:()=>{nn(this,ea,Il).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>H(this,ji).canRun(this)})),s=this.state.status==="pending",o=!i.canStart();try{if(s)n();else{nn(this,ea,Il).call(this,{type:"pending",variables:t,isPaused:o}),H(this,ji).config.onMutate&&await H(this,ji).config.onMutate(t,this,r);const N=await((l=(a=this.options).onMutate)==null?void 0:l.call(a,t,r));N!==this.state.context&&nn(this,ea,Il).call(this,{type:"pending",context:N,variables:t,isPaused:o})}this.state.isPaused&&i.canStart()&&n();const z=await i.start();return await((u=(c=H(this,ji).config).onSuccess)==null?void 0:u.call(c,z,t,this.state.context,this,r)),await((f=(h=this.options).onSuccess)==null?void 0:f.call(h,z,t,this.state.context,r)),await((g=(p=H(this,ji).config).onSettled)==null?void 0:g.call(p,z,null,this.state.variables,this.state.context,this,r)),await((v=(x=this.options).onSettled)==null?void 0:v.call(x,z,null,t,this.state.context,r)),nn(this,ea,Il).call(this,{type:"success",data:z}),z}catch(z){try{await((y=(b=H(this,ji).config).onError)==null?void 0:y.call(b,z,t,this.state.context,this,r))}catch(N){Promise.reject(N)}try{await((S=(w=this.options).onError)==null?void 0:S.call(w,z,t,this.state.context,r))}catch(N){Promise.reject(N)}try{await((_=(C=H(this,ji).config).onSettled)==null?void 0:_.call(C,void 0,z,this.state.variables,this.state.context,this,r))}catch(N){Promise.reject(N)}try{await((j=(k=this.options).onSettled)==null?void 0:j.call(k,void 0,z,t,this.state.context,r))}catch(N){Promise.reject(N)}throw nn(this,ea,Il).call(this,{type:"error",error:z}),z}finally{H(this,Eu)===i&&be(this,Eu,void 0),H(this,ji).runNext(this)}}},vg=new WeakMap,Qo=new WeakMap,ji=new WeakMap,Eu=new WeakMap,ea=new WeakSet,Il=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Ar.batch(()=>{H(this,Qo).forEach(r=>{r.onMutationUpdate(t)}),H(this,ji).notify({mutation:this,type:"updated",action:t})})},K5);function x4(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Yl,ko,xg,G5,XG=(G5=class extends wf{constructor(t={}){super();Ve(this,Yl);Ve(this,ko);Ve(this,xg);this.config=t,be(this,Yl,new Set),be(this,ko,new Map),be(this,xg,0)}build(t,n,r){const i=new ZG({client:t,mutationCache:this,mutationId:++j0(this,xg)._,options:t.defaultMutationOptions(n),state:r});return this.add(i),i}add(t){H(this,Yl).add(t);const n=M0(t);if(typeof n=="string"){const r=H(this,ko).get(n);r?r.push(t):H(this,ko).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(H(this,Yl).delete(t)){const n=M0(t);if(typeof n=="string"){const r=H(this,ko).get(n);if(r)if(r.length>1){const i=r.indexOf(t);i!==-1&&r.splice(i,1)}else r[0]===t&&H(this,ko).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){var r;const n=M0(t);if(typeof n=="string"){const i=(r=H(this,ko).get(n))==null?void 0:r.find(s=>s.state.status==="pending");return!i||i===t}else return!0}runNext(t){var r,i;const n=M0(t);return typeof n=="string"?((i=(r=H(this,ko).get(n))==null?void 0:r.find(s=>s!==t&&s.state.isPaused))==null?void 0:i.continue())??Promise.resolve():Promise.resolve()}clear(){Ar.batch(()=>{const t=this.getAll();H(this,Yl).clear(),H(this,ko).clear(),t.forEach(n=>{this.notify({type:"removed",mutation:n})})})}getAll(){return Array.from(H(this,Yl))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>RM(n,r))}findAll(t={}){return this.getAll().filter(n=>RM(t,n))}notify(t){Ar.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Ar.batch(()=>Promise.all(t.map(n=>n.continue().catch(Zi))))}},Yl=new WeakMap,ko=new WeakMap,xg=new WeakMap,G5);function M0(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Da,Zl,zi,bg,ca,Tp,S_,Y5,JG=(Y5=class extends wf{constructor(n,r){super();Ve(this,ca);Ve(this,Da);Ve(this,Zl);Ve(this,zi);Ve(this,bg);be(this,Da,n),this.setOptions(r),this.bindMethods(),nn(this,ca,Tp).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var i;const r=this.options;this.options=H(this,Da).defaultMutationOptions(n),zv(this.options,r)||H(this,Da).getMutationCache().notify({type:"observerOptionsUpdated",mutation:H(this,zi),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&ed(r.mutationKey)!==ed(this.options.mutationKey)?this.reset():((i=H(this,zi))==null?void 0:i.state.status)==="pending"&&H(this,zi).setOptions(this.options)}onSubscribe(){this.listeners.size===1&&H(this,zi)&&(H(this,zi).addObserver(this),nn(this,ca,Tp).call(this))}onUnsubscribe(){var n;this.hasListeners()||(n=H(this,zi))==null||n.removeObserver(this)}onMutationUpdate(n){nn(this,ca,Tp).call(this),nn(this,ca,S_).call(this,n)}getCurrentResult(){return H(this,Zl)}reset(){var n;(n=H(this,zi))==null||n.removeObserver(this),be(this,zi,void 0),nn(this,ca,Tp).call(this),nn(this,ca,S_).call(this)}mutate(n,r){var i;return be(this,bg,r),(i=H(this,zi))==null||i.removeObserver(this),be(this,zi,H(this,Da).getMutationCache().build(H(this,Da),this.options)),H(this,zi).addObserver(this),H(this,zi).execute(n)}},Da=new WeakMap,Zl=new WeakMap,zi=new WeakMap,bg=new WeakMap,ca=new WeakSet,Tp=function(){var r;const n=((r=H(this,zi))==null?void 0:r.state)??x4();be(this,Zl,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},S_=function(n){Ar.batch(()=>{var i,s,o,a;const r=H(this,bg);if(r&&this.hasListeners()){const l=H(this,Zl).variables,c=H(this,Zl).context,u={client:H(this,Da),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(i=r.onSuccess)==null||i.call(r,n.data,l,c,u)}catch(h){Promise.reject(h)}try{(s=r.onSettled)==null||s.call(r,n.data,null,l,c,u)}catch(h){Promise.reject(h)}}else if((n==null?void 0:n.type)==="error"){try{(o=r.onError)==null||o.call(r,n.error,l,c,u)}catch(h){Promise.reject(h)}try{(a=r.onSettled)==null||a.call(r,void 0,n.error,l,c,u)}catch(h){Promise.reject(h)}}}this.listeners.forEach(l=>{l(H(this,Zl))})})},Y5),ta,Z5,QG=(Z5=class extends wf{constructor(t={}){super();Ve(this,ta);this.config=t,be(this,ta,new Map)}build(t,n,r){const i=n.queryKey,s=n.queryHash??tN(i,n);let o=this.get(s);return o||(o=new KG({client:t,queryKey:i,queryHash:s,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(i)}),this.add(o)),o}add(t){H(this,ta).has(t.queryHash)||(H(this,ta).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){H(this,ta).get(t.queryHash)===t&&(t.destroy(),H(this,ta).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Ar.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return H(this,ta).get(t)}getAll(){return[...H(this,ta).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>IM(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>IM(t,r)):n}notify(t){Ar.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Ar.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Ar.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},ta=new WeakMap,Z5),sr,Xl,Jl,zh,Mh,Ql,$h,Ih,X5,eY=(X5=class{constructor(e={}){Ve(this,sr);Ve(this,Xl);Ve(this,Jl);Ve(this,zh);Ve(this,Mh);Ve(this,Ql);Ve(this,$h);Ve(this,Ih);be(this,sr,e.queryCache||new QG),be(this,Xl,e.mutationCache||new XG),be(this,Jl,e.defaultOptions||{}),be(this,zh,new Map),be(this,Mh,new Map),be(this,Ql,0)}mount(){j0(this,Ql)._++,H(this,Ql)===1&&(be(this,$h,oN.subscribe(async e=>{e&&(await this.resumePausedMutations(),H(this,sr).onFocus())})),be(this,Ih,xx.subscribe(async e=>{e&&(await this.resumePausedMutations(),H(this,sr).onOnline())})))}unmount(){var e,t;j0(this,Ql)._--,H(this,Ql)===0&&((e=H(this,$h))==null||e.call(this),be(this,$h,void 0),(t=H(this,Ih))==null||t.call(this),be(this,Ih,void 0))}isFetching(e){return H(this,sr).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return H(this,Xl).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=H(this,sr).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=H(this,sr).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Xn(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return H(this,sr).findAll(e).map(({queryKey:t,state:n})=>[t,n.data])}setQueryData(e,t,n){var o;const r=this.defaultQueryOptions({queryKey:e}),i=(o=H(this,sr).get(r.queryHash))==null?void 0:o.state.data,s=RG(t,i);if(s!==void 0)return H(this,sr).build(this,r).setData(s,{...n,manual:!0})}setQueriesData(e,t,n){return Ar.batch(()=>H(this,sr).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=H(this,sr).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=H(this,sr);Ar.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=H(this,sr);return Ar.batch(()=>{const r=n.findAll(e),i=new Set(r);return r.forEach(s=>{s.reset()}),this.refetchQueries({type:"active",predicate:s=>i.has(s)},t)})}cancelQueries(e,t={}){const n={revert:!0,...t},r=Ar.batch(()=>H(this,sr).findAll(e).map(i=>i.cancel(n)));return Promise.all(r).then(Zi).catch(Zi)}invalidateQueries(e,t={}){return Ar.batch(()=>(H(this,sr).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=Ar.batch(()=>H(this,sr).findAll(e).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let s=i.fetch(void 0,n);const o=i.state.fetchStatus==="paused";return(!n.throwOnError||o)&&(s=s.catch(Zi)),o?Promise.resolve():s}));return Promise.all(r).then(Zi)}async query(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=H(this,sr).build(this,t),r=n.isStaleByTime(Xn(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=H(this,sr).build(this,t);return n.isStaleByTime(Xn(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Zi).catch(Zi)}infiniteQuery(e){return e._type="infinite",this.query(e)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Zi).catch(Zi)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return xx.isOnline()?H(this,Xl).resumePausedMutations():Promise.resolve()}getQueryCache(){return H(this,sr)}getMutationCache(){return H(this,Xl)}getDefaultOptions(){return H(this,Jl)}setDefaultOptions(e){be(this,Jl,e)}setQueryDefaults(e,t){H(this,zh).set(ed(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...H(this,zh).values()],n={};return t.forEach(r=>{Qh(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){H(this,Mh).set(ed(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...H(this,Mh).values()],n={};return t.forEach(r=>{Qh(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...H(this,Jl).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=tN(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===nN&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...H(this,Jl).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){H(this,sr).clear(),H(this,Xl).clear()}},sr=new WeakMap,Xl=new WeakMap,Jl=new WeakMap,zh=new WeakMap,Mh=new WeakMap,Ql=new WeakMap,$h=new WeakMap,Ih=new WeakMap,X5);const b4=m.createContext(!1),tY=()=>m.useContext(b4);b4.Provider;function nY(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}const rY=m.createContext(nY()),iY=()=>m.useContext(rY),sY=(e,t,n)=>{const r=(n==null?void 0:n.state.status)==="error"&&typeof e.throwOnError=="function"?rN(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},oY=e=>{m.useEffect(()=>{e.clearReset()},[e])},aY=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||rN(n,[e.error,r])),lY=e=>{if(e.suspense){const n=i=>i==="static"?i:Math.max(i??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...i)=>n(r(...i)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},cY=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,uY=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function y4(e,t,n){const r=tY(),i=iY(),s=Ln(),o=s.defaultQueryOptions(e),a=s.getQueryCache().get(o.queryHash),l=e.subscribed!==!1;o._optimisticResults=r?"isRestoring":l?"optimistic":void 0,lY(o),sY(o,i,a),oY(i);const[c]=m.useState(()=>new t(s,o)),u=c.getOptimisticResult(o);m.useEffect(()=>{c.setOptions(o)},[o,c]);const h=!r&&l;if(m.useSyncExternalStore(m.useCallback(f=>{const p=h?c.subscribe(Ar.batchCalls(f)):Zi;return c.updateResult(),p},[c,h]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),cY(o,u))throw uY(o,c,i);if(aY({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:a,suspense:o.suspense}))throw u.error;return o.notifyOnChangeProps?u:c.trackResult(u)}function Et(e,t){return y4(e,v4)}function yt(e,t){const n=Ln(),[r]=m.useState(()=>new JG(n,e));m.useEffect(()=>{r.setOptions(e)},[r,e]);const i=m.useSyncExternalStore(m.useCallback(o=>r.subscribe(Ar.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),s=m.useCallback((...o)=>{r.mutate(o[0],o[1]).catch(Zi)},[r]);if(i.error&&rN(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:s,mutateAsync:i.mutate}}function dY(e,t){return y4(e,YG)}const hY="modulepreload",fY=function(e){return"/"+e},FM={},w4=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){let o=function(c){return Promise.all(c.map(u=>Promise.resolve(u).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=o(n.map(c=>{if(c=fY(c),c in FM)return;FM[c]=!0;const u=c.endsWith(".css"),h=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${h}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":hY,u||(f.as="script"),f.crossOrigin="",f.href=c,l&&f.setAttribute("nonce",l),document.head.appendChild(f),u)return new Promise((p,g)=>{f.addEventListener("load",p),f.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${c}`)))})}))}function s(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return i.then(o=>{for(const a of o||[])a.status==="rejected"&&s(a.reason);return t().catch(s)})};function lN({open:e,children:t,ms:n=180}){const r=m.useRef(t),[i,s]=m.useState(e);return e&&(r.current=t),m.useEffect(()=>{if(e){s(!0);return}const o=window.setTimeout(()=>s(!1),n);return()=>window.clearTimeout(o)},[e,n]),!e&&!i?null:d.jsx("div",{style:{display:"contents"},...e?{}:{"data-closing":""},children:e?t:r.current})}let Bl=null;const bx=new Set,pY=e=>(bx.add(e),()=>{bx.delete(e)}),BM=()=>Bl;function xr(e,t){if(!((Bl==null?void 0:Bl.kind)===e&&Bl.sessionId===(t==null?void 0:t.sessionId))){Bl={kind:e,...t!=null&&t.sessionId?{sessionId:t.sessionId}:{}};for(const n of bx)n()}}function Ni(){if(Bl!==null){Bl=null;for(const e of bx)e()}}function mY(){return m.useSyncExternalStore(pY,BM,BM)}function gY({dialogs:e}){const t=mY();return d.jsx(d.Fragment,{children:Object.keys(e).map(n=>{const r=(t==null?void 0:t.kind)===n,i=e[n],s=r?typeof i=="function"?i(t.sessionId):i:null;return d.jsx(lN,{open:r,children:s},n)})})}const vY=e=>(t,n)=>{const r=m.useRef(!1);e(()=>()=>{r.current=!1},[]),e(()=>{if(!r.current)r.current=!0;else return t()},n)},iu=e=>typeof e=="function",cN=e=>typeof e=="number"&&!Number.isNaN(e),xY=e=>typeof e>"u",bY=e=>e!=null,yY=e=>bY(e)&&iu(e.then),bn=e=>{const t=m.useRef(e);t.current=m.useMemo(()=>e,[e]);const n=m.useRef(void 0);return n.current||(n.current=function(...r){return t.current.apply(this,r)}),n.current},Pu=vY(m.useEffect);function HM(e,t){if(e===t)return!0;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function Lg(e){const t=m.useRef(e);return t.current=e,t}const Fg=e=>{const t=Lg(e);m.useEffect(()=>()=>{t.current()},[])};var v1,VM;function uN(){if(VM)return v1;VM=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return v1=e,v1}var x1,WM;function wY(){if(WM)return x1;WM=1;var e=typeof z0=="object"&&z0&&z0.Object===Object&&z0;return x1=e,x1}var b1,qM;function S4(){if(qM)return b1;qM=1;var e=wY(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return b1=n,b1}var y1,UM;function SY(){if(UM)return y1;UM=1;var e=S4(),t=function(){return e.Date.now()};return y1=t,y1}var w1,KM;function _Y(){if(KM)return w1;KM=1;var e=/\s/;function t(n){for(var r=n.length;r--&&e.test(n.charAt(r)););return r}return w1=t,w1}var S1,GM;function CY(){if(GM)return S1;GM=1;var e=_Y(),t=/^\s+/;function n(r){return r&&r.slice(0,e(r)+1).replace(t,"")}return S1=n,S1}var _1,YM;function _4(){if(YM)return _1;YM=1;var e=S4(),t=e.Symbol;return _1=t,_1}var C1,ZM;function kY(){if(ZM)return C1;ZM=1;var e=_4(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,i=e?e.toStringTag:void 0;function s(o){var a=n.call(o,i),l=o[i];try{o[i]=void 0;var c=!0}catch{}var u=r.call(o);return c&&(a?o[i]=l:delete o[i]),u}return C1=s,C1}var k1,XM;function NY(){if(XM)return k1;XM=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return k1=n,k1}var N1,JM;function EY(){if(JM)return N1;JM=1;var e=_4(),t=kY(),n=NY(),r="[object Null]",i="[object Undefined]",s=e?e.toStringTag:void 0;function o(a){return a==null?a===void 0?i:r:s&&s in Object(a)?t(a):n(a)}return N1=o,N1}var E1,QM;function jY(){if(QM)return E1;QM=1;function e(t){return t!=null&&typeof t=="object"}return E1=e,E1}var j1,e$;function zY(){if(e$)return j1;e$=1;var e=EY(),t=jY(),n="[object Symbol]";function r(i){return typeof i=="symbol"||t(i)&&e(i)==n}return j1=r,j1}var z1,t$;function MY(){if(t$)return z1;t$=1;var e=CY(),t=uN(),n=zY(),r=NaN,i=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,o=/^0o[0-7]+$/i,a=parseInt;function l(c){if(typeof c=="number")return c;if(n(c))return r;if(t(c)){var u=typeof c.valueOf=="function"?c.valueOf():c;c=t(u)?u+"":u}if(typeof c!="string")return c===0?c:+c;c=e(c);var h=s.test(c);return h||o.test(c)?a(c.slice(2),h?2:8):i.test(c)?r:+c}return z1=l,z1}var M1,n$;function C4(){if(n$)return M1;n$=1;var e=uN(),t=SY(),n=MY(),r="Expected a function",i=Math.max,s=Math.min;function o(a,l,c){var u,h,f,p,g,x,v=0,b=!1,y=!1,w=!0;if(typeof a!="function")throw new TypeError(r);l=n(l)||0,e(c)&&(b=!!c.leading,y="maxWait"in c,f=y?i(n(c.maxWait)||0,l):f,w="trailing"in c?!!c.trailing:w);function S(R){var E=u,M=h;return u=h=void 0,v=R,p=a.apply(M,E),p}function C(R){return v=R,g=setTimeout(j,l),b?S(R):p}function _(R){var E=R-x,M=R-v,P=l-E;return y?s(P,f-M):P}function k(R){var E=R-x,M=R-v;return x===void 0||E>=l||E<0||y&&M>=f}function j(){var R=t();if(k(R))return z(R);g=setTimeout(j,_(R))}function z(R){return g=void 0,w&&u?S(R):(u=h=void 0,p)}function N(){g!==void 0&&clearTimeout(g),v=0,u=x=h=g=void 0}function I(){return g===void 0?p:z(t())}function $(){var R=t(),E=k(R);if(u=arguments,h=this,x=R,E){if(g===void 0)return C(x);if(y)return clearTimeout(g),g=setTimeout(j,l),S(x)}return g===void 0&&(g=setTimeout(j,l)),p}return $.cancel=N,$.flush=I,$}return M1=o,M1}var $Y=C4();const IY=ts($Y),k4=!!(typeof window<"u"&&window.document&&window.document.createElement);var $1,r$;function RY(){if(r$)return $1;r$=1;var e=C4(),t=uN(),n="Expected a function";function r(i,s,o){var a=!0,l=!0;if(typeof i!="function")throw new TypeError(n);return t(o)&&(a="leading"in o?!!o.leading:a,l="trailing"in o?!!o.trailing:l),e(i,s,{leading:a,maxWait:s,trailing:l})}return $1=r,$1}var OY=RY();const PY=ts(OY),Db=e=>{m.useEffect(()=>{const t=e==null?void 0:e();if(!yY(t))return t},[])};function N4(e,t){if(!k4)return;if(!e)return t;let n;return iu(e)?n=e():"current"in e?n=e.current:n=e,n}const TY=e=>(n,r,i)=>{const s=m.useRef(!1),o=m.useRef([]),a=m.useRef([]),l=m.useRef(void 0);e(()=>{var c;const h=(Array.isArray(i)?i:[i]).map(f=>N4(f));if(!s.current){s.current=!0,o.current=h,a.current=r,l.current=n();return}(h.length!==o.current.length||!HM(o.current,h)||!HM(a.current,r))&&((c=l.current)===null||c===void 0||c.call(l),o.current=h,a.current=r,l.current=n())}),Fg(()=>{var c;(c=l.current)===null||c===void 0||c.call(l),s.current=!1})},AY=TY(m.useEffect);var Mv={exports:{}},DY=Mv.exports,i$;function E4(){return i$||(i$=1,(function(e,t){(function(n,r){e.exports=r()})(DY,(function(){var n=1e3,r=6e4,i=36e5,s="millisecond",o="second",a="minute",l="hour",c="day",u="week",h="month",f="quarter",p="year",g="date",x="Invalid Date",v=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,b=/\[([^\]]+)]|YYYY|YY|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,y={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(E){var M=["th","st","nd","rd"],P=E%100;return"["+E+(M[(P-20)%10]||M[P]||M[0])+"]"}},w=function(E,M,P){var A=String(E);return!A||A.length>=M?E:""+Array(M+1-A.length).join(P)+E},S={s:w,z:function(E){var M=-E.utcOffset(),P=Math.abs(M),A=Math.floor(P/60),D=P%60;return(M<=0?"+":"-")+w(A,2,"0")+":"+w(D,2,"0")},m:function E(M,P){if(M.date()<P.date())return-E(P,M);var A=12*(P.year()-M.year())+(P.month()-M.month()),D=M.clone().add(A,h),F=P-D<0,O=M.clone().add(A+(F?-1:1),h);return+(-(A+(P-D)/(F?D-O:O-D))||0)},a:function(E){return E<0?Math.ceil(E)||0:Math.floor(E)},p:function(E){return{M:h,y:p,w:u,d:c,D:g,h:l,m:a,s:o,ms:s,Q:f}[E]||String(E||"").toLowerCase().replace(/s$/,"")},u:function(E){return E===void 0}},C="en",_={};_[C]=y;var k="$isDayjsObject",j=function(E){return E instanceof $||!(!E||!E[k])},z=function E(M,P,A){var D;if(!M)return C;if(typeof M=="string"){var F=M.toLowerCase();_[F]&&(D=F),P&&(_[F]=P,D=F);var O=M.split("-");if(!D&&O.length>1)return E(O[0])}else{var B=M.name;_[B]=M,D=B}return!A&&D&&(C=D),D||!A&&C},N=function(E,M){if(j(E))return E.clone();var P=typeof M=="object"?M:{};return P.date=E,P.args=arguments,new $(P)},I=S;I.l=z,I.i=j,I.w=function(E,M){return N(E,{locale:M.$L,utc:M.$u,x:M.$x,$offset:M.$offset})};var $=(function(){function E(P){this.$L=z(P.locale,null,!0),this.parse(P),this.$x=this.$x||P.x||{},this[k]=!0}var M=E.prototype;return M.parse=function(P){this.$d=(function(A){var D=A.date,F=A.utc;if(D===null)return new Date(NaN);if(I.u(D))return new Date;if(D instanceof Date)return new Date(D);if(typeof D=="string"&&!/Z$/i.test(D)){var O=D.match(v);if(O){var B=O[2]-1||0,V=(O[7]||"0").substring(0,3);return F?new Date(Date.UTC(O[1],B,O[3]||1,O[4]||0,O[5]||0,O[6]||0,V)):new Date(O[1],B,O[3]||1,O[4]||0,O[5]||0,O[6]||0,V)}}return new Date(D)})(P),this.init()},M.init=function(){var P=this.$d;this.$y=P.getFullYear(),this.$M=P.getMonth(),this.$D=P.getDate(),this.$W=P.getDay(),this.$H=P.getHours(),this.$m=P.getMinutes(),this.$s=P.getSeconds(),this.$ms=P.getMilliseconds()},M.$utils=function(){return I},M.isValid=function(){return this.$d.toString()!==x},M.isSame=function(P,A){var D=N(P);return this.startOf(A)<=D&&D<=this.endOf(A)},M.isAfter=function(P,A){return N(P)<this.startOf(A)},M.isBefore=function(P,A){return this.endOf(A)<N(P)},M.$g=function(P,A,D){return I.u(P)?this[A]:this.set(D,P)},M.unix=function(){return Math.floor(this.valueOf()/1e3)},M.valueOf=function(){return this.$d.getTime()},M.startOf=function(P,A){var D=this,F=!!I.u(A)||A,O=I.p(P),B=function(ae,ne){var re=I.w(D.$u?Date.UTC(D.$y,ne,ae):new Date(D.$y,ne,ae),D);return F?re:re.endOf(c)},V=function(ae,ne){return I.w(D.toDate()[ae].apply(D.toDate("s"),(F?[0,0,0,0]:[23,59,59,999]).slice(ne)),D)},T=this.$W,W=this.$M,L=this.$D,q="set"+(this.$u?"UTC":"");switch(O){case p:return F?B(1,0):B(31,11);case h:return F?B(1,W):B(0,W+1);case u:var X=this.$locale().weekStart||0,J=(T<X?T+7:T)-X;return B(F?L-J:L+(6-J),W);case c:case g:return V(q+"Hours",0);case l:return V(q+"Minutes",1);case a:return V(q+"Seconds",2);case o:return V(q+"Milliseconds",3);default:return this.clone()}},M.endOf=function(P){return this.startOf(P,!1)},M.$set=function(P,A){var D,F=I.p(P),O="set"+(this.$u?"UTC":""),B=(D={},D[c]=O+"Date",D[g]=O+"Date",D[h]=O+"Month",D[p]=O+"FullYear",D[l]=O+"Hours",D[a]=O+"Minutes",D[o]=O+"Seconds",D[s]=O+"Milliseconds",D)[F],V=F===c?this.$D+(A-this.$W):A;if(F===h||F===p){var T=this.clone().set(g,1);T.$d[B](V),T.init(),this.$d=T.set(g,Math.min(this.$D,T.daysInMonth())).$d}else B&&this.$d[B](V);return this.init(),this},M.set=function(P,A){return this.clone().$set(P,A)},M.get=function(P){return this[I.p(P)]()},M.add=function(P,A){var D,F=this;P=Number(P);var O=I.p(A),B=function(W){var L=N(F);return I.w(L.date(L.date()+Math.round(W*P)),F)};if(O===h)return this.set(h,this.$M+P);if(O===p)return this.set(p,this.$y+P);if(O===c)return B(1);if(O===u)return B(7);var V=(D={},D[a]=r,D[l]=i,D[o]=n,D)[O]||1,T=this.$d.getTime()+P*V;return I.w(T,this)},M.subtract=function(P,A){return this.add(-1*P,A)},M.format=function(P){var A=this,D=this.$locale();if(!this.isValid())return D.invalidDate||x;var F=P||"YYYY-MM-DDTHH:mm:ssZ",O=I.z(this),B=this.$H,V=this.$m,T=this.$M,W=D.weekdays,L=D.months,q=D.meridiem,X=function(ne,re,ie,G){return ne&&(ne[re]||ne(A,F))||ie[re].slice(0,G)},J=function(ne){return I.s(B%12||12,ne,"0")},ae=q||function(ne,re,ie){var G=ne<12?"AM":"PM";return ie?G.toLowerCase():G};return F.replace(b,(function(ne,re){return re||(function(ie){switch(ie){case"YY":return String(A.$y).slice(-2);case"YYYY":return I.s(A.$y,4,"0");case"M":return T+1;case"MM":return I.s(T+1,2,"0");case"MMM":return X(D.monthsShort,T,L,3);case"MMMM":return X(L,T);case"D":return A.$D;case"DD":return I.s(A.$D,2,"0");case"d":return String(A.$W);case"dd":return X(D.weekdaysMin,A.$W,W,2);case"ddd":return X(D.weekdaysShort,A.$W,W,3);case"dddd":return W[A.$W];case"H":return String(B);case"HH":return I.s(B,2,"0");case"h":return J(1);case"hh":return J(2);case"a":return ae(B,V,!0);case"A":return ae(B,V,!1);case"m":return String(V);case"mm":return I.s(V,2,"0");case"s":return String(A.$s);case"ss":return I.s(A.$s,2,"0");case"SSS":return I.s(A.$ms,3,"0");case"Z":return O}return null})(ne)||O.replace(":","")}))},M.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},M.diff=function(P,A,D){var F,O=this,B=I.p(A),V=N(P),T=(V.utcOffset()-this.utcOffset())*r,W=this-V,L=function(){return I.m(O,V)};switch(B){case p:F=L()/12;break;case h:F=L();break;case f:F=L()/3;break;case u:F=(W-T)/6048e5;break;case c:F=(W-T)/864e5;break;case l:F=W/i;break;case a:F=W/r;break;case o:F=W/n;break;default:F=W}return D?F:I.a(F)},M.daysInMonth=function(){return this.endOf(h).$D},M.$locale=function(){return _[this.$L]},M.locale=function(P,A){if(!P)return this.$L;var D=this.clone(),F=z(P,A,!0);return F&&(D.$L=F),D},M.clone=function(){return I.w(this.$d,this)},M.toDate=function(){return new Date(this.valueOf())},M.toJSON=function(){return this.isValid()?this.toISOString():null},M.toISOString=function(){return this.$d.toISOString()},M.toString=function(){return this.$d.toUTCString()},E})(),R=$.prototype;return N.prototype=R,[["$ms",s],["$s",o],["$m",a],["$H",l],["$W",c],["$M",h],["$y",p],["$D",g]].forEach((function(E){R[E[1]]=function(M){return this.$g(M,E[0],E[1])}})),N.extend=function(E,M){return E.$i||(E(M,$,N),E.$i=!0),N},N.locale=z,N.isDayjs=j,N.unix=function(E){return N(1e3*E)},N.en=_[C],N.Ls=_,N.p={},N}))})(Mv)),Mv.exports}var LY=E4();const Tr=ts(LY),I1=e=>{if(!e)return 0;const t=Tr(e).valueOf()-Date.now();return t<0?0:t},FY=e=>({days:Math.floor(e/864e5),hours:Math.floor(e/36e5)%24,minutes:Math.floor(e/6e4)%60,seconds:Math.floor(e/1e3)%60,milliseconds:Math.floor(e)%1e3}),BY=(e={})=>{const{leftTime:t,targetDate:n,interval:r=1e3,onEnd:i}=e||{},s=m.useMemo(()=>cN(t)&&t>0?Date.now()+t:void 0,[t]),o="leftTime"in e?s:n,[a,l]=m.useState(()=>I1(o)),c=Lg(i);m.useEffect(()=>{if(!o){l(0);return}l(I1(o));const h=setInterval(()=>{var f;const p=I1(o);l(p),p===0&&(clearInterval(h),(f=c.current)===null||f===void 0||f.call(c))},r);return()=>clearInterval(h)},[o,r]);const u=m.useMemo(()=>FY(a),[a]);return[a,u]};function HY(){const e=(typeof global>"u"?"undefined":typeof global)=="object"&&global&&global.Object===Object&&global,t=typeof self=="object"&&self&&self.Object===Object&&self;return e||t}HY()||(global.Date=Date);function VY(e,t){var n;const r=Lg(e),i=(n=t==null?void 0:t.wait)!==null&&n!==void 0?n:1e3,s=m.useMemo(()=>IY((...o)=>r.current(...o),i,t),[]);return Fg(()=>{s.cancel()}),{run:s,cancel:s.cancel,flush:s.flush}}function WY(e,t){const[n,r]=m.useState(e),{run:i}=VY(()=>{r(e)},t);return m.useEffect(()=>{i()},[e]),n}function yr(e,t,n={}){const{enable:r=!0}=n,i=Lg(t);AY(()=>{if(!r)return;const s=N4(n.target,window);if(!(s!=null&&s.addEventListener))return;const o=l=>i.current(l),a=Array.isArray(e)?e:[e];return a.forEach(l=>{s.addEventListener(l,o,{capture:n.capture,once:n.once,passive:n.passive})}),()=>{a.forEach(l=>{s.removeEventListener(l,o,{capture:n.capture})})}},[e,n.capture,n.once,n.passive,r],n.target)}var j4=(function(){if(typeof Map<"u")return Map;function e(t,n){var r=-1;return t.some(function(i,s){return i[0]===n?(r=s,!0):!1}),r}return(function(){function t(){this.__entries__=[]}return Object.defineProperty(t.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),t.prototype.get=function(n){var r=e(this.__entries__,n),i=this.__entries__[r];return i&&i[1]},t.prototype.set=function(n,r){var i=e(this.__entries__,n);~i?this.__entries__[i][1]=r:this.__entries__.push([n,r])},t.prototype.delete=function(n){var r=this.__entries__,i=e(r,n);~i&&r.splice(i,1)},t.prototype.has=function(n){return!!~e(this.__entries__,n)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(n,r){r===void 0&&(r=null);for(var i=0,s=this.__entries__;i<s.length;i++){var o=s[i];n.call(r,o[1],o[0])}},t})()})(),__=typeof window<"u"&&typeof document<"u"&&window.document===document,yx=(function(){return typeof global<"u"&&global.Math===Math?global:typeof self<"u"&&self.Math===Math?self:typeof window<"u"&&window.Math===Math?window:Function("return this")()})(),qY=(function(){return typeof requestAnimationFrame=="function"?requestAnimationFrame.bind(yx):function(e){return setTimeout(function(){return e(Date.now())},1e3/60)}})(),UY=2;function KY(e,t){var n=!1,r=!1,i=0;function s(){n&&(n=!1,e()),r&&a()}function o(){qY(s)}function a(){var l=Date.now();if(n){if(l-i<UY)return;r=!0}else n=!0,r=!1,setTimeout(o,t);i=l}return a}var GY=20,YY=["top","right","bottom","left","width","height","size","weight"],ZY=typeof MutationObserver<"u",XY=(function(){function e(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=KY(this.refresh.bind(this),GY)}return e.prototype.addObserver=function(t){~this.observers_.indexOf(t)||this.observers_.push(t),this.connected_||this.connect_()},e.prototype.removeObserver=function(t){var n=this.observers_,r=n.indexOf(t);~r&&n.splice(r,1),!n.length&&this.connected_&&this.disconnect_()},e.prototype.refresh=function(){var t=this.updateObservers_();t&&this.refresh()},e.prototype.updateObservers_=function(){var t=this.observers_.filter(function(n){return n.gatherActive(),n.hasActive()});return t.forEach(function(n){return n.broadcastActive()}),t.length>0},e.prototype.connect_=function(){!__||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),ZY?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},e.prototype.disconnect_=function(){!__||!this.connected_||(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},e.prototype.onTransitionEnd_=function(t){var n=t.propertyName,r=n===void 0?"":n,i=YY.some(function(s){return!!~r.indexOf(s)});i&&this.refresh()},e.getInstance=function(){return this.instance_||(this.instance_=new e),this.instance_},e.instance_=null,e})(),z4=(function(e,t){for(var n=0,r=Object.keys(t);n<r.length;n++){var i=r[n];Object.defineProperty(e,i,{value:t[i],enumerable:!1,writable:!1,configurable:!0})}return e}),ef=(function(e){var t=e&&e.ownerDocument&&e.ownerDocument.defaultView;return t||yx}),M4=Lb(0,0,0,0);function wx(e){return parseFloat(e)||0}function s$(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return t.reduce(function(r,i){var s=e["border-"+i+"-width"];return r+wx(s)},0)}function JY(e){for(var t=["top","right","bottom","left"],n={},r=0,i=t;r<i.length;r++){var s=i[r],o=e["padding-"+s];n[s]=wx(o)}return n}function QY(e){var t=e.getBBox();return Lb(0,0,t.width,t.height)}function eZ(e){var t=e.clientWidth,n=e.clientHeight;if(!t&&!n)return M4;var r=ef(e).getComputedStyle(e),i=JY(r),s=i.left+i.right,o=i.top+i.bottom,a=wx(r.width),l=wx(r.height);if(r.boxSizing==="border-box"&&(Math.round(a+s)!==t&&(a-=s$(r,"left","right")+s),Math.round(l+o)!==n&&(l-=s$(r,"top","bottom")+o)),!nZ(e)){var c=Math.round(a+s)-t,u=Math.round(l+o)-n;Math.abs(c)!==1&&(a-=c),Math.abs(u)!==1&&(l-=u)}return Lb(i.left,i.top,a,l)}var tZ=(function(){return typeof SVGGraphicsElement<"u"?function(e){return e instanceof ef(e).SVGGraphicsElement}:function(e){return e instanceof ef(e).SVGElement&&typeof e.getBBox=="function"}})();function nZ(e){return e===ef(e).document.documentElement}function rZ(e){return __?tZ(e)?QY(e):eZ(e):M4}function iZ(e){var t=e.x,n=e.y,r=e.width,i=e.height,s=typeof DOMRectReadOnly<"u"?DOMRectReadOnly:Object,o=Object.create(s.prototype);return z4(o,{x:t,y:n,width:r,height:i,top:n,right:t+r,bottom:i+n,left:t}),o}function Lb(e,t,n,r){return{x:e,y:t,width:n,height:r}}var sZ=(function(){function e(t){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=Lb(0,0,0,0),this.target=t}return e.prototype.isActive=function(){var t=rZ(this.target);return this.contentRect_=t,t.width!==this.broadcastWidth||t.height!==this.broadcastHeight},e.prototype.broadcastRect=function(){var t=this.contentRect_;return this.broadcastWidth=t.width,this.broadcastHeight=t.height,t},e})(),oZ=(function(){function e(t,n){var r=iZ(n);z4(this,{target:t,contentRect:r})}return e})(),aZ=(function(){function e(t,n,r){if(this.activeObservations_=[],this.observations_=new j4,typeof t!="function")throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=t,this.controller_=n,this.callbackCtx_=r}return e.prototype.observe=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element>"u"||!(Element instanceof Object))){if(!(t instanceof ef(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var n=this.observations_;n.has(t)||(n.set(t,new sZ(t)),this.controller_.addObserver(this),this.controller_.refresh())}},e.prototype.unobserve=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element>"u"||!(Element instanceof Object))){if(!(t instanceof ef(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var n=this.observations_;n.has(t)&&(n.delete(t),n.size||this.controller_.removeObserver(this))}},e.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},e.prototype.gatherActive=function(){var t=this;this.clearActive(),this.observations_.forEach(function(n){n.isActive()&&t.activeObservations_.push(n)})},e.prototype.broadcastActive=function(){if(this.hasActive()){var t=this.callbackCtx_,n=this.activeObservations_.map(function(r){return new oZ(r.target,r.broadcastRect())});this.callback_.call(t,n,t),this.clearActive()}},e.prototype.clearActive=function(){this.activeObservations_.splice(0)},e.prototype.hasActive=function(){return this.activeObservations_.length>0},e})(),$4=typeof WeakMap<"u"?new WeakMap:new j4,I4=(function(){function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var n=XY.getInstance(),r=new aZ(t,n,this);$4.set(this,r)}return e})();["observe","unobserve","disconnect"].forEach(function(e){I4.prototype[e]=function(){var t;return(t=$4.get(this))[e].apply(t,arguments)}});var lZ=(function(){return typeof yx.ResizeObserver<"u"?yx.ResizeObserver:I4})();const dN=(e,t,n={})=>{const r=bn(e),i=m.useRef(null),s=m.useCallback(()=>{i.current&&clearInterval(i.current)},[]);return m.useEffect(()=>{if(!(!cN(t)||t<0))return n.immediate&&r(),i.current=setInterval(r,t),s},[t,n.immediate]),s},o$="AHOOKS_SYNC_STORAGE_EVENT_NAME",cZ=e=>(n,r={})=>{let i;const{listenStorageChange:s=!1,getInitialValueInEffect:o=!1}=r,a=iu(r.serializer)?r.serializer:JSON.stringify,l=iu(r.deserializer)?r.deserializer:JSON.parse,c=iu(r.onError)?r.onError:console.error;try{i=e()}catch(y){c(y)}const u=()=>{try{const y=i==null?void 0:i.getItem(n);if(y)return l(y)}catch(y){c(y)}return h()};function h(){return iu(r.defaultValue)?r.defaultValue():r.defaultValue}const[f,p]=m.useState(()=>o?h():u());Db(()=>{o&&p(u())});const g=m.useRef(f);g.current=f,Pu(()=>{const y=u();Object.is(y,g.current)||(g.current=y,p(y))},[n]);const x=y=>{const w=g.current,S=iu(y)?y(w):y;if(!Object.is(S,w)){s||(g.current=S,p(S));try{let C;const _=i==null?void 0:i.getItem(n);xY(S)?(C=null,i==null||i.removeItem(n)):(C=a(S),i==null||i.setItem(n,C)),dispatchEvent(new CustomEvent(o$,{detail:{key:n,newValue:C,oldValue:_,storageArea:i}}))}catch(C){c(C)}}},v=y=>{if(y.key!==n||y.storageArea!==i)return;const w=u();Object.is(w,g.current)||(g.current=w,p(w))},b=y=>{v(y.detail)};return yr("storage",v,{enable:s}),yr(o$,b,{enable:s}),[f,bn(x)]},th=cZ(()=>k4?localStorage:void 0);function uZ(e,t){var n;const r=Lg(e),i=(n=t==null?void 0:t.wait)!==null&&n!==void 0?n:1e3,s=m.useMemo(()=>PY((...o)=>r.current(...o),i,t),[]);return Fg(()=>{s.cancel()}),{run:s,cancel:s.cancel,flush:s.flush}}function dZ(e,t){const[n,r]=m.useState(e),{run:i}=uZ(()=>{r(e)},t);return m.useEffect(()=>{i()},[e]),n}const hZ=(e,t)=>{const n=bn(e),r=m.useRef(null),i=m.useCallback(()=>{r.current&&clearTimeout(r.current)},[]);return m.useEffect(()=>{if(!(!cN(t)||t<0))return r.current=setTimeout(n,t),i},[t]),i};/**
3
3
  * @license lucide-react v1.72.0 - ISC
4
4
  *
5
5
  * This source code is licensed under the ISC license.
@@ -847,7 +847,7 @@ html body {
847
847
  * Copyright (c) Paul O'Shannessy
848
848
  * SPDX-License-Identifier: ISC
849
849
  */var Fpe={L:oh.QrCode.Ecc.LOW,M:oh.QrCode.Ecc.MEDIUM,Q:oh.QrCode.Ecc.QUARTILE,H:oh.QrCode.Ecc.HIGH},FH=128,BH="L",HH="#FFFFFF",VH="#000000",WH=!1,qH=1,Bpe=4,Hpe=0,Vpe=.1;function UH(e,t=0){const n=[];return e.forEach(function(r,i){let s=null;r.forEach(function(o,a){if(!o&&s!==null){n.push(`M${s+t} ${i+t}h${a-s}v1H${s+t}z`),s=null;return}if(a===r.length-1){if(!o)return;s===null?n.push(`M${a+t},${i+t} h1v1H${a+t}z`):n.push(`M${s+t},${i+t} h${a+1-s}v1H${s+t}z`);return}o&&s===null&&(s=a)})}),n.join("")}function KH(e,t){return e.slice().map((n,r)=>r<t.y||r>=t.y+t.h?n:n.map((i,s)=>s<t.x||s>=t.x+t.w?i:!1))}function Wpe(e,t,n,r){if(r==null)return null;const i=e.length+n*2,s=Math.floor(t*Vpe),o=i/t,a=(r.width||s)*o,l=(r.height||s)*o,c=r.x==null?e.length/2-a/2:r.x*o,u=r.y==null?e.length/2-l/2:r.y*o,h=r.opacity==null?1:r.opacity;let f=null;if(r.excavate){let g=Math.floor(c),x=Math.floor(u),v=Math.ceil(a+c-g),b=Math.ceil(l+u-x);f={x:g,y:x,w:v,h:b}}const p=r.crossOrigin;return{x:c,y:u,h:l,w:a,excavation:f,opacity:h,crossOrigin:p}}function qpe(e,t){return t!=null?Math.max(Math.floor(t),0):e?Bpe:Hpe}function GH({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:s,size:o,boostLevel:a}){let l=Ne.useMemo(()=>{const g=(Array.isArray(e)?e:[e]).reduce((x,v)=>(x.push(...oh.QrSegment.makeSegments(v)),x),[]);return oh.QrCode.encodeSegments(g,Fpe[t],n,void 0,void 0,a)},[e,t,n,a]);const{cells:c,margin:u,numCells:h,calculatedImageSettings:f}=Ne.useMemo(()=>{let p=l.getModules();const g=qpe(r,i),x=p.length+g*2,v=Wpe(p,o,g,s);return{cells:p,margin:g,numCells:x,calculatedImageSettings:v}},[l,o,s,r,i]);return{qrcode:l,margin:u,cells:c,numCells:h,calculatedImageSettings:f}}var Upe=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),Kpe=Ne.forwardRef(function(t,n){const r=t,{value:i,size:s=FH,level:o=BH,bgColor:a=HH,fgColor:l=VH,includeMargin:c=WH,minVersion:u=qH,boostLevel:h,marginSize:f,imageSettings:p}=r,x=KC(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:v}=x,b=KC(x,["style"]),y=p==null?void 0:p.src,w=Ne.useRef(null),S=Ne.useRef(null),C=Ne.useCallback(E=>{w.current=E,typeof n=="function"?n(E):n&&(n.current=E)},[n]),[_,k]=Ne.useState(!1),{margin:j,cells:z,numCells:N,calculatedImageSettings:I}=GH({value:i,level:o,minVersion:u,boostLevel:h,includeMargin:c,marginSize:f,imageSettings:p,size:s});Ne.useEffect(()=>{if(w.current!=null){const E=w.current,M=E.getContext("2d");if(!M)return;let P=z;const A=S.current,D=I!=null&&A!==null&&A.complete&&A.naturalHeight!==0&&A.naturalWidth!==0;D&&I.excavation!=null&&(P=KH(z,I.excavation));const F=window.devicePixelRatio||1;E.height=E.width=s*F;const O=s/N*F;M.scale(O,O),M.fillStyle=a,M.fillRect(0,0,N,N),M.fillStyle=l,Upe?M.fill(new Path2D(UH(P,j))):z.forEach(function(B,V){B.forEach(function(T,W){T&&M.fillRect(W+j,V+j,1,1)})}),I&&(M.globalAlpha=I.opacity),D&&M.drawImage(A,I.x+j,I.y+j,I.w,I.h)}}),Ne.useEffect(()=>{k(!1)},[y]);const $=UC({height:s,width:s},v);let R=null;return y!=null&&(R=Ne.createElement("img",{src:y,key:y,style:{display:"none"},onLoad:()=>{k(!0)},ref:S,crossOrigin:I==null?void 0:I.crossOrigin})),Ne.createElement(Ne.Fragment,null,Ne.createElement("canvas",UC({style:$,height:s,width:s,ref:C,role:"img"},b)),R)});Kpe.displayName="QRCodeCanvas";var zy=Ne.forwardRef(function(t,n){const r=t,{value:i,size:s=FH,level:o=BH,bgColor:a=HH,fgColor:l=VH,includeMargin:c=WH,minVersion:u=qH,boostLevel:h,title:f,marginSize:p,imageSettings:g}=r,x=KC(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:v,cells:b,numCells:y,calculatedImageSettings:w}=GH({value:i,level:o,minVersion:u,boostLevel:h,includeMargin:c,marginSize:p,imageSettings:g,size:s});let S=b,C=null;g!=null&&w!=null&&(w.excavation!=null&&(S=KH(b,w.excavation)),C=Ne.createElement("image",{href:g.src,height:w.h,width:w.w,x:w.x+v,y:w.y+v,preserveAspectRatio:"none",opacity:w.opacity,crossOrigin:w.crossOrigin}));const _=UH(S,v);return Ne.createElement("svg",UC({height:s,width:s,viewBox:`0 0 ${y} ${y}`,ref:n,role:"img"},x),!!f&&Ne.createElement("title",null,f),Ne.createElement("path",{fill:a,d:`M0,0 h${y}v${y}H0z`,shapeRendering:"crispEdges"}),Ne.createElement("path",{fill:l,d:_,shapeRendering:"crispEdges"}),C)});zy.displayName="QRCodeSVG";async function Gpe(e,t,n=fetch){var l,c,u,h,f;const r=await n("/api/lark/bot/oneclick",{method:"POST",signal:e,headers:{Accept:"text/event-stream"}});if(!r.ok){const p=await r.json().catch(()=>({}));throw new Error(((l=p.error)==null?void 0:l.message)??`创建请求失败(${r.status})`)}if(!r.body||!((c=r.headers.get("content-type"))!=null&&c.includes("text/event-stream")))throw new Error("服务未返回扫码进度,请刷新页面后重试。");const i=r.body.getReader(),s=new TextDecoder;let o="",a;try{for(;;){const{done:p,value:g}=await i.read();if(p)throw new Error("扫码连接已断开。请先刷新机器人列表,确认是否已创建,再重试。");o+=s.decode(g,{stream:!0});let x;for(;x=/\r?\n\r?\n/.exec(o);){const v=o.slice(0,x.index);o=o.slice(x.index+x[0].length);const b=v.split(/\r?\n/),y=(u=b.find(C=>C.startsWith("event:")))==null?void 0:u.slice(6).trim(),w=b.filter(C=>C.startsWith("data:")).map(C=>C.slice(5).trimStart()).join(`
850
- `);if(!w||!y||y==="heartbeat"||y==="connected")continue;const S=JSON.parse(w);if(y==="error")throw new Error(S.message||"创建未完成,请重试。");if(y==="qrcode"){const C=new URL(S.url);if(C.protocol!=="https:"||!Number.isFinite(S.expireIn)||S.expireIn<=0)throw new Error("二维码信息无效,请重新生成。");a={kind:"waiting",url:C.href,expiresAt:Date.now()+S.expireIn*1e3,slow:!1},t(a)}if(y==="status"&&(S.status==="saving"?t({kind:"saving"}):a&&(a={...a,slow:S.status==="slow_down"},t(a))),y==="success"){if(typeof S.appId!="string"||!((f=(h=S.config)==null?void 0:h.bots)!=null&&f.some(C=>C.appId===S.appId)))throw new Error("创建结果不完整,请刷新机器人列表确认。");return S}}if(o.length>1e6)throw new Error("扫码进度响应异常,请重试。")}}finally{await i.cancel().catch(()=>{}),i.releaseLock()}}function Ype(){const[e,t]=m.useState({kind:"idle"}),n=m.useRef(void 0),r=bn(()=>{var s;(s=n.current)==null||s.abort(),n.current=void 0}),i=bn(async()=>{r();const s=new AbortController;n.current=s,t({kind:"starting"});try{const o=await Gpe(s.signal,a=>{n.current===s&&t(a)});n.current===s&&t({kind:"success",result:o})}catch(o){n.current===s&&!s.signal.aborted&&t({kind:"error",message:o instanceof Error?o.message:"创建失败,请重试。"})}finally{n.current===s&&(n.current=void 0)}});return Fg(r),{state:e,start:i,cancel:r}}function Zpe({onClose:e,onComplete:t}){const{state:n,start:r,cancel:i}=Ype(),s=m.useRef(null),o=m.useRef(null),a=()=>{i(),e()};Vo({panel:s,initial:o,dismissible:!0,onDismiss:a});const[l]=BY({targetDate:n.kind==="waiting"?n.expiresAt:void 0}),c=n.kind==="waiting"&&Date.now()>=n.expiresAt,u=n.kind==="starting"||n.kind==="saving",h="inline-flex min-h-9 items-center justify-center gap-1.5 rounded-md px-3 text-[12px] font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400 disabled:opacity-50";return d.jsx("div",{className:"ui-overlay fixed inset-0 z-50 grid place-items-center bg-zinc-950/30 p-4",onMouseDown:f=>{f.target===f.currentTarget&&a()},children:d.jsxs("div",{ref:s,role:"dialog","aria-modal":"true","aria-labelledby":"lark-registration-title",className:"ui-dialog flex max-h-[calc(100dvh-2rem)] w-full max-w-[440px] flex-col overflow-hidden rounded-[14px] border border-zinc-200 bg-white shadow-xl",children:[d.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-100 px-4 py-3",children:[d.jsx("h2",{id:"lark-registration-title",className:"text-[16px] font-semibold text-zinc-900",children:"扫码创建飞书机器人"}),d.jsx("button",{ref:o,type:"button","aria-label":"关闭扫码创建",onClick:a,className:`${h} text-zinc-500 hover:bg-zinc-100`,children:d.jsx(Wn,{size:16})})]}),d.jsxs("div",{className:"space-y-4 overflow-y-auto px-5 py-5 text-[12px] leading-5 text-zinc-600",children:[d.jsx("p",{children:"使用飞书扫码,在授权页确认应用名称和权限。完成后自动保存凭证,再配置工作区、可用成员和 Agent。"}),d.jsxs("div",{"aria-live":"polite",children:[n.kind==="idle"&&d.jsx("p",{className:"rounded-md bg-zinc-50 p-3",children:"将创建一个新应用。已有机器人的 App ID 和 App Secret 可通过手动配置接入。"}),u&&d.jsxs("div",{className:"flex min-h-40 flex-col items-center justify-center gap-3",children:[d.jsx(Gn,{size:24,className:"text-zinc-500"}),d.jsx("span",{children:n.kind==="saving"?"授权已完成,正在保存机器人…":"正在生成二维码…"})]}),n.kind==="waiting"&&!c&&d.jsxs("div",{className:"flex flex-col items-center gap-3",children:[d.jsx("div",{className:"w-full max-w-[248px] bg-white p-2",children:d.jsx(zy,{value:n.url,size:232,marginSize:4,className:"h-auto w-full",title:"使用飞书扫描二维码创建机器人"})}),d.jsx("p",{children:n.slow?"飞书暂时限流,正在继续等待授权…":"等待扫码并在飞书中确认授权"}),d.jsxs("p",{className:"text-[12px] text-zinc-400",children:["二维码将在 ",Math.max(1,Math.ceil(l/1e3))," 秒后过期"]}),d.jsxs("a",{href:n.url,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-zinc-700 underline underline-offset-4",children:["在浏览器打开授权页",d.jsx(Ja,{size:12})]})]}),(c||n.kind==="error")&&d.jsx("p",{role:"alert",className:"rounded-md bg-amber-50 p-3 text-amber-800",children:c?"二维码已过期,请重新生成。":n.kind==="error"?n.message:""}),n.kind==="success"&&d.jsxs("div",{className:"space-y-3",children:[d.jsxs("p",{className:"flex items-center gap-2 font-medium text-emerald-700",children:[d.jsx(gi,{size:18}),"机器人已创建,凭证已保存"]}),d.jsxs("div",{className:"border-y border-zinc-100 py-3",children:[d.jsx("p",{className:"break-words font-medium text-zinc-900",children:n.result.appName}),d.jsx("p",{className:"break-all font-mono text-[12px] text-zinc-500",children:n.result.appId})]}),d.jsx("p",{children:"接下来检查工作区和成员范围,再选择 Agent 完成接入。"}),n.result.warning&&d.jsx("p",{className:"text-amber-700",children:n.result.warning}),n.result.config.listeningDisabled&&d.jsx("p",{className:"text-amber-700",children:"当前服务已禁用飞书监听;完成配置后需启用监听才能接收消息。"})]})]})]}),d.jsxs("div",{className:"flex flex-wrap justify-end gap-2 border-t border-zinc-100 px-4 py-3",children:[d.jsx("button",{type:"button",onClick:a,className:`${h} border border-zinc-200 text-zinc-600 hover:bg-zinc-50`,children:n.kind==="idle"||n.kind==="error"?"返回手动配置":n.kind==="success"?"稍后配置":"取消"}),n.kind==="success"?d.jsx("button",{type:"button",onClick:()=>t(n.result),className:`${h} bg-zinc-900 text-white hover:bg-zinc-800`,children:"继续配置机器人"}):(n.kind==="idle"||n.kind==="error"||c)&&d.jsxs("button",{type:"button",onClick:()=>void r(),className:`${h} bg-zinc-900 text-white hover:bg-zinc-800`,children:[d.jsx(Hn,{size:12}),n.kind==="idle"?"生成二维码":"重新生成"]})]})]})})}function YH({url:e,size:t,className:n="h-full w-full rounded-md object-cover"}){const[r,i]=m.useState(!1);return r?d.jsx(ti,{size:t}):d.jsx("img",{src:e,alt:"",onError:()=>i(!0),className:n})}const cO={claude:"claudecode",claudecode:"claudecode",codex:"codex",copilot:"copilot",githubcopilot:"copilot",cursor:"cursor",cursoragent:"cursor",deepseek:"deepseek",deepseekharness:"deepseek",droid:"droid",factorydroid:"droid",fastagent:"fast-agent",gemini:"gemini",geminicli:"gemini",grokbuild:"grok",iflow:"iflow",iflowcli:"iflow",kilocode:"kilocode",kimi:"kimi",kimicli:"kimi",kiro:"kiro",kirocli:"kiro",mcode:"mcode",minimaxcode:"mcode",mux:"mux",openclaw:"openclaw",opencode:"opencode",pi:"pi",picodingagent:"pi",pool:"poolside",poolside:"poolside",qoder:"qoder",qodercli:"qoder",qwen:"qwen",qwencode:"qwen",trae:"trae",traecli:"trae",zeroclaw:"zeroclaw"},uO=new Set(["cursor","grok","kilocode","kimi","mux","opencode","pi"]);function Xpe(e,t){for(const n of[e,t]){const r=n==null?void 0:n.toLowerCase().replace(/[^a-z0-9]/g,"");if(r&&r in cO)return cO[r]}}function Hr({agentId:e,agentName:t,size:n=14,onDark:r=!1,className:i=""}){const s=Xpe(e,t);if(!s)return d.jsx(ti,{size:n,"aria-hidden":"true",className:`shrink-0 ${i}`});const o=s==="iflow"?"png":"svg";return d.jsx("img",{src:`/agent-icons/${s}.${o}`,width:n,height:n,alt:"","aria-hidden":"true",className:`shrink-0 object-contain ${uO.has(s)?"ui-mono-brand":""} ${r&&uO.has(s)?"brightness-0 invert":""} ${i}`})}function ua({options:e,value:t,placeholder:n,disabledText:r,disabled:i=!1,size:s="default",popupWidth:o,onChange:a}){var p;const l=e.map((g,x)=>({option:g,key:`${x}:${g.value}`})),c=(p=l.find(g=>g.option.value===t))==null?void 0:p.key,[u,h]=m.useState(()=>typeof window>"u"?1024:window.innerWidth);m.useEffect(()=>{const g=()=>h(window.innerWidth);return window.addEventListener("resize",g),()=>window.removeEventListener("resize",g)},[]);const f=typeof o=="number"?u<640?!0:Math.min(o,u-16):o;return d.jsx("div",{className:s==="sm"?void 0:"mt-1.5",children:d.jsx(vi,{className:"w-full",size:s==="sm"?"middle":"large",value:c,disabled:i||!e.length,placeholder:e.length?n:r,showSearch:e.length>8,optionFilterProp:"title",popupMatchSelectWidth:f??!0,listHeight:240,onChange:g=>{const x=l.find(v=>v.key===g);x&&a(x.option.value)},options:l.map(({option:g,key:x})=>({value:x,title:`${g.label} ${g.meta??""}`,label:d.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[g.agentId&&d.jsx(Hr,{agentId:g.agentId,agentName:g.label,size:15}),d.jsx("span",{className:"min-w-0 flex-1 truncate",title:g.label,children:g.label}),g.meta&&d.jsx("span",{className:"hidden max-w-[50%] shrink-0 truncate font-mono text-[12px] text-zinc-400 sm:inline",children:g.meta})]})}))})})}const Jpe="agentdock.agent_models.v1",Qpe=10080*6e4,ZH=()=>{try{return typeof window>"u"?void 0:window.localStorage}catch{return}},XH=(e,t)=>`${Jpe}:${encodeURIComponent(e)}:${encodeURIComponent(t??"")}`,dO=e=>Array.isArray(e)&&e.every(t=>t&&typeof t=="object"&&typeof t.id=="string"&&typeof t.name=="string"),JH=e=>{if(!e||typeof e!="object")return!1;const t=e;return dO(t.models)&&dO(t.reasoningEfforts)&&(t.defaultModel===void 0||typeof t.defaultModel=="string")&&(t.defaultReasoningEffort===void 0||typeof t.defaultReasoningEffort=="string")&&(t.warning===void 0||typeof t.warning=="string")&&(t.source===void 0||t.source==="acp"||t.source==="cli"||t.source==="agent")},ul=(e,t,n)=>["agent-models",e??"",t??"",n??"local"];function Cd(e,t,n=ZH(),r=Date.now()){if(!(!e||!n))try{const i=n.getItem(XH(e,t));if(!i)return;const s=JSON.parse(i);return typeof s.savedAt!="number"||r-s.savedAt>Qpe||!JH(s.value)?void 0:s.value}catch{return}}function eme(e,t,n,r=ZH(),i=Date.now()){if(!(!e||!r||!JH(n)))try{r.setItem(XH(e,t),JSON.stringify({savedAt:i,value:n}))}catch{}}function tme(e,t){return(t==null?void 0:t.source)==="acp"&&!t.warning&&(e.source!=="acp"||e.warning)?{...t,warning:`${e.warning??"本次未能读取完整 Agent 配置。"} 正在显示上次成功读取的选项。`}:e}async function dl(e,t,n=!1,r){const i=r?void 0:Cd(e,t);let s;try{s=await we.agentModels(e,t,n,r)}catch(a){if((i==null?void 0:i.source)!=="acp")throw a;return{...i,warning:"Agent 配置请求失败,正在显示上次成功读取的选项,可重新读取。"}}const o=tme(s,i);return!r&&!o.warning&&eme(e,t,o),o}function IE({value:e,onChange:t,label:n,placeholder:r,suggestion:i,suggestionLabel:s}){return d.jsxs("div",{className:"mt-1.5",children:[d.jsx(cy,{className:"w-full",value:e,onChange:t,options:i?[{value:i,label:d.jsxs("span",{className:"block py-0.5",children:[d.jsx("span",{className:"block text-[12px] font-medium text-zinc-700",children:s}),d.jsx("span",{className:"mt-0.5 block break-all font-mono text-[12px] text-zinc-500",children:i})]})}]:[],filterOption:!1,children:d.jsx(Qn,{size:"large","aria-label":n,placeholder:r,allowClear:!0,className:"font-mono text-[12px]"})}),e.trim()&&d.jsx("p",{className:"mt-1 break-all font-mono text-[12px] leading-4 text-zinc-400",title:e,children:e})]})}function nme(e){return e.enabled?e.agentSelectionSaved?e.persisted||e.hookInstalled:!1:!0}function rme(e){return e.enabled||e.agentSelectionSaved&&e.hookInstalled}function ime(e,t,n){return!e||n||!t||!t.reasoningEfforts.length||t.reasoningEfforts.some(r=>r.id===e)?e:""}function Gx(e,t){return t&&!e.some(n=>n.id===t)?[{id:t,name:`${t}(已保存)`},...e]:e}const lu="mt-1 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2 text-[12px] text-zinc-900 outline-none transition-colors placeholder:text-zinc-400 focus:border-zinc-500",qs="text-[12px] font-medium text-zinc-600",am="rounded-xl border border-zinc-200 bg-white",hO=e=>e.split(/[\s,,]+/).map(t=>t.trim()).filter(Boolean),QH=e=>e instanceof Error?e.message:e?String(e):"",sme=e=>{var t;return(((t=e==null?void 0:e.trim())==null?void 0:t[0])??"?").toUpperCase()},Ew=e=>{const t=new Date(e);if(Number.isNaN(t.getTime()))return"";const n=new Date;return t.toDateString()===n.toDateString()?t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):t.toLocaleDateString([],{month:"2-digit",day:"2-digit"})},GC=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString([],{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})},ome=e=>e==="group"?"群聊":e==="topic"?"话题群":e==="p2p"?"私聊":"飞书会话";function eu({name:e,src:t,fallbackSrc:n,size:r=32}){const i=[t,n].filter((l,c,u)=>!!l&&u.indexOf(l)===c),[s,o]=m.useState(0);m.useEffect(()=>o(0),[t,n]);const a=i[s];return a?d.jsx("img",{src:a,alt:e??"",loading:"lazy",referrerPolicy:"no-referrer",onError:()=>o(l=>l+1),className:"shrink-0 rounded-full object-cover",style:{width:r,height:r}}):d.jsx("span",{className:"grid shrink-0 place-items-center rounded-full bg-zinc-900 font-semibold text-white",style:{width:r,height:r,fontSize:Math.max(11,Math.round(r*.36))},children:sme(e)})}function jw({value:e,onChange:t,options:n}){return d.jsx("div",{className:"mt-1.5 grid gap-1 rounded-xl bg-zinc-100 p-1",style:{gridTemplateColumns:`repeat(${n.length}, minmax(0, 1fr))`},children:n.map(r=>d.jsx("button",{type:"button",onClick:()=>t(r.value),className:`rounded-lg px-2.5 py-1.5 text-[11px] font-medium transition-colors ${e===r.value?"bg-white text-zinc-900 shadow-sm":"text-zinc-500 hover:text-zinc-800"}`,children:r.label},r.value))})}function YC({connected:e,state:t,listening:n=!0}){const r=!n&&t!=="expired",i=t==="expired",s=t==="connecting";return d.jsxs("span",{className:`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-[11px] font-medium ${r?"bg-amber-50 text-amber-700":e?"bg-emerald-50 text-emerald-700":i?"bg-amber-50 text-amber-700":s?"bg-sky-50 text-sky-700":"bg-zinc-100 text-zinc-500"}`,children:[d.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${r?"bg-amber-500":e?"bg-emerald-500":i?"bg-amber-500":s?"bg-sky-500 animate-pulse":"bg-zinc-400"}`}),r?"已暂停":e?"运行中":i?"会话已失效":s?"正在重连":"未连接"]})}function Z0({label:e,value:t,hint:n}){return d.jsxs("div",{className:"rounded-xl border border-zinc-200 bg-white px-4 py-3",children:[d.jsx("p",{className:"text-[11px] text-zinc-500",children:e}),d.jsx("p",{className:"mt-1 text-[24px] font-semibold leading-none text-zinc-900",children:t}),n&&d.jsx("p",{className:"mt-1 text-[11px] text-zinc-400",children:n})]})}function ame({config:e,status:t,open:n,setOpen:r,region:i,login:s,starting:o,error:a,cookie:l,setCookie:c,importing:u,onOpen:h,onStart:f,onRegion:p,onCancel:g,onCookieImport:x}){const[v,b]=m.useState(!1),y=QH(a)||(s==null?void 0:s.message),w=(s==null?void 0:s.state)==="waiting"||(s==null?void 0:s.state)==="scanned",S=(s==null?void 0:s.state)==="success",C=(s==null?void 0:s.state)==="failed";return n?d.jsxs("div",{className:"h-full overflow-y-auto p-5",children:[d.jsxs("button",{type:"button",onClick:()=>r(!1),className:"inline-flex items-center gap-1.5 text-[12px] text-zinc-500 hover:text-zinc-900",children:[d.jsx(D4,{size:13}),"返回"]}),d.jsxs("div",{className:"mx-auto mt-4 max-w-[860px]",children:[d.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[d.jsxs("div",{children:[d.jsx("h2",{className:"text-[20px] font-semibold text-zinc-900",children:t!=null&&t.connected?"重新连接账号":"扫码连接飞书账号"}),d.jsx("p",{className:"mt-1 text-[12px] leading-5 text-zinc-500",children:"不需要 App ID、App Secret,也不需要创建机器人。"})]}),d.jsx(YC,{connected:t==null?void 0:t.connected,state:t==null?void 0:t.state,listening:t==null?void 0:t.listening})]}),d.jsxs("div",{className:"mt-5 grid gap-5 lg:grid-cols-[minmax(0,1fr)_280px]",children:[d.jsxs("div",{className:`${am} flex flex-col items-center p-5 text-center`,children:[d.jsxs("div",{className:"flex w-full items-center justify-between",children:[d.jsx("h3",{className:"text-[13px] font-semibold text-zinc-900",children:"手机扫码登录"}),d.jsx("div",{className:"flex rounded-lg bg-zinc-100 p-0.5",children:["feishu","lark"].map(_=>d.jsx("button",{type:"button",onClick:()=>p(_),disabled:o,className:`rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors ${i===_?"bg-white text-zinc-900 shadow-sm":"text-zinc-500 hover:text-zinc-800"}`,children:_==="feishu"?"飞书":"Lark"},_))})]}),d.jsx("div",{className:"mt-4 grid h-[196px] w-[196px] place-items-center rounded-2xl bg-white p-2 ring-1 ring-zinc-200",children:S?d.jsxs("div",{className:"text-center",children:[d.jsx(hN,{size:42,className:"mx-auto text-emerald-500"}),d.jsx("p",{className:"mt-2 text-[12px] font-medium text-zinc-800",children:"登录成功"})]}):w&&(s!=null&&s.qrContent)?d.jsx(zy,{value:s.qrContent,size:180,marginSize:2,title:`${i==="feishu"?"飞书":"Lark"}登录二维码`}):o||(s==null?void 0:s.state)==="starting"?d.jsxs("div",{className:"text-center text-zinc-400",children:[d.jsx(_i,{size:30,className:"mx-auto animate-spin"}),d.jsx("p",{className:"mt-2 text-[11px]",children:"正在获取二维码"})]}):d.jsxs("div",{className:"text-center text-zinc-400",children:[d.jsx(tf,{size:30,className:"mx-auto"}),d.jsx("p",{className:"mt-2 max-w-[150px] text-[11px] leading-4",children:C?"二维码获取失败":"等待生成二维码"})]})}),d.jsx("p",{className:`mt-3 text-[12px] leading-5 ${C?"text-red-600":"text-zinc-600"}`,children:y||(w?"打开飞书 App,扫一扫二维码":"正在准备登录…")}),d.jsxs("p",{className:"mt-1 text-[10px] text-zinc-400",children:[s!=null&&s.attempt?`第 ${s.attempt} / 6 次`:"扫码后请在手机上确认",(s==null?void 0:s.state)==="scanned"?" · 已扫码":""]}),d.jsxs("div",{className:"mt-3 flex gap-2",children:[d.jsx(zn,{size:"small",loading:o,onClick:f,children:C||S?"重新生成":"刷新二维码"}),d.jsx(zn,{size:"small",onClick:g,children:"取消"})]})]}),d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:`${am} p-4`,children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(aX,{size:15,className:"text-zinc-500"}),d.jsx("h3",{className:"text-[13px] font-semibold text-zinc-900",children:"登录后会发生什么"})]}),d.jsxs("ul",{className:"mt-3 space-y-2 text-[11px] leading-5 text-zinc-500",children:[d.jsx("li",{children:"· 凭证只保存在本机 SQLite,不会下发给浏览器。"}),d.jsx("li",{children:"· 以你的本人身份建立长连接,不经过机器人。"}),d.jsx("li",{children:"· Agent 的文本输出会直接以你的身份发回当前聊天。"}),d.jsx("li",{children:"· 会话失效时状态会变为「会话已失效」,重新扫码即可。"})]})]}),d.jsxs("div",{className:`${am} p-4`,children:[d.jsxs("button",{type:"button",onClick:()=>b(_=>!_),className:"flex w-full items-center justify-between text-left",children:[d.jsx("span",{className:"text-[12px] font-medium text-zinc-700",children:"高级:导入 Cookie"}),d.jsx("span",{className:"text-[11px] text-zinc-400",children:v?"收起":"展开"})]}),v&&d.jsxs("div",{className:"mt-3",children:[d.jsxs("p",{className:"text-[11px] leading-5 text-zinc-500",children:["扫码不可用时,可从已登录的飞书网页复制完整 Cookie。必须包含 ",d.jsx("code",{className:"rounded bg-zinc-100 px-1",children:"session"}),"。"]}),d.jsx("textarea",{value:l,onChange:_=>c(_.target.value),placeholder:"session=...; passport_web_did=...; swp_csrf_token=...",className:`${lu} min-h-20 resize-y`}),d.jsx(zn,{size:"small",className:"mt-2",loading:u,disabled:!l.trim(),onClick:x,children:"导入 Cookie"})]})]})]})]})]})]}):d.jsx("div",{className:"flex h-full items-center justify-center overflow-y-auto p-6",children:d.jsxs("div",{className:"w-full max-w-[620px] text-center",children:[d.jsx("div",{className:"mx-auto grid h-14 w-14 place-items-center rounded-2xl bg-zinc-900 text-white shadow-sm",children:d.jsx(_x,{size:25})}),d.jsx("h2",{className:"mt-5 text-[22px] font-semibold tracking-tight text-zinc-900",children:"连接你的飞书账号"}),d.jsx("p",{className:"mx-auto mt-2 max-w-[520px] text-[13px] leading-6 text-zinc-500",children:"直接扫码登录飞书网页端。消息通过本人身份的 WebSocket 常驻接收,并定时补拉群聊;收到触发词后 Agent 会结合上下文直接以你的身份回复。"}),d.jsx("div",{className:"mt-6 grid gap-2 text-left sm:grid-cols-3",children:[["1","手机扫码","用飞书或 Lark App 扫码确认"],["2","持续监听","WebSocket + 30 秒群聊补拉"],["3","Agent 直接回复","所有 AgentText 自动发回聊天"]].map(([_,k,j])=>d.jsxs("div",{className:"rounded-xl border border-zinc-200 bg-zinc-50/60 p-3",children:[d.jsx("span",{className:"grid h-6 w-6 place-items-center rounded-full bg-white text-[11px] font-semibold text-zinc-700 shadow-sm",children:_}),d.jsx("p",{className:"mt-2 text-[12px] font-medium text-zinc-800",children:k}),d.jsx("p",{className:"mt-0.5 text-[11px] leading-4 text-zinc-500",children:j})]},_))}),(t==null?void 0:t.lastError)&&d.jsx("p",{className:"mx-auto mt-4 max-w-[520px] rounded-lg bg-red-50 px-3 py-2 text-left text-[12px] text-red-700",children:t.lastError}),(e==null?void 0:e.account)&&d.jsxs("p",{className:"mt-5 text-[11px] text-zinc-400",children:["上次连接 ",d.jsx("span",{className:"text-zinc-600",children:e.account.name}),e.account.userId?` · ${e.account.userId}`:""]}),d.jsx(zn,{type:"primary",size:"large",className:"mt-6 !h-10 !rounded-lg !bg-zinc-900 !px-5 !text-[13px]",onClick:h,children:e!=null&&e.account?"重新扫码连接":"扫码连接"})]})})}function lme({draft:e,body:t,onBody:n,onSend:r,onDiscard:i,sending:s,discarding:o,accountName:a,accountAvatarUrl:l}){if(e.state==="sent"){const c=!!e.itemId;return d.jsxs("div",{className:"mb-5 flex items-end justify-end gap-2.5",children:[d.jsxs("div",{className:"min-w-0 max-w-[78%] text-right",children:[d.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-end gap-2",children:[d.jsx("span",{className:"text-[11px] font-medium text-zinc-700",children:c?"AI 替身":a||"你"}),d.jsx("span",{className:"text-[10px] text-zinc-400",children:GC(e.sentAt??e.updatedAt)}),d.jsx("span",{className:"rounded-full bg-emerald-50 px-1.5 py-0.5 text-[9px] font-medium text-emerald-700",children:"已发送"})]}),d.jsx("div",{className:"inline-block whitespace-pre-wrap break-words rounded-2xl rounded-tr-md bg-sky-600 px-3.5 py-2.5 text-left text-[13px] leading-5 text-white",children:e.body})]}),c?d.jsx("span",{className:"grid h-7 w-7 shrink-0 place-items-center rounded-full bg-sky-600 text-white",children:d.jsx(Lo,{size:13})}):d.jsx(eu,{name:a,src:l,size:28})]})}return e.state==="discarded"?d.jsxs("div",{className:"mb-5 max-w-[78%] rounded-lg border border-dashed border-zinc-200 px-3 py-2 text-[11px] text-zinc-400",children:["已丢弃草稿:",e.body||"(空)"]}):d.jsxs("div",{className:"mb-5 max-w-[78%] rounded-xl border border-zinc-200 bg-zinc-50/70 p-3",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-medium text-zinc-600",children:[d.jsx(Lo,{size:12}),"Agent 回复"]}),e.lastError&&d.jsx("span",{className:"truncate text-[10px] text-red-600",children:e.lastError})]}),d.jsx("textarea",{className:`${lu} mt-2 min-h-20 resize-y bg-white`,value:t,placeholder:"AI 没有生成正文,可以手动补充。",onChange:c=>n(c.target.value)}),d.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[d.jsx(zn,{size:"small",type:"primary",disabled:!t.trim(),loading:s,onClick:r,children:"确认发送"}),d.jsx(zn,{size:"small",danger:!0,loading:o,onClick:i,children:"丢弃"})]})]})}function cme(){var Qt,Yt,Y,Ae,et,Tt,dt,At,He,it,jt,St,It,Rn,Tn,Sn,mr,qn,nr,Ur,_r,ci,Rr,rr,Cr,kr,Nr,Kr,ui,Ft,Rt,se,gt,bt,tn,Nn,Un,Fn,Wi,ki,Wt,Nt,Ht,En,_n;const e=Ln(),t=Et({queryKey:["lark-avatar-status"],queryFn:we.larkAvatarStatus,refetchInterval:5e3}),n=Et({queryKey:["lark-avatar-config"],queryFn:we.larkAvatarConfig}),r=Et({queryKey:["agents"],queryFn:()=>we.agents()}),i=Et({queryKey:["system-capabilities"],queryFn:we.systemCapabilities}),s=!!((Qt=t.data)!=null&&Qt.connected),o=!!((Yt=t.data)!=null&&Yt.configured)&&((Y=t.data)==null?void 0:Y.state)!=="expired",a=Et({queryKey:["lark-avatar-inbox"],queryFn:()=>we.larkAvatarInbox(),refetchInterval:5e3,enabled:o}),l=Et({queryKey:["lark-avatar-drafts"],queryFn:()=>we.larkAvatarDrafts(),refetchInterval:5e3,enabled:o}),[c,u]=m.useState("overview"),[h,f]=m.useState(!1),[p,g]=m.useState("feishu"),[x,v]=m.useState(""),[b,y]=m.useState("/ai"),[w,S]=m.useState(10),[C,_]=m.useState("anchor"),[k,j]=m.useState(!0),[z,N]=m.useState("direct"),[I,$]=m.useState(!1),[R,E]=m.useState(""),[M,P]=m.useState(7200),[A,D]=m.useState("all"),[F,O]=m.useState([]),[B,V]=m.useState(""),[T,W]=m.useState(""),[L,q]=m.useState(""),[X,J]=m.useState(""),[ae,ne]=m.useState(""),[re,ie]=m.useState(""),[G,oe]=m.useState(),[ge,U]=m.useState(""),[ce,ve]=m.useState(""),[fe,Ce]=m.useState({}),Pe=yl(),Ie=m.useRef(null),Te=m.useRef(!1),de=Et({queryKey:ul(L,X||void 0),queryFn:()=>dl(L,X||void 0),enabled:!!L,initialData:()=>Cd(L,X||void 0),initialDataUpdatedAt:0,refetchOnMount:"always",staleTime:5*6e4}),Le=Et({queryKey:["lark-avatar-chats"],queryFn:we.larkAvatarChats,enabled:o&&c==="settings",staleTime:2e4,refetchOnMount:"always"});m.useEffect(()=>{n.data&&(g(n.data.config.region),y(n.data.config.triggerPrefix),S(n.data.config.contextMessages),_(n.data.config.contextScope),j(n.data.config.replyInTopic),N(n.data.config.replyMode),$(n.data.config.emojiReactions),E(n.data.config.replySignature),P(n.data.config.agentTimeoutSeconds),O(n.data.config.listenChats),V(n.data.config.listenChats.join(", ")),D(n.data.config.listenChats.length?"selected":"all"),q(n.data.config.agentId),J(n.data.config.model),ne(n.data.config.reasoningEffort),ie(n.data.config.workspace))},[(Ae=n.data)==null?void 0:Ae.id,(et=n.data)==null?void 0:et.updatedAt,s]),m.useEffect(()=>{var he;!L&&((he=r.data)!=null&&he.length)&&q(r.data[0].id)},[L,r.data]),m.useEffect(()=>{s&&(f(!1),u(he=>he==="overview"?he:"overview"))},[s]);const te=()=>{e.invalidateQueries({queryKey:["lark-avatar-status"]}),e.invalidateQueries({queryKey:["lark-avatar-config"]}),e.invalidateQueries({queryKey:["lark-avatar-inbox"]}),e.invalidateQueries({queryKey:["lark-avatar-drafts"]})},me=yt({mutationFn:()=>we.saveLarkAvatarConfig({region:p,triggerPrefix:b,contextMessages:w,contextScope:C,replyInTopic:k,replyMode:z,emojiReactions:I,replySignature:R,agentTimeoutSeconds:M,listenChats:A==="all"?[]:hO(B),allowedSenders:[],agentId:L,model:X,reasoningEffort:ae,workspace:re}),onSuccess:()=>{Pe.show("配置已保存,下一次触发生效","info"),te()}}),_e=yt({mutationFn:we.selectDirectory,onSuccess:he=>ie(he.path)}),$e=yt({mutationFn:he=>we.startLarkAvatarLogin(he),onSuccess:he=>e.setQueryData(["lark-avatar-login"],he)}),xe=yt({mutationFn:we.cancelLarkAvatarLogin,onSuccess:he=>{e.setQueryData(["lark-avatar-login"],he),f(!1)}}),Ze=yt({mutationFn:()=>we.importLarkAvatarCookie({cookie:x,region:p}),onSuccess:()=>{v(""),f(!1),u("overview"),te()}}),le=yt({mutationFn:we.disconnectLarkAvatar,onSuccess:()=>{f(!1),te()}}),Me=yt({mutationFn:we.pollLarkAvatar,onSuccess:te}),pe=yt({mutationFn:he=>we.setLarkAvatarListening(he),onSuccess:te}),ye=Et({queryKey:["lark-avatar-login"],queryFn:we.pollLarkAvatarLogin,enabled:h&&!s,refetchInterval:h&&!s?2e3:!1,retry:!1});m.useEffect(()=>{var he;((he=ye.data)==null?void 0:he.state)==="success"&&(f(!1),u("overview"),te())},[(Tt=ye.data)==null?void 0:Tt.state]),m.useEffect(()=>{var st,ot;if(Te.current||t.isPending||n.isPending||(Te.current=!0,(st=t.data)!=null&&st.configured&&t.data.state!=="expired"))return;const he=((ot=n.data)==null?void 0:ot.config.region)??"feishu";g(he),f(!0),$e.mutate(he)},[t.isPending,n.isPending,(dt=t.data)==null?void 0:dt.configured,(At=t.data)==null?void 0:At.state]);const Ee=yt({mutationFn:he=>we.sendLarkAvatarDraft(he.id,fe[he.id]??he.body),onSuccess:he=>{Ce(st=>{const ot={...st};return delete ot[he.id],ot}),te()}}),Se=yt({mutationFn:he=>we.discardLarkAvatarDraft(he),onSuccess:he=>{Ce(st=>{const ot={...st};return delete ot[he.id],ot}),te()}}),De=yt({mutationFn:async({conversation:he,body:st})=>{const ot=await we.createLarkAvatarDraft({target:he.chatId,body:st,threadKey:he.threadKey});return we.sendLarkAvatarDraft(ot.id)},onSuccess:()=>{ve(""),te()}}),at=a.data??[],xt=l.data??[],Mt=m.useMemo(()=>new Map(at.map(he=>[he.id,he])),[at]),rt=m.useMemo(()=>{const he=new Map,st=(ot,wt)=>{let On=he.get(ot);return On||(On={key:ot,threadKey:wt.threadKey??wt.chatId??ot,chatId:wt.chatId??"",title:wt.title??wt.chatId??"飞书会话",chatType:wt.chatType??"",...wt.avatarUrl?{avatarUrl:wt.avatarUrl}:{},...wt.avatarFallbackUrl?{avatarFallbackUrl:wt.avatarFallbackUrl}:{},items:[],drafts:[],latestAt:wt.at,latestText:wt.text},he.set(ot,On)),wt.avatarUrl&&!On.avatarUrl&&(On.avatarUrl=wt.avatarUrl),wt.avatarFallbackUrl&&(On.avatarFallbackUrl=wt.avatarFallbackUrl),wt.at>On.latestAt&&(On.latestAt=wt.at,On.latestText=wt.text),On};for(const ot of at){const wt=ot.threadKey||`chat:${ot.chatId}`;st(wt,{threadKey:ot.threadKey,chatId:ot.chatId,title:ot.chatName||ot.senderName||ot.chatId,chatType:ot.chatType,avatarUrl:ot.chatAvatarUrl||(ot.chatType==="p2p"?ot.senderAvatarUrl:void 0),avatarFallbackUrl:ot.chatType==="p2p"?ot.senderAvatarUrl:void 0,at:ot.occurredAt,text:ot.title}).items.push(ot)}for(const ot of xt){const wt=ot.itemId?Mt.get(ot.itemId):void 0,On=ot.threadKey||(wt==null?void 0:wt.threadKey)||`chat:${ot.target}`;st(On,{threadKey:ot.threadKey,chatId:(wt==null?void 0:wt.chatId)||ot.target,title:(wt==null?void 0:wt.chatName)||(wt==null?void 0:wt.senderName)||ot.target,chatType:wt==null?void 0:wt.chatType,avatarUrl:(wt==null?void 0:wt.chatAvatarUrl)||((wt==null?void 0:wt.chatType)==="p2p"?wt.senderAvatarUrl:void 0),avatarFallbackUrl:(wt==null?void 0:wt.chatType)==="p2p"?wt.senderAvatarUrl:void 0,at:ot.updatedAt,text:ot.body}).drafts.push(ot)}for(const ot of he.values())ot.items.sort((wt,On)=>wt.occurredAt.localeCompare(On.occurredAt)),ot.drafts.sort((wt,On)=>wt.createdAt.localeCompare(On.createdAt));return[...he.values()].sort((ot,wt)=>wt.latestAt.localeCompare(ot.latestAt))},[xt,Mt,at]);m.useEffect(()=>{if(!rt.length){oe(void 0);return}(!G||!rt.some(he=>he.key===G))&&oe(rt[0].key)},[rt,G]);const nt=rt.filter(he=>{const st=ge.trim().toLowerCase();return!st||he.title.toLowerCase().includes(st)||he.latestText.toLowerCase().includes(st)}),Qe=rt.find(he=>he.key===G),tt=xt.filter(he=>he.state==="pending"||he.state==="failed"),ft=xt.filter(he=>he.state==="sent"),ue=at.filter(he=>he.title.trim().startsWith(b)).length,Oe=(He=r.data)==null?void 0:He.find(he=>he.id===L),ke=(r.data??[]).map(he=>({value:he.id,label:he.name,agentId:he.id})),pt=[{value:"",label:(it=de.data)!=null&&it.defaultModel?`Agent 默认(${de.data.defaultModel})`:"Agent 默认模型"},...Gx(((jt=de.data)==null?void 0:jt.models)??[],X).map(he=>({value:he.id,label:he.name}))],mt=[{value:"",label:(St=de.data)!=null&&St.defaultReasoningEffort?`Agent 默认(${de.data.defaultReasoningEffort})`:"Agent 默认强度"},...Gx(((It=de.data)==null?void 0:It.reasoningEfforts)??[],ae).map(he=>({value:he.id,label:he.name}))],Ye=m.useMemo(()=>{const he=new Map;for(const st of at){if(!st.chatId)continue;const ot=he.get(st.chatId),wt=st.chatType==="p2p"||st.chatType==="group"||st.chatType==="topic"?st.chatType:(ot==null?void 0:ot.type)??"unknown",On=st.chatAvatarUrl||(ot==null?void 0:ot.avatarUrl)||(wt==="p2p"?st.senderAvatarUrl:void 0),bo=wt==="p2p"?st.senderAvatarUrl||(ot==null?void 0:ot.avatarFallbackUrl):void 0;he.set(st.chatId,{id:st.chatId,name:st.chatName||(ot==null?void 0:ot.name)||st.senderName||st.chatId,type:wt,...On?{avatarUrl:On}:{},...bo?{avatarFallbackUrl:bo}:{},...ot!=null&&ot.memberCount?{memberCount:ot.memberCount}:{},...st.occurredAt?{lastMessageAt:st.occurredAt}:ot!=null&&ot.lastMessageAt?{lastMessageAt:ot.lastMessageAt}:{}})}for(const st of Le.data??[]){const ot=he.get(st.id);he.set(st.id,{...ot??{},...st,...ot!=null&&ot.avatarFallbackUrl?{avatarFallbackUrl:ot.avatarFallbackUrl}:{}})}for(const st of F)he.has(st)||he.set(st,{id:st,name:st,type:"unknown"});return[...he.values()].sort((st,ot)=>(st.type==="group"||st.type==="topic"?0:1)-(ot.type==="group"||ot.type==="topic"?0:1)||(ot.lastMessageAt??"").localeCompare(st.lastMessageAt??"")||st.name.localeCompare(ot.name,"zh-CN"))},[Le.data,at,F]),ze=Ye.filter(he=>{const st=T.trim().toLowerCase();return!st||he.name.toLowerCase().includes(st)||he.id.toLowerCase().includes(st)}),Re=he=>{O(he),V(he.join(", "))},Q=he=>{Re(F.includes(he)?F.filter(st=>st!==he):[...F,he])},Ge=Qe?[...Qe.items.map(he=>({kind:"item",at:he.occurredAt,item:he})),...Qe.drafts.map(he=>({kind:"draft",at:he.state==="sent"?he.sentAt??he.updatedAt:he.createdAt,draft:he}))].sort((he,st)=>he.at.localeCompare(st.at)):[];m.useEffect(()=>{Ie.current&&(Ie.current.scrollTop=Ie.current.scrollHeight)},[G,Qe==null?void 0:Qe.items.length,Qe==null?void 0:Qe.drafts.length]);const qe=((Rn=t.data)==null?void 0:Rn.listening)!==!1,$t=[me.error,le.error,Me.error,pe.error,Ee.error,Se.error,De.error,Ze.error,_e.error].map(QH).find(Boolean),Gt=he=>{oe(he.key),u("chats")};return n.isPending||t.isPending?d.jsx("div",{className:"grid h-full place-items-center text-[12px] text-zinc-500",children:"正在读取飞书替身状态…"}):!o||h?d.jsx(ame,{config:n.data,status:t.data,open:h,setOpen:f,region:p,login:ye.data,starting:$e.isPending,error:$e.error??Ze.error,cookie:x,setCookie:v,importing:Ze.isPending,onOpen:()=>{f(!0),$e.mutate(p)},onStart:()=>$e.mutate(p),onRegion:he=>{g(he),$e.mutate(he)},onCancel:()=>xe.mutate(),onCookieImport:()=>Ze.mutate()}):d.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[d.jsxs("div",{className:"border-b border-zinc-100 px-5 py-3",children:[d.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[d.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[d.jsx(eu,{name:(Sn=(Tn=t.data)==null?void 0:Tn.account)==null?void 0:Sn.name,src:(qn=(mr=t.data)==null?void 0:mr.account)==null?void 0:qn.avatarUrl,size:40}),d.jsxs("div",{className:"min-w-0",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("h3",{className:"truncate text-[14px] font-semibold text-zinc-900",children:((Ur=(nr=t.data)==null?void 0:nr.account)==null?void 0:Ur.name)||"飞书账号"}),d.jsx(YC,{connected:(_r=t.data)==null?void 0:_r.connected,state:(ci=t.data)==null?void 0:ci.state,listening:(Rr=t.data)==null?void 0:Rr.listening})]}),d.jsx("p",{className:"mt-0.5 truncate text-[11px] text-zinc-500",children:((Cr=(rr=t.data)==null?void 0:rr.account)==null?void 0:Cr.email)||((Nr=(kr=t.data)==null?void 0:kr.account)==null?void 0:Nr.userId)||`${((Kr=t.data)==null?void 0:Kr.region)==="lark"?"Lark":"飞书"} WebSocket`})]})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(zn,{size:"small",icon:d.jsx(Hn,{size:12}),loading:Me.isPending,disabled:!qe,onClick:()=>Me.mutate(),children:"立即同步"}),d.jsx(zn,{size:"small",icon:qe?d.jsx($0,{size:12}):d.jsx(z_,{size:12}),loading:pe.isPending,onClick:()=>pe.mutate(!qe),children:qe?"暂停监听":"恢复监听"}),d.jsx(zn,{size:"small",onClick:()=>u("settings"),children:"连接设置"})]})]}),d.jsx("div",{className:"mt-3 flex items-center gap-1",children:[["overview","概览"],["chats","会话"],["settings","设置"]].map(([he,st])=>d.jsxs("button",{type:"button",onClick:()=>u(he),className:`relative rounded-lg px-3 py-1.5 text-[12px] font-medium transition-colors ${c===he?"bg-zinc-100 text-zinc-900":"text-zinc-500 hover:bg-zinc-50 hover:text-zinc-800"}`,children:[st,he==="chats"&&tt.length>0&&d.jsx("span",{className:"ml-1.5 rounded-full bg-amber-100 px-1.5 py-0.5 text-[10px] text-amber-700",children:tt.length})]},he))})]}),$t&&d.jsx("p",{className:"border-b border-red-100 bg-red-50 px-5 py-2 text-[12px] text-red-700",children:$t}),!qe&&d.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-amber-100 bg-amber-50 px-5 py-2 text-[12px] text-amber-800",children:[d.jsx($0,{size:13}),d.jsx("span",{children:"监听已暂停,不会接收新消息或触发 Agent;登录凭证仍保留,可随时恢复。"})]}),qe&&((ui=t.data)==null?void 0:ui.state)==="connecting"&&d.jsxs("p",{className:"border-b border-amber-100 bg-amber-50 px-5 py-2 text-[12px] text-amber-800",children:["WebSocket 正在重连",t.data.lastError?`:${t.data.lastError}`:"…"]}),c==="overview"&&d.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-5",children:[!qe&&d.jsxs("div",{className:"mb-4 flex items-start gap-2.5 rounded-xl border border-amber-200/70 bg-amber-50/70 px-4 py-3 text-[12px] leading-5 text-amber-900",children:[d.jsx($0,{size:15,className:"mt-0.5 shrink-0"}),d.jsxs("div",{children:[d.jsx("p",{className:"font-medium",children:"当前处于暂停状态"}),d.jsx("p",{className:"mt-0.5 text-amber-800",children:"新的飞书消息不会被读取,也不会触发 Agent。点击右上角「恢复监听」后会重新连接 WebSocket 并继续定时补拉。"})]})]}),d.jsxs("div",{className:"mb-4 rounded-xl border border-sky-100 bg-sky-50/60 px-4 py-3 text-[12px] leading-5 text-sky-900",children:["在飞书聊天里发送 ",d.jsxs("code",{className:"rounded bg-white/80 px-1 py-0.5 font-mono text-[11px]",children:[b," 你的问题"]}),", 会自动带上最近 ",w," 条聊天记录(文字消息,含本条触发消息)发起 Agent 轮次;Agent 的所有文本输出会直接以你的身份发回当前聊天。后台每 ",((Ft=t.data)==null?void 0:Ft.syncIntervalSeconds)??30," 秒补拉一次群聊,避免只依赖 WebSocket 推送。"]}),d.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:[d.jsx(Z0,{label:"收到消息",value:at.length}),d.jsx(Z0,{label:"会话",value:rt.length}),d.jsx(Z0,{label:"AI 触发",value:ue,hint:`${b} 前缀`}),d.jsx(Z0,{label:"已发送",value:ft.length,hint:tt.length?`${tt.length} 条待补发`:"全部已送达"})]}),d.jsxs("div",{className:"mt-5 grid gap-5 lg:grid-cols-[minmax(0,1.35fr)_minmax(280px,.65fr)]",children:[d.jsxs("section",{className:`${am} overflow-hidden`,children:[d.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-100 px-4 py-3",children:[d.jsx("h3",{className:"text-[13px] font-semibold text-zinc-900",children:"最近会话"}),d.jsx("button",{type:"button",onClick:()=>u("chats"),className:"text-[11px] text-zinc-500 hover:text-zinc-900",children:"全部会话"})]}),rt.length?d.jsx("div",{className:"divide-y divide-zinc-100",children:rt.slice(0,6).map(he=>d.jsxs("button",{type:"button",onClick:()=>Gt(he),className:"flex w-full items-center gap-3 px-4 py-3 text-left hover:bg-zinc-50",children:[d.jsx(eu,{name:he.title,src:he.avatarUrl,fallbackSrc:he.avatarFallbackUrl,size:30}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsx("span",{className:"truncate text-[12px] font-medium text-zinc-800",children:he.title}),d.jsx("span",{className:"shrink-0 text-[10px] text-zinc-400",children:Ew(he.latestAt)})]}),d.jsx("p",{className:"mt-0.5 truncate text-[11px] text-zinc-500",children:he.latestText||"暂无消息"})]})]},he.key))}):d.jsx("div",{className:"px-4 py-10 text-center text-[12px] text-zinc-400",children:"还没有收到消息"})]}),d.jsxs("section",{className:`${am} overflow-hidden`,children:[d.jsx("div",{className:"border-b border-zinc-100 px-4 py-3",children:d.jsx("h3",{className:"text-[13px] font-semibold text-zinc-900",children:"最近发送"})}),ft.length?d.jsx("div",{className:"divide-y divide-zinc-100",children:ft.slice(0,5).map(he=>{const st=rt.find(ot=>ot.drafts.some(wt=>wt.id===he.id));return d.jsxs("button",{type:"button",onClick:()=>{st&&Gt(st)},className:"block w-full px-4 py-3 text-left hover:bg-zinc-50",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsx("span",{className:"text-[11px] font-medium text-zinc-700",children:(st==null?void 0:st.title)||he.target}),d.jsx("span",{className:"text-[10px] text-zinc-400",children:Ew(he.updatedAt)})]}),d.jsx("p",{className:"mt-1 line-clamp-2 text-[11px] leading-4 text-zinc-500",children:he.body||"等待补充正文"})]},he.id)})}):d.jsx("div",{className:"px-4 py-10 text-center text-[12px] text-zinc-400",children:"还没有发送记录"})]})]})]}),c==="chats"&&d.jsxs("div",{className:"flex min-h-0 flex-1",children:[d.jsxs("aside",{className:"flex w-[270px] shrink-0 flex-col border-r border-zinc-100",children:[d.jsx("div",{className:"p-3",children:d.jsxs("div",{className:"relative",children:[d.jsx(fa,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-zinc-400"}),d.jsx("input",{value:ge,onChange:he=>U(he.target.value),placeholder:"搜索会话",className:"h-8 w-full rounded-lg bg-zinc-100 pl-8 pr-3 text-[12px] text-zinc-800 outline-none placeholder:text-zinc-400"})]})}),d.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-2 pb-2",children:[nt.map(he=>d.jsxs("button",{type:"button",onClick:()=>oe(he.key),className:`flex w-full items-start gap-2.5 rounded-lg px-2.5 py-2.5 text-left ${he.key===G?"bg-zinc-100":"hover:bg-zinc-50"}`,children:[d.jsx(eu,{name:he.title,src:he.avatarUrl,fallbackSrc:he.avatarFallbackUrl,size:32}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsx("span",{className:"truncate text-[12px] font-medium text-zinc-800",children:he.title}),d.jsx("span",{className:"shrink-0 text-[9px] text-zinc-400",children:Ew(he.latestAt)})]}),d.jsx("p",{className:"mt-0.5 truncate text-[11px] text-zinc-500",children:he.latestText||"暂无消息"}),he.drafts.some(st=>st.state==="pending"||st.state==="failed")&&d.jsxs("span",{className:"mt-1 inline-flex items-center gap-1 text-[10px] text-amber-700",children:[d.jsx(Lo,{size:10}),"有回复待补发"]})]})]},he.key)),!nt.length&&d.jsx("p",{className:"px-3 py-8 text-center text-[11px] text-zinc-400",children:ge?"没有匹配的会话":"还没有会话"})]})]}),d.jsx("section",{className:"flex min-w-0 flex-1 flex-col",children:Qe?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-zinc-100 px-4 py-3",children:[d.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[d.jsx(eu,{name:Qe.title,src:Qe.avatarUrl,fallbackSrc:Qe.avatarFallbackUrl,size:30}),d.jsxs("div",{className:"min-w-0",children:[d.jsx("h3",{className:"truncate text-[13px] font-semibold text-zinc-900",children:Qe.title}),d.jsxs("p",{className:"text-[10px] text-zinc-400",children:[Qe.chatType==="p2p"?"私聊":Qe.chatType==="group"?"群聊":Qe.chatType||"飞书会话"," · ",Qe.items.length," 条消息",Qe.drafts.length?` · ${Qe.drafts.length} 条回复`:""]})]})]}),d.jsxs("span",{className:"text-[10px] text-zinc-400",children:[tt.filter(he=>Qe.drafts.some(st=>st.id===he.id)).length," 条待补发"]})]}),d.jsx("div",{ref:Ie,className:"min-h-0 flex-1 overflow-y-auto bg-zinc-50/40 px-5 py-4",children:Ge.length?d.jsx(d.Fragment,{children:Ge.map(he=>{var On,bo,zd,Md,$d,Ct,Lt;if(he.kind==="draft"){const xn=he.draft;return d.jsx("div",{children:d.jsx(lme,{draft:xn,body:fe[xn.id]??xn.body,onBody:gr=>Ce(Zn=>({...Zn,[xn.id]:gr})),onSend:()=>Ee.mutate(xn),onDiscard:()=>Se.mutate(xn.id),sending:Ee.isPending&&((On=Ee.variables)==null?void 0:On.id)===xn.id,discarding:Se.isPending&&Se.variables===xn.id,accountName:(zd=(bo=t.data)==null?void 0:bo.account)==null?void 0:zd.name,accountAvatarUrl:($d=(Md=t.data)==null?void 0:Md.account)==null?void 0:$d.avatarUrl})},xn.id)}const st=he.item,ot=st.title.trim().startsWith(b),wt=!!(st.senderId&&st.senderId===((Lt=(Ct=t.data)==null?void 0:Ct.account)==null?void 0:Lt.userId));return d.jsxs("div",{className:`mb-5 flex items-start gap-2.5 ${wt?"flex-row-reverse":""}`,children:[d.jsx(eu,{name:st.senderName||Qe.title,src:st.senderAvatarUrl,size:28}),d.jsxs("div",{className:`min-w-0 max-w-[78%] ${wt?"text-right":""}`,children:[d.jsxs("div",{className:`mb-1 flex flex-wrap items-center gap-2 ${wt?"justify-end":""}`,children:[d.jsx("span",{className:"text-[11px] font-medium text-zinc-700",children:st.senderName||Qe.title}),d.jsx("span",{className:"text-[10px] text-zinc-400",children:GC(st.occurredAt)}),ot&&d.jsx("span",{className:"rounded-full bg-sky-50 px-1.5 py-0.5 text-[9px] font-medium text-sky-700",children:"Agent 触发"})]}),d.jsx("div",{className:`inline-block whitespace-pre-wrap break-words rounded-2xl px-3.5 py-2.5 text-left text-[13px] leading-5 ${wt?"rounded-tr-md bg-sky-600 text-white":"rounded-tl-md border border-zinc-200 bg-white text-zinc-800"}`,children:st.title||st.summary})]})]},st.id)})}):d.jsx("div",{className:"grid h-full place-items-center text-center",children:d.jsxs("div",{children:[d.jsx(O1,{size:26,className:"mx-auto text-zinc-300"}),d.jsx("p",{className:"mt-2 text-[12px] text-zinc-400",children:"这个会话还没有消息"})]})})}),d.jsx("div",{className:"border-t border-zinc-100 p-3",children:d.jsxs("div",{className:"flex items-end gap-2 rounded-xl border border-zinc-200 bg-white p-2 focus-within:border-zinc-400",children:[d.jsx("textarea",{value:ce,onChange:he=>ve(he.target.value),onKeyDown:he=>{he.key==="Enter"&&!he.shiftKey&&(he.preventDefault(),ce.trim()&&!De.isPending&&De.mutate({conversation:Qe,body:ce}))},rows:1,placeholder:`发送给 ${Qe.title},Enter 发送,Shift+Enter 换行`,className:"max-h-28 min-h-8 flex-1 resize-none bg-transparent px-2 py-1.5 text-[12px] leading-5 text-zinc-800 outline-none placeholder:text-zinc-400"}),d.jsx("button",{type:"button","aria-label":"发送消息",disabled:!ce.trim()||De.isPending,onClick:()=>De.mutate({conversation:Qe,body:ce}),className:"grid h-8 w-8 shrink-0 place-items-center rounded-full bg-zinc-900 text-white transition-opacity hover:bg-zinc-800 disabled:opacity-30",children:d.jsx(mN,{size:13})})]})})]}):d.jsx("div",{className:"grid h-full place-items-center text-center",children:d.jsxs("div",{children:[d.jsx(O1,{size:28,className:"mx-auto text-zinc-300"}),d.jsx("p",{className:"mt-2 text-[12px] text-zinc-400",children:"选择左侧会话查看消息"})]})})})]}),c==="settings"&&d.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-zinc-50/60",children:[d.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-3 sm:p-5",children:d.jsxs("div",{className:"mx-auto max-w-[820px] space-y-4",children:[d.jsxs("section",{className:"rounded-2xl border border-zinc-200/80 bg-white p-4 shadow-[0_1px_2px_rgba(24,24,27,.03)] sm:p-5",children:[d.jsxs("div",{className:"flex items-start gap-3",children:[d.jsx("span",{className:"grid h-8 w-8 shrink-0 place-items-center rounded-xl bg-zinc-100 text-zinc-600",children:d.jsx(Hb,{size:15})}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[d.jsx("h3",{className:"text-[14px] font-semibold text-zinc-900",children:"账号与连接"}),d.jsx(YC,{connected:(Rt=t.data)==null?void 0:Rt.connected,state:(se=t.data)==null?void 0:se.state,listening:(gt=t.data)==null?void 0:gt.listening})]}),d.jsx("p",{className:"mt-1 text-[11px] leading-5 text-zinc-500",children:qe?"本人身份常驻在线,WebSocket 接收消息并定时补拉群聊。":"监听已暂停,WebSocket 和定时补拉均已停止;登录凭证仍保留在本机。"})]})]}),d.jsxs("div",{className:"mt-4 grid gap-x-6 gap-y-3 rounded-xl bg-zinc-50/80 px-4 py-3 sm:grid-cols-2",children:[d.jsxs("div",{children:[d.jsx("span",{className:qs,children:"当前账号"}),d.jsx("p",{className:"mt-1 text-[12px] font-medium text-zinc-800",children:((tn=(bt=t.data)==null?void 0:bt.account)==null?void 0:tn.name)||"飞书账号"})]}),d.jsxs("div",{children:[d.jsx("span",{className:qs,children:"用户 ID"}),d.jsx("p",{className:"mt-1 truncate font-mono text-[11px] text-zinc-600",children:((Un=(Nn=t.data)==null?void 0:Nn.account)==null?void 0:Un.userId)||"—"})]}),d.jsxs("div",{children:[d.jsx("span",{className:qs,children:"区域"}),d.jsx("p",{className:"mt-1 text-[12px] text-zinc-700",children:((Fn=t.data)==null?void 0:Fn.region)==="lark"?"Lark 国际版":"飞书中国版"})]}),d.jsxs("div",{children:[d.jsx("span",{className:qs,children:"同步"}),d.jsxs("p",{className:"mt-1 text-[12px] text-zinc-700",children:["每 ",((Wi=t.data)==null?void 0:Wi.syncIntervalSeconds)??30," 秒补拉"]}),d.jsx("p",{className:"mt-0.5 text-[10px] text-zinc-400",children:(ki=t.data)!=null&&ki.lastSyncedAt?`最近 ${GC(t.data.lastSyncedAt)}`:"等待首次同步"})]})]}),d.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[d.jsx(zn,{size:"small",icon:qe?d.jsx($0,{size:12}):d.jsx(z_,{size:12}),loading:pe.isPending,onClick:()=>pe.mutate(!qe),children:qe?"暂停监听":"恢复监听"}),d.jsx(zn,{size:"small",onClick:()=>{f(!0),$e.mutate(p)},children:"重新扫码"}),d.jsx(zn,{size:"small",danger:!0,loading:le.isPending,onClick:()=>le.mutate(),children:"断开账号"}),d.jsx("span",{className:"ml-auto text-[10px] text-zinc-400",children:"凭证仅保存在本机 SQLite"})]})]}),d.jsxs("section",{className:"rounded-2xl border border-zinc-200/80 bg-white p-4 shadow-[0_1px_2px_rgba(24,24,27,.03)] sm:p-5",children:[d.jsxs("div",{className:"flex items-start gap-3",children:[d.jsx("span",{className:"grid h-8 w-8 shrink-0 place-items-center rounded-xl bg-zinc-100 text-zinc-600",children:d.jsx(ti,{size:15})}),d.jsxs("div",{children:[d.jsx("h3",{className:"text-[14px] font-semibold text-zinc-900",children:"Agent 配置"}),d.jsx("p",{className:"mt-1 text-[11px] leading-5 text-zinc-500",children:"选择处理 /ai 轮次的 Agent、模型和运行目录。"})]})]}),d.jsxs("div",{className:"mt-4 grid gap-4 sm:grid-cols-2",children:[d.jsxs("label",{className:"block",children:[d.jsx("span",{className:qs,children:"Agent"}),d.jsx(ua,{options:ke,value:L,placeholder:"选择 Agent",disabledText:"没有可用 Agent",popupWidth:380,onChange:he=>{q(he),J(""),ne("")}})]}),d.jsxs("label",{className:"block",children:[d.jsx("span",{className:qs,children:"默认模型"}),d.jsx(ua,{options:pt,value:X,placeholder:"选择模型",disabledText:"暂无可用模型",disabled:!((Wt=de.data)!=null&&Wt.models.length),popupWidth:380,onChange:J})]}),d.jsxs("label",{className:"block",children:[d.jsx("span",{className:qs,children:"推理强度"}),d.jsx(ua,{options:mt,value:ae,placeholder:"选择推理强度",disabledText:"当前 Agent 未提供推理强度",disabled:!((Nt=de.data)!=null&&Nt.reasoningEfforts.length),popupWidth:300,onChange:ne})]}),d.jsxs("div",{className:"block",children:[d.jsx("span",{className:qs,children:"工作目录"}),d.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[d.jsx("div",{className:"min-w-0 flex-1",children:d.jsx(IE,{value:re,onChange:ie,label:"工作目录",placeholder:"留空使用默认工作目录",suggestion:(Oe==null?void 0:Oe.cwd)||((Ht=i.data)==null?void 0:Ht.workingDirectory),suggestionLabel:"使用 Agent 默认工作目录"})}),d.jsx(zn,{size:"small",icon:d.jsx(ha,{size:12}),loading:_e.isPending,disabled:!((En=i.data)!=null&&En.directoryPicker),onClick:()=>_e.mutate(),children:"选择"})]})]}),d.jsxs("label",{className:"block",children:[d.jsx("span",{className:qs,children:"单轮超时(秒)"}),d.jsx("input",{className:lu,type:"number",min:0,max:86400,value:M,onChange:he=>P(Math.min(86400,Math.max(0,Number(he.target.value)||0)))}),d.jsx("p",{className:"mt-1 text-[10px] leading-4 text-zinc-400",children:"0 表示不限制;超时后会结束本轮。"})]}),d.jsxs("div",{className:"block",children:[d.jsx("span",{className:qs,children:"Agent 记忆范围"}),d.jsx(jw,{value:C,onChange:_,options:[{value:"anchor",label:"按话题隔离"},{value:"chat",label:"整个会话共享"}]}),d.jsx("p",{className:"mt-1 text-[10px] leading-4 text-zinc-400",children:"按话题隔离:每个飞书话题有独立的 Agent 会话;整个会话共享:同一聊天里的不同话题共用一段记忆。"})]})]}),d.jsx("p",{className:"mt-3 text-[11px] leading-5 text-zinc-400",children:de.isFetching?"正在读取 Agent 能力…":((_n=de.data)==null?void 0:_n.warning)||"修改 Agent 配置后,下一次 /ai 触发会创建对应的新会话。"})]}),d.jsxs("section",{className:"rounded-2xl border border-zinc-200/80 bg-white p-4 shadow-[0_1px_2px_rgba(24,24,27,.03)] sm:p-5",children:[d.jsxs("div",{className:"flex items-start gap-3",children:[d.jsx("span",{className:"grid h-8 w-8 shrink-0 place-items-center rounded-xl bg-zinc-100 text-zinc-600",children:d.jsx(Sx,{size:15})}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[d.jsx("h3",{className:"text-[14px] font-semibold text-zinc-900",children:"消息监听"}),d.jsx("span",{className:"rounded-full bg-zinc-100 px-2 py-0.5 text-[10px] text-zinc-500",children:A==="all"?"全部会话":`已选 ${F.length} 个`})]}),d.jsx("p",{className:"mt-1 text-[11px] leading-5 text-zinc-500",children:"决定读取哪些会话的消息和上下文。默认监听账号可见的全部会话。"})]})]}),d.jsx("div",{className:"mt-4 grid grid-cols-2 gap-1 rounded-xl bg-zinc-100 p-1",children:[["all","全部会话"],["selected","指定会话"]].map(([he,st])=>d.jsx("button",{type:"button",onClick:()=>D(he),className:`rounded-lg px-3 py-2 text-[12px] font-medium transition-colors ${A===he?"bg-white text-zinc-900 shadow-sm":"text-zinc-500 hover:text-zinc-800"}`,children:st},he))}),A==="all"?d.jsxs("div",{className:"mt-3 flex items-start gap-2.5 rounded-xl border border-emerald-100 bg-emerald-50/60 px-3.5 py-3 text-emerald-900",children:[d.jsx(_x,{size:15,className:"mt-0.5 shrink-0"}),d.jsxs("div",{children:[d.jsx("p",{className:"text-[12px] font-medium",children:"正在监听全部会话"}),d.jsx("p",{className:"mt-0.5 text-[11px] leading-5 text-emerald-700",children:"群聊和私聊都会进入上下文,并在每次触发时读取最近消息。"})]})]}):d.jsxs("div",{className:"mt-3 space-y-3",children:[F.length>0&&d.jsx("div",{className:"flex flex-wrap gap-1.5",children:F.map(he=>{const st=Ye.find(ot=>ot.id===he);return d.jsxs("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-lg border border-zinc-200 bg-zinc-50 py-1 pl-2 pr-1 text-[11px] text-zinc-700",children:[d.jsx("span",{className:"max-w-[240px] truncate",children:st&&st.type!=="unknown"?st.name:he}),d.jsx("button",{type:"button","aria-label":`移除 ${(st==null?void 0:st.name)||he}`,onClick:()=>Q(he),className:"grid h-4 w-4 place-items-center rounded text-zinc-400 hover:bg-zinc-200 hover:text-zinc-700",children:d.jsx(Wn,{size:10})})]},he)})}),d.jsxs("div",{className:"overflow-hidden rounded-xl border border-zinc-200",children:[d.jsxs("div",{className:"flex items-center gap-2 border-b border-zinc-100 bg-zinc-50/70 p-2",children:[d.jsxs("div",{className:"relative min-w-0 flex-1",children:[d.jsx(fa,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-zinc-400"}),d.jsx("input",{value:T,onChange:he=>W(he.target.value),placeholder:"搜索群名或 Chat ID",className:"h-8 w-full rounded-lg border border-zinc-200 bg-white pl-8 pr-3 text-[12px] text-zinc-800 outline-none placeholder:text-zinc-400 focus:border-zinc-400"})]}),d.jsx("button",{type:"button",disabled:Le.isFetching,onClick:()=>void Le.refetch(),className:"grid h-8 w-8 shrink-0 place-items-center rounded-lg text-zinc-500 hover:bg-zinc-200 disabled:opacity-40","aria-label":"刷新会话列表",children:d.jsx(Hn,{size:13,className:Le.isFetching?"animate-spin":""})})]}),d.jsxs("div",{className:"max-h-[230px] overflow-y-auto p-1.5",children:[ze.map(he=>{const st=F.includes(he.id);return d.jsxs("button",{type:"button",onClick:()=>Q(he.id),className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors ${st?"bg-zinc-100":"hover:bg-zinc-50"}`,children:[d.jsx(eu,{name:he.name,src:he.avatarUrl,fallbackSrc:he.avatarFallbackUrl,size:30}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("p",{className:"truncate text-[12px] font-medium text-zinc-800",children:he.name}),d.jsxs("p",{className:"truncate text-[10px] text-zinc-400",children:[ome(he.type),he.memberCount?` · ${he.memberCount} 人`:""," · ",he.id]})]}),d.jsx("span",{className:`grid h-5 w-5 shrink-0 place-items-center rounded-full border ${st?"border-zinc-900 bg-zinc-900 text-white":"border-zinc-300 text-transparent"}`,children:d.jsx(gi,{size:11})})]},he.id)}),!ze.length&&d.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-zinc-400",children:Le.isFetching?"正在读取飞书会话…":T?"没有匹配的会话":"暂无可选会话,可使用下方手动输入"})]})]}),d.jsxs("details",{className:"group rounded-xl border border-zinc-200 px-3 py-2",children:[d.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between text-[11px] font-medium text-zinc-500",children:[d.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[d.jsx(FZ,{size:12}),"手动输入 Chat ID"]}),d.jsx("span",{className:"text-[10px] text-zinc-400 group-open:hidden",children:"展开"}),d.jsx("span",{className:"hidden text-[10px] text-zinc-400 group-open:inline",children:"收起"})]}),d.jsx("input",{className:`${lu} font-mono`,value:B,placeholder:"oc_1, oc_2",onChange:he=>V(he.target.value),onBlur:()=>O(hO(B))}),d.jsx("p",{className:"mt-1 text-[10px] leading-4 text-zinc-400",children:"留空并切到「全部会话」可监听所有会话。"})]})]}),d.jsx("p",{className:"mt-3 text-[10px] leading-4 text-zinc-400",children:"最近消息面板最多保留 60 条消息,写入新消息时立即丢弃最旧记录;回复记录最多保留 80 条,待发送的会保留。图片不会下载,只保存占位摘要。"})]}),d.jsxs("section",{className:"rounded-2xl border border-zinc-200/80 bg-white p-4 shadow-[0_1px_2px_rgba(24,24,27,.03)] sm:p-5",children:[d.jsxs("div",{className:"flex items-start gap-3",children:[d.jsx("span",{className:"grid h-8 w-8 shrink-0 place-items-center rounded-xl bg-zinc-100 text-zinc-600",children:d.jsx(O1,{size:15})}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[d.jsx("h3",{className:"text-[14px] font-semibold text-zinc-900",children:"回复方式"}),d.jsx("span",{className:"rounded-full bg-sky-50 px-2 py-0.5 text-[10px] font-medium text-sky-700",children:"发送位置"})]}),d.jsx("p",{className:"mt-1 text-[11px] leading-5 text-zinc-500",children:"控制 Agent 的回复发到主会话、原话题,还是以引用或新话题发送。"})]})]}),d.jsxs("div",{className:"mt-4 space-y-3",children:[d.jsx("div",{className:"rounded-xl border border-zinc-200 px-3.5 py-3",children:d.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsx("p",{className:"text-[12px] font-medium text-zinc-800",children:"话题内的消息"}),d.jsx("p",{className:"mt-0.5 text-[11px] leading-5 text-zinc-500",children:"回复到原话题,或发到外面的主会话。"})]}),d.jsx("div",{className:"w-[210px] shrink-0",children:d.jsx(jw,{value:k?"in":"out",onChange:he=>j(he==="in"),options:[{value:"in",label:"话题内"},{value:"out",label:"主会话"}]})})]})}),d.jsx("div",{className:"rounded-xl border border-zinc-200 px-3.5 py-3",children:d.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsx("p",{className:"text-[12px] font-medium text-zinc-800",children:"主会话的消息"}),d.jsx("p",{className:"mt-0.5 text-[11px] leading-5 text-zinc-500",children:"私聊不支持话题,选择「开话题回复」时按引用发送。"})]}),d.jsx("div",{className:"w-[300px] shrink-0",children:d.jsx(jw,{value:z,onChange:N,options:[{value:"direct",label:"直接发送"},{value:"quote",label:"引用回复"},{value:"thread",label:"开话题回复"}]})})]})}),d.jsx("div",{className:"rounded-xl border border-zinc-200 px-3.5 py-3",children:d.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsx("p",{className:"text-[12px] font-medium text-zinc-800",children:"随机表情回应"}),d.jsx("p",{className:"mt-0.5 text-[11px] leading-5 text-zinc-500",children:"触发后先在原消息上加 2–3 个随机飞书表情,再开始生成回复。"})]}),d.jsx(js,{size:"small","aria-label":"随机表情回应",checked:I,onChange:$})]})}),d.jsxs("label",{className:"block rounded-xl border border-zinc-200 px-3.5 py-3",children:[d.jsx("span",{className:"text-[12px] font-medium text-zinc-800",children:"回复署名(可选)"}),d.jsx("input",{className:lu,value:R,maxLength:100,onChange:he=>E(he.target.value),placeholder:"例如:—— 🤖 数字分身"}),d.jsx("p",{className:"mt-1 text-[10px] leading-4 text-zinc-400",children:"加在 Agent 发出的每条消息末尾;手动发送的消息不加。"})]})]})]}),d.jsxs("section",{className:"rounded-2xl border border-zinc-200/80 bg-white p-4 shadow-[0_1px_2px_rgba(24,24,27,.03)] sm:p-5",children:[d.jsxs("div",{className:"flex items-start gap-3",children:[d.jsx("span",{className:"grid h-8 w-8 shrink-0 place-items-center rounded-xl bg-zinc-100 text-zinc-600",children:d.jsx(hX,{size:15})}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[d.jsx("h3",{className:"text-[14px] font-semibold text-zinc-900",children:"触发规则"}),d.jsx("span",{className:"rounded-full bg-sky-50 px-2 py-0.5 text-[10px] font-medium text-sky-700",children:"仅本人可触发"})]}),d.jsx("p",{className:"mt-1 text-[11px] leading-5 text-zinc-500",children:"只有你本人发送匹配前缀的消息才会发起 Agent 轮次;其他人的消息只作为上下文,即使发送相同前缀也不会触发。"})]})]}),d.jsxs("div",{className:"mt-4 grid gap-4 sm:grid-cols-2",children:[d.jsxs("label",{className:"block",children:[d.jsx("span",{className:qs,children:"触发前缀"}),d.jsx("input",{className:lu,value:b,placeholder:"/ai",onChange:he=>y(he.target.value)})]}),d.jsxs("label",{className:"block",children:[d.jsx("span",{className:qs,children:"每轮注入条数(1–50)"}),d.jsx("input",{className:lu,type:"number",min:1,max:50,value:w,onChange:he=>S(Number(he.target.value)||10)}),d.jsx("p",{className:"mt-1 text-[10px] leading-4 text-zinc-400",children:"每次触发时,附上最近 N 条文字消息(含本条触发消息)给 Agent;不是 Agent 的记忆条数,也不影响最近消息面板的保留上限。"})]})]}),d.jsxs("div",{className:"mt-3 rounded-xl bg-zinc-50 px-3.5 py-2.5 text-[11px] leading-5 text-zinc-500",children:["你发送 ",d.jsxs("code",{className:"rounded bg-white px-1 py-0.5 font-mono text-zinc-700",children:[b," 你的问题"]})," 即触发;所有 AgentText 会直接以你的身份发回原会话。"]})]}),d.jsxs("section",{className:"flex items-start gap-2.5 rounded-2xl border border-amber-200/70 bg-amber-50/60 p-4",children:[d.jsx(tf,{size:15,className:"mt-0.5 shrink-0 text-amber-600"}),d.jsxs("div",{children:[d.jsx("h3",{className:"text-[12px] font-semibold text-amber-900",children:"使用风险"}),d.jsx("p",{className:"mt-1 text-[11px] leading-5 text-amber-800",children:"替身以你的飞书身份读取和发送消息,Agent 输出会直接发出。请只监听可信会话,并确认 Agent 的权限边界。"})]})]})]})}),d.jsx("div",{className:"shrink-0 border-t border-zinc-200/80 bg-white px-4 py-3",children:d.jsxs("div",{className:"mx-auto flex max-w-[820px] flex-wrap items-center justify-between gap-3",children:[d.jsx("p",{className:"text-[11px] text-zinc-500",children:"修改后点击保存,后续消息立即使用新规则。"}),d.jsx(zn,{type:"primary",onClick:()=>me.mutate(),className:"!rounded-lg !bg-zinc-900",children:"保存配置"})]})})]}),Ai.createPortal(Pe.toast,document.body)]})}function ume({value:e,onChange:t}){return d.jsx(IE,{value:e,onChange:t,label:"Web 访问地址",placeholder:"留空不显示详情链接,可选择当前地址",suggestion:typeof window>"u"?void 0:window.location.origin,suggestionLabel:"使用当前访问地址"})}function ZC(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,i])=>t.indexOf(+r)===-1).map(([r,i])=>i)}function fO(e,t="|"){return e.map(n=>s9(n)).join(t)}function XC(e,t){return typeof t=="bigint"?t.toString():t}class dme{constructor(t){this._getter=t,this._value=void 0}get value(){const t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}}function RE(e){return new dme(e)}function hme(e){return e==null}function OE(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function fme(e,t){const n=e/t,r=Math.round(n),i=4*Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function Dc(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function e9(e){const t=Object.getOwnPropertyDescriptor(e,"shape");return t!=null&&t.get?t.get.raw:t==null?void 0:t.value}function hl(e){return e9(e._zod.def)??e._zod.def.shape}function t9(e,t,n){Object.defineProperty(e,t,{get(){const r=n();return Dc(this,t,r),r},enumerable:!0,configurable:!0})}function n9(e,t,n){t in e?Dc(e,t,n):e[t]=n}function cd(e,t,n,r){const i=hl(t);for(const s of n){const o=Object.getOwnPropertyDescriptor(i,s);o.enumerable&&(o.get?t9(e,s,()=>{const a=t._zod.def.shape[s];return r?r(a,s):a}):n9(e,s,r?r(o.value,s):o.value))}}function pme(e,t){for(const n of Reflect.ownKeys(t)){const r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?t9(e,n,()=>t[n]):n9(e,n,r.value))}}function zs(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function mme(e){return JSON.stringify(e)}function gme(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const r9="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Yx(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const vme=RE(()=>{var e;if(Fo.jitless||typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function lf(e){if(Yx(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Yx(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function i9(e){return lf(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const xme=new Set(["string","number","symbol"]);function My(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Lc(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function Ot(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function s9(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function bme(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const o9={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},yme={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function wme(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s={};return cd(s,e,$y(e,t)),Lc(e,zs(n,{shape:s,checks:[]}))}function $y(e,t){var i;const n=hl(e),r=[];for(const s of Reflect.ownKeys(t)){if(!((i=Object.getOwnPropertyDescriptor(n,s))!=null&&i.enumerable))throw new Error(`Unrecognized key: "${String(s)}"`);t[s]&&r.push(s)}return r}function Sme(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=new Set($y(e,t)),o={};return cd(o,e,Reflect.ownKeys(hl(e)).filter(a=>!s.has(a))),Lc(e,zs(n,{shape:o,checks:[]}))}function _me(e,t){if(!lf(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=hl(e);for(const s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Lc(e,zs(e._zod.def,{shape:a9(e,t)}))}function a9(e,t){const n={};return cd(n,e,Reflect.ownKeys(hl(e))),pme(n,t),n}function Cme(e,t){if(!lf(t))throw new Error("Invalid input to safeExtend: expected a plain object");return Lc(e,zs(e._zod.def,{shape:a9(e,t)}))}function kme(e,t){var i,s;if(!((i=t==null?void 0:t._zod)!=null&&i.def))throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if((s=e._zod.def.checks)!=null&&s.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n={};cd(n,e,Reflect.ownKeys(hl(e))),cd(n,t,Reflect.ownKeys(hl(t)));const r=zs(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Lc(e,r)}function pO(e,t,n,r="partial"){const s=t._zod.def.checks;if(s&&s.length>0)throw new Error(`.${r}() cannot be used on object schemas containing refinements`);const a=n?new Set($y(t,n)):void 0,l={};return cd(l,t,Reflect.ownKeys(hl(t)),e&&((c,u)=>a&&!a.has(u)?c:new e({type:"optional",innerType:c}))),Lc(t,zs(t._zod.def,{shape:l,checks:[]}))}function Nme(e,t,n){const r=n?new Set($y(t,n)):void 0,i={};return cd(i,t,Reflect.ownKeys(hl(t)),(s,o)=>r&&!r.has(o)?s:new e({type:"nonoptional",innerType:s})),Lc(t,zs(t._zod.def,{shape:i}))}function Ua(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function Eme(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)===!1)return!0;return!1}function ah(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function hp(e){return typeof e=="string"?e:e==null?void 0:e.message}function mO(e){const t=[];for(const n of e??[]){const r=n._zod.def;if(!/_(length|size)$|_equals$/.test(r.check))break;const i=r.maximum??r.length??r.size;i>=0&&t.push([i,n])}return t}function JC(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function kc(e,t,n){var l,c,u,h,f,p,g,x,v,b;var r;const i=(c=(l=e.inst)==null?void 0:l._zod)==null?void 0:c.traits;i!=null&&i.has("$ZodType")&&(i.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);const s=e.schema!==e.inst?(h=(u=e.schema)==null?void 0:u._zod.def)==null?void 0:h.error:void 0,o=e.message?e.message:hp((g=(p=(f=e.inst)==null?void 0:f._zod.def)==null?void 0:p.error)==null?void 0:g.call(p,e))??hp(s==null?void 0:s(e))??hp((x=t==null?void 0:t.error)==null?void 0:x.call(t,e))??hp((v=n.customError)==null?void 0:v.call(n,e))??hp((b=n.localeError)==null?void 0:b.call(n,e))??"Invalid input",a={};for(const y of Object.keys(e))y==="inst"||y==="schema"||y==="continue"||y==="input"||y==="__proto__"||(a[y]=e[y]);return a.path??(a.path=[]),a.message=o,t!=null&&t.reportInput&&(a.input=e.input),a}const jme=/[\uD800-\uDBFF]/;function PE(e){const t=e.length;if(!jme.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)===55296&&(e.charCodeAt(r+1)&64512)===56320&&(n--,r++);return n}function TE(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function zme(e){const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";const n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function Km(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function Mme(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):$me(e,n,r.value)}}function Nc(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function l9(e,t,n){return Nc(e,t,n,!1)}function c9(e,t){for(const n in e){const r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Nc(this,n,r(this))},set(i){Nc(this,n,i)}})}return t}function $me(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Nc(this,t,n.bind(this))},set(r){Nc(this,t,r)}})}function Ime(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let zw,Pl=!1;const Rme={configurable:!0,get(){Pl=!0}};function Pn(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&zw!==e._zod){zw=void 0;return}zw=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Rme);const i=Pl;Pl=!1;try{const s=n(this);return Pl?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s}),Pl=Pl||i,s}catch(s){throw delete this[t],Pl=Pl||i,s}},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i})}})}function Ome(e,t,n,r){const i=Ime(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){const s={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,s),s.value=n(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:s})}})}const Pme="~constantCatch";function Tme(e){const t=()=>e;return t[Pme]=!0,t}var gO;const Mw={value:void 0,enumerable:!1};let vO="captureStackTrace"in Error?Error:null;function Ame(e){const t=vO;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return vO=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function Ue(e,t,n,r){const i={};function s(f){this.def=f,this.constr=h,this.traits=new Set}s.prototype=i;const o=n,a=o&&new WeakSet;function l(f,p){if(f._zod){if(f._zod.traits.has(e))return}else{Mw.value=new s(p);try{Object.defineProperty(f,"_zod",Mw)}finally{Mw.value=void 0}}if(f._zod.traits.add(e),t(f,p),a){const x=Object.getPrototypeOf(f),v=f._zod.constr.prototype;let b=x;for(;b&&b!==v;)b=Object.getPrototypeOf(b);const y=b??x;a.has(y)||(a.add(y),Mme(y,o))}const g=h.prototype;for(const x in g)Object.prototype.hasOwnProperty.call(g,x)&&(x in f||(f[x]=g[x].bind(f)))}const c=(r==null?void 0:r.Parent)??Object;class u extends c{}Object.defineProperty(u,"name",{value:e});function h(f){var v;const p=r!=null&&r.Parent?Ame(u):this;l(p,f);const g=p._zod.deferred;if(g){for(const b of g)b();p._zod.deferred=void 0}const x=(v=globalThis.__zod_globalConfig)==null?void 0:v.postProcessor;return x&&x(p),p}return Object.defineProperty(h,"init",{value:l}),Object.defineProperty(h,Symbol.hasInstance,{value:f=>{var p,g;return r!=null&&r.Parent&&f instanceof r.Parent?!0:(g=(p=f==null?void 0:f._zod)==null?void 0:p.traits)==null?void 0:g.has(e)}}),Object.defineProperty(h,"name",{value:e}),h}class Du extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class u9 extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(gO=globalThis).__zod_globalConfig??(gO.__zod_globalConfig={});const Fo=globalThis.__zod_globalConfig;function xa(e){return e&&Object.assign(Fo,e),Fo}function Dme(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,XC,2)),e.message}function Lme(e){this._zod.message=e}const Fme={get:Dme,set:Lme,enumerable:!0,configurable:!0},$w={value:void 0,enumerable:!1},xO=new WeakSet([Object.prototype,Error.prototype]),Bme=(e,t)=>{e.name="$ZodError",$w.value=t,Object.defineProperty(e,"issues",$w),$w.value=void 0,Object.defineProperty(e,"message",Fme);const n=Object.getPrototypeOf(e);xO.has(n)||(xO.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){const r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}}))},Hme=Ue("$ZodError",Bme);function Vme(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function Wme(e,t=n=>n.message){const n={},r=[];for(const i of e.issues)i.path.length>0?Vme(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function qme(e,t=n=>n.message){const n={_errors:[]},r=(i,s=[])=>{for(const o of i.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(a=>r({issues:a},[...s,...o.path]));else if(o.code==="invalid_key")r({issues:o.issues},[...s,...o.path]);else if(o.code==="invalid_element")r({issues:o.issues},[...s,...o.path]);else{const a=[...s,...o.path];if(a.length===0)n._errors.push(t(o));else{let l=n,c=0;for(;c<a.length;){const u=a[c],h=c===a.length-1;if(u==="_errors"){h&&l._errors.push(t(o)),c++;continue}Object.prototype.hasOwnProperty.call(l,u)||Object.defineProperty(l,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const f=l[u];h&&f._errors.push(t(o)),l=f,c++}}}};return r(e),n}function Iy(e,t){return{callee:(t==null?void 0:t.callee)??e,Err:t==null?void 0:t.Err}}const AE=e=>{const t=(n,r,i,s)=>{const o=i?{...i,async:!1}:{async:!1},a=n._zod.run({value:r,issues:[]},o);if(a instanceof Promise)throw new Du;if(a.issues.length){const l=new((s==null?void 0:s.Err)??e)(a.issues.map(c=>kc(c,o,xa())));throw r9(l,(s==null?void 0:s.callee)??t),l}return a.value};return t},DE=e=>{const t=async(n,r,i,s)=>{const o=i?{...i,async:!0}:{async:!0};let a=n._zod.run({value:r,issues:[]},o);if(a instanceof Promise&&(a=await a),a.issues.length){const l=new((s==null?void 0:s.Err)??e)(a.issues.map(c=>kc(c,o,xa())));throw r9(l,(s==null?void 0:s.callee)??t),l}return a.value};return t},LE=e=>(t,n,r)=>{const i=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new Du;return s.issues.length?d9(e,s.issues,i):{success:!0,data:s.value}};function d9(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(i=>kc(i,n,xa()))),t=void 0,n=void 0),r},set error(i){r=i,t=void 0,n=void 0}}}const FE=e=>async(t,n,r)=>{const i=r?{...r,async:!0}:{async:!0};let s=t._zod.run({value:n,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?d9(e,s.issues,i):{success:!0,data:s.value}},Ume=Symbol.for("zod.compile.invalid"),Kme=Symbol.for("zod.compile.fallback"),Gme=((e,t,n)=>{const r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Ume)return!0;if(r.definite===!0&&n===void 0)return!1}return Yme(e,t,n)});function Yme(e,t,n){const r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun;let s;if(i?(r[Kme]=!0,s=i({value:t,issues:[]},r)):s=e._zod.run({value:t,issues:[]},r),s instanceof Promise)throw new Du;return s.issues.length===0}const Zme=async(e,t,n)=>{const r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0};let i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},Xme=e=>{const t=AE(e),n=(r,i,s,o)=>{const a=s?{...s,direction:"backward"}:{direction:"backward"};return t(r,i,a,Iy(n,o))};return n},Jme=e=>{const t=AE(e),n=(r,i,s,o)=>t(r,i,s,Iy(n,o));return n},Qme=e=>{const t=DE(e),n=async(r,i,s,o)=>{const a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(r,i,a,Iy(n,o))};return n},ege=e=>{const t=DE(e),n=async(r,i,s,o)=>await t(r,i,s,Iy(n,o));return n},tge=e=>(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return LE(e)(t,n,i)},nge=e=>(t,n,r)=>LE(e)(t,n,r),rge=e=>async(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return FE(e)(t,n,i)},ige=e=>async(t,n,r)=>FE(e)(t,n,r),sge=/^[cC][0-9a-z]{6,}$/,oge=/^[0-9a-z]+$/,age=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,lge=/^[0-9a-vA-V]{20}$/,cge=/^[A-Za-z0-9]{27}$/,uge=/^[a-zA-Z0-9_-]{21}$/;function dge(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const hge=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,fge=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,bO=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,pge=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,mge="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function gge(){return new RegExp(mge,"u")}const vge=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,xge=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,bge=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,yge=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,wge=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Sge=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,_ge=/^https?$/,Cge=/^\+[1-9]\d{6,14}$/,h9="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function kge(e){return new RegExp(`^${e}$`)}const Nge=kge(h9);function QC(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Ege(e){return new RegExp(`^${QC(e)}$`)}function jge(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${QC({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${QC({precision:e.precision})}`:n;return new RegExp(`^${h9}T(?:${r})$`)}const zge=/^[\s\S]{0,}$/,Mge=/^-?\d+$/,BE=/^-?\d+(?:\.\d+)?$/,$ge=/^(?:true|false)$/i,Ige=/^[^A-Z]*$/,Rge=/^[^a-z]*$/,ms=Ue("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),HE=e=>{const t=e.value;return!hme(t)&&t.length!==void 0},Zx={number:"number",bigint:"bigint",object:"date"},f9=Ue("$ZodCheckLessThan",(e,t)=>{ms.init(e,t);const n=Zx[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:Zx[typeof r.value]??n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),p9=Ue("$ZodCheckGreaterThan",(e,t)=>{ms.init(e,t);const n=Zx[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:Zx[typeof r.value]??n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Oge=Ue("$ZodCheckMultipleOf",(e,t)=>{ms.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):fme(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Pge=Ue("$ZodCheckNumberFormat",(e,t)=>{var o;ms.init(e,t),t.format=t.format||"float64";const n=(o=t.format)==null?void 0:o.includes("int"),r=n?"int":"number",[i,s]=o9[t.format];e._zod.check=a=>{const l=a.value;if(n){if(!Number.isInteger(l)){a.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:l,inst:e});return}if(!Number.isSafeInteger(l)){l>0?a.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):a.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}l<i&&a.issues.push({origin:"number",input:l,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),l>s&&a.issues.push({origin:"number",input:l,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),Tge=Ue("$ZodCheckMaxLength",(e,t)=>{var n;ms.init(e,t),(n=e._zod.def).when??(n.when=HE),e._zod.check=r=>{const i=r.value,s=i.length;if((typeof i=="string"&&s>t.maximum?PE(i):s)<=t.maximum)return;const a=TE(i);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Age=Ue("$ZodCheckMinLength",(e,t)=>{var n;ms.init(e,t),(n=e._zod.def).when??(n.when=HE),e._zod.check=r=>{const i=r.value,s=i.length;if((typeof i=="string"&&s>=t.minimum&&s<t.minimum*2?PE(i):s)>=t.minimum)return;const a=TE(i);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Dge=Ue("$ZodCheckLengthEquals",(e,t)=>{var n;ms.init(e,t),(n=e._zod.def).when??(n.when=HE),e._zod.check=r=>{const i=r.value,s=i.length,o=typeof i=="string"&&s>=t.length&&s<=t.length*2?PE(i):s;if(o===t.length)return;const a=TE(i),l=o>t.length;r.issues.push({origin:a,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Ry=Ue("$ZodCheckStringFormat",(e,t)=>{var n,r;ms.init(e,t),t.pattern?(n=e._zod).check??(n.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Lge=Ue("$ZodCheckRegex",(e,t)=>{Ry.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Fge=Ue("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ige),Ry.init(e,t)}),Bge=Ue("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Rge),Ry.init(e,t)}),Hge=Ue("$ZodCheckIncludes",(e,t)=>{ms.init(e,t);const n=My(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),Vge=Ue("$ZodCheckStartsWith",(e,t)=>{ms.init(e,t);const n=new RegExp(`^${My(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Wge=Ue("$ZodCheckEndsWith",(e,t)=>{ms.init(e,t);const n=new RegExp(`.*${My(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),qge=Ue("$ZodCheckOverwrite",(e,t)=>{ms.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Uge{constructor(t=[],n={}){this.content=[],this.indent=0,this.args=t,this.closed=n}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
850
+ `);if(!w||!y||y==="heartbeat"||y==="connected")continue;const S=JSON.parse(w);if(y==="error")throw new Error(S.message||"创建未完成,请重试。");if(y==="qrcode"){const C=new URL(S.url);if(C.protocol!=="https:"||!Number.isFinite(S.expireIn)||S.expireIn<=0)throw new Error("二维码信息无效,请重新生成。");a={kind:"waiting",url:C.href,expiresAt:Date.now()+S.expireIn*1e3,slow:!1},t(a)}if(y==="status"&&(S.status==="saving"?t({kind:"saving"}):a&&(a={...a,slow:S.status==="slow_down"},t(a))),y==="success"){if(typeof S.appId!="string"||!((f=(h=S.config)==null?void 0:h.bots)!=null&&f.some(C=>C.appId===S.appId)))throw new Error("创建结果不完整,请刷新机器人列表确认。");return S}}if(o.length>1e6)throw new Error("扫码进度响应异常,请重试。")}}finally{await i.cancel().catch(()=>{}),i.releaseLock()}}function Ype(){const[e,t]=m.useState({kind:"idle"}),n=m.useRef(void 0),r=bn(()=>{var s;(s=n.current)==null||s.abort(),n.current=void 0}),i=bn(async()=>{r();const s=new AbortController;n.current=s,t({kind:"starting"});try{const o=await Gpe(s.signal,a=>{n.current===s&&t(a)});n.current===s&&t({kind:"success",result:o})}catch(o){n.current===s&&!s.signal.aborted&&t({kind:"error",message:o instanceof Error?o.message:"创建失败,请重试。"})}finally{n.current===s&&(n.current=void 0)}});return Fg(r),{state:e,start:i,cancel:r}}function Zpe({onClose:e,onComplete:t}){const{state:n,start:r,cancel:i}=Ype(),s=m.useRef(null),o=m.useRef(null),a=()=>{i(),e()};Vo({panel:s,initial:o,dismissible:!0,onDismiss:a});const[l]=BY({targetDate:n.kind==="waiting"?n.expiresAt:void 0}),c=n.kind==="waiting"&&Date.now()>=n.expiresAt,u=n.kind==="starting"||n.kind==="saving",h="inline-flex min-h-9 items-center justify-center gap-1.5 rounded-md px-3 text-[12px] font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400 disabled:opacity-50";return d.jsx("div",{className:"ui-overlay fixed inset-0 z-50 grid place-items-center bg-zinc-950/30 p-4",onMouseDown:f=>{f.target===f.currentTarget&&a()},children:d.jsxs("div",{ref:s,role:"dialog","aria-modal":"true","aria-labelledby":"lark-registration-title",className:"ui-dialog flex max-h-[calc(100dvh-2rem)] w-full max-w-[440px] flex-col overflow-hidden rounded-[14px] border border-zinc-200 bg-white shadow-xl",children:[d.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-100 px-4 py-3",children:[d.jsx("h2",{id:"lark-registration-title",className:"text-[16px] font-semibold text-zinc-900",children:"扫码创建飞书机器人"}),d.jsx("button",{ref:o,type:"button","aria-label":"关闭扫码创建",onClick:a,className:`${h} text-zinc-500 hover:bg-zinc-100`,children:d.jsx(Wn,{size:16})})]}),d.jsxs("div",{className:"space-y-4 overflow-y-auto px-5 py-5 text-[12px] leading-5 text-zinc-600",children:[d.jsx("p",{children:"使用飞书扫码,在授权页确认应用名称和权限。完成后自动保存凭证,再配置工作区、可用成员和 Agent。"}),d.jsxs("div",{"aria-live":"polite",children:[n.kind==="idle"&&d.jsx("p",{className:"rounded-md bg-zinc-50 p-3",children:"将创建一个新应用。已有机器人的 App ID 和 App Secret 可通过手动配置接入。"}),u&&d.jsxs("div",{className:"flex min-h-40 flex-col items-center justify-center gap-3",children:[d.jsx(Gn,{size:24,className:"text-zinc-500"}),d.jsx("span",{children:n.kind==="saving"?"授权已完成,正在保存机器人…":"正在生成二维码…"})]}),n.kind==="waiting"&&!c&&d.jsxs("div",{className:"flex flex-col items-center gap-3",children:[d.jsx("div",{className:"w-full max-w-[248px] bg-white p-2",children:d.jsx(zy,{value:n.url,size:232,marginSize:4,className:"h-auto w-full",title:"使用飞书扫描二维码创建机器人"})}),d.jsx("p",{children:n.slow?"飞书暂时限流,正在继续等待授权…":"等待扫码并在飞书中确认授权"}),d.jsxs("p",{className:"text-[12px] text-zinc-400",children:["二维码将在 ",Math.max(1,Math.ceil(l/1e3))," 秒后过期"]}),d.jsxs("a",{href:n.url,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-zinc-700 underline underline-offset-4",children:["在浏览器打开授权页",d.jsx(Ja,{size:12})]})]}),(c||n.kind==="error")&&d.jsx("p",{role:"alert",className:"rounded-md bg-amber-50 p-3 text-amber-800",children:c?"二维码已过期,请重新生成。":n.kind==="error"?n.message:""}),n.kind==="success"&&d.jsxs("div",{className:"space-y-3",children:[d.jsxs("p",{className:"flex items-center gap-2 font-medium text-emerald-700",children:[d.jsx(gi,{size:18}),"机器人已创建,凭证已保存"]}),d.jsxs("div",{className:"border-y border-zinc-100 py-3",children:[d.jsx("p",{className:"break-words font-medium text-zinc-900",children:n.result.appName}),d.jsx("p",{className:"break-all font-mono text-[12px] text-zinc-500",children:n.result.appId})]}),d.jsx("p",{children:"接下来检查工作区和成员范围,再选择 Agent 完成接入。"}),n.result.warning&&d.jsx("p",{className:"text-amber-700",children:n.result.warning}),n.result.config.listeningDisabled&&d.jsx("p",{className:"text-amber-700",children:"当前服务已禁用飞书监听;完成配置后需启用监听才能接收消息。"})]})]})]}),d.jsxs("div",{className:"flex flex-wrap justify-end gap-2 border-t border-zinc-100 px-4 py-3",children:[d.jsx("button",{type:"button",onClick:a,className:`${h} border border-zinc-200 text-zinc-600 hover:bg-zinc-50`,children:n.kind==="idle"||n.kind==="error"?"返回手动配置":n.kind==="success"?"稍后配置":"取消"}),n.kind==="success"?d.jsx("button",{type:"button",onClick:()=>t(n.result),className:`${h} bg-zinc-900 text-white hover:bg-zinc-800`,children:"继续配置机器人"}):(n.kind==="idle"||n.kind==="error"||c)&&d.jsxs("button",{type:"button",onClick:()=>void r(),className:`${h} bg-zinc-900 text-white hover:bg-zinc-800`,children:[d.jsx(Hn,{size:12}),n.kind==="idle"?"生成二维码":"重新生成"]})]})]})})}function YH({url:e,size:t,className:n="h-full w-full rounded-md object-cover"}){const[r,i]=m.useState(!1);return r?d.jsx(ti,{size:t}):d.jsx("img",{src:e,alt:"",onError:()=>i(!0),className:n})}const cO={claude:"claudecode",claudecode:"claudecode",codex:"codex",copilot:"copilot",githubcopilot:"copilot",cursor:"cursor",cursoragent:"cursor",deepseek:"deepseek",deepseekharness:"deepseek",droid:"droid",factorydroid:"droid",fastagent:"fast-agent",gemini:"gemini",geminicli:"gemini",grokbuild:"grok",iflow:"iflow",iflowcli:"iflow",kilocode:"kilocode",kimi:"kimi",kimicli:"kimi",kiro:"kiro",kirocli:"kiro",mcode:"mcode",minimaxcode:"mcode",mux:"mux",openclaw:"openclaw",opencode:"opencode",pi:"pi",picodingagent:"pi",pool:"poolside",poolside:"poolside",qoder:"qoder",qodercli:"qoder",qwen:"qwen",qwencode:"qwen",trae:"trae",traecli:"trae",zeroclaw:"zeroclaw"},uO=new Set(["cursor","grok","kilocode","kimi","mux","opencode","pi"]);function Xpe(e,t){for(const n of[e,t]){const r=n==null?void 0:n.toLowerCase().replace(/[^a-z0-9]/g,"");if(r&&r in cO)return cO[r]}}function Hr({agentId:e,agentName:t,size:n=14,onDark:r=!1,className:i=""}){const s=Xpe(e,t);if(!s)return d.jsx(ti,{size:n,"aria-hidden":"true",className:`shrink-0 ${i}`});const o=s==="iflow"?"png":"svg";return d.jsx("img",{src:`/agent-icons/${s}.${o}`,width:n,height:n,alt:"","aria-hidden":"true",className:`shrink-0 object-contain ${uO.has(s)?"ui-mono-brand":""} ${r&&uO.has(s)?"brightness-0 invert":""} ${i}`})}function ua({options:e,value:t,placeholder:n,disabledText:r,disabled:i=!1,size:s="default",popupWidth:o,onChange:a}){var p;const l=e.map((g,x)=>({option:g,key:`${x}:${g.value}`})),c=(p=l.find(g=>g.option.value===t))==null?void 0:p.key,[u,h]=m.useState(()=>typeof window>"u"?1024:window.innerWidth);m.useEffect(()=>{const g=()=>h(window.innerWidth);return window.addEventListener("resize",g),()=>window.removeEventListener("resize",g)},[]);const f=typeof o=="number"?u<640?!0:Math.min(o,u-16):o;return d.jsx("div",{className:s==="sm"?"min-w-0 max-w-full":"mt-1.5 min-w-0 max-w-full",children:d.jsx(vi,{className:"w-full min-w-0 max-w-full",size:s==="sm"?"middle":"large",value:c,disabled:i||!e.length,placeholder:e.length?n:r,showSearch:e.length>8,optionFilterProp:"title",popupMatchSelectWidth:f??!0,listHeight:240,onChange:g=>{const x=l.find(v=>v.key===g);x&&a(x.option.value)},options:l.map(({option:g,key:x})=>({value:x,title:`${g.label} ${g.meta??""}`,label:d.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-2 overflow-hidden",children:[g.agentId&&d.jsx(Hr,{agentId:g.agentId,agentName:g.label,size:15}),d.jsx("span",{className:"min-w-0 flex-1 truncate",title:g.label,children:g.label}),g.meta&&d.jsx("span",{className:"hidden max-w-[50%] min-w-0 shrink truncate font-mono text-[12px] text-zinc-400 sm:inline",children:g.meta})]})}))})})}const Jpe="agentdock.agent_models.v1",Qpe=10080*6e4,ZH=()=>{try{return typeof window>"u"?void 0:window.localStorage}catch{return}},XH=(e,t)=>`${Jpe}:${encodeURIComponent(e)}:${encodeURIComponent(t??"")}`,dO=e=>Array.isArray(e)&&e.every(t=>t&&typeof t=="object"&&typeof t.id=="string"&&typeof t.name=="string"),JH=e=>{if(!e||typeof e!="object")return!1;const t=e;return dO(t.models)&&dO(t.reasoningEfforts)&&(t.defaultModel===void 0||typeof t.defaultModel=="string")&&(t.defaultReasoningEffort===void 0||typeof t.defaultReasoningEffort=="string")&&(t.warning===void 0||typeof t.warning=="string")&&(t.source===void 0||t.source==="acp"||t.source==="cli"||t.source==="agent")},ul=(e,t,n)=>["agent-models",e??"",t??"",n??"local"];function Cd(e,t,n=ZH(),r=Date.now()){if(!(!e||!n))try{const i=n.getItem(XH(e,t));if(!i)return;const s=JSON.parse(i);return typeof s.savedAt!="number"||r-s.savedAt>Qpe||!JH(s.value)?void 0:s.value}catch{return}}function eme(e,t,n,r=ZH(),i=Date.now()){if(!(!e||!r||!JH(n)))try{r.setItem(XH(e,t),JSON.stringify({savedAt:i,value:n}))}catch{}}function tme(e,t){return(t==null?void 0:t.source)==="acp"&&!t.warning&&(e.source!=="acp"||e.warning)?{...t,warning:`${e.warning??"本次未能读取完整 Agent 配置。"} 正在显示上次成功读取的选项。`}:e}async function dl(e,t,n=!1,r){const i=r?void 0:Cd(e,t);let s;try{s=await we.agentModels(e,t,n,r)}catch(a){if((i==null?void 0:i.source)!=="acp")throw a;return{...i,warning:"Agent 配置请求失败,正在显示上次成功读取的选项,可重新读取。"}}const o=tme(s,i);return!r&&!o.warning&&eme(e,t,o),o}function IE({value:e,onChange:t,label:n,placeholder:r,suggestion:i,suggestionLabel:s}){return d.jsxs("div",{className:"mt-1.5",children:[d.jsx(cy,{className:"w-full",value:e,onChange:t,options:i?[{value:i,label:d.jsxs("span",{className:"block py-0.5",children:[d.jsx("span",{className:"block text-[12px] font-medium text-zinc-700",children:s}),d.jsx("span",{className:"mt-0.5 block break-all font-mono text-[12px] text-zinc-500",children:i})]})}]:[],filterOption:!1,children:d.jsx(Qn,{size:"large","aria-label":n,placeholder:r,allowClear:!0,className:"font-mono text-[12px]"})}),e.trim()&&d.jsx("p",{className:"mt-1 break-all font-mono text-[12px] leading-4 text-zinc-400",title:e,children:e})]})}function nme(e){return e.enabled?e.agentSelectionSaved?e.persisted||e.hookInstalled:!1:!0}function rme(e){return e.enabled||e.agentSelectionSaved&&e.hookInstalled}function ime(e,t,n){return!e||n||!t||!t.reasoningEfforts.length||t.reasoningEfforts.some(r=>r.id===e)?e:""}function Gx(e,t){return t&&!e.some(n=>n.id===t)?[{id:t,name:`${t}(已保存)`},...e]:e}const lu="mt-1 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2 text-[12px] text-zinc-900 outline-none transition-colors placeholder:text-zinc-400 focus:border-zinc-500",qs="text-[12px] font-medium text-zinc-600",am="rounded-xl border border-zinc-200 bg-white",hO=e=>e.split(/[\s,,]+/).map(t=>t.trim()).filter(Boolean),QH=e=>e instanceof Error?e.message:e?String(e):"",sme=e=>{var t;return(((t=e==null?void 0:e.trim())==null?void 0:t[0])??"?").toUpperCase()},Ew=e=>{const t=new Date(e);if(Number.isNaN(t.getTime()))return"";const n=new Date;return t.toDateString()===n.toDateString()?t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):t.toLocaleDateString([],{month:"2-digit",day:"2-digit"})},GC=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString([],{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})},ome=e=>e==="group"?"群聊":e==="topic"?"话题群":e==="p2p"?"私聊":"飞书会话";function eu({name:e,src:t,fallbackSrc:n,size:r=32}){const i=[t,n].filter((l,c,u)=>!!l&&u.indexOf(l)===c),[s,o]=m.useState(0);m.useEffect(()=>o(0),[t,n]);const a=i[s];return a?d.jsx("img",{src:a,alt:e??"",loading:"lazy",referrerPolicy:"no-referrer",onError:()=>o(l=>l+1),className:"shrink-0 rounded-full object-cover",style:{width:r,height:r}}):d.jsx("span",{className:"grid shrink-0 place-items-center rounded-full bg-zinc-900 font-semibold text-white",style:{width:r,height:r,fontSize:Math.max(11,Math.round(r*.36))},children:sme(e)})}function jw({value:e,onChange:t,options:n}){return d.jsx("div",{className:"mt-1.5 grid gap-1 rounded-xl bg-zinc-100 p-1",style:{gridTemplateColumns:`repeat(${n.length}, minmax(0, 1fr))`},children:n.map(r=>d.jsx("button",{type:"button",onClick:()=>t(r.value),className:`rounded-lg px-2.5 py-1.5 text-[11px] font-medium transition-colors ${e===r.value?"bg-white text-zinc-900 shadow-sm":"text-zinc-500 hover:text-zinc-800"}`,children:r.label},r.value))})}function YC({connected:e,state:t,listening:n=!0}){const r=!n&&t!=="expired",i=t==="expired",s=t==="connecting";return d.jsxs("span",{className:`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-[11px] font-medium ${r?"bg-amber-50 text-amber-700":e?"bg-emerald-50 text-emerald-700":i?"bg-amber-50 text-amber-700":s?"bg-sky-50 text-sky-700":"bg-zinc-100 text-zinc-500"}`,children:[d.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${r?"bg-amber-500":e?"bg-emerald-500":i?"bg-amber-500":s?"bg-sky-500 animate-pulse":"bg-zinc-400"}`}),r?"已暂停":e?"运行中":i?"会话已失效":s?"正在重连":"未连接"]})}function Z0({label:e,value:t,hint:n}){return d.jsxs("div",{className:"rounded-xl border border-zinc-200 bg-white px-4 py-3",children:[d.jsx("p",{className:"text-[11px] text-zinc-500",children:e}),d.jsx("p",{className:"mt-1 text-[24px] font-semibold leading-none text-zinc-900",children:t}),n&&d.jsx("p",{className:"mt-1 text-[11px] text-zinc-400",children:n})]})}function ame({config:e,status:t,open:n,setOpen:r,region:i,login:s,starting:o,error:a,cookie:l,setCookie:c,importing:u,onOpen:h,onStart:f,onRegion:p,onCancel:g,onCookieImport:x}){const[v,b]=m.useState(!1),y=QH(a)||(s==null?void 0:s.message),w=(s==null?void 0:s.state)==="waiting"||(s==null?void 0:s.state)==="scanned",S=(s==null?void 0:s.state)==="success",C=(s==null?void 0:s.state)==="failed";return n?d.jsxs("div",{className:"h-full overflow-y-auto p-5",children:[d.jsxs("button",{type:"button",onClick:()=>r(!1),className:"inline-flex items-center gap-1.5 text-[12px] text-zinc-500 hover:text-zinc-900",children:[d.jsx(D4,{size:13}),"返回"]}),d.jsxs("div",{className:"mx-auto mt-4 max-w-[860px]",children:[d.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[d.jsxs("div",{children:[d.jsx("h2",{className:"text-[20px] font-semibold text-zinc-900",children:t!=null&&t.connected?"重新连接账号":"扫码连接飞书账号"}),d.jsx("p",{className:"mt-1 text-[12px] leading-5 text-zinc-500",children:"不需要 App ID、App Secret,也不需要创建机器人。"})]}),d.jsx(YC,{connected:t==null?void 0:t.connected,state:t==null?void 0:t.state,listening:t==null?void 0:t.listening})]}),d.jsxs("div",{className:"mt-5 grid gap-5 lg:grid-cols-[minmax(0,1fr)_280px]",children:[d.jsxs("div",{className:`${am} flex flex-col items-center p-5 text-center`,children:[d.jsxs("div",{className:"flex w-full items-center justify-between",children:[d.jsx("h3",{className:"text-[13px] font-semibold text-zinc-900",children:"手机扫码登录"}),d.jsx("div",{className:"flex rounded-lg bg-zinc-100 p-0.5",children:["feishu","lark"].map(_=>d.jsx("button",{type:"button",onClick:()=>p(_),disabled:o,className:`rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors ${i===_?"bg-white text-zinc-900 shadow-sm":"text-zinc-500 hover:text-zinc-800"}`,children:_==="feishu"?"飞书":"Lark"},_))})]}),d.jsx("div",{className:"mt-4 grid h-[196px] w-[196px] place-items-center rounded-2xl bg-white p-2 ring-1 ring-zinc-200",children:S?d.jsxs("div",{className:"text-center",children:[d.jsx(hN,{size:42,className:"mx-auto text-emerald-500"}),d.jsx("p",{className:"mt-2 text-[12px] font-medium text-zinc-800",children:"登录成功"})]}):w&&(s!=null&&s.qrContent)?d.jsx(zy,{value:s.qrContent,size:180,marginSize:2,title:`${i==="feishu"?"飞书":"Lark"}登录二维码`}):o||(s==null?void 0:s.state)==="starting"?d.jsxs("div",{className:"text-center text-zinc-400",children:[d.jsx(_i,{size:30,className:"mx-auto animate-spin"}),d.jsx("p",{className:"mt-2 text-[11px]",children:"正在获取二维码"})]}):d.jsxs("div",{className:"text-center text-zinc-400",children:[d.jsx(tf,{size:30,className:"mx-auto"}),d.jsx("p",{className:"mt-2 max-w-[150px] text-[11px] leading-4",children:C?"二维码获取失败":"等待生成二维码"})]})}),d.jsx("p",{className:`mt-3 text-[12px] leading-5 ${C?"text-red-600":"text-zinc-600"}`,children:y||(w?"打开飞书 App,扫一扫二维码":"正在准备登录…")}),d.jsxs("p",{className:"mt-1 text-[10px] text-zinc-400",children:[s!=null&&s.attempt?`第 ${s.attempt} / 6 次`:"扫码后请在手机上确认",(s==null?void 0:s.state)==="scanned"?" · 已扫码":""]}),d.jsxs("div",{className:"mt-3 flex gap-2",children:[d.jsx(zn,{size:"small",loading:o,onClick:f,children:C||S?"重新生成":"刷新二维码"}),d.jsx(zn,{size:"small",onClick:g,children:"取消"})]})]}),d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:`${am} p-4`,children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(aX,{size:15,className:"text-zinc-500"}),d.jsx("h3",{className:"text-[13px] font-semibold text-zinc-900",children:"登录后会发生什么"})]}),d.jsxs("ul",{className:"mt-3 space-y-2 text-[11px] leading-5 text-zinc-500",children:[d.jsx("li",{children:"· 凭证只保存在本机 SQLite,不会下发给浏览器。"}),d.jsx("li",{children:"· 以你的本人身份建立长连接,不经过机器人。"}),d.jsx("li",{children:"· Agent 的文本输出会直接以你的身份发回当前聊天。"}),d.jsx("li",{children:"· 会话失效时状态会变为「会话已失效」,重新扫码即可。"})]})]}),d.jsxs("div",{className:`${am} p-4`,children:[d.jsxs("button",{type:"button",onClick:()=>b(_=>!_),className:"flex w-full items-center justify-between text-left",children:[d.jsx("span",{className:"text-[12px] font-medium text-zinc-700",children:"高级:导入 Cookie"}),d.jsx("span",{className:"text-[11px] text-zinc-400",children:v?"收起":"展开"})]}),v&&d.jsxs("div",{className:"mt-3",children:[d.jsxs("p",{className:"text-[11px] leading-5 text-zinc-500",children:["扫码不可用时,可从已登录的飞书网页复制完整 Cookie。必须包含 ",d.jsx("code",{className:"rounded bg-zinc-100 px-1",children:"session"}),"。"]}),d.jsx("textarea",{value:l,onChange:_=>c(_.target.value),placeholder:"session=...; passport_web_did=...; swp_csrf_token=...",className:`${lu} min-h-20 resize-y`}),d.jsx(zn,{size:"small",className:"mt-2",loading:u,disabled:!l.trim(),onClick:x,children:"导入 Cookie"})]})]})]})]})]})]}):d.jsx("div",{className:"flex h-full items-center justify-center overflow-y-auto p-6",children:d.jsxs("div",{className:"w-full max-w-[620px] text-center",children:[d.jsx("div",{className:"mx-auto grid h-14 w-14 place-items-center rounded-2xl bg-zinc-900 text-white shadow-sm",children:d.jsx(_x,{size:25})}),d.jsx("h2",{className:"mt-5 text-[22px] font-semibold tracking-tight text-zinc-900",children:"连接你的飞书账号"}),d.jsx("p",{className:"mx-auto mt-2 max-w-[520px] text-[13px] leading-6 text-zinc-500",children:"直接扫码登录飞书网页端。消息通过本人身份的 WebSocket 常驻接收,并定时补拉群聊;收到触发词后 Agent 会结合上下文直接以你的身份回复。"}),d.jsx("div",{className:"mt-6 grid gap-2 text-left sm:grid-cols-3",children:[["1","手机扫码","用飞书或 Lark App 扫码确认"],["2","持续监听","WebSocket + 30 秒群聊补拉"],["3","Agent 直接回复","所有 AgentText 自动发回聊天"]].map(([_,k,j])=>d.jsxs("div",{className:"rounded-xl border border-zinc-200 bg-zinc-50/60 p-3",children:[d.jsx("span",{className:"grid h-6 w-6 place-items-center rounded-full bg-white text-[11px] font-semibold text-zinc-700 shadow-sm",children:_}),d.jsx("p",{className:"mt-2 text-[12px] font-medium text-zinc-800",children:k}),d.jsx("p",{className:"mt-0.5 text-[11px] leading-4 text-zinc-500",children:j})]},_))}),(t==null?void 0:t.lastError)&&d.jsx("p",{className:"mx-auto mt-4 max-w-[520px] rounded-lg bg-red-50 px-3 py-2 text-left text-[12px] text-red-700",children:t.lastError}),(e==null?void 0:e.account)&&d.jsxs("p",{className:"mt-5 text-[11px] text-zinc-400",children:["上次连接 ",d.jsx("span",{className:"text-zinc-600",children:e.account.name}),e.account.userId?` · ${e.account.userId}`:""]}),d.jsx(zn,{type:"primary",size:"large",className:"mt-6 !h-10 !rounded-lg !bg-zinc-900 !px-5 !text-[13px]",onClick:h,children:e!=null&&e.account?"重新扫码连接":"扫码连接"})]})})}function lme({draft:e,body:t,onBody:n,onSend:r,onDiscard:i,sending:s,discarding:o,accountName:a,accountAvatarUrl:l}){if(e.state==="sent"){const c=!!e.itemId;return d.jsxs("div",{className:"mb-5 flex items-end justify-end gap-2.5",children:[d.jsxs("div",{className:"min-w-0 max-w-[78%] text-right",children:[d.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-end gap-2",children:[d.jsx("span",{className:"text-[11px] font-medium text-zinc-700",children:c?"AI 替身":a||"你"}),d.jsx("span",{className:"text-[10px] text-zinc-400",children:GC(e.sentAt??e.updatedAt)}),d.jsx("span",{className:"rounded-full bg-emerald-50 px-1.5 py-0.5 text-[9px] font-medium text-emerald-700",children:"已发送"})]}),d.jsx("div",{className:"inline-block whitespace-pre-wrap break-words rounded-2xl rounded-tr-md bg-sky-600 px-3.5 py-2.5 text-left text-[13px] leading-5 text-white",children:e.body})]}),c?d.jsx("span",{className:"grid h-7 w-7 shrink-0 place-items-center rounded-full bg-sky-600 text-white",children:d.jsx(Lo,{size:13})}):d.jsx(eu,{name:a,src:l,size:28})]})}return e.state==="discarded"?d.jsxs("div",{className:"mb-5 max-w-[78%] rounded-lg border border-dashed border-zinc-200 px-3 py-2 text-[11px] text-zinc-400",children:["已丢弃草稿:",e.body||"(空)"]}):d.jsxs("div",{className:"mb-5 max-w-[78%] rounded-xl border border-zinc-200 bg-zinc-50/70 p-3",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-medium text-zinc-600",children:[d.jsx(Lo,{size:12}),"Agent 回复"]}),e.lastError&&d.jsx("span",{className:"truncate text-[10px] text-red-600",children:e.lastError})]}),d.jsx("textarea",{className:`${lu} mt-2 min-h-20 resize-y bg-white`,value:t,placeholder:"AI 没有生成正文,可以手动补充。",onChange:c=>n(c.target.value)}),d.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[d.jsx(zn,{size:"small",type:"primary",disabled:!t.trim(),loading:s,onClick:r,children:"确认发送"}),d.jsx(zn,{size:"small",danger:!0,loading:o,onClick:i,children:"丢弃"})]})]})}function cme(){var Qt,Yt,Y,Ae,et,Tt,dt,At,He,it,jt,St,It,Rn,Tn,Sn,mr,qn,nr,Ur,_r,ci,Rr,rr,Cr,kr,Nr,Kr,ui,Ft,Rt,se,gt,bt,tn,Nn,Un,Fn,Wi,ki,Wt,Nt,Ht,En,_n;const e=Ln(),t=Et({queryKey:["lark-avatar-status"],queryFn:we.larkAvatarStatus,refetchInterval:5e3}),n=Et({queryKey:["lark-avatar-config"],queryFn:we.larkAvatarConfig}),r=Et({queryKey:["agents"],queryFn:()=>we.agents()}),i=Et({queryKey:["system-capabilities"],queryFn:we.systemCapabilities}),s=!!((Qt=t.data)!=null&&Qt.connected),o=!!((Yt=t.data)!=null&&Yt.configured)&&((Y=t.data)==null?void 0:Y.state)!=="expired",a=Et({queryKey:["lark-avatar-inbox"],queryFn:()=>we.larkAvatarInbox(),refetchInterval:5e3,enabled:o}),l=Et({queryKey:["lark-avatar-drafts"],queryFn:()=>we.larkAvatarDrafts(),refetchInterval:5e3,enabled:o}),[c,u]=m.useState("overview"),[h,f]=m.useState(!1),[p,g]=m.useState("feishu"),[x,v]=m.useState(""),[b,y]=m.useState("/ai"),[w,S]=m.useState(10),[C,_]=m.useState("anchor"),[k,j]=m.useState(!0),[z,N]=m.useState("direct"),[I,$]=m.useState(!1),[R,E]=m.useState(""),[M,P]=m.useState(7200),[A,D]=m.useState("all"),[F,O]=m.useState([]),[B,V]=m.useState(""),[T,W]=m.useState(""),[L,q]=m.useState(""),[X,J]=m.useState(""),[ae,ne]=m.useState(""),[re,ie]=m.useState(""),[G,oe]=m.useState(),[ge,U]=m.useState(""),[ce,ve]=m.useState(""),[fe,Ce]=m.useState({}),Pe=yl(),Ie=m.useRef(null),Te=m.useRef(!1),de=Et({queryKey:ul(L,X||void 0),queryFn:()=>dl(L,X||void 0),enabled:!!L,initialData:()=>Cd(L,X||void 0),initialDataUpdatedAt:0,refetchOnMount:"always",staleTime:5*6e4}),Le=Et({queryKey:["lark-avatar-chats"],queryFn:we.larkAvatarChats,enabled:o&&c==="settings",staleTime:2e4,refetchOnMount:"always"});m.useEffect(()=>{n.data&&(g(n.data.config.region),y(n.data.config.triggerPrefix),S(n.data.config.contextMessages),_(n.data.config.contextScope),j(n.data.config.replyInTopic),N(n.data.config.replyMode),$(n.data.config.emojiReactions),E(n.data.config.replySignature),P(n.data.config.agentTimeoutSeconds),O(n.data.config.listenChats),V(n.data.config.listenChats.join(", ")),D(n.data.config.listenChats.length?"selected":"all"),q(n.data.config.agentId),J(n.data.config.model),ne(n.data.config.reasoningEffort),ie(n.data.config.workspace))},[(Ae=n.data)==null?void 0:Ae.id,(et=n.data)==null?void 0:et.updatedAt,s]),m.useEffect(()=>{var he;!L&&((he=r.data)!=null&&he.length)&&q(r.data[0].id)},[L,r.data]),m.useEffect(()=>{s&&(f(!1),u(he=>he==="overview"?he:"overview"))},[s]);const te=()=>{e.invalidateQueries({queryKey:["lark-avatar-status"]}),e.invalidateQueries({queryKey:["lark-avatar-config"]}),e.invalidateQueries({queryKey:["lark-avatar-inbox"]}),e.invalidateQueries({queryKey:["lark-avatar-drafts"]})},me=yt({mutationFn:()=>we.saveLarkAvatarConfig({region:p,triggerPrefix:b,contextMessages:w,contextScope:C,replyInTopic:k,replyMode:z,emojiReactions:I,replySignature:R,agentTimeoutSeconds:M,listenChats:A==="all"?[]:hO(B),allowedSenders:[],agentId:L,model:X,reasoningEffort:ae,workspace:re}),onSuccess:()=>{Pe.show("配置已保存,下一次触发生效","info"),te()}}),_e=yt({mutationFn:we.selectDirectory,onSuccess:he=>ie(he.path)}),$e=yt({mutationFn:he=>we.startLarkAvatarLogin(he),onSuccess:he=>e.setQueryData(["lark-avatar-login"],he)}),xe=yt({mutationFn:we.cancelLarkAvatarLogin,onSuccess:he=>{e.setQueryData(["lark-avatar-login"],he),f(!1)}}),Ze=yt({mutationFn:()=>we.importLarkAvatarCookie({cookie:x,region:p}),onSuccess:()=>{v(""),f(!1),u("overview"),te()}}),le=yt({mutationFn:we.disconnectLarkAvatar,onSuccess:()=>{f(!1),te()}}),Me=yt({mutationFn:we.pollLarkAvatar,onSuccess:te}),pe=yt({mutationFn:he=>we.setLarkAvatarListening(he),onSuccess:te}),ye=Et({queryKey:["lark-avatar-login"],queryFn:we.pollLarkAvatarLogin,enabled:h&&!s,refetchInterval:h&&!s?2e3:!1,retry:!1});m.useEffect(()=>{var he;((he=ye.data)==null?void 0:he.state)==="success"&&(f(!1),u("overview"),te())},[(Tt=ye.data)==null?void 0:Tt.state]),m.useEffect(()=>{var st,ot;if(Te.current||t.isPending||n.isPending||(Te.current=!0,(st=t.data)!=null&&st.configured&&t.data.state!=="expired"))return;const he=((ot=n.data)==null?void 0:ot.config.region)??"feishu";g(he),f(!0),$e.mutate(he)},[t.isPending,n.isPending,(dt=t.data)==null?void 0:dt.configured,(At=t.data)==null?void 0:At.state]);const Ee=yt({mutationFn:he=>we.sendLarkAvatarDraft(he.id,fe[he.id]??he.body),onSuccess:he=>{Ce(st=>{const ot={...st};return delete ot[he.id],ot}),te()}}),Se=yt({mutationFn:he=>we.discardLarkAvatarDraft(he),onSuccess:he=>{Ce(st=>{const ot={...st};return delete ot[he.id],ot}),te()}}),De=yt({mutationFn:async({conversation:he,body:st})=>{const ot=await we.createLarkAvatarDraft({target:he.chatId,body:st,threadKey:he.threadKey});return we.sendLarkAvatarDraft(ot.id)},onSuccess:()=>{ve(""),te()}}),at=a.data??[],xt=l.data??[],Mt=m.useMemo(()=>new Map(at.map(he=>[he.id,he])),[at]),rt=m.useMemo(()=>{const he=new Map,st=(ot,wt)=>{let On=he.get(ot);return On||(On={key:ot,threadKey:wt.threadKey??wt.chatId??ot,chatId:wt.chatId??"",title:wt.title??wt.chatId??"飞书会话",chatType:wt.chatType??"",...wt.avatarUrl?{avatarUrl:wt.avatarUrl}:{},...wt.avatarFallbackUrl?{avatarFallbackUrl:wt.avatarFallbackUrl}:{},items:[],drafts:[],latestAt:wt.at,latestText:wt.text},he.set(ot,On)),wt.avatarUrl&&!On.avatarUrl&&(On.avatarUrl=wt.avatarUrl),wt.avatarFallbackUrl&&(On.avatarFallbackUrl=wt.avatarFallbackUrl),wt.at>On.latestAt&&(On.latestAt=wt.at,On.latestText=wt.text),On};for(const ot of at){const wt=ot.threadKey||`chat:${ot.chatId}`;st(wt,{threadKey:ot.threadKey,chatId:ot.chatId,title:ot.chatName||ot.senderName||ot.chatId,chatType:ot.chatType,avatarUrl:ot.chatAvatarUrl||(ot.chatType==="p2p"?ot.senderAvatarUrl:void 0),avatarFallbackUrl:ot.chatType==="p2p"?ot.senderAvatarUrl:void 0,at:ot.occurredAt,text:ot.title}).items.push(ot)}for(const ot of xt){const wt=ot.itemId?Mt.get(ot.itemId):void 0,On=ot.threadKey||(wt==null?void 0:wt.threadKey)||`chat:${ot.target}`;st(On,{threadKey:ot.threadKey,chatId:(wt==null?void 0:wt.chatId)||ot.target,title:(wt==null?void 0:wt.chatName)||(wt==null?void 0:wt.senderName)||ot.target,chatType:wt==null?void 0:wt.chatType,avatarUrl:(wt==null?void 0:wt.chatAvatarUrl)||((wt==null?void 0:wt.chatType)==="p2p"?wt.senderAvatarUrl:void 0),avatarFallbackUrl:(wt==null?void 0:wt.chatType)==="p2p"?wt.senderAvatarUrl:void 0,at:ot.updatedAt,text:ot.body}).drafts.push(ot)}for(const ot of he.values())ot.items.sort((wt,On)=>wt.occurredAt.localeCompare(On.occurredAt)),ot.drafts.sort((wt,On)=>wt.createdAt.localeCompare(On.createdAt));return[...he.values()].sort((ot,wt)=>wt.latestAt.localeCompare(ot.latestAt))},[xt,Mt,at]);m.useEffect(()=>{if(!rt.length){oe(void 0);return}(!G||!rt.some(he=>he.key===G))&&oe(rt[0].key)},[rt,G]);const nt=rt.filter(he=>{const st=ge.trim().toLowerCase();return!st||he.title.toLowerCase().includes(st)||he.latestText.toLowerCase().includes(st)}),Qe=rt.find(he=>he.key===G),tt=xt.filter(he=>he.state==="pending"||he.state==="failed"),ft=xt.filter(he=>he.state==="sent"),ue=at.filter(he=>he.title.trim().startsWith(b)).length,Oe=(He=r.data)==null?void 0:He.find(he=>he.id===L),ke=(r.data??[]).map(he=>({value:he.id,label:he.name,agentId:he.id})),pt=[{value:"",label:(it=de.data)!=null&&it.defaultModel?`Agent 默认(${de.data.defaultModel})`:"Agent 默认模型"},...Gx(((jt=de.data)==null?void 0:jt.models)??[],X).map(he=>({value:he.id,label:he.name}))],mt=[{value:"",label:(St=de.data)!=null&&St.defaultReasoningEffort?`Agent 默认(${de.data.defaultReasoningEffort})`:"Agent 默认强度"},...Gx(((It=de.data)==null?void 0:It.reasoningEfforts)??[],ae).map(he=>({value:he.id,label:he.name}))],Ye=m.useMemo(()=>{const he=new Map;for(const st of at){if(!st.chatId)continue;const ot=he.get(st.chatId),wt=st.chatType==="p2p"||st.chatType==="group"||st.chatType==="topic"?st.chatType:(ot==null?void 0:ot.type)??"unknown",On=st.chatAvatarUrl||(ot==null?void 0:ot.avatarUrl)||(wt==="p2p"?st.senderAvatarUrl:void 0),bo=wt==="p2p"?st.senderAvatarUrl||(ot==null?void 0:ot.avatarFallbackUrl):void 0;he.set(st.chatId,{id:st.chatId,name:st.chatName||(ot==null?void 0:ot.name)||st.senderName||st.chatId,type:wt,...On?{avatarUrl:On}:{},...bo?{avatarFallbackUrl:bo}:{},...ot!=null&&ot.memberCount?{memberCount:ot.memberCount}:{},...st.occurredAt?{lastMessageAt:st.occurredAt}:ot!=null&&ot.lastMessageAt?{lastMessageAt:ot.lastMessageAt}:{}})}for(const st of Le.data??[]){const ot=he.get(st.id);he.set(st.id,{...ot??{},...st,...ot!=null&&ot.avatarFallbackUrl?{avatarFallbackUrl:ot.avatarFallbackUrl}:{}})}for(const st of F)he.has(st)||he.set(st,{id:st,name:st,type:"unknown"});return[...he.values()].sort((st,ot)=>(st.type==="group"||st.type==="topic"?0:1)-(ot.type==="group"||ot.type==="topic"?0:1)||(ot.lastMessageAt??"").localeCompare(st.lastMessageAt??"")||st.name.localeCompare(ot.name,"zh-CN"))},[Le.data,at,F]),ze=Ye.filter(he=>{const st=T.trim().toLowerCase();return!st||he.name.toLowerCase().includes(st)||he.id.toLowerCase().includes(st)}),Re=he=>{O(he),V(he.join(", "))},Q=he=>{Re(F.includes(he)?F.filter(st=>st!==he):[...F,he])},Ge=Qe?[...Qe.items.map(he=>({kind:"item",at:he.occurredAt,item:he})),...Qe.drafts.map(he=>({kind:"draft",at:he.state==="sent"?he.sentAt??he.updatedAt:he.createdAt,draft:he}))].sort((he,st)=>he.at.localeCompare(st.at)):[];m.useEffect(()=>{Ie.current&&(Ie.current.scrollTop=Ie.current.scrollHeight)},[G,Qe==null?void 0:Qe.items.length,Qe==null?void 0:Qe.drafts.length]);const qe=((Rn=t.data)==null?void 0:Rn.listening)!==!1,$t=[me.error,le.error,Me.error,pe.error,Ee.error,Se.error,De.error,Ze.error,_e.error].map(QH).find(Boolean),Gt=he=>{oe(he.key),u("chats")};return n.isPending||t.isPending?d.jsx("div",{className:"grid h-full place-items-center text-[12px] text-zinc-500",children:"正在读取飞书替身状态…"}):!o||h?d.jsx(ame,{config:n.data,status:t.data,open:h,setOpen:f,region:p,login:ye.data,starting:$e.isPending,error:$e.error??Ze.error,cookie:x,setCookie:v,importing:Ze.isPending,onOpen:()=>{f(!0),$e.mutate(p)},onStart:()=>$e.mutate(p),onRegion:he=>{g(he),$e.mutate(he)},onCancel:()=>xe.mutate(),onCookieImport:()=>Ze.mutate()}):d.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[d.jsxs("div",{className:"border-b border-zinc-100 px-5 py-3",children:[d.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[d.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[d.jsx(eu,{name:(Sn=(Tn=t.data)==null?void 0:Tn.account)==null?void 0:Sn.name,src:(qn=(mr=t.data)==null?void 0:mr.account)==null?void 0:qn.avatarUrl,size:40}),d.jsxs("div",{className:"min-w-0",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("h3",{className:"truncate text-[14px] font-semibold text-zinc-900",children:((Ur=(nr=t.data)==null?void 0:nr.account)==null?void 0:Ur.name)||"飞书账号"}),d.jsx(YC,{connected:(_r=t.data)==null?void 0:_r.connected,state:(ci=t.data)==null?void 0:ci.state,listening:(Rr=t.data)==null?void 0:Rr.listening})]}),d.jsx("p",{className:"mt-0.5 truncate text-[11px] text-zinc-500",children:((Cr=(rr=t.data)==null?void 0:rr.account)==null?void 0:Cr.email)||((Nr=(kr=t.data)==null?void 0:kr.account)==null?void 0:Nr.userId)||`${((Kr=t.data)==null?void 0:Kr.region)==="lark"?"Lark":"飞书"} WebSocket`})]})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(zn,{size:"small",icon:d.jsx(Hn,{size:12}),loading:Me.isPending,disabled:!qe,onClick:()=>Me.mutate(),children:"立即同步"}),d.jsx(zn,{size:"small",icon:qe?d.jsx($0,{size:12}):d.jsx(z_,{size:12}),loading:pe.isPending,onClick:()=>pe.mutate(!qe),children:qe?"暂停监听":"恢复监听"}),d.jsx(zn,{size:"small",onClick:()=>u("settings"),children:"连接设置"})]})]}),d.jsx("div",{className:"mt-3 flex items-center gap-1",children:[["overview","概览"],["chats","会话"],["settings","设置"]].map(([he,st])=>d.jsxs("button",{type:"button",onClick:()=>u(he),className:`relative rounded-lg px-3 py-1.5 text-[12px] font-medium transition-colors ${c===he?"bg-zinc-100 text-zinc-900":"text-zinc-500 hover:bg-zinc-50 hover:text-zinc-800"}`,children:[st,he==="chats"&&tt.length>0&&d.jsx("span",{className:"ml-1.5 rounded-full bg-amber-100 px-1.5 py-0.5 text-[10px] text-amber-700",children:tt.length})]},he))})]}),$t&&d.jsx("p",{className:"border-b border-red-100 bg-red-50 px-5 py-2 text-[12px] text-red-700",children:$t}),!qe&&d.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-amber-100 bg-amber-50 px-5 py-2 text-[12px] text-amber-800",children:[d.jsx($0,{size:13}),d.jsx("span",{children:"监听已暂停,不会接收新消息或触发 Agent;登录凭证仍保留,可随时恢复。"})]}),qe&&((ui=t.data)==null?void 0:ui.state)==="connecting"&&d.jsxs("p",{className:"border-b border-amber-100 bg-amber-50 px-5 py-2 text-[12px] text-amber-800",children:["WebSocket 正在重连",t.data.lastError?`:${t.data.lastError}`:"…"]}),c==="overview"&&d.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-5",children:[!qe&&d.jsxs("div",{className:"mb-4 flex items-start gap-2.5 rounded-xl border border-amber-200/70 bg-amber-50/70 px-4 py-3 text-[12px] leading-5 text-amber-900",children:[d.jsx($0,{size:15,className:"mt-0.5 shrink-0"}),d.jsxs("div",{children:[d.jsx("p",{className:"font-medium",children:"当前处于暂停状态"}),d.jsx("p",{className:"mt-0.5 text-amber-800",children:"新的飞书消息不会被读取,也不会触发 Agent。点击右上角「恢复监听」后会重新连接 WebSocket 并继续定时补拉。"})]})]}),d.jsxs("div",{className:"mb-4 rounded-xl border border-sky-100 bg-sky-50/60 px-4 py-3 text-[12px] leading-5 text-sky-900",children:["在飞书聊天里发送 ",d.jsxs("code",{className:"rounded bg-white/80 px-1 py-0.5 font-mono text-[11px]",children:[b," 你的问题"]}),", 会自动带上最近 ",w," 条聊天记录(文字消息,含本条触发消息)发起 Agent 轮次;Agent 的所有文本输出会直接以你的身份发回当前聊天。后台每 ",((Ft=t.data)==null?void 0:Ft.syncIntervalSeconds)??30," 秒补拉一次群聊,避免只依赖 WebSocket 推送。"]}),d.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:[d.jsx(Z0,{label:"收到消息",value:at.length}),d.jsx(Z0,{label:"会话",value:rt.length}),d.jsx(Z0,{label:"AI 触发",value:ue,hint:`${b} 前缀`}),d.jsx(Z0,{label:"已发送",value:ft.length,hint:tt.length?`${tt.length} 条待补发`:"全部已送达"})]}),d.jsxs("div",{className:"mt-5 grid gap-5 lg:grid-cols-[minmax(0,1.35fr)_minmax(280px,.65fr)]",children:[d.jsxs("section",{className:`${am} overflow-hidden`,children:[d.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-100 px-4 py-3",children:[d.jsx("h3",{className:"text-[13px] font-semibold text-zinc-900",children:"最近会话"}),d.jsx("button",{type:"button",onClick:()=>u("chats"),className:"text-[11px] text-zinc-500 hover:text-zinc-900",children:"全部会话"})]}),rt.length?d.jsx("div",{className:"divide-y divide-zinc-100",children:rt.slice(0,6).map(he=>d.jsxs("button",{type:"button",onClick:()=>Gt(he),className:"flex w-full items-center gap-3 px-4 py-3 text-left hover:bg-zinc-50",children:[d.jsx(eu,{name:he.title,src:he.avatarUrl,fallbackSrc:he.avatarFallbackUrl,size:30}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsx("span",{className:"truncate text-[12px] font-medium text-zinc-800",children:he.title}),d.jsx("span",{className:"shrink-0 text-[10px] text-zinc-400",children:Ew(he.latestAt)})]}),d.jsx("p",{className:"mt-0.5 truncate text-[11px] text-zinc-500",children:he.latestText||"暂无消息"})]})]},he.key))}):d.jsx("div",{className:"px-4 py-10 text-center text-[12px] text-zinc-400",children:"还没有收到消息"})]}),d.jsxs("section",{className:`${am} overflow-hidden`,children:[d.jsx("div",{className:"border-b border-zinc-100 px-4 py-3",children:d.jsx("h3",{className:"text-[13px] font-semibold text-zinc-900",children:"最近发送"})}),ft.length?d.jsx("div",{className:"divide-y divide-zinc-100",children:ft.slice(0,5).map(he=>{const st=rt.find(ot=>ot.drafts.some(wt=>wt.id===he.id));return d.jsxs("button",{type:"button",onClick:()=>{st&&Gt(st)},className:"block w-full px-4 py-3 text-left hover:bg-zinc-50",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsx("span",{className:"text-[11px] font-medium text-zinc-700",children:(st==null?void 0:st.title)||he.target}),d.jsx("span",{className:"text-[10px] text-zinc-400",children:Ew(he.updatedAt)})]}),d.jsx("p",{className:"mt-1 line-clamp-2 text-[11px] leading-4 text-zinc-500",children:he.body||"等待补充正文"})]},he.id)})}):d.jsx("div",{className:"px-4 py-10 text-center text-[12px] text-zinc-400",children:"还没有发送记录"})]})]})]}),c==="chats"&&d.jsxs("div",{className:"flex min-h-0 flex-1",children:[d.jsxs("aside",{className:"flex w-[270px] shrink-0 flex-col border-r border-zinc-100",children:[d.jsx("div",{className:"p-3",children:d.jsxs("div",{className:"relative",children:[d.jsx(fa,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-zinc-400"}),d.jsx("input",{value:ge,onChange:he=>U(he.target.value),placeholder:"搜索会话",className:"h-8 w-full rounded-lg bg-zinc-100 pl-8 pr-3 text-[12px] text-zinc-800 outline-none placeholder:text-zinc-400"})]})}),d.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-2 pb-2",children:[nt.map(he=>d.jsxs("button",{type:"button",onClick:()=>oe(he.key),className:`flex w-full items-start gap-2.5 rounded-lg px-2.5 py-2.5 text-left ${he.key===G?"bg-zinc-100":"hover:bg-zinc-50"}`,children:[d.jsx(eu,{name:he.title,src:he.avatarUrl,fallbackSrc:he.avatarFallbackUrl,size:32}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsx("span",{className:"truncate text-[12px] font-medium text-zinc-800",children:he.title}),d.jsx("span",{className:"shrink-0 text-[9px] text-zinc-400",children:Ew(he.latestAt)})]}),d.jsx("p",{className:"mt-0.5 truncate text-[11px] text-zinc-500",children:he.latestText||"暂无消息"}),he.drafts.some(st=>st.state==="pending"||st.state==="failed")&&d.jsxs("span",{className:"mt-1 inline-flex items-center gap-1 text-[10px] text-amber-700",children:[d.jsx(Lo,{size:10}),"有回复待补发"]})]})]},he.key)),!nt.length&&d.jsx("p",{className:"px-3 py-8 text-center text-[11px] text-zinc-400",children:ge?"没有匹配的会话":"还没有会话"})]})]}),d.jsx("section",{className:"flex min-w-0 flex-1 flex-col",children:Qe?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-zinc-100 px-4 py-3",children:[d.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[d.jsx(eu,{name:Qe.title,src:Qe.avatarUrl,fallbackSrc:Qe.avatarFallbackUrl,size:30}),d.jsxs("div",{className:"min-w-0",children:[d.jsx("h3",{className:"truncate text-[13px] font-semibold text-zinc-900",children:Qe.title}),d.jsxs("p",{className:"text-[10px] text-zinc-400",children:[Qe.chatType==="p2p"?"私聊":Qe.chatType==="group"?"群聊":Qe.chatType||"飞书会话"," · ",Qe.items.length," 条消息",Qe.drafts.length?` · ${Qe.drafts.length} 条回复`:""]})]})]}),d.jsxs("span",{className:"text-[10px] text-zinc-400",children:[tt.filter(he=>Qe.drafts.some(st=>st.id===he.id)).length," 条待补发"]})]}),d.jsx("div",{ref:Ie,className:"min-h-0 flex-1 overflow-y-auto bg-zinc-50/40 px-5 py-4",children:Ge.length?d.jsx(d.Fragment,{children:Ge.map(he=>{var On,bo,zd,Md,$d,Ct,Lt;if(he.kind==="draft"){const xn=he.draft;return d.jsx("div",{children:d.jsx(lme,{draft:xn,body:fe[xn.id]??xn.body,onBody:gr=>Ce(Zn=>({...Zn,[xn.id]:gr})),onSend:()=>Ee.mutate(xn),onDiscard:()=>Se.mutate(xn.id),sending:Ee.isPending&&((On=Ee.variables)==null?void 0:On.id)===xn.id,discarding:Se.isPending&&Se.variables===xn.id,accountName:(zd=(bo=t.data)==null?void 0:bo.account)==null?void 0:zd.name,accountAvatarUrl:($d=(Md=t.data)==null?void 0:Md.account)==null?void 0:$d.avatarUrl})},xn.id)}const st=he.item,ot=st.title.trim().startsWith(b),wt=!!(st.senderId&&st.senderId===((Lt=(Ct=t.data)==null?void 0:Ct.account)==null?void 0:Lt.userId));return d.jsxs("div",{className:`mb-5 flex items-start gap-2.5 ${wt?"flex-row-reverse":""}`,children:[d.jsx(eu,{name:st.senderName||Qe.title,src:st.senderAvatarUrl,size:28}),d.jsxs("div",{className:`min-w-0 max-w-[78%] ${wt?"text-right":""}`,children:[d.jsxs("div",{className:`mb-1 flex flex-wrap items-center gap-2 ${wt?"justify-end":""}`,children:[d.jsx("span",{className:"text-[11px] font-medium text-zinc-700",children:st.senderName||Qe.title}),d.jsx("span",{className:"text-[10px] text-zinc-400",children:GC(st.occurredAt)}),ot&&d.jsx("span",{className:"rounded-full bg-sky-50 px-1.5 py-0.5 text-[9px] font-medium text-sky-700",children:"Agent 触发"})]}),d.jsx("div",{className:`inline-block whitespace-pre-wrap break-words rounded-2xl px-3.5 py-2.5 text-left text-[13px] leading-5 ${wt?"rounded-tr-md bg-sky-600 text-white":"rounded-tl-md border border-zinc-200 bg-white text-zinc-800"}`,children:st.title||st.summary})]})]},st.id)})}):d.jsx("div",{className:"grid h-full place-items-center text-center",children:d.jsxs("div",{children:[d.jsx(O1,{size:26,className:"mx-auto text-zinc-300"}),d.jsx("p",{className:"mt-2 text-[12px] text-zinc-400",children:"这个会话还没有消息"})]})})}),d.jsx("div",{className:"border-t border-zinc-100 p-3",children:d.jsxs("div",{className:"flex items-end gap-2 rounded-xl border border-zinc-200 bg-white p-2 focus-within:border-zinc-400",children:[d.jsx("textarea",{value:ce,onChange:he=>ve(he.target.value),onKeyDown:he=>{he.key==="Enter"&&!he.shiftKey&&(he.preventDefault(),ce.trim()&&!De.isPending&&De.mutate({conversation:Qe,body:ce}))},rows:1,placeholder:`发送给 ${Qe.title},Enter 发送,Shift+Enter 换行`,className:"max-h-28 min-h-8 flex-1 resize-none bg-transparent px-2 py-1.5 text-[12px] leading-5 text-zinc-800 outline-none placeholder:text-zinc-400"}),d.jsx("button",{type:"button","aria-label":"发送消息",disabled:!ce.trim()||De.isPending,onClick:()=>De.mutate({conversation:Qe,body:ce}),className:"grid h-8 w-8 shrink-0 place-items-center rounded-full bg-zinc-900 text-white transition-opacity hover:bg-zinc-800 disabled:opacity-30",children:d.jsx(mN,{size:13})})]})})]}):d.jsx("div",{className:"grid h-full place-items-center text-center",children:d.jsxs("div",{children:[d.jsx(O1,{size:28,className:"mx-auto text-zinc-300"}),d.jsx("p",{className:"mt-2 text-[12px] text-zinc-400",children:"选择左侧会话查看消息"})]})})})]}),c==="settings"&&d.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-zinc-50/60",children:[d.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-3 sm:p-5",children:d.jsxs("div",{className:"mx-auto max-w-[820px] space-y-4",children:[d.jsxs("section",{className:"rounded-2xl border border-zinc-200/80 bg-white p-4 shadow-[0_1px_2px_rgba(24,24,27,.03)] sm:p-5",children:[d.jsxs("div",{className:"flex items-start gap-3",children:[d.jsx("span",{className:"grid h-8 w-8 shrink-0 place-items-center rounded-xl bg-zinc-100 text-zinc-600",children:d.jsx(Hb,{size:15})}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[d.jsx("h3",{className:"text-[14px] font-semibold text-zinc-900",children:"账号与连接"}),d.jsx(YC,{connected:(Rt=t.data)==null?void 0:Rt.connected,state:(se=t.data)==null?void 0:se.state,listening:(gt=t.data)==null?void 0:gt.listening})]}),d.jsx("p",{className:"mt-1 text-[11px] leading-5 text-zinc-500",children:qe?"本人身份常驻在线,WebSocket 接收消息并定时补拉群聊。":"监听已暂停,WebSocket 和定时补拉均已停止;登录凭证仍保留在本机。"})]})]}),d.jsxs("div",{className:"mt-4 grid gap-x-6 gap-y-3 rounded-xl bg-zinc-50/80 px-4 py-3 sm:grid-cols-2",children:[d.jsxs("div",{children:[d.jsx("span",{className:qs,children:"当前账号"}),d.jsx("p",{className:"mt-1 text-[12px] font-medium text-zinc-800",children:((tn=(bt=t.data)==null?void 0:bt.account)==null?void 0:tn.name)||"飞书账号"})]}),d.jsxs("div",{children:[d.jsx("span",{className:qs,children:"用户 ID"}),d.jsx("p",{className:"mt-1 truncate font-mono text-[11px] text-zinc-600",children:((Un=(Nn=t.data)==null?void 0:Nn.account)==null?void 0:Un.userId)||"—"})]}),d.jsxs("div",{children:[d.jsx("span",{className:qs,children:"区域"}),d.jsx("p",{className:"mt-1 text-[12px] text-zinc-700",children:((Fn=t.data)==null?void 0:Fn.region)==="lark"?"Lark 国际版":"飞书中国版"})]}),d.jsxs("div",{children:[d.jsx("span",{className:qs,children:"同步"}),d.jsxs("p",{className:"mt-1 text-[12px] text-zinc-700",children:["每 ",((Wi=t.data)==null?void 0:Wi.syncIntervalSeconds)??30," 秒补拉"]}),d.jsx("p",{className:"mt-0.5 text-[10px] text-zinc-400",children:(ki=t.data)!=null&&ki.lastSyncedAt?`最近 ${GC(t.data.lastSyncedAt)}`:"等待首次同步"})]})]}),d.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[d.jsx(zn,{size:"small",icon:qe?d.jsx($0,{size:12}):d.jsx(z_,{size:12}),loading:pe.isPending,onClick:()=>pe.mutate(!qe),children:qe?"暂停监听":"恢复监听"}),d.jsx(zn,{size:"small",onClick:()=>{f(!0),$e.mutate(p)},children:"重新扫码"}),d.jsx(zn,{size:"small",danger:!0,loading:le.isPending,onClick:()=>le.mutate(),children:"断开账号"}),d.jsx("span",{className:"ml-auto text-[10px] text-zinc-400",children:"凭证仅保存在本机 SQLite"})]})]}),d.jsxs("section",{className:"rounded-2xl border border-zinc-200/80 bg-white p-4 shadow-[0_1px_2px_rgba(24,24,27,.03)] sm:p-5",children:[d.jsxs("div",{className:"flex items-start gap-3",children:[d.jsx("span",{className:"grid h-8 w-8 shrink-0 place-items-center rounded-xl bg-zinc-100 text-zinc-600",children:d.jsx(ti,{size:15})}),d.jsxs("div",{children:[d.jsx("h3",{className:"text-[14px] font-semibold text-zinc-900",children:"Agent 配置"}),d.jsx("p",{className:"mt-1 text-[11px] leading-5 text-zinc-500",children:"选择处理 /ai 轮次的 Agent、模型和运行目录。"})]})]}),d.jsxs("div",{className:"mt-4 grid gap-4 sm:grid-cols-2",children:[d.jsxs("label",{className:"block",children:[d.jsx("span",{className:qs,children:"Agent"}),d.jsx(ua,{options:ke,value:L,placeholder:"选择 Agent",disabledText:"没有可用 Agent",popupWidth:380,onChange:he=>{q(he),J(""),ne("")}})]}),d.jsxs("label",{className:"block",children:[d.jsx("span",{className:qs,children:"默认模型"}),d.jsx(ua,{options:pt,value:X,placeholder:"选择模型",disabledText:"暂无可用模型",disabled:!((Wt=de.data)!=null&&Wt.models.length),popupWidth:380,onChange:J})]}),d.jsxs("label",{className:"block",children:[d.jsx("span",{className:qs,children:"推理强度"}),d.jsx(ua,{options:mt,value:ae,placeholder:"选择推理强度",disabledText:"当前 Agent 未提供推理强度",disabled:!((Nt=de.data)!=null&&Nt.reasoningEfforts.length),popupWidth:300,onChange:ne})]}),d.jsxs("div",{className:"block",children:[d.jsx("span",{className:qs,children:"工作目录"}),d.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[d.jsx("div",{className:"min-w-0 flex-1",children:d.jsx(IE,{value:re,onChange:ie,label:"工作目录",placeholder:"留空使用默认工作目录",suggestion:(Oe==null?void 0:Oe.cwd)||((Ht=i.data)==null?void 0:Ht.workingDirectory),suggestionLabel:"使用 Agent 默认工作目录"})}),d.jsx(zn,{size:"small",icon:d.jsx(ha,{size:12}),loading:_e.isPending,disabled:!((En=i.data)!=null&&En.directoryPicker),onClick:()=>_e.mutate(),children:"选择"})]})]}),d.jsxs("label",{className:"block",children:[d.jsx("span",{className:qs,children:"单轮超时(秒)"}),d.jsx("input",{className:lu,type:"number",min:0,max:86400,value:M,onChange:he=>P(Math.min(86400,Math.max(0,Number(he.target.value)||0)))}),d.jsx("p",{className:"mt-1 text-[10px] leading-4 text-zinc-400",children:"0 表示不限制;超时后会结束本轮。"})]}),d.jsxs("div",{className:"block",children:[d.jsx("span",{className:qs,children:"Agent 记忆范围"}),d.jsx(jw,{value:C,onChange:_,options:[{value:"anchor",label:"按话题隔离"},{value:"chat",label:"整个会话共享"}]}),d.jsx("p",{className:"mt-1 text-[10px] leading-4 text-zinc-400",children:"按话题隔离:每个飞书话题有独立的 Agent 会话;整个会话共享:同一聊天里的不同话题共用一段记忆。"})]})]}),d.jsx("p",{className:"mt-3 text-[11px] leading-5 text-zinc-400",children:de.isFetching?"正在读取 Agent 能力…":((_n=de.data)==null?void 0:_n.warning)||"修改 Agent 配置后,下一次 /ai 触发会创建对应的新会话。"})]}),d.jsxs("section",{className:"rounded-2xl border border-zinc-200/80 bg-white p-4 shadow-[0_1px_2px_rgba(24,24,27,.03)] sm:p-5",children:[d.jsxs("div",{className:"flex items-start gap-3",children:[d.jsx("span",{className:"grid h-8 w-8 shrink-0 place-items-center rounded-xl bg-zinc-100 text-zinc-600",children:d.jsx(Sx,{size:15})}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[d.jsx("h3",{className:"text-[14px] font-semibold text-zinc-900",children:"消息监听"}),d.jsx("span",{className:"rounded-full bg-zinc-100 px-2 py-0.5 text-[10px] text-zinc-500",children:A==="all"?"全部会话":`已选 ${F.length} 个`})]}),d.jsx("p",{className:"mt-1 text-[11px] leading-5 text-zinc-500",children:"决定读取哪些会话的消息和上下文。默认监听账号可见的全部会话。"})]})]}),d.jsx("div",{className:"mt-4 grid grid-cols-2 gap-1 rounded-xl bg-zinc-100 p-1",children:[["all","全部会话"],["selected","指定会话"]].map(([he,st])=>d.jsx("button",{type:"button",onClick:()=>D(he),className:`rounded-lg px-3 py-2 text-[12px] font-medium transition-colors ${A===he?"bg-white text-zinc-900 shadow-sm":"text-zinc-500 hover:text-zinc-800"}`,children:st},he))}),A==="all"?d.jsxs("div",{className:"mt-3 flex items-start gap-2.5 rounded-xl border border-emerald-100 bg-emerald-50/60 px-3.5 py-3 text-emerald-900",children:[d.jsx(_x,{size:15,className:"mt-0.5 shrink-0"}),d.jsxs("div",{children:[d.jsx("p",{className:"text-[12px] font-medium",children:"正在监听全部会话"}),d.jsx("p",{className:"mt-0.5 text-[11px] leading-5 text-emerald-700",children:"群聊和私聊都会进入上下文,并在每次触发时读取最近消息。"})]})]}):d.jsxs("div",{className:"mt-3 space-y-3",children:[F.length>0&&d.jsx("div",{className:"flex flex-wrap gap-1.5",children:F.map(he=>{const st=Ye.find(ot=>ot.id===he);return d.jsxs("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-lg border border-zinc-200 bg-zinc-50 py-1 pl-2 pr-1 text-[11px] text-zinc-700",children:[d.jsx("span",{className:"max-w-[240px] truncate",children:st&&st.type!=="unknown"?st.name:he}),d.jsx("button",{type:"button","aria-label":`移除 ${(st==null?void 0:st.name)||he}`,onClick:()=>Q(he),className:"grid h-4 w-4 place-items-center rounded text-zinc-400 hover:bg-zinc-200 hover:text-zinc-700",children:d.jsx(Wn,{size:10})})]},he)})}),d.jsxs("div",{className:"overflow-hidden rounded-xl border border-zinc-200",children:[d.jsxs("div",{className:"flex items-center gap-2 border-b border-zinc-100 bg-zinc-50/70 p-2",children:[d.jsxs("div",{className:"relative min-w-0 flex-1",children:[d.jsx(fa,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-zinc-400"}),d.jsx("input",{value:T,onChange:he=>W(he.target.value),placeholder:"搜索群名或 Chat ID",className:"h-8 w-full rounded-lg border border-zinc-200 bg-white pl-8 pr-3 text-[12px] text-zinc-800 outline-none placeholder:text-zinc-400 focus:border-zinc-400"})]}),d.jsx("button",{type:"button",disabled:Le.isFetching,onClick:()=>void Le.refetch(),className:"grid h-8 w-8 shrink-0 place-items-center rounded-lg text-zinc-500 hover:bg-zinc-200 disabled:opacity-40","aria-label":"刷新会话列表",children:d.jsx(Hn,{size:13,className:Le.isFetching?"animate-spin":""})})]}),d.jsxs("div",{className:"max-h-[230px] overflow-y-auto p-1.5",children:[ze.map(he=>{const st=F.includes(he.id);return d.jsxs("button",{type:"button",onClick:()=>Q(he.id),className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors ${st?"bg-zinc-100":"hover:bg-zinc-50"}`,children:[d.jsx(eu,{name:he.name,src:he.avatarUrl,fallbackSrc:he.avatarFallbackUrl,size:30}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("p",{className:"truncate text-[12px] font-medium text-zinc-800",children:he.name}),d.jsxs("p",{className:"truncate text-[10px] text-zinc-400",children:[ome(he.type),he.memberCount?` · ${he.memberCount} 人`:""," · ",he.id]})]}),d.jsx("span",{className:`grid h-5 w-5 shrink-0 place-items-center rounded-full border ${st?"border-zinc-900 bg-zinc-900 text-white":"border-zinc-300 text-transparent"}`,children:d.jsx(gi,{size:11})})]},he.id)}),!ze.length&&d.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-zinc-400",children:Le.isFetching?"正在读取飞书会话…":T?"没有匹配的会话":"暂无可选会话,可使用下方手动输入"})]})]}),d.jsxs("details",{className:"group rounded-xl border border-zinc-200 px-3 py-2",children:[d.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between text-[11px] font-medium text-zinc-500",children:[d.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[d.jsx(FZ,{size:12}),"手动输入 Chat ID"]}),d.jsx("span",{className:"text-[10px] text-zinc-400 group-open:hidden",children:"展开"}),d.jsx("span",{className:"hidden text-[10px] text-zinc-400 group-open:inline",children:"收起"})]}),d.jsx("input",{className:`${lu} font-mono`,value:B,placeholder:"oc_1, oc_2",onChange:he=>V(he.target.value),onBlur:()=>O(hO(B))}),d.jsx("p",{className:"mt-1 text-[10px] leading-4 text-zinc-400",children:"留空并切到「全部会话」可监听所有会话。"})]})]}),d.jsx("p",{className:"mt-3 text-[10px] leading-4 text-zinc-400",children:"最近消息面板最多保留 60 条消息,写入新消息时立即丢弃最旧记录;回复记录最多保留 80 条,待发送的会保留。图片不会下载,只保存占位摘要。"})]}),d.jsxs("section",{className:"rounded-2xl border border-zinc-200/80 bg-white p-4 shadow-[0_1px_2px_rgba(24,24,27,.03)] sm:p-5",children:[d.jsxs("div",{className:"flex items-start gap-3",children:[d.jsx("span",{className:"grid h-8 w-8 shrink-0 place-items-center rounded-xl bg-zinc-100 text-zinc-600",children:d.jsx(O1,{size:15})}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[d.jsx("h3",{className:"text-[14px] font-semibold text-zinc-900",children:"回复方式"}),d.jsx("span",{className:"rounded-full bg-sky-50 px-2 py-0.5 text-[10px] font-medium text-sky-700",children:"发送位置"})]}),d.jsx("p",{className:"mt-1 text-[11px] leading-5 text-zinc-500",children:"控制 Agent 的回复发到主会话、原话题,还是以引用或新话题发送。"})]})]}),d.jsxs("div",{className:"mt-4 space-y-3",children:[d.jsx("div",{className:"rounded-xl border border-zinc-200 px-3.5 py-3",children:d.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsx("p",{className:"text-[12px] font-medium text-zinc-800",children:"话题内的消息"}),d.jsx("p",{className:"mt-0.5 text-[11px] leading-5 text-zinc-500",children:"回复到原话题,或发到外面的主会话。"})]}),d.jsx("div",{className:"w-[210px] shrink-0",children:d.jsx(jw,{value:k?"in":"out",onChange:he=>j(he==="in"),options:[{value:"in",label:"话题内"},{value:"out",label:"主会话"}]})})]})}),d.jsx("div",{className:"rounded-xl border border-zinc-200 px-3.5 py-3",children:d.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsx("p",{className:"text-[12px] font-medium text-zinc-800",children:"主会话的消息"}),d.jsx("p",{className:"mt-0.5 text-[11px] leading-5 text-zinc-500",children:"私聊不支持话题,选择「开话题回复」时按引用发送。"})]}),d.jsx("div",{className:"w-[300px] shrink-0",children:d.jsx(jw,{value:z,onChange:N,options:[{value:"direct",label:"直接发送"},{value:"quote",label:"引用回复"},{value:"thread",label:"开话题回复"}]})})]})}),d.jsx("div",{className:"rounded-xl border border-zinc-200 px-3.5 py-3",children:d.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsx("p",{className:"text-[12px] font-medium text-zinc-800",children:"随机表情回应"}),d.jsx("p",{className:"mt-0.5 text-[11px] leading-5 text-zinc-500",children:"触发后先在原消息上加 2–3 个随机飞书表情,再开始生成回复。"})]}),d.jsx(js,{size:"small","aria-label":"随机表情回应",checked:I,onChange:$})]})}),d.jsxs("label",{className:"block rounded-xl border border-zinc-200 px-3.5 py-3",children:[d.jsx("span",{className:"text-[12px] font-medium text-zinc-800",children:"回复署名(可选)"}),d.jsx("input",{className:lu,value:R,maxLength:100,onChange:he=>E(he.target.value),placeholder:"例如:—— 🤖 数字分身"}),d.jsx("p",{className:"mt-1 text-[10px] leading-4 text-zinc-400",children:"加在 Agent 发出的每条消息末尾;手动发送的消息不加。"})]})]})]}),d.jsxs("section",{className:"rounded-2xl border border-zinc-200/80 bg-white p-4 shadow-[0_1px_2px_rgba(24,24,27,.03)] sm:p-5",children:[d.jsxs("div",{className:"flex items-start gap-3",children:[d.jsx("span",{className:"grid h-8 w-8 shrink-0 place-items-center rounded-xl bg-zinc-100 text-zinc-600",children:d.jsx(hX,{size:15})}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[d.jsx("h3",{className:"text-[14px] font-semibold text-zinc-900",children:"触发规则"}),d.jsx("span",{className:"rounded-full bg-sky-50 px-2 py-0.5 text-[10px] font-medium text-sky-700",children:"仅本人可触发"})]}),d.jsx("p",{className:"mt-1 text-[11px] leading-5 text-zinc-500",children:"只有你本人发送匹配前缀的消息才会发起 Agent 轮次;其他人的消息只作为上下文,即使发送相同前缀也不会触发。"})]})]}),d.jsxs("div",{className:"mt-4 grid gap-4 sm:grid-cols-2",children:[d.jsxs("label",{className:"block",children:[d.jsx("span",{className:qs,children:"触发前缀"}),d.jsx("input",{className:lu,value:b,placeholder:"/ai",onChange:he=>y(he.target.value)})]}),d.jsxs("label",{className:"block",children:[d.jsx("span",{className:qs,children:"每轮注入条数(1–50)"}),d.jsx("input",{className:lu,type:"number",min:1,max:50,value:w,onChange:he=>S(Number(he.target.value)||10)}),d.jsx("p",{className:"mt-1 text-[10px] leading-4 text-zinc-400",children:"每次触发时,附上最近 N 条文字消息(含本条触发消息)给 Agent;不是 Agent 的记忆条数,也不影响最近消息面板的保留上限。"})]})]}),d.jsxs("div",{className:"mt-3 rounded-xl bg-zinc-50 px-3.5 py-2.5 text-[11px] leading-5 text-zinc-500",children:["你发送 ",d.jsxs("code",{className:"rounded bg-white px-1 py-0.5 font-mono text-zinc-700",children:[b," 你的问题"]})," 即触发;所有 AgentText 会直接以你的身份发回原会话。"]})]}),d.jsxs("section",{className:"flex items-start gap-2.5 rounded-2xl border border-amber-200/70 bg-amber-50/60 p-4",children:[d.jsx(tf,{size:15,className:"mt-0.5 shrink-0 text-amber-600"}),d.jsxs("div",{children:[d.jsx("h3",{className:"text-[12px] font-semibold text-amber-900",children:"使用风险"}),d.jsx("p",{className:"mt-1 text-[11px] leading-5 text-amber-800",children:"替身以你的飞书身份读取和发送消息,Agent 输出会直接发出。请只监听可信会话,并确认 Agent 的权限边界。"})]})]})]})}),d.jsx("div",{className:"shrink-0 border-t border-zinc-200/80 bg-white px-4 py-3",children:d.jsxs("div",{className:"mx-auto flex max-w-[820px] flex-wrap items-center justify-between gap-3",children:[d.jsx("p",{className:"text-[11px] text-zinc-500",children:"修改后点击保存,后续消息立即使用新规则。"}),d.jsx(zn,{type:"primary",onClick:()=>me.mutate(),className:"!rounded-lg !bg-zinc-900",children:"保存配置"})]})})]}),Ai.createPortal(Pe.toast,document.body)]})}function ume({value:e,onChange:t}){return d.jsx(IE,{value:e,onChange:t,label:"Web 访问地址",placeholder:"留空不显示详情链接,可选择当前地址",suggestion:typeof window>"u"?void 0:window.location.origin,suggestionLabel:"使用当前访问地址"})}function ZC(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,i])=>t.indexOf(+r)===-1).map(([r,i])=>i)}function fO(e,t="|"){return e.map(n=>s9(n)).join(t)}function XC(e,t){return typeof t=="bigint"?t.toString():t}class dme{constructor(t){this._getter=t,this._value=void 0}get value(){const t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}}function RE(e){return new dme(e)}function hme(e){return e==null}function OE(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function fme(e,t){const n=e/t,r=Math.round(n),i=4*Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function Dc(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function e9(e){const t=Object.getOwnPropertyDescriptor(e,"shape");return t!=null&&t.get?t.get.raw:t==null?void 0:t.value}function hl(e){return e9(e._zod.def)??e._zod.def.shape}function t9(e,t,n){Object.defineProperty(e,t,{get(){const r=n();return Dc(this,t,r),r},enumerable:!0,configurable:!0})}function n9(e,t,n){t in e?Dc(e,t,n):e[t]=n}function cd(e,t,n,r){const i=hl(t);for(const s of n){const o=Object.getOwnPropertyDescriptor(i,s);o.enumerable&&(o.get?t9(e,s,()=>{const a=t._zod.def.shape[s];return r?r(a,s):a}):n9(e,s,r?r(o.value,s):o.value))}}function pme(e,t){for(const n of Reflect.ownKeys(t)){const r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?t9(e,n,()=>t[n]):n9(e,n,r.value))}}function zs(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function mme(e){return JSON.stringify(e)}function gme(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const r9="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Yx(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const vme=RE(()=>{var e;if(Fo.jitless||typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function lf(e){if(Yx(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Yx(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function i9(e){return lf(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const xme=new Set(["string","number","symbol"]);function My(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Lc(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function Ot(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function s9(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function bme(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const o9={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},yme={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function wme(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s={};return cd(s,e,$y(e,t)),Lc(e,zs(n,{shape:s,checks:[]}))}function $y(e,t){var i;const n=hl(e),r=[];for(const s of Reflect.ownKeys(t)){if(!((i=Object.getOwnPropertyDescriptor(n,s))!=null&&i.enumerable))throw new Error(`Unrecognized key: "${String(s)}"`);t[s]&&r.push(s)}return r}function Sme(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=new Set($y(e,t)),o={};return cd(o,e,Reflect.ownKeys(hl(e)).filter(a=>!s.has(a))),Lc(e,zs(n,{shape:o,checks:[]}))}function _me(e,t){if(!lf(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=hl(e);for(const s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Lc(e,zs(e._zod.def,{shape:a9(e,t)}))}function a9(e,t){const n={};return cd(n,e,Reflect.ownKeys(hl(e))),pme(n,t),n}function Cme(e,t){if(!lf(t))throw new Error("Invalid input to safeExtend: expected a plain object");return Lc(e,zs(e._zod.def,{shape:a9(e,t)}))}function kme(e,t){var i,s;if(!((i=t==null?void 0:t._zod)!=null&&i.def))throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if((s=e._zod.def.checks)!=null&&s.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n={};cd(n,e,Reflect.ownKeys(hl(e))),cd(n,t,Reflect.ownKeys(hl(t)));const r=zs(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Lc(e,r)}function pO(e,t,n,r="partial"){const s=t._zod.def.checks;if(s&&s.length>0)throw new Error(`.${r}() cannot be used on object schemas containing refinements`);const a=n?new Set($y(t,n)):void 0,l={};return cd(l,t,Reflect.ownKeys(hl(t)),e&&((c,u)=>a&&!a.has(u)?c:new e({type:"optional",innerType:c}))),Lc(t,zs(t._zod.def,{shape:l,checks:[]}))}function Nme(e,t,n){const r=n?new Set($y(t,n)):void 0,i={};return cd(i,t,Reflect.ownKeys(hl(t)),(s,o)=>r&&!r.has(o)?s:new e({type:"nonoptional",innerType:s})),Lc(t,zs(t._zod.def,{shape:i}))}function Ua(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function Eme(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)===!1)return!0;return!1}function ah(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function hp(e){return typeof e=="string"?e:e==null?void 0:e.message}function mO(e){const t=[];for(const n of e??[]){const r=n._zod.def;if(!/_(length|size)$|_equals$/.test(r.check))break;const i=r.maximum??r.length??r.size;i>=0&&t.push([i,n])}return t}function JC(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function kc(e,t,n){var l,c,u,h,f,p,g,x,v,b;var r;const i=(c=(l=e.inst)==null?void 0:l._zod)==null?void 0:c.traits;i!=null&&i.has("$ZodType")&&(i.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);const s=e.schema!==e.inst?(h=(u=e.schema)==null?void 0:u._zod.def)==null?void 0:h.error:void 0,o=e.message?e.message:hp((g=(p=(f=e.inst)==null?void 0:f._zod.def)==null?void 0:p.error)==null?void 0:g.call(p,e))??hp(s==null?void 0:s(e))??hp((x=t==null?void 0:t.error)==null?void 0:x.call(t,e))??hp((v=n.customError)==null?void 0:v.call(n,e))??hp((b=n.localeError)==null?void 0:b.call(n,e))??"Invalid input",a={};for(const y of Object.keys(e))y==="inst"||y==="schema"||y==="continue"||y==="input"||y==="__proto__"||(a[y]=e[y]);return a.path??(a.path=[]),a.message=o,t!=null&&t.reportInput&&(a.input=e.input),a}const jme=/[\uD800-\uDBFF]/;function PE(e){const t=e.length;if(!jme.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)===55296&&(e.charCodeAt(r+1)&64512)===56320&&(n--,r++);return n}function TE(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function zme(e){const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";const n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function Km(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function Mme(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):$me(e,n,r.value)}}function Nc(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function l9(e,t,n){return Nc(e,t,n,!1)}function c9(e,t){for(const n in e){const r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Nc(this,n,r(this))},set(i){Nc(this,n,i)}})}return t}function $me(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Nc(this,t,n.bind(this))},set(r){Nc(this,t,r)}})}function Ime(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let zw,Pl=!1;const Rme={configurable:!0,get(){Pl=!0}};function Pn(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&zw!==e._zod){zw=void 0;return}zw=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Rme);const i=Pl;Pl=!1;try{const s=n(this);return Pl?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s}),Pl=Pl||i,s}catch(s){throw delete this[t],Pl=Pl||i,s}},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i})}})}function Ome(e,t,n,r){const i=Ime(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){const s={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,s),s.value=n(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:s})}})}const Pme="~constantCatch";function Tme(e){const t=()=>e;return t[Pme]=!0,t}var gO;const Mw={value:void 0,enumerable:!1};let vO="captureStackTrace"in Error?Error:null;function Ame(e){const t=vO;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return vO=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function Ue(e,t,n,r){const i={};function s(f){this.def=f,this.constr=h,this.traits=new Set}s.prototype=i;const o=n,a=o&&new WeakSet;function l(f,p){if(f._zod){if(f._zod.traits.has(e))return}else{Mw.value=new s(p);try{Object.defineProperty(f,"_zod",Mw)}finally{Mw.value=void 0}}if(f._zod.traits.add(e),t(f,p),a){const x=Object.getPrototypeOf(f),v=f._zod.constr.prototype;let b=x;for(;b&&b!==v;)b=Object.getPrototypeOf(b);const y=b??x;a.has(y)||(a.add(y),Mme(y,o))}const g=h.prototype;for(const x in g)Object.prototype.hasOwnProperty.call(g,x)&&(x in f||(f[x]=g[x].bind(f)))}const c=(r==null?void 0:r.Parent)??Object;class u extends c{}Object.defineProperty(u,"name",{value:e});function h(f){var v;const p=r!=null&&r.Parent?Ame(u):this;l(p,f);const g=p._zod.deferred;if(g){for(const b of g)b();p._zod.deferred=void 0}const x=(v=globalThis.__zod_globalConfig)==null?void 0:v.postProcessor;return x&&x(p),p}return Object.defineProperty(h,"init",{value:l}),Object.defineProperty(h,Symbol.hasInstance,{value:f=>{var p,g;return r!=null&&r.Parent&&f instanceof r.Parent?!0:(g=(p=f==null?void 0:f._zod)==null?void 0:p.traits)==null?void 0:g.has(e)}}),Object.defineProperty(h,"name",{value:e}),h}class Du extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class u9 extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(gO=globalThis).__zod_globalConfig??(gO.__zod_globalConfig={});const Fo=globalThis.__zod_globalConfig;function xa(e){return e&&Object.assign(Fo,e),Fo}function Dme(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,XC,2)),e.message}function Lme(e){this._zod.message=e}const Fme={get:Dme,set:Lme,enumerable:!0,configurable:!0},$w={value:void 0,enumerable:!1},xO=new WeakSet([Object.prototype,Error.prototype]),Bme=(e,t)=>{e.name="$ZodError",$w.value=t,Object.defineProperty(e,"issues",$w),$w.value=void 0,Object.defineProperty(e,"message",Fme);const n=Object.getPrototypeOf(e);xO.has(n)||(xO.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){const r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}}))},Hme=Ue("$ZodError",Bme);function Vme(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function Wme(e,t=n=>n.message){const n={},r=[];for(const i of e.issues)i.path.length>0?Vme(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function qme(e,t=n=>n.message){const n={_errors:[]},r=(i,s=[])=>{for(const o of i.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(a=>r({issues:a},[...s,...o.path]));else if(o.code==="invalid_key")r({issues:o.issues},[...s,...o.path]);else if(o.code==="invalid_element")r({issues:o.issues},[...s,...o.path]);else{const a=[...s,...o.path];if(a.length===0)n._errors.push(t(o));else{let l=n,c=0;for(;c<a.length;){const u=a[c],h=c===a.length-1;if(u==="_errors"){h&&l._errors.push(t(o)),c++;continue}Object.prototype.hasOwnProperty.call(l,u)||Object.defineProperty(l,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const f=l[u];h&&f._errors.push(t(o)),l=f,c++}}}};return r(e),n}function Iy(e,t){return{callee:(t==null?void 0:t.callee)??e,Err:t==null?void 0:t.Err}}const AE=e=>{const t=(n,r,i,s)=>{const o=i?{...i,async:!1}:{async:!1},a=n._zod.run({value:r,issues:[]},o);if(a instanceof Promise)throw new Du;if(a.issues.length){const l=new((s==null?void 0:s.Err)??e)(a.issues.map(c=>kc(c,o,xa())));throw r9(l,(s==null?void 0:s.callee)??t),l}return a.value};return t},DE=e=>{const t=async(n,r,i,s)=>{const o=i?{...i,async:!0}:{async:!0};let a=n._zod.run({value:r,issues:[]},o);if(a instanceof Promise&&(a=await a),a.issues.length){const l=new((s==null?void 0:s.Err)??e)(a.issues.map(c=>kc(c,o,xa())));throw r9(l,(s==null?void 0:s.callee)??t),l}return a.value};return t},LE=e=>(t,n,r)=>{const i=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new Du;return s.issues.length?d9(e,s.issues,i):{success:!0,data:s.value}};function d9(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(i=>kc(i,n,xa()))),t=void 0,n=void 0),r},set error(i){r=i,t=void 0,n=void 0}}}const FE=e=>async(t,n,r)=>{const i=r?{...r,async:!0}:{async:!0};let s=t._zod.run({value:n,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?d9(e,s.issues,i):{success:!0,data:s.value}},Ume=Symbol.for("zod.compile.invalid"),Kme=Symbol.for("zod.compile.fallback"),Gme=((e,t,n)=>{const r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Ume)return!0;if(r.definite===!0&&n===void 0)return!1}return Yme(e,t,n)});function Yme(e,t,n){const r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun;let s;if(i?(r[Kme]=!0,s=i({value:t,issues:[]},r)):s=e._zod.run({value:t,issues:[]},r),s instanceof Promise)throw new Du;return s.issues.length===0}const Zme=async(e,t,n)=>{const r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0};let i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},Xme=e=>{const t=AE(e),n=(r,i,s,o)=>{const a=s?{...s,direction:"backward"}:{direction:"backward"};return t(r,i,a,Iy(n,o))};return n},Jme=e=>{const t=AE(e),n=(r,i,s,o)=>t(r,i,s,Iy(n,o));return n},Qme=e=>{const t=DE(e),n=async(r,i,s,o)=>{const a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(r,i,a,Iy(n,o))};return n},ege=e=>{const t=DE(e),n=async(r,i,s,o)=>await t(r,i,s,Iy(n,o));return n},tge=e=>(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return LE(e)(t,n,i)},nge=e=>(t,n,r)=>LE(e)(t,n,r),rge=e=>async(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return FE(e)(t,n,i)},ige=e=>async(t,n,r)=>FE(e)(t,n,r),sge=/^[cC][0-9a-z]{6,}$/,oge=/^[0-9a-z]+$/,age=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,lge=/^[0-9a-vA-V]{20}$/,cge=/^[A-Za-z0-9]{27}$/,uge=/^[a-zA-Z0-9_-]{21}$/;function dge(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const hge=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,fge=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,bO=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,pge=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,mge="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function gge(){return new RegExp(mge,"u")}const vge=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,xge=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,bge=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,yge=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,wge=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Sge=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,_ge=/^https?$/,Cge=/^\+[1-9]\d{6,14}$/,h9="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function kge(e){return new RegExp(`^${e}$`)}const Nge=kge(h9);function QC(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Ege(e){return new RegExp(`^${QC(e)}$`)}function jge(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${QC({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${QC({precision:e.precision})}`:n;return new RegExp(`^${h9}T(?:${r})$`)}const zge=/^[\s\S]{0,}$/,Mge=/^-?\d+$/,BE=/^-?\d+(?:\.\d+)?$/,$ge=/^(?:true|false)$/i,Ige=/^[^A-Z]*$/,Rge=/^[^a-z]*$/,ms=Ue("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),HE=e=>{const t=e.value;return!hme(t)&&t.length!==void 0},Zx={number:"number",bigint:"bigint",object:"date"},f9=Ue("$ZodCheckLessThan",(e,t)=>{ms.init(e,t);const n=Zx[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:Zx[typeof r.value]??n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),p9=Ue("$ZodCheckGreaterThan",(e,t)=>{ms.init(e,t);const n=Zx[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:Zx[typeof r.value]??n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Oge=Ue("$ZodCheckMultipleOf",(e,t)=>{ms.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):fme(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Pge=Ue("$ZodCheckNumberFormat",(e,t)=>{var o;ms.init(e,t),t.format=t.format||"float64";const n=(o=t.format)==null?void 0:o.includes("int"),r=n?"int":"number",[i,s]=o9[t.format];e._zod.check=a=>{const l=a.value;if(n){if(!Number.isInteger(l)){a.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:l,inst:e});return}if(!Number.isSafeInteger(l)){l>0?a.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):a.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}l<i&&a.issues.push({origin:"number",input:l,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),l>s&&a.issues.push({origin:"number",input:l,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),Tge=Ue("$ZodCheckMaxLength",(e,t)=>{var n;ms.init(e,t),(n=e._zod.def).when??(n.when=HE),e._zod.check=r=>{const i=r.value,s=i.length;if((typeof i=="string"&&s>t.maximum?PE(i):s)<=t.maximum)return;const a=TE(i);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Age=Ue("$ZodCheckMinLength",(e,t)=>{var n;ms.init(e,t),(n=e._zod.def).when??(n.when=HE),e._zod.check=r=>{const i=r.value,s=i.length;if((typeof i=="string"&&s>=t.minimum&&s<t.minimum*2?PE(i):s)>=t.minimum)return;const a=TE(i);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Dge=Ue("$ZodCheckLengthEquals",(e,t)=>{var n;ms.init(e,t),(n=e._zod.def).when??(n.when=HE),e._zod.check=r=>{const i=r.value,s=i.length,o=typeof i=="string"&&s>=t.length&&s<=t.length*2?PE(i):s;if(o===t.length)return;const a=TE(i),l=o>t.length;r.issues.push({origin:a,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Ry=Ue("$ZodCheckStringFormat",(e,t)=>{var n,r;ms.init(e,t),t.pattern?(n=e._zod).check??(n.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Lge=Ue("$ZodCheckRegex",(e,t)=>{Ry.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Fge=Ue("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ige),Ry.init(e,t)}),Bge=Ue("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Rge),Ry.init(e,t)}),Hge=Ue("$ZodCheckIncludes",(e,t)=>{ms.init(e,t);const n=My(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),Vge=Ue("$ZodCheckStartsWith",(e,t)=>{ms.init(e,t);const n=new RegExp(`^${My(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Wge=Ue("$ZodCheckEndsWith",(e,t)=>{ms.init(e,t);const n=new RegExp(`.*${My(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),qge=Ue("$ZodCheckOverwrite",(e,t)=>{ms.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Uge{constructor(t=[],n={}){this.content=[],this.indent=0,this.args=t,this.closed=n}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
851
851
  `).filter(o=>o),i=Math.min(...r.map(o=>o.length-o.trimStart().length)),s=r.map(o=>o.slice(i)).map(o=>" ".repeat(this.indent*2)+o);for(const o of s)this.content.push(o)}compile(){const t=Function,n=(this==null?void 0:this.content)??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
852
852
  ${n.join(`
853
853
  `)}
@@ -957,7 +957,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
957
957
  `),i;function s(o){return r.stack.push(o),a;function a(){r.stack.pop()}}}function oEe(e){throw new Error("Cannot handle value `"+e+"`, expected node")}function aEe(e){const t=e;throw new Error("Cannot handle unknown node `"+t.type+"`")}function lEe(e,t){if(e.type==="definition"&&e.type===t.type)return 0}function cEe(e,t){return XNe(e,this,t)}function uEe(e,t){return JNe(e,this,t)}function dEe(e,t){return nEe(this,e,t)}function hEe(){return{enter:{table:fEe,tableData:QT,tableHeader:QT,tableRow:mEe},exit:{codeText:gEe,table:pEe,tableData:uS,tableHeader:uS,tableRow:uS}}}function fEe(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function pEe(e){this.exit(e),this.data.inTable=void 0}function mEe(e){this.enter({type:"tableRow",children:[]},e)}function uS(e){this.exit(e)}function QT(e){this.enter({type:"tableCell",children:[]},e)}function gEe(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,vEe));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function vEe(e,t){return t==="|"?t:e}function xEe(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
958
958
  `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:f,table:o,tableCell:l,tableRow:a}};function o(p,g,x,v){return c(u(p,x,v),p.align)}function a(p,g,x,v){const b=h(p,x,v),y=c([b]);return y.slice(0,y.indexOf(`
959
959
  `))}function l(p,g,x,v){const b=x.enter("tableCell"),y=x.enter("phrasing"),w=x.containerPhrasing(p,{...v,before:s,after:s});return y(),b(),w}function c(p,g){return hNe(p,{align:g,alignDelimiters:r,padding:n,stringLength:i})}function u(p,g,x){const v=p.children;let b=-1;const y=[],w=g.enter("table");for(;++b<v.length;)y[b]=h(v[b],g,x);return w(),y}function h(p,g,x){const v=p.children;let b=-1;const y=[],w=g.enter("tableRow");for(;++b<v.length;)y[b]=l(v[b],p,g,x);return w(),y}function f(p,g,x){let v=Ej.inlineCode(p,g,x);return x.stack.includes("tableCell")&&(v=v.replace(/\|/g,"\\$&")),v}}function bEe(){return{exit:{taskListCheckValueChecked:eA,taskListCheckValueUnchecked:eA,paragraph:wEe}}}function yEe(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:SEe}}}function eA(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function wEe(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,o;for(;++s<i.length;){const a=i[s];if(a.type==="paragraph"){o=a;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function SEe(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",a=n.createTracker(r);s&&a.move(o);let l=Ej.listItem(e,t,n,{...r,...a.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(u){return u+o}}function _Ee(){return[P2e(),nNe(),oNe(),hEe(),bEe()]}function CEe(e){return{extensions:[T2e(),rNe(e),aNe(),xEe(e),yEe()]}}const kEe={tokenize:$Ee,partial:!0},BV={tokenize:IEe,partial:!0},HV={tokenize:REe,partial:!0},VV={tokenize:OEe,partial:!0},NEe={tokenize:PEe,partial:!0},WV={name:"wwwAutolink",tokenize:zEe,previous:UV},qV={name:"protocolAutolink",tokenize:MEe,previous:KV},wl={name:"emailAutolink",tokenize:jEe,previous:GV},Ea={};function EEe(){return{text:Ea}}let Jc=48;for(;Jc<123;)Ea[Jc]=wl,Jc++,Jc===58?Jc=65:Jc===91&&(Jc=97);Ea[43]=wl;Ea[45]=wl;Ea[46]=wl;Ea[95]=wl;Ea[72]=[wl,qV];Ea[104]=[wl,qV];Ea[87]=[wl,WV];Ea[119]=[wl,WV];function jEe(e,t,n){const r=this;let i,s;return o;function o(h){return!Nk(h)||!GV.call(r,r.previous)||jj(r.events)?n(h):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),a(h))}function a(h){return Nk(h)?(e.consume(h),a):h===64?(e.consume(h),l):n(h)}function l(h){return h===46?e.check(NEe,u,c)(h):h===45||h===95||Oi(h)?(s=!0,e.consume(h),l):u(h)}function c(h){return e.consume(h),i=!0,l}function u(h){return s&&i&&Xi(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(h)):n(h)}}function zEe(e,t,n){const r=this;return i;function i(o){return o!==87&&o!==119||!UV.call(r,r.previous)||jj(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(kEe,e.attempt(BV,e.attempt(HV,s),n),n)(o))}function s(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function MEe(e,t,n){const r=this;let i="",s=!1;return o;function o(h){return(h===72||h===104)&&KV.call(r,r.previous)&&!jj(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(h),e.consume(h),a):n(h)}function a(h){if(Xi(h)&&i.length<5)return i+=String.fromCodePoint(h),e.consume(h),a;if(h===58){const f=i.toLowerCase();if(f==="http"||f==="https")return e.consume(h),l}return n(h)}function l(h){return h===47?(e.consume(h),s?c:(s=!0,l)):n(h)}function c(h){return h===null||lb(h)||Vn(h)||ud(h)||Vy(h)?n(h):e.attempt(BV,e.attempt(HV,u),n)(h)}function u(h){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(h)}}function $Ee(e,t,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),i):o===46&&r===3?(e.consume(o),s):n(o)}function s(o){return o===null?n(o):t(o)}}function IEe(e,t,n){let r,i,s;return o;function o(c){return c===46||c===95?e.check(VV,l,a)(c):c===null||Vn(c)||ud(c)||c!==45&&Vy(c)?l(c):(s=!0,e.consume(c),o)}function a(c){return c===95?r=!0:(i=r,r=void 0),e.consume(c),o}function l(c){return i||r||!s?n(c):t(c)}}function REe(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?s(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(VV,t,s)(o):o===null||Vn(o)||ud(o)?t(o):(e.consume(o),i)}function s(o){return o===41&&r++,e.consume(o),i}}function OEe(e,t,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(e.consume(a),r):a===38?(e.consume(a),s):a===93?(e.consume(a),i):a===60||a===null||Vn(a)||ud(a)?t(a):n(a)}function i(a){return a===null||a===40||a===91||Vn(a)||ud(a)?t(a):r(a)}function s(a){return Xi(a)?o(a):n(a)}function o(a){return a===59?(e.consume(a),r):Xi(a)?(e.consume(a),o):n(a)}}function PEe(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return Oi(s)?n(s):t(s)}}function UV(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Vn(e)}function KV(e){return!Xi(e)}function GV(e){return!(e===47||Nk(e))}function Nk(e){return e===43||e===45||e===46||e===95||Oi(e)}function jj(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const TEe={tokenize:WEe,partial:!0};function AEe(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:BEe,continuation:{tokenize:HEe},exit:VEe}},text:{91:{name:"gfmFootnoteCall",tokenize:FEe},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:DEe,resolveTo:LEe}}}}function DEe(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return a;function a(l){if(!o||!o._balanced)return n(l);const c=Ao(r.sliceSerialize({start:o.end,end:r.now()}));return c.codePointAt(0)!==94||!s.includes(c.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function LEe(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...a),e}function FEe(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,o;return a;function a(h){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),l}function l(h){return h!==94?n(h):(e.enter("gfmFootnoteCallMarker"),e.consume(h),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(h){if(s>999||h===93&&!o||h===null||h===91||Vn(h))return n(h);if(h===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return i.includes(Ao(r.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(h)}return Vn(h)||(o=!0),s++,e.consume(h),h===92?u:c}function u(h){return h===91||h===92||h===93?(e.consume(h),s++,c):c(h)}}function BEe(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,o=0,a;return l;function l(g){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(g){return g===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",u):n(g)}function u(g){if(o>999||g===93&&!a||g===null||g===91||Vn(g))return n(g);if(g===93){e.exit("chunkString");const x=e.exit("gfmFootnoteDefinitionLabelString");return s=Ao(r.sliceSerialize(x)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return Vn(g)||(a=!0),o++,e.consume(g),g===92?h:u}function h(g){return g===91||g===92||g===93?(e.consume(g),o++,u):u(g)}function f(g){return g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),i.includes(s)||i.push(s),yn(e,p,"gfmFootnoteDefinitionWhitespace")):n(g)}function p(g){return t(g)}}function HEe(e,t,n){return e.check(i0,t,e.attempt(TEe,t,n))}function VEe(e){e.exit("gfmFootnoteDefinition")}function WEe(e,t,n){const r=this;return yn(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(s):n(s)}}function qEe(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,a){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let c=l;for(;c--;)if(o[c][0]==="exit"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[c][1].end.offset-o[c][1].start.offset){o[l][1].type="strikethroughSequence",o[c][1].type="strikethroughSequence";const u={type:"strikethrough",start:Object.assign({},o[c][1].start),end:Object.assign({},o[l][1].end)},h={type:"strikethroughText",start:Object.assign({},o[c][1].end),end:Object.assign({},o[l][1].start)},f=[["enter",u,a],["enter",o[c][1],a],["exit",o[c][1],a],["enter",h,a]],p=a.parser.constructs.insideSpan.null;p&&Rs(f,f.length,0,Wy(p,o.slice(c+1,l),a)),Rs(f,f.length,0,[["exit",h,a],["enter",o[l][1],a],["exit",o[l][1],a],["exit",u,a]]),Rs(o,c-1,l-c+3,f),l=c+f.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function s(o,a,l){const c=this.previous,u=this.events;let h=0;return f;function f(g){return c===126&&u[u.length-1][1].type!=="characterEscape"?l(g):(o.enter("strikethroughSequenceTemporary"),p(g))}function p(g){const x=hf(c);if(g===126)return h>1?l(g):(o.consume(g),h++,p);if(h<2&&!n)return l(g);const v=o.exit("strikethroughSequenceTemporary"),b=hf(g);return v._open=!b||b===2&&!!x,v._close=!x||x===2&&!!b,a(g)}}}class UEe{constructor(){this.map=[],this.index=new Map}add(t,n,r){KEe(this,t,n,r)}consume(t){if(this.map.sort(function(s,o){return s[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0,this.index.clear()}}function KEe(e,t,n,r){if(n===0&&r.length===0)return;const i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}const s=[t,n,r];e.map.push(s),e.index.set(t,s)}function GEe(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function YEe(){return{flow:{null:{name:"table",tokenize:ZEe,resolveAll:XEe}}}}function ZEe(e,t,n){const r=this;let i=0,s=0,o;return a;function a(N){let I=r.events.length-1;for(;I>-1;){const{type:E}=r.events[I][1];if(E==="lineEnding"||E==="linePrefix")I--;else break}const $=I>-1?r.events[I][1].type:null,R=$==="tableHead"||$==="tableRow"?_:l;return R===_&&r.parser.lazy[r.now().line]?n(N):R(N)}function l(N){return e.enter("tableHead"),e.enter("tableRow"),c(N)}function c(N){return N===124||(o=!0,s+=1),u(N)}function u(N){return N===null?n(N):Dt(N)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),p):n(N):cn(N)?yn(e,u,"whitespace")(N):(s+=1,o&&(o=!1,i+=1),N===124?(e.enter("tableCellDivider"),e.consume(N),e.exit("tableCellDivider"),o=!0,u):(e.enter("data"),h(N)))}function h(N){return N===null||N===124||Vn(N)?(e.exit("data"),u(N)):(e.consume(N),N===92?f:h)}function f(N){return N===92||N===124?(e.consume(N),h):h(N)}function p(N){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(N):(e.enter("tableDelimiterRow"),o=!1,cn(N)?yn(e,g,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(N):g(N))}function g(N){return N===45||N===58?v(N):N===124?(o=!0,e.enter("tableCellDivider"),e.consume(N),e.exit("tableCellDivider"),x):C(N)}function x(N){return cn(N)?yn(e,v,"whitespace")(N):v(N)}function v(N){return N===58?(s+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(N),e.exit("tableDelimiterMarker"),b):N===45?(s+=1,b(N)):N===null||Dt(N)?S(N):C(N)}function b(N){return N===45?(e.enter("tableDelimiterFiller"),y(N)):C(N)}function y(N){return N===45?(e.consume(N),y):N===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(N),e.exit("tableDelimiterMarker"),w):(e.exit("tableDelimiterFiller"),w(N))}function w(N){return cn(N)?yn(e,S,"whitespace")(N):S(N)}function S(N){return N===124?g(N):N===null||Dt(N)?!o||i!==s?C(N):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(N)):C(N)}function C(N){return n(N)}function _(N){return e.enter("tableRow"),k(N)}function k(N){return N===124?(e.enter("tableCellDivider"),e.consume(N),e.exit("tableCellDivider"),k):N===null||Dt(N)?(e.exit("tableRow"),t(N)):cn(N)?yn(e,k,"whitespace")(N):(e.enter("data"),j(N))}function j(N){return N===null||N===124||Vn(N)?(e.exit("data"),k(N)):(e.consume(N),N===92?z:j)}function z(N){return N===92||N===124?(e.consume(N),j):j(N)}}function XEe(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],o=[0,0,0,0],a=!1,l=0,c,u,h;const f=new UEe;for(;++n<e.length;){const p=e[n],g=p[1];p[0]==="enter"?g.type==="tableHead"?(a=!1,l!==0&&(tA(f,t,l,c,u),u=void 0,l=0),c={type:"table",start:Object.assign({},g.start),end:Object.assign({},g.end)},f.add(n,0,[["enter",c,t]])):g.type==="tableRow"||g.type==="tableDelimiterRow"?(r=!0,h=void 0,s=[0,0,0,0],o=[0,n+1,0,0],a&&(a=!1,u={type:"tableBody",start:Object.assign({},g.start),end:Object.assign({},g.end)},f.add(n,0,[["enter",u,t]])),i=g.type==="tableDelimiterRow"?2:u?3:1):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(s[1]!==0&&(o[0]=o[1],h=fv(f,t,s,i,void 0,h),s=[0,0,0,0]),o[2]=n)):g.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(o[0]=o[1],h=fv(f,t,s,i,void 0,h)),s=o,o=[s[1],n,0,0])):g.type==="tableHead"?(a=!0,l=n):g.type==="tableRow"||g.type==="tableDelimiterRow"?(l=n,s[1]!==0?(o[0]=o[1],h=fv(f,t,s,i,n,h)):o[1]!==0&&(h=fv(f,t,o,i,n,h)),i=0):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&tA(f,t,l,c,u),f.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=GEe(t.events,n))}return e}function fv(e,t,n,r,i,s){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},Zd(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const l=Zd(t.events,n[1]);if(s={type:o,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const c=Zd(t.events,n[2]),u=Zd(t.events,n[3]),h={type:a,start:Object.assign({},c),end:Object.assign({},u)};if(e.add(n[2],0,[["enter",h,t]]),r!==2){const f=t.events[n[2]],p=t.events[n[3]];if(f[1].end=Object.assign({},p[1].end),f[1].type="chunkText",f[1].contentType="text",n[3]>n[2]+1){const g=n[2]+1,x=n[3]-n[2]-1;e.add(g,x,[])}}e.add(n[3]+1,0,[["exit",h,t]])}return i!==void 0&&(s.end=Object.assign({},Zd(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function tA(e,t,n,r,i){const s=[],o=Zd(t.events,n);i&&(i.end=Object.assign({},o),s.push(["exit",i,t])),r.end=Object.assign({},o),s.push(["exit",r,t]),e.add(n+1,0,s)}function Zd(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const JEe={name:"tasklistCheck",tokenize:eje};function QEe(){return{text:{91:JEe}}}function eje(e,t,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),s)}function s(l){return Vn(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),a):n(l)}function a(l){return Dt(l)?t(l):cn(l)?e.check({tokenize:tje},t,n)(l):n(l)}}function tje(e,t,n){return yn(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function nje(e){return eV([EEe(),AEe(),qEe(e),YEe(),QEe()])}const rje={};function YV(e){const t=this,n=e||rje,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(nje(n)),s.push(_Ee()),o.push(CEe(n))}function ije(e){_V(e,[/\r?\n|\r/g,sje])}function sje(){return{type:"break"}}function oje(){return function(e){ije(e)}}const aje=new Set(["code","pre","a"]),lje=/[\u3000-\u303f\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uff00-\uffef]/;function cje(e){const t=[];let n="";const r=()=>{n&&(t.push(n),n="")};for(const i of e){if(i===`
960
- `){r(),t.push(i);continue}if(lje.test(i)){r(),t.push(i);continue}n+=i}return r(),t}function uje(e){return{type:"element",tagName:"span",properties:{className:["ui-tw-unit"]},children:[{type:"text",value:e}]}}function ZV(e,t){if(!Array.isArray(e.children))return;const n=t||e.type==="element"&&aje.has(e.tagName??""),r=[];for(const i of e.children){if(i.type==="text"&&typeof i.value=="string"&&!n&&i.value.trim()){for(const s of cje(i.value))r.push(uje(s));continue}ZV(i,n),r.push(i)}e.children=r}function dje(){return e=>{ZV(e,!1)}}function zj(e){if(!e||e.startsWith("#")||e.startsWith("//")||/^(?!file:)[a-z][a-z\d+.-]*:/i.test(e))return;let t=e;if(/^file:/i.test(t))try{const r=new URL(t);if(r.protocol!=="file:"||r.hostname&&r.hostname!=="localhost")return;t=decodeURIComponent(r.pathname)}catch{return}else try{t=decodeURIComponent(t.split(/[?#]/,1)[0])}catch{return}const n=t.slice(t.lastIndexOf("/")+1);if(/\.[^/.]+:\d+(?::\d+)?$/.test(n)&&(t=t.replace(/:\d+(?::\d+)?$/,"")),!(!t||t.includes("\0")||t.startsWith("/api/")||t.startsWith("/sessions/")))return t}function XV(e,t){var s;const n=(s=zj(e))==null?void 0:s.replace(/\\/g,"/");if(!n)return;const r=t.replace(/\\/g,"/").replace(/\/$/,"");if(n.startsWith("/"))return!r||!n.startsWith(`${r}/`)?void 0:n.slice(r.length+1);const i=[];for(const o of n.split("/"))if(!(!o||o==="."))if(o===".."){if(!i.length)return;i.pop()}else i.push(o);return i.join("/")||void 0}function hje(e,t){const n=zj(e);return XV(e,t)??(n!=null&&n.startsWith("/")?n:void 0)}const fje=m.lazy(()=>w4(()=>import("./ImageLightbox-6D7xjwqD.js"),__vite__mapDeps([0,1,2,3,4]))),pje=new Set([".png",".jpg",".jpeg",".gif",".webp",".bmp",".svg"]);function mje(e,t){var r;if(!e||e.startsWith("http://")||e.startsWith("https://")||e.startsWith("data:")||e.startsWith("/api/"))return e;const n=(r=e.split(".").pop())==null?void 0:r.toLowerCase();if(n&&pje.has(`.${n}`)&&t&&e.includes(".agentdock/uploads")){const i=e.split(/[/\\]/).pop();if(i)return`/api/sessions/${t}/uploads/${i}`}return e}const gje={csharp:"csharp",cs:"csharp",html:"markup",js:"javascript",jsx:"jsx",md:"markdown",py:"python",rb:"ruby",rs:"rust",sh:"bash",shell:"bash",ts:"typescript",tsx:"tsx",xml:"markup",yml:"yaml",zsh:"bash"};function vje(e){var r,i;const t=((i=(r=/(?:^|\s)language-([\w-]+)/.exec(e??""))==null?void 0:r[1])==null?void 0:i.toLowerCase())??"",n=gje[t]??t;return{language:n&&NG.languages[n]?n:"plain",label:t||"text"}}function JV(e,t){return!!(e!=null&&e.includes("language-")||String(t).includes(`
960
+ `){r(),t.push(i);continue}if(lje.test(i)){r(),t.push(i);continue}n+=i}return r(),t}function uje(e){return{type:"element",tagName:"span",properties:{className:["ui-tw-unit"]},children:[{type:"text",value:e}]}}function ZV(e,t){if(!Array.isArray(e.children))return;const n=t||e.type==="element"&&aje.has(e.tagName??""),r=[];for(const i of e.children){if(i.type==="text"&&typeof i.value=="string"&&!n&&i.value.trim()){for(const s of cje(i.value))r.push(uje(s));continue}ZV(i,n),r.push(i)}e.children=r}function dje(){return e=>{ZV(e,!1)}}function zj(e){if(!e||e.startsWith("#")||e.startsWith("//")||/^(?!file:)[a-z][a-z\d+.-]*:/i.test(e))return;let t=e;if(/^file:/i.test(t))try{const r=new URL(t);if(r.protocol!=="file:"||r.hostname&&r.hostname!=="localhost")return;t=decodeURIComponent(r.pathname)}catch{return}else try{t=decodeURIComponent(t.split(/[?#]/,1)[0])}catch{return}const n=t.slice(t.lastIndexOf("/")+1);if(/\.[^/.]+:\d+(?::\d+)?$/.test(n)&&(t=t.replace(/:\d+(?::\d+)?$/,"")),!(!t||t.includes("\0")||t.startsWith("/api/")||t.startsWith("/sessions/")))return t}function XV(e,t){var s;const n=(s=zj(e))==null?void 0:s.replace(/\\/g,"/");if(!n)return;const r=t.replace(/\\/g,"/").replace(/\/$/,"");if(n.startsWith("/"))return!r||!n.startsWith(`${r}/`)?void 0:n.slice(r.length+1);const i=[];for(const o of n.split("/"))if(!(!o||o==="."))if(o===".."){if(!i.length)return;i.pop()}else i.push(o);return i.join("/")||void 0}function hje(e,t){const n=zj(e);return XV(e,t)??(n!=null&&n.startsWith("/")?n:void 0)}const fje=m.lazy(()=>w4(()=>import("./ImageLightbox-9uMpMBH0.js"),__vite__mapDeps([0,1,2,3,4]))),pje=new Set([".png",".jpg",".jpeg",".gif",".webp",".bmp",".svg"]);function mje(e,t){var r;if(!e||e.startsWith("http://")||e.startsWith("https://")||e.startsWith("data:")||e.startsWith("/api/"))return e;const n=(r=e.split(".").pop())==null?void 0:r.toLowerCase();if(n&&pje.has(`.${n}`)&&t&&e.includes(".agentdock/uploads")){const i=e.split(/[/\\]/).pop();if(i)return`/api/sessions/${t}/uploads/${i}`}return e}const gje={csharp:"csharp",cs:"csharp",html:"markup",js:"javascript",jsx:"jsx",md:"markdown",py:"python",rb:"ruby",rs:"rust",sh:"bash",shell:"bash",ts:"typescript",tsx:"tsx",xml:"markup",yml:"yaml",zsh:"bash"};function vje(e){var r,i;const t=((i=(r=/(?:^|\s)language-([\w-]+)/.exec(e??""))==null?void 0:r[1])==null?void 0:i.toLowerCase())??"",n=gje[t]??t;return{language:n&&NG.languages[n]?n:"plain",label:t||"text"}}function JV(e,t){return!!(e!=null&&e.includes("language-")||String(t).includes(`
961
961
  `))}const QV=m.memo(function({code:t,className:n}){const{language:r,label:i}=vje(n),s=OH()==="dark",[o,a]=m.useState(!1);hZ(()=>a(!1),o?1500:void 0);const l=async()=>{var c;try{if((c=navigator.clipboard)!=null&&c.writeText)await navigator.clipboard.writeText(t);else{const u=document.createElement("textarea");u.value=t,u.style.position="fixed",u.style.opacity="0",document.body.appendChild(u),u.select(),document.execCommand("copy"),document.body.removeChild(u)}a(!0)}catch{a(!1)}};return d.jsxs("div",{className:"code-renderer group/code my-4 overflow-hidden rounded-[10px] border border-zinc-200 bg-[rgb(var(--code-bg))] [contain:layout_paint]",children:[d.jsxs("div",{className:"flex h-8 items-center px-3",children:[d.jsx("span",{className:"font-mono text-[12px] text-zinc-500",children:i}),d.jsxs("button",{type:"button",onClick:()=>void l(),className:"ml-auto flex h-6 items-center gap-1.5 rounded-md px-2 text-[12px] font-medium text-zinc-500 transition-colors hover:bg-zinc-100 hover:text-zinc-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400/50","aria-label":o?"代码已复制":"复制代码",children:[o?d.jsx(gi,{size:12}):d.jsx(a3,{size:12}),d.jsx("span",{children:o?"已复制":"复制"})]})]}),d.jsx(kG,{theme:s?$M.vsDark:$M.vsLight,code:t,language:r,children:({className:c,style:u,tokens:h,getLineProps:f,getTokenProps:p})=>d.jsx("pre",{className:`${c} code-renderer-scroll m-0 overflow-x-auto px-4 pb-3.5 pt-1 text-[13px] leading-6`,style:{...u,backgroundColor:"transparent"},children:d.jsx("code",{children:h.map((g,x)=>d.jsx("span",{...f({line:g}),className:"block min-h-6",children:g.map((v,b)=>d.jsx("span",{...p({token:v})},b))},x))})})})]})});function xje({src:e,alt:t}){const[n,r]=m.useState(!1),[i,s]=m.useState(!1);return d.jsxs(d.Fragment,{children:[d.jsx("img",{src:e,alt:t??"",loading:"lazy",onClick:()=>{r(!0),s(!0)},className:"my-2 max-h-40 w-auto max-w-full cursor-zoom-in object-contain transition-shadow hover:shadow-md"}),n&&d.jsx(m.Suspense,{fallback:null,children:d.jsx(fje,{src:e,alt:t,open:i,onClose:()=>s(!1)})})]})}const eW={a({href:e,children:t}){return d.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"font-medium text-link underline decoration-[#2563eb]/40 underline-offset-2 hover:decoration-[#2563eb]",children:t})},code({className:e,children:t}){return JV(e,t)?d.jsx(QV,{className:e,code:String(t).replace(/\n$/,"")}):d.jsx("code",{className:"rounded bg-zinc-100 px-[.32rem] py-[.12rem] font-mono text-[.9em] text-zinc-800",children:t})},pre({children:e}){return d.jsx(d.Fragment,{children:e})},table({children:e}){return d.jsx("div",{className:"markdown-table-scroll",children:d.jsx("table",{children:e})})}},bje={...eW,code({className:e,children:t}){return JV(e,t)?d.jsx(QV,{className:e,code:String(t).replace(/\n$/,"")}):/^\/[^\s]+$/.test(String(t))?d.jsx("code",{className:"ui-slash-command",children:t}):d.jsx("code",{className:"rounded bg-zinc-100 px-[.32rem] py-[.12rem] font-mono text-[.9em] text-zinc-800",children:t})}},vh=m.memo(function({children:t,sessionId:n,throttleMs:r,animateUnits:i=!1,highlightSlashCommands:s=!1}){const o=dZ(t,{wait:r??0}),a=r?o:t,l={...s?bje:eW,a({href:c,children:u}){const h=c?zj(c):void 0;return h&&n?d.jsx("button",{type:"button",title:h,onClick:()=>{const f=Js.getState();f.openTab({id:`preview:${f.primarySessionId}:${n}:${h}`,kind:"files",anchorSessionId:n,filePath:h,title:h.split("/").at(-1)||"文件"})},className:"font-medium text-link underline decoration-[#2563eb]/40 underline-offset-2 hover:decoration-[#2563eb]",children:u}):d.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"font-medium text-link underline decoration-[#2563eb]/40 underline-offset-2 hover:decoration-[#2563eb]",children:u})},img({src:c,alt:u}){const h=mje(c??"",n);return h?d.jsx(xje,{src:h,alt:u??""}):null}};return d.jsx(E2e,{remarkPlugins:[YV,oje],rehypePlugins:i?[dje]:[],urlTransform:c=>/^file:/i.test(c)?c:SV(c),components:l,children:a})}),tW={baseCharsPerSecond:14,catchUpSeconds:3,drainSeconds:.9},yje=.1,wje=40;function Sje(e,t,n,r,i=tW){if(e>=t)return t;const s=t-e,a=(r?i.baseCharsPerSecond+s/Math.max(.1,i.catchUpSeconds):s/Math.max(.05,i.drainSeconds))*Math.max(0,Math.min(yje,n));return Math.min(t,e+(r?a:Math.max(1,a)))}function _je(e){var n;if(!e)return e;const t=kje(e);if(t.openStart>=0){const r=((n=/^\s*(`{3,}|~{3,})/.exec(e.slice(t.openStart)))==null?void 0:n[1])??"```";return`${e}
962
962
  ${r}`}return zje(Nje(Eje(e,t.ranges)),t.ranges)}function Cje(e,t){return _je(e.slice(0,Math.max(0,Math.min(t,e.length))))}function kje(e){const t=[];let n=0,r=-1;for(;n<e.length;){const i=e.indexOf(`
963
963
  `,n),s=i===-1?e.length:i,o=e.slice(n,s);if(/^\s*(`{3,}|~{3,})/.test(o)&&(r<0?r=n:/^\s*(`{3,}|~{3,})\s*$/.test(o)&&(t.push({start:r,end:s+1}),r=-1)),i===-1)break;n=i+1}return{ranges:t,openStart:r}}function nW(e,t){if(t.length===0)return e;const n=e.split("");for(const r of t)for(let i=r.start;i<Math.min(r.end,n.length);i+=1)n[i]=" ";return n.join("")}function Nje(e){const t=e.split(`
@@ -1113,7 +1113,7 @@ ${e.raw??JSON.stringify(e.data,null,2)??""}`}function a3e({sessionId:e,active:t=
1113
1113
  2. …
1114
1114
  3. …`,multiline:!0},{key:"期望结果",label:"期望结果",placeholder:"正确时应该发生什么",multiline:!0},{key:"错误日志",label:"错误日志 / 堆栈(可选)",placeholder:"粘贴完整堆栈,不要截断",multiline:!0,optional:!0}]},{id:"builtin-review",title:"代码审查",description:"按清单审查 diff,给出带文件行号的发现",icon:"review",body:X3e,builtin:!0,fields:[{key:"审查范围",label:"审查范围",placeholder:"例如:git diff main...HEAD",defaultValue:"git diff main...HEAD"},{key:"重点关注",label:"重点关注(可选)",placeholder:"例如:并发、鉴权、错误处理",defaultValue:"正确性、边界条件、回归风险",optional:!0}]},{id:"builtin-test",title:"补测试",description:"为目标模块补齐关键路径和边界用例",icon:"test",body:J3e,builtin:!0,fields:[{key:"目标模块",label:"目标模块 / 文件",placeholder:"例如:packages/storage/src/index.ts",multiline:!0},{key:"测试命令",label:"测试命令",defaultValue:"pnpm test"},{key:"重点场景",label:"重点场景(可选)",placeholder:"例如:空输入、并发写入、失败重试",defaultValue:"正常路径、边界条件、错误路径",optional:!0}]},{id:"builtin-onboarding",title:"项目上手",description:"先画出代码地图,再做一次最小验证",icon:"compass",body:Q3e,builtin:!0,fields:[{key:"想了解的问题",label:"想了解什么",placeholder:"例如:一次请求从入口到存储经过了哪些模块?",multiline:!0},{key:"关注目录",label:"关注目录(可选)",placeholder:"例如:apps/server/src",defaultValue:"整个仓库",optional:!0}]}];function jM(e){const t=new Set,n=[];for(const r of e.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)){const i=r[1].trim();!i||t.has(i)||(t.add(i),n.push({key:i,label:i,multiline:!0}))}return n}function yG(e,t){return e.body.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{var s;const i=r.trim();return((s=t[i])==null?void 0:s.trim())||`{{${i}}}`})}function tLe(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t))return[];const n=[],r=new Set;for(const i of t){if(!i||typeof i!="object")continue;const s=i;if(typeof s.id!="string"||!s.id.trim()||r.has(s.id)||typeof s.title!="string"||!s.title.trim()||typeof s.body!="string"||!s.body.trim())continue;const o=s.title.trim().slice(0,kM),a=typeof s.description=="string"&&s.description.trim()?s.description.trim().slice(0,NM):"自定义提示词模板",l=s.body.slice(0,EM);if(r.add(s.id),n.push({id:s.id,title:o,description:a,body:l,icon:"custom",builtin:!1,fields:jM(l)}),n.length>=K3e)break}return n}function nLe(e){return JSON.stringify(e.map(t=>({id:t.id,title:t.title.slice(0,kM),description:t.description.slice(0,NM),body:t.body.slice(0,EM)})))}function rLe(e,t){const n=e.title.trim().slice(0,kM),r=e.body.trim().slice(0,EM);if(!n)throw new Error("模板名称不能为空");if(!r)throw new Error("模板内容不能为空");return{id:t??`custom_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`,title:n,description:e.description.trim().slice(0,NM)||"自定义提示词模板",icon:"custom",body:r,builtin:!1,fields:jM(r)}}function A5(){try{return tLe(window.localStorage.getItem(CM))}catch{return[]}}function iLe(e){try{window.localStorage.setItem(CM,nLe(e))}catch{}}const sLe={repeat:bL,sparkles:Lo,bug:jZ,review:sX,test:j3,compass:IZ,custom:DZ};function oLe({onUse:e}){const[t,n]=m.useState(()=>A5()),[r,i]=m.useState();m.useEffect(()=>{const a=l=>{l.key===CM&&n(A5())};return window.addEventListener("storage",a),()=>window.removeEventListener("storage",a)},[]);const s=a=>{n(a),iLe(a)},o=a=>{const l=Object.fromEntries(a.fields.map(c=>[c.key,c.defaultValue??""]));e(yG(a,l))};return d.jsxs("section",{"aria-label":"提示词模板",className:"mt-4",children:[d.jsxs("div",{className:"mb-2 flex items-center gap-1.5 px-0.5 text-[12px] font-medium text-zinc-500",children:[d.jsx(M_,{size:12}),d.jsx("span",{children:"提示词模板"}),d.jsx("span",{className:"ml-auto font-normal text-zinc-400",children:"点卡片直接填入,右上角可填写变量"})]}),d.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3",children:[[...eLe,...t].map(a=>{const l=sLe[a.icon],c=a.fields.length>0;return d.jsxs("div",{className:"group relative h-full",children:[d.jsxs("button",{type:"button",onClick:()=>o(a),title:"点击直接填入输入框",className:`flex h-full min-h-[78px] w-full flex-col rounded-xl border border-zinc-200 bg-white px-3 py-2.5 text-left transition-[border-color,box-shadow,transform] duration-150 ease-[cubic-bezier(.2,0,0,1)] hover:-translate-y-px hover:border-zinc-300 hover:shadow-[0_4px_14px_rgba(24,24,27,.06)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400/50 ${a.builtin?c?"pr-8":"":"pr-14"}`,children:[d.jsxs("span",{className:"flex w-full items-center gap-1.5 pr-5 text-[12px] font-medium text-zinc-800",children:[d.jsx(l,{size:13,className:"shrink-0 text-zinc-400"}),d.jsx("span",{className:"truncate",children:a.title})]}),d.jsx("span",{className:"mt-1 line-clamp-2 block text-[12px] leading-[1.5] text-zinc-500",children:a.description})]}),c&&d.jsx("button",{type:"button",onClick:()=>i({kind:"fill",template:a}),"aria-label":`填写模板变量:${a.title}`,title:"填写变量并预览最终文案",className:`absolute top-1.5 grid h-6 w-6 place-items-center rounded-md text-zinc-400 opacity-100 transition-opacity hover:bg-zinc-100 hover:text-zinc-700 focus-visible:opacity-100 sm:opacity-0 sm:group-hover:opacity-100 ${a.builtin?"right-1.5":"right-8"}`,children:d.jsx(lX,{size:11})}),!a.builtin&&d.jsx("button",{type:"button",onClick:()=>i({kind:"edit",template:a}),"aria-label":`编辑模板:${a.title}`,title:"编辑模板",className:"absolute right-1.5 top-1.5 grid h-6 w-6 place-items-center rounded-md text-zinc-400 opacity-100 transition-opacity hover:bg-zinc-100 hover:text-zinc-700 focus-visible:opacity-100 sm:opacity-0 sm:group-hover:opacity-100",children:d.jsx(fN,{size:11})})]},a.id)}),d.jsxs("button",{type:"button",onClick:()=>i({kind:"edit"}),className:"flex min-h-[78px] w-full flex-col items-center justify-center gap-1 rounded-xl border border-dashed border-zinc-300 px-3 py-2.5 text-[12px] text-zinc-500 transition-colors hover:border-zinc-400 hover:bg-zinc-50 hover:text-zinc-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400/50",children:[d.jsx(sa,{size:14}),d.jsx("span",{children:"新建模板"})]})]}),r&&d.jsx(aLe,{state:r,onClose:()=>i(void 0),onApply:a=>{i(void 0),e(a)},onSave:a=>{s(t.some(l=>l.id===a.id)?t.map(l=>l.id===a.id?a:l):[...t,a]),i(void 0)},onDelete:a=>{s(t.filter(l=>l.id!==a)),i(void 0)}})]})}function aLe({state:e,onClose:t,onApply:n,onSave:r,onDelete:i}){const s=m.useRef(null);Vo({panel:s,initial:s,dismissible:!0,onDismiss:t});const o=e.kind==="edit",a=o?e.template?"编辑模板":"新建模板":e.template.title;return d.jsx("div",{className:"ui-overlay fixed inset-0 z-[60] grid place-items-center bg-zinc-950/30 p-2 sm:p-4",children:d.jsxs("div",{ref:s,role:"dialog","aria-modal":"true","aria-label":a,className:"ui-dialog flex max-h-[88dvh] w-full max-w-xl flex-col overflow-hidden rounded-[14px] border border-zinc-200 bg-white shadow-[0_24px_80px_rgba(24,24,27,.2)]",children:[d.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-3 border-b border-zinc-100 px-4",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsx("div",{className:"truncate text-[15px] font-semibold text-zinc-900",children:a}),!o&&d.jsx("div",{className:"truncate text-[12px] text-zinc-400",children:e.template.description})]}),d.jsx("button",{type:"button",onClick:t,"aria-label":"关闭",className:"ml-auto grid h-8 w-8 shrink-0 place-items-center rounded-lg text-zinc-400 hover:bg-zinc-100 hover:text-zinc-800",children:d.jsx(Wn,{size:16})})]}),o?d.jsx(cLe,{template:e.template,onClose:t,onSave:r,onDelete:i}):d.jsx(lLe,{template:e.template,onClose:t,onApply:n})]})})}function lLe({template:e,onClose:t,onApply:n}){const[r,i]=m.useState(()=>Object.fromEntries(e.fields.map(a=>[a.key,a.defaultValue??""]))),s=m.useMemo(()=>yG(e,r),[e,r]),o=a=>{a.preventDefault(),n(s)};return d.jsxs("form",{onSubmit:o,className:"flex min-h-0 flex-1 flex-col",children:[d.jsxs("div",{className:"min-h-0 flex-1 space-y-3 overflow-y-auto px-4 py-3",children:[e.fields.map((a,l)=>d.jsxs("label",{className:"block",children:[d.jsx("span",{className:"mb-1.5 flex items-center gap-1 text-[12px] font-medium text-zinc-600",children:a.label}),a.multiline?d.jsx("textarea",{autoFocus:l===0,value:r[a.key]??"",onChange:c=>i(u=>({...u,[a.key]:c.target.value})),rows:3,placeholder:a.placeholder,className:"ui-field w-full resize-y rounded-lg border border-zinc-200 bg-white px-3 py-2 text-[13px] leading-5 text-zinc-800 outline-none transition-colors placeholder:text-zinc-400 focus:border-zinc-400"}):d.jsx("input",{autoFocus:l===0,value:r[a.key]??"",onChange:c=>i(u=>({...u,[a.key]:c.target.value})),placeholder:a.placeholder,spellCheck:!1,className:"ui-field h-9 w-full rounded-lg border border-zinc-200 bg-white px-3 text-[13px] text-zinc-800 outline-none transition-colors placeholder:text-zinc-400 focus:border-zinc-400"})]},a.key)),e.fields.length===0&&d.jsx("p",{className:"text-[12px] text-zinc-400",children:"这个模板没有变量,会直接填入输入框。"}),d.jsxs("div",{children:[d.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 text-[12px] font-medium text-zinc-600",children:[d.jsx(Bg,{size:12,className:"text-zinc-400"}),"最终文案预览"]}),d.jsx("pre",{"aria-label":"最终文案预览",className:"max-h-44 overflow-y-auto whitespace-pre-wrap break-words rounded-lg border border-zinc-200 bg-zinc-50 px-3 py-2 font-sans text-[12px] leading-5 text-zinc-600",children:s}),d.jsxs("p",{className:"mt-1 text-[12px] text-zinc-400",children:["变量留空会保留 ","{{变量}}"," 占位,填入后仍可在输入框里修改。"]})]})]}),d.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-2 border-t border-zinc-100 px-4 py-3",children:[d.jsx("button",{type:"button",onClick:t,className:"rounded-lg px-3 py-1.5 text-[12px] text-zinc-600 hover:bg-zinc-100",children:"取消"}),d.jsx("button",{type:"submit",className:"rounded-lg bg-zinc-900 px-3.5 py-1.5 text-[12px] font-medium text-white transition-colors hover:bg-zinc-800",children:"填入输入框"})]})]})}function cLe({template:e,onClose:t,onSave:n,onDelete:r}){const[i,s]=m.useState((e==null?void 0:e.title)??""),[o,a]=m.useState((e==null?void 0:e.description)??""),[l,c]=m.useState((e==null?void 0:e.body)??""),[u,h]=m.useState(),[f,p]=m.useState(!1),g=m.useMemo(()=>jM(l).map(v=>v.key),[l]),x=v=>{v.preventDefault();try{n(rLe({title:i,description:o,body:l},e==null?void 0:e.id))}catch(b){h(b instanceof Error?b.message:String(b))}};return d.jsxs("form",{onSubmit:x,className:"flex min-h-0 flex-1 flex-col",children:[d.jsxs("div",{className:"min-h-0 flex-1 space-y-3 overflow-y-auto px-4 py-3",children:[d.jsxs("label",{className:"block",children:[d.jsxs("span",{className:"mb-1.5 flex items-center gap-1 text-[12px] font-medium text-zinc-600",children:["模板名称",d.jsx("span",{className:"text-red-500",children:"*"})]}),d.jsx("input",{autoFocus:!0,value:i,onChange:v=>s(v.target.value),maxLength:40,placeholder:"例如:发布前检查",className:"ui-field h-9 w-full rounded-lg border border-zinc-200 bg-white px-3 text-[13px] text-zinc-800 outline-none transition-colors placeholder:text-zinc-400 focus:border-zinc-400"})]}),d.jsxs("label",{className:"block",children:[d.jsx("span",{className:"mb-1.5 block text-[12px] font-medium text-zinc-600",children:"一句话说明"}),d.jsx("input",{value:o,onChange:v=>a(v.target.value),maxLength:120,placeholder:"显示在卡片上,可留空",className:"ui-field h-9 w-full rounded-lg border border-zinc-200 bg-white px-3 text-[13px] text-zinc-800 outline-none transition-colors placeholder:text-zinc-400 focus:border-zinc-400"})]}),d.jsxs("label",{className:"block",children:[d.jsxs("span",{className:"mb-1.5 flex items-center gap-1 text-[12px] font-medium text-zinc-600",children:["模板内容",d.jsx("span",{className:"text-red-500",children:"*"})]}),d.jsx("textarea",{value:l,onChange:v=>c(v.target.value),rows:8,placeholder:`直接写完整提示词。用 {{变量名}} 标记需要每次填写的内容。
1115
1115
 
1116
- 例如:请检查 {{项目}} 的发布前状态,并运行 {{验证命令}}。`,className:"ui-field w-full resize-y rounded-lg border border-zinc-200 bg-white px-3 py-2 font-mono text-[12px] leading-5 text-zinc-800 outline-none transition-colors placeholder:text-zinc-400 focus:border-zinc-400"})]}),d.jsx("div",{className:"text-[12px] leading-5 text-zinc-500",children:g.length?d.jsxs(d.Fragment,{children:["识别到变量:",d.jsx("span",{className:"font-mono text-zinc-700",children:g.join("、")})]}):"没有 {{变量}},点击卡片会直接填入整段提示词。"}),u&&d.jsx("p",{role:"alert",className:"text-[12px] text-red-600",children:u})]}),d.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-t border-zinc-100 px-4 py-3",children:[e&&d.jsxs("button",{type:"button",onClick:()=>{if(!f){p(!0);return}r(e.id)},className:"flex items-center gap-1 rounded-lg px-2.5 py-1.5 text-[12px] text-red-600 hover:bg-red-50",children:[d.jsx(kf,{size:12}),f?"确认删除":"删除"]}),d.jsx("button",{type:"button",onClick:t,className:"ml-auto rounded-lg px-3 py-1.5 text-[12px] text-zinc-600 hover:bg-zinc-100",children:"取消"}),d.jsx("button",{type:"submit",disabled:!i.trim()||!l.trim(),className:"rounded-lg bg-zinc-900 px-3.5 py-1.5 text-[12px] font-medium text-white transition-colors hover:bg-zinc-800 disabled:cursor-not-allowed disabled:opacity-40",children:"保存模板"})]})]})}function uLe({agents:e,sessions:t,onCreated:n,editorRef:r,hero:i,collapsed:s=!1,companion:o}){var X,J,ae,ne,re,ie,G,oe,ge;const a=Ln(),[l,c]=m.useState(""),[u,h]=m.useState([]),[f,p]=m.useState(""),[g,x]=m.useState(""),[v,b]=m.useState(""),[y,w]=m.useState(""),[S,C]=m.useState(),[_,k]=m.useState(!1),j=m.useRef(new Map),z=m.useRef(new Set),N=m.useRef(0),I=e.some(U=>U.id===f)?f:((X=t.find(U=>!U.archivedAt&&e.some(ce=>ce.id===U.agentId)))==null?void 0:X.agentId)||((J=e[0])==null?void 0:J.id)||"",$=e.find(U=>U.id===I),R=Et({queryKey:["system-capabilities"],queryFn:we.systemCapabilities}),E=($==null?void 0:$.cwd)||((ae=R.data)==null?void 0:ae.workingDirectory),M=m.useMemo(()=>{const U=new Set,ce=[];for(const ve of[E,...t.map(fe=>fe.cwd)])!ve||U.has(ve)||(U.add(ve),ce.push(ve));return ce.slice(0,30)},[E,t]),P=(ne=R.data)==null?void 0:ne.homeDirectory,A=Et({queryKey:ul(I,v),queryFn:()=>dl(I,v||void 0),enabled:!!I,initialData:()=>Cd(I,v||void 0),initialDataUpdatedAt:0,refetchOnMount:"always",staleTime:6e4}),D=Et({queryKey:["skills",g],queryFn:()=>we.skills(g||void 0),staleTime:6e4}),F=yt({mutationFn:()=>dl(I,v||void 0,!0),onSuccess:U=>a.setQueryData(ul(I,v||void 0),U),onError:U=>C(U instanceof Error?U.message:String(U))}),O=yt({mutationFn:we.selectDirectory,onSuccess:U=>x(U.path),onError:U=>C(U instanceof Error?U.message:String(U))}),B=wK({loaded:A.data!==void 0,loading:A.data===void 0&&(A.isPending||A.isFetching||F.isPending),switching:!1,failed:A.data===void 0&&A.isError}),V=async U=>{const ce=`draft-${++N.current}`,ve="name"in U?U.name:"(未命名文件)",fe=U.type.startsWith("image/");U instanceof File&&j.current.set(ce,U);const Ce=fe?URL.createObjectURL(U):void 0;return Ce&&z.current.add(Ce),{id:ce,kind:fe?"image":"file",label:ve,value:ce,...Ce?{url:Ce}:{}}},T=()=>{for(const U of z.current)URL.revokeObjectURL(U);z.current.clear(),j.current.clear()},W=U=>{c(U),requestAnimationFrame(()=>{var ce;return(ce=r==null?void 0:r.current)==null?void 0:ce.focus()})},L=U=>{const ce=l,ve=u,fe=p2();k(!0),(async()=>{try{const Ce=await Promise.all(ve.map(async Ie=>{const Te=j.current.get(Ie.id);if(!Te)return Ie;const de=await d2(U.sessionId,Te);return h2(de,Te.type.startsWith("image/"))})),Pe=u2(ce,Ce);Pe&&await we.send(U.sessionId,Pe,"queue",void 0,fe),a.invalidateQueries({queryKey:["sessions"]}),a.invalidateQueries({queryKey:["tasks",U.sessionId]}),c(""),h([]),T(),U.onSent()}catch(Ce){C(Ce instanceof Error?Ce.message:String(Ce))}finally{k(!1)}})()},q=()=>{if(_)return;if(C(void 0),o){L(o);return}if(!I)return;const U=l,ce=u,ve=p2();k(!0),(async()=>{let fe;try{fe=await we.create({agentId:I,...g.trim()?{cwd:g.trim()}:{},...v?{model:v}:{},...y?{reasoningEffort:y}:{}});const Ce=await Promise.all(ce.map(async Ie=>{const Te=j.current.get(Ie.id);if(!Te)return Ie;const de=await d2(fe.id,Te);return h2(de,Te.type.startsWith("image/"))})),Pe=u2(U,Ce);Pe&&await we.send(fe.id,Pe,"queue",void 0,ve),a.invalidateQueries({queryKey:["sessions"]}),a.invalidateQueries({queryKey:["tasks",fe.id]}),c(""),h([]),T(),n(fe)}catch(Ce){C(Ce instanceof Error?Ce.message:String(Ce)),fe&&(a.invalidateQueries({queryKey:["sessions"]}),n(fe))}finally{k(!1)}})()};return d.jsxs("div",{className:"relative my-auto w-full max-w-[720px]",children:[i??d.jsxs("div",{className:"flex flex-col items-center text-center",children:[d.jsx(U3e,{size:88}),d.jsx("h1",{className:"ui-empty-state ui-hero-title mt-4 text-[22px] font-semibold tracking-[-.02em]",children:"有什么要做的?"})]}),d.jsx("div",{className:"ui-collapse","data-collapsed":s||void 0,"aria-hidden":s||void 0,inert:s,children:d.jsxs("div",{children:[d.jsx("div",{className:"mt-6",children:d.jsx(CK,{draft:!0,...o?{placeholder:d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"hidden sm:inline",children:["跟",o.name,"说说要做什么,Enter 发送;它会派侧边会话去办"]}),d.jsxs("span",{className:"sm:hidden",children:["跟",o.name,"说说要做什么"]})]}),sendLabel:`交给${o.name}`,lockedTarget:d.jsxs("span",{title:`消息会发进主会话,由${o.name}安排`,className:"flex h-8 shrink-0 items-center gap-1.5 rounded-lg bg-zinc-100 px-2.5 text-[12px] font-medium text-zinc-700",children:[d.jsx(Ji,{size:12}),o.name," · 主会话"]})}:{},editorRef:r,sessionId:"",state:"idle",value:l,references:u,sending:_,mode:"queue",queuedTasks:[],skills:D.data??[],models:((re=A.data)==null?void 0:re.models)??[],reasoningEfforts:((ie=A.data)==null?void 0:ie.reasoningEfforts)??[],currentModel:v||((G=A.data)==null?void 0:G.defaultModel),currentReasoningEffort:y||((oe=A.data)==null?void 0:oe.defaultReasoningEffort),context:{},advertisedCommands:[],modelReadiness:B,switchingModel:!1,switchingReasoningEffort:!1,refreshingModels:A.isFetching||F.isPending,agents:e,currentAgentId:(o==null?void 0:o.agentId)??I,onAgentChange:U=>{p(U),b(""),w("")},workspace:g,onWorkspaceChange:x,workspaceSuggestion:E,homeDirectory:P,workspaceOptions:M,directoryPickerAvailable:(ge=R.data)==null?void 0:ge.directoryPicker,pickingDirectory:O.isPending,onPickDirectory:()=>O.mutate(),onAttachFile:V,onChange:c,onReferencesChange:h,onModeChange:()=>{},onSubmit:q,onInterrupt:()=>{},onCancelQueued:()=>{},onSteerQueued:()=>{},onEditQueued:()=>{},onModelChange:b,onReasoningEffortChange:w,onRefreshModels:()=>F.mutate()})}),!o&&d.jsx(oLe,{onUse:W}),S&&d.jsx("p",{role:"alert",className:"mt-2 text-center text-[12px] text-red-600",children:S}),u.length>0&&d.jsxs("p",{className:"mt-2 text-center text-[12px] text-zinc-400",children:[u.length," 个附件会在",o?"发送":"会话创建","后上传"]})]})})]})}const wG="agentdock:adopt-agent";function dLe(){try{return typeof window>"u"?"":window.localStorage.getItem(wG)||""}catch{return""}}function hLe(e,t){const n=e instanceof Error?e.message:String(e);return/authentication required|not authenticated|unauthorized|\b401\b/i.test(n)?`${t} 还没在这台机器上登录,暂时开不了工。换一个已登录的 Agent,或先在终端完成 ${t} 的登录再回来认领。`:n}function D5(){const e=d.jsxs("svg",{viewBox:"0 0 24 24",width:"11",height:"11",fill:"currentColor","aria-hidden":"true",children:[d.jsx("ellipse",{cx:"12",cy:"16",rx:"5",ry:"4.2"}),d.jsx("circle",{cx:"6",cy:"9.5",r:"2.2"}),d.jsx("circle",{cx:"10",cy:"6",r:"2.2"}),d.jsx("circle",{cx:"14",cy:"6",r:"2.2"}),d.jsx("circle",{cx:"18",cy:"9.5",r:"2.2"})]});return d.jsxs("span",{className:"ui-paw-walk",children:[e,e,e,e]})}function L5(e){const t=M7();return e.counts.needsUser?`${t}~有 ${e.counts.needsUser} 件事等你拍板,右边的便签里看看吧`:e.counts.planned?`${t}~有 ${e.counts.planned} 张计划等你点头,右边的便签里看看`:e.busy?`${t}~我正在忙,有新想法也可以先丢给我`:e.counts.running?`${t}~我在盯着 ${e.counts.running} 张便签,有进展会叫你`:e.counts.review?`${t}~${e.counts.review} 张便签做完了,我在验收`:`${t}~我是${e.name},有事交给我,我派人去办`}function fLe({value:e,name:t,onChange:n}){return d.jsxs("div",{className:"ui-target mt-4","data-value":e,role:"group","aria-label":"这条消息发给谁",children:[d.jsx("span",{className:"ui-target-pill","aria-hidden":"true"}),d.jsxs("button",{type:"button","aria-pressed":e==="new",onClick:()=>n("new"),className:"ui-target-option",children:[d.jsx(ZZ,{size:13}),"新对话"]}),d.jsxs("button",{type:"button","aria-pressed":e==="companion",onClick:()=>n("companion"),className:"ui-target-option ui-cat-hover-host",children:[d.jsx(Ji,{size:13}),d.jsxs("span",{className:"max-w-[9rem] truncate",children:["交给",t]})]})]})}function pLe({agents:e,sessions:t,editorRef:n,onCreated:r}){var Ce,Pe,Ie,Te,de,Le,te,me,_e,$e,xe,Ze;const i=Ln(),s=Hi(),o=Na(),a=zt(le=>le.adoptPending),l=zt(le=>le.inviteDismissed),c=zt(le=>le.homeTarget),u=zt(le=>le.celebrateNonce),[h,f]=m.useState("idle"),[p,g]=m.useState(Up),[x,v]=m.useState(dLe),[b,y]=m.useState(""),[w,S]=m.useState(""),[C,_]=m.useState(""),[k,j]=m.useState(),[z,N]=m.useState(),[I,$]=m.useState(""),R=gh("kitten-hero"),E=m.useRef(null),M=m.useRef(null),P=Et({queryKey:["system-capabilities"],queryFn:we.systemCapabilities});m.useEffect(()=>{!a||!s.loaded||(zt.getState().consumeAdoption(),s.adopted||f("form"))},[a,s.loaded,s.adopted]),m.useEffect(()=>{if(h!=="form")return;const le=window.setTimeout(()=>{var Me,pe;(Me=E.current)==null||Me.focus(),(pe=E.current)==null||pe.select()},260);return()=>window.clearTimeout(le)},[h]),m.useEffect(()=>{if(!z)return;const le=window.setTimeout(()=>N(void 0),1800);return()=>window.clearTimeout(le)},[z]);const A=m.useMemo(()=>e.filter(le=>!le.disabled),[e]),D=A.some(le=>le.id===x)?x:((Ce=t.find(le=>!le.archivedAt&&A.some(Me=>Me.id===le.agentId)))==null?void 0:Ce.agentId)||((Pe=A[0])==null?void 0:Pe.id)||"",F=A.find(le=>le.id===D),O=(F==null?void 0:F.cwd)||((Ie=P.data)==null?void 0:Ie.workingDirectory),B=(Te=P.data)==null?void 0:Te.homeDirectory,V=m.useMemo(()=>{const le=new Set,Me=[];for(const pe of[O,...t.map(ye=>ye.cwd)])!pe||le.has(pe)||(le.add(pe),Me.push(pe));return Me.slice(0,20)},[O,t]),T=Et({queryKey:ul(D,w),queryFn:()=>dl(D,w||void 0),enabled:!!D&&(h==="form"||h==="adopting"),initialData:()=>Cd(D,w||void 0),initialDataUpdatedAt:0,refetchOnMount:"always",staleTime:6e4});m.useEffect(()=>{S(""),_("")},[D]);const W=((Le=(de=T.data)==null?void 0:de.models.find(le=>{var Me;return le.id===((Me=T.data)==null?void 0:Me.defaultModel)}))==null?void 0:Le.name)??((te=T.data)==null?void 0:te.defaultModel),L=((_e=(me=T.data)==null?void 0:me.reasoningEfforts.find(le=>{var Me;return le.id===((Me=T.data)==null?void 0:Me.defaultReasoningEffort)}))==null?void 0:_e.name)??(($e=T.data)==null?void 0:$e.defaultReasoningEffort),q=m.useMemo(()=>{var le;return(le=T.data)!=null&&le.models.length?[{value:"",label:W?`Agent 默认 · ${W}`:"Agent 默认"},...T.data.models.map(Me=>({value:Me.id,label:Me.name,meta:Me.name===Me.id?void 0:Me.id}))]:[]},[W,T.data]),X=m.useMemo(()=>{var le;return(le=T.data)!=null&&le.reasoningEfforts.length?[{value:"",label:L?`Agent 默认 · ${L}`:"Agent 默认"},...T.data.reasoningEfforts.map(Me=>({value:Me.id,label:Me.name}))]:[]},[L,T.data]),J=T.isPending||T.isFetching,ae=yt({mutationFn:we.selectDirectory,onSuccess:le=>{y(le.path),j(void 0)},onError:le=>j(le instanceof Error?le.message:String(le))}),ne=yt({mutationFn:()=>we.assistantSetMain({agentId:D,name:p.trim()||Up,...b.trim()?{cwd:b.trim()}:{},...w?{model:w}:{},...C?{reasoningEffort:C}:{}}),onMutate:()=>{j(void 0),f("adopting")},onSuccess:le=>{var ye;try{window.localStorage.setItem(wG,D)}catch{}const Me=((ye=le.companion)==null?void 0:ye.name)??(p.trim()||Up);$(Me),i.setQueryData(["assistant-state"],Ee=>Ee&&{...Ee,mainSessionId:le.session.id,mainSession:le.session,companion:le.companion??{name:Me,adoptedAt:new Date().toISOString()}}),i.setQueryData(["sessions"],Ee=>Ee&&[le.session,...Ee.filter(Se=>Se.id!==le.session.id)]),i.invalidateQueries({queryKey:["assistant-state"]}),i.invalidateQueries({queryKey:["sessions"]});const pe=zt.getState();pe.dismissInvite(!1),pe.celebrate(),f("celebrate"),window.setTimeout(()=>{M.current&&jc(M.current.getBoundingClientRect(),"confetti",18)},120),window.setTimeout(()=>o.openMain(le.session.id),co()?900:2300)},onError:le=>{f("form"),j(hLe(le,(F==null?void 0:F.name)??D))}}),re=()=>{const le=b.trim();if(le&&!le.startsWith("/")){j("工作目录请填绝对路径,例如 /Users/you/project");return}ne.mutate()},ie=()=>{zt.getState().dismissInvite(),N("sad"),f("idle")},G=s.adopted&&h!=="celebrate",oe=G&&c==="companion"&&!!s.mainId,ge=!s.adopted&&s.loaded&&(h==="invite"||h==="idle"&&!l),U=h==="form"||h==="adopting"||h==="celebrate",ce=z??(h==="celebrate"?"happy":h==="adopting"?"busy":G?s.mood==="curious"?"idle":s.mood:"curious"),ve=d.jsx("div",{ref:R,className:"ui-stage-kitten",children:d.jsx(Fi,{size:h==="form"||h==="adopting"?76:88,mood:ce,stage:G?s.stage:void 0,collar:G||h==="celebrate",drawCollar:h==="celebrate",track:!0,typingAware:!0,celebrateKey:u,viewTransitionName:E7,label:G?`进入主会话(${s.name})`:"小猫",onClick:()=>{G?o.openMain():h==="idle"&&f("invite")}})});let fe;if(G){const le=s.counts;fe=d.jsxs("div",{className:"ui-stage",children:[d.jsx("div",{className:"ui-speech text-center",children:L5(s)},L5(s)),ve,d.jsx("span",{className:"ui-name-tag",children:s.name}),d.jsxs("div",{className:"mt-3 flex flex-wrap justify-center gap-1.5",children:[le.needsUser>0&&d.jsxs("button",{type:"button",className:"ui-status-chip",onClick:()=>zt.getState().openDrawer({filter:"needs_user"}),children:[d.jsx("span",{className:"ui-note-swatch ui-note-paper-needs"}),le.needsUser," 件需要你"]}),le.planned>0&&d.jsxs("button",{type:"button",className:"ui-status-chip",onClick:()=>zt.getState().openDrawer({filter:"needs_user"}),children:[d.jsx("span",{className:"ui-note-swatch ui-note-paper-plan"}),le.planned," 张计划等你点头"]}),le.review>0&&d.jsxs("button",{type:"button",className:"ui-status-chip",onClick:()=>zt.getState().openDrawer({filter:"review"}),children:[d.jsx("span",{className:"ui-note-swatch ui-note-paper-review"}),le.review," 张待验收"]}),le.running>0&&d.jsxs("button",{type:"button",className:"ui-status-chip",onClick:()=>zt.getState().openDrawer({filter:"running"}),children:[d.jsx("span",{className:"ui-note-swatch ui-note-paper-running"}),le.running," 张进行中"]}),!le.open&&d.jsxs("button",{type:"button",className:"ui-status-chip",onClick:()=>zt.getState().toggleDrawer(),children:[d.jsx("span",{className:"ui-note-swatch ui-note-paper-done"}),le.closed?`${le.closed} 张已完成`:"便签墙"]})]}),d.jsx("h1",{className:"ui-empty-state ui-hero-title mt-5 text-[22px] font-semibold tracking-[-.02em]",children:oe?`交给${s.name}吧`:"有什么要做的?"}),d.jsx(fLe,{value:c,name:s.name,onChange:Me=>{zt.getState().setHomeTarget(Me),requestAnimationFrame(()=>{var pe;return(pe=n==null?void 0:n.current)==null?void 0:pe.focus()})}})]})}else fe=d.jsxs("div",{className:"ui-stage",children:[ge&&d.jsxs("div",{className:"ui-speech text-center",children:[d.jsx("p",{className:"text-[14px] font-medium text-zinc-900",children:"喵~带我回家吧?"}),d.jsx("p",{className:"mt-0.5 text-[12.5px] leading-5 text-zinc-500",children:"认领后我就是你的主会话:你说要做什么,我派侧边会话去干、盯进度、做完帮你验收,每件事都贴成便签。"}),d.jsxs("div",{className:"mt-2.5 flex justify-center gap-2",children:[d.jsxs("button",{type:"button",onClick:()=>f("form"),className:"inline-flex h-8 items-center gap-1.5 rounded-full bg-zinc-900 px-3.5 text-[12.5px] font-medium text-white transition-[background-color,transform] hover:bg-zinc-700 active:scale-95",children:[d.jsx(Ji,{size:13}),"认领它"]}),d.jsx("button",{type:"button",onClick:ie,className:"inline-flex h-8 items-center rounded-full px-3 text-[12.5px] text-zinc-500 transition-colors hover:bg-zinc-100 hover:text-zinc-800",children:"先不了"})]})]}),h==="celebrate"&&d.jsxs("div",{className:"ui-speech text-center",children:[d.jsxs("p",{className:"text-[14px] font-medium text-zinc-900",children:["喵!我是",I,",以后请多指教~"]}),d.jsxs("p",{className:"mt-1 inline-flex items-center gap-1.5 text-[12px] text-zinc-500",children:[d.jsx(D5,{}),"正在去主会话…"]})]}),ve,h==="celebrate"&&d.jsx("span",{className:"ui-name-tag",children:I}),(h==="form"||h==="adopting")&&d.jsx("div",{ref:M,className:"ui-adopt-card mt-4",children:d.jsxs("form",{onSubmit:le=>{le.preventDefault(),!ne.isPending&&D&&re()},children:[d.jsxs("div",{className:"px-5 pt-5",children:[d.jsxs("label",{className:"block",children:[d.jsx("span",{className:"text-[14px] font-semibold text-zinc-900",children:"给它起个名字"}),d.jsxs("span",{className:"mt-2 flex items-center gap-2",children:[d.jsx("input",{ref:E,value:p,maxLength:16,disabled:h==="adopting",onChange:le=>g(le.target.value),placeholder:Up,"aria-label":"小猫的名字",className:"ui-field h-10 min-w-0 flex-1 rounded-xl border border-zinc-300 bg-white px-3 text-[15px] font-semibold text-zinc-900 outline-none placeholder:font-normal placeholder:text-zinc-400 disabled:opacity-60"}),d.jsx("button",{type:"button",disabled:h==="adopting",onClick:()=>g(le=>Fy(le.trim())),"aria-label":"随机换一个名字",title:"随机换一个名字",className:"ui-dice grid h-10 w-10 shrink-0 place-items-center rounded-xl border border-zinc-200 text-zinc-500 hover:border-zinc-300 hover:text-zinc-900 disabled:opacity-50",children:d.jsx(Fb,{size:17})})]})]}),d.jsx("div",{className:"mt-4 text-[12.5px] font-medium text-zinc-600",children:"它用哪个 Agent 思考"}),d.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[A.map(le=>d.jsxs("button",{type:"button",disabled:h==="adopting","aria-pressed":le.id===D,onClick:()=>{v(le.id),S(""),_(""),j(void 0)},className:"ui-pill-choice",children:[d.jsx(Hr,{agentId:le.id,agentName:le.name,size:13}),le.name]},le.id)),!A.length&&d.jsx("span",{className:"text-[12.5px] text-zinc-400",children:"还没有可用的 Agent,先到设置里配一个。"})]}),d.jsxs("div",{className:"mt-4 grid gap-3",children:[d.jsxs("div",{children:[d.jsxs("div",{className:"text-[12.5px] font-medium text-zinc-600",children:["模型 ",d.jsx("span",{className:"font-normal text-zinc-400",children:"可选"})]}),d.jsx(ua,{size:"sm",options:q,value:w,placeholder:"Agent 默认",disabledText:J?"正在读取模型…":T.isError?"模型列表读取失败,可先不选":"这个 Agent 没有提供模型选项",disabled:h==="adopting",onChange:le=>{S(le),_("")}})]}),d.jsxs("div",{children:[d.jsxs("div",{className:"text-[12.5px] font-medium text-zinc-600",children:["思考深度 ",d.jsx("span",{className:"font-normal text-zinc-400",children:"可选"})]}),d.jsx(ua,{size:"sm",options:X,value:C,placeholder:"Agent 默认",disabledText:J?"正在读取…":T.isError?"读取失败,可先不选":"这个模型没有思考深度选项",disabled:h==="adopting",onChange:_})]})]}),((xe=T.data)==null?void 0:xe.warning)&&d.jsxs("p",{className:"mt-1.5 text-[11px] leading-4 text-amber-600",children:["这个 Agent 的配置没读出来:",T.data.warning," 如果一直这样,先检查它是否已登录。"]}),d.jsxs("div",{className:"mt-4 text-[12.5px] font-medium text-zinc-600",children:["常驻目录 ",d.jsx("span",{className:"font-normal text-zinc-400",children:"可选,派活时仍可指定别的目录"})]}),d.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[d.jsx("input",{list:"adopt-workspaces",value:b,disabled:h==="adopting",onChange:le=>y(le.target.value),placeholder:O??"绝对路径,例如 /Users/you/project","aria-label":"常驻目录",spellCheck:!1,className:"ui-field h-9 min-w-0 flex-1 rounded-xl border border-zinc-300 bg-white px-3 font-mono text-[12.5px] text-zinc-800 outline-none placeholder:font-sans placeholder:text-zinc-400 disabled:opacity-60"}),((Ze=P.data)==null?void 0:Ze.directoryPicker)&&d.jsx("button",{type:"button",disabled:h==="adopting"||ae.isPending,onClick:()=>ae.mutate(),title:ae.isPending?"选择中…":"选择目录","aria-label":"选择目录",className:"grid h-9 w-9 shrink-0 place-items-center rounded-xl border border-zinc-200 text-zinc-500 transition-colors hover:border-zinc-300 hover:text-zinc-900 disabled:opacity-50",children:ae.isPending?d.jsx(Hn,{size:14,className:"animate-spin"}):d.jsx(ha,{size:14})})]}),d.jsx("datalist",{id:"adopt-workspaces",children:V.map(le=>d.jsx("option",{value:le,children:f2(le,B)},le))}),d.jsx("p",{className:"mt-1.5 text-[11.5px] leading-4 text-zinc-400",children:"可以直接粘贴任意绝对路径,或从最近用过的目录里挑;留空就用 Agent 自己的默认目录。"}),d.jsxs("p",{className:"mt-4 rounded-xl bg-zinc-50 px-3 py-2.5 text-[12px] leading-5 text-zinc-500",children:["它会成为你的",d.jsx("b",{className:"font-medium text-zinc-700",children:"主会话"}),":听你说要做什么,派侧边会话去干、盯进度、验收结果。派出去的每件事都是一张便签,贴在屏幕右边,随时划出来看。"]}),k&&d.jsx("p",{role:"alert",className:"mt-3 text-[12px] text-red-600",children:k})]}),d.jsxs("div",{className:"mt-4 flex items-center justify-end gap-2 border-t border-zinc-100 px-4 py-3",children:[d.jsx("button",{type:"button",disabled:h==="adopting",onClick:()=>f(l?"idle":"invite"),className:"h-9 rounded-full px-3.5 text-[13px] text-zinc-500 transition-colors hover:bg-zinc-100 hover:text-zinc-800 disabled:opacity-50",children:"先不了"}),d.jsx("button",{type:"submit",disabled:h==="adopting"||!D,className:"inline-flex h-9 min-w-[8.5rem] items-center justify-center gap-1.5 rounded-full bg-zinc-900 px-4 text-[13px] font-medium text-white transition-[background-color,transform] hover:bg-zinc-700 active:scale-95 disabled:opacity-60",children:h==="adopting"?d.jsxs(d.Fragment,{children:[d.jsx(D5,{}),"正在带它回家…"]}):d.jsxs(d.Fragment,{children:[d.jsx(Ji,{size:14}),"带它回家"]})})]})]})}),!U&&d.jsx("h1",{className:"ui-empty-state ui-hero-title mt-4 text-[22px] font-semibold tracking-[-.02em]",children:"有什么要做的?"})]});return d.jsx(uLe,{editorRef:n,agents:e,sessions:t,onCreated:r,hero:fe,collapsed:U&&!G,companion:oe&&s.mainSession?{sessionId:s.mainSession.id,agentId:s.mainSession.agentId,name:s.name,onSent:()=>{const le=hm(["kitten-hero"]);le&&jc(le,"sparkles",6),window.setTimeout(()=>o.openMain(),co()?0:260)}}:void 0})}const mLe=m.lazy(()=>w4(()=>import("./PromptEditor-CX3eQM-7.js"),__vite__mapDeps([5,1,2,3]))),gLe=e=>[...new Set(e.split(/[\n,,]/).map(t=>t.trim()).filter(Boolean))];function vLe({className:e=""}){return d.jsx("img",{src:"/agent-dock.svg",alt:"","aria-hidden":"true",className:`${e} ui-logo-tile`})}function xLe({cwd:e,top:t,left:n,agents:r,creatingPair:i,onSelect:s,onClose:o}){const a=m.useRef(null);return jy(a,!0,o),d.jsxs("div",{ref:a,className:"ui-popover fixed z-50 max-h-64 w-52 overflow-y-auto rounded-lg border border-zinc-200 bg-white p-1 shadow-[0_16px_40px_rgba(24,24,27,.16)]",style:{top:t,left:n},children:[d.jsx("div",{className:"px-2 py-1 text-[12px] text-zinc-400",children:"在此工作区新建会话"}),r.length===0&&d.jsx("div",{className:"px-2 py-2 text-[12px] text-zinc-400",children:"暂无可用 Agent"}),r.map(l=>{const c=(i==null?void 0:i.agentId)===l.id&&i.cwd===e;return d.jsxs("button",{type:"button",disabled:!!i,onClick:()=>s(l.id),className:"flex h-8 w-full items-center gap-2 rounded-md px-2 text-left text-[12px] text-zinc-700 hover:bg-zinc-100 disabled:opacity-50",children:[c?d.jsx(Hn,{size:13,className:"shrink-0 animate-spin text-zinc-500"}):d.jsx(Hr,{agentId:l.id,agentName:l.name,size:14}),d.jsx("span",{className:"min-w-0 flex-1 truncate",children:l.name})]},l.id)})]})}function bLe({options:e,value:t,onChange:n}){return d.jsx(vi,{className:"w-40 shrink-0",size:"small",popupMatchSelectWidth:!1,value:t,onChange:n,options:e.map(r=>({value:r.value,label:r.label}))})}function F5({options:e,value:t,onChange:n}){return d.jsx("div",{className:"flex shrink-0 rounded-md bg-zinc-100 p-0.5",children:e.map(r=>d.jsx("button",{type:"button",onClick:()=>n(r.value),className:`h-7 rounded px-2.5 text-[12px] font-medium transition-colors ${t===r.value?"bg-white text-zinc-900 shadow-sm":"text-zinc-500 hover:text-zinc-700"}`,children:r.label},r.value))})}function yLe({agents:e,value:t,disabled:n,size:r="default",popupWidth:i,onChange:s}){return d.jsx(ua,{size:r,popupWidth:i,options:e.map(o=>({value:o.id,label:o.name,meta:o.version,agentId:o.id})),value:t,placeholder:"选择 Agent",disabledText:"未扫描到可用 Agent",disabled:n,onChange:s})}function l_({value:e,placeholder:t,onChange:n}){const[r,i]=m.useState(""),s=m.useRef(null),o=(c=r)=>{const u=gLe(c);u.length&&n([...new Set([...e,...u])]),i("")},a=c=>n(e.filter(u=>u!==c)),l=c=>{c.nativeEvent.isComposing||(c.key==="Enter"||c.key===","||c.key===","?(c.preventDefault(),o()):c.key==="Backspace"&&!r&&e.length&&a(e[e.length-1]))};return d.jsxs("div",{role:"group","aria-label":"成员真实姓名",onClick:()=>{var c;return(c=s.current)==null?void 0:c.focus()},className:"mt-2 flex min-h-11 cursor-text flex-wrap items-center gap-x-2 gap-y-2 rounded-lg border border-zinc-300 bg-zinc-50/70 p-2 ui-field-within focus-within:bg-white",children:[e.map(c=>d.jsxs("span",{title:c,className:"flex h-7 max-w-full items-center rounded-md border border-zinc-200 bg-white pl-2.5 pr-1 text-[12px] font-medium text-zinc-700 shadow-[0_1px_1px_rgba(24,24,27,.04)]",children:[d.jsx("span",{className:"min-w-0 truncate",children:c}),d.jsx("button",{type:"button","aria-label":`移除 ${c}`,onPointerDown:u=>u.preventDefault(),onClick:()=>a(c),className:"ml-1.5 grid h-5 w-5 shrink-0 place-items-center rounded text-zinc-400 transition-colors hover:bg-zinc-100 hover:text-zinc-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-300",children:d.jsx(Wn,{size:11})})]},c)),d.jsx("input",{ref:s,"aria-label":"输入成员真实姓名",value:r,onChange:c=>i(c.target.value),onKeyDown:l,onBlur:()=>o(),onPaste:c=>{const u=c.clipboardData.getData("text");/[\n,,]/.test(u)&&(c.preventDefault(),o(`${r}
1116
+ 例如:请检查 {{项目}} 的发布前状态,并运行 {{验证命令}}。`,className:"ui-field w-full resize-y rounded-lg border border-zinc-200 bg-white px-3 py-2 font-mono text-[12px] leading-5 text-zinc-800 outline-none transition-colors placeholder:text-zinc-400 focus:border-zinc-400"})]}),d.jsx("div",{className:"text-[12px] leading-5 text-zinc-500",children:g.length?d.jsxs(d.Fragment,{children:["识别到变量:",d.jsx("span",{className:"font-mono text-zinc-700",children:g.join("、")})]}):"没有 {{变量}},点击卡片会直接填入整段提示词。"}),u&&d.jsx("p",{role:"alert",className:"text-[12px] text-red-600",children:u})]}),d.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-t border-zinc-100 px-4 py-3",children:[e&&d.jsxs("button",{type:"button",onClick:()=>{if(!f){p(!0);return}r(e.id)},className:"flex items-center gap-1 rounded-lg px-2.5 py-1.5 text-[12px] text-red-600 hover:bg-red-50",children:[d.jsx(kf,{size:12}),f?"确认删除":"删除"]}),d.jsx("button",{type:"button",onClick:t,className:"ml-auto rounded-lg px-3 py-1.5 text-[12px] text-zinc-600 hover:bg-zinc-100",children:"取消"}),d.jsx("button",{type:"submit",disabled:!i.trim()||!l.trim(),className:"rounded-lg bg-zinc-900 px-3.5 py-1.5 text-[12px] font-medium text-white transition-colors hover:bg-zinc-800 disabled:cursor-not-allowed disabled:opacity-40",children:"保存模板"})]})]})}function uLe({agents:e,sessions:t,onCreated:n,editorRef:r,hero:i,collapsed:s=!1,companion:o}){var X,J,ae,ne,re,ie,G,oe,ge;const a=Ln(),[l,c]=m.useState(""),[u,h]=m.useState([]),[f,p]=m.useState(""),[g,x]=m.useState(""),[v,b]=m.useState(""),[y,w]=m.useState(""),[S,C]=m.useState(),[_,k]=m.useState(!1),j=m.useRef(new Map),z=m.useRef(new Set),N=m.useRef(0),I=e.some(U=>U.id===f)?f:((X=t.find(U=>!U.archivedAt&&e.some(ce=>ce.id===U.agentId)))==null?void 0:X.agentId)||((J=e[0])==null?void 0:J.id)||"",$=e.find(U=>U.id===I),R=Et({queryKey:["system-capabilities"],queryFn:we.systemCapabilities}),E=($==null?void 0:$.cwd)||((ae=R.data)==null?void 0:ae.workingDirectory),M=m.useMemo(()=>{const U=new Set,ce=[];for(const ve of[E,...t.map(fe=>fe.cwd)])!ve||U.has(ve)||(U.add(ve),ce.push(ve));return ce.slice(0,30)},[E,t]),P=(ne=R.data)==null?void 0:ne.homeDirectory,A=Et({queryKey:ul(I,v),queryFn:()=>dl(I,v||void 0),enabled:!!I,initialData:()=>Cd(I,v||void 0),initialDataUpdatedAt:0,refetchOnMount:"always",staleTime:6e4}),D=Et({queryKey:["skills",g],queryFn:()=>we.skills(g||void 0),staleTime:6e4}),F=yt({mutationFn:()=>dl(I,v||void 0,!0),onSuccess:U=>a.setQueryData(ul(I,v||void 0),U),onError:U=>C(U instanceof Error?U.message:String(U))}),O=yt({mutationFn:we.selectDirectory,onSuccess:U=>x(U.path),onError:U=>C(U instanceof Error?U.message:String(U))}),B=wK({loaded:A.data!==void 0,loading:A.data===void 0&&(A.isPending||A.isFetching||F.isPending),switching:!1,failed:A.data===void 0&&A.isError}),V=async U=>{const ce=`draft-${++N.current}`,ve="name"in U?U.name:"(未命名文件)",fe=U.type.startsWith("image/");U instanceof File&&j.current.set(ce,U);const Ce=fe?URL.createObjectURL(U):void 0;return Ce&&z.current.add(Ce),{id:ce,kind:fe?"image":"file",label:ve,value:ce,...Ce?{url:Ce}:{}}},T=()=>{for(const U of z.current)URL.revokeObjectURL(U);z.current.clear(),j.current.clear()},W=U=>{c(U),requestAnimationFrame(()=>{var ce;return(ce=r==null?void 0:r.current)==null?void 0:ce.focus()})},L=U=>{const ce=l,ve=u,fe=p2();k(!0),(async()=>{try{const Ce=await Promise.all(ve.map(async Ie=>{const Te=j.current.get(Ie.id);if(!Te)return Ie;const de=await d2(U.sessionId,Te);return h2(de,Te.type.startsWith("image/"))})),Pe=u2(ce,Ce);Pe&&await we.send(U.sessionId,Pe,"queue",void 0,fe),a.invalidateQueries({queryKey:["sessions"]}),a.invalidateQueries({queryKey:["tasks",U.sessionId]}),c(""),h([]),T(),U.onSent()}catch(Ce){C(Ce instanceof Error?Ce.message:String(Ce))}finally{k(!1)}})()},q=()=>{if(_)return;if(C(void 0),o){L(o);return}if(!I)return;const U=l,ce=u,ve=p2();k(!0),(async()=>{let fe;try{fe=await we.create({agentId:I,...g.trim()?{cwd:g.trim()}:{},...v?{model:v}:{},...y?{reasoningEffort:y}:{}});const Ce=await Promise.all(ce.map(async Ie=>{const Te=j.current.get(Ie.id);if(!Te)return Ie;const de=await d2(fe.id,Te);return h2(de,Te.type.startsWith("image/"))})),Pe=u2(U,Ce);Pe&&await we.send(fe.id,Pe,"queue",void 0,ve),a.invalidateQueries({queryKey:["sessions"]}),a.invalidateQueries({queryKey:["tasks",fe.id]}),c(""),h([]),T(),n(fe)}catch(Ce){C(Ce instanceof Error?Ce.message:String(Ce)),fe&&(a.invalidateQueries({queryKey:["sessions"]}),n(fe))}finally{k(!1)}})()};return d.jsxs("div",{className:"relative my-auto w-full min-w-0 max-w-[720px]",children:[i??d.jsxs("div",{className:"flex flex-col items-center text-center",children:[d.jsx(U3e,{size:88}),d.jsx("h1",{className:"ui-empty-state ui-hero-title mt-4 text-[22px] font-semibold tracking-[-.02em]",children:"有什么要做的?"})]}),d.jsx("div",{className:"ui-collapse","data-collapsed":s||void 0,"aria-hidden":s||void 0,inert:s,children:d.jsxs("div",{children:[d.jsx("div",{className:"mt-6",children:d.jsx(CK,{draft:!0,...o?{placeholder:d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"hidden sm:inline",children:["跟",o.name,"说说要做什么,Enter 发送;它会派侧边会话去办"]}),d.jsxs("span",{className:"sm:hidden",children:["跟",o.name,"说说要做什么"]})]}),sendLabel:`交给${o.name}`,lockedTarget:d.jsxs("span",{title:`消息会发进主会话,由${o.name}安排`,className:"flex h-8 shrink-0 items-center gap-1.5 rounded-lg bg-zinc-100 px-2.5 text-[12px] font-medium text-zinc-700",children:[d.jsx(Ji,{size:12}),o.name," · 主会话"]})}:{},editorRef:r,sessionId:"",state:"idle",value:l,references:u,sending:_,mode:"queue",queuedTasks:[],skills:D.data??[],models:((re=A.data)==null?void 0:re.models)??[],reasoningEfforts:((ie=A.data)==null?void 0:ie.reasoningEfforts)??[],currentModel:v||((G=A.data)==null?void 0:G.defaultModel),currentReasoningEffort:y||((oe=A.data)==null?void 0:oe.defaultReasoningEffort),context:{},advertisedCommands:[],modelReadiness:B,switchingModel:!1,switchingReasoningEffort:!1,refreshingModels:A.isFetching||F.isPending,agents:e,currentAgentId:(o==null?void 0:o.agentId)??I,onAgentChange:U=>{p(U),b(""),w("")},workspace:g,onWorkspaceChange:x,workspaceSuggestion:E,homeDirectory:P,workspaceOptions:M,directoryPickerAvailable:(ge=R.data)==null?void 0:ge.directoryPicker,pickingDirectory:O.isPending,onPickDirectory:()=>O.mutate(),onAttachFile:V,onChange:c,onReferencesChange:h,onModeChange:()=>{},onSubmit:q,onInterrupt:()=>{},onCancelQueued:()=>{},onSteerQueued:()=>{},onEditQueued:()=>{},onModelChange:b,onReasoningEffortChange:w,onRefreshModels:()=>F.mutate()})}),!o&&d.jsx(oLe,{onUse:W}),S&&d.jsx("p",{role:"alert",className:"mt-2 text-center text-[12px] text-red-600",children:S}),u.length>0&&d.jsxs("p",{className:"mt-2 text-center text-[12px] text-zinc-400",children:[u.length," 个附件会在",o?"发送":"会话创建","后上传"]})]})})]})}const wG="agentdock:adopt-agent";function dLe(){try{return typeof window>"u"?"":window.localStorage.getItem(wG)||""}catch{return""}}function hLe(e,t){const n=e instanceof Error?e.message:String(e);return/authentication required|not authenticated|unauthorized|\b401\b/i.test(n)?`${t} 还没在这台机器上登录,暂时开不了工。换一个已登录的 Agent,或先在终端完成 ${t} 的登录再回来认领。`:n}function D5(){const e=d.jsxs("svg",{viewBox:"0 0 24 24",width:"11",height:"11",fill:"currentColor","aria-hidden":"true",children:[d.jsx("ellipse",{cx:"12",cy:"16",rx:"5",ry:"4.2"}),d.jsx("circle",{cx:"6",cy:"9.5",r:"2.2"}),d.jsx("circle",{cx:"10",cy:"6",r:"2.2"}),d.jsx("circle",{cx:"14",cy:"6",r:"2.2"}),d.jsx("circle",{cx:"18",cy:"9.5",r:"2.2"})]});return d.jsxs("span",{className:"ui-paw-walk",children:[e,e,e,e]})}function L5(e){const t=M7();return e.counts.needsUser?`${t}~有 ${e.counts.needsUser} 件事等你拍板,右边的便签里看看吧`:e.counts.planned?`${t}~有 ${e.counts.planned} 张计划等你点头,右边的便签里看看`:e.busy?`${t}~我正在忙,有新想法也可以先丢给我`:e.counts.running?`${t}~我在盯着 ${e.counts.running} 张便签,有进展会叫你`:e.counts.review?`${t}~${e.counts.review} 张便签做完了,我在验收`:`${t}~我是${e.name},有事交给我,我派人去办`}function fLe({value:e,name:t,onChange:n}){return d.jsxs("div",{className:"ui-target mt-4","data-value":e,role:"group","aria-label":"这条消息发给谁",children:[d.jsx("span",{className:"ui-target-pill","aria-hidden":"true"}),d.jsxs("button",{type:"button","aria-pressed":e==="new",onClick:()=>n("new"),className:"ui-target-option",children:[d.jsx(ZZ,{size:13}),"新对话"]}),d.jsxs("button",{type:"button","aria-pressed":e==="companion",onClick:()=>n("companion"),className:"ui-target-option ui-cat-hover-host",children:[d.jsx(Ji,{size:13}),d.jsxs("span",{className:"max-w-[9rem] truncate",children:["交给",t]})]})]})}function pLe({agents:e,sessions:t,editorRef:n,onCreated:r}){var Ce,Pe,Ie,Te,de,Le,te,me,_e,$e,xe,Ze;const i=Ln(),s=Hi(),o=Na(),a=zt(le=>le.adoptPending),l=zt(le=>le.inviteDismissed),c=zt(le=>le.homeTarget),u=zt(le=>le.celebrateNonce),[h,f]=m.useState("idle"),[p,g]=m.useState(Up),[x,v]=m.useState(dLe),[b,y]=m.useState(""),[w,S]=m.useState(""),[C,_]=m.useState(""),[k,j]=m.useState(),[z,N]=m.useState(),[I,$]=m.useState(""),R=gh("kitten-hero"),E=m.useRef(null),M=m.useRef(null),P=Et({queryKey:["system-capabilities"],queryFn:we.systemCapabilities});m.useEffect(()=>{!a||!s.loaded||(zt.getState().consumeAdoption(),s.adopted||f("form"))},[a,s.loaded,s.adopted]),m.useEffect(()=>{if(h!=="form")return;const le=window.setTimeout(()=>{var Me,pe;(Me=E.current)==null||Me.focus(),(pe=E.current)==null||pe.select()},260);return()=>window.clearTimeout(le)},[h]),m.useEffect(()=>{if(!z)return;const le=window.setTimeout(()=>N(void 0),1800);return()=>window.clearTimeout(le)},[z]);const A=m.useMemo(()=>e.filter(le=>!le.disabled),[e]),D=A.some(le=>le.id===x)?x:((Ce=t.find(le=>!le.archivedAt&&A.some(Me=>Me.id===le.agentId)))==null?void 0:Ce.agentId)||((Pe=A[0])==null?void 0:Pe.id)||"",F=A.find(le=>le.id===D),O=(F==null?void 0:F.cwd)||((Ie=P.data)==null?void 0:Ie.workingDirectory),B=(Te=P.data)==null?void 0:Te.homeDirectory,V=m.useMemo(()=>{const le=new Set,Me=[];for(const pe of[O,...t.map(ye=>ye.cwd)])!pe||le.has(pe)||(le.add(pe),Me.push(pe));return Me.slice(0,20)},[O,t]),T=Et({queryKey:ul(D,w),queryFn:()=>dl(D,w||void 0),enabled:!!D&&(h==="form"||h==="adopting"),initialData:()=>Cd(D,w||void 0),initialDataUpdatedAt:0,refetchOnMount:"always",staleTime:6e4});m.useEffect(()=>{S(""),_("")},[D]);const W=((Le=(de=T.data)==null?void 0:de.models.find(le=>{var Me;return le.id===((Me=T.data)==null?void 0:Me.defaultModel)}))==null?void 0:Le.name)??((te=T.data)==null?void 0:te.defaultModel),L=((_e=(me=T.data)==null?void 0:me.reasoningEfforts.find(le=>{var Me;return le.id===((Me=T.data)==null?void 0:Me.defaultReasoningEffort)}))==null?void 0:_e.name)??(($e=T.data)==null?void 0:$e.defaultReasoningEffort),q=m.useMemo(()=>{var le;return(le=T.data)!=null&&le.models.length?[{value:"",label:W?`Agent 默认 · ${W}`:"Agent 默认"},...T.data.models.map(Me=>({value:Me.id,label:Me.name,meta:Me.name===Me.id?void 0:Me.id}))]:[]},[W,T.data]),X=m.useMemo(()=>{var le;return(le=T.data)!=null&&le.reasoningEfforts.length?[{value:"",label:L?`Agent 默认 · ${L}`:"Agent 默认"},...T.data.reasoningEfforts.map(Me=>({value:Me.id,label:Me.name}))]:[]},[L,T.data]),J=T.isPending||T.isFetching,ae=yt({mutationFn:we.selectDirectory,onSuccess:le=>{y(le.path),j(void 0)},onError:le=>j(le instanceof Error?le.message:String(le))}),ne=yt({mutationFn:()=>we.assistantSetMain({agentId:D,name:p.trim()||Up,...b.trim()?{cwd:b.trim()}:{},...w?{model:w}:{},...C?{reasoningEffort:C}:{}}),onMutate:()=>{j(void 0),f("adopting")},onSuccess:le=>{var ye;try{window.localStorage.setItem(wG,D)}catch{}const Me=((ye=le.companion)==null?void 0:ye.name)??(p.trim()||Up);$(Me),i.setQueryData(["assistant-state"],Ee=>Ee&&{...Ee,mainSessionId:le.session.id,mainSession:le.session,companion:le.companion??{name:Me,adoptedAt:new Date().toISOString()}}),i.setQueryData(["sessions"],Ee=>Ee&&[le.session,...Ee.filter(Se=>Se.id!==le.session.id)]),i.invalidateQueries({queryKey:["assistant-state"]}),i.invalidateQueries({queryKey:["sessions"]});const pe=zt.getState();pe.dismissInvite(!1),pe.celebrate(),f("celebrate"),window.setTimeout(()=>{M.current&&jc(M.current.getBoundingClientRect(),"confetti",18)},120),window.setTimeout(()=>o.openMain(le.session.id),co()?900:2300)},onError:le=>{f("form"),j(hLe(le,(F==null?void 0:F.name)??D))}}),re=()=>{const le=b.trim();if(le&&!le.startsWith("/")){j("工作目录请填绝对路径,例如 /Users/you/project");return}ne.mutate()},ie=()=>{zt.getState().dismissInvite(),N("sad"),f("idle")},G=s.adopted&&h!=="celebrate",oe=G&&c==="companion"&&!!s.mainId,ge=!s.adopted&&s.loaded&&(h==="invite"||h==="idle"&&!l),U=h==="form"||h==="adopting"||h==="celebrate",ce=z??(h==="celebrate"?"happy":h==="adopting"?"busy":G?s.mood==="curious"?"idle":s.mood:"curious"),ve=d.jsx("div",{ref:R,className:"ui-stage-kitten",children:d.jsx(Fi,{size:h==="form"||h==="adopting"?76:88,mood:ce,stage:G?s.stage:void 0,collar:G||h==="celebrate",drawCollar:h==="celebrate",track:!0,typingAware:!0,celebrateKey:u,viewTransitionName:E7,label:G?`进入主会话(${s.name})`:"小猫",onClick:()=>{G?o.openMain():h==="idle"&&f("invite")}})});let fe;if(G){const le=s.counts;fe=d.jsxs("div",{className:"ui-stage",children:[d.jsx("div",{className:"ui-speech text-center",children:L5(s)},L5(s)),ve,d.jsx("span",{className:"ui-name-tag",children:s.name}),d.jsxs("div",{className:"mt-3 flex flex-wrap justify-center gap-1.5",children:[le.needsUser>0&&d.jsxs("button",{type:"button",className:"ui-status-chip",onClick:()=>zt.getState().openDrawer({filter:"needs_user"}),children:[d.jsx("span",{className:"ui-note-swatch ui-note-paper-needs"}),le.needsUser," 件需要你"]}),le.planned>0&&d.jsxs("button",{type:"button",className:"ui-status-chip",onClick:()=>zt.getState().openDrawer({filter:"needs_user"}),children:[d.jsx("span",{className:"ui-note-swatch ui-note-paper-plan"}),le.planned," 张计划等你点头"]}),le.review>0&&d.jsxs("button",{type:"button",className:"ui-status-chip",onClick:()=>zt.getState().openDrawer({filter:"review"}),children:[d.jsx("span",{className:"ui-note-swatch ui-note-paper-review"}),le.review," 张待验收"]}),le.running>0&&d.jsxs("button",{type:"button",className:"ui-status-chip",onClick:()=>zt.getState().openDrawer({filter:"running"}),children:[d.jsx("span",{className:"ui-note-swatch ui-note-paper-running"}),le.running," 张进行中"]}),!le.open&&d.jsxs("button",{type:"button",className:"ui-status-chip",onClick:()=>zt.getState().toggleDrawer(),children:[d.jsx("span",{className:"ui-note-swatch ui-note-paper-done"}),le.closed?`${le.closed} 张已完成`:"便签墙"]})]}),d.jsx("h1",{className:"ui-empty-state ui-hero-title mt-5 text-[22px] font-semibold tracking-[-.02em]",children:oe?`交给${s.name}吧`:"有什么要做的?"}),d.jsx(fLe,{value:c,name:s.name,onChange:Me=>{zt.getState().setHomeTarget(Me),requestAnimationFrame(()=>{var pe;return(pe=n==null?void 0:n.current)==null?void 0:pe.focus()})}})]})}else fe=d.jsxs("div",{className:"ui-stage",children:[ge&&d.jsxs("div",{className:"ui-speech text-center",children:[d.jsx("p",{className:"text-[14px] font-medium text-zinc-900",children:"喵~带我回家吧?"}),d.jsx("p",{className:"mt-0.5 text-[12.5px] leading-5 text-zinc-500",children:"认领后我就是你的主会话:你说要做什么,我派侧边会话去干、盯进度、做完帮你验收,每件事都贴成便签。"}),d.jsxs("div",{className:"mt-2.5 flex justify-center gap-2",children:[d.jsxs("button",{type:"button",onClick:()=>f("form"),className:"inline-flex h-8 items-center gap-1.5 rounded-full bg-zinc-900 px-3.5 text-[12.5px] font-medium text-white transition-[background-color,transform] hover:bg-zinc-700 active:scale-95",children:[d.jsx(Ji,{size:13}),"认领它"]}),d.jsx("button",{type:"button",onClick:ie,className:"inline-flex h-8 items-center rounded-full px-3 text-[12.5px] text-zinc-500 transition-colors hover:bg-zinc-100 hover:text-zinc-800",children:"先不了"})]})]}),h==="celebrate"&&d.jsxs("div",{className:"ui-speech text-center",children:[d.jsxs("p",{className:"text-[14px] font-medium text-zinc-900",children:["喵!我是",I,",以后请多指教~"]}),d.jsxs("p",{className:"mt-1 inline-flex items-center gap-1.5 text-[12px] text-zinc-500",children:[d.jsx(D5,{}),"正在去主会话…"]})]}),ve,h==="celebrate"&&d.jsx("span",{className:"ui-name-tag",children:I}),(h==="form"||h==="adopting")&&d.jsx("div",{ref:M,className:"ui-adopt-card mt-4",children:d.jsxs("form",{className:"min-w-0",onSubmit:le=>{le.preventDefault(),!ne.isPending&&D&&re()},children:[d.jsxs("div",{className:"min-w-0 px-5 pt-5",children:[d.jsxs("label",{className:"block min-w-0",children:[d.jsx("span",{className:"text-[14px] font-semibold text-zinc-900",children:"给它起个名字"}),d.jsxs("span",{className:"mt-2 flex min-w-0 items-center gap-2",children:[d.jsx("input",{ref:E,value:p,maxLength:16,disabled:h==="adopting",onChange:le=>g(le.target.value),placeholder:Up,"aria-label":"小猫的名字",className:"ui-field h-10 min-w-0 flex-1 rounded-xl border border-zinc-300 bg-white px-3 text-[15px] font-semibold text-zinc-900 outline-none placeholder:font-normal placeholder:text-zinc-400 disabled:opacity-60"}),d.jsx("button",{type:"button",disabled:h==="adopting",onClick:()=>g(le=>Fy(le.trim())),"aria-label":"随机换一个名字",title:"随机换一个名字",className:"ui-dice grid h-10 w-10 shrink-0 place-items-center rounded-xl border border-zinc-200 text-zinc-500 hover:border-zinc-300 hover:text-zinc-900 disabled:opacity-50",children:d.jsx(Fb,{size:17})})]})]}),d.jsx("div",{className:"mt-4 text-[12.5px] font-medium text-zinc-600",children:"它用哪个 Agent 思考"}),d.jsxs("div",{className:"mt-2 flex min-w-0 max-w-full flex-wrap gap-1.5",children:[A.map(le=>d.jsxs("button",{type:"button",disabled:h==="adopting","aria-pressed":le.id===D,onClick:()=>{v(le.id),S(""),_(""),j(void 0)},className:"ui-pill-choice",children:[d.jsx(Hr,{agentId:le.id,agentName:le.name,size:13}),d.jsx("span",{className:"min-w-0 truncate",children:le.name})]},le.id)),!A.length&&d.jsx("span",{className:"text-[12.5px] text-zinc-400",children:"还没有可用的 Agent,先到设置里配一个。"})]}),d.jsxs("div",{className:"mt-4 grid min-w-0 grid-cols-[minmax(0,1fr)] gap-3",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsxs("div",{className:"text-[12.5px] font-medium text-zinc-600",children:["模型 ",d.jsx("span",{className:"font-normal text-zinc-400",children:"可选"})]}),d.jsx(ua,{size:"sm",options:q,value:w,placeholder:"Agent 默认",disabledText:J?"正在读取模型…":T.isError?"模型列表读取失败,可先不选":"这个 Agent 没有提供模型选项",disabled:h==="adopting",onChange:le=>{S(le),_("")}})]}),d.jsxs("div",{className:"min-w-0",children:[d.jsxs("div",{className:"text-[12.5px] font-medium text-zinc-600",children:["思考深度 ",d.jsx("span",{className:"font-normal text-zinc-400",children:"可选"})]}),d.jsx(ua,{size:"sm",options:X,value:C,placeholder:"Agent 默认",disabledText:J?"正在读取…":T.isError?"读取失败,可先不选":"这个模型没有思考深度选项",disabled:h==="adopting",onChange:_})]})]}),((xe=T.data)==null?void 0:xe.warning)&&d.jsxs("p",{className:"mt-1.5 break-words text-[11px] leading-4 text-amber-600 [overflow-wrap:anywhere]",children:["这个 Agent 的配置没读出来:",T.data.warning," 如果一直这样,先检查它是否已登录。"]}),d.jsxs("div",{className:"mt-4 text-[12.5px] font-medium text-zinc-600",children:["常驻目录 ",d.jsx("span",{className:"font-normal text-zinc-400",children:"可选,派活时仍可指定别的目录"})]}),d.jsxs("div",{className:"mt-2 flex min-w-0 max-w-full items-center gap-1.5",children:[d.jsx("input",{list:"adopt-workspaces",value:b,disabled:h==="adopting",onChange:le=>y(le.target.value),placeholder:O??"绝对路径,例如 /Users/you/project","aria-label":"常驻目录",title:b.trim()||O||void 0,spellCheck:!1,className:"ui-field h-9 w-0 min-w-0 max-w-full flex-1 truncate rounded-xl border border-zinc-300 bg-white px-3 font-mono text-[12.5px] text-zinc-800 outline-none placeholder:font-sans placeholder:text-zinc-400 disabled:opacity-60"}),((Ze=P.data)==null?void 0:Ze.directoryPicker)&&d.jsx("button",{type:"button",disabled:h==="adopting"||ae.isPending,onClick:()=>ae.mutate(),title:ae.isPending?"选择中…":"选择目录","aria-label":"选择目录",className:"grid h-9 w-9 shrink-0 place-items-center rounded-xl border border-zinc-200 text-zinc-500 transition-colors hover:border-zinc-300 hover:text-zinc-900 disabled:opacity-50",children:ae.isPending?d.jsx(Hn,{size:14,className:"animate-spin"}):d.jsx(ha,{size:14})})]}),b.trim()&&d.jsx("p",{className:"mt-1.5 break-all font-mono text-[11.5px] leading-4 text-zinc-400",title:b.trim(),children:b.trim()}),d.jsx("datalist",{id:"adopt-workspaces",children:V.map(le=>d.jsx("option",{value:le,children:f2(le,B)},le))}),d.jsx("p",{className:"mt-1.5 text-[11.5px] leading-4 text-zinc-400",children:"可以直接粘贴任意绝对路径,或从最近用过的目录里挑;留空就用 Agent 自己的默认目录。"}),d.jsxs("p",{className:"mt-4 rounded-xl bg-zinc-50 px-3 py-2.5 text-[12px] leading-5 text-zinc-500",children:["它会成为你的",d.jsx("b",{className:"font-medium text-zinc-700",children:"主会话"}),":听你说要做什么,派侧边会话去干、盯进度、验收结果。派出去的每件事都是一张便签,贴在屏幕右边,随时划出来看。"]}),k&&d.jsx("p",{role:"alert",className:"mt-3 break-words text-[12px] text-red-600 [overflow-wrap:anywhere]",children:k})]}),d.jsxs("div",{className:"mt-4 flex min-w-0 flex-wrap items-center justify-end gap-2 border-t border-zinc-100 px-4 py-3",children:[d.jsx("button",{type:"button",disabled:h==="adopting",onClick:()=>f(l?"idle":"invite"),className:"h-9 rounded-full px-3.5 text-[13px] text-zinc-500 transition-colors hover:bg-zinc-100 hover:text-zinc-800 disabled:opacity-50",children:"先不了"}),d.jsx("button",{type:"submit",disabled:h==="adopting"||!D,className:"inline-flex h-9 min-w-[8.5rem] items-center justify-center gap-1.5 rounded-full bg-zinc-900 px-4 text-[13px] font-medium text-white transition-[background-color,transform] hover:bg-zinc-700 active:scale-95 disabled:opacity-60",children:h==="adopting"?d.jsxs(d.Fragment,{children:[d.jsx(D5,{}),"正在带它回家…"]}):d.jsxs(d.Fragment,{children:[d.jsx(Ji,{size:14}),"带它回家"]})})]})]})}),!U&&d.jsx("h1",{className:"ui-empty-state ui-hero-title mt-4 text-[22px] font-semibold tracking-[-.02em]",children:"有什么要做的?"})]});return d.jsx(uLe,{editorRef:n,agents:e,sessions:t,onCreated:r,hero:fe,collapsed:U&&!G,companion:oe&&s.mainSession?{sessionId:s.mainSession.id,agentId:s.mainSession.agentId,name:s.name,onSent:()=>{const le=hm(["kitten-hero"]);le&&jc(le,"sparkles",6),window.setTimeout(()=>o.openMain(),co()?0:260)}}:void 0})}const mLe=m.lazy(()=>w4(()=>import("./PromptEditor-B1iVLwZz.js"),__vite__mapDeps([5,1,2,3]))),gLe=e=>[...new Set(e.split(/[\n,,]/).map(t=>t.trim()).filter(Boolean))];function vLe({className:e=""}){return d.jsx("img",{src:"/agent-dock.svg",alt:"","aria-hidden":"true",className:`${e} ui-logo-tile`})}function xLe({cwd:e,top:t,left:n,agents:r,creatingPair:i,onSelect:s,onClose:o}){const a=m.useRef(null);return jy(a,!0,o),d.jsxs("div",{ref:a,className:"ui-popover fixed z-50 max-h-64 w-52 overflow-y-auto rounded-lg border border-zinc-200 bg-white p-1 shadow-[0_16px_40px_rgba(24,24,27,.16)]",style:{top:t,left:n},children:[d.jsx("div",{className:"px-2 py-1 text-[12px] text-zinc-400",children:"在此工作区新建会话"}),r.length===0&&d.jsx("div",{className:"px-2 py-2 text-[12px] text-zinc-400",children:"暂无可用 Agent"}),r.map(l=>{const c=(i==null?void 0:i.agentId)===l.id&&i.cwd===e;return d.jsxs("button",{type:"button",disabled:!!i,onClick:()=>s(l.id),className:"flex h-8 w-full items-center gap-2 rounded-md px-2 text-left text-[12px] text-zinc-700 hover:bg-zinc-100 disabled:opacity-50",children:[c?d.jsx(Hn,{size:13,className:"shrink-0 animate-spin text-zinc-500"}):d.jsx(Hr,{agentId:l.id,agentName:l.name,size:14}),d.jsx("span",{className:"min-w-0 flex-1 truncate",children:l.name})]},l.id)})]})}function bLe({options:e,value:t,onChange:n}){return d.jsx(vi,{className:"w-40 shrink-0",size:"small",popupMatchSelectWidth:!1,value:t,onChange:n,options:e.map(r=>({value:r.value,label:r.label}))})}function F5({options:e,value:t,onChange:n}){return d.jsx("div",{className:"flex shrink-0 rounded-md bg-zinc-100 p-0.5",children:e.map(r=>d.jsx("button",{type:"button",onClick:()=>n(r.value),className:`h-7 rounded px-2.5 text-[12px] font-medium transition-colors ${t===r.value?"bg-white text-zinc-900 shadow-sm":"text-zinc-500 hover:text-zinc-700"}`,children:r.label},r.value))})}function yLe({agents:e,value:t,disabled:n,size:r="default",popupWidth:i,onChange:s}){return d.jsx(ua,{size:r,popupWidth:i,options:e.map(o=>({value:o.id,label:o.name,meta:o.version,agentId:o.id})),value:t,placeholder:"选择 Agent",disabledText:"未扫描到可用 Agent",disabled:n,onChange:s})}function l_({value:e,placeholder:t,onChange:n}){const[r,i]=m.useState(""),s=m.useRef(null),o=(c=r)=>{const u=gLe(c);u.length&&n([...new Set([...e,...u])]),i("")},a=c=>n(e.filter(u=>u!==c)),l=c=>{c.nativeEvent.isComposing||(c.key==="Enter"||c.key===","||c.key===","?(c.preventDefault(),o()):c.key==="Backspace"&&!r&&e.length&&a(e[e.length-1]))};return d.jsxs("div",{role:"group","aria-label":"成员真实姓名",onClick:()=>{var c;return(c=s.current)==null?void 0:c.focus()},className:"mt-2 flex min-h-11 cursor-text flex-wrap items-center gap-x-2 gap-y-2 rounded-lg border border-zinc-300 bg-zinc-50/70 p-2 ui-field-within focus-within:bg-white",children:[e.map(c=>d.jsxs("span",{title:c,className:"flex h-7 max-w-full items-center rounded-md border border-zinc-200 bg-white pl-2.5 pr-1 text-[12px] font-medium text-zinc-700 shadow-[0_1px_1px_rgba(24,24,27,.04)]",children:[d.jsx("span",{className:"min-w-0 truncate",children:c}),d.jsx("button",{type:"button","aria-label":`移除 ${c}`,onPointerDown:u=>u.preventDefault(),onClick:()=>a(c),className:"ml-1.5 grid h-5 w-5 shrink-0 place-items-center rounded text-zinc-400 transition-colors hover:bg-zinc-100 hover:text-zinc-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-300",children:d.jsx(Wn,{size:11})})]},c)),d.jsx("input",{ref:s,"aria-label":"输入成员真实姓名",value:r,onChange:c=>i(c.target.value),onKeyDown:l,onBlur:()=>o(),onPaste:c=>{const u=c.clipboardData.getData("text");/[\n,,]/.test(u)&&(c.preventDefault(),o(`${r}
1117
1117
  ${u}`))},placeholder:e.length?"继续添加成员…":t,className:"h-7 min-w-36 flex-[1_0_9rem] border-0 bg-transparent px-1 text-[12px] text-zinc-800 outline-none placeholder:text-zinc-400"})]})}function wLe({agents:e,onClose:t}){var Yt,Y,Ae,et,Tt,dt,At,He,it,jt,St,It,Rn,Tn,Sn,mr,qn,nr,Ur,_r,ci,Rr,rr,Cr,kr,Nr,Kr,ui,Ft,Rt;const[n,r]=m.useState(!1),i=Ln(),s=Et({queryKey:["lark-config"],queryFn:we.larkConfig}),o=Et({queryKey:["system-capabilities"],queryFn:we.systemCapabilities}),[a,l]=m.useState(),c=m.useRef(null),[u,h]=m.useState(null),[f,p]=m.useState(1),[g,x]=m.useState(""),[v,b]=m.useState(""),[y,w]=m.useState(""),[S,C]=m.useState(""),[_,k]=m.useState(""),[j,z]=m.useState(!1),[N,I]=m.useState([]),[$,R]=m.useState([]),[E,M]=m.useState(!0),[P,A]=m.useState(""),[D,F]=m.useState(""),[O,B]=m.useState(""),[V,T]=m.useState(""),[W,L]=m.useState(!1),[q,X]=m.useState(!1),[J,ae]=m.useState("user"),[ne,re]=m.useState([]),[ie,G]=m.useState(""),[oe,ge]=m.useState(!1),[U,ce]=m.useState(!1),[ve,fe]=m.useState(!1),[Ce,Pe]=m.useState(!1),[Ie,Te]=m.useState(!1),[de,Le]=m.useState(1e3),[te,me]=m.useState(String(Lw)),[_e,$e]=m.useState(!1),xe=(Yt=s.data)==null?void 0:Yt.bots.find(se=>se.appId===u),Ze=((Y=e.find(se=>se.id===P))==null?void 0:Y.cwd)||((Ae=o.data)==null?void 0:Ae.workingDirectory),le=!!(xe!=null&&xe.setupComplete&&xe.defaultAgentId===P),Me=!!(U||xe!=null&&xe.hardGateEnabled),pe=m.useMemo(()=>lye(ie),[ie]),ye=Et({queryKey:["lark-hook-status",xe==null?void 0:xe.appId,P],queryFn:()=>we.larkHookStatus(xe.appId),enabled:!!(le&&oe&&f===2)}),Ee=Et({queryKey:ul(P,D),queryFn:()=>dl(P,D||void 0),enabled:!!P,initialData:()=>Cd(P,D||void 0),initialDataUpdatedAt:0,refetchOnMount:"always",staleTime:5*6e4}),Se=yt({mutationFn:se=>dl(se.agentId,se.model,!0),onSuccess:(se,gt)=>i.setQueryData(ul(gt.agentId,gt.model),se)}),De={enabled:U,persisted:!!(xe!=null&&xe.hardGateEnabled),agentSelectionSaved:le,hookInstalled:!!((et=ye.data)!=null&&et.installed)},at=nme(De),xt=rme(De),Mt=!!(U&&(xe!=null&&xe.hardGateEnabled)&&ye.isSuccess&&!ye.data.installed),rt=!!(oe&&(xe!=null&&xe.highRiskAllowedEmails.length)&&!ne.length),nt=ime(O,(Tt=Ee.data)!=null&&Tt.warning?void 0:Ee.data,Ee.isFetching),Qe=[`机器人名称:${g.trim()||S.trim()||"未命名"}`,`Agent:${((dt=e.find(se=>se.id===P))==null?void 0:dt.name)??(P||"未选择")}`,`工作区:${v.trim()||"使用 Agent 默认工作目录"}`,`群协作工具:${W?q?"已开启(可读写)":"已开启(只读)":"未开启"}`,`回复模式:${_e?"静默回复(最终答案由服务端自动发送)":"Trace 卡片"}`].join(`
1118
1118
  `);_P(s.data,()=>{if(u!==null)return;const se=s.data.bots[0];h((se==null?void 0:se.appId)??""),p(se&&!se.setupComplete?2:1)}),_P(s.data&&u!==null?u:null,()=>{var gt,bt,tn,Nn,Un;if(u===null||c.current===u)return;c.current=u;const se=s.data.bots.find(Fn=>Fn.appId===u);x((se==null?void 0:se.name)??""),b((se==null?void 0:se.workspace)??""),w((se==null?void 0:se.webBaseUrl)??""),C((se==null?void 0:se.appId)??""),k(""),z(!!(se!=null&&se.allowedUsers.length||se!=null&&se.allowedEmails.length||(gt=se==null?void 0:se.allowedUserNames)!=null&&gt.length)),I((bt=se==null?void 0:se.allowedUserNames)!=null&&bt.length?se.allowedUserNames:((se==null?void 0:se.allowedUsers)??[]).map(Fn=>Fn.name)),R((tn=se==null?void 0:se.allowedBotNames)!=null&&tn.length?se.allowedBotNames:((se==null?void 0:se.allowedBots)??[]).map(Fn=>Fn.name)),M((se==null?void 0:se.peerBotsAllowed)!==!1),A(e.some(Fn=>Fn.id===(se==null?void 0:se.defaultAgentId))?(se==null?void 0:se.defaultAgentId)??"":((Nn=e[0])==null?void 0:Nn.id)??""),F((se==null?void 0:se.defaultModel)??""),B((se==null?void 0:se.defaultReasoningEffort)??""),Te((se==null?void 0:se.listening)??!1),Le((se==null?void 0:se.pushIntervalMs)??1e3),me(((se==null?void 0:se.traceLimit)??Lw).toString()),$e((se==null?void 0:se.quietReply)??!1),T((se==null?void 0:se.preInjectPrompt)??""),L((se==null?void 0:se.groupToolsEnabled)??!1),X((se==null?void 0:se.groupToolsAllowSend)??!1),ae((se==null?void 0:se.groupSessionScope)??"user"),re((Un=se==null?void 0:se.highRiskAllowedUserNames)!=null&&Un.length?se.highRiskAllowedUserNames:((se==null?void 0:se.highRiskAllowedUsers)??[]).map(Fn=>Fn.name)),G((se==null?void 0:se.highRiskPattern)??""),ge((se==null?void 0:se.gateEnabled)??!1),ce((se==null?void 0:se.hardGateEnabled)??!1),fe((se==null?void 0:se.hookTrustConfirmed)??!1)});const tt=yt({mutationFn:()=>we.inspectLarkBot({appId:S.trim(),appSecret:_.trim()}),onSuccess:se=>x(se.appName)}),ft=yt({mutationFn:async()=>{const se=await we.saveLarkConfig({stage:"lark",...xe?{originalAppId:xe.appId}:{},appId:S.trim(),..._.trim()?{appSecret:_.trim()}:{},workspace:v.trim(),webBaseUrl:y.trim(),allowedUserNames:j?N:[],allowedEmails:[],allowedBotNames:E?[]:$,peerBotsAllowed:E,listening:Ie,pushIntervalMs:de,traceLimit:Number(te),quietReply:_e});return i.setQueryData(["lark-config"],se),we.saveLarkConfig({stage:"agent",originalAppId:S.trim(),defaultAgentId:P,defaultModel:D,defaultReasoningEffort:nt,preInjectPrompt:V,groupToolsEnabled:W,groupToolsAllowSend:q,groupSessionScope:J,highRiskAllowedUserNames:ne,highRiskAllowedEmails:[],highRiskPattern:ie,gateEnabled:oe,softGateEnabled:oe,hardGateEnabled:U,hookTrustConfirmed:ve})},onSuccess:se=>{i.setQueryData(["lark-config"],se);const gt=S.trim();h(gt),k(""),i.invalidateQueries({queryKey:["lark-hook-status",gt]}),t()}}),ue=yt({mutationFn:async()=>{const se=await we.saveLarkConfig({stage:"agent",originalAppId:xe.appId,defaultAgentId:P,defaultModel:D,defaultReasoningEffort:nt,preInjectPrompt:V,listening:Ie,groupToolsEnabled:W,groupToolsAllowSend:q,groupSessionScope:J,highRiskAllowedUserNames:ne,highRiskAllowedEmails:[],highRiskPattern:ie,gateEnabled:!0,softGateEnabled:!0,hardGateEnabled:!1,hookTrustConfirmed:!1});return i.setQueryData(["lark-config"],se),we.installLarkHook(xe.appId,ie)},onSuccess:se=>{i.setQueryData(["lark-hook-status",xe.appId,P],se),ge(!0),ce(!1),fe(!0),i.invalidateQueries({queryKey:["lark-config"]})}}),Oe=yt({mutationFn:()=>we.deleteLarkConfig(xe.appId),onSuccess:se=>{i.setQueryData(["lark-config"],se);const gt=se.bots[0];h((gt==null?void 0:gt.appId)??""),p(gt&&!gt.setupComplete?2:1),l(void 0)}}),ke=yt({mutationFn:we.selectDirectory,onSuccess:se=>b(se.path)}),pt=f===2&&!!P&&!Ee.data&&(Ee.isLoading||Ee.isFetching),mt=f!==2||!!Ee.data,Ye=!!(S.trim()&&(xe||_.trim())&&(!j||N.length)&&(E||$.length)&&(_e||Number.isInteger(de)&&de>=500&&de<=2e4)),ze=!!(P&&mt&&(!oe||pe.valid)&&!rt&&at),Re=f===1&&!(xe!=null&&xe.setupComplete),Q=Re?Ye:Ye&&ze,Ge=!!(xe||S.trim()&&_.trim()),qe=Se.error??ft.error??Oe.error??ke.error??tt.error??ue.error??(Ee.data?void 0:Ee.error)??s.error,$t=/^cli_[\w-]+$/.test(S.trim())?`https://open.larkoffice.com/app/${encodeURIComponent(S.trim())}/auth`:void 0,Gt=!!(qe&&/权限|permission|通讯录|邮箱|open[_ ]?id|资源点|visible range/i.test(qe.message)),Qt=()=>{const se=!!(xe&&!xe.setupComplete),gt=!xe&&u===""&&!!(S.trim()||_.trim()||v.trim());if(se||gt){l(se?"incomplete":"discard");return}t()};return d.jsxs(d.Fragment,{children:[n&&d.jsx(Zpe,{onClose:()=>{r(!1),i.invalidateQueries({queryKey:["lark-config"]})},onComplete:se=>{i.setQueryData(["lark-config"],se.config),h(se.appId),p(1),r(!1)}}),d.jsx("div",{inert:n,"aria-hidden":n||void 0,className:"ui-overlay fixed inset-0 z-30 grid place-items-center bg-zinc-950/25 p-4",onMouseDown:se=>{se.currentTarget===se.target&&Qt()},children:d.jsxs("form",{onSubmit:se=>{se.preventDefault(),Q&&(Re?p(2):ft.mutate())},className:"ui-dialog flex max-h-[calc(100dvh-2rem)] w-full max-w-[640px] flex-col overflow-hidden rounded-[14px] border border-zinc-200 bg-white shadow-[0_20px_64px_rgba(24,24,27,.18)]",children:[d.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-y-2 border-b border-zinc-100 px-4 py-3",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsx("h2",{className:"text-[16px] font-semibold text-zinc-900",children:"飞书机器人"}),d.jsx("p",{className:"mt-0.5 truncate text-[12px] text-zinc-500",children:"每个机器人拥有独立工作区和会话"})]}),d.jsxs("div",{className:"col-span-2 row-start-2 flex min-w-0 flex-wrap items-center justify-end gap-0.5",children:[d.jsxs("a",{href:"https://open.larkoffice.com/app",target:"_blank",rel:"noreferrer",className:"flex h-8 items-center gap-1.5 whitespace-nowrap rounded-lg px-2.5 text-[12px] font-medium text-zinc-500 transition-colors hover:bg-zinc-100 hover:text-zinc-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400/50",children:["飞书开发者后台",d.jsx(Ja,{size:12})]}),d.jsxs("a",{href:"https://open.larkoffice.com/page/launcher?from=backend_oneclick",target:"_blank",rel:"noreferrer",className:"flex h-8 items-center gap-1.5 whitespace-nowrap rounded-lg px-2.5 text-[12px] font-medium text-zinc-600 transition-colors hover:bg-zinc-100 hover:text-zinc-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400/50",children:["快速创建机器人",d.jsx(Ja,{size:12})]}),d.jsxs("button",{type:"button",onClick:()=>r(!0),disabled:!s.data||ft.isPending,className:"flex h-8 items-center gap-1.5 whitespace-nowrap rounded-lg px-2.5 text-[12px] font-medium text-zinc-700 transition-colors hover:bg-zinc-100 disabled:opacity-40",children:["扫码创建机器人",d.jsx(sa,{size:12})]})]}),d.jsx("span",{className:"col-start-2 row-start-1 ml-1",children:d.jsx($o,{label:"关闭",onClick:Qt,children:d.jsx(Wn,{size:15})})})]}),d.jsxs("div",{className:"flex shrink-0 gap-1 overflow-x-auto border-b border-zinc-100 bg-zinc-50/70 px-3 py-2",children:[(At=s.data)==null?void 0:At.bots.map(se=>d.jsxs("button",{type:"button",onClick:()=>{h(se.appId),p(se.setupComplete?1:2)},className:`flex h-8 max-w-[250px] shrink-0 items-center gap-1.5 rounded-lg px-2.5 text-[12px] font-medium transition-colors ${u===se.appId?"bg-white text-zinc-900 shadow-sm ring-1 ring-zinc-200":"text-zinc-500 hover:bg-white/70 hover:text-zinc-800"}`,children:[se.avatarUrl?d.jsx(YH,{url:se.avatarUrl,size:13,className:"h-[13px] w-[13px] shrink-0 rounded-sm object-cover"}):d.jsx(ti,{size:13,className:"shrink-0"}),d.jsx("span",{title:se.name,className:"min-w-0 max-w-32 truncate",children:se.tabLabel}),se.setupComplete?d.jsxs("span",{title:"配置完成",className:"flex shrink-0 items-center gap-0.5 rounded bg-emerald-50 px-1 py-0.5 text-[12px] font-medium text-emerald-700",children:[d.jsx(gi,{size:9}),"已配置"]}):d.jsx("span",{className:"shrink-0 rounded bg-amber-100 px-1 py-0.5 text-[12px] text-amber-700",children:"待配置"}),se.activeListening&&d.jsx("span",{title:"长连接已连接",className:"h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500"})]},se.appId)),d.jsxs("button",{type:"button",onClick:()=>{h(""),p(1)},className:`flex h-8 shrink-0 items-center gap-1 rounded-lg px-2.5 text-[12px] font-medium ${u===""?"bg-white text-zinc-900 shadow-sm ring-1 ring-zinc-200":"text-zinc-500 hover:bg-white/70 hover:text-zinc-800"}`,children:[d.jsx(sa,{size:13}),"新增机器人"]})]}),d.jsxs("div",{className:"space-y-3.5 overflow-y-auto px-4 py-4",children:[d.jsx(fl,{placeholder:d.jsx("div",{className:"min-h-[420px]",children:d.jsx(pl,{})}),children:s.isLoading?d.jsxs("div",{className:"space-y-2.5",children:[d.jsx("div",{className:"h-9 ui-skeleton rounded-md bg-zinc-100"}),d.jsx("div",{className:"h-9 ui-skeleton rounded-md bg-zinc-100"}),d.jsx("div",{className:"h-9 ui-skeleton rounded-md bg-zinc-100"})]}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"mb-1 grid grid-cols-2 rounded-lg bg-zinc-100 p-1",children:[d.jsxs("button",{type:"button",onClick:()=>p(1),className:`rounded-md px-3 py-2 text-[12px] font-medium transition-colors ${f===1?"bg-white text-zinc-900 shadow-sm":"text-zinc-500"}`,children:[d.jsx("span",{className:"mr-1.5 inline-grid h-4 w-4 place-items-center rounded-full bg-zinc-900 text-[12px] text-white",children:"1"}),"飞书与白名单"]}),d.jsxs("button",{type:"button",disabled:!xe&&!Ye,onClick:()=>p(2),className:`rounded-md px-3 py-2 text-[12px] font-medium transition-colors disabled:opacity-40 ${f===2?"bg-white text-zinc-900 shadow-sm":"text-zinc-500"}`,children:[d.jsx("span",{className:"mr-1.5 inline-grid h-4 w-4 place-items-center rounded-full bg-zinc-900 text-[12px] text-white",children:"2"}),"Agent 与门禁"]})]}),d.jsx("p",{className:"-mt-1 text-[12px] leading-4 text-zinc-400",children:f===1?"点「下一步」继续配置 Agent,最后点「保存」才会一次性生效;指定成员和机器人的姓名在实际使用时再校验。":"Agent 配置不影响长连接;收到消息时才会校验运行配置。"}),f===1?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[d.jsxs("label",{className:"block",children:[d.jsx("span",{className:"text-[12px] font-medium text-zinc-700",children:"机器人名称"}),d.jsx(Qn,{size:"large",value:g,readOnly:!0,variant:"filled",placeholder:"校验凭证后自动识别",className:"mt-1.5 font-mono text-[12px]"})]}),d.jsxs("label",{className:"block",children:[d.jsx("span",{className:"text-[12px] font-medium text-zinc-700",children:"App ID"}),d.jsx(Qn,{size:"large",value:S,onChange:se=>{C(se.target.value),x("")},placeholder:"cli_xxx",autoComplete:"off",className:"mt-1.5 font-mono text-[12px]"})]})]}),d.jsxs("label",{className:"block",children:[d.jsxs("span",{className:"flex items-center text-[12px] font-medium text-zinc-700",children:["App Secret",xe&&d.jsx("span",{className:"ml-2 font-normal text-zinc-400",children:"留空不修改"})]}),d.jsx(Qn.Password,{size:"large",value:_,onChange:se=>k(se.target.value),visibilityToggle:{visible:Ce,onVisibleChange:Pe},iconRender:se=>se?d.jsx(TZ,{size:13}):d.jsx(Bg,{size:13}),placeholder:xe?"已保存":"输入 App Secret",autoComplete:"new-password",className:"mt-1.5 font-mono text-[12px]"})]}),d.jsxs("div",{children:[d.jsxs("span",{className:"text-[12px] font-medium text-zinc-700",children:["工作区 ",d.jsx("span",{className:"font-normal text-zinc-400",children:"可选"})]}),d.jsxs("div",{className:"flex items-start gap-2",children:[d.jsx("div",{className:"min-w-0 flex-1",children:d.jsx(IE,{value:v,onChange:b,label:"工作区",placeholder:"留空使用默认工作目录",suggestion:Ze,suggestionLabel:"使用默认工作目录"})}),d.jsxs("button",{type:"button",disabled:!((He=o.data)!=null&&He.directoryPicker)||ke.isPending,onClick:()=>ke.mutate(),className:"mt-1.5 flex h-9 shrink-0 items-center gap-1.5 rounded-md border border-zinc-300 bg-white px-3 text-[12px] font-medium text-zinc-700 hover:bg-zinc-50 disabled:cursor-not-allowed disabled:opacity-40",children:[d.jsx(ha,{size:13}),(it=o.data)!=null&&it.directoryPicker?"选择":"仅支持 Mac"]})]}),d.jsx("p",{className:"mt-1 text-[12px] leading-4 text-zinc-400",children:"留空时使用所选 Agent 的默认工作目录;路径位于 AgentDock 服务所在机器。"})]}),d.jsxs("div",{className:"block",children:[d.jsxs("span",{className:"text-[12px] font-medium text-zinc-700",children:["Web 访问地址 ",d.jsx("span",{className:"font-normal text-zinc-400",children:"可选"})]}),d.jsx(ume,{value:y,onChange:w}),d.jsx("p",{className:"mt-1 text-[12px] leading-4 text-zinc-400",children:"配置后,飞书卡片底部会显示“查看详情”链接,指向该域名下的会话 Trace 页面。"})]}),!xe&&d.jsxs("button",{type:"button",disabled:!S.trim()||!_.trim()||tt.isPending,onClick:()=>tt.mutate(),className:"flex h-9 w-full items-center justify-center gap-2 rounded-md border border-zinc-300 bg-white text-[12px] font-medium text-zinc-700 hover:bg-zinc-50 disabled:opacity-40",children:[tt.isPending?d.jsx(Hn,{size:12,className:"animate-spin"}):d.jsx(ti,{size:12}),"校验凭证并识别机器人名称"]}),d.jsxs("div",{className:"overflow-hidden rounded-xl border border-zinc-200 bg-white",children:[d.jsx(fi,{title:"可使用机器人的成员",description:"输入飞书真实姓名;收到消息时再解析为稳定的 open_id,不读取邮箱。",children:d.jsx(F5,{value:j?"restricted":"all",onChange:se=>z(se==="restricted"),options:[{value:"all",label:"所有人"},{value:"restricted",label:"指定成员"}]})}),j&&d.jsxs("div",{className:"border-t border-zinc-100 px-4 pb-3.5 pt-3",children:[!!(xe!=null&&xe.allowedEmails.length&&!xe.allowedUsers.length)&&d.jsx("div",{className:"mb-2 border-l-2 border-amber-400 bg-amber-50 px-2.5 py-2 text-[12px] leading-5 text-amber-800",children:"检测到旧邮箱白名单。请重新填写真实姓名;保存后改用姓名白名单,使用时解析 open_id,停止查询通讯录。"}),d.jsxs("div",{children:[d.jsx("div",{className:"text-[12px] font-medium text-zinc-500",children:"成员真实姓名"}),d.jsx(l_,{value:N,onChange:I,placeholder:"输入姓名后按 Enter"}),d.jsx("p",{className:"mt-1 text-[12px] leading-5 text-zinc-400",children:"支持 Enter、逗号或粘贴多行生成标签。保存时不查询群成员;使用时精确匹配,找不到或重名时拒绝访问。"})]})]})]}),d.jsxs("div",{className:"overflow-hidden rounded-xl border border-zinc-200 bg-white",children:[d.jsx(fi,{title:"可调用机器人的其他机器人",description:"输入机器人名称;收到调用时再在群成员中解析 open_id。",children:d.jsx(F5,{value:E?"all":"restricted",onChange:se=>M(se==="all"),options:[{value:"all",label:"所有机器人"},{value:"restricted",label:"指定机器人"}]})}),!E&&d.jsx("div",{className:"border-t border-zinc-100 px-4 pb-3.5 pt-3",children:d.jsxs("div",{children:[d.jsx("div",{className:"text-[12px] font-medium text-zinc-500",children:"机器人名称"}),d.jsx(l_,{value:$,onChange:R,placeholder:"输入机器人名称后按 Enter"})]})})]}),d.jsxs("div",{className:"overflow-hidden rounded-xl border border-zinc-200 bg-white",children:[d.jsxs("div",{className:"px-4 py-3",children:[d.jsx("div",{className:"text-[14px] font-medium text-zinc-900",children:"Trace 卡片"}),d.jsx("div",{className:"mt-0.5 text-[12px] leading-5 text-zinc-500",children:"控制任务过程中推送的 trace 卡片如何渲染与刷新。"})]}),d.jsx(fi,{title:"静默回复(不显示 trace 卡片)",description:"不发送 trace 卡片,任务结束时由服务自动把最终回复以文本发送到会话;Agent 会被提示如何在本模式下 @ 他人。",children:d.jsx(js,{size:"small",checked:_e,onChange:()=>$e(se=>!se)})}),!_e&&d.jsxs(d.Fragment,{children:[d.jsx(fi,{title:"飞书推送间隔",description:"500-20000 ms;心跳消息的最短间隔。",children:d.jsx(Fx,{size:"middle",min:500,max:2e4,step:100,value:de,onChange:se=>Le(se??1e3),suffix:"ms",className:"!w-40 font-mono"})}),d.jsx(fi,{title:"Trace 阶段上限",description:`默认 ${Lw};心跳渲染时最多保留最近 N 个执行阶段,超过飞书 24KB / 180 组件限制时仍会自动裁剪较早记录。`,children:d.jsx(Fx,{size:"middle",min:1,max:200,step:1,precision:0,value:te===""?null:Number(te),onChange:se=>me(se==null?"":String(se)),className:"!w-40 font-mono"})})]})]}),d.jsx("div",{className:"overflow-hidden rounded-xl border border-zinc-200 bg-white",children:d.jsx(fi,{className:(jt=s.data)!=null&&jt.listeningDisabled||!Ge?"opacity-50":"",title:"监听飞书消息",description:(St=s.data)!=null&&St.listeningDisabled?"本次启动已通过 --no-lark-listen 禁用,保存值不受影响":Ge?xe!=null&&xe.activeListening?"长连接已连接":xe!=null&&xe.setupComplete?"使用长连接接收机器人消息":"可先监听;收到消息时再校验 Agent 运行配置":"请先填写飞书凭证",children:d.jsx(js,{size:"small",checked:Ie&&!((It=s.data)!=null&&It.listeningDisabled),disabled:((Rn=s.data)==null?void 0:Rn.listeningDisabled)||!Ge,onChange:()=>Te(se=>!se)})})})]}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"overflow-hidden rounded-xl border border-zinc-200 bg-white",children:[d.jsx(fi,{title:"默认 Agent",description:Me?"硬门禁已开启,保存关闭后解锁。":"飞书会话默认使用的 Agent。",children:d.jsx("div",{className:"w-64",children:d.jsx(yLe,{size:"sm",popupWidth:360,agents:e,value:P,disabled:Me,onChange:se=>{A(se),F(""),B(""),ce(!1),fe(!1)}})})}),d.jsx(fi,{title:"默认模型",description:!Ee.isFetching&&!((Tn=Ee.data)!=null&&Tn.models.length)?"暂未取得可选模型,保留当前配置;可尝试重新读取。":"由 Agent 提供,可覆盖 Agent 默认模型。",children:d.jsx("div",{className:"w-64",children:d.jsx(ua,{size:"sm",popupWidth:380,options:[{value:"",label:(Sn=Ee.data)!=null&&Sn.defaultModel?`Agent 默认 (${Ee.data.defaultModel})`:"使用 Agent 默认模型"},...Gx(((mr=Ee.data)==null?void 0:mr.models)??[],D).map(se=>({value:se.id,label:se.name,meta:se.name===se.id?void 0:se.id}))],value:D,placeholder:"选择默认模型",disabled:!((qn=Ee.data)!=null&&qn.models.length),disabledText:"",onChange:se=>{F(se),B("")}})})}),d.jsx(fi,{title:"推理强度",description:!Ee.isFetching&&!((nr=Ee.data)!=null&&nr.reasoningEfforts.length)?"该 Agent / 模型暂未提供可选强度,保留当前配置。":"由 Agent / 模型提供。",children:d.jsx("div",{className:"w-64",children:d.jsx(ua,{size:"sm",popupWidth:300,options:[{value:"",label:(Ur=Ee.data)!=null&&Ur.defaultReasoningEffort?`Agent 默认 (${Ee.data.defaultReasoningEffort})`:"使用 Agent 默认强度"},...Gx(((_r=Ee.data)==null?void 0:_r.reasoningEfforts)??[],nt).map(se=>({value:se.id,label:se.name}))],value:nt,placeholder:"选择推理强度",disabled:!((ci=Ee.data)!=null&&ci.reasoningEfforts.length),disabledText:"",onChange:B})})}),d.jsxs("div",{className:"flex items-center justify-between gap-2 border-t border-zinc-100 px-4 py-2 text-[12px] text-zinc-400",children:[d.jsx("span",{children:Ee.isFetching||Se.isPending?"正在读取 Agent 配置…":"模型与推理强度由 Agent 提供"}),d.jsxs("button",{type:"button",disabled:!P||Ee.isFetching||Se.isPending,onClick:()=>Se.mutate({agentId:P,model:D||void 0}),className:"flex h-7 items-center gap-1 rounded px-1.5 text-[12px] text-zinc-500 hover:bg-zinc-100 disabled:opacity-40",children:[d.jsx(Hn,{size:12}),"重新读取"]})]}),(((Rr=Ee.data)==null?void 0:Rr.warning)||Ee.isError||Se.isError)&&d.jsx("p",{role:"status",className:"mx-4 mb-3 border-l-2 border-amber-300 bg-amber-50 px-2 py-1.5 text-[12px] leading-5 text-amber-800",children:((rr=Ee.data)==null?void 0:rr.warning)??"Agent 配置请求失败,请检查服务连接后重新读取。"})]}),d.jsxs("div",{children:[d.jsxs("span",{className:"text-[12px] font-medium text-zinc-700",children:["预注入 Prompt ",d.jsx("span",{className:"font-normal text-zinc-400",children:"可选,Markdown"})]}),d.jsx(m.Suspense,{fallback:d.jsx("div",{className:"mt-1.5 rounded-md border border-zinc-200 bg-zinc-50 p-3 text-[12px] text-zinc-400",children:"正在加载编辑器…"}),children:d.jsx(mLe,{value:V,onChange:T,aiContext:Qe})}),d.jsx("p",{className:"mt-1 text-[12px] leading-5 text-zinc-400",children:"每轮飞书对话都会在用户请求前隐式注入,不会在 Agent 聊天记录中重复显示为用户消息。"})]}),d.jsxs("div",{className:"overflow-hidden rounded-xl border border-zinc-200 bg-white",children:[d.jsx(fi,{title:"启用 Agent 群协作工具",description:"允许 Agent 在当前飞书群发现其他已配置 Agent,并读取增量消息。",children:d.jsx(js,{size:"small",checked:W,onChange:()=>L(se=>!se)})}),W&&d.jsx(fi,{title:"允许 Agent 发消息与 @交接",description:"关闭后仅保留 self、peers、messages 和 wait 只读能力。",children:d.jsx(js,{size:"small",checked:q,onChange:()=>X(se=>!se)})}),W&&d.jsx(fi,{title:"群聊主流消息的会话隔离",description:"话题内消息始终按话题隔离;此处仅影响群主流(非话题)消息。",children:d.jsx(bLe,{value:J,onChange:se=>ae(se),options:[{value:"user",label:"按发送人隔离"},{value:"chat",label:"全群共享"}]})}),d.jsxs("div",{className:"flex items-start gap-1.5 border-t border-zinc-100 px-4 py-3 text-[12px] leading-5 text-zinc-500",children:[d.jsx(HZ,{size:14,className:"mt-0.5 shrink-0"}),d.jsx("span",{children:"缺少群成员、消息或发消息权限时,Agent 会停止对应操作并给出管理员授权链接;不会索要 App Secret。"})]})]}),d.jsx("div",{className:"overflow-hidden rounded-xl border border-zinc-200 bg-white",children:d.jsx(fi,{title:"启用高危操作门禁",description:"启用后强制开启软门禁,并可继续配置 Hook 硬门禁。",children:d.jsx(js,{size:"small",checked:oe,onChange:()=>{const se=!oe;ge(se),se||ce(!1)}})})}),oe&&d.jsxs("div",{className:"rounded-xl border border-zinc-200 bg-zinc-50/70 p-3",children:[d.jsx("div",{className:"px-1 text-[14px] font-medium text-zinc-900",children:"高危操作门禁"}),d.jsx("p",{className:"mt-1 px-1 text-[12px] leading-5 text-zinc-500",children:"不在允许名单内的发送人会收到软门禁 Prompt;开启硬门禁后,再通过 ACP 权限层和 Agent 原生工具调用 Hook 拦截。"}),d.jsxs("div",{className:"mt-3",children:[d.jsxs("div",{className:"text-[12px] font-medium text-zinc-700",children:["允许执行高危操作的成员 ",d.jsx("span",{className:"font-normal text-zinc-400",children:"留空则继承普通成员名单"})]}),d.jsx("p",{className:"mt-0.5 text-[12px] leading-5 text-zinc-500",children:"输入真实姓名,保存时解析为 open_id。"}),rt&&d.jsx("div",{className:"mt-2 border-l-2 border-amber-400 bg-amber-50 px-2.5 py-2 text-[12px] leading-5 text-amber-800",children:"检测到旧高危邮箱名单。请重新选择成员后再保存,避免意外扩大高危权限。"}),d.jsx(l_,{value:ne,onChange:re,placeholder:"输入姓名后按 Enter"})]}),d.jsxs("label",{className:"mt-3 block",children:[d.jsx("span",{className:"text-[12px] font-medium text-zinc-700",children:"高危操作正则表达式"}),d.jsx(Qn.TextArea,{value:ie,onChange:se=>G(se.target.value),autoSize:{minRows:4,maxRows:10},status:pe.valid?void 0:"error",className:"mt-1.5 font-mono text-[12px] leading-5"}),!pe.valid&&d.jsxs("p",{className:"mt-1.5 flex items-start gap-1 text-[12px] leading-5 text-red-600",children:[d.jsx(al,{size:12,className:"mt-0.5 shrink-0"}),pe.error]})]}),d.jsxs("div",{className:"mt-3 overflow-hidden rounded-lg border border-zinc-200 bg-white",children:[d.jsx(fi,{title:"软门禁",description:"门禁启用后固定开启,隐式注入禁止绕过的安全 Prompt。",children:d.jsx(js,{size:"small",checked:!0,disabled:!0})}),d.jsx(fi,{className:!((Cr=ye.data)!=null&&Cr.installed)&&!U?"opacity-60":"",title:"硬门禁",description:(kr=ye.data)!=null&&kr.installed?"Hook 已配置,可以开启硬门禁。":le?((Nr=ye.data)==null?void 0:Nr.reason)??"请先检测并配置 Hook。":"点击下方按钮会先保存当前默认 Agent,再检测并配置 Hook。",children:d.jsx(js,{size:"small",checked:U,disabled:!xt,onChange:()=>ce(se=>!se)})})]}),Mt&&d.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2.5 py-2 text-[12px] leading-5 text-amber-800",children:"已保存的硬门禁 Hook 当前未检测到。其他设置仍可保存;如需恢复硬门禁,请先关闭上方开关,再重新检测并配置 Hook。"}),d.jsxs("button",{type:"button",disabled:!xe||U||ue.isPending||rt||!v.trim()||!pe.valid||((Kr=ye.data)==null?void 0:Kr.supported)===!1,onClick:()=>ue.mutate(),className:"mt-3 flex h-9 w-full items-center justify-center gap-2 rounded-md border border-zinc-300 bg-white text-[12px] font-medium text-zinc-700 hover:bg-zinc-50 disabled:cursor-not-allowed disabled:opacity-40",children:[d.jsx(gN,{size:13}),ue.isPending?"正在检测并配置 Hook":(ui=ye.data)!=null&&ui.installed?"重新检测并配置 Hook":"检测并配置 Hook"]}),((Ft=ye.data)==null?void 0:Ft.supported)===!1&&d.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2.5 py-2 text-[12px] leading-5 text-amber-800",children:ye.data.reason}),((Rt=ye.data)==null?void 0:Rt.trustInstructions)&&d.jsx("div",{className:"mt-2 rounded-md border border-zinc-200 bg-white px-3 py-2 text-[12px] leading-5 text-zinc-500",children:ye.data.trustInstructions})]})]})]})}),qe&&d.jsxs("div",{className:"rounded-md border border-red-100 bg-red-50 px-2.5 py-2 text-[12px] leading-4 text-red-700",children:[d.jsx("div",{children:qe.message}),Gt&&$t&&d.jsxs("a",{href:$t,target:"_blank",rel:"noreferrer",className:"mt-2 inline-flex items-center gap-1 font-medium text-red-800 underline decoration-red-300 underline-offset-2 hover:text-red-950",children:["打开当前机器人的权限配置",d.jsx(Ja,{size:11})]})]})]}),d.jsxs("div",{className:"flex items-center border-t border-zinc-100 px-4 py-3",children:[xe?d.jsxs("button",{type:"button",onClick:()=>{Oe.reset(),l("delete")},className:"flex items-center gap-1.5 rounded-md px-2 py-1.5 text-[12px] font-medium text-red-600 hover:bg-red-50",children:[d.jsx(kf,{size:13}),"删除配置"]}):d.jsx("span",{className:"text-[12px] text-zinc-400",children:"App ID 将作为唯一主键,不能重复配置"}),f===2&&d.jsx("button",{type:"button",onClick:()=>p(1),className:"ml-auto rounded-md px-3 py-1.5 text-xs font-medium text-zinc-600 hover:bg-zinc-100",children:"上一步"}),d.jsx("button",{type:"button",onClick:Qt,className:`${f===2?"":"ml-auto"} rounded-md px-3 py-1.5 text-xs font-medium text-zinc-600 hover:bg-zinc-100`,children:f===2&&xe&&!xe.setupComplete?"稍后完成":"取消"}),d.jsx("button",{type:"submit",disabled:!Q||ft.isPending,className:"ml-1 min-w-20 rounded-md bg-zinc-900 px-3 py-1.5 text-xs font-medium text-white hover:bg-zinc-700 active:scale-[.98] disabled:cursor-not-allowed disabled:opacity-35",children:ft.isPending?"保存中":pt?"读取模型中":Re?"下一步":"保存"})]})]})}),d.jsx(To,{open:!!a,tone:a==="delete"?"danger":"warning",title:a==="delete"?"删除机器人配置?":a==="incomplete"?"稍后再完成配置?":"放弃未保存的配置?",description:a==="delete"?`将删除“${(xe==null?void 0:xe.name)??"当前机器人"}”的凭证、监听和门禁配置。已有会话记录不会删除。`:a==="incomplete"?"Agent 配置尚未完成。若已开启监听,机器人仍会接收消息,并提示发送人补充运行配置。":"当前填写的机器人信息尚未保存,关闭后需要重新填写。",confirmLabel:a==="delete"?"确认删除":a==="incomplete"?"稍后完成":"放弃修改",busy:a==="delete"&&Oe.isPending,error:a==="delete"&&Oe.error?Oe.error.message:void 0,onCancel:()=>{Oe.isPending||l(void 0)},onConfirm:()=>{a==="delete"?Oe.mutate():(l(void 0),t())}})]})}function SLe({onClose:e}){return d.jsx("div",{className:"ui-overlay fixed inset-0 z-[60] grid place-items-center bg-zinc-950/30 p-2 sm:p-4",onMouseDown:t=>{t.currentTarget===t.target&&e()},children:d.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"AI 飞书替身",className:"ui-dialog flex h-[min(860px,calc(100dvh-2rem))] w-full max-w-[1120px] flex-col overflow-hidden rounded-[14px] border border-zinc-200 bg-white shadow-xl",children:[d.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-100 px-4 py-3",children:[d.jsx("h2",{className:"text-[16px] font-semibold text-zinc-900",children:"AI 飞书替身"}),d.jsx("button",{type:"button","aria-label":"关闭 AI 飞书替身",onClick:e,className:"grid h-8 w-8 place-items-center rounded-lg text-zinc-500 hover:bg-zinc-100",children:d.jsx(Wn,{size:15})})]}),d.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:d.jsx(cme,{})})]})})}function _Le({session:e,size:t=12}){return Ka.has(e.state)&&e.state!=="waiting_for_permission"?d.jsx(_i,{size:t,"aria-label":Ym[e.state],className:`shrink-0 animate-spin ${N1e[e.state]??"text-zinc-400"}`}):d.jsx("span",{"aria-label":Ym[e.state],className:`h-1.5 w-1.5 shrink-0 rounded-full ${ej[e.state]??"bg-zinc-400"}`})}function CLe({session:e,agent:t,botName:n,parentLabel:r,active:i,drag:s,noteOf:o,onClick:a}){const l=JE(e),c=!!YE(e),u=(t==null?void 0:t.name)??e.agentId,h=lc(e,t==null?void 0:t.name),f=d.jsx(g3e,{session:e,agentName:u,botName:n,parentLabel:r,now:new Date}),p=Ka.has(e.state)||e.state==="failed",g=p?d.jsx(_Le,{session:e,size:12}):d.jsx("span",{className:"text-[12px] tabular-nums text-zinc-400 transition-opacity group-hover:opacity-0 max-md:hidden",children:d1e(Gm(e))}),x=d.jsxs("div",{onClick:a,role:"button",tabIndex:0,onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),a())},...(s==null?void 0:s.props)??{},className:`group relative flex h-[34px] w-full cursor-pointer items-center gap-2 rounded-lg px-2 text-left transition-colors ${i?"bg-zinc-100 text-zinc-900":"text-zinc-700 hover:bg-zinc-100/60"} ${s!=null&&s.dragging?"opacity-40":""} ${s!=null&&s.over?"ring-1 ring-zinc-300":""}`,children:[l?d.jsx(ol,{size:12,"aria-label":"定时任务会话",className:"shrink-0 text-zinc-400"}):o?d.jsx(Wb,{size:12,"aria-label":`${o}派出的便签`,className:"shrink-0 text-amber-600/80"}):c?d.jsx(Bb,{size:12,"aria-label":"侧边会话",className:"shrink-0 text-zinc-400"}):null,d.jsx(o1e,{session:e,label:h,nameClassName:"min-w-0 flex-1 truncate text-[14px]",editButtonVisible:!p}),d.jsx("span",{className:"flex shrink-0 items-center justify-end",children:g})]});return d.jsx(rn,{content:f,side:"right",align:"start",hoverOnly:!0,children:x})}function kLe(){var Re,Q,Ge,qe,$t,Gt,Qt,Yt;const e=Ln(),{primarySessionId:t,setSession:n,openTab:r,closeTab:i,activateTab:s,renameTab:o,restoreFromUrl:a,togglePane:l}=Js(),c=Js(Y=>Y.tabs),u=m.useMemo(()=>c.filter(Y=>Y.ownerSessionId===t),[c,t]),h=Js(Y=>Y.paneOpen),f=Js(Y=>Y.activeTabId),p=u.find(Y=>Y.id===f),[g,x]=m.useState();yr("agentdock:web-access-denied",Y=>{x(Y.detail),e.cancelQueries({predicate:g1e})},{target:()=>window});const[v,b]=m.useState(!1),[y,w]=m.useState(new Set),[S,C]=m.useState(new Set),[_,k]=m.useState("all"),j=r1e(),z=Et({queryKey:["agents"],queryFn:()=>we.agents(),enabled:!g}),N=Et({queryKey:["sessions"],queryFn:we.sessions,enabled:!g,refetchInterval:g?!1:2e3,refetchIntervalInBackground:!0}),I=Et({queryKey:["lark-config"],queryFn:we.larkConfig,enabled:!g,refetchInterval:g?!1:5e3});Et({queryKey:["system-capabilities"],queryFn:we.systemCapabilities,enabled:!g});const $=Hy(!g),R=()=>{const Y=window.location.pathname.match(/^\/sessions\/([^/]+)$/),Ae=Y!=null&&Y[1]?decodeURIComponent(Y[1]):void 0,et=t1e(window.location.search,Ae);if(!et||!Ae){a(Ae);return}if(et.kind==="session"){et.sessionId&&a(Ae,dk(Ae,et.sessionId,et.sessionId));return}a(Ae,{id:`${et.kind}:${Ae}`,kind:et.kind,anchorSessionId:Ae,title:et.kind==="terminal"?"终端":et.kind==="files"?"文件":"原始日志"})};Db(R),yr("popstate",R),Pu(()=>{window.history.replaceState(null,"",e1e(t,h?p:void 0))},[t,f,u,h]);const E=m.useMemo(()=>[...N.data??[]].sort((Y,Ae)=>Gm(Ae).localeCompare(Gm(Y))),[N.data]),M=m.useMemo(()=>E.filter(Y=>{var Ae,et;return Y.id!==((Ae=$.data)==null?void 0:Ae.mainSessionId)&&!Y.archivedAt&&(_==="all"||_==="local"?_==="all"||Y.source!=="lark":Y.source==="lark"&&((et=Y.sourceId)==null?void 0:et.startsWith(`${_}:`)))}),[E,_,(Re=$.data)==null?void 0:Re.mainSessionId]),P=m.useMemo(()=>E.filter(Y=>Y.archivedAt),[E]),A=m.useMemo(()=>l1e(M,z.data??[]),[M,z.data]),D=((Q=$.data)==null?void 0:Q.mainSessionId)??void 0,[F,O]=th("agentdock:sidebar-item-order",{defaultValue:NP}),B=m.useMemo(()=>sv(F),[F]),V=m.useMemo(()=>Vw(A,B.workspaces,Y=>Y.cwd).map(Y=>({...Y,agents:Vw(Y.agents,B.agents[Y.cwd],Ae=>Ae.agentId).map(Ae=>({...Ae,sessions:Vw(Ae.sessions,B.sessions[`${Y.cwd}\0${Ae.agentId}`],et=>et.id)}))})),[A,B]),T=m.useMemo(()=>!h1e(A,V),[A,V]),[W,L]=th("agentdock:sidebar-grouping",{defaultValue:"time"}),q=W==="project"?"project":"time",X=m.useRef(null),J=bn(()=>{zt.getState().setHomeTarget("new"),n(void 0),Te(!1),b(!1),Se(void 0),requestAnimationFrame(()=>{var Y;return(Y=X.current)==null?void 0:Y.focus()})}),ae=bn(()=>{b(!1),xr("search")});yr("keydown",Y=>{(Y.metaKey||Y.ctrlKey)&&Y.key.toLowerCase()==="k"&&(Y.preventDefault(),ae())});const ne=Y=>w(Ae=>{const et=new Set(Ae);return et.has(Y)?et.delete(Y):et.add(Y),et}),re=Y=>C(Ae=>{const et=new Set(Ae);return et.has(Y)?et.delete(Y):et.add(Y),et}),ie=m.useRef(!1);Pu(()=>{ie.current||!A.length||(ie.current=!0,w(new Set(A.slice(1).map(Y=>Y.cwd))))},[A]);const G=E.find(Y=>Y.id===t);p1e(G?lc(G,(qe=(Ge=z.data)==null?void 0:Ge.find(Y=>Y.id===G.agentId))==null?void 0:qe.name):void 0);const oe=Y=>{n(Y),b(!1),Se(void 0)},ge=Y=>{var et,Tt;if(!t||Y===t)return;const Ae=E.find(dt=>dt.id===Y);Ae&&r(dk(t,Y,lc(Ae,(Tt=(et=z.data)==null?void 0:et.find(dt=>dt.id===Ae.agentId))==null?void 0:Tt.name)),t)};Pu(()=>{var Y,Ae;for(const et of c){if(et.kind!=="session"&&et.kind!=="side-chat")continue;const Tt=E.find(dt=>dt.id===et.sessionId);Tt&&o(et.id,lc(Tt,(Ae=(Y=z.data)==null?void 0:Y.find(dt=>dt.id===Tt.agentId))==null?void 0:Ae.name))}},[c,E,z.data]);const U=bn(Y=>{t&&r({id:`raw:${Y}`,kind:"raw",anchorSessionId:Y,title:Y===t?"原始日志":"侧边日志"},t)}),ce=bn(Y=>{if(Se(void 0),!!t){if(Y==="raw"){const Ae=u.find(et=>et.id===f);U((Ae==null?void 0:Ae.sessionId)??(Ae==null?void 0:Ae.anchorSessionId)??t);return}if(Y==="terminal"||Y==="files"){r({id:`${Y}:${t}`,kind:Y,anchorSessionId:t,title:Y==="terminal"?"终端":"文件"});return}G&&ve.mutate(G)}}),ve=yt({mutationFn:async Y=>we.create({agentId:Y.agentId,cwd:Y.cwd,systemPrompt:_ye(Y.id),source:Q9,sourceId:Y.id}),onSuccess:(Y,Ae)=>{e.invalidateQueries({queryKey:["sessions"]}),r({id:`side-chat:${Y.id}`,kind:"side-chat",sessionId:Y.id,title:"侧边聊天"},Ae.id)},onError:Y=>at(Y instanceof Error?Y.message:String(Y))}),fe=[{key:"t",label:Bw("t"),description:"终端",run:()=>ce("terminal")},{key:"s",shift:!0,label:Bw("s",!0),description:"侧边聊天",run:()=>ce("side-chat")},{key:"p",label:Bw("p"),description:"文件",run:()=>ce("files")}];Sye(fe);const[Ce,Pe]=th("agentdock:sidebar-width",{defaultValue:268}),[Ie,Te]=th("agentdock:sidebar-collapsed",{defaultValue:!1}),[de,Le]=m.useState(),[te,me]=m.useState(),[_e,$e]=m.useState(!1),xe=m.useRef({x:0,width:268}),Ze=Math.min(480,Math.max(200,Ce??268));yr("pointermove",Y=>{if(!_e)return;const Ae=Math.min(560,Math.max(140,xe.current.width+(Y.clientX-xe.current.x)));Pe(Ae)},{target:()=>document,enable:_e}),yr("pointerup",()=>{_e&&($e(!1),(Ce??268)<180&&Te(!0))},{target:()=>document,enable:_e});const[le,Me]=m.useState(null),[pe,ye]=m.useState(),[Ee,Se]=m.useState(),[De,at]=m.useState(),xt=yt({mutationFn:({agentId:Y,cwd:Ae})=>we.create({agentId:Y,cwd:Ae}),onMutate:Y=>ye(Y),onSuccess:Y=>{e.invalidateQueries({queryKey:["sessions"]}),ye(void 0),Me(null),oe(Y.id)},onError:()=>ye(void 0)}),Mt=bn(()=>{zt.getState().requestAdoption(),n(void 0),b(!1),Se(void 0)}),rt=bn(Y=>{const Ae=Y??D;if(!Ae){Mt();return}if(zt.getState().closeDrawer(),t===Ae){b(!1);return}mwe(()=>oe(Ae))}),nt=bn((Y,Ae="auto")=>{if(!Y.sessionId){zt.getState().openDrawer({highlight:Y.id});return}const et=E.find(dt=>dt.id===Y.sessionId);if((Ae==="pane"||Ae==="auto"&&!!t&&t===D)&&t&&et&&Y.sessionId!==t){ge(Y.sessionId);return}oe(Y.sessionId)}),Qe=bn(()=>{b(!1),xr("assistant")}),tt=bn(Y=>{zt.getState().closeDrawer(),oe(Y)}),ft=m.useMemo(()=>({openMain:rt,openTask:nt,goAdopt:Mt,openSettings:Qe,openSession:tt}),[rt,nt,Mt,Qe,tt]),ue=G?G.id===D?"main":"session":"home";if(g)return d.jsx(x1e,{denied:g});const Oe=(Y,Ae,et,Tt)=>{const dt=(de==null?void 0:de.scope)===Y&&de.id===Ae,At=(te==null?void 0:te.scope)===Y&&te.id===Ae;return{dragging:dt,over:At,props:{draggable:!0,onDragStart:He=>{Le({scope:Y,id:Ae,...Tt?{sessionId:Tt}:{}}),He.dataTransfer.effectAllowed="move"},onDragEnd:()=>{Le(void 0),me(void 0)},onDragOver:He=>{!de||de.scope!==Y||de.id===Ae||(He.preventDefault(),He.dataTransfer.dropEffect="move",me(it=>(it==null?void 0:it.scope)===Y&&it.id===Ae?it:{scope:Y,id:Ae}))},onDragLeave:()=>me(He=>(He==null?void 0:He.scope)===Y&&He.id===Ae?void 0:He),onDrop:He=>{He.preventDefault(),de&&de.scope===Y&&de.id!==Ae&&et(de.id,Ae),Le(void 0),me(void 0)}}}},ke=Y=>({dragging:(de==null?void 0:de.scope)==="session-pane"&&de.id===Y,over:!1,props:{draggable:!0,onDragStart:Ae=>{Le({scope:"session-pane",id:Y,sessionId:Y}),Ae.dataTransfer.effectAllowed="copy"},onDragEnd:()=>{Le(void 0),me(void 0)}}}),pt=(Y,Ae)=>O(et=>{const Tt=V.map(dt=>dt.cwd);return{...sv(et),workspaces:Hw(Tt,Y,Ae)}}),mt=(Y,Ae,et)=>O(Tt=>{var He;const dt=(((He=V.find(it=>it.cwd===Y))==null?void 0:He.agents)??[]).map(it=>it.agentId),At=sv(Tt);return{...At,agents:{...At.agents,[Y]:Hw(dt,Ae,et)}}}),Ye=(Y,Ae,et)=>O(Tt=>{var jt,St;const[dt,At]=Y.split("\0"),He=(((St=(jt=V.find(It=>It.cwd===dt))==null?void 0:jt.agents.find(It=>It.agentId===At))==null?void 0:St.sessions)??[]).map(It=>It.id),it=sv(Tt);return{...it,sessions:{...it.sessions,[Y]:Hw(He,Ae,et)}}}),ze=(Y,Ae)=>{var dt,At,He,it,jt,St,It,Rn,Tn;const et=Y.sourceId?E.find(Sn=>Sn.id===Y.sourceId):void 0,Tt=D&&Zwe(Y.sourceId,D,(At=(dt=$.data)==null?void 0:dt.lifecycle)==null?void 0:At.ancestorSessionIds)&&YE(Y)?((it=(He=$.data)==null?void 0:He.companion)==null?void 0:it.name)??"小猫":void 0;return d.jsx(CLe,{session:Y,drag:Ae,noteOf:Tt,agent:(jt=z.data)==null?void 0:jt.find(Sn=>Sn.id===Y.agentId),botName:(It=(St=I.data)==null?void 0:St.bots.find(Sn=>{var mr;return(mr=Y.sourceId)==null?void 0:mr.startsWith(`${Sn.appId}:`)}))==null?void 0:It.name,parentLabel:et?lc(et,(Tn=(Rn=z.data)==null?void 0:Rn.find(Sn=>Sn.id===et.agentId))==null?void 0:Tn.name):void 0,active:t===Y.id||u.some(Sn=>(Sn.kind==="session"||Sn.kind==="side-chat")&&Sn.sessionId===Y.id),onClick:()=>oe(Y.id)},Y.id)};return d.jsx(spe,{children:d.jsx(Rwe,{value:ft,children:d.jsxs("div",{ref:j,className:"ui-shell relative flex h-full overflow-hidden bg-canvas font-sans text-zinc-900",children:[v&&d.jsx("button",{type:"button","aria-label":"关闭会话列表",onClick:()=>b(!1),className:"ui-overlay fixed inset-0 z-40 bg-zinc-950/20 md:hidden"}),d.jsxs("aside",{style:{"--sb-w":`${Ze}px`},className:`ui-sidebar-safe fixed inset-y-0 left-0 z-50 flex shrink-0 flex-col overflow-hidden border-r border-zinc-200 bg-rail shadow-[12px_0_36px_rgba(24,24,27,.08)] transition-transform duration-300 ease-[cubic-bezier(.16,1,.3,1)] w-[286px] md:static md:z-20 md:translate-x-0 md:shadow-none ${v?"translate-x-0":"-translate-x-full"} ${Ie?"md:w-11":"md:w-[var(--sb-w)]"}`,children:[!Ie&&d.jsx("div",{onPointerDown:Y=>{Y.preventDefault(),xe.current={x:Y.clientX,width:Ze},$e(!0)},title:"拖拽调整宽度,拖到最窄可收起",className:"absolute inset-y-0 right-0 z-20 hidden w-1.5 cursor-col-resize touch-none bg-transparent hover:bg-blue-400/30 md:block"}),d.jsxs("div",{className:`flex h-full flex-col ${Ie?"md:hidden":""}`,children:[d.jsx("div",{className:"flex min-w-[268px] items-center pr-3",children:d.jsxs("button",{type:"button",onClick:()=>{n(void 0),b(!1),Se(void 0)},title:"回到首页","aria-label":"回到首页",className:"flex h-14 min-w-0 flex-1 items-center gap-2.5 px-4 text-left transition-colors hover:bg-zinc-100/70 active:bg-zinc-200/60",children:[d.jsx(vLe,{className:"h-7 w-7 shrink-0"}),d.jsx("span",{className:"text-sm font-semibold tracking-[-.02em]",children:"AgentDock"})]})}),d.jsxs("div",{className:"flex min-w-[268px] flex-col gap-1 px-2.5",children:[d.jsxs("button",{onClick:J,"aria-label":"新建对话",className:"flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-[14px] font-medium text-zinc-700 transition-colors hover:bg-zinc-100 active:bg-zinc-200/60",children:[d.jsx(sa,{size:16}),"新建对话"]}),d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsxs("button",{type:"button",onClick:ae,"aria-label":"搜索会话(⌘K)",className:"flex h-9 min-w-0 flex-1 items-center gap-2 rounded-lg border border-zinc-200 bg-white px-2.5 text-[13px] text-zinc-500 transition-colors hover:border-zinc-300 hover:text-zinc-700",children:[d.jsx(fa,{size:14,className:"shrink-0"}),"搜索会话",d.jsx("span",{className:"ml-auto shrink-0 rounded border border-zinc-200 bg-zinc-50 px-1 py-0.5 font-sans text-[12px] leading-none text-zinc-400",children:"⌘K"})]}),d.jsx(s1e,{compact:!0,value:_,bots:(($t=I.data)==null?void 0:$t.bots)??[],agents:z.data??[],onChange:k})]})]}),d.jsx("div",{className:"mt-3 min-w-[268px] px-2",children:d.jsx(W3e,{active:!!D&&t===D})}),d.jsxs("div",{className:"mt-3 flex min-w-[268px] items-center justify-between pl-3.5 pr-2",children:[d.jsx("span",{className:"text-[12px] font-medium text-zinc-500",children:"会话列表"}),d.jsxs("div",{className:"flex items-center gap-1",children:[q==="project"&&T&&d.jsx("button",{type:"button",title:"恢复默认排序(按最近对话时间)",onClick:()=>O(NP),className:"grid h-6 w-6 place-items-center rounded text-zinc-400 transition-colors hover:bg-zinc-100 hover:text-zinc-700",children:d.jsx(Cf,{size:12})}),d.jsx("div",{className:"flex rounded-md bg-zinc-100 p-0.5",children:["time","project"].map(Y=>d.jsx("button",{type:"button",onClick:()=>L(Y),"aria-pressed":q===Y,className:`h-6 rounded-[5px] px-2 text-[12px] font-medium transition-colors ${q===Y?"bg-white text-zinc-900 shadow-[0_1px_2px_rgba(0,0,0,.06)]":"text-zinc-500 hover:text-zinc-700"}`,children:Y==="time"?"时间":"项目"},Y))})]})]}),_!=="all"&&d.jsx("div",{className:"mt-1 flex min-w-[268px] items-center gap-1.5 px-3.5",children:d.jsxs("div",{className:"flex h-6 min-w-0 flex-1 items-center gap-1 rounded-md bg-zinc-100 px-2 text-[12px] text-zinc-600",children:[d.jsxs("span",{className:"min-w-0 flex-1 truncate",children:["来源:",_==="local"?"本地":`飞书 · ${((Qt=(Gt=I.data)==null?void 0:Gt.bots.find(Y=>Y.appId===_))==null?void 0:Qt.name)??"机器人"}`]}),d.jsx("button",{type:"button","aria-label":"清除来源筛选",onClick:()=>k("all"),className:"grid h-4 w-4 shrink-0 place-items-center rounded text-zinc-400 transition-colors hover:bg-zinc-200 hover:text-zinc-700",children:d.jsx(Wn,{size:12})})]})}),d.jsx("div",{className:"mt-1 flex min-h-0 min-w-[268px] flex-1 flex-col px-2",children:N.isLoading?d.jsxs("div",{className:"space-y-1 px-2 pt-1",children:[d.jsx("div",{className:"h-[34px] ui-skeleton rounded-lg bg-zinc-200/70"}),d.jsx("div",{className:"h-[34px] ui-skeleton rounded-lg bg-zinc-200/50"}),d.jsx("div",{className:"h-[34px] ui-skeleton rounded-lg bg-zinc-200/40"})]}):M.length?d.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto pb-2",children:q==="time"?u1e(M).map(Y=>d.jsxs("section",{className:"mb-2",children:[d.jsx("div",{className:"flex h-7 items-center px-2 text-[12px] font-medium text-zinc-400",children:Y.label}),Y.sessions.map(Ae=>ze(Ae,ke(Ae.id)))]},Y.key)):V.map(Y=>{const Ae=y.has(Y.cwd),et=Oe("workspaces",Y.cwd,pt),Tt=Y.agents.reduce((dt,At)=>dt+At.sessions.filter(He=>Ka.has(He.state)).length,0);return d.jsxs("div",{className:"mb-0.5",children:[d.jsxs("div",{role:"button",tabIndex:0,...et.props,onClick:()=>ne(Y.cwd),onKeyDown:dt=>{(dt.key==="Enter"||dt.key===" ")&&(dt.preventDefault(),ne(Y.cwd))},title:`${Y.cwd}(拖拽可换位)`,className:`group sticky top-0 z-[1] flex h-7 w-full cursor-pointer items-center gap-1.5 rounded-lg bg-rail pl-2 pr-1 text-left transition-opacity hover:bg-zinc-100/70 ${et.dragging?"opacity-40":""} ${et.over?"ring-1 ring-zinc-300":""}`,children:[Ae?d.jsx(ao,{size:12,className:"shrink-0 text-zinc-400"}):d.jsx(cs,{size:12,className:"shrink-0 text-zinc-400"}),d.jsx(_f,{size:12,className:"shrink-0 text-zinc-400"}),d.jsx(EH,{content:Y.cwd,className:"min-w-0 flex-1 truncate text-[12px] font-medium text-zinc-600",children:Y.label}),Tt>0&&d.jsx("span",{className:"ui-status-pulse h-1.5 w-1.5 shrink-0 rounded-full bg-blue-500"}),d.jsx("span",{role:"button",tabIndex:-1,onClick:dt=>{dt.stopPropagation();const At=dt.currentTarget.getBoundingClientRect();Me({cwd:Y.cwd,top:At.bottom+4,left:Math.min(At.left,window.innerWidth-224)})},className:"grid h-5 w-5 shrink-0 place-items-center rounded text-zinc-400 opacity-0 transition-opacity hover:bg-zinc-200 hover:text-zinc-800 focus:opacity-100 group-hover:opacity-100 max-md:opacity-100",children:d.jsx(sa,{size:12})}),d.jsx(l$,{size:11,className:"shrink-0 cursor-grab text-zinc-300 opacity-0 transition-opacity group-hover:opacity-100"}),d.jsx("span",{className:"shrink-0 text-[12px] tabular-nums text-zinc-400",children:Y.agents.reduce((dt,At)=>dt+At.sessions.length,0)})]}),!Ae&&d.jsx("div",{className:"ml-1.5 border-l border-zinc-200 pl-1",children:Y.agents.map(dt=>{const At=`${Y.cwd}\0${dt.agentId}`,He=S.has(At),it=Oe(`agents:${Y.cwd}`,dt.agentId,(St,It)=>mt(Y.cwd,St,It)),jt=dt.sessions.some(St=>Ka.has(St.state));return d.jsxs("div",{className:"group/agent",children:[d.jsxs("div",{role:"button",tabIndex:0,...it.props,onClick:()=>re(At),onKeyDown:St=>{(St.key==="Enter"||St.key===" ")&&(St.preventDefault(),re(At))},title:He?`展开 ${dt.agentName}(拖拽可换位)`:`收起 ${dt.agentName}(拖拽可换位)`,className:`flex h-7 w-full cursor-pointer items-center gap-1 rounded-lg px-2 text-left text-[12px] text-zinc-500 transition-opacity hover:bg-zinc-100/70 hover:text-zinc-700 ${it.dragging?"opacity-40":""} ${it.over?"ring-1 ring-zinc-300":""}`,children:[He?d.jsx(ao,{size:11,className:"shrink-0"}):d.jsx(cs,{size:11,className:"shrink-0"}),d.jsx(Hr,{agentId:dt.agentId,agentName:dt.agentName,size:12}),d.jsx("span",{className:"min-w-0 flex-1 truncate",children:dt.agentName}),jt&&!He&&d.jsx("span",{className:"ui-status-pulse h-1.5 w-1.5 shrink-0 rounded-full bg-blue-500"}),d.jsx("button",{type:"button",title:`用 ${dt.agentName} 在此工作区新建会话`,disabled:!!pe,onClick:St=>{St.stopPropagation(),xt.mutate({agentId:dt.agentId,cwd:Y.cwd})},className:"grid h-4 w-4 shrink-0 place-items-center rounded opacity-0 transition-opacity hover:bg-zinc-200 hover:text-zinc-800 focus:opacity-100 group-hover/agent:opacity-100 max-md:opacity-100 disabled:opacity-50",children:(pe==null?void 0:pe.agentId)===dt.agentId&&pe.cwd===Y.cwd?d.jsx(Hn,{size:10,className:"animate-spin"}):d.jsx(sa,{size:10})}),d.jsx(l$,{size:10,className:"shrink-0 cursor-grab text-zinc-300 opacity-0 transition-opacity group-hover/agent:opacity-100"}),d.jsx("span",{className:"shrink-0 tabular-nums",children:dt.sessions.length})]}),!He&&d.jsx("div",{className:"ml-1.5 border-l border-zinc-200 pl-1",children:dt.sessions.map(St=>d.jsxs("div",{children:[ze(St,Oe(`sessions:${At}`,St.id,(It,Rn)=>Ye(At,It,Rn),St.id)),(dt.sideChats.get(St.id)??[]).map(It=>ze(It,ke(It.id)))]},St.id))})]},`${Y.cwd}:${dt.agentId}`)})})]},Y.cwd)})}):d.jsx("div",{className:"px-3 py-6 text-xs leading-5 text-zinc-500",children:"当前分类暂无会话。"})}),d.jsx(Dpe,{webDenied:!!g,archivedCount:P.length,onSchedule:()=>{b(!1),xr("schedule")},onArchived:()=>{b(!1),xr("archived")},onImport:()=>{b(!1),xr("import")},onAgentConfig:()=>{b(!1),xr("agent")},onAssistant:Qe,onLark:()=>{b(!1),xr("lark")},onLarkAvatar:()=>{b(!1),xr("lark-avatar")},onShare:()=>{b(!1),xr("share")}})]}),d.jsxs("div",{className:`hidden h-full w-full flex-col items-center gap-1 py-3 ${Ie?"md:flex":""}`,children:[d.jsx(rn,{content:"展开会话列表",children:d.jsx("button",{type:"button",onClick:()=>Te(!1),"aria-label":"展开会话列表",className:"grid h-8 w-8 place-items-center rounded-lg text-zinc-600 hover:bg-white hover:text-zinc-900",children:d.jsx(QZ,{size:16})})}),d.jsx(rn,{content:"新建对话",children:d.jsx("button",{type:"button",onClick:J,"aria-label":"新建对话",className:"grid h-8 w-8 place-items-center rounded-lg text-zinc-600 hover:bg-white hover:text-zinc-900",children:d.jsx(sa,{size:16})})}),d.jsx(rn,{content:"搜索会话(⌘K)",children:d.jsx("button",{type:"button",onClick:ae,"aria-label":"搜索会话",className:"grid h-8 w-8 place-items-center rounded-lg text-zinc-600 hover:bg-white hover:text-zinc-900",children:d.jsx(fa,{size:16})})}),d.jsx(q3e,{}),d.jsxs("span",{className:"mt-auto flex flex-col items-center gap-1",children:[d.jsx(rn,{content:"定时任务",children:d.jsx("button",{type:"button",onClick:()=>xr("schedule"),"aria-label":"定时任务",className:"grid h-8 w-8 place-items-center rounded-lg text-zinc-500 hover:bg-white hover:text-zinc-900",children:d.jsx(ol,{size:15})})}),d.jsx(rn,{content:"归档会话",children:d.jsx("button",{type:"button",onClick:()=>xr("archived"),"aria-label":"归档会话",className:"grid h-8 w-8 place-items-center rounded-lg text-zinc-500 hover:bg-white hover:text-zinc-900",children:d.jsx(Sf,{size:15})})}),d.jsx(rn,{content:"导入外部会话",children:d.jsx("button",{type:"button",onClick:()=>{Te(!1),xr("import")},"aria-label":"导入外部会话",className:"grid h-8 w-8 place-items-center rounded-lg text-zinc-500 hover:bg-white hover:text-zinc-900",children:d.jsx(ha,{size:15})})}),d.jsx(rn,{content:"Agent 设置",children:d.jsx("button",{type:"button",onClick:()=>{Te(!1),xr("agent")},"aria-label":"Agent 设置",className:"grid h-8 w-8 place-items-center rounded-lg text-zinc-500 hover:bg-white hover:text-zinc-900",children:d.jsx(ti,{size:15})})}),d.jsx(rn,{content:"飞书设置",children:d.jsx("button",{type:"button",onClick:()=>{Te(!1),xr("lark")},"aria-label":"飞书设置",className:"grid h-8 w-8 place-items-center rounded-lg text-zinc-500 hover:bg-white hover:text-zinc-900",children:d.jsx(Hb,{size:15})})}),d.jsx(rn,{content:"在手机上打开",children:d.jsx("button",{type:"button",onClick:()=>xr("share"),"aria-label":"在手机上打开",className:"grid h-8 w-8 place-items-center rounded-lg text-zinc-500 hover:bg-white hover:text-zinc-900",children:d.jsx($L,{size:15})})})]})]})]}),d.jsx("main",{className:"flex min-w-0 flex-1 bg-canvas",children:G?d.jsxs(d.Fragment,{children:[d.jsx("div",{className:`flex min-w-0 flex-1 ${h?"max-lg:hidden":""}`,children:d.jsx(ID,{session:G,agent:(Yt=z.data)==null?void 0:Yt.find(Y=>Y.id===G.agentId),pane:"primary",onOpenSidebar:()=>b(!0),paneOpen:h,onTogglePane:()=>{Se(void 0),l()}},`primary:${G.id}`)}),(h||c.length>0)&&d.jsx(xye,{tabs:u,mountedTabs:c,activeTabId:f,visible:h,shortcuts:fe,acceptsDrop:!!(de!=null&&de.sessionId),onDropSession:()=>{const Y=de==null?void 0:de.sessionId;Le(void 0),me(void 0),Y&&ge(Y)},onActivate:s,onClose:i,onAdd:Y=>Se(Y),onPick:ce,onHide:()=>{Se(void 0),l()},children:Object.fromEntries(c.map(Y=>{var Ae;return[Y.id,Y.kind==="terminal"?d.jsx(R4e,{sessionId:Y.anchorSessionId??G.id,sshHost:(E.find(et=>et.id===Y.anchorSessionId)??G).sshHost},Y.id):Y.kind==="files"?d.jsx(P4e,{sessionId:Y.anchorSessionId??G.id,cwd:((Ae=E.find(et=>et.id===Y.anchorSessionId))==null?void 0:Ae.cwd)??G.cwd,initialPath:Y.filePath,disabledReason:(E.find(et=>et.id===Y.anchorSessionId)??G).sshHost?`SSH 远端会话(${(E.find(et=>et.id===Y.anchorSessionId)??G).sshHost})暂不支持文件浏览;终端面板可以直接连到远端。`:void 0},Y.id):Y.kind==="raw"?d.jsx(a3e,{sessionId:Y.anchorSessionId??G.id,active:h&&Y.id===f},Y.id):(()=>{var Tt;const et=E.find(dt=>dt.id===Y.sessionId);return et?d.jsx(ID,{session:et,agent:(Tt=z.data)==null?void 0:Tt.find(dt=>dt.id===et.agentId),pane:"secondary",onOpenSidebar:()=>b(!0),onOpenRawLog:U},Y.id):d.jsx("div",{className:"grid h-full place-items-center text-[12px] text-zinc-400",children:"会话已不存在。"})})()]}))}),(de==null?void 0:de.sessionId)&&!h&&d.jsx("div",{onDragOver:Y=>Y.preventDefault(),onDrop:Y=>{Y.preventDefault();const Ae=de==null?void 0:de.sessionId;Le(void 0),me(void 0),Ae&&ge(Ae)},className:"fixed inset-y-0 right-0 z-40 flex w-20 items-center justify-center border-l-2 border-dashed border-zinc-400 bg-zinc-900/5",children:d.jsx("span",{className:"text-[12px] font-medium text-zinc-600 [writing-mode:vertical-rl]",children:"放到这里,在副屏打开"})})]}):d.jsxs("div",{className:"ui-page relative flex flex-1 justify-center overflow-y-auto px-4 sm:px-8",children:[d.jsx("span",{className:"absolute left-[max(0.75rem,env(safe-area-inset-left))] top-[max(0.75rem,env(safe-area-inset-top))] md:hidden",children:d.jsx($o,{label:"打开会话列表",onClick:()=>b(!0),children:d.jsx(G3,{size:17})})}),d.jsx(pLe,{editorRef:X,agents:z.data??[],sessions:N.data??[],onCreated:Y=>oe(Y.id)})]})}),Ee&&d.jsx(mye,{anchor:Ee,shortcuts:fe,onPick:ce,onClose:()=>Se(void 0)}),De&&d.jsxs("div",{className:"fixed bottom-4 left-1/2 z-50 -translate-x-1/2 rounded-lg border border-red-200 bg-red-50 px-3.5 py-2 text-[12px] text-red-700 shadow-[0_12px_32px_rgba(24,24,27,.12)]",children:[d.jsx("button",{type:"button",onClick:()=>at(void 0),className:"mr-2 font-medium underline",children:"关闭"}),De]}),d.jsx(gY,{dialogs:{lark:d.jsx(wLe,{agents:z.data??[],onClose:Ni}),"lark-avatar":d.jsx(SLe,{onClose:Ni}),agent:d.jsx(k1e,{onClose:Ni}),assistant:d.jsx(rSe,{onClose:Ni,onOpenMain:()=>{Ni(),rt()},onAdopt:()=>{Ni(),Mt()},onOpenSession:Y=>{Ni(),oe(Y)}}),schedule:Y=>d.jsx(Jye,{...Y?{session:E.find(Ae=>Ae.id===Y)}:{},sessions:E,onClose:Ni,onOpenSession:oe}),handover:Y=>{var et;const Ae=Y?E.find(Tt=>Tt.id===Y):void 0;return Ae?d.jsx(lSe,{session:Ae,agent:(et=z.data)==null?void 0:et.find(Tt=>Tt.id===Ae.agentId),onClose:Ni}):null},"system-prompt":Y=>{const Ae=Y?E.find(et=>et.id===Y):void 0;return Ae!=null&&Ae.systemPrompt?d.jsx(gSe,{session:Ae,onClose:Ni}):null},share:d.jsx(ySe,{onClose:Ni}),archived:d.jsx(Qye,{sessions:P,agents:z.data??[],onClose:Ni,onOpenSession:Y=>{Ni(),oe(Y)}}),import:d.jsx(mSe,{agents:z.data??[],onClose:Ni,onImported:Y=>oe(Y.id)}),search:d.jsx(m1e,{agents:z.data??[],sessions:N.data??[],onClose:Ni,onOpen:Y=>{Ni(),oe(Y.id)}})}}),le&&d.jsx(xLe,{cwd:le.cwd,top:le.top,left:le.left,agents:z.data??[],creatingPair:pe,onSelect:Y=>xt.mutate({agentId:Y,cwd:le.cwd}),onClose:()=>Me(null)}),d.jsx(V3e,{view:ue})]})})})}const SG=new eY({defaultOptions:{queries:{retry:(e,t)=>!(t instanceof Ub)&&e<3}}});SG.setQueryDefaults(["events"],{structuralSharing:!1,gcTime:6e4,staleTime:3e4});CG.createRoot(document.getElementById("root")).render(d.jsx(m.StrictMode,{children:d.jsx(jG,{client:SG,children:d.jsx(jpe,{children:d.jsx(kLe,{})})})}));if(new URLSearchParams(window.location.search).get("vvdebug")==="1"&&window.visualViewport){const e=window.visualViewport,t=document.createElement("div");t.style.cssText="position:fixed;top:0;left:0;right:0;z-index:99999;margin:0;padding:6px 8px;font:11px/1.5 ui-monospace,Menlo,monospace;background:rgba(0,0,0,.78);color:#7CFC9A;pointer-events:none;white-space:pre-wrap;word-break:break-all",document.body.appendChild(t);const n=()=>`${(window.innerHeight/100).toFixed(1)}dvh?`,r=()=>{var i;t.textContent=[`vv.h=${Math.round(e.height)} offTop=${Math.round(e.offsetTop)} scale=${e.scale} w=${Math.round(e.width)}`,`innerH=${window.innerHeight} innerW=${window.innerWidth} dpr=${window.devicePixelRatio}`,`dvh100≈${n()} apply=${Math.abs(e.scale-1)<=.01}`,`docH=${document.documentElement.clientHeight} ua=${((i=navigator.userAgent.match(/OS [0-9_]+/))==null?void 0:i[0])??""}`].join(`
1119
1119
  `)};r(),e.addEventListener("resize",r),e.addEventListener("scroll",r)}export{Bg as E,vh as M,fN as P,Gn as S,Lo as a,Ic as b,we as c,g$e as k,Ai as r,wb as s};