@xopcai/xopc 0.0.253 → 0.0.254
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/dist/browser-ext/dist/background.js +59 -13
- package/dist/browser-ext/dist/content.js +0 -5
- package/dist/browser-ext/manifest.json +2 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-CeS1bgXP.js → activity-store-Ci5Rxmi_.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BdF3HhCW.js → agent-avatar-dicebear-D82jpmFL.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-vul32IsP.js +1 -0
- package/dist/gateway/static/root/assets/{agents-DARlgjTm.js → agents-p3kWyz1T.js} +1 -1
- package/dist/gateway/static/root/assets/{api-zMPeC0yU.js → api-CXIzQJ2Z.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-BaAFln8W.js → app-management-settings-panel-mhxcQpkQ.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-CXvsoBlw.js → appearance-settings-BIMwACUF.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-CJFJKNwS.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-C0o_mVQI.js → archive-plugin-C63Xp_sU.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-B5Ry3tGL.js → attachment-load-D12KYOav.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-DY5QAEQd.js → automations-page-DXj0o5CY.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-B2wxcpgq.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-BydpEgBA.js → binary-plugins-Bcv8hun6.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-D0CpUOMo.js → block-editor-C61LqK_-.js} +50 -50
- package/dist/gateway/static/root/assets/{browser-automation-inputs-DzbTsGI6.js → browser-automation-inputs-CAclu735.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-D7fZYjni.js → browser-automations-page-BITfKX8L.js} +2 -2
- package/dist/gateway/static/root/assets/browser-settings-page-BMjY8cyv.js +8 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-wB3Vgmp3.js +7 -0
- package/dist/gateway/static/root/assets/{channels-settings-bdRLT9KA.js → channels-settings-U5ffzu4r.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-status-swr-BGGRTkn6.js → channels-status-swr-Cmbx0E8O.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-_CP4nvlg.js → chat-terminal-dock-CNBgHN9U.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-BGaF--m5.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-g2U8Rllf.js → cron-expression-DCTN4QAG.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-SmVlhtj_.js → date-picker-BuEyUxZn.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-D-0gcbbM.js → dependency-picker-l6IXzk0C.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-Cl3JRIu6.js → desktop-pet-cGn_20DO.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-D7kvWQ9H.js → desktop-pet-settings-DIfccDKS.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-DtP2tJHY.js → extension-debug-page-CTS5RP_D.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CphZDdoT.js → extension-page-Dg9YssYH.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-CsxVLV4-.js → extension-settings-page-CWZYL8Fi.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-BW3Bx-aV.js → gateway-config-swr-Chsr5wGH.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-DxBZ05dX.js → gateway-settings-vHI_Que8.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-DAq74TZe.js → gateway-startup-retry-C9ynH6VV.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-DWcKsIoZ.js → heartbeat-settings-WUhSfvob.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-CYjlMzPx.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-MPuaXDRs.js → image-generation-api-D_TsVe7h.js} +1 -1
- package/dist/gateway/static/root/assets/{index-C7RDs6S-.js → index-BBlJYVxR.js} +18 -18
- package/dist/gateway/static/root/assets/index-_I0dD2LN.css +2 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CfhaTqgE.js → keyboard-shortcuts-settings-DGBf6YfD.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-CLlIl83V.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-g01W3kEK.js → local-apps-page-DGWP_xsQ.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-BkeaPZpn.js → locale-store-B2v8mNJw.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-DuhCigiB.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-DeGxJF_Z.js → management-settings-DUAZ-dtt.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-Ca7BRBLL.js → markdown-view-DBWu9d_n.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-FmOhmzlD.js → media-plugins-CsUjcIBy.js} +1 -1
- package/dist/gateway/static/root/assets/messages-ChSTFZR5.js +3 -0
- package/dist/gateway/static/root/assets/{mobile-pairing-wizard-BXNbn05L.js → mobile-pairing-wizard-Dxu8twiQ.js} +1 -1
- package/dist/gateway/static/root/assets/note-detail-panel-DMdbaTZp.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-xe_vX0nM.js +8 -0
- package/dist/gateway/static/root/assets/{page-tabs-pyukZ1PJ.js → page-tabs-YeJKwV-7.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-slFHoMUe.js → preview-open-alternatives-BfJ3jMDG.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-CXa3FNNk.js → product-open-page-B7NRGPox.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-BDF88VdN.js → project-detail-page-hG7ELibZ.js} +1 -1
- package/dist/gateway/static/root/assets/projects-page-C5G2ET4w.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-CviQoUBf.js → registry-api-B9OZUdwC.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-DTO-faxH.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-O9D9o7-O.js → runtime-tools-settings-panel-uJ8Br3ZL.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-8FesicnL.js → schema-form-CXwn6up5.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-CwzsUCgP.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-Djc3EdoO.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-CBic9TFH.js → settings-form-section-YVNYsR0U.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-Xz66_Mjg.js → settings-page-cHqrIdVR.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-C6DuwrP5.js → setup-status-panel-MUAMcZLD.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page--JpjwB58.js → share-preview-page-DnjSDQru.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-C7A0aywX.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-D1xSGJAQ.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-fVKExKv5.js → skills-page-DkrGEdiY.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-Yv9u3uJp.js → skills-page.utils-CqZbiZuK.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-CCWjVdc2.js → system-settings-panel-Dmw0RfxZ.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-BvZSCLUH.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-BtkaVpMm.js → theme-store-CubltMKm.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-C__W9BaN.js → tunnel-api-CiieC6HP.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-Dow9RRcq.js → use-autosave-XQ3SuyB9.js} +1 -1
- package/dist/gateway/static/root/assets/{user-model-page-CU6nxmoM.js → user-model-page-BKJC7tyW.js} +2 -2
- package/dist/gateway/static/root/assets/{voice-api-key-field-CvF3lEyx.js → voice-api-key-field-D4QzVgdt.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-BEUVAyM6.js → voice-config-api-B1ZbyVmF.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-B9PDfReq.js → work-discovery-overlay-D5Tf8GRZ.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-kWGFkhjz.js → workflow-run-setup-panel-BW9p8Maz.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-DuqRodIc.js +5 -0
- package/dist/gateway/static/root/index.html +10 -10
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +4 -4
- package/dist/src/agent/background-review/run-background-review.js +1 -1
- package/dist/src/agent/embedded/model-runtime.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +1 -1
- package/dist/src/agent/image/tool-model-config.js +1 -1
- package/dist/src/agent/mcp/oauth/mcp-oauth-store.js +1 -1
- package/dist/src/agent/service.js +2 -2
- package/dist/src/agent/session/session-inspector.js +1 -1
- package/dist/src/agent/skills/hub-lock.js +1 -1
- package/dist/src/agent/tasks/task-judge-service.js +3 -3
- package/dist/src/agent/tools/browser/tool/browser-use-tool.js +17 -2
- package/dist/src/agent/tools/browser/tool/schemas.d.ts +85 -1
- package/dist/src/agent/tools/browser/tool/schemas.js +212 -5
- package/dist/src/ai-assist/text-assist.js +1 -1
- package/dist/src/auth/credentials.js +2 -2
- package/dist/src/auth/oauth/xopc-cloud.js +1 -1
- package/dist/src/auth/profiles/store.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +2 -2
- package/dist/src/browser/drivers/extension-driver.d.ts +4 -4
- package/dist/src/browser/drivers/extension-driver.js +20 -8
- package/dist/src/browser/drivers/playwright-driver.js +1 -1
- package/dist/src/browser/providers/browser-ext-install.d.ts +3 -0
- package/dist/src/browser/providers/browser-ext-install.js +19 -4
- package/dist/src/browser/providers/extension.d.ts +14 -1
- package/dist/src/browser/providers/extension.js +89 -11
- package/dist/src/browser/providers/playwright-install.js +8 -12
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/config/index.js +4 -4
- package/dist/src/config/loader.js +2 -2
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/extensions/lockfile.js +1 -1
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/file-path-classifier.js +1 -1
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/routes/browser.js +149 -27
- package/dist/src/gateway/hono/routes/lazy-bundles.js +1 -1
- package/dist/src/gateway/hono/routes/models.js +1 -1
- package/dist/src/gateway/service/config-coordinator.js +1 -1
- package/dist/src/gateway/service.js +10 -10
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
- package/dist/src/providers/index.js +2 -2
- package/dist/src/providers/model-registry.js +1 -1
- package/dist/src/providers/model-thinking.js +57 -20
- package/dist/src/providers/register-runtime-providers.js +1 -1
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/tui/tui.js +1 -1
- package/dist/src/work-discovery/service.js +1 -1
- package/dist/src/workflows/service/workflow-run-service.js +1 -1
- package/package.json +2 -2
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-Bs34Kp0K.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-BhgvfBJT.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-BzX4lILP.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-BBdMqxl0.js +0 -3
- package/dist/gateway/static/root/assets/capabilities-settings-panel-D_WfftDW.js +0 -7
- package/dist/gateway/static/root/assets/connectors-page-CPDjU5wU.js +0 -2
- package/dist/gateway/static/root/assets/home-page-BdvLZKQZ.js +0 -1
- package/dist/gateway/static/root/assets/index-Cu8xqZQ9.css +0 -2
- package/dist/gateway/static/root/assets/local-app-workbench-page-CR6asX7L.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-ZP4QTWoC.js +0 -2
- package/dist/gateway/static/root/assets/messages-C72stReU.js +0 -3
- package/dist/gateway/static/root/assets/note-detail-panel-EeVeF4II.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-D7bMff96.js +0 -8
- package/dist/gateway/static/root/assets/projects-page-DeTD6pu1.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CxKrdQ6a.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-DUFJN-2t.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-CcSYDjaH.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-CovcdHSC.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-CrHagTsE.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-I8hueJnG.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-B4Is5E42.js +0 -5
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/block-editor-D0CpUOMo.js","assets/rolldown-runtime-aKtaBQYM.js","assets/index-C7RDs6S-.js","assets/preload-helper-zJ_50EbN.js","assets/es2015-BvLh9GaE.js","assets/vendor-react-BOUWij0V.js","assets/dist-CxGUk8J-.js","assets/dist-DBS3OB8K.js","assets/floating-ui.dom-B7uQOZZW.js","assets/markdown-view-Ca7BRBLL.js","assets/dist-CpzYSoz7.js","assets/chunk-KS7C4IRE-BaASWQor.js","assets/createLucideIcon-DPHK1VkS.js","assets/download-Dk-ZjtO6.js","assets/plus-Q2yW6OE7.js","assets/x-B_N4OPjy.js","assets/locale-store-BkeaPZpn.js","assets/messages-C72stReU.js","assets/cn-JdwAhgNB.js","assets/product-delivery-CV4pDOtG.js","assets/schemas-BHS7bo06.js","assets/copy-to-clipboard-HOJ79TWv.js","assets/markdown-view-Y68dCxuc.css","assets/dist-DLmwHyAh.js","assets/vendor-swr-BIWyz7Rc.js","assets/check-DUBLcKHA.js","assets/popover-select-C-Hj-nXR.js","assets/skeleton-BwbyijEw.js","assets/settings-shell-dialog-layer-BU3UuiJr.js","assets/settings-shell-layer-context-DCp6ykjQ.js","assets/circle-check-C23XjkUj.js","assets/copy-Dv6d4Dvw.js","assets/external-link-DjqjBmc3.js","assets/globe-DSSGFWFn.js","assets/loader-circle-CifKLtgG.js","assets/middleware-Pd0e8Igk.js","assets/files-BArWTfr7.js","assets/tool-activity-R8V9l6nk.js","assets/button-CtTvuElV.js","assets/registry-api-CviQoUBf.js","assets/gateway-startup-retry-DAq74TZe.js","assets/config-reload-event-Bjh2zoKp.js","assets/gateway-config-swr-BW3Bx-aV.js","assets/electron-env-DH5wF8X8.js","assets/activity-store-CeS1bgXP.js","assets/theme-store-BtkaVpMm.js","assets/index-Cu8xqZQ9.css","assets/vendor-codemirror-Qdcjid65.js","assets/with-selector-aYPsXwdl.js","assets/block-editor-D4ZIVQbk.css","assets/markdown-editor-BjMTIM-m.js","assets/languages-5WaOu0Lf.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{l as a}from"./chunk-KS7C4IRE-BaASWQor.js";import{a as o,i as s,n as c,o as l,r as u,s as d,t as f}from"./dist-CpzYSoz7.js";import{t as p}from"./check-DUBLcKHA.js";import{n as m,r as h}from"./popover-select-C-Hj-nXR.js";import{t as g}from"./circle-check-C23XjkUj.js";import{t as _}from"./copy-Dv6d4Dvw.js";import{t as v}from"./external-link-DjqjBmc3.js";import{t as y}from"./loader-circle-CifKLtgG.js";import{t as b}from"./x-B_N4OPjy.js";import{t as x}from"./copy-to-clipboard-HOJ79TWv.js";import{t as S}from"./messages-C72stReU.js";import{d as C,n as w}from"./locale-store-BkeaPZpn.js";import{t as T}from"./cn-JdwAhgNB.js";import{i as E}from"./vendor-swr-BIWyz7Rc.js";import{t as D}from"./button-CtTvuElV.js";import{i as O}from"./theme-store-BtkaVpMm.js";import{t as k}from"./skeleton-BwbyijEw.js";import{As as A,Cn as j,Dc as M,Di as N,Dn as P,En as F,Fn as I,Gn as L,In as R,Jn as z,Kn as ee,Ln as te,Ml as B,Nn as V,Os as H,Pn as ne,Sl as U,Sn as re,Uc as ie,Un as ae,Us as oe,Ut as se,Va as ce,Wn as le,Yn as ue,Ys as de,_c as fe,_n as pe,a as me,ac as he,ai as ge,bn as _e,c as ve,ec as ye,fu as be,il as xe,io as Se,jc as Ce,js as we,kn as Te,ks as Ee,l as W,o as G,pu as K,s as q,si as De,wn as Oe,xn as ke,yl as Ae,yn as je,zn as Me,zs as Ne}from"./index-C7RDs6S-.js";var J=n(),Y=e(t(),1),X=r(),Pe=(0,Y.createContext)(null);function Fe(){let e=(0,J.c)(1),t=(0,Y.useContext)(Pe);if(!t){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={openImage:Z},e[0]=t):t=e[0],t}return t}function Z(){}function Q(e){let t=(0,J.c)(22),{children:n,closeLabel:r}=e,i=r===void 0?`Close`:r,[a,s]=(0,Y.useState)(null),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(e,t)=>{s({src:e,alt:t})},t[0]=p):p=t[0];let m=p,h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h={openImage:m},t[1]=h):h=t[1];let g=h,_=a!==null,v;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(v=e=>{e||s(null)},t[2]=v):v=t[2];let y;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,X.jsx)(o,{className:`fixed inset-0 z-[70] bg-scrim/90 backdrop-blur-sm`}),t[3]=y):y=t[3];let x;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(x=T(`fixed inset-0 z-[71] flex items-center justify-center p-4 outline-none`,`data-[state=open]:animate-in data-[state=closed]:animate-out`),t[4]=x):x=t[4];let S=a?.alt||`Image preview`,C;t[5]===S?C=t[6]:(C=(0,X.jsx)(d,{className:`sr-only`,children:S}),t[5]=S,t[6]=C);let w;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,X.jsx)(b,{className:`size-5`,"aria-hidden":!0}),t[7]=w):w=t[7];let E;t[8]===i?E=t[9]:(E=(0,X.jsx)(c,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,"aria-label":i,className:`absolute right-4 top-4 z-10 rounded-lg bg-surface-panel/80 p-2 text-fg-muted backdrop-blur transition-colors hover:bg-surface-hover hover:text-fg`,children:w})}),t[8]=i,t[9]=E);let D;t[10]===a?D=t[11]:(D=a?(0,X.jsx)(`img`,{src:a.src,alt:a.alt??``,className:`max-h-[min(90vh,900px)] max-w-[min(95vw,1200px)] rounded-lg object-contain shadow-lg`}):null,t[10]=a,t[11]=D);let O;t[12]!==E||t[13]!==D||t[14]!==C?(O=(0,X.jsxs)(l,{children:[y,(0,X.jsxs)(u,{className:x,"aria-describedby":void 0,children:[C,E,D]})]}),t[12]=E,t[13]=D,t[14]=C,t[15]=O):O=t[15];let k;t[16]!==O||t[17]!==_?(k=(0,X.jsx)(f,{open:_,onOpenChange:v,children:O}),t[16]=O,t[17]=_,t[18]=k):k=t[18];let A;return t[19]!==n||t[20]!==k?(A=(0,X.jsxs)(Pe.Provider,{value:g,children:[n,k]}),t[19]=n,t[20]=k,t[21]=A):A=t[21],A}var Ie=6e4,Le=36e5,Re=864e5;function ze(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function Be(e,t,n){let r=t-e;if(r<Ie)return n.justNow;if(r<Le){let e=Math.floor(r/Ie);return n.minutesAgo.replace(`{{n}}`,String(e))}let i=ze(t);if(e>=i)return n.today+` `+new Date(e).toLocaleTimeString(n.locale,{hour:`2-digit`,minute:`2-digit`});if(e>=i-Re)return n.yesterday+` `+new Date(e).toLocaleTimeString(n.locale,{hour:`2-digit`,minute:`2-digit`});if(r<7*Re){let e=Math.floor(r/Re);return n.daysAgo.replace(`{{n}}`,String(e))}return new Date(e).toLocaleDateString(n.locale,{month:`short`,day:`numeric`})}function Ve(e,t,n){let r=ze(t);if(e>=r)return n.today;if(e>=r-Re)return n.yesterday;let i=new Date(e),a=new Date(t);return i.getFullYear()===a.getFullYear()?i.toLocaleDateString(n.locale,{month:`long`,day:`numeric`}):i.toLocaleDateString(n.locale,{year:`numeric`,month:`long`,day:`numeric`})}function He(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function Ue(e){let t=(0,J.c)(45),{title:n,description:r,prompt:i,coverage:o,className:s,variant:c}=e,l=c===void 0?`card`:c,u=w(Ge),d=S(u).automations.suggestions,f=S(u).automations,p=a(),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m={revalidateOnFocus:!1,refreshInterval:15e3},t[0]=m):m=t[0];let{data:h}=E(o?`automation-suggestion-coverage`:null,We,m),_=o?h?.automations.find(e=>ve(e,o)):void 0,v=_?G(_,f):[];if(l===`titleAction`){if(_){let e;t[1]===s?e=t[2]:(e=T(`flex min-w-0 items-center gap-2 rounded-lg border border-emerald-500/25 bg-emerald-500/10 px-2.5 py-1.5`,s),t[1]=s,t[2]=e);let n;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,X.jsx)(g,{className:`size-3.5 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[3]=n):n=t[3];let r;return t[4]===p?r=t[5]:(r=()=>p(`/automations`),t[4]=p,t[5]=r),(0,X.jsxs)(`section`,{className:e,children:[n,(0,X.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,children:d.coveredTitle}),(0,X.jsx)(D,{variant:`ghost`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:r,children:d.manage})]})}let e;t[6]===s?e=t[7]:(e=T(`flex min-w-0 items-center gap-2 rounded-lg bg-surface-panel px-2.5 py-1.5 shadow-surface`,s),t[6]=s,t[7]=e);let a;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(ie,{className:`size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),t[8]=a):a=t[8];let o;t[9]!==r||t[10]!==n?(o=(0,X.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,title:r,children:n}),t[9]=r,t[10]=n,t[11]=o):o=t[11];let c;t[12]!==p||t[13]!==i?(c=()=>{p(`/automations?${new URLSearchParams({draft:i,autogenerate:`1`}).toString()}`)},t[12]=p,t[13]=i,t[14]=c):c=t[14];let l;return t[15]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,X.jsx)(oe,{className:`size-3.5`,"aria-hidden":!0}),t[15]=l):l=t[15],(0,X.jsxs)(`section`,{className:e,children:[a,o,(0,X.jsxs)(D,{variant:`secondary`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:c,children:[l,d.setup]})]})}if(_){let e;t[16]===s?e=t[17]:(e=T(`rounded-lg border border-emerald-500/25 bg-emerald-500/10 p-3`,s),t[16]=s,t[17]=e);let n;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,X.jsx)(g,{className:`mt-0.5 size-4 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[18]=n):n=t[18];let r;t[19]===p?r=t[20]:(r=()=>p(`/automations`),t[19]=p,t[20]=r);let i;return t[21]!==d||t[22]!==r?(i=(0,X.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,X.jsx)(D,{variant:`ghost`,className:`h-8 rounded-md px-2.5 text-xs`,onClick:r,children:d.manage})}),t[21]=d,t[22]=r,t[23]=i):i=t[23],(0,X.jsxs)(`section`,{className:e,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[n,(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:d.coveredTitle}),(0,X.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:q(d.coveredDescription,{name:_.name})})]})]}),(0,X.jsxs)(`div`,{className:`mt-2 rounded-md bg-surface-base/55 px-2.5 py-2`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-fg`,children:f.explain.whyCovered}),(0,X.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:v.map($)})]}),i]})}let y;t[24]===s?y=t[25]:(y=T(`rounded-lg bg-surface-panel p-3 shadow-surface`,s),t[24]=s,t[25]=y);let b;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,X.jsx)(ie,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[26]=b):b=t[26];let x;t[27]===n?x=t[28]:(x=(0,X.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n}),t[27]=n,t[28]=x);let C;t[29]===r?C=t[30]:(C=(0,X.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:r}),t[29]=r,t[30]=C);let O;t[31]!==x||t[32]!==C?(O=(0,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[b,(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[x,C]})]}),t[31]=x,t[32]=C,t[33]=O):O=t[33];let k;t[34]!==p||t[35]!==i?(k=()=>{p(`/automations?${new URLSearchParams({draft:i,autogenerate:`1`}).toString()}`)},t[34]=p,t[35]=i,t[36]=k):k=t[36];let A;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,X.jsx)(oe,{className:`size-3.5`,"aria-hidden":!0}),t[37]=A):A=t[37];let j;t[38]!==d.create||t[39]!==k?(j=(0,X.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,X.jsxs)(D,{variant:`secondary`,className:`h-8 rounded-md px-2.5 text-xs`,onClick:k,children:[A,d.create]})}),t[38]=d.create,t[39]=k,t[40]=j):j=t[40];let M;return t[41]!==j||t[42]!==y||t[43]!==O?(M=(0,X.jsxs)(`section`,{className:y,children:[O,j]}),t[41]=j,t[42]=y,t[43]=O,t[44]=M):M=t[44],M}function $(e){return(0,X.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function We(){return W.list()}function Ge(e){return e.language}function Ke(e){let t=(0,J.c)(4),{values:n}=e;if(n.length===0)return null;let r;t[0]===n?r=t[1]:(r=n.map(qe),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,X.jsx)(`ul`,{className:`list-disc space-y-1 pl-5`,children:r}),t[2]=r,t[3]=i),i}function qe(e,t){return(0,X.jsx)(`li`,{children:e},`${t}:${e}`)}function Je(e){let t=(0,J.c)(10),{noteId:n,attachmentId:r,label:i,unavailableLabel:a}=e,[o,s]=(0,Y.useState)(null),[c,l]=(0,Y.useState)(!1),u,d;if(t[0]!==r||t[1]!==n?(u=()=>{let e=!1,t=!1;return s(null),l(!1),z(n,r).then(i=>{if(e=!0,t){ue(n,r);return}s(i)}).catch(()=>{t||l(!0)}),()=>{t=!0,e&&ue(n,r)}},d=[r,n],t[0]=r,t[1]=n,t[2]=u,t[3]=d):(u=t[2],d=t[3]),(0,Y.useEffect)(u,d),c){let e;return t[4]===a?e=t[5]:(e=(0,X.jsx)(`p`,{className:`text-xs text-danger`,children:a}),t[4]=a,t[5]=e),e}if(!o){let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(k,{className:`h-10 w-full max-w-md`}),t[6]=e):e=t[6],e}let f;return t[7]!==i||t[8]!==o?(f=(0,X.jsx)(`audio`,{controls:!0,preload:`metadata`,src:o,className:`w-full max-w-md`,"aria-label":i}),t[7]=i,t[8]=o,t[9]=f):f=t[9],f}function Ye(e){let t=(0,J.c)(39),{noteId:n}=e,r=S(w(Qe)).notes.discussionCapture,i,a;t[0]===n?(i=t[1],a=t[2]):(i=[`note-discussion-document`,n],a=()=>se(n),t[0]=n,t[1]=i,t[2]=a);let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o={revalidateOnFocus:!1},t[3]=o):o=t[3];let{data:s,mutate:c}=E(i,a,o),l,u;if(t[4]===c?(l=t[5],u=t[6]):(l=()=>{let e=e=>{let t=e.detail;t&&c(e=>{if(!e||e.discussion.id!==t.discussionId)return e;let n=e.transcript.segments.filter(e=>e.sequence!==t.segment.sequence).concat(t.segment).sort(Ze);return{...e,discussion:{...e.discussion,transcriptRevision:t.transcriptRevision},transcript:{...e.transcript,revision:t.transcriptRevision,segments:n,text:t.text,stats:t.stats}}},{revalidate:!1})},t=()=>void c();return window.addEventListener(`discussion-segment-updated`,e),window.addEventListener(`discussion-updated`,t),()=>{window.removeEventListener(`discussion-segment-updated`,e),window.removeEventListener(`discussion-updated`,t)}},u=[c],t[4]=c,t[5]=l,t[6]=u),(0,Y.useEffect)(l,u),!s)return null;let{discussion:d,transcript:f}=s,p=s.organization?.organization,m=[`stopping`,`sealing`,`organizing`].includes(d.status),h=f.stats.uploaded+f.stats.transcribing,_=f.stats.failed>0?r.failedSegments.replace(`{{count}}`,String(f.stats.failed)):h>0?r.processingSegments.replace(`{{count}}`,String(h)):m?r.finalizing:d.status===`completed`?r.transcriptReady:null,v;t[7]!==r.actionItems||t[8]!==r.decisions||t[9]!==r.openQuestions||t[10]!==r.organization||t[11]!==r.risks||t[12]!==p?(v=p?(0,X.jsxs)(`section`,{className:`border-b border-edge-subtle px-6 py-5`,children:[(0,X.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-accent-fg`,children:[(0,X.jsx)(oe,{className:`size-4`,"aria-hidden":!0}),r.organization]}),(0,X.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:p.summary}),(0,X.jsxs)(`div`,{className:`mt-4 grid gap-4 text-sm leading-6 text-fg sm:grid-cols-2 xl:grid-cols-1`,children:[p.decisions.length>0?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`font-medium`,children:r.decisions}),(0,X.jsx)(Ke,{values:p.decisions})]}):null,p.actionItems.length>0?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`font-medium`,children:r.actionItems}),(0,X.jsx)(Ke,{values:p.actionItems.map(Xe)})]}):null,p.risks.length>0?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`font-medium`,children:r.risks}),(0,X.jsx)(Ke,{values:p.risks})]}):null,p.openQuestions.length>0?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`font-medium`,children:r.openQuestions}),(0,X.jsx)(Ke,{values:p.openQuestions})]}):null]})]}):null,t[7]=r.actionItems,t[8]=r.decisions,t[9]=r.openQuestions,t[10]=r.organization,t[11]=r.risks,t[12]=p,t[13]=v):v=t[13];let y;t[14]!==r.recordingAudio||t[15]!==r.recordingUnavailable||t[16]!==d.audioAttachmentId||t[17]!==n?(y=d.audioAttachmentId?(0,X.jsxs)(`section`,{className:`border-b border-edge-subtle px-6 py-4`,children:[(0,X.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,X.jsx)(M,{className:`size-4 text-accent`,"aria-hidden":!0}),r.recordingAudio]}),(0,X.jsx)(Je,{noteId:n,attachmentId:d.audioAttachmentId,label:r.recordingAudio,unavailableLabel:r.recordingUnavailable})]}):null,t[14]=r.recordingAudio,t[15]=r.recordingUnavailable,t[16]=d.audioAttachmentId,t[17]=n,t[18]=y):y=t[18];let b;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,X.jsx)(M,{className:`size-4 text-accent`,"aria-hidden":!0}),t[19]=b):b=t[19];let x=d.status===`recording`?r.draftTranscript:r.fullTranscript,C;t[20]===x?C=t[21]:(C=(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[b,x]}),t[20]=x,t[21]=C);let T;t[22]===d.status?T=t[23]:(T=d.status===`needs_attention`?(0,X.jsx)(H,{className:`size-3.5 text-danger`}):d.status===`completed`?(0,X.jsx)(g,{className:`size-3.5 text-success`}):null,t[22]=d.status,t[23]=T);let D=d.status===`needs_attention`?d.failureMessage:_,O;t[24]!==T||t[25]!==D?(O=(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-fg-muted`,children:[T,D]}),t[24]=T,t[25]=D,t[26]=O):O=t[26];let k;t[27]!==C||t[28]!==O?(k=(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[C,O]}),t[27]=C,t[28]=O,t[29]=k):k=t[29];let A=f.text||r.waitingTranscript,j;t[30]===A?j=t[31]:(j=(0,X.jsx)(`div`,{className:`mt-3 max-h-48 overflow-y-auto whitespace-pre-wrap text-sm leading-6 text-fg-muted xl:max-h-none xl:overflow-visible`,children:A}),t[30]=A,t[31]=j);let N;t[32]!==k||t[33]!==j?(N=(0,X.jsxs)(`section`,{className:`px-6 py-4`,children:[k,j]}),t[32]=k,t[33]=j,t[34]=N):N=t[34];let P;return t[35]!==N||t[36]!==v||t[37]!==y?(P=(0,X.jsxs)(`aside`,{className:`max-h-[45%] shrink-0 overflow-y-auto border-b border-edge-subtle xl:h-full xl:max-h-none xl:w-[clamp(20rem,34%,27rem)] xl:border-r xl:border-b-0`,children:[v,y,N]}),t[35]=N,t[36]=v,t[37]=y,t[38]=P):P=t[38],P}function Xe(e){return e.title}function Ze(e,t){return e.sequence-t.sequence}function Qe(e){return e.language}var $e={edit:fe,ai_edit:oe,sync:he,restore:K};function et(e,t){return{edit:t.triggerEdit,ai_edit:t.triggerAiEdit,sync:t.triggerSync,restore:t.triggerRestore}[e]??e}function tt({noteId:e,activeTimestamp:t,onSelect:n,onClose:r,onRestored:i}){let a=w(e=>e.language),o=S(a).notes,s={justNow:o.justNow,minutesAgo:o.minutesAgo,today:o.today,yesterday:o.yesterday,daysAgo:o.daysAgo,locale:C(a)},{data:c}=E(e?[`note-history`,e]:null,()=>Oe(e)),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(null),h=(0,Y.useCallback)(async t=>{u(!0),m(null);try{await R(e,t),f(null),i()}catch{m(o.restoreFailed)}finally{u(!1)}},[e,o.restoreSuccess,o.restoreFailed,i]),g=Date.now();return(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,X.jsx)(xe,{className:`size-4`,"aria-hidden":!0}),o.history]}),(0,X.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-lg p-1 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:(0,X.jsx)(b,{className:`size-4`,"aria-hidden":!0})})]}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[p?(0,X.jsx)(`p`,{className:`border-b border-danger/20 bg-danger-soft px-4 py-2 text-xs text-danger`,role:`alert`,children:p}):null,c?.length?(0,X.jsx)(`ul`,{className:`divide-y divide-edge`,children:c.map(e=>{let r=$e[e.trigger]??fe,i=t===e.timestamp,a=d===e.timestamp;return(0,X.jsxs)(`li`,{children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:T(`w-full px-4 py-3 text-left transition-colors`,i?`bg-accent/10`:`hover:bg-surface-hover`),children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(r,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:et(e.trigger,o)}),(0,X.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:Be(e.timestamp,g,s)})]}),e.snippet&&(0,X.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted/60`,children:e.snippet})]}),i&&(0,X.jsx)(`div`,{className:`border-t border-edge/50 px-4 py-2`,children:a?(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate text-xs text-fg-muted`,children:o.restoreConfirm}),(0,X.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),h(e.timestamp)},disabled:l,className:`shrink-0 rounded-lg bg-accent px-3 py-1 text-xs font-medium text-on-accent transition-colors hover:bg-accent/90 disabled:opacity-50`,children:l?`...`:o.restore}),(0,X.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),f(null)},className:`shrink-0 rounded-lg px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover`,children:`Cancel`})]}):(0,X.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),f(e.timestamp)},className:`rounded-lg bg-surface-hover px-3 py-1 text-xs font-medium text-fg transition-colors hover:bg-accent hover:text-on-accent`,children:o.restore})})]},e.timestamp)})}):(0,X.jsxs)(`div`,{className:`px-4 py-8 text-center`,children:[(0,X.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,children:o.historyEmpty}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted/60`,children:o.historyEmptyDescription})]})]})]})}function nt({noteId:e,note:t,catalyzing:n,onCatalyze:r,onClose:i,noteThreads:o,openingChat:s,onOpenChat:c,onOpenNewChat:l}){let u=S(w(e=>e.language)).notes,d=a(),f=t?.aiDeep?.catalysis,p=f?.report??null,[m,h]=(0,Y.useState)(null),[g,_]=(0,Y.useState)(!1),{data:v,mutate:y,isLoading:b}=E(e?[`note-agent-context-status`,e]:null,()=>re(e),{revalidateOnFocus:!1}),x=(0,Y.useCallback)(async()=>{if(!g){_(!0),h(null);try{await y(()=>V(e),{revalidate:!1})}catch(e){h(`${u.contextRebuildFailed}: ${e instanceof Error?e.message:u.quickCaptureFailedHint}`)}finally{_(!1)}}},[g,y,u.contextRebuildFailed,u.quickCaptureFailedHint,e]),C=(0,Y.useCallback)(async t=>{try{await ne(e,t)}catch{}},[e]);return(0,X.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(oe,{className:`size-4 text-accent`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:u.catalysisSectionTitle})]}),(0,X.jsx)(`button`,{type:`button`,onClick:i,"aria-label":u.lightboxClose,className:`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:(0,X.jsx)(be,{className:`size-4 rotate-180`,"aria-hidden":!0})})]}),(0,X.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:[(0,X.jsx)(`p`,{className:`mb-4 text-xs leading-relaxed text-fg-muted`,children:u.catalysisSectionDescription}),v?(0,X.jsxs)(`section`,{className:`mb-4 rounded-xl bg-surface-base p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.contextStatusTitle}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void x(),disabled:b||g,className:`rounded-md px-1.5 py-0.5 text-[11px] font-medium text-accent transition-colors hover:bg-accent/10 disabled:cursor-not-allowed disabled:opacity-50`,children:g?u.processing:u.contextRebuild}),(0,X.jsx)(`span`,{className:T(`rounded-full px-2 py-0.5 text-[11px] font-medium`,v.status===`ready`?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-300`:v.status===`partial`?`bg-amber-500/10 text-amber-600 dark:text-amber-300`:`bg-red-500/10 text-red-600 dark:text-red-300`),children:v.status})]}),(0,X.jsx)(`div`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:u.contextStatusDetail.replace(`{{attachments}}`,String(v.attachments.length)).replace(`{{tokens}}`,String(v.tokenEstimate??0))}),m?(0,X.jsx)(`p`,{className:`mt-3 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:m}):null,v.attachments.length>0?(0,X.jsx)(`div`,{className:`mt-3 space-y-1.5`,children:v.attachments.slice(0,5).map(e=>(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-lg bg-surface-hover px-2 py-1.5 text-xs`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.fileName}),(0,X.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:e.status})]},e.attachmentId))}):null]}):null,(0,X.jsx)(`button`,{type:`button`,onClick:r,disabled:n,className:`w-full rounded-lg bg-accent px-2.5 py-1.5 text-xs font-medium text-white transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50`,children:n?u.processing:p?u.recatalyze:u.catalyzeAction}),p?(0,X.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.valueHypothesis}),(0,X.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg`,children:p.valueHypothesis})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.targetUsers}),(0,X.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:p.targetUsers.slice(0,5).map(e=>(0,X.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg`,children:e},e))})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.keyQuestions}),(0,X.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:p.keyQuestions.slice(0,3).map(e=>(0,X.jsxs)(`li`,{className:`flex gap-2`,children:[(0,X.jsx)(`span`,{className:`mt-2 size-1 shrink-0 rounded-full bg-accent`}),(0,X.jsx)(`span`,{children:e})]},e))})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.mvpPathLabel}),(0,X.jsx)(`ol`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:p.mvpPath.slice(0,3).map((e,t)=>(0,X.jsxs)(`li`,{className:`flex gap-2`,children:[(0,X.jsxs)(`span`,{className:`text-fg-muted`,children:[t+1,`.`]}),(0,X.jsx)(`span`,{children:e})]},e))})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.risks}),(0,X.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:p.risks.slice(0,3).map(e=>(0,X.jsxs)(`li`,{className:`flex gap-2`,children:[(0,X.jsx)(`span`,{className:`mt-2 size-1 shrink-0 rounded-full bg-fg-muted`}),(0,X.jsx)(`span`,{children:e})]},e))})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.nextActions}),(0,X.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:p.nextActions.slice(0,4).map(e=>(0,X.jsxs)(`li`,{className:`flex gap-2`,children:[(0,X.jsx)(`span`,{className:`rounded bg-accent/10 px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-accent`,children:e.kind}),(0,X.jsx)(`span`,{children:e.text})]},`${e.kind}:${e.text}`))})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle pt-3`,children:[(0,X.jsx)(`span`,{className:`text-xs text-fg-muted`,children:u.confidenceLabel.replace(`{{percent}}`,String(Math.round(p.confidence*100)))}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>void C(`helpful`),className:T(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,f?.feedback===`helpful`&&`bg-accent/10 text-accent`),"aria-label":u.feedbackHelpfulAria,children:(0,X.jsx)(A,{className:`size-3.5`,"aria-hidden":!0})}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void C(`not_helpful`),className:T(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,f?.feedback===`not_helpful`&&`bg-accent/10 text-accent`),"aria-label":u.feedbackNotHelpfulAria,children:(0,X.jsx)(we,{className:`size-3.5`,"aria-hidden":!0})})]})]})]}):(0,X.jsx)(`div`,{className:`mt-4 rounded-lg border border-dashed border-edge-subtle px-3 py-6 text-center text-sm text-fg-muted`,children:u.noCatalysisReportHint}),(0,X.jsxs)(`section`,{className:`mt-6 rounded-xl bg-surface-base p-4`,children:[(0,X.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,X.jsx)(Ce,{className:`size-4 text-accent`,"aria-hidden":!0}),u.relatedThreadsTitle]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:u.relatedThreadsDescription})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:c,disabled:s,className:`rounded-lg border border-edge px-2.5 py-1.5 text-xs font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`,children:s?u.openingChat:u.openThread}),(0,X.jsx)(`button`,{type:`button`,onClick:l,disabled:s,className:`rounded-lg bg-accent px-2.5 py-1.5 text-xs font-medium text-white transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50`,children:u.newThread})]})]}),o.length>0?(0,X.jsx)(`div`,{className:`space-y-2`,children:o.slice(0,5).map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>d(`/chat/${encodeURIComponent(e.key)}`),className:`w-full rounded-lg border border-edge-subtle px-3 py-2 text-left transition-colors hover:bg-surface-hover`,children:[(0,X.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.name||u.noteDiscussionFallback}),(0,X.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:u.messageCount.replace(`{{count}}`,String(e.messageCount??0))})]},e.key))}):(0,X.jsx)(`div`,{className:`rounded-lg border border-dashed border-edge-subtle px-3 py-5 text-center text-sm text-fg-muted`,children:u.noThreads})]})]})]})}var rt=[{value:`86400000`,zh:`24 小时`,en:`24 hours`},{value:`604800000`,zh:`7 天`,en:`7 days`},{value:`2592000000`,zh:`30 天`,en:`30 days`}];function it({open:e,onOpenChange:t,note:n}){let r=w(e=>e.language)===`zh`,i=r?st:ct,{data:a,mutate:g}=E(e?[`note-shares`,n.id]:null,()=>F(n.id)),[S,C]=(0,Y.useState)(new Set),[T,O]=(0,Y.useState)(`86400000`),[k,A]=(0,Y.useState)(``),[j,M]=(0,Y.useState)(``),[N,P]=(0,Y.useState)(!1),[L,R]=(0,Y.useState)(null),[z,ee]=(0,Y.useState)(null),[te,B]=(0,Y.useState)(!1),[V,H]=(0,Y.useState)(null),ne=(0,Y.useMemo)(()=>{let e=new Set;return n.markdown.replace(/xopc-attachment:\/\/notes\/([^/]+)\/([^\s)]+)/gi,(t,r,i)=>{try{decodeURIComponent(r)===n.id&&e.add(decodeURIComponent(i))}catch{}return t}),(n.attachments??[]).filter(t=>e.has(t.id))},[n.attachments,n.id,n.markdown]);(0,Y.useEffect)(()=>{e&&(C(new Set(ne.map(e=>e.id))),ee(null),B(!1),H(null))},[e,ne]);let U=async()=>{P(!0),H(null);try{ee((await je(n.id,{expectedNoteVersion:n.updatedAt,attachmentIds:[...S],ttlMs:Number(T),maxViews:k.trim()?Number(k):null,description:j.trim()||void 0})).payload.shareUrl),await g()}catch(e){H(e instanceof Error?e.message:String(e))}finally{P(!1)}},re=async(e,t)=>{R(e.id),H(null);try{t===`refresh`?await I(n.id,e.id,{expectedNoteVersion:n.updatedAt,attachmentIds:[...S]}):t===`extend`?await ge(e.id,864e5):await De(e.id),await g()}catch(e){H(e instanceof Error?e.message:String(e))}finally{R(null)}},ie=async e=>{H(null);try{if(!await x(e)){B(!1),H(i.copyFailed);return}B(!0),window.setTimeout(()=>B(!1),1500)}catch{B(!1),H(i.copyFailed)}};return(0,X.jsx)(f,{open:e,onOpenChange:t,children:(0,X.jsxs)(l,{children:[(0,X.jsx)(o,{className:`fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),(0,X.jsxs)(u,{className:`fixed left-1/2 top-1/2 z-[71] flex h-[min(42rem,calc(100dvh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between border-b border-edge px-5 py-4`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(d,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[(0,X.jsx)(de,{className:`size-4`}),i.title]}),(0,X.jsx)(s,{className:`mt-1 text-xs text-fg-muted`,children:i.description})]}),(0,X.jsx)(c,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:`rounded-md p-1.5 text-fg-muted hover:bg-surface-hover`,"aria-label":i.close,children:(0,X.jsx)(b,{className:`size-4`})})})]}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,X.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-subtle p-4`,children:[(0,X.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.title||i.untitled}),(0,X.jsx)(`p`,{className:`mt-2 line-clamp-4 whitespace-pre-wrap text-xs leading-5 text-fg-muted`,children:n.markdown||i.empty}),(0,X.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:i.privateExcluded})]}),ne.length>0?(0,X.jsxs)(`section`,{className:`mt-5`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.attachments}),(0,X.jsx)(`div`,{className:`mt-2 grid gap-2`,children:ne.map(e=>(0,X.jsxs)(`label`,{className:`flex items-center gap-3 rounded-lg border border-edge-subtle px-3 py-2 text-sm text-fg-muted`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:S.has(e.id),onChange:()=>C(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n}),className:`accent-accent`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.fileName}),(0,X.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:ot(e.size)})]},e.id))})]}):null,(0,X.jsxs)(`section`,{className:`mt-5 grid gap-4 sm:grid-cols-2`,children:[(0,X.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[i.expires,(0,X.jsx)(m,{value:T,onChange:e=>O(e.target.value),children:rt.map(e=>(0,X.jsx)(h,{value:e.value,children:r?e.zh:e.en},e.value))})]}),(0,X.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[i.maxViews,(0,X.jsx)(`input`,{type:`number`,min:1,max:1e3,value:k,onChange:e=>A(e.target.value),placeholder:i.unlimited,className:`h-9 rounded-md border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent`})]}),(0,X.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted sm:col-span-2`,children:[i.publicDescription,(0,X.jsx)(`input`,{value:j,onChange:e=>M(e.target.value),className:`h-9 rounded-md border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent`})]})]}),z?(0,X.jsx)(`div`,{className:`mt-5 rounded-lg border border-success/25 bg-success-soft p-3`,children:(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`input`,{readOnly:!0,value:z,className:`min-w-0 flex-1 bg-transparent text-xs text-fg outline-none`}),(0,X.jsxs)(D,{type:`button`,className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void ie(z),children:[te?(0,X.jsx)(p,{className:`size-4`}):(0,X.jsx)(_,{className:`size-4`}),te?i.copied:i.copy]}),(0,X.jsxs)(D,{type:`button`,className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>window.open(z,`_blank`,`noopener,noreferrer`),children:[(0,X.jsx)(v,{className:`size-4`}),i.open]})]})}):null,V?(0,X.jsx)(`p`,{className:`mt-4 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-sm text-danger`,children:V}):null,(a?.items.length??0)>0?(0,X.jsxs)(`section`,{className:`mt-6 border-t border-edge pt-5`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.activeLinks}),(0,X.jsx)(`div`,{className:`mt-2 grid gap-2`,children:a.items.map(e=>(0,X.jsx)(at,{share:e,busy:L===e.id,t:i,onCopy:ie,onAction:re},e.id))})]}):null]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-edge px-5 py-3`,children:[(0,X.jsx)(c,{asChild:!0,children:(0,X.jsx)(D,{type:`button`,variant:`ghost`,children:i.close})}),(0,X.jsxs)(D,{type:`button`,onClick:()=>void U(),disabled:N,children:[N?(0,X.jsx)(y,{className:`size-4 animate-spin`}):(0,X.jsx)(de,{className:`size-4`}),N?i.creating:i.create]})]})]})]})})}function at(e){let t=(0,J.c)(68),{share:n,busy:r,t:i,onCopy:a,onAction:o}=e,s=n.revoked||n.expired,c=s&&`opacity-60`,l;t[0]===c?l=t[1]:(l=T(`rounded-lg border border-edge-subtle p-3`,c),t[0]=c,t[1]=l);let u=n.stale&&!s?i.stale:s?i.inactive:i.active,d;t[2]===u?d=t[3]:(d=(0,X.jsx)(`span`,{children:u}),t[2]=u,t[3]=d);let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,X.jsx)(`span`,{children:`·`}),t[4]=f):f=t[4];let p=n.maxViews===null?``:` / ${n.maxViews}`,m;t[5]!==n.viewCount||t[6]!==i.views||t[7]!==p?(m=(0,X.jsxs)(`span`,{children:[i.views,` `,n.viewCount,p]}),t[5]=n.viewCount,t[6]=i.views,t[7]=p,t[8]=m):m=t[8];let h;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,X.jsx)(`span`,{children:`·`}),t[9]=h):h=t[9];let g;t[10]===n.expiresAt?g=t[11]:(g=new Date(n.expiresAt).toLocaleDateString(),t[10]=n.expiresAt,t[11]=g);let b;t[12]===g?b=t[13]:(b=(0,X.jsx)(`span`,{children:g}),t[12]=g,t[13]=b);let x;t[14]!==b||t[15]!==d||t[16]!==m?(x=(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[d,f,m,h,b]}),t[14]=b,t[15]=d,t[16]=m,t[17]=x):x=t[17];let S;t[18]===n.shareUrl?S=t[19]:(S=(0,X.jsx)(`div`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:n.shareUrl}),t[18]=n.shareUrl,t[19]=S);let C;t[20]!==x||t[21]!==S?(C=(0,X.jsxs)(`div`,{className:`min-w-0`,children:[x,S]}),t[20]=x,t[21]=S,t[22]=C):C=t[22];let w;t[23]===r?w=t[24]:(w=r?(0,X.jsx)(y,{className:`size-4 animate-spin text-fg-muted`}):null,t[23]=r,t[24]=w);let E;t[25]!==C||t[26]!==w?(E=(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[C,w]}),t[25]=C,t[26]=w,t[27]=E):E=t[27];let O;t[28]!==a||t[29]!==n.shareUrl?(O=()=>void a(n.shareUrl),t[28]=a,t[29]=n.shareUrl,t[30]=O):O=t[30];let k;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,X.jsx)(_,{className:`size-3.5`}),t[31]=k):k=t[31];let A;t[32]!==i.copy||t[33]!==O?(A=(0,X.jsxs)(D,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:O,children:[k,i.copy]}),t[32]=i.copy,t[33]=O,t[34]=A):A=t[34];let j;t[35]===n.shareUrl?j=t[36]:(j=()=>window.open(n.shareUrl,`_blank`,`noopener,noreferrer`),t[35]=n.shareUrl,t[36]=j);let M;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,X.jsx)(v,{className:`size-3.5`}),t[37]=M):M=t[37];let N;t[38]!==i.open||t[39]!==j?(N=(0,X.jsxs)(D,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:j,children:[M,i.open]}),t[38]=i.open,t[39]=j,t[40]=N):N=t[40];let P;t[41]!==r||t[42]!==s||t[43]!==o||t[44]!==n||t[45]!==i.refresh?(P=n.stale&&!s?(0,X.jsxs)(D,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:r,onClick:()=>void o(n,`refresh`),children:[(0,X.jsx)(he,{className:`size-3.5`}),i.refresh]}):null,t[41]=r,t[42]=s,t[43]=o,t[44]=n,t[45]=i.refresh,t[46]=P):P=t[46];let F;t[47]!==r||t[48]!==s||t[49]!==o||t[50]!==n||t[51]!==i.extend?(F=s?null:(0,X.jsx)(D,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:r,onClick:()=>void o(n,`extend`),children:i.extend}),t[47]=r,t[48]=s,t[49]=o,t[50]=n,t[51]=i.extend,t[52]=F):F=t[52];let I;t[53]!==r||t[54]!==o||t[55]!==n||t[56]!==i.revoke?(I=n.revoked?null:(0,X.jsxs)(D,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:r,onClick:()=>void o(n,`revoke`),children:[(0,X.jsx)(Ee,{className:`size-3.5`}),i.revoke]}),t[53]=r,t[54]=o,t[55]=n,t[56]=i.revoke,t[57]=I):I=t[57];let L;t[58]!==A||t[59]!==N||t[60]!==P||t[61]!==F||t[62]!==I?(L=(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[A,N,P,F,I]}),t[58]=A,t[59]=N,t[60]=P,t[61]=F,t[62]=I,t[63]=L):L=t[63];let R;return t[64]!==E||t[65]!==l||t[66]!==L?(R=(0,X.jsxs)(`div`,{className:l,children:[E,L]}),t[64]=E,t[65]=l,t[66]=L,t[67]=R):R=t[67],R}function ot(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}var st={title:`分享笔记`,description:`创建一个无需登录即可查看的只读快照。`,close:`关闭`,untitled:`无标题笔记`,empty:`空笔记`,privateExcluded:`不会分享标签、AI 元数据、项目、讨论、历史版本或未引用附件。`,attachments:`包含的附件`,expires:`有效期`,maxViews:`最多查看次数`,unlimited:`不限`,publicDescription:`公开说明(可选)`,create:`创建分享链接`,creating:`创建中…`,copy:`复制`,copied:`已复制`,open:`打开`,activeLinks:`这条笔记的分享`,copyFailed:`无法复制到剪贴板,请手动选择链接并复制。`,stale:`旧版本`,inactive:`已失效`,active:`有效`,views:`查看`,refresh:`更新快照`,extend:`延长 24 小时`,revoke:`撤销`},ct={title:`Share Note`,description:`Create a read-only snapshot that opens without sign-in.`,close:`Close`,untitled:`Untitled Note`,empty:`Empty Note`,privateExcluded:`Tags, AI metadata, projects, discussions, history, and unreferenced attachments are excluded.`,attachments:`Included attachments`,expires:`Expires`,maxViews:`Maximum views`,unlimited:`Unlimited`,publicDescription:`Public description (optional)`,create:`Create share link`,creating:`Creating…`,copy:`Copy`,copied:`Copied`,open:`Open`,activeLinks:`Shares for this Note`,copyFailed:`Could not copy to the clipboard. Select the link and copy it manually.`,stale:`Older version`,inactive:`Inactive`,active:`Active`,views:`Views`,refresh:`Update snapshot`,extend:`Extend 24 hours`,revoke:`Revoke`};function lt(e){let t=(0,J.c)(17),{input:n,labels:r}=e,i;t[0]===n?i=t[1]:(i=n(),t[0]=n,t[1]=i);let a=i.source.id,o;t[2]===a?o=t[3]:(o=e=>e.source?.type===`note`&&e.source.id===a&&e.status!==`idle`,t[2]=a,t[3]=o);let s=le(o),c;t[4]===a?c=t[5]:(c=e=>e.source?.type===`note`&&e.source.id===a&&e.status===`preparing`,t[4]=a,t[5]=c);let l=le(c),u=le(ut),d;t[6]!==n||t[7]!==r||t[8]!==l?(d=(0,X.jsx)(ae,{input:n,labels:r,disabled:l,showLabel:!0}),t[6]=n,t[7]=r,t[8]=l,t[9]=d):d=t[9];let f;t[10]!==s||t[11]!==r||t[12]!==u?(f=s?(0,X.jsx)(`button`,{type:`button`,onClick:u,title:r.stop,"aria-label":r.stop,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,X.jsx)(Ne,{className:`size-3.5`,"aria-hidden":!0})}):null,t[10]=s,t[11]=r,t[12]=u,t[13]=f):f=t[13];let p;return t[14]!==d||t[15]!==f?(p=(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[d,f]}),t[14]=d,t[15]=f,t[16]=p):p=t[16],p}function ut(e){return e.stop}function dt(e,t){let n=L(t.replace(/^\s*(`{3,}|~{3,})[^\n]*$/gm,``).replace(/xopc-attachment:\/\/[^\s)]+/g,``).replace(/^(\s*[-*+]\s+)\[[ xX]\]\s*/gm,`$1`)),r=L(e);return!r||n.split(`
|
|
3
|
-
`)[0]===r?n:[r,n].filter(Boolean).join(`
|
|
4
|
-
|
|
5
|
-
`)}var ft=()=>i(()=>import(`./block-editor-D0CpUOMo.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49])),pt=()=>i(()=>import(`./markdown-editor-BjMTIM-m.js`),__vite__mapDeps([50,1,47,5,51,3])),mt=(0,Y.lazy)(()=>ft().then(e=>({default:e.BlockEditor}))),ht=(0,Y.lazy)(()=>pt().then(e=>({default:e.MarkdownEditor})));function gt(){let e=(0,J.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col px-6 py-4`,"aria-busy":!0,children:[(0,X.jsx)(`div`,{className:`h-8 w-56 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,X.jsx)(`div`,{className:`mt-6 h-4 w-11/12 animate-pulse rounded bg-surface-hover`}),(0,X.jsx)(`div`,{className:`mt-3 h-4 w-9/12 animate-pulse rounded bg-surface-hover`}),(0,X.jsx)(`div`,{className:`mt-3 h-4 w-10/12 animate-pulse rounded bg-surface-hover`})]}),e[0]=t):t=e[0],t}function _t(e){let t=(0,J.c)(14),{mode:n,onModeChange:r,labels:i}=e,a;t[0]===i.edit?a=t[1]:(a={id:`wysiwyg`,label:i.edit,Icon:Ae},t[0]=i.edit,t[1]=a);let o;t[2]===i.source?o=t[3]:(o={id:`source`,label:i.source,Icon:B},t[2]=i.source,t[3]=o);let s;t[4]===i.preview?s=t[5]:(s={id:`preview`,label:i.preview,Icon:U},t[4]=i.preview,t[5]=s);let c;t[6]!==a||t[7]!==o||t[8]!==s?(c=[a,o,s],t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9];let l=c,u;return t[10]!==n||t[11]!==l||t[12]!==r?(u=(0,X.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg border border-edge p-0.5`,children:l.map(e=>{let{id:t,label:i,Icon:a}=e;return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>r(t),onMouseEnter:()=>{t===`wysiwyg`&&ft(),t===`source`&&pt()},onFocus:()=>{t===`wysiwyg`&&ft(),t===`source`&&pt()},className:T(`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-xs font-medium transition-colors`,n===t?`bg-surface-hover text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:[(0,X.jsx)(a,{className:`size-3.5`,"aria-hidden":!0}),i]},t)})}),t[10]=n,t[11]=l,t[12]=r,t[13]=u):u=t[13],u}function vt(e){let t=(0,J.c)(16),{noteId:n,onBack:r,onSaved:i,showBackButton:a,backButtonClassName:o,clearHeaderOnCleanup:s,onOpenSearch:c,autoFocus:l,initialMode:u,onAutoFocusConsumed:d}=e,f=a===void 0?!0:a,p=s===void 0?!0:s,m=l===void 0?!1:l,h=w(yt),g;t[0]===h?g=t[1]:(g=S(h),t[0]=h,t[1]=g);let _=g.notes.lightboxClose,v;t[2]!==m||t[3]!==o||t[4]!==p||t[5]!==u||t[6]!==n||t[7]!==d||t[8]!==r||t[9]!==c||t[10]!==i||t[11]!==f?(v=(0,X.jsx)(bt,{noteId:n,onBack:r,onSaved:i,showBackButton:f,backButtonClassName:o,clearHeaderOnCleanup:p,onOpenSearch:c,autoFocus:m,initialMode:u,onAutoFocusConsumed:d}),t[2]=m,t[3]=o,t[4]=p,t[5]=u,t[6]=n,t[7]=d,t[8]=r,t[9]=c,t[10]=i,t[11]=f,t[12]=v):v=t[12];let y;return t[13]!==_||t[14]!==v?(y=(0,X.jsx)(Q,{closeLabel:_,children:v}),t[13]=_,t[14]=v,t[15]=y):y=t[15],y}function yt(e){return e.language}function bt({noteId:e,onBack:t,onSaved:n,showBackButton:r=!0,backButtonClassName:i,clearHeaderOnCleanup:o=!0,onOpenSearch:s,autoFocus:c=!1,initialMode:l=`wysiwyg`,onAutoFocusConsumed:u}){let d=w(e=>e.language),f=S(d).notes,p=S(d).automations.suggestions,m=a(),h=O(e=>e.resolved)===`dark`,{openImage:g}=Fe(),[_,v]=(0,Y.useState)(l),[y,b]=(0,Y.useState)(null),[x,C]=(0,Y.useState)(null),[D,k]=(0,Y.useState)(!1),[A,M]=(0,Y.useState)(``),[F,I]=(0,Y.useState)(360),[L,R]=(0,Y.useState)(!1),[z,B]=(0,Y.useState)(!1),[V,H]=(0,Y.useState)(!1),[ne,U]=(0,Y.useState)(null),[re,ie]=(0,Y.useState)(!1),[ae,se]=(0,Y.useState)(null),[ue,fe]=(0,Y.useState)(!1),[he,ge]=(0,Y.useState)(!1),ve=(0,Y.useRef)(!1),we=(0,Y.useRef)(!1),W=(0,Y.useRef)(null),G=(0,Y.useRef)(null),K=(0,Y.useRef)(null),q=(0,Y.useRef)(null),De=(0,Y.useRef)(null),Oe=(0,Y.useRef)(null),Ae=(0,Y.useRef)(null),je=(0,Y.useRef)(null),Ne=(0,Y.useRef)(null),J=ce(e=>e.setPageHeader),Pe=ce(e=>e.clearPageHeader),{data:Z,mutate:Q,error:Ie}=E(e?[`note-detail`,e]:null,()=>ke(e)),{data:Le=[],mutate:Re}=E(e?[`note-threads`,e]:null,()=>P(e),{revalidateOnFocus:!1}),ze=x!==null,Be=(0,Y.useCallback)(e=>{U(`${f.refreshFailed}: ${e instanceof Error?e.message:f.quickCaptureFailedHint}`)},[f.quickCaptureFailedHint,f.refreshFailed]);(0,Y.useEffect)(()=>{if(!e)return;let t=t=>{t.detail?.noteId===e&&Q().catch(Be)};return window.addEventListener(`note-updated`,t),()=>window.removeEventListener(`note-updated`,t)},[Q,e,Be]),(0,Y.useEffect)(()=>{ve.current=!1,M(``),C(null),b(null),we.current=!1,Ne.current=null},[e]),(0,Y.useEffect)(()=>{!Z||ve.current||(M(Z.title??``),ve.current=!0)},[Z]),(0,Y.useEffect)(()=>{if(!c||!Z||ze||Ne.current===e)return;let t=window.requestAnimationFrame(()=>{je.current?.focus(),u?.()});return Ne.current=e,()=>window.cancelAnimationFrame(t)},[c,ze,Z,e,u]);let Ve=Z?new Date(Z.createdAt).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):``,He=(0,Y.useMemo)(()=>r?(0,X.jsx)(`button`,{type:`button`,onClick:t,"aria-label":f.back,className:T(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,Se,i),children:(0,X.jsx)(be,{className:`size-4`,"aria-hidden":!0})}):null,[i,f.back,t,r]),$=(0,Y.useCallback)(()=>{let t=le.getState();t.source?.type===`note`&&t.source.id===e&&t.stop()},[e]),We=(0,Y.useCallback)(e=>{e!==`preview`&&$(),v(e)},[$]),Ge=(0,Y.useCallback)(t=>{$(),M(t),e&&(q.current=t,G.current&&clearTimeout(G.current),G.current=setTimeout(async()=>{let t=q.current;if(q.current=null,t!==null){k(!0);try{await te(e,{title:t}),await Q(),n?.()}catch{}finally{k(!1)}}},600))},[$,e,Q,n]),Ke=(0,Y.useMemo)(()=>(0,X.jsxs)(`div`,{className:T(`flex min-w-0 items-center gap-2`,Se),children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,title:A||Ve||void 0,children:A||Ve}),D?(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted opacity-60`,children:f.saving}):null]}),[f.saving,D,Ve,A]),qe=(0,Y.useCallback)(async(t=!1)=>{H(!0),U(null);try{let n=await Te(e,{forceNew:t});await Q(),await Re(),m(`/chat/${encodeURIComponent(n.sessionKey)}`)}catch(e){U(`${f.chatOpenFailedTitle}: ${e instanceof Error?e.message:f.chatOpenFailedMessage}`)}finally{H(!1)}},[Q,Re,m,e,f.chatOpenFailedMessage,f.chatOpenFailedTitle]),Je=(0,Y.useCallback)(async()=>{B(!0),U(null);try{await pe(e),await Q()}catch(e){U(`${f.catalysisFailed}: ${e instanceof Error?e.message:f.chatOpenFailedMessage}`)}finally{B(!1)}},[Q,e]),Xe=(0,Y.useCallback)(()=>{b(y===`breakdown`?null:`breakdown`),!Z?.aiDeep?.catalysis?.report&&!z&&Je()},[y,z,Je,Z?.aiDeep?.catalysis?.report]),Ze=(0,Y.useCallback)(()=>{let t=x?x.markdown??``:K.current??Z?.markdown??``,n=x?x.title??``:A,r=dt(n,t);return{source:{type:`note`,id:e,title:n||f.titlePlaceholder},text:r,language:ee(r,d)}},[d,f.titlePlaceholder,Z?.markdown,e,x,A]),Qe=(0,Y.useCallback)(async()=>{W.current&&clearTimeout(W.current),G.current&&clearTimeout(G.current),W.current=null,G.current=null;let t=K.current,r=q.current;K.current=null,q.current=null;let i={};if(t!==null&&(i.markdown=t),r!==null&&(i.title=r),Object.keys(i).length===0)return Z??null;k(!0);try{let t=await te(e,i);return await Q(t,{revalidate:!1}),n?.(),t}catch(e){return U(`${f.saveFailed}: ${e instanceof Error?e.message:f.saveFailedHint}`),null}finally{k(!1)}},[Q,f.saveFailed,f.saveFailedHint,Z,e,n]),$e=(0,Y.useCallback)(async()=>{U(null);let e=await Qe();e&&(se(e),ie(!0))},[Qe]),et=(0,Y.useCallback)(async()=>{if(!(he||D)){fe(!1),ge(!0),U(null),$(),W.current&&clearTimeout(W.current),G.current&&clearTimeout(G.current),W.current=null,G.current=null,K.current=null,q.current=null;try{await _e(e),window.dispatchEvent(new CustomEvent(`note-deleted`,{detail:{noteId:e}})),n?.(),t()}catch(e){U(`${f.deleteFailed}: ${e instanceof Error?e.message:f.quickCaptureFailedHint}`)}finally{ge(!1)}}},[he,f.deleteFailed,f.quickCaptureFailedHint,e,t,n,D,$]),rt=(0,Y.useMemo)(()=>(0,X.jsxs)(`div`,{className:T(`flex items-center gap-2`,Se),children:[s?(0,X.jsx)(`button`,{type:`button`,onClick:s,"aria-label":f.searchDialogTitle,className:`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,X.jsx)(ye,{className:`size-4`,"aria-hidden":!0})}):null,(0,X.jsx)(lt,{input:Ze,labels:{read:f.readAloud,preparing:f.readAloudPreparing,pause:f.readAloudPause,resume:f.readAloudResume,retry:f.readAloudRetry,stop:f.readAloudStop}}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>void $e(),className:`inline-flex items-center gap-1.5 rounded-lg border border-edge px-2.5 py-1.5 text-xs font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:[(0,X.jsx)(de,{className:`size-3.5`,"aria-hidden":!0}),d===`zh`?`分享`:`Share`]}),(0,X.jsxs)(`button`,{type:`button`,onClick:Xe,disabled:z,"aria-label":f.catalysisSectionTitle,className:T(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50`,y===`breakdown`?`bg-accent/10 text-accent`:`bg-accent/10 text-fg hover:bg-accent/15`),children:[(0,X.jsx)(oe,{className:`size-3.5`,"aria-hidden":!0}),z?f.catalyzing:f.catalyzeButton]}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>qe(!1),disabled:V,className:T(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors`,`border border-edge text-fg-muted hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`),children:[(0,X.jsx)(Ce,{className:`size-3.5`,"aria-hidden":!0}),V?f.openingChat:f.openChatButton]}),(0,X.jsx)(_t,{mode:_,onModeChange:We,labels:{edit:f.modeEdit,source:f.modeSource,preview:f.modePreview}}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>b(y===`history`?null:`history`),"aria-label":f.history,className:T(`rounded-lg p-1.5 transition-colors`,y===`history`?`bg-accent/10 text-accent`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:(0,X.jsx)(xe,{className:`size-4`,"aria-hidden":!0})}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>fe(!0),disabled:he||D,"aria-label":f.delete,title:f.delete,className:`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-danger-soft hover:text-danger focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-danger disabled:cursor-not-allowed disabled:opacity-50`,children:(0,X.jsx)(Ee,{className:`size-4`,"aria-hidden":!0})})]}),[z,Xe,qe,_,f.history,f.modeEdit,f.modePreview,f.modeSource,V,y,s,f.searchDialogTitle,f.readAloud,f.readAloudPause,f.readAloudPreparing,f.readAloudResume,f.readAloudRetry,f.readAloudStop,We,Ze,$e,he,D,d,f.delete,fe]);(0,Y.useLayoutEffect)(()=>(J({startExtra:He,main:Z?Ke:null,end:Z?rt:null}),()=>{o&&Pe()}),[o,Pe,rt,Ke,He,Z,J]);let at=(0,Y.useCallback)(t=>{e&&($(),K.current=t,W.current&&clearTimeout(W.current),W.current=setTimeout(async()=>{let t=K.current;if(K.current=null,t!==null){k(!0),U(null);try{await te(e,{markdown:t}),await Q(),n?.()}catch(e){U(`${f.saveFailed}: ${e instanceof Error?e.message:f.saveFailedHint}`)}finally{k(!1)}}},600))},[$,e,Q,f.saveFailed,f.saveFailedHint,n]),ot=(0,Y.useCallback)(t=>{j(e,t.timestamp).then(e=>{e&&($(),C(e))})},[e,$]),st=(0,Y.useCallback)(()=>{$(),b(null),C(null)},[$]),ct=(0,Y.useCallback)(()=>{$(),b(null),C(null),Q().catch(Be),n?.()},[Q,n,Be,$]);if((0,Y.useEffect)(()=>()=>{W.current&&clearTimeout(W.current),G.current&&clearTimeout(G.current);let t=K.current,n=q.current;K.current=null,q.current=null;let r={};t!==null&&(r.markdown=t),n!==null&&(r.title=n),Object.keys(r).length>0&&te(e,r).catch(()=>void 0)},[e]),Z===void 0)return Ie?(0,X.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center`,role:`alert`,children:[(0,X.jsx)(`p`,{className:`text-sm text-danger`,children:f.home.loadFailed}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void Q().catch(Be),className:`rounded-lg border border-edge px-3 py-2 text-sm text-fg hover:bg-surface-hover`,children:f.home.retry}),(0,X.jsx)(`button`,{type:`button`,onClick:t,className:`text-sm text-fg-muted hover:text-fg`,children:f.back})]}):(0,X.jsx)(gt,{});if(Z===null)return(0,X.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 text-center`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:f.notFoundTitle}),(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f.notFoundDescription}),(0,X.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-lg border border-edge px-3 py-1.5 text-sm font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:f.back})]});let ut=ze?x.title??``:A,ft=ze?x.markdown??``:K.current??Z.markdown??``,pt=new Date(Z.createdAt).getTime(),vt=Number.isFinite(pt)&&Date.now()-pt<3600*1e3?(0,X.jsx)(Ue,{title:p.noteCreatedTitle,description:p.noteCreatedDescription,prompt:p.noteCreatedPrompt,coverage:{eventType:`note.created`,source:`notes`,eventPayload:{noteId:e}},variant:`titleAction`,className:`ml-3 hidden max-w-[18rem] shrink-0 md:flex`}):null;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 gap-3 p-4 sm:px-5`,children:[(0,X.jsxs)(`div`,{className:`mx-auto flex min-h-0 min-w-0 w-full max-w-[60rem] flex-1 flex-col`,children:[ne?(0,X.jsx)(`p`,{className:`mb-3 shrink-0 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-sm text-danger`,role:`alert`,children:ne}):null,(0,X.jsx)(me,{eventType:`note.created`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),(0,X.jsx)(me,{eventType:`note.updated`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),(0,X.jsxs)(`div`,{ref:De,className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel xl:flex-row`,children:[(0,X.jsx)(Ye,{noteId:e}),(0,X.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1`,children:ze?(0,X.jsxs)(`div`,{className:`h-full overflow-y-auto px-6 py-4`,children:[ut&&(0,X.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg/70`,children:ut}),ft?(0,X.jsx)(Me,{noteId:e,content:ft,className:`opacity-80`}):(0,X.jsx)(`p`,{className:`italic text-fg-muted`,children:f.emptyPreview})]}):(0,X.jsxs)(X.Fragment,{children:[_===`wysiwyg`&&(0,X.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-start px-6 pt-4`,children:[(0,X.jsx)(`input`,{ref:je,type:`text`,value:A,onChange:e=>Ge(e.target.value),onCompositionStart:()=>{we.current=!0},onCompositionEnd:()=>{we.current=!1},onKeyDown:e=>{let t=e.nativeEvent;e.key===`Enter`&&!we.current&&!t.isComposing&&(e.preventDefault(),(De.current?.querySelector(`.ProseMirror`))?.focus())},placeholder:f.titlePlaceholder,className:`min-w-0 flex-1 border-none bg-transparent text-2xl font-bold text-fg placeholder:text-fg-muted/40 focus:outline-none`}),vt]}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(gt,{}),children:(0,X.jsx)(mt,{initialContent:Z.markdown??``,onChange:at,noteId:e},`wysiwyg-${e}`)})})]}),_===`source`&&(0,X.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-start px-6 pt-4`,children:[(0,X.jsx)(`input`,{ref:je,type:`text`,value:A,onChange:e=>Ge(e.target.value),placeholder:f.titlePlaceholder,className:`min-w-0 flex-1 border-none bg-transparent text-2xl font-bold text-fg placeholder:text-fg-muted/40 focus:outline-none`}),vt]}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(gt,{}),children:(0,X.jsx)(ht,{initialContent:Z.markdown??``,onChange:at,isDark:h},`source-${e}`)})})]}),_===`preview`&&(0,X.jsxs)(`div`,{className:`h-full overflow-y-auto px-6 py-4`,onClick:e=>{let t=e.target;t instanceof HTMLImageElement&&g(t.currentSrc||t.src,t.alt)},children:[A&&(0,X.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg`,children:A}),Z.markdown?(0,X.jsx)(Me,{noteId:e,content:Z.markdown,className:`[&_img]:cursor-zoom-in`}):(0,X.jsx)(`p`,{className:`italic text-fg-muted`,children:f.emptyPreview})]})]})})]})]}),(0,X.jsx)(`div`,{ref:Oe,className:T(`relative flex min-h-0 shrink-0 flex-col overflow-hidden`,!L&&`transition-[width] duration-300 ease-in-out`),style:{width:y?F:0},children:(0,X.jsxs)(`div`,{ref:Ae,className:`flex min-h-0 flex-1 flex-col`,style:{width:F},children:[(0,X.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,onPointerDown:e=>{e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId),R(!0);let n=e.clientX,r=F,i=e.pointerId,a=0,o=F,s=F,c=()=>{a=0,s=o,y&&Oe.current?.style.setProperty(`width`,`${s}px`),Ae.current?.style.setProperty(`width`,`${s}px`)},l=e=>{let t=r-(e.clientX-n);o=Math.max(280,Math.min(600,Math.round(t))),a===0&&(a=window.requestAnimationFrame(c))},u=()=>{a!==0&&(window.cancelAnimationFrame(a),c());try{t.releasePointerCapture(i)}catch{}R(!1),I(s),window.removeEventListener(`pointermove`,l),window.removeEventListener(`pointerup`,u),window.removeEventListener(`pointercancel`,u)};window.addEventListener(`pointermove`,l),window.addEventListener(`pointerup`,u),window.addEventListener(`pointercancel`,u)},className:T(`absolute left-0 top-0 z-10 h-full w-2 -translate-x-1/2 cursor-col-resize`,`before:content-[''] before:pointer-events-none before:absolute before:left-1/2 before:top-0 before:h-full before:w-px before:-translate-x-1/2`,`before:bg-transparent before:transition-[background-color] before:duration-150`,`hover:before:bg-edge/65 dark:hover:before:bg-edge/75`,L&&`before:!bg-edge/80 dark:before:!bg-edge/85`,`touch-none select-none`)}),(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel`,children:y===`history`?(0,X.jsx)(tt,{noteId:e,activeTimestamp:x?.timestamp??null,onSelect:ot,onClose:st,onRestored:ct}):y===`breakdown`?(0,X.jsx)(nt,{noteId:e,note:Z??null,catalyzing:z,onCatalyze:Je,onClose:()=>b(null),noteThreads:Le,openingChat:V,onOpenChat:()=>qe(!1),onOpenNewChat:()=>qe(!0)}):null})]})})]}),ae?(0,X.jsx)(it,{open:re,onOpenChange:ie,note:ae}):null,(0,X.jsx)(N,{open:ue,title:f.deleteConfirmTitle,description:f.deleteConfirmDescription.replace(`{{title}}`,Z.title||f.titlePlaceholder),confirmLabel:f.deleteConfirmLabel,cancelLabel:f.deleteCancelLabel,destructive:!0,onConfirm:()=>void et(),onCancel:()=>fe(!1)})]})}export{Fe as a,Be as i,He as n,Ve as r,vt as t};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{c as i,d as a,l as o,p as ee}from"./chunk-KS7C4IRE-BaASWQor.js";import{t as s}from"./popover-select-C-Hj-nXR.js";import{d as c}from"./markdown-view-Ca7BRBLL.js";import{t as l}from"./loader-circle-CifKLtgG.js";import{t as u}from"./plus-Q2yW6OE7.js";import{t as d}from"./x-B_N4OPjy.js";import{t as f}from"./messages-C72stReU.js";import{d as p,n as m,s as h}from"./locale-store-BkeaPZpn.js";import{t as g}from"./cn-JdwAhgNB.js";import{i as _}from"./vendor-swr-BIWyz7Rc.js";import{t as v}from"./skeleton-BwbyijEw.js";import{$c as y,Cl as te,Dc as ne,Di as b,Ln as x,On as re,Rn as S,Rs as C,Tn as w,Us as ie,Va as T,Vn as E,Yl as D,bc as O,bn as k,cu as A,dn as ae,du as j,ec as oe,fi as se,fl as ce,fn as le,fu as ue,gn as de,io as fe,kn as M,ks as pe,lu as N,mn as me,mu as he,nu as ge,pn as _e,tc as P,va as F,vn as ve,wc as ye,yl as be}from"./index-C7RDs6S-.js";import{i as xe,t as I}from"./note-detail-panel-EeVeF4II.js";var L=e(t(),1),R=n();async function z(e){e.note??=await ve({title:e.title,markdown:e.markdown,projectId:e.projectId,channel:`web`},e.requestId);let t=e.note.id;for(let n=e.attachments.length;n<e.files.length;n++)e.attachments.push(await S(t,e.files[n],`${e.requestId}:file:${n}`));if(e.attachments.length){let n=e.attachments.map(e=>`[${e.fileName.replace(/[\\[\]]/g,`\\$&`).replace(/[\r\n]/g,` `)}](${E(t,e.id)})`);e.note=await x(t,{markdown:`${e.markdown}\n\n## ${e.materialHeading}\n\n${n.join(`
|
|
2
|
-
|
|
3
|
-
`)}`})}return{noteId:t,sessionKey:(await M(t,{projectId:e.projectId})).sessionKey}}function Se(e,t,n){let r=new URLSearchParams({draft:n.replace(`{{id}}`,t),autoSend:`1`});return`/chat/${encodeURIComponent(e)}?${r}`}var B=r(),V={meeting:A,requirements:be,research:P,weekly:D};function Ce({projects:e,projectId:t,onProjectChange:n,onCreated:r,labels:i,projectsLoading:a,projectsError:ee}){let c=i.home,u=o(),[f,p]=(0,L.useState)(``),[m,h]=(0,L.useState)(null),[_,v]=(0,L.useState)([]),[y,te]=(0,L.useState)(!1),[b,x]=(0,L.useState)(null),[re,S]=(0,L.useState)(``),C=(0,L.useRef)(null),w=(0,L.useRef)(!1),T=(0,L.useRef)(null),E=(0,L.useRef)(null),D=y||!!C.current,k=m?c.templateOptions[m]:null,A=!!(f.trim()||_.length);async function ae(){if(!(w.current||!A&&!C.current)){w.current=!0,te(!0),x(null),C.current??={requestId:crypto.randomUUID(),title:f.trim().split(`
|
|
4
|
-
`)[0]?.slice(0,80)||k?.label||i.titlePlaceholder,markdown:`## ${c.requestHeading}\n\n${k?`${k.prompt}\n`:``}${f.trim()}`,projectId:t||void 0,files:[..._],attachments:[],materialHeading:c.materialsHeading};try{let e=await z(C.current);r(),u(Se(e.sessionKey,e.noteId,c.agentPrompt))}catch(e){C.current.note&&r(),x(e instanceof Error?e.message:i.quickCaptureFailedHint)}finally{w.current=!1,te(!1)}}}function j(){C.current=null,x(null),p(``),v([]),h(null),E.current?.focus()}return(0,B.jsxs)(`section`,{"aria-label":c.askLabel,children:[(0,B.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),ae()},className:`relative rounded-xl border border-edge bg-surface-panel p-4 focus-within:border-accent/60 sm:p-5`,children:[(0,B.jsxs)(`fieldset`,{disabled:D,className:`min-w-0`,children:[(0,B.jsxs)(`label`,{htmlFor:`notes-home-prompt`,className:`flex items-center gap-2 text-xs font-medium text-accent-fg`,children:[(0,B.jsx)(ie,{className:`size-4`,"aria-hidden":!0}),c.askLabel]}),k?(0,B.jsxs)(`div`,{className:`mt-3 flex items-start gap-2 rounded-lg bg-accent-soft px-3 py-2 text-xs leading-5 text-accent-fg`,children:[(0,B.jsxs)(`p`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`span`,{className:`font-medium`,children:[k.label,` · `]}),k.prompt.split(`
|
|
5
|
-
|
|
6
|
-
`)[0]]}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>h(null),"aria-label":i.searchClear,className:`shrink-0 rounded p-1 hover:bg-surface-hover`,children:(0,B.jsx)(d,{className:`size-3.5`})})]}):null,(0,B.jsx)(`textarea`,{ref:E,id:`notes-home-prompt`,value:f,onChange:e=>p(e.target.value),placeholder:k?k.prompt.split(`
|
|
7
|
-
|
|
8
|
-
`).at(-1):c.askPlaceholder,rows:2,onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),ae())},className:`mt-2 min-h-16 w-full resize-y bg-transparent py-2 text-base leading-6 text-fg outline-none placeholder:text-fg-muted sm:text-sm`}),_.length?(0,B.jsx)(`ul`,{className:`mb-3 flex flex-wrap gap-2`,children:_.map((e,t)=>(0,B.jsxs)(`li`,{className:`flex max-w-full items-center gap-2 rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:[(0,B.jsx)(O,{className:`size-3 shrink-0`,"aria-hidden":!0}),(0,B.jsx)(`span`,{className:`truncate`,children:e.name}),(0,B.jsx)(`button`,{type:`button`,"aria-label":`${c.removeMaterial}: ${e.name}`,onClick:()=>v(e=>e.filter((e,n)=>n!==t)),className:`rounded p-1 hover:bg-surface-hover`,children:(0,B.jsx)(d,{className:`size-3`})})]},`${e.name}-${t}`))}):null,(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 sm:pr-40`,children:[(0,B.jsx)(`div`,{className:`w-44 max-w-full`,children:(0,B.jsx)(s,{value:t,options:e.filter(e=>e.name.toLowerCase().includes(re.toLowerCase())).map(e=>({value:e.id,label:e.name})),selectedLabel:t?e.find(e=>e.id===t)?.name:c.unassigned,placeholder:c.unassigned,emptyLabel:c.unassigned,ariaLabel:c.assignProject,triggerIcon:(0,B.jsx)(ce,{className:`size-4 shrink-0`,"aria-hidden":!0}),triggerClassName:`h-8 border-transparent bg-transparent px-2 text-xs text-fg-muted hover:bg-surface-hover`,onChange:n,disabled:D,loading:a,statusMessage:ee?c.projectsLoadFailed:void 0,searchPlaceholder:c.projectSearch,searchValue:re,onSearchChange:S})}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>T.current?.click(),className:`inline-flex h-8 items-center gap-1.5 rounded-md px-2 text-xs text-fg-muted hover:bg-surface-hover`,children:[(0,B.jsx)(O,{className:`size-4`,"aria-hidden":!0}),c.addMaterials]}),(0,B.jsx)(`input`,{ref:T,type:`file`,multiple:!0,className:`hidden`,"aria-label":c.addMaterials,onChange:e=>{let t=Array.from(e.target.files??[]);v(e=>[...e,...t]),e.target.value=``}})]})]}),(0,B.jsx)(`div`,{className:`mt-2 flex justify-end sm:absolute sm:bottom-5 sm:right-5 sm:mt-0`,children:(0,B.jsxs)(`button`,{type:`submit`,disabled:y||!C.current&&!A,className:`inline-flex h-9 items-center gap-2 rounded-lg bg-accent px-4 text-sm font-medium text-white hover:bg-accent-hover focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`,children:[y?(0,B.jsx)(l,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,B.jsx)(N,{className:`size-4`,"aria-hidden":!0}),y?c.creating:b?c.retry:c.agentCreate]})})]}),b?(0,B.jsxs)(`div`,{className:`mt-3 rounded-lg border border-danger/25 bg-danger-soft px-3 py-3 text-xs text-danger`,role:`alert`,children:[(0,B.jsx)(`p`,{children:b}),C.current?.note?(0,B.jsx)(`p`,{className:`mt-1`,children:c.partialFailure}):null,(0,B.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-3`,children:[C.current?.note?(0,B.jsx)(`button`,{type:`button`,onClick:()=>u(`/notes/${encodeURIComponent(C.current.note.id)}?edit=1`),className:`underline`,children:c.openSavedDraft}):null,(0,B.jsx)(`button`,{type:`button`,onClick:j,className:`underline`,children:c.newRequest})]})]}):null,(0,B.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-1 gap-y-1 text-xs text-fg-muted`,children:[(0,B.jsx)(`span`,{className:`mr-1 py-2`,children:c.templates}),Object.keys(V).map(e=>{let t=V[e];return(0,B.jsxs)(`button`,{type:`button`,disabled:D,"aria-pressed":m===e,onClick:()=>{h(m===e?null:e),E.current?.focus()},className:g(`inline-flex items-center gap-1.5 rounded-md px-2 py-2 hover:bg-surface-hover disabled:opacity-50`,m===e&&`bg-accent-soft text-accent-fg`),children:[(0,B.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),c.templateOptions[e].label]},e)}),(0,B.jsxs)(`button`,{type:`button`,disabled:y,onClick:()=>F(),className:`ml-auto inline-flex items-center gap-1.5 rounded-md px-2 py-2 hover:bg-surface-hover`,children:[(0,B.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0}),c.recordDiscussion]})]})]})}function we(e,t){let n=Number(e.get(`page`)??0),r=Number.isSafeInteger(n)&&n>=0?n:0,i=e.get(`view`);return{projectId:e.get(`projectId`)||void 0,unassigned:e.get(`unassigned`)===`true`||i===`unassigned`||void 0,pinned:i===`favorites`?!0:void 0,agentEdited:i===`agent`||void 0,status:i===`archived`?`archived`:void 0,search:t.trim()||void 0,sortBy:`updatedAt`,sortOrder:`desc`,limit:12,offset:r*12}}function Te(e){let t=e.snippet?.trim()??``,n=e.title?.trim();return n&&t.startsWith(n)?t.slice(n.length).replace(/^[\s::·—-]+/,``):t}var H=`inline-flex min-h-9 items-center justify-center gap-2 rounded-lg px-3 text-sm text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50`;function U(){let e=m(e=>e.language),t=f(e).notes,n=t.home,r=h(e=>e.token),a=T(e=>e.setPageHeader),c=T(e=>e.clearPageHeader),d=o(),{pathname:ne,search:S}=i(),[E,D]=ee(),O=E.get(`projectId`)||``,M=E.get(`view`)||`all`,N=E.get(`unassigned`)===`true`||M===`unassigned`,P=E.get(`search`)||``,[F]=se(P,250),[I,R]=(0,L.useState)(O),[z,Se]=(0,L.useState)(``),[V,U]=(0,L.useState)(null),[W,Ee]=(0,L.useState)(!1),[De,Oe]=(0,L.useState)(new Set),[ke,Ae]=(0,L.useState)(null),[je,Me]=(0,L.useState)(null),G=(0,L.useRef)(new Set),K=(0,L.useRef)(null),Ne=(0,L.useRef)(!1),Pe=(0,L.useRef)(null),Fe=we(E,F),q=(Fe.offset??0)/12,{data:Ie,error:Le,isLoading:Re,mutate:ze}=_(r?[`notes-home`,r,Fe]:null,()=>re(Fe)),{data:Be,error:Ve,isLoading:J,mutate:He}=_(r?[`notes-home-projects`,r]:null,w),Y=Be?.items??[],Ue=Y.find(e=>e.id===O)?.name??n.projectNotes,We=Ie?.items??[],X=Ie?.total??0,Ge=Re||P!==F,Ke=(0,L.useMemo)(()=>({justNow:t.justNow,minutesAgo:t.minutesAgo,today:t.today,yesterday:t.yesterday,daysAgo:t.daysAgo,locale:p(e)}),[e,t.justNow,t.minutesAgo,t.today,t.yesterday,t.daysAgo]),[qe,Je]=(0,L.useState)(()=>Date.now());(0,L.useEffect)(()=>{R(O)},[O]),(0,L.useEffect)(()=>{let e=window.setInterval(()=>Je(Date.now()),6e4);return()=>window.clearInterval(e)},[]);let Z=(0,L.useCallback)(()=>{ze().catch(()=>void 0),He().catch(()=>void 0)},[ze,He]);(0,L.useEffect)(()=>{let e=[`note-updated`,`note-created`,`note-deleted`,`project-updated`,`project-created`,`project-deleted`];return e.forEach(e=>window.addEventListener(e,Z)),()=>e.forEach(e=>window.removeEventListener(e,Z))},[Z]);let Ye=(0,L.useCallback)((e,t=!1)=>{let n=`${ne}${S}`,r=new URLSearchParams({returnTo:n});t&&r.set(`edit`,`1`),d(`/notes/${encodeURIComponent(e)}?${r}`)},[ne,S,d]),Q=(0,L.useCallback)(async()=>{if(!(Ne.current||!r)){Ne.current=!0,Ee(!0),U(null),K.current??={key:crypto.randomUUID(),projectId:I||void 0};try{let e=await ve({markdown:``,kind:`thought`,projectId:K.current.projectId},K.current.key);K.current=null,Z(),Ye(e.id,!0)}catch(e){U(`${t.createBlankFailed}: ${e instanceof Error?e.message:t.createBlankFailedHint}`)}finally{Ne.current=!1,Ee(!1)}}},[I,t.createBlankFailed,t.createBlankFailedHint,Ye,Z,r]),Xe=(0,L.useCallback)(e=>{D(t=>{let n=new URLSearchParams(t);return e?n.set(`search`,e):n.delete(`search`),n.delete(`page`),n},{replace:!0})},[D]);function $(e,t=`all`){let n=new URLSearchParams;e&&n.set(`projectId`,e),t===`unassigned`?n.set(`unassigned`,`true`):t!==`all`&&n.set(`view`,t),R(e),D(n)}function Ze(e){D(t=>{let n=new URLSearchParams(t);return N&&n.set(`unassigned`,`true`),e===`all`?n.delete(`view`):n.set(`view`,e),n.delete(`page`),n})}async function Qe(e,n){if(!G.current.has(e)){G.current.add(e),Oe(new Set(G.current)),U(null);try{await x(e,{pinned:n}),Z()}catch(e){U(`${t.actionFailed}: ${e instanceof Error?e.message:t.quickCaptureFailedHint}`)}finally{G.current.delete(e),Oe(new Set(G.current))}}}async function $e(){let e=ke;if(!(!e||je)){Ae(null),Me(e.id),U(null);try{await k(e.id),window.dispatchEvent(new CustomEvent(`note-deleted`,{detail:{noteId:e.id}})),Z()}catch(e){U(`${t.deleteFailed}: ${e instanceof Error?e.message:t.quickCaptureFailedHint}`)}finally{Me(null)}}}if((0,L.useLayoutEffect)(()=>{if(!r){c();return}return a({startExtra:null,main:(0,B.jsx)(`h1`,{className:`truncate text-base font-semibold text-fg`,children:t.title}),end:(0,B.jsxs)(`div`,{className:g(`flex min-w-0 items-center gap-2`,fe),children:[(0,B.jsxs)(`label`,{className:`flex h-9 w-32 min-w-0 items-center gap-2 rounded-lg border border-edge bg-surface-panel px-2 sm:w-48`,children:[(0,B.jsx)(oe,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,B.jsx)(`input`,{ref:Pe,type:`search`,value:P,onChange:e=>Xe(e.target.value),"aria-label":t.searchDialogTitle,placeholder:t.searchPlaceholder,className:`min-w-0 flex-1 bg-transparent text-sm text-fg outline-none placeholder:text-fg-muted`})]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>void Q(),disabled:W,"aria-label":n.blankNote,className:g(H,`border border-edge bg-surface-panel text-fg`),children:[W?(0,B.jsx)(l,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,B.jsx)(u,{className:`size-4`,"aria-hidden":!0}),(0,B.jsx)(`span`,{className:`hidden sm:inline`,children:n.blankNote})]})]})}),()=>c()},[c,Q,W,n.blankNote,t.searchDialogTitle,t.searchPlaceholder,t.title,P,a,Xe,r]),(0,L.useEffect)(()=>{let e=e=>{!(e.metaKey||e.ctrlKey)||e.altKey||e.isComposing||e.target?.closest(`input, textarea, [contenteditable="true"], [role="dialog"]`)||(e.key.toLowerCase()===`n`&&(e.preventDefault(),Q()),e.key.toLowerCase()===`f`&&(e.preventDefault(),Pe.current?.focus()))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Q]),!r)return(0,B.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8 text-sm text-fg-muted`,children:t.needToken});let et=[{id:`all`,label:n.homeNav,Icon:ye},{id:`favorites`,label:n.favorites,Icon:C},{id:`unassigned`,label:n.unassigned,Icon:y},{id:`archived`,label:t.filterArchived,Icon:he}],tt=O?`project:${O}`:N?`unassigned`:`all`;return(0,B.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-1 overflow-hidden bg-surface-panel`,children:[(0,B.jsxs)(`aside`,{className:`hidden w-44 shrink-0 flex-col gap-1 overflow-y-auto px-3 py-6 xl:flex`,"aria-label":n.homeNav,children:[et.map(({id:e,label:t,Icon:n})=>(0,B.jsxs)(`button`,{type:`button`,onClick:()=>$(``,e),"aria-current":!O&&(e===`unassigned`?N:!N&&M===e)?`page`:void 0,className:g(H,`justify-start px-2 text-left text-xs`,!O&&(e===`unassigned`?N:!N&&M===e)&&`bg-surface-hover font-medium text-fg`),children:[(0,B.jsx)(n,{className:`size-4 shrink-0`,"aria-hidden":!0}),t]},e)),(0,B.jsx)(`span`,{className:`mb-1 mt-7 px-2 text-xs text-fg-muted`,children:n.projects}),J?[0,1,2].map(e=>(0,B.jsx)(v,{className:`mb-2 h-8 w-full`},e)):Y.slice(0,8).map(e=>(0,B.jsxs)(`button`,{type:`button`,onClick:()=>$(e.id),"aria-current":O===e.id?`page`:void 0,className:g(H,`justify-start px-2 text-left text-xs`,O===e.id&&`bg-surface-hover font-medium text-fg`),children:[(0,B.jsx)(ce,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,B.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id)),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>d(`/projects`),className:g(H,`mt-2 justify-start px-2 text-xs`),children:[n.allProjects,(0,B.jsx)(j,{className:`ml-auto size-3`,"aria-hidden":!0})]})]}),(0,B.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,B.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl px-4 py-7 sm:px-8 lg:px-10 lg:py-9`,children:[(0,B.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-start justify-between gap-4`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`h2`,{className:`break-words text-2xl font-semibold tracking-tight text-fg`,children:O?Ue:N?n.unassigned:n.homeTitle}),(0,B.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:O?n.projectDescription:n.homeDescription})]}),O?(0,B.jsxs)(`button`,{type:`button`,onClick:()=>d(`/projects/${encodeURIComponent(O)}`),className:g(H,`text-xs`),children:[n.openProject,(0,B.jsx)(j,{className:`size-3.5`,"aria-hidden":!0})]}):null]}),V?(0,B.jsx)(`p`,{className:`mb-4 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-sm text-danger`,role:`alert`,children:V}):null,(0,B.jsx)(Ce,{projects:Y,projectId:I,onProjectChange:R,onCreated:Z,labels:t,projectsLoading:J,projectsError:!!Ve}),Ve?(0,B.jsxs)(`div`,{role:`alert`,className:`mt-4 flex items-center gap-3 text-xs text-danger`,children:[(0,B.jsx)(`span`,{children:n.projectsLoadFailed}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>void He().catch(()=>void 0),className:`underline`,children:n.retry})]}):null,!O&&!N&&(J||Y.length>0)?(0,B.jsxs)(`section`,{className:`mt-8`,"aria-label":n.continueProjects,children:[(0,B.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.continueProjects}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>d(`/projects`),className:`text-xs text-fg-muted hover:text-fg`,children:n.allProjects})]}),(0,B.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:J?[0,1,2].map(e=>(0,B.jsx)(v,{className:`h-28 w-full`},e)):Y.slice(0,3).map(e=>(0,B.jsxs)(`button`,{type:`button`,onClick:()=>$(e.id),className:`min-w-0 rounded-lg border border-edge bg-surface-panel p-3 text-left transition-colors sm:p-4 hover:bg-surface-base focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,B.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,B.jsx)(ce,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,B.jsx)(`span`,{className:`truncate`,children:e.name})]}),e.description?(0,B.jsx)(`p`,{className:`mt-2 hidden line-clamp-1 text-xs text-fg-muted sm:block`,children:e.description}):null,(0,B.jsxs)(`span`,{className:`mt-2 flex flex-wrap items-center justify-between gap-1 text-xs text-fg-muted sm:mt-3`,children:[(0,B.jsx)(`span`,{children:t.noteCount.replace(`{{count}}`,String(e.noteCount))}),(0,B.jsx)(`span`,{children:e.updatedAt?xe(e.updatedAt,qe,Ke):n.emptyProject})]})]},e.id))})]}):null,(0,B.jsxs)(`section`,{className:`mt-8 pb-6`,"aria-label":n.recentNotes,children:[(0,B.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-3`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:O?n.projectNotes:n.recentNotes}),(0,B.jsx)(`div`,{className:`w-48 max-w-full`,children:(0,B.jsx)(s,{value:tt,allowEmpty:!1,ariaLabel:n.projects,placeholder:n.allNotes,options:[{value:`all`,label:n.allNotes},{value:`unassigned`,label:n.unassigned},...Y.filter(e=>e.name.toLowerCase().includes(z.toLowerCase())).map(e=>({value:`project:${e.id}`,label:e.name}))],selectedLabel:O?Ue:N?n.unassigned:n.allNotes,triggerClassName:`h-8 bg-surface-panel text-xs`,loading:J,searchPlaceholder:n.projectSearch,searchValue:z,onSearchChange:Se,onChange:e=>$(e.startsWith(`project:`)?e.slice(8):``,e===`unassigned`?e:`all`)})})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-5 border-b border-edge`,"aria-label":t.libraryTitle,children:[[{id:`all`,label:t.filterAll},{id:`agent`,label:n.agentEdited},{id:`favorites`,label:n.favorites},{id:`archived`,label:t.filterArchived}].map(({id:e,label:t})=>(0,B.jsx)(`button`,{type:`button`,"aria-pressed":M===e||e===`all`&&M===`unassigned`,onClick:()=>Ze(e),className:g(`border-b-2 border-transparent py-3 text-xs text-fg-muted hover:text-fg`,(M===e||e===`all`&&M===`unassigned`)&&`border-fg font-medium text-fg`),children:t},e)),(0,B.jsx)(`span`,{className:`ml-auto py-3 text-xs text-fg-muted`,children:n.sortUpdated})]}),Le?(0,B.jsxs)(`div`,{className:`py-10 text-center`,role:`alert`,children:[(0,B.jsx)(`p`,{className:`text-sm text-danger`,children:n.loadFailed}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>void ze().catch(()=>void 0),className:g(H,`mt-2`),children:n.retry})]}):Ge?(0,B.jsx)(`div`,{"aria-busy":`true`,className:`divide-y divide-edge`,children:[0,1,2,3].map(e=>(0,B.jsxs)(`div`,{className:`flex items-center gap-3 py-4`,children:[(0,B.jsx)(v,{className:`h-10 w-8 shrink-0`}),(0,B.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,B.jsx)(v,{className:`h-4 w-2/3`}),(0,B.jsx)(v,{className:`h-3 w-1/2`})]})]},e))}):We.length===0?(0,B.jsxs)(`div`,{className:`flex flex-col items-center px-4 py-12 text-center`,children:[(0,B.jsx)(ye,{className:`mb-4 size-8 text-fg-muted`,strokeWidth:1.3,"aria-hidden":!0}),(0,B.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:P||M!==`all`&&M!==`unassigned`?n.noMatches:O?n.projectEmpty:n.emptyTitle}),(0,B.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-fg-muted`,children:P||M!==`all`&&M!==`unassigned`?n.noMatchesHint:O?n.projectEmptyHint:n.emptyDescription})]}):(0,B.jsx)(`ul`,{className:`divide-y divide-edge`,children:We.map(e=>{let r=e.voiceAttachmentId||e.kind===`voice`?A:e.kind===`bookmark`?ge:be,i=Te(e)||(e.coverAttachmentId?t.imageNote:t.noText);return(0,B.jsxs)(`li`,{className:`group flex min-w-0 items-center gap-3 py-4`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>Ye(e.id),className:`flex min-w-0 flex-1 items-center gap-3 rounded-md text-left focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,B.jsx)(`span`,{className:`flex h-10 w-8 shrink-0 items-center justify-center rounded-md border border-edge text-fg-muted`,children:(0,B.jsx)(r,{className:`size-4`,"aria-hidden":!0})}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg group-hover:text-accent-fg`,children:e.title||t.titlePlaceholder}),(0,B.jsxs)(`span`,{className:`mt-1 flex min-w-0 items-center gap-1.5 text-xs text-fg-muted`,children:[e.lastEditTrigger===`ai_edit`?(0,B.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-accent-fg`,children:[(0,B.jsx)(ie,{className:`size-3`,"aria-hidden":!0}),n.agentEditLabel,(0,B.jsx)(`span`,{"aria-hidden":!0,children:`·`})]}):null,(0,B.jsx)(`span`,{className:`truncate`,children:i})]})]})]}),(0,B.jsx)(`span`,{className:`hidden max-w-32 truncate text-xs text-fg-muted md:block`,title:e.projects?.map(e=>e.name).join(` · `),children:e.projects?.map(e=>e.name).join(` · `)||n.unassigned}),(0,B.jsx)(`time`,{dateTime:new Date(e.updatedAt).toISOString(),className:`hidden w-24 shrink-0 text-right text-xs text-fg-muted sm:block`,children:xe(e.updatedAt,qe,Ke)}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>void Qe(e.id,!e.pinned),disabled:De.has(e.id),"aria-label":`${e.pinned?n.unfavorite:n.favorite}: ${e.title||t.titlePlaceholder}`,"aria-pressed":!!e.pinned,className:`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50 focus-visible:ring-2 focus-visible:ring-accent`,children:(0,B.jsx)(C,{className:g(`size-4`,e.pinned&&`fill-current text-fg`),"aria-hidden":!0})}),(0,B.jsxs)(me,{children:[(0,B.jsx)(de,{asChild:!0,children:(0,B.jsx)(`button`,{type:`button`,disabled:je===e.id,"aria-label":`${t.noteActions}: ${e.title||t.titlePlaceholder}`,className:`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50 focus-visible:ring-2 focus-visible:ring-accent`,children:je===e.id?(0,B.jsx)(l,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,B.jsx)(te,{className:`size-4`,"aria-hidden":!0})})}),(0,B.jsx)(_e,{children:(0,B.jsx)(ae,{align:`end`,sideOffset:4,className:`z-50 min-w-36 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:(0,B.jsxs)(le,{className:`flex cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-danger-soft focus:bg-danger-soft`,onSelect:()=>Ae(e),children:[(0,B.jsx)(pe,{className:`size-4`,"aria-hidden":!0}),t.delete]})})})]})]},e.id)})}),!Ge&&!Le&&X>0?(0,B.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-between gap-3 text-xs text-fg-muted`,"aria-live":`polite`,children:[(0,B.jsx)(`span`,{children:t.noteCount.replace(`{{count}}`,String(X))}),X>12||q>0?(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,"aria-label":n.previousPage,disabled:q===0,className:H,onClick:()=>D(e=>{let t=new URLSearchParams(e);return t.set(`page`,String(q-1)),t}),children:(0,B.jsx)(ue,{className:`size-4`,"aria-hidden":!0})}),(0,B.jsxs)(`span`,{children:[q+1,` / `,Math.max(1,Math.ceil(X/12))]}),(0,B.jsx)(`button`,{type:`button`,"aria-label":n.nextPage,disabled:(q+1)*12>=X,className:H,onClick:()=>D(e=>{let t=new URLSearchParams(e);return t.set(`page`,String(q+1)),t}),children:(0,B.jsx)(j,{className:`size-4`,"aria-hidden":!0})})]}):null]}):null]})]})}),(0,B.jsx)(b,{open:ke!==null,title:t.deleteConfirmTitle,description:t.deleteConfirmDescription.replace(`{{title}}`,ke?.title||t.titlePlaceholder),confirmLabel:t.deleteConfirmLabel,cancelLabel:t.deleteCancelLabel,destructive:!0,onConfirm:()=>void $e(),onCancel:()=>Ae(null)})]})}function W(){let e=(0,R.c)(12),{noteId:t}=a(),n=o(),[r]=ee(),i;e[0]===r?i=e[1]:(i=c(r.get(`returnTo`),`/notes`,[`/chat`,`/projects`,`/notes`,`/tasks`]),e[0]=r,e[1]=i);let s=i,l;e[2]!==n||e[3]!==s?(l=()=>{n(s)},e[2]=n,e[3]=s,e[4]=l):l=e[4];let u=l;if(!t)return null;let d=r.get(`edit`)===`1`?`wysiwyg`:`preview`,f;e[5]===r?f=e[6]:(f=r.get(`edit`),e[5]=r,e[6]=f);let p=f===`1`,m;return e[7]!==u||e[8]!==t||e[9]!==d||e[10]!==p?(m=(0,B.jsx)(`div`,{className:`mx-auto flex h-full min-h-0 w-full max-w-6xl flex-1 flex-col`,children:(0,B.jsx)(I,{noteId:t,onBack:u,initialMode:d,autoFocus:p},t)}),e[7]=u,e[8]=t,e[9]=d,e[10]=p,e[11]=m):m=e[11],m}function Ee(){let e=(0,R.c)(2),{noteId:t}=a(),n;return e[0]===t?n=e[1]:(n=t?(0,B.jsx)(W,{}):(0,B.jsx)(U,{}),e[0]=t,e[1]=n),n}export{Ee as NotesPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-BaASWQor.js";import{a,i as o,n as s,o as c,r as l,s as u,t as d}from"./dist-CpzYSoz7.js";import{n as f,r as p}from"./popover-select-C-Hj-nXR.js";import{t as m}from"./loader-circle-CifKLtgG.js";import{t as h}from"./plus-Q2yW6OE7.js";import{t as g}from"./x-B_N4OPjy.js";import{t as ee}from"./messages-C72stReU.js";import{n as _}from"./locale-store-BkeaPZpn.js";import{t as v}from"./cn-JdwAhgNB.js";import{t as y}from"./button-CtTvuElV.js";import{t as b}from"./skeleton-BwbyijEw.js";import{Ri as x,Va as S,Xi as C,Yi as w,Zi as T,ca as E,du as D,ea as O,ec as k,gc as A,hc as te,hl as j,ia as M,ic as N,ml as P,mu as F,wr as I,zi as ne}from"./index-C7RDs6S-.js";var L=n(),R=e(t(),1),z=r();function B(e,t){if(e==null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:I(n)}function re(e){return[...e].sort((e,t)=>{let n=Number(!!t.pinnedAt)-Number(!!e.pinnedAt);return n===0?new Date(t.lastActiveAt??t.updatedAt).getTime()-new Date(e.lastActiveAt??e.updatedAt).getTime():n})}function ie(){let e=(0,L.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,"aria-busy":!0,children:Array.from({length:6},V)}),e[0]=t):t=e[0],t}function V(e,t){return(0,z.jsx)(b,{className:`h-40 rounded-xl`},t)}function ae(e){let t=(0,L.c)(59),{project:n,busy:r,onTogglePin:a,onToggleArchive:o}=e,s=_(H),c,l,u,d,f,p,m,h;if(t[0]!==s||t[1]!==n.brief||t[2]!==n.description||t[3]!==n.id||t[4]!==n.lastActiveAt||t[5]!==n.name||t[6]!==n.status||t[7]!==n.updatedAt||t[8]!==n.workspaceRoot){let e=ee(s).projectsPage;c=e.management,m=`flex h-full flex-col rounded-xl border border-edge-subtle bg-surface-base p-4`;let r;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,z.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-accent-soft text-accent`,children:(0,z.jsx)(j,{className:`size-4`,"aria-hidden":!0})}),t[17]=r):r=t[17];let a;t[18]===n.name?a=t[19]:(a=(0,z.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[18]=n.name,t[19]=a);let o=(0,z.jsxs)(`div`,{className:`min-w-0`,children:[a,(0,z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:e.statuses[n.status]})]}),g;t[20]===o?g=t[21]:(g=(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[r,o]}),t[20]=o,t[21]=g);let _;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,z.jsx)(D,{className:`mt-2 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[22]=_):_=t[22];let v;t[23]===g?v=t[24]:(v=(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[g,_]}),t[23]=g,t[24]=v),h=(0,z.jsxs)(i,{to:`/projects/${encodeURIComponent(n.id)}`,className:`group flex min-w-0 flex-1 flex-col rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[v,(0,z.jsx)(`p`,{className:`mt-3 line-clamp-2 min-h-10 text-xs leading-5 text-fg-muted`,children:n.description||n.brief||e.noDescription})]}),p=`mt-3 flex shrink-0 items-end justify-between gap-3 border-t border-edge-subtle pt-3`,d=`min-w-0 text-[11px] text-fg-subtle`,f=(0,z.jsx)(`p`,{className:`truncate`,children:n.workspaceRoot||e.agentDefault}),l=`mt-1`,u=B(n.lastActiveAt??n.updatedAt,e.never),t[0]=s,t[1]=n.brief,t[2]=n.description,t[3]=n.id,t[4]=n.lastActiveAt,t[5]=n.name,t[6]=n.status,t[7]=n.updatedAt,t[8]=n.workspaceRoot,t[9]=c,t[10]=l,t[11]=u,t[12]=d,t[13]=f,t[14]=p,t[15]=m,t[16]=h}else c=t[9],l=t[10],u=t[11],d=t[12],f=t[13],p=t[14],m=t[15],h=t[16];let g;t[25]!==l||t[26]!==u?(g=(0,z.jsx)(`p`,{className:l,children:u}),t[25]=l,t[26]=u,t[27]=g):g=t[27];let v;t[28]!==d||t[29]!==f||t[30]!==g?(v=(0,z.jsxs)(`div`,{className:d,children:[f,g]}),t[28]=d,t[29]=f,t[30]=g,t[31]=v):v=t[31];let b=n.pinnedAt?c.unpin:c.pin,x=n.pinnedAt?c.unpin:c.pin,S;t[32]===n.pinnedAt?S=t[33]:(S=n.pinnedAt?(0,z.jsx)(te,{className:`size-4`,"aria-hidden":!0}):(0,z.jsx)(A,{className:`size-4`,"aria-hidden":!0}),t[32]=n.pinnedAt,t[33]=S);let C;t[34]!==r||t[35]!==a||t[36]!==b||t[37]!==x||t[38]!==S?(C=(0,z.jsx)(y,{type:`button`,variant:`ghost`,className:`size-8 p-0`,disabled:r,onClick:a,"aria-label":b,title:x,children:S}),t[34]=r,t[35]=a,t[36]=b,t[37]=x,t[38]=S,t[39]=C):C=t[39];let w=n.status===`archived`?c.restore:c.archive,T=n.status===`archived`?c.restore:c.archive,E;t[40]===n.status?E=t[41]:(E=n.status===`archived`?(0,z.jsx)(N,{className:`size-4`,"aria-hidden":!0}):(0,z.jsx)(F,{className:`size-4`,"aria-hidden":!0}),t[40]=n.status,t[41]=E);let O;t[42]!==r||t[43]!==o||t[44]!==w||t[45]!==T||t[46]!==E?(O=(0,z.jsx)(y,{type:`button`,variant:`ghost`,className:`size-8 p-0`,disabled:r,onClick:o,"aria-label":w,title:T,children:E}),t[42]=r,t[43]=o,t[44]=w,t[45]=T,t[46]=E,t[47]=O):O=t[47];let k;t[48]!==C||t[49]!==O?(k=(0,z.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[C,O]}),t[48]=C,t[49]=O,t[50]=k):k=t[50];let M;t[51]!==k||t[52]!==p||t[53]!==v?(M=(0,z.jsxs)(`div`,{className:p,children:[v,k]}),t[51]=k,t[52]=p,t[53]=v,t[54]=M):M=t[54];let P;return t[55]!==M||t[56]!==m||t[57]!==h?(P=(0,z.jsxs)(`article`,{className:m,children:[h,M]}),t[55]=M,t[56]=m,t[57]=h,t[58]=P):P=t[58],P}function H(e){return e.language}function U(){let e=ee(_(e=>e.language)),t=e.projectsPage,n=t.management,r=e.chat.workingDirectory,i=S(e=>e.setPageHeader),b=S(e=>e.clearPageHeader),[D,A]=(0,R.useState)([]),[te,N]=(0,R.useState)(!0),[F,I]=(0,R.useState)(null),[L,B]=(0,R.useState)(``),[V,H]=(0,R.useState)(!1),[U,oe]=(0,R.useState)(`active`),[se,ce]=(0,R.useState)(null),[le,W]=(0,R.useState)(!1),[G,K]=(0,R.useState)(null),[q,ue]=(0,R.useState)(!1),[J,de]=(0,R.useState)(``),[Y,fe]=(0,R.useState)(``),[X,pe]=(0,R.useState)(``),Z=E({initialPath:X,onPicked:pe}),Q=(0,R.useCallback)(async()=>{N(!0),I(null);try{A(re((await w({limit:100,sortBy:`updatedAt`,sortOrder:`desc`})).items))}catch(e){I(e instanceof Error?e.message:String(e))}finally{N(!1)}},[]);(0,R.useEffect)(()=>{Q()},[Q]);let $=(0,R.useMemo)(()=>{let e=L.trim().toLocaleLowerCase();return D.filter(e=>U===`all`||e.status===U).filter(t=>!e||[t.name,t.description,t.brief,t.workspaceRoot].filter(Boolean).some(t=>t.toLocaleLowerCase().includes(e)))},[U,D,L]),me=(0,R.useMemo)(()=>(0,z.jsxs)(y,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>W(!0),children:[(0,z.jsx)(h,{className:`size-4`,"aria-hidden":!0}),t.create]}),[t.create]);(0,R.useLayoutEffect)(()=>(i({startExtra:null,main:(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),(0,z.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:n.subtitle})]}),end:me}),()=>b()),[b,me,n.subtitle,n.title,i]);let he=(0,R.useCallback)(async e=>{e.preventDefault();let t=J.trim(),n=X.trim();if(!(!t||!n||q)){ue(!0),K(null);try{let e=await ne({name:t,...Y.trim()?{description:Y.trim()}:{},workspaceRoot:n});A(t=>[e,...t.filter(t=>t.id!==e.id)]),de(``),fe(``),pe(``),W(!1),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch(e){K(e instanceof Error?e.message:String(e))}finally{ue(!1)}}},[q,Y,J,X]),ge=(0,R.useCallback)(async(e,t)=>{ce(e.id),I(null);try{let n;n=t===`pin`?e.pinnedAt?await O(e.id):await C(e.id):e.status===`archived`?await T(e.id):await x(e.id),A(e=>e.map(e=>e.id===n.id?n:e)),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch(e){I(e instanceof Error?e.message:String(e))}finally{ce(null)}},[]),_e=[{id:`active`,label:t.statuses.active},{id:`paused`,label:t.statuses.paused},{id:`archived`,label:t.statuses.archived},{id:`all`,label:t.all}],ve=_e.find(e=>e.id===U)?.label??t.all,ye=n.resultCount.replace(`{{status}}`,ve).replace(`{{count}}`,String($.length));return(0,z.jsxs)(`main`,{className:`flex w-full flex-1 flex-col gap-5 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,z.jsx)(d,{open:le,onOpenChange:e=>{W(e),e||K(null)},children:(0,z.jsxs)(c,{children:[(0,z.jsx)(a,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,z.jsxs)(l,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(34rem,calc(100vh-2rem))] w-[min(38rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,z.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,z.jsx)(u,{className:`text-base font-semibold text-fg`,children:t.createTitle}),(0,z.jsx)(o,{className:`mt-1 text-sm text-fg-muted`,children:t.createDescription})]}),(0,z.jsxs)(`form`,{onSubmit:he,className:`flex min-h-0 flex-1 flex-col`,children:[(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[t.projectName,(0,z.jsx)(`input`,{className:`h-10 rounded-lg border border-edge bg-surface-base px-3 font-normal outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`,value:J,onChange:e=>de(e.target.value),maxLength:160})]}),(0,z.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[n.descriptionLabel,(0,z.jsx)(`textarea`,{className:`min-h-28 resize-none rounded-lg border border-edge bg-surface-base px-3 py-2 font-normal leading-6 outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`,value:Y,onChange:e=>fe(e.target.value),maxLength:2e3,placeholder:n.descriptionPlaceholder})]}),(0,z.jsxs)(`div`,{className:`grid gap-1.5 text-sm`,children:[(0,z.jsx)(`span`,{className:`font-medium text-fg`,children:t.workspaceRoot}),(0,z.jsxs)(`button`,{type:`button`,className:`flex min-h-12 w-full items-center gap-3 rounded-lg border border-edge bg-surface-base px-3 py-2 text-left outline-none transition-colors hover:bg-surface-hover focus-visible:border-accent focus-visible:ring-2 focus-visible:ring-accent/20 disabled:cursor-not-allowed disabled:opacity-60`,onClick:Z.pick,disabled:q||Z.picking,children:[Z.picking?(0,z.jsx)(m,{className:`size-5 shrink-0 animate-spin text-accent`,"aria-hidden":!0}):(0,z.jsx)(P,{className:`size-5 shrink-0 text-accent`,"aria-hidden":!0}),(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:X?r.chooseFolder:r.selectWorkingDirectory}),(0,z.jsx)(`span`,{className:v(`mt-0.5 block truncate font-mono text-xs font-normal`,X?`text-fg-muted`:`text-fg-subtle`),title:X||void 0,children:X||t.workspaceSelectionPlaceholder})]})]}),(0,z.jsx)(`p`,{className:`text-xs font-normal text-fg-subtle`,children:t.workspaceSelectionHint})]}),G?(0,z.jsx)(`p`,{className:`rounded-lg bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:G}):null]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,z.jsx)(s,{asChild:!0,children:(0,z.jsx)(y,{type:`button`,variant:`ghost`,children:t.cancel})}),(0,z.jsx)(y,{type:`submit`,variant:`primary`,disabled:q||!J.trim()||!X.trim(),children:q?t.home.creating:t.create})]})]})]})]})}),Z.hasNativePicker?null:(0,z.jsx)(M,{open:Z.modalOpen,onOpenChange:Z.setModalOpen,initialAbsolutePath:X||void 0,onConfirm:Z.confirmPick,wd:r}),(0,z.jsxs)(`section`,{className:`flex min-h-10 flex-wrap items-center justify-between gap-3`,"aria-label":n.filterLabel,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,"aria-live":`polite`,children:ye}),(0,z.jsxs)(`div`,{className:v(`ml-auto flex min-w-0 items-center justify-end gap-2`,V&&`w-full sm:w-auto`),children:[V?(0,z.jsxs)(`div`,{className:`relative min-w-0 flex-1 sm:w-64 sm:flex-none`,children:[(0,z.jsx)(k,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,z.jsx)(`input`,{autoFocus:!0,className:`h-9 w-full rounded-lg border border-edge bg-surface-panel pl-9 pr-9 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:L,onChange:e=>B(e.target.value),placeholder:t.searchPlaceholder,"aria-label":t.searchPlaceholder}),(0,z.jsx)(`button`,{type:`button`,className:`absolute right-1.5 top-1/2 flex size-6 -translate-y-1/2 items-center justify-center rounded-md text-fg-subtle transition-colors hover:bg-surface-hover hover:text-fg`,onClick:()=>{B(``),H(!1)},"aria-label":n.clearSearch,title:n.clearSearch,children:(0,z.jsx)(g,{className:`size-3.5`,"aria-hidden":!0})})]}):(0,z.jsx)(y,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,onClick:()=>H(!0),"aria-label":t.searchPlaceholder,title:t.searchPlaceholder,children:(0,z.jsx)(k,{className:`size-4`,"aria-hidden":!0})}),(0,z.jsx)(f,{className:`w-28 sm:w-32`,triggerClassName:`h-9 border-edge bg-surface-panel px-2.5 text-xs font-medium`,contentClassName:`min-w-36`,align:`end`,value:U,"aria-label":n.filterLabel,onChange:e=>oe(e.target.value),children:_e.map(e=>(0,z.jsx)(p,{value:e.id,children:e.label},e.id))})]})]}),F?(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl border border-danger/25 bg-danger-soft px-4 py-3 text-sm text-danger`,role:`alert`,children:[(0,z.jsx)(`span`,{children:F}),(0,z.jsx)(y,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>void Q(),children:t.home.retry})]}):null,te?(0,z.jsx)(ie,{}):$.length?(0,z.jsx)(`section`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:$.map(e=>(0,z.jsx)(ae,{project:e,busy:se===e.id,onTogglePin:()=>void ge(e,`pin`),onToggleArchive:()=>void ge(e,`archive`)},e.id))}):(0,z.jsxs)(`section`,{className:`rounded-xl border border-dashed border-edge p-10 text-center`,children:[(0,z.jsx)(j,{className:`mx-auto size-7 text-fg-subtle`,"aria-hidden":!0}),(0,z.jsx)(`h2`,{className:`mt-3 text-sm font-semibold text-fg`,children:n.emptyTitle}),(0,z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.emptyHint})]})]})}export{U as ProjectsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i,p as a,t as o}from"./chunk-KS7C4IRE-BaASWQor.js";import{a as s,i as c,o as l,r as u,s as d,t as f}from"./dist-CpzYSoz7.js";import{t as p}from"./check-DUBLcKHA.js";import{t as m}from"./copy-Dv6d4Dvw.js";import{t as h}from"./external-link-DjqjBmc3.js";import{t as g}from"./globe-DSSGFWFn.js";import{t as _}from"./loader-circle-CifKLtgG.js";import{t as v}from"./copy-to-clipboard-HOJ79TWv.js";import{t as y}from"./messages-C72stReU.js";import{n as b,s as x}from"./locale-store-BkeaPZpn.js";import{t as S}from"./cn-JdwAhgNB.js";import{i as C}from"./vendor-swr-BIWyz7Rc.js";import{t as w}from"./button-CtTvuElV.js";import{n as T,r as E}from"./gateway-config-swr-BW3Bx-aV.js";import{i as D,o as O}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{Di as k,Jl as A,Kl as j,Ks as M,L as N,Ms as P,Os as F,Qs as I,R as L,Rl as R,Tc as z,Tt as B,Ws as V,Xa as H,Xc as ee,di as U,du as te,sa as ne,uc as W,vt as re,xt as ie,yt as ae,z as oe}from"./index-C7RDs6S-.js";import{n as G,r as K,t as q}from"./settings-page-layout-BRQNel6r.js";import{a as J,c as se,d as Y,g as ce,i as le,l as ue,n as de,o as fe,r as pe,s as me,t as he,u as ge}from"./tunnel-api-C__W9BaN.js";import{n as X,r as _e,t as ve}from"./settings-form-section-CBic9TFH.js";import{t as ye}from"./page-tabs-pyukZ1PJ.js";import{t as be}from"./settings-advanced-gate-CcSYDjaH.js";var Z=e(t(),1),Q=n(),$=r();function xe(e){switch(e){case`active`:return`bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`;case`connecting`:return`bg-amber-500/15 text-amber-700 dark:text-amber-400`;default:return`bg-surface-hover text-fg-muted`}}function Se(e){let t=(0,Q.c)(5),{label:n,kind:r}=e,i;t[0]===r?i=t[1]:(i=S(`rounded-full px-2 py-0.5 text-[11px] font-medium`,xe(r)),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,$.jsx)(`span`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function Ce(e){let t=(0,Q.c)(31),{onOpenTab:n}=e,r=b(Te),i;t[0]===r?i=t[1]:(i=y(r),t[0]=r,t[1]=i);let a=i.remoteAccess.guide,o=!!x(we),s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s={refreshInterval:3e4},t[2]=s):s=t[2];let{data:c}=C(o?`exposure-status`:null,ge,s),l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l={refreshInterval:15e3},t[3]=l):l=t[3];let{data:u}=C(o?`tunnel-status`:null,he,l),d=E(o);if(!o)return null;let f=c?.tailscale.active===!0,p=u?.state,m=u?.enabled&&p===`connected`,h=u?.enabled&&(p===`connecting`||p===`reconnecting`||!!u?.startProgress||!!u?.frpcDownload),_=d.data?.payload?.config,v=!!(_&&typeof _==`object`&&!Array.isArray(_)&&_.gateway?.publicUrl),w=f?`active`:`off`,T=f?a.statusActive:a.statusOff,D;t[4]!==a.tailscaleCardTitle||t[5]!==w||t[6]!==T?(D={tab:`tailscale`,icon:g,title:a.tailscaleCardTitle,kind:w,statusLabel:T},t[4]=a.tailscaleCardTitle,t[5]=w,t[6]=T,t[7]=D):D=t[7];let O=m?`active`:h?`connecting`:`off`,k=m?a.statusActive:h?a.statusConnecting:a.statusOff,A;t[8]!==a.publicCardTitle||t[9]!==O||t[10]!==k?(A={tab:`public`,icon:z,title:a.publicCardTitle,kind:O,statusLabel:k},t[8]=a.publicCardTitle,t[9]=O,t[10]=k,t[11]=A):A=t[11];let j=v?`active`:`off`,N=v?a.statusActive:a.statusOff,F;t[12]!==a.reverseProxyCardTitle||t[13]!==j||t[14]!==N?(F={tab:`reverse-proxy`,icon:M,title:a.reverseProxyCardTitle,kind:j,statusLabel:N},t[12]=a.reverseProxyCardTitle,t[13]=j,t[14]=N,t[15]=F):F=t[15];let L;t[16]!==a.sshCardStatus||t[17]!==a.sshCardTitle?(L={tab:`ssh`,icon:P,title:a.sshCardTitle,kind:`off`,statusLabel:a.sshCardStatus},t[16]=a.sshCardStatus,t[17]=a.sshCardTitle,t[18]=L):L=t[18];let R;t[19]!==a.lanCardStatus||t[20]!==a.lanCardTitle?(R={tab:`lan`,icon:I,title:a.lanCardTitle,kind:`off`,statusLabel:a.lanCardStatus},t[19]=a.lanCardStatus,t[20]=a.lanCardTitle,t[21]=R):R=t[21];let B;t[22]!==F||t[23]!==L||t[24]!==R||t[25]!==D||t[26]!==A?(B=[D,A,F,L,R],t[22]=F,t[23]=L,t[24]=R,t[25]=D,t[26]=A,t[27]=B):B=t[27];let V=B,H;return t[28]!==V||t[29]!==n?(H=(0,$.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5`,children:V.map(e=>{let t=e.icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.tab),className:S(`flex items-start gap-3 rounded-xl bg-surface-base px-3 py-2.5 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/50`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,$.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,children:(0,$.jsx)(t,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(Se,{label:e.statusLabel,kind:e.kind})]})]},`${e.tab}-${e.title}`)})}),t[28]=V,t[29]=n,t[30]=H):H=t[30],H}function we(e){return e.token}function Te(e){return e.language}function Ee(e){let t=(0,Q.c)(26),{title:n,description:r,recommended:i,icon:a,onOpen:o,openLabel:s,recommendedLabel:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=S(`group flex w-full flex-col rounded-2xl bg-surface-base p-4 text-left transition-colors`,`hover:bg-surface-hover/40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=l):l=t[0];let u;t[1]===a?u=t[2]:(u=(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,children:(0,$.jsx)(a,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=a,t[2]=u);let d;t[3]===n?d=t[4]:(d=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=d);let f;t[5]!==i||t[6]!==c?(f=i&&c?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:c}):null,t[5]=i,t[6]=c,t[7]=f):f=t[7];let p;t[8]!==d||t[9]!==f?(p=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[d,f]}),t[8]=d,t[9]=f,t[10]=p):p=t[10];let m;t[11]===r?m=t[12]:(m=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=m);let h;t[13]!==p||t[14]!==m?(h=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[p,m]}),t[13]=p,t[14]=m,t[15]=h):h=t[15];let g;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(j,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[16]=g):g=t[16];let _;t[17]!==u||t[18]!==h?(_=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[u,h,g]}),t[17]=u,t[18]=h,t[19]=_):_=t[19];let v;t[20]===s?v=t[21]:(v=(0,$.jsx)(`span`,{className:`mt-3 text-xs font-medium text-accent`,children:s}),t[20]=s,t[21]=v);let y;return t[22]!==o||t[23]!==v||t[24]!==_?(y=(0,$.jsxs)(`button`,{type:`button`,onClick:o,className:l,children:[_,v]}),t[22]=o,t[23]=v,t[24]=_,t[25]=y):y=t[25],y}function De(e){let t=(0,Q.c)(83),{onOpenTab:n}=e,r=b(Ae),i;t[0]===r?i=t[1]:(i=y(r),t[0]=r,t[1]=i);let a=i.remoteAccess,o=a.guide,s=!!x(ke),c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c={refreshInterval:3e4},t[2]=c):c=t[2];let{data:l}=C(s?`exposure-status`:null,ge,c),u;t[3]===l?.conflicts?u=t[4]:(u=l?.conflicts??[],t[3]=l?.conflicts,t[4]=u);let d=u;if(!s){let e;return t[5]===o.needToken?e=t[6]:(e=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.needToken}),t[5]=o.needToken,t[6]=e),e}let f;t[7]===n?f=t[8]:(f=(0,$.jsx)(Ce,{onOpenTab:n}),t[7]=n,t[8]=f);let p;t[9]!==d||t[10]!==o.conflictsHint||t[11]!==o.conflictsTitle?(p=d.length>0?(0,$.jsxs)(`div`,{className:`rounded-xl border border-amber-500/30 bg-amber-500/5 px-4 py-3 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:o.conflictsTitle}),(0,$.jsx)(`p`,{className:`mt-1`,children:o.conflictsHint}),(0,$.jsx)(`ul`,{className:`mt-2 list-inside list-disc text-xs`,children:d.map(Oe)})]}):null,t[9]=d,t[10]=o.conflictsHint,t[11]=o.conflictsTitle,t[12]=p):p=t[12];let m;t[13]===o.pickMethod?m=t[14]:(m=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:o.pickMethod}),t[13]=o.pickMethod,t[14]=m);let h;t[15]===n?h=t[16]:(h=()=>n(`tailscale`),t[15]=n,t[16]=h);let _;t[17]!==o.configure||t[18]!==o.recommended||t[19]!==o.tailscaleCardDesc||t[20]!==o.tailscaleCardTitle||t[21]!==h?(_=(0,$.jsx)(Ee,{icon:g,title:o.tailscaleCardTitle,description:o.tailscaleCardDesc,recommended:!0,recommendedLabel:o.recommended,openLabel:o.configure,onOpen:h}),t[17]=o.configure,t[18]=o.recommended,t[19]=o.tailscaleCardDesc,t[20]=o.tailscaleCardTitle,t[21]=h,t[22]=_):_=t[22];let v;t[23]===n?v=t[24]:(v=()=>n(`public`),t[23]=n,t[24]=v);let S;t[25]!==o.configure||t[26]!==o.publicCardDesc||t[27]!==o.publicCardTitle||t[28]!==v?(S=(0,$.jsx)(Ee,{icon:z,title:o.publicCardTitle,description:o.publicCardDesc,openLabel:o.configure,onOpen:v}),t[25]=o.configure,t[26]=o.publicCardDesc,t[27]=o.publicCardTitle,t[28]=v,t[29]=S):S=t[29];let w;t[30]===n?w=t[31]:(w=()=>n(`reverse-proxy`),t[30]=n,t[31]=w);let T;t[32]!==o.configure||t[33]!==o.reverseProxyCardDesc||t[34]!==o.reverseProxyCardTitle||t[35]!==w?(T=(0,$.jsx)(Ee,{icon:M,title:o.reverseProxyCardTitle,description:o.reverseProxyCardDesc,openLabel:o.configure,onOpen:w}),t[32]=o.configure,t[33]=o.reverseProxyCardDesc,t[34]=o.reverseProxyCardTitle,t[35]=w,t[36]=T):T=t[36];let E;t[37]===n?E=t[38]:(E=()=>n(`ssh`),t[37]=n,t[38]=E);let D;t[39]!==o.configure||t[40]!==o.sshCardDesc||t[41]!==o.sshCardTitle||t[42]!==E?(D=(0,$.jsx)(Ee,{icon:P,title:o.sshCardTitle,description:o.sshCardDesc,openLabel:o.configure,onOpen:E}),t[39]=o.configure,t[40]=o.sshCardDesc,t[41]=o.sshCardTitle,t[42]=E,t[43]=D):D=t[43];let O;t[44]===n?O=t[45]:(O=()=>n(`lan`),t[44]=n,t[45]=O);let k;t[46]!==o.configure||t[47]!==o.lanCardDesc||t[48]!==o.lanCardTitle||t[49]!==O?(k=(0,$.jsx)(Ee,{icon:I,title:o.lanCardTitle,description:o.lanCardDesc,openLabel:o.configure,onOpen:O}),t[46]=o.configure,t[47]=o.lanCardDesc,t[48]=o.lanCardTitle,t[49]=O,t[50]=k):k=t[50];let A;t[51]!==S||t[52]!==T||t[53]!==D||t[54]!==k||t[55]!==_?(A=(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:[_,S,T,D,k]}),t[51]=S,t[52]=T,t[53]=D,t[54]=k,t[55]=_,t[56]=A):A=t[56];let j;t[57]!==A||t[58]!==m?(j=(0,$.jsxs)(`div`,{children:[m,A]}),t[57]=A,t[58]=m,t[59]=j):j=t[59];let N;t[60]===o.oneAtATimeHint?N=t[61]:(N=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:o.oneAtATimeHint}),t[60]=o.oneAtATimeHint,t[61]=N);let F;t[62]===a.advanced.proxyTitle?F=t[63]:(F=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.advanced.proxyTitle}),t[62]=a.advanced.proxyTitle,t[63]=F);let L;t[64]===a.advanced.proxyBody?L=t[65]:(L=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.advanced.proxyBody}),t[64]=a.advanced.proxyBody,t[65]=L);let R;t[66]!==r||t[67]!==a.advanced.proxyDocs?(R=(0,$.jsx)(Y,{language:r,label:a.advanced.proxyDocs,section:`advanced`,className:`mt-2`}),t[66]=r,t[67]=a.advanced.proxyDocs,t[68]=R):R=t[68];let B;t[69]!==F||t[70]!==L||t[71]!==R?(B=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base px-4 py-3`,children:[F,L,R]}),t[69]=F,t[70]=L,t[71]=R,t[72]=B):B=t[72];let V;t[73]!==o.docsLink||t[74]!==r?(V=(0,$.jsx)(Y,{language:r,label:o.docsLink}),t[73]=o.docsLink,t[74]=r,t[75]=V):V=t[75];let H;return t[76]!==j||t[77]!==N||t[78]!==B||t[79]!==V||t[80]!==f||t[81]!==p?(H=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[f,p,j,N,B,V]}),t[76]=j,t[77]=N,t[78]=B,t[79]=V,t[80]=f,t[81]=p,t[82]=H):H=t[82],H}function Oe(e){return(0,$.jsx)(`li`,{children:e.message},e.code)}function ke(e){return e.token}function Ae(e){return e.language}function je(){let e=(0,Q.c)(16),t=b(Me),n;e[0]===t?n=e[1]:(n=y(t),e[0]=t,e[1]=n);let r=n.remoteAccess.lan,i;e[2]!==r.subtitle||e[3]!==r.title?(i=(0,$.jsx)(X,{icon:I,title:r.title,subtitle:r.subtitle}),e[2]=r.subtitle,e[3]=r.title,e[4]=i):i=e[4];let a;e[5]===r.body?a=e[6]:(a=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.body}),e[5]=r.body,e[6]=a);let s;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(h,{className:`size-3.5`,"aria-hidden":!0}),e[7]=s):s=e[7];let c;e[8]===r.link?c=e[9]:(c=(0,$.jsxs)(o,{to:`/settings/gateway`,className:`inline-flex items-center gap-1.5 text-sm font-medium text-accent hover:underline`,children:[r.link,s]}),e[8]=r.link,e[9]=c);let l;e[10]!==a||e[11]!==c?(l=(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[a,c]}),e[10]=a,e[11]=c,e[12]=l):l=e[12];let u;return e[13]!==i||e[14]!==l?(u=(0,$.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,$.jsxs)(ve,{children:[i,l]})}),e[13]=i,e[14]=l,e[15]=u):u=e[15],u}function Me(e){return e.language}function Ne(e){let t=(0,Q.c)(30),{embedded:n}=e,r=n===void 0?!1:n,i=b(Pe),a;t[0]===i?a=t[1]:(a=y(i),t[0]=i,t[1]=a);let o=a.remoteAccess.ssh,[s,c]=(0,Z.useState)(!1),l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=async()=>{await v(`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`)&&(c(!0),setTimeout(()=>c(!1),2e3))},t[2]=l):l=t[2];let u=l,d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`pre`,{className:`overflow-x-auto rounded-lg border border-edge bg-surface px-3 py-2 text-xs text-fg-muted`,children:`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`}),t[3]=d):d=t[3];let f,p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>void u(),p=(0,$.jsx)(m,{className:`mr-1 size-4`}),t[4]=f,t[5]=p):(f=t[4],p=t[5]);let h=s?o.copied:o.copy,g;t[6]===h?g=t[7]:(g=(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsxs)(w,{type:`button`,variant:`ghost`,onClick:f,children:[p,h]})}),t[6]=h,t[7]=g);let _;t[8]!==r||t[9]!==o.hint?(_=r?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:o.hint}):null,t[8]=r,t[9]=o.hint,t[10]=_):_=t[10];let x;t[11]!==g||t[12]!==_?(x=(0,$.jsxs)($.Fragment,{children:[d,g,_]}),t[11]=g,t[12]=_,t[13]=x):x=t[13];let S=x;if(r){let e;t[14]!==o.subtitle||t[15]!==o.title?(e=(0,$.jsx)(X,{icon:P,title:o.title,subtitle:o.subtitle}),t[14]=o.subtitle,t[15]=o.title,t[16]=e):e=t[16];let n;t[17]===S?n=t[18]:(n=(0,$.jsx)(`div`,{className:`mt-4 space-y-2`,children:S}),t[17]=S,t[18]=n);let r;return t[19]!==e||t[20]!==n?(r=(0,$.jsxs)(ve,{children:[e,n]}),t[19]=e,t[20]=n,t[21]=r):r=t[21],r}let C;t[22]!==o.subtitle||t[23]!==o.title?(C=(0,$.jsx)(X,{icon:P,title:o.title,subtitle:o.subtitle}),t[22]=o.subtitle,t[23]=o.title,t[24]=C):C=t[24];let T;t[25]===S?T=t[26]:(T=(0,$.jsx)(`div`,{className:`mt-4`,children:S}),t[25]=S,t[26]=T);let E;return t[27]!==C||t[28]!==T?(E=(0,$.jsxs)(ve,{children:[C,T]}),t[27]=C,t[28]=T,t[29]=E):E=t[29],E}function Pe(e){return e.language}function Fe(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Ne,{embedded:!0}),e[0]=t):t=e[0],t}var Ie=[`guide`,`tailscale`,`public`,`reverse-proxy`,`ssh`,`lan`];function Le(e){return e&&Ie.includes(e)?e:`guide`}function Re(e){let t=(0,Q.c)(26),{showLabel:n,hideLabel:r,icon:i,hint:a,children:o,className:s,defaultOpen:c,advancedOnly:l}=e,u=l===void 0?!1:l,[d,f]=(0,Z.useState)(c??!1),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=e=>f(e.currentTarget.open),t[0]=p):p=t[0];let m;t[1]===s?m=t[2]:(m=S(`group rounded-2xl bg-surface-base open:pb-1`,s),t[1]=s,t[2]=m);let h;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(A,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[3]=h):h=t[3];let g;t[4]===i?g=t[5]:(g=i?(0,$.jsx)(i,{className:`size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}):null,t[4]=i,t[5]=g);let _;t[6]===n?_=t[7]:(_=(0,$.jsx)(`span`,{className:`group-open:hidden`,children:n}),t[6]=n,t[7]=_);let v;t[8]===r?v=t[9]:(v=(0,$.jsx)(`span`,{className:`hidden group-open:inline`,children:r}),t[8]=r,t[9]=v);let y;t[10]!==g||t[11]!==_||t[12]!==v?(y=(0,$.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 rounded-2xl px-4 py-3.5 text-sm font-medium text-fg transition-colors hover:text-fg group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:[h,g,_,v]}),t[10]=g,t[11]=_,t[12]=v,t[13]=y):y=t[13];let b;t[14]===a?b=t[15]:(b=a?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:a}):null,t[14]=a,t[15]=b);let x;t[16]!==o||t[17]!==b?(x=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 px-4 pb-4 pt-1`,children:[b,o]}),t[16]=o,t[17]=b,t[18]=x):x=t[18];let C;t[19]!==d||t[20]!==x||t[21]!==m||t[22]!==y?(C=(0,$.jsxs)(`details`,{open:d,onToggle:p,className:m,children:[y,x]}),t[19]=d,t[20]=x,t[21]=m,t[22]=y,t[23]=C):C=t[23];let w=C;if(u){let e;return t[24]===w?e=t[25]:(e=(0,$.jsx)(be,{children:w}),t[24]=w,t[25]=e),e}return w}function ze(e){let t=(0,Q.c)(40),{open:n,title:r,intro:i,bullets:a,checkboxLabel:o,confirmLabel:p,cancelLabel:m,onConfirm:h,onCancel:g}=e,[_,v]=(0,Z.useState)(!1),y;t[0]===g?y=t[1]:(y=e=>{e||(v(!1),g())},t[0]=g,t[1]=y);let b;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(s,{className:S(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,O)}),t[2]=b):b=t[2];let x;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(x=S(`fixed left-1/2 top-1/2 max-h-[min(90vh,40rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`,D),t[3]=x):x=t[3];let C;t[4]===r?C=t[5]:(C=(0,$.jsx)(d,{className:`text-base font-semibold text-fg`,children:r}),t[4]=r,t[5]=C);let T;t[6]===i?T=t[7]:(T=(0,$.jsx)(c,{className:`mt-2 text-sm text-fg-muted`,children:i}),t[6]=i,t[7]=T);let E;t[8]===a?E=t[9]:(E=a.map(Be),t[8]=a,t[9]=E);let k;t[10]===E?k=t[11]:(k=(0,$.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5 text-sm text-fg-muted`,children:E}),t[10]=E,t[11]=k);let A;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>v(e.target.checked),t[12]=A):A=t[12];let j;t[13]===_?j=t[14]:(j=(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 shrink-0 rounded border-edge accent-accent`,checked:_,onChange:A}),t[13]=_,t[14]=j);let M;t[15]===o?M=t[16]:(M=(0,$.jsx)(`span`,{children:o}),t[15]=o,t[16]=M);let N;t[17]!==M||t[18]!==j?(N=(0,$.jsxs)(`label`,{className:`mt-5 flex cursor-pointer items-start gap-3 text-sm text-fg`,children:[j,M]}),t[17]=M,t[18]=j,t[19]=N):N=t[19];let P;t[20]!==m||t[21]!==g?(P=(0,$.jsx)(w,{type:`button`,variant:`secondary`,onClick:g,children:m}),t[20]=m,t[21]=g,t[22]=P):P=t[22];let F=!_,I;t[23]!==p||t[24]!==h||t[25]!==F?(I=(0,$.jsx)(w,{type:`button`,disabled:F,onClick:h,children:p}),t[23]=p,t[24]=h,t[25]=F,t[26]=I):I=t[26];let L;t[27]!==P||t[28]!==I?(L=(0,$.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[P,I]}),t[27]=P,t[28]=I,t[29]=L):L=t[29];let R;t[30]!==N||t[31]!==L||t[32]!==C||t[33]!==T||t[34]!==k?(R=(0,$.jsxs)(l,{children:[b,(0,$.jsxs)(u,{className:x,onOpenAutoFocus:Ve,children:[C,T,k,N,L]})]}),t[30]=N,t[31]=L,t[32]=C,t[33]=T,t[34]=k,t[35]=R):R=t[35];let z;return t[36]!==n||t[37]!==y||t[38]!==R?(z=(0,$.jsx)(f,{open:n,onOpenChange:y,children:R}),t[36]=n,t[37]=y,t[38]=R,t[39]=z):z=t[39],z}function Be(e){return(0,$.jsx)(`li`,{children:e},e)}function Ve(e){return e.preventDefault()}function He(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var Ue=[`preparing_frpc`,`registering`,`starting_frpc`];function We(e){return e?e===`reconnecting_frpc`?Ue.indexOf(`starting_frpc`):Ue.indexOf(e):-1}function Ge(e,t){if(t.state===`connected`)return`done`;let n=t.startProgress?.phase,r=Ue.indexOf(e),i=We(n);return i<0?t.state===`connecting`||t.state===`reconnecting`?`active`:`pending`:r<i?`done`:r===i?`active`:`pending`}function Ke(e,t,n){let r=n.startProgress;return Ge(t,n)===`active`?t===`preparing_frpc`&&n.frpcDownload?n.frpcDownload.phase===`extracting`?e.frpcExtracting:n.frpcDownload.percent==null?e.frpcDownloading:e.frpcDownloadingPercent.replace(`{{percent}}`,String(n.frpcDownload.percent)):t===`registering`&&r?.publicUrl?e.stepRegisterDetail:t===`starting_frpc`?r?.phase===`reconnecting_frpc`?e.stepReconnectDetail:e.stepFrpcDetail:null:null}function qe(e,t){switch(t){case`preparing_frpc`:return e.stepPrepareFrpc;case`registering`:return e.stepRegister;case`starting_frpc`:return e.stepFrpcLogin}}function Je(e){if(!e)return null;let t=Math.max(0,Math.floor((Date.now()-new Date(e).getTime())/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function Ye(e){let t=(0,Q.c)(31),{status:n,t:r}=e,[,i]=(0,Z.useState)(0),a;t[0]!==i||t[1]!==n.state?(a=()=>{if(n.state!==`connecting`&&n.state!==`reconnecting`)return;let e=window.setInterval(()=>i(Xe),1e3);return()=>window.clearInterval(e)},t[0]=i,t[1]=n.state,t[2]=a):a=t[2];let o=n.startProgress?.startedAt,s;if(t[3]!==n.state||t[4]!==o?(s=[n.state,o],t[3]=n.state,t[4]=o,t[5]=s):s=t[5],(0,Z.useEffect)(a,s),!(n.state===`connecting`||n.state===`reconnecting`||n.state===`connected`&&n.startProgress))return null;let c,l,u,d,f;if(t[6]!==n||t[7]!==r){let e=Je(n.startProgress?.startedAt);c=!!n.publicUrl&&n.state!==`connected`&&n.startProgress?.phase!==`registering`,l=`mt-3 space-y-3 rounded-lg bg-surface-panel/80 p-3 shadow-surface`;let i;t[13]===r.startProgressTitle?i=t[14]:(i=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:r.startProgressTitle}),t[13]=r.startProgressTitle,t[14]=i);let a;t[15]===r.startProgressHint?a=t[16]:(a=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.startProgressHint}),t[15]=r.startProgressHint,t[16]=a),t[17]!==i||t[18]!==a?(u=(0,$.jsxs)(`div`,{children:[i,a]}),t[17]=i,t[18]=a,t[19]=u):u=t[19];let o=Ue.map(e=>{let t=Ge(e,n),i=Ke(r,e,n);return(0,$.jsxs)(`li`,{className:`flex gap-2 text-xs`,children:[(0,$.jsx)(`span`,{className:`mt-0.5 shrink-0 text-fg-subtle`,"aria-hidden":!0,children:t===`done`?(0,$.jsx)(p,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`}):t===`active`?(0,$.jsx)(_,{className:`size-3.5 animate-spin text-accent`}):(0,$.jsx)(R,{className:`size-3.5`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:S(`font-medium`,t===`active`?`text-fg`:t===`done`?`text-fg-muted`:`text-fg-subtle`),children:qe(r,e)}),i?(0,$.jsx)(`div`,{className:`mt-0.5 text-fg-muted`,children:i}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload&&n.frpcDownload.phase===`downloading`?(0,$.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,$.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-surface-panel`,children:(0,$.jsx)(`div`,{className:S(`h-full rounded-full bg-accent transition-[width] duration-300`,n.frpcDownload.percent==null&&`w-1/3 animate-pulse`),style:n.frpcDownload.percent==null?void 0:{width:`${n.frpcDownload.percent}%`}})}),n.frpcDownload.bytesReceived!=null&&n.frpcDownload.totalBytes?(0,$.jsxs)(`p`,{className:`text-fg-subtle`,children:[He(n.frpcDownload.bytesReceived),` /`,` `,He(n.frpcDownload.totalBytes)]}):null]}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload?.url?(0,$.jsxs)(`p`,{className:`mt-2 text-fg-subtle`,children:[(0,$.jsxs)(`span`,{className:`font-sans`,children:[r.frpcDownloadingUrlLabel,`: `]}),(0,$.jsx)(`a`,{href:n.frpcDownload.url,target:`_blank`,rel:`noopener noreferrer`,className:`break-all font-mono text-[11px] text-accent hover:underline`,children:n.frpcDownload.url})]}):null]})]},e)});t[20]===o?d=t[21]:(d=(0,$.jsx)(`ol`,{className:`space-y-2`,children:o}),t[20]=o,t[21]=d),f=e&&n.startProgress?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.startProgressElapsed.replace(`{{elapsed}}`,e)}):null,t[6]=n,t[7]=r,t[8]=c,t[9]=l,t[10]=u,t[11]=d,t[12]=f}else c=t[8],l=t[9],u=t[10],d=t[11],f=t[12];let m;t[22]!==c||t[23]!==r.publicUrlPendingNotice?(m=c?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.publicUrlPendingNotice}):null,t[22]=c,t[23]=r.publicUrlPendingNotice,t[24]=m):m=t[24];let h;return t[25]!==l||t[26]!==u||t[27]!==d||t[28]!==f||t[29]!==m?(h=(0,$.jsxs)(`div`,{className:l,children:[u,d,f,m]}),t[25]=l,t[26]=u,t[27]=d,t[28]=f,t[29]=m,t[30]=h):h=t[30],h}function Xe(e){return e+1}function Ze(e,t){return t.state===`connected`?e.statusConnected:t.state===`error`?e.statusError:t.startProgress?.phase===`reconnecting_frpc`?e.statusReconnecting:t.startProgress?.phase===`starting_frpc`?e.statusStartingFrpc:t.startProgress?.phase===`registering`?e.statusRegistering:t.startProgress?.phase===`preparing_frpc`||t.frpcDownload?e.statusPreparingFrpc:t.state===`connecting`||t.state===`reconnecting`?e.statusConnecting:e.statusOff}function Qe(e){return e.state===`connected`?`connected`:e.state===`error`?`error`:e.state===`connecting`||e.state===`reconnecting`||e.startProgress||e.frpcDownload?`progress`:`off`}function $e(e){switch(e){case`connected`:return`bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`;case`progress`:return`bg-amber-500/15 text-amber-700 dark:text-amber-400`;case`error`:return`bg-red-500/15 text-red-700 dark:text-red-400`;default:return`bg-surface-hover text-fg-muted`}}function et(e){if(!e)return`—`;let t=Date.now()-new Date(e).getTime();if(t<0)return`—`;let n=Math.floor(t/6e4);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function tt(e){let t=(0,Q.c)(61),{t:n,status:r,isLoading:i,statusErr:a,starting:o,stopping:s,showConsentExpired:c,copyLabels:l,startDisabled:u,startDisabledReason:d,stepLabel:f,onStart:p,onStop:m}=e,h=u===void 0?!1:u,v,y,b,x,C,T,E;t[0]!==r||t[1]!==o?(E=Qe(r),v=r.enabled||o,y=o||r.state===`connecting`||r.state===`reconnecting`||!!r.startProgress||!!r.frpcDownload,t[9]===Symbol.for(`react.memo_cache_sentinel`)?(T=S(_e(),`space-y-4`),t[9]=T):T=t[9],C=`flex flex-wrap items-start justify-between gap-3`,x=`flex items-center gap-2`,b=S(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,$e(E)),t[0]=r,t[1]=o,t[2]=v,t[3]=y,t[4]=b,t[5]=x,t[6]=C,t[7]=T,t[8]=E):(v=t[2],y=t[3],b=t[4],x=t[5],C=t[6],T=t[7],E=t[8]);let D=E===`connected`&&`bg-emerald-500`,O=E===`progress`&&`bg-amber-500 animate-pulse`,k=E===`error`&&`bg-red-500`,A=E===`off`&&`bg-fg-subtle`,j;t[10]!==D||t[11]!==O||t[12]!==k||t[13]!==A?(j=S(`size-1.5 rounded-full`,D,O,k,A),t[10]=D,t[11]=O,t[12]=k,t[13]=A,t[14]=j):j=t[14];let M;t[15]===j?M=t[16]:(M=(0,$.jsx)(`span`,{className:j,"aria-hidden":!0}),t[15]=j,t[16]=M);let N;t[17]!==i||t[18]!==r||t[19]!==n?(N=i&&!r.enabled?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`inline-block h-3 w-16 animate-pulse rounded-full bg-surface-hover/70 motion-reduce:animate-none`}):Ze(n,r),t[17]=i,t[18]=r,t[19]=n,t[20]=N):N=t[20];let P;t[21]!==M||t[22]!==N||t[23]!==b?(P=(0,$.jsxs)(`span`,{className:b,children:[M,N]}),t[21]=M,t[22]=N,t[23]=b,t[24]=P):P=t[24];let I;t[25]!==r.connectedSince||t[26]!==r.state||t[27]!==n.uptime?(I=r.connectedSince&&r.state===`connected`?(0,$.jsxs)(`span`,{className:`text-xs text-fg-subtle`,children:[n.uptime,` `,et(r.connectedSince)]}):null,t[25]=r.connectedSince,t[26]=r.state,t[27]=n.uptime,t[28]=I):I=t[28];let L;t[29]!==P||t[30]!==I||t[31]!==x?(L=(0,$.jsxs)(`div`,{className:x,children:[P,I]}),t[29]=P,t[30]=I,t[31]=x,t[32]=L):L=t[32];let R;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(g,{className:`size-4 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[33]=R):R=t[33];let z;t[34]!==L||t[35]!==C?(z=(0,$.jsxs)(`div`,{className:C,children:[L,R]}),t[34]=L,t[35]=C,t[36]=z):z=t[36];let B;t[37]===a?B=t[38]:(B=a?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:a instanceof Error?a.message:String(a)}):null,t[37]=a,t[38]=B);let V;t[39]!==c||t[40]!==n.consentExpiredBanner?(V=c?(0,$.jsx)(`p`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-xs text-fg-muted`,children:n.consentExpiredBanner}):null,t[39]=c,t[40]=n.consentExpiredBanner,t[41]=V):V=t[41];let H;t[42]!==v||t[43]!==l||t[44]!==p||t[45]!==m||t[46]!==y||t[47]!==r||t[48]!==h||t[49]!==d||t[50]!==o||t[51]!==f||t[52]!==s||t[53]!==n?(H=v?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[r.publicUrl?(0,$.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,$.jsx)(U,{label:n.publicUrlLabel,text:r.publicUrl,labels:l})}):null,y?(0,$.jsx)(Ye,{status:r,t:n}):null,r.lastError&&r.state===`error`?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:r.lastError}):null,(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.enabled?(0,$.jsxs)(w,{type:`button`,variant:`secondary`,disabled:s,onClick:m,children:[s?(0,$.jsx)(_,{className:`size-4 animate-spin`}):null,n.stop]}):(0,$.jsxs)(w,{type:`button`,disabled:o,onClick:p,children:[o?(0,$.jsx)(_,{className:`size-4 animate-spin`}):(0,$.jsx)(W,{className:`size-4`}),n.start]})})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[f?(0,$.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:f}):null,(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.emptyStateTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:n.emptyStateBody})]}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,$.jsx)(F,{className:`mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-400`}),(0,$.jsx)(`p`,{children:n.riskBannerBody})]}),h&&d?(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:d}):null,(0,$.jsxs)(w,{type:`button`,disabled:o||h,onClick:p,className:`w-full sm:w-auto`,children:[o?(0,$.jsx)(_,{className:`size-4 animate-spin`}):(0,$.jsx)(W,{className:`size-4`}),n.start]})]}),t[42]=v,t[43]=l,t[44]=p,t[45]=m,t[46]=y,t[47]=r,t[48]=h,t[49]=d,t[50]=o,t[51]=f,t[52]=s,t[53]=n,t[54]=H):H=t[54];let ee;return t[55]!==z||t[56]!==B||t[57]!==V||t[58]!==H||t[59]!==T?(ee=(0,$.jsxs)(`section`,{className:T,children:[z,B,V,H]}),t[55]=z,t[56]=B,t[57]=V,t[58]=H,t[59]=T,t[60]=ee):ee=t[60],ee}var nt=`https://console.xopc.ai/access/client`,rt={reconfiguring:!1};function it(e){let t=(0,Q.c)(89),{t:n,brokerSecretReady:r,brokerSecretConfiguredInConfig:i,brokerSecretMaskedValue:a,brokerSecretDraft:o,savingBrokerSecret:s,authorizingBrokerSecret:c,brokerSecretAuthorizationUrl:l,brokerSecretNotice:u,copyFailedLabel:d,onDraftChange:f,onSave:m,onAuthorize:g,onClear:v,sectionRef:y}=e,b=(0,Z.useId)(),x=r,C=!x,[T,E]=(0,Z.useReducer)(ne,rt),{reconfiguring:D}=T,O;t[0]!==i||t[1]!==o||t[2]!==D?(O=i&&!D&&!o.trim(),t[0]=i,t[1]=o,t[2]=D,t[3]=O):O=t[3];let k=O,A;t[4]!==n.copied||t[5]!==n.copyKey||t[6]!==n.hideKey||t[7]!==n.showKey?(A={show:n.showKey,hide:n.hideKey,copy:n.copyKey,copied:n.copied},t[4]=n.copied,t[5]=n.copyKey,t[6]=n.hideKey,t[7]=n.showKey,t[8]=A):A=t[8];let j=A,M;t[9]===o?M=t[10]:(M=o.trim().length>0&&!B(o.trim()),t[9]=o,t[10]=M);let N=M,P;t[11]===f?P=t[12]:(P=()=>{E({type:`patch`,patch:{reconfiguring:!1}}),f(``)},t[11]=f,t[12]=P);let F=P,I=C&&`ring-1 ring-amber-500/30`,L;t[13]===I?L=t[14]:(L=S(I),t[13]=I,t[14]=L);let R=x?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:C?`bg-amber-500/10 text-amber-700 dark:text-amber-400`:`bg-surface-hover text-fg-muted`,z;t[15]===R?z=t[16]:(z=S(`flex size-9 shrink-0 items-center justify-center rounded-lg`,R),t[15]=R,t[16]=z);let V;t[17]===x?V=t[18]:(V=x?(0,$.jsx)(p,{className:`size-4`,strokeWidth:2,"aria-hidden":!0}):(0,$.jsx)(ee,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[17]=x,t[18]=V);let U;t[19]!==z||t[20]!==V?(U=(0,$.jsx)(`span`,{className:z,children:V}),t[19]=z,t[20]=V,t[21]=U):U=t[21];let te=x?n.brokerSecretReadyTitle:n.brokerSecretStepTitle,W;t[22]===te?W=t[23]:(W=(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:te}),t[22]=te,t[23]=W);let re=x?n.brokerSecretReadyHint:n.brokerSecretHint,ie;t[24]===re?ie=t[25]:(ie=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:re}),t[24]=re,t[25]=ie);let ae;t[26]!==C||t[27]!==n.brokerSecretMissingHint?(ae=C?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-amber-800 dark:text-amber-200`,children:n.brokerSecretMissingHint}):null,t[26]=C,t[27]=n.brokerSecretMissingHint,t[28]=ae):ae=t[28];let oe;t[29]!==W||t[30]!==ie||t[31]!==ae?(oe=(0,$.jsxs)(`div`,{children:[W,ie,ae]}),t[29]=W,t[30]=ie,t[31]=ae,t[32]=oe):oe=t[32];let G;t[33]!==c||t[34]!==C||t[35]!==g||t[36]!==D||t[37]!==s||t[38]!==n.brokerSecretAuthorize||t[39]!==n.brokerSecretAuthorizing||t[40]!==n.brokerSecretConsoleLink?(G=C||D?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(w,{type:`button`,disabled:s||c,onClick:g,children:[c?(0,$.jsx)(_,{className:`size-4 animate-spin`}):null,c?n.brokerSecretAuthorizing:n.brokerSecretAuthorize]}),(0,$.jsxs)(`a`,{href:nt,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[n.brokerSecretConsoleLink,(0,$.jsx)(h,{className:`size-3`,"aria-hidden":!0})]})]}):null,t[33]=c,t[34]=C,t[35]=g,t[36]=D,t[37]=s,t[38]=n.brokerSecretAuthorize,t[39]=n.brokerSecretAuthorizing,t[40]=n.brokerSecretConsoleLink,t[41]=G):G=t[41];let K;t[42]!==c||t[43]!==l||t[44]!==n.brokerSecretOpenAuthorization?(K=c&&l?(0,$.jsxs)(`a`,{href:l,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline`,children:[n.brokerSecretOpenAuthorization,(0,$.jsx)(h,{className:`size-3`,"aria-hidden":!0})]}):null,t[42]=c,t[43]=l,t[44]=n.brokerSecretOpenAuthorization,t[45]=K):K=t[45];let q;t[46]!==i||t[47]!==o||t[48]!==a||t[49]!==N||t[50]!==F||t[51]!==d||t[52]!==b||t[53]!==C||t[54]!==v||t[55]!==f||t[56]!==m||t[57]!==D||t[58]!==s||t[59]!==j||t[60]!==k||t[61]!==n.brokerSecretCancelReconfigure||t[62]!==n.brokerSecretClear||t[63]!==n.brokerSecretMaskedHelp||t[64]!==n.brokerSecretNotInConfigFile||t[65]!==n.brokerSecretPlaceholder||t[66]!==n.brokerSecretReconfigure||t[67]!==n.brokerSecretRevealFailed||t[68]!==n.brokerSecretSave||t[69]!==n.brokerSecretSaveAndContinue||t[70]!==n.brokerSecretTitle?(q=k?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:b,children:n.brokerSecretTitle}),(0,$.jsx)(H,{id:b,value:a,labels:j,reveal:at,loadFailedLabel:d||n.brokerSecretRevealFailed,maskedHelp:n.brokerSecretMaskedHelp,notInConfigFile:n.brokerSecretNotInConfigFile,readOnly:!0}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(w,{type:`button`,variant:`secondary`,disabled:s,onClick:()=>{E({type:`patch`,patch:{reconfiguring:!0}})},children:n.brokerSecretReconfigure}),(0,$.jsx)(w,{type:`button`,variant:`ghost`,disabled:s,onClick:v,children:n.brokerSecretClear})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:b,children:n.brokerSecretTitle}),(0,$.jsx)(H,{id:b,value:o,onChange:f,placeholder:n.brokerSecretPlaceholder,labels:j,disabled:s}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(w,{type:`button`,disabled:s||!N,onClick:m,children:[s?(0,$.jsx)(_,{className:`size-4 animate-spin`}):null,C?n.brokerSecretSaveAndContinue:n.brokerSecretSave]}),i?(0,$.jsx)(w,{type:`button`,variant:`ghost`,disabled:s,onClick:v,children:n.brokerSecretClear}):null,D?(0,$.jsx)(w,{type:`button`,variant:`ghost`,disabled:s,onClick:F,children:n.brokerSecretCancelReconfigure}):null]})]}),t[46]=i,t[47]=o,t[48]=a,t[49]=N,t[50]=F,t[51]=d,t[52]=b,t[53]=C,t[54]=v,t[55]=f,t[56]=m,t[57]=D,t[58]=s,t[59]=j,t[60]=k,t[61]=n.brokerSecretCancelReconfigure,t[62]=n.brokerSecretClear,t[63]=n.brokerSecretMaskedHelp,t[64]=n.brokerSecretNotInConfigFile,t[65]=n.brokerSecretPlaceholder,t[66]=n.brokerSecretReconfigure,t[67]=n.brokerSecretRevealFailed,t[68]=n.brokerSecretSave,t[69]=n.brokerSecretSaveAndContinue,t[70]=n.brokerSecretTitle,t[71]=q):q=t[71];let J;t[72]===u?J=t[73]:(J=u?(0,$.jsx)(`p`,{className:`text-xs text-emerald-700 dark:text-emerald-400`,children:u}):null,t[72]=u,t[73]=J);let se;t[74]!==oe||t[75]!==G||t[76]!==K||t[77]!==q||t[78]!==J?(se=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[oe,G,K,q,J]}),t[74]=oe,t[75]=G,t[76]=K,t[77]=q,t[78]=J,t[79]=se):se=t[79];let Y;t[80]!==U||t[81]!==se?(Y=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[U,se]}),t[80]=U,t[81]=se,t[82]=Y):Y=t[82];let ce;t[83]!==Y||t[84]!==L?(ce=(0,$.jsx)(ve,{className:L,children:Y}),t[83]=Y,t[84]=L,t[85]=ce):ce=t[85];let le;return t[86]!==y||t[87]!==ce?(le=(0,$.jsx)(`div`,{ref:y,id:`tunnel-broker-secret-setup`,children:ce}),t[86]=y,t[87]=ce,t[88]=le):le=t[88],le}function at(){return J().then(ot)}function ot(e){return e.registrationSecret??null}var st={actionError:null,starting:!1,stopping:!1,savingAutoStart:!1,consentOpen:!1,autoStartConfirmOpen:!1,releaseConfirmOpen:!1,releasing:!1,brokerSecretDraft:``,savingBrokerSecret:!1,authorizingBrokerSecret:!1,brokerSecretAuthorizationUrl:null,brokerSecretNotice:null};function ct({embedded:e=!1}){let t=b(e=>e.language),n=y(t).tunnelSettings,r=!!x(e=>e.token),[i,a]=(0,Z.useReducer)(ne,st),{actionError:o,starting:s,stopping:c,savingAutoStart:l,consentOpen:u,autoStartConfirmOpen:d,releaseConfirmOpen:f,releasing:p,brokerSecretDraft:m,savingBrokerSecret:h,authorizingBrokerSecret:v,brokerSecretAuthorizationUrl:D,brokerSecretNotice:O}=i,A=(0,Z.useRef)(null),{data:j}=E(r),{data:M,error:P,isLoading:F,mutate:I}=C(r?`tunnel-status`:null,he,{refreshInterval:e=>s?1e3:e?.frpcDownload||e?.state===`connecting`||e?.state===`reconnecting`?2e3:6e4}),R=(0,Z.useMemo)(()=>{let e=j?.payload?.config;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.tunnel;if(t&&typeof t==`object`&&!Array.isArray(t)&&t.autoStart===!0)return!0}return M?.config?.autoStart===!0},[j,M?.config?.autoStart]),z=(0,Z.useMemo)(()=>{let e=j?.payload?.config;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.tunnel;if(t&&typeof t==`object`&&!Array.isArray(t)){let e=t.registrationSecret;if(typeof e==`string`)return e}}return``},[j]),V=B(z),H=M?.registrationSecret?.configured??V;(0,Z.useEffect)(()=>{let e=()=>{I()};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[I]);let ee=(0,Z.useMemo)(()=>[n.consentBullet1,n.consentBullet2,n.consentBullet3],[n.consentBullet1,n.consentBullet2,n.consentBullet3]),U=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{actionError:null}}),a({type:`patch`,patch:{starting:!0}});try{await fe(),await I(),T()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{starting:!1}})}},[I]),te=(0,Z.useCallback)(()=>{if(!H){a({type:`patch`,patch:{actionError:n.brokerSecretRequiredBeforeStart}}),A.current?.scrollIntoView({behavior:`smooth`,block:`start`});return}if(M?.consentRequired){a({type:`patch`,patch:{consentOpen:!0}});return}U()},[H,M?.consentRequired,U,n.brokerSecretRequiredBeforeStart]),W=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{consentOpen:!1}}),a({type:`patch`,patch:{actionError:null}});try{await le(),await Promise.all([I(),U()])}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}},[I,U]),G=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{actionError:null}}),a({type:`patch`,patch:{stopping:!0}});try{await me(),await I(),T()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{stopping:!1}})}},[I]),K=(0,Z.useCallback)(async e=>{a({type:`patch`,patch:{savingAutoStart:!0}}),a({type:`patch`,patch:{actionError:null}});try{await de({autoStart:e}),T()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{savingAutoStart:!1}})}},[]),q=(0,Z.useCallback)(()=>{if(R){K(!1);return}if(M?.consentRequired){a({type:`patch`,patch:{actionError:n.consentExpiredBanner}});return}if(!M?.canAutoStart){a({type:`patch`,patch:{actionError:n.autoStartHint}});return}a({type:`patch`,patch:{autoStartConfirmOpen:!0}})},[K,M?.canAutoStart,M?.consentRequired,n,R]),J=(0,Z.useCallback)(async()=>{let e=m.trim();if(e){a({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await de({registrationSecret:e}),a({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretSaved}}),T(),await I(),a({type:`patch`,patch:{actionError:null}})}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{savingBrokerSecret:!1}})}}},[m,I,n.brokerSecretSaved]),se=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await de({registrationSecret:null}),a({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretCleared}}),T(),await I()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{savingBrokerSecret:!1}})}},[I,n.brokerSecretCleared]),ce=(0,Z.useCallback)(async()=>{let e=oe(),t=null,r=null;a({type:`patch`,patch:{authorizingBrokerSecret:!0,brokerSecretAuthorizationUrl:null,brokerSecretNotice:null,actionError:null}});try{for(t=(await ie(`xopc-tunnel`)).sessionId;;){await new Promise(e=>window.setTimeout(e,1e3));let i=await ae(t);if(i.authUrl&&i.authUrl!==r&&(r=i.authUrl,a({type:`patch`,patch:{brokerSecretAuthorizationUrl:i.authUrl}}),await L(i.authUrl,e)),i.status===`failed`||i.status===`cancelled`)throw Error(i.error??i.message??`OAuth authorization failed`);if(i.status===`completed`){await pe(),await Promise.all([I(),T()]),a({type:`patch`,patch:{brokerSecretNotice:n.brokerSecretSaved,brokerSecretDraft:``}});return}}}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{N(e),t&&re(t).catch(()=>void 0),a({type:`patch`,patch:{authorizingBrokerSecret:!1,brokerSecretAuthorizationUrl:null}})}},[I,n.brokerSecretSaved]),ue=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{releaseConfirmOpen:!1,actionError:null,releasing:!0}});try{await me({release:!0}),await I(),T()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{releasing:!1}})}},[I]),ge=(0,Z.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:y(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]);if(!r)return(0,$.jsx)(`div`,{className:e?void 0:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let X=M??{enabled:!1,state:`disconnected`,subdomain:null,publicUrl:null,connectedSince:null,frpcPid:null,lastHeartbeatAt:null,lastError:null,consentRequired:!0,config:{autoStart:R,brokerUrl:`https://frp.xopc.ai/api`}},_e=M?.consentRequired&&(X.enabled||R||M?.consent?.acceptedAt),ye=(0,$.jsx)(it,{t:n,brokerSecretReady:H,brokerSecretConfiguredInConfig:V,brokerSecretMaskedValue:V?z:``,brokerSecretDraft:m,savingBrokerSecret:h,authorizingBrokerSecret:v,brokerSecretAuthorizationUrl:D,brokerSecretNotice:O,copyFailedLabel:y(t).clipboard.copyFailed,onDraftChange:e=>a({type:`patch`,patch:{brokerSecretDraft:e}}),onSave:()=>void J(),onAuthorize:()=>void ce(),onClear:()=>void se(),sectionRef:A}),be=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ze,{open:u,title:n.consentTitle,intro:n.consentIntro,bullets:ee,checkboxLabel:n.consentCheckbox,confirmLabel:_e?n.consentReconfirm:n.consentConfirm,cancelLabel:n.consentCancel,onConfirm:()=>void W(),onCancel:()=>a({type:`patch`,patch:{consentOpen:!1}})},u?`consent-open`:`consent-closed`),(0,$.jsx)(k,{open:d,title:n.autoStartConfirmTitle,description:n.autoStartConfirmBody,confirmLabel:n.autoStartConfirmLabel,cancelLabel:n.consentCancel,onConfirm:()=>{a({type:`patch`,patch:{autoStartConfirmOpen:!1}}),K(!0)},onCancel:()=>a({type:`patch`,patch:{autoStartConfirmOpen:!1}})}),(0,$.jsx)(k,{open:f,title:n.releaseConfirmTitle,description:n.releaseConfirmBody,confirmLabel:n.releaseConfirmLabel,cancelLabel:n.consentCancel,destructive:!0,onConfirm:()=>void ue(),onCancel:()=>a({type:`patch`,patch:{releaseConfirmOpen:!1}})})]});return e?(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[o?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o}):null,ye,(0,$.jsx)(tt,{t:n,status:X,isLoading:F,statusErr:P,starting:s,stopping:c,showConsentExpired:!!_e,copyLabels:ge,startDisabled:!H,startDisabledReason:H?void 0:n.brokerSecretRequiredBeforeStart,stepLabel:n.flowStepStart,onStart:te,onStop:()=>void G()}),(0,$.jsxs)(Re,{showLabel:n.showOptions,hideLabel:n.hideOptions,children:[(0,$.jsxs)(`label`,{className:S(`flex items-center gap-3 text-sm text-fg`,!R&&!M?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:R,disabled:l||!R&&!M?.canAutoStart,onChange:q}),n.autoStart]}),!M?.canAutoStart&&!R?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.autoStartHint}):null,X.subdomain||X.publicUrl?(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge-subtle pt-4`,children:[(0,$.jsxs)(w,{type:`button`,variant:`secondary`,disabled:p||c,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>a({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[p?(0,$.jsx)(_,{className:`size-4 animate-spin`}):null,n.release]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint})]}):null]}),(0,$.jsx)(Re,{showLabel:n.showAdvanced,hideLabel:n.hideAdvanced,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge-subtle pt-4 text-xs text-fg-subtle`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(g,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(Y,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]})}),be]}):(0,$.jsxs)(`div`,{className:e?`flex w-full flex-col gap-6`:`flex w-full flex-col gap-6 px-3 py-8 sm:px-5 xl:px-6`,children:[e?null:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle})]}),o?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o}):null,ye,(0,$.jsx)(tt,{t:n,status:X,isLoading:F,statusErr:P,starting:s,stopping:c,showConsentExpired:!!_e,copyLabels:ge,startDisabled:!H,startDisabledReason:H?void 0:n.brokerSecretRequiredBeforeStart,onStart:te,onStop:()=>void G()}),X.subdomain||X.publicUrl?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,$.jsxs)(w,{type:`button`,variant:`secondary`,disabled:p||c,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>a({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[p?(0,$.jsx)(_,{className:`size-4 animate-spin`}):null,n.release]})}):null,X.subdomain||X.publicUrl?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint}):null,(0,$.jsxs)(ve,{children:[(0,$.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-fg`,children:n.optionsTitle}),(0,$.jsxs)(`label`,{className:S(`flex items-center gap-3 text-sm text-fg`,!R&&!M?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:R,disabled:l||!R&&!M?.canAutoStart,onChange:q}),n.autoStart]}),!M?.canAutoStart&&!R?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:n.autoStartHint}):null]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-panel/80 px-3 py-2 text-xs text-fg-subtle shadow-surface`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(g,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(Y,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]}),be]})}function lt(e,t){return e.tabs[t]}function ut(e,t){return e.tabIntro[t]}function dt(e){switch(e){case`tailscale`:return`tailscale-serve`;case`public`:return`public-tunnel`;case`reverse-proxy`:return`reverse-proxy`;case`ssh`:return`ssh-tunnel`;case`lan`:return`lan`;default:return}}function ft(e){let t=(0,Q.c)(7),{tab:n,onOpenTab:r}=e;switch(n){case`guide`:{let e;return t[0]===r?e=t[1]:(e=(0,$.jsx)(De,{onOpenTab:r}),t[0]=r,t[1]=e),e}case`tailscale`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ue,{embedded:!0}),t[2]=e):e=t[2],e}case`public`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ct,{embedded:!0}),t[3]=e):e=t[3],e}case`reverse-proxy`:{let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(se,{}),t[4]=e):e=t[4],e}case`ssh`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Fe,{}),t[5]=e):e=t[5],e}case`lan`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(je,{}),t[6]=e):e=t[6],e}}}function pt(){let e=(0,Q.c)(3),t=i(),n=b(ht),r=y(n).remoteAccess,o=!!x(mt),[s,c]=a(),l=Le(s.get(`tab`)),u=s.get(`intent`)===`mobile-pairing`,d;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(d={refreshInterval:2e3},e[0]=d):d=e[0];let f=C(u?`mobile-pairing-readiness`:null,ce,d),p;e[1]===c?p=e[2]:(p=e=>{c(t=>{let n=new URLSearchParams(t);return e===`guide`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[1]=c,e[2]=p);let m=p,h=ut(r,l),g=Ie.map(e=>({id:e,label:lt(r,e)}));return(0,$.jsxs)(K,{children:[(0,$.jsx)(G,{title:r.pageTitle,subtitle:r.pageSubtitle,meta:(0,$.jsx)(Y,{language:n,label:r.docsLink,section:dt(l),className:`mt-1`})}),o?(0,$.jsxs)($.Fragment,{children:[u?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(V,{className:`mt-0.5 size-5 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:r.mobilePairingFlow.title}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:f.data?.ready?r.mobilePairingFlow.ready:r.mobilePairingFlow.hint})]})]}),(0,$.jsxs)(w,{variant:`primary`,disabled:!f.data?.ready,onClick:()=>t(`/settings/devices?startMobilePairing=1`),children:[f.data?.ready?r.mobilePairingFlow.continue:r.mobilePairingFlow.waiting,(0,$.jsx)(te,{className:`size-4`,"aria-hidden":!0})]})]}):null,(0,$.jsx)(ye,{items:g,activeTab:l,onChange:m,ariaLabel:r.tabsAria,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`}),(0,$.jsx)(q,{id:l,activeTab:l,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`,title:lt(r,l),hint:l===`public`?void 0:h,children:(0,$.jsx)(ft,{tab:l,onOpenTab:m})})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.guide.needToken})]})}function mt(e){return e.token}function ht(e){return e.language}export{pt as RemoteAccessHub};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{p as i}from"./chunk-KS7C4IRE-BaASWQor.js";import{a,n as o,o as s,r as c,s as l,t as u}from"./dist-CpzYSoz7.js";import{n as d,r as f}from"./popover-select-C-Hj-nXR.js";import{t as p}from"./download-Dk-ZjtO6.js";import{t as m}from"./plus-Q2yW6OE7.js";import{t as h}from"./x-B_N4OPjy.js";import{t as g}from"./messages-C72stReU.js";import{a as _,n as v,r as y,s as b}from"./locale-store-BkeaPZpn.js";import{t as x}from"./cn-JdwAhgNB.js";import{i as S}from"./vendor-swr-BIWyz7Rc.js";import{t as C}from"./button-CtTvuElV.js";import{n as w,r as T}from"./gateway-config-swr-BW3Bx-aV.js";import{t as E}from"./skeleton-BwbyijEw.js";import{i as ee,o as D}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as O,t as k}from"./registry-api-CviQoUBf.js";import{Ai as A,Ec as j,El as M,Ft as N,Gc as P,Go as F,Ii as I,It as L,Jc as R,Kc as z,Kr as B,Li as V,Mi as H,N as te,Ni as U,Oc as W,Oi as G,Pi as ne,Rl as re,Wo as K,Xs as q,_s as ie,aa as ae,ec as oe,gc as se,ha as ce,hc as J,hu as le,ji as ue,ki as de,ks as fe,ml as pe,mu as me,no as he,oa as Y,sa as ge}from"./index-C7RDs6S-.js";import{n as _e,t as ve}from"./settings-form-section-CBic9TFH.js";import{n as ye,t as be}from"./use-autosave-Dow9RRcq.js";import{t as xe}from"./page-tabs-pyukZ1PJ.js";import{t as Se}from"./settings-advanced-gate-CcSYDjaH.js";var X=e(t(),1),Ce=n(),Z=r();function we(e){let t=new Date(e),n=Math.floor((new Date().getTime()-t.getTime())/(1e3*60*60*24));return n===0?t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):n===1?`Yesterday`:n<7?t.toLocaleDateString([],{weekday:`short`}):t.toLocaleDateString([],{month:`short`,day:`numeric`})}function Te(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Ee(e){let t=(0,Ce.c)(105),{session:n,variant:r,labels:i,sessionAgentId:a,sessionAgentAvatar:o,onOpen:s,onAction:c}=e,l;t[0]!==i.unnamedSession||t[1]!==n.name?(l=n.name?.trim()||i.unnamedSession,t[0]=i.unnamedSession,t[1]=n.name,t[2]=l):l=t[2];let u=l,d;t[3]===n.name?d=t[4]:(d=n.name?.trim(),t[3]=n.name,t[4]=d);let f=!!d,m=n.status===`archived`,h=n.status===`pinned`,g=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,_;t[5]===g?_=t[6]:(_=x(`group flex min-w-0 w-full max-w-full cursor-pointer flex-col rounded-xl bg-surface-base text-left transition-colors duration-150 ease-out`,`hover:bg-surface-hover active:scale-[0.99]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,g),t[5]=g,t[6]=_);let v;t[7]===s?v=t[8]:(v=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s())},t[7]=s,t[8]=v);let y=r===`list`&&`sm:py-3`,b;t[9]===y?b=t[10]:(b=x(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,y),t[9]=y,t[10]=b);let S;t[11]===n.sourceChannel?S=t[12]:(S=(0,Z.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:(0,Z.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.sourceChannel})}),t[11]=n.sourceChannel,t[12]=S);let C;t[13]===h?C=t[14]:(C=h?(0,Z.jsx)(se,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[13]=h,t[14]=C);let w;t[15]===n.updatedAt?w=t[16]:(w=we(n.updatedAt),t[15]=n.updatedAt,t[16]=w);let T;t[17]===w?T=t[18]:(T=(0,Z.jsx)(`span`,{children:w}),t[17]=w,t[18]=T);let E;t[19]!==T||t[20]!==C?(E=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[C,T]}),t[19]=T,t[20]=C,t[21]=E):E=t[21];let ee;t[22]!==E||t[23]!==b||t[24]!==S?(ee=(0,Z.jsxs)(`div`,{className:b,children:[S,E]}),t[22]=E,t[23]=b,t[24]=S,t[25]=ee):ee=t[25];let D=r===`list`&&`sm:py-3`,O;t[26]===D?O=t[27]:(O=x(`min-w-0 flex-1 px-3 py-2`,D),t[26]=D,t[27]=O);let k=r===`list`&&`sm:items-start`,A;t[28]===k?A=t[29]:(A=x(`flex gap-3`,k),t[28]=k,t[29]=A);let j;t[30]!==o||t[31]!==a?(j=(0,Z.jsx)(te,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[30]=o,t[31]=a,t[32]=j):j=t[32];let M;t[33]===u?M=t[34]:(M=(0,Z.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:u,children:u}),t[33]=u,t[34]=M);let N;t[35]!==n.key||t[36]!==f?(N=f?(0,Z.jsx)(`div`,{className:`mt-0.5 min-w-0 max-w-full truncate font-mono text-[11px] text-fg-subtle`,title:n.key,children:n.key}):null,t[35]=n.key,t[36]=f,t[37]=N):N=t[37];let P;t[38]!==M||t[39]!==N?(P=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[M,N]}),t[38]=M,t[39]=N,t[40]=P):P=t[40];let F;t[41]!==A||t[42]!==j||t[43]!==P?(F=(0,Z.jsxs)(`div`,{className:A,children:[j,P]}),t[41]=A,t[42]=j,t[43]=P,t[44]=F):F=t[44];let I;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(W,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[45]=I):I=t[45];let L;t[46]===n.messageCount?L=t[47]:(L=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[I,n.messageCount]}),t[46]=n.messageCount,t[47]=L);let R;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,Z.jsx)(ie,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[48]=R):R=t[48];let z;t[49]===n.estimatedTokens?z=t[50]:(z=Te(n.estimatedTokens),t[49]=n.estimatedTokens,t[50]=z);let B;t[51]===z?B=t[52]:(B=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[R,z]}),t[51]=z,t[52]=B);let V;t[53]!==L||t[54]!==B?(V=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[L,B]}),t[53]=L,t[54]=B,t[55]=V):V=t[55];let H;t[56]===n.tags?H=t[57]:(H=n.tags.length>0?(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(ke),n.tags.length>3?(0,Z.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[56]=n.tags,t[57]=H);let U;t[58]!==O||t[59]!==F||t[60]!==V||t[61]!==H?(U=(0,Z.jsxs)(`div`,{className:O,children:[F,V,H]}),t[58]=O,t[59]=F,t[60]=V,t[61]=H,t[62]=U):U=t[62];let G;t[63]===c?G=t[64]:(G=()=>c(`continue`),t[63]=c,t[64]=G);let ne;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,Z.jsx)(W,{className:`size-4`,strokeWidth:1.75}),t[65]=ne):ne=t[65];let re;t[66]!==i.continueChat||t[67]!==G?(re=(0,Z.jsx)(`button`,{type:`button`,className:K,title:i.continueChat,"aria-label":i.continueChat,onClick:G,children:ne}),t[66]=i.continueChat,t[67]=G,t[68]=re):re=t[68];let q;t[69]!==m||t[70]!==i.archive||t[71]!==i.unarchive||t[72]!==c?(q=m?(0,Z.jsx)(`button`,{type:`button`,className:K,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>c(`unarchive`),children:(0,Z.jsx)(le,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:K,title:i.archive,"aria-label":i.archive,onClick:()=>c(`archive`),children:(0,Z.jsx)(me,{className:`size-4`,strokeWidth:1.75})}),t[69]=m,t[70]=i.archive,t[71]=i.unarchive,t[72]=c,t[73]=q):q=t[73];let ae;t[74]!==h||t[75]!==i.pin||t[76]!==i.unpin||t[77]!==c?(ae=h?(0,Z.jsx)(`button`,{type:`button`,className:K,title:i.unpin,"aria-label":i.unpin,onClick:()=>c(`unpin`),children:(0,Z.jsx)(J,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:K,title:i.pin,"aria-label":i.pin,onClick:()=>c(`pin`),children:(0,Z.jsx)(se,{className:`size-4`,strokeWidth:1.75})}),t[74]=h,t[75]=i.pin,t[76]=i.unpin,t[77]=c,t[78]=ae):ae=t[78];let oe;t[79]===c?oe=t[80]:(oe=()=>c(`export`),t[79]=c,t[80]=oe);let ce;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,Z.jsx)(p,{className:`size-4`,strokeWidth:1.75}),t[81]=ce):ce=t[81];let ue;t[82]!==i.export||t[83]!==oe?(ue=(0,Z.jsx)(`button`,{type:`button`,className:K,title:i.export,"aria-label":i.export,onClick:oe,children:ce}),t[82]=i.export,t[83]=oe,t[84]=ue):ue=t[84];let de;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(de=x(K,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[85]=de):de=t[85];let pe;t[86]===c?pe=t[87]:(pe=()=>c(`delete`),t[86]=c,t[87]=pe);let he;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,Z.jsx)(fe,{className:`size-4`,strokeWidth:1.75}),t[88]=he):he=t[88];let Y;t[89]!==i.delete||t[90]!==pe?(Y=(0,Z.jsx)(`button`,{type:`button`,className:de,title:i.delete,"aria-label":i.delete,onClick:pe,children:he}),t[89]=i.delete,t[90]=pe,t[91]=Y):Y=t[91];let ge;t[92]!==re||t[93]!==q||t[94]!==ae||t[95]!==ue||t[96]!==Y?(ge=(0,Z.jsxs)(`div`,{role:`group`,className:`flex flex-wrap items-center gap-0.5 border-t border-edge-subtle/80 bg-surface-hover/25 p-2 dark:border-edge-subtle`,onClick:Oe,onKeyDown:De,children:[re,q,ae,ue,Y]}),t[92]=re,t[93]=q,t[94]=ae,t[95]=ue,t[96]=Y,t[97]=ge):ge=t[97];let _e;return t[98]!==s||t[99]!==ee||t[100]!==U||t[101]!==_||t[102]!==ge||t[103]!==v?(_e=(0,Z.jsxs)(`div`,{role:`button`,tabIndex:0,className:_,onClick:s,onKeyDown:v,children:[ee,U,ge]}),t[98]=s,t[99]=ee,t[100]=U,t[101]=_,t[102]=ge,t[103]=v,t[104]=_e):_e=t[104],_e}function De(e){return e.stopPropagation()}function Oe(e){return e.stopPropagation()}function ke(e){return(0,Z.jsx)(`span`,{className:`max-w-full break-words rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function Ae(e,t){return e.routing?.agentId?.trim().toLowerCase()||t.trim().toLowerCase()||`main`}function je(e,t){return t.find(t=>t.id===e)?.avatar}var Me={enabled:!0,triggerThreshold:.8,reserveTokens:8192,minMessagesBeforeCompact:10,keepRecentTokens:2e4,recentTurnsPreserve:3,summaryMaxTokens:2e3,summaryChunkTokens:24e3,summaryTimeoutMs:18e4,summaryRetries:2,qualityGuard:!0,gapAudit:!0,minToolResultKeepChars:1e3,maxActiveTranscriptBytes:2e6,postCompactionSections:[`Session Startup`,`Red Lines`]};function Ne(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Pe(e,t,n,r=1/0){return typeof e==`number`&&Number.isFinite(e)&&e>=n&&e<=r?e:t}function Q(e,t,n,r=1/0){return Number.isInteger(e)&&e>=n&&e<=r?e:t}function Fe(e){let t=Ne(e)?e:{},n=Ne(t.userContext)?t.userContext:{},r=Ne(n.contextPlanning)?n.contextPlanning:{},i=Ne(r.compaction)?r.compaction:{},a=Me,o=typeof i.model==`string`&&i.model.trim()?i.model.trim():void 0,s=Array.isArray(i.postCompactionSections)&&i.postCompactionSections.length<=12&&i.postCompactionSections.every(e=>typeof e==`string`&&e.trim())?[...new Set(i.postCompactionSections.map(e=>e.trim()))]:[...a.postCompactionSections];return{enabled:typeof i.enabled==`boolean`?i.enabled:a.enabled,triggerThreshold:Pe(i.triggerThreshold,a.triggerThreshold,.1,.98),reserveTokens:Q(i.reserveTokens,a.reserveTokens,1024),minMessagesBeforeCompact:Q(i.minMessagesBeforeCompact,a.minMessagesBeforeCompact,2),keepRecentTokens:Q(i.keepRecentTokens,a.keepRecentTokens,1e3),recentTurnsPreserve:Q(i.recentTurnsPreserve,a.recentTurnsPreserve,1,12),summaryMaxTokens:Q(i.summaryMaxTokens,a.summaryMaxTokens,256),summaryChunkTokens:Q(i.summaryChunkTokens,a.summaryChunkTokens,1e3),summaryTimeoutMs:Q(i.summaryTimeoutMs,a.summaryTimeoutMs,1e3,6e5),summaryRetries:Q(i.summaryRetries,a.summaryRetries,0,5),qualityGuard:typeof i.qualityGuard==`boolean`?i.qualityGuard:a.qualityGuard,gapAudit:typeof i.gapAudit==`boolean`?i.gapAudit:a.gapAudit,...o?{model:o}:{},minToolResultKeepChars:Q(i.minToolResultKeepChars,a.minToolResultKeepChars,200),maxActiveTranscriptBytes:Q(i.maxActiveTranscriptBytes,a.maxActiveTranscriptBytes,64e3),postCompactionSections:s}}function Ie(e){return e.triggerThreshold<.1||e.triggerThreshold>.98?`triggerThreshold`:!Number.isInteger(e.reserveTokens)||e.reserveTokens<1024?`reserveTokens`:!Number.isInteger(e.minMessagesBeforeCompact)||e.minMessagesBeforeCompact<2?`minMessagesBeforeCompact`:!Number.isInteger(e.keepRecentTokens)||e.keepRecentTokens<1e3?`keepRecentTokens`:!Number.isInteger(e.recentTurnsPreserve)||e.recentTurnsPreserve<1||e.recentTurnsPreserve>12?`recentTurnsPreserve`:!Number.isInteger(e.summaryMaxTokens)||e.summaryMaxTokens<256?`summaryMaxTokens`:!Number.isInteger(e.summaryChunkTokens)||e.summaryChunkTokens<1e3?`summaryChunkTokens`:!Number.isInteger(e.summaryTimeoutMs)||e.summaryTimeoutMs<1e3||e.summaryTimeoutMs>6e5?`summaryTimeoutMs`:!Number.isInteger(e.summaryRetries)||e.summaryRetries<0||e.summaryRetries>5?`summaryRetries`:e.model!==void 0&&!e.model.trim()?`model`:!Number.isInteger(e.minToolResultKeepChars)||e.minToolResultKeepChars<200?`minToolResultKeepChars`:!Number.isInteger(e.maxActiveTranscriptBytes)||e.maxActiveTranscriptBytes<64e3?`maxActiveTranscriptBytes`:e.postCompactionSections.length>12||e.postCompactionSections.some(e=>!e.trim())?`postCompactionSections`:null}function Le(e){let t={...e,...e.model?.trim()?{model:e.model.trim()}:{}};return e.model?.trim()||delete t.model,{userContext:{contextPlanning:{compaction:t}}}}async function Re(e){await _(y(`/api/config`),{method:`PATCH`,body:JSON.stringify(Le(e))}),await w()}var ze=128e3,Be={balanced:Me,preserve:{...Me,triggerThreshold:.88,keepRecentTokens:32e3,recentTurnsPreserve:5,maxActiveTranscriptBytes:4e6},early:{...Me,triggerThreshold:.65,reserveTokens:12e3,minMessagesBeforeCompact:6,keepRecentTokens:12e3,recentTurnsPreserve:2}},Ve=ae();function He(){return x(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg disabled:cursor-not-allowed disabled:opacity-55`,he,`dark:border-edge`)}function Ue(e){let{enabled:t,model:n,postCompactionSections:r,...i}=e;return JSON.stringify(i)}function We(e){let t=Ue(e);for(let[e,n]of Object.entries(Be))if(t===Ue(n))return e;return`custom`}function Ge(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}k`:String(e)}function $(e){let t=(0,Ce.c)(20),{id:n,label:r,hint:i,value:a,min:o,max:s,step:c,disabled:l,onChange:u}=e,d=c===void 0?1:c,f;t[0]!==n||t[1]!==r?(f=(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=He(),t[3]=p):p=t[3];let m;t[4]===u?m=t[5]:(m=e=>{if(!e.target.value.trim())return;let t=Number(e.target.value);Number.isFinite(t)&&u(t)},t[4]=u,t[5]=m);let h;t[6]!==l||t[7]!==n||t[8]!==s||t[9]!==o||t[10]!==d||t[11]!==m||t[12]!==a?(h=(0,Z.jsx)(`input`,{id:n,type:`number`,min:o,max:s,step:d,disabled:l,className:p,value:a,onChange:m}),t[6]=l,t[7]=n,t[8]=s,t[9]=o,t[10]=d,t[11]=m,t[12]=a,t[13]=h):h=t[13];let g;t[14]===i?g=t[15]:(g=i?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}):null,t[14]=i,t[15]=g);let _;return t[16]!==f||t[17]!==h||t[18]!==g?(_=(0,Z.jsxs)(`div`,{children:[f,h,g]}),t[16]=f,t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function Ke(e){let t=(0,Ce.c)(19),{label:n,hint:r,checked:i,disabled:a,onChange:o}=e,s=a?`cursor-not-allowed opacity-55`:`cursor-pointer`,c;t[0]===s?c=t[1]:(c=x(`flex items-start gap-2 text-sm text-fg`,s),t[0]=s,t[1]=c);let l;t[2]===o?l=t[3]:(l=e=>o(e.target.checked),t[2]=o,t[3]=l);let u;t[4]!==i||t[5]!==a||t[6]!==l?(u=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:i,disabled:a,onChange:l}),t[4]=i,t[5]=a,t[6]=l,t[7]=u):u=t[7];let d;t[8]===n?d=t[9]:(d=(0,Z.jsx)(`span`,{className:`font-medium`,children:n}),t[8]=n,t[9]=d);let f;t[10]===r?f=t[11]:(f=(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r}),t[10]=r,t[11]=f);let p;t[12]!==d||t[13]!==f?(p=(0,Z.jsxs)(`span`,{children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==c||t[16]!==u||t[17]!==p?(m=(0,Z.jsxs)(`label`,{className:c,children:[u,p]}),t[15]=c,t[16]=u,t[17]=p,t[18]=m):m=t[18],m}function qe({hasToken:e}){let t=g(v(e=>e.language)).sessions.compaction,{data:n,isLoading:r}=T(e),{data:i=[],isLoading:a}=S(e?k:null,O,{revalidateOnFocus:!1}),o=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Fe(n.payload.config),[n]),[s,c]=(0,X.useReducer)(Ve,{form:null,baseline:null}),[l,u]=(0,X.useState)(``),d=(0,X.useRef)(!1),f=(0,X.useRef)(s.form);f.current=s.form;let p=(0,X.useRef)(null);Y({enabled:e,parsed:o,dirty:d.current,trackedParsedRef:p,dispatch:c,onResetDirty:()=>{d.current=!1}});let _=s.form,y=s.baseline,b=!!(_&&y&&JSON.stringify(_)!==JSON.stringify(y)),w=(0,X.useCallback)(e=>{d.current=!0,c({type:`patch`,patch:e})},[]),ee=(0,X.useCallback)(e=>({enabled:t.enabled,triggerThreshold:t.triggerThreshold,reserveTokens:t.reserveTokens,minMessagesBeforeCompact:t.minMessagesBeforeCompact,keepRecentTokens:t.keepRecentTokens,recentTurnsPreserve:t.recentTurnsPreserve,summaryMaxTokens:t.summaryMaxTokens,summaryChunkTokens:t.summaryChunkTokens,summaryTimeoutMs:t.summaryTimeoutSeconds,summaryRetries:t.summaryRetries,qualityGuard:t.qualityGuard,gapAudit:t.gapAudit,model:t.summaryModel,minToolResultKeepChars:t.minToolResultKeepChars,maxActiveTranscriptBytes:t.maxActiveTranscriptMb,postCompactionSections:t.postCompactionSections})[e],[t]),D=be({value:_,dirty:b,onSave:(0,X.useCallback)(async e=>{try{await Re(e),c({type:`saved`,value:e}),d.current=!!(f.current&&JSON.stringify(f.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError]),validate:e=>{let n=Ie(e);return n?t.invalidValue.replace(`{{field}}`,ee(n)):null}});if(!e||!_)return r?(0,Z.jsx)(ve,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(E,{className:`h-5 w-48`}),(0,Z.jsx)(E,{className:`h-20 w-full rounded-xl`}),(0,Z.jsx)(E,{className:`h-36 w-full rounded-xl`})]})}):null;let A=We(_),M=Math.max(0,ze-_.reserveTokens),N=Math.min(Math.floor(ze*_.triggerThreshold),M),P=Math.min(100,N/ze*100),I=Math.min(100,M/ze*100),L=_.model?i.find(e=>e.id===_.model):void 0,R=L?.contextWindow&&_.summaryChunkTokens+_.summaryMaxTokens+4096>L.contextWindow,z=_.keepRecentTokens+_.reserveTokens>N,V=Math.round(_.summaryTimeoutMs*(_.summaryRetries+1)/1e3),H=e=>{let t=Be[e];w({...t,..._.model?{model:_.model}:{model:void 0},postCompactionSections:_.postCompactionSections})},te={balanced:{title:t.presetBalanced,hint:t.presetBalancedHint},preserve:{title:t.presetPreserve,hint:t.presetPreserveHint},early:{title:t.presetEarly,hint:t.presetEarlyHint}},U=()=>{let e=l.trim();!e||_.postCompactionSections.includes(e)||_.postCompactionSections.length>=12||(w({postCompactionSections:[..._.postCompactionSections,e]}),u(``))};return(0,Z.jsxs)(ve,{onBlurCapture:D.onBlurCapture,children:[(0,Z.jsx)(_e,{icon:j,title:t.title,subtitle:t.hint,trailing:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(ye,{status:D.status,error:D.error}),(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:_.enabled,onChange:e=>w({enabled:e.target.checked})}),_.enabled?t.enabled:t.disabled]})]})}),D.error?(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900 dark:bg-red-950/40 dark:text-red-300`,role:`alert`,children:D.error}):null,_.enabled?null:(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.disabledWarning}),(0,Z.jsxs)(`fieldset`,{disabled:!_.enabled,className:`space-y-5 disabled:opacity-60`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.presetTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.presetHint})]}),A===`custom`?(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.presetCustom}):null]}),(0,Z.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[`balanced`,`preserve`,`early`].map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":A===e,className:x(`rounded-xl border px-3 py-3 text-left`,F.transition,F.focusRingPanel,A===e?`border-accent/50 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg hover:bg-surface-hover`),onClick:()=>H(e),children:[(0,Z.jsx)(`span`,{className:`block text-sm font-medium`,children:te[e].title}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:te[e].hint})]},e))})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-hover/35 p-4 dark:border-edge`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.budgetPreview}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.budgetPreviewHint})]}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2.5 py-1 font-mono text-xs text-fg-muted`,children:t.previewModel128k})]}),(0,Z.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.compactionTrigger}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:Ge(N)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${P}%`}})})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.hardInputLimit}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:Ge(M)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-fg-subtle`,style:{width:`${I}%`}})})]})]}),(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:t.budgetFormula})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-trigger-threshold`,label:t.triggerThreshold,hint:t.triggerThresholdHint,value:Number((_.triggerThreshold*100).toFixed(2)),min:10,max:98,step:.1,onChange:e=>w({triggerThreshold:e/100})}),(0,Z.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,Ge(_.reserveTokens)),value:_.reserveTokens,min:1024,step:1024,onChange:e=>w({reserveTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-recent-turns`,label:t.recentTurnsPreserve,hint:t.recentTurnsPreserveHint,value:_.recentTurnsPreserve,min:1,max:12,onChange:e=>w({recentTurnsPreserve:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,Ge(_.keepRecentTokens)),value:_.keepRecentTokens,min:1e3,step:1e3,onChange:e=>w({keepRecentTokens:Math.floor(e)})})]}),z?(0,Z.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.retentionWarning}):null,(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.summaryModel}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,Z.jsx)(B,{value:_.model??``,disabled:!_.enabled,placeholder:t.summaryModelInherited,searchPlaceholder:t.summaryModelSearch,noMatches:t.summaryModelNoMatches,models:i,modelsLoading:a,className:`min-w-0 flex-1 justify-between`,contentAlign:`start`,showProviderSettingsFooter:!0,onChange:e=>w({model:e})}),_.model?(0,Z.jsx)(C,{type:`button`,variant:`secondary`,onClick:()=>w({model:void 0}),children:t.summaryModelUseSession}):null]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.summaryModelHint})]}),(0,Z.jsx)(Ke,{label:t.qualityGuard,hint:t.qualityGuardHint,checked:_.qualityGuard,onChange:e=>w({qualityGuard:e})}),(0,Z.jsx)(Ke,{label:t.gapAudit,hint:t.gapAuditHint,checked:_.gapAudit,onChange:e=>w({gapAudit:e})})]}),_.qualityGuard?null:(0,Z.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.qualityGuardWarning}),(0,Z.jsx)(Se,{children:(0,Z.jsxs)(`div`,{className:`space-y-5 border-t border-edge pt-5`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:t.advancedTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.advancedHint})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-min-messages`,label:t.minMessagesBeforeCompact,hint:t.minMessagesBeforeCompactHint,value:_.minMessagesBeforeCompact,min:2,onChange:e=>w({minMessagesBeforeCompact:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-max-transcript-mb`,label:t.maxActiveTranscriptMb,hint:t.maxActiveTranscriptMbHint,value:Number((_.maxActiveTranscriptBytes/1e6).toFixed(3)),min:.064,step:.1,onChange:e=>w({maxActiveTranscriptBytes:Math.max(64e3,Math.round(e*1e6))})}),(0,Z.jsx)($,{id:`compaction-summary-max-tokens`,label:t.summaryMaxTokens,hint:t.summaryMaxTokensHint,value:_.summaryMaxTokens,min:256,step:256,onChange:e=>w({summaryMaxTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-chunk-tokens`,label:t.summaryChunkTokens,hint:t.summaryChunkTokensHint,value:_.summaryChunkTokens,min:1e3,step:1e3,onChange:e=>w({summaryChunkTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(V)),value:_.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>w({summaryTimeoutMs:Math.round(e*1e3)})}),(0,Z.jsx)($,{id:`compaction-summary-retries`,label:t.summaryRetries,hint:t.summaryRetriesHint,value:_.summaryRetries,min:0,max:5,onChange:e=>w({summaryRetries:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-min-tool-result-chars`,label:t.minToolResultKeepChars,hint:t.minToolResultKeepCharsHint,value:_.minToolResultKeepChars,min:200,step:100,onChange:e=>w({minToolResultKeepChars:Math.floor(e)})})]}),R?(0,Z.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.summaryBudgetWarning}):null,(0,Z.jsxs)(`div`,{className:`border-t border-edge pt-5`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.postCompactionSections}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.postCompactionSectionsHint}),_.postCompactionSections.length>0?(0,Z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:_.postCompactionSections.map(e=>(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs text-fg`,children:[e,(0,Z.jsx)(`button`,{type:`button`,className:x(`text-fg-muted hover:text-fg`,F.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>w({postCompactionSections:_.postCompactionSections.filter(t=>t!==e)}),children:(0,Z.jsx)(h,{className:`size-3.5`,"aria-hidden":!0})})]},e))}):(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.postCompactionSectionsEmpty}),(0,Z.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,Z.jsx)(`input`,{className:He(),value:l,maxLength:120,disabled:_.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),U())}}),(0,Z.jsxs)(C,{type:`button`,variant:`secondary`,disabled:!l.trim()||_.postCompactionSections.length>=12,onClick:U,children:[(0,Z.jsx)(m,{className:`size-4`,"aria-hidden":!0}),t.addSection]})]})]})]})})]})]})}function Je(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ye(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function Xe(e){let t=Je(e)?e:{},n=Je(t.session)?t.session:{},r=Je(n.storage)?n.storage:{},i=typeof r.pruneAfterDays==`number`&&Number.isFinite(r.pruneAfterDays)?Math.max(0,Math.floor(r.pruneAfterDays)):typeof r.pruneAfterMs==`number`&&Number.isFinite(r.pruneAfterMs)?Math.max(0,Math.round(r.pruneAfterMs/864e5)):null,a=typeof r.maxEntries==`number`&&Number.isFinite(r.maxEntries)?Math.max(1,Math.floor(r.maxEntries)):null;return{dmScope:Ye(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function Ze(e){await _(y(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),w()}function Qe(){return x(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,he,`dark:border-edge`)}var $e=ae();function et({hasToken:e}){let t=g(v(e=>e.language)).sessions.config,{data:n,isLoading:r}=T(e),i=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Xe(n.payload.config),[n]),[a,o]=(0,X.useReducer)($e,{form:null,baseline:null}),s=a.form,c=a.baseline,l=(0,X.useRef)(!1),u=(0,X.useRef)(s);u.current=s;let p=(0,X.useRef)(null);Y({enabled:e,parsed:i,dirty:l.current,trackedParsedRef:p,dispatch:o,onResetDirty:()=>{l.current=!1}});let m=!!(s&&c&&JSON.stringify(s)!==JSON.stringify(c)),h=(0,X.useCallback)(e=>{l.current=!0,o({type:`patch`,patch:e})},[]),_=be({value:s,dirty:m,onSave:(0,X.useCallback)(async e=>{try{await Ze(e),o({type:`saved`,value:e}),l.current=!!(u.current&&JSON.stringify(u.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return!e||!s?r?(0,Z.jsx)(ve,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(E,{className:`h-5 w-40`}),(0,Z.jsx)(E,{className:`h-24 w-full rounded-xl`})]})}):null:(0,Z.jsxs)(ve,{onBlurCapture:_.onBlurCapture,children:[(0,Z.jsx)(_e,{icon:M,title:t.title,subtitle:t.hint,trailing:(0,Z.jsx)(ye,{status:_.status,error:_.error})}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,Z.jsxs)(d,{className:Qe(),value:s.dmScope,onChange:e=>h({dmScope:e.target.value}),children:[(0,Z.jsx)(f,{value:`main`,children:t.dmScopeMain}),(0,Z.jsx)(f,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Z.jsx)(f,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Z.jsx)(f,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,Z.jsx)(`input`,{type:`number`,min:0,className:Qe(),value:s.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();h({pruneAfterDays:t===``?null:Math.max(0,Math.floor(Number(t)||0))})}})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.maxEntries}),(0,Z.jsx)(`input`,{type:`number`,min:1,className:Qe(),value:s.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();h({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})]})]})}function tt(e){if(typeof e==`string`)return e.length>2e3?`${e.slice(0,2e3)}…`:e;try{let t=JSON.stringify(e,null,2);return t.length>2e3?`${t.slice(0,2e3)}…`:t}catch{return String(e)}}function nt(e){let t=(0,Ce.c)(60),{open:n,loading:r,session:i,sessionAgentId:d,sessionAgentAvatar:f,labels:p,onClose:m,onArchive:g,onUnarchive:_,onPin:v,onUnpin:y,onExport:b,onDelete:S}=e,w=i?.status===`archived`,T=i?.status===`pinned`,E;t[0]===m?E=t[1]:(E=e=>!e&&m(),t[0]=m,t[1]=E);let O;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(a,{className:x(`xopc-dialog-overlay fixed inset-0 bg-scrim`,D)}),t[2]=O):O=t[2];let k;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(k=x(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-panel shadow-popover outline-none`,ee,`dark:border-edge`),t[3]=k):k=t[3];let A;t[4]!==i||t[5]!==f||t[6]!==d?(A=i&&d?(0,Z.jsx)(te,{agentId:d,avatar:f,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=i,t[5]=f,t[6]=d,t[7]=A):A=t[7];let j;t[8]!==p.unnamedSession||t[9]!==i?.name?(j=i?.name?.trim()||p.unnamedSession,t[8]=p.unnamedSession,t[9]=i?.name,t[10]=j):j=t[10];let M;t[11]===j?M=t[12]:(M=(0,Z.jsx)(l,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:j}),t[11]=j,t[12]=M);let N;t[13]!==A||t[14]!==M?(N=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[A,M]}),t[13]=A,t[14]=M,t[15]=N):N=t[15];let P;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsx)(h,{className:`size-5`,strokeWidth:1.75}),t[16]=P):P=t[16];let F;t[17]===p.close?F=t[18]:(F=(0,Z.jsx)(o,{asChild:!0,children:(0,Z.jsx)(C,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":p.close,children:P})}),t[17]=p.close,t[18]=F);let I;t[19]!==N||t[20]!==F?(I=(0,Z.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[N,F]}),t[19]=N,t[20]=F,t[21]=I):I=t[21];let L;t[22]!==p.detailLoading||t[23]!==p.detailMessages||t[24]!==r||t[25]!==i?(L=r?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:p.detailLoading}):i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`dl`,{className:`mb-4 grid gap-2 text-xs text-fg-muted`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-disabled`,children:`Key`}),(0,Z.jsx)(`dd`,{className:`mt-0.5 break-all font-mono text-fg`,children:i.key})]}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,Z.jsxs)(`span`,{children:[i.messageCount,` msgs · `,i.estimatedTokens,` tok`]})})]}),(0,Z.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:p.detailMessages}),(0,Z.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(rt)})]}):null,t[22]=p.detailLoading,t[23]=p.detailMessages,t[24]=r,t[25]=i,t[26]=L):L=t[26];let R;t[27]===L?R=t[28]:(R=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:L}),t[27]=L,t[28]=R);let z;t[29]!==p.detailExport||t[30]!==b?(z=(0,Z.jsx)(C,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:b,children:p.detailExport}),t[29]=p.detailExport,t[30]=b,t[31]=z):z=t[31];let B;t[32]!==w||t[33]!==p.archive||t[34]!==p.unarchive||t[35]!==g||t[36]!==_?(B=w?(0,Z.jsx)(C,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:_,children:p.unarchive}):(0,Z.jsx)(C,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:g,children:p.archive}),t[32]=w,t[33]=p.archive,t[34]=p.unarchive,t[35]=g,t[36]=_,t[37]=B):B=t[37];let V;t[38]!==T||t[39]!==p.pin||t[40]!==p.unpin||t[41]!==v||t[42]!==y?(V=T?(0,Z.jsx)(C,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:y,children:p.unpin}):(0,Z.jsx)(C,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:v,children:p.pin}),t[38]=T,t[39]=p.pin,t[40]=p.unpin,t[41]=v,t[42]=y,t[43]=V):V=t[43];let H;t[44]!==p.delete||t[45]!==S?(H=(0,Z.jsx)(C,{type:`button`,variant:`secondary`,className:`text-sm text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`,onClick:S,children:p.delete}),t[44]=p.delete,t[45]=S,t[46]=H):H=t[46];let U;t[47]!==z||t[48]!==B||t[49]!==V||t[50]!==H?(U=(0,Z.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3 dark:border-edge`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[z,B,V,H]})}),t[47]=z,t[48]=B,t[49]=V,t[50]=H,t[51]=U):U=t[51];let W;t[52]!==I||t[53]!==R||t[54]!==U?(W=(0,Z.jsxs)(s,{children:[O,(0,Z.jsxs)(c,{className:k,"aria-describedby":void 0,children:[I,R,U]})]}),t[52]=I,t[53]=R,t[54]=U,t[55]=W):W=t[55];let G;return t[56]!==n||t[57]!==E||t[58]!==W?(G=(0,Z.jsx)(u,{open:n,onOpenChange:E,children:W}),t[56]=n,t[57]=E,t[58]=W,t[59]=G):G=t[59],G}function rt(e){return(0,Z.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,Z.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children:tt(e.content)})]},`${e.timestamp??``}-${e.role}-${tt(e.content).slice(0,24)}`)}var it=20;function at(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var ot=new Set([`all`,`active`,`pinned`,`archived`]),st=new Set([`grid`,`list`]),ct=[`sessions`,`settings`];function lt(e){return e&&ct.includes(e)?e:`sessions`}function ut(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function dt(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function ft(e){let t=(0,Ce.c)(7),{s:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=ct.map(e=>({id:e,label:ut(n,e),icon:e===`sessions`?R:q})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Z.jsx)(xe,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`sessions-tab`,panelIdPrefix:`sessions-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function pt(e){let t=(0,Ce.c)(10),{s:n,id:r,activeTab:i,plain:a,children:o}=e,s=a===void 0?!1:a;if(i!==r)return null;let c=`sessions-panel-${r}`,l=`sessions-tab-${r}`,u=s?`contents`:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,d;t[0]!==o||t[1]!==r||t[2]!==s||t[3]!==n?(d=s?o:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`mb-5`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:ut(n,r)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:dt(n,r)})]}),(0,Z.jsx)(`div`,{className:`space-y-4`,children:o})]}),t[0]=o,t[1]=r,t[2]=s,t[3]=n,t[4]=d):d=t[4];let f;return t[5]!==c||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,Z.jsx)(`section`,{id:c,role:`tabpanel`,"aria-labelledby":l,className:u,children:d}),t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f}function mt(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:ot.has(t)?t:`all`,viewMode:st.has(n)?n:`grid`,channelFilter:(e.get(`channel`)??``).trim(),sessions:[],loading:!1,error:null,hasMore:!1,stats:null,detailOpen:!1,detailLoading:!1,detailSession:null,confirmOpen:!1,confirmKey:null}}function ht(){let e=g(v(e=>e.language)),t=e.sessions,n=b(e=>e.token),r=!!n,{data:o,mutate:d}=S(r?[`gateway-chat-agents`,n]:null,ce,{revalidateOnFocus:!1}),f=o?.defaultId??`main`,p=o?.items??[],[m,h]=i(),_=lt(m.get(`tab`)),y=(0,X.useCallback)(e=>{let t=new URLSearchParams(m);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),h(t,{replace:!0})},[m,h]),[w,T]=(0,X.useReducer)(ge,m,mt),{searchInput:E,debouncedSearch:O,statusFilter:k,viewMode:j,channelFilter:M,sessions:B,loading:te,error:W,hasMore:K,stats:q,detailOpen:ie,detailLoading:ae,detailSession:J,confirmOpen:le,confirmKey:fe}=w;(0,X.useEffect)(()=>{let e=setTimeout(()=>{let e=E.trim();O!==e&&T({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[E,O]);let he=m.toString(),Y=(0,X.useRef)(he);if(Y.current!==he){Y.current=he;let e=m.get(`q`)??``,t=m.get(`status`),n=m.get(`view`),r=(m.get(`channel`)??``).trim(),i=ot.has(t)?t:`all`,a=st.has(n)?n:`grid`,o=e.trim();T({type:`patch`,patch:{...E===e?{}:{searchInput:e},...O===o?{}:{debouncedSearch:o},...k===i?{}:{statusFilter:i},...j===a?{}:{viewMode:a},...M===r?{}:{channelFilter:r}}})}(0,X.useEffect)(()=>{let e=new URLSearchParams(m),t=O.trim();t?e.set(`q`,t):e.delete(`q`),k===`all`?e.delete(`status`):e.set(`status`,k),j===`grid`?e.delete(`view`):e.set(`view`,j),M?e.set(`channel`,M):e.delete(`channel`),e.toString()!==m.toString()&&h(e,{replace:!0})},[O,m,h,k,j,M]),(0,X.useEffect)(()=>{if(!r||_!==`sessions`)return;let e=!1;return(async()=>{T({type:`patch`,patch:{loading:!0,error:null}});try{let t=await U({limit:it,offset:0,...O?{search:O}:{},...k===`all`?{}:{status:k},...M?{channel:M}:{}});if(e)return;T({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||T({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||T({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,_,O,k,M,t.loadError]),(0,X.useEffect)(()=>{!r||_!==`sessions`||H().then(e=>T({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,_]),(0,X.useEffect)(()=>{if(!r||_!==`sessions`)return;let e=()=>void d();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,_,d]),(0,X.useEffect)(()=>{if(!r||_!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||T({type:`patch`,patch:{sessions:B.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:J&&J.key===t.key?{...J,name:t.name}:J}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,_,B,J]);let _e=(0,X.useCallback)(async()=>{if(!(!r||te||!K)){T({type:`patch`,patch:{loading:!0,error:null}});try{let e=await U({limit:it,offset:B.length,...O?{search:O}:{},...k===`all`?{}:{status:k},...M?{channel:M}:{}});T({type:`patch`,patch:{sessions:[...B,...e.items],hasMore:e.hasMore}})}catch(e){T({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{T({type:`patch`,patch:{loading:!1}})}}},[r,te,K,B.length,O,k,M,t.loadError]),ve=(0,X.useCallback)((e,t)=>{T({type:`patch`,patch:{sessions:B.map(n=>n.key===e?{...n,status:t}:n),detailSession:J&&J.key===e?{...J,status:t}:J}})},[B,J]),ye=(0,X.useCallback)(async e=>{T({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{T({type:`patch`,patch:{detailSession:await ue(e)}})}catch{T({type:`patch`,patch:{detailOpen:!1}})}finally{T({type:`patch`,patch:{detailLoading:!1}})}},[]),be=e=>{ye(e)},xe=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e},bubbles:!0}));return}if(t===`delete`){T({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await G(e),ve(e,`archived`);break;case`unarchive`:await I(e),ve(e,`active`);break;case`pin`:await ne(e),ve(e,`pinned`);break;case`unpin`:await V(e),ve(e,`active`);break;case`export`:{let t=await A(e),n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`session-${e.replace(/[^a-z0-9]/gi,`_`)}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r);break}default:break}H().then(e=>T({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Se=async e=>{try{await de(e),T({type:`patch`,patch:{sessions:B.filter(t=>t.key!==e),detailSession:J?.key===e?null:J,...J?.key===e?{detailOpen:!1}:{}}}),H().then(e=>T({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Ce={continueChat:t.continueChat,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,export:t.export,delete:t.delete,unnamedSession:e.chat.newSession},we={close:t.close,detailLoading:t.detailLoading,detailMessages:t.detailMessages,detailExport:t.detailExport,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,delete:t.delete,unnamedSession:e.chat.newSession},Te=[{key:`all`,label:t.filterAll,icon:R},{key:`active`,label:t.filterActive,icon:re},{key:`pinned`,label:t.filterPinned,icon:se},{key:`archived`,label:t.filterArchived,icon:me}],De=(()=>{let e=Object.entries(q?.byChannel??{}).sort((e,t)=>t[1]-e[1]).slice(0,6).map(([e])=>e),t=new Set(e);for(let n of[`telegram`,`weixin`,`feishu`])t.has(n)||(e.push(n),t.add(n));return e.slice(0,8)})();return r?(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,children:[(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,Z.jsx)(`header`,{className:`flex flex-col gap-2`,children:(0,Z.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.title})}),(0,Z.jsx)(ft,{s:t,activeTab:_,onChange:y}),(0,Z.jsx)(pt,{s:t,id:`settings`,activeTab:_,plain:!0,children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(qe,{hasToken:r}),(0,Z.jsx)(et,{hasToken:r})]})}),(0,Z.jsxs)(pt,{s:t,id:`sessions`,activeTab:_,plain:!0,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Te.map(({key:e,label:t,icon:n})=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":k===e,onClick:()=>T({type:`patch`,patch:{statusFilter:e}}),className:x(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,F.transition,F.focusRingPanel,k===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[(0,Z.jsx)(n,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t]},e))}),(0,Z.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-2 rounded-xl bg-surface-base px-3 py-2 transition-colors lg:max-w-md dark:bg-surface-hover/40`,children:[(0,Z.jsx)(oe,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:E,onChange:e=>T({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"data-debounced-query":O||void 0,className:`min-w-0 flex-1 border-0 bg-transparent text-sm text-fg placeholder:text-fg-disabled focus:outline-none focus:ring-0`})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":!M,onClick:()=>T({type:`patch`,patch:{channelFilter:``}}),className:x(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,F.transition,F.focusRingPanel,M?`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`:`bg-accent-soft text-accent-fg`),children:t.filterChannelAll}),De.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":M===e,onClick:()=>T({type:`patch`,patch:{channelFilter:e}}),className:x(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,F.transition,F.focusRingPanel,M===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[e,q?.byChannel?.[e]==null?null:(0,Z.jsx)(`span`,{className:`ml-2 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] text-fg-subtle`,children:q.byChannel[e]})]},e))]}),q?(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[q.totalSessions,t.totalSessions],[q.activeSessions,t.activeSessions],[q.pinnedSessions,t.pinnedSessions],[q.archivedSessions,t.archivedSessions]].map(([e,t])=>(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,Z.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,W?(0,Z.jsx)(`div`,{className:`rounded-lg border border-edge bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-edge dark:bg-red-950/40 dark:text-red-300`,children:W}):null,(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:at(t.sessionCount,{count:B.length})}),(0,Z.jsxs)(`div`,{className:L,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Z.jsx)(C,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":j===`grid`,onClick:()=>T({type:`patch`,patch:{viewMode:`grid`}}),className:x(N,`size-7 p-0`,j===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,j===`grid`&&`text-accent-fg`),children:(0,Z.jsx)(z,{className:`size-3.5`,strokeWidth:1.5})}),(0,Z.jsx)(C,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":j===`list`,onClick:()=>T({type:`patch`,patch:{viewMode:`list`}}),className:x(N,`size-9 p-0`,j===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,j===`list`&&`text-accent-fg`),children:(0,Z.jsx)(P,{className:`size-3.5`,strokeWidth:1.5})})]})]}),te&&B.length===0?(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,Z.jsx)(`div`,{className:`h-40 animate-pulse rounded-xl bg-surface-hover/60 dark:bg-surface-hover/40`},t))}):B.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-2xl bg-surface-base py-16 text-center dark:bg-surface-hover/25`,children:[(0,Z.jsx)(pe,{className:`mb-3 size-12 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,Z.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:t.noSessions}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:t.noSessionsDescription}),(0,Z.jsx)(C,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:``},bubbles:!0}))},children:t.startNewChat})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:x(`grid min-w-0 gap-3`,j===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":O||void 0,children:B.map(e=>{let t=Ae(e,f);return(0,Z.jsx)(Ee,{session:e,variant:j,labels:Ce,sessionAgentId:t,sessionAgentAvatar:je(t,p),onOpen:()=>be(e.key),onAction:t=>void xe(e.key,t)},e.key)})}),K?(0,Z.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Z.jsx)(C,{type:`button`,variant:`secondary`,disabled:te,onClick:()=>void _e(),children:t.loadMore})}):null]})]})]}),(0,Z.jsx)(nt,{open:ie,loading:ae,session:J,sessionAgentId:J?Ae(J,f):void 0,sessionAgentAvatar:J?je(Ae(J,f),p):void 0,labels:we,onClose:()=>{T({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>J&&void xe(J.key,`archive`),onUnarchive:()=>J&&void xe(J.key,`unarchive`),onPin:()=>J&&void xe(J.key,`pin`),onUnpin:()=>J&&void xe(J.key,`unpin`),onExport:()=>J&&void xe(J.key,`export`),onDelete:()=>J&&T({type:`patch`,patch:{confirmKey:J.key,confirmOpen:!0}})}),(0,Z.jsx)(u,{open:le,onOpenChange:e=>T({type:`patch`,patch:{confirmOpen:e}}),children:(0,Z.jsxs)(s,{children:[(0,Z.jsx)(a,{className:x(`xopc-dialog-overlay fixed inset-0 bg-scrim`,D)}),(0,Z.jsxs)(c,{className:x(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`,ee),children:[(0,Z.jsx)(l,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:fe?at(t.deleteSessionMessage,{name:B.find(e=>e.key===fe)?.name?.trim()||e.chat.newSession}):``}),(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Z.jsx)(C,{type:`button`,variant:`secondary`,onClick:()=>T({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Z.jsx)(C,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{fe&&Se(fe),T({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,Z.jsx)(`div`,{className:`w-full px-3 py-16 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:t.needToken})}export{ht as SessionsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{on as e}from"./index-C7RDs6S-.js";function t(t){let{children:n,fallback:r}=t,i=r===void 0?null:r;return e()?n:i}export{t};
|