@sciol/xyzen 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,7 +7,7 @@ Xyzen 是一个现代化、轻量级且可扩展的 React 聊天组件。它提
7
7
  使用 yarn 或 npm 安装 Xyzen:
8
8
 
9
9
  ```bash
10
- yarn add @sciol/xyzen
10
+ yarn add @sciol/xyzen@latest
11
11
  ```
12
12
 
13
13
  或者
package/dist/xyzen.es.js CHANGED
@@ -952,7 +952,9 @@ class Js {
952
952
  async getAuthStatus() {
953
953
  console.log("AuthService: 检查认证服务状态...");
954
954
  try {
955
- const t = await fetch(`${Lc()}/api/v1/auth/status`);
955
+ const t = await fetch(
956
+ `${Lc()}/xyzen-api/v1/auth/status`
957
+ );
956
958
  if (!t.ok)
957
959
  throw console.error(`AuthService: 认证状态检查失败,HTTP ${t.status}`), new Error(`HTTP error! status: ${t.status}`);
958
960
  const n = await t.json();
@@ -977,13 +979,16 @@ class Js {
977
979
  `AuthService: 准备验证token (前20字符): ${n.substring(0, 20)}...`
978
980
  );
979
981
  try {
980
- const r = await fetch(`${Lc()}/api/v1/auth/validate`, {
981
- method: "POST",
982
- headers: {
983
- Authorization: `Bearer ${n}`,
984
- "Content-Type": "application/json"
982
+ const r = await fetch(
983
+ `${Lc()}/xyzen-api/v1/auth/validate`,
984
+ {
985
+ method: "POST",
986
+ headers: {
987
+ Authorization: `Bearer ${n}`,
988
+ "Content-Type": "application/json"
989
+ }
985
990
  }
986
- });
991
+ );
987
992
  if (console.log(`AuthService: token验证响应状态: ${r.status}`), !r.ok)
988
993
  throw r.status === 401 && (console.log("AuthService: token无效,移除本地存储"), this.removeToken()), new Error(`HTTP error! status: ${r.status}`);
989
994
  const a = await r.json();
@@ -1002,7 +1007,7 @@ class Js {
1002
1007
  if (!t)
1003
1008
  return null;
1004
1009
  try {
1005
- const n = await fetch(`${Lc()}/api/v1/auth/me`, {
1010
+ const n = await fetch(`${Lc()}/xyzen-api/v1/auth/me`, {
1006
1011
  headers: {
1007
1012
  Authorization: `Bearer ${t}`
1008
1013
  }
@@ -1092,7 +1097,7 @@ const tn = new Js(), El = () => {
1092
1097
  fetchAgents: async () => {
1093
1098
  e({ agentsLoading: !0 });
1094
1099
  try {
1095
- const n = await fetch(`${t().backendUrl}/api/v1/agents/`, {
1100
+ const n = await fetch(`${t().backendUrl}/xyzen-api/v1/agents/`, {
1096
1101
  headers: El()
1097
1102
  });
1098
1103
  if (!n.ok)
@@ -1105,7 +1110,7 @@ const tn = new Js(), El = () => {
1105
1110
  },
1106
1111
  createAgent: async (n) => {
1107
1112
  try {
1108
- const r = await fetch(`${t().backendUrl}/api/v1/agents/`, {
1113
+ const r = await fetch(`${t().backendUrl}/xyzen-api/v1/agents/`, {
1109
1114
  method: "POST",
1110
1115
  headers: El(),
1111
1116
  body: JSON.stringify(n)
@@ -1122,7 +1127,7 @@ const tn = new Js(), El = () => {
1122
1127
  updateAgent: async (n) => {
1123
1128
  try {
1124
1129
  const r = await fetch(
1125
- `${t().backendUrl}/api/v1/agents/${n.id}`,
1130
+ `${t().backendUrl}/xyzen-api/v1/agents/${n.id}`,
1126
1131
  {
1127
1132
  method: "PATCH",
1128
1133
  headers: El(),
@@ -1140,10 +1145,13 @@ const tn = new Js(), El = () => {
1140
1145
  },
1141
1146
  deleteAgent: async (n) => {
1142
1147
  try {
1143
- const r = await fetch(`${t().backendUrl}/api/v1/agents/${n}`, {
1144
- method: "DELETE",
1145
- headers: El()
1146
- });
1148
+ const r = await fetch(
1149
+ `${t().backendUrl}/xyzen-api/v1/agents/${n}`,
1150
+ {
1151
+ method: "DELETE",
1152
+ headers: El()
1153
+ }
1154
+ );
1147
1155
  if (!r.ok) {
1148
1156
  const a = await r.text();
1149
1157
  throw new Error(`Failed to delete agent: ${a}`);
@@ -1228,7 +1236,7 @@ class FO {
1228
1236
  const o = `${this.backendUrl.replace(
1229
1237
  /^http(s?):\/\//,
1230
1238
  "ws$1://"
1231
- )}/ws/v1/chat/sessions/${t}/topics/${n}?token=${encodeURIComponent(s)}`;
1239
+ )}/xyzen-ws/v1/chat/sessions/${t}/topics/${n}?token=${encodeURIComponent(s)}`;
1232
1240
  this.ws = new WebSocket(o), this.ws.onopen = () => {
1233
1241
  console.log("XyzenService: WebSocket connected"), this.onStatusChangeCallback?.({ connected: !0, error: null });
1234
1242
  }, this.ws.onmessage = (l) => {
@@ -1283,9 +1291,12 @@ const oi = new FO(), BO = (e, t) => ({
1283
1291
  Authorization: `Bearer ${r}`
1284
1292
  };
1285
1293
  console.log("ChatSlice: Making request to sessions API...");
1286
- const i = await fetch(`${t().backendUrl}/api/v1/sessions/`, {
1287
- headers: a
1288
- });
1294
+ const i = await fetch(
1295
+ `${t().backendUrl}/xyzen-api/v1/sessions/`,
1296
+ {
1297
+ headers: a
1298
+ }
1299
+ );
1289
1300
  if (console.log(
1290
1301
  `ChatSlice: Sessions API response status: ${i.status}`
1291
1302
  ), !i.ok) {
@@ -1357,7 +1368,7 @@ const oi = new FO(), BO = (e, t) => ({
1357
1368
  "Content-Type": "application/json"
1358
1369
  };
1359
1370
  l && (u.Authorization = `Bearer ${l}`);
1360
- const c = await fetch(`${s}/api/v1/sessions/`, {
1371
+ const c = await fetch(`${s}/xyzen-api/v1/sessions/`, {
1361
1372
  headers: u
1362
1373
  });
1363
1374
  if (!c.ok) throw new Error("Failed to fetch sessions");
@@ -1409,7 +1420,7 @@ const oi = new FO(), BO = (e, t) => ({
1409
1420
  };
1410
1421
  c && (d.Authorization = `Bearer ${c}`);
1411
1422
  const p = await fetch(
1412
- `${s}/api/v1/topics/${n}/messages`,
1423
+ `${s}/xyzen-api/v1/topics/${n}/messages`,
1413
1424
  { headers: d }
1414
1425
  );
1415
1426
  if (p.ok) {
@@ -1610,12 +1621,12 @@ const oi = new FO(), BO = (e, t) => ({
1610
1621
  };
1611
1622
  try {
1612
1623
  const l = await fetch(
1613
- `${t().backendUrl}/api/v1/sessions/by-agent/${r}`,
1624
+ `${t().backendUrl}/xyzen-api/v1/sessions/by-agent/${r}`,
1614
1625
  { headers: i }
1615
1626
  );
1616
1627
  if (l.ok) {
1617
1628
  const u = await l.json(), c = await fetch(
1618
- `${t().backendUrl}/api/v1/topics/`,
1629
+ `${t().backendUrl}/xyzen-api/v1/topics/`,
1619
1630
  {
1620
1631
  method: "POST",
1621
1632
  headers: i,
@@ -1651,14 +1662,17 @@ const oi = new FO(), BO = (e, t) => ({
1651
1662
  } catch {
1652
1663
  console.log("No existing session found, creating new session");
1653
1664
  }
1654
- const s = await fetch(`${t().backendUrl}/api/v1/sessions/`, {
1655
- method: "POST",
1656
- headers: i,
1657
- body: JSON.stringify({
1658
- name: "New Session",
1659
- agent_id: n
1660
- })
1661
- });
1665
+ const s = await fetch(
1666
+ `${t().backendUrl}/xyzen-api/v1/sessions/`,
1667
+ {
1668
+ method: "POST",
1669
+ headers: i,
1670
+ body: JSON.stringify({
1671
+ name: "New Session",
1672
+ agent_id: n
1673
+ })
1674
+ }
1675
+ );
1662
1676
  if (!s.ok)
1663
1677
  throw new Error("Failed to create new session with default topic");
1664
1678
  const o = await s.json();
@@ -1699,7 +1713,7 @@ const oi = new FO(), BO = (e, t) => ({
1699
1713
  Authorization: `Bearer ${a}`
1700
1714
  };
1701
1715
  if (!(await fetch(
1702
- `${t().backendUrl}/api/v1/topics/${n}`,
1716
+ `${t().backendUrl}/xyzen-api/v1/topics/${n}`,
1703
1717
  {
1704
1718
  method: "PUT",
1705
1719
  headers: i,
@@ -1768,7 +1782,7 @@ const oi = new FO(), BO = (e, t) => ({
1768
1782
  return t && (e.Authorization = `Bearer ${t}`), e;
1769
1783
  }, Fs = {
1770
1784
  async getMcpServers() {
1771
- const e = await fetch(`${Ms()}/api/v1/mcps`, {
1785
+ const e = await fetch(`${Ms()}/xyzen-api/v1/mcps`, {
1772
1786
  headers: Ps()
1773
1787
  });
1774
1788
  if (!e.ok)
@@ -1776,7 +1790,7 @@ const oi = new FO(), BO = (e, t) => ({
1776
1790
  return e.json();
1777
1791
  },
1778
1792
  async createMcpServer(e) {
1779
- const t = await fetch(`${Ms()}/api/v1/mcps`, {
1793
+ const t = await fetch(`${Ms()}/xyzen-api/v1/mcps`, {
1780
1794
  method: "POST",
1781
1795
  headers: Ps(),
1782
1796
  body: JSON.stringify(e)
@@ -1790,7 +1804,7 @@ const oi = new FO(), BO = (e, t) => ({
1790
1804
  return t.json();
1791
1805
  },
1792
1806
  async updateMcpServer(e, t) {
1793
- const n = await fetch(`${Ms()}/api/v1/mcps/${e}`, {
1807
+ const n = await fetch(`${Ms()}/xyzen-api/v1/mcps/${e}`, {
1794
1808
  method: "PATCH",
1795
1809
  headers: Ps(),
1796
1810
  body: JSON.stringify(t)
@@ -1804,7 +1818,7 @@ const oi = new FO(), BO = (e, t) => ({
1804
1818
  return n.json();
1805
1819
  },
1806
1820
  async deleteMcpServer(e) {
1807
- const t = await fetch(`${Ms()}/api/v1/mcps/${e}`, {
1821
+ const t = await fetch(`${Ms()}/xyzen-api/v1/mcps/${e}`, {
1808
1822
  method: "DELETE",
1809
1823
  headers: Ps()
1810
1824
  });
@@ -1816,10 +1830,13 @@ const oi = new FO(), BO = (e, t) => ({
1816
1830
  }
1817
1831
  },
1818
1832
  async refreshMcpServers() {
1819
- const e = await fetch(`${Ms()}/api/v1/mcps/refresh`, {
1820
- method: "POST",
1821
- headers: Ps()
1822
- });
1833
+ const e = await fetch(
1834
+ `${Ms()}/xyzen-api/v1/mcps/refresh`,
1835
+ {
1836
+ method: "POST",
1837
+ headers: Ps()
1838
+ }
1839
+ );
1823
1840
  if (!e.ok) {
1824
1841
  const t = await e.text();
1825
1842
  throw new Error(
@@ -1957,7 +1974,7 @@ class zO {
1957
1974
  }
1958
1975
  async getLlmProviders() {
1959
1976
  const t = await fetch(
1960
- `${this.getBackendUrl()}/api/v1/llm-providers/`
1977
+ `${this.getBackendUrl()}/xyzen-api/v1/llm-providers/`
1961
1978
  );
1962
1979
  if (!t.ok)
1963
1980
  throw new Error("Failed to fetch LLM providers");
@@ -1965,7 +1982,7 @@ class zO {
1965
1982
  }
1966
1983
  async createLlmProvider(t) {
1967
1984
  const n = await fetch(
1968
- `${this.getBackendUrl()}/api/v1/llm-providers/`,
1985
+ `${this.getBackendUrl()}/xyzen-api/v1/llm-providers/`,
1969
1986
  {
1970
1987
  method: "POST",
1971
1988
  headers: {
@@ -1982,7 +1999,7 @@ class zO {
1982
1999
  }
1983
2000
  async getLlmProvider(t) {
1984
2001
  const n = await fetch(
1985
- `${this.getBackendUrl()}/api/v1/llm-providers/${t}`
2002
+ `${this.getBackendUrl()}/xyzen-api/v1/llm-providers/${t}`
1986
2003
  );
1987
2004
  if (!n.ok)
1988
2005
  throw new Error("Failed to fetch LLM provider");
@@ -1990,7 +2007,7 @@ class zO {
1990
2007
  }
1991
2008
  async updateLlmProvider(t, n) {
1992
2009
  const r = await fetch(
1993
- `${this.getBackendUrl()}/api/v1/llm-providers/${t}`,
2010
+ `${this.getBackendUrl()}/xyzen-api/v1/llm-providers/${t}`,
1994
2011
  {
1995
2012
  method: "PUT",
1996
2013
  headers: {
@@ -2007,7 +2024,7 @@ class zO {
2007
2024
  }
2008
2025
  async deleteLlmProvider(t) {
2009
2026
  const n = await fetch(
2010
- `${this.getBackendUrl()}/api/v1/llm-providers/${t}`,
2027
+ `${this.getBackendUrl()}/xyzen-api/v1/llm-providers/${t}`,
2011
2028
  {
2012
2029
  method: "DELETE"
2013
2030
  }
@@ -2019,7 +2036,7 @@ class zO {
2019
2036
  }
2020
2037
  async switchActiveProvider(t) {
2021
2038
  const n = await fetch(
2022
- `${this.getBackendUrl()}/api/v1/llm-providers/switch`,
2039
+ `${this.getBackendUrl()}/xyzen-api/v1/llm-providers/switch`,
2023
2040
  {
2024
2041
  method: "POST",
2025
2042
  headers: {
@@ -2036,7 +2053,7 @@ class zO {
2036
2053
  }
2037
2054
  async getSupportedTypes() {
2038
2055
  const t = await fetch(
2039
- `${this.getBackendUrl()}/api/v1/llm-providers/supported-types/`
2056
+ `${this.getBackendUrl()}/xyzen-api/v1/llm-providers/supported-types/`
2040
2057
  );
2041
2058
  if (!t.ok)
2042
2059
  throw new Error("Failed to fetch supported provider types");
@@ -12360,7 +12377,7 @@ const WU = ({
12360
12377
  f(!0), d(null);
12361
12378
  try {
12362
12379
  const _ = Date.now(), A = await fetch(
12363
- `${s}/api/v1/mcps/${n.id}/tools/${r}/test`,
12380
+ `${s}/xyzen-api/v1/mcps/${n.id}/tools/${r}/test`,
12364
12381
  {
12365
12382
  method: "POST",
12366
12383
  headers: {
@@ -12774,7 +12791,7 @@ function QU() {
12774
12791
  };
12775
12792
  Ce(() => {
12776
12793
  if (i)
12777
- return t(), AT.connect("/ws/v1/mcp", (m) => {
12794
+ return t(), AT.connect("/xyzen-ws/v1/mcp", (m) => {
12778
12795
  a(m);
12779
12796
  }), () => {
12780
12797
  AT.disconnect();
package/dist/xyzen.umd.js CHANGED
@@ -19,7 +19,7 @@
19
19
  <%s {...props} />
20
20
  React keys must be passed directly to JSX without using spread:
21
21
  let props = %s;
22
- <%s key={someKey} {...props} />`,O,Le,Xe,Le),fe[Le+O]=!0)}if(Le=null,ne!==void 0&&(n(ne),Le=""+ne),s(X)&&(n(X.key),Le=""+X.key),"key"in X){ne={};for(var Ve in X)Ve!=="key"&&(ne[Ve]=X[Ve])}else ne=X;return Le&&o(ne,typeof C=="function"?C.displayName||C.name||"Unknown":C),u(C,Le,we,Te,a(),ne,Ae,Re)}function d(C){typeof C=="object"&&C!==null&&C.$$typeof===f&&C._store&&(C._store.validated=1)}var p=v,f=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),g=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),T=Symbol.for("react.profiler"),y=Symbol.for("react.consumer"),w=Symbol.for("react.context"),k=Symbol.for("react.forward_ref"),_=Symbol.for("react.suspense"),A=Symbol.for("react.suspense_list"),R=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),P=Symbol.for("react.activity"),D=Symbol.for("react.client.reference"),z=p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V=Object.prototype.hasOwnProperty,W=Array.isArray,K=console.createTask?console.createTask:function(){return null};p={"react-stack-bottom-frame":function(C){return C()}};var te,ge={},ue=p["react-stack-bottom-frame"].bind(p,i)(),ee=K(r(i)),fe={};_s.Fragment=g,_s.jsx=function(C,X,ne,O,Te){var we=1e4>z.recentlyCreatedOwnerStacks++;return c(C,X,ne,!1,O,Te,we?Error("react-stack-top-frame"):ue,we?K(r(C)):ee)},_s.jsxs=function(C,X,ne,O,Te){var we=1e4>z.recentlyCreatedOwnerStacks++;return c(C,X,ne,!0,O,Te,we?Error("react-stack-top-frame"):ue,we?K(r(C)):ee)}}()),_s}var cy;function OR(){return cy||(cy=1,process.env.NODE_ENV==="production"?sl.exports=IR():sl.exports=RR()),sl.exports}var b=OR();const dy=e=>{let t;const n=new Set,r=(u,c)=>{const d=typeof u=="function"?u(t):u;if(!Object.is(d,t)){const p=t;t=c??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(f=>f(t,p))}},a=()=>t,o={setState:r,getState:a,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u))},l=t=e(r,a,o);return o},LR=e=>e?dy(e):dy,DR=e=>e;function MR(e,t=DR){const n=v.useSyncExternalStore(e.subscribe,()=>t(e.getState()),()=>t(e.getInitialState()));return v.useDebugValue(n),n}const py=e=>{const t=LR(e),n=r=>MR(t,r);return Object.assign(n,t),n},PR=e=>e?py(e):py;function fy(e,t){let n;try{n=e()}catch{return}return{getItem:a=>{var i;const s=l=>l===null?null:JSON.parse(l,void 0),o=(i=n.getItem(a))!=null?i:null;return o instanceof Promise?o.then(s):s(o)},setItem:(a,i)=>n.setItem(a,JSON.stringify(i,void 0)),removeItem:a=>n.removeItem(a)}}const yc=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return yc(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return yc(r)(n)}}}},FR=(e,t)=>(n,r,a)=>{let i={storage:fy(()=>localStorage),partialize:g=>g,version:0,merge:(g,x)=>({...x,...g}),...t},s=!1;const o=new Set,l=new Set;let u=i.storage;if(!u)return e((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...g)},r,a);const c=()=>{const g=i.partialize({...r()});return u.setItem(i.name,{state:g,version:i.version})},d=a.setState;a.setState=(g,x)=>{d(g,x),c()};const p=e((...g)=>{n(...g),c()},r,a);a.getInitialState=()=>p;let f;const m=()=>{var g,x;if(!u)return;s=!1,o.forEach(y=>{var w;return y((w=r())!=null?w:p)});const T=((x=i.onRehydrateStorage)==null?void 0:x.call(i,(g=r())!=null?g:p))||void 0;return yc(u.getItem.bind(u))(i.name).then(y=>{if(y)if(typeof y.version=="number"&&y.version!==i.version){if(i.migrate){const w=i.migrate(y.state,y.version);return w instanceof Promise?w.then(k=>[!0,k]):[!0,w]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,y.state];return[!1,void 0]}).then(y=>{var w;const[k,_]=y;if(f=i.merge(_,(w=r())!=null?w:p),n(f,!0),k)return c()}).then(()=>{T?.(f,void 0),f=r(),s=!0,l.forEach(y=>y(f))}).catch(y=>{T?.(void 0,y)})};return a.persist={setOptions:g=>{i={...i,...g},g.storage&&(u=g.storage)},clearStorage:()=>{u?.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>m(),hasHydrated:()=>s,onHydrate:g=>(o.add(g),()=>{o.delete(g)}),onFinishHydration:g=>(l.add(g),()=>{l.delete(g)})},i.skipHydration||m(),f||p};var hy=Symbol.for("immer-nothing"),my=Symbol.for("immer-draftable"),qn=Symbol.for("immer-state"),BR=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function On(e,...t){if(process.env.NODE_ENV!=="production"){const n=BR[e],r=typeof n=="function"?n.apply(null,t):n;throw new Error(`[Immer] ${r}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var _i=Object.getPrototypeOf;function ki(e){return!!e&&!!e[qn]}function Ka(e){return e?gy(e)||Array.isArray(e)||!!e[my]||!!e.constructor?.[my]||ul(e)||cl(e):!1}var UR=Object.prototype.constructor.toString();function gy(e){if(!e||typeof e!="object")return!1;const t=_i(e);if(t===null)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===UR}function ol(e,t){ll(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function ll(e){const t=e[qn];return t?t.type_:Array.isArray(e)?1:ul(e)?2:cl(e)?3:0}function vc(e,t){return ll(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function by(e,t,n){const r=ll(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function HR(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function ul(e){return e instanceof Map}function cl(e){return e instanceof Set}function Xa(e){return e.copy_||e.base_}function Tc(e,t){if(ul(e))return new Map(e);if(cl(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=gy(e);if(t===!0||t==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(e);delete r[qn];let a=Reflect.ownKeys(r);for(let i=0;i<a.length;i++){const s=a[i],o=r[s];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[s]={configurable:!0,writable:!0,enumerable:o.enumerable,value:e[s]})}return Object.create(_i(e),r)}else{const r=_i(e);if(r!==null&&n)return{...e};const a=Object.create(r);return Object.assign(a,e)}}function Sc(e,t=!1){return dl(e)||ki(e)||!Ka(e)||(ll(e)>1&&(e.set=e.add=e.clear=e.delete=$R),Object.freeze(e),t&&Object.entries(e).forEach(([n,r])=>Sc(r,!0))),e}function $R(){On(2)}function dl(e){return Object.isFrozen(e)}var zR={};function Za(e){const t=zR[e];return t||On(0,e),t}var ks;function Ey(){return ks}function qR(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function yy(e,t){t&&(Za("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function xc(e){wc(e),e.drafts_.forEach(jR),e.drafts_=null}function wc(e){e===ks&&(ks=e.parent_)}function vy(e){return ks=qR(ks,e)}function jR(e){const t=e[qn];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Ty(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[qn].modified_&&(xc(t),On(4)),Ka(e)&&(e=pl(t,e),t.parent_||fl(t,e)),t.patches_&&Za("Patches").generateReplacementPatches_(n[qn].base_,e,t.patches_,t.inversePatches_)):e=pl(t,n,[]),xc(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==hy?e:void 0}function pl(e,t,n){if(dl(t))return t;const r=t[qn];if(!r)return ol(t,(a,i)=>Sy(e,r,t,a,i,n)),t;if(r.scope_!==e)return t;if(!r.modified_)return fl(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const a=r.copy_;let i=a,s=!1;r.type_===3&&(i=new Set(a),a.clear(),s=!0),ol(i,(o,l)=>Sy(e,r,a,o,l,n,s)),fl(e,a,!1),n&&e.patches_&&Za("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function Sy(e,t,n,r,a,i,s){if(process.env.NODE_ENV!=="production"&&a===n&&On(5),ki(a)){const o=i&&t&&t.type_!==3&&!vc(t.assigned_,r)?i.concat(r):void 0,l=pl(e,a,o);if(by(n,r,l),ki(l))e.canAutoFreeze_=!1;else return}else s&&n.add(a);if(Ka(a)&&!dl(a)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;pl(e,a),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,r)&&fl(e,a)}}function fl(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Sc(t,n)}function GR(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:Ey(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let a=r,i=Ac;n&&(a=[r],i=Ns);const{revoke:s,proxy:o}=Proxy.revocable(a,i);return r.draft_=o,r.revoke_=s,o}var Ac={get(e,t){if(t===qn)return e;const n=Xa(e);if(!vc(n,t))return VR(e,n,t);const r=n[t];return e.finalized_||!Ka(r)?r:r===_c(e.base_,t)?(Nc(e),e.copy_[t]=Cc(r,e)):r},has(e,t){return t in Xa(e)},ownKeys(e){return Reflect.ownKeys(Xa(e))},set(e,t,n){const r=xy(Xa(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const a=_c(Xa(e),t),i=a?.[qn];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(HR(n,a)&&(n!==void 0||vc(e.base_,t)))return!0;Nc(e),kc(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return _c(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Nc(e),kc(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Xa(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){On(11)},getPrototypeOf(e){return _i(e.base_)},setPrototypeOf(){On(12)}},Ns={};ol(Ac,(e,t)=>{Ns[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),Ns.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&On(13),Ns.set.call(this,e,t,void 0)},Ns.set=function(e,t,n){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&On(14),Ac.set.call(this,e[0],t,n,e[0])};function _c(e,t){const n=e[qn];return(n?Xa(n):e)[t]}function VR(e,t,n){const r=xy(t,n);return r?"value"in r?r.value:r.get?.call(e.draft_):void 0}function xy(e,t){if(!(t in e))return;let n=_i(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=_i(n)}}function kc(e){e.modified_||(e.modified_=!0,e.parent_&&kc(e.parent_))}function Nc(e){e.copy_||(e.copy_=Tc(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var WR=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const i=n;n=t;const s=this;return function(l=i,...u){return s.produce(l,c=>n.call(this,c,...u))}}typeof n!="function"&&On(6),r!==void 0&&typeof r!="function"&&On(7);let a;if(Ka(t)){const i=vy(this),s=Cc(t,void 0);let o=!0;try{a=n(s),o=!1}finally{o?xc(i):wc(i)}return yy(i,r),Ty(a,i)}else if(!t||typeof t!="object"){if(a=n(t),a===void 0&&(a=t),a===hy&&(a=void 0),this.autoFreeze_&&Sc(a,!0),r){const i=[],s=[];Za("Patches").generateReplacementPatches_(t,a,i,s),r(i,s)}return a}else On(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(s,...o)=>this.produceWithPatches(s,l=>t(l,...o));let r,a;return[this.produce(t,n,(s,o)=>{r=s,a=o}),r,a]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Ka(e)||On(8),ki(e)&&(e=YR(e));const t=vy(this),n=Cc(e,void 0);return n[qn].isManual_=!0,wc(t),n}finishDraft(e,t){const n=e&&e[qn];(!n||!n.isManual_)&&On(9);const{scope_:r}=n;return yy(r,t),Ty(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const a=t[n];if(a.path.length===0&&a.op==="replace"){e=a.value;break}}n>-1&&(t=t.slice(n+1));const r=Za("Patches").applyPatches_;return ki(e)?r(e,t):this.produce(e,a=>r(a,t))}};function Cc(e,t){const n=ul(e)?Za("MapSet").proxyMap_(e,t):cl(e)?Za("MapSet").proxySet_(e,t):GR(e,t);return(t?t.scope_:Ey()).drafts_.push(n),n}function YR(e){return ki(e)||On(10,e),wy(e)}function wy(e){if(!Ka(e)||dl(e))return e;const t=e[qn];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Tc(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Tc(e,!0);return ol(n,(r,a)=>{by(n,r,wy(a))}),t&&(t.finalized_=!1),n}var jn=new WR,KR=jn.produce;jn.produceWithPatches.bind(jn),jn.setAutoFreeze.bind(jn),jn.setUseStrictShallowCopy.bind(jn),jn.applyPatches.bind(jn),jn.createDraft.bind(jn),jn.finishDraft.bind(jn);const XR=e=>(t,n,r)=>(r.setState=(a,i,...s)=>{const o=typeof a=="function"?KR(a):a;return t(o,i,...s)},e(r.setState,n,r)),Ic=()=>Kt.getState().backendUrl;var Gn=(e=>(e.NOT_CONFIGURED="not_configured",e.NOT_AUTHENTICATED="not_authenticated",e.AUTHENTICATED="authenticated",e.ERROR="error",e))(Gn||{});class Cs{static TOKEN_KEY="access_token";authCheckPromise=null;listeners=[];getToken(){return localStorage.getItem(Cs.TOKEN_KEY)}setToken(t){localStorage.setItem(Cs.TOKEN_KEY,t)}removeToken(){localStorage.removeItem(Cs.TOKEN_KEY)}addAuthStateListener(t){this.listeners.push(t)}removeAuthStateListener(t){const n=this.listeners.indexOf(t);n>-1&&this.listeners.splice(n,1)}notifyListeners(t){this.listeners.forEach(n=>{try{n(t)}catch(r){console.error("Auth listener error:",r)}})}async getAuthStatus(){console.log("AuthService: 检查认证服务状态...");try{const t=await fetch(`${Ic()}/api/v1/auth/status`);if(!t.ok)throw console.error(`AuthService: 认证状态检查失败,HTTP ${t.status}`),new Error(`HTTP error! status: ${t.status}`);const n=await t.json();return console.log("AuthService: 认证状态:",n),n}catch(t){throw console.error("AuthService: 获取认证状态失败:",t),t}}async validateToken(t){const n=t||this.getToken();if(console.log("AuthService: 验证token...",n?"有token":"无token"),!n)return console.log("AuthService: 没有可用的访问令牌"),{success:!1,error_code:"NO_TOKEN",error_message:"No access token available"};console.log(`AuthService: 准备验证token (前20字符): ${n.substring(0,20)}...`);try{const r=await fetch(`${Ic()}/api/v1/auth/validate`,{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"}});if(console.log(`AuthService: token验证响应状态: ${r.status}`),!r.ok)throw r.status===401&&(console.log("AuthService: token无效,移除本地存储"),this.removeToken()),new Error(`HTTP error! status: ${r.status}`);const a=await r.json();return console.log("AuthService: token验证结果:",a),a}catch(r){return console.error("AuthService: token验证失败:",r),{success:!1,error_code:"VALIDATION_ERROR",error_message:r instanceof Error?r.message:"Token validation failed"}}}async getCurrentUser(){const t=this.getToken();if(!t)return null;try{const n=await fetch(`${Ic()}/api/v1/auth/me`,{headers:{Authorization:`Bearer ${t}`}});if(!n.ok)throw n.status===401&&this.removeToken(),new Error(`HTTP error! status: ${n.status}`);return await n.json()}catch(n){return console.error("Failed to get current user:",n),null}}async checkAuthState(t=!1){if(console.log("AuthService: 检查认证状态,force =",t),this.authCheckPromise&&!t)return console.log("AuthService: 返回已存在的认证检查Promise"),this.authCheckPromise;this.authCheckPromise=this._performAuthCheck();const n=await this.authCheckPromise;return console.log("AuthService: 认证检查完成,结果:",n),this.notifyListeners(n),n}async _performAuthCheck(){console.log("AuthService: 开始执行认证检查...");try{console.log("AuthService: 步骤1 - 检查认证服务配置");const t=await this.getAuthStatus();if(!t.is_configured)return console.log("AuthService: 认证服务未配置"),{state:"not_configured",message:t.message};console.log("AuthService: 步骤2 - 检查本地token");const n=this.getToken();if(!n)return console.log("AuthService: 没有本地token"),{state:"not_authenticated",message:"请先登录",provider:t.provider};console.log(`AuthService: 找到本地token (前20字符): ${n.substring(0,20)}...`),console.log("AuthService: 步骤3 - 验证token");const r=await this.validateToken(n);return r.success?(console.log("AuthService: token验证成功,用户信息:",r.user_info),{state:"authenticated",user:r.user_info,message:`已登录 (${t.provider})`,provider:t.provider}):(console.log("AuthService: token验证失败:",r.error_message),{state:"not_authenticated",message:r.error_message||"令牌无效,请重新登录",provider:t.provider})}catch(t){return console.error("AuthService: 认证检查失败:",t),{state:"error",message:t instanceof Error?t.message:"认证检查失败"}}}async autoLogin(){return console.log("Performing auto-login check..."),this.checkAuthState(!0)}async login(t){return this.setToken(t),this.checkAuthState(!0)}logout(){this.removeToken(),this.authCheckPromise=null,this.notifyListeners({state:"not_authenticated",message:"已登出"})}}const $t=new Cs,hl=()=>{const e=$t.getToken(),t={"Content-Type":"application/json"};return e&&(t.Authorization=`Bearer ${e}`),t},ZR=(e,t)=>({agents:[],agentsLoading:!1,fetchAgents:async()=>{e({agentsLoading:!0});try{const n=await fetch(`${t().backendUrl}/api/v1/agents/`,{headers:hl()});if(!n.ok)throw new Error("Failed to fetch agents");const r=await n.json();e({agents:r,agentsLoading:!1})}catch(n){throw console.error("Failed to fetch agents:",n),e({agentsLoading:!1}),n}},createAgent:async n=>{try{const r=await fetch(`${t().backendUrl}/api/v1/agents/`,{method:"POST",headers:hl(),body:JSON.stringify(n)});if(!r.ok){const a=await r.text();throw new Error(`Failed to create agent: ${a}`)}await t().fetchAgents()}catch(r){throw console.error(r),r}},updateAgent:async n=>{try{const r=await fetch(`${t().backendUrl}/api/v1/agents/${n.id}`,{method:"PATCH",headers:hl(),body:JSON.stringify(n)});if(!r.ok){const a=await r.text();throw new Error(`Failed to update agent: ${a}`)}await t().fetchAgents()}catch(r){throw console.error(r),r}},deleteAgent:async n=>{try{const r=await fetch(`${t().backendUrl}/api/v1/agents/${n}`,{method:"DELETE",headers:hl()});if(!r.ok){const a=await r.text();throw new Error(`Failed to delete agent: ${a}`)}await t().fetchAgents()}catch(r){throw console.error(r),r}}}),QR=(e,t)=>({user:null,token:null,status:"idle",login:async n=>{e({status:"loading"});try{const r=await $t.login(n);if(r.state==="authenticated"&&r.user)e({token:n,user:{id:r.user.id,username:r.user.username||r.user.display_name||"Unknown",avatar:r.user.avatar_url||`https://i.pravatar.cc/40?u=${r.user.id}`},status:"succeeded"});else throw new Error(r.message)}catch(r){e({status:"failed"}),console.error("Login failed:",r)}},logout:()=>{$t.logout(),e({user:null,token:null,status:"idle"})},fetchUserByToken:async()=>{const n=$t.getToken();if(n){e({status:"loading"});try{const r=await $t.checkAuthState(!0);r.state==="authenticated"&&r.user?e({token:n,user:{id:r.user.id,username:r.user.username||r.user.display_name||"Unknown",avatar:r.user.avatar_url||`https://i.pravatar.cc/40?u=${r.user.id}`},status:"succeeded"}):(e({status:"failed"}),$t.removeToken())}catch(r){e({status:"failed"}),$t.removeToken(),console.error("Failed to fetch user by token:",r)}}}});class JR{ws=null;onMessageCallback=null;onMessageEventCallback=null;onStatusChangeCallback=null;backendUrl="";setBackendUrl(t){this.backendUrl=t}connect(t,n,r,a,i){if(this.ws&&this.ws.readyState===WebSocket.OPEN){console.log("WebSocket is already connected.");return}this.onMessageCallback=r,this.onMessageEventCallback=i||null,this.onStatusChangeCallback=a;const s=$t.getToken();if(!s){console.error("XyzenService: No authentication token available"),this.onStatusChangeCallback?.({connected:!1,error:"Authentication required"});return}const o=`${this.backendUrl.replace(/^http(s?):\/\//,"ws$1://")}/ws/v1/chat/sessions/${t}/topics/${n}?token=${encodeURIComponent(s)}`;this.ws=new WebSocket(o),this.ws.onopen=()=>{console.log("XyzenService: WebSocket connected"),this.onStatusChangeCallback?.({connected:!0,error:null})},this.ws.onmessage=l=>{try{const u=JSON.parse(l.data);u.type&&this.onMessageEventCallback?this.onMessageEventCallback(u):this.onMessageCallback?.(u)}catch(u){console.error("XyzenService: Failed to parse message data:",u)}},this.ws.onclose=l=>{console.log(`XyzenService: WebSocket disconnected (code: ${l.code}, reason: ${l.reason})`),this.onStatusChangeCallback?.({connected:!1,error:l.reason||"Connection closed."})},this.ws.onerror=l=>{console.error("XyzenService: WebSocket error:",l),this.onStatusChangeCallback?.({connected:!1,error:"A connection error occurred."})}}sendMessage(t){this.ws&&this.ws.readyState===WebSocket.OPEN?this.ws.send(JSON.stringify({message:t})):console.error("XyzenService: WebSocket is not connected.")}sendStructuredMessage(t){this.ws&&this.ws.readyState===WebSocket.OPEN?this.ws.send(JSON.stringify(t)):console.error("XyzenService: WebSocket is not connected.")}disconnect(){this.ws&&(this.ws.close(),this.ws=null)}}const Ea=new JR,eO=(e,t)=>({activeChatChannel:null,chatHistory:[],chatHistoryLoading:!0,channels:{},setActiveChatChannel:n=>e({activeChatChannel:n}),fetchChatHistory:async()=>{const{setLoading:n}=t();n("chatHistory",!0);try{console.log("ChatSlice: Starting to fetch chat history...");const r=$t.getToken();if(!r){console.error("ChatSlice: No authentication token available");return}const a={"Content-Type":"application/json",Authorization:`Bearer ${r}`};console.log("ChatSlice: Making request to sessions API...");const i=await fetch(`${t().backendUrl}/api/v1/sessions/`,{headers:a});if(console.log(`ChatSlice: Sessions API response status: ${i.status}`),!i.ok){const c=await i.text();throw console.error(`ChatSlice: Sessions API error: ${i.status} - ${c}`),new Error(`Failed to fetch chat history: ${i.status} ${c}`)}const s=await i.json();console.log("ChatSlice: Received sessions data:",s);const l={...t().channels},u=s.flatMap(c=>(console.log(`ChatSlice: Processing session ${c.id} with ${c.topics?.length||0} topics`),c.topics?.map(d=>(l[d.id]?l[d.id]={...l[d.id],sessionId:c.id,title:d.name,agentId:c.agent_id}:l[d.id]={id:d.id,sessionId:c.id,title:d.name,messages:[],agentId:c.agent_id,connected:!1,error:null},{id:d.id,title:d.name,updatedAt:d.updated_at,assistantTitle:"通用助理",lastMessage:"",isPinned:!1}))||[]));console.log(`ChatSlice: Processed ${u.length} chat history items`),e({chatHistory:u,channels:l,chatHistoryLoading:!1}),console.log(`ChatSlice: Loaded ${u.length} chat history items, keeping current active channel`)}catch(r){console.error("ChatSlice: Failed to fetch chat history:",r),e({chatHistoryLoading:!1})}finally{n("chatHistory",!1)}},togglePinChat:n=>{e(r=>{const a=r.chatHistory.find(i=>i.id===n);a&&(a.isPinned=!a.isPinned)})},activateChannel:async n=>{const{channels:r,activeChatChannel:a,connectToChannel:i,backendUrl:s}=t();if(n===a&&r[n]?.connected)return;e({activeChatChannel:n});let o=r[n];if(!o)try{const l=$t.getToken(),u={"Content-Type":"application/json"};l&&(u.Authorization=`Bearer ${l}`);const c=await fetch(`${s}/api/v1/sessions/`,{headers:u});if(!c.ok)throw new Error("Failed to fetch sessions");const d=await c.json();let p=null,f=null;for(const m of d){const g=m.topics.find(x=>x.id===n);if(g){p=m.id,f=g.name;break}}if(p&&f)o={id:n,sessionId:p,title:f,messages:[],agentId:void 0,connected:!1,error:null},e(m=>{m.channels[n]=o});else{console.error(`Topic ${n} not found in any session, refetching history...`),await t().fetchChatHistory();const m=t().channels;if(m[n])o=m[n];else{console.error(`Topic ${n} still not found after refetch.`);return}}}catch(l){console.error("Failed to find session for topic:",l);return}if(o){if(o.messages.length===0){const{setLoading:l}=t(),u=`topicMessages-${n}`;l(u,!0);try{const c=$t.getToken(),d={"Content-Type":"application/json"};c&&(d.Authorization=`Bearer ${c}`);const p=await fetch(`${s}/api/v1/topics/${n}/messages`,{headers:d});if(p.ok){const f=await p.json();console.log(`ChatSlice: Loaded ${f.length} messages for topic ${n}`),e(m=>{m.channels[n]&&(m.channels[n].messages=f)})}else{const f=await p.text();console.error(`ChatSlice: Failed to load messages for topic ${n}: ${p.status} ${f}`),(p.status===401||p.status===403)&&console.error("ChatSlice: Authentication/authorization issue loading messages")}}catch(c){console.error("Failed to load topic messages:",c)}finally{l(u,!1)}}i(o.sessionId,o.id)}},connectToChannel:(n,r)=>{Ea.disconnect(),Ea.connect(n,r,a=>{e(i=>{const s=i.channels[r];s&&(s.messages.some(o=>o.id===a.id)||s.messages.push(a))})},a=>{e(i=>{const s=i.channels[r];s&&(s.connected=a.connected,s.error=a.error)})},a=>{e(i=>{const s=i.channels[r];if(s)switch(a.type){case"loading":{const o=`loading-${Date.now()}`;s.messages.findIndex(u=>u.isLoading)===-1&&s.messages.push({id:o,role:"assistant",content:"",created_at:new Date().toISOString(),isLoading:!0,isStreaming:!1});break}case"streaming_start":{const o=s.messages.findIndex(u=>u.isLoading),l=a.data;o!==-1&&(s.messages[o]={...s.messages[o],id:l.id,isLoading:!1,isStreaming:!0,content:""});break}case"streaming_chunk":{const o=a.data,l=s.messages.findIndex(u=>u.id===o.id);if(l!==-1){const u=s.messages[l].content;s.messages[l].content=u+o.content}break}case"streaming_end":{const o=a.data,l=s.messages.findIndex(u=>u.id===o.id);l!==-1&&(s.messages[l]={...s.messages[l],isStreaming:!1,created_at:o.created_at||new Date().toISOString()});break}case"message":{const o=a.data;s.messages.some(l=>l.id===o.id)||s.messages.push(o);break}case"message_saved":{const o=a.data,l=s.messages.findIndex(u=>u.id===o.stream_id);l!==-1&&(s.messages[l]={...s.messages[l],id:o.db_id,created_at:o.created_at});break}case"tool_call_request":{console.log("ChatSlice: Received tool_call_request event:",a.data);const o=a.data,l=s.messages.findIndex(d=>d.isLoading);l!==-1&&s.messages.splice(l,1);const c={id:`tool-call-${o.id}`,role:"assistant",content:"我需要使用工具来帮助回答您的问题。",created_at:new Date().toISOString(),isLoading:!1,isStreaming:!1,toolCalls:[{id:o.id,name:o.name,description:o.description,arguments:o.arguments,status:o.status,timestamp:new Date(o.timestamp).toISOString()}]};s.messages.push(c),console.log(`ChatSlice: Created new tool call message with tool ${o.name}`);break}case"tool_call_response":{console.log("ChatSlice: Received tool_call_response event:",a.data);const o=a.data;let l=!1;s.messages.forEach(u=>{u.toolCalls&&u.toolCalls.forEach(c=>{c.id===o.toolCallId&&(c.status=o.status,o.result&&(c.result=JSON.stringify(o.result)),o.error&&(c.error=o.error),console.log(`ChatSlice: Updated tool call ${c.name} status to ${o.status}`),o.status==="completed"&&(l=!0))})}),l&&(console.log("ChatSlice: Tool completed, creating loading message for AI response"),s.messages.push({id:`loading-${Date.now()}`,role:"assistant",content:"",created_at:new Date().toISOString(),isLoading:!0}));break}case"error":{const o=a.data,l=s.messages.findIndex(u=>u.isLoading);l!==-1&&s.messages.splice(l,1),console.error("Chat error:",o.error);break}}})})},disconnectFromChannel:()=>{Ea.disconnect()},sendMessage:n=>{const{activeChatChannel:r}=t();r&&Ea.sendMessage(n)},createDefaultChannel:async n=>{try{const r=n||"default",a=$t.getToken();if(!a){console.error("No authentication token available");return}const i={"Content-Type":"application/json",Authorization:`Bearer ${a}`};try{const l=await fetch(`${t().backendUrl}/api/v1/sessions/by-agent/${r}`,{headers:i});if(l.ok){const u=await l.json(),c=await fetch(`${t().backendUrl}/api/v1/topics/`,{method:"POST",headers:i,body:JSON.stringify({name:"新的聊天",session_id:u.id})});if(!c.ok)throw new Error("Failed to create new topic in existing session");const d=await c.json(),p={id:d.id,sessionId:u.id,title:d.name,messages:[],agentId:u.agent_id,connected:!1,error:null},f={id:d.id,title:d.name,updatedAt:d.updated_at,assistantTitle:"通用助理",lastMessage:"",isPinned:!1};e(m=>{m.channels[d.id]=p,m.chatHistory.unshift(f),m.activeChatChannel=d.id,m.activeTabIndex=1}),t().connectToChannel(u.id,d.id);return}}catch{console.log("No existing session found, creating new session")}const s=await fetch(`${t().backendUrl}/api/v1/sessions/`,{method:"POST",headers:i,body:JSON.stringify({name:"New Session",agent_id:n})});if(!s.ok)throw new Error("Failed to create new session with default topic");const o=await s.json();if(o.topics&&o.topics.length>0){const l=o.topics[0],u={id:l.id,sessionId:o.id,title:l.name,messages:[],agentId:o.agent_id,connected:!1,error:null},c={id:l.id,title:l.name,updatedAt:l.updated_at,assistantTitle:"通用助理",lastMessage:"",isPinned:!1};e(d=>{d.channels[l.id]=u,d.chatHistory.unshift(c),d.activeChatChannel=l.id,d.activeTabIndex=1}),t().connectToChannel(o.id,l.id)}}catch(r){console.error("Failed to create channel:",r)}},updateTopicName:async(n,r)=>{try{const a=$t.getToken();if(!a){console.error("No authentication token available");return}const i={"Content-Type":"application/json",Authorization:`Bearer ${a}`};if(!(await fetch(`${t().backendUrl}/api/v1/topics/${n}`,{method:"PUT",headers:i,body:JSON.stringify({name:r})})).ok)throw new Error("Failed to update topic name");e(o=>{o.channels[n]&&(o.channels[n].title=r);const l=o.chatHistory.find(u=>u.id===n);l&&(l.title=r)}),console.log(`Topic ${n} name updated to: ${r}`)}catch(a){throw console.error("Failed to update topic name:",a),a}},confirmToolCall:(n,r)=>{Ea.sendStructuredMessage({type:"tool_call_confirm",data:{toolCallId:r}}),e(a=>{a.channels[n]&&a.channels[n].messages.forEach(i=>{i.toolCalls&&i.toolCalls.forEach(s=>{s.id===r&&s.status==="waiting_confirmation"&&(s.status="executing")})})})},cancelToolCall:(n,r)=>{Ea.sendStructuredMessage({type:"tool_call_cancel",data:{toolCallId:r}}),e(a=>{a.channels[n]&&a.channels[n].messages.forEach(i=>{i.toolCalls&&i.toolCalls.forEach(s=>{s.id===r&&s.status==="waiting_confirmation"&&(s.status="failed",s.error="用户取消执行")})})})}}),tO=(e,t)=>({loadingStates:{},setLoading:(n,r)=>{e(a=>{r?a.loadingStates[n]=!0:delete a.loadingStates[n]})},getLoading:n=>t().loadingStates[n]||!1,clearAllLoading:()=>{e(n=>{n.loadingStates={}})}}),Cr={MCP_SERVERS:"mcpServers",MCP_SERVER_CREATE:"mcpServerCreate",MCP_SERVER_UPDATE:"mcpServerUpdate",MCP_SERVER_DELETE:"mcpServerDelete"},Is=()=>Kt.getState().backendUrl,Rs=()=>{const e={"Content-Type":"application/json"},t=$t.getToken();return t&&(e.Authorization=`Bearer ${t}`),e},Os={async getMcpServers(){const e=await fetch(`${Is()}/api/v1/mcps`,{headers:Rs()});if(!e.ok)throw new Error("Failed to fetch MCP servers");return e.json()},async createMcpServer(e){const t=await fetch(`${Is()}/api/v1/mcps`,{method:"POST",headers:Rs(),body:JSON.stringify(e)});if(!t.ok){const n=await t.text();throw new Error(`Failed to create MCP server: ${t.status} ${n}`)}return t.json()},async updateMcpServer(e,t){const n=await fetch(`${Is()}/api/v1/mcps/${e}`,{method:"PATCH",headers:Rs(),body:JSON.stringify(t)});if(!n.ok){const r=await n.text();throw new Error(`Failed to update MCP server: ${n.status} ${r}`)}return n.json()},async deleteMcpServer(e){const t=await fetch(`${Is()}/api/v1/mcps/${e}`,{method:"DELETE",headers:Rs()});if(!t.ok){const n=await t.text();throw new Error(`Failed to delete MCP server: ${t.status} ${n}`)}},async refreshMcpServers(){const e=await fetch(`${Is()}/api/v1/mcps/refresh`,{method:"POST",headers:Rs()});if(!e.ok){const t=await e.text();throw new Error(`Failed to trigger MCP server refresh: ${e.status} ${t}`)}}},nO=(e,t)=>({mcpServers:[],fetchMcpServers:async()=>{const{setLoading:n}=t();n(Cr.MCP_SERVERS,!0);try{console.log("McpSlice: Starting to fetch MCP servers...");const r=await Os.getMcpServers();console.log(`McpSlice: Loaded ${r.length} MCP servers`),e({mcpServers:r})}catch(r){console.error("Failed to fetch MCP servers:",r)}finally{n(Cr.MCP_SERVERS,!1)}},refreshMcpServers:async()=>{const{setLoading:n}=t();n(Cr.MCP_SERVERS,!0);try{await Os.refreshMcpServers(),setTimeout(()=>{t().fetchMcpServers()},1e3)}catch(r){console.error("Failed to refresh MCP servers:",r)}finally{setTimeout(()=>n(Cr.MCP_SERVERS,!1),1500)}},addMcpServer:async n=>{const{setLoading:r}=t();r(Cr.MCP_SERVER_CREATE,!0);try{const a=await Os.createMcpServer(n);e(i=>{i.mcpServers.push(a)}),t().closeAddMcpServerModal()}catch(a){throw console.error("Failed to add MCP server:",a),a}finally{r(Cr.MCP_SERVER_CREATE,!1)}},editMcpServer:async(n,r)=>{const{setLoading:a}=t();a(Cr.MCP_SERVER_UPDATE,!0);try{const i=await Os.updateMcpServer(n,r);e(s=>{const o=s.mcpServers.findIndex(l=>l.id===n);o!==-1&&(s.mcpServers[o]=i)})}catch(i){throw console.error("Failed to edit MCP server:",i),i}finally{a(Cr.MCP_SERVER_UPDATE,!1)}},removeMcpServer:async n=>{const{setLoading:r}=t();r(Cr.MCP_SERVER_DELETE,!0);try{await Os.deleteMcpServer(n),e(a=>{a.mcpServers=a.mcpServers.filter(i=>i.id!==n)})}catch(a){throw console.error("Failed to remove MCP server:",a),a}finally{r(Cr.MCP_SERVER_DELETE,!1)}},updateMcpServerInList:n=>{e(r=>{const a=r.mcpServers.findIndex(i=>i.id===n.id);a!==-1?r.mcpServers[a]=n:r.mcpServers.push(n)})}}),rO=(e,t)=>({toolTestModal:{isOpen:!1},toolExecutionHistory:[],openToolTestModal:(n,r,a)=>{e(i=>{i.toolTestModal={isOpen:!0,server:n,toolName:r,toolDescription:a}})},closeToolTestModal:()=>{e(n=>{n.toolTestModal={isOpen:!1}})},addToolExecution:n=>{e(r=>{const a={...n,id:`${Date.now()}-${Math.random().toString(36).substr(2,9)}`,timestamp:new Date};r.toolExecutionHistory.unshift(a),r.toolExecutionHistory.length>100&&(r.toolExecutionHistory=r.toolExecutionHistory.slice(0,100))})},clearToolExecutionHistory:()=>{e(n=>{n.toolExecutionHistory=[]})},getToolExecutionHistory:(n,r)=>{const{toolExecutionHistory:a}=t();return!n&&!r?a:a.filter(i=>{const s=!n||i.serverId===n,o=!r||i.toolName===r;return s&&o})}});class aO{getBackendUrl(){const{backendUrl:t}=Kt.getState();return t}async getLlmProviders(){const t=await fetch(`${this.getBackendUrl()}/api/v1/llm-providers/`);if(!t.ok)throw new Error("Failed to fetch LLM providers");return t.json()}async createLlmProvider(t){const n=await fetch(`${this.getBackendUrl()}/api/v1/llm-providers/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const r=await n.text();throw new Error(`Failed to create LLM provider: ${r}`)}return n.json()}async getLlmProvider(t){const n=await fetch(`${this.getBackendUrl()}/api/v1/llm-providers/${t}`);if(!n.ok)throw new Error("Failed to fetch LLM provider");return n.json()}async updateLlmProvider(t,n){const r=await fetch(`${this.getBackendUrl()}/api/v1/llm-providers/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok){const a=await r.text();throw new Error(`Failed to update LLM provider: ${a}`)}return r.json()}async deleteLlmProvider(t){const n=await fetch(`${this.getBackendUrl()}/api/v1/llm-providers/${t}`,{method:"DELETE"});if(!n.ok){const r=await n.text();throw new Error(`Failed to delete LLM provider: ${r}`)}}async switchActiveProvider(t){const n=await fetch(`${this.getBackendUrl()}/api/v1/llm-providers/switch`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const r=await n.text();throw new Error(`Failed to switch active provider: ${r}`)}return n.json()}async getSupportedTypes(){const t=await fetch(`${this.getBackendUrl()}/api/v1/llm-providers/supported-types/`);if(!t.ok)throw new Error("Failed to fetch supported provider types");return t.json()}}const Ni=new aO,iO=(e,t)=>({llmProviders:[],llmProvidersLoading:!1,fetchLlmProviders:async()=>{e({llmProvidersLoading:!0});try{const n=await Ni.getLlmProviders();e({llmProviders:n,llmProvidersLoading:!1})}catch(n){console.error("Failed to fetch LLM providers:",n),e({llmProvidersLoading:!1})}},addLlmProvider:async n=>{try{const r=await Ni.createLlmProvider(n);e(a=>{a.llmProviders.push(r)}),t().closeAddLlmProviderModal()}catch(r){throw console.error("Failed to add LLM provider:",r),r}},editLlmProvider:async(n,r)=>{try{const a=await Ni.updateLlmProvider(n,r);e(i=>{const s=i.llmProviders.findIndex(o=>o.id===n);s!==-1&&(i.llmProviders[s]=a)})}catch(a){throw console.error("Failed to edit LLM provider:",a),a}},removeLlmProvider:async n=>{try{await Ni.deleteLlmProvider(n),e(r=>{r.llmProviders=r.llmProviders.filter(a=>a.id!==n)})}catch(r){throw console.error("Failed to remove LLM provider:",r),r}},switchActiveProvider:async n=>{try{await Ni.switchActiveProvider({provider_id:n}),await t().fetchLlmProviders()}catch(r){throw console.error("Failed to switch active provider:",r),r}}}),sO=e=>({backendUrl:"",isXyzenOpen:!1,panelWidth:380,activeTabIndex:0,theme:"system",isAddMcpServerModalOpen:!1,isAddLlmProviderModalOpen:!1,toggleXyzen:()=>e(t=>({isXyzenOpen:!t.isXyzenOpen})),openXyzen:()=>e({isXyzenOpen:!0}),closeXyzen:()=>e({isXyzenOpen:!1}),setPanelWidth:t=>e({panelWidth:t}),setTabIndex:t=>e({activeTabIndex:t}),setTheme:t=>e({theme:t}),setBackendUrl:t=>{e({backendUrl:t}),Ea.setBackendUrl(t)},openAddMcpServerModal:()=>e({isAddMcpServerModalOpen:!0}),closeAddMcpServerModal:()=>e({isAddMcpServerModalOpen:!1}),openAddLlmProviderModal:()=>e({isAddLlmProviderModalOpen:!0}),closeAddLlmProviderModal:()=>e({isAddLlmProviderModalOpen:!1})}),Kt=PR()(FR(XR((...e)=>({...sO(...e),...eO(...e),...ZR(...e),...nO(...e),...rO(...e),...iO(...e),...QR(...e),...tO(...e)})),{name:"xyzen-storage",storage:fy(()=>localStorage),partialize:e=>({isXyzenOpen:e.isXyzenOpen,panelWidth:e.panelWidth,theme:e.theme,token:e.token,user:e.user})})),ml=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ci(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Rc(e){return"nodeType"in e}function Ln(e){var t,n;return e?Ci(e)?e:Rc(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function Oc(e){const{Document:t}=Ln(e);return e instanceof t}function Ls(e){return Ci(e)?!1:e instanceof Ln(e).HTMLElement}function Ay(e){return e instanceof Ln(e).SVGElement}function Ii(e){return e?Ci(e)?e.document:Rc(e)?Oc(e)?e:Ls(e)||Ay(e)?e.ownerDocument:document:document:document}const ya=ml?v.useLayoutEffect:v.useEffect;function Lc(e){const t=v.useRef(e);return ya(()=>{t.current=e}),v.useCallback(function(){for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return t.current==null?void 0:t.current(...r)},[])}function oO(){const e=v.useRef(null),t=v.useCallback((r,a)=>{e.current=setInterval(r,a)},[]),n=v.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Dc(e,t){t===void 0&&(t=[e]);const n=v.useRef(e);return ya(()=>{n.current!==e&&(n.current=e)},t),n}function Ds(e,t){const n=v.useRef();return v.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Mc(e){const t=Lc(e),n=v.useRef(null),r=v.useCallback(a=>{a!==n.current&&t?.(a,n.current),n.current=a},[]);return[n,r]}function Pc(e){const t=v.useRef();return v.useEffect(()=>{t.current=e},[e]),t.current}let Fc={};function Bc(e,t){return v.useMemo(()=>{if(t)return t;const n=Fc[e]==null?0:Fc[e]+1;return Fc[e]=n,e+"-"+n},[e,t])}function _y(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];return r.reduce((i,s)=>{const o=Object.entries(s);for(const[l,u]of o){const c=i[l];c!=null&&(i[l]=c+e*u)}return i},{...t})}}const Ri=_y(1),gl=_y(-1);function lO(e){return"clientX"in e&&"clientY"in e}function ky(e){if(!e)return!1;const{KeyboardEvent:t}=Ln(e.target);return t&&e instanceof t}function uO(e){if(!e)return!1;const{TouchEvent:t}=Ln(e.target);return t&&e instanceof t}function Uc(e){if(uO(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return lO(e)?{x:e.clientX,y:e.clientY}:null}const Ny="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function cO(e){return e.matches(Ny)?e:e.querySelector(Ny)}const dO={display:"none"};function pO(e){let{id:t,value:n}=e;return v.createElement("div",{id:t,style:dO},n)}function fO(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const a={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return v.createElement("div",{id:t,style:a,role:"status","aria-live":r,"aria-atomic":!0},n)}function hO(){const[e,t]=v.useState("");return{announce:v.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const Cy=v.createContext(null);function mO(e){const t=v.useContext(Cy);v.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function gO(){const[e]=v.useState(()=>new Set),t=v.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[v.useCallback(r=>{let{type:a,event:i}=r;e.forEach(s=>{var o;return(o=s[a])==null?void 0:o.call(s,i)})},[e]),t]}const bO={draggable:`
22
+ <%s key={someKey} {...props} />`,O,Le,Xe,Le),fe[Le+O]=!0)}if(Le=null,ne!==void 0&&(n(ne),Le=""+ne),s(X)&&(n(X.key),Le=""+X.key),"key"in X){ne={};for(var Ve in X)Ve!=="key"&&(ne[Ve]=X[Ve])}else ne=X;return Le&&o(ne,typeof C=="function"?C.displayName||C.name||"Unknown":C),u(C,Le,we,Te,a(),ne,Ae,Re)}function d(C){typeof C=="object"&&C!==null&&C.$$typeof===f&&C._store&&(C._store.validated=1)}var p=v,f=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),g=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),T=Symbol.for("react.profiler"),y=Symbol.for("react.consumer"),w=Symbol.for("react.context"),k=Symbol.for("react.forward_ref"),_=Symbol.for("react.suspense"),A=Symbol.for("react.suspense_list"),R=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),P=Symbol.for("react.activity"),D=Symbol.for("react.client.reference"),z=p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V=Object.prototype.hasOwnProperty,W=Array.isArray,K=console.createTask?console.createTask:function(){return null};p={"react-stack-bottom-frame":function(C){return C()}};var te,ge={},ue=p["react-stack-bottom-frame"].bind(p,i)(),ee=K(r(i)),fe={};_s.Fragment=g,_s.jsx=function(C,X,ne,O,Te){var we=1e4>z.recentlyCreatedOwnerStacks++;return c(C,X,ne,!1,O,Te,we?Error("react-stack-top-frame"):ue,we?K(r(C)):ee)},_s.jsxs=function(C,X,ne,O,Te){var we=1e4>z.recentlyCreatedOwnerStacks++;return c(C,X,ne,!0,O,Te,we?Error("react-stack-top-frame"):ue,we?K(r(C)):ee)}}()),_s}var cy;function OR(){return cy||(cy=1,process.env.NODE_ENV==="production"?sl.exports=IR():sl.exports=RR()),sl.exports}var b=OR();const dy=e=>{let t;const n=new Set,r=(u,c)=>{const d=typeof u=="function"?u(t):u;if(!Object.is(d,t)){const p=t;t=c??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(f=>f(t,p))}},a=()=>t,o={setState:r,getState:a,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u))},l=t=e(r,a,o);return o},LR=e=>e?dy(e):dy,DR=e=>e;function MR(e,t=DR){const n=v.useSyncExternalStore(e.subscribe,()=>t(e.getState()),()=>t(e.getInitialState()));return v.useDebugValue(n),n}const py=e=>{const t=LR(e),n=r=>MR(t,r);return Object.assign(n,t),n},PR=e=>e?py(e):py;function fy(e,t){let n;try{n=e()}catch{return}return{getItem:a=>{var i;const s=l=>l===null?null:JSON.parse(l,void 0),o=(i=n.getItem(a))!=null?i:null;return o instanceof Promise?o.then(s):s(o)},setItem:(a,i)=>n.setItem(a,JSON.stringify(i,void 0)),removeItem:a=>n.removeItem(a)}}const yc=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return yc(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return yc(r)(n)}}}},FR=(e,t)=>(n,r,a)=>{let i={storage:fy(()=>localStorage),partialize:g=>g,version:0,merge:(g,x)=>({...x,...g}),...t},s=!1;const o=new Set,l=new Set;let u=i.storage;if(!u)return e((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...g)},r,a);const c=()=>{const g=i.partialize({...r()});return u.setItem(i.name,{state:g,version:i.version})},d=a.setState;a.setState=(g,x)=>{d(g,x),c()};const p=e((...g)=>{n(...g),c()},r,a);a.getInitialState=()=>p;let f;const m=()=>{var g,x;if(!u)return;s=!1,o.forEach(y=>{var w;return y((w=r())!=null?w:p)});const T=((x=i.onRehydrateStorage)==null?void 0:x.call(i,(g=r())!=null?g:p))||void 0;return yc(u.getItem.bind(u))(i.name).then(y=>{if(y)if(typeof y.version=="number"&&y.version!==i.version){if(i.migrate){const w=i.migrate(y.state,y.version);return w instanceof Promise?w.then(k=>[!0,k]):[!0,w]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,y.state];return[!1,void 0]}).then(y=>{var w;const[k,_]=y;if(f=i.merge(_,(w=r())!=null?w:p),n(f,!0),k)return c()}).then(()=>{T?.(f,void 0),f=r(),s=!0,l.forEach(y=>y(f))}).catch(y=>{T?.(void 0,y)})};return a.persist={setOptions:g=>{i={...i,...g},g.storage&&(u=g.storage)},clearStorage:()=>{u?.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>m(),hasHydrated:()=>s,onHydrate:g=>(o.add(g),()=>{o.delete(g)}),onFinishHydration:g=>(l.add(g),()=>{l.delete(g)})},i.skipHydration||m(),f||p};var hy=Symbol.for("immer-nothing"),my=Symbol.for("immer-draftable"),qn=Symbol.for("immer-state"),BR=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function On(e,...t){if(process.env.NODE_ENV!=="production"){const n=BR[e],r=typeof n=="function"?n.apply(null,t):n;throw new Error(`[Immer] ${r}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var _i=Object.getPrototypeOf;function ki(e){return!!e&&!!e[qn]}function Ka(e){return e?gy(e)||Array.isArray(e)||!!e[my]||!!e.constructor?.[my]||ul(e)||cl(e):!1}var UR=Object.prototype.constructor.toString();function gy(e){if(!e||typeof e!="object")return!1;const t=_i(e);if(t===null)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===UR}function ol(e,t){ll(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function ll(e){const t=e[qn];return t?t.type_:Array.isArray(e)?1:ul(e)?2:cl(e)?3:0}function vc(e,t){return ll(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function by(e,t,n){const r=ll(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function HR(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function ul(e){return e instanceof Map}function cl(e){return e instanceof Set}function Xa(e){return e.copy_||e.base_}function Tc(e,t){if(ul(e))return new Map(e);if(cl(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=gy(e);if(t===!0||t==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(e);delete r[qn];let a=Reflect.ownKeys(r);for(let i=0;i<a.length;i++){const s=a[i],o=r[s];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[s]={configurable:!0,writable:!0,enumerable:o.enumerable,value:e[s]})}return Object.create(_i(e),r)}else{const r=_i(e);if(r!==null&&n)return{...e};const a=Object.create(r);return Object.assign(a,e)}}function Sc(e,t=!1){return dl(e)||ki(e)||!Ka(e)||(ll(e)>1&&(e.set=e.add=e.clear=e.delete=$R),Object.freeze(e),t&&Object.entries(e).forEach(([n,r])=>Sc(r,!0))),e}function $R(){On(2)}function dl(e){return Object.isFrozen(e)}var zR={};function Za(e){const t=zR[e];return t||On(0,e),t}var ks;function Ey(){return ks}function qR(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function yy(e,t){t&&(Za("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function xc(e){wc(e),e.drafts_.forEach(jR),e.drafts_=null}function wc(e){e===ks&&(ks=e.parent_)}function vy(e){return ks=qR(ks,e)}function jR(e){const t=e[qn];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Ty(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[qn].modified_&&(xc(t),On(4)),Ka(e)&&(e=pl(t,e),t.parent_||fl(t,e)),t.patches_&&Za("Patches").generateReplacementPatches_(n[qn].base_,e,t.patches_,t.inversePatches_)):e=pl(t,n,[]),xc(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==hy?e:void 0}function pl(e,t,n){if(dl(t))return t;const r=t[qn];if(!r)return ol(t,(a,i)=>Sy(e,r,t,a,i,n)),t;if(r.scope_!==e)return t;if(!r.modified_)return fl(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const a=r.copy_;let i=a,s=!1;r.type_===3&&(i=new Set(a),a.clear(),s=!0),ol(i,(o,l)=>Sy(e,r,a,o,l,n,s)),fl(e,a,!1),n&&e.patches_&&Za("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function Sy(e,t,n,r,a,i,s){if(process.env.NODE_ENV!=="production"&&a===n&&On(5),ki(a)){const o=i&&t&&t.type_!==3&&!vc(t.assigned_,r)?i.concat(r):void 0,l=pl(e,a,o);if(by(n,r,l),ki(l))e.canAutoFreeze_=!1;else return}else s&&n.add(a);if(Ka(a)&&!dl(a)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;pl(e,a),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,r)&&fl(e,a)}}function fl(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Sc(t,n)}function GR(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:Ey(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let a=r,i=Ac;n&&(a=[r],i=Ns);const{revoke:s,proxy:o}=Proxy.revocable(a,i);return r.draft_=o,r.revoke_=s,o}var Ac={get(e,t){if(t===qn)return e;const n=Xa(e);if(!vc(n,t))return VR(e,n,t);const r=n[t];return e.finalized_||!Ka(r)?r:r===_c(e.base_,t)?(Nc(e),e.copy_[t]=Cc(r,e)):r},has(e,t){return t in Xa(e)},ownKeys(e){return Reflect.ownKeys(Xa(e))},set(e,t,n){const r=xy(Xa(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const a=_c(Xa(e),t),i=a?.[qn];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(HR(n,a)&&(n!==void 0||vc(e.base_,t)))return!0;Nc(e),kc(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return _c(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Nc(e),kc(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Xa(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){On(11)},getPrototypeOf(e){return _i(e.base_)},setPrototypeOf(){On(12)}},Ns={};ol(Ac,(e,t)=>{Ns[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),Ns.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&On(13),Ns.set.call(this,e,t,void 0)},Ns.set=function(e,t,n){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&On(14),Ac.set.call(this,e[0],t,n,e[0])};function _c(e,t){const n=e[qn];return(n?Xa(n):e)[t]}function VR(e,t,n){const r=xy(t,n);return r?"value"in r?r.value:r.get?.call(e.draft_):void 0}function xy(e,t){if(!(t in e))return;let n=_i(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=_i(n)}}function kc(e){e.modified_||(e.modified_=!0,e.parent_&&kc(e.parent_))}function Nc(e){e.copy_||(e.copy_=Tc(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var WR=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const i=n;n=t;const s=this;return function(l=i,...u){return s.produce(l,c=>n.call(this,c,...u))}}typeof n!="function"&&On(6),r!==void 0&&typeof r!="function"&&On(7);let a;if(Ka(t)){const i=vy(this),s=Cc(t,void 0);let o=!0;try{a=n(s),o=!1}finally{o?xc(i):wc(i)}return yy(i,r),Ty(a,i)}else if(!t||typeof t!="object"){if(a=n(t),a===void 0&&(a=t),a===hy&&(a=void 0),this.autoFreeze_&&Sc(a,!0),r){const i=[],s=[];Za("Patches").generateReplacementPatches_(t,a,i,s),r(i,s)}return a}else On(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(s,...o)=>this.produceWithPatches(s,l=>t(l,...o));let r,a;return[this.produce(t,n,(s,o)=>{r=s,a=o}),r,a]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Ka(e)||On(8),ki(e)&&(e=YR(e));const t=vy(this),n=Cc(e,void 0);return n[qn].isManual_=!0,wc(t),n}finishDraft(e,t){const n=e&&e[qn];(!n||!n.isManual_)&&On(9);const{scope_:r}=n;return yy(r,t),Ty(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const a=t[n];if(a.path.length===0&&a.op==="replace"){e=a.value;break}}n>-1&&(t=t.slice(n+1));const r=Za("Patches").applyPatches_;return ki(e)?r(e,t):this.produce(e,a=>r(a,t))}};function Cc(e,t){const n=ul(e)?Za("MapSet").proxyMap_(e,t):cl(e)?Za("MapSet").proxySet_(e,t):GR(e,t);return(t?t.scope_:Ey()).drafts_.push(n),n}function YR(e){return ki(e)||On(10,e),wy(e)}function wy(e){if(!Ka(e)||dl(e))return e;const t=e[qn];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Tc(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Tc(e,!0);return ol(n,(r,a)=>{by(n,r,wy(a))}),t&&(t.finalized_=!1),n}var jn=new WR,KR=jn.produce;jn.produceWithPatches.bind(jn),jn.setAutoFreeze.bind(jn),jn.setUseStrictShallowCopy.bind(jn),jn.applyPatches.bind(jn),jn.createDraft.bind(jn),jn.finishDraft.bind(jn);const XR=e=>(t,n,r)=>(r.setState=(a,i,...s)=>{const o=typeof a=="function"?KR(a):a;return t(o,i,...s)},e(r.setState,n,r)),Ic=()=>Kt.getState().backendUrl;var Gn=(e=>(e.NOT_CONFIGURED="not_configured",e.NOT_AUTHENTICATED="not_authenticated",e.AUTHENTICATED="authenticated",e.ERROR="error",e))(Gn||{});class Cs{static TOKEN_KEY="access_token";authCheckPromise=null;listeners=[];getToken(){return localStorage.getItem(Cs.TOKEN_KEY)}setToken(t){localStorage.setItem(Cs.TOKEN_KEY,t)}removeToken(){localStorage.removeItem(Cs.TOKEN_KEY)}addAuthStateListener(t){this.listeners.push(t)}removeAuthStateListener(t){const n=this.listeners.indexOf(t);n>-1&&this.listeners.splice(n,1)}notifyListeners(t){this.listeners.forEach(n=>{try{n(t)}catch(r){console.error("Auth listener error:",r)}})}async getAuthStatus(){console.log("AuthService: 检查认证服务状态...");try{const t=await fetch(`${Ic()}/xyzen-api/v1/auth/status`);if(!t.ok)throw console.error(`AuthService: 认证状态检查失败,HTTP ${t.status}`),new Error(`HTTP error! status: ${t.status}`);const n=await t.json();return console.log("AuthService: 认证状态:",n),n}catch(t){throw console.error("AuthService: 获取认证状态失败:",t),t}}async validateToken(t){const n=t||this.getToken();if(console.log("AuthService: 验证token...",n?"有token":"无token"),!n)return console.log("AuthService: 没有可用的访问令牌"),{success:!1,error_code:"NO_TOKEN",error_message:"No access token available"};console.log(`AuthService: 准备验证token (前20字符): ${n.substring(0,20)}...`);try{const r=await fetch(`${Ic()}/xyzen-api/v1/auth/validate`,{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"}});if(console.log(`AuthService: token验证响应状态: ${r.status}`),!r.ok)throw r.status===401&&(console.log("AuthService: token无效,移除本地存储"),this.removeToken()),new Error(`HTTP error! status: ${r.status}`);const a=await r.json();return console.log("AuthService: token验证结果:",a),a}catch(r){return console.error("AuthService: token验证失败:",r),{success:!1,error_code:"VALIDATION_ERROR",error_message:r instanceof Error?r.message:"Token validation failed"}}}async getCurrentUser(){const t=this.getToken();if(!t)return null;try{const n=await fetch(`${Ic()}/xyzen-api/v1/auth/me`,{headers:{Authorization:`Bearer ${t}`}});if(!n.ok)throw n.status===401&&this.removeToken(),new Error(`HTTP error! status: ${n.status}`);return await n.json()}catch(n){return console.error("Failed to get current user:",n),null}}async checkAuthState(t=!1){if(console.log("AuthService: 检查认证状态,force =",t),this.authCheckPromise&&!t)return console.log("AuthService: 返回已存在的认证检查Promise"),this.authCheckPromise;this.authCheckPromise=this._performAuthCheck();const n=await this.authCheckPromise;return console.log("AuthService: 认证检查完成,结果:",n),this.notifyListeners(n),n}async _performAuthCheck(){console.log("AuthService: 开始执行认证检查...");try{console.log("AuthService: 步骤1 - 检查认证服务配置");const t=await this.getAuthStatus();if(!t.is_configured)return console.log("AuthService: 认证服务未配置"),{state:"not_configured",message:t.message};console.log("AuthService: 步骤2 - 检查本地token");const n=this.getToken();if(!n)return console.log("AuthService: 没有本地token"),{state:"not_authenticated",message:"请先登录",provider:t.provider};console.log(`AuthService: 找到本地token (前20字符): ${n.substring(0,20)}...`),console.log("AuthService: 步骤3 - 验证token");const r=await this.validateToken(n);return r.success?(console.log("AuthService: token验证成功,用户信息:",r.user_info),{state:"authenticated",user:r.user_info,message:`已登录 (${t.provider})`,provider:t.provider}):(console.log("AuthService: token验证失败:",r.error_message),{state:"not_authenticated",message:r.error_message||"令牌无效,请重新登录",provider:t.provider})}catch(t){return console.error("AuthService: 认证检查失败:",t),{state:"error",message:t instanceof Error?t.message:"认证检查失败"}}}async autoLogin(){return console.log("Performing auto-login check..."),this.checkAuthState(!0)}async login(t){return this.setToken(t),this.checkAuthState(!0)}logout(){this.removeToken(),this.authCheckPromise=null,this.notifyListeners({state:"not_authenticated",message:"已登出"})}}const $t=new Cs,hl=()=>{const e=$t.getToken(),t={"Content-Type":"application/json"};return e&&(t.Authorization=`Bearer ${e}`),t},ZR=(e,t)=>({agents:[],agentsLoading:!1,fetchAgents:async()=>{e({agentsLoading:!0});try{const n=await fetch(`${t().backendUrl}/xyzen-api/v1/agents/`,{headers:hl()});if(!n.ok)throw new Error("Failed to fetch agents");const r=await n.json();e({agents:r,agentsLoading:!1})}catch(n){throw console.error("Failed to fetch agents:",n),e({agentsLoading:!1}),n}},createAgent:async n=>{try{const r=await fetch(`${t().backendUrl}/xyzen-api/v1/agents/`,{method:"POST",headers:hl(),body:JSON.stringify(n)});if(!r.ok){const a=await r.text();throw new Error(`Failed to create agent: ${a}`)}await t().fetchAgents()}catch(r){throw console.error(r),r}},updateAgent:async n=>{try{const r=await fetch(`${t().backendUrl}/xyzen-api/v1/agents/${n.id}`,{method:"PATCH",headers:hl(),body:JSON.stringify(n)});if(!r.ok){const a=await r.text();throw new Error(`Failed to update agent: ${a}`)}await t().fetchAgents()}catch(r){throw console.error(r),r}},deleteAgent:async n=>{try{const r=await fetch(`${t().backendUrl}/xyzen-api/v1/agents/${n}`,{method:"DELETE",headers:hl()});if(!r.ok){const a=await r.text();throw new Error(`Failed to delete agent: ${a}`)}await t().fetchAgents()}catch(r){throw console.error(r),r}}}),QR=(e,t)=>({user:null,token:null,status:"idle",login:async n=>{e({status:"loading"});try{const r=await $t.login(n);if(r.state==="authenticated"&&r.user)e({token:n,user:{id:r.user.id,username:r.user.username||r.user.display_name||"Unknown",avatar:r.user.avatar_url||`https://i.pravatar.cc/40?u=${r.user.id}`},status:"succeeded"});else throw new Error(r.message)}catch(r){e({status:"failed"}),console.error("Login failed:",r)}},logout:()=>{$t.logout(),e({user:null,token:null,status:"idle"})},fetchUserByToken:async()=>{const n=$t.getToken();if(n){e({status:"loading"});try{const r=await $t.checkAuthState(!0);r.state==="authenticated"&&r.user?e({token:n,user:{id:r.user.id,username:r.user.username||r.user.display_name||"Unknown",avatar:r.user.avatar_url||`https://i.pravatar.cc/40?u=${r.user.id}`},status:"succeeded"}):(e({status:"failed"}),$t.removeToken())}catch(r){e({status:"failed"}),$t.removeToken(),console.error("Failed to fetch user by token:",r)}}}});class JR{ws=null;onMessageCallback=null;onMessageEventCallback=null;onStatusChangeCallback=null;backendUrl="";setBackendUrl(t){this.backendUrl=t}connect(t,n,r,a,i){if(this.ws&&this.ws.readyState===WebSocket.OPEN){console.log("WebSocket is already connected.");return}this.onMessageCallback=r,this.onMessageEventCallback=i||null,this.onStatusChangeCallback=a;const s=$t.getToken();if(!s){console.error("XyzenService: No authentication token available"),this.onStatusChangeCallback?.({connected:!1,error:"Authentication required"});return}const o=`${this.backendUrl.replace(/^http(s?):\/\//,"ws$1://")}/xyzen-ws/v1/chat/sessions/${t}/topics/${n}?token=${encodeURIComponent(s)}`;this.ws=new WebSocket(o),this.ws.onopen=()=>{console.log("XyzenService: WebSocket connected"),this.onStatusChangeCallback?.({connected:!0,error:null})},this.ws.onmessage=l=>{try{const u=JSON.parse(l.data);u.type&&this.onMessageEventCallback?this.onMessageEventCallback(u):this.onMessageCallback?.(u)}catch(u){console.error("XyzenService: Failed to parse message data:",u)}},this.ws.onclose=l=>{console.log(`XyzenService: WebSocket disconnected (code: ${l.code}, reason: ${l.reason})`),this.onStatusChangeCallback?.({connected:!1,error:l.reason||"Connection closed."})},this.ws.onerror=l=>{console.error("XyzenService: WebSocket error:",l),this.onStatusChangeCallback?.({connected:!1,error:"A connection error occurred."})}}sendMessage(t){this.ws&&this.ws.readyState===WebSocket.OPEN?this.ws.send(JSON.stringify({message:t})):console.error("XyzenService: WebSocket is not connected.")}sendStructuredMessage(t){this.ws&&this.ws.readyState===WebSocket.OPEN?this.ws.send(JSON.stringify(t)):console.error("XyzenService: WebSocket is not connected.")}disconnect(){this.ws&&(this.ws.close(),this.ws=null)}}const Ea=new JR,eO=(e,t)=>({activeChatChannel:null,chatHistory:[],chatHistoryLoading:!0,channels:{},setActiveChatChannel:n=>e({activeChatChannel:n}),fetchChatHistory:async()=>{const{setLoading:n}=t();n("chatHistory",!0);try{console.log("ChatSlice: Starting to fetch chat history...");const r=$t.getToken();if(!r){console.error("ChatSlice: No authentication token available");return}const a={"Content-Type":"application/json",Authorization:`Bearer ${r}`};console.log("ChatSlice: Making request to sessions API...");const i=await fetch(`${t().backendUrl}/xyzen-api/v1/sessions/`,{headers:a});if(console.log(`ChatSlice: Sessions API response status: ${i.status}`),!i.ok){const c=await i.text();throw console.error(`ChatSlice: Sessions API error: ${i.status} - ${c}`),new Error(`Failed to fetch chat history: ${i.status} ${c}`)}const s=await i.json();console.log("ChatSlice: Received sessions data:",s);const l={...t().channels},u=s.flatMap(c=>(console.log(`ChatSlice: Processing session ${c.id} with ${c.topics?.length||0} topics`),c.topics?.map(d=>(l[d.id]?l[d.id]={...l[d.id],sessionId:c.id,title:d.name,agentId:c.agent_id}:l[d.id]={id:d.id,sessionId:c.id,title:d.name,messages:[],agentId:c.agent_id,connected:!1,error:null},{id:d.id,title:d.name,updatedAt:d.updated_at,assistantTitle:"通用助理",lastMessage:"",isPinned:!1}))||[]));console.log(`ChatSlice: Processed ${u.length} chat history items`),e({chatHistory:u,channels:l,chatHistoryLoading:!1}),console.log(`ChatSlice: Loaded ${u.length} chat history items, keeping current active channel`)}catch(r){console.error("ChatSlice: Failed to fetch chat history:",r),e({chatHistoryLoading:!1})}finally{n("chatHistory",!1)}},togglePinChat:n=>{e(r=>{const a=r.chatHistory.find(i=>i.id===n);a&&(a.isPinned=!a.isPinned)})},activateChannel:async n=>{const{channels:r,activeChatChannel:a,connectToChannel:i,backendUrl:s}=t();if(n===a&&r[n]?.connected)return;e({activeChatChannel:n});let o=r[n];if(!o)try{const l=$t.getToken(),u={"Content-Type":"application/json"};l&&(u.Authorization=`Bearer ${l}`);const c=await fetch(`${s}/xyzen-api/v1/sessions/`,{headers:u});if(!c.ok)throw new Error("Failed to fetch sessions");const d=await c.json();let p=null,f=null;for(const m of d){const g=m.topics.find(x=>x.id===n);if(g){p=m.id,f=g.name;break}}if(p&&f)o={id:n,sessionId:p,title:f,messages:[],agentId:void 0,connected:!1,error:null},e(m=>{m.channels[n]=o});else{console.error(`Topic ${n} not found in any session, refetching history...`),await t().fetchChatHistory();const m=t().channels;if(m[n])o=m[n];else{console.error(`Topic ${n} still not found after refetch.`);return}}}catch(l){console.error("Failed to find session for topic:",l);return}if(o){if(o.messages.length===0){const{setLoading:l}=t(),u=`topicMessages-${n}`;l(u,!0);try{const c=$t.getToken(),d={"Content-Type":"application/json"};c&&(d.Authorization=`Bearer ${c}`);const p=await fetch(`${s}/xyzen-api/v1/topics/${n}/messages`,{headers:d});if(p.ok){const f=await p.json();console.log(`ChatSlice: Loaded ${f.length} messages for topic ${n}`),e(m=>{m.channels[n]&&(m.channels[n].messages=f)})}else{const f=await p.text();console.error(`ChatSlice: Failed to load messages for topic ${n}: ${p.status} ${f}`),(p.status===401||p.status===403)&&console.error("ChatSlice: Authentication/authorization issue loading messages")}}catch(c){console.error("Failed to load topic messages:",c)}finally{l(u,!1)}}i(o.sessionId,o.id)}},connectToChannel:(n,r)=>{Ea.disconnect(),Ea.connect(n,r,a=>{e(i=>{const s=i.channels[r];s&&(s.messages.some(o=>o.id===a.id)||s.messages.push(a))})},a=>{e(i=>{const s=i.channels[r];s&&(s.connected=a.connected,s.error=a.error)})},a=>{e(i=>{const s=i.channels[r];if(s)switch(a.type){case"loading":{const o=`loading-${Date.now()}`;s.messages.findIndex(u=>u.isLoading)===-1&&s.messages.push({id:o,role:"assistant",content:"",created_at:new Date().toISOString(),isLoading:!0,isStreaming:!1});break}case"streaming_start":{const o=s.messages.findIndex(u=>u.isLoading),l=a.data;o!==-1&&(s.messages[o]={...s.messages[o],id:l.id,isLoading:!1,isStreaming:!0,content:""});break}case"streaming_chunk":{const o=a.data,l=s.messages.findIndex(u=>u.id===o.id);if(l!==-1){const u=s.messages[l].content;s.messages[l].content=u+o.content}break}case"streaming_end":{const o=a.data,l=s.messages.findIndex(u=>u.id===o.id);l!==-1&&(s.messages[l]={...s.messages[l],isStreaming:!1,created_at:o.created_at||new Date().toISOString()});break}case"message":{const o=a.data;s.messages.some(l=>l.id===o.id)||s.messages.push(o);break}case"message_saved":{const o=a.data,l=s.messages.findIndex(u=>u.id===o.stream_id);l!==-1&&(s.messages[l]={...s.messages[l],id:o.db_id,created_at:o.created_at});break}case"tool_call_request":{console.log("ChatSlice: Received tool_call_request event:",a.data);const o=a.data,l=s.messages.findIndex(d=>d.isLoading);l!==-1&&s.messages.splice(l,1);const c={id:`tool-call-${o.id}`,role:"assistant",content:"我需要使用工具来帮助回答您的问题。",created_at:new Date().toISOString(),isLoading:!1,isStreaming:!1,toolCalls:[{id:o.id,name:o.name,description:o.description,arguments:o.arguments,status:o.status,timestamp:new Date(o.timestamp).toISOString()}]};s.messages.push(c),console.log(`ChatSlice: Created new tool call message with tool ${o.name}`);break}case"tool_call_response":{console.log("ChatSlice: Received tool_call_response event:",a.data);const o=a.data;let l=!1;s.messages.forEach(u=>{u.toolCalls&&u.toolCalls.forEach(c=>{c.id===o.toolCallId&&(c.status=o.status,o.result&&(c.result=JSON.stringify(o.result)),o.error&&(c.error=o.error),console.log(`ChatSlice: Updated tool call ${c.name} status to ${o.status}`),o.status==="completed"&&(l=!0))})}),l&&(console.log("ChatSlice: Tool completed, creating loading message for AI response"),s.messages.push({id:`loading-${Date.now()}`,role:"assistant",content:"",created_at:new Date().toISOString(),isLoading:!0}));break}case"error":{const o=a.data,l=s.messages.findIndex(u=>u.isLoading);l!==-1&&s.messages.splice(l,1),console.error("Chat error:",o.error);break}}})})},disconnectFromChannel:()=>{Ea.disconnect()},sendMessage:n=>{const{activeChatChannel:r}=t();r&&Ea.sendMessage(n)},createDefaultChannel:async n=>{try{const r=n||"default",a=$t.getToken();if(!a){console.error("No authentication token available");return}const i={"Content-Type":"application/json",Authorization:`Bearer ${a}`};try{const l=await fetch(`${t().backendUrl}/xyzen-api/v1/sessions/by-agent/${r}`,{headers:i});if(l.ok){const u=await l.json(),c=await fetch(`${t().backendUrl}/xyzen-api/v1/topics/`,{method:"POST",headers:i,body:JSON.stringify({name:"新的聊天",session_id:u.id})});if(!c.ok)throw new Error("Failed to create new topic in existing session");const d=await c.json(),p={id:d.id,sessionId:u.id,title:d.name,messages:[],agentId:u.agent_id,connected:!1,error:null},f={id:d.id,title:d.name,updatedAt:d.updated_at,assistantTitle:"通用助理",lastMessage:"",isPinned:!1};e(m=>{m.channels[d.id]=p,m.chatHistory.unshift(f),m.activeChatChannel=d.id,m.activeTabIndex=1}),t().connectToChannel(u.id,d.id);return}}catch{console.log("No existing session found, creating new session")}const s=await fetch(`${t().backendUrl}/xyzen-api/v1/sessions/`,{method:"POST",headers:i,body:JSON.stringify({name:"New Session",agent_id:n})});if(!s.ok)throw new Error("Failed to create new session with default topic");const o=await s.json();if(o.topics&&o.topics.length>0){const l=o.topics[0],u={id:l.id,sessionId:o.id,title:l.name,messages:[],agentId:o.agent_id,connected:!1,error:null},c={id:l.id,title:l.name,updatedAt:l.updated_at,assistantTitle:"通用助理",lastMessage:"",isPinned:!1};e(d=>{d.channels[l.id]=u,d.chatHistory.unshift(c),d.activeChatChannel=l.id,d.activeTabIndex=1}),t().connectToChannel(o.id,l.id)}}catch(r){console.error("Failed to create channel:",r)}},updateTopicName:async(n,r)=>{try{const a=$t.getToken();if(!a){console.error("No authentication token available");return}const i={"Content-Type":"application/json",Authorization:`Bearer ${a}`};if(!(await fetch(`${t().backendUrl}/xyzen-api/v1/topics/${n}`,{method:"PUT",headers:i,body:JSON.stringify({name:r})})).ok)throw new Error("Failed to update topic name");e(o=>{o.channels[n]&&(o.channels[n].title=r);const l=o.chatHistory.find(u=>u.id===n);l&&(l.title=r)}),console.log(`Topic ${n} name updated to: ${r}`)}catch(a){throw console.error("Failed to update topic name:",a),a}},confirmToolCall:(n,r)=>{Ea.sendStructuredMessage({type:"tool_call_confirm",data:{toolCallId:r}}),e(a=>{a.channels[n]&&a.channels[n].messages.forEach(i=>{i.toolCalls&&i.toolCalls.forEach(s=>{s.id===r&&s.status==="waiting_confirmation"&&(s.status="executing")})})})},cancelToolCall:(n,r)=>{Ea.sendStructuredMessage({type:"tool_call_cancel",data:{toolCallId:r}}),e(a=>{a.channels[n]&&a.channels[n].messages.forEach(i=>{i.toolCalls&&i.toolCalls.forEach(s=>{s.id===r&&s.status==="waiting_confirmation"&&(s.status="failed",s.error="用户取消执行")})})})}}),tO=(e,t)=>({loadingStates:{},setLoading:(n,r)=>{e(a=>{r?a.loadingStates[n]=!0:delete a.loadingStates[n]})},getLoading:n=>t().loadingStates[n]||!1,clearAllLoading:()=>{e(n=>{n.loadingStates={}})}}),Cr={MCP_SERVERS:"mcpServers",MCP_SERVER_CREATE:"mcpServerCreate",MCP_SERVER_UPDATE:"mcpServerUpdate",MCP_SERVER_DELETE:"mcpServerDelete"},Is=()=>Kt.getState().backendUrl,Rs=()=>{const e={"Content-Type":"application/json"},t=$t.getToken();return t&&(e.Authorization=`Bearer ${t}`),e},Os={async getMcpServers(){const e=await fetch(`${Is()}/xyzen-api/v1/mcps`,{headers:Rs()});if(!e.ok)throw new Error("Failed to fetch MCP servers");return e.json()},async createMcpServer(e){const t=await fetch(`${Is()}/xyzen-api/v1/mcps`,{method:"POST",headers:Rs(),body:JSON.stringify(e)});if(!t.ok){const n=await t.text();throw new Error(`Failed to create MCP server: ${t.status} ${n}`)}return t.json()},async updateMcpServer(e,t){const n=await fetch(`${Is()}/xyzen-api/v1/mcps/${e}`,{method:"PATCH",headers:Rs(),body:JSON.stringify(t)});if(!n.ok){const r=await n.text();throw new Error(`Failed to update MCP server: ${n.status} ${r}`)}return n.json()},async deleteMcpServer(e){const t=await fetch(`${Is()}/xyzen-api/v1/mcps/${e}`,{method:"DELETE",headers:Rs()});if(!t.ok){const n=await t.text();throw new Error(`Failed to delete MCP server: ${t.status} ${n}`)}},async refreshMcpServers(){const e=await fetch(`${Is()}/xyzen-api/v1/mcps/refresh`,{method:"POST",headers:Rs()});if(!e.ok){const t=await e.text();throw new Error(`Failed to trigger MCP server refresh: ${e.status} ${t}`)}}},nO=(e,t)=>({mcpServers:[],fetchMcpServers:async()=>{const{setLoading:n}=t();n(Cr.MCP_SERVERS,!0);try{console.log("McpSlice: Starting to fetch MCP servers...");const r=await Os.getMcpServers();console.log(`McpSlice: Loaded ${r.length} MCP servers`),e({mcpServers:r})}catch(r){console.error("Failed to fetch MCP servers:",r)}finally{n(Cr.MCP_SERVERS,!1)}},refreshMcpServers:async()=>{const{setLoading:n}=t();n(Cr.MCP_SERVERS,!0);try{await Os.refreshMcpServers(),setTimeout(()=>{t().fetchMcpServers()},1e3)}catch(r){console.error("Failed to refresh MCP servers:",r)}finally{setTimeout(()=>n(Cr.MCP_SERVERS,!1),1500)}},addMcpServer:async n=>{const{setLoading:r}=t();r(Cr.MCP_SERVER_CREATE,!0);try{const a=await Os.createMcpServer(n);e(i=>{i.mcpServers.push(a)}),t().closeAddMcpServerModal()}catch(a){throw console.error("Failed to add MCP server:",a),a}finally{r(Cr.MCP_SERVER_CREATE,!1)}},editMcpServer:async(n,r)=>{const{setLoading:a}=t();a(Cr.MCP_SERVER_UPDATE,!0);try{const i=await Os.updateMcpServer(n,r);e(s=>{const o=s.mcpServers.findIndex(l=>l.id===n);o!==-1&&(s.mcpServers[o]=i)})}catch(i){throw console.error("Failed to edit MCP server:",i),i}finally{a(Cr.MCP_SERVER_UPDATE,!1)}},removeMcpServer:async n=>{const{setLoading:r}=t();r(Cr.MCP_SERVER_DELETE,!0);try{await Os.deleteMcpServer(n),e(a=>{a.mcpServers=a.mcpServers.filter(i=>i.id!==n)})}catch(a){throw console.error("Failed to remove MCP server:",a),a}finally{r(Cr.MCP_SERVER_DELETE,!1)}},updateMcpServerInList:n=>{e(r=>{const a=r.mcpServers.findIndex(i=>i.id===n.id);a!==-1?r.mcpServers[a]=n:r.mcpServers.push(n)})}}),rO=(e,t)=>({toolTestModal:{isOpen:!1},toolExecutionHistory:[],openToolTestModal:(n,r,a)=>{e(i=>{i.toolTestModal={isOpen:!0,server:n,toolName:r,toolDescription:a}})},closeToolTestModal:()=>{e(n=>{n.toolTestModal={isOpen:!1}})},addToolExecution:n=>{e(r=>{const a={...n,id:`${Date.now()}-${Math.random().toString(36).substr(2,9)}`,timestamp:new Date};r.toolExecutionHistory.unshift(a),r.toolExecutionHistory.length>100&&(r.toolExecutionHistory=r.toolExecutionHistory.slice(0,100))})},clearToolExecutionHistory:()=>{e(n=>{n.toolExecutionHistory=[]})},getToolExecutionHistory:(n,r)=>{const{toolExecutionHistory:a}=t();return!n&&!r?a:a.filter(i=>{const s=!n||i.serverId===n,o=!r||i.toolName===r;return s&&o})}});class aO{getBackendUrl(){const{backendUrl:t}=Kt.getState();return t}async getLlmProviders(){const t=await fetch(`${this.getBackendUrl()}/xyzen-api/v1/llm-providers/`);if(!t.ok)throw new Error("Failed to fetch LLM providers");return t.json()}async createLlmProvider(t){const n=await fetch(`${this.getBackendUrl()}/xyzen-api/v1/llm-providers/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const r=await n.text();throw new Error(`Failed to create LLM provider: ${r}`)}return n.json()}async getLlmProvider(t){const n=await fetch(`${this.getBackendUrl()}/xyzen-api/v1/llm-providers/${t}`);if(!n.ok)throw new Error("Failed to fetch LLM provider");return n.json()}async updateLlmProvider(t,n){const r=await fetch(`${this.getBackendUrl()}/xyzen-api/v1/llm-providers/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok){const a=await r.text();throw new Error(`Failed to update LLM provider: ${a}`)}return r.json()}async deleteLlmProvider(t){const n=await fetch(`${this.getBackendUrl()}/xyzen-api/v1/llm-providers/${t}`,{method:"DELETE"});if(!n.ok){const r=await n.text();throw new Error(`Failed to delete LLM provider: ${r}`)}}async switchActiveProvider(t){const n=await fetch(`${this.getBackendUrl()}/xyzen-api/v1/llm-providers/switch`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const r=await n.text();throw new Error(`Failed to switch active provider: ${r}`)}return n.json()}async getSupportedTypes(){const t=await fetch(`${this.getBackendUrl()}/xyzen-api/v1/llm-providers/supported-types/`);if(!t.ok)throw new Error("Failed to fetch supported provider types");return t.json()}}const Ni=new aO,iO=(e,t)=>({llmProviders:[],llmProvidersLoading:!1,fetchLlmProviders:async()=>{e({llmProvidersLoading:!0});try{const n=await Ni.getLlmProviders();e({llmProviders:n,llmProvidersLoading:!1})}catch(n){console.error("Failed to fetch LLM providers:",n),e({llmProvidersLoading:!1})}},addLlmProvider:async n=>{try{const r=await Ni.createLlmProvider(n);e(a=>{a.llmProviders.push(r)}),t().closeAddLlmProviderModal()}catch(r){throw console.error("Failed to add LLM provider:",r),r}},editLlmProvider:async(n,r)=>{try{const a=await Ni.updateLlmProvider(n,r);e(i=>{const s=i.llmProviders.findIndex(o=>o.id===n);s!==-1&&(i.llmProviders[s]=a)})}catch(a){throw console.error("Failed to edit LLM provider:",a),a}},removeLlmProvider:async n=>{try{await Ni.deleteLlmProvider(n),e(r=>{r.llmProviders=r.llmProviders.filter(a=>a.id!==n)})}catch(r){throw console.error("Failed to remove LLM provider:",r),r}},switchActiveProvider:async n=>{try{await Ni.switchActiveProvider({provider_id:n}),await t().fetchLlmProviders()}catch(r){throw console.error("Failed to switch active provider:",r),r}}}),sO=e=>({backendUrl:"",isXyzenOpen:!1,panelWidth:380,activeTabIndex:0,theme:"system",isAddMcpServerModalOpen:!1,isAddLlmProviderModalOpen:!1,toggleXyzen:()=>e(t=>({isXyzenOpen:!t.isXyzenOpen})),openXyzen:()=>e({isXyzenOpen:!0}),closeXyzen:()=>e({isXyzenOpen:!1}),setPanelWidth:t=>e({panelWidth:t}),setTabIndex:t=>e({activeTabIndex:t}),setTheme:t=>e({theme:t}),setBackendUrl:t=>{e({backendUrl:t}),Ea.setBackendUrl(t)},openAddMcpServerModal:()=>e({isAddMcpServerModalOpen:!0}),closeAddMcpServerModal:()=>e({isAddMcpServerModalOpen:!1}),openAddLlmProviderModal:()=>e({isAddLlmProviderModalOpen:!0}),closeAddLlmProviderModal:()=>e({isAddLlmProviderModalOpen:!1})}),Kt=PR()(FR(XR((...e)=>({...sO(...e),...eO(...e),...ZR(...e),...nO(...e),...rO(...e),...iO(...e),...QR(...e),...tO(...e)})),{name:"xyzen-storage",storage:fy(()=>localStorage),partialize:e=>({isXyzenOpen:e.isXyzenOpen,panelWidth:e.panelWidth,theme:e.theme,token:e.token,user:e.user})})),ml=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ci(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Rc(e){return"nodeType"in e}function Ln(e){var t,n;return e?Ci(e)?e:Rc(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function Oc(e){const{Document:t}=Ln(e);return e instanceof t}function Ls(e){return Ci(e)?!1:e instanceof Ln(e).HTMLElement}function Ay(e){return e instanceof Ln(e).SVGElement}function Ii(e){return e?Ci(e)?e.document:Rc(e)?Oc(e)?e:Ls(e)||Ay(e)?e.ownerDocument:document:document:document}const ya=ml?v.useLayoutEffect:v.useEffect;function Lc(e){const t=v.useRef(e);return ya(()=>{t.current=e}),v.useCallback(function(){for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return t.current==null?void 0:t.current(...r)},[])}function oO(){const e=v.useRef(null),t=v.useCallback((r,a)=>{e.current=setInterval(r,a)},[]),n=v.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Dc(e,t){t===void 0&&(t=[e]);const n=v.useRef(e);return ya(()=>{n.current!==e&&(n.current=e)},t),n}function Ds(e,t){const n=v.useRef();return v.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Mc(e){const t=Lc(e),n=v.useRef(null),r=v.useCallback(a=>{a!==n.current&&t?.(a,n.current),n.current=a},[]);return[n,r]}function Pc(e){const t=v.useRef();return v.useEffect(()=>{t.current=e},[e]),t.current}let Fc={};function Bc(e,t){return v.useMemo(()=>{if(t)return t;const n=Fc[e]==null?0:Fc[e]+1;return Fc[e]=n,e+"-"+n},[e,t])}function _y(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];return r.reduce((i,s)=>{const o=Object.entries(s);for(const[l,u]of o){const c=i[l];c!=null&&(i[l]=c+e*u)}return i},{...t})}}const Ri=_y(1),gl=_y(-1);function lO(e){return"clientX"in e&&"clientY"in e}function ky(e){if(!e)return!1;const{KeyboardEvent:t}=Ln(e.target);return t&&e instanceof t}function uO(e){if(!e)return!1;const{TouchEvent:t}=Ln(e.target);return t&&e instanceof t}function Uc(e){if(uO(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return lO(e)?{x:e.clientX,y:e.clientY}:null}const Ny="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function cO(e){return e.matches(Ny)?e:e.querySelector(Ny)}const dO={display:"none"};function pO(e){let{id:t,value:n}=e;return v.createElement("div",{id:t,style:dO},n)}function fO(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const a={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return v.createElement("div",{id:t,style:a,role:"status","aria-live":r,"aria-atomic":!0},n)}function hO(){const[e,t]=v.useState("");return{announce:v.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const Cy=v.createContext(null);function mO(e){const t=v.useContext(Cy);v.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function gO(){const[e]=v.useState(()=>new Set),t=v.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[v.useCallback(r=>{let{type:a,event:i}=r;e.forEach(s=>{var o;return(o=s[a])==null?void 0:o.call(s,i)})},[e]),t]}const bO={draggable:`
23
23
  To pick up a draggable item, press the space bar.
24
24
  While dragging, use the arrow keys to move the item.
25
25
  Press space again to drop the item in its new position, or press escape to cancel.
@@ -51,7 +51,7 @@ React keys must be passed directly to JSX without using spread:
51
51
  ${f}px !important;
52
52
  top: ${c}px !important;
53
53
  }
54
- `),()=>{g.contains(m)&&g.removeChild(m)}},[t]),b.jsx(AP,{isPresent:t,childRef:i,sizeRef:s,children:Y.cloneElement(e,{ref:i})})}const kP=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:a,presenceAffectsLayout:i,mode:s,anchorX:o,root:l})=>{const u=Ud(NP),c=v.useId();let d=!0,p=v.useMemo(()=>(d=!1,{id:c,initial:t,isPresent:n,custom:a,onExitComplete:f=>{u.set(f,!0);for(const m of u.values())if(!m)return;r&&r()},register:f=>(u.set(f,!1),()=>u.delete(f))}),[n,u,r]);return i&&d&&(p={...p}),v.useMemo(()=>{u.forEach((f,m)=>u.set(m,!1))},[n]),Y.useEffect(()=>{!n&&!u.size&&r&&r()},[n]),s==="popLayout"&&(e=b.jsx(_P,{isPresent:n,anchorX:o,root:l,children:e})),b.jsx(Ul.Provider,{value:p,children:e})};function NP(){return new Map}function FS(e=!0){const t=v.useContext(Ul);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:r,register:a}=t,i=v.useId();v.useEffect(()=>{if(e)return a(i)},[e]);const s=v.useCallback(()=>e&&r&&r(i),[i,r,e]);return!n&&r?[!1,s]:[!0]}const Wl=e=>e.key||"";function BS(e){const t=[];return v.Children.forEach(e,n=>{v.isValidElement(n)&&t.push(n)}),t}const Dr=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:a=!0,mode:i="sync",propagate:s=!1,anchorX:o="left",root:l})=>{const[u,c]=FS(s),d=v.useMemo(()=>BS(e),[e]),p=s&&!u?[]:d.map(Wl),f=v.useRef(!0),m=v.useRef(d),g=Ud(()=>new Map),[x,T]=v.useState(d),[y,w]=v.useState(d);AT(()=>{f.current=!1,m.current=d;for(let A=0;A<y.length;A++){const R=Wl(y[A]);p.includes(R)?g.delete(R):g.get(R)!==!0&&g.set(R,!1)}},[y,p.length,p.join("-")]);const k=[];if(d!==x){let A=[...d];for(let R=0;R<y.length;R++){const M=y[R],P=Wl(M);p.includes(P)||(A.splice(R,0,M),k.push(M))}return i==="wait"&&k.length&&(A=k),w(BS(A)),T(d),null}process.env.NODE_ENV!=="production"&&i==="wait"&&y.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:_}=v.useContext(Bd);return b.jsx(b.Fragment,{children:y.map(A=>{const R=Wl(A),M=s&&!u?!1:d===y||p.includes(R),P=()=>{if(g.has(R))g.set(R,!0);else return;let D=!0;g.forEach(z=>{z||(D=!1)}),D&&(_?.(),w(m.current),s&&c?.(),r&&r())};return b.jsx(kP,{isPresent:M,initial:!f.current||n?void 0:!1,custom:t,presenceAffectsLayout:a,mode:i,root:l,onExitComplete:M?void 0:P,anchorX:o,children:A},R)})})},US=v.createContext({strict:!1}),HS={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},Wi={};for(const e in HS)Wi[e]={isEnabled:t=>HS[e].some(n=>!!t[n])};function CP(e){for(const t in e)Wi[t]={...Wi[t],...e[t]}}const IP=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function Yl(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||IP.has(e)}let $S=e=>!Yl(e);function RP(e){typeof e=="function"&&($S=t=>t.startsWith("on")?!Yl(t):e(t))}try{RP(require("@emotion/is-prop-valid").default)}catch{}function OP(e,t,n){const r={};for(const a in e)a==="values"&&typeof e.values=="object"||($S(a)||n===!0&&Yl(a)||!t&&!Yl(a)||e.draggable&&a.startsWith("onDrag"))&&(r[a]=e[a]);return r}const Kl=v.createContext({});function Xl(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function lo(e){return typeof e=="string"||Array.isArray(e)}const C0=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],I0=["initial",...C0];function Zl(e){return Xl(e.animate)||I0.some(t=>lo(e[t]))}function zS(e){return!!(Zl(e)||e.variants)}function LP(e,t){if(Zl(e)){const{initial:n,animate:r}=e;return{initial:n===!1||lo(n)?n:void 0,animate:lo(r)?r:void 0}}return e.inherit!==!1?t:{}}function DP(e){const{initial:t,animate:n}=LP(e,v.useContext(Kl));return v.useMemo(()=>({initial:t,animate:n}),[qS(t),qS(n)])}function qS(e){return Array.isArray(e)?e.join(" "):e}const uo={};function MP(e){for(const t in e)uo[t]=e[t],Xd(t)&&(uo[t].isCSSVariable=!0)}function jS(e,{layout:t,layoutId:n}){return Gi.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!uo[e]||e==="opacity")}const PP={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},FP=ji.length;function BP(e,t,n){let r="",a=!0;for(let i=0;i<FP;i++){const s=ji[i],o=e[s];if(o===void 0)continue;let l=!0;if(typeof o=="number"?l=o===(s.startsWith("scale")?1:0):l=parseFloat(o)===0,!l||n){const u=kS(o,w0[s]);if(!l){a=!1;const c=PP[s]||s;r+=`${c}(${u}) `}n&&(t[s]=u)}}return r=r.trim(),n?r=n(t,a?"":r):a&&(r="none"),r}function R0(e,t,n){const{style:r,vars:a,transformOrigin:i}=e;let s=!1,o=!1;for(const l in t){const u=t[l];if(Gi.has(l)){s=!0;continue}else if(Xd(l)){a[l]=u;continue}else{const c=kS(u,w0[l]);l.startsWith("origin")?(o=!0,i[l]=c):r[l]=c}}if(t.transform||(s||n?r.transform=BP(t,e.transform,n):r.transform&&(r.transform="none")),o){const{originX:l="50%",originY:u="50%",originZ:c=0}=i;r.transformOrigin=`${l} ${u} ${c}`}}const O0=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function GS(e,t,n){for(const r in t)!bn(t[r])&&!jS(r,n)&&(e[r]=t[r])}function UP({transformTemplate:e},t){return v.useMemo(()=>{const n=O0();return R0(n,t,e),Object.assign({},n.vars,n.style)},[t])}function HP(e,t){const n=e.style||{},r={};return GS(r,n,e),Object.assign(r,UP(e,t)),r}function $P(e,t){const n={},r=HP(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}const zP={offset:"stroke-dashoffset",array:"stroke-dasharray"},qP={offset:"strokeDashoffset",array:"strokeDasharray"};function jP(e,t,n=1,r=0,a=!0){e.pathLength=1;const i=a?zP:qP;e[i.offset]=Ue.transform(-r);const s=Ue.transform(t),o=Ue.transform(n);e[i.array]=`${s} ${o}`}function VS(e,{attrX:t,attrY:n,attrScale:r,pathLength:a,pathSpacing:i=1,pathOffset:s=0,...o},l,u,c){if(R0(e,o,u),l){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:d,style:p}=e;d.transform&&(p.transform=d.transform,delete d.transform),(p.transform||d.transformOrigin)&&(p.transformOrigin=d.transformOrigin??"50% 50%",delete d.transformOrigin),p.transform&&(p.transformBox=c?.transformBox??"fill-box",delete d.transformBox),t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),a!==void 0&&jP(d,a,i,s,!1)}const WS=()=>({...O0(),attrs:{}}),YS=e=>typeof e=="string"&&e.toLowerCase()==="svg";function GP(e,t,n,r){const a=v.useMemo(()=>{const i=WS();return VS(i,t,YS(r),e.transformTemplate,e.style),{...i.attrs,style:{...i.style}}},[t]);if(e.style){const i={};GS(i,e.style,e),a.style={...i,...a.style}}return a}const VP=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function L0(e){return typeof e!="string"||e.includes("-")?!1:!!(VP.indexOf(e)>-1||/[A-Z]/u.test(e))}function WP(e,t,n,{latestValues:r},a,i=!1){const o=(L0(e)?GP:$P)(t,r,a,e),l=OP(t,typeof e=="string",i),u=e!==v.Fragment?{...l,...o,ref:n}:{},{children:c}=t,d=v.useMemo(()=>bn(c)?c.get():c,[c]);return v.createElement(e,{...u,children:d})}function KS(e){const t=[{},{}];return e?.values.forEach((n,r)=>{t[0][r]=n.get(),t[1][r]=n.getVelocity()}),t}function D0(e,t,n,r){if(typeof t=="function"){const[a,i]=KS(r);t=t(n!==void 0?n:e.custom,a,i)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[a,i]=KS(r);t=t(n!==void 0?n:e.custom,a,i)}return t}function Ql(e){return bn(e)?e.get():e}function YP({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,a){return{latestValues:KP(n,r,a,e),renderState:t()}}function KP(e,t,n,r){const a={},i=r(e,{});for(const p in i)a[p]=Ql(i[p]);let{initial:s,animate:o}=e;const l=Zl(e),u=zS(e);t&&u&&!l&&e.inherit!==!1&&(s===void 0&&(s=t.initial),o===void 0&&(o=t.animate));let c=n?n.initial===!1:!1;c=c||s===!1;const d=c?o:s;if(d&&typeof d!="boolean"&&!Xl(d)){const p=Array.isArray(d)?d:[d];for(let f=0;f<p.length;f++){const m=D0(e,p[f]);if(m){const{transitionEnd:g,transition:x,...T}=m;for(const y in T){let w=T[y];if(Array.isArray(w)){const k=c?w.length-1:0;w=w[k]}w!==null&&(a[y]=w)}for(const y in g)a[y]=g[y]}}}return a}const XS=e=>(t,n)=>{const r=v.useContext(Kl),a=v.useContext(Ul),i=()=>YP(e,t,r,a);return n?i():Ud(i)};function M0(e,t,n){const{style:r}=e,a={};for(const i in r)(bn(r[i])||t.style&&bn(t.style[i])||jS(i,e)||n?.getValue(i)?.liveStyle!==void 0)&&(a[i]=r[i]);return a}const XP=XS({scrapeMotionValuesFromProps:M0,createRenderState:O0});function ZS(e,t,n){const r=M0(e,t,n);for(const a in e)if(bn(e[a])||bn(t[a])){const i=ji.indexOf(a)!==-1?"attr"+a.charAt(0).toUpperCase()+a.substring(1):a;r[i]=e[a]}return r}const ZP=XS({scrapeMotionValuesFromProps:ZS,createRenderState:WS}),QP=Symbol.for("motionComponentSymbol");function Yi(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function JP(e,t,n){return v.useCallback(r=>{r&&e.onMount&&e.onMount(r),t&&(r?t.mount(r):t.unmount()),n&&(typeof n=="function"?n(r):Yi(n)&&(n.current=r))},[t])}const P0=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),QS="data-"+P0("framerAppearId"),JS=v.createContext({});function eF(e,t,n,r,a){const{visualElement:i}=v.useContext(Kl),s=v.useContext(US),o=v.useContext(Ul),l=v.useContext(N0).reducedMotion,u=v.useRef(null);r=r||s.renderer,!u.current&&r&&(u.current=r(e,{visualState:t,parent:i,props:n,presenceContext:o,blockInitialAnimation:o?o.initial===!1:!1,reducedMotionConfig:l}));const c=u.current,d=v.useContext(JS);c&&!c.projection&&a&&(c.type==="html"||c.type==="svg")&&tF(u.current,n,a,d);const p=v.useRef(!1);v.useInsertionEffect(()=>{c&&p.current&&c.update(n,o)});const f=n[QS],m=v.useRef(!!f&&!window.MotionHandoffIsComplete?.(f)&&window.MotionHasOptimisedAnimation?.(f));return AT(()=>{c&&(p.current=!0,window.MotionIsMounted=!0,c.updateFeatures(),c.scheduleRenderMicrotask(),m.current&&c.animationState&&c.animationState.animateChanges())}),v.useEffect(()=>{c&&(!m.current&&c.animationState&&c.animationState.animateChanges(),m.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(f)}),m.current=!1))}),c}function tF(e,t,n,r){const{layoutId:a,layout:i,drag:s,dragConstraints:o,layoutScroll:l,layoutRoot:u,layoutCrossfade:c}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:e2(e.parent)),e.projection.setOptions({layoutId:a,layout:i,alwaysMeasureLayout:!!s||o&&Yi(o),visualElement:e,animationType:typeof i=="string"?i:"both",initialPromotionConfig:r,crossfade:c,layoutScroll:l,layoutRoot:u})}function e2(e){if(e)return e.options.allowProjection!==!1?e.projection:e2(e.parent)}function F0(e,{forwardMotionProps:t=!1}={},n,r){n&&CP(n);const a=L0(e)?ZP:XP;function i(o,l){let u;const c={...v.useContext(N0),...o,layoutId:nF(o)},{isStatic:d}=c,p=DP(o),f=a(o,d);if(!d&&Hd){rF(c,n);const m=aF(c);u=m.MeasureLayout,p.visualElement=eF(e,f,c,r,m.ProjectionNode)}return b.jsxs(Kl.Provider,{value:p,children:[u&&p.visualElement?b.jsx(u,{visualElement:p.visualElement,...c}):null,WP(e,o,JP(f,p.visualElement,l),f,d,t)]})}i.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const s=v.forwardRef(i);return s[QP]=e,s}function nF({layoutId:e}){const t=v.useContext(Bd).id;return t&&e!==void 0?t+"-"+e:e}function rF(e,t){const n=v.useContext(US).strict;if(process.env.NODE_ENV!=="production"&&t&&n){const r="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";e.ignoreStrict?Hi(!1,r,"lazy-strict-mode"):na(!1,r,"lazy-strict-mode")}}function aF(e){const{drag:t,layout:n}=Wi;if(!t&&!n)return{};const r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function iF(e,t){if(typeof Proxy>"u")return F0;const n=new Map,r=(i,s)=>F0(i,s,e,t),a=(i,s)=>(process.env.NODE_ENV!=="production"&&Vd(!1,"motion() is deprecated. Use motion.create() instead."),r(i,s));return new Proxy(a,{get:(i,s)=>s==="create"?r:(n.has(s)||n.set(s,F0(s,void 0,e,t)),n.get(s))})}function t2({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function sF({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function oF(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function B0(e){return e===void 0||e===1}function U0({scale:e,scaleX:t,scaleY:n}){return!B0(e)||!B0(t)||!B0(n)}function ci(e){return U0(e)||n2(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function n2(e){return r2(e.x)||r2(e.y)}function r2(e){return e&&e!=="0%"}function Jl(e,t,n){const r=e-n,a=t*r;return n+a}function a2(e,t,n,r,a){return a!==void 0&&(e=Jl(e,a,r)),Jl(e,n,r)+t}function H0(e,t=0,n=1,r,a){e.min=a2(e.min,t,n,r,a),e.max=a2(e.max,t,n,r,a)}function i2(e,{x:t,y:n}){H0(e.x,t.translate,t.scale,t.originPoint),H0(e.y,n.translate,n.scale,n.originPoint)}const s2=.999999999999,o2=1.0000000000001;function lF(e,t,n,r=!1){const a=n.length;if(!a)return;t.x=t.y=1;let i,s;for(let o=0;o<a;o++){i=n[o],s=i.projectionDelta;const{visualElement:l}=i.options;l&&l.props.style&&l.props.style.display==="contents"||(r&&i.options.layoutScroll&&i.scroll&&i!==i.root&&Xi(e,{x:-i.scroll.offset.x,y:-i.scroll.offset.y}),s&&(t.x*=s.x.scale,t.y*=s.y.scale,i2(e,s)),r&&ci(i.latestValues)&&Xi(e,i.latestValues))}t.x<o2&&t.x>s2&&(t.x=1),t.y<o2&&t.y>s2&&(t.y=1)}function Ki(e,t){e.min=e.min+t,e.max=e.max+t}function l2(e,t,n,r,a=.5){const i=xt(e.min,e.max,a);H0(e,t,n,i,r)}function Xi(e,t){l2(e.x,t.x,t.scaleX,t.scale,t.originX),l2(e.y,t.y,t.scaleY,t.scale,t.originY)}function u2(e,t){return t2(oF(e.getBoundingClientRect(),t))}function uF(e,t,n){const r=u2(e,n),{scroll:a}=t;return a&&(Ki(r.x,a.offset.x),Ki(r.y,a.offset.y)),r}const c2=()=>({translate:0,scale:1,origin:0,originPoint:0}),Zi=()=>({x:c2(),y:c2()}),d2=()=>({min:0,max:0}),Dt=()=>({x:d2(),y:d2()}),$0={current:null},p2={current:!1};function cF(){if(p2.current=!0,!!Hd)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>$0.current=e.matches;e.addEventListener("change",t),t()}else $0.current=!1}const dF=new WeakMap;function pF(e,t,n){for(const r in t){const a=t[r],i=n[r];if(bn(a))e.addValue(r,a);else if(bn(i))e.addValue(r,Vi(a,{owner:e}));else if(i!==a)if(e.hasValue(r)){const s=e.getValue(r);s.liveStyle===!0?s.jump(a):s.hasAnimated||s.set(a)}else{const s=e.getStaticValue(r);e.addValue(r,Vi(s!==void 0?s:a,{owner:e}))}}for(const r in n)t[r]===void 0&&e.removeValue(r);return t}const f2=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class fF{scrapeMotionValuesFromProps(t,n,r){return{}}constructor({parent:t,props:n,presenceContext:r,reducedMotionConfig:a,blockInitialAnimation:i,visualState:s},o={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=v0,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const p=Pn.now();this.renderScheduledAt<p&&(this.renderScheduledAt=p,yt.render(this.render,!1,!0))};const{latestValues:l,renderState:u}=s;this.latestValues=l,this.baseTarget={...l},this.initialValues=n.initial?{...l}:{},this.renderState=u,this.parent=t,this.props=n,this.presenceContext=r,this.depth=t?t.depth+1:0,this.reducedMotionConfig=a,this.options=o,this.blockInitialAnimation=!!i,this.isControllingVariants=Zl(n),this.isVariantNode=zS(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:c,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const p in d){const f=d[p];l[p]!==void 0&&bn(f)&&f.set(l[p])}}mount(t){this.current=t,dF.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,r)=>this.bindToMotionValue(r,n)),p2.current||cF(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:$0.current,process.env.NODE_ENV!=="production"&&Vd(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),Na(this.notifyUpdate),Na(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const n=this.features[t];n&&(n.unmount(),n.isMounted=!1)}this.current=null}bindToMotionValue(t,n){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();const r=Gi.has(t);r&&this.onBindTransform&&this.onBindTransform();const a=n.on("change",s=>{this.latestValues[t]=s,this.props.onUpdate&&yt.preRender(this.notifyUpdate),r&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let i;window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{a(),i&&i(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in Wi){const n=Wi[t];if(!n)continue;const{isEnabled:r,Feature:a}=n;if(!this.features[t]&&a&&r(this.props)&&(this.features[t]=new a(this)),this.features[t]){const i=this.features[t];i.isMounted?i.update():(i.mount(),i.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Dt()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let r=0;r<f2.length;r++){const a=f2[r];this.propEventSubscriptions[a]&&(this.propEventSubscriptions[a](),delete this.propEventSubscriptions[a]);const i="on"+a,s=t[i];s&&(this.propEventSubscriptions[a]=this.on(a,s))}this.prevMotionValues=pF(this,this.scrapeMotionValuesFromProps(t,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(t){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){const r=this.values.get(t);n!==r&&(r&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let r=this.values.get(t);return r===void 0&&n!==void 0&&(r=Vi(n===null?void 0:n,{owner:this}),this.addValue(t,r)),r}readValue(t,n){let r=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return r!=null&&(typeof r=="string"&&(_T(r)||NT(r))?r=parseFloat(r):!wP(r)&&Ia.test(n)&&(r=_S(t,n)),this.setBaseTarget(t,bn(r)?r.get():r)),bn(r)?r.get():r}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){const{initial:n}=this.props;let r;if(typeof n=="string"||typeof n=="object"){const i=D0(this.props,n,this.presenceContext?.custom);i&&(r=i[t])}if(n&&r!==void 0)return r;const a=this.getBaseTargetFromProps(this.props,t);return a!==void 0&&!bn(a)?a:this.initialValues[t]!==void 0&&r===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new Gd),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){A0.render(this.render)}}class h2 extends fF{constructor(){super(...arguments),this.KeyframeResolver=pP}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){return t.style?t.style[n]:void 0}removeValueFromRenderState(t,{vars:n,style:r}){delete n[t],delete r[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;bn(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function m2(e,{style:t,vars:n},r,a){const i=e.style;let s;for(s in t)i[s]=t[s];a?.applyProjectionStyles(i,r);for(s in n)i.setProperty(s,n[s])}function hF(e){return window.getComputedStyle(e)}class mF extends h2{constructor(){super(...arguments),this.type="html",this.renderInstance=m2}readValueFromInstance(t,n){if(Gi.has(n))return this.projection?.isProjecting?m0(n):R9(t,n);{const r=hF(t),a=(Xd(n)?r.getPropertyValue(n):r[n])||0;return typeof a=="string"?a.trim():a}}measureInstanceViewportBox(t,{transformPagePoint:n}){return u2(t,n)}build(t,n,r){R0(t,n,r.transformTemplate)}scrapeMotionValuesFromProps(t,n,r){return M0(t,n,r)}}const g2=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function gF(e,t,n,r){m2(e,t,void 0,r);for(const a in t.attrs)e.setAttribute(g2.has(a)?a:P0(a),t.attrs[a])}class bF extends h2{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Dt}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(Gi.has(n)){const r=AS(n);return r&&r.default||0}return n=g2.has(n)?n:P0(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,r){return ZS(t,n,r)}build(t,n,r){VS(t,n,this.isSVGTag,r.transformTemplate,r.style)}renderInstance(t,n,r,a){gF(t,n,r,a)}mount(t){this.isSVGTag=YS(t.tagName),super.mount(t)}}const EF=(e,t)=>L0(e)?new bF(t):new mF(t,{allowProjection:e!==v.Fragment});function co(e,t,n){const r=e.getProps();return D0(r,t,n!==void 0?n:r.custom,e)}const z0=e=>Array.isArray(e);function yF(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Vi(n))}function vF(e){return z0(e)?e[e.length-1]||0:e}function TF(e,t){const n=co(e,t);let{transitionEnd:r={},transition:a={},...i}=n||{};i={...i,...r};for(const s in i){const o=vF(i[s]);yF(e,s,o)}}function SF(e){return!!(bn(e)&&e.add)}function q0(e,t){const n=e.getValue("willChange");if(SF(n))return n.add(t);if(!n&&ra.WillChange){const r=new ra.WillChange("auto");e.addValue("willChange",r),r.add(t)}}function b2(e){return e.props[QS]}const xF=e=>e!==null;function wF(e,{repeat:t,repeatType:n="loop"},r){const a=e.filter(xF),i=t&&n!=="loop"&&t%2===1?0:a.length-1;return a[i]}const AF={type:"spring",stiffness:500,damping:25,restSpeed:10},_F=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),kF={type:"keyframes",duration:.8},NF={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},CF=(e,{keyframes:t})=>t.length>2?kF:Gi.has(e)?e.startsWith("scale")?_F(t[1]):AF:NF;function IF({when:e,delay:t,delayChildren:n,staggerChildren:r,staggerDirection:a,repeat:i,repeatType:s,repeatDelay:o,from:l,elapsed:u,...c}){return!!Object.keys(c).length}const j0=(e,t,n,r={},a,i)=>s=>{const o=S0(r,e)||{},l=o.delay||r.delay||0;let{elapsed:u=0}=r;u=u-Tr(l);const c={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...o,delay:-u,onUpdate:p=>{t.set(p),o.onUpdate&&o.onUpdate(p)},onComplete:()=>{s(),o.onComplete&&o.onComplete()},name:e,motionValue:t,element:i?void 0:a};IF(o)||Object.assign(c,CF(e,c)),c.duration&&(c.duration=Tr(c.duration)),c.repeatDelay&&(c.repeatDelay=Tr(c.repeatDelay)),c.from!==void 0&&(c.keyframes[0]=c.from);let d=!1;if((c.type===!1||c.duration===0&&!c.repeatDelay)&&(T0(c),c.delay===0&&(d=!0)),(ra.instantAnimations||ra.skipAnimations)&&(d=!0,T0(c),c.delay=0),c.allowFlatten=!o.type&&!o.ease,d&&!i&&t.get()!==void 0){const p=wF(c.keyframes,o);if(p!==void 0){yt.update(()=>{c.onUpdate(p),c.onComplete()});return}}return o.isSync?new p0(c):new eP(c)};function RF({protectedKeys:e,needsAnimating:t},n){const r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function E2(e,t,{delay:n=0,transitionOverride:r,type:a}={}){let{transition:i=e.getDefaultTransition(),transitionEnd:s,...o}=t;r&&(i=r);const l=[],u=a&&e.animationState&&e.animationState.getState()[a];for(const c in o){const d=e.getValue(c,e.latestValues[c]??null),p=o[c];if(p===void 0||u&&RF(u,c))continue;const f={delay:n,...S0(i||{},c)},m=d.get();if(m!==void 0&&!d.isAnimating&&!Array.isArray(p)&&p===m&&!f.velocity)continue;let g=!1;if(window.MotionHandoffAnimation){const T=b2(e);if(T){const y=window.MotionHandoffAnimation(T,c,yt);y!==null&&(f.startTime=y,g=!0)}}q0(e,c),d.start(j0(c,d,p,e.shouldReduceMotion&&vS.has(c)?{type:!1}:f,e,g));const x=d.animation;x&&l.push(x)}return s&&Promise.all(l).then(()=>{yt.update(()=>{s&&TF(e,s)})}),l}function G0(e,t,n={}){const r=co(e,t,n.type==="exit"?e.presenceContext?.custom:void 0);let{transition:a=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(a=n.transitionOverride);const i=r?()=>Promise.all(E2(e,r,n)):()=>Promise.resolve(),s=e.variantChildren&&e.variantChildren.size?(l=0)=>{const{delayChildren:u=0,staggerChildren:c,staggerDirection:d}=a;return OF(e,t,l,u,c,d,n)}:()=>Promise.resolve(),{when:o}=a;if(o){const[l,u]=o==="beforeChildren"?[i,s]:[s,i];return l().then(()=>u())}else return Promise.all([i(),s(n.delay)])}function OF(e,t,n=0,r=0,a=0,i=1,s){const o=[],l=e.variantChildren.size,u=(l-1)*a,c=typeof r=="function",d=c?p=>r(p,l):i===1?(p=0)=>p*a:(p=0)=>u-p*a;return Array.from(e.variantChildren).sort(LF).forEach((p,f)=>{p.notify("AnimationStart",t),o.push(G0(p,t,{...s,delay:n+(c?0:r)+d(f)}).then(()=>p.notify("AnimationComplete",t)))}),Promise.all(o)}function LF(e,t){return e.sortNodePosition(t)}function DF(e,t,n={}){e.notify("AnimationStart",t);let r;if(Array.isArray(t)){const a=t.map(i=>G0(e,i,n));r=Promise.all(a)}else if(typeof t=="string")r=G0(e,t,n);else{const a=typeof t=="function"?co(e,t,n.custom):t;r=Promise.all(E2(e,a,n))}return r.then(()=>{e.notify("AnimationComplete",t)})}function y2(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}const MF=I0.length;function v2(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?v2(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<MF;n++){const r=I0[n],a=e.props[r];(lo(a)||a===!1)&&(t[r]=a)}return t}const PF=[...C0].reverse(),FF=C0.length;function BF(e){return t=>Promise.all(t.map(({animation:n,options:r})=>DF(e,n,r)))}function UF(e){let t=BF(e),n=T2(),r=!0;const a=l=>(u,c)=>{const d=co(e,c,l==="exit"?e.presenceContext?.custom:void 0);if(d){const{transition:p,transitionEnd:f,...m}=d;u={...u,...m,...f}}return u};function i(l){t=l(e)}function s(l){const{props:u}=e,c=v2(e.parent)||{},d=[],p=new Set;let f={},m=1/0;for(let x=0;x<FF;x++){const T=PF[x],y=n[T],w=u[T]!==void 0?u[T]:c[T],k=lo(w),_=T===l?y.isActive:null;_===!1&&(m=x);let A=w===c[T]&&w!==u[T]&&k;if(A&&r&&e.manuallyAnimateOnMount&&(A=!1),y.protectedKeys={...f},!y.isActive&&_===null||!w&&!y.prevProp||Xl(w)||typeof w=="boolean")continue;const R=HF(y.prevProp,w);let M=R||T===l&&y.isActive&&!A&&k||x>m&&k,P=!1;const D=Array.isArray(w)?w:[w];let z=D.reduce(a(T),{});_===!1&&(z={});const{prevResolvedValues:V={}}=y,W={...V,...z},K=ue=>{M=!0,p.has(ue)&&(P=!0,p.delete(ue)),y.needsAnimating[ue]=!0;const ee=e.getValue(ue);ee&&(ee.liveStyle=!1)};for(const ue in W){const ee=z[ue],fe=V[ue];if(f.hasOwnProperty(ue))continue;let C=!1;z0(ee)&&z0(fe)?C=!y2(ee,fe):C=ee!==fe,C?ee!=null?K(ue):p.add(ue):ee!==void 0&&p.has(ue)?K(ue):y.protectedKeys[ue]=!0}y.prevProp=w,y.prevResolvedValues=z,y.isActive&&(f={...f,...z}),r&&e.blockInitialAnimation&&(M=!1),M&&(!(A&&R)||P)&&d.push(...D.map(ue=>({animation:ue,options:{type:T}})))}if(p.size){const x={};if(typeof u.initial!="boolean"){const T=co(e,Array.isArray(u.initial)?u.initial[0]:u.initial);T&&T.transition&&(x.transition=T.transition)}p.forEach(T=>{const y=e.getBaseTarget(T),w=e.getValue(T);w&&(w.liveStyle=!0),x[T]=y??null}),d.push({animation:x})}let g=!!d.length;return r&&(u.initial===!1||u.initial===u.animate)&&!e.manuallyAnimateOnMount&&(g=!1),r=!1,g?t(d):Promise.resolve()}function o(l,u){if(n[l].isActive===u)return Promise.resolve();e.variantChildren?.forEach(d=>d.animationState?.setActive(l,u)),n[l].isActive=u;const c=s(l);for(const d in n)n[d].protectedKeys={};return c}return{animateChanges:s,setActive:o,setAnimateFunction:i,getState:()=>n,reset:()=>{n=T2(),r=!0}}}function HF(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!y2(t,e):!1}function di(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function T2(){return{animate:di(!0),whileInView:di(),whileHover:di(),whileTap:di(),whileDrag:di(),whileFocus:di(),exit:di()}}class Ra{constructor(t){this.isMounted=!1,this.node=t}update(){}}class $F extends Ra{constructor(t){super(t),t.animationState||(t.animationState=UF(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Xl(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let zF=0;class qF extends Ra{constructor(){super(...arguments),this.id=zF++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===r)return;const a=this.node.animationState.setActive("exit",!t);n&&!t&&a.then(()=>{n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const jF={animation:{Feature:$F},exit:{Feature:qF}};function po(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n)}function fo(e){return{point:{x:e.pageX,y:e.pageY}}}const GF=e=>t=>_0(t)&&e(t,fo(t));function ho(e,t,n,r){return po(e,t,GF(n),r)}const S2=1e-4,VF=1-S2,WF=1+S2,x2=.01,YF=0-x2,KF=0+x2;function wn(e){return e.max-e.min}function XF(e,t,n){return Math.abs(e-t)<=n}function w2(e,t,n,r=.5){e.origin=r,e.originPoint=xt(t.min,t.max,e.origin),e.scale=wn(n)/wn(t),e.translate=xt(n.min,n.max,e.origin)-e.originPoint,(e.scale>=VF&&e.scale<=WF||isNaN(e.scale))&&(e.scale=1),(e.translate>=YF&&e.translate<=KF||isNaN(e.translate))&&(e.translate=0)}function mo(e,t,n,r){w2(e.x,t.x,n.x,r?r.originX:void 0),w2(e.y,t.y,n.y,r?r.originY:void 0)}function A2(e,t,n){e.min=n.min+t.min,e.max=e.min+wn(t)}function ZF(e,t,n){A2(e.x,t.x,n.x),A2(e.y,t.y,n.y)}function _2(e,t,n){e.min=t.min-n.min,e.max=e.min+wn(t)}function go(e,t,n){_2(e.x,t.x,n.x),_2(e.y,t.y,n.y)}function ar(e){return[e("x"),e("y")]}const k2=({current:e})=>e?e.ownerDocument.defaultView:null,N2=(e,t)=>Math.abs(e-t);function QF(e,t){const n=N2(e.x,t.x),r=N2(e.y,t.y);return Math.sqrt(n**2+r**2)}class C2{constructor(t,n,{transformPagePoint:r,contextWindow:a=window,dragSnapToOrigin:i=!1,distanceThreshold:s=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const p=W0(this.lastMoveEventInfo,this.history),f=this.startEvent!==null,m=QF(p.offset,{x:0,y:0})>=this.distanceThreshold;if(!f&&!m)return;const{point:g}=p,{timestamp:x}=hn;this.history.push({...g,timestamp:x});const{onStart:T,onMove:y}=this.handlers;f||(T&&T(this.lastMoveEvent,p),this.startEvent=this.lastMoveEvent),y&&y(this.lastMoveEvent,p)},this.handlePointerMove=(p,f)=>{this.lastMoveEvent=p,this.lastMoveEventInfo=V0(f,this.transformPagePoint),yt.update(this.updatePoint,!0)},this.handlePointerUp=(p,f)=>{this.end();const{onEnd:m,onSessionEnd:g,resumeAnimation:x}=this.handlers;if(this.dragSnapToOrigin&&x&&x(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const T=W0(p.type==="pointercancel"?this.lastMoveEventInfo:V0(f,this.transformPagePoint),this.history);this.startEvent&&m&&m(p,T),g&&g(p,T)},!_0(t))return;this.dragSnapToOrigin=i,this.handlers=n,this.transformPagePoint=r,this.distanceThreshold=s,this.contextWindow=a||window;const o=fo(t),l=V0(o,this.transformPagePoint),{point:u}=l,{timestamp:c}=hn;this.history=[{...u,timestamp:c}];const{onSessionStart:d}=n;d&&d(t,W0(l,this.history)),this.removeListeners=eo(ho(this.contextWindow,"pointermove",this.handlePointerMove),ho(this.contextWindow,"pointerup",this.handlePointerUp),ho(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),Na(this.updatePoint)}}function V0(e,t){return t?{point:t(e.point)}:e}function I2(e,t){return{x:e.x-t.x,y:e.y-t.y}}function W0({point:e},t){return{point:e,delta:I2(e,R2(t)),offset:I2(e,JF(t)),velocity:eB(t,.1)}}function JF(e){return e[0]}function R2(e){return e[e.length-1]}function eB(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null;const a=R2(e);for(;n>=0&&(r=e[n],!(a.timestamp-r.timestamp>Tr(t)));)n--;if(!r)return{x:0,y:0};const i=Or(a.timestamp-r.timestamp);if(i===0)return{x:0,y:0};const s={x:(a.x-r.x)/i,y:(a.y-r.y)/i};return s.x===1/0&&(s.x=0),s.y===1/0&&(s.y=0),s}function tB(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?xt(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?xt(n,e,r.max):Math.min(e,n)),e}function O2(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function nB(e,{top:t,left:n,bottom:r,right:a}){return{x:O2(e.x,n,a),y:O2(e.y,t,r)}}function L2(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function rB(e,t){return{x:L2(e.x,t.x),y:L2(e.y,t.y)}}function aB(e,t){let n=.5;const r=wn(e),a=wn(t);return a>r?n=to(t.min,t.max-r,e.min):r>a&&(n=to(e.min,e.max-a,t.min)),ta(0,1,n)}function iB(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const Y0=.35;function sB(e=Y0){return e===!1?e=0:e===!0&&(e=Y0),{x:D2(e,"left","right"),y:D2(e,"top","bottom")}}function D2(e,t,n){return{min:M2(e,t),max:M2(e,n)}}function M2(e,t){return typeof e=="number"?e:e[t]||0}const oB=new WeakMap;class lB{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Dt(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:r}={}){const{presenceContext:a}=this.visualElement;if(a&&a.isPresent===!1)return;const i=d=>{const{dragSnapToOrigin:p}=this.getProps();p?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(fo(d).point)},s=(d,p)=>{const{drag:f,dragPropagation:m,onDragStart:g}=this.getProps();if(f&&!m&&(this.openDragLock&&this.openDragLock(),this.openDragLock=gP(f),!this.openDragLock))return;this.latestPointerEvent=d,this.latestPanInfo=p,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),ar(T=>{let y=this.getAxisMotionValue(T).get()||0;if(Lr.test(y)){const{projection:w}=this.visualElement;if(w&&w.layout){const k=w.layout.layoutBox[T];k&&(y=wn(k)*(parseFloat(y)/100))}}this.originPoint[T]=y}),g&&yt.postRender(()=>g(d,p)),q0(this.visualElement,"transform");const{animationState:x}=this.visualElement;x&&x.setActive("whileDrag",!0)},o=(d,p)=>{this.latestPointerEvent=d,this.latestPanInfo=p;const{dragPropagation:f,dragDirectionLock:m,onDirectionLock:g,onDrag:x}=this.getProps();if(!f&&!this.openDragLock)return;const{offset:T}=p;if(m&&this.currentDirection===null){this.currentDirection=uB(T),this.currentDirection!==null&&g&&g(this.currentDirection);return}this.updateAxis("x",p.point,T),this.updateAxis("y",p.point,T),this.visualElement.render(),x&&x(d,p)},l=(d,p)=>{this.latestPointerEvent=d,this.latestPanInfo=p,this.stop(d,p),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>ar(d=>this.getAnimationState(d)==="paused"&&this.getAxisMotionValue(d).animation?.play()),{dragSnapToOrigin:c}=this.getProps();this.panSession=new C2(t,{onSessionStart:i,onStart:s,onMove:o,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:c,distanceThreshold:r,contextWindow:k2(this.visualElement)})}stop(t,n){const r=t||this.latestPointerEvent,a=n||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!a||!r)return;const{velocity:s}=a;this.startAnimation(s);const{onDragEnd:o}=this.getProps();o&&yt.postRender(()=>o(r,a))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(t,n,r){const{drag:a}=this.getProps();if(!r||!eu(t,a,this.currentDirection))return;const i=this.getAxisMotionValue(t);let s=this.originPoint[t]+r[t];this.constraints&&this.constraints[t]&&(s=tB(s,this.constraints[t],this.elastic[t])),i.set(s)}resolveConstraints(){const{dragConstraints:t,dragElastic:n}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,a=this.constraints;t&&Yi(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&r?this.constraints=nB(r.layoutBox,t):this.constraints=!1,this.elastic=sB(n),a!==this.constraints&&r&&this.constraints&&!this.hasMutatedConstraints&&ar(i=>{this.constraints!==!1&&this.getAxisMotionValue(i)&&(this.constraints[i]=iB(r.layoutBox[i],this.constraints[i]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Yi(t))return!1;const r=t.current;na(r!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:a}=this.visualElement;if(!a||!a.layout)return!1;const i=uF(r,a.root,this.visualElement.getTransformPagePoint());let s=rB(a.layout.layoutBox,i);if(n){const o=n(sF(s));this.hasMutatedConstraints=!!o,o&&(s=t2(o))}return s}startAnimation(t){const{drag:n,dragMomentum:r,dragElastic:a,dragTransition:i,dragSnapToOrigin:s,onDragTransitionEnd:o}=this.getProps(),l=this.constraints||{},u=ar(c=>{if(!eu(c,n,this.currentDirection))return;let d=l&&l[c]||{};s&&(d={min:0,max:0});const p=a?200:1e6,f=a?40:1e7,m={type:"inertia",velocity:r?t[c]:0,bounceStiffness:p,bounceDamping:f,timeConstant:750,restDelta:1,restSpeed:10,...i,...d};return this.startAxisValueAnimation(c,m)});return Promise.all(u).then(o)}startAxisValueAnimation(t,n){const r=this.getAxisMotionValue(t);return q0(this.visualElement,t),r.start(j0(t,r,0,n,this.visualElement,!1))}stopAnimation(){ar(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){ar(t=>this.getAxisMotionValue(t).animation?.pause())}getAnimationState(t){return this.getAxisMotionValue(t).animation?.state}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,r=this.visualElement.getProps(),a=r[n];return a||this.visualElement.getValue(t,(r.initial?r.initial[t]:void 0)||0)}snapToCursor(t){ar(n=>{const{drag:r}=this.getProps();if(!eu(n,r,this.currentDirection))return;const{projection:a}=this.visualElement,i=this.getAxisMotionValue(n);if(a&&a.layout){const{min:s,max:o}=a.layout.layoutBox[n];i.set(t[n]-xt(s,o,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!Yi(n)||!r||!this.constraints)return;this.stopAnimation();const a={x:0,y:0};ar(s=>{const o=this.getAxisMotionValue(s);if(o&&this.constraints!==!1){const l=o.get();a[s]=aB({min:l,max:l},this.constraints[s])}});const{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.resolveConstraints(),ar(s=>{if(!eu(s,t,null))return;const o=this.getAxisMotionValue(s),{min:l,max:u}=this.constraints[s];o.set(xt(l,u,a[s]))})}addListeners(){if(!this.visualElement.current)return;oB.set(this.visualElement,this);const t=this.visualElement.current,n=ho(t,"pointerdown",l=>{const{drag:u,dragListener:c=!0}=this.getProps();u&&c&&this.start(l)}),r=()=>{const{dragConstraints:l}=this.getProps();Yi(l)&&l.current&&(this.constraints=this.resolveRefConstraints())},{projection:a}=this.visualElement,i=a.addEventListener("measure",r);a&&!a.layout&&(a.root&&a.root.updateScroll(),a.updateLayout()),yt.read(r);const s=po(window,"resize",()=>this.scalePositionWithinConstraints()),o=a.addEventListener("didUpdate",({delta:l,hasLayoutChanged:u})=>{this.isDragging&&u&&(ar(c=>{const d=this.getAxisMotionValue(c);d&&(this.originPoint[c]+=l[c].translate,d.set(d.get()+l[c].translate))}),this.visualElement.render())});return()=>{s(),n(),i(),o&&o()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:r=!1,dragPropagation:a=!1,dragConstraints:i=!1,dragElastic:s=Y0,dragMomentum:o=!0}=t;return{...t,drag:n,dragDirectionLock:r,dragPropagation:a,dragConstraints:i,dragElastic:s,dragMomentum:o}}}function eu(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function uB(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class cB extends Ra{constructor(t){super(t),this.removeGroupControls=rr,this.removeListeners=rr,this.controls=new lB(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||rr}unmount(){this.removeGroupControls(),this.removeListeners()}}const P2=e=>(t,n)=>{e&&yt.postRender(()=>e(t,n))};class dB extends Ra{constructor(){super(...arguments),this.removePointerDownListener=rr}onPointerDown(t){this.session=new C2(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:k2(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:r,onPanEnd:a}=this.node.getProps();return{onSessionStart:P2(t),onStart:P2(n),onMove:r,onEnd:(i,s)=>{delete this.session,a&&yt.postRender(()=>a(i,s))}}}mount(){this.removePointerDownListener=ho(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const tu={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function F2(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const bo={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(Ue.test(e))e=parseFloat(e);else return e;const n=F2(e,t.target.x),r=F2(e,t.target.y);return`${n}% ${r}%`}},pB={correct:(e,{treeScale:t,projectionDelta:n})=>{const r=e,a=Ia.parse(e);if(a.length>5)return r;const i=Ia.createTransformer(e),s=typeof a[0]!="number"?1:0,o=n.x.scale*t.x,l=n.y.scale*t.y;a[0+s]/=o,a[1+s]/=l;const u=xt(o,l,.5);return typeof a[2+s]=="number"&&(a[2+s]/=u),typeof a[3+s]=="number"&&(a[3+s]/=u),i(a)}};let B2=!1;class fB extends v.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r,layoutId:a}=this.props,{projection:i}=t;MP(hB),i&&(n.group&&n.group.add(i),r&&r.register&&a&&r.register(i),B2&&i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,onExitComplete:()=>this.safeToRemove()})),tu.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:r,drag:a,isPresent:i}=this.props,{projection:s}=r;return s&&(s.isPresent=i,B2=!0,a||t.layoutDependency!==n||n===void 0||t.isPresent!==i?s.willUpdate():this.safeToRemove(),t.isPresent!==i&&(i?s.promote():s.relegate()||yt.postRender(()=>{const o=s.getStack();(!o||!o.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),A0.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r}=this.props,{projection:a}=t;a&&(a.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(a),r&&r.deregister&&r.deregister(a))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function U2(e){const[t,n]=FS(),r=v.useContext(Bd);return b.jsx(fB,{...e,layoutGroup:r,switchLayoutGroup:v.useContext(JS),isPresent:t,safeToRemove:n})}const hB={borderRadius:{...bo,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:bo,borderTopRightRadius:bo,borderBottomLeftRadius:bo,borderBottomRightRadius:bo,boxShadow:pB};function mB(e,t,n){const r=bn(e)?e:Vi(e);return r.start(j0("",r,t,n)),r.animation}const gB=(e,t)=>e.depth-t.depth;class bB{constructor(){this.children=[],this.isDirty=!1}add(t){$d(this.children,t),this.isDirty=!0}remove(t){zd(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(gB),this.isDirty=!1,this.children.forEach(t)}}function EB(e,t){const n=Pn.now(),r=({timestamp:a})=>{const i=a-n;i>=t&&(Na(r),e(i-t))};return yt.setup(r,!0),()=>Na(r)}const H2=["TopLeft","TopRight","BottomLeft","BottomRight"],yB=H2.length,$2=e=>typeof e=="string"?parseFloat(e):e,z2=e=>typeof e=="number"||Ue.test(e);function vB(e,t,n,r,a,i){a?(e.opacity=xt(0,n.opacity??1,TB(r)),e.opacityExit=xt(t.opacity??1,0,SB(r))):i&&(e.opacity=xt(t.opacity??1,n.opacity??1,r));for(let s=0;s<yB;s++){const o=`border${H2[s]}Radius`;let l=q2(t,o),u=q2(n,o);if(l===void 0&&u===void 0)continue;l||(l=0),u||(u=0),l===0||u===0||z2(l)===z2(u)?(e[o]=Math.max(xt($2(l),$2(u),r),0),(Lr.test(u)||Lr.test(l))&&(e[o]+="%")):e[o]=u}(t.rotate||n.rotate)&&(e.rotate=xt(t.rotate||0,n.rotate||0,r))}function q2(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const TB=j2(0,.5,FT),SB=j2(.5,.95,rr);function j2(e,t,n){return r=>r<e?0:r>t?1:n(to(e,t,r))}function G2(e,t){e.min=t.min,e.max=t.max}function ir(e,t){G2(e.x,t.x),G2(e.y,t.y)}function V2(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function W2(e,t,n,r,a){return e-=t,e=Jl(e,1/n,r),a!==void 0&&(e=Jl(e,1/a,r)),e}function xB(e,t=0,n=1,r=.5,a,i=e,s=e){if(Lr.test(t)&&(t=parseFloat(t),t=xt(s.min,s.max,t/100)-s.min),typeof t!="number")return;let o=xt(i.min,i.max,r);e===i&&(o-=t),e.min=W2(e.min,t,n,o,a),e.max=W2(e.max,t,n,o,a)}function Y2(e,t,[n,r,a],i,s){xB(e,t[n],t[r],t[a],t.scale,i,s)}const wB=["x","scaleX","originX"],AB=["y","scaleY","originY"];function K2(e,t,n,r){Y2(e.x,t,wB,n?n.x:void 0,r?r.x:void 0),Y2(e.y,t,AB,n?n.y:void 0,r?r.y:void 0)}function X2(e){return e.translate===0&&e.scale===1}function Z2(e){return X2(e.x)&&X2(e.y)}function Q2(e,t){return e.min===t.min&&e.max===t.max}function _B(e,t){return Q2(e.x,t.x)&&Q2(e.y,t.y)}function J2(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function ex(e,t){return J2(e.x,t.x)&&J2(e.y,t.y)}function tx(e){return wn(e.x)/wn(e.y)}function nx(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class kB{constructor(){this.members=[]}add(t){$d(this.members,t),t.scheduleRender()}remove(t){if(zd(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){const n=this.members.findIndex(a=>t===a);if(n===0)return!1;let r;for(let a=n;a>=0;a--){const i=this.members[a];if(i.isPresent!==!1){r=i;break}}return r?(this.promote(r),!0):!1}promote(t,n){const r=this.lead;if(t!==r&&(this.prevLead=r,this.lead=t,t.show(),r)){r.instance&&r.scheduleRender(),t.scheduleRender(),t.resumeFrom=r,n&&(t.resumeFrom.preserveOpacity=!0),r.snapshot&&(t.snapshot=r.snapshot,t.snapshot.latestValues=r.animationValues||r.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0);const{crossfade:a}=t.options;a===!1&&r.hide()}}exitAnimationComplete(){this.members.forEach(t=>{const{options:n,resumingFrom:r}=t;n.onExitComplete&&n.onExitComplete(),r&&r.options.onExitComplete&&r.options.onExitComplete()})}scheduleRender(){this.members.forEach(t=>{t.instance&&t.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function NB(e,t,n){let r="";const a=e.x.translate/t.x,i=e.y.translate/t.y,s=n?.z||0;if((a||i||s)&&(r=`translate3d(${a}px, ${i}px, ${s}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:u,rotate:c,rotateX:d,rotateY:p,skewX:f,skewY:m}=n;u&&(r=`perspective(${u}px) ${r}`),c&&(r+=`rotate(${c}deg) `),d&&(r+=`rotateX(${d}deg) `),p&&(r+=`rotateY(${p}deg) `),f&&(r+=`skewX(${f}deg) `),m&&(r+=`skewY(${m}deg) `)}const o=e.x.scale*t.x,l=e.y.scale*t.y;return(o!==1||l!==1)&&(r+=`scale(${o}, ${l})`),r||"none"}const K0=["","X","Y","Z"],CB=1e3;let IB=0;function X0(e,t,n,r){const{latestValues:a}=t;a[e]&&(n[e]=a[e],t.setStaticValue(e,0),r&&(r[e]=0))}function rx(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=b2(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:a,layoutId:i}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",yt,!(a||i))}const{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&rx(r)}function ax({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:a}){return class{constructor(s={},o=t?.()){this.id=IB++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(LB),this.nodes.forEach(FB),this.nodes.forEach(BB),this.nodes.forEach(DB)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=s,this.root=o?o.root||o:this,this.path=o?[...o.path,o]:[],this.parent=o,this.depth=o?o.depth+1:0;for(let l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new bB)}addEventListener(s,o){return this.eventHandlers.has(s)||this.eventHandlers.set(s,new Gd),this.eventHandlers.get(s).add(o)}notifyListeners(s,...o){const l=this.eventHandlers.get(s);l&&l.notify(...o)}hasListeners(s){return this.eventHandlers.has(s)}mount(s){if(this.instance)return;this.isSVG=PS(s)&&!SP(s),this.instance=s;const{layoutId:o,layout:l,visualElement:u}=this.options;if(u&&!u.current&&u.mount(s),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||o)&&(this.isLayoutDirty=!0),e){let c,d=0;const p=()=>this.root.updateBlockedByResize=!1;yt.read(()=>{d=window.innerWidth}),e(s,()=>{const f=window.innerWidth;f!==d&&(d=f,this.root.updateBlockedByResize=!0,c&&c(),c=EB(p,250),tu.hasAnimatedSinceResize&&(tu.hasAnimatedSinceResize=!1,this.nodes.forEach(ox)))})}o&&this.root.registerSharedNode(o,this),this.options.animate!==!1&&u&&(o||l)&&this.addEventListener("didUpdate",({delta:c,hasLayoutChanged:d,hasRelativeLayoutChanged:p,layout:f})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const m=this.options.transition||u.getDefaultTransition()||qB,{onLayoutAnimationStart:g,onLayoutAnimationComplete:x}=u.getProps(),T=!this.targetLayout||!ex(this.targetLayout,f),y=!d&&p;if(this.options.layoutRoot||this.resumeFrom||y||d&&(T||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const w={...S0(m,"layout"),onPlay:g,onComplete:x};(u.shouldReduceMotion||this.options.layoutRoot)&&(w.delay=0,w.type=!1),this.startAnimation(w),this.setAnimationOrigin(c,y)}else d||ox(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=f})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const s=this.getStack();s&&s.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Na(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(UB),this.animationId++)}getTransformTemplate(){const{visualElement:s}=this.options;return s&&s.getProps().transformTemplate}willUpdate(s=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&rx(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let c=0;c<this.path.length;c++){const d=this.path[c];d.shouldResetTransform=!0,d.updateScroll("snapshot"),d.options.layoutRoot&&d.willUpdate(!1)}const{layoutId:o,layout:l}=this.options;if(o===void 0&&!l)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),s&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(ix);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(sx);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(PB),this.nodes.forEach(RB),this.nodes.forEach(OB)):this.nodes.forEach(sx),this.clearAllSnapshots();const o=Pn.now();hn.delta=ta(0,1e3/60,o-hn.timestamp),hn.timestamp=o,hn.isProcessing=!0,Kd.update.process(hn),Kd.preRender.process(hn),Kd.render.process(hn),hn.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,A0.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(MB),this.sharedNodes.forEach(HB)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,yt.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){yt.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!wn(this.snapshot.measuredBox.x)&&!wn(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let l=0;l<this.path.length;l++)this.path[l].updateScroll();const s=this.layout;this.layout=this.measure(!1),this.layoutCorrected=Dt(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:o}=this.options;o&&o.notify("LayoutMeasure",this.layout.layoutBox,s?s.layoutBox:void 0)}updateScroll(s="measure"){let o=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===s&&(o=!1),o&&this.instance){const l=r(this.instance);this.scroll={animationId:this.root.animationId,phase:s,isRoot:l,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!a)return;const s=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,o=this.projectionDelta&&!Z2(this.projectionDelta),l=this.getTransformTemplate(),u=l?l(this.latestValues,""):void 0,c=u!==this.prevTransformTemplateValue;s&&this.instance&&(o||ci(this.latestValues)||c)&&(a(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(s=!0){const o=this.measurePageBox();let l=this.removeElementScroll(o);return s&&(l=this.removeTransform(l)),jB(l),{animationId:this.root.animationId,measuredBox:o,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:s}=this.options;if(!s)return Dt();const o=s.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(GB))){const{scroll:u}=this.root;u&&(Ki(o.x,u.offset.x),Ki(o.y,u.offset.y))}return o}removeElementScroll(s){const o=Dt();if(ir(o,s),this.scroll?.wasRoot)return o;for(let l=0;l<this.path.length;l++){const u=this.path[l],{scroll:c,options:d}=u;u!==this.root&&c&&d.layoutScroll&&(c.wasRoot&&ir(o,s),Ki(o.x,c.offset.x),Ki(o.y,c.offset.y))}return o}applyTransform(s,o=!1){const l=Dt();ir(l,s);for(let u=0;u<this.path.length;u++){const c=this.path[u];!o&&c.options.layoutScroll&&c.scroll&&c!==c.root&&Xi(l,{x:-c.scroll.offset.x,y:-c.scroll.offset.y}),ci(c.latestValues)&&Xi(l,c.latestValues)}return ci(this.latestValues)&&Xi(l,this.latestValues),l}removeTransform(s){const o=Dt();ir(o,s);for(let l=0;l<this.path.length;l++){const u=this.path[l];if(!u.instance||!ci(u.latestValues))continue;U0(u.latestValues)&&u.updateSnapshot();const c=Dt(),d=u.measurePageBox();ir(c,d),K2(o,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,c)}return ci(this.latestValues)&&K2(o,this.latestValues),o}setTargetDelta(s){this.targetDelta=s,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(s){this.options={...this.options,...s,crossfade:s.crossfade!==void 0?s.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==hn.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(s=!1){const o=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=o.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=o.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=o.isSharedProjectionDirty);const l=!!this.resumingFrom||this!==o;if(!(s||l&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:c,layoutId:d}=this.options;if(!(!this.layout||!(c||d))){if(this.resolvedRelativeTargetAt=hn.timestamp,!this.targetDelta&&!this.relativeTarget){const p=this.getClosestProjectingParent();p&&p.layout&&this.animationProgress!==1?(this.relativeParent=p,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Dt(),this.relativeTargetOrigin=Dt(),go(this.relativeTargetOrigin,this.layout.layoutBox,p.layout.layoutBox),ir(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=Dt(),this.targetWithTransforms=Dt()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),ZF(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):ir(this.target,this.layout.layoutBox),i2(this.target,this.targetDelta)):ir(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const p=this.getClosestProjectingParent();p&&!!p.resumingFrom==!!this.resumingFrom&&!p.options.layoutScroll&&p.target&&this.animationProgress!==1?(this.relativeParent=p,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Dt(),this.relativeTargetOrigin=Dt(),go(this.relativeTargetOrigin,this.target,p.target),ir(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||U0(this.parent.latestValues)||n2(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){const s=this.getLead(),o=!!this.resumingFrom||this!==s;let l=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(l=!1),o&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(l=!1),this.resolvedRelativeTargetAt===hn.timestamp&&(l=!1),l)return;const{layout:u,layoutId:c}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(u||c))return;ir(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,p=this.treeScale.y;lF(this.layoutCorrected,this.treeScale,this.path,o),s.layout&&!s.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(s.target=s.layout.layoutBox,s.targetWithTransforms=Dt());const{target:f}=s;if(!f){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(V2(this.prevProjectionDelta.x,this.projectionDelta.x),V2(this.prevProjectionDelta.y,this.projectionDelta.y)),mo(this.projectionDelta,this.layoutCorrected,f,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==p||!nx(this.projectionDelta.x,this.prevProjectionDelta.x)||!nx(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",f))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(s=!0){if(this.options.visualElement?.scheduleRender(),s){const o=this.getStack();o&&o.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Zi(),this.projectionDelta=Zi(),this.projectionDeltaWithTransform=Zi()}setAnimationOrigin(s,o=!1){const l=this.snapshot,u=l?l.latestValues:{},c={...this.latestValues},d=Zi();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!o;const p=Dt(),f=l?l.source:void 0,m=this.layout?this.layout.source:void 0,g=f!==m,x=this.getStack(),T=!x||x.members.length<=1,y=!!(g&&!T&&this.options.crossfade===!0&&!this.path.some(zB));this.animationProgress=0;let w;this.mixTargetDelta=k=>{const _=k/1e3;lx(d.x,s.x,_),lx(d.y,s.y,_),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(go(p,this.layout.layoutBox,this.relativeParent.layout.layoutBox),$B(this.relativeTarget,this.relativeTargetOrigin,p,_),w&&_B(this.relativeTarget,w)&&(this.isProjectionDirty=!1),w||(w=Dt()),ir(w,this.relativeTarget)),g&&(this.animationValues=c,vB(c,u,this.latestValues,_,y,T)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=_},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(s){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Na(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=yt.update(()=>{tu.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Vi(0)),this.currentAnimation=mB(this.motionValue,[0,1e3],{...s,velocity:0,isSync:!0,onUpdate:o=>{this.mixTargetDelta(o),s.onUpdate&&s.onUpdate(o)},onStop:()=>{},onComplete:()=>{s.onComplete&&s.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const s=this.getStack();s&&s.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(CB),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const s=this.getLead();let{targetWithTransforms:o,target:l,layout:u,latestValues:c}=s;if(!(!o||!l||!u)){if(this!==s&&this.layout&&u&&fx(this.options.animationType,this.layout.layoutBox,u.layoutBox)){l=this.target||Dt();const d=wn(this.layout.layoutBox.x);l.x.min=s.target.x.min,l.x.max=l.x.min+d;const p=wn(this.layout.layoutBox.y);l.y.min=s.target.y.min,l.y.max=l.y.min+p}ir(o,l),Xi(o,c),mo(this.projectionDeltaWithTransform,this.layoutCorrected,o,c)}}registerSharedNode(s,o){this.sharedNodes.has(s)||this.sharedNodes.set(s,new kB),this.sharedNodes.get(s).add(o);const u=o.options.initialPromotionConfig;o.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(o):void 0})}isLead(){const s=this.getStack();return s?s.lead===this:!0}getLead(){const{layoutId:s}=this.options;return s?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:s}=this.options;return s?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:s}=this.options;if(s)return this.root.sharedNodes.get(s)}promote({needsReset:s,transition:o,preserveFollowOpacity:l}={}){const u=this.getStack();u&&u.promote(this,l),s&&(this.projectionDelta=void 0,this.needsReset=!0),o&&this.setOptions({transition:o})}relegate(){const s=this.getStack();return s?s.relegate(this):!1}resetSkewAndRotation(){const{visualElement:s}=this.options;if(!s)return;let o=!1;const{latestValues:l}=s;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(o=!0),!o)return;const u={};l.z&&X0("z",s,u,this.animationValues);for(let c=0;c<K0.length;c++)X0(`rotate${K0[c]}`,s,u,this.animationValues),X0(`skew${K0[c]}`,s,u,this.animationValues);s.render();for(const c in u)s.setStaticValue(c,u[c]),this.animationValues&&(this.animationValues[c]=u[c]);s.scheduleRender()}applyProjectionStyles(s,o){if(!this.instance||this.isSVG)return;if(!this.isVisible){s.visibility="hidden";return}const l=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,s.visibility="",s.opacity="",s.pointerEvents=Ql(o?.pointerEvents)||"",s.transform=l?l(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(s.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,s.pointerEvents=Ql(o?.pointerEvents)||""),this.hasProjected&&!ci(this.latestValues)&&(s.transform=l?l({},""):"none",this.hasProjected=!1);return}s.visibility="";const c=u.animationValues||u.latestValues;this.applyTransformsToTarget();let d=NB(this.projectionDeltaWithTransform,this.treeScale,c);l&&(d=l(c,d)),s.transform=d;const{x:p,y:f}=this.projectionDelta;s.transformOrigin=`${p.origin*100}% ${f.origin*100}% 0`,u.animationValues?s.opacity=u===this?c.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:c.opacityExit:s.opacity=u===this?c.opacity!==void 0?c.opacity:"":c.opacityExit!==void 0?c.opacityExit:0;for(const m in uo){if(c[m]===void 0)continue;const{correct:g,applyTo:x,isCSSVariable:T}=uo[m],y=d==="none"?c[m]:g(c[m],u);if(x){const w=x.length;for(let k=0;k<w;k++)s[x[k]]=y}else T?this.options.visualElement.renderState.vars[m]=y:s[m]=y}this.options.layoutId&&(s.pointerEvents=u===this?Ql(o?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(s=>s.currentAnimation?.stop()),this.root.nodes.forEach(ix),this.root.sharedNodes.clear()}}}function RB(e){e.updateLayout()}function OB(e){const t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:r}=e.layout,{animationType:a}=e.options,i=t.source!==e.layout.source;a==="size"?ar(c=>{const d=i?t.measuredBox[c]:t.layoutBox[c],p=wn(d);d.min=n[c].min,d.max=d.min+p}):fx(a,t.layoutBox,n)&&ar(c=>{const d=i?t.measuredBox[c]:t.layoutBox[c],p=wn(n[c]);d.max=d.min+p,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[c].max=e.relativeTarget[c].min+p)});const s=Zi();mo(s,n,t.layoutBox);const o=Zi();i?mo(o,e.applyTransform(r,!0),t.measuredBox):mo(o,n,t.layoutBox);const l=!Z2(s);let u=!1;if(!e.resumeFrom){const c=e.getClosestProjectingParent();if(c&&!c.resumeFrom){const{snapshot:d,layout:p}=c;if(d&&p){const f=Dt();go(f,t.layoutBox,d.layoutBox);const m=Dt();go(m,n,p.layoutBox),ex(f,m)||(u=!0),c.options.layoutRoot&&(e.relativeTarget=m,e.relativeTargetOrigin=f,e.relativeParent=c)}}}e.notifyListeners("didUpdate",{layout:n,snapshot:t,delta:o,layoutDelta:s,hasLayoutChanged:l,hasRelativeLayoutChanged:u})}else if(e.isLead()){const{onExitComplete:n}=e.options;n&&n()}e.options.transition=void 0}function LB(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function DB(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function MB(e){e.clearSnapshot()}function ix(e){e.clearMeasurements()}function sx(e){e.isLayoutDirty=!1}function PB(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function ox(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function FB(e){e.resolveTargetDelta()}function BB(e){e.calcProjection()}function UB(e){e.resetSkewAndRotation()}function HB(e){e.removeLeadSnapshot()}function lx(e,t,n){e.translate=xt(t.translate,0,n),e.scale=xt(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function ux(e,t,n,r){e.min=xt(t.min,n.min,r),e.max=xt(t.max,n.max,r)}function $B(e,t,n,r){ux(e.x,t.x,n.x,r),ux(e.y,t.y,n.y,r)}function zB(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const qB={duration:.45,ease:[.4,0,.1,1]},cx=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),dx=cx("applewebkit/")&&!cx("chrome/")?Math.round:rr;function px(e){e.min=dx(e.min),e.max=dx(e.max)}function jB(e){px(e.x),px(e.y)}function fx(e,t,n){return e==="position"||e==="preserve-aspect"&&!XF(tx(t),tx(n),.2)}function GB(e){return e!==e.root&&e.scroll?.wasRoot}const VB=ax({attachResizeListener:(e,t)=>po(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Z0={current:void 0},hx=ax({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Z0.current){const e=new VB({});e.mount(window),e.setOptions({layoutScroll:!0}),Z0.current=e}return Z0.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),WB={pan:{Feature:dB},drag:{Feature:cB,ProjectionNode:hx,MeasureLayout:U2}};function mx(e,t,n){const{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive("whileHover",n==="Start");const a="onHover"+n,i=r[a];i&&yt.postRender(()=>i(t,fo(t)))}class YB extends Ra{mount(){const{current:t}=this.node;t&&(this.unmount=bP(t,(n,r)=>(mx(this.node,r,"Start"),a=>mx(this.node,a,"End"))))}unmount(){}}class KB extends Ra{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=eo(po(this.node.current,"focus",()=>this.onFocus()),po(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function gx(e,t,n){const{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive("whileTap",n==="Start");const a="onTap"+(n==="End"?"":n),i=r[a];i&&yt.postRender(()=>i(t,fo(t)))}class XB extends Ra{mount(){const{current:t}=this.node;t&&(this.unmount=TP(t,(n,r)=>(gx(this.node,r,"Start"),(a,{success:i})=>gx(this.node,a,i?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const Q0=new WeakMap,J0=new WeakMap,ZB=e=>{const t=Q0.get(e.target);t&&t(e)},QB=e=>{e.forEach(ZB)};function JB({root:e,...t}){const n=e||document;J0.has(n)||J0.set(n,{});const r=J0.get(n),a=JSON.stringify(t);return r[a]||(r[a]=new IntersectionObserver(QB,{root:e,...t})),r[a]}function eU(e,t,n){const r=JB(t);return Q0.set(e,n),r.observe(e),()=>{Q0.delete(e),r.unobserve(e)}}const tU={some:0,all:1};class nU extends Ra{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:r,amount:a="some",once:i}=t,s={root:n?n.current:void 0,rootMargin:r,threshold:typeof a=="number"?a:tU[a]},o=l=>{const{isIntersecting:u}=l;if(this.isInView===u||(this.isInView=u,i&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:c,onViewportLeave:d}=this.node.getProps(),p=u?c:d;p&&p(l)};return eU(this.node.current,s,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(rU(t,n))&&this.startObserver()}unmount(){}}function rU({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const aU={...jF,...{inView:{Feature:nU},tap:{Feature:XB},focus:{Feature:KB},hover:{Feature:YB}},...WB,...{layout:{ProjectionNode:hx,MeasureLayout:U2}}},ke=iF(aU,EF);function Eo({isOpen:e,onClose:t,title:n,children:r,maxWidth:a="max-w-2xl"}){return b.jsx(Dr,{children:e&&b.jsxs(Nd,{static:!0,open:e,onClose:t,className:"relative z-50",children:[b.jsxs(ke.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.4,ease:"easeInOut"},className:"fixed inset-0","aria-hidden":"true",children:[b.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-black/40 via-black/30 to-black/50"}),b.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-neutral-900/20 via-transparent to-neutral-800/10"}),b.jsxs("div",{className:"absolute inset-0 opacity-30",children:[b.jsx("div",{className:"absolute top-0 left-0 w-full h-full bg-gradient-to-br from-indigo-500/5 via-transparent to-purple-500/5"}),b.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_center,_var(--tw-gradient-stops))] from-transparent via-white/2 to-transparent"})]})]}),b.jsx("div",{className:"fixed inset-0 flex w-screen items-center justify-center p-4",children:b.jsx(ke.div,{initial:{opacity:0,scale:.9,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.9,y:20},transition:{duration:.3,ease:[.4,0,.2,1],opacity:{duration:.25}},children:b.jsxs(Bl,{className:`w-full ${a} min-w-xl space-y-4 rounded-2xl border border-neutral-200/20 bg-white/95 p-8 shadow-2xl shadow-black/20 backdrop-blur-xl dark:border-neutral-700/30 dark:bg-neutral-900/95 dark:shadow-black/40`,children:[b.jsx(pT,{className:"text-lg font-bold text-neutral-900 dark:text-neutral-100",children:n}),r]})})})]})})}const iU=({isOpen:e,onClose:t,server:n,toolName:r,toolDescription:a})=>{const{token:i,backendUrl:s,addToolExecution:o}=Kt(),[l,u]=v.useState("{}"),[c,d]=v.useState(null),[p,f]=v.useState(!1),[m,g]=v.useState(null),x=k=>{try{return JSON.parse(k),g(null),!0}catch{return g("Invalid JSON format"),!1}},T=k=>{u(k),m&&x(k)},y=async()=>{if(x(l)){f(!0),d(null);try{const k=Date.now(),_=await fetch(`${s}/api/v1/mcps/${n.id}/tools/${r}/test`,{method:"POST",headers:{"Content-Type":"application/json",...i&&{Authorization:`Bearer ${i}`}},body:JSON.stringify({parameters:JSON.parse(l)})}),R=Date.now()-k;if(_.ok){const M=await _.json(),P={success:M.success,result:M.result,error:M.error,executionTime:M.execution_time_ms||R};d(P),o({serverId:n.id,toolName:r,parameters:JSON.parse(l),result:M.result,success:M.success,error:M.error,executionTime:M.execution_time_ms||R})}else{const M=await _.json(),P={success:!1,error:M.detail||"Tool execution failed",executionTime:R};d(P),o({serverId:n.id,toolName:r,parameters:JSON.parse(l),success:!1,error:M.detail||"Tool execution failed",executionTime:R})}}catch(k){const _={success:!1,error:k instanceof Error?k.message:"Network error",executionTime:Date.now()-Date.now()};d(_),o({serverId:n.id,toolName:r,parameters:JSON.parse(l),success:!1,error:k instanceof Error?k.message:"Network error",executionTime:Date.now()-Date.now()})}finally{f(!1)}}},w=()=>{p||(u("{}"),d(null),g(null),t())};return b.jsx(Eo,{isOpen:e,onClose:w,title:"Test MCP Tool",maxWidth:"max-w-[calc(100vw-200px)]",children:b.jsxs("div",{className:"flex flex-col h-[calc(100vh-200px)] gap-6",children:[b.jsxs("div",{className:"flex flex-1 gap-6 min-h-0",children:[b.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[b.jsxs("div",{className:"rounded-lg bg-neutral-50 p-4 dark:bg-neutral-800/50 mb-6",children:[b.jsxs("div",{className:"flex items-center space-x-2 mb-3",children:[b.jsx(TT,{className:"h-5 w-5 text-indigo-500"}),b.jsx("h3",{className:"font-medium text-neutral-900 dark:text-white",children:"Tool Information"})]}),b.jsxs("div",{className:"space-y-3",children:[b.jsxs("div",{children:[b.jsx("span",{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Tool Name:"}),b.jsx("code",{className:"ml-2 rounded bg-neutral-200 px-2 py-1 text-sm font-mono text-indigo-600 dark:bg-neutral-700 dark:text-indigo-400",children:r})]}),b.jsxs("div",{children:[b.jsx("span",{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Server:"}),b.jsxs("span",{className:"ml-2 text-sm text-neutral-600 dark:text-neutral-400",children:[n.name," (",n.url,")"]})]}),a&&b.jsxs("div",{children:[b.jsx("span",{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Description:"}),b.jsx("p",{className:"mt-1 text-sm text-neutral-600 dark:text-neutral-400 leading-relaxed",children:a})]})]})]}),b.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[b.jsxs("label",{className:"mb-3 flex items-center space-x-2 text-sm font-medium text-neutral-700 dark:text-neutral-300",children:[b.jsx(rM,{className:"h-4 w-4"}),b.jsx("span",{children:"Parameters (JSON)"})]}),b.jsx("textarea",{value:l,onChange:k=>T(k.target.value),placeholder:'{"key": "value"}',className:"flex-1 w-full rounded-lg border border-neutral-300 bg-white px-3 py-2 text-sm font-mono text-neutral-900 placeholder-neutral-500 focus:border-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/20 dark:border-neutral-600 dark:bg-neutral-800 dark:text-neutral-100 dark:placeholder-neutral-400 resize-none min-h-[200px]"}),m&&b.jsxs("div",{className:"mt-2 flex items-center space-x-2 text-sm text-red-600 dark:text-red-400",children:[b.jsx(ST,{className:"h-4 w-4"}),b.jsx("span",{children:m})]})]})]}),b.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[b.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx("div",{className:"h-5 w-5 rounded-full bg-gradient-to-r from-green-500 to-emerald-500 flex items-center justify-center",children:b.jsx("span",{className:"text-white text-xs font-bold",children:"R"})}),b.jsx("h3",{className:"font-medium text-neutral-900 dark:text-white",children:"Test Results"})]}),b.jsx(xn,{onClick:y,disabled:p||!!m,className:"inline-flex items-center gap-2 rounded-lg bg-gradient-to-r from-indigo-600 to-indigo-700 px-4 py-2 text-sm font-medium text-white shadow-lg transition-all hover:from-indigo-500 hover:to-indigo-600 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed",children:p?b.jsxs(b.Fragment,{children:[b.jsx(Ui,{size:"sm"}),"Running..."]}):b.jsxs(b.Fragment,{children:[b.jsx(Dd,{className:"h-4 w-4"}),"Test Tool"]})})]}),b.jsx("div",{className:"flex-1 overflow-y-auto min-w-0",children:b.jsxs(Dr,{mode:"wait",children:[p&&b.jsxs(ke.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.2},className:"flex flex-col items-center justify-center h-64 text-center",children:[b.jsx(Ui,{size:"lg",centered:!0}),b.jsx("p",{className:"mt-4 text-sm text-neutral-600 dark:text-neutral-400",children:"Executing tool..."})]},"loading"),!p&&!c&&b.jsxs(ke.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{duration:.2},className:"flex flex-col items-center justify-center h-64 text-center",children:[b.jsx("div",{className:"rounded-full bg-neutral-100 dark:bg-neutral-800 p-6 mb-4",children:b.jsx(Dd,{className:"h-12 w-12 text-neutral-400 dark:text-neutral-500"})}),b.jsx("p",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:'Click "Test Tool" to see results here'})]},"empty"),!p&&c&&b.jsxs(ke.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.3},className:`rounded-lg border p-4 ${c.success?"border-green-200 bg-green-50 dark:border-green-800 dark:bg-green-900/20":"border-red-200 bg-red-50 dark:border-red-800 dark:bg-red-900/20"}`,children:[b.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[b.jsx("h4",{className:`font-semibold ${c.success?"text-green-800 dark:text-green-300":"text-red-800 dark:text-red-300"}`,children:c.success?"✅ Success":"❌ Error"}),c.executionTime&&b.jsxs("span",{className:"text-xs font-medium text-neutral-600 dark:text-neutral-400 bg-neutral-100 dark:bg-neutral-800 px-2 py-1 rounded",children:[c.executionTime,"ms"]})]}),b.jsxs("div",{className:"space-y-4",children:[c.success&&c.result!==null&&c.result!==void 0&&b.jsxs("div",{children:[b.jsx("span",{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300 mb-2 block",children:"Result:"}),b.jsx("pre",{className:"overflow-auto rounded-lg bg-neutral-900 p-4 text-sm text-green-400 dark:bg-neutral-800 max-h-96 whitespace-pre-wrap break-words",children:typeof c.result=="string"?c.result:JSON.stringify(c.result,null,2)??"null"})]}),!c.success&&c.error&&b.jsxs("div",{children:[b.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-300 mb-2 block",children:"Error:"}),b.jsx("pre",{className:"overflow-auto rounded-lg bg-neutral-900 p-4 text-sm text-red-400 dark:bg-neutral-800 max-h-96 whitespace-pre-wrap break-words",children:c.error})]})]})]},"result")]})})]})]}),b.jsx("div",{className:"flex-shrink-0 flex justify-end pt-4 border-t border-neutral-200 dark:border-neutral-700",children:b.jsx(xn,{onClick:w,disabled:p,className:"rounded-lg bg-neutral-200 px-6 py-2 text-sm font-medium text-neutral-700 transition-colors hover:bg-neutral-300 focus:outline-none focus:ring-2 focus:ring-neutral-500 focus:ring-offset-2 disabled:opacity-50 dark:bg-neutral-700 dark:text-neutral-200 dark:hover:bg-neutral-600",children:"Close"})})]})})},sU=e=>{const t=Kt.getState().backendUrl,n=new URL(t);return`${n.protocol==="https:"?"wss:":"ws:"}//${n.host}${e}`};class oU{ws=null;connect(t,n){this.ws&&this.ws.close();const r=sU(t);this.ws=new WebSocket(r),this.ws.onopen=()=>{console.log("WebSocket connected")},this.ws.onmessage=a=>{try{const i=JSON.parse(a.data);n(i)}catch(i){console.error("Failed to parse WebSocket message:",i)}},this.ws.onerror=a=>{console.error("WebSocket error:",a)},this.ws.onclose=()=>{console.log("WebSocket disconnected")}}disconnect(){this.ws&&(this.ws.close(),this.ws=null)}}const bx=new oU,lU=({status:e})=>{const t=e==="online";return b.jsxs("div",{className:"flex items-center",children:[b.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${t?"bg-green-500":"bg-red-500"}`}),b.jsx("span",{className:`ml-2 text-xs font-medium transition-colors duration-200 ${t?"text-green-700 dark:text-green-300":"text-red-700 dark:text-red-300"}`,children:t?"Online":"Offline"})]})},uU=({server:e,onRemove:t,onTestTool:n})=>{const r=e.tools?.length||0,[a,i]=v.useState(!1),[s,o]=v.useState(!1),l=async()=>{i(!0);try{await t(e.id)}catch(c){i(!1),console.error("Failed to remove server:",c)}},u=()=>{r>0&&o(!s)};return b.jsxs(ke.div,{layout:!0,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2},className:"group relative overflow-hidden rounded-xl border border-neutral-200/50 bg-white/50 shadow-sm backdrop-blur-sm transition-all duration-300 hover:border-indigo-200 hover:bg-white/80 hover:shadow-md dark:border-neutral-800/50 dark:bg-neutral-900/50 dark:hover:border-indigo-800 dark:hover:bg-neutral-900/80",children:[b.jsxs("div",{className:"flex items-center justify-between p-4",children:[b.jsxs("div",{className:"flex-1 overflow-hidden",children:[b.jsxs("div",{className:"flex items-center",children:[b.jsx(lU,{status:e.status}),b.jsxs("div",{className:"ml-3 flex items-center space-x-2",children:[b.jsx(Md,{className:"h-4 w-4 text-indigo-500"}),b.jsx("h3",{className:"truncate text-sm font-semibold text-neutral-800 dark:text-white",children:e.name})]})]}),e.description&&b.jsx("p",{className:"mt-2 truncate text-xs text-neutral-600 dark:text-neutral-400",children:e.description}),b.jsxs("div",{className:"mt-3 flex items-center space-x-4 text-xs text-neutral-500",children:[b.jsxs("div",{className:"flex items-center space-x-1",children:[b.jsx(oM,{className:"h-3.5 w-3.5"}),b.jsx("span",{className:"truncate max-w-48",children:e.url})]}),b.jsxs(ke.button,{onClick:u,disabled:r===0,className:`flex items-center space-x-1 rounded-md px-2 py-1 transition-colors ${r>0?"hover:bg-indigo-50 dark:hover:bg-indigo-900/20":"cursor-not-allowed opacity-50"}`,children:[b.jsx(AM,{className:"h-3.5 w-3.5"}),b.jsxs("span",{className:"whitespace-nowrap font-medium",children:[r," ",r===1?"Tool":"Tools"]}),r>0&&b.jsx(ke.div,{animate:{rotate:s?90:0},transition:{duration:.2},children:b.jsx(ET,{className:"h-3 w-3"})})]})]})]}),b.jsx("div",{className:"ml-6 flex items-center",children:b.jsx(ke.button,{whileTap:{scale:.95},onClick:l,disabled:a,className:"rounded-lg p-2 text-neutral-400 opacity-0 transition-all duration-200 hover:bg-red-50 hover:text-red-600 group-hover:opacity-100 disabled:opacity-50 dark:hover:bg-red-900/20 dark:hover:text-red-400",title:"Remove Server",children:a?b.jsx(ke.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:b.jsx(Ui,{size:"sm"})}):b.jsx(wT,{className:"h-4 w-4"})})})]}),b.jsx(Dr,{children:s&&r>0&&b.jsx(ke.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.3,ease:"easeInOut"},className:"overflow-hidden border-t border-neutral-200/30 dark:border-neutral-700/30",children:b.jsxs("div",{className:"p-4 pt-3",children:[b.jsxs("div",{className:"mb-2 flex items-center space-x-2",children:[b.jsx(TT,{className:"h-3.5 w-3.5 text-indigo-500"}),b.jsx("span",{className:"text-xs font-medium text-neutral-700 dark:text-neutral-300",children:"Available Tools"})]}),b.jsx("div",{className:"max-h-64 overflow-y-auto space-y-2 scrollbar-thin scrollbar-thumb-neutral-300 scrollbar-track-transparent dark:scrollbar-thumb-neutral-600 pr-2",children:e.tools?.map((c,d)=>b.jsxs(ke.button,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:d*.05},onClick:()=>n(e,c.name,c.description),className:"w-full flex items-start justify-between rounded-lg bg-neutral-50/80 p-3 text-left transition-all hover:bg-neutral-100/80 hover:shadow-sm active:scale-[0.99] dark:bg-neutral-800/50 dark:hover:bg-neutral-700/50 group cursor-pointer",children:[b.jsxs("div",{className:"flex-1 min-w-0",children:[b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx("code",{className:"text-xs font-mono font-semibold text-indigo-600 dark:text-indigo-400",children:c.name}),b.jsx("span",{className:"text-xs text-neutral-500 opacity-0 group-hover:opacity-100 transition-opacity",children:"Click to test"})]}),c.description&&b.jsx("p",{className:"mt-1 text-xs text-neutral-600 dark:text-neutral-400 line-clamp-2",children:c.description})]}),b.jsx("div",{className:"ml-3 opacity-60 group-hover:opacity-100 transition-opacity",children:b.jsx(Dd,{className:"h-4 w-4 text-indigo-500"})})]},`${c.name}-${d}`))})]})})})]})};function cU(){const{mcpServers:e,fetchMcpServers:t,refreshMcpServers:n,removeMcpServer:r,updateMcpServerInList:a,backendUrl:i,openAddMcpServerModal:s,getLoading:o,toolTestModal:l,openToolTestModal:u,closeToolTestModal:c}=Kt(),d=o("mcpServers"),p=(m,g,x)=>{u(m,g,x)};v.useEffect(()=>{if(i)return t(),bx.connect("/ws/v1/mcp",m=>{a(m)}),()=>{bx.disconnect()}},[i,t,a]);const f=()=>{n()};return b.jsxs("div",{className:"min-h-full rounded-2xl bg-gradient-to-br from-neutral-50 via-white to-neutral-100 p-6 dark:from-neutral-950 dark:via-neutral-900 dark:to-neutral-950",children:[b.jsxs(ke.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5},className:"mx-auto max-w-6xl",children:[b.jsxs(ke.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,delay:.1},className:"mb-8 flex items-center justify-between",children:[b.jsxs("div",{className:"flex items-center space-x-3",children:[b.jsx("div",{className:"rounded-xl bg-gradient-to-r from-indigo-500 to-purple-500 p-2.5 shadow-lg",children:b.jsx(Md,{className:"h-6 w-6 text-white"})}),b.jsxs("div",{children:[b.jsx("h1",{className:"text-2xl font-bold tracking-tight text-neutral-900 dark:text-neutral-100",children:"MCP Servers"}),b.jsx("p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:"Manage your Model-Context-Protocol servers."})]})]}),b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsxs("button",{onClick:f,disabled:d,className:"inline-flex items-center gap-2 rounded-xl border border-neutral-200 bg-white px-4 py-2.5 text-sm font-semibold text-neutral-700 shadow-sm transition-colors hover:bg-neutral-50 disabled:cursor-not-allowed disabled:opacity-50 dark:border-neutral-800 dark:bg-neutral-900 dark:text-neutral-200 dark:hover:bg-neutral-800",children:[b.jsx(mT,{className:`h-4 w-4 ${d?"animate-spin":""}`}),b.jsx("span",{children:"Refresh"})]}),b.jsxs("button",{onClick:s,className:"inline-flex items-center gap-2 rounded-xl bg-gradient-to-r from-indigo-600 to-indigo-700 px-4 py-2.5 text-sm font-semibold text-white shadow-lg shadow-indigo-500/25 transition-all duration-200 hover:from-indigo-500 hover:to-indigo-600 hover:shadow-xl hover:shadow-indigo-500/30 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 dark:shadow-indigo-500/20 dark:hover:shadow-indigo-500/40",children:[b.jsx(ii,{className:"h-4 w-4"}),"Add Server"]})]})]}),b.jsx(ke.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,delay:.2},className:"relative",children:b.jsxs("div",{className:"relative min-h-[66vh] max-h-[66vh] overflow-hidden rounded-3xl border border-neutral-200/30 bg-gradient-to-br from-white/80 via-white/60 to-white/40 backdrop-blur-xl dark:border-neutral-700/30 dark:from-neutral-900/80 dark:via-neutral-900/60 dark:to-neutral-900/40",children:[b.jsxs("div",{className:"absolute inset-0 opacity-30",children:[b.jsx("div",{className:"absolute top-0 right-0 w-96 h-96 bg-gradient-to-bl from-indigo-100/50 via-transparent to-transparent rounded-full blur-3xl dark:from-indigo-900/30"}),b.jsx("div",{className:"absolute bottom-0 left-0 w-80 h-80 bg-gradient-to-tr from-purple-100/40 via-transparent to-transparent rounded-full blur-3xl dark:from-purple-900/20"})]}),b.jsx("div",{className:"relative h-full overflow-y-auto p-8 scrollbar-thin scrollbar-thumb-neutral-300 scrollbar-track-transparent dark:scrollbar-thumb-neutral-600",children:b.jsx(Dr,{mode:"wait",children:d?b.jsx(ke.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex items-center justify-center h-full min-h-[400px]",children:b.jsxs("div",{className:"text-center",children:[b.jsx(Ui,{size:"md",centered:!0}),b.jsx("p",{className:"mt-3 text-sm text-neutral-600 dark:text-neutral-400",children:"Loading MCP servers..."})]})},"loading"):e.length>0?b.jsx(ke.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"space-y-4",children:b.jsx(Dr,{children:e.map((m,g)=>b.jsx(ke.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.3,delay:g*.1},children:b.jsx(uU,{server:m,onRemove:r,onTestTool:p})},m.id))})},"servers"):b.jsxs(ke.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3},className:"flex flex-col items-center justify-center h-full min-h-[400px] text-center",children:[b.jsx(ke.div,{initial:{scale:0},animate:{scale:1},transition:{duration:.5,delay:.2,type:"spring"},className:"mb-6 rounded-full bg-gradient-to-br from-indigo-100/80 to-purple-100/60 p-6 dark:from-indigo-900/40 dark:to-purple-900/30",children:b.jsx(Ld,{className:"h-12 w-12 text-indigo-500"})}),b.jsxs(ke.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.3,delay:.4},children:[b.jsx("h3",{className:"text-xl font-semibold text-neutral-900 dark:text-white",children:"No MCP Servers Found"}),b.jsx("p",{className:"mt-2 max-w-md text-sm text-neutral-600 dark:text-neutral-400",children:"Get started by adding your first MCP server to connect tools and enhance your AI capabilities."})]}),b.jsx(ke.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.3,delay:.6},children:b.jsxs(xn,{onClick:s,className:"mt-8 inline-flex items-center gap-2 rounded-xl bg-gradient-to-r from-indigo-600 to-indigo-700 px-6 py-3 text-sm font-semibold text-white transition-all duration-200 hover:from-indigo-500 hover:to-indigo-600 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2",children:[b.jsx(ii,{className:"h-5 w-5"}),"Add Your First Server"]})})]},"empty")})})]})})]}),l.isOpen&&l.server&&l.toolName&&b.jsx(iU,{isOpen:l.isOpen,onClose:c,server:l.server,toolName:l.toolName,toolDescription:l.toolDescription})]})}const nu=e=>b.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",fillRule:"evenodd",viewBox:"0 0 24 24",...e,children:[b.jsx("title",{children:"ModelContextProtocol"}),b.jsx("path",{d:"M15.688 2.343a2.588 2.588 0 00-3.61 0l-9.626 9.44a.863.863 0 01-1.203 0 .823.823 0 010-1.18l9.626-9.44a4.313 4.313 0 016.016 0 4.116 4.116 0 011.204 3.54 4.3 4.3 0 013.609 1.18l.05.05a4.115 4.115 0 010 5.9l-8.706 8.537a.274.274 0 000 .393l1.788 1.754a.823.823 0 010 1.18.863.863 0 01-1.203 0l-1.788-1.753a1.92 1.92 0 010-2.754l8.706-8.538a2.47 2.47 0 000-3.54l-.05-.049a2.588 2.588 0 00-3.607-.003l-7.172 7.034-.002.002-.098.097a.863.863 0 01-1.204 0 .823.823 0 010-1.18l7.273-7.133a2.47 2.47 0 00-.003-3.537z"}),b.jsx("path",{d:"M14.485 4.703a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a4.115 4.115 0 000 5.9 4.314 4.314 0 006.016 0l7.12-6.982a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a2.588 2.588 0 01-3.61 0 2.47 2.47 0 010-3.54l7.12-6.982z"})]});function dU(){const[e,t]=v.useState({state:Gn.NOT_AUTHENTICATED,message:"检查中..."}),[n,r]=v.useState(!0),a=v.useCallback(l=>{t(l),r(!1)},[]),i=v.useCallback(async(l=!1)=>{r(!0);try{const u=await $t.checkAuthState(l);t(u)}catch(u){console.error("Auth check failed:",u),t({state:Gn.ERROR,message:u instanceof Error?u.message:"认证检查失败"})}finally{r(!1)}},[]),s=v.useCallback(async l=>{r(!0);try{const u=await $t.login(l);t(u)}catch(u){console.error("Login failed:",u),t({state:Gn.ERROR,message:u instanceof Error?u.message:"登录失败"})}finally{r(!1)}},[]),o=v.useCallback(()=>{$t.logout()},[]);return v.useEffect(()=>((async()=>{r(!0);try{const u=await $t.autoLogin();t(u)}catch(u){console.error("Auto-login failed:",u),t({state:Gn.ERROR,message:u instanceof Error?u.message:"自动登录失败"})}finally{r(!1)}})(),$t.addAuthStateListener(a),()=>{$t.removeAuthStateListener(a)}),[a]),{authState:e.state,user:e.user,message:e.message,provider:e.provider,isLoading:n,isAuthenticated:e.state===Gn.AUTHENTICATED,isConfigured:e.state!==Gn.NOT_CONFIGURED,login:s,logout:o,checkAuth:i}}function pU({isOpen:e,onClose:t,onSubmit:n}){const[r,a]=v.useState(""),i=l=>{l.preventDefault(),r.trim()&&(n(r.trim()),a(""),t())},s=v.useCallback(()=>{a(""),t()},[t]),o=l=>{l.target===l.currentTarget&&s()};return v.useEffect(()=>{const l=u=>{u.key==="Escape"&&s()};if(e)return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[e,s]),e?b.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50",onClick:o,children:b.jsxs("div",{className:"w-full max-w-md rounded-lg bg-white p-6 shadow-xl dark:bg-neutral-800",children:[b.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[b.jsx("h3",{className:"text-lg font-medium text-neutral-900 dark:text-neutral-100",children:"输入访问令牌"}),b.jsx("button",{onClick:s,className:"rounded-md p-1 text-neutral-400 hover:bg-neutral-100 hover:text-neutral-500 dark:hover:bg-neutral-700",children:b.jsx(Fd,{className:"h-5 w-5"})})]}),b.jsxs("form",{onSubmit:i,children:[b.jsxs("div",{className:"mb-4",children:[b.jsx("label",{htmlFor:"token-input",className:"block text-sm font-medium text-neutral-700 dark:text-neutral-300 mb-2",children:"访问令牌"}),b.jsx("input",{id:"token-input",type:"password",value:r,onChange:l=>a(l.target.value),placeholder:"请输入您的访问令牌",className:"w-full rounded-md border border-neutral-300 px-3 py-2 text-sm focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500 dark:border-neutral-600 dark:bg-neutral-700 dark:text-neutral-100",autoFocus:!0,required:!0}),b.jsx("p",{className:"mt-1 text-xs text-neutral-500 dark:text-neutral-400",children:"请输入有效的访问令牌进行身份验证"})]}),b.jsxs("div",{className:"flex justify-end space-x-3",children:[b.jsx("button",{type:"button",onClick:s,className:"rounded-md px-4 py-2 text-sm font-medium text-neutral-700 hover:bg-neutral-50 dark:text-neutral-300 dark:hover:bg-neutral-700",children:"取消"}),b.jsx("button",{type:"submit",className:"rounded-md bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2",children:"确认"})]})]})]})}):null}function fU({onTokenInput:e,className:t=""}){const n=dU(),[r,a]=v.useState(!1),i=async s=>{await n.login(s),e?.(s)};if(n.isLoading)return b.jsxs("div",{className:`flex items-center space-x-2 ${t}`,children:[b.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-neutral-300 border-t-indigo-600 dark:border-neutral-700 dark:border-t-indigo-500"}),b.jsx("span",{className:"text-sm text-neutral-500",children:"检查认证状态..."})]});switch(n.authState){case Gn.NOT_CONFIGURED:case Gn.NOT_AUTHENTICATED:case Gn.ERROR:{const s=n.authState===Gn.NOT_CONFIGURED?"认证服务未配置":n.authState===Gn.ERROR?"认证错误":"未授权的用户";return b.jsxs(b.Fragment,{children:[b.jsx("div",{className:`flex items-center space-x-2 ${t}`,children:b.jsx("button",{onClick:()=>a(!0),className:"flex items-center justify-center h-6 w-6 rounded-full text-amber-600 hover:bg-amber-50 dark:text-amber-400 dark:hover:bg-amber-900/20 transition-colors",title:s,children:b.jsx(Ld,{className:"h-4 w-4"})})}),b.jsx(pU,{isOpen:r,onClose:()=>a(!1),onSubmit:i})]})}case Gn.AUTHENTICATED:return b.jsx("div",{className:`flex items-center space-x-2 ${t}`,children:b.jsxs("div",{className:"flex items-center space-x-2",children:[n.user?.avatar_url?b.jsx("img",{src:n.user.avatar_url,alt:n.user.display_name||n.user.username,className:"h-6 w-6 rounded-full"}):b.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-indigo-100 dark:bg-indigo-900",children:b.jsx(Pd,{className:"h-4 w-4 text-indigo-600 dark:text-indigo-400"})}),b.jsx("div",{className:"flex flex-col",children:b.jsx("span",{className:"text-sm font-medium max-w-16 truncate text-neutral-900 dark:text-neutral-100",children:n.user?.display_name||n.user?.username})})]})});default:return b.jsxs("div",{className:`flex items-center space-x-2 ${t}`,children:[b.jsx(Ld,{className:"h-5 w-5 text-red-500"}),b.jsx("span",{className:"text-sm text-red-600",title:n.message,children:"未知状态"})]})}}const Ex=({children:e,variant:t="default",size:n="sm",className:r})=>{const a="inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium",i={default:"bg-neutral-100 text-neutral-800 dark:bg-neutral-800 dark:text-neutral-200",blue:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",green:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",yellow:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200",red:"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200",gray:"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-200"},s={sm:"text-xs",md:"text-sm px-2.5 py-1"};return b.jsx("span",{className:Oi(a,i[t],s[n],r),children:e})},hU="block w-full appearance-none rounded-lg border-[1px] border-neutral-300 bg-white py-[calc(theme(spacing.2)-1px)] px-[calc(theme(spacing.3)-1px)] text-neutral-950 placeholder:text-neutral-500 sm:text-sm/6 focus:outline-none focus:ring-1 focus:ring-inset focus:ring-indigo-500 dark:border-neutral-700 dark:bg-neutral-800 dark:text-white dark:focus:ring-indigo-400";function Vn({className:e,...t}){return b.jsx("span",{className:Oi(e,"relative"),children:b.jsx(dD,{className:Oi(hU,"pr-8"),...t})})}const mU={type:"spring",stiffness:700,damping:30},gU=({checked:e,onChange:t,className:n,disabled:r=!1})=>b.jsxs(vD,{checked:e,onChange:t,disabled:r,className:Oi("group relative inline-flex h-6 w-11 flex-shrink-0 rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 dark:focus:ring-offset-neutral-900",n,{"cursor-pointer":!r,"cursor-not-allowed opacity-50":r},e?"bg-indigo-600":"bg-neutral-200 dark:bg-neutral-700"),children:[b.jsx("span",{className:"sr-only",children:"Use setting"}),b.jsx(ke.span,{animate:{x:e?20:0},transition:mU,className:"pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow ring-0"})]}),yx=({mcp:e,isSelected:t,onSelectionChange:n})=>{const r=e.status!=="online";return b.jsxs("div",{className:Oi("flex items-center justify-between rounded-lg p-3 transition-colors",{"hover:bg-neutral-100 dark:hover:bg-neutral-800":!r,"opacity-60":r}),title:r?"This MCP server is offline and cannot be selected":"",children:[b.jsxs("div",{className:"flex-grow",children:[b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx("div",{className:Oi("h-2.5 w-2.5 flex-shrink-0 rounded-full",{"bg-green-500":!r,"bg-neutral-500":r})}),b.jsx("p",{className:"font-medium text-neutral-900 dark:text-neutral-100",children:e.name}),e.tools&&e.tools.length>0&&b.jsxs(Ex,{variant:"blue",children:[e.tools.length," Tools"]})]}),b.jsx("p",{className:"mt-1 text-sm text-neutral-600 dark:text-neutral-400 line-clamp-1",children:e.description||"No description available"})]}),b.jsx("div",{className:"ml-4",children:b.jsx(gU,{checked:t,onChange:n,disabled:r})})]})},bU=({isOpen:e,onClose:t})=>{const{createAgent:n,mcpServers:r,fetchMcpServers:a,openAddMcpServerModal:i}=Kt(),[s,o]=v.useState({name:"",description:"",prompt:""}),[l,u]=v.useState([]);v.useEffect(()=>{e&&a()},[e,a]);const c=f=>{const{name:m,value:g}=f.target;o(x=>({...x,[m]:g}))},d=f=>{u(m=>m.includes(f)?m.filter(g=>g!==f):[...m,f])},p=async f=>{if(f.preventDefault(),!s.name){alert("助手名称不能为空");return}try{await n({...s,mcp_server_ids:l,user_id:"temp",mcp_servers:[]}),t(),o({name:"",description:"",prompt:""}),u([])}catch(m){console.error("Failed to create agent:",m),alert("创建助手失败,请查看控制台获取更多信息。")}};return b.jsxs(Eo,{isOpen:e,onClose:t,title:"添加新助手",children:[b.jsx("p",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:"创建一个新的助手来协助您完成任务。"}),b.jsxs("form",{onSubmit:p,className:"mt-4 space-y-4",children:[b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"名称"}),b.jsx(Vn,{name:"name",value:s.name,onChange:c,placeholder:"例如:研究助手",required:!0})]}),b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"描述"}),b.jsx("textarea",{name:"description",value:s.description,onChange:c,placeholder:"助手的目的简要描述",className:"w-full rounded-md border-neutral-300 bg-neutral-100 px-3 py-2 text-sm text-neutral-900 placeholder-neutral-400 focus:border-indigo-500 focus:ring-indigo-500 dark:border-neutral-700 dark:bg-neutral-800 dark:text-neutral-100 dark:placeholder-neutral-500"})]}),b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"系统提示"}),b.jsx("textarea",{name:"prompt",value:s.prompt,onChange:c,placeholder:"定义助手的行为和个性",rows:4,className:"w-full rounded-md border-neutral-300 bg-neutral-100 px-3 py-2 text-sm text-neutral-900 placeholder-neutral-400 focus:border-indigo-500 focus:ring-indigo-500 dark:border-neutral-700 dark:bg-neutral-800 dark:text-neutral-100 dark:placeholder-neutral-500"})]}),b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"连接的 MCP 服务器"}),b.jsx("div",{className:"mt-2 max-h-40 space-y-1 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50 p-2 dark:border-neutral-700 dark:bg-neutral-800/50",children:r.length>0?r.map(f=>b.jsx(yx,{mcp:f,isSelected:l.includes(f.id),onSelectionChange:()=>d(f.id)},f.id)):b.jsxs("div",{className:"flex flex-col items-center justify-center p-4 text-center",children:[b.jsx("p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:"No MCP servers available."}),b.jsxs(xn,{type:"button",onClick:()=>{t(),i()},className:"mt-2 inline-flex items-center gap-2 rounded-md bg-indigo-100 py-1.5 px-3 text-sm/6 font-semibold text-indigo-600 focus:outline-none data-[hover]:bg-indigo-200 dark:bg-indigo-900/50 dark:text-indigo-300 dark:data-[hover]:bg-indigo-900",children:[b.jsx(ii,{className:"h-4 w-4"}),"Create MCP Server"]})]})})]}),b.jsxs("div",{className:"mt-6 flex justify-end gap-4",children:[b.jsx(xn,{type:"button",onClick:t,className:"inline-flex items-center gap-2 rounded-md bg-neutral-100 py-1.5 px-3 text-sm/6 font-semibold text-neutral-700 shadow-sm focus:outline-none data-[hover]:bg-neutral-200 dark:bg-neutral-800 dark:text-neutral-200 dark:data-[hover]:bg-neutral-700",children:"取消"}),b.jsx(xn,{type:"submit",className:"inline-flex items-center gap-2 rounded-md bg-indigo-600 py-1.5 px-3 text-sm/6 font-semibold text-white shadow-inner shadow-white/10 focus:outline-none data-[hover]:bg-indigo-500 data-[open]:bg-indigo-700 data-[focus]:outline-1 data-[focus]:outline-white dark:bg-indigo-500 dark:data-[hover]:bg-indigo-400",children:"创建助手"})]})]})]})},EU=({isOpen:e,onClose:t,agent:n})=>{const{updateAgent:r,mcpServers:a,fetchMcpServers:i,openAddMcpServerModal:s}=Kt(),[o,l]=v.useState(n),[u,c]=v.useState([]);v.useEffect(()=>{l(n),n&&c(n.mcp_servers.map(m=>m.id)),e&&i()},[n,e,i]);const d=m=>{if(!o)return;const{name:g,value:x}=m.target;l({...o,[g]:x})},p=m=>{c(g=>g.includes(m)?g.filter(x=>x!==m):[...g,m])},f=async m=>{m.preventDefault(),o&&(await r({...o,mcp_server_ids:u}),t())};return o?b.jsxs(Eo,{isOpen:e,onClose:t,title:`Edit ${o.name}`,children:[b.jsx("p",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:"Update the details for your agent."}),b.jsxs("form",{onSubmit:f,className:"mt-4 space-y-4",children:[b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Name"}),b.jsx(Vn,{name:"name",value:o.name,onChange:d,placeholder:"e.g., Research Assistant",required:!0})]}),b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Description"}),b.jsx("textarea",{name:"description",value:o.description,onChange:d,placeholder:"A brief description of the agent's purpose",className:"w-full rounded-md border-neutral-300 bg-neutral-100 px-3 py-2 text-sm text-neutral-900 placeholder-neutral-400 focus:border-indigo-500 focus:ring-indigo-500 dark:border-neutral-700 dark:bg-neutral-800 dark:text-neutral-100 dark:placeholder-neutral-500"})]}),b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"System Prompt"}),b.jsx("textarea",{name:"prompt",value:o.prompt,onChange:d,placeholder:"Define the agent's behavior and personality",rows:4,className:"w-full rounded-md border-neutral-300 bg-neutral-100 px-3 py-2 text-sm text-neutral-900 placeholder-neutral-400 focus:border-indigo-500 focus:ring-indigo-500 dark:border-neutral-700 dark:bg-neutral-800 dark:text-neutral-100 dark:placeholder-neutral-500"})]}),b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Connected MCP Servers"}),b.jsx("div",{className:"mt-2 max-h-40 space-y-1 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50 p-2 dark:border-neutral-700 dark:bg-neutral-800/50",children:a.length>0?a.map(m=>b.jsx(yx,{mcp:m,isSelected:u.includes(m.id),onSelectionChange:()=>p(m.id)},m.id)):b.jsxs("div",{className:"flex flex-col items-center justify-center p-4 text-center",children:[b.jsx("p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:"No MCP servers available."}),b.jsxs(xn,{type:"button",onClick:()=>{t(),s()},className:"mt-2 inline-flex items-center gap-2 rounded-md bg-indigo-100 py-1.5 px-3 text-sm/6 font-semibold text-indigo-600 focus:outline-none data-[hover]:bg-indigo-200 dark:bg-indigo-900/50 dark:text-indigo-300 dark:data-[hover]:bg-indigo-900",children:[b.jsx(ii,{className:"h-4 w-4"}),"Create MCP Server"]})]})})]}),b.jsxs("div",{className:"mt-6 flex justify-end gap-4",children:[b.jsx(xn,{type:"button",onClick:t,className:"inline-flex items-center gap-2 rounded-md bg-neutral-100 py-1.5 px-3 text-sm/6 font-semibold text-neutral-700 shadow-sm focus:outline-none data-[hover]:bg-neutral-200 dark:bg-neutral-800 dark:text-neutral-200 dark:data-[hover]:bg-neutral-700",children:"Cancel"}),b.jsx(xn,{type:"submit",className:"inline-flex items-center gap-2 rounded-md bg-indigo-600 py-1.5 px-3 text-sm/6 font-semibold text-white shadow-inner shadow-white/10 focus:outline-none data-[hover]:bg-indigo-500 data-[open]:bg-indigo-700 data-[focus]:outline-1 data-[focus]:outline-white dark:bg-indigo-500 dark:data-[hover]:bg-indigo-400",children:"Save Changes"})]})]})]}):null},yU={hidden:{y:20,opacity:0},visible:{y:0,opacity:1,transition:{type:"spring",stiffness:100,damping:12}}},vU=({agent:e,onClick:t,onEdit:n})=>b.jsxs(ke.div,{layout:!0,variants:yU,whileHover:{scale:1.03,transition:{duration:.2}},whileTap:{scale:.98},onClick:()=>t?.(e),className:`
54
+ `),()=>{g.contains(m)&&g.removeChild(m)}},[t]),b.jsx(AP,{isPresent:t,childRef:i,sizeRef:s,children:Y.cloneElement(e,{ref:i})})}const kP=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:a,presenceAffectsLayout:i,mode:s,anchorX:o,root:l})=>{const u=Ud(NP),c=v.useId();let d=!0,p=v.useMemo(()=>(d=!1,{id:c,initial:t,isPresent:n,custom:a,onExitComplete:f=>{u.set(f,!0);for(const m of u.values())if(!m)return;r&&r()},register:f=>(u.set(f,!1),()=>u.delete(f))}),[n,u,r]);return i&&d&&(p={...p}),v.useMemo(()=>{u.forEach((f,m)=>u.set(m,!1))},[n]),Y.useEffect(()=>{!n&&!u.size&&r&&r()},[n]),s==="popLayout"&&(e=b.jsx(_P,{isPresent:n,anchorX:o,root:l,children:e})),b.jsx(Ul.Provider,{value:p,children:e})};function NP(){return new Map}function FS(e=!0){const t=v.useContext(Ul);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:r,register:a}=t,i=v.useId();v.useEffect(()=>{if(e)return a(i)},[e]);const s=v.useCallback(()=>e&&r&&r(i),[i,r,e]);return!n&&r?[!1,s]:[!0]}const Wl=e=>e.key||"";function BS(e){const t=[];return v.Children.forEach(e,n=>{v.isValidElement(n)&&t.push(n)}),t}const Dr=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:a=!0,mode:i="sync",propagate:s=!1,anchorX:o="left",root:l})=>{const[u,c]=FS(s),d=v.useMemo(()=>BS(e),[e]),p=s&&!u?[]:d.map(Wl),f=v.useRef(!0),m=v.useRef(d),g=Ud(()=>new Map),[x,T]=v.useState(d),[y,w]=v.useState(d);AT(()=>{f.current=!1,m.current=d;for(let A=0;A<y.length;A++){const R=Wl(y[A]);p.includes(R)?g.delete(R):g.get(R)!==!0&&g.set(R,!1)}},[y,p.length,p.join("-")]);const k=[];if(d!==x){let A=[...d];for(let R=0;R<y.length;R++){const M=y[R],P=Wl(M);p.includes(P)||(A.splice(R,0,M),k.push(M))}return i==="wait"&&k.length&&(A=k),w(BS(A)),T(d),null}process.env.NODE_ENV!=="production"&&i==="wait"&&y.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:_}=v.useContext(Bd);return b.jsx(b.Fragment,{children:y.map(A=>{const R=Wl(A),M=s&&!u?!1:d===y||p.includes(R),P=()=>{if(g.has(R))g.set(R,!0);else return;let D=!0;g.forEach(z=>{z||(D=!1)}),D&&(_?.(),w(m.current),s&&c?.(),r&&r())};return b.jsx(kP,{isPresent:M,initial:!f.current||n?void 0:!1,custom:t,presenceAffectsLayout:a,mode:i,root:l,onExitComplete:M?void 0:P,anchorX:o,children:A},R)})})},US=v.createContext({strict:!1}),HS={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},Wi={};for(const e in HS)Wi[e]={isEnabled:t=>HS[e].some(n=>!!t[n])};function CP(e){for(const t in e)Wi[t]={...Wi[t],...e[t]}}const IP=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function Yl(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||IP.has(e)}let $S=e=>!Yl(e);function RP(e){typeof e=="function"&&($S=t=>t.startsWith("on")?!Yl(t):e(t))}try{RP(require("@emotion/is-prop-valid").default)}catch{}function OP(e,t,n){const r={};for(const a in e)a==="values"&&typeof e.values=="object"||($S(a)||n===!0&&Yl(a)||!t&&!Yl(a)||e.draggable&&a.startsWith("onDrag"))&&(r[a]=e[a]);return r}const Kl=v.createContext({});function Xl(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function lo(e){return typeof e=="string"||Array.isArray(e)}const C0=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],I0=["initial",...C0];function Zl(e){return Xl(e.animate)||I0.some(t=>lo(e[t]))}function zS(e){return!!(Zl(e)||e.variants)}function LP(e,t){if(Zl(e)){const{initial:n,animate:r}=e;return{initial:n===!1||lo(n)?n:void 0,animate:lo(r)?r:void 0}}return e.inherit!==!1?t:{}}function DP(e){const{initial:t,animate:n}=LP(e,v.useContext(Kl));return v.useMemo(()=>({initial:t,animate:n}),[qS(t),qS(n)])}function qS(e){return Array.isArray(e)?e.join(" "):e}const uo={};function MP(e){for(const t in e)uo[t]=e[t],Xd(t)&&(uo[t].isCSSVariable=!0)}function jS(e,{layout:t,layoutId:n}){return Gi.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!uo[e]||e==="opacity")}const PP={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},FP=ji.length;function BP(e,t,n){let r="",a=!0;for(let i=0;i<FP;i++){const s=ji[i],o=e[s];if(o===void 0)continue;let l=!0;if(typeof o=="number"?l=o===(s.startsWith("scale")?1:0):l=parseFloat(o)===0,!l||n){const u=kS(o,w0[s]);if(!l){a=!1;const c=PP[s]||s;r+=`${c}(${u}) `}n&&(t[s]=u)}}return r=r.trim(),n?r=n(t,a?"":r):a&&(r="none"),r}function R0(e,t,n){const{style:r,vars:a,transformOrigin:i}=e;let s=!1,o=!1;for(const l in t){const u=t[l];if(Gi.has(l)){s=!0;continue}else if(Xd(l)){a[l]=u;continue}else{const c=kS(u,w0[l]);l.startsWith("origin")?(o=!0,i[l]=c):r[l]=c}}if(t.transform||(s||n?r.transform=BP(t,e.transform,n):r.transform&&(r.transform="none")),o){const{originX:l="50%",originY:u="50%",originZ:c=0}=i;r.transformOrigin=`${l} ${u} ${c}`}}const O0=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function GS(e,t,n){for(const r in t)!bn(t[r])&&!jS(r,n)&&(e[r]=t[r])}function UP({transformTemplate:e},t){return v.useMemo(()=>{const n=O0();return R0(n,t,e),Object.assign({},n.vars,n.style)},[t])}function HP(e,t){const n=e.style||{},r={};return GS(r,n,e),Object.assign(r,UP(e,t)),r}function $P(e,t){const n={},r=HP(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}const zP={offset:"stroke-dashoffset",array:"stroke-dasharray"},qP={offset:"strokeDashoffset",array:"strokeDasharray"};function jP(e,t,n=1,r=0,a=!0){e.pathLength=1;const i=a?zP:qP;e[i.offset]=Ue.transform(-r);const s=Ue.transform(t),o=Ue.transform(n);e[i.array]=`${s} ${o}`}function VS(e,{attrX:t,attrY:n,attrScale:r,pathLength:a,pathSpacing:i=1,pathOffset:s=0,...o},l,u,c){if(R0(e,o,u),l){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:d,style:p}=e;d.transform&&(p.transform=d.transform,delete d.transform),(p.transform||d.transformOrigin)&&(p.transformOrigin=d.transformOrigin??"50% 50%",delete d.transformOrigin),p.transform&&(p.transformBox=c?.transformBox??"fill-box",delete d.transformBox),t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),a!==void 0&&jP(d,a,i,s,!1)}const WS=()=>({...O0(),attrs:{}}),YS=e=>typeof e=="string"&&e.toLowerCase()==="svg";function GP(e,t,n,r){const a=v.useMemo(()=>{const i=WS();return VS(i,t,YS(r),e.transformTemplate,e.style),{...i.attrs,style:{...i.style}}},[t]);if(e.style){const i={};GS(i,e.style,e),a.style={...i,...a.style}}return a}const VP=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function L0(e){return typeof e!="string"||e.includes("-")?!1:!!(VP.indexOf(e)>-1||/[A-Z]/u.test(e))}function WP(e,t,n,{latestValues:r},a,i=!1){const o=(L0(e)?GP:$P)(t,r,a,e),l=OP(t,typeof e=="string",i),u=e!==v.Fragment?{...l,...o,ref:n}:{},{children:c}=t,d=v.useMemo(()=>bn(c)?c.get():c,[c]);return v.createElement(e,{...u,children:d})}function KS(e){const t=[{},{}];return e?.values.forEach((n,r)=>{t[0][r]=n.get(),t[1][r]=n.getVelocity()}),t}function D0(e,t,n,r){if(typeof t=="function"){const[a,i]=KS(r);t=t(n!==void 0?n:e.custom,a,i)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[a,i]=KS(r);t=t(n!==void 0?n:e.custom,a,i)}return t}function Ql(e){return bn(e)?e.get():e}function YP({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,a){return{latestValues:KP(n,r,a,e),renderState:t()}}function KP(e,t,n,r){const a={},i=r(e,{});for(const p in i)a[p]=Ql(i[p]);let{initial:s,animate:o}=e;const l=Zl(e),u=zS(e);t&&u&&!l&&e.inherit!==!1&&(s===void 0&&(s=t.initial),o===void 0&&(o=t.animate));let c=n?n.initial===!1:!1;c=c||s===!1;const d=c?o:s;if(d&&typeof d!="boolean"&&!Xl(d)){const p=Array.isArray(d)?d:[d];for(let f=0;f<p.length;f++){const m=D0(e,p[f]);if(m){const{transitionEnd:g,transition:x,...T}=m;for(const y in T){let w=T[y];if(Array.isArray(w)){const k=c?w.length-1:0;w=w[k]}w!==null&&(a[y]=w)}for(const y in g)a[y]=g[y]}}}return a}const XS=e=>(t,n)=>{const r=v.useContext(Kl),a=v.useContext(Ul),i=()=>YP(e,t,r,a);return n?i():Ud(i)};function M0(e,t,n){const{style:r}=e,a={};for(const i in r)(bn(r[i])||t.style&&bn(t.style[i])||jS(i,e)||n?.getValue(i)?.liveStyle!==void 0)&&(a[i]=r[i]);return a}const XP=XS({scrapeMotionValuesFromProps:M0,createRenderState:O0});function ZS(e,t,n){const r=M0(e,t,n);for(const a in e)if(bn(e[a])||bn(t[a])){const i=ji.indexOf(a)!==-1?"attr"+a.charAt(0).toUpperCase()+a.substring(1):a;r[i]=e[a]}return r}const ZP=XS({scrapeMotionValuesFromProps:ZS,createRenderState:WS}),QP=Symbol.for("motionComponentSymbol");function Yi(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function JP(e,t,n){return v.useCallback(r=>{r&&e.onMount&&e.onMount(r),t&&(r?t.mount(r):t.unmount()),n&&(typeof n=="function"?n(r):Yi(n)&&(n.current=r))},[t])}const P0=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),QS="data-"+P0("framerAppearId"),JS=v.createContext({});function eF(e,t,n,r,a){const{visualElement:i}=v.useContext(Kl),s=v.useContext(US),o=v.useContext(Ul),l=v.useContext(N0).reducedMotion,u=v.useRef(null);r=r||s.renderer,!u.current&&r&&(u.current=r(e,{visualState:t,parent:i,props:n,presenceContext:o,blockInitialAnimation:o?o.initial===!1:!1,reducedMotionConfig:l}));const c=u.current,d=v.useContext(JS);c&&!c.projection&&a&&(c.type==="html"||c.type==="svg")&&tF(u.current,n,a,d);const p=v.useRef(!1);v.useInsertionEffect(()=>{c&&p.current&&c.update(n,o)});const f=n[QS],m=v.useRef(!!f&&!window.MotionHandoffIsComplete?.(f)&&window.MotionHasOptimisedAnimation?.(f));return AT(()=>{c&&(p.current=!0,window.MotionIsMounted=!0,c.updateFeatures(),c.scheduleRenderMicrotask(),m.current&&c.animationState&&c.animationState.animateChanges())}),v.useEffect(()=>{c&&(!m.current&&c.animationState&&c.animationState.animateChanges(),m.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(f)}),m.current=!1))}),c}function tF(e,t,n,r){const{layoutId:a,layout:i,drag:s,dragConstraints:o,layoutScroll:l,layoutRoot:u,layoutCrossfade:c}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:e2(e.parent)),e.projection.setOptions({layoutId:a,layout:i,alwaysMeasureLayout:!!s||o&&Yi(o),visualElement:e,animationType:typeof i=="string"?i:"both",initialPromotionConfig:r,crossfade:c,layoutScroll:l,layoutRoot:u})}function e2(e){if(e)return e.options.allowProjection!==!1?e.projection:e2(e.parent)}function F0(e,{forwardMotionProps:t=!1}={},n,r){n&&CP(n);const a=L0(e)?ZP:XP;function i(o,l){let u;const c={...v.useContext(N0),...o,layoutId:nF(o)},{isStatic:d}=c,p=DP(o),f=a(o,d);if(!d&&Hd){rF(c,n);const m=aF(c);u=m.MeasureLayout,p.visualElement=eF(e,f,c,r,m.ProjectionNode)}return b.jsxs(Kl.Provider,{value:p,children:[u&&p.visualElement?b.jsx(u,{visualElement:p.visualElement,...c}):null,WP(e,o,JP(f,p.visualElement,l),f,d,t)]})}i.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const s=v.forwardRef(i);return s[QP]=e,s}function nF({layoutId:e}){const t=v.useContext(Bd).id;return t&&e!==void 0?t+"-"+e:e}function rF(e,t){const n=v.useContext(US).strict;if(process.env.NODE_ENV!=="production"&&t&&n){const r="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";e.ignoreStrict?Hi(!1,r,"lazy-strict-mode"):na(!1,r,"lazy-strict-mode")}}function aF(e){const{drag:t,layout:n}=Wi;if(!t&&!n)return{};const r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function iF(e,t){if(typeof Proxy>"u")return F0;const n=new Map,r=(i,s)=>F0(i,s,e,t),a=(i,s)=>(process.env.NODE_ENV!=="production"&&Vd(!1,"motion() is deprecated. Use motion.create() instead."),r(i,s));return new Proxy(a,{get:(i,s)=>s==="create"?r:(n.has(s)||n.set(s,F0(s,void 0,e,t)),n.get(s))})}function t2({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function sF({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function oF(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function B0(e){return e===void 0||e===1}function U0({scale:e,scaleX:t,scaleY:n}){return!B0(e)||!B0(t)||!B0(n)}function ci(e){return U0(e)||n2(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function n2(e){return r2(e.x)||r2(e.y)}function r2(e){return e&&e!=="0%"}function Jl(e,t,n){const r=e-n,a=t*r;return n+a}function a2(e,t,n,r,a){return a!==void 0&&(e=Jl(e,a,r)),Jl(e,n,r)+t}function H0(e,t=0,n=1,r,a){e.min=a2(e.min,t,n,r,a),e.max=a2(e.max,t,n,r,a)}function i2(e,{x:t,y:n}){H0(e.x,t.translate,t.scale,t.originPoint),H0(e.y,n.translate,n.scale,n.originPoint)}const s2=.999999999999,o2=1.0000000000001;function lF(e,t,n,r=!1){const a=n.length;if(!a)return;t.x=t.y=1;let i,s;for(let o=0;o<a;o++){i=n[o],s=i.projectionDelta;const{visualElement:l}=i.options;l&&l.props.style&&l.props.style.display==="contents"||(r&&i.options.layoutScroll&&i.scroll&&i!==i.root&&Xi(e,{x:-i.scroll.offset.x,y:-i.scroll.offset.y}),s&&(t.x*=s.x.scale,t.y*=s.y.scale,i2(e,s)),r&&ci(i.latestValues)&&Xi(e,i.latestValues))}t.x<o2&&t.x>s2&&(t.x=1),t.y<o2&&t.y>s2&&(t.y=1)}function Ki(e,t){e.min=e.min+t,e.max=e.max+t}function l2(e,t,n,r,a=.5){const i=xt(e.min,e.max,a);H0(e,t,n,i,r)}function Xi(e,t){l2(e.x,t.x,t.scaleX,t.scale,t.originX),l2(e.y,t.y,t.scaleY,t.scale,t.originY)}function u2(e,t){return t2(oF(e.getBoundingClientRect(),t))}function uF(e,t,n){const r=u2(e,n),{scroll:a}=t;return a&&(Ki(r.x,a.offset.x),Ki(r.y,a.offset.y)),r}const c2=()=>({translate:0,scale:1,origin:0,originPoint:0}),Zi=()=>({x:c2(),y:c2()}),d2=()=>({min:0,max:0}),Dt=()=>({x:d2(),y:d2()}),$0={current:null},p2={current:!1};function cF(){if(p2.current=!0,!!Hd)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>$0.current=e.matches;e.addEventListener("change",t),t()}else $0.current=!1}const dF=new WeakMap;function pF(e,t,n){for(const r in t){const a=t[r],i=n[r];if(bn(a))e.addValue(r,a);else if(bn(i))e.addValue(r,Vi(a,{owner:e}));else if(i!==a)if(e.hasValue(r)){const s=e.getValue(r);s.liveStyle===!0?s.jump(a):s.hasAnimated||s.set(a)}else{const s=e.getStaticValue(r);e.addValue(r,Vi(s!==void 0?s:a,{owner:e}))}}for(const r in n)t[r]===void 0&&e.removeValue(r);return t}const f2=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class fF{scrapeMotionValuesFromProps(t,n,r){return{}}constructor({parent:t,props:n,presenceContext:r,reducedMotionConfig:a,blockInitialAnimation:i,visualState:s},o={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=v0,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const p=Pn.now();this.renderScheduledAt<p&&(this.renderScheduledAt=p,yt.render(this.render,!1,!0))};const{latestValues:l,renderState:u}=s;this.latestValues=l,this.baseTarget={...l},this.initialValues=n.initial?{...l}:{},this.renderState=u,this.parent=t,this.props=n,this.presenceContext=r,this.depth=t?t.depth+1:0,this.reducedMotionConfig=a,this.options=o,this.blockInitialAnimation=!!i,this.isControllingVariants=Zl(n),this.isVariantNode=zS(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:c,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const p in d){const f=d[p];l[p]!==void 0&&bn(f)&&f.set(l[p])}}mount(t){this.current=t,dF.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,r)=>this.bindToMotionValue(r,n)),p2.current||cF(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:$0.current,process.env.NODE_ENV!=="production"&&Vd(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),Na(this.notifyUpdate),Na(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const n=this.features[t];n&&(n.unmount(),n.isMounted=!1)}this.current=null}bindToMotionValue(t,n){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();const r=Gi.has(t);r&&this.onBindTransform&&this.onBindTransform();const a=n.on("change",s=>{this.latestValues[t]=s,this.props.onUpdate&&yt.preRender(this.notifyUpdate),r&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let i;window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{a(),i&&i(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in Wi){const n=Wi[t];if(!n)continue;const{isEnabled:r,Feature:a}=n;if(!this.features[t]&&a&&r(this.props)&&(this.features[t]=new a(this)),this.features[t]){const i=this.features[t];i.isMounted?i.update():(i.mount(),i.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Dt()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let r=0;r<f2.length;r++){const a=f2[r];this.propEventSubscriptions[a]&&(this.propEventSubscriptions[a](),delete this.propEventSubscriptions[a]);const i="on"+a,s=t[i];s&&(this.propEventSubscriptions[a]=this.on(a,s))}this.prevMotionValues=pF(this,this.scrapeMotionValuesFromProps(t,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(t){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){const r=this.values.get(t);n!==r&&(r&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let r=this.values.get(t);return r===void 0&&n!==void 0&&(r=Vi(n===null?void 0:n,{owner:this}),this.addValue(t,r)),r}readValue(t,n){let r=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return r!=null&&(typeof r=="string"&&(_T(r)||NT(r))?r=parseFloat(r):!wP(r)&&Ia.test(n)&&(r=_S(t,n)),this.setBaseTarget(t,bn(r)?r.get():r)),bn(r)?r.get():r}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){const{initial:n}=this.props;let r;if(typeof n=="string"||typeof n=="object"){const i=D0(this.props,n,this.presenceContext?.custom);i&&(r=i[t])}if(n&&r!==void 0)return r;const a=this.getBaseTargetFromProps(this.props,t);return a!==void 0&&!bn(a)?a:this.initialValues[t]!==void 0&&r===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new Gd),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){A0.render(this.render)}}class h2 extends fF{constructor(){super(...arguments),this.KeyframeResolver=pP}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){return t.style?t.style[n]:void 0}removeValueFromRenderState(t,{vars:n,style:r}){delete n[t],delete r[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;bn(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function m2(e,{style:t,vars:n},r,a){const i=e.style;let s;for(s in t)i[s]=t[s];a?.applyProjectionStyles(i,r);for(s in n)i.setProperty(s,n[s])}function hF(e){return window.getComputedStyle(e)}class mF extends h2{constructor(){super(...arguments),this.type="html",this.renderInstance=m2}readValueFromInstance(t,n){if(Gi.has(n))return this.projection?.isProjecting?m0(n):R9(t,n);{const r=hF(t),a=(Xd(n)?r.getPropertyValue(n):r[n])||0;return typeof a=="string"?a.trim():a}}measureInstanceViewportBox(t,{transformPagePoint:n}){return u2(t,n)}build(t,n,r){R0(t,n,r.transformTemplate)}scrapeMotionValuesFromProps(t,n,r){return M0(t,n,r)}}const g2=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function gF(e,t,n,r){m2(e,t,void 0,r);for(const a in t.attrs)e.setAttribute(g2.has(a)?a:P0(a),t.attrs[a])}class bF extends h2{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Dt}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(Gi.has(n)){const r=AS(n);return r&&r.default||0}return n=g2.has(n)?n:P0(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,r){return ZS(t,n,r)}build(t,n,r){VS(t,n,this.isSVGTag,r.transformTemplate,r.style)}renderInstance(t,n,r,a){gF(t,n,r,a)}mount(t){this.isSVGTag=YS(t.tagName),super.mount(t)}}const EF=(e,t)=>L0(e)?new bF(t):new mF(t,{allowProjection:e!==v.Fragment});function co(e,t,n){const r=e.getProps();return D0(r,t,n!==void 0?n:r.custom,e)}const z0=e=>Array.isArray(e);function yF(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Vi(n))}function vF(e){return z0(e)?e[e.length-1]||0:e}function TF(e,t){const n=co(e,t);let{transitionEnd:r={},transition:a={},...i}=n||{};i={...i,...r};for(const s in i){const o=vF(i[s]);yF(e,s,o)}}function SF(e){return!!(bn(e)&&e.add)}function q0(e,t){const n=e.getValue("willChange");if(SF(n))return n.add(t);if(!n&&ra.WillChange){const r=new ra.WillChange("auto");e.addValue("willChange",r),r.add(t)}}function b2(e){return e.props[QS]}const xF=e=>e!==null;function wF(e,{repeat:t,repeatType:n="loop"},r){const a=e.filter(xF),i=t&&n!=="loop"&&t%2===1?0:a.length-1;return a[i]}const AF={type:"spring",stiffness:500,damping:25,restSpeed:10},_F=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),kF={type:"keyframes",duration:.8},NF={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},CF=(e,{keyframes:t})=>t.length>2?kF:Gi.has(e)?e.startsWith("scale")?_F(t[1]):AF:NF;function IF({when:e,delay:t,delayChildren:n,staggerChildren:r,staggerDirection:a,repeat:i,repeatType:s,repeatDelay:o,from:l,elapsed:u,...c}){return!!Object.keys(c).length}const j0=(e,t,n,r={},a,i)=>s=>{const o=S0(r,e)||{},l=o.delay||r.delay||0;let{elapsed:u=0}=r;u=u-Tr(l);const c={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...o,delay:-u,onUpdate:p=>{t.set(p),o.onUpdate&&o.onUpdate(p)},onComplete:()=>{s(),o.onComplete&&o.onComplete()},name:e,motionValue:t,element:i?void 0:a};IF(o)||Object.assign(c,CF(e,c)),c.duration&&(c.duration=Tr(c.duration)),c.repeatDelay&&(c.repeatDelay=Tr(c.repeatDelay)),c.from!==void 0&&(c.keyframes[0]=c.from);let d=!1;if((c.type===!1||c.duration===0&&!c.repeatDelay)&&(T0(c),c.delay===0&&(d=!0)),(ra.instantAnimations||ra.skipAnimations)&&(d=!0,T0(c),c.delay=0),c.allowFlatten=!o.type&&!o.ease,d&&!i&&t.get()!==void 0){const p=wF(c.keyframes,o);if(p!==void 0){yt.update(()=>{c.onUpdate(p),c.onComplete()});return}}return o.isSync?new p0(c):new eP(c)};function RF({protectedKeys:e,needsAnimating:t},n){const r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function E2(e,t,{delay:n=0,transitionOverride:r,type:a}={}){let{transition:i=e.getDefaultTransition(),transitionEnd:s,...o}=t;r&&(i=r);const l=[],u=a&&e.animationState&&e.animationState.getState()[a];for(const c in o){const d=e.getValue(c,e.latestValues[c]??null),p=o[c];if(p===void 0||u&&RF(u,c))continue;const f={delay:n,...S0(i||{},c)},m=d.get();if(m!==void 0&&!d.isAnimating&&!Array.isArray(p)&&p===m&&!f.velocity)continue;let g=!1;if(window.MotionHandoffAnimation){const T=b2(e);if(T){const y=window.MotionHandoffAnimation(T,c,yt);y!==null&&(f.startTime=y,g=!0)}}q0(e,c),d.start(j0(c,d,p,e.shouldReduceMotion&&vS.has(c)?{type:!1}:f,e,g));const x=d.animation;x&&l.push(x)}return s&&Promise.all(l).then(()=>{yt.update(()=>{s&&TF(e,s)})}),l}function G0(e,t,n={}){const r=co(e,t,n.type==="exit"?e.presenceContext?.custom:void 0);let{transition:a=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(a=n.transitionOverride);const i=r?()=>Promise.all(E2(e,r,n)):()=>Promise.resolve(),s=e.variantChildren&&e.variantChildren.size?(l=0)=>{const{delayChildren:u=0,staggerChildren:c,staggerDirection:d}=a;return OF(e,t,l,u,c,d,n)}:()=>Promise.resolve(),{when:o}=a;if(o){const[l,u]=o==="beforeChildren"?[i,s]:[s,i];return l().then(()=>u())}else return Promise.all([i(),s(n.delay)])}function OF(e,t,n=0,r=0,a=0,i=1,s){const o=[],l=e.variantChildren.size,u=(l-1)*a,c=typeof r=="function",d=c?p=>r(p,l):i===1?(p=0)=>p*a:(p=0)=>u-p*a;return Array.from(e.variantChildren).sort(LF).forEach((p,f)=>{p.notify("AnimationStart",t),o.push(G0(p,t,{...s,delay:n+(c?0:r)+d(f)}).then(()=>p.notify("AnimationComplete",t)))}),Promise.all(o)}function LF(e,t){return e.sortNodePosition(t)}function DF(e,t,n={}){e.notify("AnimationStart",t);let r;if(Array.isArray(t)){const a=t.map(i=>G0(e,i,n));r=Promise.all(a)}else if(typeof t=="string")r=G0(e,t,n);else{const a=typeof t=="function"?co(e,t,n.custom):t;r=Promise.all(E2(e,a,n))}return r.then(()=>{e.notify("AnimationComplete",t)})}function y2(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}const MF=I0.length;function v2(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?v2(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<MF;n++){const r=I0[n],a=e.props[r];(lo(a)||a===!1)&&(t[r]=a)}return t}const PF=[...C0].reverse(),FF=C0.length;function BF(e){return t=>Promise.all(t.map(({animation:n,options:r})=>DF(e,n,r)))}function UF(e){let t=BF(e),n=T2(),r=!0;const a=l=>(u,c)=>{const d=co(e,c,l==="exit"?e.presenceContext?.custom:void 0);if(d){const{transition:p,transitionEnd:f,...m}=d;u={...u,...m,...f}}return u};function i(l){t=l(e)}function s(l){const{props:u}=e,c=v2(e.parent)||{},d=[],p=new Set;let f={},m=1/0;for(let x=0;x<FF;x++){const T=PF[x],y=n[T],w=u[T]!==void 0?u[T]:c[T],k=lo(w),_=T===l?y.isActive:null;_===!1&&(m=x);let A=w===c[T]&&w!==u[T]&&k;if(A&&r&&e.manuallyAnimateOnMount&&(A=!1),y.protectedKeys={...f},!y.isActive&&_===null||!w&&!y.prevProp||Xl(w)||typeof w=="boolean")continue;const R=HF(y.prevProp,w);let M=R||T===l&&y.isActive&&!A&&k||x>m&&k,P=!1;const D=Array.isArray(w)?w:[w];let z=D.reduce(a(T),{});_===!1&&(z={});const{prevResolvedValues:V={}}=y,W={...V,...z},K=ue=>{M=!0,p.has(ue)&&(P=!0,p.delete(ue)),y.needsAnimating[ue]=!0;const ee=e.getValue(ue);ee&&(ee.liveStyle=!1)};for(const ue in W){const ee=z[ue],fe=V[ue];if(f.hasOwnProperty(ue))continue;let C=!1;z0(ee)&&z0(fe)?C=!y2(ee,fe):C=ee!==fe,C?ee!=null?K(ue):p.add(ue):ee!==void 0&&p.has(ue)?K(ue):y.protectedKeys[ue]=!0}y.prevProp=w,y.prevResolvedValues=z,y.isActive&&(f={...f,...z}),r&&e.blockInitialAnimation&&(M=!1),M&&(!(A&&R)||P)&&d.push(...D.map(ue=>({animation:ue,options:{type:T}})))}if(p.size){const x={};if(typeof u.initial!="boolean"){const T=co(e,Array.isArray(u.initial)?u.initial[0]:u.initial);T&&T.transition&&(x.transition=T.transition)}p.forEach(T=>{const y=e.getBaseTarget(T),w=e.getValue(T);w&&(w.liveStyle=!0),x[T]=y??null}),d.push({animation:x})}let g=!!d.length;return r&&(u.initial===!1||u.initial===u.animate)&&!e.manuallyAnimateOnMount&&(g=!1),r=!1,g?t(d):Promise.resolve()}function o(l,u){if(n[l].isActive===u)return Promise.resolve();e.variantChildren?.forEach(d=>d.animationState?.setActive(l,u)),n[l].isActive=u;const c=s(l);for(const d in n)n[d].protectedKeys={};return c}return{animateChanges:s,setActive:o,setAnimateFunction:i,getState:()=>n,reset:()=>{n=T2(),r=!0}}}function HF(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!y2(t,e):!1}function di(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function T2(){return{animate:di(!0),whileInView:di(),whileHover:di(),whileTap:di(),whileDrag:di(),whileFocus:di(),exit:di()}}class Ra{constructor(t){this.isMounted=!1,this.node=t}update(){}}class $F extends Ra{constructor(t){super(t),t.animationState||(t.animationState=UF(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Xl(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let zF=0;class qF extends Ra{constructor(){super(...arguments),this.id=zF++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===r)return;const a=this.node.animationState.setActive("exit",!t);n&&!t&&a.then(()=>{n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const jF={animation:{Feature:$F},exit:{Feature:qF}};function po(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n)}function fo(e){return{point:{x:e.pageX,y:e.pageY}}}const GF=e=>t=>_0(t)&&e(t,fo(t));function ho(e,t,n,r){return po(e,t,GF(n),r)}const S2=1e-4,VF=1-S2,WF=1+S2,x2=.01,YF=0-x2,KF=0+x2;function wn(e){return e.max-e.min}function XF(e,t,n){return Math.abs(e-t)<=n}function w2(e,t,n,r=.5){e.origin=r,e.originPoint=xt(t.min,t.max,e.origin),e.scale=wn(n)/wn(t),e.translate=xt(n.min,n.max,e.origin)-e.originPoint,(e.scale>=VF&&e.scale<=WF||isNaN(e.scale))&&(e.scale=1),(e.translate>=YF&&e.translate<=KF||isNaN(e.translate))&&(e.translate=0)}function mo(e,t,n,r){w2(e.x,t.x,n.x,r?r.originX:void 0),w2(e.y,t.y,n.y,r?r.originY:void 0)}function A2(e,t,n){e.min=n.min+t.min,e.max=e.min+wn(t)}function ZF(e,t,n){A2(e.x,t.x,n.x),A2(e.y,t.y,n.y)}function _2(e,t,n){e.min=t.min-n.min,e.max=e.min+wn(t)}function go(e,t,n){_2(e.x,t.x,n.x),_2(e.y,t.y,n.y)}function ar(e){return[e("x"),e("y")]}const k2=({current:e})=>e?e.ownerDocument.defaultView:null,N2=(e,t)=>Math.abs(e-t);function QF(e,t){const n=N2(e.x,t.x),r=N2(e.y,t.y);return Math.sqrt(n**2+r**2)}class C2{constructor(t,n,{transformPagePoint:r,contextWindow:a=window,dragSnapToOrigin:i=!1,distanceThreshold:s=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const p=W0(this.lastMoveEventInfo,this.history),f=this.startEvent!==null,m=QF(p.offset,{x:0,y:0})>=this.distanceThreshold;if(!f&&!m)return;const{point:g}=p,{timestamp:x}=hn;this.history.push({...g,timestamp:x});const{onStart:T,onMove:y}=this.handlers;f||(T&&T(this.lastMoveEvent,p),this.startEvent=this.lastMoveEvent),y&&y(this.lastMoveEvent,p)},this.handlePointerMove=(p,f)=>{this.lastMoveEvent=p,this.lastMoveEventInfo=V0(f,this.transformPagePoint),yt.update(this.updatePoint,!0)},this.handlePointerUp=(p,f)=>{this.end();const{onEnd:m,onSessionEnd:g,resumeAnimation:x}=this.handlers;if(this.dragSnapToOrigin&&x&&x(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const T=W0(p.type==="pointercancel"?this.lastMoveEventInfo:V0(f,this.transformPagePoint),this.history);this.startEvent&&m&&m(p,T),g&&g(p,T)},!_0(t))return;this.dragSnapToOrigin=i,this.handlers=n,this.transformPagePoint=r,this.distanceThreshold=s,this.contextWindow=a||window;const o=fo(t),l=V0(o,this.transformPagePoint),{point:u}=l,{timestamp:c}=hn;this.history=[{...u,timestamp:c}];const{onSessionStart:d}=n;d&&d(t,W0(l,this.history)),this.removeListeners=eo(ho(this.contextWindow,"pointermove",this.handlePointerMove),ho(this.contextWindow,"pointerup",this.handlePointerUp),ho(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),Na(this.updatePoint)}}function V0(e,t){return t?{point:t(e.point)}:e}function I2(e,t){return{x:e.x-t.x,y:e.y-t.y}}function W0({point:e},t){return{point:e,delta:I2(e,R2(t)),offset:I2(e,JF(t)),velocity:eB(t,.1)}}function JF(e){return e[0]}function R2(e){return e[e.length-1]}function eB(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null;const a=R2(e);for(;n>=0&&(r=e[n],!(a.timestamp-r.timestamp>Tr(t)));)n--;if(!r)return{x:0,y:0};const i=Or(a.timestamp-r.timestamp);if(i===0)return{x:0,y:0};const s={x:(a.x-r.x)/i,y:(a.y-r.y)/i};return s.x===1/0&&(s.x=0),s.y===1/0&&(s.y=0),s}function tB(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?xt(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?xt(n,e,r.max):Math.min(e,n)),e}function O2(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function nB(e,{top:t,left:n,bottom:r,right:a}){return{x:O2(e.x,n,a),y:O2(e.y,t,r)}}function L2(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function rB(e,t){return{x:L2(e.x,t.x),y:L2(e.y,t.y)}}function aB(e,t){let n=.5;const r=wn(e),a=wn(t);return a>r?n=to(t.min,t.max-r,e.min):r>a&&(n=to(e.min,e.max-a,t.min)),ta(0,1,n)}function iB(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const Y0=.35;function sB(e=Y0){return e===!1?e=0:e===!0&&(e=Y0),{x:D2(e,"left","right"),y:D2(e,"top","bottom")}}function D2(e,t,n){return{min:M2(e,t),max:M2(e,n)}}function M2(e,t){return typeof e=="number"?e:e[t]||0}const oB=new WeakMap;class lB{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Dt(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:r}={}){const{presenceContext:a}=this.visualElement;if(a&&a.isPresent===!1)return;const i=d=>{const{dragSnapToOrigin:p}=this.getProps();p?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(fo(d).point)},s=(d,p)=>{const{drag:f,dragPropagation:m,onDragStart:g}=this.getProps();if(f&&!m&&(this.openDragLock&&this.openDragLock(),this.openDragLock=gP(f),!this.openDragLock))return;this.latestPointerEvent=d,this.latestPanInfo=p,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),ar(T=>{let y=this.getAxisMotionValue(T).get()||0;if(Lr.test(y)){const{projection:w}=this.visualElement;if(w&&w.layout){const k=w.layout.layoutBox[T];k&&(y=wn(k)*(parseFloat(y)/100))}}this.originPoint[T]=y}),g&&yt.postRender(()=>g(d,p)),q0(this.visualElement,"transform");const{animationState:x}=this.visualElement;x&&x.setActive("whileDrag",!0)},o=(d,p)=>{this.latestPointerEvent=d,this.latestPanInfo=p;const{dragPropagation:f,dragDirectionLock:m,onDirectionLock:g,onDrag:x}=this.getProps();if(!f&&!this.openDragLock)return;const{offset:T}=p;if(m&&this.currentDirection===null){this.currentDirection=uB(T),this.currentDirection!==null&&g&&g(this.currentDirection);return}this.updateAxis("x",p.point,T),this.updateAxis("y",p.point,T),this.visualElement.render(),x&&x(d,p)},l=(d,p)=>{this.latestPointerEvent=d,this.latestPanInfo=p,this.stop(d,p),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>ar(d=>this.getAnimationState(d)==="paused"&&this.getAxisMotionValue(d).animation?.play()),{dragSnapToOrigin:c}=this.getProps();this.panSession=new C2(t,{onSessionStart:i,onStart:s,onMove:o,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:c,distanceThreshold:r,contextWindow:k2(this.visualElement)})}stop(t,n){const r=t||this.latestPointerEvent,a=n||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!a||!r)return;const{velocity:s}=a;this.startAnimation(s);const{onDragEnd:o}=this.getProps();o&&yt.postRender(()=>o(r,a))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(t,n,r){const{drag:a}=this.getProps();if(!r||!eu(t,a,this.currentDirection))return;const i=this.getAxisMotionValue(t);let s=this.originPoint[t]+r[t];this.constraints&&this.constraints[t]&&(s=tB(s,this.constraints[t],this.elastic[t])),i.set(s)}resolveConstraints(){const{dragConstraints:t,dragElastic:n}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,a=this.constraints;t&&Yi(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&r?this.constraints=nB(r.layoutBox,t):this.constraints=!1,this.elastic=sB(n),a!==this.constraints&&r&&this.constraints&&!this.hasMutatedConstraints&&ar(i=>{this.constraints!==!1&&this.getAxisMotionValue(i)&&(this.constraints[i]=iB(r.layoutBox[i],this.constraints[i]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Yi(t))return!1;const r=t.current;na(r!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:a}=this.visualElement;if(!a||!a.layout)return!1;const i=uF(r,a.root,this.visualElement.getTransformPagePoint());let s=rB(a.layout.layoutBox,i);if(n){const o=n(sF(s));this.hasMutatedConstraints=!!o,o&&(s=t2(o))}return s}startAnimation(t){const{drag:n,dragMomentum:r,dragElastic:a,dragTransition:i,dragSnapToOrigin:s,onDragTransitionEnd:o}=this.getProps(),l=this.constraints||{},u=ar(c=>{if(!eu(c,n,this.currentDirection))return;let d=l&&l[c]||{};s&&(d={min:0,max:0});const p=a?200:1e6,f=a?40:1e7,m={type:"inertia",velocity:r?t[c]:0,bounceStiffness:p,bounceDamping:f,timeConstant:750,restDelta:1,restSpeed:10,...i,...d};return this.startAxisValueAnimation(c,m)});return Promise.all(u).then(o)}startAxisValueAnimation(t,n){const r=this.getAxisMotionValue(t);return q0(this.visualElement,t),r.start(j0(t,r,0,n,this.visualElement,!1))}stopAnimation(){ar(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){ar(t=>this.getAxisMotionValue(t).animation?.pause())}getAnimationState(t){return this.getAxisMotionValue(t).animation?.state}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,r=this.visualElement.getProps(),a=r[n];return a||this.visualElement.getValue(t,(r.initial?r.initial[t]:void 0)||0)}snapToCursor(t){ar(n=>{const{drag:r}=this.getProps();if(!eu(n,r,this.currentDirection))return;const{projection:a}=this.visualElement,i=this.getAxisMotionValue(n);if(a&&a.layout){const{min:s,max:o}=a.layout.layoutBox[n];i.set(t[n]-xt(s,o,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!Yi(n)||!r||!this.constraints)return;this.stopAnimation();const a={x:0,y:0};ar(s=>{const o=this.getAxisMotionValue(s);if(o&&this.constraints!==!1){const l=o.get();a[s]=aB({min:l,max:l},this.constraints[s])}});const{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.resolveConstraints(),ar(s=>{if(!eu(s,t,null))return;const o=this.getAxisMotionValue(s),{min:l,max:u}=this.constraints[s];o.set(xt(l,u,a[s]))})}addListeners(){if(!this.visualElement.current)return;oB.set(this.visualElement,this);const t=this.visualElement.current,n=ho(t,"pointerdown",l=>{const{drag:u,dragListener:c=!0}=this.getProps();u&&c&&this.start(l)}),r=()=>{const{dragConstraints:l}=this.getProps();Yi(l)&&l.current&&(this.constraints=this.resolveRefConstraints())},{projection:a}=this.visualElement,i=a.addEventListener("measure",r);a&&!a.layout&&(a.root&&a.root.updateScroll(),a.updateLayout()),yt.read(r);const s=po(window,"resize",()=>this.scalePositionWithinConstraints()),o=a.addEventListener("didUpdate",({delta:l,hasLayoutChanged:u})=>{this.isDragging&&u&&(ar(c=>{const d=this.getAxisMotionValue(c);d&&(this.originPoint[c]+=l[c].translate,d.set(d.get()+l[c].translate))}),this.visualElement.render())});return()=>{s(),n(),i(),o&&o()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:r=!1,dragPropagation:a=!1,dragConstraints:i=!1,dragElastic:s=Y0,dragMomentum:o=!0}=t;return{...t,drag:n,dragDirectionLock:r,dragPropagation:a,dragConstraints:i,dragElastic:s,dragMomentum:o}}}function eu(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function uB(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class cB extends Ra{constructor(t){super(t),this.removeGroupControls=rr,this.removeListeners=rr,this.controls=new lB(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||rr}unmount(){this.removeGroupControls(),this.removeListeners()}}const P2=e=>(t,n)=>{e&&yt.postRender(()=>e(t,n))};class dB extends Ra{constructor(){super(...arguments),this.removePointerDownListener=rr}onPointerDown(t){this.session=new C2(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:k2(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:r,onPanEnd:a}=this.node.getProps();return{onSessionStart:P2(t),onStart:P2(n),onMove:r,onEnd:(i,s)=>{delete this.session,a&&yt.postRender(()=>a(i,s))}}}mount(){this.removePointerDownListener=ho(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const tu={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function F2(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const bo={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(Ue.test(e))e=parseFloat(e);else return e;const n=F2(e,t.target.x),r=F2(e,t.target.y);return`${n}% ${r}%`}},pB={correct:(e,{treeScale:t,projectionDelta:n})=>{const r=e,a=Ia.parse(e);if(a.length>5)return r;const i=Ia.createTransformer(e),s=typeof a[0]!="number"?1:0,o=n.x.scale*t.x,l=n.y.scale*t.y;a[0+s]/=o,a[1+s]/=l;const u=xt(o,l,.5);return typeof a[2+s]=="number"&&(a[2+s]/=u),typeof a[3+s]=="number"&&(a[3+s]/=u),i(a)}};let B2=!1;class fB extends v.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r,layoutId:a}=this.props,{projection:i}=t;MP(hB),i&&(n.group&&n.group.add(i),r&&r.register&&a&&r.register(i),B2&&i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,onExitComplete:()=>this.safeToRemove()})),tu.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:r,drag:a,isPresent:i}=this.props,{projection:s}=r;return s&&(s.isPresent=i,B2=!0,a||t.layoutDependency!==n||n===void 0||t.isPresent!==i?s.willUpdate():this.safeToRemove(),t.isPresent!==i&&(i?s.promote():s.relegate()||yt.postRender(()=>{const o=s.getStack();(!o||!o.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),A0.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r}=this.props,{projection:a}=t;a&&(a.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(a),r&&r.deregister&&r.deregister(a))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function U2(e){const[t,n]=FS(),r=v.useContext(Bd);return b.jsx(fB,{...e,layoutGroup:r,switchLayoutGroup:v.useContext(JS),isPresent:t,safeToRemove:n})}const hB={borderRadius:{...bo,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:bo,borderTopRightRadius:bo,borderBottomLeftRadius:bo,borderBottomRightRadius:bo,boxShadow:pB};function mB(e,t,n){const r=bn(e)?e:Vi(e);return r.start(j0("",r,t,n)),r.animation}const gB=(e,t)=>e.depth-t.depth;class bB{constructor(){this.children=[],this.isDirty=!1}add(t){$d(this.children,t),this.isDirty=!0}remove(t){zd(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(gB),this.isDirty=!1,this.children.forEach(t)}}function EB(e,t){const n=Pn.now(),r=({timestamp:a})=>{const i=a-n;i>=t&&(Na(r),e(i-t))};return yt.setup(r,!0),()=>Na(r)}const H2=["TopLeft","TopRight","BottomLeft","BottomRight"],yB=H2.length,$2=e=>typeof e=="string"?parseFloat(e):e,z2=e=>typeof e=="number"||Ue.test(e);function vB(e,t,n,r,a,i){a?(e.opacity=xt(0,n.opacity??1,TB(r)),e.opacityExit=xt(t.opacity??1,0,SB(r))):i&&(e.opacity=xt(t.opacity??1,n.opacity??1,r));for(let s=0;s<yB;s++){const o=`border${H2[s]}Radius`;let l=q2(t,o),u=q2(n,o);if(l===void 0&&u===void 0)continue;l||(l=0),u||(u=0),l===0||u===0||z2(l)===z2(u)?(e[o]=Math.max(xt($2(l),$2(u),r),0),(Lr.test(u)||Lr.test(l))&&(e[o]+="%")):e[o]=u}(t.rotate||n.rotate)&&(e.rotate=xt(t.rotate||0,n.rotate||0,r))}function q2(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const TB=j2(0,.5,FT),SB=j2(.5,.95,rr);function j2(e,t,n){return r=>r<e?0:r>t?1:n(to(e,t,r))}function G2(e,t){e.min=t.min,e.max=t.max}function ir(e,t){G2(e.x,t.x),G2(e.y,t.y)}function V2(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function W2(e,t,n,r,a){return e-=t,e=Jl(e,1/n,r),a!==void 0&&(e=Jl(e,1/a,r)),e}function xB(e,t=0,n=1,r=.5,a,i=e,s=e){if(Lr.test(t)&&(t=parseFloat(t),t=xt(s.min,s.max,t/100)-s.min),typeof t!="number")return;let o=xt(i.min,i.max,r);e===i&&(o-=t),e.min=W2(e.min,t,n,o,a),e.max=W2(e.max,t,n,o,a)}function Y2(e,t,[n,r,a],i,s){xB(e,t[n],t[r],t[a],t.scale,i,s)}const wB=["x","scaleX","originX"],AB=["y","scaleY","originY"];function K2(e,t,n,r){Y2(e.x,t,wB,n?n.x:void 0,r?r.x:void 0),Y2(e.y,t,AB,n?n.y:void 0,r?r.y:void 0)}function X2(e){return e.translate===0&&e.scale===1}function Z2(e){return X2(e.x)&&X2(e.y)}function Q2(e,t){return e.min===t.min&&e.max===t.max}function _B(e,t){return Q2(e.x,t.x)&&Q2(e.y,t.y)}function J2(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function ex(e,t){return J2(e.x,t.x)&&J2(e.y,t.y)}function tx(e){return wn(e.x)/wn(e.y)}function nx(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class kB{constructor(){this.members=[]}add(t){$d(this.members,t),t.scheduleRender()}remove(t){if(zd(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){const n=this.members.findIndex(a=>t===a);if(n===0)return!1;let r;for(let a=n;a>=0;a--){const i=this.members[a];if(i.isPresent!==!1){r=i;break}}return r?(this.promote(r),!0):!1}promote(t,n){const r=this.lead;if(t!==r&&(this.prevLead=r,this.lead=t,t.show(),r)){r.instance&&r.scheduleRender(),t.scheduleRender(),t.resumeFrom=r,n&&(t.resumeFrom.preserveOpacity=!0),r.snapshot&&(t.snapshot=r.snapshot,t.snapshot.latestValues=r.animationValues||r.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0);const{crossfade:a}=t.options;a===!1&&r.hide()}}exitAnimationComplete(){this.members.forEach(t=>{const{options:n,resumingFrom:r}=t;n.onExitComplete&&n.onExitComplete(),r&&r.options.onExitComplete&&r.options.onExitComplete()})}scheduleRender(){this.members.forEach(t=>{t.instance&&t.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function NB(e,t,n){let r="";const a=e.x.translate/t.x,i=e.y.translate/t.y,s=n?.z||0;if((a||i||s)&&(r=`translate3d(${a}px, ${i}px, ${s}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:u,rotate:c,rotateX:d,rotateY:p,skewX:f,skewY:m}=n;u&&(r=`perspective(${u}px) ${r}`),c&&(r+=`rotate(${c}deg) `),d&&(r+=`rotateX(${d}deg) `),p&&(r+=`rotateY(${p}deg) `),f&&(r+=`skewX(${f}deg) `),m&&(r+=`skewY(${m}deg) `)}const o=e.x.scale*t.x,l=e.y.scale*t.y;return(o!==1||l!==1)&&(r+=`scale(${o}, ${l})`),r||"none"}const K0=["","X","Y","Z"],CB=1e3;let IB=0;function X0(e,t,n,r){const{latestValues:a}=t;a[e]&&(n[e]=a[e],t.setStaticValue(e,0),r&&(r[e]=0))}function rx(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=b2(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:a,layoutId:i}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",yt,!(a||i))}const{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&rx(r)}function ax({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:a}){return class{constructor(s={},o=t?.()){this.id=IB++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(LB),this.nodes.forEach(FB),this.nodes.forEach(BB),this.nodes.forEach(DB)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=s,this.root=o?o.root||o:this,this.path=o?[...o.path,o]:[],this.parent=o,this.depth=o?o.depth+1:0;for(let l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new bB)}addEventListener(s,o){return this.eventHandlers.has(s)||this.eventHandlers.set(s,new Gd),this.eventHandlers.get(s).add(o)}notifyListeners(s,...o){const l=this.eventHandlers.get(s);l&&l.notify(...o)}hasListeners(s){return this.eventHandlers.has(s)}mount(s){if(this.instance)return;this.isSVG=PS(s)&&!SP(s),this.instance=s;const{layoutId:o,layout:l,visualElement:u}=this.options;if(u&&!u.current&&u.mount(s),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||o)&&(this.isLayoutDirty=!0),e){let c,d=0;const p=()=>this.root.updateBlockedByResize=!1;yt.read(()=>{d=window.innerWidth}),e(s,()=>{const f=window.innerWidth;f!==d&&(d=f,this.root.updateBlockedByResize=!0,c&&c(),c=EB(p,250),tu.hasAnimatedSinceResize&&(tu.hasAnimatedSinceResize=!1,this.nodes.forEach(ox)))})}o&&this.root.registerSharedNode(o,this),this.options.animate!==!1&&u&&(o||l)&&this.addEventListener("didUpdate",({delta:c,hasLayoutChanged:d,hasRelativeLayoutChanged:p,layout:f})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const m=this.options.transition||u.getDefaultTransition()||qB,{onLayoutAnimationStart:g,onLayoutAnimationComplete:x}=u.getProps(),T=!this.targetLayout||!ex(this.targetLayout,f),y=!d&&p;if(this.options.layoutRoot||this.resumeFrom||y||d&&(T||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const w={...S0(m,"layout"),onPlay:g,onComplete:x};(u.shouldReduceMotion||this.options.layoutRoot)&&(w.delay=0,w.type=!1),this.startAnimation(w),this.setAnimationOrigin(c,y)}else d||ox(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=f})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const s=this.getStack();s&&s.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Na(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(UB),this.animationId++)}getTransformTemplate(){const{visualElement:s}=this.options;return s&&s.getProps().transformTemplate}willUpdate(s=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&rx(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let c=0;c<this.path.length;c++){const d=this.path[c];d.shouldResetTransform=!0,d.updateScroll("snapshot"),d.options.layoutRoot&&d.willUpdate(!1)}const{layoutId:o,layout:l}=this.options;if(o===void 0&&!l)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),s&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(ix);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(sx);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(PB),this.nodes.forEach(RB),this.nodes.forEach(OB)):this.nodes.forEach(sx),this.clearAllSnapshots();const o=Pn.now();hn.delta=ta(0,1e3/60,o-hn.timestamp),hn.timestamp=o,hn.isProcessing=!0,Kd.update.process(hn),Kd.preRender.process(hn),Kd.render.process(hn),hn.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,A0.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(MB),this.sharedNodes.forEach(HB)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,yt.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){yt.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!wn(this.snapshot.measuredBox.x)&&!wn(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let l=0;l<this.path.length;l++)this.path[l].updateScroll();const s=this.layout;this.layout=this.measure(!1),this.layoutCorrected=Dt(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:o}=this.options;o&&o.notify("LayoutMeasure",this.layout.layoutBox,s?s.layoutBox:void 0)}updateScroll(s="measure"){let o=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===s&&(o=!1),o&&this.instance){const l=r(this.instance);this.scroll={animationId:this.root.animationId,phase:s,isRoot:l,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!a)return;const s=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,o=this.projectionDelta&&!Z2(this.projectionDelta),l=this.getTransformTemplate(),u=l?l(this.latestValues,""):void 0,c=u!==this.prevTransformTemplateValue;s&&this.instance&&(o||ci(this.latestValues)||c)&&(a(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(s=!0){const o=this.measurePageBox();let l=this.removeElementScroll(o);return s&&(l=this.removeTransform(l)),jB(l),{animationId:this.root.animationId,measuredBox:o,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:s}=this.options;if(!s)return Dt();const o=s.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(GB))){const{scroll:u}=this.root;u&&(Ki(o.x,u.offset.x),Ki(o.y,u.offset.y))}return o}removeElementScroll(s){const o=Dt();if(ir(o,s),this.scroll?.wasRoot)return o;for(let l=0;l<this.path.length;l++){const u=this.path[l],{scroll:c,options:d}=u;u!==this.root&&c&&d.layoutScroll&&(c.wasRoot&&ir(o,s),Ki(o.x,c.offset.x),Ki(o.y,c.offset.y))}return o}applyTransform(s,o=!1){const l=Dt();ir(l,s);for(let u=0;u<this.path.length;u++){const c=this.path[u];!o&&c.options.layoutScroll&&c.scroll&&c!==c.root&&Xi(l,{x:-c.scroll.offset.x,y:-c.scroll.offset.y}),ci(c.latestValues)&&Xi(l,c.latestValues)}return ci(this.latestValues)&&Xi(l,this.latestValues),l}removeTransform(s){const o=Dt();ir(o,s);for(let l=0;l<this.path.length;l++){const u=this.path[l];if(!u.instance||!ci(u.latestValues))continue;U0(u.latestValues)&&u.updateSnapshot();const c=Dt(),d=u.measurePageBox();ir(c,d),K2(o,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,c)}return ci(this.latestValues)&&K2(o,this.latestValues),o}setTargetDelta(s){this.targetDelta=s,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(s){this.options={...this.options,...s,crossfade:s.crossfade!==void 0?s.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==hn.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(s=!1){const o=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=o.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=o.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=o.isSharedProjectionDirty);const l=!!this.resumingFrom||this!==o;if(!(s||l&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:c,layoutId:d}=this.options;if(!(!this.layout||!(c||d))){if(this.resolvedRelativeTargetAt=hn.timestamp,!this.targetDelta&&!this.relativeTarget){const p=this.getClosestProjectingParent();p&&p.layout&&this.animationProgress!==1?(this.relativeParent=p,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Dt(),this.relativeTargetOrigin=Dt(),go(this.relativeTargetOrigin,this.layout.layoutBox,p.layout.layoutBox),ir(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=Dt(),this.targetWithTransforms=Dt()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),ZF(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):ir(this.target,this.layout.layoutBox),i2(this.target,this.targetDelta)):ir(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const p=this.getClosestProjectingParent();p&&!!p.resumingFrom==!!this.resumingFrom&&!p.options.layoutScroll&&p.target&&this.animationProgress!==1?(this.relativeParent=p,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Dt(),this.relativeTargetOrigin=Dt(),go(this.relativeTargetOrigin,this.target,p.target),ir(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||U0(this.parent.latestValues)||n2(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){const s=this.getLead(),o=!!this.resumingFrom||this!==s;let l=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(l=!1),o&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(l=!1),this.resolvedRelativeTargetAt===hn.timestamp&&(l=!1),l)return;const{layout:u,layoutId:c}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(u||c))return;ir(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,p=this.treeScale.y;lF(this.layoutCorrected,this.treeScale,this.path,o),s.layout&&!s.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(s.target=s.layout.layoutBox,s.targetWithTransforms=Dt());const{target:f}=s;if(!f){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(V2(this.prevProjectionDelta.x,this.projectionDelta.x),V2(this.prevProjectionDelta.y,this.projectionDelta.y)),mo(this.projectionDelta,this.layoutCorrected,f,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==p||!nx(this.projectionDelta.x,this.prevProjectionDelta.x)||!nx(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",f))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(s=!0){if(this.options.visualElement?.scheduleRender(),s){const o=this.getStack();o&&o.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Zi(),this.projectionDelta=Zi(),this.projectionDeltaWithTransform=Zi()}setAnimationOrigin(s,o=!1){const l=this.snapshot,u=l?l.latestValues:{},c={...this.latestValues},d=Zi();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!o;const p=Dt(),f=l?l.source:void 0,m=this.layout?this.layout.source:void 0,g=f!==m,x=this.getStack(),T=!x||x.members.length<=1,y=!!(g&&!T&&this.options.crossfade===!0&&!this.path.some(zB));this.animationProgress=0;let w;this.mixTargetDelta=k=>{const _=k/1e3;lx(d.x,s.x,_),lx(d.y,s.y,_),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(go(p,this.layout.layoutBox,this.relativeParent.layout.layoutBox),$B(this.relativeTarget,this.relativeTargetOrigin,p,_),w&&_B(this.relativeTarget,w)&&(this.isProjectionDirty=!1),w||(w=Dt()),ir(w,this.relativeTarget)),g&&(this.animationValues=c,vB(c,u,this.latestValues,_,y,T)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=_},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(s){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Na(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=yt.update(()=>{tu.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Vi(0)),this.currentAnimation=mB(this.motionValue,[0,1e3],{...s,velocity:0,isSync:!0,onUpdate:o=>{this.mixTargetDelta(o),s.onUpdate&&s.onUpdate(o)},onStop:()=>{},onComplete:()=>{s.onComplete&&s.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const s=this.getStack();s&&s.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(CB),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const s=this.getLead();let{targetWithTransforms:o,target:l,layout:u,latestValues:c}=s;if(!(!o||!l||!u)){if(this!==s&&this.layout&&u&&fx(this.options.animationType,this.layout.layoutBox,u.layoutBox)){l=this.target||Dt();const d=wn(this.layout.layoutBox.x);l.x.min=s.target.x.min,l.x.max=l.x.min+d;const p=wn(this.layout.layoutBox.y);l.y.min=s.target.y.min,l.y.max=l.y.min+p}ir(o,l),Xi(o,c),mo(this.projectionDeltaWithTransform,this.layoutCorrected,o,c)}}registerSharedNode(s,o){this.sharedNodes.has(s)||this.sharedNodes.set(s,new kB),this.sharedNodes.get(s).add(o);const u=o.options.initialPromotionConfig;o.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(o):void 0})}isLead(){const s=this.getStack();return s?s.lead===this:!0}getLead(){const{layoutId:s}=this.options;return s?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:s}=this.options;return s?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:s}=this.options;if(s)return this.root.sharedNodes.get(s)}promote({needsReset:s,transition:o,preserveFollowOpacity:l}={}){const u=this.getStack();u&&u.promote(this,l),s&&(this.projectionDelta=void 0,this.needsReset=!0),o&&this.setOptions({transition:o})}relegate(){const s=this.getStack();return s?s.relegate(this):!1}resetSkewAndRotation(){const{visualElement:s}=this.options;if(!s)return;let o=!1;const{latestValues:l}=s;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(o=!0),!o)return;const u={};l.z&&X0("z",s,u,this.animationValues);for(let c=0;c<K0.length;c++)X0(`rotate${K0[c]}`,s,u,this.animationValues),X0(`skew${K0[c]}`,s,u,this.animationValues);s.render();for(const c in u)s.setStaticValue(c,u[c]),this.animationValues&&(this.animationValues[c]=u[c]);s.scheduleRender()}applyProjectionStyles(s,o){if(!this.instance||this.isSVG)return;if(!this.isVisible){s.visibility="hidden";return}const l=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,s.visibility="",s.opacity="",s.pointerEvents=Ql(o?.pointerEvents)||"",s.transform=l?l(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(s.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,s.pointerEvents=Ql(o?.pointerEvents)||""),this.hasProjected&&!ci(this.latestValues)&&(s.transform=l?l({},""):"none",this.hasProjected=!1);return}s.visibility="";const c=u.animationValues||u.latestValues;this.applyTransformsToTarget();let d=NB(this.projectionDeltaWithTransform,this.treeScale,c);l&&(d=l(c,d)),s.transform=d;const{x:p,y:f}=this.projectionDelta;s.transformOrigin=`${p.origin*100}% ${f.origin*100}% 0`,u.animationValues?s.opacity=u===this?c.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:c.opacityExit:s.opacity=u===this?c.opacity!==void 0?c.opacity:"":c.opacityExit!==void 0?c.opacityExit:0;for(const m in uo){if(c[m]===void 0)continue;const{correct:g,applyTo:x,isCSSVariable:T}=uo[m],y=d==="none"?c[m]:g(c[m],u);if(x){const w=x.length;for(let k=0;k<w;k++)s[x[k]]=y}else T?this.options.visualElement.renderState.vars[m]=y:s[m]=y}this.options.layoutId&&(s.pointerEvents=u===this?Ql(o?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(s=>s.currentAnimation?.stop()),this.root.nodes.forEach(ix),this.root.sharedNodes.clear()}}}function RB(e){e.updateLayout()}function OB(e){const t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:r}=e.layout,{animationType:a}=e.options,i=t.source!==e.layout.source;a==="size"?ar(c=>{const d=i?t.measuredBox[c]:t.layoutBox[c],p=wn(d);d.min=n[c].min,d.max=d.min+p}):fx(a,t.layoutBox,n)&&ar(c=>{const d=i?t.measuredBox[c]:t.layoutBox[c],p=wn(n[c]);d.max=d.min+p,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[c].max=e.relativeTarget[c].min+p)});const s=Zi();mo(s,n,t.layoutBox);const o=Zi();i?mo(o,e.applyTransform(r,!0),t.measuredBox):mo(o,n,t.layoutBox);const l=!Z2(s);let u=!1;if(!e.resumeFrom){const c=e.getClosestProjectingParent();if(c&&!c.resumeFrom){const{snapshot:d,layout:p}=c;if(d&&p){const f=Dt();go(f,t.layoutBox,d.layoutBox);const m=Dt();go(m,n,p.layoutBox),ex(f,m)||(u=!0),c.options.layoutRoot&&(e.relativeTarget=m,e.relativeTargetOrigin=f,e.relativeParent=c)}}}e.notifyListeners("didUpdate",{layout:n,snapshot:t,delta:o,layoutDelta:s,hasLayoutChanged:l,hasRelativeLayoutChanged:u})}else if(e.isLead()){const{onExitComplete:n}=e.options;n&&n()}e.options.transition=void 0}function LB(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function DB(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function MB(e){e.clearSnapshot()}function ix(e){e.clearMeasurements()}function sx(e){e.isLayoutDirty=!1}function PB(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function ox(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function FB(e){e.resolveTargetDelta()}function BB(e){e.calcProjection()}function UB(e){e.resetSkewAndRotation()}function HB(e){e.removeLeadSnapshot()}function lx(e,t,n){e.translate=xt(t.translate,0,n),e.scale=xt(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function ux(e,t,n,r){e.min=xt(t.min,n.min,r),e.max=xt(t.max,n.max,r)}function $B(e,t,n,r){ux(e.x,t.x,n.x,r),ux(e.y,t.y,n.y,r)}function zB(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const qB={duration:.45,ease:[.4,0,.1,1]},cx=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),dx=cx("applewebkit/")&&!cx("chrome/")?Math.round:rr;function px(e){e.min=dx(e.min),e.max=dx(e.max)}function jB(e){px(e.x),px(e.y)}function fx(e,t,n){return e==="position"||e==="preserve-aspect"&&!XF(tx(t),tx(n),.2)}function GB(e){return e!==e.root&&e.scroll?.wasRoot}const VB=ax({attachResizeListener:(e,t)=>po(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Z0={current:void 0},hx=ax({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Z0.current){const e=new VB({});e.mount(window),e.setOptions({layoutScroll:!0}),Z0.current=e}return Z0.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),WB={pan:{Feature:dB},drag:{Feature:cB,ProjectionNode:hx,MeasureLayout:U2}};function mx(e,t,n){const{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive("whileHover",n==="Start");const a="onHover"+n,i=r[a];i&&yt.postRender(()=>i(t,fo(t)))}class YB extends Ra{mount(){const{current:t}=this.node;t&&(this.unmount=bP(t,(n,r)=>(mx(this.node,r,"Start"),a=>mx(this.node,a,"End"))))}unmount(){}}class KB extends Ra{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=eo(po(this.node.current,"focus",()=>this.onFocus()),po(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function gx(e,t,n){const{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive("whileTap",n==="Start");const a="onTap"+(n==="End"?"":n),i=r[a];i&&yt.postRender(()=>i(t,fo(t)))}class XB extends Ra{mount(){const{current:t}=this.node;t&&(this.unmount=TP(t,(n,r)=>(gx(this.node,r,"Start"),(a,{success:i})=>gx(this.node,a,i?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const Q0=new WeakMap,J0=new WeakMap,ZB=e=>{const t=Q0.get(e.target);t&&t(e)},QB=e=>{e.forEach(ZB)};function JB({root:e,...t}){const n=e||document;J0.has(n)||J0.set(n,{});const r=J0.get(n),a=JSON.stringify(t);return r[a]||(r[a]=new IntersectionObserver(QB,{root:e,...t})),r[a]}function eU(e,t,n){const r=JB(t);return Q0.set(e,n),r.observe(e),()=>{Q0.delete(e),r.unobserve(e)}}const tU={some:0,all:1};class nU extends Ra{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:r,amount:a="some",once:i}=t,s={root:n?n.current:void 0,rootMargin:r,threshold:typeof a=="number"?a:tU[a]},o=l=>{const{isIntersecting:u}=l;if(this.isInView===u||(this.isInView=u,i&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:c,onViewportLeave:d}=this.node.getProps(),p=u?c:d;p&&p(l)};return eU(this.node.current,s,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(rU(t,n))&&this.startObserver()}unmount(){}}function rU({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const aU={...jF,...{inView:{Feature:nU},tap:{Feature:XB},focus:{Feature:KB},hover:{Feature:YB}},...WB,...{layout:{ProjectionNode:hx,MeasureLayout:U2}}},ke=iF(aU,EF);function Eo({isOpen:e,onClose:t,title:n,children:r,maxWidth:a="max-w-2xl"}){return b.jsx(Dr,{children:e&&b.jsxs(Nd,{static:!0,open:e,onClose:t,className:"relative z-50",children:[b.jsxs(ke.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.4,ease:"easeInOut"},className:"fixed inset-0","aria-hidden":"true",children:[b.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-black/40 via-black/30 to-black/50"}),b.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-neutral-900/20 via-transparent to-neutral-800/10"}),b.jsxs("div",{className:"absolute inset-0 opacity-30",children:[b.jsx("div",{className:"absolute top-0 left-0 w-full h-full bg-gradient-to-br from-indigo-500/5 via-transparent to-purple-500/5"}),b.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_center,_var(--tw-gradient-stops))] from-transparent via-white/2 to-transparent"})]})]}),b.jsx("div",{className:"fixed inset-0 flex w-screen items-center justify-center p-4",children:b.jsx(ke.div,{initial:{opacity:0,scale:.9,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.9,y:20},transition:{duration:.3,ease:[.4,0,.2,1],opacity:{duration:.25}},children:b.jsxs(Bl,{className:`w-full ${a} min-w-xl space-y-4 rounded-2xl border border-neutral-200/20 bg-white/95 p-8 shadow-2xl shadow-black/20 backdrop-blur-xl dark:border-neutral-700/30 dark:bg-neutral-900/95 dark:shadow-black/40`,children:[b.jsx(pT,{className:"text-lg font-bold text-neutral-900 dark:text-neutral-100",children:n}),r]})})})]})})}const iU=({isOpen:e,onClose:t,server:n,toolName:r,toolDescription:a})=>{const{token:i,backendUrl:s,addToolExecution:o}=Kt(),[l,u]=v.useState("{}"),[c,d]=v.useState(null),[p,f]=v.useState(!1),[m,g]=v.useState(null),x=k=>{try{return JSON.parse(k),g(null),!0}catch{return g("Invalid JSON format"),!1}},T=k=>{u(k),m&&x(k)},y=async()=>{if(x(l)){f(!0),d(null);try{const k=Date.now(),_=await fetch(`${s}/xyzen-api/v1/mcps/${n.id}/tools/${r}/test`,{method:"POST",headers:{"Content-Type":"application/json",...i&&{Authorization:`Bearer ${i}`}},body:JSON.stringify({parameters:JSON.parse(l)})}),R=Date.now()-k;if(_.ok){const M=await _.json(),P={success:M.success,result:M.result,error:M.error,executionTime:M.execution_time_ms||R};d(P),o({serverId:n.id,toolName:r,parameters:JSON.parse(l),result:M.result,success:M.success,error:M.error,executionTime:M.execution_time_ms||R})}else{const M=await _.json(),P={success:!1,error:M.detail||"Tool execution failed",executionTime:R};d(P),o({serverId:n.id,toolName:r,parameters:JSON.parse(l),success:!1,error:M.detail||"Tool execution failed",executionTime:R})}}catch(k){const _={success:!1,error:k instanceof Error?k.message:"Network error",executionTime:Date.now()-Date.now()};d(_),o({serverId:n.id,toolName:r,parameters:JSON.parse(l),success:!1,error:k instanceof Error?k.message:"Network error",executionTime:Date.now()-Date.now()})}finally{f(!1)}}},w=()=>{p||(u("{}"),d(null),g(null),t())};return b.jsx(Eo,{isOpen:e,onClose:w,title:"Test MCP Tool",maxWidth:"max-w-[calc(100vw-200px)]",children:b.jsxs("div",{className:"flex flex-col h-[calc(100vh-200px)] gap-6",children:[b.jsxs("div",{className:"flex flex-1 gap-6 min-h-0",children:[b.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[b.jsxs("div",{className:"rounded-lg bg-neutral-50 p-4 dark:bg-neutral-800/50 mb-6",children:[b.jsxs("div",{className:"flex items-center space-x-2 mb-3",children:[b.jsx(TT,{className:"h-5 w-5 text-indigo-500"}),b.jsx("h3",{className:"font-medium text-neutral-900 dark:text-white",children:"Tool Information"})]}),b.jsxs("div",{className:"space-y-3",children:[b.jsxs("div",{children:[b.jsx("span",{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Tool Name:"}),b.jsx("code",{className:"ml-2 rounded bg-neutral-200 px-2 py-1 text-sm font-mono text-indigo-600 dark:bg-neutral-700 dark:text-indigo-400",children:r})]}),b.jsxs("div",{children:[b.jsx("span",{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Server:"}),b.jsxs("span",{className:"ml-2 text-sm text-neutral-600 dark:text-neutral-400",children:[n.name," (",n.url,")"]})]}),a&&b.jsxs("div",{children:[b.jsx("span",{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Description:"}),b.jsx("p",{className:"mt-1 text-sm text-neutral-600 dark:text-neutral-400 leading-relaxed",children:a})]})]})]}),b.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[b.jsxs("label",{className:"mb-3 flex items-center space-x-2 text-sm font-medium text-neutral-700 dark:text-neutral-300",children:[b.jsx(rM,{className:"h-4 w-4"}),b.jsx("span",{children:"Parameters (JSON)"})]}),b.jsx("textarea",{value:l,onChange:k=>T(k.target.value),placeholder:'{"key": "value"}',className:"flex-1 w-full rounded-lg border border-neutral-300 bg-white px-3 py-2 text-sm font-mono text-neutral-900 placeholder-neutral-500 focus:border-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/20 dark:border-neutral-600 dark:bg-neutral-800 dark:text-neutral-100 dark:placeholder-neutral-400 resize-none min-h-[200px]"}),m&&b.jsxs("div",{className:"mt-2 flex items-center space-x-2 text-sm text-red-600 dark:text-red-400",children:[b.jsx(ST,{className:"h-4 w-4"}),b.jsx("span",{children:m})]})]})]}),b.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[b.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx("div",{className:"h-5 w-5 rounded-full bg-gradient-to-r from-green-500 to-emerald-500 flex items-center justify-center",children:b.jsx("span",{className:"text-white text-xs font-bold",children:"R"})}),b.jsx("h3",{className:"font-medium text-neutral-900 dark:text-white",children:"Test Results"})]}),b.jsx(xn,{onClick:y,disabled:p||!!m,className:"inline-flex items-center gap-2 rounded-lg bg-gradient-to-r from-indigo-600 to-indigo-700 px-4 py-2 text-sm font-medium text-white shadow-lg transition-all hover:from-indigo-500 hover:to-indigo-600 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed",children:p?b.jsxs(b.Fragment,{children:[b.jsx(Ui,{size:"sm"}),"Running..."]}):b.jsxs(b.Fragment,{children:[b.jsx(Dd,{className:"h-4 w-4"}),"Test Tool"]})})]}),b.jsx("div",{className:"flex-1 overflow-y-auto min-w-0",children:b.jsxs(Dr,{mode:"wait",children:[p&&b.jsxs(ke.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.2},className:"flex flex-col items-center justify-center h-64 text-center",children:[b.jsx(Ui,{size:"lg",centered:!0}),b.jsx("p",{className:"mt-4 text-sm text-neutral-600 dark:text-neutral-400",children:"Executing tool..."})]},"loading"),!p&&!c&&b.jsxs(ke.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{duration:.2},className:"flex flex-col items-center justify-center h-64 text-center",children:[b.jsx("div",{className:"rounded-full bg-neutral-100 dark:bg-neutral-800 p-6 mb-4",children:b.jsx(Dd,{className:"h-12 w-12 text-neutral-400 dark:text-neutral-500"})}),b.jsx("p",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:'Click "Test Tool" to see results here'})]},"empty"),!p&&c&&b.jsxs(ke.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.3},className:`rounded-lg border p-4 ${c.success?"border-green-200 bg-green-50 dark:border-green-800 dark:bg-green-900/20":"border-red-200 bg-red-50 dark:border-red-800 dark:bg-red-900/20"}`,children:[b.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[b.jsx("h4",{className:`font-semibold ${c.success?"text-green-800 dark:text-green-300":"text-red-800 dark:text-red-300"}`,children:c.success?"✅ Success":"❌ Error"}),c.executionTime&&b.jsxs("span",{className:"text-xs font-medium text-neutral-600 dark:text-neutral-400 bg-neutral-100 dark:bg-neutral-800 px-2 py-1 rounded",children:[c.executionTime,"ms"]})]}),b.jsxs("div",{className:"space-y-4",children:[c.success&&c.result!==null&&c.result!==void 0&&b.jsxs("div",{children:[b.jsx("span",{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300 mb-2 block",children:"Result:"}),b.jsx("pre",{className:"overflow-auto rounded-lg bg-neutral-900 p-4 text-sm text-green-400 dark:bg-neutral-800 max-h-96 whitespace-pre-wrap break-words",children:typeof c.result=="string"?c.result:JSON.stringify(c.result,null,2)??"null"})]}),!c.success&&c.error&&b.jsxs("div",{children:[b.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-300 mb-2 block",children:"Error:"}),b.jsx("pre",{className:"overflow-auto rounded-lg bg-neutral-900 p-4 text-sm text-red-400 dark:bg-neutral-800 max-h-96 whitespace-pre-wrap break-words",children:c.error})]})]})]},"result")]})})]})]}),b.jsx("div",{className:"flex-shrink-0 flex justify-end pt-4 border-t border-neutral-200 dark:border-neutral-700",children:b.jsx(xn,{onClick:w,disabled:p,className:"rounded-lg bg-neutral-200 px-6 py-2 text-sm font-medium text-neutral-700 transition-colors hover:bg-neutral-300 focus:outline-none focus:ring-2 focus:ring-neutral-500 focus:ring-offset-2 disabled:opacity-50 dark:bg-neutral-700 dark:text-neutral-200 dark:hover:bg-neutral-600",children:"Close"})})]})})},sU=e=>{const t=Kt.getState().backendUrl,n=new URL(t);return`${n.protocol==="https:"?"wss:":"ws:"}//${n.host}${e}`};class oU{ws=null;connect(t,n){this.ws&&this.ws.close();const r=sU(t);this.ws=new WebSocket(r),this.ws.onopen=()=>{console.log("WebSocket connected")},this.ws.onmessage=a=>{try{const i=JSON.parse(a.data);n(i)}catch(i){console.error("Failed to parse WebSocket message:",i)}},this.ws.onerror=a=>{console.error("WebSocket error:",a)},this.ws.onclose=()=>{console.log("WebSocket disconnected")}}disconnect(){this.ws&&(this.ws.close(),this.ws=null)}}const bx=new oU,lU=({status:e})=>{const t=e==="online";return b.jsxs("div",{className:"flex items-center",children:[b.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${t?"bg-green-500":"bg-red-500"}`}),b.jsx("span",{className:`ml-2 text-xs font-medium transition-colors duration-200 ${t?"text-green-700 dark:text-green-300":"text-red-700 dark:text-red-300"}`,children:t?"Online":"Offline"})]})},uU=({server:e,onRemove:t,onTestTool:n})=>{const r=e.tools?.length||0,[a,i]=v.useState(!1),[s,o]=v.useState(!1),l=async()=>{i(!0);try{await t(e.id)}catch(c){i(!1),console.error("Failed to remove server:",c)}},u=()=>{r>0&&o(!s)};return b.jsxs(ke.div,{layout:!0,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2},className:"group relative overflow-hidden rounded-xl border border-neutral-200/50 bg-white/50 shadow-sm backdrop-blur-sm transition-all duration-300 hover:border-indigo-200 hover:bg-white/80 hover:shadow-md dark:border-neutral-800/50 dark:bg-neutral-900/50 dark:hover:border-indigo-800 dark:hover:bg-neutral-900/80",children:[b.jsxs("div",{className:"flex items-center justify-between p-4",children:[b.jsxs("div",{className:"flex-1 overflow-hidden",children:[b.jsxs("div",{className:"flex items-center",children:[b.jsx(lU,{status:e.status}),b.jsxs("div",{className:"ml-3 flex items-center space-x-2",children:[b.jsx(Md,{className:"h-4 w-4 text-indigo-500"}),b.jsx("h3",{className:"truncate text-sm font-semibold text-neutral-800 dark:text-white",children:e.name})]})]}),e.description&&b.jsx("p",{className:"mt-2 truncate text-xs text-neutral-600 dark:text-neutral-400",children:e.description}),b.jsxs("div",{className:"mt-3 flex items-center space-x-4 text-xs text-neutral-500",children:[b.jsxs("div",{className:"flex items-center space-x-1",children:[b.jsx(oM,{className:"h-3.5 w-3.5"}),b.jsx("span",{className:"truncate max-w-48",children:e.url})]}),b.jsxs(ke.button,{onClick:u,disabled:r===0,className:`flex items-center space-x-1 rounded-md px-2 py-1 transition-colors ${r>0?"hover:bg-indigo-50 dark:hover:bg-indigo-900/20":"cursor-not-allowed opacity-50"}`,children:[b.jsx(AM,{className:"h-3.5 w-3.5"}),b.jsxs("span",{className:"whitespace-nowrap font-medium",children:[r," ",r===1?"Tool":"Tools"]}),r>0&&b.jsx(ke.div,{animate:{rotate:s?90:0},transition:{duration:.2},children:b.jsx(ET,{className:"h-3 w-3"})})]})]})]}),b.jsx("div",{className:"ml-6 flex items-center",children:b.jsx(ke.button,{whileTap:{scale:.95},onClick:l,disabled:a,className:"rounded-lg p-2 text-neutral-400 opacity-0 transition-all duration-200 hover:bg-red-50 hover:text-red-600 group-hover:opacity-100 disabled:opacity-50 dark:hover:bg-red-900/20 dark:hover:text-red-400",title:"Remove Server",children:a?b.jsx(ke.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:b.jsx(Ui,{size:"sm"})}):b.jsx(wT,{className:"h-4 w-4"})})})]}),b.jsx(Dr,{children:s&&r>0&&b.jsx(ke.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.3,ease:"easeInOut"},className:"overflow-hidden border-t border-neutral-200/30 dark:border-neutral-700/30",children:b.jsxs("div",{className:"p-4 pt-3",children:[b.jsxs("div",{className:"mb-2 flex items-center space-x-2",children:[b.jsx(TT,{className:"h-3.5 w-3.5 text-indigo-500"}),b.jsx("span",{className:"text-xs font-medium text-neutral-700 dark:text-neutral-300",children:"Available Tools"})]}),b.jsx("div",{className:"max-h-64 overflow-y-auto space-y-2 scrollbar-thin scrollbar-thumb-neutral-300 scrollbar-track-transparent dark:scrollbar-thumb-neutral-600 pr-2",children:e.tools?.map((c,d)=>b.jsxs(ke.button,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:d*.05},onClick:()=>n(e,c.name,c.description),className:"w-full flex items-start justify-between rounded-lg bg-neutral-50/80 p-3 text-left transition-all hover:bg-neutral-100/80 hover:shadow-sm active:scale-[0.99] dark:bg-neutral-800/50 dark:hover:bg-neutral-700/50 group cursor-pointer",children:[b.jsxs("div",{className:"flex-1 min-w-0",children:[b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx("code",{className:"text-xs font-mono font-semibold text-indigo-600 dark:text-indigo-400",children:c.name}),b.jsx("span",{className:"text-xs text-neutral-500 opacity-0 group-hover:opacity-100 transition-opacity",children:"Click to test"})]}),c.description&&b.jsx("p",{className:"mt-1 text-xs text-neutral-600 dark:text-neutral-400 line-clamp-2",children:c.description})]}),b.jsx("div",{className:"ml-3 opacity-60 group-hover:opacity-100 transition-opacity",children:b.jsx(Dd,{className:"h-4 w-4 text-indigo-500"})})]},`${c.name}-${d}`))})]})})})]})};function cU(){const{mcpServers:e,fetchMcpServers:t,refreshMcpServers:n,removeMcpServer:r,updateMcpServerInList:a,backendUrl:i,openAddMcpServerModal:s,getLoading:o,toolTestModal:l,openToolTestModal:u,closeToolTestModal:c}=Kt(),d=o("mcpServers"),p=(m,g,x)=>{u(m,g,x)};v.useEffect(()=>{if(i)return t(),bx.connect("/xyzen-ws/v1/mcp",m=>{a(m)}),()=>{bx.disconnect()}},[i,t,a]);const f=()=>{n()};return b.jsxs("div",{className:"min-h-full rounded-2xl bg-gradient-to-br from-neutral-50 via-white to-neutral-100 p-6 dark:from-neutral-950 dark:via-neutral-900 dark:to-neutral-950",children:[b.jsxs(ke.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5},className:"mx-auto max-w-6xl",children:[b.jsxs(ke.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,delay:.1},className:"mb-8 flex items-center justify-between",children:[b.jsxs("div",{className:"flex items-center space-x-3",children:[b.jsx("div",{className:"rounded-xl bg-gradient-to-r from-indigo-500 to-purple-500 p-2.5 shadow-lg",children:b.jsx(Md,{className:"h-6 w-6 text-white"})}),b.jsxs("div",{children:[b.jsx("h1",{className:"text-2xl font-bold tracking-tight text-neutral-900 dark:text-neutral-100",children:"MCP Servers"}),b.jsx("p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:"Manage your Model-Context-Protocol servers."})]})]}),b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsxs("button",{onClick:f,disabled:d,className:"inline-flex items-center gap-2 rounded-xl border border-neutral-200 bg-white px-4 py-2.5 text-sm font-semibold text-neutral-700 shadow-sm transition-colors hover:bg-neutral-50 disabled:cursor-not-allowed disabled:opacity-50 dark:border-neutral-800 dark:bg-neutral-900 dark:text-neutral-200 dark:hover:bg-neutral-800",children:[b.jsx(mT,{className:`h-4 w-4 ${d?"animate-spin":""}`}),b.jsx("span",{children:"Refresh"})]}),b.jsxs("button",{onClick:s,className:"inline-flex items-center gap-2 rounded-xl bg-gradient-to-r from-indigo-600 to-indigo-700 px-4 py-2.5 text-sm font-semibold text-white shadow-lg shadow-indigo-500/25 transition-all duration-200 hover:from-indigo-500 hover:to-indigo-600 hover:shadow-xl hover:shadow-indigo-500/30 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 dark:shadow-indigo-500/20 dark:hover:shadow-indigo-500/40",children:[b.jsx(ii,{className:"h-4 w-4"}),"Add Server"]})]})]}),b.jsx(ke.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,delay:.2},className:"relative",children:b.jsxs("div",{className:"relative min-h-[66vh] max-h-[66vh] overflow-hidden rounded-3xl border border-neutral-200/30 bg-gradient-to-br from-white/80 via-white/60 to-white/40 backdrop-blur-xl dark:border-neutral-700/30 dark:from-neutral-900/80 dark:via-neutral-900/60 dark:to-neutral-900/40",children:[b.jsxs("div",{className:"absolute inset-0 opacity-30",children:[b.jsx("div",{className:"absolute top-0 right-0 w-96 h-96 bg-gradient-to-bl from-indigo-100/50 via-transparent to-transparent rounded-full blur-3xl dark:from-indigo-900/30"}),b.jsx("div",{className:"absolute bottom-0 left-0 w-80 h-80 bg-gradient-to-tr from-purple-100/40 via-transparent to-transparent rounded-full blur-3xl dark:from-purple-900/20"})]}),b.jsx("div",{className:"relative h-full overflow-y-auto p-8 scrollbar-thin scrollbar-thumb-neutral-300 scrollbar-track-transparent dark:scrollbar-thumb-neutral-600",children:b.jsx(Dr,{mode:"wait",children:d?b.jsx(ke.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex items-center justify-center h-full min-h-[400px]",children:b.jsxs("div",{className:"text-center",children:[b.jsx(Ui,{size:"md",centered:!0}),b.jsx("p",{className:"mt-3 text-sm text-neutral-600 dark:text-neutral-400",children:"Loading MCP servers..."})]})},"loading"):e.length>0?b.jsx(ke.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"space-y-4",children:b.jsx(Dr,{children:e.map((m,g)=>b.jsx(ke.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.3,delay:g*.1},children:b.jsx(uU,{server:m,onRemove:r,onTestTool:p})},m.id))})},"servers"):b.jsxs(ke.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3},className:"flex flex-col items-center justify-center h-full min-h-[400px] text-center",children:[b.jsx(ke.div,{initial:{scale:0},animate:{scale:1},transition:{duration:.5,delay:.2,type:"spring"},className:"mb-6 rounded-full bg-gradient-to-br from-indigo-100/80 to-purple-100/60 p-6 dark:from-indigo-900/40 dark:to-purple-900/30",children:b.jsx(Ld,{className:"h-12 w-12 text-indigo-500"})}),b.jsxs(ke.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.3,delay:.4},children:[b.jsx("h3",{className:"text-xl font-semibold text-neutral-900 dark:text-white",children:"No MCP Servers Found"}),b.jsx("p",{className:"mt-2 max-w-md text-sm text-neutral-600 dark:text-neutral-400",children:"Get started by adding your first MCP server to connect tools and enhance your AI capabilities."})]}),b.jsx(ke.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.3,delay:.6},children:b.jsxs(xn,{onClick:s,className:"mt-8 inline-flex items-center gap-2 rounded-xl bg-gradient-to-r from-indigo-600 to-indigo-700 px-6 py-3 text-sm font-semibold text-white transition-all duration-200 hover:from-indigo-500 hover:to-indigo-600 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2",children:[b.jsx(ii,{className:"h-5 w-5"}),"Add Your First Server"]})})]},"empty")})})]})})]}),l.isOpen&&l.server&&l.toolName&&b.jsx(iU,{isOpen:l.isOpen,onClose:c,server:l.server,toolName:l.toolName,toolDescription:l.toolDescription})]})}const nu=e=>b.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",fillRule:"evenodd",viewBox:"0 0 24 24",...e,children:[b.jsx("title",{children:"ModelContextProtocol"}),b.jsx("path",{d:"M15.688 2.343a2.588 2.588 0 00-3.61 0l-9.626 9.44a.863.863 0 01-1.203 0 .823.823 0 010-1.18l9.626-9.44a4.313 4.313 0 016.016 0 4.116 4.116 0 011.204 3.54 4.3 4.3 0 013.609 1.18l.05.05a4.115 4.115 0 010 5.9l-8.706 8.537a.274.274 0 000 .393l1.788 1.754a.823.823 0 010 1.18.863.863 0 01-1.203 0l-1.788-1.753a1.92 1.92 0 010-2.754l8.706-8.538a2.47 2.47 0 000-3.54l-.05-.049a2.588 2.588 0 00-3.607-.003l-7.172 7.034-.002.002-.098.097a.863.863 0 01-1.204 0 .823.823 0 010-1.18l7.273-7.133a2.47 2.47 0 00-.003-3.537z"}),b.jsx("path",{d:"M14.485 4.703a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a4.115 4.115 0 000 5.9 4.314 4.314 0 006.016 0l7.12-6.982a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a2.588 2.588 0 01-3.61 0 2.47 2.47 0 010-3.54l7.12-6.982z"})]});function dU(){const[e,t]=v.useState({state:Gn.NOT_AUTHENTICATED,message:"检查中..."}),[n,r]=v.useState(!0),a=v.useCallback(l=>{t(l),r(!1)},[]),i=v.useCallback(async(l=!1)=>{r(!0);try{const u=await $t.checkAuthState(l);t(u)}catch(u){console.error("Auth check failed:",u),t({state:Gn.ERROR,message:u instanceof Error?u.message:"认证检查失败"})}finally{r(!1)}},[]),s=v.useCallback(async l=>{r(!0);try{const u=await $t.login(l);t(u)}catch(u){console.error("Login failed:",u),t({state:Gn.ERROR,message:u instanceof Error?u.message:"登录失败"})}finally{r(!1)}},[]),o=v.useCallback(()=>{$t.logout()},[]);return v.useEffect(()=>((async()=>{r(!0);try{const u=await $t.autoLogin();t(u)}catch(u){console.error("Auto-login failed:",u),t({state:Gn.ERROR,message:u instanceof Error?u.message:"自动登录失败"})}finally{r(!1)}})(),$t.addAuthStateListener(a),()=>{$t.removeAuthStateListener(a)}),[a]),{authState:e.state,user:e.user,message:e.message,provider:e.provider,isLoading:n,isAuthenticated:e.state===Gn.AUTHENTICATED,isConfigured:e.state!==Gn.NOT_CONFIGURED,login:s,logout:o,checkAuth:i}}function pU({isOpen:e,onClose:t,onSubmit:n}){const[r,a]=v.useState(""),i=l=>{l.preventDefault(),r.trim()&&(n(r.trim()),a(""),t())},s=v.useCallback(()=>{a(""),t()},[t]),o=l=>{l.target===l.currentTarget&&s()};return v.useEffect(()=>{const l=u=>{u.key==="Escape"&&s()};if(e)return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[e,s]),e?b.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50",onClick:o,children:b.jsxs("div",{className:"w-full max-w-md rounded-lg bg-white p-6 shadow-xl dark:bg-neutral-800",children:[b.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[b.jsx("h3",{className:"text-lg font-medium text-neutral-900 dark:text-neutral-100",children:"输入访问令牌"}),b.jsx("button",{onClick:s,className:"rounded-md p-1 text-neutral-400 hover:bg-neutral-100 hover:text-neutral-500 dark:hover:bg-neutral-700",children:b.jsx(Fd,{className:"h-5 w-5"})})]}),b.jsxs("form",{onSubmit:i,children:[b.jsxs("div",{className:"mb-4",children:[b.jsx("label",{htmlFor:"token-input",className:"block text-sm font-medium text-neutral-700 dark:text-neutral-300 mb-2",children:"访问令牌"}),b.jsx("input",{id:"token-input",type:"password",value:r,onChange:l=>a(l.target.value),placeholder:"请输入您的访问令牌",className:"w-full rounded-md border border-neutral-300 px-3 py-2 text-sm focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500 dark:border-neutral-600 dark:bg-neutral-700 dark:text-neutral-100",autoFocus:!0,required:!0}),b.jsx("p",{className:"mt-1 text-xs text-neutral-500 dark:text-neutral-400",children:"请输入有效的访问令牌进行身份验证"})]}),b.jsxs("div",{className:"flex justify-end space-x-3",children:[b.jsx("button",{type:"button",onClick:s,className:"rounded-md px-4 py-2 text-sm font-medium text-neutral-700 hover:bg-neutral-50 dark:text-neutral-300 dark:hover:bg-neutral-700",children:"取消"}),b.jsx("button",{type:"submit",className:"rounded-md bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2",children:"确认"})]})]})]})}):null}function fU({onTokenInput:e,className:t=""}){const n=dU(),[r,a]=v.useState(!1),i=async s=>{await n.login(s),e?.(s)};if(n.isLoading)return b.jsxs("div",{className:`flex items-center space-x-2 ${t}`,children:[b.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-neutral-300 border-t-indigo-600 dark:border-neutral-700 dark:border-t-indigo-500"}),b.jsx("span",{className:"text-sm text-neutral-500",children:"检查认证状态..."})]});switch(n.authState){case Gn.NOT_CONFIGURED:case Gn.NOT_AUTHENTICATED:case Gn.ERROR:{const s=n.authState===Gn.NOT_CONFIGURED?"认证服务未配置":n.authState===Gn.ERROR?"认证错误":"未授权的用户";return b.jsxs(b.Fragment,{children:[b.jsx("div",{className:`flex items-center space-x-2 ${t}`,children:b.jsx("button",{onClick:()=>a(!0),className:"flex items-center justify-center h-6 w-6 rounded-full text-amber-600 hover:bg-amber-50 dark:text-amber-400 dark:hover:bg-amber-900/20 transition-colors",title:s,children:b.jsx(Ld,{className:"h-4 w-4"})})}),b.jsx(pU,{isOpen:r,onClose:()=>a(!1),onSubmit:i})]})}case Gn.AUTHENTICATED:return b.jsx("div",{className:`flex items-center space-x-2 ${t}`,children:b.jsxs("div",{className:"flex items-center space-x-2",children:[n.user?.avatar_url?b.jsx("img",{src:n.user.avatar_url,alt:n.user.display_name||n.user.username,className:"h-6 w-6 rounded-full"}):b.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-indigo-100 dark:bg-indigo-900",children:b.jsx(Pd,{className:"h-4 w-4 text-indigo-600 dark:text-indigo-400"})}),b.jsx("div",{className:"flex flex-col",children:b.jsx("span",{className:"text-sm font-medium max-w-16 truncate text-neutral-900 dark:text-neutral-100",children:n.user?.display_name||n.user?.username})})]})});default:return b.jsxs("div",{className:`flex items-center space-x-2 ${t}`,children:[b.jsx(Ld,{className:"h-5 w-5 text-red-500"}),b.jsx("span",{className:"text-sm text-red-600",title:n.message,children:"未知状态"})]})}}const Ex=({children:e,variant:t="default",size:n="sm",className:r})=>{const a="inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium",i={default:"bg-neutral-100 text-neutral-800 dark:bg-neutral-800 dark:text-neutral-200",blue:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",green:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",yellow:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200",red:"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200",gray:"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-200"},s={sm:"text-xs",md:"text-sm px-2.5 py-1"};return b.jsx("span",{className:Oi(a,i[t],s[n],r),children:e})},hU="block w-full appearance-none rounded-lg border-[1px] border-neutral-300 bg-white py-[calc(theme(spacing.2)-1px)] px-[calc(theme(spacing.3)-1px)] text-neutral-950 placeholder:text-neutral-500 sm:text-sm/6 focus:outline-none focus:ring-1 focus:ring-inset focus:ring-indigo-500 dark:border-neutral-700 dark:bg-neutral-800 dark:text-white dark:focus:ring-indigo-400";function Vn({className:e,...t}){return b.jsx("span",{className:Oi(e,"relative"),children:b.jsx(dD,{className:Oi(hU,"pr-8"),...t})})}const mU={type:"spring",stiffness:700,damping:30},gU=({checked:e,onChange:t,className:n,disabled:r=!1})=>b.jsxs(vD,{checked:e,onChange:t,disabled:r,className:Oi("group relative inline-flex h-6 w-11 flex-shrink-0 rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 dark:focus:ring-offset-neutral-900",n,{"cursor-pointer":!r,"cursor-not-allowed opacity-50":r},e?"bg-indigo-600":"bg-neutral-200 dark:bg-neutral-700"),children:[b.jsx("span",{className:"sr-only",children:"Use setting"}),b.jsx(ke.span,{animate:{x:e?20:0},transition:mU,className:"pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow ring-0"})]}),yx=({mcp:e,isSelected:t,onSelectionChange:n})=>{const r=e.status!=="online";return b.jsxs("div",{className:Oi("flex items-center justify-between rounded-lg p-3 transition-colors",{"hover:bg-neutral-100 dark:hover:bg-neutral-800":!r,"opacity-60":r}),title:r?"This MCP server is offline and cannot be selected":"",children:[b.jsxs("div",{className:"flex-grow",children:[b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx("div",{className:Oi("h-2.5 w-2.5 flex-shrink-0 rounded-full",{"bg-green-500":!r,"bg-neutral-500":r})}),b.jsx("p",{className:"font-medium text-neutral-900 dark:text-neutral-100",children:e.name}),e.tools&&e.tools.length>0&&b.jsxs(Ex,{variant:"blue",children:[e.tools.length," Tools"]})]}),b.jsx("p",{className:"mt-1 text-sm text-neutral-600 dark:text-neutral-400 line-clamp-1",children:e.description||"No description available"})]}),b.jsx("div",{className:"ml-4",children:b.jsx(gU,{checked:t,onChange:n,disabled:r})})]})},bU=({isOpen:e,onClose:t})=>{const{createAgent:n,mcpServers:r,fetchMcpServers:a,openAddMcpServerModal:i}=Kt(),[s,o]=v.useState({name:"",description:"",prompt:""}),[l,u]=v.useState([]);v.useEffect(()=>{e&&a()},[e,a]);const c=f=>{const{name:m,value:g}=f.target;o(x=>({...x,[m]:g}))},d=f=>{u(m=>m.includes(f)?m.filter(g=>g!==f):[...m,f])},p=async f=>{if(f.preventDefault(),!s.name){alert("助手名称不能为空");return}try{await n({...s,mcp_server_ids:l,user_id:"temp",mcp_servers:[]}),t(),o({name:"",description:"",prompt:""}),u([])}catch(m){console.error("Failed to create agent:",m),alert("创建助手失败,请查看控制台获取更多信息。")}};return b.jsxs(Eo,{isOpen:e,onClose:t,title:"添加新助手",children:[b.jsx("p",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:"创建一个新的助手来协助您完成任务。"}),b.jsxs("form",{onSubmit:p,className:"mt-4 space-y-4",children:[b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"名称"}),b.jsx(Vn,{name:"name",value:s.name,onChange:c,placeholder:"例如:研究助手",required:!0})]}),b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"描述"}),b.jsx("textarea",{name:"description",value:s.description,onChange:c,placeholder:"助手的目的简要描述",className:"w-full rounded-md border-neutral-300 bg-neutral-100 px-3 py-2 text-sm text-neutral-900 placeholder-neutral-400 focus:border-indigo-500 focus:ring-indigo-500 dark:border-neutral-700 dark:bg-neutral-800 dark:text-neutral-100 dark:placeholder-neutral-500"})]}),b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"系统提示"}),b.jsx("textarea",{name:"prompt",value:s.prompt,onChange:c,placeholder:"定义助手的行为和个性",rows:4,className:"w-full rounded-md border-neutral-300 bg-neutral-100 px-3 py-2 text-sm text-neutral-900 placeholder-neutral-400 focus:border-indigo-500 focus:ring-indigo-500 dark:border-neutral-700 dark:bg-neutral-800 dark:text-neutral-100 dark:placeholder-neutral-500"})]}),b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"连接的 MCP 服务器"}),b.jsx("div",{className:"mt-2 max-h-40 space-y-1 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50 p-2 dark:border-neutral-700 dark:bg-neutral-800/50",children:r.length>0?r.map(f=>b.jsx(yx,{mcp:f,isSelected:l.includes(f.id),onSelectionChange:()=>d(f.id)},f.id)):b.jsxs("div",{className:"flex flex-col items-center justify-center p-4 text-center",children:[b.jsx("p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:"No MCP servers available."}),b.jsxs(xn,{type:"button",onClick:()=>{t(),i()},className:"mt-2 inline-flex items-center gap-2 rounded-md bg-indigo-100 py-1.5 px-3 text-sm/6 font-semibold text-indigo-600 focus:outline-none data-[hover]:bg-indigo-200 dark:bg-indigo-900/50 dark:text-indigo-300 dark:data-[hover]:bg-indigo-900",children:[b.jsx(ii,{className:"h-4 w-4"}),"Create MCP Server"]})]})})]}),b.jsxs("div",{className:"mt-6 flex justify-end gap-4",children:[b.jsx(xn,{type:"button",onClick:t,className:"inline-flex items-center gap-2 rounded-md bg-neutral-100 py-1.5 px-3 text-sm/6 font-semibold text-neutral-700 shadow-sm focus:outline-none data-[hover]:bg-neutral-200 dark:bg-neutral-800 dark:text-neutral-200 dark:data-[hover]:bg-neutral-700",children:"取消"}),b.jsx(xn,{type:"submit",className:"inline-flex items-center gap-2 rounded-md bg-indigo-600 py-1.5 px-3 text-sm/6 font-semibold text-white shadow-inner shadow-white/10 focus:outline-none data-[hover]:bg-indigo-500 data-[open]:bg-indigo-700 data-[focus]:outline-1 data-[focus]:outline-white dark:bg-indigo-500 dark:data-[hover]:bg-indigo-400",children:"创建助手"})]})]})]})},EU=({isOpen:e,onClose:t,agent:n})=>{const{updateAgent:r,mcpServers:a,fetchMcpServers:i,openAddMcpServerModal:s}=Kt(),[o,l]=v.useState(n),[u,c]=v.useState([]);v.useEffect(()=>{l(n),n&&c(n.mcp_servers.map(m=>m.id)),e&&i()},[n,e,i]);const d=m=>{if(!o)return;const{name:g,value:x}=m.target;l({...o,[g]:x})},p=m=>{c(g=>g.includes(m)?g.filter(x=>x!==m):[...g,m])},f=async m=>{m.preventDefault(),o&&(await r({...o,mcp_server_ids:u}),t())};return o?b.jsxs(Eo,{isOpen:e,onClose:t,title:`Edit ${o.name}`,children:[b.jsx("p",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:"Update the details for your agent."}),b.jsxs("form",{onSubmit:f,className:"mt-4 space-y-4",children:[b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Name"}),b.jsx(Vn,{name:"name",value:o.name,onChange:d,placeholder:"e.g., Research Assistant",required:!0})]}),b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Description"}),b.jsx("textarea",{name:"description",value:o.description,onChange:d,placeholder:"A brief description of the agent's purpose",className:"w-full rounded-md border-neutral-300 bg-neutral-100 px-3 py-2 text-sm text-neutral-900 placeholder-neutral-400 focus:border-indigo-500 focus:ring-indigo-500 dark:border-neutral-700 dark:bg-neutral-800 dark:text-neutral-100 dark:placeholder-neutral-500"})]}),b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"System Prompt"}),b.jsx("textarea",{name:"prompt",value:o.prompt,onChange:d,placeholder:"Define the agent's behavior and personality",rows:4,className:"w-full rounded-md border-neutral-300 bg-neutral-100 px-3 py-2 text-sm text-neutral-900 placeholder-neutral-400 focus:border-indigo-500 focus:ring-indigo-500 dark:border-neutral-700 dark:bg-neutral-800 dark:text-neutral-100 dark:placeholder-neutral-500"})]}),b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Connected MCP Servers"}),b.jsx("div",{className:"mt-2 max-h-40 space-y-1 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50 p-2 dark:border-neutral-700 dark:bg-neutral-800/50",children:a.length>0?a.map(m=>b.jsx(yx,{mcp:m,isSelected:u.includes(m.id),onSelectionChange:()=>p(m.id)},m.id)):b.jsxs("div",{className:"flex flex-col items-center justify-center p-4 text-center",children:[b.jsx("p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:"No MCP servers available."}),b.jsxs(xn,{type:"button",onClick:()=>{t(),s()},className:"mt-2 inline-flex items-center gap-2 rounded-md bg-indigo-100 py-1.5 px-3 text-sm/6 font-semibold text-indigo-600 focus:outline-none data-[hover]:bg-indigo-200 dark:bg-indigo-900/50 dark:text-indigo-300 dark:data-[hover]:bg-indigo-900",children:[b.jsx(ii,{className:"h-4 w-4"}),"Create MCP Server"]})]})})]}),b.jsxs("div",{className:"mt-6 flex justify-end gap-4",children:[b.jsx(xn,{type:"button",onClick:t,className:"inline-flex items-center gap-2 rounded-md bg-neutral-100 py-1.5 px-3 text-sm/6 font-semibold text-neutral-700 shadow-sm focus:outline-none data-[hover]:bg-neutral-200 dark:bg-neutral-800 dark:text-neutral-200 dark:data-[hover]:bg-neutral-700",children:"Cancel"}),b.jsx(xn,{type:"submit",className:"inline-flex items-center gap-2 rounded-md bg-indigo-600 py-1.5 px-3 text-sm/6 font-semibold text-white shadow-inner shadow-white/10 focus:outline-none data-[hover]:bg-indigo-500 data-[open]:bg-indigo-700 data-[focus]:outline-1 data-[focus]:outline-white dark:bg-indigo-500 dark:data-[hover]:bg-indigo-400",children:"Save Changes"})]})]})]}):null},yU={hidden:{y:20,opacity:0},visible:{y:0,opacity:1,transition:{type:"spring",stiffness:100,damping:12}}},vU=({agent:e,onClick:t,onEdit:n})=>b.jsxs(ke.div,{layout:!0,variants:yU,whileHover:{scale:1.03,transition:{duration:.2}},whileTap:{scale:.98},onClick:()=>t?.(e),className:`
55
55
  group relative flex cursor-pointer items-start gap-4 rounded-lg border p-3
56
56
  border-neutral-200 bg-white hover:bg-neutral-50 dark:border-neutral-800 dark:bg-neutral-900 dark:hover:bg-neutral-800/60
57
57
  `,children:[b.jsx("img",{src:e.id==="default-chat"?"https://avatars.githubusercontent.com/u/176685?v=4":"https://cdn1.deepmd.net/static/img/affb038eChatGPT Image 2025年8月6日 10_33_07.png",alt:e.name,className:"h-10 w-10 rounded-full object-cover border border-neutral-200 dark:border-neutral-700"}),b.jsxs("div",{className:"flex flex-1 flex-col",children:[b.jsxs("div",{className:"flex items-center",children:[b.jsx("h3",{className:"text-sm font-semibold text-neutral-800 dark:text-white",children:e.name}),e.mcp_servers&&e.mcp_servers.length>0&&b.jsxs(Ex,{variant:"blue",className:"ml-2 flex items-center gap-1",children:[b.jsx(nu,{className:"h-3 w-3"}),e.mcp_servers.length]})]}),b.jsx("p",{className:"mt-1 text-xs text-neutral-600 dark:text-neutral-400 line-clamp-2",children:e.description})]}),e.id!=="default-chat"&&b.jsx("button",{onClick:r=>{r.stopPropagation(),n?.(e)},className:"z-10 ml-3 flex items-center justify-center rounded-lg bg-transparent px-3 text-neutral-400 opacity-0 transition-all duration-300 ease-in-out hover:bg-neutral-100 hover:text-indigo-600 hover:shadow-md hover:scale-105 group-hover:opacity-100 group-hover:shadow-sm active:scale-95 dark:text-neutral-500 dark:hover:bg-neutral-800 dark:hover:text-indigo-400",style:{alignSelf:"stretch",margin:"4px 0"},title:"编辑助手",children:b.jsx(fM,{className:"h-5 w-5 transition-transform duration-200"})})]}),TU={hidden:{opacity:0},visible:{opacity:1,transition:{staggerChildren:.08,delayChildren:.1}}};function SU(){const[e,t]=v.useState(!1),[n,r]=v.useState(!1),[a,i]=v.useState(null),{agents:s,fetchAgents:o,createDefaultChannel:l}=Kt(),u={id:"default-chat",name:"随便聊聊",description:"与AI助手自由对话,无需特定的设定或工具",prompt:"",mcp_servers:[],user_id:"system"};v.useEffect(()=>{o()},[o]);const c=f=>{f.id==="default-chat"?l():l(f.id)},d=f=>{f.id!=="default-chat"&&(i(f),r(!0))},p=[u,...s];return b.jsxs(ke.div,{className:"space-y-2 px-4",variants:TU,initial:"hidden",animate:"visible",children:[p.map(f=>b.jsx(vU,{agent:f,onClick:c,onEdit:d},f.id)),b.jsx("button",{className:"w-full rounded-lg border-2 border-dashed border-neutral-300 bg-transparent py-3 text-sm font-semibold text-neutral-600 transition-colors hover:border-neutral-400 hover:bg-neutral-50 dark:border-neutral-700 dark:text-neutral-400 dark:hover:border-neutral-600 dark:hover:bg-neutral-800/50",onClick:()=>t(!0),children:"+ 添加助手"}),b.jsx(bU,{isOpen:e,onClose:()=>t(!1)}),b.jsx(EU,{isOpen:n,onClose:()=>r(!1),agent:a})]})}function xU({title:e,titleId:t,...n},r){return Y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?Y.createElement("title",{id:t},e):null,Y.createElement("path",{fillRule:"evenodd",d:"m9.69 18.933.003.001C9.89 19.02 10 19 10 19s.11.02.308-.066l.002-.001.006-.003.018-.008a5.741 5.741 0 0 0 .281-.14c.186-.096.446-.24.757-.433.62-.384 1.445-.966 2.274-1.765C15.302 14.988 17 12.493 17 9A7 7 0 1 0 3 9c0 3.492 1.698 5.988 3.355 7.584a13.731 13.731 0 0 0 2.273 1.765 11.842 11.842 0 0 0 .976.544l.062.029.018.008.006.003ZM10 11.25a2.25 2.25 0 1 0 0-4.5 2.25 2.25 0 0 0 0 4.5Z",clipRule:"evenodd"}))}const vx=Y.forwardRef(xU);function wU({title:e,titleId:t,...n},r){return Y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?Y.createElement("title",{id:t},e):null,Y.createElement("path",{d:"m2.695 14.762-1.262 3.155a.5.5 0 0 0 .65.65l3.155-1.262a4 4 0 0 0 1.343-.886L17.5 5.501a2.121 2.121 0 0 0-3-3L3.58 13.419a4 4 0 0 0-.885 1.343Z"}))}const AU=Y.forwardRef(wU);function ep({title:e,onSave:t,className:n="",textClassName:r="",maxLength:a=100}){const[i,s]=v.useState(!1),[o,l]=v.useState(e),[u,c]=v.useState(!1),[d,p]=v.useState(!1),f=v.useRef(null);v.useEffect(()=>{l(e)},[e]),v.useEffect(()=>{i&&f.current&&(f.current.focus(),f.current.select())},[i]);const m=w=>{w.stopPropagation(),s(!0)},g=async()=>{if(d)return;const w=o.trim();if(!w||w===e){l(e),s(!1);return}p(!0);try{await t(w),s(!1)}catch(k){console.error("Failed to save title:",k),l(e)}finally{p(!1)}},x=()=>{l(e),s(!1)},T=w=>{w.key==="Enter"?(w.preventDefault(),g()):w.key==="Escape"&&(w.preventDefault(),x())},y=()=>{setTimeout(()=>{i&&g()},100)};return i?b.jsx("div",{className:n,onClick:w=>w.stopPropagation(),children:b.jsx("input",{ref:f,type:"text",value:o,onChange:w=>l(w.target.value),onKeyDown:T,onBlur:y,onClick:w=>w.stopPropagation(),maxLength:a,disabled:d,className:`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sciol/xyzen",
3
3
  "packageManager": "yarn@4.9.2",
4
- "version": "0.2.3",
4
+ "version": "0.2.4",
5
5
  "description": "A modern, lightweight, and extensible chat component for React.",
6
6
  "author": "Haohui <harveyque@outlook.com>",
7
7
  "license": "GPL-3.0-only",