kiki-agent-lite 0.3.1 → 0.3.2
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 +13 -10
- package/dist/docs/en/configuration/config-files.md +63 -20
- package/dist/docs/en/configuration/data-locations.md +12 -4
- package/dist/docs/en/configuration/env-vars.md +4 -6
- package/dist/docs/en/configuration/overrides.md +13 -14
- package/dist/docs/en/configuration/providers.md +8 -6
- package/dist/docs/en/customization/agent-profiles.md +33 -38
- package/dist/docs/en/customization/agents.md +129 -107
- package/dist/docs/en/customization/hooks.md +41 -48
- package/dist/docs/en/customization/personas.md +19 -21
- package/dist/docs/en/customization/plugins.md +180 -156
- package/dist/docs/en/customization/prompt-fields.md +10 -6
- package/dist/docs/en/customization/skills.md +11 -13
- package/dist/docs/en/customization/skins.md +23 -27
- package/dist/docs/en/customization/themes.md +15 -15
- package/dist/docs/en/features/agents.md +85 -0
- package/dist/docs/en/features/daily.md +37 -7
- package/dist/docs/en/features/ecosystem.md +3 -1
- package/dist/docs/en/features/extend.md +7 -1
- package/dist/docs/en/features/freedom.md +4 -0
- package/dist/docs/en/features/index.md +6 -5
- package/dist/docs/en/features/long-work.md +23 -5
- package/dist/docs/en/features/look.md +1 -1
- package/dist/docs/en/features/people.md +10 -2
- package/dist/docs/en/features/spaces.md +16 -4
- package/dist/docs/en/features/workbench.md +11 -3
- package/dist/docs/en/getting-started/desktop-app.md +44 -29
- package/dist/docs/en/getting-started/first-launch.md +32 -21
- package/dist/docs/en/getting-started/installation.md +27 -12
- package/dist/docs/en/getting-started/use-cases.md +35 -35
- package/dist/docs/en/guides/goals.md +9 -7
- package/dist/docs/en/guides/interaction.md +26 -26
- package/dist/docs/en/guides/interface.md +18 -14
- package/dist/docs/en/guides/memory.md +43 -14
- package/dist/docs/en/guides/sessions.md +32 -26
- package/dist/docs/en/guides/settings.md +60 -29
- package/dist/docs/en/index.md +8 -2
- package/dist/docs/en/reference/command.md +8 -4
- package/dist/docs/en/reference/keyboard.md +18 -4
- package/dist/docs/en/reference/model-vocabulary.md +6 -8
- package/dist/docs/en/reference/slash-commands.md +4 -4
- package/dist/docs/en/reference/tools.md +92 -15
- package/dist/docs/en/release-notes/changelog.md +1 -9
- package/dist/docs/en/server/acp.md +1 -1
- package/dist/docs/en/server/ide.md +1 -1
- package/dist/docs/en/server/local-server.md +5 -5
- package/dist/docs/en/server/mcp.md +2 -2
- package/dist/docs/en/server/rest-api.md +79 -5
- package/dist/docs/en/server/sdk.md +2 -2
- package/dist/docs/zh/configuration/config-files.md +56 -15
- package/dist/docs/zh/configuration/data-locations.md +12 -4
- package/dist/docs/zh/configuration/env-vars.md +4 -6
- package/dist/docs/zh/configuration/overrides.md +13 -14
- package/dist/docs/zh/configuration/providers.md +7 -5
- package/dist/docs/zh/customization/agent-profiles.md +31 -36
- package/dist/docs/zh/customization/agents.md +120 -98
- package/dist/docs/zh/customization/hooks.md +35 -42
- package/dist/docs/zh/customization/personas.md +16 -18
- package/dist/docs/zh/customization/plugins.md +167 -142
- package/dist/docs/zh/customization/prompt-fields.md +9 -5
- package/dist/docs/zh/customization/skills.md +10 -12
- package/dist/docs/zh/customization/skins.md +19 -23
- package/dist/docs/zh/customization/themes.md +12 -12
- package/dist/docs/zh/features/agents.md +85 -0
- package/dist/docs/zh/features/daily.md +37 -7
- package/dist/docs/zh/features/ecosystem.md +3 -1
- package/dist/docs/zh/features/extend.md +7 -1
- package/dist/docs/zh/features/freedom.md +4 -0
- package/dist/docs/zh/features/index.md +6 -5
- package/dist/docs/zh/features/long-work.md +22 -4
- package/dist/docs/zh/features/look.md +1 -1
- package/dist/docs/zh/features/people.md +10 -2
- package/dist/docs/zh/features/spaces.md +15 -3
- package/dist/docs/zh/features/workbench.md +11 -3
- package/dist/docs/zh/getting-started/desktop-app.md +43 -28
- package/dist/docs/zh/getting-started/first-launch.md +32 -21
- package/dist/docs/zh/getting-started/installation.md +26 -11
- package/dist/docs/zh/getting-started/use-cases.md +35 -37
- package/dist/docs/zh/guides/goals.md +8 -8
- package/dist/docs/zh/guides/interaction.md +25 -25
- package/dist/docs/zh/guides/interface.md +18 -14
- package/dist/docs/zh/guides/memory.md +43 -14
- package/dist/docs/zh/guides/sessions.md +30 -24
- package/dist/docs/zh/guides/settings.md +54 -23
- package/dist/docs/zh/index.md +7 -1
- package/dist/docs/zh/reference/command.md +7 -3
- package/dist/docs/zh/reference/keyboard.md +18 -4
- package/dist/docs/zh/reference/model-vocabulary.md +6 -8
- package/dist/docs/zh/reference/slash-commands.md +3 -3
- package/dist/docs/zh/reference/tools.md +74 -9
- package/dist/docs/zh/release-notes/changelog.md +1 -9
- package/dist/docs/zh/server/acp.md +1 -1
- package/dist/docs/zh/server/ide.md +1 -1
- package/dist/docs/zh/server/local-server.md +5 -5
- package/dist/docs/zh/server/mcp.md +2 -2
- package/dist/docs/zh/server/rest-api.md +69 -1
- package/dist/docs/zh/server/sdk.md +2 -2
- package/dist/main.mjs +12545 -3456
- package/dist/web/assets/AppErrorBoundary-RFIAb-Uf.js +1 -0
- package/dist/web/assets/NavScopeBoundary-DY_ET7A-.js +1 -0
- package/dist/web/assets/{arc-y2SkSoyr.js → arc-CMgTB1m7.js} +1 -1
- package/dist/web/assets/{architectureDiagram-3BPJPVTR-uCwLz53m.js → architectureDiagram-3BPJPVTR-BU79ou2C.js} +1 -1
- package/dist/web/assets/{blockDiagram-GPEHLZMM-BZyWv36G.js → blockDiagram-GPEHLZMM-Bkuldod2.js} +1 -1
- package/dist/web/assets/{c4Diagram-AAUBKEIU-DKGx9i50.js → c4Diagram-AAUBKEIU-C3WMeqyu.js} +1 -1
- package/dist/web/assets/channel-DpDZUJRn.js +1 -0
- package/dist/web/assets/{chunk-2J33WTMH-CSkrhrsp.js → chunk-2J33WTMH-CesyWmwo.js} +1 -1
- package/dist/web/assets/{chunk-4BX2VUAB-CtxMoJ68.js → chunk-4BX2VUAB-C7rghYTf.js} +1 -1
- package/dist/web/assets/{chunk-55IACEB6-Dos3ftEy.js → chunk-55IACEB6-BqRHhwtz.js} +1 -1
- package/dist/web/assets/{chunk-727SXJPM-wbzEYK9z.js → chunk-727SXJPM-BhSqCRBc.js} +1 -1
- package/dist/web/assets/{chunk-AQP2D5EJ-B9GKvCD6.js → chunk-AQP2D5EJ-DdYE2ZVZ.js} +1 -1
- package/dist/web/assets/{chunk-FMBD7UC4-u5Y2P6IX.js → chunk-FMBD7UC4-BCRPUxDF.js} +1 -1
- package/dist/web/assets/{chunk-ND2GUHAM-B8rFKkTV.js → chunk-ND2GUHAM-CuvyDjTR.js} +1 -1
- package/dist/web/assets/{chunk-QZHKN3VN-EQsKtuD-.js → chunk-QZHKN3VN-BU5vAS78.js} +1 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-Bju1GfNu.js +1 -0
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-Bju1GfNu.js +1 -0
- package/dist/web/assets/client-C0oH7-8r.js +2 -0
- package/dist/web/assets/connection-BhO2nh7P.js +1 -0
- package/dist/web/assets/{cose-bilkent-S5V4N54A-D6dr5mIW.js → cose-bilkent-S5V4N54A-CXrvsA1a.js} +1 -1
- package/dist/web/assets/{dagre-BM42HDAG-Dnyhc4Hn.js → dagre-BM42HDAG-TaAea3Rt.js} +1 -1
- package/dist/web/assets/{diagram-2AECGRRQ-CYXkWdne.js → diagram-2AECGRRQ-CdEH4jGt.js} +1 -1
- package/dist/web/assets/{diagram-5GNKFQAL-DPwBf5Ag.js → diagram-5GNKFQAL-A0jZ_p-T.js} +1 -1
- package/dist/web/assets/{diagram-KO2AKTUF-DNeLYZ8X.js → diagram-KO2AKTUF-miHWORz3.js} +1 -1
- package/dist/web/assets/{diagram-LMA3HP47-zU8RsQTX.js → diagram-LMA3HP47-BlUIwEIg.js} +1 -1
- package/dist/web/assets/{diagram-OG6HWLK6-Cf9Mm94H.js → diagram-OG6HWLK6-DwDzMhEg.js} +1 -1
- package/dist/web/assets/{erDiagram-TEJ5UH35-Ch4CeiUI.js → erDiagram-TEJ5UH35-BJr5w62i.js} +1 -1
- package/dist/web/assets/export-BlxaZKEe.js +2 -0
- package/dist/web/assets/{flowDiagram-I6XJVG4X-Csn6WqEH.js → flowDiagram-I6XJVG4X-BP7KSFjx.js} +1 -1
- package/dist/web/assets/{ganttDiagram-6RSMTGT7-DsuBgEyu.js → ganttDiagram-6RSMTGT7-BstLBBof.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-PVQCEYII-CPA7jCxU.js → gitGraphDiagram-PVQCEYII-C57s7nZ-.js} +1 -1
- package/dist/web/assets/highlighted-body-OFNGDK62-BVb-7KsA.js +1 -0
- package/dist/web/assets/index-69qhvTvD.js +1 -0
- package/dist/web/assets/{index-BYUHmd8w.js → index-BDNM6yJI.js} +2 -2
- package/dist/web/assets/{index-BGgZxlEQ.js → index-BJF_gEDs.js} +2 -2
- package/dist/web/assets/index-BOwMP6BP.js +1 -0
- package/dist/web/assets/{index-C69a5Mcz.js → index-BZsyXCqm.js} +1 -1
- package/dist/web/assets/{index-C7EA7a_g.js → index-Bfl4JiNq.js} +2 -2
- package/dist/web/assets/index-BlD3AKX-.js +1 -0
- package/dist/web/assets/{index-CIymCfcP.js → index-BnvW0EvQ.js} +1 -1
- package/dist/web/assets/index-C4rmWyOm.js +1 -0
- package/dist/web/assets/index-CGLcb3HY.js +1 -0
- package/dist/web/assets/{index-kWBxPqIX.js → index-CPvOeQPX.js} +1 -1
- package/dist/web/assets/index-Cjbe0JKM.js +1 -0
- package/dist/web/assets/index-CmYoJWUm.js +1 -0
- package/dist/web/assets/index-CtUFrjKe.js +1 -0
- package/dist/web/assets/index-DDvDRMTK.js +1 -0
- package/dist/web/assets/index-DSpndwAR.css +1 -0
- package/dist/web/assets/index-D_JjTHxi.js +1 -0
- package/dist/web/assets/index-DbuwcnbT.js +1 -0
- package/dist/web/assets/index-DcXyS0nN.js +1 -0
- package/dist/web/assets/index-Dcl9ruKA.js +1 -0
- package/dist/web/assets/index-DgwALPNA.js +121 -0
- package/dist/web/assets/{index-DoN1FTEe.js → index-DkE8hRT1.js} +2 -2
- package/dist/web/assets/index-DsyRBZ4h.js +1 -0
- package/dist/web/assets/{index-29zav3JI.js → index-DuudNhLL.js} +4 -4
- package/dist/web/assets/index-Gc4F0b2f.js +1 -0
- package/dist/web/assets/index-HGqqwKoV.js +13 -0
- package/dist/web/assets/index-KchrJnno.js +3 -0
- package/dist/web/assets/{index-B0KNSyji.js → index-Tmi2BPYU.js} +1 -1
- package/dist/web/assets/index-Ya4GuDs0.js +1 -0
- package/dist/web/assets/index-_aDaKqLB.js +1 -0
- package/dist/web/assets/index-_qwOAotB.js +1 -0
- package/dist/web/assets/index-hnIkczza.js +7 -0
- package/dist/web/assets/{infoDiagram-5YYISTIA-D3Q__m62.js → infoDiagram-5YYISTIA-CifuVY6C.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-CcvCBuZ5.js → ishikawaDiagram-YF4QCWOH-Cd60vQUi.js} +1 -1
- package/dist/web/assets/{journeyDiagram-JHISSGLW-COZU4LNt.js → journeyDiagram-JHISSGLW-Cb3Xl_wl.js} +1 -1
- package/dist/web/assets/{kanban-definition-UN3LZRKU-BrXjBoAU.js → kanban-definition-UN3LZRKU-Ei6ThuZt.js} +1 -1
- package/dist/web/assets/{linear-BgP1STFi.js → linear-CDZJx-o2.js} +1 -1
- package/dist/web/assets/mermaid-GHXKKRXX-DFxyxD7G.js +331 -0
- package/dist/web/assets/{mindmap-definition-RKZ34NQL-CgjSrE5r.js → mindmap-definition-RKZ34NQL-B0ygxzkx.js} +1 -1
- package/dist/web/assets/navViewState-Ck_HK-TK.js +1 -0
- package/dist/web/assets/{pieDiagram-4H26LBE5-DTfe1sKA.js → pieDiagram-4H26LBE5-B2FdrvDv.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-W4KKPZXB-D95hfh0q.js → quadrantDiagram-W4KKPZXB-CwpOTy3d.js} +1 -1
- package/dist/web/assets/{requirementDiagram-4Y6WPE33-DtSLi7Mh.js → requirementDiagram-4Y6WPE33-ExdZNzLQ.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-5OEKKPKP-gi_dJpcU.js → sankeyDiagram-5OEKKPKP-u0EZKD7D.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-3UESZ5HK-DKQ9a72t.js → sequenceDiagram-3UESZ5HK-BXHMy5DY.js} +1 -1
- package/dist/web/assets/{spaces-B2Ccyh_T.js → spaces-C8n7xQPx.js} +1 -1
- package/dist/web/assets/{stateDiagram-AJRCARHV-Bz7tmSqa.js → stateDiagram-AJRCARHV-DMXx7ell.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-Bydq1_By.js +1 -0
- package/dist/web/assets/theme-BBnHttAf.js +1 -0
- package/dist/web/assets/{timeline-definition-PNZ67QCA-BfMXPwhV.js → timeline-definition-PNZ67QCA-DtqVG_4u.js} +1 -1
- package/dist/web/assets/{vennDiagram-CIIHVFJN-WLxW2KT5.js → vennDiagram-CIIHVFJN-Dom0ex8r.js} +1 -1
- package/dist/web/assets/{wardley-L42UT6IY-DiiqwIdq.js → wardley-L42UT6IY-C-RstmuQ.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-YWT4CUSO-DmCukWuw.js → wardleyDiagram-YWT4CUSO-C8CzNfdf.js} +1 -1
- package/dist/web/assets/{xychartDiagram-2RQKCTM6-Cfq1W2tT.js → xychartDiagram-2RQKCTM6-1AxVTyB6.js} +1 -1
- package/dist/web/index.html +2 -2
- package/native/auth-native/prebuilds/linux-arm64/auth-native.node +0 -0
- package/native/auth-native/prebuilds/linux-x64/auth-native.node +0 -0
- package/native/auth-native/prebuilds/win32-arm64/auth-native.node +0 -0
- package/native/auth-native/prebuilds/win32-x64/auth-native.node +0 -0
- package/package.json +1 -1
- package/dist/web/assets/AppErrorBoundary-DWpgwxFV.js +0 -1
- package/dist/web/assets/NavScopeBoundary-D8Lf1G0U.js +0 -1
- package/dist/web/assets/channel-BGdXootG.js +0 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-CPcnLy_H.js +0 -1
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-CPcnLy_H.js +0 -1
- package/dist/web/assets/client-DSIbyfoz.js +0 -2
- package/dist/web/assets/connection-DYZn9oPZ.js +0 -1
- package/dist/web/assets/export-Bq8ZECqX.js +0 -2
- package/dist/web/assets/highlighted-body-OFNGDK62-CDPBxM_E.js +0 -1
- package/dist/web/assets/index-AksnytJj.js +0 -1
- package/dist/web/assets/index-B8xhhYDh.css +0 -1
- package/dist/web/assets/index-BUrlrKap.js +0 -1
- package/dist/web/assets/index-B_5-HLed.js +0 -62
- package/dist/web/assets/index-BfmoxdpP.js +0 -1
- package/dist/web/assets/index-Bo3e-ohM.js +0 -3
- package/dist/web/assets/index-BrYV9gV_.js +0 -1
- package/dist/web/assets/index-C8XUtAvK.js +0 -1
- package/dist/web/assets/index-C9uil5my.js +0 -13
- package/dist/web/assets/index-CKpWHSp9.js +0 -1
- package/dist/web/assets/index-CLKBgQxV.js +0 -1
- package/dist/web/assets/index-CTyyUNWj.js +0 -7
- package/dist/web/assets/index-D7cg9qYZ.js +0 -1
- package/dist/web/assets/index-D7dg8R_q.js +0 -1
- package/dist/web/assets/index-DCSpedV_.js +0 -1
- package/dist/web/assets/index-DLbD0Nx5.js +0 -1
- package/dist/web/assets/index-DaEzbvvu.js +0 -1
- package/dist/web/assets/index-DhbcjMZF.js +0 -1
- package/dist/web/assets/index-Dw2h88mF.js +0 -1
- package/dist/web/assets/index-FcMtfmKv.js +0 -1
- package/dist/web/assets/index-XFq9Kgg0.js +0 -1
- package/dist/web/assets/index-iI2mM43w.js +0 -1
- package/dist/web/assets/index-oXOF7lko.js +0 -1
- package/dist/web/assets/locale-CANfezJ4.js +0 -17
- package/dist/web/assets/mermaid-GHXKKRXX-_JLagMll.js +0 -321
- package/dist/web/assets/navViewState-DS5LnMYc.js +0 -1
- package/dist/web/assets/settings-CcwMWXbp.js +0 -42
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-D6-wdUbw.js +0 -1
- package/dist/web/assets/theme-DlDhDxeD.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{E as Tt,F as Ft,G as Ot,H as Dt,I as Qt,J as qt,K as W,L as gt,M as st,N as B,O as vt,Q as $t,P as rt,T as Wt,U as ot,V as it,W as Kt,X as at,Y as ct,Z as Ut,j as n,r as a,c as We,S as w,_ as Oe,$ as Vt,a0 as zt,a1 as Bt,a2 as Gt,a as lt,b as Te,a3 as Zt,a4 as Yt,a5 as Xt}from"./index-B_5-HLed.js";import{u as ne}from"./index-BfmoxdpP.js";import{t as Jt}from"./locale-CANfezJ4.js";import{C as en,s as tn,f as nn,g as sn}from"./settings-CcwMWXbp.js";import{c as De,K as we,A as Ie,R as Qe,a as ye,w as rn}from"./client-DSIbyfoz.js";function ut(t){return{onFetch:(e,s)=>{const r=e.options,l=e.fetchOptions?.meta?.fetchMore?.direction,c=e.state.data?.pages||[],o=e.state.data?.pageParams||[];let v={pages:[],pageParams:[]},I=0;const _=async()=>{let N=!1;const E=b=>{Dt(b,()=>e.signal,()=>N=!0)},Q=Tt(e.options,e.fetchOptions),H=async(b,u,p)=>{if(N)return Promise.reject();if(u==null&&b.pages.length)return Promise.resolve(b);const C=(()=>{const j={client:e.client,queryKey:e.queryKey,pageParam:u,direction:p?"backward":"forward",meta:e.options.meta};return E(j),j})(),S=await Q(C),{maxPages:M}=e.options,f=p?Ft:Ot;return{pages:f(b.pages,S,M),pageParams:f(b.pageParams,u,M)}};if(l&&c.length){const b=l==="backward",u=b?bt:qe,p={pages:c,pageParams:o},k=u(r,p);v=await H(p,k,b)}else{const b=t??c.length;do{const u=I===0?o[0]??r.initialPageParam:qe(r,v);if(I>0&&u==null)break;v=await H(v,u),I++}while(I<b)}return v};e.options.persister?e.fetchFn=()=>e.options.persister?.(_,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},s):e.fetchFn=_}}}function qe(t,{pages:e,pageParams:s}){const r=e.length-1;return e.length>0?t.getNextPageParam(e[r],e,s[r],s):void 0}function bt(t,{pages:e,pageParams:s}){return e.length>0?t.getPreviousPageParam?.(e[0],e,s[0],s):void 0}function Kn(t,e){return e?qe(t,e)!=null:!1}function Un(t,e){return!e||!t.getPreviousPageParam?!1:bt(t,e)!=null}var on=class extends Qt{#e;#t;#n;#r;constructor(t){super(),this.#e=t.client,this.mutationId=t.mutationId,this.#n=t.mutationCache,this.#t=[],this.state=t.state||an(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#t.includes(t)||(this.#t.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#t=this.#t.filter(e=>e!==t),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(t){const e=()=>{this.#s({type:"continue"})},s={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=qt({fn:()=>this.options.mutationFn?this.options.mutationFn(t,s):Promise.reject(new Error("No mutationFn found")),onFail:(c,o)=>{this.#s({type:"failed",failureCount:c,error:o})},onPause:()=>{this.#s({type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});const r=this.state.status==="pending",l=!this.#r.canStart();try{if(r)e();else{this.#s({type:"pending",variables:t,isPaused:l}),this.#n.config.onMutate&&await this.#n.config.onMutate(t,this,s);const o=await this.options.onMutate?.(t,s);o!==this.state.context&&this.#s({type:"pending",context:o,variables:t,isPaused:l})}const c=await this.#r.start();return await this.#n.config.onSuccess?.(c,t,this.state.context,this,s),await this.options.onSuccess?.(c,t,this.state.context,s),await this.#n.config.onSettled?.(c,null,this.state.variables,this.state.context,this,s),await this.options.onSettled?.(c,null,t,this.state.context,s),this.#s({type:"success",data:c}),c}catch(c){try{await this.#n.config.onError?.(c,t,this.state.context,this,s)}catch(o){Promise.reject(o)}try{await this.options.onError?.(c,t,this.state.context,s)}catch(o){Promise.reject(o)}try{await this.#n.config.onSettled?.(void 0,c,this.state.variables,this.state.context,this,s)}catch(o){Promise.reject(o)}try{await this.options.onSettled?.(void 0,c,t,this.state.context,s)}catch(o){Promise.reject(o)}throw this.#s({type:"error",error:c}),c}finally{this.#n.runNext(this)}}#s(t){const e=s=>{switch(t.type){case"failed":return{...s,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};case"pending":return{...s,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...s,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:t.error,failureCount:s.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=e(this.state),W.batch(()=>{this.#t.forEach(s=>{s.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function an(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var cn=class extends gt{constructor(t={}){super(),this.config=t,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(t,e,s){const r=new on({client:t,mutationCache:this,mutationId:++this.#n,options:t.defaultMutationOptions(e),state:s});return this.add(r),r}add(t){this.#e.add(t);const e=be(t);if(typeof e=="string"){const s=this.#t.get(e);s?s.push(t):this.#t.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#e.delete(t)){const e=be(t);if(typeof e=="string"){const s=this.#t.get(e);if(s)if(s.length>1){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}else s[0]===t&&this.#t.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){const e=be(t);if(typeof e=="string"){const r=this.#t.get(e)?.find(l=>l.state.status==="pending");return!r||r===t}else return!0}runNext(t){const e=be(t);return typeof e=="string"?this.#t.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){W.batch(()=>{this.#e.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(t){const e={exact:!0,...t};return this.getAll().find(s=>st(e,s))}findAll(t={}){return this.getAll().filter(e=>st(t,e))}notify(t){W.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return W.batch(()=>Promise.all(t.map(e=>e.continue().catch(B))))}};function be(t){return t.options.scope?.id}var ln=class extends gt{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,s){const r=e.queryKey,l=e.queryHash??vt(r,e);let c=this.get(l);return c||(c=new $t({client:t,queryKey:r,queryHash:l,options:t.defaultQueryOptions(e),state:s,defaultOptions:t.getQueryDefaults(r)}),this.add(c)),c}add(t){this.#e.has(t.queryHash)||(this.#e.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#e.get(t.queryHash);e&&(t.destroy(),e===t&&this.#e.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){W.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#e.get(t)}getAll(){return[...this.#e.values()]}find(t){const e={exact:!0,...t};return this.getAll().find(s=>rt(e,s))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(s=>rt(t,s)):e}notify(t){W.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){W.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){W.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},un=class{#e;#t;#n;#r;#s;#o;#i;#a;constructor(t={}){this.#e=t.queryCache||new ln,this.#t=t.mutationCache||new cn,this.#n=t.defaultOptions||{},this.#r=new Map,this.#s=new Map,this.#o=0}mount(){this.#o++,this.#o===1&&(this.#i=Wt.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=ot.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#o--,this.#o===0&&(this.#i?.(),this.#i=void 0,this.#a?.(),this.#a=void 0)}isFetching(t){return this.#e.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#t.findAll({...t,status:"pending"}).length}getQueryData(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),s=this.#e.build(this,e),r=s.state.data;return r===void 0?this.fetchQuery(t):(t.revalidateIfStale&&s.isStaleByTime(it(e.staleTime,s))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return this.#e.findAll(t).map(({queryKey:e,state:s})=>{const r=s.data;return[e,r]})}setQueryData(t,e,s){const r=this.defaultQueryOptions({queryKey:t}),c=this.#e.get(r.queryHash)?.state.data,o=Kt(e,c);if(o!==void 0)return this.#e.build(this,r).setData(o,{...s,manual:!0})}setQueriesData(t,e,s){return W.batch(()=>this.#e.findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,s)]))}getQueryState(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state}removeQueries(t){const e=this.#e;W.batch(()=>{e.findAll(t).forEach(s=>{e.remove(s)})})}resetQueries(t,e){const s=this.#e;return W.batch(()=>(s.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const s={revert:!0,...e},r=W.batch(()=>this.#e.findAll(t).map(l=>l.cancel(s)));return Promise.all(r).then(B).catch(B)}invalidateQueries(t,e={}){return W.batch(()=>(this.#e.findAll(t).forEach(s=>{s.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){const s={...e,cancelRefetch:e.cancelRefetch??!0},r=W.batch(()=>this.#e.findAll(t).filter(l=>!l.isDisabled()&&!l.isStatic()).map(l=>{let c=l.fetch(void 0,s);return s.throwOnError||(c=c.catch(B)),l.state.fetchStatus==="paused"?Promise.resolve():c}));return Promise.all(r).then(B)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const s=this.#e.build(this,e);return s.isStaleByTime(it(e.staleTime,s))?s.fetch(e):Promise.resolve(s.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(B).catch(B)}fetchInfiniteQuery(t){return t.behavior=ut(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(B).catch(B)}ensureInfiniteQueryData(t){return t.behavior=ut(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return ot.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(t){this.#n=t}setQueryDefaults(t,e){this.#r.set(at(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#r.values()],s={};return e.forEach(r=>{ct(t,r.queryKey)&&Object.assign(s,r.defaultOptions)}),s}setMutationDefaults(t,e){this.#s.set(at(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#s.values()],s={};return e.forEach(r=>{ct(t,r.mutationKey)&&Object.assign(s,r.defaultOptions)}),s}defaultQueryOptions(t){if(t._defaulted)return t;const e={...this.#n.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=vt(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===Ut&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#n.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};const wt={12:"h-3 w-3",14:"h-3.5 w-3.5",16:"h-4 w-4"},dn={read:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 2.5h5.2L12 5.3v8.2H4z"}),n.jsx("path",{d:"M9 2.5v3h3"})]}),search:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"7",cy:"7",r:"4.2"}),n.jsx("path",{d:"m10.2 10.2 3.3 3.3"})]}),edit:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M10.4 2.9 13.1 5.6 6 12.7l-3.2.5.5-3.2z"}),n.jsx("path",{d:"m9.2 4.1 2.7 2.7"})]}),terminal:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"2",y:"3",width:"12",height:"10",rx:"1.8"}),n.jsx("path",{d:"m5 6.5 2 1.5-2 1.5M8.5 10H11"})]}),web:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"8",cy:"8",r:"5.8"}),n.jsx("path",{d:"M2.4 8h11.2M8 2.2c1.7 1.6 2.5 3.6 2.5 5.8s-.8 4.2-2.5 5.8C6.3 12.2 5.5 10.2 5.5 8S6.3 3.8 8 2.2z"})]}),agent:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"2.5",y:"2.5",width:"7.5",height:"7.5",rx:"1.6"}),n.jsx("path",{d:"M6 13.5h5.9a1.6 1.6 0 0 0 1.6-1.6V6"})]}),skill:n.jsx("path",{d:"M8 2.3 9.4 6.6l4.3 1.4-4.3 1.4L8 13.7 6.6 9.4 2.3 8l4.3-1.4z"}),plan:n.jsx("path",{d:"M5.5 4.5h8M5.5 8h8M5.5 11.5h8M2.5 4.5h.01M2.5 8h.01M2.5 11.5h.01"}),task:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"8",cy:"8",r:"5.8"}),n.jsx("path",{d:"M6.8 5.6v4.8L10.4 8z"})]}),goal:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"8",cy:"8",r:"5.8"}),n.jsx("circle",{cx:"8",cy:"8",r:"2.4"})]}),memory:n.jsx("path",{d:"M8 2.5c.5 3 2.5 5 5.5 5.5-3 .5-5 2.5-5.5 5.5-.5-3-2.5-5-5.5-5.5 3-.5 5-2.5 5.5-5.5z"}),think:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5.2 11.3a4.3 4.3 0 1 1 5.6 0v1.2H5.2z"}),n.jsx("path",{d:"M6.3 14h3.4"})]}),system:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"2.5",y:"2.5",width:"11",height:"11",rx:"2"}),n.jsx("path",{d:"M5.5 6.5h5M5.5 9.5h3"})]}),clock:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"8",cy:"8",r:"5.8"}),n.jsx("path",{d:"M8 4.8V8l2.2 1.4"})]}),gate:n.jsx("path",{d:"M8 2.2 13 4v3.6c0 3-2.1 5.2-5 6.2-2.9-1-5-3.2-5-6.2V4z"}),ask:n.jsx("path",{d:"M3 3.5h10c.6 0 1 .4 1 1v6c0 .6-.4 1-1 1H8.2L5 13.8v-2.3H3c-.6 0-1-.4-1-1v-6c0-.6.4-1 1-1z"}),file:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 2.5h5.2L12 5.3v8.2H4z"}),n.jsx("path",{d:"M6.2 8.2h3.6M6.2 10.6h2.4"})]}),tool:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"8",cy:"8",r:"2.2"}),n.jsx("path",{d:"M8 2.3v1.9M8 11.8v1.9M2.3 8h1.9M11.8 8h1.9M4 4l1.3 1.3M10.7 10.7 12 12M4 12l1.3-1.3M10.7 5.3 12 4"})]}),check:n.jsx("path",{d:"m3.5 8.4 2.9 2.9 6.1-6.6"}),cross:n.jsx("path",{d:"m4.3 4.3 7.4 7.4m0-7.4-7.4 7.4"}),dash:n.jsx("path",{d:"M4 8h8"}),warning:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M8 2.6 13.8 13H2.2z"}),n.jsx("path",{d:"M8 6.6v2.8M8 11.3h.01"})]}),info:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"8",cy:"8",r:"5.9"}),n.jsx("path",{d:"M6.5 6.4a1.6 1.6 0 1 1 2.2 1.5c-.5.2-.7.5-.7 1v.4M8 11.4h.01"})]}),hold:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"8",cy:"8",r:"5.8"}),n.jsx("path",{d:"M6.6 5.8v4.4M9.4 5.8v4.4"})]}),chevron:n.jsx("path",{d:"m6 3.8 4.2 4.2L6 12.2"}),close:n.jsx("path",{d:"m4.5 4.5 7 7m0-7-7 7"}),menu:n.jsx("path",{d:"M2.8 4.5h10.4M2.8 8h10.4M2.8 11.5h10.4"}),more:n.jsx("path",{d:"M3.5 8h.01M8 8h.01M12.5 8h.01",strokeWidth:2.2}),plus:n.jsx("path",{d:"M8 3v10M3 8h10"}),arrowRight:n.jsx("path",{d:"M3 8h10m-3.8-3.8L13 8l-3.8 3.8"}),arrowDown:n.jsx("path",{d:"M8 3v10m-3.8-3.8L8 13l3.8-3.8"}),external:n.jsx("path",{d:"M6.5 3H3.5a1 1 0 0 0-1 1v8.5a1 1 0 0 0 1 1H12a1 1 0 0 0 1-1V9.5M9.5 2.5h4v4M13.5 2.5 7.5 8.5"}),folder:n.jsx("path",{d:"M13.5 11.3a1.2 1.2 0 0 1-1.2 1.2H3.7a1.2 1.2 0 0 1-1.2-1.2V3.9a1.2 1.2 0 0 1 1.2-1.2h2.7l1.3 1.9h4.6a1.2 1.2 0 0 1 1.2 1.2z"}),panel:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"2",y:"3",width:"12",height:"10",rx:"1.6"}),n.jsx("path",{d:"M10 3v10"})]}),filter:n.jsx("path",{d:"M2.5 3.5h11l-4.2 5v4l-2.6 1v-5z"}),sliders:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M2.5 4.5h7M13.5 4.5h0M2.5 8h2M7.5 8h6M2.5 11.5h6M12 11.5h1.5"}),n.jsx("circle",{cx:"11",cy:"4.5",r:"1.5"}),n.jsx("circle",{cx:"6",cy:"8",r:"1.5"}),n.jsx("circle",{cx:"10.5",cy:"11.5",r:"1.5"})]}),pin:n.jsx("path",{d:"M9.6 2.2 13.8 6.4l-1.5 1.5-1-.3-2.8 2.8.4 3.1-1 1-2.4-3.4-3 2.2 4.7-5.3-.3-1 2.8-2.8-.3-1z"}),board:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"2",y:"2.5",width:"12",height:"11",rx:"1.8"}),n.jsx("path",{d:"M6 2.5v11M10 2.5v7"})]}),usage:n.jsx("path",{d:"M2.5 13.5h11M4.5 11V8M8 11V4.5M11.5 11V6.5"}),notes:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M3.4 2.5h7.3l2 2v9a1 1 0 0 1-1 1H3.4a1 1 0 0 1-1-1v-10a1 1 0 0 1 1-1z"}),n.jsx("path",{d:"M5.2 6.4h4.4M5.2 9h3"})]}),settings:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),n.jsx("path",{d:"M8 1.8v1.6M8 12.6v1.6M1.8 8h1.6M12.6 8h1.6M3.6 3.6l1.1 1.1M11.3 11.3l1.1 1.1M3.6 12.4l1.1-1.1M11.3 4.7l1.1-1.1"})]}),arrowLeft:n.jsx("path",{d:"M13 8H3m3.8-3.8L3 8l3.8 3.8"}),arrowUp:n.jsx("path",{d:"M8 13V3M4.2 6.8 8 3l3.8 3.8"}),arrowUpRight:n.jsx("path",{d:"M4.5 11.5 11.5 4.5M5.5 4.5h6v6"}),expand:n.jsx("path",{d:"M9.5 2.5h4v4M6.5 13.5h-4v-4M13.5 2.5 9.3 6.7M2.5 13.5l4.2-4.2"}),collapse:n.jsx("path",{d:"M13.5 6.5h-4v-4M2.5 9.5h4v4M9.5 6.5l4-4M6.5 9.5l-4 4"}),grip:n.jsx("path",{d:"M6 4h.01M10 4h.01M6 8h.01M10 8h.01M6 12h.01M10 12h.01",strokeWidth:2.2}),stop:n.jsx("rect",{x:"4.5",y:"4.5",width:"7",height:"7",rx:"1.2",fill:"currentColor"}),quote:n.jsx("path",{d:"M3 11.5c0-3 1-5 3.5-6M9 11.5c0-3 1-5 3.5-6M3 11.5h2.6V9H3zM9 11.5h2.6V9H9z"}),star:n.jsx("path",{d:"M8 2l1.6 3.4 3.7.5-2.7 2.6.7 3.7L8 10.4l-3.3 1.8.7-3.7L2.7 5.9l3.7-.5z"}),starFilled:n.jsx("path",{d:"M8 2l1.6 3.4 3.7.5-2.7 2.6.7 3.7L8 10.4l-3.3 1.8.7-3.7L2.7 5.9l3.7-.5z",fill:"currentColor"}),dot:n.jsx("circle",{cx:"8",cy:"8",r:"3",fill:"currentColor",stroke:"none"}),ring:n.jsx("circle",{cx:"8",cy:"8",r:"4.5"}),partial:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"8",cy:"8",r:"5.8"}),n.jsx("path",{d:"M8 8V2.2A5.8 5.8 0 0 1 13.8 8z",fill:"currentColor"})]}),bell:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4.2 7a3.8 3.8 0 0 1 7.6 0v2.4l1 1.6H3.2l1-1.6z"}),n.jsx("path",{d:"M6.6 12.4a1.5 1.5 0 0 0 2.8 0"})]}),branch:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"4.5",cy:"3.8",r:"1.3"}),n.jsx("circle",{cx:"4.5",cy:"12.2",r:"1.3"}),n.jsx("circle",{cx:"11.5",cy:"6.2",r:"1.3"}),n.jsx("path",{d:"M4.5 5.1v5.8M11.5 7.5c0 2.2-2 2.9-7 3.4"})]}),eye:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M1.8 8S4.2 3.6 8 3.6 14.2 8 14.2 8 11.8 12.4 8 12.4 1.8 8 1.8 8z"}),n.jsx("circle",{cx:"8",cy:"8",r:"2"})]}),eyeOff:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6.3 4c.5-.2 1.1-.4 1.7-.4 3.8 0 6.2 4.4 6.2 4.4a11 11 0 0 1-1.6 2.1M10 11.8a4.8 4.8 0 0 1-2 .6C4.2 12.4 1.8 8 1.8 8a11 11 0 0 1 2.3-2.8"}),n.jsx("path",{d:"M6.6 6.6a2 2 0 0 0 2.8 2.8M2.5 2.5l11 11"})]}),copy:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"5.5",y:"5.5",width:"8",height:"8",rx:"1.6"}),n.jsx("path",{d:"M10.5 5.5V4.1a1.6 1.6 0 0 0-1.6-1.6H4.1a1.6 1.6 0 0 0-1.6 1.6v4.8a1.6 1.6 0 0 0 1.6 1.6h1.4"})]}),thread:n.jsx("path",{d:"M4 2.8v5.4c0 1.4 1.1 2.5 2.5 2.5H12m-2.6-2.6 2.6 2.6-2.6 2.6"}),persona:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"2.5",y:"2.5",width:"11",height:"11",rx:"3"}),n.jsx("circle",{cx:"8",cy:"6.8",r:"1.8"}),n.jsx("path",{d:"M4.9 11.6c.6-1.4 1.7-2.1 3.1-2.1s2.5.7 3.1 2.1"})]})};function $e({name:t,size:e=14,className:s=""}){const r=/(^|\s)h-/.test(s)?"":wt[e];return n.jsx("svg",{"aria-hidden":!0,"data-icon":t,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.35,strokeLinecap:"round",strokeLinejoin:"round",className:`shrink-0 ${r} ${s}`.trim(),children:dn[t]})}function hn({open:t,size:e=12,className:s="text-ink-faint"}){return n.jsx($e,{name:"chevron",size:e,className:`transition-transform duration-[var(--kiki-motion-quick)] ease-out motion-reduce:transition-none ${t?"rotate-90":""} ${s}`})}function fn({label:t,size:e=14}){return n.jsxs("svg",{role:"img","aria-label":t,viewBox:"0 0 16 16",fill:"none",className:`spinner shrink-0 text-ink-soft ${wt[e]}`,children:[n.jsx("circle",{cx:"8",cy:"8",r:"5.8",stroke:"currentColor",strokeOpacity:"0.22",strokeWidth:1.35}),n.jsx("path",{d:"M13.8 8A5.8 5.8 0 0 0 8 2.2",stroke:"currentColor",strokeWidth:1.35,strokeLinecap:"round"})]})}function Vn({state:t,labels:e,title:s}){switch(t){case"running":return n.jsx(fn,{label:e.running});case"failed":return n.jsx("span",{role:"img","aria-label":e.failed,title:s,"data-outcome":"failed",className:"text-danger",children:n.jsx($e,{name:"cross"})});case"stopped":return n.jsx("span",{role:"img","aria-label":e.stopped,title:s,"data-outcome":"stopped",className:"text-amber-rule",children:n.jsx($e,{name:"dash"})});case"done":return n.jsx("span",{className:"sr-only",children:e.done})}}const pn=10*6e4;function zn(t,e=Date.now()){if(t.pending_interaction==="approval"||t.pending_interaction==="question")return"waiting";if(t.busy)return"working";if(t.last_turn_reason==="failed"||t.last_turn_reason==="cancelled")return"failed";if(t.last_turn_reason==="completed"&&t.updated_at!==void 0){const s=Date.parse(t.updated_at);if(Number.isFinite(s)&&e-s<pn)return"done"}return"idle"}function Bn(t,e=8){return{"--kiki-i":Math.min(t,e)}}function mn(){if(typeof document>"u")return"system";const t=document.documentElement.dataset.kikiMotion;return t==="reduce"||t==="full"?t:"system"}function Gn(){const t=mn();return t!=="system"?t==="reduce":typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}const dt=new Map;function xn(t,e){const s=a.useRef(null);if(s.current===null||s.current.life!==e){const r=dt.get(t);s.current={life:e,changed:e!==void 0&&r!==void 0&&r!==e}}return a.useEffect(()=>{e!==void 0&&dt.set(t,e)},[t,e]),s.current.changed}function ge({size:t="md",life:e,echo:s}){const r=xn("wordmark",e),l=e==="idle"?void 0:e,c=t==="xl"?"text-[44px] sm:text-[56px]":t==="lg"?"text-4xl":"text-[22px]",o=t==="xl"?"h-2.5 w-2.5 sm:h-3 sm:w-3":t==="lg"?"h-2 w-2":"h-1.5 w-1.5";return n.jsxs("span",{className:"inline-flex items-baseline select-none","aria-label":"kiki",children:[n.jsx("span",{className:`font-display ${c} leading-none font-semibold tracking-tight text-ink`,style:{fontVariationSettings:t==="xl"?'"opsz" 60':'"opsz" 40'},children:"kiki"}),n.jsx("span",{className:`kiki-wordmark-echo inline-block ${t==="xl"?"ml-1":"ml-[3px]"}`,"data-echo":s===void 0?void 0:s===0?"arrive":s%2===0?"a":"b",children:n.jsx("span",{"data-life":l,"data-life-changed":r?"":void 0,className:`kiki-wordmark-dot block ${o} translate-y-[-1px] rounded-full bg-accent`})})]})}function Zn({className:t=""}){return n.jsx("span",{"aria-hidden":!0,className:`inline-block h-2.5 w-2.5 rounded-[3px] bg-accent ${t}`})}function ht({onConnect:t,selectedProfile:e}){const{t:s}=ne(),r=We(),[l,c]=a.useState([]),[o,v]=a.useState(""),[I,_]=a.useState(""),[N,E]=a.useState(""),[Q,H]=a.useState("58627"),[b,u]=a.useState(""),[p,k]=a.useState("stable"),[C,S]=a.useState(null),[M,f]=a.useState(null),[j,T]=a.useState(null),[R,F]=a.useState(null),[O,ae]=a.useState(!1);a.useEffect(()=>{if(!r.connection.listSshProfiles)return;let h=!0;return r.connection.listSshProfiles().then(A=>{h&&c(A)},A=>{h&&(ae(!0),F(String(A)))}),()=>{h=!1}},[r]);const G=()=>{T("list"),F(null),r.connection.listSshProfiles().then(h=>{c(h),ae(!1)},h=>F(String(h))).finally(()=>T(null))};if(!r.connection.listSshProfiles||!r.connection.saveSshProfile||!r.connection.removeSshProfile)return null;const Se=h=>{h.preventDefault();const A=Number(Q);if(!Number.isInteger(A)||A<1||A>65535||!/^[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$/.test(b.trim())){F(s("connect.sshNeedSetup"));return}const U=l.find(V=>V.id===C),Ce={id:U?.id??crypto.randomUUID(),label:o.trim(),target:U?.target.kind==="host"?{...U.target,hostname:I.trim()}:{kind:"alias",alias:I.trim()},identityFile:N.trim()||null,releaseChannel:p,remotePort:A,serverHomeId:b.trim().toLowerCase()};T("save"),F(null),r.connection.saveSshProfile(Ce).then(V=>{c(V),v(""),_(""),E(""),H("58627"),u(""),k("stable"),S(null)},V=>F(String(V))).finally(()=>T(null))},Z=h=>{const A=l.find(U=>U.id===h)??(e?.id===h?e:void 0);if(!A?.remotePort||!A.serverHomeId||M?.id!==h||!/^[A-Za-z0-9_-]{43}$/.test(M.value)){F(s("connect.sshNeedSetup"));return}T(h),F(null),t(h,M.value).then(()=>f(null),U=>F(String(U))).finally(()=>T(null))},Me=h=>{T(h),F(null),r.connection.removeSshProfile(h).then(A=>c(A),A=>F(String(A))).finally(()=>T(null))};return n.jsxs("section",{className:"mt-5 border-t border-hairline pt-4","aria-label":s("connect.sshTitle"),children:[n.jsx("h2",{className:"text-[13px] font-semibold text-ink",children:s("connect.sshTitle")}),n.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-ink-soft",children:s("connect.sshHint")}),O?n.jsx("button",{type:"button",disabled:j!==null,onClick:G,className:"mt-2 rounded-md border border-hairline-strong px-2 py-1 text-[11px] text-ink disabled:opacity-50",children:s("common.retry")}):null,(e&&!l.some(h=>h.id===e.id)?[e,...l]:l).map(h=>n.jsxs("div",{className:"mt-2 rounded-lg border border-hairline px-3 py-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"truncate text-[12px] font-medium text-ink",children:h.label}),n.jsxs("p",{className:"truncate font-mono text-[10px] text-ink-soft",children:[h.target.kind==="alias"?h.target.alias:h.target.hostname,h.remotePort?` · 127.0.0.1:${h.remotePort}`:""," · ",s(h.releaseChannel==="beta"?"st.about.beta":"st.about.stable")]})]}),n.jsx("button",{type:"button",disabled:j!==null,onClick:()=>{S(h.id),v(h.label),_(h.target.kind==="alias"?h.target.alias:h.target.hostname),E(h.identityFile??""),H(String(h.remotePort??58627)),u(h.serverHomeId??""),k(h.releaseChannel),F(null)},className:"rounded-md border border-hairline px-2 py-1 text-[11px] text-ink-soft disabled:opacity-50",children:s("goal.edit")}),n.jsx("button",{type:"button",disabled:j!==null,onClick:()=>Me(h.id),className:"rounded-md border border-hairline px-2 py-1 text-[11px] text-ink-soft disabled:opacity-50",children:s("connect.sshRemove")})]}),n.jsxs("label",{className:"mt-2 block text-[11px] text-ink-soft",children:[s("connect.sshToken"),n.jsx("input",{type:"password",value:M?.id===h.id?M.value:"",onChange:A=>f({id:h.id,value:A.target.value}),autoComplete:"off",spellCheck:!1,maxLength:43,className:"mt-1 w-full rounded-md border border-hairline bg-paper px-2 py-1.5 font-mono text-[12px] text-ink"})]}),n.jsx("button",{type:"button",disabled:j!==null,onClick:()=>Z(h.id),className:"mt-2 rounded-md border border-hairline-strong px-2 py-1 text-[11px] text-ink disabled:opacity-50",children:s("connect.sshConnect")})]},h.id)),n.jsxs("form",{onSubmit:Se,className:"mt-3 grid gap-2",children:[n.jsxs("label",{className:"text-[11px] text-ink-soft",children:[s("connect.sshLabel"),n.jsx("input",{value:o,onChange:h=>v(h.target.value),required:!0,maxLength:100,className:"mt-1 w-full rounded-md border border-hairline bg-paper px-2 py-1.5 text-[12px] text-ink"})]}),n.jsxs("label",{className:"text-[11px] text-ink-soft",children:[s("connect.sshAlias"),n.jsx("input",{value:I,onChange:h=>_(h.target.value),required:!0,maxLength:255,autoComplete:"off",spellCheck:!1,placeholder:"dev-linux",className:"mt-1 w-full rounded-md border border-hairline bg-paper px-2 py-1.5 font-mono text-[12px] text-ink"})]}),n.jsxs("label",{className:"text-[11px] text-ink-soft",children:[s("connect.sshIdentity"),n.jsx("input",{value:N,onChange:h=>E(h.target.value),autoComplete:"off",spellCheck:!1,placeholder:"~/.ssh/id_ed25519",className:"mt-1 w-full rounded-md border border-hairline bg-paper px-2 py-1.5 font-mono text-[12px] text-ink"})]}),n.jsxs("label",{className:"text-[11px] text-ink-soft",children:[s("connect.sshPort"),n.jsx("input",{type:"number",min:1,max:65535,required:!0,value:Q,onChange:h=>H(h.target.value),className:"mt-1 w-full rounded-md border border-hairline bg-paper px-2 py-1.5 font-mono text-[12px] text-ink"})]}),n.jsxs("label",{className:"text-[11px] text-ink-soft",children:[s("connect.sshHomeId"),n.jsx("input",{value:b,onChange:h=>u(h.target.value),required:!0,maxLength:36,autoComplete:"off",spellCheck:!1,placeholder:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",className:"mt-1 w-full rounded-md border border-hairline bg-paper px-2 py-1.5 font-mono text-[12px] text-ink"})]}),n.jsxs("label",{className:"text-[11px] text-ink-soft",children:[s("st.about.channel"),n.jsxs("select",{value:p,onChange:h=>k(h.target.value),className:"mt-1 w-full rounded-md border border-hairline bg-paper px-2 py-1.5 text-[12px] text-ink",children:[n.jsx("option",{value:"stable",children:s("st.about.stable")}),n.jsx("option",{value:"beta",children:s("st.about.beta")})]})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("button",{type:"submit",disabled:j!==null,className:"rounded-md border border-hairline-strong px-2 py-1.5 text-[12px] text-ink disabled:opacity-50",children:s("connect.sshAdd")}),C!==null?n.jsx("button",{type:"button",disabled:j!==null,onClick:()=>{S(null),v(""),_(""),E(""),H("58627"),u(""),k("stable")},className:"rounded-md border border-hairline px-2 py-1.5 text-[12px] text-ink-soft disabled:opacity-50",children:s("common.cancel")}):null]})]}),R!==null?n.jsx("p",{role:"alert",className:"mt-2 whitespace-pre-wrap text-[11px] text-danger",children:R}):null]})}function gn({problem:t,onRetry:e}){const{t:s}=ne(),[r,l]=a.useState(!1);return n.jsxs("div",{className:"px-7 pt-6 pb-7","data-web-link-problem":t,children:[n.jsx(ge,{size:"lg"}),n.jsx("p",{className:"mt-3 text-[14px] font-medium text-ink",children:s(t==="retargeted"?"connect.webLinkRetargeted":"connect.webLinkRefused")}),n.jsx("p",{className:"mt-1.5 max-w-[46ch] text-[13px] leading-relaxed text-ink-soft",children:s(t==="retargeted"?"connect.webLinkRetargetedBody":"connect.webLinkRefusedBody")}),e!==void 0?n.jsx("button",{type:"button","data-web-link-retry":!0,onClick:e,className:"mt-5 w-full rounded-md bg-accent px-3 py-2 text-[14px] font-medium text-on-accent transition-colors hover:bg-accent-deep focus-visible:ring-2 focus-visible:ring-selected-ink/50 focus-visible:outline-none",children:s("connect.webLinkRetry")}):null,n.jsx("button",{type:"button","data-web-link-connect":!0,"aria-expanded":r,onClick:()=>{l(c=>!c)},className:"mt-3 w-full rounded-md px-3 py-1.5 text-[12px] text-ink-soft transition-colors hover:text-ink",children:s(r?"connect.webLinkHideConnect":"connect.webLinkUseConnect")})]})}function vn({initial:t,connecting:e,error:s,onConnect:r,onBack:l,desktopBoot:c,desktopFailure:o,onRetryDesktop:v,onCancelDesktopBoot:I,onConnectSsh:_,onSwitchLocal:N,sshProfile:E,webLink:Q,onRetryWebLink:H}){return N!==void 0?n.jsx(xe,{children:o!==null?n.jsxs(n.Fragment,{children:[n.jsx(ft,{failure:o,onRetry:v,onSwitchLocal:N}),n.jsx("div",{className:"px-7 pb-7",children:n.jsx(ht,{onConnect:_,selectedProfile:E})})]}):n.jsx(wn,{onSwitchLocal:N})}):c!==null?n.jsx(xe,{children:n.jsx(yn,{boot:c,onCancel:I})}):o!==null?n.jsxs(xe,{children:[n.jsx(ft,{failure:o,onRetry:v}),n.jsx("div",{className:"px-7 pb-7",children:n.jsx(ht,{onConnect:_})})]}):Q!==void 0?n.jsx(xe,{children:n.jsx(gn,{problem:Q,onRetry:H})}):n.jsx(xe,{children:n.jsx(kn,{initial:t,connecting:e,error:s,onConnect:r,onBack:l})})}function xe({children:t}){return n.jsx("div",{className:"flex h-full items-center justify-center overflow-y-auto bg-paper px-4 py-4",children:n.jsx("div",{className:"anim-enter w-full max-w-[420px]",children:n.jsx("div",{className:"rounded-2xl border border-hairline bg-panel shadow-[0_1px_2px_rgba(28,25,23,0.04),0_12px_32px_-16px_rgba(28,25,23,0.12)]",children:t})})})}function bn(t){const[e,s]=a.useState(()=>Date.now());return a.useEffect(()=>{s(Date.now());const r=window.setInterval(()=>{s(Date.now())},1e3);return()=>{window.clearInterval(r)}},[t]),Math.max(0,Math.floor((e-t)/1e3))}function wn({onSwitchLocal:t}){const{t:e}=ne();return n.jsxs("div",{className:"px-7 pt-6 pb-7",children:[n.jsx(ge,{size:"lg"}),n.jsx("p",{className:"mt-2 text-[13px] text-ink-soft",children:e("connect.sshChecking")}),n.jsx("button",{type:"button",onClick:t,className:"mt-5 w-full rounded-lg border border-hairline-strong bg-paper px-3 py-2 text-[13px] font-medium text-ink transition-colors hover:border-accent hover:text-ink",children:e("connect.switchLocal")})]})}function yn({boot:t,onCancel:e}){const{t:s}=ne(),r=bn(t.startedAtMs);return n.jsxs("div",{className:"px-7 pt-6 pb-7",children:[n.jsx(ge,{size:"lg"}),n.jsx("p",{className:"mt-2 text-[13px] leading-relaxed text-ink-soft",children:t.stage==="spawning"?s("connect.desktopBootingSpawning"):s("connect.desktopBootingWaiting")}),n.jsx("p",{className:"mt-1 font-mono text-[12px] text-ink-faint","aria-live":"polite",children:s("connect.desktopElapsed",{seconds:r})}),n.jsx("button",{type:"button",onClick:e,className:"mt-5 w-full rounded-lg border border-hairline-strong bg-paper px-3 py-2 text-[13px] font-medium text-ink transition-colors hover:border-accent hover:text-ink",children:s("connect.desktopCancel")})]})}function ft({failure:t,onRetry:e,onSwitchLocal:s}){const{t:r}=ne(),[l,c]=a.useState(!1);a.useEffect(()=>{if(!l)return;const v=window.setTimeout(()=>{c(!1)},1500);return()=>{window.clearTimeout(v)}},[l]);const o=async()=>{try{await navigator.clipboard.writeText(t.message),c(!0)}catch{}};return n.jsxs("div",{className:"px-7 pt-6 pb-7",children:[n.jsx(ge,{size:"lg"}),n.jsx("p",{className:"mt-2 text-[13px] font-semibold text-danger",children:r(s===void 0?"connect.desktopFailedTitle":"connect.sshFailedTitle")}),n.jsx("pre",{className:"mt-3 max-h-56 overflow-auto whitespace-pre-wrap rounded-lg border border-danger/30 bg-danger/5 px-3 py-2 font-mono text-[12px] leading-relaxed text-danger",children:t.message}),t.logPath!==null?n.jsxs("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-soft",children:[r("connect.desktopLogPathLabel")," ",n.jsx("span",{className:"font-mono",children:t.logPath})]}):null,n.jsxs("div",{className:"mt-4 flex gap-2",children:[n.jsx("button",{type:"button",onClick:s??e,className:"flex-1 rounded-lg bg-accent px-3 py-2 text-[13px] font-semibold text-on-accent transition-colors hover:bg-accent-deep",children:r(s===void 0?"connect.desktopRetry":"connect.switchLocal")}),n.jsx("button",{type:"button",onClick:()=>{o()},className:"flex-1 rounded-lg border border-hairline-strong bg-paper px-3 py-2 text-[13px] font-medium text-ink transition-colors hover:border-accent hover:text-ink",children:r(l?"connect.desktopCopied":"connect.desktopCopyDiagnostics")})]})]})}function kn({initial:t,connecting:e,error:s,onConnect:r,onBack:l}){const c=We(),{t:o}=ne(),[v,I]=a.useState(t.url),[_,N]=a.useState(t.token),[E,Q]=a.useState(!1),[H,b]=a.useState(t.url!==""||t.token!==""||s!==null);a.useEffect(()=>{s!==null&&b(!0)},[s]);const[u,p]=a.useState(!1),[k,C]=a.useState(null),S=f=>{f.preventDefault(),r({url:v.trim(),token:_.trim()})},M=async()=>{p(!0),C(null);try{const f=await c.connection.discover();if(f===null){C(o("connect.noneFound"));return}r(f.config,f.persist)}catch(f){C(c.kind==="tauri"?o("connect.desktopStartFailed",{detail:f instanceof Error?f.message:String(f)}):o("connect.detectNeedsDev"))}finally{p(!1)}};return n.jsxs("div",{className:"px-7 pt-6 pb-7",children:[n.jsx(ge,{size:"lg"}),n.jsx("p",{className:"mt-3 font-display text-[18px] leading-snug text-ink-soft",children:o("connect.tagline")}),n.jsxs("form",{onSubmit:S,className:"mt-6",children:[n.jsx("button",{type:"button",onClick:()=>{M()},disabled:u||e,className:"w-full rounded-md bg-accent px-3 py-2 text-[14px] font-medium text-on-accent transition-colors hover:bg-accent-deep focus-visible:ring-2 focus-visible:ring-selected-ink/50 focus-visible:outline-none disabled:opacity-60",children:o(u?"connect.detecting":"connect.detect")}),k!==null?n.jsx("p",{role:"status",className:"mt-2 text-[13px] leading-relaxed text-ink-soft",children:k}):null,n.jsxs("button",{type:"button","aria-expanded":H,"aria-controls":"connect-manual",onClick:()=>{b(f=>!f)},className:"mt-5 flex items-center gap-1.5 rounded-md py-1 text-[13px] text-ink-soft transition-colors hover:text-ink focus-visible:ring-2 focus-visible:ring-selected-ink/40 focus-visible:outline-none",children:[n.jsx(hn,{open:H,className:"text-current"}),o("connect.otherMachine")]}),n.jsxs("div",{id:"connect-manual",hidden:!H,className:"mt-3",children:[n.jsx("label",{htmlFor:"connect-server-url",className:"mb-1 block text-[12px] font-medium text-ink-soft",children:o("connect.serverUrl")}),n.jsx("input",{id:"connect-server-url",className:"mb-4 w-full rounded-lg border border-hairline bg-paper px-3 py-2 font-mono text-[13px] text-ink outline-none transition-colors placeholder:text-ink-faint focus:border-accent",placeholder:o("connect.urlPlaceholder",{target:"http://127.0.0.1:58627"}),value:v,onChange:f=>{I(f.target.value)},spellCheck:!1}),n.jsxs("label",{htmlFor:"connect-token",className:"mb-1 flex items-baseline justify-between gap-2 text-[12px] font-medium text-ink-soft",children:[o("connect.accessToken"),n.jsx("span",{title:o("connect.accessTokenHelp"),className:"cursor-help text-[12px] font-normal text-ink-faint underline decoration-dotted underline-offset-2",children:o("connect.accessTokenWhere")})]}),n.jsxs("div",{className:"mb-5 flex gap-2",children:[n.jsx("input",{id:"connect-token",className:"min-w-0 flex-1 rounded-lg border border-hairline bg-paper px-3 py-2 font-mono text-[13px] text-ink outline-none transition-colors placeholder:text-ink-faint focus:border-accent","aria-describedby":"connect-token-help",value:_,onChange:f=>{N(f.target.value)},spellCheck:!1,type:E?"text":"password"}),n.jsx("button",{type:"button",className:"rounded-lg border border-hairline px-3 text-[12px] text-ink-soft transition-colors hover:border-accent hover:text-ink","aria-label":`${o(E?"st.providers.hideKey":"st.providers.showKey")} ${o("connect.token")}`,onClick:()=>{Q(f=>!f)},children:o(E?"st.providers.hideKey":"st.providers.showKey")})]}),n.jsx("p",{id:"connect-token-help",className:"sr-only",children:o("connect.accessTokenHelp")}),s!==null?n.jsx("div",{role:"alert",className:"mb-4 rounded-md border-l-2 border-danger bg-danger/5 px-3 py-2 text-[13px] text-danger",children:s}):null,n.jsx("button",{type:"submit",disabled:e,className:"w-full rounded-md border border-hairline-strong bg-paper px-3 py-2 text-[13px] font-medium text-ink transition-colors hover:border-ink-faint focus-visible:ring-2 focus-visible:ring-selected-ink/40 focus-visible:outline-none disabled:opacity-60",children:o(e?"connect.connecting":"connect.connect")})]}),l!==void 0?n.jsx("button",{type:"button",onClick:l,className:"mt-2 w-full rounded-lg px-3 py-1.5 text-[12px] text-ink-soft transition-colors hover:text-ink",children:o("connect.back")}):null]})]})}const Ke="kiki.connection",jn=["server","url","token"];function In(t){const e=new URLSearchParams(t.search);for(const o of jn)e.delete(o);const s=e.toString(),r=t.hash.startsWith("#")?t.hash.slice(1).split("&"):[],l=r.filter(o=>!o.startsWith("token=")&&!o.startsWith("access=")),c=l.length===r.length?t.hash:l.length===0?"":`#${l.join("&")}`;return`${t.pathname}${s===""?"":`?${s}`}${c}`}function Sn(t=window.location){const e=new URLSearchParams(t.search),s=e.get("server")??e.get("url"),r=e.get("token");if(s!==null||r!==null)return{url:s??"",token:r??""};const l=/(?:^|#|&)token=([^&]+)/.exec(t.hash);return l!==null?{url:"",token:decodeURIComponent(l[1]??"")}:null}function Mn(t){try{const e=(t??localStorage).getItem(Ke);if(e===null)return null;const s=JSON.parse(e);return typeof s.url!="string"||typeof s.token!="string"?null:{url:s.url,token:s.token}}catch{return null}}function Cn(t,e){try{return(e??localStorage).setItem(Ke,JSON.stringify(t)),!0}catch{return!1}}function Pn(t){try{return(t??localStorage).removeItem(Ke),!0}catch{return!1}}function Nn(t){return t.desktop!==void 0?{config:t.desktop,persist:!1,source:"desktop"}:t.deepLink!==void 0&&t.deepLink!==null?{config:t.deepLink,persist:En(t.deepLink.url),source:"deep-link"}:t.stored!==void 0&&t.stored!==null?{config:t.stored,persist:!0,source:"stored"}:null}function En(t){if(t==="")return!0;try{const e=new URL(t);if(e.protocol!=="http:"&&e.protocol!=="https:")return!1;const s=e.hostname.toLowerCase();return s==="localhost"||s.endsWith(".localhost")||s==="[::1]"||s==="::1"?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(s)}catch{return!1}}function pt(t){if(t!==null&&typeof t=="object"&&"message"in t){const e=t;if(typeof e.message=="string")return{message:e.message,stderrTail:Array.isArray(e.stderrTail)?e.stderrTail.filter(s=>typeof s=="string"):[],logPath:typeof e.logPath=="string"?e.logPath:null}}return{message:t instanceof Error?t.message:String(t),stderrTail:[],logPath:null}}async function Yn(t,e,s){s.throwIfAborted();const r=e.scopeId.slice(7);if(e.homeId!==e.scopeId||!e.scopeId.startsWith("remote:")||!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(r))throw new w("scope-invalid");if(t.openRemoteSpace===void 0)throw new w("scope-invalid");await t.openRemoteSpace(r),s.throwIfAborted()}async function mt(t,e,s){s.throwIfAborted();const r=new URL(e,"http://example.test").pathname,l=/^\/s\/([^/]+)/.exec(r)?.[1],c=/^\/(?:rooms|r)\/([^/]+)$/.exec(r)?.[1];try{if(l!==void 0&&await t.getSession(decodeURIComponent(l)),c!==void 0){const o=t.klient.rest;if(o===void 0)throw new w("offline");if(await o.rooms.get(decodeURIComponent(c))===void 0)throw new w("target-missing")}}catch(o){throw l!==void 0&&o instanceof Ie&&o.code===ye.SESSION_NOT_FOUND?new w("target-missing"):c!==void 0&&o instanceof Qe&&o.code===ye.REQUEST_INVALID&&o.message===`Room '${decodeURIComponent(c)}' does not exist.`?new w("target-missing"):(o instanceof Ie||o instanceof Qe)&&o.code===ye.UNAUTHORIZED?new w("auth-required"):o}s.throwIfAborted()}function Rn(t){return{async prepare(e,s,r){s.throwIfAborted();const l=t.active(),c=l.scope.homeId!==e.homeId;let o,v,I=!1,_=!1,N=l.scope.homeId,E=!1,Q;t.preparing?.(!0);const H=async()=>{try{if(I&&v!==void 0&&(I=!1,await v.klient.close()),Q!==void 0){const b=Q;Q=void 0,await t.host.connection.disconnectSshProfile?.(b.id,b.tunnelId)}_&&(_=!1,await t.host.prepareSpace?.(N))}finally{t.preparing?.(!1)}};try{if(e.scopeId.startsWith("remote:")||e.homeId.startsWith("remote:")){const p=e.scopeId.slice(7);if(e.homeId!==e.scopeId||!e.scopeId.startsWith("remote:")||!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(p))throw new w("scope-invalid");const k=t.control?.()??t.local();if(k===null||k.selection.source==="remote"||k.selection.source==="ssh")throw new w("offline");const C=k.client.klient.rest?.connections;if(C===void 0)throw new w("offline");const S=await C.list();s.throwIfAborted();const M=S.find(T=>T.id===p);if(M===void 0)throw new w("scope-invalid");if(M.enabled!==!0||M.state==="disabled"||M.target.protocol!==en)throw new w("identity-mismatch");o={config:k.selection.config,persist:!1,source:"remote",scopeId:e.scopeId,connectionId:M.id,serverHomeId:M.target.homeId},v=t.createClient?.(o)??De({endpoint:o.config.url,token:o.config.token,connectionId:M.id}),I=!0;const f=await v.meta();if(s.throwIfAborted(),f.server_home_id!==M.target.homeId||e.serverHomeId!==void 0&&e.serverHomeId!==f.server_home_id||e.connectionRef!==void 0&&e.connectionRef!==M.id)throw new w("identity-mismatch");const j=v;return{scope:{...e,serverHomeId:f.server_home_id,connectionRef:M.id},validate:(T,R)=>mt(j,T,R),commit:()=>{s.throwIfAborted(),t.commit(o,j,f),t.reload(),I=!1,t.preparing?.(!1)},dispose:H}}if(e.scopeId.startsWith("ssh:")&&!r&&!e.connectionRef)throw new w("auth-required");if(c&&l.selection.source==="remote"&&(N=t.host.activeSpace===void 0?"main":Oe(await t.host.activeSpace())?.homeId??"main",s.throwIfAborted(),E=e.homeId===N&&(e.scopeId==="local"||e.scopeId.startsWith("direct:"))),c&&!E){if(!t.host.prepareSpace)throw new w("scope-invalid");const p=await t.host.prepareSpace(e.homeId);if(_=!0,s.throwIfAborted(),p.homeId!==e.homeId)throw new w("identity-mismatch")}if(e.scopeId.startsWith("ssh:")){const p=e.scopeId.slice(4),k=await t.host.connection.listSshProfiles?.();s.throwIfAborted();const C=k?.find(f=>f.id===p);if(C===void 0)throw new w("scope-invalid");if(!C.serverHomeId||!C.remotePort)throw new w("scope-invalid");let S;if(r!==void 0){if(!/^[A-Za-z0-9_-]{43}$/.test(r))throw new w("auth-required");if(!t.host.connection.prepareSshProfile)throw new w("scope-invalid");try{S=await t.host.connection.prepareSshProfile(p,r)}catch(f){if(f instanceof w)throw f;const j=f instanceof Error?f.message:String(f);throw j.includes("rejected the bearer token")?new w("auth-required"):j.includes("home identity")||j.includes("authentication; SSH connection blocked")||j.includes("build identity")||j.includes("release channel")?new w("identity-mismatch"):f}S.tunnelId&&(Q={id:p,tunnelId:S.tunnelId})}else{if(!e.connectionRef||!t.host.connection.resumeScopeConnection)throw new w("auth-required");try{S=(await t.host.connection.resumeScopeConnection(e.homeId,p,e.connectionRef)).connection}catch(f){const j=f instanceof Error?f.message:String(f);throw new w(j.includes("offline")?"offline":j.includes("identity changed")?"identity-mismatch":"auth-required")}if(S.tunnelId!==e.connectionRef)throw new w("identity-mismatch")}s.throwIfAborted();let M;try{M=new URL(S.config.url)}catch{throw new w("identity-mismatch")}if(M.protocol!=="http:"||M.hostname!=="127.0.0.1"||M.username||M.password||!M.port||!S.tunnelId||r!==void 0&&S.config.token!==r||S.serverHomeId!==C.serverHomeId)throw new w("identity-mismatch");o={config:S.config,persist:!1,source:"ssh",scopeId:e.scopeId,profile:C,tunnelId:S.tunnelId,serverHomeId:S.serverHomeId,serverInstanceId:S.serverInstanceId,serverVersion:S.serverVersion,buildId:S.buildId,buildChannel:S.buildChannel}}else if(e.scopeId==="local"||E&&e.scopeId.startsWith("direct:"))if(c&&!E){const p=await t.host.connection.discover();if(p===null)throw new w("offline");o={config:p.config,persist:!1,source:"desktop",scopeId:"local"}}else{const p=E?t.control?.()??t.local():t.local();if(p===null)throw new w("offline");if(e.scopeId.startsWith("direct:")&&e.scopeId!==(p.selection.scopeId??`direct:${p.selection.config.url.trim().replace(/\/+$/,"")}`))throw new w("scope-invalid");o=p.selection,v=p.client}else if(e.homeId===l.scope.homeId&&e.scopeId===l.scope.scopeId)o=l.selection,v=l.client;else throw new w("scope-invalid");s.throwIfAborted(),v===void 0&&(v=t.createClient?.(o)??new we({baseUrl:o.config.url,token:o.config.token}),I=!0);const b=await v.meta();if(s.throwIfAborted(),e.serverHomeId!==void 0&&b.server_home_id!==e.serverHomeId)throw new w("identity-mismatch");if(o.source==="ssh"&&(b.server_home_id!==o.serverHomeId||b.server_id!==o.serverInstanceId||b.server_version!==o.serverVersion||b.dangerous_bypass_auth!==!1||(b.build_id??null)!==o.buildId||(b.build_channel??null)!==o.buildChannel))throw new w("identity-mismatch");const u=v;return{scope:{...e,serverHomeId:b.server_home_id,connectionRef:o.source==="ssh"?o.tunnelId:void 0},validate:(p,k)=>mt(u,p,k),commit:async()=>{if(s.throwIfAborted(),o.source==="ssh"&&o.profile&&o.tunnelId){if(!t.host.connection.commitScopeConnection)throw new w("scope-invalid");await t.host.connection.commitScopeConnection(e.homeId,o.profile.id,o.tunnelId,c),s.throwIfAborted()}c?(I&&await u.klient.close(),s.throwIfAborted(),t.reload()):t.commit(o,u,b),I=!1,_=!1,Q=void 0,t.preparing?.(!1)},dispose:H}}catch(b){throw await H(),(b instanceof Ie||b instanceof Qe)&&b.code===ye.UNAUTHORIZED?new w("auth-required"):b}}}}function Fe(){const t=`${window.location.pathname}${window.location.search}${window.location.hash}`,e=In(window.location);if(e!==t)try{window.history.replaceState(window.history.state,"",e)}catch{}}function yt(t,e){return t.type!=="event.model_catalog.changed"?!1:(e.invalidateQueries({queryKey:["models"]}),e.invalidateQueries({queryKey:["providers"]}),e.invalidateQueries({queryKey:["model-entity"]}),e.invalidateQueries({queryKey:["provider-entity"]}),e.invalidateQueries({queryKey:["discovered-models"]}),!0)}function ke(t,e){t.invalidateQueries({queryKey:["sessions"]}),t.invalidateQueries({queryKey:["rooms"]}),t.invalidateQueries({queryKey:["activity-prompts",e]}),t.invalidateQueries({queryKey:["activity-tasks",e]})}const kt=3,Ue=64*1024*1024,jt=Ue/2,It=5*6e4,St=4;function je(t){const e=t.getState();return e.busy||e.pendingInteraction!=="none"||e.tasks.some(s=>s.status==="running")}function An(t){const e=t.getState();return e.loaded&&e.loadError===void 0&&!(e.resyncFailed&&e.resyncError?.retryable===!1)}class Mt{controllers=new Set;retained=new WeakMap;parked=new Map;listeners=new Set;generation=0;limits;now;setTimer;clearTimer;ttlTimer=null;constructor(e={}){this.limits={maxParked:e.maxParked??kt,maxBytes:e.maxBytes??Ue,maxEntryBytes:e.maxEntryBytes??jt,ttlMs:e.ttlMs??It,maxLiveParked:e.maxLiveParked??St},this.now=e.now??Date.now,this.setTimer=e.setTimer??((s,r)=>setTimeout(s,r)),this.clearTimer=e.clearTimer??(s=>{clearTimeout(s)})}acquire(e,s,r){let l=this.retained.get(s);l===void 0&&(l=new Map,this.retained.set(s,l));let c=l.get(e);if(c===void 0){const I=r();if(I.sessionId!==e||this.controllers.has(I))throw new Error("Controller factory must return a fresh controller for the requested session");c={controller:I,ready:I.open(),references:1,sessions:l,sessionId:e},l.set(e,c),this.add(I)}else c.parked!==void 0?(this.unpark(c),c.references=1,c.ready=Promise.resolve(),c.controller.resume(),this.add(c.controller)):c.references+=1;const o=c;let v=!1;return{controller:o.controller,ready:o.ready,release:()=>{v||(v=!0,o.references-=1,!(o.references>0)&&(this.park(o,s)||this.dispose(o)))}}}get parkedCount(){return this.parked.size}evictScope(e){for(const[s,r]of Array.from(this.parked))r===e&&this.dispose(s)}clearParked(){for(const e of Array.from(this.parked.keys()))this.dispose(e)}park(e,s){const{controller:r}=e;if(typeof r.getState!="function"||typeof r.suspend!="function"||!An(r))return!1;const l=r.residentBytes();if(l>this.limits.maxEntryBytes)return!1;const c=r.subscribe(()=>{this.onParkedChange(e)});return e.parked={at:this.now(),bytes:l,unsubscribe:c},this.parked.set(e,s),je(r)||r.suspend(),this.delete(r),this.enforceLimits(),!0}unpark(e){e.parked?.unsubscribe(),e.parked=void 0,this.parked.delete(e),this.scheduleTtl()}dispose(e){e.parked!==void 0&&this.unpark(e),e.sessions.get(e.sessionId)===e&&e.sessions.delete(e.sessionId),e.controller.close(),this.delete(e.controller)}onParkedChange(e){const s=e.parked;if(s===void 0||e.controller.suspended||je(e.controller))return;const r=this.parked.get(e)??{};e.parked={...s,at:this.now()},this.parked.delete(e),this.parked.set(e,r),e.controller.suspend(),this.enforceLimits()}isLiveProtected(e){return!e.controller.suspended&&je(e.controller)}enforceLimits(){const e=this.now(),s=Array.from(this.parked.keys()).filter(o=>this.isLiveProtected(o));for(const o of s.slice(0,Math.max(0,s.length-this.limits.maxLiveParked)))o.controller.suspend();for(const o of Array.from(this.parked.keys()))!this.isLiveProtected(o)&&e-(o.parked?.at??e)>=this.limits.ttlMs&&this.dispose(o);const r=()=>Array.from(this.parked.keys()).filter(o=>!this.isLiveProtected(o));let l=r(),c=l.reduce((o,v)=>o+(v.parked?.bytes??0),0);for(;l.length>0&&(l.length>this.limits.maxParked||c>this.limits.maxBytes);){const o=l[0];c-=o.parked?.bytes??0,this.dispose(o),l=r()}this.scheduleTtl()}scheduleTtl(){this.ttlTimer!==null&&(this.clearTimer(this.ttlTimer),this.ttlTimer=null);let e=1/0;for(const s of this.parked.keys())this.isLiveProtected(s)||(e=Math.min(e,(s.parked?.at??0)+this.limits.ttlMs));e!==1/0&&(this.ttlTimer=this.setTimer(()=>{this.ttlTimer=null,this.enforceLimits()},Math.max(0,e-this.now())))}add(e){this.controllers.add(e),this.emit()}delete(e){this.controllers.delete(e)&&this.emit()}[Symbol.iterator](){return this.controllers.values()}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}snapshot(){return this.generation}emit(){this.generation+=1;for(const e of this.listeners)e()}}const Ve=a.createContext(null),Ln=15e3;let xt=0;function Ct(t=Date.now()){return xt+=1,`gui-${t.toString(36)}-${xt.toString(36)}`}function _n({children:t}){const e=We(),s=e.kind==="tauri",r=Yt(),{locale:l,t:c}=ne(),o=a.useRef(new Map),v=Vt(),I=a.useRef(v?.scopeId.startsWith("remote:")?v:null),N=a.useSyncExternalStore(tn,nn,sn).requestTimeoutSeconds*1e3,[E,Q]=a.useState(()=>zt()),[H,b]=a.useState(E.kind==="failed"?Bt(E.reason):void 0),[u,p]=a.useState(()=>s||r?null:E.kind==="signed-in"?{config:{url:"",token:""},persist:!1,source:"web-cookie"}:(Gt(i=>{!i||L.current!==null||(q.current+=1,p({config:{url:"",token:""},persist:!1,source:"web-cookie"}))}),Nn({deepLink:Sn(),stored:Mn()}))),k=u?.config??null,C=u?.scopeId??(s?"local":`direct:${k?.url.trim().replace(/\/+$/,"")??""}`),S=u?.source==="remote"?u.connectionId??null:null,M=u?.source??null,f=S===null?lt()?.homeId??"main":`remote:${S}`;let j=o.current.get(C);j===void 0&&(j=new un({defaultOptions:{queries:{retry:1,staleTime:0,refetchOnWindowFocus:!1}}}),o.current.set(C,j));const[T,R]=a.useState(null),[F,O]=a.useState(null),[ae,G]=a.useState(()=>s?{stage:"spawning",startedAtMs:Date.now()}:null),[Se,Z]=a.useState(null),[Me,h]=a.useState(0),A=a.useRef(!1),[U,Ce]=a.useState("closed"),V=a.useRef(new Mt),q=a.useRef(0),se=a.useRef(0),Y=a.useRef(null),[ee,Pt]=a.useState(null),X=a.useCallback(i=>{Y.current=i,Pt(i)},[]),Pe=a.useRef(null),Be=a.useRef(new Map),ce=a.useRef(null),Ge=a.useRef(!1),Nt=a.useRef({promise:null,consumed:!1}),L=a.useRef(u);L.current=u;const Et=a.useRef(Ct());a.useEffect(()=>(e.connection.setWorkspaceScope?.(u?.source==="ssh"?"ssh":"local"),()=>e.connection.setWorkspaceScope?.("local")),[e,u?.source]),a.useEffect(()=>{if(!r)return;let i=!1;return e.connection.discover().then(d=>{i||d!==null&&(q.current+=1,p({config:d.config,persist:d.persist,source:"local-detection"}))},d=>{i||O({kind:"raw",text:d instanceof Error?d.message:String(d)})}),()=>{i=!0}},[e,r]),a.useEffect(()=>{if(e.kind!=="tauri")return;let i=!1,d=0;A.current=!1;let m;const x=()=>{const y=++d,g=Nt.current;g.promise??=(e.connection.takeScopeConnection?.()??Promise.resolve(null)).then(P=>{if(P===null)return null;const $=P.connection;return{config:$.config,persist:!1,source:"ssh",scopeId:`ssh:${P.profile.id}`,profile:P.profile,tunnelId:$.tunnelId,serverHomeId:$.serverHomeId,serverInstanceId:$.serverInstanceId,serverVersion:$.serverVersion,buildId:$.buildId,buildChannel:$.buildChannel}}).catch(()=>null),Promise.all([e.connection.discover(),g.consumed?Promise.resolve(null):g.promise]).then(([P,$])=>{if(i||y!==d)return;if(G(null),Z(null),P===null){if(X(null),L.current?.source==="ssh"||L.current?.source==="remote")return;O({kind:"key",key:"conn.desktopNoServer"});return}const nt={config:P.config,persist:!1,source:"desktop",scopeId:"local"};if(X(nt),$!==null&&!g.consumed){g.consumed=!0,g.promise=Promise.resolve(null),L.current=$,$.profile&&$.tunnelId&&(ce.current={id:$.profile.id,tunnelId:$.tunnelId}),q.current+=1,p($);return}L.current?.source==="ssh"||L.current?.source==="remote"||(q.current+=1,p(nt))},P=>{i||y!==d||(X(null),!(L.current?.source==="ssh"||L.current?.source==="remote")&&(q.current+=1,G(null),R(null),p(null),!A.current&&Z(pt(P))))})};return e.connection.onBackendStage(y=>{if(!Ge.current){if(y==="waiting"){if(X(null),L.current?.source==="ssh"||L.current?.source==="remote"){x();return}q.current+=1,Z(null),O(null),p(null),R(null),G(g=>({stage:"waiting",startedAtMs:g?.startedAtMs??Date.now()})),x();return}y===null||typeof y!="object"||!("stage"in y)||y.stage!=="failed"||!("failure"in y)||(d+=1,X(null),!(L.current?.source==="ssh"||L.current?.source==="remote")&&(q.current+=1,R(null),p(null),O(null),G(null),Z(pt(y.failure))))}}).then(y=>{i?y():(m=y,x())},()=>{x()}),()=>{i=!0,d+=1,m?.()}},[e,Me,X]);const Ne=a.useCallback(()=>{Z(null),O(null),G({stage:"spawning",startedAtMs:Date.now()}),h(i=>i+1)},[]),Rt=a.useCallback(()=>{A.current=!0,G(null),Z({message:c("connect.desktopCancelled"),stderrTail:[],logPath:null}),e.connection.cancelStartup?.().catch(()=>{})},[e,c]),Ee=ee?.config.url.trim().replace(/\/+$/,"")??null,Re=ee?.config.token.trim()??null,[Ze,At]=a.useState(null),le=ee!==null&&Ze?.selection===ee?Ze.client:null,te=a.useRef(le);te.current=le;const Ae=a.useRef(null);a.useEffect(()=>{if(ee===null||Ee===null||Re===null)return;const i=new we({baseUrl:Ee,token:Re,timeoutMs:N,onSessionMutation:d=>{const m=o.current.get("local");m!==void 0&&ke(m,d)}});return At({selection:ee,client:i}),()=>{i.klient.close()}},[ee,Ee,Re,N]);const re=k?.url.trim().replace(/\/+$/,"")??null,oe=k?.token.trim()??null,[ue,Ye]=a.useState(null),ve=u?.source==="desktop",de=Pe.current?.selection===u?Pe.current:null,he=ve?le:null,D=de?.client??(ue?.endpoint===re&&ue.token===oe&&ue.scopeId===C&&(!ve||ue.client===he)?ue.client:null),J=D?.klient??null;a.useEffect(()=>{if(re===null||oe===null||ve&&he===null)return;const i=x=>{ke(j,x)},d=de?.client??he??(u?.source==="remote"?De({endpoint:re,token:oe,connectionId:u.connectionId,timeoutMs:N,onSessionMutation:i}):new we({baseUrl:re,token:oe,timeoutMs:N,onSessionMutation:i}));Ye({endpoint:re,token:oe,scopeId:C,client:d});const m=V.current;return()=>{m.evictScope(d),d!==he&&d.klient.close()}},[re,oe,C,N,j,ve,he,de?.client]),a.useEffect(()=>{if(D===null||I.current!==null&&u?.source!=="remote")return;let i=!1;const d=q.current;O(null);const m=de?.client===D?de:Ae.current?.client===D?Ae.current:null;return m!==null&&(Ae.current=null),(m!==null?Promise.resolve(m.meta):D.meta()).then(x=>{if(!(i||d!==q.current)){if(Fe(),u?.source==="ssh"){const y=u.serverHomeId,g=Be.current.get(C);if(!y||!u.serverInstanceId||!u.serverVersion||x.server_home_id!==y||x.server_id!==u.serverInstanceId||x.server_version!==u.serverVersion||x.dangerous_bypass_auth!==!1||(x.build_id??null)!==u.buildId||(x.build_channel??null)!==u.buildChannel||g!==void 0&&g!==y){R(null),O({kind:"raw",text:"SSH server identity changed or could not be verified. This connection is blocked."});return}Be.current.set(C,y)}if(u?.source==="remote"&&(!u.serverHomeId||x.server_home_id!==u.serverHomeId)){R(null),O({kind:"raw",text:"identity-mismatch"});return}u?.source!=="remote"&&u?.persist===!0&&k!==null&&Cn(k),R(x)}},x=>{i||d!==q.current||(R(null),O({kind:"raw",text:x instanceof Ie||x instanceof Error?x.message:String(x)}),Fe())}),()=>{i=!0}},[D,k,u?.persist]);const fe=k!==null&&T!==null&&D!==null;a.useEffect(()=>{if(!fe||D===null)return;const i=()=>{D.renewLease({clientId:Et.current,kind:"gui"}).catch(()=>{})};i();const d=window.setInterval(i,Ln);return()=>{window.clearInterval(d)}},[D,fe]),a.useEffect(()=>{if(!fe||u?.source!=="ssh"||!e.connection.sshTunnelRunning)return;const i=u.profile?.id,d=u.tunnelId;if(!i||!d)return;let m=!0,x=!1;const y=()=>{x||(x=!0,e.connection.sshTunnelRunning(i,d).then(P=>{!m||P||(q.current+=1,R(null),O({kind:"raw",text:"SSH tunnel disconnected. Check the remote service and connect again."}))},P=>{m&&(q.current+=1,R(null),O({kind:"raw",text:`Cannot check the SSH tunnel: ${String(P)}`}))}).finally(()=>{x=!1}))};y();const g=window.setInterval(y,2e3);return()=>{m=!1,window.clearInterval(g)}},[fe,u?.source,u?.profile?.id,u?.tunnelId,e]);const K=fe?J?.terminal??null:null;a.useEffect(()=>{if(K===null||J===null)return;let i=!0;const d=()=>{const g=J.events.on("search.indexStateChanged",P=>{j.cancelQueries({queryKey:["search-index-state"]}).then(()=>{i&&m===g&&j.setQueryData(["search-index-state"],P)})});return g.ready.then(()=>{if(i&&m===g)return j.invalidateQueries({queryKey:["search-index-state"]})}).catch(()=>{}),g};let m=d();const x=K.onStatus(g=>{Ce(g),g==="open"&&(m.dispose(),m=d())}),y=J.events.on("kosong.changed",()=>{yt({type:"event.model_catalog.changed"},j)});return()=>{i=!1,x(),y.dispose(),m.dispose()}},[K,J,j]),a.useEffect(()=>{if(K!==null)return rn()},[K]),a.useEffect(()=>{if(K===null)return;const i=()=>{K.nudge();for(const m of V.current)m.nudge()},d=()=>{document.visibilityState==="visible"&&i()};return window.addEventListener("online",i),window.addEventListener("focus",i),window.addEventListener("pageshow",i),document.addEventListener("visibilitychange",d),()=>{window.removeEventListener("online",i),window.removeEventListener("focus",i),window.removeEventListener("pageshow",i),document.removeEventListener("visibilitychange",d)}},[K]);const[Xe,Lt]=a.useState(!1),z=a.useRef({scope:{homeId:f,scopeId:C},selection:u,client:D});z.current={scope:{homeId:f,scopeId:C},selection:u,client:D};const ie=a.useMemo(()=>Rn({host:e,active:()=>{const i=z.current;if(i.selection===null||i.client===null)throw new Error("No active connection");return{scope:i.scope,selection:i.selection,client:i.client}},local:()=>Y.current!==null&&te.current!==null?{selection:Y.current,client:te.current}:null,control:()=>{if(Y.current!==null&&te.current!==null)return{selection:Y.current,client:te.current};const i=z.current;return i.selection!==null&&i.client!==null&&i.selection.source!=="remote"&&i.selection.source!=="ssh"?{selection:i.selection,client:i.client}:null},createClient:i=>i.source==="remote"?De({endpoint:i.config.url,token:i.config.token,connectionId:i.connectionId,timeoutMs:N,onSessionMutation:d=>{const m=o.current.get(i.scopeId);m!==void 0&&ke(m,d)}}):new we({baseUrl:i.config.url,token:i.config.token,timeoutMs:N}),reload:()=>{I.current===null&&Lt(!0)},preparing:i=>{Ge.current=i},commit:(i,d,m)=>{if(se.current+=1,q.current+=1,i===z.current.selection&&d===z.current.client){R(m);return}const x=z.current.selection;i.source==="remote"&&!s&&x!==null&&x.source!=="remote"&&x.source!=="ssh"&&X({...x,scopeId:z.current.scope.scopeId});const y=i.source==="ssh"&&i.profile&&i.tunnelId?{id:i.profile.id,tunnelId:i.tunnelId}:null;ce.current=y,Pe.current={selection:i,client:d,meta:m},L.current=i,p(i),Ye({endpoint:i.config.url.trim().replace(/\/+$/,""),token:i.config.token.trim(),scopeId:i.scopeId??"local",client:d}),O(null),R(m)}}),[e,N,s,X]);a.useEffect(()=>{const i=I.current;if(i===null||D===null||u?.source==="remote")return;const d=new AbortController;return(async()=>{const m=await ie.prepare(i,d.signal);try{await m.validate(`${window.location.pathname}${window.location.search}${window.location.hash}`,d.signal),d.signal.throwIfAborted(),await m.commit(),I.current=null}catch(x){throw await m.dispose(),x}})().catch(m=>{d.signal.aborted||(R(null),O({kind:"raw",text:m instanceof Error?m.message:String(m)}))}),()=>{d.abort()}},[D,u?.source,ie]);const Je=a.useCallback(async(i=new AbortController().signal)=>{const d=te.current,m=L.current,x=se.current,y=m?.source==="remote"?e.activeSpace===void 0?"main":Oe(await e.activeSpace())?.homeId??"main":lt()?.homeId??"main",g=await ie.prepare({homeId:y,scopeId:"local"},i);try{if(i.throwIfAborted(),d!==te.current||m!==L.current||x!==se.current)throw new DOMException("Local connection restoration was superseded.","AbortError");await g.commit()}catch(P){throw await g.dispose(),P}},[ie,e]),pe=a.useCallback(()=>{if(T!==null&&D!==null){L.current?.source==="remote"?(async()=>{const d=e.activeSpace===void 0?"main":Oe(await e.activeSpace())?.homeId??"main";await Te({homeId:d,scopeId:Y.current?.scopeId??"local"})})().catch(()=>{}):Te({scopeId:"local"}).catch(()=>{});return}se.current+=1,q.current+=1;const i=ce.current;ce.current=null,i!==null&&e.connection.disconnectSshProfile?.(i.id,i.tunnelId).catch(()=>{}),R(null),O(null),p(Y.current),Y.current===null&&s&&Ne()},[T,D,e,s,Ne]),Le=a.useCallback(async(i,d)=>{if(z.current.client!==null&&z.current.selection!==null){await Te({scopeId:`ssh:${i}`,token:d});return}if(!e.connection.connectSshProfile||!e.connection.listSshProfiles)throw new Error("SSH connections are available only in the desktop application.");const m=++se.current,y=(await e.connection.listSshProfiles()).find($=>$.id===i);if(!y)throw new Error("SSH profile no longer exists.");if(!y.serverHomeId||!y.remotePort||!/^[A-Za-z0-9_-]{43}$/.test(d))throw new Error("Set the remote Kiki port, expected home ID and bearer token first.");const g=await e.connection.connectSshProfile(i,d);if(m!==se.current){g.tunnelId&&e.connection.disconnectSshProfile?.(i,g.tunnelId).catch(()=>{});return}let P;try{P=new URL(g.config.url)}catch{P=null}if(P?.protocol!=="http:"||P.hostname!=="127.0.0.1"||P.username||P.password||!P.port||!g.tunnelId||g.config.token!==d||g.serverHomeId!==y.serverHomeId)throw g.tunnelId&&e.connection.disconnectSshProfile?.(i,g.tunnelId).catch(()=>{}),new Error("SSH tunnel endpoint or server home ID could not be verified.");ce.current={id:i,tunnelId:g.tunnelId},q.current+=1,R(null),O(null),p({config:g.config,persist:!1,source:"ssh",scopeId:`ssh:${i}`,profile:y,tunnelId:g.tunnelId,serverHomeId:g.serverHomeId,serverInstanceId:g.serverInstanceId,serverVersion:g.serverVersion,buildId:g.buildId,buildChannel:g.buildChannel})},[e]),_e=a.useCallback(()=>{if(L.current?.source==="ssh"){pe();return}q.current+=1,Pn(),R(null),p(null),O(null),Fe()},[pe]),_t=a.useCallback(()=>{Xt(),Q({kind:"none"}),b(void 0)},[]),He=a.useCallback((i,d=!0)=>{const m=++q.current,x=L.current,y=x!==null&&x.config.url.trim().replace(/\/+$/,"")===i.url.trim().replace(/\/+$/,"")&&x.config.token.trim()===i.token.trim();O(null),R(null),p({config:i,persist:d,source:d?"manual":"local-detection",scopeId:y?x.scopeId:`direct:${i.url.trim().replace(/\/+$/,"")}:${m}`})},[]),et=a.useCallback(i=>{L.current?.source==="ssh"||L.current?.source==="remote"||He(i,!0)},[He]),tt=a.useMemo(()=>k===null||D===null||J===null||K===null||T===null?null:{connectionId:S,connectionSource:u?.source??null,spaceKey:f,scopeId:C,connectionRef:u?.source==="remote"?u.connectionId:u?.source==="ssh"?u.tunnelId:void 0,sshLabel:u?.profile?.label??null,activateSshProfile:Le,activateLocal:pe,restoreLocal:Je,scopeAdapter:ie,needsScopeReload:Xe,config:k,client:D,localClient:le,klient:J,socket:K,meta:T,wsStatus:U,disconnect:_e,applyConnection:et},[S,M,f,C,u?.tunnelId,u?.profile?.label,Le,pe,Je,ie,Xe,k,D,le,J,K,T,U,_e,et]),me=F===null?null:F.kind==="key"?Jt(l,F.key,F.params):F.text,Ht=u?.source==="ssh"?me===null?null:{message:me,stderrTail:[],logPath:null}:Se??(s&&me!==null?{message:me,stderrTail:[],logPath:null}:null);return n.jsx(Ve.Provider,{value:tt,children:tt!==null?n.jsx(Zt,{client:j,children:n.jsx(ze.Provider,{value:V.current,children:t})}):n.jsx(vn,{initial:k??{url:"",token:""},connecting:ae!==null||k!==null&&F===null,error:s?null:me,onConnect:He,onBack:s?void 0:k!==null?_e:void 0,desktopBoot:ae,desktopFailure:Ht,onRetryDesktop:Ne,onCancelDesktopBoot:Rt,onConnectSsh:Le,onSwitchLocal:u?.source==="ssh"?pe:void 0,sshProfile:u?.source==="ssh"?u.profile:void 0,webLink:H,onRetryWebLink:_t})})}const ze=a.createContext(null);function Hn(){const t=a.useContext(ze);if(t===null)throw new Error("useControllerRegistry outside provider");return t}function Tn(){return a.useContext(ze)}function Fn(){const t=a.useContext(Ve);if(t===null)throw new Error("useConnection used before connecting");return t}function On(){return a.useContext(Ve)}const Xn=Object.freeze(Object.defineProperty({__proto__:null,ConnectionProvider:_n,LiveControllerRegistry:Mt,VIEW_CACHE_MAX_BYTES:Ue,VIEW_CACHE_MAX_ENTRY_BYTES:jt,VIEW_CACHE_MAX_LIVE_PARKED:St,VIEW_CACHE_MAX_PARKED:kt,VIEW_CACHE_TTL_MS:It,handleGlobalConnectionFrame:yt,isProtectedView:je,nextGuiLeaseClientId:Ct,refreshSessionAttention:ke,useConnection:Fn,useControllerRegistry:Hn,useOptionalConnection:On,useOptionalControllerRegistry:Tn},Symbol.toStringTag,{value:"Module"}));export{hn as D,$e as I,Zn as K,Vn as O,fn as S,ge as W,Kn as a,On as b,Hn as c,Tn as d,ht as e,Xn as f,an as g,Un as h,ut as i,zn as l,Yn as o,Gn as p,Bn as s,Fn as u};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{S as Yn,D as qn,B as Xn,b as Qn,c as Zn,p as yn,r as et,w as nt,d as An,e as tt,A as Xe}from"./settings-CcwMWXbp.js";import{u as rt,B as b}from"./index-B_5-HLed.js";import{M as ot,h as it}from"./spaces-B2Ccyh_T.js";function st(e,n){const t=n?.current_space_id;return!n?.server_id||t===void 0||t!==ot&&!Yn.test(t)?null:{client:e,identity:{serverId:n.server_id,homeId:t}}}const Qe=new WeakMap;let at=0;function ct(e){let n=Qe.get(e);return n===void 0&&(n=++at,Qe.set(e,n)),n}function Er(e,n){const t=rt({queryKey:["space-settings","meta",e===null?null:ct(e)],queryFn:async({signal:r})=>{if(e===null)throw new Error("Space client unavailable");const o=await e.meta();return r.throwIfAborted(),o},enabled:e!==null&&n===void 0,staleTime:3e4,retry:!1});return e===null?null:st(e,n===void 0?t.data:n)}function je(e){return it(e)}const yr={all:["space-settings"],detail:e=>["space-settings","detail",e]},lt=["config","appearance","agents","instructions","skills","mcp","credentials","plugins"],Cn="generic_roots";function Ar(e){return`st.spaces.group.${e}`}const ne={theme:"pref:theme",skin:"pref:skin",tweaks:"pref:tweaks",background:"pref:background",proseFont:"pref:proseFont",defaultAppendTiming:"pref:defaultAppendTiming",foldSteps:"pref:foldSteps",worktreeSkipConfirm:"pref:worktreeSkipConfirm"};function Cr(e,n){return e?.items.find(t=>t.id===n)}function ut(e){return e.replaceAll(/[A-Z]/g,n=>`_${n.toLowerCase()}`)}function Dr(e,n=[]){return`config:${[e,...n].map(ut).join(".")}`}const dt={"pref:theme":"st.appearance.theme","pref:skin":"st.skin.title","pref:tweaks":"st.skin.tweaks","pref:background":"st.bg.title","pref:proseFont":"st.appearance.prose","pref:defaultAppendTiming":"st.communication.appendTimingTitle","pref:foldSteps":"st.transcript.foldSteps","pref:worktreeSkipConfirm":"st.composer.worktreeConfirm","config:default_model":"st.defaults.globalModelLabel","config:fast_model":"st.defaults.row.fast","config:subagent.default_model":"st.defaults.row.subagent","config:session_title.model":"st.defaults.row.title","config:default_permission_mode":"st.defaults.permissionMode","config:default_plan_mode":"st.defaults.planMode","config:thinking.effort":"st.profiles.effort","source:credentials":"st.spaces.group.credentials","source:instructions":"st.spaces.group.instructions","source:generic_roots":"st.spaces.group.generic_roots"};function Ir(e,n,t){const r=dt[e];return r===void 0?n:t(r)}function ft(e,n){const t=e.groups.find(r=>r.domain===n);if(t!==void 0)return{mode:t.mode,fixedCount:t.fixed_count,followCount:t.follow_count,stacked:n==="instructions"&&e.inherit.instructions==="stack"}}function Br(e,n,t){const r=ft(e,n);return r===void 0?t("st.spaces.origin.unknown"):n==="credentials"?t(e.inherit.credentials==="shared"?"st.spaces.group.shared":"st.spaces.group.isolated"):n===Cn?t(e.inherit.generic_roots?"st.spaces.group.available":"st.spaces.group.unavailable"):e.primary?t("st.spaces.group.items",{count:r.fixedCount}):r.mode==="follow"?r.stacked?t("st.spaces.group.stacked"):r.fixedCount===0?t("st.spaces.group.follow"):t("st.spaces.group.followFixed",{count:r.fixedCount}):r.followCount===0?t("st.spaces.group.fixed"):t("st.spaces.group.fixedFollow",{count:r.followCount})}function wr(e){const n=new Map([...lt,Cn].map((t,r)=>[t,r]));return e.items.filter(t=>t.kind!=="source"&&t.origin==="home").toSorted((t,r)=>(n.get(t.domain)??99)-(n.get(r.domain)??99)||t.name.localeCompare(r.name))}const pt={"pref:theme":"/settings/appearance","pref:skin":"/settings/appearance","pref:tweaks":"/settings/appearance","pref:background":"/settings/appearance","pref:proseFont":"/settings/appearance","pref:defaultAppendTiming":"/settings/general","pref:foldSteps":"/settings/general","pref:worktreeSkipConfirm":"/settings/general","config:default_model":"/settings/ai","config:fast_model":"/settings/ai","config:thinking.effort":"/settings/ai","config:session_title.model":"/settings/ai","config:default_permission_mode":"/settings/permissions"},kt=[["resource:agents:","/settings/agents"],["resource:skills:","/settings/skills"],["resource:mcp:","/settings/mcp"],["resource:plugins:","/settings/plugins"],["resource:appearance:","/settings/appearance"]];function _r(e){const n=pt[e];return n!==void 0?n:kt.find(([t])=>e.startsWith(t))?.[1]}function Ke(e,n=48){return e.length>n?`${e.slice(0,n-1)}…`:e}function mt(e){try{return Ke(JSON.stringify(e),72)}catch{return""}}function ht(e,n,t){if(e==="pref:background"&&n==null)return t("st.spaces.value.backgroundNone");if(e==="pref:theme"&&(n==="light"||n==="dark"||n==="system"))return t(`st.appearance.theme.${n}`);if(e==="pref:proseFont"&&(n==="serif"||n==="sans"))return t(`st.appearance.prose.${n}`);if(e==="pref:defaultAppendTiming"&&(n==="agent_idle"||n==="subagents_done"||n==="tasks_done"))return t(`st.spaces.value.appendTiming.${n}`);if(e==="pref:skin"&&typeof n=="object"&&n!==null){const r=n;if(typeof r.id!="string")return;const o=r.source==="pack"?"st.spaces.value.skinPack":r.source==="user"?"st.spaces.value.skinUser":"st.spaces.value.skinBuiltin";return t(o,{id:r.id})}if(e==="pref:tweaks"&&typeof n=="object"&&n!==null){const r=Object.keys(n).length;return r===0?t("st.spaces.value.tweaksNone"):t("st.spaces.value.tweaksCount",{count:r})}if(e==="pref:background"&&typeof n=="object"&&n!==null){const r=n,o=(r.linked===!1?r.dark:r.light)??r.light??r.dark;if(o==null||typeof o!="object")return t("st.spaces.value.backgroundNone");const i=o.media;if(!Array.isArray(i)||i.length===0)return t("st.spaces.value.backgroundNone");if(i.length>1)return t("st.spaces.value.backgroundCount",{count:i.length});const s=i[0],c=typeof s?.name=="string"&&s.name!==""?s.name:typeof s?.id=="string"?s.id.split("/").at(-1)??s.id:"";return c===""?t("st.spaces.value.backgroundCount",{count:i.length}):Ke(c,32)}}function Or(e,n,t){const r=ht(e,n,t);return r!==void 0?r:n==null?t("st.spaces.value.none"):typeof n=="boolean"?t(n?"st.spaces.value.on":"st.spaces.value.off"):typeof n=="string"?Ke(n):typeof n=="number"?String(n):Array.isArray(n)?t("st.spaces.group.items",{count:n.length}):mt(n)}function Pr(e){const n=[],t=[],r=[];for(const o of e.rows)o.id.startsWith("group:")?n.push(o):o.same_value?r.push(o):t.push(o);return{changed:t,same:r,groups:n}}function Mr(e){return e.blocked_reason===void 0}const gt=[["Resource content is unavailable","st.spaces.blocked.resourceUnavailable"],["Only resources can be excluded","st.spaces.blocked.onlyResources"],["This item cannot be shared through the ordinary push flow","st.spaces.blocked.notShareable"],["Edit this resource through its resource editor","st.spaces.blocked.editResource"],["Main space has no parent source","st.spaces.blocked.mainNoParent"]];function Nr(e,n){if(e.startsWith("Connection contains account data"))return n("st.spaces.blocked.accountData");const t=gt.find(([r])=>r===e);return t===void 0?e:n(t[1])}function v(e){return`${e.serverId}|${e.homeId}`}const Dn="kiki.spacePreferences.cache",Ze={entries:{},lastKnown:null,resolved:{}};function ue(){try{const e=localStorage.getItem(Dn);if(e===null)return Ze;const n=JSON.parse(e);return{entries:typeof n.entries=="object"&&n.entries!==null?n.entries:{},lastKnown:n.lastKnown??null,resolved:typeof n.resolved=="object"&&n.resolved!==null?n.resolved:{}}}catch{return Ze}}function In(e){try{localStorage.setItem(Dn,JSON.stringify(e))}catch{}}const L={identity:null,confirmed:null,authoritative:!1,drafts:{},writes:{},deviceConflict:!1,loaded:!1};let u=L,K=0,Ft=0,I=0,ye={},z={};const Ae=new Set;function g(e){return u.identity!==null&&v(u.identity)===v(e)}function de(){K+=1,ye={},z={}}function Bn(e){return Ae.add(e),()=>{Ae.delete(e)}}function wn(){return u}function Tr(){return L}function y(e){u=e;for(const n of Ae)n();vt()}function J(e,n,t=!0){const r=ue();In({...r,entries:{...r.entries,[v(e)]:n},lastKnown:t?{homeId:e.homeId,serverId:e.serverId,values:n}:r.lastKnown})}function Rr(e){return ue().resolved[v(e)]===!0}function Lr(e,n){const t=ue(),r=t.lastKnown?.homeId===e?t.lastKnown:null,o=n===void 0?r===null?null:{serverId:r.serverId,homeId:e}:{serverId:n,homeId:e};if(o===null||g(o)&&u.loaded)return;const i=n===void 0?r?.values??null:t.entries[v(o)]??null;g(o)||de(),y({...L,identity:o,confirmed:i})}function $r(e,n){const t=g(e);t||de(),J(e,n.preferences),y({...t?u:L,identity:e,confirmed:n.preferences,authoritative:n.preference_authority,loaded:!0})}function xr(){u!==L&&(de(),y(L))}function Hr(){u.deviceConflict||y({...u,deviceConflict:!0})}function Ur(e){const n=e??u.identity;if(n!==null){const t=ue();In({...t,resolved:{...t.resolved,[v(n)]:!0}})}n!==null&&g(n)&&u.deviceConflict&&y({...u,deviceConflict:!1})}function Ce(e){const n=u.drafts[e];return n!==void 0?n:u.confirmed===null?void 0:u.confirmed[e]}function te(){return u.confirmed!==null||Y!==void 0}let Y;const bt=new Set;function jr(e){Y=e}function vt(){for(const e of bt)e()}function ze(e,n,t,r=[]){if(!g(e)||u.confirmed===null)return n;const o={...n.preferences};for(const s of Object.keys(ne))((z[s]??0)>t||r.includes(s))&&Object.assign(o,{[s]:u.confirmed[s]});const i=Object.values(z).some(s=>s>t);return{...n,preferences:o,preference_authority:i?u.authoritative:n.preference_authority}}async function Kr(e,n){const t=I,r=await je(e).detail(n.homeId);return ze(n,r,t)}async function De(e,n){const t=Y,r=t?.client()??null,o=t?.identity()??null;return t===void 0||r===null||o===null||t.spaceId()!==o.homeId?!1:St(r,o,{[e]:n})}async function St(e,n,t){if(!g(n))return!1;const r=Object.keys(ne).filter(l=>t[l]!==void 0);if(r.length===0)return!1;const o=Y,i=K,s=I,c=++Ft,d={...u.drafts},f={...u.writes};for(const l of r)ye[l]=c,d[l]=t[l],f[l]={state:"saving"};y({...u,drafts:d,writes:f});const h=()=>K===i&&g(n),S=()=>r.filter(l=>ye[l]===c);try{const l=je(e),a=r.map(k=>({id:ne[k],value:t[k]})),P=await l.preview(n.homeId,{action:"edit",changes:a});for(const k of a){const me=P.rows.find(Wn=>Wn.id===k.id);if(me===void 0||me.blocked_reason!==void 0)throw new Error(me?.blocked_reason??`The server returned no plan for ${k.id}`)}const q=await l.apply(n.homeId,{token:P.token,selected:a.map(k=>k.id)});if(!h())return g(n)||J(n,q.detail.preferences,!1),!0;const pe=S();if(pe.length===0)return!0;const X=ze(n,q.detail,s,r.filter(k=>!pe.includes(k))),Ye={...u.drafts},qe={...u.writes};I+=1;for(const k of pe)z[k]=I,delete Ye[k],delete qe[k];J(n,X.preferences),y({...u,confirmed:X.preferences,authoritative:X.preference_authority,loaded:!0,drafts:Ye,writes:qe});const ke=o?.identity();return h()&&ke!==null&&ke!==void 0&&v(ke)===v(n)&&o?.onDetail?.(X),!0}catch(l){if(h()){const a={...u.writes};for(const P of S())a[P]={state:"error",error:l};S().length>0&&y({...u,writes:a})}return!1}}async function zr(e,n,t,r){const o=K,i=I,s=Y;try{const c=await je(e).importPreferences(n.homeId,{values:r,device_id:t});if(K!==o||u.identity!==null&&!g(n))return g(n)||J(n,c.detail.preferences,!1),{imported:c.imported,conflict:c.device_conflict};const d=ze(n,c.detail,i);u.identity===null&&de(),I+=1;for(const h of Object.keys(ne))z[h]=I;J(n,d.preferences),y({...u,identity:n,confirmed:d.preferences,authoritative:d.preference_authority,deviceConflict:c.device_conflict,loaded:!0});const f=s?.identity();return g(n)&&f!==null&&f!==void 0&&v(f)===v(n)&&s?.onDetail?.(d),{imported:c.imported,conflict:c.device_conflict}}catch{return null}}function Jr(){const e="kiki.deviceId";try{const n=localStorage.getItem(e);if(n!==null&&n!=="")return n;const t=globalThis.crypto?.randomUUID?.()??`device-${Date.now().toString(36)}`;return localStorage.setItem(e,t),t}catch{return"device-unknown"}}const V={light:null,dark:null,linked:!0,assist:!0},Ie="kiki.background";function F(e,n,t,r){return typeof e=="number"&&Number.isFinite(e)?Math.min(t,Math.max(n,e)):r}function he(e,n,t){return typeof e=="string"&&n.includes(e)?e:t}function _n(e){const n=typeof e=="object"&&e!==null?e:{},t=qn;return{fit:he(n.fit,Zn,t.fit),alignment:he(n.alignment,Qn,t.alignment),opacity:F(n.opacity,0,1,t.opacity),blur:F(n.blur,0,40,t.blur),brightness:F(n.brightness,.4,1.4,t.brightness),scrim:F(n.scrim,0,.9,t.scrim),scope:he(n.scope,Xn,t.scope),surfaceOpacity:F(n.surfaceOpacity,.3,1,t.surfaceOpacity),surfaceBlur:F(n.surfaceBlur,0,32,t.surfaceBlur)}}function en(e){if(typeof e!="object"||e===null)return null;const n=e;return typeof n.id!="string"||!/^(?:local-[\w-]{1,80}|pack:[a-z0-9][a-z0-9-]{0,63}\/[A-Za-z0-9][A-Za-z0-9._-]{0,99})$/.test(n.id)||n.kind!=="image"&&n.kind!=="video"||typeof n.mime!="string"||!/^(image|video)\/[\w.+-]+$/.test(n.mime)?null:{id:n.id,kind:n.kind,mime:n.mime,name:typeof n.name=="string"?n.name.slice(0,200):n.id,bytes:F(n.bytes,0,Number.MAX_SAFE_INTEGER,0)}}function Et(e){if(typeof e!="object"||e===null)return;const n=e;if(!(typeof n.dark!="number"||typeof n.light!="number"))return{dark:F(n.dark,0,1,0),light:F(n.light,0,1,1)}}function nn(e){if(typeof e!="object"||e===null)return null;const n=e,t=(Array.isArray(n.media)?n.media:[]).map(en).filter(o=>o!==null).slice(0,12);if(t.length===0)return null;const r=en(n.poster)??void 0;return{media:t,poster:r,interval:F(n.interval,0,3600,0),look:_n(n.look),packId:typeof n.packId=="string"&&/^[a-z0-9][a-z0-9-]{0,63}$/.test(n.packId)?n.packId:void 0,sample:Et(n.sample)}}function Je(e){if(typeof e!="object"||e===null)return V;const n=e;return{light:nn(n.light),dark:nn(n.dark),linked:n.linked!==!1,assist:n.assist!==!1}}const G=new Set;let B;function On(){try{const e=b.getItem(Ie);return e===null?V:Je(JSON.parse(e))}catch{return V}}function Vr(e){return G.add(e),()=>{G.delete(e)}}function Gr(){return On()}function tn(e){return{id:e.id,kind:e.kind,mime:e.mime,name:e.name,bytes:e.bytes}}function re(e){return e===null?null:{media:e.media.map(tn),...e.poster===void 0?{}:{poster:tn(e.poster)},interval:e.interval,look:e.look,...e.packId===void 0?{}:{packId:e.packId},...e.sample===void 0?{}:{sample:e.sample}}}function M(e){return e===null?!0:[...e.media,...e.poster===void 0?[]:[e.poster]].every(n=>n.id.startsWith("pack:"))}function Wr(e){if(!(!M(e.light)||!M(e.dark)))return{light:re(e.light),dark:re(e.dark),linked:e.linked,assist:e.assist}}function yt(){const e=Ce("background");if(e!==void 0)return Je(e)}let rn,on,sn=!1;function At(){const e=wn();return(!sn||rn!==e)&&(rn=e,on=yt(),sn=!0),on}let Be=!1;function Yr(){return Be}function an(e){if(Be!==e){Be=e;for(const n of G)n()}}function Ve(){const e=At();return e!==void 0?(B=e,e):(B??=On(),B)}function qr(){return V}function Ct(e){const n=Je({...e,assist:e.assist??Ve().assist});if(te()&&M(n.light)&&M(n.dark)){an(!1),De("background",{light:re(n.light),dark:re(n.dark),linked:n.linked,assist:n.assist});return}an(te()&&!(M(n.light)&&M(n.dark)));try{n.light===null&&n.dark===null&&n.linked&&n.assist?b.removeItem(Ie):b.setItem(Ie,JSON.stringify(n))}catch{}JSON.stringify(n)!==JSON.stringify(B)&&(B=n);for(const t of G)t()}Bn(()=>{B=void 0;for(const e of G)e()});function Xr(){return Ve()}function Qr(){B=void 0}function Zr(e,n){return e.linked?e.light??e.dark:e[n]}function eo(e,n){return e.linked?"light":n}function ge(e){const n=e.trim().replace("#",""),t=n.length===3?n.split("").map(r=>`${r}${r}`).join(""):n;return/^[0-9a-fA-F]{6}$/.test(t)?[0,2,4].map(r=>Number.parseInt(t.slice(r,r+2),16)/255):null}const Fe=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4,Dt=e=>e<=.0031308?e*12.92:1.055*e**(1/2.4)-.055;function we(e){return .2126*Fe(e[0])+.7152*Fe(e[1])+.0722*Fe(e[2])}function It(e,n){const[t,r]=e>n?[e,n]:[n,e];return(t+.05)/(r+.05)}function cn(e,n,t){return[0,1,2].map(r=>e[r]*t+n[r]*(1-t))}function Bt(e){const n=Dt(Math.min(1,Math.max(0,e)));return[n,n,n]}const wt=4.5,_t=.15;function Ot(e,n,t,r){const o=ge(e.surface),i=ge(e.ground),s=e.texts.map(ge).filter(l=>l!==null);if(o===null||i===null||s.length===0)return 1;const c=n.opacity*(1-n.scrim),d=[t?.dark??0,t?.light??1].map(l=>{const a=Bt(Math.min(1,l*n.brightness));return cn(a,i,c)}),f=l=>d.every(a=>{const P=we(cn(o,a,l));return s.every(q=>It(we(q),P)>=wt+_t)});if(f(r))return r;let h=r,S=1;for(let l=0;l<16;l+=1){const a=(h+S)/2;f(a)?S=a:h=a}return Math.min(1,Math.ceil(S*100)/100)}function Pt(e){const n=[];for(let r=0;r+3<e.length;r+=4)e[r+3]<16||n.push(we([e[r]/255,e[r+1]/255,e[r+2]/255]));if(n.length===0)return{dark:0,light:1};n.sort((r,o)=>r-o);const t=r=>n[Math.min(n.length-1,Math.floor(r*n.length))];return{dark:t(.05),light:t(.95)}}const Mt={center:"center",top:"center top",bottom:"center bottom",left:"left center",right:"right center",topLeft:"left top",topRight:"right top",bottomLeft:"left bottom",bottomRight:"right bottom"};function ln(e){return Mt[e]}const Pn="paper",Nt=new Set(["linen","graphite","forest","claret","heather","nocturne","sand","slate"]),_e="'Instrument Sans Variable', 'Instrument Sans', ui-sans-serif, system-ui, 'Segoe UI', 'PingFang SC', 'Noto Sans SC', sans-serif",un=_e,Tt=[{kind:"kiki-skin",version:1,id:Pn,name:"纸色 Paper × 墨砚 Inkstone",description:"Warm white paper and ink-blue marks; cool charcoal and copper after dark.",variants:{light:{colors:{canvas:"#F2EFE8",paper:"#FBFAF6",panel:"#FFFDFA",hairline:"#E4DDD0",hairlineStrong:"#CDC3B1",ink:"#1B1A17",inkSoft:"#4B453E",inkFaint:"#665E54",accent:"#C8401A",accentDeep:"#9C3012",accentSoft:"#F8E3D8",accentInk:"#9C3012",onAccent:"#FFFFFF",sectionInk:"#4B453E",selected:"#DFE8F0",selectedInk:"#1D4D6D",attention:"#B33A12",attentionSoft:"#FAE3D7",amberInk:"#87480B",amberCard:"#F8EEDD",amberRule:"#D9A441",success:"#2F6B45",danger:"#B0261E",onDanger:"#FFFFFF",bubbleUser:"#EEE8DC",scrollbar:"#D8D0C1",scrollbarHover:"#C4BAA8",termScrollbar:"#4A4238",shell:"#1F1B16",shellInk:"#E8DCC4",shellInkStrong:"#F3E9D8",shellInkSoft:"#9B8E7A",shellDanger:"#D9A08A",shellHairline:"#332D24",shellHover:"#2A251D",shadowInk:"#1B1A17"}},dark:{colors:{canvas:"#13191C",paper:"#1B2226",panel:"#252D31",hairline:"#354047",hairlineStrong:"#596870",ink:"#EEEAE2",inkSoft:"#C1C5C5",inkFaint:"#A2ACAF",accent:"#EB946F",accentDeep:"#F4B08F",accentSoft:"#382A25",accentInk:"#F4AE8D",onAccent:"#261A14",sectionInk:"#C1C5C5",selected:"#24323B",selectedInk:"#A3CBDE",attention:"#F4AE8D",attentionSoft:"#382A25",amberInk:"#E6BD78",amberCard:"#322B20",amberRule:"#96783F",success:"#9AC6AE",danger:"#F1A29A",onDanger:"#301414",bubbleUser:"#293238",scrollbar:"#4F5F68",scrollbarHover:"#74838C",termScrollbar:"#526068",shell:"#101518",shellInk:"#D1D9DA",shellInkStrong:"#F0F2EF",shellInkSoft:"#9AA7AB",shellDanger:"#F1A29A",shellHairline:"#354047",shellHover:"#202B30",shadowInk:"#000000"}}}},{kind:"kiki-skin",version:1,id:"porcelain",name:"瓷白 Porcelain × 深海 Deepwater",description:"Cool white paper and cobalt details; layered navy and mist-blue controls at night.",variants:{light:{colors:{canvas:"#E7EDF4",paper:"#F8FBFF",panel:"#FFFFFF",hairline:"#D2DDE9",hairlineStrong:"#A9B9CA",ink:"#17283D",inkSoft:"#405570",inkFaint:"#516279",accent:"#2856A6",accentDeep:"#1B3F84",accentSoft:"#E2EBFA",accentInk:"#204986",onAccent:"#FFFFFF",sectionInk:"#405570",selected:"#DEE8F7",selectedInk:"#204986",attention:"#9C461C",attentionSoft:"#F9E8DC",amberInk:"#7E520D",amberCard:"#F8EED9",amberRule:"#B58A3B",success:"#28664B",danger:"#AF343E",onDanger:"#FFFFFF",bubbleUser:"#E6EDF6",scrollbar:"#B6C5D6",scrollbarHover:"#8B9FB5",termScrollbar:"#52657C",shell:"#142033",shellInk:"#D8E3F1",shellInkStrong:"#F2F7FF",shellInkSoft:"#9CACC2",shellDanger:"#F1A6AB",shellHairline:"#35475E",shellHover:"#24354C",shadowInk:"#132237"}},dark:{colors:{canvas:"#0D1624",paper:"#152238",panel:"#1E304A",hairline:"#304761",hairlineStrong:"#586E88",ink:"#E4EDF9",inkSoft:"#B8C9E0",inkFaint:"#98B0CB",accent:"#9DAEF5",accentDeep:"#BAC8FF",accentSoft:"#283653",accentInk:"#BAC8FF",onAccent:"#17203C",sectionInk:"#B8C9E0",selected:"#293A55",selectedInk:"#BAD1F5",attention:"#F1C28C",attentionSoft:"#362D26",amberInk:"#E9C474",amberCard:"#332D20",amberRule:"#927A46",success:"#99D0B5",danger:"#F2A4AE",onDanger:"#351724",bubbleUser:"#223551",scrollbar:"#455F7E",scrollbarHover:"#6D88A8",termScrollbar:"#4D627C",shell:"#090F1A",shellInk:"#CFDDF0",shellInkStrong:"#EDF4FF",shellInkSoft:"#98ADC8",shellDanger:"#F2A4AE",shellHairline:"#283B53",shellHover:"#17273D",shadowInk:"#000000"}}}},{kind:"kiki-skin",version:1,id:"celadon",name:"青瓷 Celadon × 夜园 Night Garden",description:"Celadon glaze and soft white paper; deep pine surfaces and jade details at night.",variants:{light:{colors:{canvas:"#DDE7DE",paper:"#F2F7EF",panel:"#FCFEF9",hairline:"#C8D8CB",hairlineStrong:"#9DB6A7",ink:"#21382F",inkSoft:"#435D50",inkFaint:"#4D6253",accent:"#24675F",accentDeep:"#174F4A",accentSoft:"#DCECE6",accentInk:"#1E5650",onAccent:"#FFFFFF",sectionInk:"#435D50",selected:"#D7E9DE",selectedInk:"#20594D",attention:"#984B21",attentionSoft:"#F5E7DA",amberInk:"#79520D",amberCard:"#F6EED5",amberRule:"#A1843C",success:"#3E642A",danger:"#A9363C",onDanger:"#FFFFFF",bubbleUser:"#E2ECDD",scrollbar:"#AEC3B1",scrollbarHover:"#839E8B",termScrollbar:"#526A5D",shell:"#14251E",shellInk:"#DDE8DB",shellInkStrong:"#F4F9ED",shellInkSoft:"#9CAC9F",shellDanger:"#F0A8A5",shellHairline:"#364D3F",shellHover:"#253A2F",shadowInk:"#172A23"}},dark:{colors:{canvas:"#111C1A",paper:"#1A2925",panel:"#243830",hairline:"#354E43",hairlineStrong:"#597968",ink:"#E5EEE3",inkSoft:"#BDCEC1",inkFaint:"#9DB4A4",accent:"#8FCBB8",accentDeep:"#ACDCCD",accentSoft:"#283F36",accentInk:"#ACDCCD",onAccent:"#122C23",sectionInk:"#BDCEC1",selected:"#2A4036",selectedInk:"#B4DCC2",attention:"#E8BD86",attentionSoft:"#3B3023",amberInk:"#E2C47E",amberCard:"#34311E",amberRule:"#8C824A",success:"#C0D58F",danger:"#F0AAA4",onDanger:"#351915",bubbleUser:"#2B3E33",scrollbar:"#4E6C5B",scrollbarHover:"#799A85",termScrollbar:"#526B5D",shell:"#0C1512",shellInk:"#D2E1D4",shellInkStrong:"#F0F6EA",shellInkSoft:"#9FB5A6",shellDanger:"#F0AAA4",shellHairline:"#2D493A",shellHover:"#1D3026",shadowInk:"#000000"}}}},{kind:"kiki-skin",version:1,id:"apricot",name:"杏云 Apricot × 晚霞 Afterglow",description:"Apricot-white paper and berry controls; plum-charcoal layers and peach light after dark.",variants:{light:{colors:{canvas:"#F4DED5",paper:"#FFF3EB",panel:"#FFFAF5",hairline:"#DFC7C0",hairlineStrong:"#B698A0",ink:"#382C38",inkSoft:"#604F5C",inkFaint:"#6B5563",accent:"#A13B55",accentDeep:"#822C46",accentSoft:"#F9DFE4",accentInk:"#822C46",onAccent:"#FFFFFF",sectionInk:"#604F5C",selected:"#F2DEE2",selectedInk:"#7D3553",attention:"#934018",attentionSoft:"#FAE2CF",amberInk:"#794C0B",amberCard:"#F8EBD0",amberRule:"#B38A42",success:"#3E674E",danger:"#AF263C",onDanger:"#FFFFFF",bubbleUser:"#F7E3DB",scrollbar:"#CDB0B1",scrollbarHover:"#AC8C96",termScrollbar:"#68576A",shell:"#251D29",shellInk:"#EADDE8",shellInkStrong:"#FFF3F0",shellInkSoft:"#B7A3B6",shellDanger:"#F0A3AD",shellHairline:"#4B3B4C",shellHover:"#382C3A",shadowInk:"#372635"}},dark:{colors:{canvas:"#201A22",paper:"#2C2430",panel:"#3A303E",hairline:"#51404F",hairlineStrong:"#816477",ink:"#F4E9E7",inkSoft:"#D8C2CD",inkFaint:"#C1A9B8",accent:"#F4B29C",accentDeep:"#FFCCB6",accentSoft:"#49323C",accentInk:"#FFCCB6",onAccent:"#351D22",sectionInk:"#D8C2CD",selected:"#443440",selectedInk:"#F3BED0",attention:"#F5C27F",attentionSoft:"#493824",amberInk:"#EDCE8E",amberCard:"#413821",amberRule:"#A48C50",success:"#AFD4B0",danger:"#F8ABB8",onDanger:"#381A29",bubbleUser:"#41323D",scrollbar:"#705768",scrollbarHover:"#9C7F90",termScrollbar:"#705B71",shell:"#17131D",shellInk:"#E5D6E3",shellInkStrong:"#F9EDF1",shellInkSoft:"#BAA3BC",shellDanger:"#F8ABB8",shellHairline:"#46384D",shellHover:"#302638",shadowInk:"#000000"}}}},{kind:"kiki-skin",version:1,id:"iris",name:"鸢尾 Iris × 星幕 Starveil",description:"Violet-white paper and iris ink; indigo-violet layers and silver-lilac controls at night.",variants:{light:{colors:{canvas:"#E7E3F2",paper:"#F6F3FC",panel:"#FCFAFF",hairline:"#D5CEE5",hairlineStrong:"#A99BBF",ink:"#302B48",inkSoft:"#514964",inkFaint:"#615775",accent:"#6542A5",accentDeep:"#4D2F86",accentSoft:"#EAE1F7",accentInk:"#53318B",onAccent:"#FFFFFF",sectionInk:"#514964",selected:"#E7DEF4",selectedInk:"#593793",attention:"#98491B",attentionSoft:"#F7E5D5",amberInk:"#78500B",amberCard:"#F7ECCF",amberRule:"#AE8E45",success:"#306448",danger:"#B1294E",onDanger:"#FFFFFF",bubbleUser:"#ECE6F6",scrollbar:"#BEB1D5",scrollbarHover:"#9985BA",termScrollbar:"#595179",shell:"#211D34",shellInk:"#DED9F0",shellInkStrong:"#F5F0FF",shellInkSoft:"#AAA0C5",shellDanger:"#F0A5BF",shellHairline:"#413857",shellHover:"#312A49",shadowInk:"#29203F"}},dark:{colors:{canvas:"#171626",paper:"#232137",panel:"#312F4A",hairline:"#44405F",hairlineStrong:"#71668F",ink:"#EEECFA",inkSoft:"#CAC3E2",inkFaint:"#ADA4C7",accent:"#C5ADF6",accentDeep:"#DECCFF",accentSoft:"#3D305B",accentInk:"#DECCFF",onAccent:"#27183F",sectionInk:"#CAC3E2",selected:"#35304F",selectedInk:"#D4C6F7",attention:"#F1BE86",attentionSoft:"#413226",amberInk:"#E8CC87",amberCard:"#3C3422",amberRule:"#9E884C",success:"#A5D6BA",danger:"#F3A6C2",onDanger:"#34182A",bubbleUser:"#36304D",scrollbar:"#63577E",scrollbarHover:"#9180B2",termScrollbar:"#615577",shell:"#100F1B",shellInk:"#D8D1EF",shellInkStrong:"#F3EFFF",shellInkSoft:"#ABA0C9",shellDanger:"#F3A6C2",shellHairline:"#39304E",shellHover:"#272238",shadowInk:"#000000"}}}},{kind:"kiki-skin",version:1,id:"contrast",name:"高对比 High contrast × 高对比·黑曜 Obsidian",description:"White paper, black text and visible borders; layered charcoal, ice-cyan focus and near-white controls at night.",variants:{light:{colors:{canvas:"#E7E9EC",paper:"#FFFFFF",panel:"#FFFFFF",hairline:"#6E7781",hairlineStrong:"#20252C",ink:"#0E1116",inkSoft:"#20252C",inkFaint:"#353B44",accent:"#0349B4",accentDeep:"#023787",accentSoft:"#DBE7FB",accentInk:"#023B95",onAccent:"#FFFFFF",sectionInk:"#0E1116",selected:"#DBE7FB",selectedInk:"#023B95",attention:"#A2280A",attentionSoft:"#FDE3D9",amberInk:"#6B3D00",amberCard:"#FDF0CF",amberRule:"#8A5A00",success:"#055D20",danger:"#A0111F",onDanger:"#FFFFFF",bubbleUser:"#F3F3F3",scrollbar:"#C9CBCE",scrollbarHover:"#B3B5B9",termScrollbar:"#4D4F53",shell:"#0E1116",shellInk:"#D4D4D5",shellInkStrong:"#F1F1F1",shellInkSoft:"#939698",shellDanger:"#F0A39C",shellHairline:"#303237",shellHover:"#212429",shadowInk:"#0A0C0F"},fonts:{display:un,sans:_e},shape:{radius:8}},dark:{colors:{canvas:"#101214",paper:"#1C2024",panel:"#2A3036",hairline:"#8A949E",hairlineStrong:"#C5CDD5",ink:"#F7F9FB",inkSoft:"#E1E6EB",inkFaint:"#C2CBD3",accent:"#E7EDF4",accentDeep:"#FFFFFF",accentSoft:"#303840",accentInk:"#F4F7FA",onAccent:"#11171C",sectionInk:"#F7F9FB",selected:"#303840",selectedInk:"#8DE3F0",attention:"#FFD080",attentionSoft:"#30343A",amberInk:"#F5D58C",amberCard:"#30343A",amberRule:"#BAA276",success:"#A4E0B2",danger:"#FFADB8",onDanger:"#241318",bubbleUser:"#30363C",scrollbar:"#8A949E",scrollbarHover:"#C5CDD5",termScrollbar:"#89939D",shell:"#0C0F12",shellInk:"#E1E6EB",shellInkStrong:"#F7F9FB",shellInkSoft:"#BBC6D0",shellDanger:"#FFADB8",shellHairline:"#89939D",shellHover:"#22282E",shadowInk:"#000000"},fonts:{display:un,sans:_e},shape:{radius:8}}}}];function Mn(e){return Tt.find(n=>n.id===e)}const dn={paper:"st.skin.desc.paperPair",porcelain:"st.skin.desc.porcelain",celadon:"st.skin.desc.celadon",apricot:"st.skin.desc.apricot",iris:"st.skin.desc.iris",contrast:"st.skin.desc.contrastPair"},fn={paper:"st.skin.name.paper",porcelain:"st.skin.name.porcelain",celadon:"st.skin.name.celadon",apricot:"st.skin.name.apricot",iris:"st.skin.name.iris",contrast:"st.skin.name.contrast"};function no(e){return e!==void 0&&Object.hasOwn(dn,e)?dn[e]:void 0}function to(e){return e!==void 0&&Object.hasOwn(fn,e)?fn[e]:void 0}const Rt=/^[a-z0-9][a-z0-9-]{0,63}$|^[a-z0-9][a-z0-9_-]{0,63}:[a-z0-9][a-z0-9-]{0,63}$/,_={selection:{source:"builtin",id:Pn},tweaks:{}},Nn="kiki.skin",Lt=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,be=/^[\p{L}\p{N}\u4e00-\u9fff '",\-_. ]{1,200}$/u;function Ge(e){if(typeof e!="object"||e===null)return _;const n=e,t=n.selection,r=typeof t?.id=="string"&&Rt.test(t.id)&&(t.source==="builtin"||t.source==="user"||t.source==="pack")?{source:t.source,id:t.id}:_.selection,o=n.tweaks??{},i={...typeof o.accent=="string"&&Lt.test(o.accent)?{accent:o.accent}:{},...typeof o.fontSans=="string"&&be.test(o.fontSans)?{fontSans:o.fontSans}:{},...typeof o.fontMono=="string"&&be.test(o.fontMono)?{fontMono:o.fontMono}:{},...typeof o.fontProse=="string"&&be.test(o.fontProse)?{fontProse:o.fontProse}:{},...typeof o.radius=="number"&&o.radius>=0&&o.radius<=28?{radius:o.radius}:{},...typeof o.spacing=="number"&&o.spacing>=.19&&o.spacing<=.33?{spacing:o.spacing}:{}};return{selection:$t(r),tweaks:i}}function $t(e){return e.source==="builtin"&&Nt.has(e.id)?_.selection:e}function xt(){try{const e=b.getItem(Nn);return e===null?_:Ge(JSON.parse(e))}catch{return _}}const oe=.25;function Tn(e){const n=Ge(e),t=e.tweaks.spacing;return t===void 0||!Number.isFinite(t)||t<.5*oe||t>2*oe?n:{...n,tweaks:{...n.tweaks,spacing:t}}}function Ht(e){return{...e.accent===void 0?{}:{accent:e.accent},...e.fontSans===void 0?{}:{fontSans:e.fontSans},...e.fontMono===void 0?{}:{fontMono:e.fontMono},...e.fontProse===void 0?{}:{fontProse:e.fontProse},...e.radius===void 0?{}:{radius:e.radius},...e.spacing===void 0?{}:{spacing:e.spacing*oe}}}function Ut(e){return{...e.accent===void 0?{}:{accent:e.accent},...e.fontSans===void 0?{}:{fontSans:e.fontSans},...e.fontMono===void 0?{}:{fontMono:e.fontMono},...e.fontProse===void 0?{}:{fontProse:e.fontProse},...e.radius===void 0?{}:{radius:e.radius},...e.spacing===void 0?{}:{spacing:Number((e.spacing/oe).toFixed(4))}}}function jt(){const e=Ce("skin");if(e!==void 0)return Tn({selection:e,tweaks:Ht(Ce("tweaks")??{})})}let pn,kn,mn=!1;function Kt(){const e=wn();return(!mn||pn!==e)&&(pn=e,kn=jt(),mn=!0),kn}const Oe=new Set;let T;function ro(e){return Oe.add(e),()=>{Oe.delete(e)}}function We(){const e=Kt();return e!==void 0?(T=e,e):(T??=xt(),T)}function oo(){return _}function $(){for(const e of Oe)e()}function zt(e){if(JSON.stringify(e)===JSON.stringify(T)){$();return}T=e,$()}function Jt(e){const n={...We(),...e},t=te()?Tn(n):Ge(n);if(te()){De("skin",t.selection),e.tweaks!==void 0&&De("tweaks",Ut(t.tweaks));return}try{b.setItem(Nn,JSON.stringify(t))}catch{}zt(t)}Bn(()=>{T=void 0,$()});let ie=null;function io(e){const n=JSON.stringify(e)!==JSON.stringify(ie);ie=e,n&&$()}function so(){return ie}function Vt(){return ie??We()}const Pe="kiki.skin.cache";function Gt(){try{const e=b.getItem(Pe);return e===null?null:yn(JSON.parse(e)).skin}catch{return null}}function Rn(e){try{e===null?b.removeItem(Pe):b.setItem(Pe,JSON.stringify(e))}catch{}}let se=[],Me=null,H=null,ae=!1;function ao(e,n){const t=n!==Me||JSON.stringify(e)!==JSON.stringify(se);se=e,Me=n;const r=Vt().selection;if(r.source==="user"){const o=e.find(i=>i.id===r.id)??null;H=o,ae=!0,Rn(o)}t&&$()}function co(){return se}function lo(){return Me}let Ne=Wt();const Ln="kiki.skin.packCache";function Wt(){try{const e=b.getItem(Ln);if(e===null)return[];const n=JSON.parse(e);return Array.isArray(n)?n.map(t=>yn(t).skin).filter(t=>t!==null):[]}catch{return[]}}function uo(e){if(JSON.stringify(e)!==JSON.stringify(Ne)){Ne=e;try{b.setItem(Ln,JSON.stringify(e))}catch{}$()}}function fo(){H=null,ae=!1,Rn(null)}function Yt(e){if(e.source==="builtin")return Mn(e.id)??null;if(e.source==="pack")return Ne.find(t=>t.id===e.id)??null;const n=se.find(t=>t.id===e.id);return n!==void 0?n:(ae||(H=Gt(),ae=!0),H?.id===e.id?H:null)}function po(e){if(typeof document>"u")return;const n=document.documentElement;n.dataset.kikiMotion=e.motion,n.dataset.kikiProse=e.proseFont}const Q={theme:"system",motion:"system",proseFont:"serif",skin:_,background:V};function ko(){const e=et();return{theme:e.theme,motion:e.motion,proseFont:e.proseFont,skin:We(),background:Ve()}}function mo(e){return e.motion===Q.motion&&e.proseFont===Q.proseFont&&JSON.stringify(e.skin)===JSON.stringify(Q.skin)&&e.background.light===null&&e.background.dark===null}function ho(e){return{...Q,theme:e.theme}}function go(e){nt({theme:e.theme,motion:e.motion,proseFont:e.proseFont}),Jt(e.skin),Ct(e.background)}const Z={canvas:["--color-canvas"],paper:["--color-paper","--color-muted","--color-sidebar"],panel:["--color-panel","--color-background"],hairline:["--color-hairline","--color-border","--color-input"],hairlineStrong:["--color-hairline-strong"],ink:["--color-ink","--color-foreground"],inkSoft:["--color-ink-soft","--color-muted-foreground"],inkFaint:["--color-ink-faint"],accent:["--color-accent","--color-primary"],accentDeep:["--color-accent-deep"],accentSoft:["--color-accent-soft"],accentInk:["--color-accent-ink"],onAccent:["--color-on-accent","--color-primary-foreground"],sectionInk:["--color-section-ink"],selected:["--color-selected"],selectedInk:["--color-selected-ink"],attention:["--color-attention"],attentionSoft:["--color-attention-soft"],amberInk:["--color-amber-ink"],amberCard:["--color-amber-card"],amberRule:["--color-amber-rule"],success:["--color-success"],danger:["--color-danger"],onDanger:["--color-on-danger"],bubbleUser:["--color-bubble-user"],scrollbar:["--color-scrollbar"],scrollbarHover:["--color-scrollbar-hover"],termScrollbar:["--color-term-scrollbar"],shell:["--color-shell"],shellInk:["--color-shell-ink"],shellInkStrong:["--color-shell-ink-strong"],shellInkSoft:["--color-shell-ink-soft"],shellDanger:["--color-shell-danger"],shellHairline:["--color-shell-hairline"],shellHover:["--color-shell-hover"],shadowInk:[]},$n={display:["--font-display"],sans:["--font-sans"],mono:["--font-mono"]};function qt(e){const n=e.replace("#",""),t=n.length===3?n.split("").map(o=>`${o}${o}`).join(""):n;return/^[0-9a-fA-F]{6}$/.test(t)?[0,2,4].map(o=>Number.parseInt(t.slice(o,o+2),16)).join(" "):null}function Fo(e,n){return e.variants[n]??null}function Xt(e){const n=[];return e.variants.light!==void 0&&n.push("light"),e.variants.dark!==void 0&&n.push("dark"),n}const hn="color-mix(in oklab, var(--color-accent) 72%, var(--color-ink))",Qt={sectionInk:"var(--color-ink-soft)",selected:"color-mix(in oklab, var(--color-accent) 12%, var(--color-panel))",selectedInk:"var(--color-accent-ink)",attention:"var(--color-accent-ink)",attentionSoft:"var(--color-accent-soft)"};function bo(e,n={}){const t={};for(const[o,i]of Object.entries(e?.colors??{}))if(typeof i=="string"){if(o==="shadowInk"){const s=qt(i);s!==null&&(t["--kiki-shadow-ink"]=s);continue}for(const s of Z[o]??[])t[s]=i}for(const[o,i]of Object.entries(e?.fonts??{}))if(typeof i=="string")for(const s of $n[o]??[])t[s]=i;if(e?.colors?.accent!==void 0&&e.colors.accentInk===void 0&&(t["--color-accent-ink"]=hn),e?.colors!==void 0&&Object.keys(e.colors).length>0){for(const[o,i]of Object.entries(Qt))if(e.colors[o]===void 0)for(const s of Z[o])t[s]=i}const r=e?.shape;if(r?.radius!==void 0&&(t["--kiki-sheet-radius"]=`${r.radius}px`),r?.stageGap!==void 0&&(t["--kiki-stage-gap"]=`${r.stageGap}px`),r?.spacing!==void 0&&(t["--spacing"]=`${r.spacing}rem`),n.accent!==void 0){for(const o of Z.accent)t[o]=n.accent;t["--color-accent-deep"]=`color-mix(in oklab, ${n.accent} 78%, black)`,t["--color-accent-soft"]=`color-mix(in oklab, ${n.accent} 14%, var(--color-panel))`,t["--color-accent-ink"]=hn}return n.fontSans!==void 0&&(t["--font-sans"]=n.fontSans),n.fontMono!==void 0&&(t["--font-mono"]=n.fontMono),n.fontProse!==void 0&&(t["--kiki-prose-user"]=n.fontProse),n.radius!==void 0&&(t["--kiki-sheet-radius"]=`${n.radius}px`),n.spacing!==void 0&&(t["--spacing"]=`${n.spacing}rem`),t}function Zt(){return[...Object.values(Z).flat(),...Object.values($n).flat(),"--kiki-shadow-ink","--kiki-prose-user","--kiki-sheet-radius","--kiki-stage-gap","--spacing","--color-accent-deep","--color-accent-soft","--color-accent-ink"]}function vo(e,n){for(const t of Zt())e.style.removeProperty(t);for(const[t,r]of Object.entries(n))e.style.setProperty(t,r)}const E=new Map,er=8;function nr(){if(typeof window>"u")return 2560;const e=Math.min(2,window.devicePixelRatio||1),n=Math.max(window.screen?.width??0,window.screen?.height??0,window.innerWidth,window.innerHeight);return Math.min(3840,Math.max(1920,Math.ceil(n*e)))}const tr=320;function rr(){return typeof createImageBitmap=="function"&&typeof OffscreenCanvas<"u"}async function or(e,n){if(!e.type.startsWith("image/")||e.type==="image/gif"||!rr())return e;let t,r;try{t=await createImageBitmap(e);const o=Math.max(t.width,t.height);if(o<=n)return e;const i=n/o,s=Math.max(1,Math.round(t.width*i)),c=Math.max(1,Math.round(t.height*i));r=await createImageBitmap(t,{resizeWidth:s,resizeHeight:c,resizeQuality:"high"});const d=new OffscreenCanvas(s,c),f=d.getContext("bitmaprenderer");return f===null?e:(f.transferFromImageBitmap(r),r=void 0,await d.convertToBlob({type:"image/webp",quality:.9}))}catch{return e}finally{t?.close(),r?.close()}}function ir(){for(;E.size>er;){const e=E.keys().next().value;E.delete(e)}}function xn(e,n,t){const r=`${e}|${n}`,o=E.get(r);if(o!==void 0)return E.delete(r),E.set(r,o),o.catch(()=>null);const i=t().then(s=>s===null?Promise.reject(new Error("missing")):or(s,n));return E.set(r,i),ir(),i.catch(()=>(E.get(r)===i&&E.delete(r),null))}const sr="kiki-appearance",Te="media",O=new Map;let Re=null;function Hn(){return Re??=new Promise(e=>{if(typeof indexedDB>"u"){e(null);return}try{const n=indexedDB.open(sr,1);n.onupgradeneeded=()=>{n.result.createObjectStore(Te)},n.onsuccess=()=>{e(n.result)},n.onerror=()=>{e(null)}}catch{e(null)}}),Re}function fe(e,n){return Hn().then(t=>new Promise((r,o)=>{if(t===null){r(void 0);return}const i=n(t.transaction(Te,e).objectStore(Te));i.onsuccess=()=>{r(i.result)},i.onerror=()=>{o(i.error??new Error("media store failed"))}}))}async function So(){return await Hn()!==null}async function ar(e,n){O.set(e,n),await fe("readwrite",t=>t.put(n,e)).catch(()=>{})}async function cr(e){const n=O.get(e);if(n!==void 0)return n;const t=await fe("readonly",r=>r.get(e)).catch(()=>{});return t===void 0?null:(O.set(e,t),t)}async function lr(e){O.delete(e),await fe("readwrite",n=>n.delete(e)).catch(()=>{})}async function Eo(e,n=e.name){const t=n===void 0?null:An(n),r=await ur(e),o=tt(r);if(o===null)return{ok:!1,reason:t===null?"type":"content"};if(t!==null&&t.mime!==o)return{ok:!1,reason:"content"};const i=o.startsWith("video/")?"video":"image",s=i==="video"?Xe.videoBytes:Xe.imageBytes;return e.size>s?{ok:!1,reason:"size"}:{ok:!0,kind:i,mime:o}}function ur(e){return new Promise(n=>{const t=new FileReader;t.onload=()=>{n(new Uint8Array(t.result))},t.onerror=()=>{n(new Uint8Array)},t.readAsArrayBuffer(e.slice(0,32))})}let gn=0;async function yo(e,n,t){gn+=1;const r=`local-${Date.now().toString(36)}-${gn.toString(36)}`;return await ar(r,e.type===n.mime?e:new Blob([e],{type:n.mime})),{id:r,kind:n.kind,mime:n.mime,name:t.slice(0,200),bytes:e.size}}async function Ao(e){for(const t of Array.from(O.keys()))e.has(t)||O.delete(t);const n=await fe("readonly",t=>t.getAllKeys()).catch(()=>{});for(const t of n??[])typeof t=="string"&&!e.has(t)&&await lr(t)}function Co(){O.clear(),Re=null}const Un={missing:!1,heavyVideo:!1,paused:null,surfaceAlpha:null,textAlpha:null};let ee=Un;const Le=new Set;function Do(){return ee}function Io(e){return Le.add(e),()=>{Le.delete(e)}}function w(e){const n={...ee,...e};if(JSON.stringify(n)!==JSON.stringify(ee)){ee=n;for(const t of Le)t()}}const ce=new Map;let $e=!0;function dr(e){return ce.get(e)}function jn(e,n){if(!(ce.has(n)||typeof document>"u"))try{const t=document.createElement("canvas");t.width=48,t.height=32;const r=t.getContext("2d",{willReadFrequently:!0});if(r===null)return;r.drawImage(e,0,0,t.width,t.height),ce.set(n,Pt(r.getImageData(0,0,t.width,t.height).data))}catch{}}function ve(e){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function fr(){const e=["--color-ink","--color-ink-soft","--color-ink-faint"].map(ve),n=ve("--color-canvas");return["--color-canvas","--color-paper","--color-panel"].map(t=>({surface:ve(t),ground:n,texts:e}))}let C=null,m={key:"",element:null,urls:[]},N=null,U,D=0,p=null,R=0;function Kn(){if(C!==null&&C.root.isConnected)return C;const e=document.createElement("div");e.dataset.kikiBackdrop="",e.setAttribute("aria-hidden","true");const n=document.createElement("div");n.dataset.kikiBackdropMedia="";const t=document.createElement("div");return t.dataset.kikiBackdropScrim="",e.append(n,t),document.body.prepend(e),C={root:e,media:n,scrim:t},C}function zn(){const e=document.documentElement.dataset.kikiMotion;return e==="reduce"?!1:e==="full"?!0:!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches}let Jn=!1;function pr(){navigator.getBattery?.().then(n=>{const t=()=>{Jn=!n.charging&&n.level<.2,W()};n.addEventListener("levelchange",t),n.addEventListener("chargingchange",t),t()}).catch(()=>{})}function kr(){return zn()?document.visibilityState==="hidden"||!document.hasFocus()?"hidden":Jn?"power":null:"motion"}function W(){const e=m.element instanceof HTMLVideoElement?m.element:null;if(e===null){w({paused:null});return}const n=kr();w({paused:n==="hidden"?null:n}),n===null?e.play().catch(()=>{}):e.pause()}function Vn(){for(const e of m.urls)URL.revokeObjectURL(e);m={key:"",element:null,urls:[]},N=null}async function Fn(e,n,t,r=!1){const o=e.kind==="image"&&!r?await xn(e.id,nr(),()=>n(e)):await n(e);if(o===null)return null;const i=URL.createObjectURL(o);return t.push(i),i}async function mr(e){if(ce.has(e.id)||typeof createImageBitmap!="function")return;const n=await xn(e.id,tr,()=>x(e));if(n!==null)try{const t=await createImageBitmap(n,{resizeWidth:48,resizeHeight:32,resizeQuality:"low"});jn(t,e.id),t.close()}catch{}}let x=e=>cr(e.id);function Bo(e){e!==x&&(x=e,p!==null&&m.element===null&&(N=null,xe(p,D,R)))}function wo(e){return x(e)}function bn(e,n,t){const{look:r}=n,o=[r.blur>0?`blur(${r.blur}px)`:"",r.brightness!==1?`brightness(${r.brightness})`:""].filter(Boolean).join(" ");if(e.style.opacity=String(r.opacity),e.style.filter=o,t!==null){e.style.backgroundImage=`url("${t}")`,e.style.backgroundRepeat="repeat",e.style.backgroundPosition=ln(r.alignment);return}e.style.objectFit=r.fit==="contain"?"contain":r.fit==="center"?"none":"cover",e.style.objectPosition=ln(r.alignment)}async function xe(e,n,t){const{media:r}=Kn(),o=e.media[n%e.media.length],i=`${e.packId??""}|${o.id}|${e.look.fit}`;if(m.key===i&&m.element!==null){bn(m.element,e,m.element instanceof HTMLDivElement?m.urls[0]??null:null),W();return}if(N?.key===i)return;const s={key:i};N=s;const c=[],d=()=>t!==R||N!==s,f=await Fn(o,x,c,e.look.fit==="tile");let h=null;if(f!==null&&o.kind==="video"&&e.poster!==void 0&&!d()&&(h=await Fn(e.poster,x,c)),d()){for(const a of c)URL.revokeObjectURL(a);return}N=null;const S=p??e;if(f===null){Vn(),r.replaceChildren(),w({missing:!0});return}let l;if(o.kind==="video"){const a=document.createElement("video");a.muted=!0,a.defaultMuted=!0,a.loop=!0,a.playsInline=!0,a.autoplay=!1,a.preload="auto",a.disablePictureInPicture=!0,a.setAttribute("muted",""),a.setAttribute("playsinline",""),h!==null&&(a.poster=h),a.addEventListener("loadeddata",()=>{jn(a,o.id),w({heavyVideo:a.videoWidth*a.videoHeight>2560*1440}),p!==null&&He(p)},{once:!0}),a.src=f,l=a}else{if(e.look.fit==="tile")l=document.createElement("div");else{const a=document.createElement("img");a.decoding="async",a.alt="",a.src=f,l=a}mr(o).then(()=>{p!==null&&m.key===i&&He(p)})}l.dataset.kikiBackdropItem=o.kind,bn(l,S,l instanceof HTMLDivElement?f:null),r.replaceChildren(l);for(const a of m.urls)URL.revokeObjectURL(a);m={key:i,element:l,urls:c},w({missing:!1,heavyVideo:!1}),W()}function He(e){const n=document.documentElement,t=e.sample??dr(e.media[D%e.media.length].id),r=e.look.surfaceOpacity,o=$e?Math.max(...fr().map(s=>Ot(s,e.look,t,r))):r,i=r>=1?0:Math.max(0,(o-r)/(1-r));n.style.setProperty("--kiki-surface-alpha",`${Math.round(r*100)}%`),n.style.setProperty("--kiki-text-alpha",`${Math.ceil(i*100)}%`),n.style.setProperty("--kiki-solid-alpha",`${Math.ceil(o*100)}%`),n.style.setProperty("--kiki-surface-blur",`${e.look.surfaceBlur}px`),n.style.setProperty("--kiki-backdrop-scrim",String(e.look.scrim)),n.style.setProperty("--kiki-backdrop-overscan",`${Math.ceil(e.look.blur*3)}px`),$e?n.dataset.kikiBgAssist="":delete n.dataset.kikiBgAssist,w({surfaceAlpha:r,textAlpha:o})}function Gn(){R+=1,clearInterval(U),U=void 0,p=null,Vn(),C?.root.remove(),C=null;const e=document.documentElement;delete e.dataset.kikiBg,delete e.dataset.kikiBgAssist;for(const n of["--kiki-surface-alpha","--kiki-text-alpha","--kiki-solid-alpha","--kiki-surface-blur","--kiki-backdrop-scrim","--kiki-backdrop-overscan"])e.style.removeProperty(n);w(Un)}function _o(e,n=!0){if(typeof document>"u")return;if($e=n,e===null){(p!==null||C!==null)&&Gn();return}const t=JSON.stringify(p?.media)!==JSON.stringify(e.media)||p?.packId!==e.packId;p=e,t&&(R+=1,D=0),document.documentElement.dataset.kikiBg=e.look.scope,Kn().root.dataset.scope=e.look.scope,e.look.scope!=="window"&&(vn(),requestAnimationFrame(vn)),He(e),xe(e,D,R),clearInterval(U),U=void 0,e.media.length>1&&e.interval>0&&zn()&&(U=setInterval(()=>{p===null||document.visibilityState==="hidden"||(D=(D+1)%p.media.length,xe(p,D,R))},e.interval*1e3))}let j=null,A=null;function le(){const e=A?.getBoundingClientRect().right??0;document.documentElement.style.setProperty("--kiki-backdrop-sidebar",`${Math.round(e)}px`)}function vn(){if(typeof ResizeObserver>"u")return;const e=document.querySelector(".app-sidebar");e!==A&&(j??=new ResizeObserver(le),A!==null&&j.unobserve(A),A=e,A!==null&&j.observe(A),le())}function hr(){return window.addEventListener("resize",le),()=>{window.removeEventListener("resize",le),j?.disconnect(),j=null,A=null,document.documentElement.style.removeProperty("--kiki-backdrop-sidebar")}}let Se=!1;function Oo(){if(Se||typeof window>"u")return()=>{};Se=!0;const e=()=>{W()};document.addEventListener("visibilitychange",e),window.addEventListener("focus",e),window.addEventListener("blur",e);const n=window.matchMedia?.("(prefers-reduced-motion: reduce)");n?.addEventListener?.("change",e),pr();const t=hr();return()=>{Se=!1,t(),document.removeEventListener("visibilitychange",e),window.removeEventListener("focus",e),window.removeEventListener("blur",e),n?.removeEventListener?.("change",e),Gn()}}function Po(){typeof document<"u"&&W()}const Ue="pack:";function gr(e,n){return`${Ue}${e}/${n}`}function Mo(e){if(!e.startsWith(Ue))return null;const n=e.slice(Ue.length),t=n.indexOf("/");return t<=0?null:{packId:n.slice(0,t),file:n.slice(t+1)}}function Sn(e,n){const t=An(n);return t===null?null:{id:gr(e,n),kind:t.kind,mime:t.mime,name:n,bytes:0}}function En(e,n){if(n===void 0)return null;const{media:t,poster:r,interval:o,shuffle:i,...s}=n,c=t.map(d=>Sn(e,d)).filter(d=>d!==null);return c.length===0?null:{media:c,poster:r===void 0?void 0:Sn(e,r)??void 0,interval:o??0,look:_n(s),packId:e}}function No(e){const n=En(e.id,e.variants.light?.background),t=En(e.id,e.variants.dark?.background);return n===null||t===null?{light:n??t,dark:null,linked:!0}:{light:n,dark:t,linked:!1}}function To(e){const n=o=>{const i=e.variants[o];if(i===void 0)return;const{background:s,...c}=i;return c.colors===void 0&&c.fonts===void 0&&c.shape===void 0?void 0:c},t=n("light"),r=n("dark");return t===void 0&&r===void 0?null:{kind:"kiki-skin",version:1,id:e.id,name:e.name,description:e.description,author:e.author,variants:{light:t,dark:r}}}function Ee(e,n){const t={...e.colors};n.tweaks.accent!==void 0&&(t.accent=n.tweaks.accent);const r={...e.fonts};n.tweaks.fontSans!==void 0&&(r.sans=n.tweaks.fontSans),n.tweaks.fontMono!==void 0&&(r.mono=n.tweaks.fontMono);const o={...e.shape};return n.tweaks.radius!==void 0&&(o.radius=n.tweaks.radius),n.tweaks.spacing!==void 0&&(o.spacing=n.tweaks.spacing),{...e.base!==void 0?{base:e.base}:{},...Object.keys(t).length>0?{colors:t}:{},...Object.keys(r).length>0?{fonts:r}:{},...Object.keys(o).length>0?{shape:o}:{}}}function Ro(e,n){const t=Yt(e.selection)??Mn("paper")??null,r=Fr(n)||"my-skin",o={};for(const s of t===null?[]:Xt(t))o[s]=Ee(t?.variants[s]??{},e);Object.keys(o).length===0&&(o.light=Ee({},e),o.dark=Ee({},e));const i={$schema:"https://kiki.dev/schema/skin-v1.json",kind:"kiki-skin",version:1,id:r,name:n.trim()===""?"My skin":n.trim(),...t?.description!==void 0?{description:t.description}:{},variants:o};return{filename:`${r}.json`,json:`${JSON.stringify(i,null,2)}
|
|
2
|
-
`}}function Fr(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64).replace(/^[^a-z0-9]+/,"")}export{nn as $,hn as A,Tt as B,Z as C,Q as D,no as E,Qt as F,to as G,Eo as H,fo as I,It as J,ho as K,lr as L,eo as M,Mn as N,cr as O,Ue as P,co as Q,Nt as R,lo as S,wt as T,qt as U,mo as V,So as W,dr as X,Je as Y,_n as Z,Ge as _,po as a,Dr as a$,ln as a0,No as a1,gr as a2,To as a3,ge as a4,Mo as a5,Ao as a6,ar as a7,ko as a8,xt as a9,Bn as aA,xr as aB,Lr as aC,jr as aD,Rr as aE,$r as aF,Hr as aG,zr as aH,Jr as aI,wn as aJ,Tr as aK,St as aL,Ur as aM,De as aN,yr as aO,Ce as aP,Kr as aQ,ct as aR,je as aS,Mr as aT,Pr as aU,Ir as aV,Nr as aW,Or as aX,st as aY,Cr as aZ,ne as a_,Gr as aa,Ot as ab,we as ac,Qr as ad,Co as ae,wo as af,Pt as ag,Bo as ah,uo as ai,io as aj,ao as ak,oo as al,We as am,so as an,Fr as ao,Wr as ap,yt as aq,jt as ar,Ut as as,yo as at,Io as au,go as av,Ct as aw,Jt as ax,xn as ay,tr as az,vo as b,v as b0,wr as b1,lt as b2,_r as b3,Ar as b4,Br as b5,Cn as b6,Er as b7,Xr as c,_o as d,Vt as e,Po as f,Xt as g,Fo as h,ro as i,Vr as j,dn as k,fn as l,V as m,Pn as n,_ as o,$n as p,Zt as q,Yt as r,Zr as s,Do as t,Yr as u,bo as v,Oo as w,qr as x,Ve as y,Ro as z};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{R as c,L as x,A as d}from"./mermaid-GHXKKRXX-_JLagMll.js";import{r as a,j as f}from"./index-B_5-HLed.js";import"./connection-DYZn9oPZ.js";import"./index-BfmoxdpP.js";import"./locale-CANfezJ4.js";import"./settings-CcwMWXbp.js";import"./client-DSIbyfoz.js";import"./navViewState-DS5LnMYc.js";import"./export-Bq8ZECqX.js";import"./spaces-B2Ccyh_T.js";import"./theme-DlDhDxeD.js";var w=({code:o,language:t,raw:e,className:l,startLine:p,lineNumbers:u,...n})=>{let{shikiTheme:s}=a.useContext(c),r=x(),[g,i]=a.useState(e);return a.useEffect(()=>{if(!r){i(e);return}let m=r.highlight({code:o,language:t,themes:s},h=>{i(h)});m&&i(m)},[o,t,s,r,e]),f.jsx(d,{className:l,language:t,lineNumbers:u,result:g,startLine:p,...n})};export{w as HighlightedCodeBlockBody};
|